Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upStickySideConstraint needs documentation #1912
Comments
|
@staktrace Thanks for the feedback and sorry for the pain! My plan for today is to:
|
|
@mrobinson Thanks! I was also thinking about this some more yesterday and I realized that we need to expose the 0 value as part of the API. The reason is that when gecko generates the display list it can do so at a scroll offset that's not zero. In those cases, the "top" sticky item for example might need to allow a negative offset in order for the item to positioned properly during async scrolling. A more concrete example:
I think this is mostly an artifact of how we did the integration, because WR internally assumes all the inputs are with zero scroll offsets but in gecko we can't actually do that easily, so we draw things with scroll offsets applied. However async scrolling can still happen and make the scroll position "negative". If you recall there was some other place where we were clamping the scroll offset in WR that needed to be taken out to solve this same class of problems. I think the same thing needs to be done to the sticky API. |
|
So in addition to any naming/documentation I think the API needs to change like so: staktrace@866096d |
Allow gecko to provide the already-applied sticky offset to WR Fixes the remaining issue in #1912. r? @mrobinson <!-- 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/1977) <!-- Reviewable:end -->
|
@staktrace I guess we can close this now? |
|
Yup! |
It appears that I've been laboring under a misunderstanding about how
StickySideConstraintis supposed to work. Some documentation here would probably have saved me a couple of weeks of wasted time (and will save me from wasting more time). In particular, the waymax_offsetis used makes no sense to me. Here's my current understanding based on the code incalculate_sticky_offset:This line:
seems to be computing the position the item would be in when "stuck", relative to
sticky_rect's current y-offset. And this line:then tries to clamp the item so that it doesn't go outside the container it's supposed to be inside. However it's not clear to me why the min bound of the clamp range is 0 because the item might have a normal position somewhere further down inside the sticky container.
Looking at the "bottom" case we have:
which is a roundabout way of writing
sticky_offset.y = (viewport_rect.max_y() - info.margin - sticky_rect.size.height) - sticky_rect.min_y()which is again the position the item would be in when "stuck", relative tosticky_rect's current y-offset. But then once we've done that, the clamping should be exactly the same as in the previous case, but for some reason it's inverted:and this makes no sense to me. I must be misunderstanding something but I can't find an interpretation of
max_offsetthat makes this code make any sense.@mrobinson can you please document this API so that users can build a model of what's supposed to happen and what needs to be passed in? Thanks!