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

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

Issue 880983009: Fix isInternalProperty when there are no internal properties (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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 | 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 #!/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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 character = (propertyNamePointer - 2 != cssPropertyName) ? toASCIIUp per(nextCharacter) : nextCharacter; 157 character = (propertyNamePointer - 2 != cssPropertyName) ? toASCIIUp per(nextCharacter) : nextCharacter;
158 } 158 }
159 *resultPointer++ = character; 159 *resultPointer++ = character;
160 } 160 }
161 *resultPointer = '\\0'; 161 *resultPointer = '\\0';
162 return String(result); 162 return String(result);
163 } 163 }
164 164
165 bool isInternalProperty(CSSPropertyID id) 165 bool isInternalProperty(CSSPropertyID id)
166 { 166 {
167 switch (id) { 167 %(internal_properties)s
168 %(internal_properties)s
169 return true;
170 default:
171 return false;
172 }
173 } 168 }
174 169
175 } // namespace blink 170 } // namespace blink
176 """ 171 """
177 172
178 173
179 class CSSPropertyNamesWriter(css_properties.CSSProperties): 174 class CSSPropertyNamesWriter(css_properties.CSSProperties):
180 class_name = "CSSPropertyNames" 175 class_name = "CSSPropertyNames"
181 176
182 def __init__(self, in_file_path): 177 def __init__(self, in_file_path):
(...skipping 20 matching lines...) Expand all
203 property_offsets = [] 198 property_offsets = []
204 current_offset = 0 199 current_offset = 0
205 for property in self._properties_list: 200 for property in self._properties_list:
206 property_offsets.append(current_offset) 201 property_offsets.append(current_offset)
207 current_offset += len(property["name"]) + 1 202 current_offset += len(property["name"]) + 1
208 203
209 css_name_and_enum_pairs = [(property['name'], property_id) for property_ id, property in self._properties.items()] 204 css_name_and_enum_pairs = [(property['name'], property_id) for property_ id, property in self._properties.items()]
210 for name, aliased_name in self._aliases.items(): 205 for name, aliased_name in self._aliases.items():
211 css_name_and_enum_pairs.append((name, css_properties.css_name_to_enu m(aliased_name))) 206 css_name_and_enum_pairs.append((name, css_properties.css_name_to_enu m(aliased_name)))
212 207
208 internal_properties = ""
209 internal_properties = '\n'.join("case %s:" % property_id for property_id , property in self._properties.items() if property['is_internal'])
210 if internal_properties:
211 internal_properties = "switch (id) {\n " +\
212 internal_properties +\
213 "\n return true;" +\
214 "\n default:" +\
215 "\n return false;" +\
216 "\n }\n"
217 else:
218 internal_properties = "return false;"
219
213 gperf_input = GPERF_TEMPLATE % { 220 gperf_input = GPERF_TEMPLATE % {
214 'license': license.license_for_generated_cpp(), 221 'license': license.license_for_generated_cpp(),
215 'class_name': self.class_name, 222 'class_name': self.class_name,
216 'property_name_strings': '\n'.join(map(lambda property: ' "%(name )s\\0"' % property, self._properties_list)), 223 'property_name_strings': '\n'.join(map(lambda property: ' "%(name )s\\0"' % property, self._properties_list)),
217 'property_name_offsets': '\n'.join(map(lambda offset: ' %d,' % of fset, property_offsets)), 224 'property_name_offsets': '\n'.join(map(lambda offset: ' %d,' % of fset, property_offsets)),
218 'property_to_enum_map': '\n'.join(map(lambda property: '%s, %s' % pr operty, css_name_and_enum_pairs)), 225 'property_to_enum_map': '\n'.join(map(lambda property: '%s, %s' % pr operty, css_name_and_enum_pairs)),
219 'internal_properties': '\n'.join("case %s:" % property_id for proper ty_id, property in self._properties.items() if property['is_internal']), 226 'internal_properties': internal_properties,
220 } 227 }
221 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output 228 # FIXME: If we could depend on Python 2.7, we would use subprocess.check _output
222 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n'] 229 gperf_args = [self.gperf_path, '--key-positions=*', '-P', '-n']
223 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. 230 gperf_args.extend(['-m', '50']) # Pick best of 50 attempts.
224 gperf_args.append('-D') # Allow duplicate hashes -> More compact code. 231 gperf_args.append('-D') # Allow duplicate hashes -> More compact code.
225 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr ocess.PIPE, universal_newlines=True) 232 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subpr ocess.PIPE, universal_newlines=True)
226 return gperf.communicate(gperf_input)[0] 233 return gperf.communicate(gperf_input)[0]
227 234
228 235
229 if __name__ == "__main__": 236 if __name__ == "__main__":
230 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv) 237 in_generator.Maker(CSSPropertyNamesWriter).main(sys.argv)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698