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

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

Issue 182843002: Drop isindex from HTMLTagNames. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/build/scripts/make_element_factory.py ('k') | Source/core/html/HTMLTagNames.in » ('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 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import sys 6 import sys
7 from collections import defaultdict 7 from collections import defaultdict
8 8
9 import hasher 9 import hasher
10 import in_generator 10 import in_generator
(...skipping 24 matching lines...) Expand all
35 'fallbackJSInterfaceName': '', 35 'fallbackJSInterfaceName': '',
36 } 36 }
37 filters = { 37 filters = {
38 'hash': hasher.hash, 38 'hash': hasher.hash,
39 } 39 }
40 40
41 def __init__(self, in_file_path): 41 def __init__(self, in_file_path):
42 super(MakeElementTypeHelpersWriter, self).__init__(in_file_path) 42 super(MakeElementTypeHelpersWriter, self).__init__(in_file_path)
43 43
44 self.namespace = self.in_file.parameters['namespace'].strip('"') 44 self.namespace = self.in_file.parameters['namespace'].strip('"')
45 self.fallbackInterface = self.in_file.parameters['fallbackInterfaceName' ].strip('"')
45 46
46 assert self.namespace, 'A namespace is required.' 47 assert self.namespace, 'A namespace is required.'
47 48
48 self._outputs = { 49 self._outputs = {
49 (self.namespace + "ElementTypeHelpers.h"): self.generate_helper_head er, 50 (self.namespace + "ElementTypeHelpers.h"): self.generate_helper_head er,
50 } 51 }
51 52
52 self._template_context = { 53 self._template_context = {
53 'namespace': self.namespace, 54 'namespace': self.namespace,
54 'tags': self.in_file.name_dictionaries, 55 'tags': self.in_file.name_dictionaries,
55 } 56 }
56 57
57 tags = self._template_context['tags'] 58 tags = self._template_context['tags']
58 interface_counts = defaultdict(int) 59 interface_counts = defaultdict(int)
59 for tag in tags: 60 for tag in tags:
60 tag['interface'] = self._interface(tag) 61 tag['interface'] = self._interface(tag)
61 interface_counts[tag['interface']] += 1 62 interface_counts[tag['interface']] += 1
62 63
63 for tag in tags: 64 for tag in tags:
64 tag['multipleTagNames'] = interface_counts[tag['interface']] > 1 65 tag['multipleTagNames'] = (interface_counts[tag['interface']] > 1 or tag['interface'] == self.fallbackInterface)
65 66
66 @template_expander.use_jinja("ElementTypeHelpers.h.tmpl", filters=filters) 67 @template_expander.use_jinja("ElementTypeHelpers.h.tmpl", filters=filters)
67 def generate_helper_header(self): 68 def generate_helper_header(self):
68 return self._template_context 69 return self._template_context
69 70
70 def _interface(self, tag): 71 def _interface(self, tag):
71 if tag['interfaceName']: 72 if tag['interfaceName']:
72 return tag['interfaceName'] 73 return tag['interfaceName']
73 name = name_utilities.upper_first(tag['name']) 74 name = name_utilities.upper_first(tag['name'])
74 # FIXME: We shouldn't hard-code HTML here. 75 # FIXME: We shouldn't hard-code HTML here.
75 if name == 'HTML': 76 if name == 'HTML':
76 name = 'Html' 77 name = 'Html'
77 dash = name.find('-') 78 dash = name.find('-')
78 while dash != -1: 79 while dash != -1:
79 name = name[:dash] + name[dash + 1].upper() + name[dash + 2:] 80 name = name[:dash] + name[dash + 1].upper() + name[dash + 2:]
80 dash = name.find('-') 81 dash = name.find('-')
81 return '%s%sElement' % (self.namespace, name) 82 return '%s%sElement' % (self.namespace, name)
82 83
83 if __name__ == "__main__": 84 if __name__ == "__main__":
84 in_generator.Maker(MakeElementTypeHelpersWriter).main(sys.argv) 85 in_generator.Maker(MakeElementTypeHelpersWriter).main(sys.argv)
OLDNEW
« no previous file with comments | « Source/build/scripts/make_element_factory.py ('k') | Source/core/html/HTMLTagNames.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698