OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 import subprocess | 3 import subprocess |
4 import sys | 4 import sys |
5 | 5 |
6 import css_properties | 6 import css_properties |
7 import in_generator | 7 import in_generator |
8 import license | 8 import license |
9 | 9 |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... | |
21 | 21 |
22 namespace WTF { | 22 namespace WTF { |
23 class AtomicString; | 23 class AtomicString; |
24 class String; | 24 class String; |
25 } | 25 } |
26 | 26 |
27 namespace blink { | 27 namespace blink { |
28 | 28 |
29 enum CSSPropertyID { | 29 enum CSSPropertyID { |
30 CSSPropertyInvalid = 0, | 30 CSSPropertyInvalid = 0, |
31 CSSPropertyVariable = 1, | |
31 %(property_enums)s | 32 %(property_enums)s |
32 }; | 33 }; |
33 | 34 |
34 const int firstCSSProperty = %(first_property_id)s; | 35 const int firstCSSProperty = %(first_property_id)s; |
35 const int numCSSProperties = %(properties_count)s; | 36 const int numCSSProperties = %(properties_count)s; |
36 const int lastCSSProperty = %(last_property_id)d; | 37 const int lastCSSProperty = %(last_property_id)d; |
37 const int lastUnresolvedCSSProperty = %(last_unresolved_property_id)d; | 38 const int lastUnresolvedCSSProperty = %(last_unresolved_property_id)d; |
38 const size_t maxCSSPropertyNameLength = %(max_name_length)d; | 39 const size_t maxCSSPropertyNameLength = %(max_name_length)d; |
39 | 40 |
40 const char* getPropertyName(CSSPropertyID); | 41 const char* getPropertyName(CSSPropertyID); |
41 const WTF::AtomicString& getPropertyNameAtomicString(CSSPropertyID); | 42 const WTF::AtomicString& getPropertyNameAtomicString(CSSPropertyID); |
42 WTF::String getPropertyNameString(CSSPropertyID); | 43 WTF::String getPropertyNameString(CSSPropertyID); |
43 WTF::String getJSPropertyName(CSSPropertyID); | 44 WTF::String getJSPropertyName(CSSPropertyID); |
44 | 45 |
45 inline CSSPropertyID convertToCSSPropertyID(int value) | 46 inline CSSPropertyID convertToCSSPropertyID(int value) |
46 { | 47 { |
47 ASSERT((value >= firstCSSProperty && value <= lastCSSProperty) || value == C SSPropertyInvalid); | 48 ASSERT((value >= firstCSSProperty && value <= lastCSSProperty) || value == C SSPropertyInvalid || value == CSSPropertyVariable); |
48 return static_cast<CSSPropertyID>(value); | 49 return static_cast<CSSPropertyID>(value); |
49 } | 50 } |
50 | 51 |
51 inline CSSPropertyID resolveCSSPropertyID(CSSPropertyID id) | 52 inline CSSPropertyID resolveCSSPropertyID(CSSPropertyID id) |
52 { | 53 { |
53 return convertToCSSPropertyID(id & ~512); | 54 return convertToCSSPropertyID(id & ~512); |
54 } | 55 } |
55 | 56 |
56 inline bool isPropertyAlias(CSSPropertyID id) { return id & 512; } | 57 inline bool isPropertyAlias(CSSPropertyID id) { return id & 512; } |
57 | 58 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 %%%% | 113 %%%% |
113 %(property_to_enum_map)s | 114 %(property_to_enum_map)s |
114 %%%% | 115 %%%% |
115 const Property* findProperty(register const char* str, register unsigned int len ) | 116 const Property* findProperty(register const char* str, register unsigned int len ) |
116 { | 117 { |
117 return %(class_name)sHash::findPropertyImpl(str, len); | 118 return %(class_name)sHash::findPropertyImpl(str, len); |
118 } | 119 } |
119 | 120 |
120 const char* getPropertyName(CSSPropertyID id) | 121 const char* getPropertyName(CSSPropertyID id) |
121 { | 122 { |
122 ASSERT(id >= firstCSSProperty && id <= lastUnresolvedCSSProperty); | 123 ASSERT(id >= firstCSSProperty && id <= lastUnresolvedCSSProperty || id == CS SPropertyVariable); |
Timothy Loh
2015/11/02 07:28:48
I don't think this assertion should be changed (if
| |
123 int index = id - firstCSSProperty; | 124 int index = id - firstCSSProperty; |
124 return propertyNameStringsPool + propertyNameStringsOffsets[index]; | 125 return propertyNameStringsPool + propertyNameStringsOffsets[index]; |
125 } | 126 } |
126 | 127 |
127 const AtomicString& getPropertyNameAtomicString(CSSPropertyID id) | 128 const AtomicString& getPropertyNameAtomicString(CSSPropertyID id) |
128 { | 129 { |
129 ASSERT(id >= firstCSSProperty && id <= lastUnresolvedCSSProperty); | 130 ASSERT(id >= firstCSSProperty && id <= lastUnresolvedCSSProperty); |
130 int index = id - firstCSSProperty; | 131 int index = id - firstCSSProperty; |
131 static AtomicString* propertyStrings = new AtomicString[lastUnresolvedCSSPro perty]; // Intentionally never destroyed. | 132 static AtomicString* propertyStrings = new AtomicString[lastUnresolvedCSSPro perty]; // Intentionally never destroyed. |
132 AtomicString& propertyString = propertyStrings[index]; | 133 AtomicString& propertyString = propertyStrings[index]; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output | 223 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output |
223 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] | 224 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] |
224 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. | 225 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. |
225 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. | 226 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. |
226 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr ocess.PIPE, universal_newlines=True) | 227 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr ocess.PIPE, universal_newlines=True) |
227 return gperf.communicate(gperf_input)[0] | 228 return gperf.communicate(gperf_input)[0] |
228 | 229 |
229 | 230 |
230 if __name__ == "__main__": | 231 if __name__ == "__main__": |
231 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv) | 232 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv) |
OLD | NEW |