Skip to content

Commit

Permalink
LibWeb: Convert Navigable::navigate's csp_navigation_type to an enum
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
trflynn89 authored and ADKaster committed May 9, 2023
1 parent f7c2755 commit 872e18f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/HTML/Navigable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate(
JS::GCPtr<Fetch::Infrastructure::Response> 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.
Expand Down Expand Up @@ -904,7 +904,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate_to_a_fragment(AK::URL const&, Hist
TODO();
}

WebIDL::ExceptionOr<void> Navigable::navigate_to_a_javascript_url(AK::URL const&, HistoryHandlingBehavior, Origin const& initiator_origin, String csp_navigation_type)
WebIDL::ExceptionOr<void> 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;
Expand Down
9 changes: 7 additions & 2 deletions Userland/Libraries/LibWeb/HTML/Navigable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -70,12 +75,12 @@ class Navigable : public JS::Cell {
JS::GCPtr<Fetch::Infrastructure::Response> = 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<void> navigate_to_a_fragment(AK::URL const&, HistoryHandlingBehavior, String navigation_id);

WebIDL::ExceptionOr<void> navigate_to_a_javascript_url(AK::URL const&, HistoryHandlingBehavior, Origin const& initiator_origin, String csp_navigation_type);
WebIDL::ExceptionOr<void> navigate_to_a_javascript_url(AK::URL const&, HistoryHandlingBehavior, Origin const& initiator_origin, CSPNavigationType csp_navigation_type);

protected:
Navigable();
Expand Down

0 comments on commit 872e18f

Please sign in to comment.