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

Improve clipping and positioning documentation #2892

Merged
merged 1 commit into from Jul 17, 2018

Conversation

@mrobinson
Copy link
Member

mrobinson commented Jul 13, 2018

The new documentation gives a more complete and up-to-date picture of
WebRender's clipping and positioning architecture.


This change is Reviewable

@leeoniya
Copy link

leeoniya commented Jul 13, 2018

is anything mentioned these issues still relevant for Ideas for the Future?

#2551

...when we separate the concept of
reference frames and stacking contexts.

#2736

@mrobinson
Copy link
Member Author

mrobinson commented Jul 13, 2018

@leeoniya Stacking contexts and reference frames are now two separate concepts after #2756. The idea of applying clips to stacking contexts was implemented in #2600. We are still working out exactly how flexible Gecko requires the display list to be.

@staktrace
Copy link
Contributor

staktrace commented Jul 13, 2018

Thanks for writing this documentation! I read through it and it clarified a few things for me. I agree that differentiating between the three kinds of things in the API would be good and make things more robust. I was looking at the gecko side code and it seems like every clip node that we create with a parent has what is effectively a spatial node as the parent (i.e. it's the WrClipId corresponding to a scroll frame, a reference frame, or a sticky node) with one exception: here we create a clip node with a mask, and then use that clip code as the parent for other clip nodes that might get defined on items nested inside the mask.

If we can do this in a different way (e.g. including the mask in the clip chain of the nested items) then that would clean this up and we should be able to separate WrClipId from a WrSpatialNodeId on the gecko side. That would be a good first step towards a better API, I think.

Copy link
Member

kvark left a comment

Nice writeup, thank you! I got a few questions/concerns.

# Original Design

To understand the current design for clipping and positioning (transformations
and scrolling) in WebRender if can be useful to have a little background about

This comment has been minimized.

@kvark

kvark Jul 13, 2018

Member

"if" typo

intersecting content from outside the scroll area.
3. Items in the same scrolling root, clipped by different clips one or more of
which are defined outside the scrolling root itself.
4. Items which are clipped by some clips in the hierarchy, but not others ie

This comment has been minimized.

@kvark

kvark Jul 13, 2018

Member

"ie"?

elements. Every display list item has an assigned `ClipChain` which
specifies what `ClipNodes` are applied to that item.

The `SpatialNode` of the clips applied to each item are completely independent of

This comment has been minimized.

@kvark

kvark Jul 13, 2018

Member

SpatialNodes

This comment has been minimized.

@mrobinson

mrobinson Jul 16, 2018

Author Member

I changed this to make the inflection of the noun match the subject.


One holdover from the previous design is that both `ClipNode` and `SpatialNodes`
have a parent node, which is either a `SpatialNode` or a `ClipNode`. From this
node WebRender can determine both a parent `ClipNode` and a parent `SpatialNode`

This comment has been minimized.

@kvark

kvark Jul 13, 2018

Member

This is confusing me quite a bit. Why do we want to support the ClipNode being a parent, ever?

This comment has been minimized.

@mrobinson

mrobinson Jul 16, 2018

Author Member

Nowadays there is no reason this has to be the case, but consider that in the past the only way to combine clip nodes was to have them be part of the ancestry in the ClipScrollTree. With the ClipChain API and the fact that an item can have both a positioning node and clip node assigned, it isn't strictly necessary. Once both Gecko and Servo are using the ClipChain API for all clips and never using ClipNodes as positioning nodes, we can fix this for good.

This comment has been minimized.

@kvark

kvark Jul 16, 2018

Member

Thank you for explanation! @staktrace do you know if there is an issue to file/track for this on Gecko side?

This comment has been minimized.

@staktrace

staktrace Jul 16, 2018

Contributor

@kvark I don't believe there is; please feel free to file one

This comment has been minimized.

# Clipping and Positioning in the Display List

Each non-structural WebRender display list item has
* A `ClipId` of a `SpatialNode` or `ClipNode` for positioning

This comment has been minimized.

@kvark

kvark Jul 13, 2018

Member

a clip id of a clip node for positioning - this rings a bell for me

to the evolutionary nature of the design. The general trend is that the display
list gradually moves toward the internal representation. The most important of
these incongruities is that while `ClipNodes`, sticky frames, and scroll frames
are defined and simply return a ClipId, reference frames return a ClipId, but

This comment has been minimized.

@kvark

kvark Jul 13, 2018

Member

nit: codify ClipId

This comment has been minimized.

@mrobinson

mrobinson Jul 16, 2018

Author Member

Fixed.

## Converting `ClipId` to global `ClipScrollTree` indices

WebRender must access `ClipNodes` and `SpatialNodes` quite a bit when building
scenes and frames, so it tries to convert `CiipIds`, which are already

This comment has been minimized.

@kvark

kvark Jul 13, 2018

Member

"CiipIds"

This comment has been minimized.

@mrobinson

mrobinson Jul 16, 2018

Author Member

Fixed.


WebRender must access `ClipNodes` and `SpatialNodes` quite a bit when building
scenes and frames, so it tries to convert `CiipIds`, which are already
per-pipeline indices, to global scene-wide indices. Internally this a

This comment has been minimized.

@kvark

kvark Jul 13, 2018

Member

a verb is missing? ("this a")

This comment has been minimized.

@mrobinson

mrobinson Jul 16, 2018

Author Member

Fixed.

scene-wide `ClipScrollTree`.

Nodes are added to their respective arrays sequentially as the display list is
processed during "flattening." When encountering an iframe, the

This comment has been minimized.

@kvark

kvark Jul 13, 2018

Member

let's not include the "." in quote marks

This comment has been minimized.

@mrobinson

mrobinson Jul 16, 2018

Author Member

So weirdly this is the style in American English, which I admit is bizarre. Since the rest of the document is written in American English though, maybe it makes sense to be consistent here.

@gw3583
Copy link
Collaborator

gw3583 commented Jul 16, 2018

This will be great to have updated, thanks!

Copy link
Member Author

mrobinson left a comment

Thanks for the review! I've updated the PR fixing the issues you mentioned and leaving comments in others.

# Original Design

To understand the current design for clipping and positioning (transformations
and scrolling) in WebRender if can be useful to have a little background about

This comment has been minimized.

@mrobinson

mrobinson Jul 16, 2018

Author Member

Fixed.

elements. Every display list item has an assigned `ClipChain` which
specifies what `ClipNodes` are applied to that item.

The `SpatialNode` of the clips applied to each item are completely independent of

This comment has been minimized.

@mrobinson

mrobinson Jul 16, 2018

Author Member

I changed this to make the inflection of the noun match the subject.


One holdover from the previous design is that both `ClipNode` and `SpatialNodes`
have a parent node, which is either a `SpatialNode` or a `ClipNode`. From this
node WebRender can determine both a parent `ClipNode` and a parent `SpatialNode`

This comment has been minimized.

@mrobinson

mrobinson Jul 16, 2018

Author Member

Nowadays there is no reason this has to be the case, but consider that in the past the only way to combine clip nodes was to have them be part of the ancestry in the ClipScrollTree. With the ClipChain API and the fact that an item can have both a positioning node and clip node assigned, it isn't strictly necessary. Once both Gecko and Servo are using the ClipChain API for all clips and never using ClipNodes as positioning nodes, we can fix this for good.

to the evolutionary nature of the design. The general trend is that the display
list gradually moves toward the internal representation. The most important of
these incongruities is that while `ClipNodes`, sticky frames, and scroll frames
are defined and simply return a ClipId, reference frames return a ClipId, but

This comment has been minimized.

@mrobinson

mrobinson Jul 16, 2018

Author Member

Fixed.

## Converting `ClipId` to global `ClipScrollTree` indices

WebRender must access `ClipNodes` and `SpatialNodes` quite a bit when building
scenes and frames, so it tries to convert `CiipIds`, which are already

This comment has been minimized.

@mrobinson

mrobinson Jul 16, 2018

Author Member

Fixed.


WebRender must access `ClipNodes` and `SpatialNodes` quite a bit when building
scenes and frames, so it tries to convert `CiipIds`, which are already
per-pipeline indices, to global scene-wide indices. Internally this a

This comment has been minimized.

@mrobinson

mrobinson Jul 16, 2018

Author Member

Fixed.

scene-wide `ClipScrollTree`.

Nodes are added to their respective arrays sequentially as the display list is
processed during "flattening." When encountering an iframe, the

This comment has been minimized.

@mrobinson

mrobinson Jul 16, 2018

Author Member

So weirdly this is the style in American English, which I admit is bizarre. Since the rest of the document is written in American English though, maybe it makes sense to be consistent here.

The new documentation gives a more complete and up-to-date picture of
WebRender's clipping and positioning architecture.
@mrobinson mrobinson force-pushed the mrobinson:improve-doc branch from 8592ad5 to 8ad0431 Jul 16, 2018
@kvark
kvark approved these changes Jul 16, 2018
@kvark
Copy link
Member

kvark commented Jul 16, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Jul 16, 2018

📌 Commit 8ad0431 has been approved by kvark

@bors-servo
Copy link
Contributor

bors-servo commented Jul 16, 2018

Testing commit 8ad0431 with merge 1505a50...

bors-servo added a commit that referenced this pull request Jul 16, 2018
Improve clipping and positioning documentation

The new documentation gives a more complete and up-to-date picture of
WebRender's clipping and positioning architecture.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2892)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 17, 2018

💥 Test timed out

@gw3583
Copy link
Collaborator

gw3583 commented Jul 17, 2018

@bors-servo retry

@bors-servo
Copy link
Contributor

bors-servo commented Jul 17, 2018

Testing commit 8ad0431 with merge de0ef91...

bors-servo added a commit that referenced this pull request Jul 17, 2018
Improve clipping and positioning documentation

The new documentation gives a more complete and up-to-date picture of
WebRender's clipping and positioning architecture.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2892)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 17, 2018

☀️ Test successful - status-appveyor, status-taskcluster
Approved by: kvark
Pushing de0ef91 to master...

@bors-servo bors-servo merged commit 8ad0431 into servo:master Jul 17, 2018
3 checks passed
3 checks passed
Taskcluster (pull_request) TaskGroup: success
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
@mrobinson mrobinson deleted the mrobinson:improve-doc branch Jul 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.