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

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

Issue 2759343002: Generate inherited nonproperties insideLink and hasSimpleUnderline. (Closed)
Patch Set: Rebase Created 3 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 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 math 6 import math
7 import sys 7 import sys
8 8
9 import json5_generator 9 import json5_generator
10 import template_expander 10 import template_expander
11 import make_style_builder 11 import make_style_builder
12 12
13 from name_utilities import ( 13 from name_utilities import (
14 enum_for_css_keyword, enum_type_name, enum_value_name, class_member_name, me thod_name 14 enum_for_css_keyword, enum_type_name, enum_value_name, class_member_name, me thod_name
15 ) 15 )
16 16
17 17
18 # Temporary hard-coded list of fields that are not CSS properties. 18 # Temporary hard-coded list of fields that are not CSS properties.
19 # TODO(shend): Put this into its own JSON5 file. 19 # TODO(shend): Put this into its own JSON5 file.
20 NONPROPERTIES = [ 20 NONPROPERTIES = [
21 {'name': 'IsLink', 'field_template': 'monotonic_flag', 21 {'name': 'IsLink', 'field_template': 'monotonic_flag',
22 'inherited': False, 'independent': False}, 22 'inherited': False, 'independent': False},
23 {'name': 'InsideLink', 'field_template': 'keyword', 'initial_keyword': 'not- inside-link',
24 'keywords': ['not-inside-link', 'inside-unvisited-link', 'inside-visited-li nk'],
25 'inherited': True, 'independent': False},
23 # Style can not be shared. 26 # Style can not be shared.
24 {'name': 'Unique', 'field_template': 'monotonic_flag', 27 {'name': 'Unique', 'field_template': 'monotonic_flag',
25 'inherited': False, 'independent': False}, 28 'inherited': False, 'independent': False},
26 # Whether this style is affected by these pseudo-classes. 29 # Whether this style is affected by these pseudo-classes.
27 {'name': 'AffectedByFocus', 'field_template': 'monotonic_flag', 30 {'name': 'AffectedByFocus', 'field_template': 'monotonic_flag',
28 'inherited': False, 'independent': False}, 31 'inherited': False, 'independent': False},
29 {'name': 'AffectedByHover', 'field_template': 'monotonic_flag', 32 {'name': 'AffectedByHover', 'field_template': 'monotonic_flag',
30 'inherited': False, 'independent': False}, 33 'inherited': False, 'independent': False},
31 {'name': 'AffectedByActive', 'field_template': 'monotonic_flag', 34 {'name': 'AffectedByActive', 'field_template': 'monotonic_flag',
32 'inherited': False, 'independent': False}, 35 'inherited': False, 'independent': False},
33 {'name': 'AffectedByDrag', 'field_template': 'monotonic_flag', 36 {'name': 'AffectedByDrag', 'field_template': 'monotonic_flag',
34 'inherited': False, 'independent': False}, 37 'inherited': False, 'independent': False},
35 # A non-inherited property references a variable or @apply is used 38 # A non-inherited property references a variable or @apply is used
36 {'name': 'HasVariableReferenceFromNonInheritedProperty', 'field_template': ' monotonic_flag', 39 {'name': 'HasVariableReferenceFromNonInheritedProperty', 'field_template': ' monotonic_flag',
37 'inherited': False, 'independent': False}, 40 'inherited': False, 'independent': False},
38 # Explicitly inherits a non-inherited property 41 # Explicitly inherits a non-inherited property
39 {'name': 'HasExplicitlyInheritedProperties', 'field_template': 'monotonic_fl ag', 42 {'name': 'HasExplicitlyInheritedProperties', 'field_template': 'monotonic_fl ag',
40 'inherited': False, 'independent': False}, 43 'inherited': False, 'independent': False},
41 # These properties only have generated storage, and their methods are handwr itten in ComputedStyle. 44 # These properties only have generated storage, and their methods are handwr itten in ComputedStyle.
42 # TODO(shend): Remove these fields and delete the 'storage_only' template. 45 # TODO(shend): Remove these fields and delete the 'storage_only' template.
43 {'name': 'EmptyState', 'field_template': 'storage_only', 'size': 1, 'default _value': 'false', 46 {'name': 'EmptyState', 'field_template': 'storage_only', 'size': 1, 'default _value': 'false',
44 'type_name': 'bool', 'inherited': False, 'independent': False}, 47 'type_name': 'bool', 'inherited': False, 'independent': False},
45 {'name': 'StyleType', 'field_template': 'storage_only', 'size': 6, 'default_ value': '0', 48 {'name': 'StyleType', 'field_template': 'storage_only', 'size': 6, 'default_ value': '0',
46 'type_name': 'PseudoId', 'inherited': False, 'independent': False}, 49 'type_name': 'PseudoId', 'inherited': False, 'independent': False},
47 {'name': 'PseudoBits', 'field_template': 'storage_only', 'size': 8, 'default _value': 'PseudoIdNone', 50 {'name': 'PseudoBits', 'field_template': 'storage_only', 'size': 8, 'default _value': 'PseudoIdNone',
48 'type_name': 'PseudoId', 'inherited': False, 'independent': False}, 51 'type_name': 'PseudoId', 'inherited': False, 'independent': False},
52 # True if 'underline solid' is the only text decoration on this element.
53 {'name': 'HasSimpleUnderline', 'field_template': 'storage_only', 'size': 1, 'default_value': 'false',
54 'type_name': 'bool', 'inherited': True, 'independent': False},
49 ] 55 ]
50 56
51 57
52 class Field(object): 58 class Field(object):
53 """ 59 """
54 The generated ComputedStyle object is made up of a series of Fields. 60 The generated ComputedStyle object is made up of a series of Fields.
55 Each Field has a name, size, type, etc, and a bunch of attributes to 61 Each Field has a name, size, type, etc, and a bunch of attributes to
56 determine which methods it will be used in. 62 determine which methods it will be used in.
57 63
58 A Field also has enough information to use any storage type in C++, such as 64 A Field also has enough information to use any storage type in C++, such as
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 'mapping': [(enum_value_name(k), enum_for_css_keyword(k)) fo r k in property_['keywords']], 361 'mapping': [(enum_value_name(k), enum_for_css_keyword(k)) fo r k in property_['keywords']],
356 } 362 }
357 363
358 return { 364 return {
359 'include_paths': self._include_paths, 365 'include_paths': self._include_paths,
360 'mappings': mappings, 366 'mappings': mappings,
361 } 367 }
362 368
363 if __name__ == '__main__': 369 if __name__ == '__main__':
364 json5_generator.Maker(ComputedStyleBaseWriter).main() 370 json5_generator.Maker(ComputedStyleBaseWriter).main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698