Skip to content
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

[css-view-transitions-2] First pass at layered capture #11045

Merged
merged 13 commits into from
Nov 5, 2024

Conversation

noamr
Copy link
Collaborator

@noamr noamr commented Oct 17, 2024

Describe how layered capture works, which CSS properties it targets and how it affects rendering. Based on this resolution.

This is a first pass, and still has open issues (will open separately):

  1. Should there be a CSS property to decide on this? What should be the default?
  2. How do we capture overflow/box-sizing?
  3. (More capture questions if they come up)

Closes #10585

@noamr noamr requested a review from khushalsagar October 17, 2024 14:43
Describe how layered capture works, which CSS properties it targets and how it affects rendering.
Based on [this resolution](w3c#10585 (comment)).

This is a first pass, and still has open issues (will open separately):
1. Should there be a CSS property to decide on this? What should be the default?
2. How do we capture overflow/box-sizing?
3. (More capture questions if they come up)

Closes w3c#10585
@noamr noamr force-pushed the vt2-capture-mode-initial branch from 11fb9a6 to ae59e4c Compare October 17, 2024 14:43
css-view-transitions-2/Overview.bs Show resolved Hide resolved
css-view-transitions-2/Overview.bs Outdated Show resolved Hide resolved
css-view-transitions-2/Overview.bs Outdated Show resolved Hide resolved
- 'overflow-clip-margin'
- 'padding'

Issue: the behavior of 'overflow' is not entirely clear, especially with ''overflow/scroll'' and ''overflow-auto''. Should the scroll bars be part of the snapshot?
Copy link
Member

Choose a reason for hiding this comment

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

nit: Also containment. Not clear whether style, layout and size containment should be carried over.

- 'overflow-clip-margin'
- 'padding'

Issue: the behavior of 'overflow' needs to be clarified, especially with ''overflow/scroll'' and ''overflow-auto''. Should the scroll bars be part of the snapshot?
Copy link
Member

Choose a reason for hiding this comment

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

containment is also an open question. We likely only want to consider paint containment and set overflow to clip if it's there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added to the note, also moved the note

css-view-transitions-2/Overview.bs Show resolved Hide resolved
:: A string.

: <dfn>transform from snapshot containing block</dfn>
: <dfn>old nested group transform
Copy link
Member

Choose a reason for hiding this comment

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

why do we need new transforms here...? we dealt with this for nesting, layered capture shouldn't need to track new transforms.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done


### Render the snapshot with layered capture ### {#layered-capture-rendering}

When capturing an element into a snapshot, apply the following style to the element in addition to the [=capture rendering characteristics=]:
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this would be the right way to define this since we don't actually want to remove these styles. We could lean on the concept of "contents" defined in the contain spec: https://drafts.csswg.org/css-contain/#skips-its-contents:~:text=the%20flat%20tree%20descendants%20of%20the%20element%2C%20including%20both%20text%20and%20elements%2C%20or%20the%20replaced%20content%20of%20a%20replaced%20element to describe what should be painted when generating this snapshot. @vmpstr might have more input here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reworded, PTAL?

css-view-transitions-2/Overview.bs Show resolved Hide resolved
Note: we apply 'outline-color' and 'border-color' instead of 'outline' and 'border' so that layout is not affected by capturing.

### Compute the nested group transform ### {#vt-compute-nested-group-transform}
To compute the <dfn>nested group transform</dfn> given an {{Element}} |element|, return a [=matrix=] equivalent to a 2D translation of (|element|'s [=computed value|computed=] ''border-left-width'', |element|'s [=computed value|computed=] ''border-top-width'').
Copy link
Member

Choose a reason for hiding this comment

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

Ah, so this is for the border offset. could we cache a 2D offset instead of a transform, and just name it explicitly like border offset.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

css-view-transitions-2/Overview.bs Outdated Show resolved Hide resolved
css-view-transitions-2/Overview.bs Outdated Show resolved Hide resolved
css-view-transitions-2/Overview.bs Show resolved Hide resolved
<div algorithm="adjust image capture size (layered)">
When [=capturing the image=] given |element|:
1. Let |geometry| be |element|'s [=layered capture geometry=].
1. If |geometry| is not null and |geometry|'s [=layered box properties/box sizing=] is ''box-sizing/content-box'',
Copy link
Member

Choose a reason for hiding this comment

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

The snapshot capture is independent of box-sizing, box-sizing only impacts the CSS of the pseudos. But the snapshot would always be content box size because there's no reason to capture borders as a part of it. So it wouldn't make sense for the snapshot to be larger than the element's content.

You can fold this into the "layered-capture-rendering" algorithm below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But this is the spot in L1 where we define the natural dimension of the image and how it's positioned...

Copy link
Member

Choose a reason for hiding this comment

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

Eh ok, my main point was about not making this conditional based on box-sizing. Does that make sense?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

css-view-transitions-2/Overview.bs Show resolved Hide resolved

### Render the snapshot with layered capture ### {#layered-capture-rendering}

When capturing an element into a snapshot, only the [=element contents=] are painted, without the element's effects and box decorations.
Copy link
Member

Choose a reason for hiding this comment

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

Would love to get @vmpstr's input on this phrasing too.

Taking inspiration from the wording in L1: https://drafts.csswg.org/css-view-transitions-1/#capture-the-image-algorithm:~:text=containing%20block.-,Otherwise,-%3A.

  • We want to say what is painted, which is covered here.
  • We want to say what the image size is internally in the UA which I think would be the union of ink overflow rectangles of all the descendants + size of replaced content..?
  • And we want to define the web observable size of the image which is covered above as content box.

1. Append the [=string/concatenate|concatentation=] of « `"::view-transition-group("`, |transitionName|, `") {"`, |style| , `"}"` » to the constructed user-agent stylesheet.
1. Let (|oldContentWidth|, |oldContentHeight|) be (|capturedElement|'s [=captured element/old width=], |capturedElement|'s [=captured element/old height=]) if |capturedElement|'s [=old box properties=] is null, otherwise |capturedElement|'s [=old box properties=]'s [=layered box properties/content box=]'s size.
1. Let (|newContentWidth|, |newContentHeight|) be (|width|, |height|) if [=new box properties=] is null, otherwise |capturedElement|'s [=new box properties=]'s [=layered box properties/content box=]'s size.
1. Append the next string (with replaced variables) to the user agent stylesheet:
Copy link
Member

Choose a reason for hiding this comment

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

https://chromium-review.googlesource.com/c/chromium/src/+/5953705 is appending the extra styles for image-pair only if layered capture is in use. Did you mean to do the same here as well? No need to override the existing styles in image-pair in flat capture mode.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea, but we haven't resolved yet on "when are we in capture mode". So currently the capture mode spec changes assume that we're in that mode.

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm ok. Then maybe a link to the issue saying this is tentative is good enough.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's already there in the overview...

Copy link
Collaborator Author

@noamr noamr left a comment

Choose a reason for hiding this comment

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

Revised box-sizing thing to only apply to the width/height rather than to the capture.

1. Append the [=string/concatenate|concatentation=] of « `"::view-transition-group("`, |transitionName|, `") {"`, |style| , `"}"` » to the constructed user-agent stylesheet.
1. Let (|oldContentWidth|, |oldContentHeight|) be (|capturedElement|'s [=captured element/old width=], |capturedElement|'s [=captured element/old height=]) if |capturedElement|'s [=old box properties=] is null, otherwise |capturedElement|'s [=old box properties=]'s [=layered box properties/content box=]'s size.
1. Let (|newContentWidth|, |newContentHeight|) be (|width|, |height|) if [=new box properties=] is null, otherwise |capturedElement|'s [=new box properties=]'s [=layered box properties/content box=]'s size.
1. Append the next string (with replaced variables) to the user agent stylesheet:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's already there in the overview...

@noamr noamr merged commit 02eb632 into w3c:main Nov 5, 2024
1 check passed
@noamr noamr deleted the vt2-capture-mode-initial branch November 6, 2024 09:28
noamr added a commit to noamr/csswg-drafts that referenced this pull request Nov 18, 2024
noamr added a commit that referenced this pull request Nov 18, 2024
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-2] Optionally capture some properties (e.g. opacity/border) as style instead of snapshot
2 participants