LibWeb+WebContent: Remove unused code in BrowsingContext

This commit is contained in:
Aliaksandr Kalenik 2025-02-17 23:57:52 +01:00 committed by Tim Flynn
commit 184ae687c5
Notes: github-actions[bot] 2025-02-18 06:38:18 +00:00
4 changed files with 8 additions and 85 deletions

View file

@ -9,28 +9,20 @@
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/ElementFactory.h> #include <LibWeb/DOM/ElementFactory.h>
#include <LibWeb/DOM/Event.h> #include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/HTMLCollection.h>
#include <LibWeb/DOM/Range.h> #include <LibWeb/DOM/Range.h>
#include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/HTML/BrowsingContext.h> #include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/BrowsingContextGroup.h> #include <LibWeb/HTML/BrowsingContextGroup.h>
#include <LibWeb/HTML/CrossOrigin/OpenerPolicy.h>
#include <LibWeb/HTML/DocumentState.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLDocument.h> #include <LibWeb/HTML/HTMLDocument.h>
#include <LibWeb/HTML/HTMLInputElement.h> #include <LibWeb/HTML/HTMLInputElement.h>
#include <LibWeb/HTML/NavigableContainer.h>
#include <LibWeb/HTML/SandboxingFlagSet.h> #include <LibWeb/HTML/SandboxingFlagSet.h>
#include <LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h> #include <LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h>
#include <LibWeb/HTML/TraversableNavigable.h> #include <LibWeb/HTML/TraversableNavigable.h>
#include <LibWeb/HTML/Window.h> #include <LibWeb/HTML/Window.h>
#include <LibWeb/HTML/WindowProxy.h> #include <LibWeb/HTML/WindowProxy.h>
#include <LibWeb/HighResolutionTime/TimeOrigin.h> #include <LibWeb/HighResolutionTime/TimeOrigin.h>
#include <LibWeb/Layout/BreakNode.h>
#include <LibWeb/Layout/Viewport.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Namespace.h> #include <LibWeb/Namespace.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
#include <LibWeb/Painting/Paintable.h>
namespace Web::HTML { namespace Web::HTML {
@ -312,7 +304,7 @@ void BrowsingContext::visit_edges(Cell::Visitor& visitor)
} }
// https://html.spec.whatwg.org/multipage/document-sequences.html#bc-traversable // https://html.spec.whatwg.org/multipage/document-sequences.html#bc-traversable
GC::Ref<HTML::TraversableNavigable> BrowsingContext::top_level_traversable() const GC::Ref<TraversableNavigable> BrowsingContext::top_level_traversable() const
{ {
// A browsing context's top-level traversable is its active document's node navigable's top-level traversable. // A browsing context's top-level traversable is its active document's node navigable's top-level traversable.
auto traversable = active_document()->navigable()->top_level_traversable(); auto traversable = active_document()->navigable()->top_level_traversable();
@ -435,15 +427,6 @@ BrowsingContext const* BrowsingContext::the_one_permitted_sandboxed_navigator()
return nullptr; return nullptr;
} }
GC::Ptr<BrowsingContext> BrowsingContext::first_child() const
{
return m_first_child;
}
GC::Ptr<BrowsingContext> BrowsingContext::next_sibling() const
{
return m_next_sibling;
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#ancestor-browsing-context // https://html.spec.whatwg.org/multipage/document-sequences.html#ancestor-browsing-context
bool BrowsingContext::is_ancestor_of(BrowsingContext const& potential_descendant) const bool BrowsingContext::is_ancestor_of(BrowsingContext const& potential_descendant) const
{ {

View file

@ -6,24 +6,13 @@
#pragma once #pragma once
#include <AK/Function.h>
#include <AK/Noncopyable.h> #include <AK/Noncopyable.h>
#include <AK/RefPtr.h>
#include <AK/WeakPtr.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Rect.h>
#include <LibGfx/Size.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/Cell.h> #include <LibJS/Heap/Cell.h>
#include <LibURL/Origin.h> #include <LibURL/Origin.h>
#include <LibWeb/HTML/ActivateTab.h>
#include <LibWeb/HTML/NavigableContainer.h> #include <LibWeb/HTML/NavigableContainer.h>
#include <LibWeb/HTML/SandboxingFlagSet.h> #include <LibWeb/HTML/SandboxingFlagSet.h>
#include <LibWeb/HTML/SessionHistoryEntry.h> #include <LibWeb/HTML/SessionHistoryEntry.h>
#include <LibWeb/HTML/TokenizedFeatures.h> #include <LibWeb/HTML/TokenizedFeatures.h>
#include <LibWeb/HTML/VisibilityState.h>
#include <LibWeb/Platform/Timer.h>
#include <LibWeb/TreeNode.h>
namespace Web::HTML { namespace Web::HTML {
@ -42,58 +31,11 @@ public:
virtual ~BrowsingContext() override; virtual ~BrowsingContext() override;
GC::Ref<HTML::TraversableNavigable> top_level_traversable() const; GC::Ref<TraversableNavigable> top_level_traversable() const;
GC::Ptr<BrowsingContext> first_child() const;
GC::Ptr<BrowsingContext> next_sibling() const;
bool is_ancestor_of(BrowsingContext const&) const; bool is_ancestor_of(BrowsingContext const&) const;
bool is_familiar_with(BrowsingContext const&) const; bool is_familiar_with(BrowsingContext const&) const;
template<typename Callback>
TraversalDecision for_each_in_inclusive_subtree(Callback callback) const
{
if (callback(*this) == TraversalDecision::Break)
return TraversalDecision::Break;
for (auto child = first_child(); child; child = child->next_sibling()) {
if (child->for_each_in_inclusive_subtree(callback) == TraversalDecision::Break)
return TraversalDecision::Break;
}
return TraversalDecision::Continue;
}
template<typename Callback>
TraversalDecision for_each_in_inclusive_subtree(Callback callback)
{
if (callback(*this) == TraversalDecision::Break)
return TraversalDecision::Break;
for (auto child = first_child(); child; child = child->next_sibling()) {
if (child->for_each_in_inclusive_subtree(callback) == TraversalDecision::Break)
return TraversalDecision::Break;
}
return TraversalDecision::Continue;
}
template<typename Callback>
TraversalDecision for_each_in_subtree(Callback callback) const
{
for (auto child = first_child(); child; child = child->next_sibling()) {
if (child->for_each_in_inclusive_subtree(callback) == TraversalDecision::Break)
return TraversalDecision::Break;
}
return TraversalDecision::Continue;
}
template<typename Callback>
TraversalDecision for_each_in_subtree(Callback callback)
{
for (auto child = first_child(); child; child = child->next_sibling()) {
if (child->for_each_in_inclusive_subtree(callback) == TraversalDecision::Break)
return TraversalDecision::Break;
}
return TraversalDecision::Continue;
}
bool is_top_level() const; bool is_top_level() const;
bool is_auxiliary() const { return m_is_auxiliary; } bool is_auxiliary() const { return m_is_auxiliary; }
@ -147,7 +89,7 @@ private:
GC::Ref<Page> m_page; GC::Ref<Page> m_page;
// https://html.spec.whatwg.org/multipage/document-sequences.html#browsing-context // https://html.spec.whatwg.org/multipage/document-sequences.html#browsing-context
GC::Ptr<HTML::WindowProxy> m_window_proxy; GC::Ptr<WindowProxy> m_window_proxy;
// https://html.spec.whatwg.org/multipage/browsers.html#opener-browsing-context // https://html.spec.whatwg.org/multipage/browsers.html#opener-browsing-context
GC::Ptr<BrowsingContext> m_opener_browsing_context; GC::Ptr<BrowsingContext> m_opener_browsing_context;

View file

@ -47,6 +47,7 @@
#include <LibWeb/Loader/ResourceLoader.h> #include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
#include <LibWeb/Platform/EventLoopPlugin.h> #include <LibWeb/Platform/EventLoopPlugin.h>
#include <LibWeb/Platform/Timer.h>
#include <LibWeb/WebIDL/DOMException.h> #include <LibWeb/WebIDL/DOMException.h>
#include <LibWeb/WebIDL/ExceptionOr.h> #include <LibWeb/WebIDL/ExceptionOr.h>
#include <LibWeb/XHR/EventNames.h> #include <LibWeb/XHR/EventNames.h>

View file

@ -439,14 +439,11 @@ void ConnectionFromClient::inspect_dom_node(u64 page_id, Web::UniqueNodeID const
if (!page.has_value()) if (!page.has_value())
return; return;
auto& top_context = page->page().top_level_browsing_context(); for (auto& navigable : Web::HTML::all_navigables()) {
if (navigable->active_document() != nullptr) {
top_context.for_each_in_inclusive_subtree([&](auto& ctx) { navigable->active_document()->set_inspected_node(nullptr, {});
if (ctx.active_document() != nullptr) {
ctx.active_document()->set_inspected_node(nullptr, {});
} }
return Web::TraversalDecision::Continue; }
});
auto* node = Web::DOM::Node::from_unique_id(node_id); auto* node = Web::DOM::Node::from_unique_id(node_id);
// Note: Nodes without layout (aka non-visible nodes, don't have style computed) // Note: Nodes without layout (aka non-visible nodes, don't have style computed)