Commit a51698b2 authored by Kent Tamura's avatar Kent Tamura Committed by Chromium LUCI CQ

Style: Allow multiple aliases of a single CSS property in css_properties.json5

make_css_property_names.py supports multiple aliases.
Before this CL, |<a resolved property id> + 1024| was an an alias.
Since this CL, |<a resolved property id> + 1024 * n| is an alias where
|n| is a natural number.

This CL will be necessary for unprefixing -webkit-text-emphasis, which
already has -epub-text-emphasis alias.

This CL has no behavior changes for now.

Bug: 666433
Change-Id: I6e620b55f07fde7542d1bd04fa25beaad8ee659e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2596466Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838403}
parent ee6a07f7
...@@ -67,6 +67,7 @@ class CSSProperties(object): ...@@ -67,6 +67,7 @@ class CSSProperties(object):
# in the various generators for ComputedStyle. # in the various generators for ComputedStyle.
self._field_alias_expander = FieldAliasExpander(file_paths[1]) self._field_alias_expander = FieldAliasExpander(file_paths[1])
# _alias_offset must be a power of 2.
self._alias_offset = 1024 self._alias_offset = 1024
# 0: CSSPropertyID::kInvalid # 0: CSSPropertyID::kInvalid
# 1: CSSPropertyID::kVariable # 1: CSSPropertyID::kVariable
...@@ -224,7 +225,7 @@ class CSSProperties(object): ...@@ -224,7 +225,7 @@ class CSSProperties(object):
updated_alias['enum_key'] = enum_key_for_css_property_alias( updated_alias['enum_key'] = enum_key_for_css_property_alias(
alias['name']) alias['name'])
updated_alias['enum_value'] = aliased_property['enum_value'] + \ updated_alias['enum_value'] = aliased_property['enum_value'] + \
self._alias_offset self._alias_offset * len(aliased_property['aliases'])
updated_alias['superclass'] = 'CSSUnresolvedProperty' updated_alias['superclass'] = 'CSSUnresolvedProperty'
updated_alias['namespace_group'] = \ updated_alias['namespace_group'] = \
'Shorthand' if aliased_property['longhands'] else 'Longhand' 'Shorthand' if aliased_property['longhands'] else 'Longhand'
......
...@@ -29,8 +29,8 @@ class CSSPropertyNamesWriter(json5_generator.Writer): ...@@ -29,8 +29,8 @@ class CSSPropertyNamesWriter(json5_generator.Writer):
'core/css/templates/css_property_names.h.tmpl') 'core/css/templates/css_property_names.h.tmpl')
def generate_header(self): def generate_header(self):
return { return {
'alias_offset': 'alias_mask':
self._css_properties.alias_offset, hex(0xffffffff - self._css_properties.alias_offset + 1),
'class_name': 'class_name':
self.class_name, self.class_name,
'property_enums': 'property_enums':
......
...@@ -83,10 +83,10 @@ inline CSSPropertyID convertToCSSPropertyID(int value) ...@@ -83,10 +83,10 @@ inline CSSPropertyID convertToCSSPropertyID(int value)
inline CSSPropertyID resolveCSSPropertyID(CSSPropertyID id) inline CSSPropertyID resolveCSSPropertyID(CSSPropertyID id)
{ {
return convertToCSSPropertyID(static_cast<int>(id) & ~{{alias_offset}}); return convertToCSSPropertyID(static_cast<int>(id) & ~{{alias_mask}});
} }
inline bool isPropertyAlias(CSSPropertyID id) { return static_cast<int>(id) & {{alias_offset}}; } inline bool isPropertyAlias(CSSPropertyID id) { return static_cast<int>(id) & {{alias_mask}}; }
CSSPropertyID CORE_EXPORT unresolvedCSSPropertyID(const ExecutionContext*, const WTF::String&); CSSPropertyID CORE_EXPORT unresolvedCSSPropertyID(const ExecutionContext*, const WTF::String&);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment