diff options
author | Linus Groh <mail@linusgroh.de> | 2022-02-14 22:03:16 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-15 01:31:03 +0100 |
commit | 75dd4fbd16cfa7abe161caed8a628c781953cd88 (patch) | |
tree | f6888d947d82ab7c91cd643f4a5c2e045ee1b5cd /Userland/Libraries/LibWeb/HTML | |
parent | 5e8bfb5efc0e4b8cdffd2ecbf0239916a6d3d69d (diff) | |
download | serenity-75dd4fbd16cfa7abe161caed8a628c781953cd88.zip |
LibWeb: Implement BCC's "content document" concept according to spec
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp | 36 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h | 3 |
2 files changed, 20 insertions, 19 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp index 3279798a6c..95b354d98d 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -35,25 +36,28 @@ void BrowsingContextContainer::inserted() } } -Origin BrowsingContextContainer::content_origin() const +// https://html.spec.whatwg.org/multipage/browsers.html#concept-bcc-content-document +const DOM::Document* BrowsingContextContainer::content_document() const { - if (!m_nested_browsing_context || !m_nested_browsing_context->active_document()) - return {}; - return m_nested_browsing_context->active_document()->origin(); -} + // 1. If container's nested browsing context is null, then return null. + if (m_nested_browsing_context == nullptr) + return nullptr; -bool BrowsingContextContainer::may_access_from_origin(const Origin& origin) const -{ - if (auto* page = document().page()) { - if (!page->is_same_origin_policy_enabled()) - return true; - } - return origin.is_same_origin(content_origin()); -} + // 2. Let context be container's nested browsing context. + auto const& context = *m_nested_browsing_context; -const DOM::Document* BrowsingContextContainer::content_document() const -{ - return m_nested_browsing_context ? m_nested_browsing_context->active_document() : nullptr; + // 3. Let document be context's active document. + auto const* document = context.active_document(); + + VERIFY(document); + VERIFY(m_document); + + // 4. If document's origin and container's node document's origin are not same origin-domain, then return null. + if (!document->origin().is_same_origin_domain(m_document->origin())) + return nullptr; + + // 5. Return document. + return document; } } diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h index bde9bc394c..43f17da1a4 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h @@ -20,9 +20,6 @@ public: const DOM::Document* content_document() const; - Origin content_origin() const; - bool may_access_from_origin(const Origin&) const; - virtual void inserted() override; protected: |