Commit afbbcc99 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Some changes for LayoutBox VisualOverflowRect unit tests

- Test SelfVisualOverflowRect and VisualOverflowRect
  instead of LocalVisualRect and VisualOverflowRect to be more focus on
  visual overflow rects. LocalVisualRect is less interesting than
  SelfVisualOverflowRect because the former is almost directly based on
  the latter and the latter is more used.

- Enable the tests for CompositeAfterPaint

- Add a test for overflow: clip

Change-Id: I50c15a28114b5a3537b205245ac18bcf84a869d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2458868Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814905}
parent 4025b5e9
......@@ -396,78 +396,123 @@ TEST_P(LayoutBoxTest, ControlClip) {
EXPECT_EQ(PhysicalRect(2, 2, 96, 46), target->ClippingRect(PhysicalOffset()));
}
TEST_P(LayoutBoxTest, LocalVisualRectWithMask) {
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return;
TEST_P(LayoutBoxTest, VisualOverflowRectWithMask) {
SetBodyInnerHTML(R"HTML(
<div id='target' style='-webkit-mask-image: url(#a);
width: 100px; height: 100px; background: blue'>
<div style='width: 300px; height: 10px; background: green'></div>
width: 100px; height: 100px; baground: blue'>
<div style='width: 300px; height: 300px; background: green'></div>
</div>
)HTML");
LayoutBox* target = GetLayoutBoxByElementId("target");
EXPECT_TRUE(target->HasMask());
EXPECT_EQ(PhysicalRect(0, 0, 100, 100), target->LocalVisualRect());
EXPECT_FALSE(target->IsScrollContainer());
EXPECT_FALSE(target->ShouldClipOverflowAlongEitherAxis());
EXPECT_EQ(LayoutRect(0, 0, 100, 100), target->SelfVisualOverflowRect());
EXPECT_EQ(LayoutRect(0, 0, 100, 100), target->VisualOverflowRect());
}
TEST_P(LayoutBoxTest, LocalVisualRectWithMaskAndOverflowClip) {
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return;
TEST_P(LayoutBoxTest, VisualOverflowRectWithMaskAndOverflowHidden) {
SetBodyInnerHTML(R"HTML(
<div id='target' style='-webkit-mask-image: url(#a); overflow: hidden;
width: 100px; height: 100px; background: blue'>
<div style='width: 300px; height: 10px; background: green'></div>
<div style='width: 300px; height: 300px; background: green'></div>
</div>
)HTML");
LayoutBox* target = GetLayoutBoxByElementId("target");
EXPECT_TRUE(target->HasMask());
EXPECT_TRUE(target->IsScrollContainer());
EXPECT_EQ(PhysicalRect(0, 0, 100, 100), target->LocalVisualRect());
EXPECT_TRUE(target->ShouldClipOverflowAlongBothAxis());
EXPECT_EQ(LayoutRect(0, 0, 100, 100), target->SelfVisualOverflowRect());
EXPECT_EQ(LayoutRect(0, 0, 100, 100), target->VisualOverflowRect());
}
TEST_P(LayoutBoxTest, LocalVisualRectWithMaskWithOutset) {
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return;
TEST_P(LayoutBoxTest, VisualOverflowRectWithMaskWithOutset) {
SetBodyInnerHTML(R"HTML(
<div id='target' style='-webkit-mask-box-image-source: url(#a);
-webkit-mask-box-image-outset: 10px 20px;
width: 100px; height: 100px; background: blue'>
<div style='width: 300px; height: 10px; background: green'></div>
<div style='width: 300px; height: 300px; background: green'></div>
</div>
)HTML");
LayoutBox* target = GetLayoutBoxByElementId("target");
EXPECT_TRUE(target->HasMask());
EXPECT_EQ(PhysicalRect(-20, -10, 140, 120), target->LocalVisualRect());
EXPECT_FALSE(target->IsScrollContainer());
EXPECT_FALSE(target->ShouldClipOverflowAlongEitherAxis());
EXPECT_EQ(LayoutRect(-20, -10, 140, 120), target->SelfVisualOverflowRect());
EXPECT_EQ(LayoutRect(-20, -10, 140, 120), target->VisualOverflowRect());
}
TEST_P(LayoutBoxTest, LocalVisualRectWithMaskWithOutsetAndOverflowClip) {
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return;
TEST_P(LayoutBoxTest, VisualOverflowRectWithMaskWithOutsetAndOverflowHidden) {
SetBodyInnerHTML(R"HTML(
<div id='target' style='-webkit-mask-box-image-source: url(#a);
-webkit-mask-box-image-outset: 10px 20px; overflow: hidden;
width: 100px; height: 100px; background: blue'>
<div style='width: 300px; height: 10px; background: green'></div>
<div style='width: 300px; height: 300px; background: green'></div>
</div>
)HTML");
LayoutBox* target = GetLayoutBoxByElementId("target");
EXPECT_TRUE(target->HasMask());
EXPECT_TRUE(target->IsScrollContainer());
EXPECT_EQ(PhysicalRect(-20, -10, 140, 120), target->LocalVisualRect());
EXPECT_TRUE(target->ShouldClipOverflowAlongBothAxis());
EXPECT_EQ(LayoutRect(-20, -10, 140, 120), target->SelfVisualOverflowRect());
EXPECT_EQ(LayoutRect(-20, -10, 140, 120), target->VisualOverflowRect());
}
TEST_P(LayoutBoxTest, VisualOverflowRectOverflowHidden) {
SetBodyInnerHTML(R"HTML(
<div id='target' style='overflow: hidden;
width: 100px; height: 100px; background: blue'>
<div style='width: 300px; height: 300px; background: green'></div>
</div>
)HTML");
LayoutBox* target = GetLayoutBoxByElementId("target");
EXPECT_TRUE(target->IsScrollContainer());
EXPECT_TRUE(target->ShouldClipOverflowAlongBothAxis());
EXPECT_EQ(LayoutRect(0, 0, 100, 100), target->SelfVisualOverflowRect());
EXPECT_EQ(LayoutRect(0, 0, 100, 100), target->VisualOverflowRect());
}
TEST_P(LayoutBoxTest, VisualOverflowRectOverflowClip) {
SetBodyInnerHTML(R"HTML(
<style>
.parent { width: 100px; height: 50px; }
.child { width: 300px; height: 300px; }
</style>
<div id="clip" style="overflow: clip" class="parent">
<div class="child"></div>
</div>
<div id="clip-x" style="overflow-x: clip" class="parent">
<div class="child"></div>
</div>
<div id="clip-y" style="overflow-y: clip" class="parent">
<div class="child"></div>
</div>
)HTML");
LayoutBox* clip = GetLayoutBoxByElementId("clip");
EXPECT_FALSE(clip->IsScrollContainer());
EXPECT_TRUE(clip->ShouldClipOverflowAlongBothAxis());
EXPECT_EQ(LayoutRect(0, 0, 100, 50), clip->SelfVisualOverflowRect());
EXPECT_EQ(LayoutRect(0, 0, 100, 50), clip->VisualOverflowRect());
LayoutBox* clip_x = GetLayoutBoxByElementId("clip-x");
EXPECT_FALSE(clip_x->IsScrollContainer());
EXPECT_EQ(kOverflowClipX, clip_x->GetOverflowClipAxes());
EXPECT_EQ(LayoutRect(0, 0, 100, 50), clip_x->SelfVisualOverflowRect());
EXPECT_EQ(LayoutRect(0, 0, 100, 300), clip_x->VisualOverflowRect());
LayoutBox* clip_y = GetLayoutBoxByElementId("clip-y");
EXPECT_FALSE(clip_y->IsScrollContainer());
EXPECT_EQ(kOverflowClipY, clip_y->GetOverflowClipAxes());
EXPECT_EQ(LayoutRect(0, 0, 100, 50), clip_y->SelfVisualOverflowRect());
EXPECT_EQ(LayoutRect(0, 0, 300, 50), clip_y->VisualOverflowRect());
}
TEST_P(LayoutBoxTest, ContentsVisualOverflowPropagation) {
SetBodyInnerHTML(R"HTML(
<style>
......
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