From 6bc6e2d4a884ce1b95d93a283a9ab0373957c24b Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Fri, 15 Dec 2023 02:44:45 +0000 Subject: [PATCH] Add pagereveal event The pagereveal event is fired at the beginning of the first rendering opportunity after activation (initial load or reactivation). It is a way for the author to execute some JS that affects the presentation "just in time" for the first frame. If there is an inbound cross-document view transition, the reveal event holds a reference to the ViewTransition object. Closes #9315. --- source | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/source b/source index 1a6bf93fbf2..66f36ec10eb 100644 --- a/source +++ b/source @@ -4022,12 +4022,15 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The math functions
  • -

    The following features are defined in CSS View Transitions 1: +

    The following features are defined in CSS View Transitions: CSSVIEWTRANSITIONS

    The term HashChangeEventInit : EventInit { +

    The PageRevealEvent interface
    + +
    [Exposed=Window]
    +interface PageRevealEvent : Event {
    +  constructor(DOMString type, optional PageRevealEventInit eventInitDict = {});
    +  readonly attribute ViewTransition? viewTransition;
    +};
    +
    +dictionary PageRevealEventInit : EventInit {
    +  ViewTransition? viewTransition = null;
    +};
    + +
    +
    event.viewTransition
    +
    +

    Returns the ViewTransition object that represents an inbound cross-document view + transition, if such transition is active when the event is fired. Otherwise, returns null.

    +
    +
    + +
    + +

    The viewTransition attribute must return the + value it was initialized to.

    + +
    + +
    The PageTransitionEvent interface
    [Exposed=Window]
    @@ -101417,6 +101449,8 @@ location.href = '#foo';
    1. Set document's page showing flag to true.

    2. +
    3. Set document's has been revealed to false.

      +
    4. Update the visibility state of document to "visible".

    5. @@ -101458,6 +101492,40 @@ location.href = '#foo';
    +
    Revealing the document
    + +

    A Document has a boolean has been revealed, initially false. It is used + to ensure that the pagereveal event is fired once for each + activation of the Document (once when it's rendered initially, and once for each + reactivation).

    + +

    To reveal a Document document:

    + +
      +
    1. If document's has been revealed is true, then return.

    2. + +
    3. Set document's has been revealed to true.

    4. + +
    5. Let transition be the result of + resolving cross-document view-transition for document.

    6. + +
    7. Fire an event named + pagereveal at document's + relevant global object, using PageRevealEvent with its viewTransition set to + transition.

    8. + +
    9. If transition is not null, then activate transition.

    10. +
    + +

    Though pagereveal is guaranteed to be fired + during the first update the rendering step that displays an up-to-date version of the + page, user agents are free to display a cached frame of the page before firing it. This prevents + the presence of a pagereveal handler from delaying the + presentation of such cached frame.

    + +
    Scrolling to a fragment

    To scroll to the fragment given a @@ -108146,6 +108214,9 @@ import "https://example.com/foo/../module2.mjs"; +

  • For each fully active Document in docs, + reveal that Document.

  • +
  • For each fully active Document in docs, flush autofocus candidates for that Document if its node navigable is a top-level traversable.

  • @@ -109880,6 +109951,7 @@ typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnl onoffline offline ononline online onpagehide pagehide + onpagereveal pagereveal onpageshow pageshow onpopstate popstate onrejectionhandled rejectionhandled @@ -110007,6 +110079,7 @@ interface mixin WindowEventHandlers { attribute EventHandler onoffline; attribute EventHandler ononline; attribute EventHandler onpagehide; + attribute EventHandler onpagereveal; attribute EventHandler onpageshow; attribute EventHandler onpopstate; attribute EventHandler onrejectionhandled; @@ -138999,6 +139072,12 @@ interface External { pagehide event handler for Window object Event handler content attribute + + onpagereveal + body + pagereveal event handler for Window object + Event handler content attribute + onpageshow body @@ -139869,6 +139948,13 @@ INSERT INTERFACES HERE Fired at the Window when the page's session history entry stops being the active entry + + pagereveal + PageRevealEvent + Window + Fired at the Window when the page begins to render for the first time after + it has been initialized or reactivated + pageshow PageTransitionEvent