mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Cascade: skip duplicated properties before rather than after a virtual call.
This commit is contained in:
parent
0b4877590f
commit
86562992da
4 changed files with 31 additions and 36 deletions
|
@ -245,7 +245,6 @@
|
|||
inherited_style: &ComputedValues,
|
||||
default_style: &Arc<ComputedValues>,
|
||||
context: &mut computed::Context,
|
||||
seen: &mut PropertyBitField,
|
||||
cacheable: &mut bool,
|
||||
cascade_info: &mut Option<<&mut CascadeInfo>,
|
||||
error_reporter: &mut StdBox<ParseErrorReporter + Send>) {
|
||||
|
@ -256,16 +255,7 @@
|
|||
_ => panic!("entered the wrong cascade_property() implementation"),
|
||||
};
|
||||
|
||||
% if property.logical:
|
||||
let wm = context.style.writing_mode;
|
||||
% endif
|
||||
<% maybe_wm = "wm" if property.logical else "" %>
|
||||
<% maybe_physical = "_physical" if property.logical else "" %>
|
||||
% if not property.derived_from:
|
||||
if seen.get${maybe_physical}_${property.ident}(${maybe_wm}) {
|
||||
return
|
||||
}
|
||||
seen.set${maybe_physical}_${property.ident}(${maybe_wm});
|
||||
{
|
||||
let custom_props = context.style().custom_properties();
|
||||
::properties::substitute_variables_${property.ident}(
|
||||
|
@ -275,6 +265,9 @@
|
|||
cascade_info.on_cascade_property(&declaration,
|
||||
&value);
|
||||
}
|
||||
% if property.logical:
|
||||
let wm = context.style.writing_mode;
|
||||
% endif
|
||||
<% maybe_wm = ", wm" if property.logical else "" %>
|
||||
match *value {
|
||||
DeclaredValue::Value(ref specified_value) => {
|
||||
|
@ -321,7 +314,6 @@
|
|||
cascade_property_custom(declaration,
|
||||
inherited_style,
|
||||
context,
|
||||
seen,
|
||||
cacheable,
|
||||
error_reporter);
|
||||
% endif
|
||||
|
|
|
@ -84,7 +84,6 @@
|
|||
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
||||
_inherited_style: &ComputedValues,
|
||||
context: &mut computed::Context,
|
||||
_seen: &mut PropertyBitField,
|
||||
_cacheable: &mut bool,
|
||||
_error_reporter: &mut StdBox<ParseErrorReporter + Send>) {
|
||||
longhands::_servo_display_for_hypothetical_box::derive_from_display(context);
|
||||
|
|
|
@ -204,7 +204,6 @@ ${helpers.single_keyword("unicode-bidi",
|
|||
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
||||
_inherited_style: &ComputedValues,
|
||||
context: &mut computed::Context,
|
||||
_seen: &mut PropertyBitField,
|
||||
_cacheable: &mut bool,
|
||||
_error_reporter: &mut StdBox<ParseErrorReporter + Send>) {
|
||||
longhands::_servo_text_decorations_in_effect::derive_from_text_decoration(context);
|
||||
|
|
|
@ -180,7 +180,6 @@ pub mod animated_properties {
|
|||
|
||||
#[allow(missing_docs)]
|
||||
pub mod property_bit_field {
|
||||
use logical_geometry::WritingMode;
|
||||
use properties::animated_properties::TransitionProperty;
|
||||
use properties::LonghandId;
|
||||
|
||||
|
@ -223,24 +222,6 @@ pub mod property_bit_field {
|
|||
self.insert(LonghandId::${property.camel_case})
|
||||
}
|
||||
% endif
|
||||
% if property.logical:
|
||||
#[allow(non_snake_case, missing_docs)]
|
||||
pub fn get_physical_${property.ident}(&self, wm: WritingMode) -> bool {
|
||||
<%helpers:logical_setter_helper name="${property.name}">
|
||||
<%def name="inner(physical_ident)">
|
||||
self.get_${physical_ident}()
|
||||
</%def>
|
||||
</%helpers:logical_setter_helper>
|
||||
}
|
||||
#[allow(non_snake_case, missing_docs)]
|
||||
pub fn set_physical_${property.ident}(&mut self, wm: WritingMode) {
|
||||
<%helpers:logical_setter_helper name="${property.name}">
|
||||
<%def name="inner(physical_ident)">
|
||||
self.set_${physical_ident}()
|
||||
</%def>
|
||||
</%helpers:logical_setter_helper>
|
||||
}
|
||||
% endif
|
||||
% endfor
|
||||
|
||||
/// Set the corresponding bit of TransitionProperty.
|
||||
|
@ -450,6 +431,25 @@ impl LonghandId {
|
|||
% endfor
|
||||
}
|
||||
}
|
||||
|
||||
/// If this is a logical property, return the corresponding physical one in the given writing mode.
|
||||
/// Otherwise, return unchanged.
|
||||
pub fn to_physical(&self, wm: WritingMode) -> Self {
|
||||
match *self {
|
||||
% for property in data.longhands:
|
||||
% if property.logical:
|
||||
LonghandId::${property.camel_case} => {
|
||||
<%helpers:logical_setter_helper name="${property.name}">
|
||||
<%def name="inner(physical_ident)">
|
||||
LonghandId::${to_camel_case(physical_ident)}
|
||||
</%def>
|
||||
</%helpers:logical_setter_helper>
|
||||
}
|
||||
% endif
|
||||
% endfor
|
||||
_ => *self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An identifier for a given shorthand property.
|
||||
|
@ -1697,7 +1697,6 @@ pub type CascadePropertyFn =
|
|||
inherited_style: &ComputedValues,
|
||||
default_style: &Arc<ComputedValues>,
|
||||
context: &mut computed::Context,
|
||||
seen: &mut PropertyBitField,
|
||||
cacheable: &mut bool,
|
||||
cascade_info: &mut Option<<&mut CascadeInfo>,
|
||||
error_reporter: &mut StdBox<ParseErrorReporter + Send>);
|
||||
|
@ -1907,19 +1906,25 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D<Au>,
|
|||
continue
|
||||
}
|
||||
|
||||
<% maybe_to_physical = ".to_physical(writing_mode)" if category_to_cascade_now != "early" else "" %>
|
||||
let physical_longhand_id = longhand_id ${maybe_to_physical};
|
||||
if seen.contains(physical_longhand_id) {
|
||||
continue
|
||||
}
|
||||
seen.insert(physical_longhand_id);
|
||||
|
||||
let discriminant = longhand_id as usize;
|
||||
(CASCADE_PROPERTY[discriminant])(declaration,
|
||||
inherited_style,
|
||||
default_style,
|
||||
&mut context,
|
||||
&mut seen,
|
||||
&mut cacheable,
|
||||
&mut cascade_info,
|
||||
&mut error_reporter);
|
||||
}
|
||||
% if category_to_cascade_now == "early":
|
||||
let mode = get_writing_mode(context.style.get_inheritedbox());
|
||||
context.style.set_writing_mode(mode);
|
||||
let writing_mode = get_writing_mode(context.style.get_inheritedbox());
|
||||
context.style.set_writing_mode(writing_mode);
|
||||
% endif
|
||||
% endfor
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue