Commit c9a923c3 authored by Aleks Totic's avatar Aleks Totic Committed by Commit Bot

[LayoutNG] bugfix for NG painting in vertical-rl with scrollbars.

This bug occurs when painting NG child inside non-inline vertical-rl parent
with scrollbars.

Root cause is extra scrollbar offset that Paint applies to Legacy painting that
is not needed for NG.

The fix is hacky: NG applies reverse offset.

This fix does not make any additional tests pass or fail.

Bug: 852395
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I7dda2cdbf682485ab30c048987ae683981731886
Reviewed-on: https://chromium-review.googlesource.com/1115863
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571080}
parent 9b40f8ff
<!DOCTYPE html>
<html>
<head>
<title>CSS Writing Modes Test: vertical-rl painting with vertical scrollbar reference</title>
<link rel="author" title="Aleks Totic" href="atotic@chromium.org" />
<style>
#container {
width: 300px;
height: 200px;
border: 1px solid black;
writing-mode: vertical-rl;
overflow: scroll;
background: blue;
}
#target {
width:500px;
}
</style>
<div id="container">
<div id="target"><br></div>
</div>
<!DOCTYPE html>
<html>
<head>
<title>CSS Writing Modes Test: vertical-rl painting with vertical scrollbar</title>
<link rel="author" title="Aleks Totic" href="atotic@chromium.org" />
<link rel="help" href="https://www.w3.org/TR/css-writing-modes-3/#orthogonal-flows" title="7.3 Orthogonal flows" />
<link rel="match" href="./reference/scrollbar-vertical-rl-ref.html" />
<style>
#container {
width: 300px;
height: 200px;
border: 1px solid black;
writing-mode: vertical-rl;
overflow: scroll;
background: red;
}
#target {
width:500px;
background:blue;
}
</style>
</head>
<body>
<div id="container">
<div id="target"><br></div>
</div>
</body>
......@@ -21,6 +21,7 @@
#include "third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h"
#include "third_party/blink/renderer/core/layout/ng/ng_relative_utils.h"
#include "third_party/blink/renderer/core/page/scrolling/root_scroller_util.h"
#include "third_party/blink/renderer/core/paint/adjust_paint_offset_scope.h"
#include "third_party/blink/renderer/core/paint/ng/ng_block_flow_painter.h"
#include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h"
......@@ -293,9 +294,25 @@ void LayoutNGMixin<Base>::InvalidateDisplayItemClients(
template <typename Base>
void LayoutNGMixin<Base>::Paint(const PaintInfo& paint_info,
const LayoutPoint& paint_offset) const {
if (PaintFragment())
NGBlockFlowPainter(*this).Paint(paint_info, paint_offset);
else
if (PaintFragment()) {
LayoutPoint flipped_offset(paint_offset);
// HACK: Legacy paints all FlippedBlocks Elements with an offset that
// is incorrect by VerticalScrollbarWidth. This happens because vertical-rl
// Location() does not include Scrollbar size (but does include border!).
// Paint corrects for incorrect LayoutObject.Location() by applyiing
// scroll transformation to all children of FlippedBlocks().
// See LayoutBox::ScrolledContentOffset() and
// paint_property_tree_builder VisualOffsetFromPaintOffsetRoot() for
// details.
// For NG, we modify paint_offset to correct for this transformation.
if (UNLIKELY(Base::Parent()->HasFlippedBlocksWritingMode() &&
!AdjustPaintOffsetScope::WillUseLegacyLocation(this) &&
Base::Parent()->IsBox())) {
flipped_offset.Move(ToLayoutBox(Base::Parent())->VerticalScrollbarWidth(),
0);
}
NGBlockFlowPainter(*this).Paint(paint_info, flipped_offset);
} else
LayoutBlockFlow::Paint(paint_info, paint_offset);
}
......
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