0

[carousel] Fix layout parent search for ::scroll-button()

It should be the same as for ::scroll-marker-group, also
this CL updates the debug check accordingly.

Bug: 370067113
Change-Id: I64496acf51b72268cf3d152a78a3e7a4db969d80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6069930
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Auto-Submit: Daniil Sakhapov <sakhapov@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1391591}
This commit is contained in:
Daniil Sakhapov
2024-12-04 11:49:05 +00:00
committed by Chromium LUCI CQ
parent 94b0c619e1
commit 2b516fb13e
3 changed files with 42 additions and 10 deletions
third_party/blink

@ -81,14 +81,13 @@ LayoutObject* LayoutTreeBuilderForElement::ParentLayoutObject() const {
return node_->GetDocument().GetLayoutView();
}
#if DCHECK_IS_ON()
// Box of ::scroll-marker-group is previous/next sibling of
// its originating element, so the parent should be originating element's
// parent.
if (node_->IsScrollMarkerGroupPseudoElement()) {
Element* originating_element =
To<PseudoElement>(node_)->UltimateOriginatingElement();
// Box of ::scroll-marker-group and ::scroll-button is previous/next
// sibling of its originating element, so the parent should be originating
// element's parent.
if (node_->IsScrollMarkerGroupPseudoElement() ||
node_->IsScrollButtonPseudoElement()) {
ContainerNode* parent_element =
LayoutTreeBuilderTraversal::LayoutParent(*originating_element);
LayoutTreeBuilderTraversal::LayoutParent(*node_->parentElement());
DCHECK_EQ(parent_element->GetLayoutObject(), context_.parent);
}
#endif // DCHECK_IS_ON()

@ -94,9 +94,10 @@ LayoutObject* LayoutTreeBuilderTraversal::ParentLayoutObject(const Node& node) {
return node.GetDocument().GetLayoutView();
}
const Node* search_start_node = &node;
// Parent of ::scroll-marker-group should be layout parent of its
// originating element.
if (node.IsScrollMarkerGroupPseudoElement()) {
// Parent of ::scroll-marker-group and ::scroll-button() should be layout
// parent of its originating element.
if (node.IsScrollMarkerGroupPseudoElement() ||
node.IsScrollButtonPseudoElement()) {
search_start_node = node.parentNode();
}
ContainerNode* parent =

@ -0,0 +1,32 @@
<!doctype html>
<title>CSS Overflow Test: ::scroll-button() can be created and removed dynamicaly</title>
<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-buttons">
<link rel="match" href="../reference/ref-filled-green-100px-square.xht">
<style>
#carousel {
overflow: hidden;
width: 100px;
height: 100px;
}
#carousel div {
background: green;
width: 100px;
height: 100px;
}
.scroll-buttons::scroll-button(right) {
content: "r";
}
</style>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div id="carousel">
<div></div>
<div>
<script>
carousel.offsetTop;
carousel.className = "scroll-buttons";
carousel.offsetTop;
carousel.className = "";
</script>