12021-08-17 Martin Robinson <mrobinson@webkit.org>
2
3 position: sticky with display: inline-block
4 https://bugs.webkit.org/show_bug.cgi?id=224415
5 <rdar://problem/76811968>
6
7 Reviewed by NOBODY (OOPS!).
8
9 Improve sticky positioning applied to inline items. The first improvement is to
10 skip anonymous RenderBlock parents of inline display items when looking for the
11 containing block used to calculate sticky constraints. These anonymous parents
12 are not the containing block that constrains the movement of these kind of stickily
13 positioned items. Instead look for containing block for the anonymous parent,
14 which does limit the scroll boundaries of inline stickily position items.
15
16 Previously, when converting the frame rect from the coordinate space of the stickily
17 positioned item to that of the scrolling container, the code used to apply the offset
18 from the containing block to the scrolling ancestor directly to the frame rect. That
19 doesn't work when the containing block that determines sticky constraints is not the
20 direct containing block of the stickily positioned items (as it is for inlines).
21
22 Instead, the code now just maps the frame rect directly from the item parent to
23 the scrolling ancestor. This simplifies things a bit and allows it to work with
24 inline stickily positioned items.
25
26 Finally, this change adds comments to make it clearer what this method is doing.
27
28 No new tests. This is covered by existing WPT tests. Specifically the following
29 tests are now passing:
30 imported/w3c/web-platform-tests/css/css-position/sticky/position-sticky-hyperlink.html
31 imported/w3c/web-platform-tests/css/css-position/sticky/position-sticky-nested-table.html
32 imported/w3c/web-platform-tests/css/css-position/sticky/position-sticky-table-parts.html
33 imported/w3c/web-platform-tests/css/css-position/sticky/position-sticky-table-th-bottom.html
34 imported/w3c/web-platform-tests/css/css-position/sticky/position-sticky-nested-thead-th.html
35
36 * css/CSSComputedStyleDeclaration.cpp:
37 (WebCore::positionOffsetValue): enclosingClippingBoxForStickyPosition now returns a pair
38 to avoid passing in a pointer. Only look at the first part of the pair here.
39 * rendering/RenderBoxModelObject.cpp:
40 (WebCore::RenderBoxModelObject::computeStickyPositionConstraints const): Modified this method
41 to return a pair in order to avoid dealing with input parameters. This allows simplifying this
42 method, making the code a bit simpler.
43 (WebCore::RenderBoxModelObject::enclosingClippingBoxForStickyPosition const): Deleted.
44 (WebCore::RenderBoxModelObject::computeStickyPositionConstraints const): Make two changes
45 to this method to improve sticky positioning for inline elements. The first change is
46 to be a bit better about finding the appropriate containing block for calculating sticky
47 constraints. The second is to more resiliently move from coordinate systems. In addition,
48 improve the comments for this method to make it clearer what is happening at each step.
49 * rendering/RenderBoxModelObject.h: Updated method declaration.
50