mirror of
https://github.com/servo/servo.git
synced 2025-06-22 08:08:59 +01:00
style: Handle logical shorthand animations with variable references correctly.
When we physicalize the declarations for @keyframes, we end up having a physical declaration with an unparsed value with `from_shorthand` being the logical shorthand. Account for this case properly when substituting custom properties, to avoid panicking. Differential Revision: https://phabricator.services.mozilla.com/D53663
This commit is contained in:
parent
9a43ad996f
commit
a7c50b57a1
2 changed files with 27 additions and 15 deletions
|
@ -257,10 +257,12 @@ class Longhand(object):
|
||||||
def type():
|
def type():
|
||||||
return "longhand"
|
return "longhand"
|
||||||
|
|
||||||
# For a given logical property return all the physical
|
# For a given logical property return all the physical property names
|
||||||
# property names corresponding to it.
|
# corresponding to it.
|
||||||
def all_physical_mapped_properties(self):
|
def all_physical_mapped_properties(self, data):
|
||||||
assert self.logical
|
if not self.logical:
|
||||||
|
return []
|
||||||
|
|
||||||
candidates = [s for s in LOGICAL_SIDES + LOGICAL_SIZES + LOGICAL_CORNERS
|
candidates = [s for s in LOGICAL_SIDES + LOGICAL_SIZES + LOGICAL_CORNERS
|
||||||
if s in self.name] + [s for s in LOGICAL_AXES if self.name.endswith(s)]
|
if s in self.name] + [s for s in LOGICAL_AXES if self.name.endswith(s)]
|
||||||
assert(len(candidates) == 1)
|
assert(len(candidates) == 1)
|
||||||
|
@ -270,7 +272,7 @@ class Longhand(object):
|
||||||
else PHYSICAL_SIZES if logical_side in LOGICAL_SIZES \
|
else PHYSICAL_SIZES if logical_side in LOGICAL_SIZES \
|
||||||
else PHYSICAL_AXES if logical_side in LOGICAL_AXES \
|
else PHYSICAL_AXES if logical_side in LOGICAL_AXES \
|
||||||
else LOGICAL_CORNERS
|
else LOGICAL_CORNERS
|
||||||
return [to_phys(self.name, logical_side, physical_side)
|
return [data.longhands_by_name[to_phys(self.name, logical_side, physical_side)]
|
||||||
for physical_side in physical]
|
for physical_side in physical]
|
||||||
|
|
||||||
def experimental(self, engine):
|
def experimental(self, engine):
|
||||||
|
|
|
@ -1651,13 +1651,25 @@ impl UnparsedValue {
|
||||||
shorthands::${shorthand.ident}::parse_value(&context, input)
|
shorthands::${shorthand.ident}::parse_value(&context, input)
|
||||||
.map(|longhands| {
|
.map(|longhands| {
|
||||||
match longhand_id {
|
match longhand_id {
|
||||||
|
<% seen = set() %>
|
||||||
% for property in shorthand.sub_properties:
|
% for property in shorthand.sub_properties:
|
||||||
LonghandId::${property.camel_case} => {
|
// When animating logical properties, we end up
|
||||||
PropertyDeclaration::${property.camel_case}(
|
// physicalizing the value during the animation, but
|
||||||
longhands.${property.ident}
|
// the value still comes from the logical shorthand.
|
||||||
)
|
//
|
||||||
}
|
// So we need to handle the physical properties too.
|
||||||
|
% for prop in [property] + property.all_physical_mapped_properties(data):
|
||||||
|
% if prop.camel_case not in seen:
|
||||||
|
LonghandId::${prop.camel_case} => {
|
||||||
|
PropertyDeclaration::${prop.camel_case}(
|
||||||
|
longhands.${property.ident}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
<% seen.add(prop.camel_case) %>
|
||||||
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
|
% endfor
|
||||||
|
<% del seen %>
|
||||||
_ => unreachable!()
|
_ => unreachable!()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -2176,14 +2188,12 @@ impl PropertyDeclaration {
|
||||||
let mut ret = self.clone();
|
let mut ret = self.clone();
|
||||||
|
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
% if prop.logical:
|
% for physical_property in prop.all_physical_mapped_properties(data):
|
||||||
% for physical_property in prop.all_physical_mapped_properties():
|
% if physical_property.specified_type() != prop.specified_type():
|
||||||
% if data.longhands_by_name[physical_property].specified_type() != prop.specified_type():
|
|
||||||
<% raise "Logical property %s should share specified value with physical property %s" % \
|
<% raise "Logical property %s should share specified value with physical property %s" % \
|
||||||
(prop.name, physical_property) %>
|
(prop.name, physical_property.name) %>
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
% endif
|
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue