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

Unified Diff: Source/core/scripts/templates/StyleBuilder.cpp.tmpl

Issue 15157002: Begin moving DeprecatedStyleBuilder properties to new generated StyleBuilder. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: move StyleBuilder call to below DeprecatedStyleBuilder Created 7 years, 7 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
« no previous file with comments | « Source/core/scripts/make_style_builder.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/scripts/templates/StyleBuilder.cpp.tmpl
diff --git a/Source/core/scripts/templates/StyleBuilder.cpp.tmpl b/Source/core/scripts/templates/StyleBuilder.cpp.tmpl
new file mode 100644
index 0000000000000000000000000000000000000000..0d5fae0bf617eb2c743d00a781a8e9a4ca0fb8cd
--- /dev/null
+++ b/Source/core/scripts/templates/StyleBuilder.cpp.tmpl
@@ -0,0 +1,67 @@
+{% from "macros.tmpl" import wrap_with_condition, license -%}
+{{ license() }}
+
+#include "config.h"
+#include "core/css/resolver/StyleBuilder.h"
+
+#include "core/css/CSSPrimitiveValueMappings.h"
+#include "core/css/resolver/StyleResolver.h"
+
+// FIXME: currently we're just generating a switch statement, but we should
+// test other variations for performance once we have more properties here.
+
+namespace WebCore {
+
+class StyleBuilderImpl {
+public:
+
+{%- macro setValue(property) -%}
+ styleResolver->style()->{{property.setter}}
+{%- endmacro %}
+
+{%- for property in properties %}
+{%- call wrap_with_condition(property.condition) %}
+{%- set propertyid = property.propertyid %}
+{%- set applytype = property.applytype %}
+
+static void applyInitial{{propertyid}}(StyleResolver* styleResolver)
+{
+ {{ setValue(property) }}(RenderStyle::{{property.initial}}());
+}
+
+static void applyInherit{{propertyid}}(StyleResolver* styleResolver)
+{
+ {{ setValue(property) }}(styleResolver->parentStyle()->{{property.getter}}());
+}
+
+static void applyValue{{propertyid}}(StyleResolver* styleResolver, CSSValue* value)
+{
+ {{ setValue(property) }}(static_cast<{{property.typename}}>(*static_cast<CSSPrimitiveValue*>(value)));
+}
+
+{%- endcall %}
+{%- endfor %}
+
+};
+
+bool StyleBuilder::applyProperty(CSSPropertyID property, StyleResolver* styleResolver, CSSValue* value, bool isInitial, bool isInherit) {
+ switch(property) {
+{%- for property in properties %}
+{%- call wrap_with_condition(property.condition) %}
+{%- set propertyid = property.propertyid %}
+ case {{propertyid}}:
+ if (isInitial)
+ StyleBuilderImpl::applyInitial{{propertyid}}(styleResolver);
+ else if (isInherit)
+ StyleBuilderImpl::applyInherit{{propertyid}}(styleResolver);
+ else
+ StyleBuilderImpl::applyValue{{propertyid}}(styleResolver, value);
+ return true;
+{%- endcall %}
+{% endfor %}
+ default:
+ return false;
+ }
+}
+}
+
« no previous file with comments | « Source/core/scripts/make_style_builder.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698