Skip to content

[css-view-transitions-1] Clean up use of dynamic styles #8093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 22, 2022

Conversation

jakearchibald
Copy link
Contributor

Fixes #8069

if it has both ''::view-transition-new()'' and ''::view-transition-old()'' as children.

Issue: This reads like a non-normative note, but it's normative. This rule should be specified at the same time as other styles, when the condition above can be determined.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can fix this as part of this PR, once I've checked the details.

if the ancestor ''::view-transition-image-pair()'' has both ''::view-transition-new()'' and ''::view-transition-old()'' as descendants.

Issue: This reads like a non-normative note, but it's normative. This rule should be specified at the same time as other styles, when the condition above can be determined.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can fix this as part of this PR, once I've checked the details.


: <dfn>new view-box rule</dfn>
:: A {{CSSStyleRule}} or null. Initially null.
</dl>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These definitions let us update/remove rules later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some non-normative text to explain this briefly

:: a [=style sheet=].
Initially a new [=style sheet=] in the [=user-agent origin=], ordered after the [=HTML user agent style sheet=].

Note: This is used to hold dynamic styles relating to transitions.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stylesheet is for dynamic styles involved in the transition. It's explicitly linked to a single document, clarifying the scoping.


<div algorithm>
To <dfn>perform an old capture</dfn> given a {{ViewTransition}} |transition|,
To <dfn>setup view transition</dfn> given a {{ViewTransition}} |transition|,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This algorithm is doing much more than capturing, so I renamed it.

@@ -828,13 +866,13 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;

Note: The ready promise would've been resolved if {{ViewTransition/skipTransition()}} is called after we start animating.

1. [=promise/React=] to [=ViewTransition/DOM updated promise=]:
1. [=promise/React=] to |transition|'s [=ViewTransition/DOM updated promise=]:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being specific about which instance of the promise we're talking about

@@ -987,83 +1019,14 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
Issue: Define the algorithm used to clip the snapshot when it exceeds max size.
</div>

## [=Animate a view transition=] ## {#animate-a-view-transition-algorithm}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This algorithm was being called every frame, but the things it does only need to be done once ever (like non-changing UA styles), or once at the start of each transition.

I moved the steps elsewhere.

@@ -987,83 +1019,14 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
Issue: Define the algorithm used to clip the snapshot when it exceeds max size.
</div>

## [=Animate a view transition=] ## {#animate-a-view-transition-algorithm}
## [=Setup transition pseudo-elements=] ## {#setup-transition-pseudo-elements-algorithm}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This algorithm used to be "create transition pseudo-elements", but I added the style rules for things that only need to be done once per transition, so I renamed it to reflect that.

html::view-transition-old(<var>transitionName</var>) {
object-view-box: <var>oldViewBox</var>;
}
</pre>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the pattern of using a CSS code block to describe a rule being created, but we weren't consistent with it, so I used it for all style creation.

}
</pre>

Note: The above code example contains variables to be replaced.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are styles that only need to be set once per transition.

</div>

## [=Style transition pseudo-elements=] ## {#style-transition-pseudo-elements-algorithm}
## [=Update pseudo-element styles=] ## {#style-transition-pseudo-elements-algorithm}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the naming to suggest that it happens more than once.

1. [=list/For each=] |style| of |capturedElement|'s [=captured element/style definitions=]:

1. If |style| is not null,
then remove |style| from |document|'s [=document/view transition style sheet=].
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were missing this bit before, so styles would just hang around forever.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that I think the style removal is sufficient to cause the pseudo elements to be removed, since if no style targets a pseudo element it has default styles that are equivalent to it not being there, so I wonder if this can supersede the need to remove pseudo elements

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that idea, but wouldn't it mean a user style like:

::view-transition {
  content: '';
}

…would cause the view transition pseudo to be 'always there'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've filed #8113 to think more about this.


: <dfn>new view-box rule</dfn>
:: A {{CSSStyleRule}} or null. Initially null.
</dl>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some non-normative text to explain this briefly

1. [=list/For each=] |style| of |capturedElement|'s [=captured element/style definitions=]:

1. If |style| is not null,
then remove |style| from |document|'s [=document/view transition style sheet=].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that I think the style removal is sufficient to cause the pseudo elements to be removed, since if no style targets a pseudo element it has default styles that are equivalent to it not being there, so I wonder if this can supersede the need to remove pseudo elements


Note: The above code example contains variables to be replaced.

Issue: Which of ''xywh()''/''rect()''/''inset()'' should we use?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be resolved at editor's discretion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any preferences?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably do inset :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Settled

@@ -1101,19 +1070,81 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
except the [=view-transition pseudo-elements=],
are not painted (as if they had visibility: hidden)
and do not respond to hit-testing (as if they had pointer-events: none) until |new| exists.

1. If neither of |capturedElement|'s [=captured element/old image=] or [=captured element/new element=] is null:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer "If both ... are not null", since it sounds more in the positive? Just a nit though.


1. If neither of |capturedElement|'s [=captured element/old image=] or [=captured element/new element=] is null:

1. Let |transform| be |capturedElement|'s [=old styles=]'s 'transform' property.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is old styles defined? I know this has moved from elsewhere, but is this correct? We're not using the captured element's style and read its transform property, but rather find the transform it has in screen space and use that as the transform. Similarly for width/height, it could be a flex grow with no explicit width, so what does style width mean here?

Copy link
Contributor Author

@jakearchibald jakearchibald Nov 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've replaced [=old styles=] with [=captured element/old styles=]. It's set in "setup view transition".

I think the confusion here is it feels like a direct reference to the old styles. Would it be better if the prose was:

1. Let |transform| be |capturedElement|'s [=captured element/old offset transform=].


Note: The above code example contains variables to be replaced.

Issue: Which of ''xywh()''/''rect()''/''inset()'' should we use?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@vmpstr vmpstr merged commit f6bd34b into w3c:main Nov 22, 2022
@jakearchibald jakearchibald deleted the ua-stylesheet branch November 22, 2022 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[css-view-transitions-1] Scope of the "user-agent origin" stylesheet
2 participants