Commit 7c2a0da2 authored by Aleks Totic's avatar Aleks Totic Committed by Commit Bot

[LayoutNG] NGPhysicalBoxFragment::ScrollableOverflow implementation

Bug: 728378
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: Iea3a95e237792af3d1f99dc23e8b68b3ce10c60d
Reviewed-on: https://chromium-review.googlesource.com/1071088
Commit-Queue: Aleks Totic <atotic@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561645}
parent c34f2886
<!doctype html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<style>
#container {
overflow: auto;
width: 200px;
height: 100px;
font: 20px Ahem;
outline: blue solid 1px;
}
#target {
padding-bottom: 200px;
background: yellow;
}
</style>
<p>Overflow of inline block descendant.</p>
<!--
#target is inside a linebox, and its scroll overflow
propagates to container.
-->
<div id="container">A<span id="outer"><span id="target" class=padding>T</span></span>Z<br>2</div>
<script>
var container = document.querySelector('#container');
var target = document.querySelector('#target');
test(function() {
var targetStyle = window.getComputedStyle(target);
assert_equals(container.scrollHeight,
parseInt(targetStyle.fontSize) + parseInt(targetStyle.paddingBottom),
"vertical");
}, "overflow for inline block descendant with padding");
</script>
...@@ -101,6 +101,31 @@ LayoutRect NGPhysicalBoxFragment::OverflowClipRect( ...@@ -101,6 +101,31 @@ LayoutRect NGPhysicalBoxFragment::OverflowClipRect(
return box->OverflowClipRect(location, overlay_scrollbar_clip_behavior); return box->OverflowClipRect(location, overlay_scrollbar_clip_behavior);
} }
NGPhysicalOffsetRect NGPhysicalBoxFragment::ScrollableOverflow() const {
DCHECK(GetLayoutObject());
LayoutObject* layout_object = GetLayoutObject();
if (layout_object->IsBox()) {
if (HasOverflowClip())
return NGPhysicalOffsetRect({}, Size());
// Legacy is the source of truth for overflow
return NGPhysicalOffsetRect(
ToLayoutBox(layout_object)->LayoutOverflowRect());
} else if (layout_object->IsLayoutInline()) {
// Inline overflow is a union of child overflows.
NGPhysicalOffsetRect overflow({}, Size());
for (const auto& child_fragment : Children()) {
NGPhysicalOffsetRect child_overflow =
child_fragment->ScrollableOverflow();
child_overflow.offset += child_fragment->Offset();
overflow.Unite(child_overflow);
}
return overflow;
} else {
NOTREACHED();
}
return NGPhysicalOffsetRect({}, Size());
}
IntSize NGPhysicalBoxFragment::ScrolledContentOffset() const { IntSize NGPhysicalBoxFragment::ScrolledContentOffset() const {
DCHECK(GetLayoutObject() && GetLayoutObject()->IsBox()); DCHECK(GetLayoutObject() && GetLayoutObject()->IsBox());
const LayoutBox* box = ToLayoutBox(GetLayoutObject()); const LayoutBox* box = ToLayoutBox(GetLayoutObject());
......
...@@ -42,6 +42,8 @@ class CORE_EXPORT NGPhysicalBoxFragment final ...@@ -42,6 +42,8 @@ class CORE_EXPORT NGPhysicalBoxFragment final
bool HasOverflowClip() const; bool HasOverflowClip() const;
bool ShouldClipOverflow() const; bool ShouldClipOverflow() const;
NGPhysicalOffsetRect ScrollableOverflow() const;
// TODO(layout-dev): These three methods delegate to legacy layout for now, // TODO(layout-dev): These three methods delegate to legacy layout for now,
// update them to use LayoutNG based overflow information from the fragment // update them to use LayoutNG based overflow information from the fragment
// and change them to use NG geometry types once LayoutNG supports overflow. // and change them to use NG geometry types once LayoutNG supports overflow.
......
...@@ -331,7 +331,7 @@ NGPhysicalOffsetRect NGPhysicalFragment::VisualRectWithContents() const { ...@@ -331,7 +331,7 @@ NGPhysicalOffsetRect NGPhysicalFragment::VisualRectWithContents() const {
NGPhysicalOffsetRect NGPhysicalFragment::ScrollableOverflow() const { NGPhysicalOffsetRect NGPhysicalFragment::ScrollableOverflow() const {
switch (Type()) { switch (Type()) {
case NGPhysicalFragment::kFragmentBox: case NGPhysicalFragment::kFragmentBox:
return {{}, Size()}; return ToNGPhysicalBoxFragment(*this).ScrollableOverflow();
case NGPhysicalFragment::kFragmentText: case NGPhysicalFragment::kFragmentText:
return {{}, Size()}; return {{}, Size()};
case NGPhysicalFragment::kFragmentLineBox: case NGPhysicalFragment::kFragmentLineBox:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment