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

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

Issue 1405293012: [Variables] Enable get/setProperty and similar APIs from the CSSOM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use static_assert. Created 5 years, 1 month 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/StylePropertySerializer.cpp
diff --git a/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp b/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp
index eb8165d634ee583bb3b57a3521d67fe7faaea43f..4f3f20dcfe88d55a6ffaf83c2d95349e4a952024 100644
--- a/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp
+++ b/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp
@@ -25,6 +25,7 @@
#include "core/CSSValueKeywords.h"
#include "core/StylePropertyShorthand.h"
+#include "core/css/CSSCustomPropertyDeclaration.h"
#include "core/css/CSSPropertyMetadata.h"
#include "core/css/CSSValuePool.h"
#include "wtf/BitArray.h"
@@ -176,6 +177,22 @@ StylePropertySerializer::StylePropertySerializer(const StylePropertySet& propert
{
}
+String StylePropertySerializer::getCustomPropertyText(const PropertyValueForSerializer& property, bool isNotFirstDecl) const
+{
+ ASSERT(property.id() == CSSPropertyVariable);
+ StringBuilder result;
+ if (isNotFirstDecl)
+ result.append(' ');
+ const CSSCustomPropertyDeclaration* value = toCSSCustomPropertyDeclaration(property.value());
+ result.append(value->name());
+ result.appendLiteral(": ");
+ result.append(value->customCSSText());
+ if (property.isImportant())
+ result.appendLiteral(" !important");
+ result.append(';');
+ return result.toString();
+}
+
String StylePropertySerializer::getPropertyText(CSSPropertyID propertyID, const String& value, bool isImportant, bool isNotFirstDecl) const
{
StringBuilder result;
@@ -343,6 +360,9 @@ String StylePropertySerializer::asText() const
case CSSPropertyWebkitMaskOrigin:
shorthandPropertyID = CSSPropertyWebkitMask;
break;
+ case CSSPropertyVariable:
+ result.append(getCustomPropertyText(property, numDecls++));
+ continue;
case CSSPropertyAll:
result.append(getPropertyText(propertyID, property.value()->cssText(), property.isImportant(), numDecls++));
continue;
« no previous file with comments | « third_party/WebKit/Source/core/css/StylePropertySerializer.h ('k') | third_party/WebKit/Source/core/css/StylePropertySet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698