зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1491622 - Deindent the non-css-wide-keyword-related code from cascade_property. r=xidorn
There's no good reason we construct a DeclaredValue as an intermediate step. Differential Revision: https://phabricator.services.mozilla.com/D5977 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8f07de38bf
Коммит
7c47b574fc
|
@ -312,20 +312,6 @@
|
||||||
declaration: &PropertyDeclaration,
|
declaration: &PropertyDeclaration,
|
||||||
context: &mut computed::Context,
|
context: &mut computed::Context,
|
||||||
) {
|
) {
|
||||||
let value = match *declaration {
|
|
||||||
PropertyDeclaration::${property.camel_case}(ref value) => {
|
|
||||||
DeclaredValue::Value(value)
|
|
||||||
},
|
|
||||||
PropertyDeclaration::CSSWideKeyword(ref declaration) => {
|
|
||||||
debug_assert_eq!(declaration.id, LonghandId::${property.camel_case});
|
|
||||||
DeclaredValue::CSSWideKeyword(declaration.keyword)
|
|
||||||
},
|
|
||||||
PropertyDeclaration::WithVariables(..) => {
|
|
||||||
panic!("variables should already have been substituted")
|
|
||||||
}
|
|
||||||
_ => panic!("entered the wrong cascade_property() implementation"),
|
|
||||||
};
|
|
||||||
|
|
||||||
context.for_non_inherited_property =
|
context.for_non_inherited_property =
|
||||||
% if property.style_struct.inherited:
|
% if property.style_struct.inherited:
|
||||||
None;
|
None;
|
||||||
|
@ -333,78 +319,86 @@
|
||||||
Some(LonghandId::${property.camel_case});
|
Some(LonghandId::${property.camel_case});
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
match value {
|
let specified_value = match *declaration {
|
||||||
DeclaredValue::Value(specified_value) => {
|
PropertyDeclaration::${property.camel_case}(ref value) => value,
|
||||||
% if property.ident in SYSTEM_FONT_LONGHANDS and product == "gecko":
|
PropertyDeclaration::CSSWideKeyword(ref declaration) => {
|
||||||
if let Some(sf) = specified_value.get_system() {
|
debug_assert_eq!(declaration.id, LonghandId::${property.camel_case});
|
||||||
longhands::system_font::resolve_system_font(sf, context);
|
match declaration.keyword {
|
||||||
|
% if not data.current_style_struct.inherited:
|
||||||
|
CSSWideKeyword::Unset |
|
||||||
|
% endif
|
||||||
|
CSSWideKeyword::Initial => {
|
||||||
|
% if property.ident == "font_size":
|
||||||
|
computed::FontSize::cascade_initial_font_size(context);
|
||||||
|
% else:
|
||||||
|
context.builder.reset_${property.ident}();
|
||||||
|
% endif
|
||||||
|
},
|
||||||
|
% if data.current_style_struct.inherited:
|
||||||
|
CSSWideKeyword::Unset |
|
||||||
|
% endif
|
||||||
|
CSSWideKeyword::Inherit => {
|
||||||
|
% if not property.style_struct.inherited:
|
||||||
|
context.rule_cache_conditions.borrow_mut().set_uncacheable();
|
||||||
|
% endif
|
||||||
|
% if property.ident == "font_size":
|
||||||
|
computed::FontSize::cascade_inherit_font_size(context);
|
||||||
|
% else:
|
||||||
|
context.builder.inherit_${property.ident}();
|
||||||
|
% endif
|
||||||
}
|
}
|
||||||
% endif
|
|
||||||
% if not property.style_struct.inherited and property.logical:
|
|
||||||
context.rule_cache_conditions.borrow_mut()
|
|
||||||
.set_writing_mode_dependency(context.builder.writing_mode);
|
|
||||||
% endif
|
|
||||||
% if property.is_vector:
|
|
||||||
// In the case of a vector property we want to pass
|
|
||||||
// down an iterator so that this can be computed
|
|
||||||
// without allocation
|
|
||||||
//
|
|
||||||
// However, computing requires a context, but the
|
|
||||||
// style struct being mutated is on the context. We
|
|
||||||
// temporarily remove it, mutate it, and then put it
|
|
||||||
// back. Vector longhands cannot touch their own
|
|
||||||
// style struct whilst computing, else this will
|
|
||||||
// panic.
|
|
||||||
let mut s =
|
|
||||||
context.builder.take_${data.current_style_struct.name_lower}();
|
|
||||||
{
|
|
||||||
let iter = specified_value.compute_iter(context);
|
|
||||||
s.set_${property.ident}(iter);
|
|
||||||
}
|
|
||||||
context.builder.put_${data.current_style_struct.name_lower}(s);
|
|
||||||
% else:
|
|
||||||
% if property.boxed:
|
|
||||||
let computed = (**specified_value).to_computed_value(context);
|
|
||||||
% else:
|
|
||||||
let computed = specified_value.to_computed_value(context);
|
|
||||||
% endif
|
|
||||||
% if property.ident == "font_size":
|
|
||||||
specified::FontSize::cascade_specified_font_size(
|
|
||||||
context,
|
|
||||||
&specified_value,
|
|
||||||
computed,
|
|
||||||
);
|
|
||||||
% else:
|
|
||||||
context.builder.set_${property.ident}(computed)
|
|
||||||
% endif
|
|
||||||
% endif
|
|
||||||
}
|
|
||||||
DeclaredValue::CSSWideKeyword(keyword) => match keyword {
|
|
||||||
% if not data.current_style_struct.inherited:
|
|
||||||
CSSWideKeyword::Unset |
|
|
||||||
% endif
|
|
||||||
CSSWideKeyword::Initial => {
|
|
||||||
% if property.ident == "font_size":
|
|
||||||
computed::FontSize::cascade_initial_font_size(context);
|
|
||||||
% else:
|
|
||||||
context.builder.reset_${property.ident}();
|
|
||||||
% endif
|
|
||||||
},
|
|
||||||
% if data.current_style_struct.inherited:
|
|
||||||
CSSWideKeyword::Unset |
|
|
||||||
% endif
|
|
||||||
CSSWideKeyword::Inherit => {
|
|
||||||
% if not property.style_struct.inherited:
|
|
||||||
context.rule_cache_conditions.borrow_mut().set_uncacheable();
|
|
||||||
% endif
|
|
||||||
% if property.ident == "font_size":
|
|
||||||
computed::FontSize::cascade_inherit_font_size(context);
|
|
||||||
% else:
|
|
||||||
context.builder.inherit_${property.ident}();
|
|
||||||
% endif
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
PropertyDeclaration::WithVariables(..) => {
|
||||||
|
panic!("variables should already have been substituted")
|
||||||
|
}
|
||||||
|
_ => panic!("entered the wrong cascade_property() implementation"),
|
||||||
|
};
|
||||||
|
|
||||||
|
% if property.ident in SYSTEM_FONT_LONGHANDS and product == "gecko":
|
||||||
|
if let Some(sf) = specified_value.get_system() {
|
||||||
|
longhands::system_font::resolve_system_font(sf, context);
|
||||||
|
}
|
||||||
|
% endif
|
||||||
|
|
||||||
|
% if not property.style_struct.inherited and property.logical:
|
||||||
|
context.rule_cache_conditions.borrow_mut()
|
||||||
|
.set_writing_mode_dependency(context.builder.writing_mode);
|
||||||
|
% endif
|
||||||
|
|
||||||
|
% if property.is_vector:
|
||||||
|
// In the case of a vector property we want to pass down an
|
||||||
|
// iterator so that this can be computed without allocation.
|
||||||
|
//
|
||||||
|
// However, computing requires a context, but the style struct
|
||||||
|
// being mutated is on the context. We temporarily remove it,
|
||||||
|
// mutate it, and then put it back. Vector longhands cannot
|
||||||
|
// touch their own style struct whilst computing, else this will
|
||||||
|
// panic.
|
||||||
|
let mut s =
|
||||||
|
context.builder.take_${data.current_style_struct.name_lower}();
|
||||||
|
{
|
||||||
|
let iter = specified_value.compute_iter(context);
|
||||||
|
s.set_${property.ident}(iter);
|
||||||
|
}
|
||||||
|
context.builder.put_${data.current_style_struct.name_lower}(s);
|
||||||
|
% else:
|
||||||
|
% if property.boxed:
|
||||||
|
let computed = (**specified_value).to_computed_value(context);
|
||||||
|
% else:
|
||||||
|
let computed = specified_value.to_computed_value(context);
|
||||||
|
% endif
|
||||||
|
% if property.ident == "font_size":
|
||||||
|
specified::FontSize::cascade_specified_font_size(
|
||||||
|
context,
|
||||||
|
&specified_value,
|
||||||
|
computed,
|
||||||
|
);
|
||||||
|
% else:
|
||||||
|
context.builder.set_${property.ident}(computed)
|
||||||
|
% endif
|
||||||
|
% endif
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_declared<'i, 't>(
|
pub fn parse_declared<'i, 't>(
|
||||||
|
|
Загрузка…
Ссылка в новой задаче