1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:18:12 +00:00

LibWeb: Rename BrowsingContextContainer => NavigableContainer

The "browsing context container" concept in the HTML spec has been
replaced with "navigable container". Renaming this is the first step of
many towards implementing the new world.

Co-authored-by: Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
This commit is contained in:
Andreas Kling 2022-12-12 12:20:02 +01:00
parent 0f9f6aef81
commit d8ccc2d54e
17 changed files with 61 additions and 60 deletions

View file

@ -202,7 +202,6 @@ set(SOURCES
Geometry/DOMRectReadOnly.cpp
HTML/AttributeNames.cpp
HTML/BrowsingContext.cpp
HTML/BrowsingContextContainer.cpp
HTML/BrowsingContextGroup.cpp
HTML/Canvas/CanvasDrawImage.cpp
HTML/Canvas/CanvasPath.cpp
@ -314,6 +313,7 @@ set(SOURCES
HTML/MessagePort.cpp
HTML/MimeType.cpp
HTML/MimeTypeArray.cpp
HTML/NavigableContainer.cpp
HTML/Navigator.cpp
HTML/NavigatorID.cpp
HTML/PageTransitionEvent.cpp

View file

@ -1706,8 +1706,8 @@ bool Document::is_fully_active() const
return false;
if (browsing_context->is_top_level())
return true;
if (auto* browsing_context_container_document = browsing_context->container_document()) {
if (browsing_context_container_document->is_fully_active())
if (auto* navigable_container_document = browsing_context->container_document()) {
if (navigable_container_document->is_fully_active())
return true;
}
return false;

View file

@ -29,10 +29,10 @@
#include <LibWeb/DOM/Range.h>
#include <LibWeb/DOM/ShadowRoot.h>
#include <LibWeb/DOM/StaticNodeList.h>
#include <LibWeb/HTML/BrowsingContextContainer.h>
#include <LibWeb/HTML/CustomElements/CustomElementReactionNames.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLStyleElement.h>
#include <LibWeb/HTML/NavigableContainer.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/Infra/CharacterTypes.h>
@ -1070,8 +1070,8 @@ void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) c
MUST(attributes.finish());
}
if (element->is_browsing_context_container()) {
auto const* container = static_cast<HTML::BrowsingContextContainer const*>(element);
if (element->is_navigable_container()) {
auto const* container = static_cast<HTML::NavigableContainer const*>(element);
if (auto const* content_document = container->content_document()) {
auto children = MUST(object.add_array("children"sv));
JsonObjectSerializer<StringBuilder> content_document_object = MUST(children.add_object());

View file

@ -90,7 +90,7 @@ public:
virtual bool is_html_input_element() const { return false; }
virtual bool is_html_progress_element() const { return false; }
virtual bool is_html_template_element() const { return false; }
virtual bool is_browsing_context_container() const { return false; }
virtual bool is_navigable_container() const { return false; }
WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> pre_insert(JS::NonnullGCPtr<Node>, JS::GCPtr<Node>);
WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> pre_remove(JS::NonnullGCPtr<Node>);

View file

@ -274,7 +274,6 @@ class DOMRectReadOnly;
namespace Web::HTML {
class BrowsingContext;
class BrowsingContextContainer;
class BrowsingContextGroup;
class CanvasRenderingContext2D;
class ClassicScript;
@ -370,7 +369,9 @@ class MessageEvent;
class MessagePort;
class MimeType;
class MimeTypeArray;
class NavigableContainer;
class Navigator;
struct NavigationParams;
class Origin;
class PageTransitionEvent;
class Path2D;

View file

@ -12,12 +12,12 @@
#include <LibWeb/DOM/Range.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/BrowsingContextContainer.h>
#include <LibWeb/HTML/BrowsingContextGroup.h>
#include <LibWeb/HTML/CrossOrigin/CrossOriginOpenerPolicy.h>
#include <LibWeb/HTML/EventLoop/EventLoop.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLInputElement.h>
#include <LibWeb/HTML/NavigableContainer.h>
#include <LibWeb/HTML/RemoteBrowsingContext.h>
#include <LibWeb/HTML/SandboxingFlagSet.h>
#include <LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h>
@ -87,7 +87,7 @@ JS::NonnullGCPtr<BrowsingContext> BrowsingContext::create_a_new_top_level_browsi
JS::NonnullGCPtr<BrowsingContext> BrowsingContext::create_a_new_browsing_context(Page& page, JS::GCPtr<DOM::Document> creator, JS::GCPtr<DOM::Element> embedder, BrowsingContextGroup&)
{
// 1. Let browsingContext be a new browsing context.
BrowsingContextContainer* container = (embedder && is<BrowsingContextContainer>(*embedder)) ? static_cast<BrowsingContextContainer*>(embedder.ptr()) : nullptr;
NavigableContainer* container = (embedder && is<NavigableContainer>(*embedder)) ? static_cast<NavigableContainer*>(embedder.ptr()) : nullptr;
auto browsing_context = Bindings::main_thread_vm().heap().allocate_without_realm<BrowsingContext>(page, container);
// 2. Let unsafeContextCreationTime be the unsafe shared current time.
@ -226,7 +226,7 @@ JS::NonnullGCPtr<BrowsingContext> BrowsingContext::create_a_new_browsing_context
return *browsing_context;
}
BrowsingContext::BrowsingContext(Page& page, HTML::BrowsingContextContainer* container)
BrowsingContext::BrowsingContext(Page& page, HTML::NavigableContainer* container)
: m_page(page)
, m_loader(*this)
, m_event_handler({}, *this)
@ -604,9 +604,9 @@ JS::GCPtr<DOM::Node> BrowsingContext::currently_focused_area()
// 3. While candidate's focused area is a browsing context container with a non-null nested browsing context:
// set candidate to the active document of that browsing context container's nested browsing context.
while (candidate->focused_element()
&& is<HTML::BrowsingContextContainer>(candidate->focused_element())
&& static_cast<HTML::BrowsingContextContainer&>(*candidate->focused_element()).nested_browsing_context()) {
candidate = static_cast<HTML::BrowsingContextContainer&>(*candidate->focused_element()).nested_browsing_context()->active_document();
&& is<HTML::NavigableContainer>(candidate->focused_element())
&& static_cast<HTML::NavigableContainer&>(*candidate->focused_element()).nested_browsing_context()) {
candidate = static_cast<HTML::NavigableContainer&>(*candidate->focused_element()).nested_browsing_context()->active_document();
}
// 4. If candidate's focused area is non-null, set candidate to candidate's focused area.

View file

@ -18,8 +18,8 @@
#include <LibWeb/DOM/Position.h>
#include <LibWeb/HTML/AbstractBrowsingContext.h>
#include <LibWeb/HTML/ActivateTab.h>
#include <LibWeb/HTML/BrowsingContextContainer.h>
#include <LibWeb/HTML/HistoryHandlingBehavior.h>
#include <LibWeb/HTML/NavigableContainer.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/SessionHistoryEntry.h>
#include <LibWeb/HTML/TokenizedFeatures.h>
@ -179,8 +179,8 @@ public:
bool is_child_of(BrowsingContext const&) const;
HTML::BrowsingContextContainer* container() { return m_container; }
HTML::BrowsingContextContainer const* container() const { return m_container; }
HTML::NavigableContainer* container() { return m_container; }
HTML::NavigableContainer const* container() const { return m_container; }
CSSPixelPoint to_top_level_position(CSSPixelPoint);
CSSPixelRect to_top_level_rect(CSSPixelRect const&);
@ -266,7 +266,7 @@ public:
virtual void set_window_handle(String handle) override { m_window_handle = move(handle); }
private:
explicit BrowsingContext(Page&, HTML::BrowsingContextContainer*);
explicit BrowsingContext(Page&, HTML::NavigableContainer*);
virtual void visit_edges(Cell::Visitor&) override;
@ -296,7 +296,7 @@ private:
// https://html.spec.whatwg.org/multipage/browsers.html#creator-origin
Optional<HTML::Origin> m_creator_origin;
JS::GCPtr<HTML::BrowsingContextContainer> m_container;
JS::GCPtr<HTML::NavigableContainer> m_container;
CSSPixelSize m_size;
CSSPixelPoint m_viewport_scroll_offset;

View file

@ -174,11 +174,11 @@ void run_focusing_steps(DOM::Node* new_focus_target, DOM::Node* fallback_target,
new_focus_target = fallback_target;
}
// 3. If new focus target is a browsing context container with non-null nested browsing context,
// 3. If new focus target is a navigable container with non-null nested browsing context,
// then set new focus target to the nested browsing context's active document.
if (is<HTML::BrowsingContextContainer>(*new_focus_target)) {
auto& browsing_context_container = static_cast<HTML::BrowsingContextContainer&>(*new_focus_target);
if (auto* nested_browsing_context = browsing_context_container.nested_browsing_context())
if (is<HTML::NavigableContainer>(*new_focus_target)) {
auto& navigable_container = static_cast<HTML::NavigableContainer&>(*new_focus_target);
if (auto* nested_browsing_context = navigable_container.nested_browsing_context())
new_focus_target = nested_browsing_context->active_document();
}

View file

@ -12,7 +12,6 @@
#include <LibWeb/DOM/IDLEventListener.h>
#include <LibWeb/DOM/ShadowRoot.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/BrowsingContextContainer.h>
#include <LibWeb/HTML/DOMStringMap.h>
#include <LibWeb/HTML/EventHandler.h>
#include <LibWeb/HTML/Focus.h>
@ -20,6 +19,7 @@
#include <LibWeb/HTML/HTMLAreaElement.h>
#include <LibWeb/HTML/HTMLBodyElement.h>
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/HTML/NavigableContainer.h>
#include <LibWeb/HTML/VisibilityState.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Layout/Box.h>

View file

@ -15,7 +15,7 @@
namespace Web::HTML {
HTMLIFrameElement::HTMLIFrameElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: BrowsingContextContainer(document, move(qualified_name))
: NavigableContainer(document, move(qualified_name))
{
}

View file

@ -6,12 +6,12 @@
#pragma once
#include <LibWeb/HTML/BrowsingContextContainer.h>
#include <LibWeb/HTML/NavigableContainer.h>
namespace Web::HTML {
class HTMLIFrameElement final : public BrowsingContextContainer {
WEB_PLATFORM_OBJECT(HTMLIFrameElement, BrowsingContextContainer);
class HTMLIFrameElement final : public NavigableContainer {
WEB_PLATFORM_OBJECT(HTMLIFrameElement, NavigableContainer);
public:
virtual ~HTMLIFrameElement() override;

View file

@ -17,7 +17,7 @@
namespace Web::HTML {
HTMLObjectElement::HTMLObjectElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: BrowsingContextContainer(document, move(qualified_name))
: NavigableContainer(document, move(qualified_name))
{
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-object-element
// Whenever one of the following conditions occur:
@ -40,7 +40,7 @@ JS::ThrowCompletionOr<void> HTMLObjectElement::initialize(JS::Realm& realm)
void HTMLObjectElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value)
{
BrowsingContextContainer::parse_attribute(name, value);
NavigableContainer::parse_attribute(name, value);
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-object-element
// Whenever one of the following conditions occur:
@ -70,7 +70,7 @@ JS::GCPtr<Layout::Node> HTMLObjectElement::create_layout_node(NonnullRefPtr<CSS:
{
switch (m_representation) {
case Representation::Children:
return BrowsingContextContainer::create_layout_node(move(style));
return NavigableContainer::create_layout_node(move(style));
case Representation::NestedBrowsingContext:
// FIXME: Actually paint the nested browsing context's document, similar to how iframes are painted with FrameBox and NestedBrowsingContextPaintable.
return nullptr;

View file

@ -8,19 +8,19 @@
#include <LibCore/Forward.h>
#include <LibGfx/Forward.h>
#include <LibWeb/HTML/BrowsingContextContainer.h>
#include <LibWeb/HTML/FormAssociatedElement.h>
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/HTML/NavigableContainer.h>
#include <LibWeb/Loader/ImageLoader.h>
namespace Web::HTML {
class HTMLObjectElement final
: public BrowsingContextContainer
: public NavigableContainer
, public FormAssociatedElement
, public ResourceClient {
WEB_PLATFORM_OBJECT(HTMLObjectElement, BrowsingContextContainer)
FORM_ASSOCIATED_ELEMENT(BrowsingContextContainer, HTMLObjectElement)
WEB_PLATFORM_OBJECT(HTMLObjectElement, NavigableContainer)
FORM_ASSOCIATED_ELEMENT(NavigableContainer, HTMLObjectElement)
enum class Representation {
Unknown,

View file

@ -9,36 +9,36 @@
#include <LibWeb/DOM/Event.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/BrowsingContextContainer.h>
#include <LibWeb/HTML/BrowsingContextGroup.h>
#include <LibWeb/HTML/HTMLIFrameElement.h>
#include <LibWeb/HTML/NavigableContainer.h>
#include <LibWeb/HTML/NavigationParams.h>
#include <LibWeb/HTML/Origin.h>
#include <LibWeb/Page/Page.h>
namespace Web::HTML {
HashTable<BrowsingContextContainer*>& BrowsingContextContainer::all_instances()
HashTable<NavigableContainer*>& NavigableContainer::all_instances()
{
static HashTable<BrowsingContextContainer*> set;
static HashTable<NavigableContainer*> set;
return set;
}
BrowsingContextContainer::BrowsingContextContainer(DOM::Document& document, DOM::QualifiedName qualified_name)
NavigableContainer::NavigableContainer(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
}
BrowsingContextContainer::~BrowsingContextContainer() = default;
NavigableContainer::~NavigableContainer() = default;
void BrowsingContextContainer::visit_edges(Cell::Visitor& visitor)
void NavigableContainer::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_nested_browsing_context);
}
// https://html.spec.whatwg.org/multipage/browsers.html#creating-a-new-nested-browsing-context
void BrowsingContextContainer::create_new_nested_browsing_context()
void NavigableContainer::create_new_nested_browsing_context()
{
// 1. Let group be element's node document's browsing context's top-level browsing context's group.
VERIFY(document().browsing_context());
@ -62,7 +62,7 @@ void BrowsingContextContainer::create_new_nested_browsing_context()
}
// https://html.spec.whatwg.org/multipage/browsers.html#concept-bcc-content-document
const DOM::Document* BrowsingContextContainer::content_document() const
const DOM::Document* NavigableContainer::content_document() const
{
// 1. If container's nested browsing context is null, then return null.
if (m_nested_browsing_context == nullptr)
@ -89,7 +89,7 @@ const DOM::Document* BrowsingContextContainer::content_document() const
return document;
}
DOM::Document const* BrowsingContextContainer::content_document_without_origin_check() const
DOM::Document const* NavigableContainer::content_document_without_origin_check() const
{
if (!m_nested_browsing_context)
return nullptr;
@ -97,7 +97,7 @@ DOM::Document const* BrowsingContextContainer::content_document_without_origin_c
}
// https://html.spec.whatwg.org/multipage/embedded-content-other.html#dom-media-getsvgdocument
const DOM::Document* BrowsingContextContainer::get_svg_document() const
const DOM::Document* NavigableContainer::get_svg_document() const
{
// 1. Let document be this element's content document.
auto const* document = content_document();
@ -109,7 +109,7 @@ const DOM::Document* BrowsingContextContainer::get_svg_document() const
return nullptr;
}
HTML::WindowProxy* BrowsingContextContainer::content_window()
HTML::WindowProxy* NavigableContainer::content_window()
{
if (!m_nested_browsing_context)
return nullptr;
@ -128,7 +128,7 @@ static bool url_matches_about_blank(AK::URL const& url)
}
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#shared-attribute-processing-steps-for-iframe-and-frame-elements
void BrowsingContextContainer::shared_attribute_processing_steps_for_iframe_and_frame(bool initial_insertion)
void NavigableContainer::shared_attribute_processing_steps_for_iframe_and_frame(bool initial_insertion)
{
// 1. Let url be the URL record about:blank.
auto url = AK::URL("about:blank");
@ -196,7 +196,7 @@ void BrowsingContextContainer::shared_attribute_processing_steps_for_iframe_and_
}
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#navigate-an-iframe-or-frame
void BrowsingContextContainer::navigate_an_iframe_or_frame(JS::NonnullGCPtr<Fetch::Infrastructure::Request> resource)
void NavigableContainer::navigate_an_iframe_or_frame(JS::NonnullGCPtr<Fetch::Infrastructure::Request> resource)
{
// 1. Let historyHandling be "default".
auto history_handling = HistoryHandlingBehavior::Default;

View file

@ -10,13 +10,13 @@
namespace Web::HTML {
class BrowsingContextContainer : public HTMLElement {
WEB_PLATFORM_OBJECT(BrowsingContextContainer, HTMLElement);
class NavigableContainer : public HTMLElement {
WEB_PLATFORM_OBJECT(NavigableContainer, HTMLElement);
public:
virtual ~BrowsingContextContainer() override;
virtual ~NavigableContainer() override;
static HashTable<BrowsingContextContainer*>& all_instances();
static HashTable<NavigableContainer*>& all_instances();
BrowsingContext* nested_browsing_context() { return m_nested_browsing_context; }
BrowsingContext const* nested_browsing_context() const { return m_nested_browsing_context; }
@ -29,7 +29,7 @@ public:
DOM::Document const* get_svg_document() const;
protected:
BrowsingContextContainer(DOM::Document&, DOM::QualifiedName);
NavigableContainer(DOM::Document&, DOM::QualifiedName);
virtual void visit_edges(Cell::Visitor&) override;
@ -44,12 +44,12 @@ protected:
JS::GCPtr<BrowsingContext> m_nested_browsing_context;
private:
virtual bool is_browsing_context_container() const override { return true; }
virtual bool is_navigable_container() const override { return true; }
};
}
namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::BrowsingContextContainer>() const { return is_browsing_context_container(); }
inline bool Node::fast_is<HTML::NavigableContainer>() const { return is_navigable_container(); }
}

View file

@ -687,10 +687,10 @@ bool EventHandler::fire_keyboard_event(FlyString const& event_name, HTML::Browsi
return false;
if (JS::GCPtr<DOM::Element> focused_element = document->focused_element()) {
if (is<HTML::BrowsingContextContainer>(*focused_element)) {
auto& browsing_context_container = verify_cast<HTML::BrowsingContextContainer>(*focused_element);
if (browsing_context_container.nested_browsing_context())
return fire_keyboard_event(event_name, *browsing_context_container.nested_browsing_context(), key, modifiers, code_point);
if (is<HTML::NavigableContainer>(*focused_element)) {
auto& navigable_container = verify_cast<HTML::NavigableContainer>(*focused_element);
if (navigable_container.nested_browsing_context())
return fire_keyboard_event(event_name, *navigable_container.nested_browsing_context(), key, modifiers, code_point);
}
auto event = UIEvents::KeyboardEvent::create_from_platform_event(document->realm(), event_name, key, modifiers, code_point).release_value_but_fixme_should_propagate_errors();

View file

@ -5,7 +5,7 @@
*/
#include <AK/Debug.h>
#include <LibWeb/HTML/BrowsingContextContainer.h>
#include <LibWeb/HTML/NavigableContainer.h>
#include <LibWeb/Layout/FrameBox.h>
#include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/BorderRadiusCornerClipper.h>