зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #4424 - style: Remove glob imports added in #4405 (from saneyuki:glob_style); r=SimonSapin
#4406 Source-Repo: https://github.com/servo/servo Source-Revision: 1f342638c46d6b43bca4cfbd405aceedc0465a85
This commit is contained in:
Родитель
667e396b08
Коммит
34f83f1a6e
|
@ -559,10 +559,10 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
|
|||
|
||||
|
||||
// In terms of `SimpleSelector`s, these two functions will insert and remove:
|
||||
// - `LocalNameSelector`
|
||||
// - `NamepaceSelector`
|
||||
// - `IDSelector`
|
||||
// - `ClassSelector`
|
||||
// - `SimpleSelector::LocalName`
|
||||
// - `SimpleSelector::Namepace`
|
||||
// - `SimpleSelector::ID`
|
||||
// - `SimpleSelector::Class`
|
||||
|
||||
fn insert_into_bloom_filter(&self, bf: &mut BloomFilter) {
|
||||
// Only elements are interesting.
|
||||
|
|
|
@ -39,7 +39,7 @@ impl TableCellFlow {
|
|||
-> TableCellFlow {
|
||||
TableCellFlow {
|
||||
block_flow: BlockFlow::from_node_and_fragment(node, fragment),
|
||||
column_span: node.get_unsigned_integer_attribute(UnsignedIntegerAttribute::ColSpanUnsignedIntegerAttribute)
|
||||
column_span: node.get_unsigned_integer_attribute(UnsignedIntegerAttribute::ColSpan)
|
||||
.unwrap_or(1),
|
||||
visible: visible,
|
||||
}
|
||||
|
|
|
@ -594,7 +594,7 @@ impl<'le> TElement<'le> for LayoutElement<'le> {
|
|||
fn has_nonzero_border(self) -> bool {
|
||||
unsafe {
|
||||
match self.element
|
||||
.get_unsigned_integer_attribute_for_layout(UnsignedIntegerAttribute::BorderUnsignedIntegerAttribute) {
|
||||
.get_unsigned_integer_attribute_for_layout(UnsignedIntegerAttribute::Border) {
|
||||
None | Some(0) => false,
|
||||
_ => true,
|
||||
}
|
||||
|
|
|
@ -369,7 +369,7 @@ impl RawLayoutElementHelpers for Element {
|
|||
attribute: UnsignedIntegerAttribute)
|
||||
-> Option<u32> {
|
||||
match attribute {
|
||||
UnsignedIntegerAttribute::BorderUnsignedIntegerAttribute => {
|
||||
UnsignedIntegerAttribute::Border => {
|
||||
if self.is_htmltableelement() {
|
||||
let this: &HTMLTableElement = mem::transmute(self);
|
||||
this.get_border()
|
||||
|
@ -379,7 +379,7 @@ impl RawLayoutElementHelpers for Element {
|
|||
None
|
||||
}
|
||||
}
|
||||
UnsignedIntegerAttribute::ColSpanUnsignedIntegerAttribute => {
|
||||
UnsignedIntegerAttribute::ColSpan => {
|
||||
if self.is_htmltablecellelement() {
|
||||
let this: &HTMLTableCellElement = mem::transmute(self);
|
||||
this.get_colspan()
|
||||
|
@ -397,7 +397,7 @@ impl RawLayoutElementHelpers for Element {
|
|||
unsafe fn get_simple_color_attribute_for_layout(&self, attribute: SimpleColorAttribute)
|
||||
-> Option<RGBA> {
|
||||
match attribute {
|
||||
SimpleColorAttribute::BgColorSimpleColorAttribute => {
|
||||
SimpleColorAttribute::BgColor => {
|
||||
if self.is_htmlbodyelement() {
|
||||
let this: &HTMLBodyElement = mem::transmute(self);
|
||||
this.get_background_color()
|
||||
|
|
|
@ -5,9 +5,6 @@
|
|||
//! Legacy presentational attributes defined in the HTML5 specification: `<td width>`,
|
||||
//! `<input size>`, and so forth.
|
||||
|
||||
use self::UnsignedIntegerAttribute::*;
|
||||
use self::SimpleColorAttribute::*;
|
||||
|
||||
use node::{TElement, TElementAttributes, TNode};
|
||||
use properties::DeclaredValue::SpecifiedValue;
|
||||
use properties::PropertyDeclaration::*;
|
||||
|
@ -36,15 +33,15 @@ pub enum IntegerAttribute {
|
|||
/// Legacy presentational attributes that take a nonnegative integer as defined in HTML5 § 2.4.4.2.
|
||||
pub enum UnsignedIntegerAttribute {
|
||||
/// `<td border>`
|
||||
BorderUnsignedIntegerAttribute,
|
||||
Border,
|
||||
/// `<td colspan>`
|
||||
ColSpanUnsignedIntegerAttribute,
|
||||
ColSpan,
|
||||
}
|
||||
|
||||
/// Legacy presentational attributes that take a simple color as defined in HTML5 § 2.4.6.
|
||||
pub enum SimpleColorAttribute {
|
||||
/// `<body bgcolor>`
|
||||
BgColorSimpleColorAttribute,
|
||||
BgColor,
|
||||
}
|
||||
|
||||
/// Extension methods for `Stylist` that cause rules to be synthesized for legacy attributes.
|
||||
|
@ -210,7 +207,7 @@ impl PresentationalHintSynthesis for Stylist {
|
|||
TElementAttributes,
|
||||
V: VecLike<
|
||||
DeclarationBlock> {
|
||||
match element.get_simple_color_attribute(BgColorSimpleColorAttribute) {
|
||||
match element.get_simple_color_attribute(SimpleColorAttribute::BgColor) {
|
||||
None => {}
|
||||
Some(color) => {
|
||||
matching_rules_list.vec_push(DeclarationBlock::from_declaration(
|
||||
|
@ -229,7 +226,7 @@ impl PresentationalHintSynthesis for Stylist {
|
|||
E: TElement<'a> +
|
||||
TElementAttributes,
|
||||
V: VecLike<DeclarationBlock> {
|
||||
match element.get_unsigned_integer_attribute(BorderUnsignedIntegerAttribute) {
|
||||
match element.get_unsigned_integer_attribute(UnsignedIntegerAttribute::Border) {
|
||||
None => {}
|
||||
Some(length) => {
|
||||
let width_value = specified::Length::Au(Au::from_px(length as int));
|
||||
|
|
|
@ -222,7 +222,7 @@ impl SelectorMap {
|
|||
match *ss {
|
||||
// TODO(pradeep): Implement case-sensitivity based on the document type and quirks
|
||||
// mode.
|
||||
SimpleSelector::IDSelector(ref id) => return Some(id.clone()),
|
||||
SimpleSelector::ID(ref id) => return Some(id.clone()),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ impl SelectorMap {
|
|||
match *ss {
|
||||
// TODO(pradeep): Implement case-sensitivity based on the document type and quirks
|
||||
// mode.
|
||||
SimpleSelector::ClassSelector(ref class) => return Some(class.clone()),
|
||||
SimpleSelector::Class(ref class) => return Some(class.clone()),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ impl SelectorMap {
|
|||
let simple_selector_sequence = &rule.selector.simple_selectors;
|
||||
for ss in simple_selector_sequence.iter() {
|
||||
match *ss {
|
||||
SimpleSelector::LocalNameSelector(ref name) => {
|
||||
SimpleSelector::LocalName(ref name) => {
|
||||
return Some(name.clone())
|
||||
}
|
||||
_ => {}
|
||||
|
@ -665,23 +665,23 @@ fn can_fast_reject<'a,E,N>(mut selector: &CompoundSelector,
|
|||
|
||||
for ss in selector.simple_selectors.iter() {
|
||||
match *ss {
|
||||
SimpleSelector::LocalNameSelector(LocalName { ref name, ref lower_name }) => {
|
||||
SimpleSelector::LocalName(LocalName { ref name, ref lower_name }) => {
|
||||
if !bf.might_contain(name)
|
||||
&& !bf.might_contain(lower_name) {
|
||||
return Some(SelectorMatchingResult::NotMatchedGlobally);
|
||||
}
|
||||
},
|
||||
SimpleSelector::NamespaceSelector(ref namespace) => {
|
||||
SimpleSelector::Namespace(ref namespace) => {
|
||||
if !bf.might_contain(namespace) {
|
||||
return Some(SelectorMatchingResult::NotMatchedGlobally);
|
||||
}
|
||||
},
|
||||
SimpleSelector::IDSelector(ref id) => {
|
||||
SimpleSelector::ID(ref id) => {
|
||||
if !bf.might_contain(id) {
|
||||
return Some(SelectorMatchingResult::NotMatchedGlobally);
|
||||
}
|
||||
},
|
||||
SimpleSelector::ClassSelector(ref class) => {
|
||||
SimpleSelector::Class(ref class) => {
|
||||
if !bf.might_contain(class) {
|
||||
return Some(SelectorMatchingResult::NotMatchedGlobally);
|
||||
}
|
||||
|
@ -830,25 +830,25 @@ pub fn matches_simple_selector<'a,E,N>(selector: &SimpleSelector,
|
|||
-> bool
|
||||
where E: TElement<'a>, N: TNode<'a,E> {
|
||||
match *selector {
|
||||
SimpleSelector::LocalNameSelector(LocalName { ref name, ref lower_name }) => {
|
||||
SimpleSelector::LocalName(LocalName { ref name, ref lower_name }) => {
|
||||
let name = if element.is_html_element_in_html_document() { lower_name } else { name };
|
||||
let element = element.as_element();
|
||||
element.get_local_name() == name
|
||||
}
|
||||
|
||||
SimpleSelector::NamespaceSelector(ref namespace) => {
|
||||
SimpleSelector::Namespace(ref namespace) => {
|
||||
let element = element.as_element();
|
||||
element.get_namespace() == namespace
|
||||
}
|
||||
// TODO: case-sensitivity depends on the document type and quirks mode
|
||||
SimpleSelector::IDSelector(ref id) => {
|
||||
SimpleSelector::ID(ref id) => {
|
||||
*shareable = false;
|
||||
let element = element.as_element();
|
||||
element.get_id().map_or(false, |attr| {
|
||||
attr == *id
|
||||
})
|
||||
}
|
||||
SimpleSelector::ClassSelector(ref class) => {
|
||||
SimpleSelector::Class(ref class) => {
|
||||
let element = element.as_element();
|
||||
element.has_class(class)
|
||||
}
|
||||
|
|
|
@ -52,10 +52,10 @@ pub enum Combinator {
|
|||
|
||||
#[deriving(Eq, PartialEq, Clone, Hash)]
|
||||
pub enum SimpleSelector {
|
||||
IDSelector(Atom),
|
||||
ClassSelector(Atom),
|
||||
LocalNameSelector(LocalName),
|
||||
NamespaceSelector(Namespace),
|
||||
ID(Atom),
|
||||
Class(Atom),
|
||||
LocalName(LocalName),
|
||||
Namespace(Namespace),
|
||||
|
||||
// Attribute selectors
|
||||
AttrExists(AttrSelector), // [foo]
|
||||
|
@ -162,11 +162,11 @@ fn compute_specificity(mut selector: &CompoundSelector,
|
|||
specificity: &mut Specificity) {
|
||||
for simple_selector in simple_selectors.iter() {
|
||||
match simple_selector {
|
||||
&SimpleSelector::LocalNameSelector(..) =>
|
||||
&SimpleSelector::LocalName(..) =>
|
||||
specificity.element_selectors += 1,
|
||||
&SimpleSelector::IDSelector(..) =>
|
||||
&SimpleSelector::ID(..) =>
|
||||
specificity.id_selectors += 1,
|
||||
&SimpleSelector::ClassSelector(..) |
|
||||
&SimpleSelector::Class(..) |
|
||||
&SimpleSelector::AttrExists(..) |
|
||||
&SimpleSelector::AttrEqual(..) |
|
||||
&SimpleSelector::AttrIncludes(..) |
|
||||
|
@ -190,7 +190,7 @@ fn compute_specificity(mut selector: &CompoundSelector,
|
|||
&SimpleSelector::OnlyOfType |
|
||||
&SimpleSelector::ServoNonzeroBorder =>
|
||||
specificity.class_like_selectors += 1,
|
||||
&SimpleSelector::NamespaceSelector(..) => (),
|
||||
&SimpleSelector::Namespace(..) => (),
|
||||
&SimpleSelector::Negation(ref negated) =>
|
||||
simple_selectors_specificity(negated.as_slice(), specificity),
|
||||
}
|
||||
|
@ -218,13 +218,13 @@ fn parse_type_selector<I: Iterator<ComponentValue>>(
|
|||
let mut simple_selectors = vec!();
|
||||
match namespace {
|
||||
NamespaceConstraint::Specific(ns) => {
|
||||
simple_selectors.push(SimpleSelector::NamespaceSelector(ns))
|
||||
simple_selectors.push(SimpleSelector::Namespace(ns))
|
||||
},
|
||||
NamespaceConstraint::Any => (),
|
||||
}
|
||||
match local_name {
|
||||
Some(name) => {
|
||||
simple_selectors.push(SimpleSelector::LocalNameSelector(LocalName {
|
||||
simple_selectors.push(SimpleSelector::LocalName(LocalName {
|
||||
name: Atom::from_slice(name.as_slice()),
|
||||
lower_name: Atom::from_slice(name.into_ascii_lower().as_slice())
|
||||
}))
|
||||
|
@ -539,14 +539,14 @@ fn parse_one_simple_selector<I>(context: &ParserContext,
|
|||
match iter.peek() {
|
||||
Some(&IDHash(_)) => match iter.next() {
|
||||
Some(IDHash(id)) => Ok(Some(SimpleSelectorParseResult::SimpleSelector(
|
||||
SimpleSelector::IDSelector(Atom::from_slice(id.as_slice()))))),
|
||||
SimpleSelector::ID(Atom::from_slice(id.as_slice()))))),
|
||||
_ => panic!("Implementation error, this should not happen."),
|
||||
},
|
||||
Some(&Delim('.')) => {
|
||||
iter.next();
|
||||
match iter.next() {
|
||||
Some(Ident(class)) => Ok(Some(SimpleSelectorParseResult::SimpleSelector(
|
||||
SimpleSelector::ClassSelector(Atom::from_slice(class.as_slice()))))),
|
||||
SimpleSelector::Class(Atom::from_slice(class.as_slice()))))),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
|
@ -672,8 +672,6 @@ mod tests {
|
|||
use selector_matching::StylesheetOrigin;
|
||||
use string_cache::Atom;
|
||||
use super::*;
|
||||
use super::SimpleSelector::*;
|
||||
use super::PseudoElement::*;
|
||||
|
||||
fn parse(input: &str) -> Result<Vec<Selector>, ()> {
|
||||
parse_ns(input, &NamespaceMap::new())
|
||||
|
@ -695,7 +693,7 @@ mod tests {
|
|||
assert!(parse("") == Err(()))
|
||||
assert!(parse("EeÉ") == Ok(vec!(Selector {
|
||||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(SimpleSelector::LocalNameSelector(LocalName {
|
||||
simple_selectors: vec!(SimpleSelector::LocalName(LocalName {
|
||||
name: Atom::from_slice("EeÉ"),
|
||||
lower_name: Atom::from_slice("eeÉ") })),
|
||||
next: None,
|
||||
|
@ -705,7 +703,7 @@ mod tests {
|
|||
})))
|
||||
assert!(parse(".foo") == Ok(vec!(Selector {
|
||||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(SimpleSelector::ClassSelector(Atom::from_slice("foo"))),
|
||||
simple_selectors: vec!(SimpleSelector::Class(Atom::from_slice("foo"))),
|
||||
next: None,
|
||||
}),
|
||||
pseudo_element: None,
|
||||
|
@ -713,7 +711,7 @@ mod tests {
|
|||
})))
|
||||
assert!(parse("#bar") == Ok(vec!(Selector {
|
||||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(SimpleSelector::IDSelector(Atom::from_slice("bar"))),
|
||||
simple_selectors: vec!(SimpleSelector::ID(Atom::from_slice("bar"))),
|
||||
next: None,
|
||||
}),
|
||||
pseudo_element: None,
|
||||
|
@ -721,11 +719,11 @@ mod tests {
|
|||
})))
|
||||
assert!(parse("e.foo#bar") == Ok(vec!(Selector {
|
||||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(SimpleSelector::LocalNameSelector(LocalName {
|
||||
simple_selectors: vec!(SimpleSelector::LocalName(LocalName {
|
||||
name: Atom::from_slice("e"),
|
||||
lower_name: Atom::from_slice("e") }),
|
||||
SimpleSelector::ClassSelector(Atom::from_slice("foo")),
|
||||
SimpleSelector::IDSelector(Atom::from_slice("bar"))),
|
||||
SimpleSelector::Class(Atom::from_slice("foo")),
|
||||
SimpleSelector::ID(Atom::from_slice("bar"))),
|
||||
next: None,
|
||||
}),
|
||||
pseudo_element: None,
|
||||
|
@ -733,12 +731,12 @@ mod tests {
|
|||
})))
|
||||
assert!(parse("e.foo #bar") == Ok(vec!(Selector {
|
||||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(IDSelector(Atom::from_slice("bar"))),
|
||||
simple_selectors: vec!(SimpleSelector::ID(Atom::from_slice("bar"))),
|
||||
next: Some((box CompoundSelector {
|
||||
simple_selectors: vec!(SimpleSelector::LocalNameSelector(LocalName {
|
||||
simple_selectors: vec!(SimpleSelector::LocalName(LocalName {
|
||||
name: Atom::from_slice("e"),
|
||||
lower_name: Atom::from_slice("e") }),
|
||||
SimpleSelector::ClassSelector(Atom::from_slice("foo"))),
|
||||
SimpleSelector::Class(Atom::from_slice("foo"))),
|
||||
next: None,
|
||||
}, Combinator::Descendant)),
|
||||
}),
|
||||
|
@ -750,7 +748,7 @@ mod tests {
|
|||
let mut namespaces = NamespaceMap::new();
|
||||
assert!(parse_ns("[Foo]", &namespaces) == Ok(vec!(Selector {
|
||||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(AttrExists(AttrSelector {
|
||||
simple_selectors: vec!(SimpleSelector::AttrExists(AttrSelector {
|
||||
name: Atom::from_slice("Foo"),
|
||||
lower_name: Atom::from_slice("foo"),
|
||||
namespace: NamespaceConstraint::Specific(ns!("")),
|
||||
|
@ -765,7 +763,7 @@ mod tests {
|
|||
namespaces.default = Some(ns!(MathML));
|
||||
assert!(parse_ns("[Foo]", &namespaces) == Ok(vec!(Selector {
|
||||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(AttrExists(AttrSelector {
|
||||
simple_selectors: vec!(SimpleSelector::AttrExists(AttrSelector {
|
||||
name: Atom::from_slice("Foo"),
|
||||
lower_name: Atom::from_slice("foo"),
|
||||
namespace: NamespaceConstraint::Specific(ns!("")),
|
||||
|
@ -779,8 +777,8 @@ mod tests {
|
|||
assert!(parse_ns("e", &namespaces) == Ok(vec!(Selector {
|
||||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(
|
||||
NamespaceSelector(ns!(MathML)),
|
||||
LocalNameSelector(LocalName {
|
||||
SimpleSelector::Namespace(ns!(MathML)),
|
||||
SimpleSelector::LocalName(LocalName {
|
||||
name: Atom::from_slice("e"),
|
||||
lower_name: Atom::from_slice("e") }),
|
||||
),
|
||||
|
@ -795,20 +793,20 @@ mod tests {
|
|||
simple_selectors: vec!(),
|
||||
next: None,
|
||||
}),
|
||||
pseudo_element: Some(Before),
|
||||
pseudo_element: Some(PseudoElement::Before),
|
||||
specificity: specificity(0, 0, 1),
|
||||
})))
|
||||
assert!(parse("div :after") == Ok(vec!(Selector {
|
||||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(),
|
||||
next: Some((box CompoundSelector {
|
||||
simple_selectors: vec!(LocalNameSelector(LocalName {
|
||||
simple_selectors: vec!(SimpleSelector::LocalName(LocalName {
|
||||
name: atom!("div"),
|
||||
lower_name: atom!("div") })),
|
||||
next: None,
|
||||
}, Combinator::Descendant)),
|
||||
}),
|
||||
pseudo_element: Some(After),
|
||||
pseudo_element: Some(PseudoElement::After),
|
||||
specificity: specificity(0, 0, 2),
|
||||
})))
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче