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

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

Issue 2695093007: [Typed CSSOM] Get computed values for custom properties
Patch Set: test whitespace Created 3 years, 10 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 49c51fc42352eb88b795c3cfa54c48089323e0d4..bf59a8b751c3aef7befea9970a5bb1065a20c697 100644
--- a/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp
@@ -6,6 +6,7 @@
#include "core/css/CSSComputedStyleDeclaration.h"
#include "core/css/ComputedStyleCSSValueMapping.h"
+#include "core/css/PropertyRegistry.h"
#include "core/css/cssom/CSSCalcLength.h"
#include "core/css/cssom/CSSKeywordValue.h"
#include "core/css/cssom/CSSNumberValue.h"
@@ -59,18 +60,15 @@ Node* ComputedStylePropertyMap::node() const {
return nullptr;
}
-CSSStyleValueVector ComputedStylePropertyMap::getAllInternal(
- CSSPropertyID propertyID) {
- CSSStyleValueVector styleValueVector;
-
+const ComputedStyle* ComputedStylePropertyMap::updateStyle() const {
Node* node = this->node();
if (!node || !node->inActiveDocument()) {
- return styleValueVector;
+ return nullptr;
}
node->document().updateStyleAndLayoutTreeForNode(node);
node = this->node();
if (!node) {
- return styleValueVector;
+ return nullptr;
}
// I have copied this from
// CSSComputedStyleDeclaration::computeComputedStyle(). I don't know if
@@ -81,11 +79,19 @@ CSSStyleValueVector ComputedStylePropertyMap::getAllInternal(
node->isPseudoElement() ? PseudoIdNone : m_pseudoId);
node = this->node();
if (!node || !node->inActiveDocument() || !style) {
- return styleValueVector;
+ return nullptr;
}
+ return style;
+}
- CSSStyleValue* styleValue = nullptr;
+CSSStyleValueVector ComputedStylePropertyMap::getAllInternal(
+ CSSPropertyID propertyID) {
+ CSSStyleValueVector styleValueVector;
+ const ComputedStyle* style = this->updateStyle();
alancutter (OOO until 2018) 2017/02/24 05:57:21 No need for "this->" where it's not ambiguous. Sty
+ if (!style)
+ return styleValueVector;
+ CSSStyleValue* styleValue = nullptr;
switch (propertyID) {
// TODO(rjwright): Generate this code.
case CSSPropertyLeft:
@@ -129,12 +135,8 @@ CSSStyleValueVector ComputedStylePropertyMap::getAllInternal(
break;
}
default:
- // TODO(rjwright): Add a flag argument to
- // ComputedStyleCSSValyeMapping::get that makes it return
- // just the raw value off the ComputedStyle, and not zoom adjusted or
- // anything like that.
const CSSValue* value = ComputedStyleCSSValueMapping::get(
- propertyID, *style, nullptr, node, false);
+ propertyID, *style, nullptr, this->node(), false);
alancutter (OOO until 2018) 2017/02/24 05:57:21 I don't think it's necessary to pass in the node h
if (value) {
return StyleValueFactory::cssValueToStyleValueVector(propertyID,
*value);
@@ -149,9 +151,17 @@ CSSStyleValueVector ComputedStylePropertyMap::getAllInternal(
}
CSSStyleValueVector ComputedStylePropertyMap::getAllInternal(
- AtomicString customPropertyName) {
- const CSSValue* cssValue =
- m_computedStyleDeclaration->getPropertyCSSValue(customPropertyName);
+ AtomicString customPropertyName,
+ ExceptionState& exceptionState) {
+ const ComputedStyle* style = this->updateStyle();
+ if (!style)
+ return CSSStyleValueVector();
+ const PropertyRegistration* registration =
+ m_node->document().propertyRegistry()->registration(customPropertyName);
alancutter (OOO until 2018) 2017/02/24 05:57:21 The property registry is nullptr in stable Chrome.
+ if (!registration)
+ return CSSStyleValueVector();
+ const CSSValue* cssValue = style->getRegisteredVariable(
+ customPropertyName, registration->inherits());
if (!cssValue)
return CSSStyleValueVector();
return StyleValueFactory::cssValueToStyleValueVector(CSSPropertyInvalid,
alancutter (OOO until 2018) 2017/02/24 05:57:21 No need to pass in CSSPropertyInvalid here, there'

Powered by Google App Engine
This is Rietveld 408576698