Skip to content

Commit 08e173a

Browse files
committed
servo: Merge #19956 - Generate some PropertyDeclaration methods by hand 🐉🐲 (from servo:derive-all-the-things); r=emilio
We rely on rust-lang/rfcs#2195 to make some enums share the same discriminants by definition. This fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1428285. Source-Repo: https://github.com/servo/servo Source-Revision: 9faf0cdce50379dfb8125d7a9c913babd56382e2 UltraBlame original commit: 8bd0a2507ccbb5fad4588e43bbca20eead87a2bb
1 parent 7813899 commit 08e173a

File tree

6 files changed

+347
-156
lines changed

6 files changed

+347
-156
lines changed

servo/components/style/properties/data.py

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def __init__(self, style_struct, name, spec=None, animation_value_type=None, key
149149
predefined_type=None, servo_pref=None, gecko_pref=None,
150150
enabled_in="content", need_index=False,
151151
gecko_ffi_name=None,
152+
is_gecko_size_type_hack=False,
152153
allowed_in_keyframe_block=True, cast_type='u8',
153154
logical=False, alias=None, extra_prefixes=None, boxed=False,
154155
flags=None, allowed_in_page_rule=False, allow_quirks=False, ignored_when_colors_disabled=False,
@@ -185,6 +186,7 @@ def __init__(self, style_struct, name, spec=None, animation_value_type=None, key
185186
self.allow_quirks = allow_quirks
186187
self.ignored_when_colors_disabled = ignored_when_colors_disabled
187188
self.is_vector = vector
189+
self.is_gecko_size_type_hack = is_gecko_size_type_hack
188190

189191

190192

servo/components/style/properties/declaration_block.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,9 @@ impl PropertyDeclarationBlock {
430430
AllShorthand::NotSet => {}
431431
AllShorthand::CSSWideKeyword(keyword) => {
432432
for &id in ShorthandId::All.longhands() {
433-
let decl = PropertyDeclaration::CSSWideKeyword(id, keyword);
433+
let decl = PropertyDeclaration::CSSWideKeyword(
434+
WideKeywordDeclaration { id, keyword },
435+
);
434436
changed |= self.push(
435437
decl,
436438
importance,
@@ -440,7 +442,9 @@ impl PropertyDeclarationBlock {
440442
}
441443
AllShorthand::WithVariables(unparsed) => {
442444
for &id in ShorthandId::All.longhands() {
443-
let decl = PropertyDeclaration::WithVariables(id, unparsed.clone());
445+
let decl = PropertyDeclaration::WithVariables(
446+
VariableDeclaration { id, value: unparsed.clone() },
447+
);
444448
changed |= self.push(
445449
decl,
446450
importance,
@@ -639,14 +643,15 @@ impl PropertyDeclarationBlock {
639643

640644

641645

642-
(&PropertyDeclaration::WithVariables(id, ref unparsed),
643-
Some(ref _computed_values)) => {
644-
unparsed.substitute_variables(
645-
id,
646+
(
647+
&PropertyDeclaration::WithVariables(ref declaration),
648+
Some(ref _computed_values),
649+
) => {
650+
declaration.value.substitute_variables(
651+
declaration.id,
646652
custom_properties.as_ref(),
647653
QuirksMode::NoQuirks,
648-
)
649-
.to_css(dest)
654+
).to_css(dest)
650655
},
651656
(ref d, _) => d.to_css(dest),
652657
}
@@ -726,8 +731,8 @@ impl PropertyDeclarationBlock {
726731
let mut builder = CustomPropertiesBuilder::new(inherited_custom_properties);
727732

728733
for declaration in self.normal_declaration_iter() {
729-
if let PropertyDeclaration::Custom(ref name, ref value) = *declaration {
730-
builder.cascade(name, value.borrow());
734+
if let PropertyDeclaration::Custom(ref declaration) = *declaration {
735+
builder.cascade(&declaration.name, declaration.value.borrow());
731736
}
732737
}
733738

servo/components/style/properties/helpers.mako.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@
302302
PropertyDeclaration::${property.camel_case}(ref value) => {
303303
DeclaredValue::Value(value)
304304
},
305-
PropertyDeclaration::CSSWideKeyword(id, value) => {
306-
debug_assert!(id == LonghandId::${property.camel_case});
307-
DeclaredValue::CSSWideKeyword(value)
305+
PropertyDeclaration::CSSWideKeyword(ref declaration) => {
306+
debug_assert!(declaration.id == LonghandId::${property.camel_case});
307+
DeclaredValue::CSSWideKeyword(declaration.keyword)
308308
},
309309
PropertyDeclaration::WithVariables(..) => {
310310
panic!("variables should already have been substituted")
@@ -903,6 +903,7 @@
903903
<%call expr="longhand(name,
904904
predefined_type=length_type,
905905
logical=logical,
906+
is_gecko_size_type_hack=True,
906907
**kwargs)">
907908
% if not logical:
908909
use values::specified::AllowQuirks;

servo/components/style/properties/helpers/animated_properties.mako.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,14 @@ impl AnimationValue {
435435
},
436436
% endif
437437
% endfor
438-
PropertyDeclaration::CSSWideKeyword(id, keyword) => {
439-
match id {
438+
PropertyDeclaration::CSSWideKeyword(ref declaration) => {
439+
match declaration.id {
440440
// We put all the animatable properties first in the hopes
441441
// that it might increase match locality.
442442
% for prop in data.longhands:
443443
% if prop.animatable:
444444
LonghandId::${prop.camel_case} => {
445-
let style_struct = match keyword {
445+
let style_struct = match declaration.keyword {
446446
% if not prop.style_struct.inherited:
447447
CSSWideKeyword::Unset |
448448
% endif
@@ -472,15 +472,15 @@ impl AnimationValue {
472472
% endfor
473473
}
474474
},
475-
PropertyDeclaration::WithVariables(id, ref unparsed) => {
475+
PropertyDeclaration::WithVariables(ref declaration) => {
476476
let substituted = {
477477
let custom_properties =
478478
extra_custom_properties.or_else(|| context.style().custom_properties());
479479

480-
unparsed.substitute_variables(
481-
id,
480+
declaration.value.substitute_variables(
481+
declaration.id,
482482
custom_properties,
483-
context.quirks_mode
483+
context.quirks_mode,
484484
)
485485
};
486486
return AnimationValue::from_declaration(

0 commit comments

Comments
 (0)