From eeb5446c1b5bc6f4344e5279fcf4b9783e5e0ff4 Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Thu, 16 Oct 2025 14:07:09 +0100 Subject: [PATCH] LibWeb: Avoid including Navigable.h in headers This greatly reduces how much is recompiled when changing Navigable.h, from >1000 to 82. --- Libraries/LibWeb/CMakeLists.txt | 1 + Libraries/LibWeb/CSS/CSSImportRule.cpp | 1 + Libraries/LibWeb/CSS/CSSStyleProperties.cpp | 1 + Libraries/LibWeb/CSS/Length.cpp | 1 + .../LibWeb/CSS/StyleValues/StyleValue.cpp | 1 + Libraries/LibWeb/CSS/VisualViewport.cpp | 1 + Libraries/LibWeb/DOM/Document.h | 1 + Libraries/LibWeb/DOM/DocumentLoading.h | 2 ++ Libraries/LibWeb/Fetch/Body.cpp | 1 + Libraries/LibWeb/Fetch/Fetching/Fetching.cpp | 1 + Libraries/LibWeb/Forward.h | 2 ++ Libraries/LibWeb/HTML/CloseWatcher.cpp | 1 + .../LibWeb/HTML/CrossOrigin/Reporting.cpp | 1 + Libraries/LibWeb/HTML/Focus.cpp | 1 + Libraries/LibWeb/HTML/HTMLBodyElement.cpp | 1 + Libraries/LibWeb/HTML/HTMLFormElement.cpp | 1 + Libraries/LibWeb/HTML/HTMLFormElement.h | 3 ++- .../LibWeb/HTML/HTMLHyperlinkElementUtils.h | 2 +- Libraries/LibWeb/HTML/HTMLObjectElement.cpp | 1 + Libraries/LibWeb/HTML/HTMLSelectElement.cpp | 1 + Libraries/LibWeb/HTML/HTMLTrackElement.cpp | 2 ++ Libraries/LibWeb/HTML/InitialInsertion.h | 16 ++++++++++++ Libraries/LibWeb/HTML/Location.cpp | 1 + Libraries/LibWeb/HTML/Location.h | 2 +- Libraries/LibWeb/HTML/Navigable.cpp | 14 ---------- Libraries/LibWeb/HTML/Navigable.h | 22 ++-------------- Libraries/LibWeb/HTML/NavigableContainer.cpp | 14 ++++++++++ Libraries/LibWeb/HTML/NavigableContainer.h | 16 +++--------- Libraries/LibWeb/HTML/Navigation.h | 2 +- Libraries/LibWeb/HTML/NavigationParams.h | 8 +----- Libraries/LibWeb/HTML/PaintConfig.h | 19 ++++++++++++++ .../WindowEnvironmentSettingsObject.cpp | 1 + Libraries/LibWeb/HTML/Storage.cpp | 1 + .../LibWeb/HTML/UserNavigationInvolvement.cpp | 26 +++++++++++++++++++ .../LibWeb/HTML/UserNavigationInvolvement.h | 22 ++++++++++++++++ Libraries/LibWeb/HTML/Window.cpp | 4 +-- Libraries/LibWeb/HTML/Window.h | 5 ++-- Libraries/LibWeb/HTML/WindowProxy.cpp | 1 + Libraries/LibWeb/HTML/WindowType.h | 17 ++++++++++++ Libraries/LibWeb/Internals/Internals.cpp | 1 + .../Layout/NavigableContainerViewport.cpp | 1 + Libraries/LibWeb/Layout/Node.cpp | 1 + .../MixedContent/AbstractOperations.cpp | 1 + Libraries/LibWeb/Page/EventHandler.cpp | 1 + .../LibWeb/Painting/BackgroundPainting.cpp | 1 + .../LibWeb/Painting/BackingStoreManager.h | 1 - .../LibWeb/Painting/LabelablePaintable.cpp | 1 + Libraries/LibWeb/Painting/MediaPaintable.cpp | 1 + .../NavigableContainerViewportPaintable.cpp | 1 + Libraries/LibWeb/Painting/PaintableBox.cpp | 1 + Libraries/LibWeb/Painting/TextPaintable.cpp | 1 + .../ReferrerPolicy/AbstractOperations.cpp | 1 + Libraries/LibWeb/SVG/SVGScriptElement.cpp | 1 + Libraries/LibWeb/UIEvents/PointerEvent.cpp | 1 + .../LibWeb/ViewTransition/ViewTransition.cpp | 1 + 55 files changed, 170 insertions(+), 64 deletions(-) create mode 100644 Libraries/LibWeb/HTML/InitialInsertion.h create mode 100644 Libraries/LibWeb/HTML/PaintConfig.h create mode 100644 Libraries/LibWeb/HTML/UserNavigationInvolvement.cpp create mode 100644 Libraries/LibWeb/HTML/UserNavigationInvolvement.h create mode 100644 Libraries/LibWeb/HTML/WindowType.h diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index 61d1437ba14..610637824d3 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -654,6 +654,7 @@ set(SOURCES HTML/TraversableNavigable.cpp HTML/UniversalGlobalScope.cpp HTML/UserActivation.cpp + HTML/UserNavigationInvolvement.cpp HTML/ValidityState.cpp HTML/VideoTrack.cpp HTML/VideoTrackList.cpp diff --git a/Libraries/LibWeb/CSS/CSSImportRule.cpp b/Libraries/LibWeb/CSS/CSSImportRule.cpp index 5e7e2ce18bf..eb14180fee2 100644 --- a/Libraries/LibWeb/CSS/CSSImportRule.cpp +++ b/Libraries/LibWeb/CSS/CSSImportRule.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include namespace Web::CSS { diff --git a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp index 08a3f96b4d3..cc153df0910 100644 --- a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/CSS/Length.cpp b/Libraries/LibWeb/CSS/Length.cpp index acddf608b56..713005dfcf1 100644 --- a/Libraries/LibWeb/CSS/Length.cpp +++ b/Libraries/LibWeb/CSS/Length.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include diff --git a/Libraries/LibWeb/CSS/StyleValues/StyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/StyleValue.cpp index 99a35f4218e..7abcd7b09e0 100644 --- a/Libraries/LibWeb/CSS/StyleValues/StyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/StyleValue.cpp @@ -74,6 +74,7 @@ #include #include #include +#include #include namespace Web::CSS { diff --git a/Libraries/LibWeb/CSS/VisualViewport.cpp b/Libraries/LibWeb/CSS/VisualViewport.cpp index 2ede8cacf88..c9a1c2ea265 100644 --- a/Libraries/LibWeb/CSS/VisualViewport.cpp +++ b/Libraries/LibWeb/CSS/VisualViewport.cpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace Web::CSS { diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.h index 1af943c3320..b97efe03de0 100644 --- a/Libraries/LibWeb/DOM/Document.h +++ b/Libraries/LibWeb/DOM/Document.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/DOM/DocumentLoading.h b/Libraries/LibWeb/DOM/DocumentLoading.h index 787b68c2d0c..fe65861ae59 100644 --- a/Libraries/LibWeb/DOM/DocumentLoading.h +++ b/Libraries/LibWeb/DOM/DocumentLoading.h @@ -9,6 +9,8 @@ #include #include +#include +#include namespace Web { diff --git a/Libraries/LibWeb/Fetch/Body.cpp b/Libraries/LibWeb/Fetch/Body.cpp index bd87072911f..431169ac884 100644 --- a/Libraries/LibWeb/Fetch/Body.cpp +++ b/Libraries/LibWeb/Fetch/Body.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index fa3eef3e617..77aa8361e03 100644 --- a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index 00a48d5a527..d73efd19fef 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -781,6 +781,7 @@ struct EnvironmentSettingsObject; struct NavigationParams; struct OpenerPolicy; struct OpenerPolicyEnforcementResult; +struct PaintConfig; struct PolicyContainer; struct POSTResource; struct ScrollOptions; @@ -788,6 +789,7 @@ struct ScrollToOptions; struct SerializedFormData; struct SerializedPolicyContainer; struct SerializedTransferRecord; +struct SourceSnapshotParams; struct StructuredSerializeOptions; struct SyntheticRealmSettings; struct ToggleTaskTracker; diff --git a/Libraries/LibWeb/HTML/CloseWatcher.cpp b/Libraries/LibWeb/HTML/CloseWatcher.cpp index 47cd09d0fb7..276898c8bff 100644 --- a/Libraries/LibWeb/HTML/CloseWatcher.cpp +++ b/Libraries/LibWeb/HTML/CloseWatcher.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include namespace Web::HTML { diff --git a/Libraries/LibWeb/HTML/CrossOrigin/Reporting.cpp b/Libraries/LibWeb/HTML/CrossOrigin/Reporting.cpp index 72ad5edde8d..58342b03ca7 100644 --- a/Libraries/LibWeb/HTML/CrossOrigin/Reporting.cpp +++ b/Libraries/LibWeb/HTML/CrossOrigin/Reporting.cpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace Web::HTML { diff --git a/Libraries/LibWeb/HTML/Focus.cpp b/Libraries/LibWeb/HTML/Focus.cpp index 1dc43cd94bd..ed5672ee2b7 100644 --- a/Libraries/LibWeb/HTML/Focus.cpp +++ b/Libraries/LibWeb/HTML/Focus.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include diff --git a/Libraries/LibWeb/HTML/HTMLBodyElement.cpp b/Libraries/LibWeb/HTML/HTMLBodyElement.cpp index cebc5e0f6a5..54ba726252e 100644 --- a/Libraries/LibWeb/HTML/HTMLBodyElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLBodyElement.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Libraries/LibWeb/HTML/HTMLFormElement.cpp index b3dce03a5df..924670f5059 100644 --- a/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/HTML/HTMLFormElement.h b/Libraries/LibWeb/HTML/HTMLFormElement.h index 947d02caad6..5d3cea330a5 100644 --- a/Libraries/LibWeb/HTML/HTMLFormElement.h +++ b/Libraries/LibWeb/HTML/HTMLFormElement.h @@ -10,8 +10,9 @@ #include #include +#include #include -#include +#include namespace Web::HTML { diff --git a/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.h b/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.h index fe728fa843c..fc79bcabdc2 100644 --- a/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.h +++ b/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.h @@ -9,8 +9,8 @@ #include #include #include -#include #include +#include namespace Web::HTML { diff --git a/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index 1a273083c70..04cf6087144 100644 --- a/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index eb53e22d199..8f3768b4a6e 100644 --- a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/HTML/HTMLTrackElement.cpp b/Libraries/LibWeb/HTML/HTMLTrackElement.cpp index 8958171922c..9daa17de528 100644 --- a/Libraries/LibWeb/HTML/HTMLTrackElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTrackElement.cpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/Libraries/LibWeb/HTML/InitialInsertion.h b/Libraries/LibWeb/HTML/InitialInsertion.h new file mode 100644 index 00000000000..16b932886b6 --- /dev/null +++ b/Libraries/LibWeb/HTML/InitialInsertion.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025, Sam Atkins + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +namespace Web::HTML { + +enum class InitialInsertion : u8 { + Yes, + No, +}; + +} diff --git a/Libraries/LibWeb/HTML/Location.cpp b/Libraries/LibWeb/HTML/Location.cpp index 2fe21c06c28..8da3d0416c6 100644 --- a/Libraries/LibWeb/HTML/Location.cpp +++ b/Libraries/LibWeb/HTML/Location.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/HTML/Location.h b/Libraries/LibWeb/HTML/Location.h index 14454e626d0..9393a20e99c 100644 --- a/Libraries/LibWeb/HTML/Location.h +++ b/Libraries/LibWeb/HTML/Location.h @@ -10,10 +10,10 @@ #include #include #include +#include #include #include #include -#include namespace Web::HTML { diff --git a/Libraries/LibWeb/HTML/Navigable.cpp b/Libraries/LibWeb/HTML/Navigable.cpp index 0cf967b1d4f..0dc25d76906 100644 --- a/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Libraries/LibWeb/HTML/Navigable.cpp @@ -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; diff --git a/Libraries/LibWeb/HTML/Navigable.h b/Libraries/LibWeb/HTML/Navigable.h index 9e4f700594d..df6fbb5f20f 100644 --- a/Libraries/LibWeb/HTML/Navigable.h +++ b/Libraries/LibWeb/HTML/Navigable.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -24,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -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 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; WindowType window_type; @@ -306,6 +289,5 @@ WEB_API HashTable>& all_navigables(); bool navigation_must_be_a_replace(URL::URL const& url, DOM::Document const& document); void finalize_a_cross_document_navigation(GC::Ref, HistoryHandlingBehavior, UserNavigationInvolvement, GC::Ref); void perform_url_and_history_update_steps(DOM::Document& document, URL::URL new_url, Optional = {}, HistoryHandlingBehavior history_handling = HistoryHandlingBehavior::Replace); -UserNavigationInvolvement user_navigation_involvement(DOM::Event const&); } diff --git a/Libraries/LibWeb/HTML/NavigableContainer.cpp b/Libraries/LibWeb/HTML/NavigableContainer.cpp index e7f63581af0..39db39f2660 100644 --- a/Libraries/LibWeb/HTML/NavigableContainer.cpp +++ b/Libraries/LibWeb/HTML/NavigableContainer.cpp @@ -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(); +} + } diff --git a/Libraries/LibWeb/HTML/NavigableContainer.h b/Libraries/LibWeb/HTML/NavigableContainer.h index 7da85c65ce2..c660246cc7e 100644 --- a/Libraries/LibWeb/HTML/NavigableContainer.h +++ b/Libraries/LibWeb/HTML/NavigableContainer.h @@ -8,7 +8,7 @@ #include #include -#include +#include 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; } diff --git a/Libraries/LibWeb/HTML/Navigation.h b/Libraries/LibWeb/HTML/Navigation.h index 19aaf20f691..aea4ac7de9d 100644 --- a/Libraries/LibWeb/HTML/Navigation.h +++ b/Libraries/LibWeb/HTML/Navigation.h @@ -10,9 +10,9 @@ #include #include #include -#include #include #include +#include namespace Web::HTML { diff --git a/Libraries/LibWeb/HTML/NavigationParams.h b/Libraries/LibWeb/HTML/NavigationParams.h index 02be441cf06..7e74ea0042f 100644 --- a/Libraries/LibWeb/HTML/NavigationParams.h +++ b/Libraries/LibWeb/HTML/NavigationParams.h @@ -17,16 +17,10 @@ #include #include #include +#include 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); diff --git a/Libraries/LibWeb/HTML/PaintConfig.h b/Libraries/LibWeb/HTML/PaintConfig.h new file mode 100644 index 00000000000..0d9dd72814d --- /dev/null +++ b/Libraries/LibWeb/HTML/PaintConfig.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025, Aliaksandr Kalenik + * + * 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 canvas_fill_rect {}; + + bool operator==(PaintConfig const& other) const = default; +}; + +} diff --git a/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp b/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp index 0f09d154eaa..f391d2bc2a8 100644 --- a/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp +++ b/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/Libraries/LibWeb/HTML/Storage.cpp b/Libraries/LibWeb/HTML/Storage.cpp index 7a75eebc11e..03f4cd196ec 100644 --- a/Libraries/LibWeb/HTML/Storage.cpp +++ b/Libraries/LibWeb/HTML/Storage.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/HTML/UserNavigationInvolvement.cpp b/Libraries/LibWeb/HTML/UserNavigationInvolvement.cpp new file mode 100644 index 00000000000..bf1e674d2c7 --- /dev/null +++ b/Libraries/LibWeb/HTML/UserNavigationInvolvement.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024, Andrew Kaster + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include + +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; +} + +} diff --git a/Libraries/LibWeb/HTML/UserNavigationInvolvement.h b/Libraries/LibWeb/HTML/UserNavigationInvolvement.h new file mode 100644 index 00000000000..17f9d5cc3cf --- /dev/null +++ b/Libraries/LibWeb/HTML/UserNavigationInvolvement.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023, Andrew Kaster + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +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&); + +} diff --git a/Libraries/LibWeb/HTML/Window.cpp b/Libraries/LibWeb/HTML/Window.cpp index 1db1f45831c..4f92172a289 100644 --- a/Libraries/LibWeb/HTML/Window.cpp +++ b/Libraries/LibWeb/HTML/Window.cpp @@ -156,7 +156,7 @@ WebIDL::ExceptionOr> 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::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)); diff --git a/Libraries/LibWeb/HTML/Window.h b/Libraries/LibWeb/HTML/Window.h index 51d32ac5619..3e6d92ca628 100644 --- a/Libraries/LibWeb/HTML/Window.h +++ b/Libraries/LibWeb/HTML/Window.h @@ -19,14 +19,13 @@ #include #include #include -#include -#include #include #include #include #include #include #include +#include #include #include @@ -123,7 +122,7 @@ public: struct OpenedWindow { GC::Ptr navigable; TokenizedFeature::NoOpener no_opener { TokenizedFeature::NoOpener::No }; - Navigable::WindowType window_type { Navigable::WindowType::ExistingOrNone }; + WindowType window_type { WindowType::ExistingOrNone }; }; WebIDL::ExceptionOr window_open_steps_internal(StringView url, StringView target, StringView features); diff --git a/Libraries/LibWeb/HTML/WindowProxy.cpp b/Libraries/LibWeb/HTML/WindowProxy.cpp index 7914a988596..394d31b30c8 100644 --- a/Libraries/LibWeb/HTML/WindowProxy.cpp +++ b/Libraries/LibWeb/HTML/WindowProxy.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/HTML/WindowType.h b/Libraries/LibWeb/HTML/WindowType.h new file mode 100644 index 00000000000..f5827b75931 --- /dev/null +++ b/Libraries/LibWeb/HTML/WindowType.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2023, Aliaksandr Kalenik + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +namespace Web::HTML { + +enum class WindowType { + ExistingOrNone, + NewAndUnrestricted, + NewWithNoOpener, +}; + +} diff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cpp index 346a6637cd2..06a84d6f0f1 100644 --- a/Libraries/LibWeb/Internals/Internals.cpp +++ b/Libraries/LibWeb/Internals/Internals.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/Layout/NavigableContainerViewport.cpp b/Libraries/LibWeb/Layout/NavigableContainerViewport.cpp index d6485262faa..42030c1fa8f 100644 --- a/Libraries/LibWeb/Layout/NavigableContainerViewport.cpp +++ b/Libraries/LibWeb/Layout/NavigableContainerViewport.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/Layout/Node.cpp b/Libraries/LibWeb/Layout/Node.cpp index e2facd2aa63..3d0ed0219c5 100644 --- a/Libraries/LibWeb/Layout/Node.cpp +++ b/Libraries/LibWeb/Layout/Node.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/MixedContent/AbstractOperations.cpp b/Libraries/LibWeb/MixedContent/AbstractOperations.cpp index 81c8fc4f5f7..0e009f5bb82 100644 --- a/Libraries/LibWeb/MixedContent/AbstractOperations.cpp +++ b/Libraries/LibWeb/MixedContent/AbstractOperations.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include #include diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cpp index eaa3b9fb973..9a1a07cd371 100644 --- a/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Libraries/LibWeb/Page/EventHandler.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/Painting/BackgroundPainting.cpp b/Libraries/LibWeb/Painting/BackgroundPainting.cpp index dd3a0593136..8ff4c19267e 100644 --- a/Libraries/LibWeb/Painting/BackgroundPainting.cpp +++ b/Libraries/LibWeb/Painting/BackgroundPainting.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include diff --git a/Libraries/LibWeb/Painting/BackingStoreManager.h b/Libraries/LibWeb/Painting/BackingStoreManager.h index 57a5053318d..6982edc11fe 100644 --- a/Libraries/LibWeb/Painting/BackingStoreManager.h +++ b/Libraries/LibWeb/Painting/BackingStoreManager.h @@ -7,7 +7,6 @@ #pragma once #include -#include namespace Web::Painting { diff --git a/Libraries/LibWeb/Painting/LabelablePaintable.cpp b/Libraries/LibWeb/Painting/LabelablePaintable.cpp index b24d522b5b8..c449e3e7017 100644 --- a/Libraries/LibWeb/Painting/LabelablePaintable.cpp +++ b/Libraries/LibWeb/Painting/LabelablePaintable.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include #include diff --git a/Libraries/LibWeb/Painting/MediaPaintable.cpp b/Libraries/LibWeb/Painting/MediaPaintable.cpp index e0cb08af6b2..46882f38da6 100644 --- a/Libraries/LibWeb/Painting/MediaPaintable.cpp +++ b/Libraries/LibWeb/Painting/MediaPaintable.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/Painting/NavigableContainerViewportPaintable.cpp b/Libraries/LibWeb/Painting/NavigableContainerViewportPaintable.cpp index 9d32412aad7..d90398dae51 100644 --- a/Libraries/LibWeb/Painting/NavigableContainerViewportPaintable.cpp +++ b/Libraries/LibWeb/Painting/NavigableContainerViewportPaintable.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include #include diff --git a/Libraries/LibWeb/Painting/PaintableBox.cpp b/Libraries/LibWeb/Painting/PaintableBox.cpp index 79da8357f75..3e00a7c3261 100644 --- a/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/Painting/TextPaintable.cpp b/Libraries/LibWeb/Painting/TextPaintable.cpp index 6b1092080ed..9fa9b16549c 100644 --- a/Libraries/LibWeb/Painting/TextPaintable.cpp +++ b/Libraries/LibWeb/Painting/TextPaintable.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include #include diff --git a/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.cpp b/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.cpp index 540a8abd2c9..1b8c0bc04dc 100644 --- a/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.cpp +++ b/Libraries/LibWeb/ReferrerPolicy/AbstractOperations.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/SVG/SVGScriptElement.cpp b/Libraries/LibWeb/SVG/SVGScriptElement.cpp index a03cd95df17..d4a25378523 100644 --- a/Libraries/LibWeb/SVG/SVGScriptElement.cpp +++ b/Libraries/LibWeb/SVG/SVGScriptElement.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/UIEvents/PointerEvent.cpp b/Libraries/LibWeb/UIEvents/PointerEvent.cpp index 839bc346630..f1e78ce9295 100644 --- a/Libraries/LibWeb/UIEvents/PointerEvent.cpp +++ b/Libraries/LibWeb/UIEvents/PointerEvent.cpp @@ -5,6 +5,7 @@ */ #include +#include #include namespace Web::UIEvents { diff --git a/Libraries/LibWeb/ViewTransition/ViewTransition.cpp b/Libraries/LibWeb/ViewTransition/ViewTransition.cpp index 2552a5bf2ab..d6df003988a 100644 --- a/Libraries/LibWeb/ViewTransition/ViewTransition.cpp +++ b/Libraries/LibWeb/ViewTransition/ViewTransition.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include