summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-08-05 10:55:47 +0200
committerAndreas Kling <kling@serenityos.org>2022-08-05 12:46:42 +0200
commit2a7924f96cb20c13897dc3faa8c1b18a79ae3f52 (patch)
treee4942cfe3611888bdf951f52c78599f332fdea62 /Userland/Libraries/LibWeb/DOM
parent73f77969a61f263c8042226cd0d24b1efdb6ed84 (diff)
downloadserenity-2a7924f96cb20c13897dc3faa8c1b18a79ae3f52.zip
LibWeb: Bring browsing context creation closer to spec
This patch implements the "create a new browsing context" function from the HTML spec and replaces our existing logic with it. The big difference is that browsing contexts now initially navigate to "about:blank" instead of starting out in a strange "empty" state. This makes it possible for websites to create a new iframe and start scripting inside it right away, without having to load an URL into it.
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM')
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp6
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.h9
2 files changed, 14 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index ad4922f5cf..3c25b51f47 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -659,7 +659,6 @@ void Document::set_title(String const& title)
void Document::attach_to_browsing_context(Badge<HTML::BrowsingContext>, HTML::BrowsingContext& browsing_context)
{
m_browsing_context = browsing_context;
- update_layout();
}
void Document::detach_from_browsing_context(Badge<HTML::BrowsingContext>, HTML::BrowsingContext& browsing_context)
@@ -1833,4 +1832,9 @@ void Document::check_favicon_after_loading_link_resource()
dbgln_if(SPAM_DEBUG, "No favicon found to be used");
}
+void Document::set_window(Badge<HTML::BrowsingContext>, HTML::Window& window)
+{
+ m_window = window;
+}
+
}
diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h
index a34fcc0e9f..36b971930f 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.h
+++ b/Userland/Libraries/LibWeb/DOM/Document.h
@@ -25,6 +25,7 @@
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOM/NonElementParentNode.h>
#include <LibWeb/DOM/ParentNode.h>
+#include <LibWeb/HTML/CrossOrigin/CrossOriginOpenerPolicy.h>
#include <LibWeb/HTML/DocumentReadyState.h>
#include <LibWeb/HTML/HTMLScriptElement.h>
#include <LibWeb/HTML/History.h>
@@ -82,6 +83,9 @@ public:
HTML::Origin origin() const;
void set_origin(HTML::Origin const& origin);
+ HTML::CrossOriginOpenerPolicy const& cross_origin_opener_policy() const { return m_cross_origin_opener_policy; }
+ void set_cross_origin_opener_policy(HTML::CrossOriginOpenerPolicy policy) { m_cross_origin_opener_policy = move(policy); }
+
AK::URL parse_url(String const&) const;
CSS::StyleComputer& style_computer() { return *m_style_computer; }
@@ -263,6 +267,8 @@ public:
HTML::Window& window() { return *m_window; }
HTML::Window const& window() const { return *m_window; }
+ void set_window(Badge<HTML::BrowsingContext>, HTML::Window&);
+
ExceptionOr<void> write(Vector<String> const& strings);
ExceptionOr<void> writeln(Vector<String> const& strings);
@@ -484,6 +490,9 @@ private:
// https://html.spec.whatwg.org/multipage/dom.html#is-initial-about:blank
bool m_is_initial_about_blank { false };
+ // https://html.spec.whatwg.org/multipage/dom.html#concept-document-coop
+ HTML::CrossOriginOpenerPolicy m_cross_origin_opener_policy;
+
// https://html.spec.whatwg.org/multipage/dom.html#the-document's-referrer
String m_referrer { "" };