Commit 0e3be792 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[PE] Detect fragment clip change

Bug: 854783
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I7ae7d241596f8eedce26ff43b2ee9ff584b911ff
Reviewed-on: https://chromium-review.googlesource.com/1123108
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572365}
parent 98c28a6f
......@@ -2189,20 +2189,27 @@ void PaintPropertyTreeBuilder::CreateFragmentContextsInFlowThread(
new_fragment_contexts.push_back(
ContextForFragment(fragment_clip, logical_top_in_flow_thread));
base::Optional<LayoutUnit> old_logical_top_in_flow_thread;
if (current_fragment_data) {
if (const auto* old_fragment = current_fragment_data->NextFragment())
old_logical_top_in_flow_thread = old_fragment->LogicalTopInFlowThread();
if (!current_fragment_data->NextFragment())
fragments_changed = true;
current_fragment_data = &current_fragment_data->EnsureNextFragment();
} else {
current_fragment_data = &object_.GetMutableForPainting().FirstFragment();
old_logical_top_in_flow_thread =
current_fragment_data->LogicalTopInFlowThread();
}
if (!old_logical_top_in_flow_thread ||
*old_logical_top_in_flow_thread != logical_top_in_flow_thread)
fragments_changed = true;
fragments_changed |= logical_top_in_flow_thread !=
current_fragment_data->LogicalTopInFlowThread();
if (!fragments_changed) {
const ClipPaintPropertyNode* old_fragment_clip = nullptr;
if (const auto* properties = current_fragment_data->PaintProperties())
old_fragment_clip = properties->FragmentClip();
const base::Optional<LayoutRect>& new_fragment_clip =
new_fragment_contexts.back().fragment_clip;
fragments_changed =
!!old_fragment_clip != !!new_fragment_clip ||
(old_fragment_clip && new_fragment_clip &&
old_fragment_clip->ClipRect() != ToClipRect(*new_fragment_clip));
}
InitFragmentPaintProperties(
*current_fragment_data,
......
......@@ -3591,25 +3591,6 @@ TEST_P(PaintPropertyTreeBuilderTest, MainThreadScrollReasonsWithoutScrolling) {
nullptr);
}
static unsigned NumFragments(const LayoutObject* obj) {
unsigned count = 0;
auto* fragment = &obj->FirstFragment();
while (fragment) {
count++;
fragment = fragment->NextFragment();
}
return count;
}
static const FragmentData& FragmentAt(const LayoutObject* obj, unsigned count) {
auto* fragment = &obj->FirstFragment();
while (count > 0) {
count--;
fragment = fragment->NextFragment();
}
return *fragment;
}
TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetsUnderMultiColumnScrolled) {
SetBodyInnerHTML(R"HTML(
<!doctype HTML>
......
......@@ -40,6 +40,26 @@ class PaintPropertyTreeBuilderTest : public PaintControllerPaintTest {
const ObjectPaintProperties* PaintPropertiesForElement(const char* name);
static unsigned NumFragments(const LayoutObject* obj) {
unsigned count = 0;
auto* fragment = &obj->FirstFragment();
while (fragment) {
count++;
fragment = fragment->NextFragment();
}
return count;
}
static const FragmentData& FragmentAt(const LayoutObject* obj,
unsigned count) {
auto* fragment = &obj->FirstFragment();
while (count > 0) {
count--;
fragment = fragment->NextFragment();
}
return *fragment;
}
private:
void SetUp() override;
};
......
......@@ -1175,4 +1175,50 @@ TEST_P(PaintPropertyTreeBuilderTest, OmitOverflowClipOnCaretChange) {
EXPECT_FALSE(PaintPropertiesForElement("target")->OverflowClip());
}
TEST_P(PaintPropertyTreeUpdateTest,
FragmentClipUpdateOnMulticolContainerWidthChange) {
SetBodyInnerHTML(R"HTML(
<style>body {margin: 0}</style>
<div id="container" style="width: 100px">
<div id="multicol" style="columns: 2; column-gap: 0; line-height: 500px">
<div><br></div>
<div><br></div>
</div>
</div>
)HTML");
auto* flow_thread = GetLayoutObjectByElementId("multicol")->SlowFirstChild();
ASSERT_EQ(2u, NumFragments(flow_thread));
EXPECT_EQ(50, FragmentAt(flow_thread, 0)
.PaintProperties()
->FragmentClip()
->ClipRect()
.Rect()
.MaxX());
EXPECT_EQ(50, FragmentAt(flow_thread, 1)
.PaintProperties()
->FragmentClip()
->ClipRect()
.Rect()
.X());
GetDocument()
.getElementById("container")
->setAttribute(HTMLNames::styleAttr, "width: 500px");
GetDocument().View()->UpdateAllLifecyclePhases();
ASSERT_EQ(2u, NumFragments(flow_thread));
EXPECT_EQ(250, FragmentAt(flow_thread, 0)
.PaintProperties()
->FragmentClip()
->ClipRect()
.Rect()
.MaxX());
EXPECT_EQ(250, FragmentAt(flow_thread, 1)
.PaintProperties()
->FragmentClip()
->ClipRect()
.Rect()
.X());
}
} // namespace blink
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