diff options
Diffstat (limited to 'Libraries/LibWeb/DOM/Document.cpp')
-rw-r--r-- | Libraries/LibWeb/DOM/Document.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index 43c881ce8f..6162deaac2 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -52,14 +52,16 @@ #include <LibWeb/HtmlView.h> #include <LibWeb/Layout/LayoutDocument.h> #include <LibWeb/Layout/LayoutTreeBuilder.h> +#include <LibWeb/Origin.h> #include <LibWeb/Parser/CSSParser.h> #include <stdio.h> namespace Web { -Document::Document() +Document::Document(const URL& url) : ParentNode(*this, NodeType::DOCUMENT_NODE) , m_style_resolver(make<StyleResolver>(*this)) + , m_url(url) , m_window(Window::create_with_document(*this)) { m_style_update_timer = Core::Timer::create_single_shot(0, [this] { @@ -71,6 +73,13 @@ Document::~Document() { } +Origin Document::origin() const +{ + if (!m_url.is_valid()) + return {}; + return { m_url.protocol(), m_url.host(), m_url.port() }; +} + void Document::schedule_style_update() { if (m_style_update_timer->is_active()) |