1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09:00

LibWeb: Implement snapshotting source snapshot params per the spec

This commit is contained in:
Andrew Kaster 2023-08-25 20:34:50 -06:00 committed by Andreas Kling
parent 798a1b2751
commit 03eae09619
Notes: sideshowbarker 2024-07-16 23:23:26 +09:00
4 changed files with 32 additions and 17 deletions

View file

@ -1315,7 +1315,7 @@ Color Document::visited_link_color() const
} }
// https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object // https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object
HTML::EnvironmentSettingsObject& Document::relevant_settings_object() HTML::EnvironmentSettingsObject& Document::relevant_settings_object() const
{ {
// Then, the relevant settings object for a platform object o is the environment settings object of the relevant Realm for o. // Then, the relevant settings object for a platform object o is the environment settings object of the relevant Realm for o.
return Bindings::host_defined_environment_settings_object(realm()); return Bindings::host_defined_environment_settings_object(realm());
@ -2514,6 +2514,31 @@ HTML::PolicyContainer Document::policy_container() const
return m_policy_container; return m_policy_container;
} }
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#snapshotting-source-snapshot-params
HTML::SourceSnapshotParams Document::snapshot_source_snapshot_params() const
{
// To snapshot source snapshot params given a Document sourceDocument, return a new source snapshot params with
// has transient activation
// true if sourceDocument's relevant global object has transient activation; otherwise false
// sandboxing flags
// sourceDocument's active sandboxing flag set
// allows downloading
// false if sourceDocument's active sandboxing flag set has the sandboxed downloads browsing context flag set; otherwise true
// fetch client
// sourceDocument's relevant settings object
// source policy container
// sourceDocument's policy container
return HTML::SourceSnapshotParams {
.has_transient_activation = verify_cast<HTML::Window>(HTML::relevant_global_object(*this)).has_transient_activation(),
.sandboxing_flags = m_active_sandboxing_flag_set,
.allows_downloading = (m_active_sandboxing_flag_set.flags & HTML::SandboxingFlagSet::SandboxedDownloads) != HTML::SandboxingFlagSet::SandboxedDownloads,
.fetch_client = relevant_settings_object(),
.source_policy_container = m_policy_container
};
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#descendant-navigables // https://html.spec.whatwg.org/multipage/document-sequences.html#descendant-navigables
Vector<JS::Handle<HTML::Navigable>> Document::descendant_navigables() Vector<JS::Handle<HTML::Navigable>> Document::descendant_navigables()
{ {

View file

@ -232,7 +232,7 @@ public:
DeprecatedString const& source() const { return m_source; } DeprecatedString const& source() const { return m_source; }
void set_source(DeprecatedString source) { m_source = move(source); } void set_source(DeprecatedString source) { m_source = move(source); }
HTML::EnvironmentSettingsObject& relevant_settings_object(); HTML::EnvironmentSettingsObject& relevant_settings_object() const;
void navigate_to_javascript_url(StringView url); void navigate_to_javascript_url(StringView url);
void evaluate_javascript_url(StringView url); void evaluate_javascript_url(StringView url);
@ -530,6 +530,8 @@ public:
u32 unload_counter() const { return m_unload_counter; } u32 unload_counter() const { return m_unload_counter; }
HTML::SourceSnapshotParams snapshot_source_snapshot_params() const;
protected: protected:
virtual void initialize(JS::Realm&) override; virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override; virtual void visit_edges(Cell::Visitor&) override;

View file

@ -814,13 +814,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate(
ReferrerPolicy::ReferrerPolicy referrer_policy) ReferrerPolicy::ReferrerPolicy referrer_policy)
{ {
// 1. Let sourceSnapshotParams be the result of snapshotting source snapshot params given sourceDocument. // 1. Let sourceSnapshotParams be the result of snapshotting source snapshot params given sourceDocument.
auto source_snapshot_params = SourceSnapshotParams { auto source_snapshot_params = source_document->snapshot_source_snapshot_params();
.has_transient_activation = false,
.sandboxing_flags = source_document->active_sandboxing_flag_set(),
.allows_downloading = true,
.fetch_client = source_document->relevant_settings_object(),
.source_policy_container = source_document->policy_container()
};
// 2. Let initiatorOriginSnapshot be sourceDocument's origin. // 2. Let initiatorOriginSnapshot be sourceDocument's origin.
auto initiator_origin_snapshot = source_document->origin(); auto initiator_origin_snapshot = source_document->origin();

View file

@ -330,15 +330,9 @@ void TraversableNavigable::apply_the_history_step(int step, Optional<SourceSnaps
// 3. Let potentiallyTargetSpecificSourceSnapshotParams be sourceSnapshotParams. // 3. Let potentiallyTargetSpecificSourceSnapshotParams be sourceSnapshotParams.
Optional<SourceSnapshotParams> potentially_target_specific_source_snapshot_params = source_snapshot_params; Optional<SourceSnapshotParams> potentially_target_specific_source_snapshot_params = source_snapshot_params;
// FIXME: 4. If potentiallyTargetSpecificSourceSnapshotParams is null, then set it to the result of snapshotting source snapshot params given navigable's active document. // 4. If potentiallyTargetSpecificSourceSnapshotParams is null, then set it to the result of snapshotting source snapshot params given navigable's active document.
if (!potentially_target_specific_source_snapshot_params.has_value()) { if (!potentially_target_specific_source_snapshot_params.has_value()) {
potentially_target_specific_source_snapshot_params = SourceSnapshotParams { potentially_target_specific_source_snapshot_params = navigable->active_document()->snapshot_source_snapshot_params();
.has_transient_activation = false,
.sandboxing_flags = navigable->active_document()->active_sandboxing_flag_set(),
.allows_downloading = true,
.fetch_client = navigable->active_document()->relevant_settings_object(),
.source_policy_container = navigable->active_document()->policy_container()
};
} }
// 5. Set targetEntry's document state's reload pending to false. // 5. Set targetEntry's document state's reload pending to false.