mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Update to selectors 0.8.2
This commit is contained in:
parent
f419db834c
commit
fdb2071b2d
28 changed files with 455 additions and 286 deletions
|
@ -33,7 +33,7 @@ range = {path = "../range"}
|
||||||
rustc-serialize = "0.3"
|
rustc-serialize = "0.3"
|
||||||
script_layout_interface = {path = "../script_layout_interface"}
|
script_layout_interface = {path = "../script_layout_interface"}
|
||||||
script_traits = {path = "../script_traits"}
|
script_traits = {path = "../script_traits"}
|
||||||
selectors = {version = "0.7", features = ["heap_size"]}
|
selectors = {version = "0.8", features = ["heap_size"]}
|
||||||
serde_macros = "0.7.15"
|
serde_macros = "0.7.15"
|
||||||
smallvec = "0.1"
|
smallvec = "0.1"
|
||||||
string_cache = {version = "0.2.20", features = ["heap_size"]}
|
string_cache = {version = "0.2.20", features = ["heap_size"]}
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub struct RecalcStyleAndConstructFlows<'lc> {
|
||||||
|
|
||||||
impl<'lc, N> DomTraversalContext<N> for RecalcStyleAndConstructFlows<'lc>
|
impl<'lc, N> DomTraversalContext<N> for RecalcStyleAndConstructFlows<'lc>
|
||||||
where N: LayoutNode + TNode,
|
where N: LayoutNode + TNode,
|
||||||
N::ConcreteElement: ::selectors::Element<Impl=ServoSelectorImpl, AttrString=String>
|
N::ConcreteElement: ::selectors::Element<Impl=ServoSelectorImpl>
|
||||||
|
|
||||||
{
|
{
|
||||||
type SharedContext = SharedLayoutContext;
|
type SharedContext = SharedLayoutContext;
|
||||||
|
|
|
@ -61,7 +61,7 @@ regex = "0.1.43"
|
||||||
rustc-serialize = "0.3"
|
rustc-serialize = "0.3"
|
||||||
script_layout_interface = {path = "../script_layout_interface"}
|
script_layout_interface = {path = "../script_layout_interface"}
|
||||||
script_traits = {path = "../script_traits"}
|
script_traits = {path = "../script_traits"}
|
||||||
selectors = {version = "0.7", features = ["heap_size"]}
|
selectors = {version = "0.8", features = ["heap_size"]}
|
||||||
serde = "0.7.15"
|
serde = "0.7.15"
|
||||||
smallvec = "0.1"
|
smallvec = "0.1"
|
||||||
string_cache = {version = "0.2.20", features = ["heap_size", "unstable"]}
|
string_cache = {version = "0.2.20", features = ["heap_size", "unstable"]}
|
||||||
|
|
|
@ -73,7 +73,6 @@ use html5ever::tree_builder::{LimitedQuirks, NoQuirks, Quirks};
|
||||||
use ref_filter_map::ref_filter_map;
|
use ref_filter_map::ref_filter_map;
|
||||||
use selectors::matching::{DeclarationBlock, ElementFlags, matches};
|
use selectors::matching::{DeclarationBlock, ElementFlags, matches};
|
||||||
use selectors::matching::{HAS_SLOW_SELECTOR, HAS_EDGE_CHILD_SELECTOR, HAS_SLOW_SELECTOR_LATER_SIBLINGS};
|
use selectors::matching::{HAS_SLOW_SELECTOR, HAS_EDGE_CHILD_SELECTOR, HAS_SLOW_SELECTOR_LATER_SIBLINGS};
|
||||||
use selectors::matching::{common_style_affecting_attributes, rare_style_affecting_attributes};
|
|
||||||
use selectors::parser::{AttrSelector, NamespaceConstraint, parse_author_origin_selector_list_from_str};
|
use selectors::parser::{AttrSelector, NamespaceConstraint, parse_author_origin_selector_list_from_str};
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
@ -83,9 +82,10 @@ use std::default::Default;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
use string_cache::{Atom, BorrowedAtom, BorrowedNamespace, Namespace, QualName};
|
use string_cache::{Atom, Namespace, QualName};
|
||||||
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
|
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
|
||||||
use style::element_state::*;
|
use style::element_state::*;
|
||||||
|
use style::matching::{common_style_affecting_attributes, rare_style_affecting_attributes};
|
||||||
use style::parser::ParserContextExtraData;
|
use style::parser::ParserContextExtraData;
|
||||||
use style::properties::DeclaredValue;
|
use style::properties::DeclaredValue;
|
||||||
use style::properties::longhands::{self, background_image, border_spacing, font_family, overflow_x, font_size};
|
use style::properties::longhands::{self, background_image, border_spacing, font_family, overflow_x, font_size};
|
||||||
|
@ -2235,7 +2235,9 @@ impl VirtualMethods for Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::selectors::MatchAttrGeneric for Root<Element> {
|
impl<'a> ::selectors::MatchAttrGeneric for Root<Element> {
|
||||||
fn match_attr<F>(&self, attr: &AttrSelector, test: F) -> bool
|
type Impl = ServoSelectorImpl;
|
||||||
|
|
||||||
|
fn match_attr<F>(&self, attr: &AttrSelector<ServoSelectorImpl>, test: F) -> bool
|
||||||
where F: Fn(&str) -> bool
|
where F: Fn(&str) -> bool
|
||||||
{
|
{
|
||||||
use ::selectors::Element;
|
use ::selectors::Element;
|
||||||
|
@ -2263,8 +2265,6 @@ impl<'a> ::selectors::MatchAttrGeneric for Root<Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ::selectors::Element for Root<Element> {
|
impl<'a> ::selectors::Element for Root<Element> {
|
||||||
type Impl = ServoSelectorImpl;
|
|
||||||
|
|
||||||
fn parent_element(&self) -> Option<Root<Element>> {
|
fn parent_element(&self) -> Option<Root<Element>> {
|
||||||
self.upcast::<Node>().GetParentElement()
|
self.upcast::<Node>().GetParentElement()
|
||||||
}
|
}
|
||||||
|
@ -2299,12 +2299,12 @@ impl<'a> ::selectors::Element for Root<Element> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_local_name(&self) -> BorrowedAtom {
|
fn get_local_name(&self) -> &Atom {
|
||||||
BorrowedAtom(self.local_name())
|
self.local_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_namespace(&self) -> BorrowedNamespace {
|
fn get_namespace(&self) -> &Namespace {
|
||||||
BorrowedNamespace(self.namespace())
|
self.namespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_non_ts_pseudo_class(&self, pseudo_class: NonTSPseudoClass) -> bool {
|
fn match_non_ts_pseudo_class(&self, pseudo_class: NonTSPseudoClass) -> bool {
|
||||||
|
|
|
@ -52,7 +52,7 @@ use selectors::parser::{AttrSelector, NamespaceConstraint};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::mem::{transmute, transmute_copy};
|
use std::mem::{transmute, transmute_copy};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use string_cache::{Atom, BorrowedAtom, BorrowedNamespace, Namespace};
|
use string_cache::{Atom, Namespace};
|
||||||
use style::attr::AttrValue;
|
use style::attr::AttrValue;
|
||||||
use style::computed_values::display;
|
use style::computed_values::display;
|
||||||
use style::context::SharedStyleContext;
|
use style::context::SharedStyleContext;
|
||||||
|
@ -433,7 +433,10 @@ fn as_element<'le>(node: LayoutJS<Node>) -> Option<ServoLayoutElement<'le>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'le> ::selectors::MatchAttrGeneric for ServoLayoutElement<'le> {
|
impl<'le> ::selectors::MatchAttrGeneric for ServoLayoutElement<'le> {
|
||||||
fn match_attr<F>(&self, attr: &AttrSelector, test: F) -> bool where F: Fn(&str) -> bool {
|
type Impl = ServoSelectorImpl;
|
||||||
|
|
||||||
|
fn match_attr<F>(&self, attr: &AttrSelector<ServoSelectorImpl>, test: F) -> bool
|
||||||
|
where F: Fn(&str) -> bool {
|
||||||
use ::selectors::Element;
|
use ::selectors::Element;
|
||||||
let name = if self.is_html_element_in_html_document() {
|
let name = if self.is_html_element_in_html_document() {
|
||||||
&attr.lower_name
|
&attr.lower_name
|
||||||
|
@ -455,8 +458,6 @@ impl<'le> ::selectors::MatchAttrGeneric for ServoLayoutElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
||||||
type Impl = ServoSelectorImpl;
|
|
||||||
|
|
||||||
fn parent_element(&self) -> Option<ServoLayoutElement<'le>> {
|
fn parent_element(&self) -> Option<ServoLayoutElement<'le>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.element.upcast().parent_node_ref().and_then(as_element)
|
self.element.upcast().parent_node_ref().and_then(as_element)
|
||||||
|
@ -516,13 +517,13 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_local_name<'a>(&'a self) -> BorrowedAtom<'a> {
|
fn get_local_name(&self) -> &Atom {
|
||||||
BorrowedAtom(self.element.local_name())
|
self.element.local_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_namespace<'a>(&'a self) -> BorrowedNamespace<'a> {
|
fn get_namespace(&self) -> &Namespace {
|
||||||
BorrowedNamespace(self.element.namespace())
|
self.element.namespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_non_ts_pseudo_class(&self, pseudo_class: NonTSPseudoClass) -> bool {
|
fn match_non_ts_pseudo_class(&self, pseudo_class: NonTSPseudoClass) -> bool {
|
||||||
|
@ -823,8 +824,8 @@ impl<ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<ConcreteNod
|
||||||
loop {
|
loop {
|
||||||
let next_node = if let Some(ref node) = current_node {
|
let next_node = if let Some(ref node) = current_node {
|
||||||
if node.is_element() &&
|
if node.is_element() &&
|
||||||
node.as_element().get_local_name() == atom!("summary") &&
|
node.as_element().get_local_name() == &atom!("summary") &&
|
||||||
node.as_element().get_namespace() == ns!(html) {
|
node.as_element().get_namespace() == &ns!(html) {
|
||||||
self.current_node = None;
|
self.current_node = None;
|
||||||
return Some(node.clone());
|
return Some(node.clone());
|
||||||
}
|
}
|
||||||
|
@ -841,8 +842,8 @@ impl<ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<ConcreteNod
|
||||||
let node = self.current_node.clone();
|
let node = self.current_node.clone();
|
||||||
let node = node.and_then(|node| {
|
let node = node.and_then(|node| {
|
||||||
if node.is_element() &&
|
if node.is_element() &&
|
||||||
node.as_element().get_local_name() == atom!("summary") &&
|
node.as_element().get_local_name() == &atom!("summary") &&
|
||||||
node.as_element().get_namespace() == ns!(html) {
|
node.as_element().get_namespace() == &ns!(html) {
|
||||||
unsafe { node.dangerous_next_sibling() }
|
unsafe { node.dangerous_next_sibling() }
|
||||||
} else {
|
} else {
|
||||||
Some(node)
|
Some(node)
|
||||||
|
@ -902,13 +903,13 @@ impl<'le> ThreadSafeLayoutElement for ServoThreadSafeLayoutElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_local_name<'a>(&'a self) -> BorrowedAtom<'a> {
|
fn get_local_name(&self) -> &Atom {
|
||||||
BorrowedAtom(self.element.local_name())
|
self.element.local_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_namespace<'a>(&'a self) -> BorrowedNamespace<'a> {
|
fn get_namespace(&self) -> &Namespace {
|
||||||
BorrowedNamespace(self.element.namespace())
|
self.element.namespace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -925,7 +926,9 @@ impl<'le> ThreadSafeLayoutElement for ServoThreadSafeLayoutElement<'le> {
|
||||||
/// Note that the element implementation is needed only for selector matching,
|
/// Note that the element implementation is needed only for selector matching,
|
||||||
/// not for inheritance (styles are inherited appropiately).
|
/// not for inheritance (styles are inherited appropiately).
|
||||||
impl<'le> ::selectors::MatchAttrGeneric for ServoThreadSafeLayoutElement<'le> {
|
impl<'le> ::selectors::MatchAttrGeneric for ServoThreadSafeLayoutElement<'le> {
|
||||||
fn match_attr<F>(&self, attr: &AttrSelector, test: F) -> bool
|
type Impl = ServoSelectorImpl;
|
||||||
|
|
||||||
|
fn match_attr<F>(&self, attr: &AttrSelector<ServoSelectorImpl>, test: F) -> bool
|
||||||
where F: Fn(&str) -> bool {
|
where F: Fn(&str) -> bool {
|
||||||
match attr.namespace {
|
match attr.namespace {
|
||||||
NamespaceConstraint::Specific(ref ns) => {
|
NamespaceConstraint::Specific(ref ns) => {
|
||||||
|
@ -941,8 +944,6 @@ impl<'le> ::selectors::MatchAttrGeneric for ServoThreadSafeLayoutElement<'le> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {
|
impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {
|
||||||
type Impl = ServoSelectorImpl;
|
|
||||||
|
|
||||||
fn parent_element(&self) -> Option<Self> {
|
fn parent_element(&self) -> Option<Self> {
|
||||||
warn!("ServoThreadSafeLayoutElement::parent_element called");
|
warn!("ServoThreadSafeLayoutElement::parent_element called");
|
||||||
None
|
None
|
||||||
|
@ -977,12 +978,12 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_local_name<'a>(&'a self) -> BorrowedAtom<'a> {
|
fn get_local_name(&self) -> &Atom {
|
||||||
ThreadSafeLayoutElement::get_local_name(self)
|
ThreadSafeLayoutElement::get_local_name(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_namespace<'a>(&'a self) -> BorrowedNamespace<'a> {
|
fn get_namespace(&self) -> &Namespace {
|
||||||
ThreadSafeLayoutElement::get_namespace(self)
|
ThreadSafeLayoutElement::get_namespace(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ plugins = {path = "../plugins"}
|
||||||
profile_traits = {path = "../profile_traits"}
|
profile_traits = {path = "../profile_traits"}
|
||||||
range = {path = "../range"}
|
range = {path = "../range"}
|
||||||
script_traits = {path = "../script_traits"}
|
script_traits = {path = "../script_traits"}
|
||||||
selectors = {version = "0.7", features = ["heap_size"]}
|
selectors = {version = "0.8", features = ["heap_size"]}
|
||||||
string_cache = {version = "0.2.20", features = ["heap_size"]}
|
string_cache = {version = "0.2.20", features = ["heap_size"]}
|
||||||
style = {path = "../style"}
|
style = {path = "../style"}
|
||||||
url = {version = "1.0.0", features = ["heap_size"]}
|
url = {version = "1.0.0", features = ["heap_size"]}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use msg::constellation_msg::PipelineId;
|
||||||
use range::Range;
|
use range::Range;
|
||||||
use restyle_damage::RestyleDamage;
|
use restyle_damage::RestyleDamage;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use string_cache::{Atom, BorrowedAtom, BorrowedNamespace, Namespace};
|
use string_cache::{Atom, Namespace};
|
||||||
use style::computed_values::display;
|
use style::computed_values::display;
|
||||||
use style::context::SharedStyleContext;
|
use style::context::SharedStyleContext;
|
||||||
use style::dom::OpaqueNode;
|
use style::dom::OpaqueNode;
|
||||||
|
@ -86,7 +86,7 @@ pub trait LayoutNode: TNode {
|
||||||
pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq {
|
pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq {
|
||||||
type ConcreteThreadSafeLayoutElement:
|
type ConcreteThreadSafeLayoutElement:
|
||||||
ThreadSafeLayoutElement<ConcreteThreadSafeLayoutNode = Self>
|
ThreadSafeLayoutElement<ConcreteThreadSafeLayoutNode = Self>
|
||||||
+ ::selectors::Element<Impl=ServoSelectorImpl, AttrString=String>;
|
+ ::selectors::Element<Impl=ServoSelectorImpl>;
|
||||||
type ChildrenIterator: Iterator<Item = Self> + Sized;
|
type ChildrenIterator: Iterator<Item = Self> + Sized;
|
||||||
|
|
||||||
/// Creates a new `ThreadSafeLayoutNode` for the same `LayoutNode`
|
/// Creates a new `ThreadSafeLayoutNode` for the same `LayoutNode`
|
||||||
|
@ -158,8 +158,8 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_details_summary_pseudo(&self) -> Option<Self> {
|
fn get_details_summary_pseudo(&self) -> Option<Self> {
|
||||||
if self.is_element() &&
|
if self.is_element() &&
|
||||||
self.as_element().get_local_name() == atom!("details") &&
|
self.as_element().get_local_name() == &atom!("details") &&
|
||||||
self.as_element().get_namespace() == ns!(html) {
|
self.as_element().get_namespace() == &ns!(html) {
|
||||||
Some(self.with_pseudo(PseudoElementType::DetailsSummary(None)))
|
Some(self.with_pseudo(PseudoElementType::DetailsSummary(None)))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -169,8 +169,8 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_details_content_pseudo(&self) -> Option<Self> {
|
fn get_details_content_pseudo(&self) -> Option<Self> {
|
||||||
if self.is_element() &&
|
if self.is_element() &&
|
||||||
self.as_element().get_local_name() == atom!("details") &&
|
self.as_element().get_local_name() == &atom!("details") &&
|
||||||
self.as_element().get_namespace() == ns!(html) {
|
self.as_element().get_namespace() == &ns!(html) {
|
||||||
let display = if self.as_element().get_attr(&ns!(), &atom!("open")).is_some() {
|
let display = if self.as_element().get_attr(&ns!(), &atom!("open")).is_some() {
|
||||||
None // Specified by the stylesheet
|
None // Specified by the stylesheet
|
||||||
} else {
|
} else {
|
||||||
|
@ -351,7 +351,7 @@ pub trait DangerousThreadSafeLayoutNode: ThreadSafeLayoutNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ThreadSafeLayoutElement: Clone + Copy + Sized +
|
pub trait ThreadSafeLayoutElement: Clone + Copy + Sized +
|
||||||
::selectors::Element<Impl=ServoSelectorImpl, AttrString=String> +
|
::selectors::Element<Impl=ServoSelectorImpl> +
|
||||||
PresentationalHintsSynthetizer {
|
PresentationalHintsSynthetizer {
|
||||||
type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<ConcreteThreadSafeLayoutElement = Self>;
|
type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<ConcreteThreadSafeLayoutElement = Self>;
|
||||||
|
|
||||||
|
@ -359,8 +359,8 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized +
|
||||||
fn get_attr(&self, namespace: &Namespace, name: &Atom) -> Option<&str>;
|
fn get_attr(&self, namespace: &Namespace, name: &Atom) -> Option<&str>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_local_name<'a>(&'a self) -> BorrowedAtom<'a>;
|
fn get_local_name(&self) -> &Atom;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_namespace<'a>(&'a self) -> BorrowedNamespace<'a>;
|
fn get_namespace(&self) -> &Namespace;
|
||||||
}
|
}
|
||||||
|
|
32
components/servo/Cargo.lock
generated
32
components/servo/Cargo.lock
generated
|
@ -777,7 +777,7 @@ dependencies = [
|
||||||
"servo-fontconfig 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"servo-fontconfig 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"simd 0.1.0 (git+https://github.com/huonw/simd)",
|
"simd 0.1.0 (git+https://github.com/huonw/simd)",
|
||||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -942,7 +942,7 @@ dependencies = [
|
||||||
"phf 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"phf_codegen 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf_codegen 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tendril 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tendril 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
@ -1132,10 +1132,10 @@ dependencies = [
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"script_layout_interface 0.0.1",
|
"script_layout_interface 0.0.1",
|
||||||
"script_traits 0.0.1",
|
"script_traits 0.0.1",
|
||||||
"selectors 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_macros 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_macros 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
"unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -1904,10 +1904,10 @@ dependencies = [
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"script_layout_interface 0.0.1",
|
"script_layout_interface 0.0.1",
|
||||||
"script_traits 0.0.1",
|
"script_traits 0.0.1",
|
||||||
"selectors 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tinyfiledialogs 0.1.0 (git+https://github.com/jdm/tinyfiledialogs)",
|
"tinyfiledialogs 0.1.0 (git+https://github.com/jdm/tinyfiledialogs)",
|
||||||
|
@ -1941,8 +1941,8 @@ dependencies = [
|
||||||
"profile_traits 0.0.1",
|
"profile_traits 0.0.1",
|
||||||
"range 0.0.1",
|
"range 0.0.1",
|
||||||
"script_traits 0.0.1",
|
"script_traits 0.0.1",
|
||||||
"selectors 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
|
@ -1989,7 +1989,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "selectors"
|
name = "selectors"
|
||||||
version = "0.7.0"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2000,7 +2000,7 @@ dependencies = [
|
||||||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quickersort 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quickersort 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2173,7 +2173,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "string_cache"
|
name = "string_cache"
|
||||||
version = "0.2.21"
|
version = "0.2.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2208,11 +2208,11 @@ dependencies = [
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"selectors 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_macros 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_macros 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2228,8 +2228,8 @@ dependencies = [
|
||||||
"cssparser 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cssparser 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"selectors 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2698,7 +2698,7 @@ dependencies = [
|
||||||
"phf 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"phf_codegen 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf_codegen 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tendril 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tendril 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
|
@ -12,11 +12,11 @@ name = "style"
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
gecko = ["gecko_bindings", "selectors/gecko"]
|
gecko = ["gecko_bindings", "gecko_string_cache"]
|
||||||
servo = ["serde", "serde/nightly", "serde_macros", "heapsize", "heapsize_plugin",
|
servo = ["serde", "serde/nightly", "serde_macros", "heapsize", "heapsize_plugin",
|
||||||
"style_traits/servo", "app_units/plugins", "euclid/plugins",
|
"style_traits/servo", "app_units/plugins", "euclid/plugins",
|
||||||
"cssparser/heap_size", "cssparser/serde-serialization",
|
"cssparser/heap_size", "cssparser/serde-serialization",
|
||||||
"selectors/heap_size", "selectors/unstable", "string_cache/heap_size",
|
"selectors/heap_size", "selectors/unstable", "string_cache",
|
||||||
"url/heap_size", "plugins"]
|
"url/heap_size", "plugins"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -28,6 +28,7 @@ encoding = "0.2"
|
||||||
euclid = "0.7.1"
|
euclid = "0.7.1"
|
||||||
fnv = "1.0"
|
fnv = "1.0"
|
||||||
gecko_bindings = {path = "../../ports/geckolib/gecko_bindings", optional = true}
|
gecko_bindings = {path = "../../ports/geckolib/gecko_bindings", optional = true}
|
||||||
|
gecko_string_cache = {path = "../../ports/geckolib/string_cache", optional = true}
|
||||||
heapsize = {version = "0.3.0", optional = true}
|
heapsize = {version = "0.3.0", optional = true}
|
||||||
heapsize_plugin = {version = "0.1.2", optional = true}
|
heapsize_plugin = {version = "0.1.2", optional = true}
|
||||||
lazy_static = "0.2"
|
lazy_static = "0.2"
|
||||||
|
@ -37,11 +38,11 @@ num-traits = "0.1.32"
|
||||||
ordered-float = "0.2.2"
|
ordered-float = "0.2.2"
|
||||||
rand = "0.3"
|
rand = "0.3"
|
||||||
rustc-serialize = "0.3"
|
rustc-serialize = "0.3"
|
||||||
selectors = "0.7"
|
selectors = "0.8.2"
|
||||||
serde = {version = "0.7.15", optional = true}
|
serde = {version = "0.7.15", optional = true}
|
||||||
serde_macros = {version = "0.7.15", optional = true}
|
serde_macros = {version = "0.7.15", optional = true}
|
||||||
smallvec = "0.1"
|
smallvec = "0.1"
|
||||||
string_cache = "0.2.20"
|
string_cache = {version = "0.2.22", features = ["heap_size"], optional = true}
|
||||||
style_traits = {path = "../style_traits"}
|
style_traits = {path = "../style_traits"}
|
||||||
time = "0.1"
|
time = "0.1"
|
||||||
url = "1.0.0"
|
url = "1.0.0"
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
|
|
||||||
use element_state::ElementState;
|
use element_state::ElementState;
|
||||||
use selector_impl::PseudoElementCascadeType;
|
use selector_impl::PseudoElementCascadeType;
|
||||||
use selectors::parser::{ParserContext, SelectorImpl};
|
use selector_impl::{attr_exists_selector_is_shareable, attr_equals_selector_is_shareable};
|
||||||
use string_cache::Atom;
|
use selectors::parser::{ParserContext, SelectorImpl, AttrSelector};
|
||||||
|
use string_cache::{Atom, WeakAtom};
|
||||||
use stylesheets::Stylesheet;
|
use stylesheets::Stylesheet;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
@ -149,10 +150,27 @@ impl NonTSPseudoClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SelectorImpl for GeckoSelectorImpl {
|
impl SelectorImpl for GeckoSelectorImpl {
|
||||||
type AttrString = Atom;
|
type AttrValue = Atom;
|
||||||
|
type Identifier = Atom;
|
||||||
|
type ClassName = Atom;
|
||||||
|
type LocalName = Atom;
|
||||||
|
type Namespace = Atom;
|
||||||
|
type BorrowedNamespace = WeakAtom;
|
||||||
|
type BorrowedLocalName = WeakAtom;
|
||||||
|
|
||||||
type PseudoElement = PseudoElement;
|
type PseudoElement = PseudoElement;
|
||||||
type NonTSPseudoClass = NonTSPseudoClass;
|
type NonTSPseudoClass = NonTSPseudoClass;
|
||||||
fn parse_non_ts_pseudo_class(_context: &ParserContext,
|
|
||||||
|
fn attr_exists_selector_is_shareable(attr_selector: &AttrSelector<Self>) -> bool {
|
||||||
|
attr_exists_selector_is_shareable(attr_selector)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn attr_equals_selector_is_shareable(attr_selector: &AttrSelector<Self>,
|
||||||
|
value: &Self::AttrValue) -> bool {
|
||||||
|
attr_equals_selector_is_shareable(attr_selector, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_non_ts_pseudo_class(_context: &ParserContext<Self>,
|
||||||
name: &str) -> Result<NonTSPseudoClass, ()> {
|
name: &str) -> Result<NonTSPseudoClass, ()> {
|
||||||
use self::NonTSPseudoClass::*;
|
use self::NonTSPseudoClass::*;
|
||||||
let pseudo_class = match_ignore_ascii_case! { name,
|
let pseudo_class = match_ignore_ascii_case! { name,
|
||||||
|
@ -174,7 +192,7 @@ impl SelectorImpl for GeckoSelectorImpl {
|
||||||
Ok(pseudo_class)
|
Ok(pseudo_class)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_pseudo_element(context: &ParserContext,
|
fn parse_pseudo_element(context: &ParserContext<Self>,
|
||||||
name: &str) -> Result<PseudoElement, ()> {
|
name: &str) -> Result<PseudoElement, ()> {
|
||||||
use self::AnonBoxPseudoElement::*;
|
use self::AnonBoxPseudoElement::*;
|
||||||
use self::PseudoElement::*;
|
use self::PseudoElement::*;
|
||||||
|
|
|
@ -45,8 +45,8 @@ extern crate deque;
|
||||||
extern crate encoding;
|
extern crate encoding;
|
||||||
extern crate euclid;
|
extern crate euclid;
|
||||||
extern crate fnv;
|
extern crate fnv;
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")] extern crate gecko_bindings;
|
||||||
extern crate gecko_bindings;
|
#[cfg(feature = "gecko")] #[macro_use] extern crate gecko_string_cache as string_cache;
|
||||||
#[cfg(feature = "servo")] extern crate heapsize;
|
#[cfg(feature = "servo")] extern crate heapsize;
|
||||||
#[allow(unused_extern_crates)]
|
#[allow(unused_extern_crates)]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -63,7 +63,7 @@ extern crate rustc_serialize;
|
||||||
extern crate selectors;
|
extern crate selectors;
|
||||||
#[cfg(feature = "servo")] extern crate serde;
|
#[cfg(feature = "servo")] extern crate serde;
|
||||||
extern crate smallvec;
|
extern crate smallvec;
|
||||||
#[macro_use(atom, ns)] extern crate string_cache;
|
#[cfg(feature = "servo")] #[macro_use] extern crate string_cache;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate style_traits;
|
extern crate style_traits;
|
||||||
extern crate time;
|
extern crate time;
|
||||||
|
|
|
@ -15,12 +15,11 @@ use dom::{TElement, TNode, TRestyleDamage};
|
||||||
use properties::{ComputedValues, PropertyDeclaration, cascade};
|
use properties::{ComputedValues, PropertyDeclaration, cascade};
|
||||||
use selector_impl::{ElementExt, TheSelectorImpl, PseudoElement};
|
use selector_impl::{ElementExt, TheSelectorImpl, PseudoElement};
|
||||||
use selector_matching::{DeclarationBlock, Stylist};
|
use selector_matching::{DeclarationBlock, Stylist};
|
||||||
use selectors::Element;
|
|
||||||
use selectors::bloom::BloomFilter;
|
use selectors::bloom::BloomFilter;
|
||||||
use selectors::matching::{CommonStyleAffectingAttributeMode, CommonStyleAffectingAttributes};
|
use selectors::{Element, MatchAttr};
|
||||||
use selectors::matching::{common_style_affecting_attributes, rare_style_affecting_attributes};
|
|
||||||
use sink::ForgetfulSink;
|
use sink::ForgetfulSink;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
use std::borrow::Borrow;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::hash::{BuildHasherDefault, Hash, Hasher};
|
use std::hash::{BuildHasherDefault, Hash, Hasher};
|
||||||
use std::slice::Iter;
|
use std::slice::Iter;
|
||||||
|
@ -257,7 +256,7 @@ impl StyleSharingCandidate {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn can_share_style_with<E: TElement>(&self, element: &E) -> bool {
|
pub fn can_share_style_with<E: TElement>(&self, element: &E) -> bool {
|
||||||
if *element.get_local_name() != self.local_name {
|
if element.get_local_name() != self.local_name.borrow() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +275,7 @@ impl StyleSharingCandidate {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if *element.get_namespace() != self.namespace {
|
if element.get_namespace() != self.namespace.borrow() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,6 +326,61 @@ impl StyleSharingCandidate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bitflags! {
|
||||||
|
pub flags CommonStyleAffectingAttributes: u8 {
|
||||||
|
const HIDDEN_ATTRIBUTE = 0x01,
|
||||||
|
const NO_WRAP_ATTRIBUTE = 0x02,
|
||||||
|
const ALIGN_LEFT_ATTRIBUTE = 0x04,
|
||||||
|
const ALIGN_CENTER_ATTRIBUTE = 0x08,
|
||||||
|
const ALIGN_RIGHT_ATTRIBUTE = 0x10,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct CommonStyleAffectingAttributeInfo {
|
||||||
|
pub atom: Atom,
|
||||||
|
pub mode: CommonStyleAffectingAttributeMode,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub enum CommonStyleAffectingAttributeMode {
|
||||||
|
IsPresent(CommonStyleAffectingAttributes),
|
||||||
|
IsEqual(Atom, CommonStyleAffectingAttributes),
|
||||||
|
}
|
||||||
|
|
||||||
|
// NB: This must match the order in `selectors::matching::CommonStyleAffectingAttributes`.
|
||||||
|
#[inline]
|
||||||
|
pub fn common_style_affecting_attributes() -> [CommonStyleAffectingAttributeInfo; 5] {
|
||||||
|
[
|
||||||
|
CommonStyleAffectingAttributeInfo {
|
||||||
|
atom: atom!("hidden"),
|
||||||
|
mode: CommonStyleAffectingAttributeMode::IsPresent(HIDDEN_ATTRIBUTE),
|
||||||
|
},
|
||||||
|
CommonStyleAffectingAttributeInfo {
|
||||||
|
atom: atom!("nowrap"),
|
||||||
|
mode: CommonStyleAffectingAttributeMode::IsPresent(NO_WRAP_ATTRIBUTE),
|
||||||
|
},
|
||||||
|
CommonStyleAffectingAttributeInfo {
|
||||||
|
atom: atom!("align"),
|
||||||
|
mode: CommonStyleAffectingAttributeMode::IsEqual(atom!("left"), ALIGN_LEFT_ATTRIBUTE),
|
||||||
|
},
|
||||||
|
CommonStyleAffectingAttributeInfo {
|
||||||
|
atom: atom!("align"),
|
||||||
|
mode: CommonStyleAffectingAttributeMode::IsEqual(atom!("center"), ALIGN_CENTER_ATTRIBUTE),
|
||||||
|
},
|
||||||
|
CommonStyleAffectingAttributeInfo {
|
||||||
|
atom: atom!("align"),
|
||||||
|
mode: CommonStyleAffectingAttributeMode::IsEqual(atom!("right"), ALIGN_RIGHT_ATTRIBUTE),
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Attributes that, if present, disable style sharing. All legacy HTML attributes must be in
|
||||||
|
/// either this list or `common_style_affecting_attributes`. See the comment in
|
||||||
|
/// `synthesize_presentational_hints_for_legacy_attributes`.
|
||||||
|
pub fn rare_style_affecting_attributes() -> [Atom; 3] {
|
||||||
|
[ atom!("bgcolor"), atom!("border"), atom!("colspan") ]
|
||||||
|
}
|
||||||
|
|
||||||
static STYLE_SHARING_CANDIDATE_CACHE_SIZE: usize = 40;
|
static STYLE_SHARING_CANDIDATE_CACHE_SIZE: usize = 40;
|
||||||
|
|
||||||
impl StyleSharingCandidateCache {
|
impl StyleSharingCandidateCache {
|
||||||
|
@ -710,7 +764,7 @@ pub trait MatchMethods : TNode {
|
||||||
|
|
||||||
data.style = Some(final_style);
|
data.style = Some(final_style);
|
||||||
|
|
||||||
<Self::ConcreteElement as Element>::Impl::each_eagerly_cascaded_pseudo_element(|pseudo| {
|
<Self::ConcreteElement as MatchAttr>::Impl::each_eagerly_cascaded_pseudo_element(|pseudo| {
|
||||||
let applicable_declarations_for_this_pseudo =
|
let applicable_declarations_for_this_pseudo =
|
||||||
applicable_declarations.per_pseudo.get(&pseudo).unwrap();
|
applicable_declarations.per_pseudo.get(&pseudo).unwrap();
|
||||||
|
|
||||||
|
@ -718,7 +772,7 @@ pub trait MatchMethods : TNode {
|
||||||
// NB: Transitions and animations should only work for
|
// NB: Transitions and animations should only work for
|
||||||
// pseudo-elements ::before and ::after
|
// pseudo-elements ::before and ::after
|
||||||
let should_animate_properties =
|
let should_animate_properties =
|
||||||
<Self::ConcreteElement as Element>::Impl::pseudo_is_before_or_after(&pseudo);
|
<Self::ConcreteElement as MatchAttr>::Impl::pseudo_is_before_or_after(&pseudo);
|
||||||
let (new_damage, style) = self.cascade_node_pseudo_element(
|
let (new_damage, style) = self.cascade_node_pseudo_element(
|
||||||
context,
|
context,
|
||||||
Some(data.style.as_ref().unwrap()),
|
Some(data.style.as_ref().unwrap()),
|
||||||
|
|
|
@ -8,6 +8,7 @@ use cssparser::{Parser, SourcePosition};
|
||||||
use error_reporting::ParseErrorReporter;
|
use error_reporting::ParseErrorReporter;
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use gecko_bindings::ptr::{GeckoArcPrincipal, GeckoArcURI};
|
use gecko_bindings::ptr::{GeckoArcPrincipal, GeckoArcURI};
|
||||||
|
use selector_impl::TheSelectorImpl;
|
||||||
use selectors::parser::ParserContext as SelectorParserContext;
|
use selectors::parser::ParserContext as SelectorParserContext;
|
||||||
use stylesheets::Origin;
|
use stylesheets::Origin;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
@ -37,7 +38,7 @@ impl ParserContextExtraData {
|
||||||
pub struct ParserContext<'a> {
|
pub struct ParserContext<'a> {
|
||||||
pub stylesheet_origin: Origin,
|
pub stylesheet_origin: Origin,
|
||||||
pub base_url: &'a Url,
|
pub base_url: &'a Url,
|
||||||
pub selector_context: SelectorParserContext,
|
pub selector_context: SelectorParserContext<TheSelectorImpl>,
|
||||||
pub error_reporter: Box<ParseErrorReporter + Send>,
|
pub error_reporter: Box<ParseErrorReporter + Send>,
|
||||||
pub extra_data: ParserContextExtraData,
|
pub extra_data: ParserContextExtraData,
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
//! Restyle hints: an optimization to avoid unnecessarily matching selectors.
|
//! Restyle hints: an optimization to avoid unnecessarily matching selectors.
|
||||||
|
|
||||||
use element_state::*;
|
use element_state::*;
|
||||||
use selector_impl::{ElementExt, TheSelectorImpl, AttrString, NonTSPseudoClass};
|
use selector_impl::{ElementExt, TheSelectorImpl, NonTSPseudoClass, AttrValue};
|
||||||
use selectors::matching::matches_compound_selector;
|
use selectors::matching::matches_compound_selector;
|
||||||
use selectors::parser::{AttrSelector, Combinator, CompoundSelector, SimpleSelector};
|
use selectors::parser::{AttrSelector, Combinator, CompoundSelector, SimpleSelector, SelectorImpl};
|
||||||
use selectors::{Element, MatchAttr};
|
use selectors::{Element, MatchAttr};
|
||||||
use std::clone::Clone;
|
use std::clone::Clone;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use string_cache::{Atom, BorrowedAtom, BorrowedNamespace};
|
use string_cache::Atom;
|
||||||
|
|
||||||
/// When the ElementState of an element (like IN_HOVER_STATE) changes, certain
|
/// When the ElementState of an element (like IN_HOVER_STATE) changes, certain
|
||||||
/// pseudo-classes (like :hover) may require us to restyle that element, its
|
/// pseudo-classes (like :hover) may require us to restyle that element, its
|
||||||
|
@ -52,7 +52,7 @@ bitflags! {
|
||||||
/// still need to take the ElementWrapper approach for attribute-dependent
|
/// still need to take the ElementWrapper approach for attribute-dependent
|
||||||
/// style. So we do it the same both ways for now to reduce complexity, but it's
|
/// style. So we do it the same both ways for now to reduce complexity, but it's
|
||||||
/// worth measuring the performance impact (if any) of the mStateMask approach.
|
/// worth measuring the performance impact (if any) of the mStateMask approach.
|
||||||
pub trait ElementSnapshot : Sized + MatchAttr {
|
pub trait ElementSnapshot : Sized + MatchAttr<Impl=TheSelectorImpl> {
|
||||||
/// The state of the snapshot, if any.
|
/// The state of the snapshot, if any.
|
||||||
fn state(&self) -> Option<ElementState>;
|
fn state(&self) -> Option<ElementState>;
|
||||||
|
|
||||||
|
@ -93,11 +93,11 @@ impl<'a, E> ElementWrapper<'a, E>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, E> MatchAttr for ElementWrapper<'a, E>
|
impl<'a, E> MatchAttr for ElementWrapper<'a, E>
|
||||||
where E: ElementExt<AttrString=AttrString>,
|
where E: ElementExt,
|
||||||
{
|
{
|
||||||
type AttrString = E::AttrString;
|
type Impl = TheSelectorImpl;
|
||||||
|
|
||||||
fn match_attr_has(&self, attr: &AttrSelector) -> bool {
|
fn match_attr_has(&self, attr: &AttrSelector<TheSelectorImpl>) -> bool {
|
||||||
match self.snapshot {
|
match self.snapshot {
|
||||||
Some(snapshot) if snapshot.has_attrs()
|
Some(snapshot) if snapshot.has_attrs()
|
||||||
=> snapshot.match_attr_has(attr),
|
=> snapshot.match_attr_has(attr),
|
||||||
|
@ -106,8 +106,8 @@ impl<'a, E> MatchAttr for ElementWrapper<'a, E>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_attr_equals(&self,
|
fn match_attr_equals(&self,
|
||||||
attr: &AttrSelector,
|
attr: &AttrSelector<TheSelectorImpl>,
|
||||||
value: &Self::AttrString) -> bool {
|
value: &AttrValue) -> bool {
|
||||||
match self.snapshot {
|
match self.snapshot {
|
||||||
Some(snapshot) if snapshot.has_attrs()
|
Some(snapshot) if snapshot.has_attrs()
|
||||||
=> snapshot.match_attr_equals(attr, value),
|
=> snapshot.match_attr_equals(attr, value),
|
||||||
|
@ -116,8 +116,8 @@ impl<'a, E> MatchAttr for ElementWrapper<'a, E>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_attr_equals_ignore_ascii_case(&self,
|
fn match_attr_equals_ignore_ascii_case(&self,
|
||||||
attr: &AttrSelector,
|
attr: &AttrSelector<TheSelectorImpl>,
|
||||||
value: &Self::AttrString) -> bool {
|
value: &AttrValue) -> bool {
|
||||||
match self.snapshot {
|
match self.snapshot {
|
||||||
Some(snapshot) if snapshot.has_attrs()
|
Some(snapshot) if snapshot.has_attrs()
|
||||||
=> snapshot.match_attr_equals_ignore_ascii_case(attr, value),
|
=> snapshot.match_attr_equals_ignore_ascii_case(attr, value),
|
||||||
|
@ -126,8 +126,8 @@ impl<'a, E> MatchAttr for ElementWrapper<'a, E>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_attr_includes(&self,
|
fn match_attr_includes(&self,
|
||||||
attr: &AttrSelector,
|
attr: &AttrSelector<TheSelectorImpl>,
|
||||||
value: &Self::AttrString) -> bool {
|
value: &AttrValue) -> bool {
|
||||||
match self.snapshot {
|
match self.snapshot {
|
||||||
Some(snapshot) if snapshot.has_attrs()
|
Some(snapshot) if snapshot.has_attrs()
|
||||||
=> snapshot.match_attr_includes(attr, value),
|
=> snapshot.match_attr_includes(attr, value),
|
||||||
|
@ -136,8 +136,8 @@ impl<'a, E> MatchAttr for ElementWrapper<'a, E>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_attr_dash(&self,
|
fn match_attr_dash(&self,
|
||||||
attr: &AttrSelector,
|
attr: &AttrSelector<TheSelectorImpl>,
|
||||||
value: &Self::AttrString) -> bool {
|
value: &AttrValue) -> bool {
|
||||||
match self.snapshot {
|
match self.snapshot {
|
||||||
Some(snapshot) if snapshot.has_attrs()
|
Some(snapshot) if snapshot.has_attrs()
|
||||||
=> snapshot.match_attr_dash(attr, value),
|
=> snapshot.match_attr_dash(attr, value),
|
||||||
|
@ -146,8 +146,8 @@ impl<'a, E> MatchAttr for ElementWrapper<'a, E>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_attr_prefix(&self,
|
fn match_attr_prefix(&self,
|
||||||
attr: &AttrSelector,
|
attr: &AttrSelector<TheSelectorImpl>,
|
||||||
value: &Self::AttrString) -> bool {
|
value: &AttrValue) -> bool {
|
||||||
match self.snapshot {
|
match self.snapshot {
|
||||||
Some(snapshot) if snapshot.has_attrs()
|
Some(snapshot) if snapshot.has_attrs()
|
||||||
=> snapshot.match_attr_prefix(attr, value),
|
=> snapshot.match_attr_prefix(attr, value),
|
||||||
|
@ -156,8 +156,8 @@ impl<'a, E> MatchAttr for ElementWrapper<'a, E>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_attr_substring(&self,
|
fn match_attr_substring(&self,
|
||||||
attr: &AttrSelector,
|
attr: &AttrSelector<TheSelectorImpl>,
|
||||||
value: &Self::AttrString) -> bool {
|
value: &AttrValue) -> bool {
|
||||||
match self.snapshot {
|
match self.snapshot {
|
||||||
Some(snapshot) if snapshot.has_attrs()
|
Some(snapshot) if snapshot.has_attrs()
|
||||||
=> snapshot.match_attr_substring(attr, value),
|
=> snapshot.match_attr_substring(attr, value),
|
||||||
|
@ -166,8 +166,8 @@ impl<'a, E> MatchAttr for ElementWrapper<'a, E>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_attr_suffix(&self,
|
fn match_attr_suffix(&self,
|
||||||
attr: &AttrSelector,
|
attr: &AttrSelector<TheSelectorImpl>,
|
||||||
value: &Self::AttrString) -> bool {
|
value: &AttrValue) -> bool {
|
||||||
match self.snapshot {
|
match self.snapshot {
|
||||||
Some(snapshot) if snapshot.has_attrs()
|
Some(snapshot) if snapshot.has_attrs()
|
||||||
=> snapshot.match_attr_suffix(attr, value),
|
=> snapshot.match_attr_suffix(attr, value),
|
||||||
|
@ -177,10 +177,8 @@ impl<'a, E> MatchAttr for ElementWrapper<'a, E>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, E> Element for ElementWrapper<'a, E>
|
impl<'a, E> Element for ElementWrapper<'a, E>
|
||||||
where E: ElementExt<Impl=TheSelectorImpl, AttrString=AttrString>
|
where E: ElementExt<Impl=TheSelectorImpl>
|
||||||
{
|
{
|
||||||
type Impl = TheSelectorImpl;
|
|
||||||
|
|
||||||
fn match_non_ts_pseudo_class(&self, pseudo_class: NonTSPseudoClass) -> bool {
|
fn match_non_ts_pseudo_class(&self, pseudo_class: NonTSPseudoClass) -> bool {
|
||||||
let flag = TheSelectorImpl::pseudo_class_state_flag(&pseudo_class);
|
let flag = TheSelectorImpl::pseudo_class_state_flag(&pseudo_class);
|
||||||
if flag == ElementState::empty() {
|
if flag == ElementState::empty() {
|
||||||
|
@ -217,11 +215,11 @@ impl<'a, E> Element for ElementWrapper<'a, E>
|
||||||
self.element.is_html_element_in_html_document()
|
self.element.is_html_element_in_html_document()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_local_name(&self) -> BorrowedAtom {
|
fn get_local_name(&self) -> &<Self::Impl as SelectorImpl>::BorrowedLocalName {
|
||||||
self.element.get_local_name()
|
self.element.get_local_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_namespace(&self) -> BorrowedNamespace {
|
fn get_namespace(&self) -> &<Self::Impl as SelectorImpl>::BorrowedNamespace {
|
||||||
self.element.get_namespace()
|
self.element.get_namespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,12 @@
|
||||||
|
|
||||||
//! The pseudo-classes and pseudo-elements supported by the style system.
|
//! The pseudo-classes and pseudo-elements supported by the style system.
|
||||||
|
|
||||||
|
use matching::{common_style_affecting_attributes, CommonStyleAffectingAttributeMode};
|
||||||
use restyle_hints;
|
use restyle_hints;
|
||||||
use selectors::Element;
|
use selectors::Element;
|
||||||
use selectors::parser::SelectorImpl;
|
use selectors::parser::{AttrSelector, SelectorImpl};
|
||||||
|
|
||||||
pub type AttrString = <TheSelectorImpl as SelectorImpl>::AttrString;
|
pub type AttrValue = <TheSelectorImpl as SelectorImpl>::AttrValue;
|
||||||
|
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
pub use servo_selector_impl::*;
|
pub use servo_selector_impl::*;
|
||||||
|
@ -69,8 +70,8 @@ impl PseudoElementCascadeType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ElementExt: Element<Impl=TheSelectorImpl, AttrString=<TheSelectorImpl as SelectorImpl>::AttrString> {
|
pub trait ElementExt: Element<Impl=TheSelectorImpl> {
|
||||||
type Snapshot: restyle_hints::ElementSnapshot<AttrString = Self::AttrString> + 'static;
|
type Snapshot: restyle_hints::ElementSnapshot + 'static;
|
||||||
|
|
||||||
fn is_link(&self) -> bool;
|
fn is_link(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
@ -96,3 +97,29 @@ impl TheSelectorImpl {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn attr_exists_selector_is_shareable(attr_selector: &AttrSelector<TheSelectorImpl>) -> bool {
|
||||||
|
// NB(pcwalton): If you update this, remember to update the corresponding list in
|
||||||
|
// `can_share_style_with()` as well.
|
||||||
|
common_style_affecting_attributes().iter().any(|common_attr_info| {
|
||||||
|
common_attr_info.atom == attr_selector.name && match common_attr_info.mode {
|
||||||
|
CommonStyleAffectingAttributeMode::IsPresent(_) => true,
|
||||||
|
CommonStyleAffectingAttributeMode::IsEqual(..) => false,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn attr_equals_selector_is_shareable(attr_selector: &AttrSelector<TheSelectorImpl>,
|
||||||
|
value: &AttrValue) -> bool {
|
||||||
|
// FIXME(pcwalton): Remove once we start actually supporting RTL text. This is in
|
||||||
|
// here because the UA style otherwise disables all style sharing completely.
|
||||||
|
atom!("dir") == *value ||
|
||||||
|
common_style_affecting_attributes().iter().any(|common_attr_info| {
|
||||||
|
common_attr_info.atom == attr_selector.name && match common_attr_info.mode {
|
||||||
|
CommonStyleAffectingAttributeMode::IsEqual(ref target_value, _) => {
|
||||||
|
*target_value == *value
|
||||||
|
}
|
||||||
|
CommonStyleAffectingAttributeMode::IsPresent(_) => false,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use keyframes::KeyframesAnimation;
|
||||||
use media_queries::{Device, MediaType};
|
use media_queries::{Device, MediaType};
|
||||||
use properties::{self, PropertyDeclaration, PropertyDeclarationBlock, ComputedValues};
|
use properties::{self, PropertyDeclaration, PropertyDeclarationBlock, ComputedValues};
|
||||||
use restyle_hints::{RestyleHint, DependencySet};
|
use restyle_hints::{RestyleHint, DependencySet};
|
||||||
use selector_impl::{ElementExt, TheSelectorImpl, PseudoElement, AttrString};
|
use selector_impl::{ElementExt, TheSelectorImpl, PseudoElement};
|
||||||
use selectors::Element;
|
use selectors::Element;
|
||||||
use selectors::bloom::BloomFilter;
|
use selectors::bloom::BloomFilter;
|
||||||
use selectors::matching::DeclarationBlock as GenericDeclarationBlock;
|
use selectors::matching::DeclarationBlock as GenericDeclarationBlock;
|
||||||
|
@ -242,7 +242,7 @@ impl Stylist {
|
||||||
pseudo: &PseudoElement,
|
pseudo: &PseudoElement,
|
||||||
parent: &Arc<ComputedValues>)
|
parent: &Arc<ComputedValues>)
|
||||||
-> Option<Arc<ComputedValues>>
|
-> Option<Arc<ComputedValues>>
|
||||||
where E: Element<Impl=TheSelectorImpl, AttrString=AttrString> +
|
where E: Element<Impl=TheSelectorImpl> +
|
||||||
PresentationalHintsSynthetizer {
|
PresentationalHintsSynthetizer {
|
||||||
debug_assert!(TheSelectorImpl::pseudo_element_cascade_type(pseudo).is_lazy());
|
debug_assert!(TheSelectorImpl::pseudo_element_cascade_type(pseudo).is_lazy());
|
||||||
if self.pseudos_map.get(pseudo).is_none() {
|
if self.pseudos_map.get(pseudo).is_none() {
|
||||||
|
@ -308,7 +308,7 @@ impl Stylist {
|
||||||
pseudo_element: Option<&PseudoElement>,
|
pseudo_element: Option<&PseudoElement>,
|
||||||
applicable_declarations: &mut V)
|
applicable_declarations: &mut V)
|
||||||
-> bool
|
-> bool
|
||||||
where E: Element<Impl=TheSelectorImpl, AttrString=AttrString> +
|
where E: Element<Impl=TheSelectorImpl> +
|
||||||
PresentationalHintsSynthetizer,
|
PresentationalHintsSynthetizer,
|
||||||
V: Push<DeclarationBlock> + VecLike<DeclarationBlock> {
|
V: Push<DeclarationBlock> + VecLike<DeclarationBlock> {
|
||||||
assert!(!self.is_device_dirty);
|
assert!(!self.is_device_dirty);
|
||||||
|
|
|
@ -8,6 +8,7 @@ use error_reporting::StdoutErrorReporter;
|
||||||
use parser::ParserContextExtraData;
|
use parser::ParserContextExtraData;
|
||||||
use restyle_hints::ElementSnapshot;
|
use restyle_hints::ElementSnapshot;
|
||||||
use selector_impl::{ElementExt, PseudoElementCascadeType, TheSelectorImpl};
|
use selector_impl::{ElementExt, PseudoElementCascadeType, TheSelectorImpl};
|
||||||
|
use selector_impl::{attr_exists_selector_is_shareable, attr_equals_selector_is_shareable};
|
||||||
use selectors::parser::{AttrSelector, ParserContext, SelectorImpl};
|
use selectors::parser::{AttrSelector, ParserContext, SelectorImpl};
|
||||||
use selectors::{Element, MatchAttrGeneric};
|
use selectors::{Element, MatchAttrGeneric};
|
||||||
use std::process;
|
use std::process;
|
||||||
|
@ -98,11 +99,27 @@ impl NonTSPseudoClass {
|
||||||
pub struct ServoSelectorImpl;
|
pub struct ServoSelectorImpl;
|
||||||
|
|
||||||
impl SelectorImpl for ServoSelectorImpl {
|
impl SelectorImpl for ServoSelectorImpl {
|
||||||
type AttrString = String;
|
|
||||||
type PseudoElement = PseudoElement;
|
type PseudoElement = PseudoElement;
|
||||||
type NonTSPseudoClass = NonTSPseudoClass;
|
type NonTSPseudoClass = NonTSPseudoClass;
|
||||||
|
|
||||||
fn parse_non_ts_pseudo_class(context: &ParserContext,
|
type AttrValue = String;
|
||||||
|
type Identifier = Atom;
|
||||||
|
type ClassName = Atom;
|
||||||
|
type LocalName = Atom;
|
||||||
|
type Namespace = Namespace;
|
||||||
|
type BorrowedLocalName = Atom;
|
||||||
|
type BorrowedNamespace = Namespace;
|
||||||
|
|
||||||
|
fn attr_exists_selector_is_shareable(attr_selector: &AttrSelector<Self>) -> bool {
|
||||||
|
attr_exists_selector_is_shareable(attr_selector)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn attr_equals_selector_is_shareable(attr_selector: &AttrSelector<Self>,
|
||||||
|
value: &Self::AttrValue) -> bool {
|
||||||
|
attr_equals_selector_is_shareable(attr_selector, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_non_ts_pseudo_class(context: &ParserContext<TheSelectorImpl>,
|
||||||
name: &str) -> Result<NonTSPseudoClass, ()> {
|
name: &str) -> Result<NonTSPseudoClass, ()> {
|
||||||
use self::NonTSPseudoClass::*;
|
use self::NonTSPseudoClass::*;
|
||||||
let pseudo_class = match_ignore_ascii_case! { name,
|
let pseudo_class = match_ignore_ascii_case! { name,
|
||||||
|
@ -132,7 +149,7 @@ impl SelectorImpl for ServoSelectorImpl {
|
||||||
Ok(pseudo_class)
|
Ok(pseudo_class)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_pseudo_element(context: &ParserContext,
|
fn parse_pseudo_element(context: &ParserContext<TheSelectorImpl>,
|
||||||
name: &str) -> Result<PseudoElement, ()> {
|
name: &str) -> Result<PseudoElement, ()> {
|
||||||
use self::PseudoElement::*;
|
use self::PseudoElement::*;
|
||||||
let pseudo_element = match_ignore_ascii_case! { name,
|
let pseudo_element = match_ignore_ascii_case! { name,
|
||||||
|
@ -257,7 +274,9 @@ impl ElementSnapshot for ServoElementSnapshot {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MatchAttrGeneric for ServoElementSnapshot {
|
impl MatchAttrGeneric for ServoElementSnapshot {
|
||||||
fn match_attr<F>(&self, attr: &AttrSelector, test: F) -> bool
|
type Impl = ServoSelectorImpl;
|
||||||
|
|
||||||
|
fn match_attr<F>(&self, attr: &AttrSelector<ServoSelectorImpl>, test: F) -> bool
|
||||||
where F: Fn(&str) -> bool
|
where F: Fn(&str) -> bool
|
||||||
{
|
{
|
||||||
use selectors::parser::NamespaceConstraint;
|
use selectors::parser::NamespaceConstraint;
|
||||||
|
@ -270,7 +289,7 @@ impl MatchAttrGeneric for ServoElementSnapshot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: Element<Impl=TheSelectorImpl, AttrString=String>> ElementExt for E {
|
impl<E: Element<Impl=TheSelectorImpl>> ElementExt for E {
|
||||||
type Snapshot = ServoElementSnapshot;
|
type Snapshot = ServoElementSnapshot;
|
||||||
|
|
||||||
fn is_link(&self) -> bool {
|
fn is_link(&self) -> bool {
|
||||||
|
|
28
ports/cef/Cargo.lock
generated
28
ports/cef/Cargo.lock
generated
|
@ -695,7 +695,7 @@ dependencies = [
|
||||||
"servo-fontconfig 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"servo-fontconfig 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"simd 0.1.0 (git+https://github.com/huonw/simd)",
|
"simd 0.1.0 (git+https://github.com/huonw/simd)",
|
||||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -851,7 +851,7 @@ dependencies = [
|
||||||
"phf 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"phf_codegen 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf_codegen 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tendril 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tendril 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
@ -1041,10 +1041,10 @@ dependencies = [
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"script_layout_interface 0.0.1",
|
"script_layout_interface 0.0.1",
|
||||||
"script_traits 0.0.1",
|
"script_traits 0.0.1",
|
||||||
"selectors 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_macros 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_macros 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
"unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -1758,10 +1758,10 @@ dependencies = [
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"script_layout_interface 0.0.1",
|
"script_layout_interface 0.0.1",
|
||||||
"script_traits 0.0.1",
|
"script_traits 0.0.1",
|
||||||
"selectors 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tinyfiledialogs 0.1.0 (git+https://github.com/jdm/tinyfiledialogs)",
|
"tinyfiledialogs 0.1.0 (git+https://github.com/jdm/tinyfiledialogs)",
|
||||||
|
@ -1795,8 +1795,8 @@ dependencies = [
|
||||||
"profile_traits 0.0.1",
|
"profile_traits 0.0.1",
|
||||||
"range 0.0.1",
|
"range 0.0.1",
|
||||||
"script_traits 0.0.1",
|
"script_traits 0.0.1",
|
||||||
"selectors 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
|
@ -1833,7 +1833,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "selectors"
|
name = "selectors"
|
||||||
version = "0.7.0"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -1844,7 +1844,7 @@ dependencies = [
|
||||||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quickersort 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quickersort 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2058,7 +2058,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "string_cache"
|
name = "string_cache"
|
||||||
version = "0.2.21"
|
version = "0.2.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2093,11 +2093,11 @@ dependencies = [
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"selectors 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_macros 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_macros 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2560,7 +2560,7 @@ dependencies = [
|
||||||
"phf 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"phf_codegen 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf_codegen 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tendril 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tendril 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
63
ports/geckolib/Cargo.lock
generated
63
ports/geckolib/Cargo.lock
generated
|
@ -6,12 +6,12 @@ dependencies = [
|
||||||
"env_logger 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gecko_bindings 0.0.1",
|
"gecko_bindings 0.0.1",
|
||||||
|
"gecko_string_cache 0.2.20",
|
||||||
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num_cpus 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"selectors 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -56,6 +56,14 @@ dependencies = [
|
||||||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "debug_unreachable"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deque"
|
name = "deque"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
|
@ -154,6 +162,18 @@ dependencies = [
|
||||||
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gecko_string_cache"
|
||||||
|
version = "0.2.20"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"gecko_bindings 0.0.1",
|
||||||
|
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"libc 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getopts"
|
name = "getopts"
|
||||||
version = "0.2.14"
|
version = "0.2.14"
|
||||||
|
@ -263,6 +283,20 @@ dependencies = [
|
||||||
"unreachable 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unreachable 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "phf_generator"
|
||||||
|
version = "0.7.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"phf_shared 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "phf_shared"
|
||||||
|
version = "0.7.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quickersort"
|
name = "quickersort"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
|
@ -304,7 +338,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "selectors"
|
name = "selectors"
|
||||||
version = "0.7.0"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -313,7 +347,7 @@ dependencies = [
|
||||||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quickersort 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quickersort 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
"string_cache 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -328,21 +362,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "string_cache"
|
name = "string_cache"
|
||||||
version = "0.2.20"
|
version = "0.2.22"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gecko_bindings 0.0.1",
|
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf_generator 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"phf_shared 0.7.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "string_cache"
|
|
||||||
version = "0.2.20"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
replace = "string_cache 0.2.20"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "style"
|
name = "style"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
|
@ -355,6 +384,7 @@ dependencies = [
|
||||||
"euclid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fnv 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fnv 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gecko_bindings 0.0.1",
|
"gecko_bindings 0.0.1",
|
||||||
|
"gecko_string_cache 0.2.20",
|
||||||
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -364,9 +394,8 @@ dependencies = [
|
||||||
"ordered-float 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ordered-float 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"selectors 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"selectors 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"string_cache 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -14,16 +14,13 @@ app_units = "0.2.5"
|
||||||
env_logger = "0.3"
|
env_logger = "0.3"
|
||||||
euclid = "0.7.1"
|
euclid = "0.7.1"
|
||||||
gecko_bindings = {version = "0.0.1", path = "gecko_bindings"}
|
gecko_bindings = {version = "0.0.1", path = "gecko_bindings"}
|
||||||
|
gecko_string_cache = {path = "string_cache"}
|
||||||
lazy_static = "0.2"
|
lazy_static = "0.2"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
log = {version = "0.3.5", features = ["release_max_level_info"]}
|
log = {version = "0.3.5", features = ["release_max_level_info"]}
|
||||||
num_cpus = "0.2.2"
|
num_cpus = "0.2.2"
|
||||||
selectors = "0.7"
|
selectors = "0.8"
|
||||||
string_cache = {version = "0.2.20", features = ["unstable"]}
|
|
||||||
style = {path = "../../components/style", features = ["gecko"]}
|
style = {path = "../../components/style", features = ["gecko"]}
|
||||||
style_traits = {path = "../../components/style_traits"}
|
style_traits = {path = "../../components/style_traits"}
|
||||||
url = "1.0.0"
|
url = "1.0.0"
|
||||||
util = {path = "../../components/util"}
|
util = {path = "../../components/util"}
|
||||||
|
|
||||||
[replace]
|
|
||||||
"string_cache:0.2.20" = {path = "string_cache"}
|
|
||||||
|
|
|
@ -6,15 +6,12 @@ extern crate app_units;
|
||||||
extern crate env_logger;
|
extern crate env_logger;
|
||||||
extern crate euclid;
|
extern crate euclid;
|
||||||
extern crate gecko_bindings;
|
extern crate gecko_bindings;
|
||||||
#[macro_use]
|
#[macro_use] extern crate gecko_string_cache;
|
||||||
extern crate lazy_static;
|
#[macro_use] extern crate lazy_static;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
#[macro_use]
|
#[macro_use] extern crate log;
|
||||||
extern crate log;
|
|
||||||
extern crate num_cpus;
|
extern crate num_cpus;
|
||||||
extern crate selectors;
|
extern crate selectors;
|
||||||
#[macro_use(atom, ns)]
|
|
||||||
extern crate string_cache;
|
|
||||||
extern crate style;
|
extern crate style;
|
||||||
extern crate style_traits;
|
extern crate style_traits;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
|
|
|
@ -4,11 +4,12 @@
|
||||||
use gecko_bindings::bindings;
|
use gecko_bindings::bindings;
|
||||||
use gecko_bindings::structs::ServoElementSnapshot;
|
use gecko_bindings::structs::ServoElementSnapshot;
|
||||||
use gecko_bindings::structs::ServoElementSnapshotFlags as Flags;
|
use gecko_bindings::structs::ServoElementSnapshotFlags as Flags;
|
||||||
|
use gecko_string_cache::Atom;
|
||||||
use selectors::parser::AttrSelector;
|
use selectors::parser::AttrSelector;
|
||||||
use snapshot_helpers;
|
use snapshot_helpers;
|
||||||
use string_cache::Atom;
|
|
||||||
use style::element_state::ElementState;
|
use style::element_state::ElementState;
|
||||||
use style::restyle_hints::ElementSnapshot;
|
use style::restyle_hints::ElementSnapshot;
|
||||||
|
use style::selector_impl::TheSelectorImpl;
|
||||||
use wrapper::AttrSelectorHelpers;
|
use wrapper::AttrSelectorHelpers;
|
||||||
|
|
||||||
// NB: This is sound, in some sense, because during computation of restyle hints
|
// NB: This is sound, in some sense, because during computation of restyle hints
|
||||||
|
@ -34,9 +35,9 @@ impl GeckoElementSnapshot {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::selectors::MatchAttr for GeckoElementSnapshot {
|
impl ::selectors::MatchAttr for GeckoElementSnapshot {
|
||||||
type AttrString = Atom;
|
type Impl = TheSelectorImpl;
|
||||||
|
|
||||||
fn match_attr_has(&self, attr: &AttrSelector) -> bool {
|
fn match_attr_has(&self, attr: &AttrSelector<TheSelectorImpl>) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_SnapshotHasAttr(self.0,
|
bindings::Gecko_SnapshotHasAttr(self.0,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
|
@ -44,7 +45,7 @@ impl ::selectors::MatchAttr for GeckoElementSnapshot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_attr_equals(&self, attr: &AttrSelector, value: &Self::AttrString) -> bool {
|
fn match_attr_equals(&self, attr: &AttrSelector<TheSelectorImpl>, value: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_SnapshotAttrEquals(self.0,
|
bindings::Gecko_SnapshotAttrEquals(self.0,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
|
@ -54,7 +55,7 @@ impl ::selectors::MatchAttr for GeckoElementSnapshot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_attr_equals_ignore_ascii_case(&self, attr: &AttrSelector, value: &Self::AttrString) -> bool {
|
fn match_attr_equals_ignore_ascii_case(&self, attr: &AttrSelector<TheSelectorImpl>, value: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_SnapshotAttrEquals(self.0,
|
bindings::Gecko_SnapshotAttrEquals(self.0,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
|
@ -63,7 +64,7 @@ impl ::selectors::MatchAttr for GeckoElementSnapshot {
|
||||||
/* ignoreCase = */ true)
|
/* ignoreCase = */ true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn match_attr_includes(&self, attr: &AttrSelector, value: &Self::AttrString) -> bool {
|
fn match_attr_includes(&self, attr: &AttrSelector<TheSelectorImpl>, value: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_SnapshotAttrIncludes(self.0,
|
bindings::Gecko_SnapshotAttrIncludes(self.0,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
|
@ -71,7 +72,7 @@ impl ::selectors::MatchAttr for GeckoElementSnapshot {
|
||||||
value.as_ptr())
|
value.as_ptr())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn match_attr_dash(&self, attr: &AttrSelector, value: &Self::AttrString) -> bool {
|
fn match_attr_dash(&self, attr: &AttrSelector<TheSelectorImpl>, value: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_SnapshotAttrDashEquals(self.0,
|
bindings::Gecko_SnapshotAttrDashEquals(self.0,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
|
@ -79,7 +80,7 @@ impl ::selectors::MatchAttr for GeckoElementSnapshot {
|
||||||
value.as_ptr())
|
value.as_ptr())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn match_attr_prefix(&self, attr: &AttrSelector, value: &Self::AttrString) -> bool {
|
fn match_attr_prefix(&self, attr: &AttrSelector<TheSelectorImpl>, value: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_SnapshotAttrHasPrefix(self.0,
|
bindings::Gecko_SnapshotAttrHasPrefix(self.0,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
|
@ -87,7 +88,7 @@ impl ::selectors::MatchAttr for GeckoElementSnapshot {
|
||||||
value.as_ptr())
|
value.as_ptr())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn match_attr_substring(&self, attr: &AttrSelector, value: &Self::AttrString) -> bool {
|
fn match_attr_substring(&self, attr: &AttrSelector<TheSelectorImpl>, value: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_SnapshotAttrHasSubstring(self.0,
|
bindings::Gecko_SnapshotAttrHasSubstring(self.0,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
|
@ -95,7 +96,7 @@ impl ::selectors::MatchAttr for GeckoElementSnapshot {
|
||||||
value.as_ptr())
|
value.as_ptr())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn match_attr_suffix(&self, attr: &AttrSelector, value: &Self::AttrString) -> bool {
|
fn match_attr_suffix(&self, attr: &AttrSelector<TheSelectorImpl>, value: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_SnapshotAttrHasSuffix(self.0,
|
bindings::Gecko_SnapshotAttrHasSuffix(self.0,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
//! Element an snapshot common logic.
|
//! Element an snapshot common logic.
|
||||||
|
|
||||||
use gecko_bindings::structs::nsIAtom;
|
use gecko_bindings::structs::nsIAtom;
|
||||||
|
use gecko_string_cache::Atom;
|
||||||
use std::{ptr, slice};
|
use std::{ptr, slice};
|
||||||
use string_cache::Atom;
|
|
||||||
|
|
||||||
pub type ClassOrClassList<T> = unsafe extern fn (T, *mut *mut nsIAtom, *mut *mut *mut nsIAtom) -> u32;
|
pub type ClassOrClassList<T> = unsafe extern fn (T, *mut *mut nsIAtom, *mut *mut *mut nsIAtom) -> u32;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "string_cache"
|
name = "gecko_string_cache"
|
||||||
description = "A crate to allow using Gecko's nsIAtom as a replacement for string_cache."
|
description = "A crate to allow using Gecko's nsIAtom as a replacement for string_cache."
|
||||||
version = "0.2.20"
|
version = "0.2.20"
|
||||||
authors = ["The Servo Project Developers"]
|
authors = ["The Servo Project Developers"]
|
||||||
|
@ -7,17 +7,12 @@ license = "MPL-2.0"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "string_cache"
|
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
[features]
|
|
||||||
log-events = []
|
|
||||||
unstable = []
|
|
||||||
heap_size = []
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cfg-if = "0.1.0"
|
cfg-if = "0.1.0"
|
||||||
gecko_bindings = {version = "0.0.1", path = "../gecko_bindings"}
|
gecko_bindings = {version = "0.0.1", path = "../gecko_bindings"}
|
||||||
heapsize = "0.3.5"
|
heapsize = "0.3.5"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
|
selectors = "0.8"
|
||||||
serde = "0.7.15"
|
serde = "0.7.15"
|
||||||
|
|
|
@ -1,8 +1,17 @@
|
||||||
use gecko_bindings::structs::nsIAtom;
|
use gecko_bindings::structs::nsIAtom;
|
||||||
|
|
||||||
use Atom;
|
use Atom;
|
||||||
|
use WeakAtom;
|
||||||
|
|
||||||
pub fn unsafe_atom_from_static(ptr: *mut nsIAtom) -> Atom { unsafe { Atom::from_static(ptr) } }
|
// Static atoms have a dummy AddRef/Release, so we don't bother calling
|
||||||
|
// AddRef() here. This would cause memory corruption with non-static atoms
|
||||||
|
// both because (a) we wouldn't hold the atom alive, and (b) we can't avoid
|
||||||
|
// calling Release() when the Atom is dropped, since we can't tell the
|
||||||
|
// difference between static and non-static atoms without bloating the
|
||||||
|
// size of Atom beyond word-size.
|
||||||
|
pub fn unsafe_atom_from_static(ptr: *mut nsIAtom) -> Atom {
|
||||||
|
Atom(ptr as *mut WeakAtom)
|
||||||
|
}
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(not(target_env = "msvc"))] {
|
if #[cfg(not(target_env = "msvc"))] {
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use] #[no_link]
|
||||||
extern crate cfg_if;
|
extern crate cfg_if;
|
||||||
extern crate gecko_bindings;
|
extern crate gecko_bindings;
|
||||||
extern crate heapsize;
|
extern crate heapsize;
|
||||||
|
extern crate selectors;
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
|
|
||||||
use gecko_bindings::bindings::Gecko_AddRefAtom;
|
use gecko_bindings::bindings::Gecko_AddRefAtom;
|
||||||
|
@ -15,13 +16,15 @@ use gecko_bindings::bindings::Gecko_GetAtomAsUTF16;
|
||||||
use gecko_bindings::bindings::Gecko_ReleaseAtom;
|
use gecko_bindings::bindings::Gecko_ReleaseAtom;
|
||||||
use gecko_bindings::structs::nsIAtom;
|
use gecko_bindings::structs::nsIAtom;
|
||||||
use heapsize::HeapSizeOf;
|
use heapsize::HeapSizeOf;
|
||||||
|
use selectors::bloom::BloomHash;
|
||||||
|
use selectors::parser::FromCowStr;
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
use std::borrow::Cow;
|
use std::borrow::{Cow, Borrow};
|
||||||
use std::char;
|
use std::char::{self, DecodeUtf16};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use std::marker::PhantomData;
|
use std::iter::Cloned;
|
||||||
use std::mem::transmute;
|
use std::mem;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
|
@ -30,90 +33,88 @@ pub mod atom_macro;
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! ns {
|
macro_rules! ns {
|
||||||
() => { $crate::Namespace(atom!("")) };
|
() => { atom!("") }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub type Namespace = Atom;
|
||||||
|
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
#[inline]
|
||||||
|
pub fn Namespace(atom: Atom) -> Atom {
|
||||||
|
atom
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A strong reference to a Gecko atom.
|
||||||
#[derive(PartialEq, Eq)]
|
#[derive(PartialEq, Eq)]
|
||||||
pub struct Atom(*mut nsIAtom);
|
pub struct Atom(*mut WeakAtom);
|
||||||
#[derive(PartialEq, Eq, Debug, Hash, Clone)]
|
|
||||||
pub struct Namespace(pub Atom);
|
|
||||||
|
|
||||||
pub struct BorrowedAtom<'a> {
|
/// An atom *without* a strong reference.
|
||||||
weak_ptr: *mut nsIAtom,
|
///
|
||||||
chain: PhantomData<&'a ()>,
|
/// Only usable as `&'a WeakAtom`,
|
||||||
}
|
/// where `'a` is the lifetime of something that holds a strong reference to that atom.
|
||||||
|
pub struct WeakAtom(nsIAtom);
|
||||||
|
|
||||||
impl<'a> BorrowedAtom<'a> {
|
pub type BorrowedAtom<'a> = &'a WeakAtom;
|
||||||
pub unsafe fn new(atom: *mut nsIAtom) -> Self {
|
|
||||||
BorrowedAtom {
|
|
||||||
weak_ptr: atom,
|
|
||||||
chain: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Deref for BorrowedAtom<'a> {
|
impl Deref for Atom {
|
||||||
type Target = Atom;
|
type Target = WeakAtom;
|
||||||
fn deref(&self) -> &Atom {
|
|
||||||
|
#[inline]
|
||||||
|
fn deref(&self) -> &WeakAtom {
|
||||||
unsafe {
|
unsafe {
|
||||||
transmute(self)
|
&*self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> PartialEq<Atom> for BorrowedAtom<'a> {
|
impl Borrow<WeakAtom> for Atom {
|
||||||
fn eq(&self, other: &Atom) -> bool {
|
#[inline]
|
||||||
self.weak_ptr == other.as_ptr()
|
fn borrow(&self) -> &WeakAtom {
|
||||||
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct BorrowedNamespace<'a> {
|
impl Eq for WeakAtom {}
|
||||||
weak_ptr: *mut nsIAtom,
|
impl PartialEq for WeakAtom {
|
||||||
chain: PhantomData<&'a ()>,
|
#[inline]
|
||||||
}
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
let weak: *const WeakAtom = self;
|
||||||
impl<'a> BorrowedNamespace<'a> {
|
let other: *const WeakAtom = other;
|
||||||
pub unsafe fn new(atom: *mut nsIAtom) -> Self {
|
weak == other
|
||||||
BorrowedNamespace {
|
|
||||||
weak_ptr: atom,
|
|
||||||
chain: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Deref for BorrowedNamespace<'a> {
|
|
||||||
type Target = Namespace;
|
|
||||||
fn deref(&self) -> &Namespace {
|
|
||||||
unsafe {
|
|
||||||
transmute(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> PartialEq<Namespace> for BorrowedNamespace<'a> {
|
|
||||||
fn eq(&self, other: &Namespace) -> bool {
|
|
||||||
self.weak_ptr == other.0.as_ptr()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for Atom {}
|
unsafe impl Send for Atom {}
|
||||||
unsafe impl Sync for Atom {}
|
unsafe impl Sync for Atom {}
|
||||||
|
unsafe impl Sync for WeakAtom {}
|
||||||
|
|
||||||
|
impl WeakAtom {
|
||||||
|
#[inline]
|
||||||
|
pub unsafe fn new<'a>(atom: *mut nsIAtom) -> &'a mut Self {
|
||||||
|
&mut *(atom as *mut WeakAtom)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn clone(&self) -> Atom {
|
||||||
|
Atom::from(self.as_ptr())
|
||||||
|
}
|
||||||
|
|
||||||
impl Atom {
|
|
||||||
pub fn get_hash(&self) -> u32 {
|
pub fn get_hash(&self) -> u32 {
|
||||||
unsafe {
|
self.0.mHash
|
||||||
(*self.0).mHash
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_slice(&self) -> &[u16] {
|
pub fn as_slice(&self) -> &[u16] {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut len = 0;
|
let mut len = 0;
|
||||||
let ptr = Gecko_GetAtomAsUTF16(self.0, &mut len);
|
let ptr = Gecko_GetAtomAsUTF16(self.as_ptr(), &mut len);
|
||||||
slice::from_raw_parts(ptr, len as usize)
|
slice::from_raw_parts(ptr, len as usize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn chars(&self) -> DecodeUtf16<Cloned<slice::Iter<u16>>> {
|
||||||
|
char::decode_utf16(self.as_slice().iter().cloned())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn with_str<F, Output>(&self, cb: F) -> Output
|
pub fn with_str<F, Output>(&self, cb: F) -> Output
|
||||||
where F: FnOnce(&str) -> Output {
|
where F: FnOnce(&str) -> Output {
|
||||||
// FIXME(bholley): We should measure whether it makes more sense to
|
// FIXME(bholley): We should measure whether it makes more sense to
|
||||||
|
@ -124,7 +125,7 @@ impl Atom {
|
||||||
|
|
||||||
pub fn eq_str_ignore_ascii_case(&self, s: &str) -> bool {
|
pub fn eq_str_ignore_ascii_case(&self, s: &str) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_AtomEqualsUTF8IgnoreCase(self.0, s.as_ptr() as *const _, s.len() as u32)
|
Gecko_AtomEqualsUTF8IgnoreCase(self.as_ptr(), s.as_ptr() as *const _, s.len() as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,29 +133,43 @@ impl Atom {
|
||||||
String::from_utf16(self.as_slice()).unwrap()
|
String::from_utf16(self.as_slice()).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn as_ptr(&self) -> *mut nsIAtom {
|
pub fn as_ptr(&self) -> *mut nsIAtom {
|
||||||
self.0
|
let const_ptr: *const nsIAtom = &self.0;
|
||||||
|
const_ptr as *mut nsIAtom
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Atom {
|
||||||
pub unsafe fn with<F>(ptr: *mut nsIAtom, callback: &mut F) where F: FnMut(&Atom) {
|
pub unsafe fn with<F>(ptr: *mut nsIAtom, callback: &mut F) where F: FnMut(&Atom) {
|
||||||
callback(transmute(&ptr))
|
let atom = Atom(WeakAtom::new(ptr));
|
||||||
}
|
callback(&atom);
|
||||||
|
mem::forget(atom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Static atoms have a dummy AddRef/Release, so we don't bother calling
|
impl BloomHash for Atom {
|
||||||
// AddRef() here. This would cause memory corruption with non-static atoms
|
#[inline]
|
||||||
// both because (a) we wouldn't hold the atom alive, and (b) we can't avoid
|
fn bloom_hash(&self) -> u32 {
|
||||||
// calling Release() when the Atom is dropped, since we can't tell the
|
self.get_hash()
|
||||||
// difference between static and non-static atoms without bloating the
|
}
|
||||||
// size of Atom beyond word-size.
|
}
|
||||||
pub unsafe fn from_static(ptr: *mut nsIAtom) -> Atom {
|
|
||||||
Atom(ptr)
|
impl BloomHash for WeakAtom {
|
||||||
|
#[inline]
|
||||||
|
fn bloom_hash(&self) -> u32 {
|
||||||
|
self.get_hash()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Hash for Atom {
|
impl Hash for Atom {
|
||||||
fn hash<H>(&self, state: &mut H)
|
fn hash<H>(&self, state: &mut H) where H: Hasher {
|
||||||
where H: Hasher
|
state.write_u32(self.get_hash());
|
||||||
{
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Hash for WeakAtom {
|
||||||
|
fn hash<H>(&self, state: &mut H) where H: Hasher {
|
||||||
state.write_u32(self.get_hash());
|
state.write_u32(self.get_hash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,10 +177,7 @@ impl Hash for Atom {
|
||||||
impl Clone for Atom {
|
impl Clone for Atom {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn clone(&self) -> Atom {
|
fn clone(&self) -> Atom {
|
||||||
unsafe {
|
Atom::from(self.as_ptr())
|
||||||
Gecko_AddRefAtom(self.0);
|
|
||||||
}
|
|
||||||
Atom(self.0)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,18 +185,19 @@ impl Drop for Atom {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_ReleaseAtom(self.0);
|
Gecko_ReleaseAtom(self.as_ptr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HeapSizeOf for Atom {
|
impl Default for Atom {
|
||||||
fn heap_size_of_children(&self) -> usize {
|
#[inline]
|
||||||
0
|
fn default() -> Self {
|
||||||
|
atom!("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HeapSizeOf for Namespace {
|
impl HeapSizeOf for Atom {
|
||||||
fn heap_size_of_children(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
@ -222,9 +235,11 @@ impl<'a> From<&'a str> for Atom {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(string: &str) -> Atom {
|
fn from(string: &str) -> Atom {
|
||||||
assert!(string.len() <= u32::max_value() as usize);
|
assert!(string.len() <= u32::max_value() as usize);
|
||||||
Atom(unsafe {
|
unsafe {
|
||||||
Gecko_Atomize(string.as_ptr() as *const _, string.len() as u32)
|
Atom(WeakAtom::new(
|
||||||
})
|
Gecko_Atomize(string.as_ptr() as *const _, string.len() as u32)
|
||||||
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,6 +250,13 @@ impl<'a> From<Cow<'a, str>> for Atom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FromCowStr for Atom {
|
||||||
|
#[inline]
|
||||||
|
fn from_cow_str(string: Cow<str>) -> Atom {
|
||||||
|
Atom::from(&*string)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<String> for Atom {
|
impl From<String> for Atom {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(string: String) -> Atom {
|
fn from(string: String) -> Atom {
|
||||||
|
@ -243,10 +265,11 @@ impl From<String> for Atom {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<*mut nsIAtom> for Atom {
|
impl From<*mut nsIAtom> for Atom {
|
||||||
|
#[inline]
|
||||||
fn from(ptr: *mut nsIAtom) -> Atom {
|
fn from(ptr: *mut nsIAtom) -> Atom {
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_AddRefAtom(ptr);
|
Gecko_AddRefAtom(ptr);
|
||||||
Atom(ptr)
|
Atom(WeakAtom::new(ptr))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ use gecko_bindings::bindings::{Gecko_LocalName, Gecko_Namespace, Gecko_NodeIsEle
|
||||||
use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
|
use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
|
||||||
use gecko_bindings::structs::{NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO, NODE_IS_DIRTY_FOR_SERVO};
|
use gecko_bindings::structs::{NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO, NODE_IS_DIRTY_FOR_SERVO};
|
||||||
use gecko_bindings::structs::{nsIAtom, nsChangeHint, nsStyleContext};
|
use gecko_bindings::structs::{nsIAtom, nsChangeHint, nsStyleContext};
|
||||||
|
use gecko_string_cache::{Atom, Namespace, WeakAtom};
|
||||||
use glue::GeckoDeclarationBlock;
|
use glue::GeckoDeclarationBlock;
|
||||||
use libc::uintptr_t;
|
use libc::uintptr_t;
|
||||||
use selectors::Element;
|
use selectors::Element;
|
||||||
|
@ -37,7 +38,6 @@ use std::marker::PhantomData;
|
||||||
use std::ops::BitOr;
|
use std::ops::BitOr;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use string_cache::{Atom, BorrowedAtom, BorrowedNamespace, Namespace};
|
|
||||||
use style::data::PrivateStyleData;
|
use style::data::PrivateStyleData;
|
||||||
use style::dom::{OpaqueNode, PresentationalHintsSynthetizer};
|
use style::dom::{OpaqueNode, PresentationalHintsSynthetizer};
|
||||||
use style::dom::{TDocument, TElement, TNode, TRestyleDamage, UnsafeNode};
|
use style::dom::{TDocument, TElement, TNode, TRestyleDamage, UnsafeNode};
|
||||||
|
@ -433,7 +433,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
fn has_attr(&self, namespace: &Namespace, attr: &Atom) -> bool {
|
fn has_attr(&self, namespace: &Namespace, attr: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_HasAttr(self.element,
|
bindings::Gecko_HasAttr(self.element,
|
||||||
namespace.0.as_ptr(),
|
namespace.as_ptr(),
|
||||||
attr.as_ptr())
|
attr.as_ptr())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -442,7 +442,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
fn attr_equals(&self, namespace: &Namespace, attr: &Atom, val: &Atom) -> bool {
|
fn attr_equals(&self, namespace: &Namespace, attr: &Atom, val: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_AttrEquals(self.element,
|
bindings::Gecko_AttrEquals(self.element,
|
||||||
namespace.0.as_ptr(),
|
namespace.as_ptr(),
|
||||||
attr.as_ptr(),
|
attr.as_ptr(),
|
||||||
val.as_ptr(),
|
val.as_ptr(),
|
||||||
/* ignoreCase = */ false)
|
/* ignoreCase = */ false)
|
||||||
|
@ -459,8 +459,6 @@ impl<'le> PresentationalHintsSynthetizer for GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'le> ::selectors::Element for GeckoElement<'le> {
|
impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
type Impl = GeckoSelectorImpl;
|
|
||||||
|
|
||||||
fn parent_element(&self) -> Option<Self> {
|
fn parent_element(&self) -> Option<Self> {
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_GetParentElement(self.element).as_ref().map(|el| GeckoElement::from_ref(el))
|
Gecko_GetParentElement(self.element).as_ref().map(|el| GeckoElement::from_ref(el))
|
||||||
|
@ -502,15 +500,15 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_local_name<'a>(&'a self) -> BorrowedAtom<'a> {
|
fn get_local_name(&self) -> &WeakAtom {
|
||||||
unsafe {
|
unsafe {
|
||||||
BorrowedAtom::new(Gecko_LocalName(self.element))
|
WeakAtom::new(Gecko_LocalName(self.element))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_namespace<'a>(&'a self) -> BorrowedNamespace<'a> {
|
fn get_namespace(&self) -> &WeakAtom {
|
||||||
unsafe {
|
unsafe {
|
||||||
BorrowedNamespace::new(Gecko_Namespace(self.element))
|
WeakAtom::new(Gecko_Namespace(self.element))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,11 +573,11 @@ pub trait AttrSelectorHelpers {
|
||||||
fn select_name(&self, is_html_element_in_html_document: bool) -> *mut nsIAtom;
|
fn select_name(&self, is_html_element_in_html_document: bool) -> *mut nsIAtom;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AttrSelectorHelpers for AttrSelector {
|
impl AttrSelectorHelpers for AttrSelector<GeckoSelectorImpl> {
|
||||||
fn ns_or_null(&self) -> *mut nsIAtom {
|
fn ns_or_null(&self) -> *mut nsIAtom {
|
||||||
match self.namespace {
|
match self.namespace {
|
||||||
NamespaceConstraint::Any => ptr::null_mut(),
|
NamespaceConstraint::Any => ptr::null_mut(),
|
||||||
NamespaceConstraint::Specific(ref ns) => ns.0.as_ptr(),
|
NamespaceConstraint::Specific(ref ns) => ns.as_ptr(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,15 +591,16 @@ impl AttrSelectorHelpers for AttrSelector {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'le> ::selectors::MatchAttr for GeckoElement<'le> {
|
impl<'le> ::selectors::MatchAttr for GeckoElement<'le> {
|
||||||
type AttrString = Atom;
|
type Impl = GeckoSelectorImpl;
|
||||||
fn match_attr_has(&self, attr: &AttrSelector) -> bool {
|
|
||||||
|
fn match_attr_has(&self, attr: &AttrSelector<Self::Impl>) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_HasAttr(self.element,
|
bindings::Gecko_HasAttr(self.element,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
attr.select_name(self.is_html_element_in_html_document()))
|
attr.select_name(self.is_html_element_in_html_document()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn match_attr_equals(&self, attr: &AttrSelector, value: &Self::AttrString) -> bool {
|
fn match_attr_equals(&self, attr: &AttrSelector<Self::Impl>, value: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_AttrEquals(self.element,
|
bindings::Gecko_AttrEquals(self.element,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
|
@ -610,7 +609,7 @@ impl<'le> ::selectors::MatchAttr for GeckoElement<'le> {
|
||||||
/* ignoreCase = */ false)
|
/* ignoreCase = */ false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn match_attr_equals_ignore_ascii_case(&self, attr: &AttrSelector, value: &Self::AttrString) -> bool {
|
fn match_attr_equals_ignore_ascii_case(&self, attr: &AttrSelector<Self::Impl>, value: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_AttrEquals(self.element,
|
bindings::Gecko_AttrEquals(self.element,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
|
@ -619,7 +618,7 @@ impl<'le> ::selectors::MatchAttr for GeckoElement<'le> {
|
||||||
/* ignoreCase = */ false)
|
/* ignoreCase = */ false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn match_attr_includes(&self, attr: &AttrSelector, value: &Self::AttrString) -> bool {
|
fn match_attr_includes(&self, attr: &AttrSelector<Self::Impl>, value: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_AttrIncludes(self.element,
|
bindings::Gecko_AttrIncludes(self.element,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
|
@ -627,7 +626,7 @@ impl<'le> ::selectors::MatchAttr for GeckoElement<'le> {
|
||||||
value.as_ptr())
|
value.as_ptr())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn match_attr_dash(&self, attr: &AttrSelector, value: &Self::AttrString) -> bool {
|
fn match_attr_dash(&self, attr: &AttrSelector<Self::Impl>, value: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_AttrDashEquals(self.element,
|
bindings::Gecko_AttrDashEquals(self.element,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
|
@ -635,7 +634,7 @@ impl<'le> ::selectors::MatchAttr for GeckoElement<'le> {
|
||||||
value.as_ptr())
|
value.as_ptr())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn match_attr_prefix(&self, attr: &AttrSelector, value: &Self::AttrString) -> bool {
|
fn match_attr_prefix(&self, attr: &AttrSelector<Self::Impl>, value: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_AttrHasPrefix(self.element,
|
bindings::Gecko_AttrHasPrefix(self.element,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
|
@ -643,7 +642,7 @@ impl<'le> ::selectors::MatchAttr for GeckoElement<'le> {
|
||||||
value.as_ptr())
|
value.as_ptr())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn match_attr_substring(&self, attr: &AttrSelector, value: &Self::AttrString) -> bool {
|
fn match_attr_substring(&self, attr: &AttrSelector<Self::Impl>, value: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_AttrHasSubstring(self.element,
|
bindings::Gecko_AttrHasSubstring(self.element,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
|
@ -651,7 +650,7 @@ impl<'le> ::selectors::MatchAttr for GeckoElement<'le> {
|
||||||
value.as_ptr())
|
value.as_ptr())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn match_attr_suffix(&self, attr: &AttrSelector, value: &Self::AttrString) -> bool {
|
fn match_attr_suffix(&self, attr: &AttrSelector<Self::Impl>, value: &Atom) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_AttrHasSuffix(self.element,
|
bindings::Gecko_AttrHasSuffix(self.element,
|
||||||
attr.ns_or_null(),
|
attr.ns_or_null(),
|
||||||
|
|
|
@ -14,7 +14,7 @@ app_units = "0.2.5"
|
||||||
cssparser = {version = "0.5.4", features = ["heap_size"]}
|
cssparser = {version = "0.5.4", features = ["heap_size"]}
|
||||||
euclid = "0.7.1"
|
euclid = "0.7.1"
|
||||||
rustc-serialize = "0.3"
|
rustc-serialize = "0.3"
|
||||||
selectors = {version = "0.7", features = ["heap_size"]}
|
selectors = {version = "0.8", features = ["heap_size"]}
|
||||||
string_cache = {version = "0.2", features = ["heap_size"]}
|
string_cache = {version = "0.2", features = ["heap_size"]}
|
||||||
style = {path = "../../../components/style"}
|
style = {path = "../../../components/style"}
|
||||||
style_traits = {path = "../../../components/style_traits"}
|
style_traits = {path = "../../../components/style_traits"}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue