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

Side by Side Diff: third_party/WebKit/Source/build/scripts/make_css_property_names.py

Issue 2228313002: Make a function to query whether a CSSPropertyID is valid and whether it has a name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@asan
Patch Set: Revert incorrect changes Created 4 years, 2 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 isPropertyIDWithName(int id)
rune 2016/09/30 09:48:33 Should the name here also include "CSS"? isCSSProp
meade_UTC10 2016/10/06 04:42:05 Done.
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
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(isPropertyIDWithName(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(isPropertyIDWithName(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
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)
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698