Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp |
| diff --git a/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp b/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp |
| index f0cbe2b848f31f97e7f9beb71db0ff6bce653295..da012786cd3982270a52b65e30d1f3dd1b9dc5f0 100644 |
| --- a/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp |
| +++ b/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp |
| @@ -5,16 +5,68 @@ |
| #include "core/css/cssom/ComputedStylePropertyMap.h" |
| #include "core/css/CSSComputedStyleDeclaration.h" |
| +#include "core/css/cssom/CSSCalcLength.h" |
| +#include "core/css/cssom/CSSKeywordValue.h" |
| +#include "core/css/cssom/CSSSimpleLength.h" |
| #include "core/css/cssom/StyleValueFactory.h" |
| namespace blink { |
| +CSSStyleValue* styleValueForLengthProperty(const Length& length) |
|
meade_UTC10
2016/09/23 05:21:25
nit: just styleValueForLength for brevity? (also y
rjwright
2016/09/23 05:39:29
Done.
|
| +{ |
| + if (length.isAuto()) { |
| + return CSSKeywordValue::create("auto"); |
| + } |
| + if (length.isFixed()) { |
| + return CSSSimpleLength::create(length.pixels(), CSSPrimitiveValue::UnitType::Pixels); |
| + } |
| + if (length.isPercent()) { |
| + return CSSSimpleLength::create(length.percent(), CSSPrimitiveValue::UnitType::Percentage); |
| + } |
| + if (length.isCalculated()) { |
| + return CSSCalcLength::fromLength(length); |
| + } |
| + NOTREACHED(); |
| + return nullptr; |
| +} |
| + |
| CSSStyleValueVector ComputedStylePropertyMap::getAllInternal(CSSPropertyID propertyID) |
| { |
| + Document& document = m_node->document(); |
| + // TODO(rjwright): This style recalc is copied from |
| + // CSSComputedStyleDeclaration::getPropertyValue, which also does a bunch of other stuff. |
| + // Need to look back to it and see if I need to do more here. |
| + document.updateStyleAndLayoutTreeForNode(m_node); |
| + const ComputedStyle* style = m_node->ensureComputedStyle(); |
| + CSSStyleValueVector styleValueVector; |
| + CSSStyleValue* styleValue = nullptr; |
| + switch (propertyID) { |
| + case CSSPropertyLeft: |
| + styleValue = styleValueForLengthProperty(style->left()); |
| + case CSSPropertyRight: |
| + styleValue = styleValueForLengthProperty(style->right()); |
| + case CSSPropertyTop: |
| + styleValue = styleValueForLengthProperty(style->top()); |
| + case CSSPropertyBottom: |
| + styleValue = styleValueForLengthProperty(style->bottom()); |
| + case CSSPropertyHeight: |
| + styleValue = styleValueForLengthProperty(style->height()); |
| + case CSSPropertyWidth: { |
| + styleValue = styleValueForLengthProperty(style->width()); |
| + } |
| + default: |
| + break; |
| + } |
| + |
| + if (styleValue) { |
| + styleValueVector.append(styleValue); |
| + return styleValueVector; |
| + } |
| const CSSValue* cssValue = m_computedStyleDeclaration->getPropertyCSSValueInternal(propertyID); |
| - if (!cssValue) |
| - return CSSStyleValueVector(); |
| - return StyleValueFactory::cssValueToStyleValueVector(propertyID, *cssValue); |
| + if (cssValue) { |
| + return StyleValueFactory::unsupportedCSSValue(*cssValue); |
| + } |
| + return styleValueVector; |
| } |
| CSSStyleValueVector ComputedStylePropertyMap::getAllInternal(AtomicString customPropertyName) |