From 872e18f660d3a276fc78dc533ec42c7fe43922a4 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sun, 7 May 2023 12:47:38 -0400 Subject: LibWeb: Convert Navigable::navigate's csp_navigation_type to an enum Some versions of clang will have an issue using a consteval function to set the optional parameter's default value. For example, see: https://stackoverflow.com/questions/68789984/immediate-function-as-default-function-argument-initializer-in-clang This doesn't need to be a String anyways, so let's make it an enum. --- Userland/Libraries/LibWeb/HTML/Navigable.cpp | 4 ++-- Userland/Libraries/LibWeb/HTML/Navigable.h | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.cpp b/Userland/Libraries/LibWeb/HTML/Navigable.cpp index 3c75e3a493..006fe0719d 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigable.cpp @@ -692,7 +692,7 @@ WebIDL::ExceptionOr Navigable::navigate( JS::GCPtr response, bool exceptions_enabled, HistoryHandlingBehavior history_handling, - String csp_navigation_type, + CSPNavigationType csp_navigation_type, ReferrerPolicy::ReferrerPolicy referrer_policy) { // 1. Let sourceSnapshotParams be the result of snapshotting source snapshot params given sourceDocument. @@ -904,7 +904,7 @@ WebIDL::ExceptionOr Navigable::navigate_to_a_fragment(AK::URL const&, Hist TODO(); } -WebIDL::ExceptionOr Navigable::navigate_to_a_javascript_url(AK::URL const&, HistoryHandlingBehavior, Origin const& initiator_origin, String csp_navigation_type) +WebIDL::ExceptionOr Navigable::navigate_to_a_javascript_url(AK::URL const&, HistoryHandlingBehavior, Origin const& initiator_origin, CSPNavigationType csp_navigation_type) { (void)initiator_origin; (void)csp_navigation_type; diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.h b/Userland/Libraries/LibWeb/HTML/Navigable.h index f1b041130c..7a57939cfe 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.h +++ b/Userland/Libraries/LibWeb/HTML/Navigable.h @@ -15,6 +15,11 @@ namespace Web::HTML { +enum class CSPNavigationType { + Other, + FormSubmission, +}; + // https://html.spec.whatwg.org/multipage/document-sequences.html#navigable class Navigable : public JS::Cell { JS_CELL(Navigable, JS::Cell); @@ -70,12 +75,12 @@ public: JS::GCPtr = nullptr, bool exceptions_enabled = false, HistoryHandlingBehavior = HistoryHandlingBehavior::Push, - String csp_navigation_type = String::from_utf8_short_string("other"sv), + CSPNavigationType csp_navigation_type = CSPNavigationType::Other, ReferrerPolicy::ReferrerPolicy = ReferrerPolicy::ReferrerPolicy::EmptyString); WebIDL::ExceptionOr navigate_to_a_fragment(AK::URL const&, HistoryHandlingBehavior, String navigation_id); - WebIDL::ExceptionOr navigate_to_a_javascript_url(AK::URL const&, HistoryHandlingBehavior, Origin const& initiator_origin, String csp_navigation_type); + WebIDL::ExceptionOr navigate_to_a_javascript_url(AK::URL const&, HistoryHandlingBehavior, Origin const& initiator_origin, CSPNavigationType csp_navigation_type); protected: Navigable(); -- cgit v1.2.3