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

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: - 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
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..c4fdc2de6308230dda303f26dbd1a7f8e2d857cf 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 LayoutBlock).
+ return !object.isSVGChild();
+}
+
const CSSValue* ComputedStyleCSSValueMapping::get(
CSSPropertyID propertyID,
const ComputedStyle& style,
@@ -2531,14 +2544,8 @@ const CSSValue* ComputedStyleCSSValueMapping::get(
styledNode, allowVisitedStyle);
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())
- return CSSIdentifierValue::create(CSSValueAuto);
+ if (layoutObject && widthOrHeightPropertyAppliesToObject(*layoutObject))
return zoomAdjustedPixelValue(sizingBox(layoutObject).height(), style);
- }
return zoomAdjustedPixelValueForLength(style.height(), style);
case CSSPropertyWebkitHighlight:
if (style.highlight() == nullAtom)
@@ -2892,14 +2899,8 @@ const CSSValue* ComputedStyleCSSValueMapping::get(
return CSSPrimitiveValue::create(style.widows(),
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())
- return CSSIdentifierValue::create(CSSValueAuto);
+ if (layoutObject && widthOrHeightPropertyAppliesToObject(*layoutObject))
return zoomAdjustedPixelValue(sizingBox(layoutObject).width(), style);
- }
return zoomAdjustedPixelValueForLength(style.width(), style);
case CSSPropertyWillChange:
return valueForWillChange(style.willChangeProperties(),

Powered by Google App Engine
This is Rietveld 408576698