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

Unified Diff: third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp

Issue 2312293003: [CSSTypedOM] Computed StylePropertyMap use ComputedStyle for Lengths (Closed)
Patch Set: rebase Created 4 years, 3 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/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..e56d2d6dc43b45ff4cbf96891a8972272b4151d7 100644
--- a/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp
@@ -5,16 +5,71 @@
#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* styleValueForLength(const Length& length)
meade_UTC10 2016/09/27 04:41:39 Nit: It's conventional to put pure methods like th
rjwright 2016/09/28 01:38:24 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.
meade_UTC10 2016/09/27 04:41:39 Did you end up asking anyone about this?
rjwright 2016/09/28 01:38:24 No. I'm not sure who to ask. I was planning to jus
meade_UTC10 2016/09/28 01:51:32 No strong opinions - but we may be able to ask Bug
+ document.updateStyleAndLayoutTreeForNode(m_node);
+ const ComputedStyle* style = m_node->ensureComputedStyle();
+ CSSStyleValueVector styleValueVector;
+ CSSStyleValue* styleValue = nullptr;
+ switch (propertyID) {
+ case CSSPropertyLeft:
+ styleValue = styleValueForLength(style->left());
+ case CSSPropertyRight:
+ styleValue = styleValueForLength(style->right());
+ case CSSPropertyTop:
+ styleValue = styleValueForLength(style->top());
+ case CSSPropertyBottom:
+ styleValue = styleValueForLength(style->bottom());
+ case CSSPropertyHeight:
+ styleValue = styleValueForLength(style->height());
+ case CSSPropertyWidth: {
+ styleValue = styleValueForLength(style->width());
+ }
+ default:
+ break;
+ }
+
+ if (styleValue) {
+ styleValueVector.append(styleValue);
+ return styleValueVector;
+ }
+ // Note: this is just a stopgap to make prototyping easier. cssValue represents a resolved
+ // style, not a computed style; so the cssText in the unsupportedCSSValue won't necessarily
+ // match the typed CSSStyleValue that will eventually be returned here.
const CSSValue* cssValue = m_computedStyleDeclaration->getPropertyCSSValueInternal(propertyID);
- if (!cssValue)
- return CSSStyleValueVector();
- return StyleValueFactory::cssValueToStyleValueVector(propertyID, *cssValue);
+ if (cssValue) {
+ return StyleValueFactory::unsupportedCSSValue(*cssValue);
meade_UTC10 2016/09/27 04:41:39 We're going to get rid of UnsupportedCSSValue afte
rjwright 2016/09/28 01:38:24 Done.
+ }
+ return styleValueVector;
}
CSSStyleValueVector ComputedStylePropertyMap::getAllInternal(AtomicString customPropertyName)

Powered by Google App Engine
This is Rietveld 408576698