Move selectors size_of tests to Stylo tests

This commit is contained in:
Simon Sapin 2018-01-12 15:09:24 +01:00
parent 5d920df460
commit 7d1dc7286a
8 changed files with 8 additions and 124 deletions

1
Cargo.lock generated
View file

@ -2723,7 +2723,6 @@ dependencies = [
"phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
"precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_arc 0.1.0",
"size_of_test 0.0.1",
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

View file

@ -17,7 +17,6 @@ name = "selectors"
path = "lib.rs"
[features]
gecko_like_types = []
bench = []
[dependencies]
@ -31,8 +30,5 @@ precomputed-hash = "0.1"
servo_arc = { version = "0.1", path = "../servo_arc" }
smallvec = "0.6"
[dev-dependencies]
size_of_test = {path = "../size_of_test"}
[build-dependencies]
phf_codegen = "0.7.18"

View file

@ -1,28 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! These types need to have the same size and alignment as the respectively corresponding
//! types in components/style/gecko/selector_parser.rs
#[derive(Clone, Debug, Eq, PartialEq)]
#[allow(dead_code)]
pub enum PseudoClass {
Bare,
String(Box<[u16]>),
Dir(Box<()>),
MozAny(Box<[()]>),
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum PseudoElement {
A,
B,
Tree(Box<[String]>),
}
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct Atom(usize);
#[derive(Clone, Eq, PartialEq)]
pub struct Impl;

View file

@ -12,7 +12,6 @@
extern crate fnv;
extern crate phf;
extern crate precomputed_hash;
#[cfg(test)] #[macro_use] extern crate size_of_test;
extern crate servo_arc;
extern crate smallvec;
@ -23,8 +22,6 @@ pub mod context;
pub mod matching;
mod nth_index_cache;
pub mod parser;
#[cfg(test)] mod size_of_tests;
#[cfg(any(test, feature = "gecko_like_types"))] pub mod gecko_like_types;
pub mod sink;
mod tree;
pub mod visitor;

View file

@ -1,69 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::ToCss;
use gecko_like_types;
use gecko_like_types::*;
use parser;
use parser::*;
use std::fmt;
use visitor::SelectorVisitor;
size_of_test!(size_of_selector, Selector<Impl>, 8);
size_of_test!(size_of_pseudo_element, gecko_like_types::PseudoElement, 24);
size_of_test!(size_of_component, Component<Impl>, 32);
size_of_test!(size_of_pseudo_class, PseudoClass, 24);
impl parser::PseudoElement for gecko_like_types::PseudoElement {
type Impl = Impl;
}
// Boilerplate
impl SelectorImpl for Impl {
type ExtraMatchingData = u64;
type AttrValue = Atom;
type Identifier = Atom;
type ClassName = Atom;
type LocalName = Atom;
type NamespaceUrl = Atom;
type NamespacePrefix = Atom;
type BorrowedLocalName = Atom;
type BorrowedNamespaceUrl = Atom;
type NonTSPseudoClass = PseudoClass;
type PseudoElement = gecko_like_types::PseudoElement;
#[inline]
fn is_active_or_hover(_pseudo_class: &Self::NonTSPseudoClass) -> bool {
unimplemented!()
}
}
impl SelectorMethods for PseudoClass {
type Impl = Impl;
fn visit<V>(&self, _visitor: &mut V) -> bool
where V: SelectorVisitor<Impl = Self::Impl> { unimplemented!() }
}
impl ToCss for PseudoClass {
fn to_css<W>(&self, _: &mut W) -> fmt::Result where W: fmt::Write { unimplemented!() }
}
impl ToCss for gecko_like_types::PseudoElement {
fn to_css<W>(&self, _: &mut W) -> fmt::Result where W: fmt::Write { unimplemented!() }
}
impl fmt::Display for Atom {
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { unimplemented!() }
}
impl From<String> for Atom {
fn from(_: String) -> Self { unimplemented!() }
}
impl<'a> From<&'a str> for Atom {
fn from(_: &'a str) -> Self { unimplemented!() }
}

View file

@ -22,11 +22,7 @@ log = {version = "0.3.5", features = ["release_max_level_info"]}
malloc_size_of = {path = "../../components/malloc_size_of"}
nsstring = {path = "../../support/gecko/nsstring"}
parking_lot = "0.4"
# Turn on gecko_like_types because of so that crates which use this
# crate and also dev-depend on stylo_tests get reasonable behavior
# during rebuilds. See https://github.com/rust-lang/cargo/issues/3923
# for the cargo problem behind this.
selectors = {path = "../../components/selectors", features = ["gecko_like_types"]}
selectors = {path = "../../components/selectors"}
servo_arc = {path = "../../components/servo_arc"}
smallvec = "0.6"
style = {path = "../../components/style", features = ["gecko"]}

View file

@ -20,7 +20,7 @@ geckoservo = {path = "../../../ports/geckolib"}
libc = "0.2"
log = {version = "0.3.5", features = ["release_max_level_info"]}
malloc_size_of = {path = "../../../components/malloc_size_of"}
selectors = {path = "../../../components/selectors", features = ["gecko_like_types"]}
selectors = {path = "../../../components/selectors"}
size_of_test = {path = "../../../components/size_of_test"}
smallvec = "0.6"
style_traits = {path = "../../../components/style_traits"}

View file

@ -2,29 +2,22 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use selectors::gecko_like_types as dummies;
use selectors;
use servo_arc::Arc;
use std::mem::{size_of, align_of};
use style;
use style::applicable_declarations::ApplicableDeclarationBlock;
use style::data::{ElementData, ElementStyles};
use style::gecko::selector_parser as real;
use style::gecko::selector_parser::{self, SelectorImpl};
use style::properties::ComputedValues;
use style::rule_tree::{RuleNode, StrongRuleNode};
use style::values::computed;
use style::values::specified;
#[test]
fn size_of_selectors_dummy_types() {
assert_eq!(size_of::<dummies::PseudoClass>(), size_of::<real::NonTSPseudoClass>());
assert_eq!(align_of::<dummies::PseudoClass>(), align_of::<real::NonTSPseudoClass>());
size_of_test!(size_of_selector, selectors::parser::Selector<SelectorImpl>, 8);
size_of_test!(size_of_pseudo_element, selector_parser::PseudoElement, 24);
assert_eq!(size_of::<dummies::PseudoElement>(), size_of::<real::PseudoElement>());
assert_eq!(align_of::<dummies::PseudoElement>(), align_of::<real::PseudoElement>());
assert_eq!(size_of::<dummies::Atom>(), size_of::<style::Atom>());
assert_eq!(align_of::<dummies::Atom>(), align_of::<style::Atom>());
}
size_of_test!(size_of_component, selectors::parser::Component<SelectorImpl>, 32);
size_of_test!(size_of_pseudo_class, selector_parser::NonTSPseudoClass, 24);
// The size of this is critical to performance on the bloom-basic microbenchmark.
// When iterating over a large Rule array, we want to be able to fast-reject