Commit f3218e00 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

blink: adjusts overflow-clip-margin value

It should only be set if overflow: clip is specified
along both axis.

BUG=1087667
TEST=StyleAdjusterTest.AdjustOverflow

Change-Id: I3cddaf8b1b6e5041759762284f150f28b7b7662a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2463749
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817211}
parent a2c6d660
......@@ -715,6 +715,13 @@ void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state,
style.OverflowY() != EOverflow::kVisible)
AdjustOverflow(style);
// overflow-clip-margin only applies if 'overflow: clip' is set along both
// axis.
if (style.OverflowX() != EOverflow::kClip ||
style.OverflowY() != EOverflow::kClip) {
style.SetOverflowClipMargin(LayoutUnit());
}
if (StopPropagateTextDecorations(style, element))
style.ClearAppliedTextDecorations();
else
......
......@@ -114,13 +114,20 @@ TEST_F(StyleAdjusterTest, AdjustOverflow) {
ScopedOverflowClipForTest overflow_clip_feature_enabler(true);
GetDocument().SetBaseURLOverride(KURL("http://test.com"));
SetBodyInnerHTML(R"HTML(
<div id='clipauto' style='overflow-x: clip; overflow-y: auto;'>
<div id='autoclip' style='overflow-x: auto; overflow-y: clip;'>
<div id='clipclip' style='overflow-x: clip; overflow-y: clip;'>
<div id='visclip' style='overflow-x: visible; overflow-y: clip;'>
<div id='clipvis' style='overflow-x: clip; overflow-y: visible;'>
<div id='hiddenvis' style='overflow-x: hidden; overflow-y: visible;'>
<div id='vishidden' style='overflow-x: visible; overflow-y: hidden;'>
<div id='clipauto' style='overflow-x: clip; overflow-y: auto;
overflow-clip-margin: 1px;'>
<div id='autoclip' style='overflow-x: auto; overflow-y: clip;
overflow-clip-margin: 1px;'>
<div id='clipclip' style='overflow-x: clip; overflow-y: clip;
overflow-clip-margin: 1px;'>
<div id='visclip' style='overflow-x: visible; overflow-y: clip;
overflow-clip-margin: 1px;'>
<div id='clipvis' style='overflow-x: clip; overflow-y: visible;
overflow-clip-margin: 1px;'>
<div id='hiddenvis' style='overflow-x: hidden; overflow-y: visible;
overflow-clip-margin: 1px;'>
<div id='vishidden' style='overflow-x: visible; overflow-y: hidden;
overflow-clip-margin: 1px;'>
</div>
)HTML");
UpdateAllLifecyclePhasesForTest();
......@@ -129,36 +136,43 @@ TEST_F(StyleAdjusterTest, AdjustOverflow) {
ASSERT_TRUE(target);
EXPECT_EQ(EOverflow::kHidden, target->GetComputedStyle()->OverflowX());
EXPECT_EQ(EOverflow::kAuto, target->GetComputedStyle()->OverflowY());
EXPECT_EQ(LayoutUnit(), target->GetComputedStyle()->OverflowClipMargin());
target = GetDocument().getElementById("autoclip");
ASSERT_TRUE(target);
EXPECT_EQ(EOverflow::kAuto, target->GetComputedStyle()->OverflowX());
EXPECT_EQ(EOverflow::kHidden, target->GetComputedStyle()->OverflowY());
EXPECT_EQ(LayoutUnit(), target->GetComputedStyle()->OverflowClipMargin());
target = GetDocument().getElementById("clipclip");
ASSERT_TRUE(target);
EXPECT_EQ(EOverflow::kClip, target->GetComputedStyle()->OverflowX());
EXPECT_EQ(EOverflow::kClip, target->GetComputedStyle()->OverflowY());
EXPECT_EQ(LayoutUnit(1), target->GetComputedStyle()->OverflowClipMargin());
target = GetDocument().getElementById("visclip");
ASSERT_TRUE(target);
EXPECT_EQ(EOverflow::kVisible, target->GetComputedStyle()->OverflowX());
EXPECT_EQ(EOverflow::kClip, target->GetComputedStyle()->OverflowY());
EXPECT_EQ(LayoutUnit(), target->GetComputedStyle()->OverflowClipMargin());
target = GetDocument().getElementById("clipvis");
ASSERT_TRUE(target);
EXPECT_EQ(EOverflow::kClip, target->GetComputedStyle()->OverflowX());
EXPECT_EQ(EOverflow::kVisible, target->GetComputedStyle()->OverflowY());
EXPECT_EQ(LayoutUnit(), target->GetComputedStyle()->OverflowClipMargin());
target = GetDocument().getElementById("vishidden");
ASSERT_TRUE(target);
EXPECT_EQ(EOverflow::kAuto, target->GetComputedStyle()->OverflowX());
EXPECT_EQ(EOverflow::kHidden, target->GetComputedStyle()->OverflowY());
EXPECT_EQ(LayoutUnit(), target->GetComputedStyle()->OverflowClipMargin());
target = GetDocument().getElementById("hiddenvis");
ASSERT_TRUE(target);
EXPECT_EQ(EOverflow::kHidden, target->GetComputedStyle()->OverflowX());
EXPECT_EQ(EOverflow::kAuto, target->GetComputedStyle()->OverflowY());
EXPECT_EQ(LayoutUnit(), target->GetComputedStyle()->OverflowClipMargin());
}
TEST_F(StyleAdjusterTest, SetListenerForContentEditableArea) {
......
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