LibWeb: Avoid including Navigable.h in headers

This greatly reduces how much is recompiled when changing Navigable.h,
from >1000 to 82.
This commit is contained in:
Luke Wilde 2025-10-16 14:07:09 +01:00 committed by Sam Atkins
parent 7bccd65b4a
commit eeb5446c1b
Notes: github-actions[bot] 2025-10-20 09:18:20 +00:00
55 changed files with 170 additions and 64 deletions

View file

@ -15,6 +15,7 @@
#include <LibWeb/HTML/CloseWatcherManager.h>
#include <LibWeb/HTML/EventHandler.h>
#include <LibWeb/HTML/HTMLIFrameElement.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/Window.h>
namespace Web::HTML {

View file

@ -12,6 +12,7 @@
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/CrossOrigin/AbstractOperations.h>
#include <LibWeb/HTML/CrossOrigin/Reporting.h>
#include <LibWeb/HTML/Navigable.h>
namespace Web::HTML {

View file

@ -14,6 +14,7 @@
#include <LibWeb/DOM/ShadowRoot.h>
#include <LibWeb/HTML/Focus.h>
#include <LibWeb/HTML/HTMLInputElement.h>
#include <LibWeb/HTML/Navigation.h>
#include <LibWeb/HTML/TraversableNavigable.h>
#include <LibWeb/UIEvents/FocusEvent.h>

View file

@ -12,6 +12,7 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/Gamepad/EventNames.h>
#include <LibWeb/HTML/HTMLBodyElement.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/Numbers.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/HTML/Window.h>

View file

@ -30,6 +30,7 @@
#include <LibWeb/HTML/HTMLOutputElement.h>
#include <LibWeb/HTML/HTMLSelectElement.h>
#include <LibWeb/HTML/HTMLTextAreaElement.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/RadioNodeList.h>
#include <LibWeb/HTML/SubmitEvent.h>
#include <LibWeb/Infra/CharacterTypes.h>

View file

@ -10,8 +10,9 @@
#include <AK/Time.h>
#include <LibWeb/ARIA/Roles.h>
#include <LibWeb/Bindings/NavigationPrototype.h>
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/UserNavigationInvolvement.h>
namespace Web::HTML {

View file

@ -9,8 +9,8 @@
#include <LibURL/URL.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/EventLoop/Task.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/TokenizedFeatures.h>
#include <LibWeb/HTML/UserNavigationInvolvement.h>
namespace Web::HTML {

View file

@ -23,6 +23,7 @@
#include <LibWeb/HTML/HTMLMediaElement.h>
#include <LibWeb/HTML/HTMLObjectElement.h>
#include <LibWeb/HTML/ImageRequest.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/Numbers.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/HTML/PotentialCORSRequest.h>

View file

@ -21,6 +21,7 @@
#include <LibWeb/HTML/HTMLOptGroupElement.h>
#include <LibWeb/HTML/HTMLOptionElement.h>
#include <LibWeb/HTML/HTMLSelectElement.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/Numbers.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Infra/Strings.h>

View file

@ -14,6 +14,8 @@
#include <LibWeb/Fetch/Fetching/Fetching.h>
#include <LibWeb/Fetch/Infrastructure/FetchAlgorithms.h>
#include <LibWeb/Fetch/Infrastructure/FetchController.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Statuses.h>
#include <LibWeb/HTML/HTMLMediaElement.h>
#include <LibWeb/HTML/HTMLTrackElement.h>
#include <LibWeb/HTML/PotentialCORSRequest.h>

View file

@ -0,0 +1,16 @@
/*
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
namespace Web::HTML {
enum class InitialInsertion : u8 {
Yes,
No,
};
}

View file

@ -17,6 +17,7 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/CrossOrigin/AbstractOperations.h>
#include <LibWeb/HTML/Location.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/Navigation.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/WebIDL/DOMException.h>

View file

@ -10,10 +10,10 @@
#include <LibJS/Forward.h>
#include <LibJS/Runtime/Completion.h>
#include <LibURL/URL.h>
#include <LibWeb/Bindings/NavigationPrototype.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/CrossOrigin/CrossOriginPropertyDescriptorMap.h>
#include <LibWeb/HTML/Navigable.h>
namespace Web::HTML {

View file

@ -2503,20 +2503,6 @@ void Navigable::inform_the_navigation_api_about_aborting_navigation()
}));
}
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#event-uni
UserNavigationInvolvement user_navigation_involvement(DOM::Event const& event)
{
// For convenience at certain call sites, the user navigation involvement for an Event event is defined as follows:
// 1. Assert: this algorithm is being called as part of an activation behavior definition.
// 2. Assert: event's type is "click".
VERIFY(event.type() == "click"_fly_string);
// 3. If event's isTrusted is initialized to true, then return "activation".
// 4. Return "none".
return event.is_trusted() ? UserNavigationInvolvement::Activation : UserNavigationInvolvement::None;
}
bool Navigable::is_focused() const
{
return &m_page->focused_navigable() == this;

View file

@ -17,6 +17,7 @@
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/ActivateTab.h>
#include <LibWeb/HTML/HistoryHandlingBehavior.h>
#include <LibWeb/HTML/InitialInsertion.h>
#include <LibWeb/HTML/NavigationParams.h>
#include <LibWeb/HTML/POSTResource.h>
#include <LibWeb/HTML/RenderingThread.h>
@ -24,6 +25,7 @@
#include <LibWeb/HTML/SourceSnapshotParams.h>
#include <LibWeb/HTML/StructuredSerializeTypes.h>
#include <LibWeb/HTML/TokenizedFeatures.h>
#include <LibWeb/HTML/WindowType.h>
#include <LibWeb/InvalidateDisplayList.h>
#include <LibWeb/Page/EventHandler.h>
#include <LibWeb/Painting/BackingStoreManager.h>
@ -32,24 +34,11 @@
namespace Web::HTML {
enum class InitialInsertion : u8 {
Yes,
No,
};
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#target-snapshot-params
struct TargetSnapshotParams {
SandboxingFlagSet sandboxing_flags {};
};
struct PaintConfig {
bool paint_overlay { false };
bool should_show_line_box_borders { false };
Optional<Gfx::IntRect> canvas_fill_rect {};
bool operator==(PaintConfig const& other) const = default;
};
// https://html.spec.whatwg.org/multipage/document-sequences.html#navigable
class WEB_API Navigable : public JS::Cell {
GC_CELL(Navigable, JS::Cell);
@ -111,12 +100,6 @@ public:
[[nodiscard]] bool is_focused() const;
enum class WindowType {
ExistingOrNone,
NewAndUnrestricted,
NewWithNoOpener,
};
struct ChosenNavigable {
GC::Ptr<Navigable> navigable;
WindowType window_type;
@ -306,6 +289,5 @@ WEB_API HashTable<GC::RawRef<Navigable>>& all_navigables();
bool navigation_must_be_a_replace(URL::URL const& url, DOM::Document const& document);
void finalize_a_cross_document_navigation(GC::Ref<Navigable>, HistoryHandlingBehavior, UserNavigationInvolvement, GC::Ref<SessionHistoryEntry>);
void perform_url_and_history_update_steps(DOM::Document& document, URL::URL new_url, Optional<SerializationRecord> = {}, HistoryHandlingBehavior history_handling = HistoryHandlingBehavior::Replace);
UserNavigationInvolvement user_navigation_involvement(DOM::Event const&);
}

View file

@ -351,4 +351,18 @@ bool NavigableContainer::currently_delays_the_load_event() const
return false;
}
bool NavigableContainer::content_navigable_has_session_history_entry_and_ready_for_navigation() const
{
if (!content_navigable())
return false;
return m_content_navigable->has_session_history_entry_and_ready_for_navigation();
}
void NavigableContainer::set_content_navigable_has_session_history_entry_and_ready_for_navigation()
{
if (!content_navigable())
return;
content_navigable()->set_has_session_history_entry_and_ready_for_navigation();
}
}

View file

@ -8,7 +8,7 @@
#include <LibWeb/Export.h>
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/InitialInsertion.h>
namespace Web::HTML {
@ -39,12 +39,7 @@ public:
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#potentially-delays-the-load-event
bool currently_delays_the_load_event() const;
bool content_navigable_has_session_history_entry_and_ready_for_navigation() const
{
if (!content_navigable())
return false;
return m_content_navigable->has_session_history_entry_and_ready_for_navigation();
}
bool content_navigable_has_session_history_entry_and_ready_for_navigation() const;
protected:
NavigableContainer(DOM::Document&, DOM::QualifiedName);
@ -64,12 +59,7 @@ protected:
void set_potentially_delays_the_load_event(bool value) { m_potentially_delays_the_load_event = value; }
void set_content_navigable_has_session_history_entry_and_ready_for_navigation()
{
if (!content_navigable())
return;
content_navigable()->set_has_session_history_entry_and_ready_for_navigation();
}
void set_content_navigable_has_session_history_entry_and_ready_for_navigation();
private:
virtual bool is_navigable_container() const override { return true; }

View file

@ -10,9 +10,9 @@
#include <LibWeb/Bindings/NavigationPrototype.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/HTML/HistoryHandlingBehavior.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/NavigationType.h>
#include <LibWeb/HTML/StructuredSerializeTypes.h>
#include <LibWeb/HTML/UserNavigationInvolvement.h>
namespace Web::HTML {

View file

@ -17,16 +17,10 @@
#include <LibWeb/HTML/CrossOrigin/OpenerPolicyEnforcementResult.h>
#include <LibWeb/HTML/PolicyContainers.h>
#include <LibWeb/HTML/SandboxingFlagSet.h>
#include <LibWeb/HTML/UserNavigationInvolvement.h>
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#user-navigation-involvement
enum class UserNavigationInvolvement {
BrowserUI,
Activation,
None,
};
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigation-params
struct NavigationParams : GC::Cell {
GC_CELL(NavigationParams, GC::Cell);

View file

@ -0,0 +1,19 @@
/*
* Copyright (c) 2025, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
namespace Web::HTML {
struct PaintConfig {
bool paint_overlay { false };
bool should_show_line_box_borders { false };
Optional<Gfx::IntRect> canvas_fill_rect {};
bool operator==(PaintConfig const& other) const = default;
};
}

View file

@ -7,6 +7,7 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/PrincipalHostDefined.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h>
#include <LibWeb/HTML/Window.h>

View file

@ -10,6 +10,7 @@
#include <LibGC/RootVector.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/StoragePrototype.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/Storage.h>
#include <LibWeb/HTML/StorageEvent.h>
#include <LibWeb/HTML/Window.h>

View file

@ -0,0 +1,26 @@
/*
* Copyright (c) 2024, Andrew Kaster <andrew@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/DOM/Event.h>
#include <LibWeb/HTML/UserNavigationInvolvement.h>
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#event-uni
UserNavigationInvolvement user_navigation_involvement(DOM::Event const& event)
{
// For convenience at certain call sites, the user navigation involvement for an Event event is defined as follows:
// 1. Assert: this algorithm is being called as part of an activation behavior definition.
// 2. Assert: event's type is "click".
VERIFY(event.type() == "click"_fly_string);
// 3. If event's isTrusted is initialized to true, then return "activation".
// 4. Return "none".
return event.is_trusted() ? UserNavigationInvolvement::Activation : UserNavigationInvolvement::None;
}
}

View file

@ -0,0 +1,22 @@
/*
* Copyright (c) 2023, Andrew Kaster <andrew@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Forward.h>
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#user-navigation-involvement
enum class UserNavigationInvolvement {
BrowserUI,
Activation,
None,
};
UserNavigationInvolvement user_navigation_involvement(DOM::Event const&);
}

View file

@ -156,7 +156,7 @@ WebIDL::ExceptionOr<GC::Ptr<WindowProxy>> Window::window_open_steps(StringView u
return nullptr;
// 17. If noopener is true or windowType is "new with no opener", then return null.
if (no_opener == TokenizedFeature::NoOpener::Yes || window_type == Navigable::WindowType::NewWithNoOpener)
if (no_opener == TokenizedFeature::NoOpener::Yes || window_type == WindowType::NewWithNoOpener)
return nullptr;
// 18. Return targetNavigable's active WindowProxy.
@ -254,7 +254,7 @@ WebIDL::ExceptionOr<Window::OpenedWindow> Window::window_open_steps_internal(Str
return OpenedWindow {};
// 15. If windowType is either "new and unrestricted" or "new with no opener", then:
if (window_type == Navigable::WindowType::NewAndUnrestricted || window_type == Navigable::WindowType::NewWithNoOpener) {
if (window_type == WindowType::NewAndUnrestricted || window_type == WindowType::NewWithNoOpener) {
// 1. Set targetNavigable's active browsing context's is popup to the result of checking if a popup window is requested, given tokenizedFeatures.
target_navigable->active_browsing_context()->set_is_popup(check_if_a_popup_window_is_requested(tokenized_features));

View file

@ -19,14 +19,13 @@
#include <LibWeb/HTML/CrossOrigin/CrossOriginPropertyDescriptorMap.h>
#include <LibWeb/HTML/GlobalEventHandlers.h>
#include <LibWeb/HTML/MimeType.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/Navigation.h>
#include <LibWeb/HTML/Plugin.h>
#include <LibWeb/HTML/ScrollOptions.h>
#include <LibWeb/HTML/StructuredSerializeOptions.h>
#include <LibWeb/HTML/UniversalGlobalScope.h>
#include <LibWeb/HTML/WindowEventHandlers.h>
#include <LibWeb/HTML/WindowOrWorkerGlobalScope.h>
#include <LibWeb/HTML/WindowType.h>
#include <LibWeb/RequestIdleCallback/IdleRequest.h>
#include <LibWeb/WebIDL/Types.h>
@ -123,7 +122,7 @@ public:
struct OpenedWindow {
GC::Ptr<Navigable> navigable;
TokenizedFeature::NoOpener no_opener { TokenizedFeature::NoOpener::No };
Navigable::WindowType window_type { Navigable::WindowType::ExistingOrNone };
WindowType window_type { WindowType::ExistingOrNone };
};
WebIDL::ExceptionOr<OpenedWindow> window_open_steps_internal(StringView url, StringView target, StringView features);

View file

@ -14,6 +14,7 @@
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/HTML/CrossOrigin/AbstractOperations.h>
#include <LibWeb/HTML/CrossOrigin/Reporting.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/HTML/WindowProxy.h>

View file

@ -0,0 +1,17 @@
/*
* Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
namespace Web::HTML {
enum class WindowType {
ExistingOrNone,
NewAndUnrestricted,
NewWithNoOpener,
};
}