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, ...@@ -715,6 +715,13 @@ void StyleAdjuster::AdjustComputedStyle(StyleResolverState& state,
style.OverflowY() != EOverflow::kVisible) style.OverflowY() != EOverflow::kVisible)
AdjustOverflow(style); 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)) if (StopPropagateTextDecorations(style, element))
style.ClearAppliedTextDecorations(); style.ClearAppliedTextDecorations();
else else
......
...@@ -114,13 +114,20 @@ TEST_F(StyleAdjusterTest, AdjustOverflow) { ...@@ -114,13 +114,20 @@ TEST_F(StyleAdjusterTest, AdjustOverflow) {
ScopedOverflowClipForTest overflow_clip_feature_enabler(true); ScopedOverflowClipForTest overflow_clip_feature_enabler(true);
GetDocument().SetBaseURLOverride(KURL("http://test.com")); GetDocument().SetBaseURLOverride(KURL("http://test.com"));
SetBodyInnerHTML(R"HTML( SetBodyInnerHTML(R"HTML(
<div id='clipauto' style='overflow-x: clip; overflow-y: auto;'> <div id='clipauto' style='overflow-x: clip; overflow-y: auto;
<div id='autoclip' style='overflow-x: auto; overflow-y: clip;'> overflow-clip-margin: 1px;'>
<div id='clipclip' style='overflow-x: clip; overflow-y: clip;'> <div id='autoclip' style='overflow-x: auto; overflow-y: clip;
<div id='visclip' style='overflow-x: visible; overflow-y: clip;'> overflow-clip-margin: 1px;'>
<div id='clipvis' style='overflow-x: clip; overflow-y: visible;'> <div id='clipclip' style='overflow-x: clip; overflow-y: clip;
<div id='hiddenvis' style='overflow-x: hidden; overflow-y: visible;'> overflow-clip-margin: 1px;'>
<div id='vishidden' style='overflow-x: visible; overflow-y: hidden;'> <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> </div>
)HTML"); )HTML");
UpdateAllLifecyclePhasesForTest(); UpdateAllLifecyclePhasesForTest();
...@@ -129,36 +136,43 @@ TEST_F(StyleAdjusterTest, AdjustOverflow) { ...@@ -129,36 +136,43 @@ TEST_F(StyleAdjusterTest, AdjustOverflow) {
ASSERT_TRUE(target); ASSERT_TRUE(target);
EXPECT_EQ(EOverflow::kHidden, target->GetComputedStyle()->OverflowX()); EXPECT_EQ(EOverflow::kHidden, target->GetComputedStyle()->OverflowX());
EXPECT_EQ(EOverflow::kAuto, target->GetComputedStyle()->OverflowY()); EXPECT_EQ(EOverflow::kAuto, target->GetComputedStyle()->OverflowY());
EXPECT_EQ(LayoutUnit(), target->GetComputedStyle()->OverflowClipMargin());
target = GetDocument().getElementById("autoclip"); target = GetDocument().getElementById("autoclip");
ASSERT_TRUE(target); ASSERT_TRUE(target);
EXPECT_EQ(EOverflow::kAuto, target->GetComputedStyle()->OverflowX()); EXPECT_EQ(EOverflow::kAuto, target->GetComputedStyle()->OverflowX());
EXPECT_EQ(EOverflow::kHidden, target->GetComputedStyle()->OverflowY()); EXPECT_EQ(EOverflow::kHidden, target->GetComputedStyle()->OverflowY());
EXPECT_EQ(LayoutUnit(), target->GetComputedStyle()->OverflowClipMargin());
target = GetDocument().getElementById("clipclip"); target = GetDocument().getElementById("clipclip");
ASSERT_TRUE(target); ASSERT_TRUE(target);
EXPECT_EQ(EOverflow::kClip, target->GetComputedStyle()->OverflowX()); EXPECT_EQ(EOverflow::kClip, target->GetComputedStyle()->OverflowX());
EXPECT_EQ(EOverflow::kClip, target->GetComputedStyle()->OverflowY()); EXPECT_EQ(EOverflow::kClip, target->GetComputedStyle()->OverflowY());
EXPECT_EQ(LayoutUnit(1), target->GetComputedStyle()->OverflowClipMargin());
target = GetDocument().getElementById("visclip"); target = GetDocument().getElementById("visclip");
ASSERT_TRUE(target); ASSERT_TRUE(target);
EXPECT_EQ(EOverflow::kVisible, target->GetComputedStyle()->OverflowX()); EXPECT_EQ(EOverflow::kVisible, target->GetComputedStyle()->OverflowX());
EXPECT_EQ(EOverflow::kClip, target->GetComputedStyle()->OverflowY()); EXPECT_EQ(EOverflow::kClip, target->GetComputedStyle()->OverflowY());
EXPECT_EQ(LayoutUnit(), target->GetComputedStyle()->OverflowClipMargin());
target = GetDocument().getElementById("clipvis"); target = GetDocument().getElementById("clipvis");
ASSERT_TRUE(target); ASSERT_TRUE(target);
EXPECT_EQ(EOverflow::kClip, target->GetComputedStyle()->OverflowX()); EXPECT_EQ(EOverflow::kClip, target->GetComputedStyle()->OverflowX());
EXPECT_EQ(EOverflow::kVisible, target->GetComputedStyle()->OverflowY()); EXPECT_EQ(EOverflow::kVisible, target->GetComputedStyle()->OverflowY());
EXPECT_EQ(LayoutUnit(), target->GetComputedStyle()->OverflowClipMargin());
target = GetDocument().getElementById("vishidden"); target = GetDocument().getElementById("vishidden");
ASSERT_TRUE(target); ASSERT_TRUE(target);
EXPECT_EQ(EOverflow::kAuto, target->GetComputedStyle()->OverflowX()); EXPECT_EQ(EOverflow::kAuto, target->GetComputedStyle()->OverflowX());
EXPECT_EQ(EOverflow::kHidden, target->GetComputedStyle()->OverflowY()); EXPECT_EQ(EOverflow::kHidden, target->GetComputedStyle()->OverflowY());
EXPECT_EQ(LayoutUnit(), target->GetComputedStyle()->OverflowClipMargin());
target = GetDocument().getElementById("hiddenvis"); target = GetDocument().getElementById("hiddenvis");
ASSERT_TRUE(target); ASSERT_TRUE(target);
EXPECT_EQ(EOverflow::kHidden, target->GetComputedStyle()->OverflowX()); EXPECT_EQ(EOverflow::kHidden, target->GetComputedStyle()->OverflowX());
EXPECT_EQ(EOverflow::kAuto, target->GetComputedStyle()->OverflowY()); EXPECT_EQ(EOverflow::kAuto, target->GetComputedStyle()->OverflowY());
EXPECT_EQ(LayoutUnit(), target->GetComputedStyle()->OverflowClipMargin());
} }
TEST_F(StyleAdjusterTest, SetListenerForContentEditableArea) { 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