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

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

Issue 1184413005: Clean up some CSSPropertyID helpers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Bring back CSSParserString overload Created 5 years, 6 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 | Source/core/css/PropertySetCSSStyleDeclaration.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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 return static_cast<CSSPropertyID>(value); 48 return static_cast<CSSPropertyID>(value);
49 } 49 }
50 50
51 inline CSSPropertyID resolveCSSPropertyID(CSSPropertyID id) 51 inline CSSPropertyID resolveCSSPropertyID(CSSPropertyID id)
52 { 52 {
53 return convertToCSSPropertyID(id & ~512); 53 return convertToCSSPropertyID(id & ~512);
54 } 54 }
55 55
56 inline bool isPropertyAlias(CSSPropertyID id) { return id & 512; } 56 inline bool isPropertyAlias(CSSPropertyID id) { return id & 512; }
57 57
58 CSSPropertyID unresolvedCSSPropertyID(const WTF::String&);
59
60 CSSPropertyID cssPropertyID(const WTF::String&);
61
58 } // namespace blink 62 } // namespace blink
59 63
60 namespace WTF { 64 namespace WTF {
61 template<> struct DefaultHash<blink::CSSPropertyID> { typedef IntHash<unsigned> Hash; }; 65 template<> struct DefaultHash<blink::CSSPropertyID> { typedef IntHash<unsigned> Hash; };
62 template<> struct HashTraits<blink::CSSPropertyID> : GenericHashTraits<blink::CS SPropertyID> { 66 template<> struct HashTraits<blink::CSSPropertyID> : GenericHashTraits<blink::CS SPropertyID> {
63 static const bool emptyValueIsZero = true; 67 static const bool emptyValueIsZero = true;
64 static void constructDeletedValue(blink::CSSPropertyID& slot, bool) { slot = static_cast<blink::CSSPropertyID>(blink::lastUnresolvedCSSProperty + 1); } 68 static void constructDeletedValue(blink::CSSPropertyID& slot, bool) { slot = static_cast<blink::CSSPropertyID>(blink::lastUnresolvedCSSProperty + 1); }
65 static bool isDeletedValue(blink::CSSPropertyID value) { return value == (bl ink::lastUnresolvedCSSProperty + 1); } 69 static bool isDeletedValue(blink::CSSPropertyID value) { return value == (bl ink::lastUnresolvedCSSProperty + 1); }
66 }; 70 };
67 } 71 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 if (!nextCharacter) 158 if (!nextCharacter)
155 break; 159 break;
156 character = (propertyNamePointer - 2 != cssPropertyName) ? toASCIIUp per(nextCharacter) : nextCharacter; 160 character = (propertyNamePointer - 2 != cssPropertyName) ? toASCIIUp per(nextCharacter) : nextCharacter;
157 } 161 }
158 *resultPointer++ = character; 162 *resultPointer++ = character;
159 } 163 }
160 *resultPointer = '\\0'; 164 *resultPointer = '\\0';
161 return String(result); 165 return String(result);
162 } 166 }
163 167
168 CSSPropertyID cssPropertyID(const String& string)
169 {
170 return resolveCSSPropertyID(unresolvedCSSPropertyID(string));
171 }
172
164 } // namespace blink 173 } // namespace blink
165 """ 174 """
166 175
167 176
168 class CSSPropertyNamesWriter(css_properties.CSSProperties): 177 class CSSPropertyNamesWriter(css_properties.CSSProperties):
169 class_name = "CSSPropertyNames" 178 class_name = "CSSPropertyNames"
170 179
171 def __init__(self, in_file_path): 180 def __init__(self, in_file_path):
172 super(CSSPropertyNamesWriter, self).__init__(in_file_path) 181 super(CSSPropertyNamesWriter, self).__init__(in_file_path)
173 self._outputs = {(self.class_name + ".h"): self.generate_header, 182 self._outputs = {(self.class_name + ".h"): self.generate_header,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output 222 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output
214 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] 223 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n']
215 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. 224 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts.
216 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. 225 gperf_args.append('-D') # Allow duplicate hashes -> More compact code.
217 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr ocess.PIPE, universal_newlines=True) 226 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr ocess.PIPE, universal_newlines=True)
218 return gperf.communicate(gperf_input)[0] 227 return gperf.communicate(gperf_input)[0]
219 228
220 229
221 if __name__ == "__main__": 230 if __name__ == "__main__":
222 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv) 231 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv)
OLDNEW
« no previous file with comments | « no previous file | Source/core/css/PropertySetCSSStyleDeclaration.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698