Commit ef690472 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Block/InlineSize::IsLayoutDependent() should consider SVG

The function decides whether we should update layout for
getComputedStyle().getPropertyValue("block/inline-size") on an element,
and it incorrectly returns false on SVG elements. This patch fixes it.

Note: This patch makes the function identical to
Width/Height::IsLayoutDependent().

Bug: 1115887
Change-Id: Ieb628e2e81ce02d95ac8a41a04b3aaa96d532829
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354625
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Auto-Submit: Xiaocheng Hu <xiaochengh@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798369}
parent fdeeee36
......@@ -6,6 +6,7 @@
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
namespace blink {
......@@ -117,4 +118,42 @@ TEST_F(CSSComputedStyleDeclarationTest,
// Don't crash.
}
// https://crbug.com/1115877
TEST_F(CSSComputedStyleDeclarationTest, SVGBlockSizeLayoutDependent) {
GetDocument().body()->setInnerHTML(R"HTML(
<svg viewBox="0 0 400 400">
<rect width="400" height="400"></rect>
</svg>
)HTML");
Element* rect = GetDocument().QuerySelector("rect");
auto* computed = MakeGarbageCollected<CSSComputedStyleDeclaration>(rect);
EXPECT_EQ("400px", computed->GetPropertyValue(CSSPropertyID::kBlockSize));
EXPECT_FALSE(GetDocument().NeedsLayoutTreeUpdate());
EXPECT_FALSE(GetDocument().NeedsLayoutTreeUpdateForNode(*rect));
EXPECT_FALSE(rect->NeedsStyleRecalc());
EXPECT_FALSE(rect->GetLayoutObject()->NeedsLayout());
}
// https://crbug.com/1115877
TEST_F(CSSComputedStyleDeclarationTest, SVGInlineSizeLayoutDependent) {
GetDocument().body()->setInnerHTML(R"HTML(
<svg viewBox="0 0 400 400">
<rect width="400" height="400"></rect>
</svg>
)HTML");
Element* rect = GetDocument().QuerySelector("rect");
auto* computed = MakeGarbageCollected<CSSComputedStyleDeclaration>(rect);
EXPECT_EQ("400px", computed->GetPropertyValue(CSSPropertyID::kInlineSize));
EXPECT_FALSE(GetDocument().NeedsLayoutTreeUpdate());
EXPECT_FALSE(GetDocument().NeedsLayoutTreeUpdateForNode(*rect));
EXPECT_FALSE(rect->NeedsStyleRecalc());
EXPECT_FALSE(rect->GetLayoutObject()->NeedsLayout());
}
} // namespace blink
......@@ -723,7 +723,7 @@ const CSSValue* BlockSize::ParseSingleValue(
bool BlockSize::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
return layout_object && (layout_object->IsBox() || layout_object->IsSVG());
}
const CSSValue* BorderBlockEndColor::ParseSingleValue(
......@@ -3277,7 +3277,7 @@ const CSSValue* InlineSize::ParseSingleValue(
bool InlineSize::IsLayoutDependent(const ComputedStyle* style,
LayoutObject* layout_object) const {
return layout_object && layout_object->IsBox();
return layout_object && (layout_object->IsBox() || layout_object->IsSVG());
}
const CSSValue* InsetBlockEnd::ParseSingleValue(
......
......@@ -77,7 +77,7 @@ background-position-y: 0%
background-repeat: repeat
background-size: auto
baseline-shift: 0px
block-size: 0px
block-size: 100px
border-block-end-color: rgb(0, 0, 0)
border-block-end-style: none
border-block-end-width: 0px
......
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