mirror of
https://github.com/servo/servo.git
synced 2025-08-09 15:35:34 +01:00
Stylo: replace product={gecko,servo} with engine={gecko,servo-2013,servo-2020}
Renaming the variable helped make sure I looked at every use.
This commit is contained in:
parent
f1300bb98b
commit
ddb4e369dd
52 changed files with 870 additions and 469 deletions
|
@ -167,7 +167,7 @@ pub mod shorthands {
|
|||
for p in data.longhands:
|
||||
if p.name in ['direction', 'unicode-bidi']:
|
||||
continue;
|
||||
if not p.enabled_in_content() and not p.experimental(product):
|
||||
if not p.enabled_in_content() and not p.experimental(engine):
|
||||
continue;
|
||||
if p.logical:
|
||||
logical_longhands.append(p.name)
|
||||
|
@ -177,6 +177,7 @@ pub mod shorthands {
|
|||
data.declare_shorthand(
|
||||
"all",
|
||||
logical_longhands + other_longhands,
|
||||
engines="gecko servo-2013 servo-2020",
|
||||
spec="https://drafts.csswg.org/css-cascade-3/#all-shorthand"
|
||||
)
|
||||
%>
|
||||
|
@ -426,7 +427,7 @@ pub struct NonCustomPropertyId(usize);
|
|||
pub const NON_CUSTOM_PROPERTY_ID_COUNT: usize =
|
||||
${len(data.longhands) + len(data.shorthands) + len(data.all_aliases())};
|
||||
|
||||
% if product == "gecko":
|
||||
% if engine == "gecko":
|
||||
#[allow(dead_code)]
|
||||
unsafe fn static_assert_nscsspropertyid() {
|
||||
% for i, property in enumerate(data.longhands + data.shorthands + data.all_aliases()):
|
||||
|
@ -492,20 +493,26 @@ impl NonCustomPropertyId {
|
|||
fn enabled_for_all_content(self) -> bool {
|
||||
${static_non_custom_property_id_set(
|
||||
"EXPERIMENTAL",
|
||||
lambda p: p.experimental(product)
|
||||
lambda p: p.experimental(engine)
|
||||
)}
|
||||
|
||||
${static_non_custom_property_id_set(
|
||||
"ALWAYS_ENABLED",
|
||||
lambda p: (not p.experimental(product)) and p.enabled_in_content()
|
||||
lambda p: (not p.experimental(engine)) and p.enabled_in_content()
|
||||
)}
|
||||
|
||||
let passes_pref_check = || {
|
||||
% if product == "servo":
|
||||
% if engine == "gecko":
|
||||
unsafe { structs::nsCSSProps_gPropertyEnabled[self.0] }
|
||||
% else:
|
||||
static PREF_NAME: [Option< &str>; ${len(data.longhands) + len(data.shorthands)}] = [
|
||||
% for property in data.longhands + data.shorthands:
|
||||
% if property.servo_pref:
|
||||
Some("${property.servo_pref}"),
|
||||
<%
|
||||
attrs = {"servo-2013": "servo_2013_pref", "servo-2020": "servo_2020_pref"}
|
||||
pref = getattr(property, attrs[engine])
|
||||
%>
|
||||
% if pref:
|
||||
Some("${pref}"),
|
||||
% else:
|
||||
None,
|
||||
% endif
|
||||
|
@ -517,8 +524,6 @@ impl NonCustomPropertyId {
|
|||
};
|
||||
|
||||
prefs::pref_map().get(pref).as_bool().unwrap_or(false)
|
||||
% else:
|
||||
unsafe { structs::nsCSSProps_gPropertyEnabled[self.0] }
|
||||
% endif
|
||||
};
|
||||
|
||||
|
@ -1242,7 +1247,7 @@ impl LonghandId {
|
|||
/// processing these properties.
|
||||
fn is_visited_dependent(&self) -> bool {
|
||||
matches!(*self,
|
||||
% if product == "gecko":
|
||||
% if engine == "gecko":
|
||||
LonghandId::ColumnRuleColor |
|
||||
LonghandId::TextEmphasisColor |
|
||||
LonghandId::WebkitTextFillColor |
|
||||
|
@ -1252,13 +1257,15 @@ impl LonghandId {
|
|||
LonghandId::Stroke |
|
||||
LonghandId::CaretColor |
|
||||
% endif
|
||||
LonghandId::Color |
|
||||
% if engine in ["gecko", "servo-2013"]:
|
||||
LonghandId::BackgroundColor |
|
||||
LonghandId::BorderTopColor |
|
||||
LonghandId::BorderRightColor |
|
||||
LonghandId::BorderBottomColor |
|
||||
LonghandId::BorderLeftColor |
|
||||
LonghandId::OutlineColor
|
||||
LonghandId::OutlineColor |
|
||||
% endif
|
||||
LonghandId::Color
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1279,7 +1286,7 @@ impl LonghandId {
|
|||
/// correct.
|
||||
fn is_early_property(&self) -> bool {
|
||||
matches!(*self,
|
||||
% if product == 'gecko':
|
||||
% if engine == "gecko":
|
||||
|
||||
// Needed to properly compute the writing mode, to resolve logical
|
||||
// properties, and similar stuff. In this block instead of along
|
||||
|
@ -1305,12 +1312,14 @@ impl LonghandId {
|
|||
LonghandId::MozScriptLevel |
|
||||
% endif
|
||||
|
||||
% if engine in ["gecko", "servo-2013"]:
|
||||
// Needed to compute the first available font, in order to
|
||||
// compute font-relative units correctly.
|
||||
LonghandId::FontSize |
|
||||
LonghandId::FontWeight |
|
||||
LonghandId::FontStretch |
|
||||
LonghandId::FontStyle |
|
||||
% endif
|
||||
LonghandId::FontFamily |
|
||||
|
||||
// Needed to properly compute the writing mode, to resolve logical
|
||||
|
@ -2151,7 +2160,7 @@ impl PropertyDeclaration {
|
|||
/// Returns whether or not the property is set by a system font
|
||||
pub fn get_system(&self) -> Option<SystemFont> {
|
||||
match *self {
|
||||
% if product == "gecko":
|
||||
% if engine == "gecko":
|
||||
% for prop in SYSTEM_FONT_LONGHANDS:
|
||||
PropertyDeclaration::${to_camel_case(prop)}(ref prop) => {
|
||||
prop.get_system()
|
||||
|
@ -2355,7 +2364,8 @@ impl PropertyDeclaration {
|
|||
}
|
||||
|
||||
type SubpropertiesArray<T> =
|
||||
[T; ${max(len(s.sub_properties) for s in data.shorthands_except_all())}];
|
||||
[T; ${max(len(s.sub_properties) for s in data.shorthands_except_all()) \
|
||||
if data.shorthands_except_all() else 0}];
|
||||
|
||||
type SubpropertiesVec<T> = ArrayVec<SubpropertiesArray<T>>;
|
||||
|
||||
|
@ -3181,7 +3191,7 @@ impl ComputedValuesInner {
|
|||
}
|
||||
}
|
||||
|
||||
% if product == "gecko":
|
||||
% if engine == "gecko":
|
||||
pub use crate::servo_arc::RawOffsetArc as BuilderArc;
|
||||
/// Clone an arc, returning a regular arc
|
||||
fn clone_arc<T: 'static>(x: &BuilderArc<T>) -> Arc<T> {
|
||||
|
@ -3494,7 +3504,7 @@ impl<'a> StyleBuilder<'a> {
|
|||
}
|
||||
% endif
|
||||
|
||||
% if not property.is_vector or property.simple_vector_bindings or product != "gecko":
|
||||
% if not property.is_vector or property.simple_vector_bindings or engine in ["servo-2013", "servo-2020"]:
|
||||
/// Set the `${property.ident}` to the computed value `value`.
|
||||
#[allow(non_snake_case)]
|
||||
pub fn set_${property.ident}(
|
||||
|
@ -3882,7 +3892,7 @@ macro_rules! longhand_properties_idents {
|
|||
}
|
||||
}
|
||||
|
||||
% if product == "servo":
|
||||
% if engine in ["servo-2013", "servo-2020"]:
|
||||
% for effect_name in ["repaint", "reflow_out_of_flow", "reflow", "rebuild_and_reflow_inline", "rebuild_and_reflow"]:
|
||||
macro_rules! restyle_damage_${effect_name} {
|
||||
($old: ident, $new: ident, $damage: ident, [ $($effect:expr),* ]) => ({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue