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

Side by Side Diff: Source/core/scripts/templates/StylePropertyShorthand.cpp.tmpl

Issue 22610005: Implement runtime feature support for CSS Shorthands (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/scripts/make_style_shorthands.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2013 Intel Corporation. All rights reserved. 4 * Copyright (C) 2013 Intel Corporation. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 */ 20 */
21 21
22 #include "config.h" 22 #include "config.h"
23 #include "StylePropertyShorthand.h" 23 #include "StylePropertyShorthand.h"
24 #include "RuntimeEnabledFeatures.h"
24 25
25 #include "wtf/HashMap.h" 26 #include "wtf/HashMap.h"
26 #include "wtf/StdLibExtras.h" 27 #include "wtf/StdLibExtras.h"
27 28
28 namespace WebCore { 29 namespace WebCore {
29 30
30 {%- for property_id, property in properties.items() %} 31 {%- for property_id, property in properties.items() %}
31 32
32 const StylePropertyShorthand& {{ property.camel_case_name }}Shorthand() 33 const StylePropertyShorthand& {{ property.camel_case_name }}Shorthand()
33 { 34 {
34 static const CSSPropertyID {{ property.camel_case_name }}Properties[] = { 35 static const CSSPropertyID {{ property.camel_case_name }}Properties[] = {
35 {%- for longhand_id in property.camel_case_longhands %} 36 {%- for longhand_id in property.camel_case_longhands %}
36 {{ longhand_id }}, 37 {{ longhand_id }},
37 {%- endfor %} 38 {%- endfor %}
38 }; 39 };
39 DEFINE_STATIC_LOCAL(StylePropertyShorthand, {{ property.camel_case_name }}Lo nghands, ({{ property_id }}, {{ property.camel_case_name }}Properties, WTF_ARRAY _LENGTH({{ property.camel_case_name }}Properties))); 40 DEFINE_STATIC_LOCAL(StylePropertyShorthand, {{ property.camel_case_name }}Lo nghands, ({{ property_id }}, {{ property.camel_case_name }}Properties, WTF_ARRAY _LENGTH({{ property.camel_case_name }}Properties)));
40 return {{ property.camel_case_name }}Longhands; 41 return {{ property.camel_case_name }}Longhands;
41 } 42 }
42 {%- endfor %} 43 {%- endfor %}
43 44
44 // Returns an empty list if the property is not a shorthand 45 // Returns an empty list if the property is not a shorthand
45 const StylePropertyShorthand& shorthandForProperty(CSSPropertyID propertyID) 46 const StylePropertyShorthand& shorthandForProperty(CSSPropertyID propertyID)
46 { 47 {
48 DEFINE_STATIC_LOCAL(StylePropertyShorthand, emptyShorthand, ());
47 switch (propertyID) { 49 switch (propertyID) {
48 {%- for property_id, property in properties.items() %} 50 {%- for property_id, property in properties.items() %}
49 {%- if property.camel_case_name not in ["width", "height", "marker"] %} 51 {%- if property.camel_case_name not in ["width", "height", "marker"] %}
50 case {{ property_id }}: 52 case {{ property_id }}:
53 {%- if property.runtime_conditional_getter %}
54 if (!RuntimeEnabledFeatures::{{ property.runtime_conditional_getter }}())
55 return emptyShorthand;
56 {%- endif %}
51 return {{ property.camel_case_name }}Shorthand(); 57 return {{ property.camel_case_name }}Shorthand();
52 {%- endif %} 58 {%- endif %}
53 {%- endfor %} 59 {%- endfor %}
54 default: { 60 default: {
55 DEFINE_STATIC_LOCAL(StylePropertyShorthand, emptyShorthand, ());
56 return emptyShorthand; 61 return emptyShorthand;
57 } 62 }
58 } 63 }
59 } 64 }
60 65
61 typedef HashMap<CSSPropertyID, Vector<StylePropertyShorthand> > longhandsMap; 66 typedef HashMap<CSSPropertyID, Vector<StylePropertyShorthand> > longhandsMap;
62 const Vector<StylePropertyShorthand> matchingShorthandsForLonghand(CSSPropertyID propertyID) 67 const Vector<StylePropertyShorthand> matchingShorthandsForLonghand(CSSPropertyID propertyID)
63 { 68 {
64 DEFINE_STATIC_LOCAL(longhandsMap, map, ()); 69 DEFINE_STATIC_LOCAL(longhandsMap, map, ());
65 if (map.isEmpty()) { 70 if (map.isEmpty()) {
66 {%- for longhand_id, shorthands in longhands_dictionary.items() %} 71 {%- for longhand_id, shorthands in longhands_dictionary.items() %}
67 72
68 Vector<StylePropertyShorthand, {{ shorthands|length }}> {{ longhand_id } }Shorthands; 73 Vector<StylePropertyShorthand, {{ shorthands|length }}> {{ longhand_id } }Shorthands;
69 {% for shorthand in shorthands -%} 74 {% for shorthand in shorthands -%}
70 {{ longhand_id }}Shorthands.uncheckedAppend({{ shorthand.camel_case_ name }}Shorthand()); 75 {{ longhand_id }}Shorthands.uncheckedAppend({{ shorthand.camel_case_ name }}Shorthand());
71 {% endfor -%} 76 {% endfor -%}
72 map.set({{ longhand_id }}, {{ longhand_id }}Shorthands); 77 map.set({{ longhand_id }}, {{ longhand_id }}Shorthands);
73 {%- endfor %} 78 {%- endfor %}
74 } 79 }
75 return map.get(propertyID); 80 return map.get(propertyID);
76 } 81 }
77 82
78 } // namespace WebCore 83 } // namespace WebCore
79 84
OLDNEW
« no previous file with comments | « Source/core/scripts/make_style_shorthands.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698