From 59cfc4a8db351f78b7bf2f447be03b637269f6f2 Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 31 May 2021 13:59:28 +0100 Subject: LibWeb: Rename "FrameHostElement" to "BrowsingContextContainer" With the renaming of "Frame" to "BrowsingContext", this changes "FrameHostElement" to "BrowsingContextContainer" to further match the spec. https://html.spec.whatwg.org/#browsing-context-container --- Userland/Libraries/LibWeb/CMakeLists.txt | 2 +- .../LibWeb/HTML/BrowsingContextContainer.cpp | 58 ++++++++++++++++++++++ .../LibWeb/HTML/BrowsingContextContainer.h | 34 +++++++++++++ .../Libraries/LibWeb/HTML/FrameHostElement.cpp | 58 ---------------------- Userland/Libraries/LibWeb/HTML/FrameHostElement.h | 34 ------------- .../Libraries/LibWeb/HTML/HTMLIFrameElement.cpp | 4 +- Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h | 4 +- 7 files changed, 97 insertions(+), 97 deletions(-) create mode 100644 Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp create mode 100644 Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h delete mode 100644 Userland/Libraries/LibWeb/HTML/FrameHostElement.cpp delete mode 100644 Userland/Libraries/LibWeb/HTML/FrameHostElement.h diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 4649f46f0c..e6a714f915 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -67,10 +67,10 @@ set(SOURCES Dump.cpp FontCache.cpp HTML/AttributeNames.cpp + HTML/BrowsingContextContainer.cpp HTML/CanvasRenderingContext2D.cpp HTML/EventNames.cpp HTML/FormAssociatedElement.cpp - HTML/FrameHostElement.cpp HTML/GlobalEventHandlers.cpp HTML/HTMLAnchorElement.cpp HTML/HTMLAreaElement.cpp diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp new file mode 100644 index 0000000000..c4e4d0afd1 --- /dev/null +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020-2021, Andreas Kling + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include +#include +#include +#include + +namespace Web::HTML { + +BrowsingContextContainer::BrowsingContextContainer(DOM::Document& document, QualifiedName qualified_name) + : HTMLElement(document, move(qualified_name)) +{ +} + +BrowsingContextContainer::~BrowsingContextContainer() +{ +} + +void BrowsingContextContainer::inserted() +{ + HTMLElement::inserted(); + if (!is_connected()) + return; + if (auto* frame = document().browsing_context()) { + m_nested_browsing_context = BrowsingContext::create_nested(*this, frame->top_level_browsing_context()); + m_nested_browsing_context->set_frame_nesting_levels(frame->frame_nesting_levels()); + m_nested_browsing_context->register_frame_nesting(document().url()); + } +} + +Origin BrowsingContextContainer::content_origin() const +{ + if (!m_nested_browsing_context || !m_nested_browsing_context->document()) + return {}; + return m_nested_browsing_context->document()->origin(); +} + +bool BrowsingContextContainer::may_access_from_origin(const Origin& origin) const +{ + return origin.is_same(content_origin()); +} + +const DOM::Document* BrowsingContextContainer::content_document() const +{ + return m_nested_browsing_context ? m_nested_browsing_context->document() : nullptr; +} + +void BrowsingContextContainer::nested_browsing_context_did_load(Badge) +{ + dispatch_event(DOM::Event::create(EventNames::load)); +} + +} diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h new file mode 100644 index 0000000000..6dc69e497a --- /dev/null +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020-2021, Andreas Kling + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace Web::HTML { + +class BrowsingContextContainer : public HTMLElement { +public: + BrowsingContextContainer(DOM::Document&, QualifiedName); + virtual ~BrowsingContextContainer() override; + + BrowsingContext* nested_browsing_context() { return m_nested_browsing_context; } + const BrowsingContext* nested_browsing_context() const { return m_nested_browsing_context; } + + const DOM::Document* content_document() const; + + Origin content_origin() const; + bool may_access_from_origin(const Origin&) const; + + void nested_browsing_context_did_load(Badge); + + virtual void inserted() override; + +protected: + RefPtr m_nested_browsing_context; +}; + +} diff --git a/Userland/Libraries/LibWeb/HTML/FrameHostElement.cpp b/Userland/Libraries/LibWeb/HTML/FrameHostElement.cpp deleted file mode 100644 index 66a4467205..0000000000 --- a/Userland/Libraries/LibWeb/HTML/FrameHostElement.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2020-2021, Andreas Kling - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include -#include -#include -#include -#include - -namespace Web::HTML { - -FrameHostElement::FrameHostElement(DOM::Document& document, QualifiedName qualified_name) - : HTMLElement(document, move(qualified_name)) -{ -} - -FrameHostElement::~FrameHostElement() -{ -} - -void FrameHostElement::inserted() -{ - HTMLElement::inserted(); - if (!is_connected()) - return; - if (auto* frame = document().browsing_context()) { - m_nested_browsing_context = BrowsingContext::create_nested(*this, frame->top_level_browsing_context()); - m_nested_browsing_context->set_frame_nesting_levels(frame->frame_nesting_levels()); - m_nested_browsing_context->register_frame_nesting(document().url()); - } -} - -Origin FrameHostElement::content_origin() const -{ - if (!m_nested_browsing_context || !m_nested_browsing_context->document()) - return {}; - return m_nested_browsing_context->document()->origin(); -} - -bool FrameHostElement::may_access_from_origin(const Origin& origin) const -{ - return origin.is_same(content_origin()); -} - -const DOM::Document* FrameHostElement::content_document() const -{ - return m_nested_browsing_context ? m_nested_browsing_context->document() : nullptr; -} - -void FrameHostElement::nested_browsing_context_did_load(Badge) -{ - dispatch_event(DOM::Event::create(EventNames::load)); -} - -} diff --git a/Userland/Libraries/LibWeb/HTML/FrameHostElement.h b/Userland/Libraries/LibWeb/HTML/FrameHostElement.h deleted file mode 100644 index 6bb7afaefe..0000000000 --- a/Userland/Libraries/LibWeb/HTML/FrameHostElement.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2020-2021, Andreas Kling - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#include - -namespace Web::HTML { - -class FrameHostElement : public HTMLElement { -public: - FrameHostElement(DOM::Document&, QualifiedName); - virtual ~FrameHostElement() override; - - BrowsingContext* nested_browsing_context() { return m_nested_browsing_context; } - const BrowsingContext* nested_browsing_context() const { return m_nested_browsing_context; } - - const DOM::Document* content_document() const; - - Origin content_origin() const; - bool may_access_from_origin(const Origin&) const; - - void nested_browsing_context_did_load(Badge); - - virtual void inserted() override; - -protected: - RefPtr m_nested_browsing_context; -}; - -} diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index ba01d28f43..f58b01ea9c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -13,7 +13,7 @@ namespace Web::HTML { HTMLIFrameElement::HTMLIFrameElement(DOM::Document& document, QualifiedName qualified_name) - : FrameHostElement(document, move(qualified_name)) + : BrowsingContextContainer(document, move(qualified_name)) { } @@ -36,7 +36,7 @@ void HTMLIFrameElement::parse_attribute(const FlyString& name, const String& val void HTMLIFrameElement::inserted() { - FrameHostElement::inserted(); + BrowsingContextContainer::inserted(); if (is_connected()) load_src(attribute(HTML::AttributeNames::src)); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h index 2427b8b788..e8f3d1561a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h @@ -6,11 +6,11 @@ #pragma once -#include +#include namespace Web::HTML { -class HTMLIFrameElement final : public FrameHostElement { +class HTMLIFrameElement final : public BrowsingContextContainer { public: using WrapperType = Bindings::HTMLIFrameElementWrapper; -- cgit v1.2.3