mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibWeb: Move Origin into the HTML namespace
Origin is defined in the HTML Standard, and therefore belongs into the HTML directory and namespace in LibWeb. https://html.spec.whatwg.org/multipage/origin.html#origin
This commit is contained in:
parent
1748362e05
commit
22a627fc1a
Notes:
sideshowbarker
2024-07-17 08:59:11 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/22a627fc1a Pull-request: https://github.com/SerenityOS/serenity/pull/14568 Reviewed-by: https://github.com/trflynn89 ✅
14 changed files with 23 additions and 21 deletions
|
@ -3118,9 +3118,9 @@ void generate_prototype_implementation(IDL::Interface const& interface)
|
|||
#include <LibWeb/DOM/IDLEventListener.h>
|
||||
#include <LibWeb/DOM/NodeFilter.h>
|
||||
#include <LibWeb/DOM/Range.h>
|
||||
#include <LibWeb/HTML/Origin.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Origin.h>
|
||||
|
||||
#if __has_include(<LibWeb/Bindings/@prototype_base_class@.h>)
|
||||
# include <LibWeb/Bindings/@prototype_base_class@.h>
|
||||
|
|
|
@ -41,10 +41,10 @@
|
|||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/EventHandler.h>
|
||||
#include <LibWeb/HTML/Origin.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/Storage.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Origin.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/WebAssembly/WebAssemblyObject.h>
|
||||
|
||||
|
@ -157,7 +157,7 @@ void WindowObject::visit_edges(Visitor& visitor)
|
|||
visitor.visit(it.value);
|
||||
}
|
||||
|
||||
Origin WindowObject::origin() const
|
||||
HTML::Origin WindowObject::origin() const
|
||||
{
|
||||
return impl().associated_document().origin();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <LibWeb/Bindings/CrossOriginAbstractOperations.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/GlobalEventHandlers.h>
|
||||
#include <LibWeb/HTML/Origin.h>
|
||||
#include <LibWeb/HTML/WindowEventHandlers.h>
|
||||
|
||||
namespace Web {
|
||||
|
@ -38,7 +39,7 @@ public:
|
|||
HTML::Window& impl() { return *m_impl; }
|
||||
const HTML::Window& impl() const { return *m_impl; }
|
||||
|
||||
Origin origin() const;
|
||||
HTML::Origin origin() const;
|
||||
|
||||
LocationObject* location_object() { return m_location_object; }
|
||||
LocationObject const* location_object() const { return m_location_object; }
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
#include <LibWeb/DOM/DocumentType.h>
|
||||
#include <LibWeb/DOM/ElementFactory.h>
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
#include <LibWeb/HTML/Origin.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
#include <LibWeb/Origin.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include <LibWeb/HTML/HTMLScriptElement.h>
|
||||
#include <LibWeb/HTML/HTMLTitleElement.h>
|
||||
#include <LibWeb/HTML/MessageEvent.h>
|
||||
#include <LibWeb/HTML/Origin.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||
#include <LibWeb/HTML/Scripting/ExceptionReporter.h>
|
||||
#include <LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h>
|
||||
|
@ -64,7 +65,6 @@
|
|||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/TreeBuilder.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
#include <LibWeb/Origin.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/SVG/TagNames.h>
|
||||
#include <LibWeb/UIEvents/EventNames.h>
|
||||
|
@ -305,14 +305,14 @@ ExceptionOr<void> Document::close()
|
|||
return {};
|
||||
}
|
||||
|
||||
Origin Document::origin() const
|
||||
HTML::Origin Document::origin() const
|
||||
{
|
||||
if (!m_url.is_valid())
|
||||
return {};
|
||||
return { m_url.protocol(), m_url.host(), m_url.port_or_default() };
|
||||
}
|
||||
|
||||
void Document::set_origin(Origin const& origin)
|
||||
void Document::set_origin(HTML::Origin const& origin)
|
||||
{
|
||||
m_url.set_protocol(origin.protocol());
|
||||
m_url.set_host(origin.host());
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <LibWeb/HTML/DocumentReadyState.h>
|
||||
#include <LibWeb/HTML/HTMLScriptElement.h>
|
||||
#include <LibWeb/HTML/History.h>
|
||||
#include <LibWeb/HTML/Origin.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
@ -82,8 +83,8 @@ public:
|
|||
String url_string() const { return m_url.to_string(); }
|
||||
String document_uri() const { return m_url.to_string(); }
|
||||
|
||||
Origin origin() const;
|
||||
void set_origin(Origin const& origin);
|
||||
HTML::Origin origin() const;
|
||||
void set_origin(HTML::Origin const& origin);
|
||||
|
||||
AK::URL parse_url(String const&) const;
|
||||
|
||||
|
|
|
@ -29,11 +29,11 @@
|
|||
#include <LibWeb/DOM/StaticNodeList.h>
|
||||
#include <LibWeb/HTML/BrowsingContextContainer.h>
|
||||
#include <LibWeb/HTML/HTMLAnchorElement.h>
|
||||
#include <LibWeb/HTML/Origin.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Origin.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
|
|
@ -268,6 +268,7 @@ class ImageData;
|
|||
class MessageChannel;
|
||||
class MessageEvent;
|
||||
class MessagePort;
|
||||
class Origin;
|
||||
class PageTransitionEvent;
|
||||
class PromiseRejectionEvent;
|
||||
class WorkerDebugConsoleClient;
|
||||
|
@ -379,7 +380,6 @@ class EditEventHandler;
|
|||
class EventHandler;
|
||||
class FrameLoader;
|
||||
class LoadRequest;
|
||||
class Origin;
|
||||
class Page;
|
||||
class PageClient;
|
||||
class PaintContext;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/BrowsingContextContainer.h>
|
||||
#include <LibWeb/Origin.h>
|
||||
#include <LibWeb/HTML/Origin.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/HTMLIFrameElement.h>
|
||||
#include <LibWeb/HTML/Origin.h>
|
||||
#include <LibWeb/Layout/FrameBox.h>
|
||||
#include <LibWeb/Origin.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <AK/String.h>
|
||||
|
||||
namespace Web {
|
||||
namespace Web::HTML {
|
||||
|
||||
class Origin {
|
||||
public:
|
||||
|
@ -105,8 +105,8 @@ private:
|
|||
|
||||
namespace AK {
|
||||
template<>
|
||||
struct Traits<Web::Origin> : public GenericTraits<Web::Origin> {
|
||||
static unsigned hash(Web::Origin const& origin)
|
||||
struct Traits<Web::HTML::Origin> : public GenericTraits<Web::HTML::Origin> {
|
||||
static unsigned hash(Web::HTML::Origin const& origin)
|
||||
{
|
||||
return pair_int_hash(origin.protocol().hash(), pair_int_hash(int_hash(origin.port()), origin.host().hash()));
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
||||
#include <LibWeb/Origin.h>
|
||||
#include <LibWeb/HTML/Origin.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
#include <LibWeb/HTML/EventHandler.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/HTML/MessageEvent.h>
|
||||
#include <LibWeb/HTML/Origin.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Origin.h>
|
||||
#include <LibWeb/WebSockets/WebSocket.h>
|
||||
|
||||
namespace Web::WebSockets {
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
#include <LibWeb/Fetch/AbstractOperations.h>
|
||||
#include <LibWeb/HTML/EventHandler.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/HTML/Origin.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
#include <LibWeb/Origin.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/XHR/EventNames.h>
|
||||
#include <LibWeb/XHR/ProgressEvent.h>
|
||||
|
@ -581,7 +581,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::send(Optional<XMLHttpRequestBodyInit> bod
|
|||
dbgln("XHR send from {} to {}", m_window->associated_document().url(), request_url);
|
||||
|
||||
// TODO: Add support for preflight requests to support CORS requests
|
||||
Origin request_url_origin = Origin(request_url.protocol(), request_url.host(), request_url.port_or_default());
|
||||
auto request_url_origin = HTML::Origin(request_url.protocol(), request_url.host(), request_url.port_or_default());
|
||||
|
||||
bool should_enforce_same_origin_policy = true;
|
||||
if (auto* page = m_window->page())
|
||||
|
|
Loading…
Add table
Reference in a new issue