mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 02:55:49 +03:00
LibWeb: Implement snapshotting source snapshot params per the spec
This commit is contained in:
parent
798a1b2751
commit
03eae09619
Notes:
sideshowbarker
2024-07-16 23:23:26 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/03eae09619 Pull-request: https://github.com/SerenityOS/serenity/pull/20780 Reviewed-by: https://github.com/awesomekling ✅ Reviewed-by: https://github.com/kalenikaliaksandr
@ -1315,7 +1315,7 @@ Color Document::visited_link_color() const
|
||||
}
|
||||
|
||||
// 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.
|
||||
return Bindings::host_defined_environment_settings_object(realm());
|
||||
@ -2514,6 +2514,31 @@ HTML::PolicyContainer Document::policy_container() const
|
||||
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
|
||||
Vector<JS::Handle<HTML::Navigable>> Document::descendant_navigables()
|
||||
{
|
||||
|
@ -232,7 +232,7 @@ public:
|
||||
DeprecatedString const& source() const { return m_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 evaluate_javascript_url(StringView url);
|
||||
@ -530,6 +530,8 @@ public:
|
||||
|
||||
u32 unload_counter() const { return m_unload_counter; }
|
||||
|
||||
HTML::SourceSnapshotParams snapshot_source_snapshot_params() const;
|
||||
|
||||
protected:
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
@ -814,13 +814,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate(
|
||||
ReferrerPolicy::ReferrerPolicy referrer_policy)
|
||||
{
|
||||
// 1. Let sourceSnapshotParams be the result of snapshotting source snapshot params given sourceDocument.
|
||||
auto source_snapshot_params = SourceSnapshotParams {
|
||||
.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()
|
||||
};
|
||||
auto source_snapshot_params = source_document->snapshot_source_snapshot_params();
|
||||
|
||||
// 2. Let initiatorOriginSnapshot be sourceDocument's origin.
|
||||
auto initiator_origin_snapshot = source_document->origin();
|
||||
|
@ -330,15 +330,9 @@ void TraversableNavigable::apply_the_history_step(int step, Optional<SourceSnaps
|
||||
// 3. Let potentiallyTargetSpecificSourceSnapshotParams be sourceSnapshotParams.
|
||||
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()) {
|
||||
potentially_target_specific_source_snapshot_params = SourceSnapshotParams {
|
||||
.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()
|
||||
};
|
||||
potentially_target_specific_source_snapshot_params = navigable->active_document()->snapshot_source_snapshot_params();
|
||||
}
|
||||
|
||||
// 5. Set targetEntry's document state's reload pending to false.
|
||||
|
Loading…
Reference in New Issue
Block a user