mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:07:35 +00:00
LibWeb: Move XMLHttpRequest to separate XHR directory
In keeping with the one-directory-per-web-spec layout, let's move XHR into its own clubhouse.
This commit is contained in:
parent
5d9c36d016
commit
5b91362d4e
8 changed files with 33 additions and 30 deletions
|
@ -30,7 +30,7 @@
|
||||||
#include <LibWeb/Bindings/XMLHttpRequestConstructor.h>
|
#include <LibWeb/Bindings/XMLHttpRequestConstructor.h>
|
||||||
#include <LibWeb/Bindings/XMLHttpRequestPrototype.h>
|
#include <LibWeb/Bindings/XMLHttpRequestPrototype.h>
|
||||||
#include <LibWeb/Bindings/XMLHttpRequestWrapper.h>
|
#include <LibWeb/Bindings/XMLHttpRequestWrapper.h>
|
||||||
#include <LibWeb/DOM/XMLHttpRequest.h>
|
#include <LibWeb/XHR/XMLHttpRequest.h>
|
||||||
|
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
|
||||||
|
@ -47,11 +47,11 @@ void XMLHttpRequestConstructor::initialize(JS::GlobalObject& global_object)
|
||||||
define_property(vm.names.prototype, window.xhr_prototype(), 0);
|
define_property(vm.names.prototype, window.xhr_prototype(), 0);
|
||||||
define_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
define_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
||||||
|
|
||||||
define_property("UNSENT", JS::Value((i32)XMLHttpRequest::ReadyState::Unsent), JS::Attribute::Enumerable);
|
define_property("UNSENT", JS::Value((i32)XHR::XMLHttpRequest::ReadyState::Unsent), JS::Attribute::Enumerable);
|
||||||
define_property("OPENED", JS::Value((i32)XMLHttpRequest::ReadyState::Opened), JS::Attribute::Enumerable);
|
define_property("OPENED", JS::Value((i32)XHR::XMLHttpRequest::ReadyState::Opened), JS::Attribute::Enumerable);
|
||||||
define_property("HEADERS_RECEIVED", JS::Value((i32)XMLHttpRequest::ReadyState::HeadersReceived), JS::Attribute::Enumerable);
|
define_property("HEADERS_RECEIVED", JS::Value((i32)XHR::XMLHttpRequest::ReadyState::HeadersReceived), JS::Attribute::Enumerable);
|
||||||
define_property("LOADING", JS::Value((i32)XMLHttpRequest::ReadyState::Loading), JS::Attribute::Enumerable);
|
define_property("LOADING", JS::Value((i32)XHR::XMLHttpRequest::ReadyState::Loading), JS::Attribute::Enumerable);
|
||||||
define_property("DONE", JS::Value((i32)XMLHttpRequest::ReadyState::Done), JS::Attribute::Enumerable);
|
define_property("DONE", JS::Value((i32)XHR::XMLHttpRequest::ReadyState::Done), JS::Attribute::Enumerable);
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLHttpRequestConstructor::~XMLHttpRequestConstructor()
|
XMLHttpRequestConstructor::~XMLHttpRequestConstructor()
|
||||||
|
@ -67,7 +67,7 @@ JS::Value XMLHttpRequestConstructor::call()
|
||||||
JS::Value XMLHttpRequestConstructor::construct(Function&)
|
JS::Value XMLHttpRequestConstructor::construct(Function&)
|
||||||
{
|
{
|
||||||
auto& window = static_cast<WindowObject&>(global_object());
|
auto& window = static_cast<WindowObject&>(global_object());
|
||||||
return heap().allocate<XMLHttpRequestWrapper>(window, window, XMLHttpRequest::create(window.impl()));
|
return heap().allocate<XMLHttpRequestWrapper>(window, window, XHR::XMLHttpRequest::create(window.impl()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <LibJS/Runtime/GlobalObject.h>
|
#include <LibJS/Runtime/GlobalObject.h>
|
||||||
#include <LibWeb/Bindings/XMLHttpRequestPrototype.h>
|
#include <LibWeb/Bindings/XMLHttpRequestPrototype.h>
|
||||||
#include <LibWeb/Bindings/XMLHttpRequestWrapper.h>
|
#include <LibWeb/Bindings/XMLHttpRequestWrapper.h>
|
||||||
#include <LibWeb/DOM/XMLHttpRequest.h>
|
#include <LibWeb/XHR/XMLHttpRequest.h>
|
||||||
|
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
|
||||||
|
@ -47,18 +47,18 @@ void XMLHttpRequestPrototype::initialize(JS::GlobalObject& global_object)
|
||||||
define_native_property("readyState", ready_state_getter, nullptr, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
define_native_property("readyState", ready_state_getter, nullptr, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||||
define_native_property("responseText", response_text_getter, nullptr, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
define_native_property("responseText", response_text_getter, nullptr, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||||
|
|
||||||
define_property("UNSENT", JS::Value((i32)XMLHttpRequest::ReadyState::Unsent), JS::Attribute::Enumerable);
|
define_property("UNSENT", JS::Value((i32)XHR::XMLHttpRequest::ReadyState::Unsent), JS::Attribute::Enumerable);
|
||||||
define_property("OPENED", JS::Value((i32)XMLHttpRequest::ReadyState::Opened), JS::Attribute::Enumerable);
|
define_property("OPENED", JS::Value((i32)XHR::XMLHttpRequest::ReadyState::Opened), JS::Attribute::Enumerable);
|
||||||
define_property("HEADERS_RECEIVED", JS::Value((i32)XMLHttpRequest::ReadyState::HeadersReceived), JS::Attribute::Enumerable);
|
define_property("HEADERS_RECEIVED", JS::Value((i32)XHR::XMLHttpRequest::ReadyState::HeadersReceived), JS::Attribute::Enumerable);
|
||||||
define_property("LOADING", JS::Value((i32)XMLHttpRequest::ReadyState::Loading), JS::Attribute::Enumerable);
|
define_property("LOADING", JS::Value((i32)XHR::XMLHttpRequest::ReadyState::Loading), JS::Attribute::Enumerable);
|
||||||
define_property("DONE", JS::Value((i32)XMLHttpRequest::ReadyState::Done), JS::Attribute::Enumerable);
|
define_property("DONE", JS::Value((i32)XHR::XMLHttpRequest::ReadyState::Done), JS::Attribute::Enumerable);
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLHttpRequestPrototype::~XMLHttpRequestPrototype()
|
XMLHttpRequestPrototype::~XMLHttpRequestPrototype()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static XMLHttpRequest* impl_from(JS::VM& vm, JS::GlobalObject& global_object)
|
static XHR::XMLHttpRequest* impl_from(JS::VM& vm, JS::GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
auto* this_object = vm.this_value(global_object).to_object(global_object);
|
auto* this_object = vm.this_value(global_object).to_object(global_object);
|
||||||
if (!this_object)
|
if (!this_object)
|
||||||
|
|
|
@ -30,16 +30,16 @@
|
||||||
#include <LibWeb/Bindings/WindowObject.h>
|
#include <LibWeb/Bindings/WindowObject.h>
|
||||||
#include <LibWeb/Bindings/XMLHttpRequestPrototype.h>
|
#include <LibWeb/Bindings/XMLHttpRequestPrototype.h>
|
||||||
#include <LibWeb/Bindings/XMLHttpRequestWrapper.h>
|
#include <LibWeb/Bindings/XMLHttpRequestWrapper.h>
|
||||||
#include <LibWeb/DOM/XMLHttpRequest.h>
|
#include <LibWeb/XHR/XMLHttpRequest.h>
|
||||||
|
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
|
||||||
XMLHttpRequestWrapper* wrap(JS::GlobalObject& global_object, XMLHttpRequest& impl)
|
XMLHttpRequestWrapper* wrap(JS::GlobalObject& global_object, XHR::XMLHttpRequest& impl)
|
||||||
{
|
{
|
||||||
return static_cast<XMLHttpRequestWrapper*>(wrap_impl(global_object, impl));
|
return static_cast<XMLHttpRequestWrapper*>(wrap_impl(global_object, impl));
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLHttpRequestWrapper::XMLHttpRequestWrapper(JS::GlobalObject& global_object, XMLHttpRequest& impl)
|
XMLHttpRequestWrapper::XMLHttpRequestWrapper(JS::GlobalObject& global_object, XHR::XMLHttpRequest& impl)
|
||||||
: EventTargetWrapper(global_object, impl)
|
: EventTargetWrapper(global_object, impl)
|
||||||
{
|
{
|
||||||
set_prototype(static_cast<WindowObject&>(global_object).xhr_prototype());
|
set_prototype(static_cast<WindowObject&>(global_object).xhr_prototype());
|
||||||
|
@ -49,14 +49,14 @@ XMLHttpRequestWrapper::~XMLHttpRequestWrapper()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLHttpRequest& XMLHttpRequestWrapper::impl()
|
XHR::XMLHttpRequest& XMLHttpRequestWrapper::impl()
|
||||||
{
|
{
|
||||||
return static_cast<XMLHttpRequest&>(EventTargetWrapper::impl());
|
return static_cast<XHR::XMLHttpRequest&>(EventTargetWrapper::impl());
|
||||||
}
|
}
|
||||||
|
|
||||||
const XMLHttpRequest& XMLHttpRequestWrapper::impl() const
|
const XHR::XMLHttpRequest& XMLHttpRequestWrapper::impl() const
|
||||||
{
|
{
|
||||||
return static_cast<const XMLHttpRequest&>(EventTargetWrapper::impl());
|
return static_cast<const XHR::XMLHttpRequest&>(EventTargetWrapper::impl());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,16 +32,16 @@ namespace Web::Bindings {
|
||||||
|
|
||||||
class XMLHttpRequestWrapper final : public EventTargetWrapper {
|
class XMLHttpRequestWrapper final : public EventTargetWrapper {
|
||||||
public:
|
public:
|
||||||
XMLHttpRequestWrapper(JS::GlobalObject&, XMLHttpRequest&);
|
XMLHttpRequestWrapper(JS::GlobalObject&, XHR::XMLHttpRequest&);
|
||||||
virtual ~XMLHttpRequestWrapper() override;
|
virtual ~XMLHttpRequestWrapper() override;
|
||||||
|
|
||||||
XMLHttpRequest& impl();
|
XHR::XMLHttpRequest& impl();
|
||||||
const XMLHttpRequest& impl() const;
|
const XHR::XMLHttpRequest& impl() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual const char* class_name() const override { return "XMLHttpRequestWrapper"; }
|
virtual const char* class_name() const override { return "XMLHttpRequestWrapper"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
XMLHttpRequestWrapper* wrap(JS::GlobalObject&, XMLHttpRequest&);
|
XMLHttpRequestWrapper* wrap(JS::GlobalObject&, XHR::XMLHttpRequest&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,6 @@ set(SOURCES
|
||||||
DOM/Text.idl
|
DOM/Text.idl
|
||||||
DOM/Timer.cpp
|
DOM/Timer.cpp
|
||||||
DOM/Window.cpp
|
DOM/Window.cpp
|
||||||
DOM/XMLHttpRequest.cpp
|
|
||||||
DOMTreeModel.cpp
|
DOMTreeModel.cpp
|
||||||
Dump.cpp
|
Dump.cpp
|
||||||
FontCache.cpp
|
FontCache.cpp
|
||||||
|
@ -204,6 +203,7 @@ set(SOURCES
|
||||||
UIEvents/EventNames.cpp
|
UIEvents/EventNames.cpp
|
||||||
UIEvents/MouseEvent.cpp
|
UIEvents/MouseEvent.cpp
|
||||||
URLEncoder.cpp
|
URLEncoder.cpp
|
||||||
|
XHR/XMLHttpRequest.cpp
|
||||||
WebContentClient.cpp
|
WebContentClient.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -187,6 +187,9 @@ class PaintContext;
|
||||||
class Resource;
|
class Resource;
|
||||||
class ResourceLoader;
|
class ResourceLoader;
|
||||||
class StackingContext;
|
class StackingContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Web::XHR {
|
||||||
class XMLHttpRequest;
|
class XMLHttpRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,12 +33,12 @@
|
||||||
#include <LibWeb/DOM/EventDispatcher.h>
|
#include <LibWeb/DOM/EventDispatcher.h>
|
||||||
#include <LibWeb/DOM/EventListener.h>
|
#include <LibWeb/DOM/EventListener.h>
|
||||||
#include <LibWeb/DOM/Window.h>
|
#include <LibWeb/DOM/Window.h>
|
||||||
#include <LibWeb/DOM/XMLHttpRequest.h>
|
|
||||||
#include <LibWeb/HTML/EventNames.h>
|
#include <LibWeb/HTML/EventNames.h>
|
||||||
#include <LibWeb/Loader/ResourceLoader.h>
|
#include <LibWeb/Loader/ResourceLoader.h>
|
||||||
#include <LibWeb/Origin.h>
|
#include <LibWeb/Origin.h>
|
||||||
|
#include <LibWeb/XHR/XMLHttpRequest.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web::XHR {
|
||||||
|
|
||||||
XMLHttpRequest::XMLHttpRequest(DOM::Window& window)
|
XMLHttpRequest::XMLHttpRequest(DOM::Window& window)
|
||||||
: EventTarget(static_cast<Bindings::ScriptExecutionContext&>(window.document()))
|
: EventTarget(static_cast<Bindings::ScriptExecutionContext&>(window.document()))
|
|
@ -32,7 +32,7 @@
|
||||||
#include <LibWeb/Bindings/Wrappable.h>
|
#include <LibWeb/Bindings/Wrappable.h>
|
||||||
#include <LibWeb/DOM/EventTarget.h>
|
#include <LibWeb/DOM/EventTarget.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web::XHR {
|
||||||
|
|
||||||
class XMLHttpRequest final
|
class XMLHttpRequest final
|
||||||
: public RefCounted<XMLHttpRequest>
|
: public RefCounted<XMLHttpRequest>
|
Loading…
Add table
Add a link
Reference in a new issue