| 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 26 matching lines...) Expand all Loading... |
| 37 const int numCSSProperties = %(properties_count)s; | 37 const int numCSSProperties = %(properties_count)s; |
| 38 const int lastCSSProperty = %(last_property_id)d; | 38 const int lastCSSProperty = %(last_property_id)d; |
| 39 const int lastUnresolvedCSSProperty = %(last_unresolved_property_id)d; | 39 const int lastUnresolvedCSSProperty = %(last_unresolved_property_id)d; |
| 40 const size_t maxCSSPropertyNameLength = %(max_name_length)d; | 40 const size_t maxCSSPropertyNameLength = %(max_name_length)d; |
| 41 | 41 |
| 42 const char* getPropertyName(CSSPropertyID); | 42 const char* getPropertyName(CSSPropertyID); |
| 43 const WTF::AtomicString& getPropertyNameAtomicString(CSSPropertyID); | 43 const WTF::AtomicString& getPropertyNameAtomicString(CSSPropertyID); |
| 44 WTF::String getPropertyNameString(CSSPropertyID); | 44 WTF::String getPropertyNameString(CSSPropertyID); |
| 45 WTF::String getJSPropertyName(CSSPropertyID); | 45 WTF::String getJSPropertyName(CSSPropertyID); |
| 46 | 46 |
| 47 inline bool isCSSPropertyIDWithName(int id) |
| 48 { |
| 49 return id >= firstCSSProperty && id <= lastUnresolvedCSSProperty; |
| 50 } |
| 51 |
| 52 inline bool isValidCSSPropertyID(CSSPropertyID id) |
| 53 { |
| 54 return id != CSSPropertyInvalid; |
| 55 } |
| 56 |
| 47 inline CSSPropertyID convertToCSSPropertyID(int value) | 57 inline CSSPropertyID convertToCSSPropertyID(int value) |
| 48 { | 58 { |
| 49 ASSERT(value >= CSSPropertyInvalid && value <= lastCSSProperty); | 59 DCHECK(value >= CSSPropertyInvalid && value <= lastCSSProperty); |
| 50 return static_cast<CSSPropertyID>(value); | 60 return static_cast<CSSPropertyID>(value); |
| 51 } | 61 } |
| 52 | 62 |
| 53 inline CSSPropertyID resolveCSSPropertyID(CSSPropertyID id) | 63 inline CSSPropertyID resolveCSSPropertyID(CSSPropertyID id) |
| 54 { | 64 { |
| 55 return convertToCSSPropertyID(id & ~512); | 65 return convertToCSSPropertyID(id & ~512); |
| 56 } | 66 } |
| 57 | 67 |
| 58 inline bool isPropertyAlias(CSSPropertyID id) { return id & 512; } | 68 inline bool isPropertyAlias(CSSPropertyID id) { return id & 512; } |
| 59 | 69 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 %%%% | 121 %%%% |
| 112 %(property_to_enum_map)s | 122 %(property_to_enum_map)s |
| 113 %%%% | 123 %%%% |
| 114 const Property* findProperty(register const char* str, register unsigned int len
) | 124 const Property* findProperty(register const char* str, register unsigned int len
) |
| 115 { | 125 { |
| 116 return %(class_name)sHash::findPropertyImpl(str, len); | 126 return %(class_name)sHash::findPropertyImpl(str, len); |
| 117 } | 127 } |
| 118 | 128 |
| 119 const char* getPropertyName(CSSPropertyID id) | 129 const char* getPropertyName(CSSPropertyID id) |
| 120 { | 130 { |
| 121 ASSERT(id >= firstCSSProperty && id <= lastUnresolvedCSSProperty); | 131 DCHECK(isCSSPropertyIDWithName(id)); |
| 122 int index = id - firstCSSProperty; | 132 int index = id - firstCSSProperty; |
| 123 return propertyNameStringsPool + propertyNameStringsOffsets[index]; | 133 return propertyNameStringsPool + propertyNameStringsOffsets[index]; |
| 124 } | 134 } |
| 125 | 135 |
| 126 const AtomicString& getPropertyNameAtomicString(CSSPropertyID id) | 136 const AtomicString& getPropertyNameAtomicString(CSSPropertyID id) |
| 127 { | 137 { |
| 128 ASSERT(id >= firstCSSProperty && id <= lastUnresolvedCSSProperty); | 138 DCHECK(isCSSPropertyIDWithName(id)); |
| 129 int index = id - firstCSSProperty; | 139 int index = id - firstCSSProperty; |
| 130 static AtomicString* propertyStrings = new AtomicString[lastUnresolvedCSSPro
perty]; // Intentionally never destroyed. | 140 static AtomicString* propertyStrings = new AtomicString[lastUnresolvedCSSPro
perty]; // Intentionally never destroyed. |
| 131 AtomicString& propertyString = propertyStrings[index]; | 141 AtomicString& propertyString = propertyStrings[index]; |
| 132 if (propertyString.isNull()) | 142 if (propertyString.isNull()) |
| 133 propertyString = AtomicString(propertyNameStringsPool + propertyNameStri
ngsOffsets[index]); | 143 propertyString = AtomicString(propertyNameStringsPool + propertyNameStri
ngsOffsets[index]); |
| 134 return propertyString; | 144 return propertyString; |
| 135 } | 145 } |
| 136 | 146 |
| 137 String getPropertyNameString(CSSPropertyID id) | 147 String getPropertyNameString(CSSPropertyID id) |
| 138 { | 148 { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output | 229 # FIXME: If we could depend on Python 2.7, we would use subprocess.check
_output |
| 220 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] | 230 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] |
| 221 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. | 231 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. |
| 222 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. | 232 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. |
| 223 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE, universal_newlines=True) | 233 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr
ocess.PIPE, universal_newlines=True) |
| 224 return gperf.communicate(gperf_input)[0] | 234 return gperf.communicate(gperf_input)[0] |
| 225 | 235 |
| 226 | 236 |
| 227 if __name__ == "__main__": | 237 if __name__ == "__main__": |
| 228 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv) | 238 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv) |
| OLD | NEW |