Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Unified Diff: third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp

Issue 2798903005: Return computed style for width/height for non-root SVG (Closed)
Patch Set: Reduce behavior change Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/css/getComputedStyle-svg-text-width-height.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
diff --git a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
index d17561ad8751214aed2d19a20d6d1a16fe34bc93..42e6910abe394302e6d82ca1586472a2dd3b2d55 100644
--- a/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
+++ b/third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp
@@ -2037,6 +2037,19 @@ ComputedStyleCSSValueMapping::getVariables(const ComputedStyle& style) {
return nullptr;
}
+static bool widthOrHeightPropertyAppliesToObject(const LayoutObject& object) {
+ // According to
+ // http://www.w3.org/TR/CSS2/visudet.html#the-width-property and
+ // http://www.w3.org/TR/CSS2/visudet.html#the-height-property, the "width" or
+ // "height" property does not apply to non-atomic inline elements.
+ if (!object.isAtomicInlineLevel() && object.isInline())
+ return false;
+
+ // Non-root SVG should be treated as non-atomic inline no matter how we
+ // implement it internally (e.g. LayoutSVGBlock is based on LayoutBlockFlow).
+ return !object.isSVGChild();
+}
+
const CSSValue* ComputedStyleCSSValueMapping::get(
CSSPropertyID propertyID,
const ComputedStyle& style,
@@ -2532,10 +2545,7 @@ const CSSValue* ComputedStyleCSSValueMapping::get(
case CSSPropertyHeight:
if (layoutObject) {
- // According to
- // http://www.w3.org/TR/CSS2/visudet.html#the-height-property, the
- // "height" property does not apply for non-atomic inline elements.
- if (!layoutObject->isAtomicInlineLevel() && layoutObject->isInline())
+ if (!widthOrHeightPropertyAppliesToObject(*layoutObject))
return CSSIdentifierValue::create(CSSValueAuto);
return zoomAdjustedPixelValue(sizingBox(layoutObject).height(), style);
}
@@ -2893,10 +2903,7 @@ const CSSValue* ComputedStyleCSSValueMapping::get(
CSSPrimitiveValue::UnitType::Number);
case CSSPropertyWidth:
if (layoutObject) {
- // According to
- // http://www.w3.org/TR/CSS2/visudet.html#the-width-property,
- // the "width" property does not apply for non-atomic inline elements.
- if (!layoutObject->isAtomicInlineLevel() && layoutObject->isInline())
+ if (!widthOrHeightPropertyAppliesToObject(*layoutObject))
return CSSIdentifierValue::create(CSSValueAuto);
return zoomAdjustedPixelValue(sizingBox(layoutObject).width(), style);
}
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/css/getComputedStyle-svg-text-width-height.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698