-
Notifications
You must be signed in to change notification settings - Fork 711
[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
Conversation
css-view-transitions-1/Overview.bs
Outdated
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. |
There was a problem hiding this comment.
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.
css-view-transitions-1/Overview.bs
Outdated
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. |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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|, |
There was a problem hiding this comment.
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=]: |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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=]. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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'?
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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=]. |
There was a problem hiding this comment.
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
css-view-transitions-1/Overview.bs
Outdated
|
||
Note: The above code example contains variables to be replaced. | ||
|
||
Issue: Which of ''xywh()''/''rect()''/''inset()'' should we use? |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any preferences?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably do inset
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Settled
css-view-transitions-1/Overview.bs
Outdated
@@ -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: |
There was a problem hiding this comment.
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.
css-view-transitions-1/Overview.bs
Outdated
|
||
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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=].
css-view-transitions-1/Overview.bs
Outdated
|
||
Note: The above code example contains variables to be replaced. | ||
|
||
Issue: Which of ''xywh()''/''rect()''/''inset()'' should we use? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Fixes #8069