mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-07 11:42:51 +00:00
LibWeb: Add XHREventTarget and have XHR inherit from it
This commit is contained in:
parent
4f2e154dbe
commit
0a1226344a
Notes:
sideshowbarker
2024-07-18 22:54:47 +09:00
Author: https://github.com/Lubrsi
Commit: 0a1226344a
Pull-request: https://github.com/SerenityOS/serenity/pull/5072
7 changed files with 66 additions and 4 deletions
|
@ -373,6 +373,7 @@ libweb_js_wrapper(UIEvents/MouseEvent)
|
||||||
libweb_js_wrapper(UIEvents/UIEvent)
|
libweb_js_wrapper(UIEvents/UIEvent)
|
||||||
libweb_js_wrapper(XHR/ProgressEvent)
|
libweb_js_wrapper(XHR/ProgressEvent)
|
||||||
libweb_js_wrapper(XHR/XMLHttpRequest)
|
libweb_js_wrapper(XHR/XMLHttpRequest)
|
||||||
|
libweb_js_wrapper(XHR/XMLHttpRequestEventTarget)
|
||||||
|
|
||||||
get_property(WRAPPER_SOURCES GLOBAL PROPERTY wrapper_sources)
|
get_property(WRAPPER_SOURCES GLOBAL PROPERTY wrapper_sources)
|
||||||
set(SOURCES ${SOURCES} ${WRAPPER_SOURCES})
|
set(SOURCES ${SOURCES} ${WRAPPER_SOURCES})
|
||||||
|
|
|
@ -192,6 +192,7 @@ class StackingContext;
|
||||||
namespace Web::XHR {
|
namespace Web::XHR {
|
||||||
class ProgressEvent;
|
class ProgressEvent;
|
||||||
class XMLHttpRequest;
|
class XMLHttpRequest;
|
||||||
|
class XMLHttpRequestEventTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
@ -300,6 +301,7 @@ class Wrapper;
|
||||||
class XMLHttpRequestConstructor;
|
class XMLHttpRequestConstructor;
|
||||||
class XMLHttpRequestPrototype;
|
class XMLHttpRequestPrototype;
|
||||||
class XMLHttpRequestWrapper;
|
class XMLHttpRequestWrapper;
|
||||||
|
class XMLHttpRequestEventTargetWrapper;
|
||||||
class RangeConstructor;
|
class RangeConstructor;
|
||||||
class RangePrototype;
|
class RangePrototype;
|
||||||
class RangeWrapper;
|
class RangeWrapper;
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
namespace Web::XHR {
|
namespace Web::XHR {
|
||||||
|
|
||||||
XMLHttpRequest::XMLHttpRequest(DOM::Window& window)
|
XMLHttpRequest::XMLHttpRequest(DOM::Window& window)
|
||||||
: EventTarget(static_cast<Bindings::ScriptExecutionContext&>(window.document()))
|
: XMLHttpRequestEventTarget(static_cast<Bindings::ScriptExecutionContext&>(window.document()))
|
||||||
, m_window(window)
|
, m_window(window)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,14 +32,14 @@
|
||||||
#include <AK/Weakable.h>
|
#include <AK/Weakable.h>
|
||||||
#include <LibWeb/Bindings/Wrappable.h>
|
#include <LibWeb/Bindings/Wrappable.h>
|
||||||
#include <LibWeb/DOM/EventTarget.h>
|
#include <LibWeb/DOM/EventTarget.h>
|
||||||
|
#include <LibWeb/XHR/XMLHttpRequestEventTarget.h>
|
||||||
|
|
||||||
namespace Web::XHR {
|
namespace Web::XHR {
|
||||||
|
|
||||||
class XMLHttpRequest final
|
class XMLHttpRequest final
|
||||||
: public RefCounted<XMLHttpRequest>
|
: public RefCounted<XMLHttpRequest>
|
||||||
, public Weakable<XMLHttpRequest>
|
, public Weakable<XMLHttpRequest>
|
||||||
, public DOM::EventTarget
|
, public XMLHttpRequestEventTarget {
|
||||||
, public Bindings::Wrappable {
|
|
||||||
public:
|
public:
|
||||||
enum class ReadyState : u16 {
|
enum class ReadyState : u16 {
|
||||||
Unsent = 0,
|
Unsent = 0,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
interface XMLHttpRequest : EventTarget {
|
interface XMLHttpRequest : XMLHttpRequestEventTarget {
|
||||||
|
|
||||||
const unsigned short UNSENT = 0;
|
const unsigned short UNSENT = 0;
|
||||||
const unsigned short OPENED = 1;
|
const unsigned short OPENED = 1;
|
||||||
|
|
56
Userland/Libraries/LibWeb/XHR/XMLHttpRequestEventTarget.h
Normal file
56
Userland/Libraries/LibWeb/XHR/XMLHttpRequestEventTarget.h
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021, the SerenityOS developers.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/EventTargetWrapperFactory.h>
|
||||||
|
#include <LibWeb/DOM/EventDispatcher.h>
|
||||||
|
#include <LibWeb/DOM/EventTarget.h>
|
||||||
|
|
||||||
|
namespace Web::XHR {
|
||||||
|
|
||||||
|
class XMLHttpRequestEventTarget
|
||||||
|
: public DOM::EventTarget
|
||||||
|
, public Bindings::Wrappable {
|
||||||
|
public:
|
||||||
|
using WrapperType = Bindings::XMLHttpRequestEventTargetWrapper;
|
||||||
|
|
||||||
|
virtual ~XMLHttpRequestEventTarget() override {};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
explicit XMLHttpRequestEventTarget(Bindings::ScriptExecutionContext& script_execution_context)
|
||||||
|
: DOM::EventTarget(script_execution_context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual JS::Object* create_wrapper(JS::GlobalObject& global_object) override
|
||||||
|
{
|
||||||
|
return wrap(global_object, *this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
interface XMLHttpRequestEventTarget : EventTarget {
|
||||||
|
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue