Commit eefd9868 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Update scrollbar sizes after layout.

At least when using mock scrollbars from web tests (and maybe there are
real use cases too?), NeedsScrollbarReconstruction() will return true
after layout, which will make us remove the current scrollbars. Legacy
layout will re-lay out and eventually end up with updating the scrollbar
rectangles. NG cannot re-lay out from
PaintLayerScrollableArea::UpdateAfterLayout() like legacy does, but we
do need to update the scrollbar rectangles anyway. NG has its own
scrollbar size change detection mechanism, but in this particular case,
the scrollbars would have the exact same size with the default skin and
with the mock scrollbars, so no change would be detected, and there'd be
no re-layout, and no call to UpdateScrollDimensions().

Without this fix, scrollbars/rtl/overflow-scroll-rtl.html
would fail with
https://chromium-review.googlesource.com/c/chromium/src/+/1297367

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I15e159e0c26ab9fe8469ae8ad2c0af0dabe7417b
Reviewed-on: https://chromium-review.googlesource.com/c/1309741Reviewed-by: default avatarStefan Zager <szager@chromium.org>
Reviewed-by: default avatarAleks Totic <atotic@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605116}
parent 4e416906
<!DOCTYPE html>
<style>body { overflow:hidden; }</style>
<p>The scrollable container below should not appear to be scrollable.</p>
<div id="child" style="display:none; overflow:scroll; width:200px; height:200px;">
<div style="box-sizing:border-box; border:solid; width:100%; height:100%;"></div>
</div>
<script>
onload = ()=> {
if (!window.internals)
return;
internals.settings.setMockScrollbarsEnabled(true);
child.style.display = "block";
}
</script>
<!DOCTYPE html>
<style>body { overflow:hidden; }</style>
<p>The scrollable container below should not appear to be scrollable.</p>
<div style="overflow:scroll; width:200px; height:200px;">
<div style="box-sizing:border-box; border:solid; width:100%; height:100%;"></div>
</div>
<script>
onload = ()=> {
if (!window.internals)
return;
internals.settings.setMockScrollbarsEnabled(true);
}
</script>
......@@ -975,9 +975,13 @@ void PaintLayerScrollableArea::UpdateAfterLayout() {
!GetLayoutBox()->IsHorizontalWritingMode())) {
GetLayoutBox()->SetPreferredLogicalWidthsDirty();
}
// If the box is managed by LayoutNG, don't go here. We don't want to
// re-enter the NG layout algorithm for this box from here.
if (!IsManagedByLayoutNG(*GetLayoutBox())) {
if (IsManagedByLayoutNG(*GetLayoutBox())) {
// If the box is managed by LayoutNG, don't go here. We don't want to
// re-enter the NG layout algorithm for this box from here. Just update
// the rectangles, in case scrollbars were added or removed. LayoutNG
// has its own scrollbar change detection mechanism.
UpdateScrollDimensions();
} else {
if (PreventRelayoutScope::RelayoutIsPrevented()) {
// We're not doing re-layout right now, but we still want to
// add the scrollbar to the logical width now, to facilitate parent
......
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