зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1461285 part 1 - Rename DeclarationSource to DeclarationPushMode. r=emilio
MozReview-Commit-ID: Iyv9JrXrpzl --HG-- extra : rebase_source : d0fac58c300bdde21a0225d7793f554487f48791
This commit is contained in:
Родитель
3a224153bd
Коммит
c237e1be0d
|
@ -39,13 +39,17 @@ impl AnimationRules {
|
|||
}
|
||||
}
|
||||
|
||||
/// Whether a given declaration comes from CSS parsing, or from CSSOM.
|
||||
/// Enum for how a given declaration should be pushed into a declaration block.
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq)]
|
||||
pub enum DeclarationSource {
|
||||
/// The declaration was obtained from CSS parsing of sheets and such.
|
||||
pub enum DeclarationPushMode {
|
||||
/// Mode used when declarations were obtained from CSS parsing.
|
||||
/// If there is an existing declaration of the same property with a higher
|
||||
/// importance, the new declaration will be discarded. Otherwise, it will
|
||||
/// be appended to the end of the declaration block.
|
||||
Parsing,
|
||||
/// The declaration was obtained from CSSOM.
|
||||
CssOm,
|
||||
/// In this mode, the new declaration is always pushed to the end of the
|
||||
/// declaration block. This is for CSSOM.
|
||||
Append,
|
||||
}
|
||||
|
||||
/// A declaration [importance][importance].
|
||||
|
@ -418,10 +422,10 @@ impl PropertyDeclarationBlock {
|
|||
&mut self,
|
||||
mut drain: SourcePropertyDeclarationDrain,
|
||||
importance: Importance,
|
||||
source: DeclarationSource,
|
||||
mode: DeclarationPushMode,
|
||||
) -> bool {
|
||||
match source {
|
||||
DeclarationSource::Parsing => {
|
||||
match mode {
|
||||
DeclarationPushMode::Parsing => {
|
||||
let all_shorthand_len = match drain.all_shorthand {
|
||||
AllShorthand::NotSet => 0,
|
||||
AllShorthand::CSSWideKeyword(_) |
|
||||
|
@ -433,7 +437,7 @@ impl PropertyDeclarationBlock {
|
|||
// With deduplication the actual length increase may be less than this.
|
||||
self.declarations.reserve(push_calls_count);
|
||||
}
|
||||
DeclarationSource::CssOm => {
|
||||
_ => {
|
||||
// Don't bother reserving space, since it's usually the case
|
||||
// that CSSOM just overrides properties and we don't need to use
|
||||
// more memory. See bug 1424346 for an example where this
|
||||
|
@ -448,7 +452,7 @@ impl PropertyDeclarationBlock {
|
|||
changed |= self.push(
|
||||
decl,
|
||||
importance,
|
||||
source,
|
||||
mode,
|
||||
);
|
||||
}
|
||||
match drain.all_shorthand {
|
||||
|
@ -461,7 +465,7 @@ impl PropertyDeclarationBlock {
|
|||
changed |= self.push(
|
||||
decl,
|
||||
importance,
|
||||
source,
|
||||
mode,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -473,7 +477,7 @@ impl PropertyDeclarationBlock {
|
|||
changed |= self.push(
|
||||
decl,
|
||||
importance,
|
||||
source,
|
||||
mode,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -483,22 +487,16 @@ impl PropertyDeclarationBlock {
|
|||
|
||||
/// Adds or overrides the declaration for a given property in this block.
|
||||
///
|
||||
/// Depending on the value of `source`, this has a different behavior in the
|
||||
/// Depending on the value of `mode`, this has a different behavior in the
|
||||
/// presence of another declaration with the same ID in the declaration
|
||||
/// block.
|
||||
///
|
||||
/// * For `DeclarationSource::Parsing`, this will not override a
|
||||
/// declaration with more importance, and will ensure that, if inserted,
|
||||
/// it's inserted at the end of the declaration block.
|
||||
///
|
||||
/// * For `DeclarationSource::CssOm`, this will override importance.
|
||||
///
|
||||
/// Returns whether the declaration has changed.
|
||||
pub fn push(
|
||||
&mut self,
|
||||
declaration: PropertyDeclaration,
|
||||
importance: Importance,
|
||||
source: DeclarationSource,
|
||||
mode: DeclarationPushMode,
|
||||
) -> bool {
|
||||
let longhand_id = match declaration.id() {
|
||||
PropertyDeclarationId::Longhand(id) => Some(id),
|
||||
|
@ -516,7 +514,7 @@ impl PropertyDeclarationBlock {
|
|||
continue;
|
||||
}
|
||||
|
||||
if matches!(source, DeclarationSource::Parsing) {
|
||||
if matches!(mode, DeclarationPushMode::Parsing) {
|
||||
let important = self.declarations_importance[i];
|
||||
|
||||
// For declarations from parsing, non-important declarations
|
||||
|
@ -1209,7 +1207,7 @@ pub fn parse_property_declaration_list(
|
|||
block.extend(
|
||||
iter.parser.declarations.drain(),
|
||||
importance,
|
||||
DeclarationSource::Parsing,
|
||||
DeclarationPushMode::Parsing,
|
||||
);
|
||||
}
|
||||
Err((error, slice)) => {
|
||||
|
|
|
@ -8,7 +8,7 @@ use cssparser::{AtRuleParser, CowRcStr, Parser, ParserInput, QualifiedRuleParser
|
|||
use cssparser::{parse_one_rule, DeclarationListParser, DeclarationParser, SourceLocation, Token};
|
||||
use error_reporting::ContextualParseError;
|
||||
use parser::ParserContext;
|
||||
use properties::{DeclarationSource, Importance, PropertyDeclaration};
|
||||
use properties::{DeclarationPushMode, Importance, PropertyDeclaration};
|
||||
use properties::{LonghandId, PropertyDeclarationBlock, PropertyId};
|
||||
use properties::{PropertyDeclarationId, SourcePropertyDeclaration};
|
||||
use properties::LonghandIdSet;
|
||||
|
@ -554,7 +554,7 @@ impl<'a, 'i> QualifiedRuleParser<'i> for KeyframeListParser<'a> {
|
|||
block.extend(
|
||||
iter.parser.declarations.drain(),
|
||||
Importance::Normal,
|
||||
DeclarationSource::Parsing,
|
||||
DeclarationPushMode::Parsing,
|
||||
);
|
||||
},
|
||||
Err((error, slice)) => {
|
||||
|
|
|
@ -127,7 +127,7 @@ use style::gecko_properties;
|
|||
use style::invalidation::element::restyle_hints;
|
||||
use style::media_queries::MediaList;
|
||||
use style::parser::{Parse, ParserContext, self};
|
||||
use style::properties::{ComputedValues, DeclarationSource, Importance};
|
||||
use style::properties::{ComputedValues, DeclarationPushMode, Importance};
|
||||
use style::properties::{LonghandId, LonghandIdSet, PropertyDeclarationBlock, PropertyId};
|
||||
use style::properties::{PropertyDeclarationId, ShorthandId};
|
||||
use style::properties::{SourcePropertyDeclaration, StyleBuilder};
|
||||
|
@ -3276,7 +3276,7 @@ pub extern "C" fn Servo_ParseProperty(
|
|||
block.extend(
|
||||
declarations.drain(),
|
||||
Importance::Normal,
|
||||
DeclarationSource::CssOm,
|
||||
DeclarationPushMode::Append,
|
||||
);
|
||||
Arc::new(global_style_data.shared_lock.wrap(block)).into_strong()
|
||||
}
|
||||
|
@ -3590,7 +3590,7 @@ fn set_property(
|
|||
decls.extend(
|
||||
source_declarations.drain(),
|
||||
importance,
|
||||
DeclarationSource::CssOm
|
||||
DeclarationPushMode::Append
|
||||
)
|
||||
})
|
||||
}
|
||||
|
@ -3629,7 +3629,7 @@ pub unsafe extern "C" fn Servo_DeclarationBlock_SetPropertyToAnimationValue(
|
|||
decls.push(
|
||||
AnimationValue::as_arc(&animation_value).uncompute(),
|
||||
Importance::Normal,
|
||||
DeclarationSource::CssOm,
|
||||
DeclarationPushMode::Append,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
@ -3920,7 +3920,7 @@ pub unsafe extern "C" fn Servo_DeclarationBlock_SetIdentStringValue(
|
|||
XLang => Lang(Atom::from_raw(value)),
|
||||
};
|
||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||
decls.push(prop, Importance::Normal, DeclarationSource::CssOm);
|
||||
decls.push(prop, Importance::Normal, DeclarationPushMode::Append);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -3974,7 +3974,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(
|
|||
BorderLeftStyle => BorderStyle::from_gecko_keyword(value),
|
||||
};
|
||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||
decls.push(prop, Importance::Normal, DeclarationSource::CssOm);
|
||||
decls.push(prop, Importance::Normal, DeclarationPushMode::Append);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -3995,7 +3995,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetIntValue(
|
|||
MozScriptLevel => MozScriptLevel::Relative(value),
|
||||
};
|
||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||
decls.push(prop, Importance::Normal, DeclarationSource::CssOm);
|
||||
decls.push(prop, Importance::Normal, DeclarationPushMode::Append);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -4050,7 +4050,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(
|
|||
},
|
||||
};
|
||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||
decls.push(prop, Importance::Normal, DeclarationSource::CssOm);
|
||||
decls.push(prop, Importance::Normal, DeclarationPushMode::Append);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -4088,7 +4088,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetLengthValue(
|
|||
MozScriptMinSize => MozScriptMinSize(nocalc),
|
||||
};
|
||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||
decls.push(prop, Importance::Normal, DeclarationSource::CssOm);
|
||||
decls.push(prop, Importance::Normal, DeclarationPushMode::Append);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -4110,7 +4110,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetNumberValue(
|
|||
MozScriptLevel => MozScriptLevel::MozAbsolute(value as i32),
|
||||
};
|
||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||
decls.push(prop, Importance::Normal, DeclarationSource::CssOm);
|
||||
decls.push(prop, Importance::Normal, DeclarationPushMode::Append);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -4138,7 +4138,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetPercentValue(
|
|||
FontSize => LengthOrPercentage::from(pc).into(),
|
||||
};
|
||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||
decls.push(prop, Importance::Normal, DeclarationSource::CssOm);
|
||||
decls.push(prop, Importance::Normal, DeclarationPushMode::Append);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -4162,7 +4162,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetAutoValue(
|
|||
MarginLeft => auto,
|
||||
};
|
||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||
decls.push(prop, Importance::Normal, DeclarationSource::CssOm);
|
||||
decls.push(prop, Importance::Normal, DeclarationPushMode::Append);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -4184,7 +4184,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetCurrentColor(
|
|||
BorderLeftColor => cc,
|
||||
};
|
||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||
decls.push(prop, Importance::Normal, DeclarationSource::CssOm);
|
||||
decls.push(prop, Importance::Normal, DeclarationPushMode::Append);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -4212,7 +4212,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetColorValue(
|
|||
BackgroundColor => color,
|
||||
};
|
||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||
decls.push(prop, Importance::Normal, DeclarationSource::CssOm);
|
||||
decls.push(prop, Importance::Normal, DeclarationPushMode::Append);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -4233,7 +4233,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetFontFamily(
|
|||
if parser.is_exhausted() {
|
||||
let decl = PropertyDeclaration::FontFamily(family);
|
||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||
decls.push(decl, Importance::Normal, DeclarationSource::CssOm);
|
||||
decls.push(decl, Importance::Normal, DeclarationPushMode::Append);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -4266,7 +4266,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetBackgroundImage(
|
|||
vec![Either::Second(Image::Url(url))]
|
||||
));
|
||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||
decls.push(decl, Importance::Normal, DeclarationSource::CssOm);
|
||||
decls.push(decl, Importance::Normal, DeclarationPushMode::Append);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4281,7 +4281,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetTextDecorationColorOverride(
|
|||
decoration |= TextDecorationLine::COLOR_OVERRIDE;
|
||||
let decl = PropertyDeclaration::TextDecorationLine(decoration);
|
||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||
decls.push(decl, Importance::Normal, DeclarationSource::CssOm);
|
||||
decls.push(decl, Importance::Normal, DeclarationPushMode::Append);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -4939,7 +4939,7 @@ pub unsafe extern "C" fn Servo_StyleSet_GetKeyframesForName(
|
|||
custom_properties.push(
|
||||
declaration.clone(),
|
||||
Importance::Normal,
|
||||
DeclarationSource::CssOm,
|
||||
DeclarationPushMode::Append,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче