LibWeb: Implement plumbing for view transitions

This implements large parts of the CSS view-transitions-1 spec.
This commit is contained in:
Psychpsyo 2025-03-23 12:38:21 +01:00 committed by Sam Atkins
parent 4f0e8236a0
commit 56739b4b16
Notes: github-actions[bot] 2025-09-07 12:59:13 +00:00
22 changed files with 1516 additions and 4 deletions

View file

@ -458,7 +458,10 @@ void EventLoop::update_the_rendering()
// FIXME: 17. For each doc of docs, if the focused area of doc is not a focusable area, then run the focusing steps for doc's viewport, and set doc's relevant global object's navigation API's focus changed during ongoing navigation to false.
// FIXME: 18. For each doc of docs, perform pending transition operations for doc. [CSSVIEWTRANSITIONS]
// 18. For each doc of docs, perform pending transition operations for doc. [CSSVIEWTRANSITIONS]
for (auto& document : docs) {
document->perform_pending_transition_operations();
}
// 19. For each doc of docs, run the update intersection observations steps for doc, passing in the relative high resolution time given now and doc's relevant global object as the timestamp. [INTERSECTIONOBSERVER]
for (auto& document : docs) {

View file

@ -2587,6 +2587,22 @@ void Navigable::paste(String const& text)
m_event_handler.handle_paste(text);
}
// https://drafts.csswg.org/css-view-transitions-1/#snapshot-containing-block
CSSPixelRect Navigable::snapshot_containing_block()
{
// The snapshot containing block is a rectangle that covers all areas of the window that could potentially display
// page content (and is therefore consistent regardless of root scrollbars or interactive widgets).
// Within a child navigable, the snapshot containing block is the union of the navigables viewport with any scrollbar gutters.
// FIXME: Actually get the correct rectangle here.
return viewport_rect();
}
// https://drafts.csswg.org/css-view-transitions-1/#snapshot-containing-block-size
CSSPixelSize Navigable::snapshot_containing_block_size()
{
return this->snapshot_containing_block().size();
}
void Navigable::register_navigation_observer(Badge<NavigationObserver>, NavigationObserver& navigation_observer)
{
auto result = m_navigation_observers.set(navigation_observer);

View file

@ -9,6 +9,7 @@
#include <AK/HashTable.h>
#include <AK/String.h>
#include <AK/Tuple.h>
#include <LibJS/Heap/Cell.h>
#include <LibWeb/Bindings/NavigationPrototype.h>
#include <LibWeb/DOM/DocumentLoadEventDelayer.h>
@ -200,6 +201,11 @@ public:
Web::EventHandler& event_handler() { return m_event_handler; }
Web::EventHandler const& event_handler() const { return m_event_handler; }
// https://drafts.csswg.org/css-view-transitions-1/#snapshot-containing-block
CSSPixelRect snapshot_containing_block();
// https://drafts.csswg.org/css-view-transitions-1/#snapshot-containing-block-size
CSSPixelSize snapshot_containing_block_size();
bool has_session_history_entry_and_ready_for_navigation() const { return m_has_session_history_entry_and_ready_for_navigation; }
void set_has_session_history_entry_and_ready_for_navigation();