mirror of
https://github.com/servo/servo.git
synced 2025-08-25 07:08:21 +01:00
Auto merge of #9510 - nox:bump-selectors, r=SimonSapin
Update rust-selectors This commits updates rust-selectors to use the generic parser, and as such it moves the element state into the style crate. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9510) <!-- Reviewable:end -->
This commit is contained in:
commit
ae20f2556b
40 changed files with 342 additions and 252 deletions
12
ports/cef/Cargo.lock
generated
12
ports/cef/Cargo.lock
generated
|
@ -930,7 +930,7 @@ dependencies = [
|
|||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"selectors 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1454,7 +1454,7 @@ dependencies = [
|
|||
"ref_slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script_traits 0.0.1",
|
||||
"selectors 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1494,7 +1494,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "selectors"
|
||||
version = "0.2.3"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1732,7 +1732,7 @@ dependencies = [
|
|||
"num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1754,7 +1754,7 @@ dependencies = [
|
|||
"num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1910,7 +1910,7 @@ dependencies = [
|
|||
"plugins 0.0.1",
|
||||
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
10
ports/geckolib/Cargo.lock
generated
10
ports/geckolib/Cargo.lock
generated
|
@ -9,7 +9,7 @@ dependencies = [
|
|||
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"style 0.0.1",
|
||||
|
@ -312,7 +312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "selectors"
|
||||
version = "0.2.3"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -383,7 +383,7 @@ dependencies = [
|
|||
"num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -405,7 +405,7 @@ dependencies = [
|
|||
"num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -465,7 +465,7 @@ dependencies = [
|
|||
"plugins 0.0.1",
|
||||
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -16,7 +16,7 @@ euclid = {version = "0.4", features = ["plugins"]}
|
|||
libc = "0.2"
|
||||
log = "0.3"
|
||||
num_cpus = "0.2.2"
|
||||
selectors = "0.2"
|
||||
selectors = "0.4.1"
|
||||
smallvec = "0.1"
|
||||
string_cache = "0.2"
|
||||
url = "0.5.2"
|
||||
|
|
|
@ -13,7 +13,6 @@ extern crate cssparser;
|
|||
extern crate euclid;
|
||||
extern crate libc;
|
||||
extern crate num_cpus;
|
||||
#[macro_use(state_pseudo_classes)]
|
||||
extern crate selectors;
|
||||
extern crate smallvec;
|
||||
#[macro_use(atom, ns)]
|
||||
|
|
|
@ -17,7 +17,6 @@ use bindings::{ServoNodeData};
|
|||
use libc::uintptr_t;
|
||||
use selectors::matching::DeclarationBlock;
|
||||
use selectors::parser::{AttrSelector, NamespaceConstraint};
|
||||
use selectors::states::*;
|
||||
use smallvec::VecLike;
|
||||
use std::cell::{Ref, RefCell, RefMut};
|
||||
use std::marker::PhantomData;
|
||||
|
@ -28,12 +27,14 @@ use std::sync::Arc;
|
|||
use string_cache::{Atom, Namespace};
|
||||
use style::data::PrivateStyleData;
|
||||
use style::dom::{OpaqueNode, TDocument, TElement, TNode, TRestyleDamage, UnsafeNode};
|
||||
use style::element_state::ElementState;
|
||||
#[allow(unused_imports)] // Used in commented-out code.
|
||||
use style::error_reporting::StdoutErrorReporter;
|
||||
use style::properties::{ComputedValues, PropertyDeclaration, PropertyDeclarationBlock};
|
||||
#[allow(unused_imports)] // Used in commented-out code.
|
||||
use style::properties::{parse_style_attribute};
|
||||
use style::restyle_hints::ElementSnapshot;
|
||||
use style::selector_impl::{NonTSPseudoClass, ServoSelectorImpl};
|
||||
#[allow(unused_imports)] // Used in commented-out code.
|
||||
use url::Url;
|
||||
|
||||
|
@ -351,17 +352,9 @@ impl<'le> TElement<'le> for GeckoElement<'le> {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! state_getter {
|
||||
($(
|
||||
$(#[$Flag_attr: meta])*
|
||||
state $css: expr => $variant: ident / $method: ident /
|
||||
$flag: ident = $value: expr,
|
||||
)+) => {
|
||||
$( fn $method(&self) -> bool { self.get_state().contains($flag) } )+
|
||||
}
|
||||
}
|
||||
|
||||
impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||
type Impl = ServoSelectorImpl;
|
||||
|
||||
fn parent_element(&self) -> Option<Self> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
@ -412,26 +405,29 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
*/
|
||||
}
|
||||
|
||||
fn is_link(&self) -> bool {
|
||||
unsafe {
|
||||
Gecko_IsLink(self.element) != 0
|
||||
fn match_non_ts_pseudo_class(&self, pseudo_class: NonTSPseudoClass) -> bool {
|
||||
match pseudo_class {
|
||||
// https://github.com/servo/servo/issues/8718
|
||||
NonTSPseudoClass::Link => unsafe { Gecko_IsLink(self.element) != 0 },
|
||||
NonTSPseudoClass::AnyLink => unsafe { Gecko_IsUnvisitedLink(self.element) != 0 },
|
||||
NonTSPseudoClass::Visited => unsafe { Gecko_IsVisitedLink(self.element) != 0 },
|
||||
|
||||
NonTSPseudoClass::ServoNonZeroBorder => {
|
||||
unimplemented!()
|
||||
},
|
||||
|
||||
NonTSPseudoClass::Active |
|
||||
NonTSPseudoClass::Focus |
|
||||
NonTSPseudoClass::Hover |
|
||||
NonTSPseudoClass::Enabled |
|
||||
NonTSPseudoClass::Disabled |
|
||||
NonTSPseudoClass::Checked |
|
||||
NonTSPseudoClass::Indeterminate => {
|
||||
self.get_state().contains(pseudo_class.state_flag())
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn is_unvisited_link(&self) -> bool {
|
||||
unsafe {
|
||||
Gecko_IsUnvisitedLink(self.element) != 0
|
||||
}
|
||||
}
|
||||
|
||||
fn is_visited_link(&self) -> bool {
|
||||
unsafe {
|
||||
Gecko_IsVisitedLink(self.element) != 0
|
||||
}
|
||||
}
|
||||
|
||||
state_pseudo_classes!(state_getter);
|
||||
|
||||
fn get_id(&self) -> Option<Atom> {
|
||||
// FIXME(bholley): Servo caches the id atom directly on the element to
|
||||
// make this blazing fast. Assuming that was a measured optimization, doing
|
||||
|
@ -452,10 +448,6 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
}
|
||||
}
|
||||
|
||||
fn has_servo_nonzero_border(&self) -> bool {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn match_attr<F>(&self, attr: &AttrSelector, test: F) -> bool where F: Fn(&str) -> bool {
|
||||
// FIXME(bholley): This is copy-pasted from the servo wrapper's version.
|
||||
// We should find a way to share it.
|
||||
|
|
12
ports/gonk/Cargo.lock
generated
12
ports/gonk/Cargo.lock
generated
|
@ -901,7 +901,7 @@ dependencies = [
|
|||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"selectors 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1425,7 +1425,7 @@ dependencies = [
|
|||
"ref_slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script_traits 0.0.1",
|
||||
"selectors 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1465,7 +1465,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "selectors"
|
||||
version = "0.2.3"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1701,7 +1701,7 @@ dependencies = [
|
|||
"num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1723,7 +1723,7 @@ dependencies = [
|
|||
"num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1879,7 +1879,7 @@ dependencies = [
|
|||
"plugins 0.0.1",
|
||||
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue