Auto merge of #22083 - servo:2018, r=emilio

Prepare stylo crates for switching to the 2018 edition

This can land when [Gecko requires Rust 1.30](https://bugzilla.mozilla.org/show_bug.cgi?id=1504031). This does not switch the crates yet because the new edition is not yet stable in 1.30.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22083)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-11-10 11:48:09 -05:00 committed by GitHub
commit 3b1078b58d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
259 changed files with 2667 additions and 2601 deletions

View file

@ -26,7 +26,7 @@ pub use std::collections::hash_set::{IntoIter as SetIntoIter, Iter as SetIter};
#[derive(Clone)] #[derive(Clone)]
pub struct HashMap<K, V, S = RandomState>(StdMap<K, V, S>); pub struct HashMap<K, V, S = RandomState>(StdMap<K, V, S>);
use FailedAllocationError; use crate::FailedAllocationError;
impl<K, V, S> Deref for HashMap<K, V, S> { impl<K, V, S> Deref for HashMap<K, V, S> {
type Target = StdMap<K, V, S>; type Target = StdMap<K, V, S>;

View file

@ -23,7 +23,7 @@ use std::ops::{Deref, Index};
use super::table::BucketState::{Empty, Full}; use super::table::BucketState::{Empty, Full};
use super::table::{self, Bucket, EmptyBucket, FullBucket, FullBucketMut, RawTable, SafeHash}; use super::table::{self, Bucket, EmptyBucket, FullBucket, FullBucketMut, RawTable, SafeHash};
use FailedAllocationError; use crate::FailedAllocationError;
const MIN_NONZERO_RAW_CAPACITY: usize = 32; // must be a power of two const MIN_NONZERO_RAW_CAPACITY: usize = 32; // must be a power of two

View file

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use alloc::{alloc, dealloc}; use crate::alloc::{alloc, dealloc};
use shim::{Shared, Unique}; use crate::shim::{Shared, Unique};
use std::cmp; use std::cmp;
use std::hash::{BuildHasher, Hash, Hasher}; use std::hash::{BuildHasher, Hash, Hasher};
use std::marker; use std::marker;
@ -18,7 +18,7 @@ use std::ops::{Deref, DerefMut};
use std::ptr; use std::ptr;
use self::BucketState::*; use self::BucketState::*;
use FailedAllocationError; use crate::FailedAllocationError;
/// Integer type used for stored hash values. /// Integer type used for stored hash values.
/// ///
@ -795,7 +795,7 @@ impl<K, V> RawTable<K, V> {
let buffer = alloc(size, alignment); let buffer = alloc(size, alignment);
if buffer.is_null() { if buffer.is_null() {
use AllocationInfo; use crate::AllocationInfo;
return Err(FailedAllocationError { return Err(FailedAllocationError {
reason: "out of memory when allocating RawTable", reason: "out of memory when allocating RawTable",
allocation_info: Some(AllocationInfo { size, alignment }), allocation_info: Some(AllocationInfo { size, alignment }),

View file

@ -2,8 +2,8 @@
* 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/. */
use crate::parser::SelectorImpl;
use cssparser::ToCss; use cssparser::ToCss;
use parser::SelectorImpl;
use std::fmt; use std::fmt;
#[derive(Clone, Eq, PartialEq)] #[derive(Clone, Eq, PartialEq)]

View file

@ -17,9 +17,9 @@
//! is non-trivial. This module encapsulates those details and presents an //! is non-trivial. This module encapsulates those details and presents an
//! easy-to-use API for the parser. //! easy-to-use API for the parser.
use parser::{Combinator, Component, SelectorImpl}; use crate::parser::{Combinator, Component, SelectorImpl};
use crate::sink::Push;
use servo_arc::{Arc, HeaderWithLength, ThinArc}; use servo_arc::{Arc, HeaderWithLength, ThinArc};
use sink::Push;
use smallvec::{self, SmallVec}; use smallvec::{self, SmallVec};
use std::cmp; use std::cmp;
use std::iter; use std::iter;

View file

@ -2,11 +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/. */
use attr::CaseSensitivity; use crate::attr::CaseSensitivity;
use bloom::BloomFilter; use crate::bloom::BloomFilter;
use nth_index_cache::NthIndexCache; use crate::nth_index_cache::NthIndexCache;
use parser::SelectorImpl; use crate::parser::SelectorImpl;
use tree::{Element, OpaqueElement}; use crate::tree::{Element, OpaqueElement};
/// What kind of selector matching mode we should use. /// What kind of selector matching mode we should use.
/// ///

View file

@ -31,6 +31,6 @@ pub mod sink;
mod tree; mod tree;
pub mod visitor; pub mod visitor;
pub use nth_index_cache::NthIndexCache; pub use crate::nth_index_cache::NthIndexCache;
pub use parser::{Parser, SelectorImpl, SelectorList}; pub use crate::parser::{Parser, SelectorImpl, SelectorList};
pub use tree::{Element, OpaqueElement}; pub use crate::tree::{Element, OpaqueElement};

View file

@ -2,16 +2,16 @@
* 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/. */
use attr::{AttrSelectorOperation, NamespaceConstraint, ParsedAttrSelectorOperation}; use crate::attr::{AttrSelectorOperation, NamespaceConstraint, ParsedAttrSelectorOperation};
use bloom::{BloomFilter, BLOOM_HASH_MASK}; use crate::bloom::{BloomFilter, BLOOM_HASH_MASK};
use nth_index_cache::NthIndexCacheInner; use crate::nth_index_cache::NthIndexCacheInner;
use parser::{AncestorHashes, Combinator, Component, LocalName}; use crate::parser::{AncestorHashes, Combinator, Component, LocalName};
use parser::{NonTSPseudoClass, Selector, SelectorImpl, SelectorIter, SelectorList}; use crate::parser::{NonTSPseudoClass, Selector, SelectorImpl, SelectorIter, SelectorList};
use crate::tree::Element;
use std::borrow::Borrow; use std::borrow::Borrow;
use std::iter; use std::iter;
use tree::Element;
pub use context::*; pub use crate::context::*;
// The bloom filter for descendant CSS selectors will have a <1% false // The bloom filter for descendant CSS selectors will have a <1% false
// positive rate until it has this many selectors in it, then it will // positive rate until it has this many selectors in it, then it will
@ -678,7 +678,7 @@ where
element.namespace() == url.borrow() element.namespace() == url.borrow()
}, },
Component::ExplicitNoNamespace => { Component::ExplicitNoNamespace => {
let ns = ::parser::namespace_empty_string::<E::Impl>(); let ns = crate::parser::namespace_empty_string::<E::Impl>();
element.namespace() == ns.borrow() element.namespace() == ns.borrow()
}, },
Component::ID(ref id) => { Component::ID(ref id) => {
@ -693,7 +693,7 @@ where
} => { } => {
let is_html = element.is_html_element_in_html_document(); let is_html = element.is_html_element_in_html_document();
element.attr_matches( element.attr_matches(
&NamespaceConstraint::Specific(&::parser::namespace_empty_string::<E::Impl>()), &NamespaceConstraint::Specific(&crate::parser::namespace_empty_string::<E::Impl>()),
select_name(is_html, local_name, local_name_lower), select_name(is_html, local_name, local_name_lower),
&AttrSelectorOperation::Exists, &AttrSelectorOperation::Exists,
) )
@ -710,7 +710,7 @@ where
} }
let is_html = element.is_html_element_in_html_document(); let is_html = element.is_html_element_in_html_document();
element.attr_matches( element.attr_matches(
&NamespaceConstraint::Specific(&::parser::namespace_empty_string::<E::Impl>()), &NamespaceConstraint::Specific(&crate::parser::namespace_empty_string::<E::Impl>()),
local_name, local_name,
&AttrSelectorOperation::WithValue { &AttrSelectorOperation::WithValue {
operator: operator, operator: operator,
@ -728,7 +728,7 @@ where
let namespace = match attr_sel.namespace() { let namespace = match attr_sel.namespace() {
Some(ns) => ns, Some(ns) => ns,
None => { None => {
empty_string = ::parser::namespace_empty_string::<E::Impl>(); empty_string = crate::parser::namespace_empty_string::<E::Impl>();
NamespaceConstraint::Specific(&empty_string) NamespaceConstraint::Specific(&empty_string)
}, },
}; };

View file

@ -2,8 +2,8 @@
* 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/. */
use crate::tree::OpaqueElement;
use fxhash::FxHashMap; use fxhash::FxHashMap;
use tree::OpaqueElement;
/// A cache to speed up matching of nth-index-like selectors. /// A cache to speed up matching of nth-index-like selectors.
/// ///

View file

@ -2,26 +2,26 @@
* 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/. */
use attr::{AttrSelectorOperator, AttrSelectorWithOptionalNamespace}; use crate::attr::{AttrSelectorOperator, AttrSelectorWithOptionalNamespace};
use attr::{NamespaceConstraint, ParsedAttrSelectorOperation}; use crate::attr::{NamespaceConstraint, ParsedAttrSelectorOperation};
use attr::{ParsedCaseSensitivity, SELECTOR_WHITESPACE}; use crate::attr::{ParsedCaseSensitivity, SELECTOR_WHITESPACE};
use bloom::BLOOM_HASH_MASK; use crate::bloom::BLOOM_HASH_MASK;
use builder::{SelectorBuilder, SpecificityAndFlags}; use crate::builder::{SelectorBuilder, SpecificityAndFlags};
use context::QuirksMode; use crate::context::QuirksMode;
use crate::sink::Push;
pub use crate::visitor::{SelectorVisitor, Visit};
use cssparser::{parse_nth, serialize_identifier}; use cssparser::{parse_nth, serialize_identifier};
use cssparser::{BasicParseError, BasicParseErrorKind, ParseError, ParseErrorKind}; use cssparser::{BasicParseError, BasicParseErrorKind, ParseError, ParseErrorKind};
use cssparser::{CowRcStr, Delimiter, SourceLocation}; use cssparser::{CowRcStr, Delimiter, SourceLocation};
use cssparser::{CssStringWriter, Parser as CssParser, ToCss, Token}; use cssparser::{CssStringWriter, Parser as CssParser, ToCss, Token};
use precomputed_hash::PrecomputedHash; use precomputed_hash::PrecomputedHash;
use servo_arc::ThinArc; use servo_arc::ThinArc;
use sink::Push;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::borrow::{Borrow, Cow}; use std::borrow::{Borrow, Cow};
use std::fmt::{self, Debug, Display, Write}; use std::fmt::{self, Debug, Display, Write};
use std::iter::Rev; use std::iter::Rev;
use std::slice; use std::slice;
use thin_slice::ThinBoxedSlice; use thin_slice::ThinBoxedSlice;
pub use visitor::{SelectorVisitor, Visit};
/// A trait that represents a pseudo-element. /// A trait that represents a pseudo-element.
pub trait PseudoElement: Sized + ToCss { pub trait PseudoElement: Sized + ToCss {
@ -465,7 +465,7 @@ where
let namespace = match attr_selector.namespace() { let namespace = match attr_selector.namespace() {
Some(ns) => ns, Some(ns) => ns,
None => { None => {
empty_string = ::parser::namespace_empty_string::<Impl>(); empty_string = crate::parser::namespace_empty_string::<Impl>();
NamespaceConstraint::Specific(&empty_string) NamespaceConstraint::Specific(&empty_string)
}, },
}; };
@ -2147,9 +2147,9 @@ where
#[cfg(test)] #[cfg(test)]
pub mod tests { pub mod tests {
use super::*; use super::*;
use builder::HAS_PSEUDO_BIT; use crate::builder::HAS_PSEUDO_BIT;
use crate::parser;
use cssparser::{serialize_identifier, Parser as CssParser, ParserInput, ToCss}; use cssparser::{serialize_identifier, Parser as CssParser, ParserInput, ToCss};
use parser;
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt; use std::fmt;

View file

@ -5,9 +5,9 @@
//! Traits that nodes must implement. Breaks the otherwise-cyclic dependency //! Traits that nodes must implement. Breaks the otherwise-cyclic dependency
//! between layout and style. //! between layout and style.
use attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint}; use crate::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
use matching::{ElementSelectorFlags, MatchingContext}; use crate::matching::{ElementSelectorFlags, MatchingContext};
use parser::SelectorImpl; use crate::parser::SelectorImpl;
use std::fmt::Debug; use std::fmt::Debug;
use std::ptr::NonNull; use std::ptr::NonNull;

View file

@ -6,8 +6,8 @@
#![deny(missing_docs)] #![deny(missing_docs)]
use attr::NamespaceConstraint; use crate::attr::NamespaceConstraint;
use parser::{Combinator, Component, SelectorImpl}; use crate::parser::{Combinator, Component, SelectorImpl};
/// A trait to visit selector properties. /// A trait to visit selector properties.
/// ///

View file

@ -1060,7 +1060,7 @@ unsafe impl<A: Sync + Send, B: Send + Sync> Sync for ArcUnion<A, B> {}
impl<A: PartialEq, B: PartialEq> PartialEq for ArcUnion<A, B> { impl<A: PartialEq, B: PartialEq> PartialEq for ArcUnion<A, B> {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {
use ArcUnionBorrow::*; use crate::ArcUnionBorrow::*;
match (self.borrow(), other.borrow()) { match (self.borrow(), other.borrow()) {
(First(x), First(y)) => x == y, (First(x), First(y)) => x == y,
(Second(x), Second(y)) => x == y, (Second(x), Second(y)) => x == y,

View file

@ -8,29 +8,29 @@
// compile it out so that people remember it exists, thus the cfg'd Sender // compile it out so that people remember it exists, thus the cfg'd Sender
// import. // import.
use bezier::Bezier; use crate::bezier::Bezier;
use context::SharedStyleContext; use crate::context::SharedStyleContext;
use dom::{OpaqueNode, TElement}; use crate::dom::{OpaqueNode, TElement};
use font_metrics::FontMetricsProvider; use crate::font_metrics::FontMetricsProvider;
use properties::animated_properties::AnimatedProperty; use crate::properties::animated_properties::AnimatedProperty;
use properties::longhands::animation_direction::computed_value::single_value::T as AnimationDirection; use crate::properties::longhands::animation_direction::computed_value::single_value::T as AnimationDirection;
use properties::longhands::animation_play_state::computed_value::single_value::T as AnimationPlayState; use crate::properties::longhands::animation_play_state::computed_value::single_value::T as AnimationPlayState;
use properties::{self, CascadeMode, ComputedValues, LonghandId}; use crate::properties::{self, CascadeMode, ComputedValues, LonghandId};
use rule_tree::CascadeLevel; use crate::rule_tree::CascadeLevel;
use crate::stylesheets::keyframes_rule::{KeyframesAnimation, KeyframesStep, KeyframesStepValue};
use crate::timer::Timer;
use crate::values::computed::box_::TransitionProperty;
use crate::values::computed::Time;
use crate::values::computed::TimingFunction;
use crate::values::generics::box_::AnimationIterationCount;
use crate::values::generics::easing::{StepPosition, TimingFunction as GenericTimingFunction};
use crate::Atom;
use servo_arc::Arc; use servo_arc::Arc;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
use servo_channel::Sender; use servo_channel::Sender;
use std::fmt; use std::fmt;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use std::sync::mpsc::Sender; use std::sync::mpsc::Sender;
use stylesheets::keyframes_rule::{KeyframesAnimation, KeyframesStep, KeyframesStepValue};
use timer::Timer;
use values::computed::box_::TransitionProperty;
use values::computed::Time;
use values::computed::TimingFunction;
use values::generics::box_::AnimationIterationCount;
use values::generics::easing::{StepPosition, TimingFunction as GenericTimingFunction};
use Atom;
/// This structure represents a keyframes animation current iteration state. /// This structure represents a keyframes animation current iteration state.
/// ///

View file

@ -4,10 +4,10 @@
//! Applicable declarations management. //! Applicable declarations management.
use properties::PropertyDeclarationBlock; use crate::properties::PropertyDeclarationBlock;
use rule_tree::{CascadeLevel, ShadowCascadeOrder, StyleSource}; use crate::rule_tree::{CascadeLevel, ShadowCascadeOrder, StyleSource};
use crate::shared_lock::Locked;
use servo_arc::Arc; use servo_arc::Arc;
use shared_lock::Locked;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::fmt::{self, Debug}; use std::fmt::{self, Debug};

View file

@ -7,20 +7,20 @@
//! [attr]: https://dom.spec.whatwg.org/#interface-attr //! [attr]: https://dom.spec.whatwg.org/#interface-attr
use app_units::Au; use app_units::Au;
use crate::properties::PropertyDeclarationBlock;
use crate::shared_lock::Locked;
use crate::str::str_join;
use crate::str::{read_exponent, read_fraction, HTML_SPACE_CHARACTERS};
use crate::str::{read_numbers, split_commas, split_html_space_chars};
use crate::values::specified::Length;
use crate::{Atom, LocalName, Namespace, Prefix};
use cssparser::{self, Color, RGBA}; use cssparser::{self, Color, RGBA};
use euclid::num::Zero; use euclid::num::Zero;
use num_traits::ToPrimitive; use num_traits::ToPrimitive;
use properties::PropertyDeclarationBlock;
use selectors::attr::AttrSelectorOperation; use selectors::attr::AttrSelectorOperation;
use servo_arc::Arc; use servo_arc::Arc;
use servo_url::ServoUrl; use servo_url::ServoUrl;
use shared_lock::Locked;
use std::str::FromStr; use std::str::FromStr;
use str::str_join;
use str::{read_exponent, read_fraction, HTML_SPACE_CHARACTERS};
use str::{read_numbers, split_commas, split_html_space_chars};
use values::specified::Length;
use {Atom, LocalName, Namespace, Prefix};
// Duplicated from script::dom::values. // Duplicated from script::dom::values.
const UNSIGNED_LONG_MAX: u32 = 2147483647; const UNSIGNED_LONG_MAX: u32 = 2147483647;

View file

@ -5,16 +5,16 @@
//! A set of author stylesheets and their computed representation, such as the //! A set of author stylesheets and their computed representation, such as the
//! ones used for ShadowRoot and XBL. //! ones used for ShadowRoot and XBL.
use context::QuirksMode; use crate::context::QuirksMode;
use dom::TElement; use crate::dom::TElement;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI}; use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
use invalidation::media_queries::ToMediaListKey; use crate::invalidation::media_queries::ToMediaListKey;
use media_queries::Device; use crate::media_queries::Device;
use shared_lock::SharedRwLockReadGuard; use crate::shared_lock::SharedRwLockReadGuard;
use stylesheet_set::AuthorStylesheetSet; use crate::stylesheet_set::AuthorStylesheetSet;
use stylesheets::StylesheetInDocument; use crate::stylesheets::StylesheetInDocument;
use stylist::CascadeData; use crate::stylist::CascadeData;
/// A set of author stylesheets and their computed representation, such as the /// A set of author stylesheets and their computed representation, such as the
/// ones used for ShadowRoot and XBL. /// ones used for ShadowRoot and XBL.
@ -76,10 +76,10 @@ where
} }
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
unsafe impl HasFFI for AuthorStyles<::gecko::data::GeckoStyleSheet> { unsafe impl HasFFI for AuthorStyles<crate::gecko::data::GeckoStyleSheet> {
type FFIType = ::gecko_bindings::bindings::RawServoAuthorStyles; type FFIType = crate::gecko_bindings::bindings::RawServoAuthorStyles;
} }
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
unsafe impl HasSimpleFFI for AuthorStyles<::gecko::data::GeckoStyleSheet> {} unsafe impl HasSimpleFFI for AuthorStyles<crate::gecko::data::GeckoStyleSheet> {}
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
unsafe impl HasBoxFFI for AuthorStyles<::gecko::data::GeckoStyleSheet> {} unsafe impl HasBoxFFI for AuthorStyles<crate::gecko::data::GeckoStyleSheet> {}

View file

@ -8,7 +8,7 @@
#![deny(missing_docs)] #![deny(missing_docs)]
use values::CSSFloat; use crate::values::CSSFloat;
const NEWTON_METHOD_ITERATIONS: u8 = 8; const NEWTON_METHOD_ITERATIONS: u8 = 8;

View file

@ -8,7 +8,7 @@
#![deny(missing_docs)] #![deny(missing_docs)]
use atomic_refcell::{AtomicRefCell, AtomicRefMut}; use atomic_refcell::{AtomicRefCell, AtomicRefMut};
use dom::{SendElement, TElement}; use crate::dom::{SendElement, TElement};
use owning_ref::OwningHandle; use owning_ref::OwningHandle;
use selectors::bloom::BloomFilter; use selectors::bloom::BloomFilter;
use servo_arc::Arc; use servo_arc::Arc;

View file

@ -4,29 +4,36 @@
//! The context within which style is calculated. //! The context within which style is calculated.
#[cfg(feature = "servo")]
use animation::Animation;
use app_units::Au; use app_units::Au;
use bloom::StyleBloom;
use data::{EagerPseudoStyles, ElementData};
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
use dom::OpaqueNode; use crate::animation::Animation;
use dom::{SendElement, TElement}; use crate::bloom::StyleBloom;
use crate::data::{EagerPseudoStyles, ElementData};
#[cfg(feature = "servo")]
use crate::dom::OpaqueNode;
use crate::dom::{SendElement, TElement};
use crate::font_metrics::FontMetricsProvider;
#[cfg(feature = "gecko")]
use crate::gecko_bindings::structs;
use crate::parallel::{STACK_SAFETY_MARGIN_KB, STYLE_THREAD_STACK_SIZE_KB};
use crate::properties::ComputedValues;
#[cfg(feature = "servo")]
use crate::properties::PropertyId;
use crate::rule_cache::RuleCache;
use crate::rule_tree::StrongRuleNode;
use crate::selector_parser::{SnapshotMap, EAGER_PSEUDO_COUNT};
use crate::shared_lock::StylesheetGuards;
use crate::sharing::StyleSharingCache;
use crate::stylist::Stylist;
use crate::thread_state::{self, ThreadState};
use crate::timer::Timer;
use crate::traversal::DomTraversal;
use crate::traversal_flags::TraversalFlags;
use euclid::Size2D; use euclid::Size2D;
use euclid::TypedScale; use euclid::TypedScale;
use font_metrics::FontMetricsProvider;
use fxhash::FxHashMap; use fxhash::FxHashMap;
#[cfg(feature = "gecko")]
use gecko_bindings::structs;
use parallel::{STACK_SAFETY_MARGIN_KB, STYLE_THREAD_STACK_SIZE_KB};
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
use parking_lot::RwLock; use parking_lot::RwLock;
use properties::ComputedValues;
#[cfg(feature = "servo")]
use properties::PropertyId;
use rule_cache::RuleCache;
use rule_tree::StrongRuleNode;
use selector_parser::{SnapshotMap, EAGER_PSEUDO_COUNT};
use selectors::matching::ElementSelectorFlags; use selectors::matching::ElementSelectorFlags;
use selectors::NthIndexCache; use selectors::NthIndexCache;
use servo_arc::Arc; use servo_arc::Arc;
@ -34,8 +41,6 @@ use servo_arc::Arc;
use servo_atoms::Atom; use servo_atoms::Atom;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
use servo_channel::Sender; use servo_channel::Sender;
use shared_lock::StylesheetGuards;
use sharing::StyleSharingCache;
use std::fmt; use std::fmt;
use std::ops; use std::ops;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
@ -44,12 +49,7 @@ use style_traits::CSSPixel;
use style_traits::DevicePixel; use style_traits::DevicePixel;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
use style_traits::SpeculativePainter; use style_traits::SpeculativePainter;
use stylist::Stylist;
use thread_state::{self, ThreadState};
use time; use time;
use timer::Timer;
use traversal::DomTraversal;
use traversal_flags::TraversalFlags;
use uluru::{Entry, LRUCache}; use uluru::{Entry, LRUCache};
pub use selectors::matching::QuirksMode; pub use selectors::matching::QuirksMode;

View file

@ -6,22 +6,22 @@
//! //!
//! [counter-style]: https://drafts.csswg.org/css-counter-styles/ //! [counter-style]: https://drafts.csswg.org/css-counter-styles/
use crate::error_reporting::ContextualParseError;
use crate::parser::{Parse, ParserContext};
use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
use crate::str::CssStringWriter;
use crate::values::specified::Integer;
use crate::values::CustomIdent;
use crate::Atom;
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser}; use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser};
use cssparser::{CowRcStr, Parser, SourceLocation, Token}; use cssparser::{CowRcStr, Parser, SourceLocation, Token};
use error_reporting::ContextualParseError;
use parser::{Parse, ParserContext};
use selectors::parser::SelectorParseErrorKind; use selectors::parser::SelectorParseErrorKind;
use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use std::mem; use std::mem;
use std::num::Wrapping; use std::num::Wrapping;
use std::ops::Range; use std::ops::Range;
use str::CssStringWriter;
use style_traits::{Comma, CssWriter, OneOrMoreSeparated, ParseError}; use style_traits::{Comma, CssWriter, OneOrMoreSeparated, ParseError};
use style_traits::{StyleParseErrorKind, ToCss}; use style_traits::{StyleParseErrorKind, ToCss};
use values::specified::Integer;
use values::CustomIdent;
use Atom;
/// Parse a counter style name reference. /// Parse a counter style name reference.
/// ///
@ -370,7 +370,7 @@ impl Parse for System {
"symbolic" => Ok(System::Symbolic), "symbolic" => Ok(System::Symbolic),
"additive" => Ok(System::Additive), "additive" => Ok(System::Additive),
"fixed" => { "fixed" => {
let first_symbol_value = input.try(|i| Integer::parse(context, i)).ok(); let first_symbol_value = input.r#try(|i| Integer::parse(context, i)).ok();
Ok(System::Fixed { first_symbol_value: first_symbol_value }) Ok(System::Fixed { first_symbol_value: first_symbol_value })
} }
"extends" => { "extends" => {
@ -457,7 +457,7 @@ impl Parse for Negative {
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
Ok(Negative( Ok(Negative(
Symbol::parse(context, input)?, Symbol::parse(context, input)?,
input.try(|input| Symbol::parse(context, input)).ok(), input.r#try(|input| Symbol::parse(context, input)).ok(),
)) ))
} }
} }
@ -483,7 +483,7 @@ impl Parse for Ranges {
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
if input if input
.try(|input| input.expect_ident_matching("auto")) .r#try(|input| input.expect_ident_matching("auto"))
.is_ok() .is_ok()
{ {
Ok(Ranges(Vec::new())) Ok(Ranges(Vec::new()))
@ -512,7 +512,7 @@ fn parse_bound<'i, 't>(
context: &ParserContext, context: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<CounterBound, ParseError<'i>> { ) -> Result<CounterBound, ParseError<'i>> {
if let Ok(integer) = input.try(|input| Integer::parse(context, input)) { if let Ok(integer) = input.r#try(|input| Integer::parse(context, input)) {
return Ok(CounterBound::Integer(integer)); return Ok(CounterBound::Integer(integer));
} }
input.expect_ident_matching("infinite")?; input.expect_ident_matching("infinite")?;
@ -556,7 +556,7 @@ impl Parse for Pad {
context: &ParserContext, context: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
let pad_with = input.try(|input| Symbol::parse(context, input)); let pad_with = input.r#try(|input| Symbol::parse(context, input));
let min_length = Integer::parse_non_negative(context, input)?; let min_length = Integer::parse_non_negative(context, input)?;
let pad_with = pad_with.or_else(|_| Symbol::parse(context, input))?; let pad_with = pad_with.or_else(|_| Symbol::parse(context, input))?;
Ok(Pad(min_length, pad_with)) Ok(Pad(min_length, pad_with))
@ -588,7 +588,7 @@ impl Parse for Symbols {
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
let mut symbols = Vec::new(); let mut symbols = Vec::new();
loop { loop {
if let Ok(s) = input.try(|input| Symbol::parse(context, input)) { if let Ok(s) = input.r#try(|input| Symbol::parse(context, input)) {
symbols.push(s) symbols.push(s)
} else { } else {
if symbols.is_empty() { if symbols.is_empty() {
@ -640,7 +640,7 @@ impl Parse for AdditiveTuple {
context: &ParserContext, context: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
let symbol = input.try(|input| Symbol::parse(context, input)); let symbol = input.r#try(|input| Symbol::parse(context, input));
let weight = Integer::parse_non_negative(context, input)?; let weight = Integer::parse_non_negative(context, input)?;
let symbol = symbol.or_else(|_| Symbol::parse(context, input))?; let symbol = symbol.or_else(|_| Symbol::parse(context, input))?;
Ok(AdditiveTuple { Ok(AdditiveTuple {
@ -673,7 +673,7 @@ impl Parse for SpeakAs {
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
let mut is_spell_out = false; let mut is_spell_out = false;
let result = input.try(|input| { let result = input.r#try(|input| {
let ident = input.expect_ident().map_err(|_| ())?; let ident = input.expect_ident().map_err(|_| ())?;
match_ignore_ascii_case! { &*ident, match_ignore_ascii_case! { &*ident,
"auto" => Ok(SpeakAs::Auto), "auto" => Ok(SpeakAs::Auto),

View file

@ -6,11 +6,12 @@
//! //!
//! [custom]: https://drafts.csswg.org/css-variables/ //! [custom]: https://drafts.csswg.org/css-variables/
use crate::hash::map::Entry;
use crate::properties::{CSSWideKeyword, CustomDeclarationValue};
use crate::selector_map::{PrecomputedHashMap, PrecomputedHashSet};
use crate::Atom;
use cssparser::{Delimiter, Parser, ParserInput, SourcePosition, Token, TokenSerializationType}; use cssparser::{Delimiter, Parser, ParserInput, SourcePosition, Token, TokenSerializationType};
use hash::map::Entry;
use precomputed_hash::PrecomputedHash; use precomputed_hash::PrecomputedHash;
use properties::{CSSWideKeyword, CustomDeclarationValue};
use selector_map::{PrecomputedHashMap, PrecomputedHashSet};
use selectors::parser::SelectorParseErrorKind; use selectors::parser::SelectorParseErrorKind;
use servo_arc::Arc; use servo_arc::Arc;
use smallvec::SmallVec; use smallvec::SmallVec;
@ -19,7 +20,6 @@ use std::cmp;
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use std::hash::Hash; use std::hash::Hash;
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
use Atom;
/// The environment from which to get `env` function values. /// The environment from which to get `env` function values.
/// ///
@ -553,7 +553,7 @@ fn parse_var_function<'i, 't>(
let name = parse_name(&name).map_err(|()| { let name = parse_name(&name).map_err(|()| {
input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone())) input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone()))
})?; })?;
if input.try(|input| input.expect_comma()).is_ok() { if input.r#try(|input| input.expect_comma()).is_ok() {
parse_fallback(input)?; parse_fallback(input)?;
} }
if let Some(refs) = references { if let Some(refs) = references {
@ -569,7 +569,7 @@ fn parse_env_function<'i, 't>(
// TODO(emilio): This should be <custom-ident> per spec, but no other // TODO(emilio): This should be <custom-ident> per spec, but no other
// browser does that, see https://github.com/w3c/csswg-drafts/issues/3262. // browser does that, see https://github.com/w3c/csswg-drafts/issues/3262.
input.expect_ident()?; input.expect_ident()?;
if input.try(|input| input.expect_comma()).is_ok() { if input.r#try(|input| input.expect_comma()).is_ok() {
parse_fallback(input)?; parse_fallback(input)?;
} }
if let Some(references) = references { if let Some(references) = references {

View file

@ -4,22 +4,22 @@
//! Per-node data used in style calculation. //! Per-node data used in style calculation.
use context::{SharedStyleContext, StackLimitChecker}; use crate::context::{SharedStyleContext, StackLimitChecker};
use dom::TElement; use crate::dom::TElement;
use invalidation::element::invalidator::InvalidationResult; use crate::invalidation::element::invalidator::InvalidationResult;
use invalidation::element::restyle_hints::RestyleHint; use crate::invalidation::element::restyle_hints::RestyleHint;
use crate::properties::ComputedValues;
use crate::rule_tree::StrongRuleNode;
use crate::selector_parser::{PseudoElement, RestyleDamage, EAGER_PSEUDO_COUNT};
use crate::shared_lock::StylesheetGuards;
use crate::style_resolver::{PrimaryStyle, ResolvedElementStyles, ResolvedStyle};
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use malloc_size_of::MallocSizeOfOps; use malloc_size_of::MallocSizeOfOps;
use properties::ComputedValues;
use rule_tree::StrongRuleNode;
use selector_parser::{PseudoElement, RestyleDamage, EAGER_PSEUDO_COUNT};
use selectors::NthIndexCache; use selectors::NthIndexCache;
use servo_arc::Arc; use servo_arc::Arc;
use shared_lock::StylesheetGuards;
use std::fmt; use std::fmt;
use std::mem; use std::mem;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use style_resolver::{PrimaryStyle, ResolvedElementStyles, ResolvedStyle};
bitflags! { bitflags! {
/// Various flags stored on ElementData. /// Various flags stored on ElementData.
@ -255,8 +255,8 @@ impl ElementData {
return InvalidationResult::empty(); return InvalidationResult::empty();
} }
use invalidation::element::invalidator::TreeStyleInvalidator; use crate::invalidation::element::invalidator::TreeStyleInvalidator;
use invalidation::element::state_and_attributes::StateAndAttrInvalidationProcessor; use crate::invalidation::element::state_and_attributes::StateAndAttrInvalidationProcessor;
debug!( debug!(
"invalidate_style_if_needed: {:?}, flags: {:?}, has_snapshot: {}, \ "invalidate_style_if_needed: {:?}, flags: {:?}, has_snapshot: {}, \

View file

@ -7,30 +7,30 @@
#![allow(unsafe_code)] #![allow(unsafe_code)]
#![deny(missing_docs)] #![deny(missing_docs)]
use applicable_declarations::ApplicableDeclarationBlock;
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use crate::applicable_declarations::ApplicableDeclarationBlock;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use context::PostAnimationTasks; use crate::context::PostAnimationTasks;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use context::UpdateAnimationsTasks; use crate::context::UpdateAnimationsTasks;
use data::ElementData; use crate::data::ElementData;
use element_state::ElementState; use crate::element_state::ElementState;
use font_metrics::FontMetricsProvider; use crate::font_metrics::FontMetricsProvider;
use media_queries::Device; use crate::media_queries::Device;
use properties::{AnimationRules, ComputedValues, PropertyDeclarationBlock}; use crate::properties::{AnimationRules, ComputedValues, PropertyDeclarationBlock};
use selector_parser::{AttrValue, Lang, PseudoElement, SelectorImpl}; use crate::selector_parser::{AttrValue, Lang, PseudoElement, SelectorImpl};
use crate::shared_lock::Locked;
use crate::stylist::CascadeData;
use crate::traversal_flags::TraversalFlags;
use crate::{Atom, LocalName, Namespace, WeakAtom};
use selectors::matching::{ElementSelectorFlags, QuirksMode, VisitedHandlingMode}; use selectors::matching::{ElementSelectorFlags, QuirksMode, VisitedHandlingMode};
use selectors::sink::Push; use selectors::sink::Push;
use selectors::Element as SelectorsElement; use selectors::Element as SelectorsElement;
use servo_arc::{Arc, ArcBorrow}; use servo_arc::{Arc, ArcBorrow};
use shared_lock::Locked;
use std::fmt; use std::fmt;
use std::fmt::Debug; use std::fmt::Debug;
use std::hash::Hash; use std::hash::Hash;
use std::ops::Deref; use std::ops::Deref;
use stylist::CascadeData;
use traversal_flags::TraversalFlags;
use {Atom, LocalName, Namespace, WeakAtom};
/// An opaque handle to a node, which, unlike UnsafeNode, cannot be transformed /// An opaque handle to a node, which, unlike UnsafeNode, cannot be transformed
/// back into a non-opaque representation. The only safe operation that can be /// back into a non-opaque representation. The only safe operation that can be

View file

@ -5,17 +5,17 @@
//! Generic implementations of some DOM APIs so they can be shared between Servo //! Generic implementations of some DOM APIs so they can be shared between Servo
//! and Gecko. //! and Gecko.
use context::QuirksMode; use crate::context::QuirksMode;
use dom::{TDocument, TElement, TNode, TShadowRoot}; use crate::dom::{TDocument, TElement, TNode, TShadowRoot};
use invalidation::element::invalidator::{DescendantInvalidationLists, Invalidation}; use crate::invalidation::element::invalidator::{DescendantInvalidationLists, Invalidation};
use invalidation::element::invalidator::{InvalidationProcessor, InvalidationVector}; use crate::invalidation::element::invalidator::{InvalidationProcessor, InvalidationVector};
use crate::Atom;
use selectors::attr::CaseSensitivity; use selectors::attr::CaseSensitivity;
use selectors::matching::{self, MatchingContext, MatchingMode}; use selectors::matching::{self, MatchingContext, MatchingMode};
use selectors::parser::{Combinator, Component, LocalName, SelectorImpl}; use selectors::parser::{Combinator, Component, LocalName, SelectorImpl};
use selectors::{Element, NthIndexCache, SelectorList}; use selectors::{Element, NthIndexCache, SelectorList};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::borrow::Borrow; use std::borrow::Borrow;
use Atom;
/// <https://dom.spec.whatwg.org/#dom-element-matches> /// <https://dom.spec.whatwg.org/#dom-element-matches>
pub fn element_matches<E>( pub fn element_matches<E>(
@ -594,7 +594,7 @@ pub fn query_selector<E, Q>(
E: TElement, E: TElement,
Q: SelectorQuery<E>, Q: SelectorQuery<E>,
{ {
use invalidation::element::invalidator::TreeStyleInvalidator; use crate::invalidation::element::invalidator::TreeStyleInvalidator;
let quirks_mode = root.owner_doc().quirks_mode(); let quirks_mode = root.owner_doc().quirks_mode();

View file

@ -7,17 +7,17 @@
#![deny(missing_docs)] #![deny(missing_docs)]
use context::{PerThreadTraversalStatistics, StyleContext}; use crate::context::{PerThreadTraversalStatistics, StyleContext};
use context::{ThreadLocalStyleContext, TraversalStatistics}; use crate::context::{ThreadLocalStyleContext, TraversalStatistics};
use dom::{SendNode, TElement, TNode}; use crate::dom::{SendNode, TElement, TNode};
use parallel; use crate::parallel;
use parallel::{DispatchMode, WORK_UNIT_MAX}; use crate::parallel::{DispatchMode, WORK_UNIT_MAX};
use crate::scoped_tls::ScopedTLS;
use crate::traversal::{DomTraversal, PerLevelTraversalData, PreTraverseToken};
use rayon; use rayon;
use scoped_tls::ScopedTLS;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::mem; use std::mem;
use time; use time;
use traversal::{DomTraversal, PerLevelTraversalData, PreTraverseToken};
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
fn should_report_statistics() -> bool { fn should_report_statistics() -> bool {
@ -26,7 +26,7 @@ fn should_report_statistics() -> bool {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
fn should_report_statistics() -> bool { fn should_report_statistics() -> bool {
unsafe { ::gecko_bindings::structs::ServoTraversalStatistics_sActive } unsafe { crate::gecko_bindings::structs::ServoTraversalStatistics_sActive }
} }
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
@ -38,9 +38,9 @@ fn report_statistics(_stats: &PerThreadTraversalStatistics) {
fn report_statistics(stats: &PerThreadTraversalStatistics) { fn report_statistics(stats: &PerThreadTraversalStatistics) {
// This should only be called in the main thread, or it may be racy // This should only be called in the main thread, or it may be racy
// to update the statistics in a global variable. // to update the statistics in a global variable.
debug_assert!(unsafe { ::gecko_bindings::bindings::Gecko_IsMainThread() }); debug_assert!(unsafe { crate::gecko_bindings::bindings::Gecko_IsMainThread() });
let gecko_stats = let gecko_stats =
unsafe { &mut ::gecko_bindings::structs::ServoTraversalStatistics_sSingleton }; unsafe { &mut crate::gecko_bindings::structs::ServoTraversalStatistics_sSingleton };
gecko_stats.mElementsTraversed += stats.elements_traversed; gecko_stats.mElementsTraversed += stats.elements_traversed;
gecko_stats.mElementsStyled += stats.elements_styled; gecko_stats.mElementsStyled += stats.elements_styled;
gecko_stats.mElementsMatched += stats.elements_matched; gecko_stats.mElementsMatched += stats.elements_matched;

View file

@ -6,15 +6,15 @@
extern crate encoding_rs; extern crate encoding_rs;
use context::QuirksMode; use crate::context::QuirksMode;
use crate::error_reporting::ParseErrorReporter;
use crate::media_queries::MediaList;
use crate::shared_lock::SharedRwLock;
use crate::stylesheets::{Origin, Stylesheet, StylesheetLoader, UrlExtraData};
use cssparser::{stylesheet_encoding, EncodingSupport}; use cssparser::{stylesheet_encoding, EncodingSupport};
use error_reporting::ParseErrorReporter;
use media_queries::MediaList;
use servo_arc::Arc; use servo_arc::Arc;
use shared_lock::SharedRwLock;
use std::borrow::Cow; use std::borrow::Cow;
use std::str; use std::str;
use stylesheets::{Origin, Stylesheet, StylesheetLoader, UrlExtraData};
struct EncodingRs; struct EncodingRs;

View file

@ -6,10 +6,10 @@
#![deny(missing_docs)] #![deny(missing_docs)]
use crate::stylesheets::UrlExtraData;
use cssparser::{BasicParseErrorKind, ParseErrorKind, SourceLocation, Token}; use cssparser::{BasicParseErrorKind, ParseErrorKind, SourceLocation, Token};
use std::fmt; use std::fmt;
use style_traits::ParseError; use style_traits::ParseError;
use stylesheets::UrlExtraData;
/// Errors that can be encountered while parsing CSS. /// Errors that can be encountered while parsing CSS.
#[derive(Debug)] #[derive(Debug)]

View file

@ -6,29 +6,31 @@
//! //!
//! [ff]: https://drafts.csswg.org/css-fonts/#at-font-face-rule //! [ff]: https://drafts.csswg.org/css-fonts/#at-font-face-rule
use crate::error_reporting::ContextualParseError;
use crate::parser::{Parse, ParserContext};
#[cfg(feature = "gecko")]
use crate::properties::longhands::font_language_override;
use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
use crate::str::CssStringWriter;
use crate::values::computed::font::FamilyName;
use crate::values::generics::font::FontStyle as GenericFontStyle;
use crate::values::specified::font::SpecifiedFontStyle;
use crate::values::specified::font::{AbsoluteFontWeight, FontStretch};
#[cfg(feature = "gecko")]
use crate::values::specified::font::{
SpecifiedFontFeatureSettings, SpecifiedFontVariationSettings,
};
use crate::values::specified::url::SpecifiedUrl;
use crate::values::specified::Angle;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use cssparser::UnicodeRange; use cssparser::UnicodeRange;
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser}; use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser};
use cssparser::{CowRcStr, SourceLocation}; use cssparser::{CowRcStr, SourceLocation};
use error_reporting::ContextualParseError;
use parser::{Parse, ParserContext};
#[cfg(feature = "gecko")]
use properties::longhands::font_language_override;
use selectors::parser::SelectorParseErrorKind; use selectors::parser::SelectorParseErrorKind;
use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use str::CssStringWriter;
use style_traits::values::SequenceWriter; use style_traits::values::SequenceWriter;
use style_traits::{Comma, CssWriter, OneOrMoreSeparated, ParseError}; use style_traits::{Comma, CssWriter, OneOrMoreSeparated, ParseError};
use style_traits::{StyleParseErrorKind, ToCss}; use style_traits::{StyleParseErrorKind, ToCss};
use values::computed::font::FamilyName;
use values::generics::font::FontStyle as GenericFontStyle;
use values::specified::font::SpecifiedFontStyle;
use values::specified::font::{AbsoluteFontWeight, FontStretch};
#[cfg(feature = "gecko")]
use values::specified::font::{SpecifiedFontFeatureSettings, SpecifiedFontVariationSettings};
use values::specified::url::SpecifiedUrl;
use values::specified::Angle;
/// A source for a font-face rule. /// A source for a font-face rule.
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
@ -53,8 +55,8 @@ impl OneOrMoreSeparated for Source {
#[repr(u8)] #[repr(u8)]
#[allow(missing_docs)] #[allow(missing_docs)]
pub enum FontFaceSourceListComponent { pub enum FontFaceSourceListComponent {
Url(*const ::gecko_bindings::structs::mozilla::css::URLValue), Url(*const crate::gecko_bindings::structs::mozilla::css::URLValue),
Local(*mut ::gecko_bindings::structs::nsAtom), Local(*mut crate::gecko_bindings::structs::nsAtom),
FormatHint { FormatHint {
length: usize, length: usize,
utf8_bytes: *const u8, utf8_bytes: *const u8,
@ -118,7 +120,7 @@ macro_rules! impl_range {
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
let first = $component::parse(context, input)?; let first = $component::parse(context, input)?;
let second = input let second = input
.try(|input| $component::parse(context, input)) .r#try(|input| $component::parse(context, input))
.unwrap_or_else(|_| first.clone()); .unwrap_or_else(|_| first.clone());
Ok($range(first, second)) Ok($range(first, second))
} }
@ -232,7 +234,7 @@ impl Parse for FontStyle {
GenericFontStyle::Italic => FontStyle::Italic, GenericFontStyle::Italic => FontStyle::Italic,
GenericFontStyle::Oblique(angle) => { GenericFontStyle::Oblique(angle) => {
let second_angle = input let second_angle = input
.try(|input| SpecifiedFontStyle::parse_angle(context, input)) .r#try(|input| SpecifiedFontStyle::parse_angle(context, input))
.unwrap_or_else(|_| angle.clone()); .unwrap_or_else(|_| angle.clone());
FontStyle::Oblique(angle, second_angle) FontStyle::Oblique(angle, second_angle)
@ -378,7 +380,7 @@ impl Parse for Source {
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Source, ParseError<'i>> { ) -> Result<Source, ParseError<'i>> {
if input if input
.try(|input| input.expect_function_matching("local")) .r#try(|input| input.expect_function_matching("local"))
.is_ok() .is_ok()
{ {
return input return input
@ -390,7 +392,7 @@ impl Parse for Source {
// Parsing optional format() // Parsing optional format()
let format_hints = if input let format_hints = if input
.try(|input| input.expect_function_matching("format")) .r#try(|input| input.expect_function_matching("format"))
.is_ok() .is_ok()
{ {
input.parse_nested_block(|input| { input.parse_nested_block(|input| {
@ -410,13 +412,13 @@ impl Parse for Source {
macro_rules! is_descriptor_enabled { macro_rules! is_descriptor_enabled {
("font-display") => { ("font-display") => {
unsafe { unsafe {
use gecko_bindings::structs::mozilla; use crate::gecko_bindings::structs::mozilla;
mozilla::StaticPrefs_sVarCache_layout_css_font_display_enabled mozilla::StaticPrefs_sVarCache_layout_css_font_display_enabled
} }
}; };
("font-variation-settings") => { ("font-variation-settings") => {
unsafe { unsafe {
use gecko_bindings::structs::mozilla; use crate::gecko_bindings::structs::mozilla;
mozilla::StaticPrefs_sVarCache_layout_css_font_variations_enabled != 0 mozilla::StaticPrefs_sVarCache_layout_css_font_variations_enabled != 0
} }
}; };

View file

@ -7,11 +7,11 @@
#![deny(missing_docs)] #![deny(missing_docs)]
use app_units::Au; use app_units::Au;
use context::SharedStyleContext; use crate::context::SharedStyleContext;
use logical_geometry::WritingMode; use crate::logical_geometry::WritingMode;
use media_queries::Device; use crate::media_queries::Device;
use properties::style_structs::Font; use crate::properties::style_structs::Font;
use Atom; use crate::Atom;
/// Represents the font metrics that style needs from a font to compute the /// Represents the font metrics that style needs from a font to compute the
/// value of certain CSS units like `ex`. /// value of certain CSS units like `ex`.
@ -86,8 +86,8 @@ impl FontMetricsProvider for ServoMetricsProvider {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
/// Construct a font metrics provider for the current product /// Construct a font metrics provider for the current product
pub fn get_metrics_provider_for_product() -> ::gecko::wrapper::GeckoFontMetricsProvider { pub fn get_metrics_provider_for_product() -> crate::gecko::wrapper::GeckoFontMetricsProvider {
::gecko::wrapper::GeckoFontMetricsProvider::new() crate::gecko::wrapper::GeckoFontMetricsProvider::new()
} }
#[cfg(feature = "servo")] #[cfg(feature = "servo")]

View file

@ -8,40 +8,42 @@
#![allow(non_snake_case, missing_docs)] #![allow(non_snake_case, missing_docs)]
use gecko::url::CssUrlData; use crate::gecko::url::CssUrlData;
use gecko_bindings::bindings::RawServoCounterStyleRule; use crate::gecko_bindings::bindings::RawServoCounterStyleRule;
use gecko_bindings::bindings::RawServoFontFeatureValuesRule; use crate::gecko_bindings::bindings::RawServoFontFeatureValuesRule;
use gecko_bindings::bindings::RawServoImportRule; use crate::gecko_bindings::bindings::RawServoImportRule;
use gecko_bindings::bindings::RawServoKeyframe; use crate::gecko_bindings::bindings::RawServoKeyframe;
use gecko_bindings::bindings::RawServoKeyframesRule; use crate::gecko_bindings::bindings::RawServoKeyframesRule;
use gecko_bindings::bindings::RawServoMediaRule; use crate::gecko_bindings::bindings::RawServoMediaRule;
use gecko_bindings::bindings::RawServoMozDocumentRule; use crate::gecko_bindings::bindings::RawServoMozDocumentRule;
use gecko_bindings::bindings::RawServoNamespaceRule; use crate::gecko_bindings::bindings::RawServoNamespaceRule;
use gecko_bindings::bindings::RawServoPageRule; use crate::gecko_bindings::bindings::RawServoPageRule;
use gecko_bindings::bindings::RawServoRuleNode; use crate::gecko_bindings::bindings::RawServoRuleNode;
use gecko_bindings::bindings::RawServoRuleNodeStrong; use crate::gecko_bindings::bindings::RawServoRuleNodeStrong;
use gecko_bindings::bindings::RawServoSupportsRule; use crate::gecko_bindings::bindings::RawServoSupportsRule;
use gecko_bindings::bindings::ServoCssRules; use crate::gecko_bindings::bindings::ServoCssRules;
use gecko_bindings::structs::RawServoAnimationValue; use crate::gecko_bindings::structs::RawServoAnimationValue;
use gecko_bindings::structs::RawServoCssUrlData; use crate::gecko_bindings::structs::RawServoCssUrlData;
use gecko_bindings::structs::RawServoDeclarationBlock; use crate::gecko_bindings::structs::RawServoDeclarationBlock;
use gecko_bindings::structs::RawServoFontFaceRule; use crate::gecko_bindings::structs::RawServoFontFaceRule;
use gecko_bindings::structs::RawServoMediaList; use crate::gecko_bindings::structs::RawServoMediaList;
use gecko_bindings::structs::RawServoQuotes; use crate::gecko_bindings::structs::RawServoQuotes;
use gecko_bindings::structs::RawServoStyleRule; use crate::gecko_bindings::structs::RawServoStyleRule;
use gecko_bindings::structs::RawServoStyleSheetContents; use crate::gecko_bindings::structs::RawServoStyleSheetContents;
use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong}; use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong};
use media_queries::MediaList; use crate::media_queries::MediaList;
use properties::animated_properties::AnimationValue; use crate::properties::animated_properties::AnimationValue;
use properties::{ComputedValues, PropertyDeclarationBlock}; use crate::properties::{ComputedValues, PropertyDeclarationBlock};
use rule_tree::StrongRuleNode; use crate::rule_tree::StrongRuleNode;
use crate::shared_lock::Locked;
use crate::stylesheets::keyframes_rule::Keyframe;
use crate::stylesheets::{CounterStyleRule, CssRules, FontFaceRule, FontFeatureValuesRule};
use crate::stylesheets::{
DocumentRule, ImportRule, KeyframesRule, MediaRule, NamespaceRule, PageRule,
};
use crate::stylesheets::{StyleRule, StylesheetContents, SupportsRule};
use servo_arc::{Arc, ArcBorrow}; use servo_arc::{Arc, ArcBorrow};
use shared_lock::Locked;
use std::{mem, ptr}; use std::{mem, ptr};
use stylesheets::keyframes_rule::Keyframe;
use stylesheets::{CounterStyleRule, CssRules, FontFaceRule, FontFeatureValuesRule};
use stylesheets::{DocumentRule, ImportRule, KeyframesRule, MediaRule, NamespaceRule, PageRule};
use stylesheets::{StyleRule, StylesheetContents, SupportsRule};
use values::computed::QuotePair; use values::computed::QuotePair;
macro_rules! impl_arc_ffi { macro_rules! impl_arc_ffi {

View file

@ -9,24 +9,24 @@
#![allow(unsafe_code)] #![allow(unsafe_code)]
use app_units::Au; use app_units::Au;
use gecko::values::GeckoStyleCoordConvertible; use crate::gecko::values::GeckoStyleCoordConvertible;
use gecko_bindings::bindings; use crate::gecko_bindings::bindings;
use gecko_bindings::structs::{self, nsStyleCoord_CalcValue}; use crate::gecko_bindings::structs::{self, nsStyleCoord_CalcValue};
use gecko_bindings::structs::{nsStyleImage, nsresult, SheetType}; use crate::gecko_bindings::structs::{nsStyleImage, nsresult, SheetType};
use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue}; use crate::gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
use std::f32::consts::PI; use crate::stylesheets::{Origin, RulesMutateError};
use stylesheets::{Origin, RulesMutateError}; use crate::values::computed::image::LineDirection;
use values::computed::image::LineDirection; use crate::values::computed::url::ComputedImageUrl;
use values::computed::url::ComputedImageUrl; use crate::values::computed::{Angle, CalcLengthOrPercentage, Gradient, Image};
use values::computed::{Angle, CalcLengthOrPercentage, Gradient, Image}; use crate::values::computed::{
use values::computed::{
Integer, LengthOrPercentage, LengthOrPercentageOrAuto, NonNegativeLengthOrPercentageOrAuto, Integer, LengthOrPercentage, LengthOrPercentageOrAuto, NonNegativeLengthOrPercentageOrAuto,
}; };
use values::computed::{Percentage, TextAlign}; use crate::values::computed::{Percentage, TextAlign};
use values::generics::box_::VerticalAlign; use crate::values::generics::box_::VerticalAlign;
use values::generics::grid::{TrackListValue, TrackSize}; use crate::values::generics::grid::{TrackListValue, TrackSize};
use values::generics::image::{CompatMode, GradientItem, Image as GenericImage}; use crate::values::generics::image::{CompatMode, GradientItem, Image as GenericImage};
use values::generics::rect::Rect; use crate::values::generics::rect::Rect;
use std::f32::consts::PI;
impl From<CalcLengthOrPercentage> for nsStyleCoord_CalcValue { impl From<CalcLengthOrPercentage> for nsStyleCoord_CalcValue {
fn from(other: CalcLengthOrPercentage) -> nsStyleCoord_CalcValue { fn from(other: CalcLengthOrPercentage) -> nsStyleCoord_CalcValue {
@ -112,8 +112,8 @@ impl From<nsStyleCoord_CalcValue> for LengthOrPercentageOrAuto {
// disappear as we move more stuff to cbindgen. // disappear as we move more stuff to cbindgen.
impl From<nsStyleCoord_CalcValue> for NonNegativeLengthOrPercentageOrAuto { impl From<nsStyleCoord_CalcValue> for NonNegativeLengthOrPercentageOrAuto {
fn from(other: nsStyleCoord_CalcValue) -> Self { fn from(other: nsStyleCoord_CalcValue) -> Self {
use crate::values::generics::NonNegative;
use style_traits::values::specified::AllowedNumericType; use style_traits::values::specified::AllowedNumericType;
use values::generics::NonNegative;
NonNegative(if other.mLength < 0 || other.mPercent < 0. { NonNegative(if other.mLength < 0 || other.mPercent < 0. {
LengthOrPercentageOrAuto::Calc(CalcLengthOrPercentage::with_clamping_mode( LengthOrPercentageOrAuto::Calc(CalcLengthOrPercentage::with_clamping_mode(
Au(other.mLength).into(), Au(other.mLength).into(),
@ -137,8 +137,8 @@ impl From<Angle> for CoordDataValue {
} }
fn line_direction(horizontal: LengthOrPercentage, vertical: LengthOrPercentage) -> LineDirection { fn line_direction(horizontal: LengthOrPercentage, vertical: LengthOrPercentage) -> LineDirection {
use values::computed::position::Position; use crate::values::computed::position::Position;
use values::specified::position::{X, Y}; use crate::values::specified::position::{X, Y};
let horizontal_percentage = match horizontal { let horizontal_percentage = match horizontal {
LengthOrPercentage::Percentage(percentage) => Some(percentage.0), LengthOrPercentage::Percentage(percentage) => Some(percentage.0),
@ -240,8 +240,10 @@ impl nsStyleImage {
use self::structs::NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE as CLOSEST_SIDE; use self::structs::NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE as CLOSEST_SIDE;
use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER as FARTHEST_CORNER; use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER as FARTHEST_CORNER;
use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_SIDE as FARTHEST_SIDE; use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_SIDE as FARTHEST_SIDE;
use values::generics::image::{Circle, Ellipse, EndingShape, GradientKind, ShapeExtent}; use crate::values::generics::image::{
use values::specified::position::{X, Y}; Circle, Ellipse, EndingShape, GradientKind, ShapeExtent,
};
use crate::values::specified::position::{X, Y};
let stop_count = gradient.items.len(); let stop_count = gradient.items.len();
if stop_count >= ::std::u32::MAX as usize { if stop_count >= ::std::u32::MAX as usize {
@ -437,8 +439,8 @@ impl nsStyleImage {
/// Converts into Image. /// Converts into Image.
pub unsafe fn into_image(self: &nsStyleImage) -> Option<Image> { pub unsafe fn into_image(self: &nsStyleImage) -> Option<Image> {
use gecko_bindings::structs::nsStyleImageType; use crate::gecko_bindings::structs::nsStyleImageType;
use values::computed::{MozImageRect, NumberOrPercentage}; use crate::values::computed::{MozImageRect, NumberOrPercentage};
match self.mType { match self.mType {
nsStyleImageType::eStyleImageType_Null => None, nsStyleImageType::eStyleImageType_Null => None,
@ -477,7 +479,7 @@ impl nsStyleImage {
Some(GenericImage::Gradient(self.get_gradient())) Some(GenericImage::Gradient(self.get_gradient()))
}, },
nsStyleImageType::eStyleImageType_Element => { nsStyleImageType::eStyleImageType_Element => {
use gecko_string_cache::Atom; use crate::gecko_string_cache::Atom;
let atom = bindings::Gecko_GetImageElement(self); let atom = bindings::Gecko_GetImageElement(self);
Some(GenericImage::Element(Atom::from_raw(atom))) Some(GenericImage::Element(Atom::from_raw(atom)))
}, },
@ -497,11 +499,11 @@ impl nsStyleImage {
use self::structs::NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE as CLOSEST_SIDE; use self::structs::NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE as CLOSEST_SIDE;
use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER as FARTHEST_CORNER; use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER as FARTHEST_CORNER;
use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_SIDE as FARTHEST_SIDE; use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_SIDE as FARTHEST_SIDE;
use values::computed::image::LineDirection; use crate::values::computed::image::LineDirection;
use values::computed::position::Position; use crate::values::computed::position::Position;
use values::computed::Length; use crate::values::computed::Length;
use values::generics::image::{Circle, ColorStop, CompatMode, Ellipse}; use crate::values::generics::image::{Circle, ColorStop, CompatMode, Ellipse};
use values::generics::image::{EndingShape, GradientKind, ShapeExtent}; use crate::values::generics::image::{EndingShape, GradientKind, ShapeExtent};
let gecko_gradient = bindings::Gecko_GetGradientImageValue(self) let gecko_gradient = bindings::Gecko_GetGradientImageValue(self)
.as_ref() .as_ref()
@ -652,26 +654,32 @@ impl nsStyleImage {
pub mod basic_shape { pub mod basic_shape {
//! Conversions from and to CSS shape representations. //! Conversions from and to CSS shape representations.
use gecko::values::GeckoStyleCoordConvertible; use crate::gecko::values::GeckoStyleCoordConvertible;
use gecko_bindings::structs; use crate::gecko_bindings::structs;
use gecko_bindings::structs::{nsStyleCoord, nsStyleCorners}; use crate::gecko_bindings::structs::{nsStyleCoord, nsStyleCorners};
use gecko_bindings::structs::{StyleBasicShape, StyleBasicShapeType}; use crate::gecko_bindings::structs::{StyleBasicShape, StyleBasicShapeType};
use gecko_bindings::structs::{StyleGeometryBox, StyleShapeSource, StyleShapeSourceType}; use crate::gecko_bindings::structs::{
use gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue}; StyleGeometryBox, StyleShapeSource, StyleShapeSourceType,
use gecko_bindings::sugar::refptr::RefPtr; };
use crate::gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue};
use crate::gecko_bindings::sugar::refptr::RefPtr;
use crate::values::computed::basic_shape::{
BasicShape, ClippingShape, FloatAreaShape, ShapeRadius,
};
use crate::values::computed::border::{BorderCornerRadius, BorderRadius};
use crate::values::computed::length::LengthOrPercentage;
use crate::values::computed::motion::OffsetPath;
use crate::values::computed::position;
use crate::values::computed::url::ComputedUrl;
use crate::values::generics::basic_shape::{
BasicShape as GenericBasicShape, InsetRect, Polygon,
};
use crate::values::generics::basic_shape::{Circle, Ellipse, Path, PolygonCoord};
use crate::values::generics::basic_shape::{GeometryBox, ShapeBox, ShapeSource};
use crate::values::generics::border::BorderRadius as GenericBorderRadius;
use crate::values::generics::rect::Rect;
use crate::values::specified::SVGPathData;
use std::borrow::Borrow; use std::borrow::Borrow;
use values::computed::basic_shape::{BasicShape, ClippingShape, FloatAreaShape, ShapeRadius};
use values::computed::border::{BorderCornerRadius, BorderRadius};
use values::computed::length::LengthOrPercentage;
use values::computed::motion::OffsetPath;
use values::computed::position;
use values::computed::url::ComputedUrl;
use values::generics::basic_shape::{BasicShape as GenericBasicShape, InsetRect, Polygon};
use values::generics::basic_shape::{Circle, Ellipse, Path, PolygonCoord};
use values::generics::basic_shape::{GeometryBox, ShapeBox, ShapeSource};
use values::generics::border::BorderRadius as GenericBorderRadius;
use values::generics::rect::Rect;
use values::specified::SVGPathData;
impl StyleShapeSource { impl StyleShapeSource {
/// Convert StyleShapeSource to ShapeSource except URL and Image /// Convert StyleShapeSource to ShapeSource except URL and Image
@ -706,7 +714,7 @@ pub mod basic_shape {
/// Generate a SVGPathData from StyleShapeSource if possible. /// Generate a SVGPathData from StyleShapeSource if possible.
fn to_svg_path(&self) -> Option<SVGPathData> { fn to_svg_path(&self) -> Option<SVGPathData> {
use values::specified::svg_path::PathCommand; use crate::values::specified::svg_path::PathCommand;
match self.mType { match self.mType {
StyleShapeSourceType::Path => { StyleShapeSourceType::Path => {
let gecko_path = unsafe { &*self.__bindgen_anon_1.mSVGPath.as_ref().mPtr }; let gecko_path = unsafe { &*self.__bindgen_anon_1.mSVGPath.as_ref().mPtr };
@ -908,7 +916,7 @@ pub mod basic_shape {
impl From<ShapeBox> for StyleGeometryBox { impl From<ShapeBox> for StyleGeometryBox {
fn from(reference: ShapeBox) -> Self { fn from(reference: ShapeBox) -> Self {
use gecko_bindings::structs::StyleGeometryBox::*; use crate::gecko_bindings::structs::StyleGeometryBox::*;
match reference { match reference {
ShapeBox::ContentBox => ContentBox, ShapeBox::ContentBox => ContentBox,
ShapeBox::PaddingBox => PaddingBox, ShapeBox::PaddingBox => PaddingBox,
@ -920,7 +928,7 @@ pub mod basic_shape {
impl From<GeometryBox> for StyleGeometryBox { impl From<GeometryBox> for StyleGeometryBox {
fn from(reference: GeometryBox) -> Self { fn from(reference: GeometryBox) -> Self {
use gecko_bindings::structs::StyleGeometryBox::*; use crate::gecko_bindings::structs::StyleGeometryBox::*;
match reference { match reference {
GeometryBox::ShapeBox(shape_box) => From::from(shape_box), GeometryBox::ShapeBox(shape_box) => From::from(shape_box),
GeometryBox::FillBox => FillBox, GeometryBox::FillBox => FillBox,
@ -935,7 +943,7 @@ pub mod basic_shape {
// but coherence doesn't like that and TryFrom isn't stable // but coherence doesn't like that and TryFrom isn't stable
impl From<StyleGeometryBox> for GeometryBox { impl From<StyleGeometryBox> for GeometryBox {
fn from(reference: StyleGeometryBox) -> Self { fn from(reference: StyleGeometryBox) -> Self {
use gecko_bindings::structs::StyleGeometryBox::*; use crate::gecko_bindings::structs::StyleGeometryBox::*;
match reference { match reference {
ContentBox => GeometryBox::ShapeBox(ShapeBox::ContentBox), ContentBox => GeometryBox::ShapeBox(ShapeBox::ContentBox),
PaddingBox => GeometryBox::ShapeBox(ShapeBox::PaddingBox), PaddingBox => GeometryBox::ShapeBox(ShapeBox::PaddingBox),
@ -951,7 +959,7 @@ pub mod basic_shape {
impl From<StyleGeometryBox> for ShapeBox { impl From<StyleGeometryBox> for ShapeBox {
fn from(reference: StyleGeometryBox) -> Self { fn from(reference: StyleGeometryBox) -> Self {
use gecko_bindings::structs::StyleGeometryBox::*; use crate::gecko_bindings::structs::StyleGeometryBox::*;
match reference { match reference {
ContentBox => ShapeBox::ContentBox, ContentBox => ShapeBox::ContentBox,
PaddingBox => ShapeBox::PaddingBox, PaddingBox => ShapeBox::PaddingBox,
@ -987,9 +995,9 @@ impl From<Origin> for SheetType {
impl TrackSize<LengthOrPercentage> { impl TrackSize<LengthOrPercentage> {
/// Return TrackSize from given two nsStyleCoord /// Return TrackSize from given two nsStyleCoord
pub fn from_gecko_style_coords<T: CoordData>(gecko_min: &T, gecko_max: &T) -> Self { pub fn from_gecko_style_coords<T: CoordData>(gecko_min: &T, gecko_max: &T) -> Self {
use gecko_bindings::structs::root::nsStyleUnit; use crate::gecko_bindings::structs::root::nsStyleUnit;
use values::computed::length::LengthOrPercentage; use crate::values::computed::length::LengthOrPercentage;
use values::generics::grid::{TrackBreadth, TrackSize}; use crate::values::generics::grid::{TrackBreadth, TrackSize};
if gecko_min.unit() == nsStyleUnit::eStyleUnit_None { if gecko_min.unit() == nsStyleUnit::eStyleUnit_None {
debug_assert!( debug_assert!(
@ -1016,7 +1024,7 @@ impl TrackSize<LengthOrPercentage> {
/// Save TrackSize to given gecko fields. /// Save TrackSize to given gecko fields.
pub fn to_gecko_style_coords<T: CoordDataMut>(&self, gecko_min: &mut T, gecko_max: &mut T) { pub fn to_gecko_style_coords<T: CoordDataMut>(&self, gecko_min: &mut T, gecko_max: &mut T) {
use values::generics::grid::TrackSize; use crate::values::generics::grid::TrackSize;
match *self { match *self {
TrackSize::FitContent(ref lop) => { TrackSize::FitContent(ref lop) => {
@ -1047,7 +1055,7 @@ impl TrackListValue<LengthOrPercentage, Integer> {
/// Save TrackSize to given gecko fields. /// Save TrackSize to given gecko fields.
pub fn to_gecko_style_coords<T: CoordDataMut>(&self, gecko_min: &mut T, gecko_max: &mut T) { pub fn to_gecko_style_coords<T: CoordDataMut>(&self, gecko_min: &mut T, gecko_max: &mut T) {
use values::generics::grid::TrackListValue; use crate::values::generics::grid::TrackListValue;
match *self { match *self {
TrackListValue::TrackSize(ref size) => size.to_gecko_style_coords(gecko_min, gecko_max), TrackListValue::TrackSize(ref size) => size.to_gecko_style_coords(gecko_min, gecko_max),
@ -1061,7 +1069,7 @@ where
T: GeckoStyleCoordConvertible, T: GeckoStyleCoordConvertible,
{ {
/// Convert this generic Rect to given Gecko fields. /// Convert this generic Rect to given Gecko fields.
pub fn to_gecko_rect(&self, sides: &mut ::gecko_bindings::structs::nsStyleSides) { pub fn to_gecko_rect(&self, sides: &mut crate::gecko_bindings::structs::nsStyleSides) {
self.0.to_gecko_style_coord(&mut sides.data_at_mut(0)); self.0.to_gecko_style_coord(&mut sides.data_at_mut(0));
self.1.to_gecko_style_coord(&mut sides.data_at_mut(1)); self.1.to_gecko_style_coord(&mut sides.data_at_mut(1));
self.2.to_gecko_style_coord(&mut sides.data_at_mut(2)); self.2.to_gecko_style_coord(&mut sides.data_at_mut(2));
@ -1070,9 +1078,9 @@ where
/// Convert from given Gecko data to generic Rect. /// Convert from given Gecko data to generic Rect.
pub fn from_gecko_rect( pub fn from_gecko_rect(
sides: &::gecko_bindings::structs::nsStyleSides, sides: &crate::gecko_bindings::structs::nsStyleSides,
) -> Option<::values::generics::rect::Rect<T>> { ) -> Option<crate::values::generics::rect::Rect<T>> {
use values::generics::rect::Rect; use crate::values::generics::rect::Rect;
Some(Rect::new( Some(Rect::new(
T::from_gecko_style_coord(&sides.data_at(0)).expect("coord[0] cound not convert"), T::from_gecko_style_coord(&sides.data_at(0)).expect("coord[0] cound not convert"),

View file

@ -5,23 +5,23 @@
//! Data needed to style a Gecko document. //! Data needed to style a Gecko document.
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use context::QuirksMode; use crate::context::QuirksMode;
use dom::TElement; use crate::dom::TElement;
use gecko_bindings::bindings::{self, RawServoStyleSet}; use crate::gecko_bindings::bindings::{self, RawServoStyleSet};
use gecko_bindings::structs::StyleSheet as DomStyleSheet; use crate::gecko_bindings::structs::StyleSheet as DomStyleSheet;
use gecko_bindings::structs::{nsIDocument, StyleSheetInfo}; use crate::gecko_bindings::structs::{nsIDocument, StyleSheetInfo};
use gecko_bindings::structs::{RawGeckoPresContextBorrowed, ServoStyleSetSizes}; use crate::gecko_bindings::structs::{RawGeckoPresContextBorrowed, ServoStyleSetSizes};
use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI}; use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI};
use invalidation::media_queries::{MediaListKey, ToMediaListKey}; use crate::invalidation::media_queries::{MediaListKey, ToMediaListKey};
use crate::media_queries::{Device, MediaList};
use crate::properties::ComputedValues;
use crate::selector_parser::SnapshotMap;
use crate::shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
use crate::stylesheets::{CssRule, Origin, StylesheetContents, StylesheetInDocument};
use crate::stylist::Stylist;
use malloc_size_of::MallocSizeOfOps; use malloc_size_of::MallocSizeOfOps;
use media_queries::{Device, MediaList};
use properties::ComputedValues;
use selector_parser::SnapshotMap;
use servo_arc::Arc; use servo_arc::Arc;
use shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
use std::fmt; use std::fmt;
use stylesheets::{CssRule, Origin, StylesheetContents, StylesheetInDocument};
use stylist::Stylist;
/// Little wrapper to a Gecko style sheet. /// Little wrapper to a Gecko style sheet.
#[derive(Eq, PartialEq)] #[derive(Eq, PartialEq)]
@ -38,7 +38,7 @@ impl fmt::Debug for GeckoStyleSheet {
} }
} }
impl ToMediaListKey for ::gecko::data::GeckoStyleSheet { impl ToMediaListKey for crate::gecko::data::GeckoStyleSheet {
fn to_media_list_key(&self) -> MediaListKey { fn to_media_list_key(&self) -> MediaListKey {
use std::mem; use std::mem;
unsafe { MediaListKey::from_raw(mem::transmute(self.0)) } unsafe { MediaListKey::from_raw(mem::transmute(self.0)) }
@ -105,7 +105,7 @@ impl StylesheetInDocument for GeckoStyleSheet {
} }
fn media<'a>(&'a self, guard: &'a SharedRwLockReadGuard) -> Option<&'a MediaList> { fn media<'a>(&'a self, guard: &'a SharedRwLockReadGuard) -> Option<&'a MediaList> {
use gecko_bindings::structs::mozilla::dom::MediaList as DomMediaList; use crate::gecko_bindings::structs::mozilla::dom::MediaList as DomMediaList;
use std::mem; use std::mem;
unsafe { unsafe {

View file

@ -4,17 +4,19 @@
//! Global style data //! Global style data
use context::StyleSystemOptions; use crate::context::StyleSystemOptions;
use gecko_bindings::bindings::Gecko_SetJemallocThreadLocalArena; use crate::gecko_bindings::bindings::Gecko_SetJemallocThreadLocalArena;
use gecko_bindings::bindings::{Gecko_RegisterProfilerThread, Gecko_UnregisterProfilerThread}; use crate::gecko_bindings::bindings::{
Gecko_RegisterProfilerThread, Gecko_UnregisterProfilerThread,
};
use crate::parallel::STYLE_THREAD_STACK_SIZE_KB;
use crate::shared_lock::SharedRwLock;
use crate::thread_state;
use num_cpus; use num_cpus;
use parallel::STYLE_THREAD_STACK_SIZE_KB;
use rayon; use rayon;
use shared_lock::SharedRwLock;
use std::cmp; use std::cmp;
use std::env; use std::env;
use std::ffi::CString; use std::ffi::CString;
use thread_state;
/// Global style data /// Global style data
pub struct GlobalStyleData { pub struct GlobalStyleData {

View file

@ -5,16 +5,16 @@
//! Gecko's media feature list and evaluator. //! Gecko's media feature list and evaluator.
use app_units::Au; use app_units::Au;
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs;
use crate::media_queries::media_feature::{AllowsRanges, ParsingRequirements};
use crate::media_queries::media_feature::{Evaluator, MediaFeatureDescription};
use crate::media_queries::media_feature_expression::{AspectRatio, RangeOrOperator};
use crate::media_queries::Device;
use crate::values::computed::CSSPixelLength;
use crate::values::computed::Resolution;
use crate::Atom;
use euclid::Size2D; use euclid::Size2D;
use gecko_bindings::bindings;
use gecko_bindings::structs;
use media_queries::media_feature::{AllowsRanges, ParsingRequirements};
use media_queries::media_feature::{Evaluator, MediaFeatureDescription};
use media_queries::media_feature_expression::{AspectRatio, RangeOrOperator};
use media_queries::Device;
use values::computed::CSSPixelLength;
use values::computed::Resolution;
use Atom;
fn viewport_size(device: &Device) -> Size2D<Au> { fn viewport_size(device: &Device) -> Size2D<Au> {
let pc = device.pres_context(); let pc = device.pres_context();

View file

@ -6,24 +6,24 @@
use app_units::Au; use app_units::Au;
use app_units::AU_PER_PX; use app_units::AU_PER_PX;
use crate::custom_properties::CssEnvironment;
use crate::gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor};
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs;
use crate::gecko_bindings::structs::{nsPresContext, RawGeckoPresContextBorrowed};
use crate::media_queries::MediaType;
use crate::properties::ComputedValues;
use crate::string_cache::Atom;
use crate::values::computed::font::FontSize;
use crate::values::{CustomIdent, KeyframesName};
use cssparser::RGBA; use cssparser::RGBA;
use custom_properties::CssEnvironment;
use euclid::Size2D; use euclid::Size2D;
use euclid::TypedScale; use euclid::TypedScale;
use gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor};
use gecko_bindings::bindings;
use gecko_bindings::structs;
use gecko_bindings::structs::{nsPresContext, RawGeckoPresContextBorrowed};
use media_queries::MediaType;
use properties::ComputedValues;
use servo_arc::Arc; use servo_arc::Arc;
use std::fmt; use std::fmt;
use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicUsize, Ordering}; use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicUsize, Ordering};
use string_cache::Atom;
use style_traits::viewport::ViewportConstraints; use style_traits::viewport::ViewportConstraints;
use style_traits::{CSSPixel, DevicePixel}; use style_traits::{CSSPixel, DevicePixel};
use values::computed::font::FontSize;
use values::{CustomIdent, KeyframesName};
/// The `Device` in Gecko wraps a pres context, has a default values computed, /// The `Device` in Gecko wraps a pres context, has a default values computed,
/// and contains all the viewport rule state. /// and contains all the viewport rule state.

View file

@ -8,16 +8,16 @@
//! `pseudo_element_definition.mako.rs`. If you touch that file, you probably //! `pseudo_element_definition.mako.rs`. If you touch that file, you probably
//! need to update the checked-in files for Servo. //! need to update the checked-in files for Servo.
use crate::gecko_bindings::structs::{self, CSSPseudoElementType};
use crate::properties::longhands::display::computed_value::T as Display;
use crate::properties::{ComputedValues, PropertyFlags};
use crate::selector_parser::{NonTSPseudoClass, PseudoElementCascadeType, SelectorImpl};
use crate::str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase};
use crate::string_cache::Atom;
use crate::values::serialize_atom_identifier;
use cssparser::ToCss; use cssparser::ToCss;
use gecko_bindings::structs::{self, CSSPseudoElementType};
use properties::longhands::display::computed_value::T as Display;
use properties::{ComputedValues, PropertyFlags};
use selector_parser::{NonTSPseudoClass, PseudoElementCascadeType, SelectorImpl};
use std::fmt; use std::fmt;
use str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase};
use string_cache::Atom;
use thin_slice::ThinBoxedSlice; use thin_slice::ThinBoxedSlice;
use values::serialize_atom_identifier;
include!(concat!( include!(concat!(
env!("OUT_DIR"), env!("OUT_DIR"),

View file

@ -156,7 +156,7 @@ impl PseudoElement {
/// Construct a `CSSPseudoElementType` from a pseudo-element /// Construct a `CSSPseudoElementType` from a pseudo-element
#[inline] #[inline]
fn pseudo_type(&self) -> CSSPseudoElementType { fn pseudo_type(&self) -> CSSPseudoElementType {
use gecko_bindings::structs::CSSPseudoElementType_InheritingAnonBox; use crate::gecko_bindings::structs::CSSPseudoElementType_InheritingAnonBox;
match *self { match *self {
% for pseudo in PSEUDOS: % for pseudo in PSEUDOS:

View file

@ -4,11 +4,11 @@
//! Gecko's restyle damage computation (aka change hints, aka `nsChangeHint`). //! Gecko's restyle damage computation (aka change hints, aka `nsChangeHint`).
use gecko_bindings::bindings; use crate::gecko_bindings::bindings;
use gecko_bindings::structs; use crate::gecko_bindings::structs;
use gecko_bindings::structs::nsChangeHint; use crate::gecko_bindings::structs::nsChangeHint;
use matching::{StyleChange, StyleDifference}; use crate::matching::{StyleChange, StyleDifference};
use properties::ComputedValues; use crate::properties::ComputedValues;
use std::ops::{BitAnd, BitOr, BitOrAssign, Not}; use std::ops::{BitAnd, BitOr, BitOrAssign, Not};
/// The representation of Gecko's restyle damage is just a wrapper over /// The representation of Gecko's restyle damage is just a wrapper over

View file

@ -4,13 +4,13 @@
//! Bindings for CSS Rule objects //! Bindings for CSS Rule objects
use counter_style::{self, CounterBound}; use crate::counter_style::{self, CounterBound};
use gecko_bindings::structs::{self, nsCSSValue}; use crate::gecko_bindings::structs::{self, nsCSSValue};
use gecko_bindings::sugar::ns_css_value::ToNsCssValue; use crate::gecko_bindings::sugar::ns_css_value::ToNsCssValue;
impl<'a> ToNsCssValue for &'a counter_style::System { impl<'a> ToNsCssValue for &'a counter_style::System {
fn convert(self, nscssvalue: &mut nsCSSValue) { fn convert(self, nscssvalue: &mut nsCSSValue) {
use counter_style::System::*; use crate::counter_style::System::*;
match *self { match *self {
Cyclic => nscssvalue.set_enum(structs::NS_STYLE_COUNTER_SYSTEM_CYCLIC as i32), Cyclic => nscssvalue.set_enum(structs::NS_STYLE_COUNTER_SYSTEM_CYCLIC as i32),
Numeric => nscssvalue.set_enum(structs::NS_STYLE_COUNTER_SYSTEM_NUMERIC as i32), Numeric => nscssvalue.set_enum(structs::NS_STYLE_COUNTER_SYSTEM_NUMERIC as i32),
@ -123,7 +123,7 @@ impl<'a> ToNsCssValue for &'a counter_style::AdditiveSymbols {
impl<'a> ToNsCssValue for &'a counter_style::SpeakAs { impl<'a> ToNsCssValue for &'a counter_style::SpeakAs {
fn convert(self, nscssvalue: &mut nsCSSValue) { fn convert(self, nscssvalue: &mut nsCSSValue) {
use counter_style::SpeakAs::*; use crate::counter_style::SpeakAs::*;
match *self { match *self {
Auto => nscssvalue.set_auto(), Auto => nscssvalue.set_auto(),
Bullets => nscssvalue.set_enum(structs::NS_STYLE_COUNTER_SPEAKAS_BULLETS as i32), Bullets => nscssvalue.set_enum(structs::NS_STYLE_COUNTER_SPEAKAS_BULLETS as i32),

View file

@ -4,27 +4,29 @@
//! Gecko-specific bits for selector-parsing. //! Gecko-specific bits for selector-parsing.
use crate::element_state::{DocumentState, ElementState};
use crate::gecko_bindings::structs;
use crate::gecko_bindings::structs::RawServoSelectorList;
use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
use crate::invalidation::element::document_state::InvalidationMatchingData;
use crate::selector_parser::{Direction, SelectorParser};
use crate::str::starts_with_ignore_ascii_case;
use crate::string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
use crate::values::serialize_atom_identifier;
use cssparser::{BasicParseError, BasicParseErrorKind, Parser}; use cssparser::{BasicParseError, BasicParseErrorKind, Parser};
use cssparser::{CowRcStr, SourceLocation, ToCss, Token}; use cssparser::{CowRcStr, SourceLocation, ToCss, Token};
use element_state::{DocumentState, ElementState};
use gecko_bindings::structs;
use gecko_bindings::structs::RawServoSelectorList;
use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
use invalidation::element::document_state::InvalidationMatchingData;
use selector_parser::{Direction, SelectorParser};
use selectors::parser::{self as selector_parser, Selector}; use selectors::parser::{self as selector_parser, Selector};
use selectors::parser::{SelectorParseErrorKind, Visit}; use selectors::parser::{SelectorParseErrorKind, Visit};
use selectors::visitor::SelectorVisitor; use selectors::visitor::SelectorVisitor;
use selectors::SelectorList; use selectors::SelectorList;
use std::fmt; use std::fmt;
use str::starts_with_ignore_ascii_case;
use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss as ToCss_}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss as ToCss_};
use thin_slice::ThinBoxedSlice; use thin_slice::ThinBoxedSlice;
use values::serialize_atom_identifier;
pub use gecko::pseudo_element::{PseudoElement, EAGER_PSEUDOS, EAGER_PSEUDO_COUNT, PSEUDO_COUNT}; pub use crate::gecko::pseudo_element::{
pub use gecko::snapshot::SnapshotMap; PseudoElement, EAGER_PSEUDOS, EAGER_PSEUDO_COUNT, PSEUDO_COUNT,
};
pub use crate::gecko::snapshot::SnapshotMap;
bitflags! { bitflags! {
// See NonTSPseudoClass::is_enabled_in() // See NonTSPseudoClass::is_enabled_in()
@ -169,7 +171,7 @@ impl NonTSPseudoClass {
/// Returns whether the pseudo-class is enabled in content sheets. /// Returns whether the pseudo-class is enabled in content sheets.
fn is_enabled_in_content(&self) -> bool { fn is_enabled_in_content(&self) -> bool {
use gecko_bindings::structs::mozilla; use crate::gecko_bindings::structs::mozilla;
match *self { match *self {
// For pseudo-classes with pref, the availability in content // For pseudo-classes with pref, the availability in content
// depends on the pref. // depends on the pref.

View file

@ -5,19 +5,19 @@
//! A gecko snapshot, that stores the element attributes and state before they //! A gecko snapshot, that stores the element attributes and state before they
//! change in order to properly calculate restyle hints. //! change in order to properly calculate restyle hints.
use dom::TElement; use crate::dom::TElement;
use element_state::ElementState; use crate::element_state::ElementState;
use gecko::snapshot_helpers; use crate::gecko::snapshot_helpers;
use gecko::wrapper::{GeckoElement, NamespaceConstraintHelpers}; use crate::gecko::wrapper::{GeckoElement, NamespaceConstraintHelpers};
use gecko_bindings::bindings; use crate::gecko_bindings::bindings;
use gecko_bindings::structs::ServoElementSnapshot; use crate::gecko_bindings::structs::ServoElementSnapshot;
use gecko_bindings::structs::ServoElementSnapshotFlags as Flags; use crate::gecko_bindings::structs::ServoElementSnapshotFlags as Flags;
use gecko_bindings::structs::ServoElementSnapshotTable; use crate::gecko_bindings::structs::ServoElementSnapshotTable;
use invalidation::element::element_wrapper::ElementSnapshot; use crate::invalidation::element::element_wrapper::ElementSnapshot;
use crate::string_cache::{Atom, Namespace};
use crate::WeakAtom;
use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator}; use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator};
use selectors::attr::{CaseSensitivity, NamespaceConstraint}; use selectors::attr::{CaseSensitivity, NamespaceConstraint};
use string_cache::{Atom, Namespace};
use WeakAtom;
/// A snapshot of a Gecko element. /// A snapshot of a Gecko element.
pub type GeckoElementSnapshot = ServoElementSnapshot; pub type GeckoElementSnapshot = ServoElementSnapshot;

View file

@ -4,11 +4,11 @@
//! Element an snapshot common logic. //! Element an snapshot common logic.
use gecko_bindings::bindings; use crate::gecko_bindings::bindings;
use gecko_bindings::structs::{self, nsAtom}; use crate::gecko_bindings::structs::{self, nsAtom};
use crate::string_cache::{Atom, WeakAtom};
use crate::CaseSensitivityExt;
use selectors::attr::CaseSensitivity; use selectors::attr::CaseSensitivity;
use string_cache::{Atom, WeakAtom};
use CaseSensitivityExt;
/// A function that, given an element of type `T`, allows you to get a single /// A function that, given an element of type `T`, allows you to get a single
/// class or a class list. /// class or a class list.

View file

@ -4,10 +4,10 @@
//! Gecko-specific bits for the styling DOM traversal. //! Gecko-specific bits for the styling DOM traversal.
use context::{SharedStyleContext, StyleContext}; use crate::context::{SharedStyleContext, StyleContext};
use dom::{TElement, TNode}; use crate::dom::{TElement, TNode};
use gecko::wrapper::{GeckoElement, GeckoNode}; use crate::gecko::wrapper::{GeckoElement, GeckoNode};
use traversal::{recalc_style_at, DomTraversal, PerLevelTraversalData}; use crate::traversal::{recalc_style_at, DomTraversal, PerLevelTraversalData};
/// This is the simple struct that Gecko uses to encapsulate a DOM traversal for /// This is the simple struct that Gecko uses to encapsulate a DOM traversal for
/// styling. /// styling.

View file

@ -4,21 +4,21 @@
//! Common handling for the specified value CSS url() values. //! Common handling for the specified value CSS url() values.
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs::root::mozilla::css::URLValue;
use crate::gecko_bindings::structs::root::mozilla::CORSMode;
use crate::gecko_bindings::structs::root::nsStyleImageRequest;
use crate::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI};
use crate::gecko_bindings::sugar::refptr::RefPtr;
use crate::parser::{Parse, ParserContext};
use crate::stylesheets::UrlExtraData;
use crate::values::computed::{Context, ToComputedValue};
use cssparser::Parser; use cssparser::Parser;
use gecko_bindings::bindings;
use gecko_bindings::structs::root::mozilla::css::URLValue;
use gecko_bindings::structs::root::mozilla::CORSMode;
use gecko_bindings::structs::root::nsStyleImageRequest;
use gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI};
use gecko_bindings::sugar::refptr::RefPtr;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use nsstring::nsCString; use nsstring::nsCString;
use parser::{Parse, ParserContext};
use servo_arc::Arc; use servo_arc::Arc;
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use style_traits::{CssWriter, ParseError, ToCss}; use style_traits::{CssWriter, ParseError, ToCss};
use stylesheets::UrlExtraData;
use values::computed::{Context, ToComputedValue};
/// A CSS url() value for gecko. /// A CSS url() value for gecko.
#[css(function = "url")] #[css(function = "url")]
@ -132,12 +132,12 @@ impl SpecifiedUrl {
} }
fn from_css_url(url: CssUrl) -> Self { fn from_css_url(url: CssUrl) -> Self {
use gecko_bindings::structs::root::mozilla::CORSMode_CORS_NONE; use crate::gecko_bindings::structs::root::mozilla::CORSMode_CORS_NONE;
Self::from_css_url_with_cors(url, CORSMode_CORS_NONE) Self::from_css_url_with_cors(url, CORSMode_CORS_NONE)
} }
fn from_css_url_with_cors_anonymous(url: CssUrl) -> Self { fn from_css_url_with_cors_anonymous(url: CssUrl) -> Self {
use gecko_bindings::structs::root::mozilla::CORSMode_CORS_ANONYMOUS; use crate::gecko_bindings::structs::root::mozilla::CORSMode_CORS_ANONYMOUS;
Self::from_css_url_with_cors(url, CORSMode_CORS_ANONYMOUS) Self::from_css_url_with_cors(url, CORSMode_CORS_ANONYMOUS)
} }
} }

View file

@ -7,30 +7,32 @@
//! Different kind of helpers to interact with Gecko values. //! Different kind of helpers to interact with Gecko values.
use app_units::Au; use app_units::Au;
use counter_style::{Symbol, Symbols}; use crate::counter_style::{Symbol, Symbols};
use crate::gecko_bindings::structs::{self, nsStyleCoord, CounterStylePtr};
use crate::gecko_bindings::structs::{StyleGridTrackBreadth, StyleShapeRadius};
use crate::gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
use crate::media_queries::Device;
use crate::values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
use crate::values::computed::FlexBasis as ComputedFlexBasis;
use crate::values::computed::{Angle, ExtremumLength, Length, LengthOrPercentage};
use crate::values::computed::{LengthOrPercentageOrAuto, Percentage};
use crate::values::computed::{LengthOrPercentageOrNone, Number, NumberOrPercentage};
use crate::values::computed::{MaxLength as ComputedMaxLength, MozLength as ComputedMozLength};
use crate::values::computed::{
NonNegativeLength, NonNegativeLengthOrPercentage, NonNegativeNumber,
};
use crate::values::generics::basic_shape::ShapeRadius;
use crate::values::generics::box_::Perspective;
use crate::values::generics::flex::FlexBasis;
use crate::values::generics::gecko::ScrollSnapPoint;
use crate::values::generics::grid::{TrackBreadth, TrackKeyword};
use crate::values::generics::length::{MaxLength, MozLength};
use crate::values::generics::{CounterStyleOrNone, NonNegative};
use crate::values::{Auto, Either, None_, Normal};
use crate::Atom;
use cssparser::RGBA; use cssparser::RGBA;
use gecko_bindings::structs::{self, nsStyleCoord, CounterStylePtr};
use gecko_bindings::structs::{StyleGridTrackBreadth, StyleShapeRadius};
use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
use media_queries::Device;
use nsstring::{nsACString, nsCStr}; use nsstring::{nsACString, nsCStr};
use std::cmp::max; use std::cmp::max;
use values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
use values::computed::FlexBasis as ComputedFlexBasis;
use values::computed::{Angle, ExtremumLength, Length, LengthOrPercentage};
use values::computed::{LengthOrPercentageOrAuto, Percentage};
use values::computed::{LengthOrPercentageOrNone, Number, NumberOrPercentage};
use values::computed::{MaxLength as ComputedMaxLength, MozLength as ComputedMozLength};
use values::computed::{NonNegativeLength, NonNegativeLengthOrPercentage, NonNegativeNumber};
use values::generics::basic_shape::ShapeRadius;
use values::generics::box_::Perspective;
use values::generics::flex::FlexBasis;
use values::generics::gecko::ScrollSnapPoint;
use values::generics::grid::{TrackBreadth, TrackKeyword};
use values::generics::length::{MaxLength, MozLength};
use values::generics::{CounterStyleOrNone, NonNegative};
use values::{Auto, Either, None_, Normal};
use Atom;
/// A trait that defines an interface to convert from and to `nsStyleCoord`s. /// A trait that defines an interface to convert from and to `nsStyleCoord`s.
pub trait GeckoStyleCoordConvertible: Sized { pub trait GeckoStyleCoordConvertible: Sized {
@ -377,8 +379,12 @@ impl GeckoStyleCoordConvertible for Normal {
impl GeckoStyleCoordConvertible for ExtremumLength { impl GeckoStyleCoordConvertible for ExtremumLength {
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) { fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
use gecko_bindings::structs::{NS_STYLE_WIDTH_AVAILABLE, NS_STYLE_WIDTH_FIT_CONTENT}; use crate::gecko_bindings::structs::{
use gecko_bindings::structs::{NS_STYLE_WIDTH_MAX_CONTENT, NS_STYLE_WIDTH_MIN_CONTENT}; NS_STYLE_WIDTH_AVAILABLE, NS_STYLE_WIDTH_FIT_CONTENT,
};
use crate::gecko_bindings::structs::{
NS_STYLE_WIDTH_MAX_CONTENT, NS_STYLE_WIDTH_MIN_CONTENT,
};
coord.set_value(CoordDataValue::Enumerated(match *self { coord.set_value(CoordDataValue::Enumerated(match *self {
ExtremumLength::MozMaxContent => NS_STYLE_WIDTH_MAX_CONTENT, ExtremumLength::MozMaxContent => NS_STYLE_WIDTH_MAX_CONTENT,
ExtremumLength::MozMinContent => NS_STYLE_WIDTH_MIN_CONTENT, ExtremumLength::MozMinContent => NS_STYLE_WIDTH_MIN_CONTENT,
@ -388,8 +394,12 @@ impl GeckoStyleCoordConvertible for ExtremumLength {
} }
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> { fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
use gecko_bindings::structs::{NS_STYLE_WIDTH_AVAILABLE, NS_STYLE_WIDTH_FIT_CONTENT}; use crate::gecko_bindings::structs::{
use gecko_bindings::structs::{NS_STYLE_WIDTH_MAX_CONTENT, NS_STYLE_WIDTH_MIN_CONTENT}; NS_STYLE_WIDTH_AVAILABLE, NS_STYLE_WIDTH_FIT_CONTENT,
};
use crate::gecko_bindings::structs::{
NS_STYLE_WIDTH_MAX_CONTENT, NS_STYLE_WIDTH_MIN_CONTENT,
};
match coord.as_value() { match coord.as_value() {
CoordDataValue::Enumerated(NS_STYLE_WIDTH_MAX_CONTENT) => { CoordDataValue::Enumerated(NS_STYLE_WIDTH_MAX_CONTENT) => {
Some(ExtremumLength::MozMaxContent) Some(ExtremumLength::MozMaxContent)
@ -451,8 +461,8 @@ impl GeckoStyleCoordConvertible for ScrollSnapPoint<LengthOrPercentage> {
} }
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> { fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
use gecko_bindings::structs::root::nsStyleUnit; use crate::gecko_bindings::structs::root::nsStyleUnit;
use values::generics::gecko::ScrollSnapPoint; use crate::values::generics::gecko::ScrollSnapPoint;
Some(match coord.unit() { Some(match coord.unit() {
nsStyleUnit::eStyleUnit_None => ScrollSnapPoint::None, nsStyleUnit::eStyleUnit_None => ScrollSnapPoint::None,
@ -476,7 +486,7 @@ where
} }
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> { fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
use gecko_bindings::structs::root::nsStyleUnit; use crate::gecko_bindings::structs::root::nsStyleUnit;
if coord.unit() == nsStyleUnit::eStyleUnit_None { if coord.unit() == nsStyleUnit::eStyleUnit_None {
return Some(Perspective::None); return Some(Perspective::None);
@ -521,8 +531,8 @@ pub fn round_border_to_device_pixels(width: Au, au_per_device_px: Au) -> Au {
impl CounterStyleOrNone { impl CounterStyleOrNone {
/// Convert this counter style to a Gecko CounterStylePtr. /// Convert this counter style to a Gecko CounterStylePtr.
pub fn to_gecko_value(self, gecko_value: &mut CounterStylePtr, device: &Device) { pub fn to_gecko_value(self, gecko_value: &mut CounterStylePtr, device: &Device) {
use gecko_bindings::bindings::Gecko_SetCounterStyleToName as set_name; use crate::gecko_bindings::bindings::Gecko_SetCounterStyleToName as set_name;
use gecko_bindings::bindings::Gecko_SetCounterStyleToSymbols as set_symbols; use crate::gecko_bindings::bindings::Gecko_SetCounterStyleToSymbols as set_symbols;
let pres_context = device.pres_context(); let pres_context = device.pres_context();
match self { match self {
CounterStyleOrNone::None => unsafe { CounterStyleOrNone::None => unsafe {
@ -558,9 +568,9 @@ impl CounterStyleOrNone {
/// Convert Gecko CounterStylePtr to CounterStyleOrNone or String. /// Convert Gecko CounterStylePtr to CounterStyleOrNone or String.
pub fn from_gecko_value(gecko_value: &CounterStylePtr) -> Either<Self, String> { pub fn from_gecko_value(gecko_value: &CounterStylePtr) -> Either<Self, String> {
use gecko_bindings::bindings; use crate::gecko_bindings::bindings;
use values::generics::SymbolsType; use crate::values::generics::SymbolsType;
use values::CustomIdent; use crate::values::CustomIdent;
let name = unsafe { bindings::Gecko_CounterStyle_GetName(gecko_value) }; let name = unsafe { bindings::Gecko_CounterStyle_GetName(gecko_value) };
if !name.is_null() { if !name.is_null() {

View file

@ -15,59 +15,63 @@
//! the separation between the style system implementation and everything else. //! the separation between the style system implementation and everything else.
use app_units::Au; use app_units::Au;
use applicable_declarations::ApplicableDeclarationBlock;
use atomic_refcell::{AtomicRefCell, AtomicRefMut}; use atomic_refcell::{AtomicRefCell, AtomicRefMut};
use author_styles::AuthorStyles; use crate::applicable_declarations::ApplicableDeclarationBlock;
use context::{PostAnimationTasks, QuirksMode, SharedStyleContext, UpdateAnimationsTasks}; use crate::author_styles::AuthorStyles;
use data::ElementData; use crate::context::{PostAnimationTasks, QuirksMode, SharedStyleContext, UpdateAnimationsTasks};
use dom::{LayoutIterator, NodeInfo, OpaqueNode, TDocument, TElement, TNode, TShadowRoot}; use crate::data::ElementData;
use element_state::{DocumentState, ElementState}; use crate::dom::{LayoutIterator, NodeInfo, OpaqueNode, TDocument, TElement, TNode, TShadowRoot};
use font_metrics::{FontMetrics, FontMetricsProvider, FontMetricsQueryResult}; use crate::element_state::{DocumentState, ElementState};
use gecko::data::GeckoStyleSheet; use crate::font_metrics::{FontMetrics, FontMetricsProvider, FontMetricsQueryResult};
use gecko::global_style_data::GLOBAL_STYLE_DATA; use crate::gecko::data::GeckoStyleSheet;
use gecko::selector_parser::{NonTSPseudoClass, PseudoElement, SelectorImpl}; use crate::gecko::global_style_data::GLOBAL_STYLE_DATA;
use gecko::snapshot_helpers; use crate::gecko::selector_parser::{NonTSPseudoClass, PseudoElement, SelectorImpl};
use gecko_bindings::bindings; use crate::gecko::snapshot_helpers;
use gecko_bindings::bindings::Gecko_ElementHasAnimations; use crate::gecko_bindings::bindings;
use gecko_bindings::bindings::Gecko_ElementHasCSSAnimations; use crate::gecko_bindings::bindings::Gecko_ElementHasAnimations;
use gecko_bindings::bindings::Gecko_ElementHasCSSTransitions; use crate::gecko_bindings::bindings::Gecko_ElementHasCSSAnimations;
use gecko_bindings::bindings::Gecko_GetActiveLinkAttrDeclarationBlock; use crate::gecko_bindings::bindings::Gecko_ElementHasCSSTransitions;
use gecko_bindings::bindings::Gecko_GetAnimationEffectCount; use crate::gecko_bindings::bindings::Gecko_GetActiveLinkAttrDeclarationBlock;
use gecko_bindings::bindings::Gecko_GetAnimationRule; use crate::gecko_bindings::bindings::Gecko_GetAnimationEffectCount;
use gecko_bindings::bindings::Gecko_GetExtraContentStyleDeclarations; use crate::gecko_bindings::bindings::Gecko_GetAnimationRule;
use gecko_bindings::bindings::Gecko_GetHTMLPresentationAttrDeclarationBlock; use crate::gecko_bindings::bindings::Gecko_GetExtraContentStyleDeclarations;
use gecko_bindings::bindings::Gecko_GetStyleAttrDeclarationBlock; use crate::gecko_bindings::bindings::Gecko_GetHTMLPresentationAttrDeclarationBlock;
use gecko_bindings::bindings::Gecko_GetUnvisitedLinkAttrDeclarationBlock; use crate::gecko_bindings::bindings::Gecko_GetStyleAttrDeclarationBlock;
use gecko_bindings::bindings::Gecko_GetVisitedLinkAttrDeclarationBlock; use crate::gecko_bindings::bindings::Gecko_GetUnvisitedLinkAttrDeclarationBlock;
use gecko_bindings::bindings::Gecko_IsSignificantChild; use crate::gecko_bindings::bindings::Gecko_GetVisitedLinkAttrDeclarationBlock;
use gecko_bindings::bindings::Gecko_MatchLang; use crate::gecko_bindings::bindings::Gecko_IsSignificantChild;
use gecko_bindings::bindings::Gecko_UnsetDirtyStyleAttr; use crate::gecko_bindings::bindings::Gecko_MatchLang;
use gecko_bindings::bindings::Gecko_UpdateAnimations; use crate::gecko_bindings::bindings::Gecko_UnsetDirtyStyleAttr;
use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentLWTheme}; use crate::gecko_bindings::bindings::Gecko_UpdateAnimations;
use gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags}; use crate::gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentLWTheme};
use gecko_bindings::structs; use crate::gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags};
use gecko_bindings::structs::nsChangeHint; use crate::gecko_bindings::structs;
use gecko_bindings::structs::nsIDocument_DocumentTheme as DocumentTheme; use crate::gecko_bindings::structs::nsChangeHint;
use gecko_bindings::structs::nsRestyleHint; use crate::gecko_bindings::structs::nsIDocument_DocumentTheme as DocumentTheme;
use gecko_bindings::structs::EffectCompositor_CascadeLevel as CascadeLevel; use crate::gecko_bindings::structs::nsRestyleHint;
use gecko_bindings::structs::ELEMENT_HANDLED_SNAPSHOT; use crate::gecko_bindings::structs::EffectCompositor_CascadeLevel as CascadeLevel;
use gecko_bindings::structs::ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO; use crate::gecko_bindings::structs::ELEMENT_HANDLED_SNAPSHOT;
use gecko_bindings::structs::ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO; use crate::gecko_bindings::structs::ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO;
use gecko_bindings::structs::ELEMENT_HAS_SNAPSHOT; use crate::gecko_bindings::structs::ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO;
use gecko_bindings::structs::NODE_DESCENDANTS_NEED_FRAMES; use crate::gecko_bindings::structs::ELEMENT_HAS_SNAPSHOT;
use gecko_bindings::structs::NODE_NEEDS_FRAME; use crate::gecko_bindings::structs::NODE_DESCENDANTS_NEED_FRAMES;
use gecko_bindings::structs::{nsAtom, nsIContent, nsINode_BooleanFlag}; use crate::gecko_bindings::structs::NODE_NEEDS_FRAME;
use gecko_bindings::structs::{RawGeckoElement, RawGeckoNode, RawGeckoXBLBinding}; use crate::gecko_bindings::structs::{nsAtom, nsIContent, nsINode_BooleanFlag};
use gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI}; use crate::gecko_bindings::structs::{RawGeckoElement, RawGeckoNode, RawGeckoXBLBinding};
use hash::FxHashMap; use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI};
use logical_geometry::WritingMode; use crate::hash::FxHashMap;
use media_queries::Device; use crate::logical_geometry::WritingMode;
use properties::animated_properties::{AnimationValue, AnimationValueMap}; use crate::media_queries::Device;
use properties::style_structs::Font; use crate::properties::animated_properties::{AnimationValue, AnimationValueMap};
use properties::{ComputedValues, LonghandId}; use crate::properties::style_structs::Font;
use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock}; use crate::properties::{ComputedValues, LonghandId};
use rule_tree::CascadeLevel as ServoCascadeLevel; use crate::properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock};
use selector_parser::{AttrValue, HorizontalDirection, Lang}; use crate::rule_tree::CascadeLevel as ServoCascadeLevel;
use crate::selector_parser::{AttrValue, HorizontalDirection, Lang};
use crate::shared_lock::Locked;
use crate::string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
use crate::stylist::CascadeData;
use crate::CaseSensitivityExt;
use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator}; use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator};
use selectors::attr::{CaseSensitivity, NamespaceConstraint}; use selectors::attr::{CaseSensitivity, NamespaceConstraint};
use selectors::matching::VisitedHandlingMode; use selectors::matching::VisitedHandlingMode;
@ -75,15 +79,11 @@ use selectors::matching::{ElementSelectorFlags, MatchingContext};
use selectors::sink::Push; use selectors::sink::Push;
use selectors::{Element, OpaqueElement}; use selectors::{Element, OpaqueElement};
use servo_arc::{Arc, ArcBorrow, RawOffsetArc}; use servo_arc::{Arc, ArcBorrow, RawOffsetArc};
use shared_lock::Locked;
use std::cell::RefCell; use std::cell::RefCell;
use std::fmt; use std::fmt;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use std::mem; use std::mem;
use std::ptr; use std::ptr;
use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
use stylist::CascadeData;
use CaseSensitivityExt;
#[inline] #[inline]
fn elements_with_id<'a, 'le>( fn elements_with_id<'a, 'le>(
@ -287,7 +287,7 @@ impl<'ln> GeckoNode<'ln> {
/// This logic is duplicate in Gecko's nsINode::IsInShadowTree(). /// This logic is duplicate in Gecko's nsINode::IsInShadowTree().
#[inline] #[inline]
fn is_in_shadow_tree(&self) -> bool { fn is_in_shadow_tree(&self) -> bool {
use gecko_bindings::structs::NODE_IS_IN_SHADOW_TREE; use crate::gecko_bindings::structs::NODE_IS_IN_SHADOW_TREE;
self.flags() & (NODE_IS_IN_SHADOW_TREE as u32) != 0 self.flags() & (NODE_IS_IN_SHADOW_TREE as u32) != 0
} }
@ -295,7 +295,7 @@ impl<'ln> GeckoNode<'ln> {
/// Make sure to mirror any modifications in both places. /// Make sure to mirror any modifications in both places.
#[inline] #[inline]
fn flattened_tree_parent_is_parent(&self) -> bool { fn flattened_tree_parent_is_parent(&self) -> bool {
use gecko_bindings::structs::*; use crate::gecko_bindings::structs::*;
let flags = self.flags(); let flags = self.flags();
if flags & (NODE_MAY_BE_IN_BINDING_MNGR as u32 | NODE_IS_IN_SHADOW_TREE as u32) != 0 { if flags & (NODE_MAY_BE_IN_BINDING_MNGR as u32 | NODE_IS_IN_SHADOW_TREE as u32) != 0 {
return false; return false;
@ -767,7 +767,7 @@ impl<'le> GeckoElement<'le> {
#[inline] #[inline]
fn has_properties(&self) -> bool { fn has_properties(&self) -> bool {
use gecko_bindings::structs::NODE_HAS_PROPERTIES; use crate::gecko_bindings::structs::NODE_HAS_PROPERTIES;
(self.flags() & NODE_HAS_PROPERTIES as u32) != 0 (self.flags() & NODE_HAS_PROPERTIES as u32) != 0
} }
@ -805,8 +805,8 @@ impl<'le> GeckoElement<'le> {
restyle_hint: nsRestyleHint, restyle_hint: nsRestyleHint,
change_hint: nsChangeHint, change_hint: nsChangeHint,
) { ) {
use gecko::restyle_damage::GeckoRestyleDamage; use crate::gecko::restyle_damage::GeckoRestyleDamage;
use invalidation::element::restyle_hints::RestyleHint; use crate::invalidation::element::restyle_hints::RestyleHint;
let damage = GeckoRestyleDamage::new(change_hint); let damage = GeckoRestyleDamage::new(change_hint);
debug!( debug!(
@ -844,14 +844,14 @@ impl<'le> GeckoElement<'le> {
/// This logic is duplicated in Gecko's nsIContent::IsRootOfAnonymousSubtree. /// This logic is duplicated in Gecko's nsIContent::IsRootOfAnonymousSubtree.
#[inline] #[inline]
fn is_root_of_anonymous_subtree(&self) -> bool { fn is_root_of_anonymous_subtree(&self) -> bool {
use gecko_bindings::structs::NODE_IS_ANONYMOUS_ROOT; use crate::gecko_bindings::structs::NODE_IS_ANONYMOUS_ROOT;
self.flags() & (NODE_IS_ANONYMOUS_ROOT as u32) != 0 self.flags() & (NODE_IS_ANONYMOUS_ROOT as u32) != 0
} }
/// This logic is duplicated in Gecko's nsIContent::IsRootOfNativeAnonymousSubtree. /// This logic is duplicated in Gecko's nsIContent::IsRootOfNativeAnonymousSubtree.
#[inline] #[inline]
fn is_root_of_native_anonymous_subtree(&self) -> bool { fn is_root_of_native_anonymous_subtree(&self) -> bool {
use gecko_bindings::structs::NODE_IS_NATIVE_ANONYMOUS_ROOT; use crate::gecko_bindings::structs::NODE_IS_NATIVE_ANONYMOUS_ROOT;
return self.flags() & (NODE_IS_NATIVE_ANONYMOUS_ROOT as u32) != 0; return self.flags() & (NODE_IS_NATIVE_ANONYMOUS_ROOT as u32) != 0;
} }
@ -883,8 +883,8 @@ impl<'le> GeckoElement<'le> {
} }
fn css_transitions_info(&self) -> FxHashMap<LonghandId, Arc<AnimationValue>> { fn css_transitions_info(&self) -> FxHashMap<LonghandId, Arc<AnimationValue>> {
use gecko_bindings::bindings::Gecko_ElementTransitions_EndValueAt; use crate::gecko_bindings::bindings::Gecko_ElementTransitions_EndValueAt;
use gecko_bindings::bindings::Gecko_ElementTransitions_Length; use crate::gecko_bindings::bindings::Gecko_ElementTransitions_Length;
let collection_length = unsafe { Gecko_ElementTransitions_Length(self.0) } as usize; let collection_length = unsafe { Gecko_ElementTransitions_Length(self.0) } as usize;
let mut map = FxHashMap::with_capacity_and_hasher(collection_length, Default::default()); let mut map = FxHashMap::with_capacity_and_hasher(collection_length, Default::default());
@ -910,7 +910,7 @@ impl<'le> GeckoElement<'le> {
after_change_style: &ComputedValues, after_change_style: &ComputedValues,
existing_transitions: &FxHashMap<LonghandId, Arc<AnimationValue>>, existing_transitions: &FxHashMap<LonghandId, Arc<AnimationValue>>,
) -> bool { ) -> bool {
use values::animated::{Animate, Procedure}; use crate::values::animated::{Animate, Procedure};
debug_assert!(!longhand_id.is_logical()); debug_assert!(!longhand_id.is_logical());
// If there is an existing transition, update only if the end value // If there is an existing transition, update only if the end value
@ -945,7 +945,7 @@ impl<'le> GeckoElement<'le> {
/// by Gecko. We could align these and then do this without conditionals, but /// by Gecko. We could align these and then do this without conditionals, but
/// it's probably not worth the trouble. /// it's probably not worth the trouble.
fn selector_flags_to_node_flags(flags: ElementSelectorFlags) -> u32 { fn selector_flags_to_node_flags(flags: ElementSelectorFlags) -> u32 {
use gecko_bindings::structs::*; use crate::gecko_bindings::structs::*;
let mut gecko_flags = 0u32; let mut gecko_flags = 0u32;
if flags.contains(ElementSelectorFlags::HAS_SLOW_SELECTOR) { if flags.contains(ElementSelectorFlags::HAS_SLOW_SELECTOR) {
gecko_flags |= NODE_HAS_SLOW_SELECTOR as u32; gecko_flags |= NODE_HAS_SLOW_SELECTOR as u32;
@ -967,8 +967,8 @@ fn get_animation_rule(
element: &GeckoElement, element: &GeckoElement,
cascade_level: CascadeLevel, cascade_level: CascadeLevel,
) -> Option<Arc<Locked<PropertyDeclarationBlock>>> { ) -> Option<Arc<Locked<PropertyDeclarationBlock>>> {
use gecko_bindings::sugar::ownership::HasSimpleFFI; use crate::gecko_bindings::sugar::ownership::HasSimpleFFI;
use properties::longhands::ANIMATABLE_PROPERTY_COUNT; use crate::properties::longhands::ANIMATABLE_PROPERTY_COUNT;
// There's a very rough correlation between the number of effects // There's a very rough correlation between the number of effects
// (animations) on an element and the number of properties it is likely to // (animations) on an element and the number of properties it is likely to
@ -1006,7 +1006,7 @@ pub struct GeckoFontMetricsProvider {
// This may be slow on pages using more languages, might be worth optimizing // This may be slow on pages using more languages, might be worth optimizing
// by caching lang->group mapping separately and/or using a hashmap on larger // by caching lang->group mapping separately and/or using a hashmap on larger
// loads. // loads.
pub font_size_cache: RefCell<Vec<(Atom, ::gecko_bindings::structs::FontSizePrefs)>>, pub font_size_cache: RefCell<Vec<(Atom, crate::gecko_bindings::structs::FontSizePrefs)>>,
} }
impl GeckoFontMetricsProvider { impl GeckoFontMetricsProvider {
@ -1024,7 +1024,7 @@ impl FontMetricsProvider for GeckoFontMetricsProvider {
} }
fn get_size(&self, font_name: &Atom, font_family: u8) -> Au { fn get_size(&self, font_name: &Atom, font_family: u8) -> Au {
use gecko_bindings::bindings::Gecko_GetBaseSize; use crate::gecko_bindings::bindings::Gecko_GetBaseSize;
let mut cache = self.font_size_cache.borrow_mut(); let mut cache = self.font_size_cache.borrow_mut();
if let Some(sizes) = cache.iter().find(|el| el.0 == *font_name) { if let Some(sizes) = cache.iter().find(|el| el.0 == *font_name) {
return sizes.1.size_for_generic(font_family); return sizes.1.size_for_generic(font_family);
@ -1042,7 +1042,7 @@ impl FontMetricsProvider for GeckoFontMetricsProvider {
in_media_query: bool, in_media_query: bool,
device: &Device, device: &Device,
) -> FontMetricsQueryResult { ) -> FontMetricsQueryResult {
use gecko_bindings::bindings::Gecko_GetFontMetrics; use crate::gecko_bindings::bindings::Gecko_GetFontMetrics;
let gecko_metrics = unsafe { let gecko_metrics = unsafe {
Gecko_GetFontMetrics( Gecko_GetFontMetrics(
device.pres_context(), device.pres_context(),
@ -1392,7 +1392,7 @@ impl<'le> TElement for GeckoElement<'le> {
/// This logic is duplicated in Gecko's nsINode::IsInNativeAnonymousSubtree. /// This logic is duplicated in Gecko's nsINode::IsInNativeAnonymousSubtree.
#[inline] #[inline]
fn is_in_native_anonymous_subtree(&self) -> bool { fn is_in_native_anonymous_subtree(&self) -> bool {
use gecko_bindings::structs::NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE; use crate::gecko_bindings::structs::NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE;
self.flags() & (NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE as u32) != 0 self.flags() & (NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE as u32) != 0
} }
@ -1499,8 +1499,8 @@ impl<'le> TElement for GeckoElement<'le> {
/// Process various tasks that are a result of animation-only restyle. /// Process various tasks that are a result of animation-only restyle.
fn process_post_animation(&self, tasks: PostAnimationTasks) { fn process_post_animation(&self, tasks: PostAnimationTasks) {
use gecko_bindings::structs::nsChangeHint_nsChangeHint_Empty; use crate::gecko_bindings::structs::nsChangeHint_nsChangeHint_Empty;
use gecko_bindings::structs::nsRestyleHint_eRestyle_Subtree; use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_Subtree;
debug_assert!(!tasks.is_empty(), "Should be involved a task"); debug_assert!(!tasks.is_empty(), "Should be involved a task");
@ -1638,9 +1638,9 @@ impl<'le> TElement for GeckoElement<'le> {
before_change_style: &ComputedValues, before_change_style: &ComputedValues,
after_change_style: &ComputedValues, after_change_style: &ComputedValues,
) -> bool { ) -> bool {
use gecko_bindings::structs::nsCSSPropertyID; use crate::gecko_bindings::structs::nsCSSPropertyID;
use properties::LonghandIdSet; use crate::properties::LonghandIdSet;
use values::computed::TransitionProperty; use crate::values::computed::TransitionProperty;
debug_assert!( debug_assert!(
self.might_need_transitions_update(Some(before_change_style), after_change_style), self.might_need_transitions_update(Some(before_change_style), after_change_style),
@ -1753,11 +1753,11 @@ impl<'le> TElement for GeckoElement<'le> {
) where ) where
V: Push<ApplicableDeclarationBlock>, V: Push<ApplicableDeclarationBlock>,
{ {
use properties::longhands::_x_lang::SpecifiedValue as SpecifiedLang; use crate::properties::longhands::_x_lang::SpecifiedValue as SpecifiedLang;
use properties::longhands::_x_text_zoom::SpecifiedValue as SpecifiedZoom; use crate::properties::longhands::_x_text_zoom::SpecifiedValue as SpecifiedZoom;
use properties::longhands::color::SpecifiedValue as SpecifiedColor; use crate::properties::longhands::color::SpecifiedValue as SpecifiedColor;
use properties::longhands::text_align::SpecifiedValue as SpecifiedTextAlign; use crate::properties::longhands::text_align::SpecifiedValue as SpecifiedTextAlign;
use values::specified::color::Color; use crate::values::specified::color::Color;
lazy_static! { lazy_static! {
static ref TH_RULE: ApplicableDeclarationBlock = { static ref TH_RULE: ApplicableDeclarationBlock = {
let global_style_data = &*GLOBAL_STYLE_DATA; let global_style_data = &*GLOBAL_STYLE_DATA;

View file

@ -4,7 +4,7 @@
//! Little helpers for `nsCOMPtr`. //! Little helpers for `nsCOMPtr`.
use gecko_bindings::structs::nsCOMPtr; use crate::gecko_bindings::structs::nsCOMPtr;
#[cfg(feature = "gecko_debug")] #[cfg(feature = "gecko_debug")]
impl<T> nsCOMPtr<T> { impl<T> nsCOMPtr<T> {

View file

@ -4,8 +4,8 @@
//! Little helper for `nsCompatibility`. //! Little helper for `nsCompatibility`.
use context::QuirksMode; use crate::context::QuirksMode;
use gecko_bindings::structs::nsCompatibility; use crate::gecko_bindings::structs::nsCompatibility;
impl From<nsCompatibility> for QuirksMode { impl From<nsCompatibility> for QuirksMode {
#[inline] #[inline]

View file

@ -4,10 +4,10 @@
//! Rust helpers for Gecko's `nsCSSShadowArray`. //! Rust helpers for Gecko's `nsCSSShadowArray`.
use gecko_bindings::bindings::Gecko_AddRefCSSShadowArrayArbitraryThread; use crate::gecko_bindings::bindings::Gecko_AddRefCSSShadowArrayArbitraryThread;
use gecko_bindings::bindings::Gecko_NewCSSShadowArray; use crate::gecko_bindings::bindings::Gecko_NewCSSShadowArray;
use gecko_bindings::bindings::Gecko_ReleaseCSSShadowArrayArbitraryThread; use crate::gecko_bindings::bindings::Gecko_ReleaseCSSShadowArrayArbitraryThread;
use gecko_bindings::structs::{nsCSSShadowArray, nsCSSShadowItem, RefPtr}; use crate::gecko_bindings::structs::{nsCSSShadowArray, nsCSSShadowItem, RefPtr};
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use std::{ptr, slice}; use std::{ptr, slice};

View file

@ -5,8 +5,8 @@
//! Rust helpers for Gecko's `nsCSSShadowItem`. //! Rust helpers for Gecko's `nsCSSShadowItem`.
use app_units::Au; use app_units::Au;
use gecko_bindings::structs::nsCSSShadowItem; use crate::gecko_bindings::structs::nsCSSShadowItem;
use values::computed::effects::{BoxShadow, SimpleShadow}; use crate::values::computed::effects::{BoxShadow, SimpleShadow};
impl nsCSSShadowItem { impl nsCSSShadowItem {
/// Sets this item from the given box shadow. /// Sets this item from the given box shadow.

View file

@ -4,16 +4,16 @@
//! Little helpers for `nsCSSValue`. //! Little helpers for `nsCSSValue`.
use gecko_bindings::bindings; use crate::gecko_bindings::bindings;
use gecko_bindings::structs; use crate::gecko_bindings::structs;
use gecko_bindings::structs::{nsCSSUnit, nsCSSValue}; use crate::gecko_bindings::structs::{nsCSSUnit, nsCSSValue};
use gecko_bindings::structs::{nsCSSValueList, nsCSSValue_Array}; use crate::gecko_bindings::structs::{nsCSSValueList, nsCSSValue_Array};
use gecko_string_cache::Atom; use crate::gecko_string_cache::Atom;
use crate::values::computed::{Angle, Length, LengthOrPercentage, Percentage};
use std::marker::PhantomData; use std::marker::PhantomData;
use std::mem; use std::mem;
use std::ops::{Index, IndexMut}; use std::ops::{Index, IndexMut};
use std::slice; use std::slice;
use values::computed::{Angle, Length, LengthOrPercentage, Percentage};
impl nsCSSValue { impl nsCSSValue {
/// Create a CSSValue with null unit, useful to be used as a return value. /// Create a CSSValue with null unit, useful to be used as a return value.

View file

@ -4,10 +4,10 @@
//! Rust helpers for Gecko's `nsStyleAutoArray`. //! Rust helpers for Gecko's `nsStyleAutoArray`.
use gecko_bindings::bindings::Gecko_EnsureStyleAnimationArrayLength; use crate::gecko_bindings::bindings::Gecko_EnsureStyleAnimationArrayLength;
use gecko_bindings::bindings::Gecko_EnsureStyleTransitionArrayLength; use crate::gecko_bindings::bindings::Gecko_EnsureStyleTransitionArrayLength;
use gecko_bindings::structs::nsStyleAutoArray; use crate::gecko_bindings::structs::nsStyleAutoArray;
use gecko_bindings::structs::{StyleAnimation, StyleTransition}; use crate::gecko_bindings::structs::{StyleAnimation, StyleTransition};
use std::iter::{once, Chain, IntoIterator, Once}; use std::iter::{once, Chain, IntoIterator, Once};
use std::ops::{Index, IndexMut}; use std::ops::{Index, IndexMut};
use std::slice::{Iter, IterMut}; use std::slice::{Iter, IterMut};

View file

@ -4,9 +4,11 @@
//! Rust helpers for Gecko's `nsStyleCoord`. //! Rust helpers for Gecko's `nsStyleCoord`.
use gecko_bindings::bindings; use crate::gecko_bindings::bindings;
use gecko_bindings::structs::{nsStyleCoord, nsStyleCoord_Calc, nsStyleCoord_CalcValue}; use crate::gecko_bindings::structs::{nsStyleCoord, nsStyleCoord_Calc, nsStyleCoord_CalcValue};
use gecko_bindings::structs::{nsStyleCorners, nsStyleSides, nsStyleUnion, nsStyleUnit, nscoord}; use crate::gecko_bindings::structs::{
nsStyleCorners, nsStyleSides, nsStyleUnion, nsStyleUnit, nscoord,
};
use std::mem; use std::mem;
impl nsStyleCoord { impl nsStyleCoord {
@ -266,7 +268,7 @@ pub unsafe trait CoordDataMut: CoordData {
/// Useful for initializing uninits, given that `set_value` may segfault on /// Useful for initializing uninits, given that `set_value` may segfault on
/// uninits. /// uninits.
fn leaky_set_null(&mut self) { fn leaky_set_null(&mut self) {
use gecko_bindings::structs::nsStyleUnit::*; use crate::gecko_bindings::structs::nsStyleUnit::*;
unsafe { unsafe {
let (unit, union) = self.values_mut(); let (unit, union) = self.values_mut();
*unit = eStyleUnit_Null; *unit = eStyleUnit_Null;
@ -278,7 +280,7 @@ pub unsafe trait CoordDataMut: CoordData {
/// Sets the inner value. /// Sets the inner value.
fn set_value(&mut self, value: CoordDataValue) { fn set_value(&mut self, value: CoordDataValue) {
use self::CoordDataValue::*; use self::CoordDataValue::*;
use gecko_bindings::structs::nsStyleUnit::*; use crate::gecko_bindings::structs::nsStyleUnit::*;
self.reset(); self.reset();
unsafe { unsafe {
let (unit, union) = self.values_mut(); let (unit, union) = self.values_mut();
@ -365,7 +367,7 @@ pub unsafe trait CoordData {
/// Get the appropriate value for this object. /// Get the appropriate value for this object.
fn as_value(&self) -> CoordDataValue { fn as_value(&self) -> CoordDataValue {
use self::CoordDataValue::*; use self::CoordDataValue::*;
use gecko_bindings::structs::nsStyleUnit::*; use crate::gecko_bindings::structs::nsStyleUnit::*;
unsafe { unsafe {
match self.unit() { match self.unit() {
eStyleUnit_Null => Null, eStyleUnit_Null => Null,
@ -387,7 +389,7 @@ pub unsafe trait CoordData {
#[inline] #[inline]
/// Pretend inner value is a float; obtain it. /// Pretend inner value is a float; obtain it.
unsafe fn get_float(&self) -> f32 { unsafe fn get_float(&self) -> f32 {
use gecko_bindings::structs::nsStyleUnit::*; use crate::gecko_bindings::structs::nsStyleUnit::*;
debug_assert!( debug_assert!(
self.unit() == eStyleUnit_Percent || self.unit() == eStyleUnit_Percent ||
self.unit() == eStyleUnit_Factor || self.unit() == eStyleUnit_Factor ||
@ -400,7 +402,7 @@ pub unsafe trait CoordData {
#[inline] #[inline]
/// Pretend inner value is an int; obtain it. /// Pretend inner value is an int; obtain it.
unsafe fn get_integer(&self) -> i32 { unsafe fn get_integer(&self) -> i32 {
use gecko_bindings::structs::nsStyleUnit::*; use crate::gecko_bindings::structs::nsStyleUnit::*;
debug_assert!( debug_assert!(
self.unit() == eStyleUnit_Coord || self.unit() == eStyleUnit_Coord ||
self.unit() == eStyleUnit_Integer || self.unit() == eStyleUnit_Integer ||

View file

@ -4,8 +4,8 @@
//! Rust helpers for Gecko's nsTArray. //! Rust helpers for Gecko's nsTArray.
use gecko_bindings::bindings; use crate::gecko_bindings::bindings;
use gecko_bindings::structs::{nsTArray, nsTArrayHeader}; use crate::gecko_bindings::structs::{nsTArray, nsTArrayHeader};
use std::mem; use std::mem;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use std::slice; use std::slice;

View file

@ -4,15 +4,15 @@
//! Helper to iterate over `OriginFlags` bits. //! Helper to iterate over `OriginFlags` bits.
use gecko_bindings::structs::OriginFlags; use crate::gecko_bindings::structs::OriginFlags;
use gecko_bindings::structs::OriginFlags_Author; use crate::gecko_bindings::structs::OriginFlags_Author;
use gecko_bindings::structs::OriginFlags_User; use crate::gecko_bindings::structs::OriginFlags_User;
use gecko_bindings::structs::OriginFlags_UserAgent; use crate::gecko_bindings::structs::OriginFlags_UserAgent;
use stylesheets::OriginSet; use crate::stylesheets::OriginSet;
/// Checks that the values for OriginFlags are the ones we expect. /// Checks that the values for OriginFlags are the ones we expect.
pub fn assert_flags_match() { pub fn assert_flags_match() {
use stylesheets::origin::*; use crate::stylesheets::origin::*;
debug_assert_eq!(OriginFlags_UserAgent.0, OriginSet::ORIGIN_USER_AGENT.bits()); debug_assert_eq!(OriginFlags_UserAgent.0, OriginSet::ORIGIN_USER_AGENT.bits());
debug_assert_eq!(OriginFlags_Author.0, OriginSet::ORIGIN_AUTHOR.bits()); debug_assert_eq!(OriginFlags_Author.0, OriginSet::ORIGIN_AUTHOR.bits());
debug_assert_eq!(OriginFlags_User.0, OriginSet::ORIGIN_USER.bits()); debug_assert_eq!(OriginFlags_User.0, OriginSet::ORIGIN_USER.bits());

View file

@ -4,13 +4,13 @@
//! A rust helper to ease the use of Gecko's refcounted types. //! A rust helper to ease the use of Gecko's refcounted types.
use gecko_bindings::sugar::ownership::HasArcFFI; use crate::gecko_bindings::sugar::ownership::HasArcFFI;
use gecko_bindings::{bindings, structs}; use crate::gecko_bindings::{bindings, structs};
use crate::Atom;
use servo_arc::Arc; use servo_arc::Arc;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use std::{fmt, mem, ptr}; use std::{fmt, mem, ptr};
use Atom;
/// Trait for all objects that have Addref() and Release /// Trait for all objects that have Addref() and Release
/// methods and can be placed inside RefPtr<T> /// methods and can be placed inside RefPtr<T>

View file

@ -4,13 +4,13 @@
//! Rust helpers to interact with Gecko's StyleComplexColor. //! Rust helpers to interact with Gecko's StyleComplexColor.
use gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor}; use crate::gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor};
use gecko_bindings::structs::StyleComplexColor; use crate::gecko_bindings::structs::StyleComplexColor;
use gecko_bindings::structs::StyleComplexColor_Tag as Tag; use crate::gecko_bindings::structs::StyleComplexColor_Tag as Tag;
use values::computed::ui::ColorOrAuto; use crate::values::computed::ui::ColorOrAuto;
use values::computed::{Color as ComputedColor, RGBAColor as ComputedRGBA}; use crate::values::computed::{Color as ComputedColor, RGBAColor as ComputedRGBA};
use values::generics::color::{Color as GenericColor, ComplexColorRatios}; use crate::values::generics::color::{Color as GenericColor, ComplexColorRatios};
use values::{Auto, Either}; use crate::values::{Auto, Either};
impl StyleComplexColor { impl StyleComplexColor {
/// Create a `StyleComplexColor` value that represents `currentColor`. /// Create a `StyleComplexColor` value that represents `currentColor`.

View file

@ -10,11 +10,11 @@
//! A drop-in replacement for string_cache, but backed by Gecko `nsAtom`s. //! A drop-in replacement for string_cache, but backed by Gecko `nsAtom`s.
use gecko_bindings::bindings::Gecko_AddRefAtom; use crate::gecko_bindings::bindings::Gecko_AddRefAtom;
use gecko_bindings::bindings::Gecko_Atomize; use crate::gecko_bindings::bindings::Gecko_Atomize;
use gecko_bindings::bindings::Gecko_Atomize16; use crate::gecko_bindings::bindings::Gecko_Atomize16;
use gecko_bindings::bindings::Gecko_ReleaseAtom; use crate::gecko_bindings::bindings::Gecko_ReleaseAtom;
use gecko_bindings::structs::{nsAtom, nsAtom_AtomKind, nsDynamicAtom, nsStaticAtom}; use crate::gecko_bindings::structs::{nsAtom, nsAtom_AtomKind, nsDynamicAtom, nsStaticAtom};
use nsstring::{nsAString, nsStr}; use nsstring::{nsAString, nsStr};
use precomputed_hash::PrecomputedHash; use precomputed_hash::PrecomputedHash;
use std::borrow::{Borrow, Cow}; use std::borrow::{Borrow, Cow};

View file

@ -4,12 +4,12 @@
//! A type to represent a namespace. //! A type to represent a namespace.
use gecko_bindings::structs::nsAtom; use crate::gecko_bindings::structs::nsAtom;
use crate::string_cache::{Atom, WeakAtom};
use precomputed_hash::PrecomputedHash; use precomputed_hash::PrecomputedHash;
use std::borrow::Borrow; use std::borrow::Borrow;
use std::fmt; use std::fmt;
use std::ops::Deref; use std::ops::Deref;
use string_cache::{Atom, WeakAtom};
#[macro_export] #[macro_export]
macro_rules! ns { macro_rules! ns {

View file

@ -4,13 +4,13 @@
//! An invalidation processor for style changes due to document state changes. //! An invalidation processor for style changes due to document state changes.
use dom::TElement; use crate::dom::TElement;
use element_state::DocumentState; use crate::element_state::DocumentState;
use invalidation::element::invalidator::{DescendantInvalidationLists, InvalidationVector}; use crate::invalidation::element::invalidator::{DescendantInvalidationLists, InvalidationVector};
use invalidation::element::invalidator::{Invalidation, InvalidationProcessor}; use crate::invalidation::element::invalidator::{Invalidation, InvalidationProcessor};
use invalidation::element::state_and_attributes; use crate::invalidation::element::state_and_attributes;
use crate::stylist::CascadeData;
use selectors::matching::{MatchingContext, MatchingMode, QuirksMode, VisitedHandlingMode}; use selectors::matching::{MatchingContext, MatchingMode, QuirksMode, VisitedHandlingMode};
use stylist::CascadeData;
/// A struct holding the members necessary to invalidate document state /// A struct holding the members necessary to invalidate document state
/// selectors. /// selectors.

View file

@ -5,16 +5,16 @@
//! A wrapper over an element and a snapshot, that allows us to selector-match //! A wrapper over an element and a snapshot, that allows us to selector-match
//! against a past state of the element. //! against a past state of the element.
use dom::TElement; use crate::dom::TElement;
use element_state::ElementState; use crate::element_state::ElementState;
use selector_parser::{AttrValue, NonTSPseudoClass, PseudoElement, SelectorImpl}; use crate::selector_parser::{AttrValue, NonTSPseudoClass, PseudoElement, SelectorImpl};
use selector_parser::{Snapshot, SnapshotMap}; use crate::selector_parser::{Snapshot, SnapshotMap};
use crate::{Atom, CaseSensitivityExt, LocalName, Namespace, WeakAtom};
use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint}; use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
use selectors::matching::{ElementSelectorFlags, MatchingContext}; use selectors::matching::{ElementSelectorFlags, MatchingContext};
use selectors::{Element, OpaqueElement}; use selectors::{Element, OpaqueElement};
use std::cell::Cell; use std::cell::Cell;
use std::fmt; use std::fmt;
use {Atom, CaseSensitivityExt, LocalName, Namespace, WeakAtom};
/// In order to compute restyle hints, we perform a selector match against a /// In order to compute restyle hints, we perform a selector match against a
/// list of partial selectors whose rightmost simple selector may be sensitive /// list of partial selectors whose rightmost simple selector may be sensitive
@ -60,7 +60,7 @@ pub trait ElementSnapshot: Sized {
/// A callback that should be called for each class of the snapshot. Should /// A callback that should be called for each class of the snapshot. Should
/// only be called if `has_attrs()` returns true. /// only be called if `has_attrs()` returns true.
fn each_class<F>(&self, F) fn each_class<F>(&self, _: F)
where where
F: FnMut(&Atom); F: FnMut(&Atom);

View file

@ -4,18 +4,18 @@
//! Code for invalidations due to state or attribute changes. //! Code for invalidations due to state or attribute changes.
use context::QuirksMode; use crate::context::QuirksMode;
use element_state::{DocumentState, ElementState}; use crate::element_state::{DocumentState, ElementState};
use crate::selector_map::{MaybeCaseInsensitiveHashMap, SelectorMap, SelectorMapEntry};
use crate::selector_parser::SelectorImpl;
use crate::{Atom, LocalName, Namespace};
use fallible::FallibleVec; use fallible::FallibleVec;
use hashglobe::FailedAllocationError; use hashglobe::FailedAllocationError;
use selector_map::{MaybeCaseInsensitiveHashMap, SelectorMap, SelectorMapEntry};
use selector_parser::SelectorImpl;
use selectors::attr::NamespaceConstraint; use selectors::attr::NamespaceConstraint;
use selectors::parser::{Combinator, Component}; use selectors::parser::{Combinator, Component};
use selectors::parser::{Selector, SelectorIter, Visit}; use selectors::parser::{Selector, SelectorIter, Visit};
use selectors::visitor::SelectorVisitor; use selectors::visitor::SelectorVisitor;
use smallvec::SmallVec; use smallvec::SmallVec;
use {Atom, LocalName, Namespace};
/// Mapping between (partial) CompoundSelectors (and the combinator to their /// Mapping between (partial) CompoundSelectors (and the combinator to their
/// right) and the states and attributes they depend on. /// right) and the states and attributes they depend on.
@ -358,7 +358,7 @@ impl<'a> SelectorVisitor for CompoundSelectorDependencyCollector<'a> {
fn visit_simple_selector(&mut self, s: &Component<SelectorImpl>) -> bool { fn visit_simple_selector(&mut self, s: &Component<SelectorImpl>) -> bool {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use selector_parser::NonTSPseudoClass; use crate::selector_parser::NonTSPseudoClass;
match *s { match *s {
Component::ID(ref id) => { Component::ID(ref id) => {

View file

@ -5,9 +5,9 @@
//! The struct that takes care of encapsulating all the logic on where and how //! The struct that takes care of encapsulating all the logic on where and how
//! element styles need to be invalidated. //! element styles need to be invalidated.
use context::StackLimitChecker; use crate::context::StackLimitChecker;
use dom::{TElement, TNode, TShadowRoot}; use crate::dom::{TElement, TNode, TShadowRoot};
use selector_parser::SelectorImpl; use crate::selector_parser::SelectorImpl;
use selectors::matching::matches_compound_selector_from; use selectors::matching::matches_compound_selector_from;
use selectors::matching::{CompoundSelectorMatchingResult, MatchingContext}; use selectors::matching::{CompoundSelectorMatchingResult, MatchingContext};
use selectors::parser::{Combinator, Component, Selector}; use selectors::parser::{Combinator, Component, Selector};

View file

@ -5,8 +5,8 @@
//! Restyle hints: an optimization to avoid unnecessarily matching selectors. //! Restyle hints: an optimization to avoid unnecessarily matching selectors.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use gecko_bindings::structs::nsRestyleHint; use crate::gecko_bindings::structs::nsRestyleHint;
use traversal_flags::TraversalFlags; use crate::traversal_flags::TraversalFlags;
bitflags! { bitflags! {
/// The kind of restyle we need to do for a given element. /// The kind of restyle we need to do for a given element.
@ -193,12 +193,12 @@ impl Default for RestyleHint {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
impl From<nsRestyleHint> for RestyleHint { impl From<nsRestyleHint> for RestyleHint {
fn from(mut raw: nsRestyleHint) -> Self { fn from(mut raw: nsRestyleHint) -> Self {
use gecko_bindings::structs::nsRestyleHint_eRestyle_Force as eRestyle_Force; use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_Force as eRestyle_Force;
use gecko_bindings::structs::nsRestyleHint_eRestyle_ForceDescendants as eRestyle_ForceDescendants; use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_ForceDescendants as eRestyle_ForceDescendants;
use gecko_bindings::structs::nsRestyleHint_eRestyle_LaterSiblings as eRestyle_LaterSiblings; use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_LaterSiblings as eRestyle_LaterSiblings;
use gecko_bindings::structs::nsRestyleHint_eRestyle_Self as eRestyle_Self; use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_Self as eRestyle_Self;
use gecko_bindings::structs::nsRestyleHint_eRestyle_SomeDescendants as eRestyle_SomeDescendants; use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_SomeDescendants as eRestyle_SomeDescendants;
use gecko_bindings::structs::nsRestyleHint_eRestyle_Subtree as eRestyle_Subtree; use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_Subtree as eRestyle_Subtree;
let mut hint = RestyleHint::empty(); let mut hint = RestyleHint::empty();
@ -241,7 +241,7 @@ malloc_size_of_is_0!(RestyleHint);
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
#[inline] #[inline]
pub fn assert_restyle_hints_match() { pub fn assert_restyle_hints_match() {
use gecko_bindings::structs; use crate::gecko_bindings::structs;
macro_rules! check_restyle_hints { macro_rules! check_restyle_hints {
( $( $a:ident => $b:path),*, ) => { ( $( $a:ident => $b:path),*, ) => {

View file

@ -5,24 +5,24 @@
//! An invalidation processor for style changes due to state and attribute //! An invalidation processor for style changes due to state and attribute
//! changes. //! changes.
use context::SharedStyleContext; use crate::context::SharedStyleContext;
use data::ElementData; use crate::data::ElementData;
use dom::TElement; use crate::dom::TElement;
use element_state::ElementState; use crate::element_state::ElementState;
use invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper}; use crate::invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper};
use invalidation::element::invalidation_map::*; use crate::invalidation::element::invalidation_map::*;
use invalidation::element::invalidator::{DescendantInvalidationLists, InvalidationVector}; use crate::invalidation::element::invalidator::{DescendantInvalidationLists, InvalidationVector};
use invalidation::element::invalidator::{Invalidation, InvalidationProcessor}; use crate::invalidation::element::invalidator::{Invalidation, InvalidationProcessor};
use invalidation::element::restyle_hints::RestyleHint; use crate::invalidation::element::restyle_hints::RestyleHint;
use selector_map::SelectorMap; use crate::selector_map::SelectorMap;
use selector_parser::Snapshot; use crate::selector_parser::Snapshot;
use crate::stylesheets::origin::{Origin, OriginSet};
use crate::{Atom, WeakAtom};
use selectors::attr::CaseSensitivity; use selectors::attr::CaseSensitivity;
use selectors::matching::matches_selector; use selectors::matching::matches_selector;
use selectors::matching::{MatchingContext, MatchingMode, VisitedHandlingMode}; use selectors::matching::{MatchingContext, MatchingMode, VisitedHandlingMode};
use selectors::NthIndexCache; use selectors::NthIndexCache;
use smallvec::SmallVec; use smallvec::SmallVec;
use stylesheets::origin::{Origin, OriginSet};
use {Atom, WeakAtom};
/// The collector implementation. /// The collector implementation.
struct Collector<'a, 'b: 'a, 'selectors: 'a, E> struct Collector<'a, 'b: 'a, 'selectors: 'a, E>

View file

@ -4,12 +4,12 @@
//! Code related to the invalidation of media-query-affected rules. //! Code related to the invalidation of media-query-affected rules.
use context::QuirksMode; use crate::context::QuirksMode;
use crate::media_queries::Device;
use crate::shared_lock::SharedRwLockReadGuard;
use crate::stylesheets::{DocumentRule, ImportRule, MediaRule};
use crate::stylesheets::{NestedRuleIterationCondition, Stylesheet, SupportsRule};
use fxhash::FxHashSet; use fxhash::FxHashSet;
use media_queries::Device;
use shared_lock::SharedRwLockReadGuard;
use stylesheets::{DocumentRule, ImportRule, MediaRule};
use stylesheets::{NestedRuleIterationCondition, Stylesheet, SupportsRule};
/// A key for a given media query result. /// A key for a given media query result.
/// ///
@ -115,7 +115,7 @@ impl NestedRuleIterationCondition for PotentiallyEffectiveMediaRules {
quirks_mode: QuirksMode, quirks_mode: QuirksMode,
rule: &DocumentRule, rule: &DocumentRule,
) -> bool { ) -> bool {
use stylesheets::EffectiveRules; use crate::stylesheets::EffectiveRules;
EffectiveRules::process_document(guard, device, quirks_mode, rule) EffectiveRules::process_document(guard, device, quirks_mode, rule)
} }
@ -126,7 +126,7 @@ impl NestedRuleIterationCondition for PotentiallyEffectiveMediaRules {
quirks_mode: QuirksMode, quirks_mode: QuirksMode,
rule: &SupportsRule, rule: &SupportsRule,
) -> bool { ) -> bool {
use stylesheets::EffectiveRules; use crate::stylesheets::EffectiveRules;
EffectiveRules::process_supports(guard, device, quirks_mode, rule) EffectiveRules::process_supports(guard, device, quirks_mode, rule)
} }
} }

View file

@ -7,19 +7,19 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
use dom::{TDocument, TElement, TNode}; use crate::dom::{TDocument, TElement, TNode};
use crate::invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper};
use crate::invalidation::element::restyle_hints::RestyleHint;
use crate::media_queries::Device;
use crate::selector_parser::{SelectorImpl, Snapshot, SnapshotMap};
use crate::shared_lock::SharedRwLockReadGuard;
use crate::stylesheets::{CssRule, StylesheetInDocument};
use crate::Atom;
use crate::CaseSensitivityExt;
use crate::LocalName as SelectorLocalName;
use fxhash::FxHashSet; use fxhash::FxHashSet;
use invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper};
use invalidation::element::restyle_hints::RestyleHint;
use media_queries::Device;
use selector_parser::{SelectorImpl, Snapshot, SnapshotMap};
use selectors::attr::CaseSensitivity; use selectors::attr::CaseSensitivity;
use selectors::parser::{Component, LocalName, Selector}; use selectors::parser::{Component, LocalName, Selector};
use shared_lock::SharedRwLockReadGuard;
use stylesheets::{CssRule, StylesheetInDocument};
use Atom;
use CaseSensitivityExt;
use LocalName as SelectorLocalName;
/// A style sheet invalidation represents a kind of element or subtree that may /// A style sheet invalidation represents a kind of element or subtree that may
/// need to be restyled. Whether it represents a whole subtree or just a single /// need to be restyled. Whether it represents a whole subtree or just a single
@ -419,7 +419,7 @@ impl StylesheetInvalidationSet {
guard: &SharedRwLockReadGuard, guard: &SharedRwLockReadGuard,
device: &Device, device: &Device,
) { ) {
use stylesheets::CssRule::*; use crate::stylesheets::CssRule::*;
debug!("StylesheetInvalidationSet::collect_invalidations_for_rule"); debug!("StylesheetInvalidationSet::collect_invalidations_for_rule");
debug_assert!(!self.fully_invalid, "Not worth to be here!"); debug_assert!(!self.fully_invalid, "Not worth to be here!");

View file

@ -165,15 +165,15 @@ pub mod use_counters;
pub mod values; pub mod values;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use gecko_string_cache as string_cache; pub use crate::gecko_string_cache as string_cache;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use gecko_string_cache::Atom; pub use crate::gecko_string_cache::Atom;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use gecko_string_cache::Atom as Prefix; pub use crate::gecko_string_cache::Atom as Prefix;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use gecko_string_cache::Atom as LocalName; pub use crate::gecko_string_cache::Atom as LocalName;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use gecko_string_cache::Namespace; pub use crate::gecko_string_cache::Namespace;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
pub use html5ever::LocalName; pub use html5ever::LocalName;
@ -215,17 +215,17 @@ macro_rules! reexport_computed_values {
/// [computed]: https://drafts.csswg.org/css-cascade/#computed /// [computed]: https://drafts.csswg.org/css-cascade/#computed
pub mod computed_values { pub mod computed_values {
$( $(
pub use properties::longhands::$name::computed_value as $name; pub use crate::properties::longhands::$name::computed_value as $name;
)+ )+
// Don't use a side-specific name needlessly: // Don't use a side-specific name needlessly:
pub use properties::longhands::border_top_style::computed_value as border_style; pub use crate::properties::longhands::border_top_style::computed_value as border_style;
} }
} }
} }
longhand_properties_idents!(reexport_computed_values); longhand_properties_idents!(reexport_computed_values);
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use gecko_string_cache::WeakAtom; use crate::gecko_string_cache::WeakAtom;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
use servo_atoms::Atom as WeakAtom; use servo_atoms::Atom as WeakAtom;

View file

@ -4,9 +4,9 @@
//! Geometry in flow-relative space. //! Geometry in flow-relative space.
use crate::properties::style_structs;
use euclid::num::Zero; use euclid::num::Zero;
use euclid::{Point2D, Rect, SideOffsets2D, Size2D}; use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
use properties::style_structs;
use std::cmp::{max, min}; use std::cmp::{max, min};
use std::fmt::{self, Debug, Error, Formatter}; use std::fmt::{self, Debug, Error, Formatter};
use std::ops::{Add, Sub}; use std::ops::{Add, Sub};
@ -42,8 +42,8 @@ bitflags!(
impl WritingMode { impl WritingMode {
/// Return a WritingMode bitflags from the relevant CSS properties. /// Return a WritingMode bitflags from the relevant CSS properties.
pub fn new(inheritedbox_style: &style_structs::InheritedBox) -> Self { pub fn new(inheritedbox_style: &style_structs::InheritedBox) -> Self {
use properties::longhands::direction::computed_value::T as Direction; use crate::properties::longhands::direction::computed_value::T as Direction;
use properties::longhands::writing_mode::computed_value::T as SpecifiedWritingMode; use crate::properties::longhands::writing_mode::computed_value::T as SpecifiedWritingMode;
let mut flags = WritingMode::empty(); let mut flags = WritingMode::empty();
@ -79,7 +79,7 @@ impl WritingMode {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
{ {
use properties::longhands::text_orientation::computed_value::T as TextOrientation; use crate::properties::longhands::text_orientation::computed_value::T as TextOrientation;
// If FLAG_SIDEWAYS is already set, this means writing-mode is // If FLAG_SIDEWAYS is already set, this means writing-mode is
// either sideways-rl or sideways-lr, and for both of these values, // either sideways-rl or sideways-lr, and for both of these values,

View file

@ -7,19 +7,19 @@
#![allow(unsafe_code)] #![allow(unsafe_code)]
#![deny(missing_docs)] #![deny(missing_docs)]
use context::{ElementCascadeInputs, QuirksMode, SelectorFlagsMap}; use crate::context::{ElementCascadeInputs, QuirksMode, SelectorFlagsMap};
use context::{SharedStyleContext, StyleContext}; use crate::context::{SharedStyleContext, StyleContext};
use data::ElementData; use crate::data::ElementData;
use dom::TElement; use crate::dom::TElement;
use invalidation::element::restyle_hints::RestyleHint; use crate::invalidation::element::restyle_hints::RestyleHint;
use properties::longhands::display::computed_value::T as Display; use crate::properties::longhands::display::computed_value::T as Display;
use properties::ComputedValues; use crate::properties::ComputedValues;
use rule_tree::{CascadeLevel, StrongRuleNode}; use crate::rule_tree::{CascadeLevel, StrongRuleNode};
use selector_parser::{PseudoElement, RestyleDamage}; use crate::selector_parser::{PseudoElement, RestyleDamage};
use crate::style_resolver::ResolvedElementStyles;
use crate::traversal_flags::TraversalFlags;
use selectors::matching::ElementSelectorFlags; use selectors::matching::ElementSelectorFlags;
use servo_arc::{Arc, ArcBorrow}; use servo_arc::{Arc, ArcBorrow};
use style_resolver::ResolvedElementStyles;
use traversal_flags::TraversalFlags;
/// Represents the result of comparing an element's old and new style. /// Represents the result of comparing an element's old and new style.
#[derive(Debug)] #[derive(Debug)]
@ -93,8 +93,8 @@ trait PrivateMatchMethods: TElement {
cascade_visited: CascadeVisitedMode, cascade_visited: CascadeVisitedMode,
cascade_inputs: &mut ElementCascadeInputs, cascade_inputs: &mut ElementCascadeInputs,
) -> bool { ) -> bool {
use properties::PropertyDeclarationBlock; use crate::properties::PropertyDeclarationBlock;
use shared_lock::Locked; use crate::shared_lock::Locked;
debug_assert!( debug_assert!(
replacements.intersects(RestyleHint::replacements()) && replacements.intersects(RestyleHint::replacements()) &&
@ -195,9 +195,9 @@ trait PrivateMatchMethods: TElement {
context: &mut StyleContext<Self>, context: &mut StyleContext<Self>,
primary_style: &Arc<ComputedValues>, primary_style: &Arc<ComputedValues>,
) -> Option<Arc<ComputedValues>> { ) -> Option<Arc<ComputedValues>> {
use context::CascadeInputs; use crate::context::CascadeInputs;
use style_resolver::{PseudoElementResolution, StyleResolverForElement}; use crate::style_resolver::{PseudoElementResolution, StyleResolverForElement};
use stylist::RuleInclusion; use crate::stylist::RuleInclusion;
let rule_node = primary_style.rules(); let rule_node = primary_style.rules();
let without_transition_rules = context let without_transition_rules = context
@ -307,7 +307,7 @@ trait PrivateMatchMethods: TElement {
new_values: &ComputedValues, new_values: &ComputedValues,
restyle_hints: RestyleHint, restyle_hints: RestyleHint,
) { ) {
use context::PostAnimationTasks; use crate::context::PostAnimationTasks;
if !restyle_hints.intersects(RestyleHint::RESTYLE_SMIL) { if !restyle_hints.intersects(RestyleHint::RESTYLE_SMIL) {
return; return;
@ -337,7 +337,7 @@ trait PrivateMatchMethods: TElement {
restyle_hint: RestyleHint, restyle_hint: RestyleHint,
important_rules_changed: bool, important_rules_changed: bool,
) { ) {
use context::UpdateAnimationsTasks; use crate::context::UpdateAnimationsTasks;
if context.shared.traversal_flags.for_animation_only() { if context.shared.traversal_flags.for_animation_only() {
self.handle_display_change_for_smil_if_needed( self.handle_display_change_for_smil_if_needed(
@ -419,8 +419,8 @@ trait PrivateMatchMethods: TElement {
_restyle_hint: RestyleHint, _restyle_hint: RestyleHint,
_important_rules_changed: bool, _important_rules_changed: bool,
) { ) {
use animation; use crate::animation;
use dom::TNode; use crate::dom::TNode;
let mut possibly_expired_animations = vec![]; let mut possibly_expired_animations = vec![];
let shared_context = context.shared; let shared_context = context.shared;
@ -538,7 +538,7 @@ trait PrivateMatchMethods: TElement {
// seems not common enough to care about. // seems not common enough to care about.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
{ {
use values::specified::align::AlignFlags; use crate::values::specified::align::AlignFlags;
let old_justify_items = old_values.get_position().clone_justify_items(); let old_justify_items = old_values.get_position().clone_justify_items();
let new_justify_items = new_values.get_position().clone_justify_items(); let new_justify_items = new_values.get_position().clone_justify_items();
@ -583,11 +583,11 @@ trait PrivateMatchMethods: TElement {
&self, &self,
context: &SharedStyleContext, context: &SharedStyleContext,
style: &mut Arc<ComputedValues>, style: &mut Arc<ComputedValues>,
possibly_expired_animations: &mut Vec<::animation::PropertyAnimation>, possibly_expired_animations: &mut Vec<crate::animation::PropertyAnimation>,
font_metrics: &::font_metrics::FontMetricsProvider, font_metrics: &crate::font_metrics::FontMetricsProvider,
) { ) {
use animation::{self, Animation, AnimationUpdate}; use crate::animation::{self, Animation, AnimationUpdate};
use dom::TNode; use crate::dom::TNode;
// Finish any expired transitions. // Finish any expired transitions.
let this_opaque = self.as_node().opaque(); let this_opaque = self.as_node().opaque();

View file

@ -7,9 +7,9 @@
//! https://drafts.csswg.org/mediaqueries-4/#typedef-media-condition //! https://drafts.csswg.org/mediaqueries-4/#typedef-media-condition
use super::{Device, MediaFeatureExpression}; use super::{Device, MediaFeatureExpression};
use context::QuirksMode; use crate::context::QuirksMode;
use crate::parser::ParserContext;
use cssparser::{Parser, Token}; use cssparser::{Parser, Token};
use parser::ParserContext;
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
@ -114,7 +114,7 @@ impl MediaCondition {
// ParenthesisBlock. // ParenthesisBlock.
let first_condition = Self::parse_paren_block(context, input)?; let first_condition = Self::parse_paren_block(context, input)?;
let operator = match input.try(Operator::parse) { let operator = match input.r#try(Operator::parse) {
Ok(op) => op, Ok(op) => op,
Err(..) => return Ok(first_condition), Err(..) => return Ok(first_condition),
}; };
@ -133,7 +133,7 @@ impl MediaCondition {
}; };
loop { loop {
if input.try(|i| i.expect_ident_matching(delim)).is_err() { if input.r#try(|i| i.expect_ident_matching(delim)).is_err() {
return Ok(MediaCondition::Operation( return Ok(MediaCondition::Operation(
conditions.into_boxed_slice(), conditions.into_boxed_slice(),
operator, operator,
@ -159,7 +159,7 @@ impl MediaCondition {
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
input.parse_nested_block(|input| { input.parse_nested_block(|input| {
// Base case. // Base case.
if let Ok(inner) = input.try(|i| Self::parse(context, i)) { if let Ok(inner) = input.r#try(|i| Self::parse(context, i)) {
return Ok(MediaCondition::InParens(Box::new(inner))); return Ok(MediaCondition::InParens(Box::new(inner)));
} }
let expr = MediaFeatureExpression::parse_in_parenthesis_block(context, input)?; let expr = MediaFeatureExpression::parse_in_parenthesis_block(context, input)?;

View file

@ -6,12 +6,12 @@
use super::media_feature_expression::{AspectRatio, RangeOrOperator}; use super::media_feature_expression::{AspectRatio, RangeOrOperator};
use super::Device; use super::Device;
use crate::parser::ParserContext;
use crate::values::computed::{CSSPixelLength, Resolution};
use crate::Atom;
use cssparser::Parser; use cssparser::Parser;
use parser::ParserContext;
use std::fmt; use std::fmt;
use style_traits::ParseError; use style_traits::ParseError;
use values::computed::{CSSPixelLength, Resolution};
use Atom;
/// A generic discriminant for an enum value. /// A generic discriminant for an enum value.
pub type KeywordDiscriminant = u8; pub type KeywordDiscriminant = u8;

View file

@ -8,21 +8,21 @@
use super::media_feature::{Evaluator, MediaFeatureDescription}; use super::media_feature::{Evaluator, MediaFeatureDescription};
use super::media_feature::{KeywordDiscriminant, ParsingRequirements}; use super::media_feature::{KeywordDiscriminant, ParsingRequirements};
use super::Device; use super::Device;
use context::QuirksMode; use crate::context::QuirksMode;
use cssparser::{Parser, Token};
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use gecko_bindings::structs; use crate::gecko_bindings::structs;
use crate::parser::{Parse, ParserContext};
use crate::str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase};
use crate::stylesheets::Origin;
use crate::values::computed::{self, ToComputedValue};
use crate::values::specified::{Integer, Length, Number, Resolution};
use crate::values::{serialize_atom_identifier, CSSFloat};
use crate::Atom;
use cssparser::{Parser, Token};
use num_traits::Zero; use num_traits::Zero;
use parser::{Parse, ParserContext};
use std::cmp::{Ordering, PartialOrd}; use std::cmp::{Ordering, PartialOrd};
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase};
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
use stylesheets::Origin;
use values::computed::{self, ToComputedValue};
use values::specified::{Integer, Length, Number, Resolution};
use values::{serialize_atom_identifier, CSSFloat};
use Atom;
/// An aspect ratio, with a numerator and denominator. /// An aspect ratio, with a numerator and denominator.
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq)] #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq)]
@ -221,14 +221,14 @@ fn consume_operation_or_colon(input: &mut Parser) -> Result<Option<Operator>, ()
Ok(Some(match first_delim { Ok(Some(match first_delim {
'=' => Operator::Equal, '=' => Operator::Equal,
'>' => { '>' => {
if input.try(|i| i.expect_delim('=')).is_ok() { if input.r#try(|i| i.expect_delim('=')).is_ok() {
Operator::GreaterThanEqual Operator::GreaterThanEqual
} else { } else {
Operator::GreaterThan Operator::GreaterThan
} }
}, },
'<' => { '<' => {
if input.try(|i| i.expect_delim('=')).is_ok() { if input.r#try(|i| i.expect_delim('=')).is_ok() {
Operator::LessThanEqual Operator::LessThanEqual
} else { } else {
Operator::LessThan Operator::LessThan
@ -271,9 +271,9 @@ impl MediaFeatureExpression {
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use gecko::media_features::MEDIA_FEATURES; use crate::gecko::media_features::MEDIA_FEATURES;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
use servo::media_queries::MEDIA_FEATURES; use crate::servo::media_queries::MEDIA_FEATURES;
// FIXME: remove extra indented block when lifetimes are non-lexical // FIXME: remove extra indented block when lifetimes are non-lexical
let feature; let feature;
@ -350,7 +350,7 @@ impl MediaFeatureExpression {
} }
} }
let operator = input.try(consume_operation_or_colon); let operator = input.r#try(consume_operation_or_colon);
let operator = match operator { let operator = match operator {
Err(..) => { Err(..) => {
// If there's no colon, this is a media query of the // If there's no colon, this is a media query of the

View file

@ -7,11 +7,11 @@
//! https://drafts.csswg.org/mediaqueries/#typedef-media-query-list //! https://drafts.csswg.org/mediaqueries/#typedef-media-query-list
use super::{Device, MediaQuery, Qualifier}; use super::{Device, MediaQuery, Qualifier};
use context::QuirksMode; use crate::context::QuirksMode;
use crate::error_reporting::ContextualParseError;
use crate::parser::ParserContext;
use cssparser::{Delimiter, Parser}; use cssparser::{Delimiter, Parser};
use cssparser::{ParserInput, Token}; use cssparser::{ParserInput, Token};
use error_reporting::ContextualParseError;
use parser::ParserContext;
/// A type that encapsulates a media query list. /// A type that encapsulates a media query list.
#[css(comma, derive_debug)] #[css(comma, derive_debug)]

View file

@ -7,13 +7,13 @@
//! https://drafts.csswg.org/mediaqueries/#typedef-media-query //! https://drafts.csswg.org/mediaqueries/#typedef-media-query
use super::media_condition::MediaCondition; use super::media_condition::MediaCondition;
use crate::parser::ParserContext;
use crate::str::string_as_ascii_lowercase;
use crate::values::CustomIdent;
use crate::Atom;
use cssparser::Parser; use cssparser::Parser;
use parser::ParserContext;
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use str::string_as_ascii_lowercase;
use style_traits::{CssWriter, ParseError, ToCss}; use style_traits::{CssWriter, ParseError, ToCss};
use values::CustomIdent;
use Atom;
/// <https://drafts.csswg.org/mediaqueries/#mq-prefix> /// <https://drafts.csswg.org/mediaqueries/#mq-prefix>
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)] #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)]
@ -125,8 +125,8 @@ impl MediaQuery {
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
let (qualifier, explicit_media_type) = input let (qualifier, explicit_media_type) = input
.try(|input| -> Result<_, ()> { .r#try(|input| -> Result<_, ()> {
let qualifier = input.try(Qualifier::parse).ok(); let qualifier = input.r#try(Qualifier::parse).ok();
let ident = input.expect_ident().map_err(|_| ())?; let ident = input.expect_ident().map_err(|_| ())?;
let media_type = MediaQueryType::parse(&ident)?; let media_type = MediaQueryType::parse(&ident)?;
Ok((qualifier, Some(media_type))) Ok((qualifier, Some(media_type)))
@ -135,7 +135,7 @@ impl MediaQuery {
let condition = if explicit_media_type.is_none() { let condition = if explicit_media_type.is_none() {
Some(MediaCondition::parse(context, input)?) Some(MediaCondition::parse(context, input)?)
} else if input.try(|i| i.expect_ident_matching("and")).is_ok() { } else if input.r#try(|i| i.expect_ident_matching("and")).is_ok() {
Some(MediaCondition::parse_disallow_or(context, input)?) Some(MediaCondition::parse_disallow_or(context, input)?)
} else { } else {
None None

View file

@ -19,6 +19,6 @@ pub use self::media_list::MediaList;
pub use self::media_query::{MediaQuery, MediaQueryType, MediaType, Qualifier}; pub use self::media_query::{MediaQuery, MediaQueryType, MediaType, Qualifier};
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use gecko::media_queries::Device; pub use crate::gecko::media_queries::Device;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
pub use servo::media_queries::Device; pub use crate::servo::media_queries::Device;

View file

@ -23,13 +23,13 @@
#![deny(missing_docs)] #![deny(missing_docs)]
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
use context::{StyleContext, ThreadLocalStyleContext}; use crate::context::{StyleContext, ThreadLocalStyleContext};
use dom::{OpaqueNode, SendNode, TElement}; use crate::dom::{OpaqueNode, SendNode, TElement};
use crate::scoped_tls::ScopedTLS;
use crate::traversal::{DomTraversal, PerLevelTraversalData};
use itertools::Itertools; use itertools::Itertools;
use rayon; use rayon;
use scoped_tls::ScopedTLS;
use smallvec::SmallVec; use smallvec::SmallVec;
use traversal::{DomTraversal, PerLevelTraversalData};
/// The minimum stack size for a thread in the styling pool, in kilobytes. /// The minimum stack size for a thread in the styling pool, in kilobytes.
pub const STYLE_THREAD_STACK_SIZE_KB: usize = 256; pub const STYLE_THREAD_STACK_SIZE_KB: usize = 256;

View file

@ -4,18 +4,18 @@
//! The context within which CSS code is parsed. //! The context within which CSS code is parsed.
use context::QuirksMode; use crate::context::QuirksMode;
use crate::error_reporting::{ContextualParseError, ParseErrorReporter};
use crate::stylesheets::{CssRuleType, Namespaces, Origin, UrlExtraData};
use crate::use_counters::UseCounters;
use cssparser::{Parser, SourceLocation, UnicodeRange}; use cssparser::{Parser, SourceLocation, UnicodeRange};
use error_reporting::{ContextualParseError, ParseErrorReporter};
use style_traits::{OneOrMoreSeparated, ParseError, ParsingMode, Separator}; use style_traits::{OneOrMoreSeparated, ParseError, ParsingMode, Separator};
use stylesheets::{CssRuleType, Namespaces, Origin, UrlExtraData};
use use_counters::UseCounters;
/// Asserts that all ParsingMode flags have a matching ParsingMode value in gecko. /// Asserts that all ParsingMode flags have a matching ParsingMode value in gecko.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
#[inline] #[inline]
pub fn assert_parsing_mode_match() { pub fn assert_parsing_mode_match() {
use gecko_bindings::structs; use crate::gecko_bindings::structs;
macro_rules! check_parsing_modes { macro_rules! check_parsing_modes {
( $( $a:ident => $b:path ),*, ) => { ( $( $a:ident => $b:path ),*, ) => {

View file

@ -4,27 +4,27 @@
//! The main cascading algorithm of the style system. //! The main cascading algorithm of the style system.
use context::QuirksMode; use crate::context::QuirksMode;
use custom_properties::CustomPropertiesBuilder; use crate::custom_properties::CustomPropertiesBuilder;
use dom::TElement; use crate::dom::TElement;
use font_metrics::FontMetricsProvider; use crate::font_metrics::FontMetricsProvider;
use logical_geometry::WritingMode; use crate::logical_geometry::WritingMode;
use media_queries::Device; use crate::media_queries::Device;
use properties::{ComputedValues, StyleBuilder}; use crate::properties::{ComputedValues, StyleBuilder};
use properties::{LonghandId, LonghandIdSet}; use crate::properties::{LonghandId, LonghandIdSet};
use properties::{PropertyDeclaration, PropertyDeclarationId, DeclarationImportanceIterator}; use crate::properties::{PropertyDeclaration, PropertyDeclarationId, DeclarationImportanceIterator};
use properties::CASCADE_PROPERTY; use crate::properties::CASCADE_PROPERTY;
use rule_cache::{RuleCache, RuleCacheConditions}; use crate::rule_cache::{RuleCache, RuleCacheConditions};
use rule_tree::{CascadeLevel, StrongRuleNode}; use crate::rule_tree::{CascadeLevel, StrongRuleNode};
use selector_parser::PseudoElement; use crate::selector_parser::PseudoElement;
use servo_arc::Arc; use servo_arc::Arc;
use shared_lock::StylesheetGuards; use crate::shared_lock::StylesheetGuards;
use smallbitvec::SmallBitVec; use smallbitvec::SmallBitVec;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::borrow::Cow; use std::borrow::Cow;
use std::cell::RefCell; use std::cell::RefCell;
use style_adjuster::StyleAdjuster; use crate::style_adjuster::StyleAdjuster;
use values::computed; use crate::values::computed;
/// We split the cascade in two phases: 'early' properties, and 'late' /// We split the cascade in two phases: 'early' properties, and 'late'
/// properties. /// properties.
@ -745,7 +745,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
let gecko_font = self.context.builder.mutate_font().gecko_mut(); let gecko_font = self.context.builder.mutate_font().gecko_mut();
gecko_font.mGenericID = generic; gecko_font.mGenericID = generic;
unsafe { unsafe {
::gecko_bindings::bindings::Gecko_nsStyleFont_PrefillDefaultForGeneric( crate::gecko_bindings::bindings::Gecko_nsStyleFont_PrefillDefaultForGeneric(
gecko_font, gecko_font,
pres_context, pres_context,
generic, generic,
@ -796,7 +796,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
self.seen.contains(LonghandId::MozMinFontSizeRatio) || self.seen.contains(LonghandId::MozMinFontSizeRatio) ||
self.seen.contains(LonghandId::FontFamily) self.seen.contains(LonghandId::FontFamily)
{ {
use properties::{CSSWideKeyword, WideKeywordDeclaration}; use crate::properties::{CSSWideKeyword, WideKeywordDeclaration};
// font-size must be explicitly inherited to handle lang // font-size must be explicitly inherited to handle lang
// changes and scriptlevel changes. // changes and scriptlevel changes.

View file

@ -270,12 +270,12 @@ class Longhand(object):
def base_type(self): def base_type(self):
if self.predefined_type and not self.is_vector: if self.predefined_type and not self.is_vector:
return "::values::specified::{}".format(self.predefined_type) return "crate::values::specified::{}".format(self.predefined_type)
return "longhands::{}::SpecifiedValue".format(self.ident) return "longhands::{}::SpecifiedValue".format(self.ident)
def specified_type(self): def specified_type(self):
if self.predefined_type and not self.is_vector: if self.predefined_type and not self.is_vector:
ty = "::values::specified::{}".format(self.predefined_type) ty = "crate::values::specified::{}".format(self.predefined_type)
else: else:
ty = "longhands::{}::SpecifiedValue".format(self.ident) ty = "longhands::{}::SpecifiedValue".format(self.ident)
if self.boxed: if self.boxed:

View file

@ -6,25 +6,25 @@
#![deny(missing_docs)] #![deny(missing_docs)]
use context::QuirksMode; use crate::context::QuirksMode;
use cssparser::{DeclarationListParser, parse_important, ParserInput, CowRcStr}; use cssparser::{DeclarationListParser, parse_important, ParserInput, CowRcStr};
use cssparser::{Parser, AtRuleParser, DeclarationParser, Delimiter, ParseErrorKind}; use cssparser::{Parser, AtRuleParser, DeclarationParser, Delimiter, ParseErrorKind};
use custom_properties::{CustomPropertiesBuilder, CssEnvironment}; use crate::custom_properties::{CustomPropertiesBuilder, CssEnvironment};
use error_reporting::{ParseErrorReporter, ContextualParseError}; use crate::error_reporting::{ParseErrorReporter, ContextualParseError};
use itertools::Itertools; use itertools::Itertools;
use parser::ParserContext; use crate::parser::ParserContext;
use properties::animated_properties::{AnimationValue, AnimationValueMap}; use crate::properties::animated_properties::{AnimationValue, AnimationValueMap};
use shared_lock::Locked; use crate::shared_lock::Locked;
use smallbitvec::{self, SmallBitVec}; use smallbitvec::{self, SmallBitVec};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use std::iter::{DoubleEndedIterator, Zip}; use std::iter::{DoubleEndedIterator, Zip};
use std::slice::Iter; use std::slice::Iter;
use str::{CssString, CssStringBorrow, CssStringWriter}; use crate::str::{CssString, CssStringBorrow, CssStringWriter};
use style_traits::{CssWriter, ParseError, ParsingMode, StyleParseErrorKind, ToCss}; use style_traits::{CssWriter, ParseError, ParsingMode, StyleParseErrorKind, ToCss};
use stylesheets::{CssRuleType, Origin, UrlExtraData}; use crate::stylesheets::{CssRuleType, Origin, UrlExtraData};
use super::*; use super::*;
use values::computed::Context; use crate::values::computed::Context;
/// The animation rules. /// The animation rules.
/// ///
@ -144,7 +144,7 @@ pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> {
context: &'cx mut Context<'cx_a>, context: &'cx mut Context<'cx_a>,
default_values: &'a ComputedValues, default_values: &'a ComputedValues,
/// Custom properties in a keyframe if exists. /// Custom properties in a keyframe if exists.
extra_custom_properties: Option<&'a Arc<::custom_properties::CustomPropertiesMap>>, extra_custom_properties: Option<&'a Arc<crate::custom_properties::CustomPropertiesMap>>,
} }
impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> { impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> {
@ -152,7 +152,7 @@ impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> {
declarations: &'a PropertyDeclarationBlock, declarations: &'a PropertyDeclarationBlock,
context: &'cx mut Context<'cx_a>, context: &'cx mut Context<'cx_a>,
default_values: &'a ComputedValues, default_values: &'a ComputedValues,
extra_custom_properties: Option<&'a Arc<::custom_properties::CustomPropertiesMap>>, extra_custom_properties: Option<&'a Arc<crate::custom_properties::CustomPropertiesMap>>,
) -> AnimationValueIterator<'a, 'cx, 'cx_a> { ) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
AnimationValueIterator { AnimationValueIterator {
iter: declarations.declaration_importance_iter(), iter: declarations.declaration_importance_iter(),
@ -258,7 +258,7 @@ impl PropertyDeclarationBlock {
&'a self, &'a self,
context: &'cx mut Context<'cx_a>, context: &'cx mut Context<'cx_a>,
default_values: &'a ComputedValues, default_values: &'a ComputedValues,
extra_custom_properties: Option<&'a Arc<::custom_properties::CustomPropertiesMap>>, extra_custom_properties: Option<&'a Arc<crate::custom_properties::CustomPropertiesMap>>,
) -> AnimationValueIterator<'a, 'cx, 'cx_a> { ) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
AnimationValueIterator::new(self, context, default_values, extra_custom_properties) AnimationValueIterator::new(self, context, default_values, extra_custom_properties)
} }
@ -467,7 +467,7 @@ impl PropertyDeclarationBlock {
// //
// TODO(emilio): Unship. // TODO(emilio): Unship.
if let PropertyDeclaration::Display(old_display) = *slot { if let PropertyDeclaration::Display(old_display) = *slot {
use properties::longhands::display::computed_value::T as display; use crate::properties::longhands::display::computed_value::T as display;
if let PropertyDeclaration::Display(new_display) = declaration { if let PropertyDeclaration::Display(new_display) = declaration {
if display::should_ignore_parsed_value(old_display, new_display) { if display::should_ignore_parsed_value(old_display, new_display) {
@ -841,7 +841,7 @@ impl PropertyDeclarationBlock {
pub fn cascade_custom_properties_with_context( pub fn cascade_custom_properties_with_context(
&self, &self,
context: &Context, context: &Context,
) -> Option<Arc<::custom_properties::CustomPropertiesMap>> { ) -> Option<Arc<crate::custom_properties::CustomPropertiesMap>> {
self.cascade_custom_properties( self.cascade_custom_properties(
context.style().custom_properties(), context.style().custom_properties(),
context.device().environment(), context.device().environment(),
@ -853,9 +853,9 @@ impl PropertyDeclarationBlock {
/// properties. /// properties.
fn cascade_custom_properties( fn cascade_custom_properties(
&self, &self,
inherited_custom_properties: Option<&Arc<::custom_properties::CustomPropertiesMap>>, inherited_custom_properties: Option<&Arc<crate::custom_properties::CustomPropertiesMap>>,
environment: &CssEnvironment, environment: &CssEnvironment,
) -> Option<Arc<::custom_properties::CustomPropertiesMap>> { ) -> Option<Arc<crate::custom_properties::CustomPropertiesMap>> {
let mut builder = CustomPropertiesBuilder::new( let mut builder = CustomPropertiesBuilder::new(
inherited_custom_properties, inherited_custom_properties,
environment, environment,

File diff suppressed because it is too large Load diff

View file

@ -17,15 +17,15 @@
#[allow(unused_imports)] #[allow(unused_imports)]
use cssparser::{Color as CSSParserColor, RGBA}; use cssparser::{Color as CSSParserColor, RGBA};
#[allow(unused_imports)] #[allow(unused_imports)]
use values::specified::AllowQuirks; use crate::values::specified::AllowQuirks;
#[allow(unused_imports)] #[allow(unused_imports)]
use smallvec::SmallVec; use smallvec::SmallVec;
pub use values::specified::${type} as SpecifiedValue; pub use crate::values::specified::${type} as SpecifiedValue;
pub mod computed_value { pub mod computed_value {
% if computed_type: % if computed_type:
pub use ${computed_type} as T; pub use ${computed_type} as T;
% else: % else:
pub use values::computed::${type} as T; pub use crate::values::computed::${type} as T;
% endif % endif
} }
% if initial_value: % if initial_value:
@ -91,19 +91,19 @@
#[allow(unused_imports)] #[allow(unused_imports)]
use cssparser::{Parser, BasicParseError}; use cssparser::{Parser, BasicParseError};
#[allow(unused_imports)] #[allow(unused_imports)]
use parser::{Parse, ParserContext}; use crate::parser::{Parse, ParserContext};
#[allow(unused_imports)] #[allow(unused_imports)]
use properties::ShorthandId; use crate::properties::ShorthandId;
#[allow(unused_imports)] #[allow(unused_imports)]
use selectors::parser::SelectorParseErrorKind; use selectors::parser::SelectorParseErrorKind;
#[allow(unused_imports)] #[allow(unused_imports)]
use style_traits::{ParseError, StyleParseErrorKind}; use style_traits::{ParseError, StyleParseErrorKind};
#[allow(unused_imports)] #[allow(unused_imports)]
use values::computed::{Context, ToComputedValue}; use crate::values::computed::{Context, ToComputedValue};
#[allow(unused_imports)] #[allow(unused_imports)]
use values::{computed, specified}; use crate::values::{computed, specified};
#[allow(unused_imports)] #[allow(unused_imports)]
use values::{Auto, Either, None_, Normal}; use crate::values::{Auto, Either, None_, Normal};
${caller.body()} ${caller.body()}
} }
@ -116,7 +116,7 @@
% else: % else:
use smallvec::{IntoIter, SmallVec}; use smallvec::{IntoIter, SmallVec};
% endif % endif
use values::computed::ComputedVecIter; use crate::values::computed::ComputedVecIter;
/// The generic type defining the value for this property. /// The generic type defining the value for this property.
/// ///
@ -148,9 +148,9 @@
Sorry, this is stupid but needed for now. Sorry, this is stupid but needed for now.
% endif % endif
use properties::animated_properties::ListAnimation; use crate::properties::animated_properties::ListAnimation;
use values::animated::{Animate, ToAnimatedValue, ToAnimatedZero, Procedure}; use crate::values::animated::{Animate, ToAnimatedValue, ToAnimatedZero, Procedure};
use values::distance::{SquaredDistance, ComputeSquaredDistance}; use crate::values::distance::{SquaredDistance, ComputeSquaredDistance};
// FIXME(emilio): For some reason rust thinks that this alias is // FIXME(emilio): For some reason rust thinks that this alias is
// unused, even though it's clearly used below? // unused, even though it's clearly used below?
@ -235,7 +235,7 @@
} }
% endif % endif
::style_traits::${separator}::parse(input, |parser| { style_traits::${separator}::parse(input, |parser| {
single_value::parse(context, parser) single_value::parse(context, parser)
}).map(SpecifiedValue) }).map(SpecifiedValue)
} }
@ -279,21 +279,21 @@
#[allow(unused_imports)] #[allow(unused_imports)]
use cssparser::{Parser, BasicParseError, Token}; use cssparser::{Parser, BasicParseError, Token};
#[allow(unused_imports)] #[allow(unused_imports)]
use parser::{Parse, ParserContext}; use crate::parser::{Parse, ParserContext};
#[allow(unused_imports)] #[allow(unused_imports)]
use properties::{UnparsedValue, ShorthandId}; use crate::properties::{UnparsedValue, ShorthandId};
#[allow(unused_imports)] #[allow(unused_imports)]
use values::{Auto, Either, None_, Normal}; use crate::values::{Auto, Either, None_, Normal};
#[allow(unused_imports)] #[allow(unused_imports)]
use error_reporting::ParseErrorReporter; use crate::error_reporting::ParseErrorReporter;
#[allow(unused_imports)] #[allow(unused_imports)]
use properties::longhands; use crate::properties::longhands;
#[allow(unused_imports)] #[allow(unused_imports)]
use properties::{LonghandId, LonghandIdSet}; use crate::properties::{LonghandId, LonghandIdSet};
#[allow(unused_imports)] #[allow(unused_imports)]
use properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration}; use crate::properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration};
#[allow(unused_imports)] #[allow(unused_imports)]
use properties::style_structs; use crate::properties::style_structs;
#[allow(unused_imports)] #[allow(unused_imports)]
use selectors::parser::SelectorParseErrorKind; use selectors::parser::SelectorParseErrorKind;
#[allow(unused_imports)] #[allow(unused_imports)]
@ -301,11 +301,11 @@
#[allow(unused_imports)] #[allow(unused_imports)]
use style_traits::{ParseError, StyleParseErrorKind}; use style_traits::{ParseError, StyleParseErrorKind};
#[allow(unused_imports)] #[allow(unused_imports)]
use values::computed::{Context, ToComputedValue}; use crate::values::computed::{Context, ToComputedValue};
#[allow(unused_imports)] #[allow(unused_imports)]
use values::{computed, generics, specified}; use crate::values::{computed, generics, specified};
#[allow(unused_imports)] #[allow(unused_imports)]
use Atom; use crate::Atom;
${caller.body()} ${caller.body()}
#[allow(unused_variables)] #[allow(unused_variables)]
pub fn cascade_property( pub fn cascade_property(
@ -428,7 +428,7 @@
keyword = keyword=Keyword(name, values, **keyword_kwargs) keyword = keyword=Keyword(name, values, **keyword_kwargs)
%> %>
<%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)"> <%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)">
use properties::longhands::system_font::SystemFont; use crate::properties::longhands::system_font::SystemFont;
pub mod computed_value { pub mod computed_value {
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
@ -511,7 +511,7 @@
/// ///
/// Intended for use with presentation attributes, not style structs /// Intended for use with presentation attributes, not style structs
pub fn from_gecko_keyword(kw: u32) -> Self { pub fn from_gecko_keyword(kw: u32) -> Self {
use gecko_bindings::structs; use crate::gecko_bindings::structs;
% for value in values: % for value in values:
// We can't match on enum values if we're matching on a u32 // We can't match on enum values if we're matching on a u32
const ${to_rust_ident(value).upper()}: ${const_type} const ${to_rust_ident(value).upper()}: ${const_type}
@ -535,7 +535,7 @@
/// Intended for use with presentation attributes, not style structs /// Intended for use with presentation attributes, not style structs
pub fn from_gecko_keyword(kw: ${kw_type}) -> Self { pub fn from_gecko_keyword(kw: ${kw_type}) -> Self {
% for gecko_bit in bit_map.values(): % for gecko_bit in bit_map.values():
use gecko_bindings::structs::${gecko_bit_prefix}${gecko_bit}; use crate::gecko_bindings::structs::${gecko_bit_prefix}${gecko_bit};
% endfor % endfor
let mut bits = ${type}::empty(); let mut bits = ${type}::empty();
@ -549,7 +549,7 @@
pub fn to_gecko_keyword(self) -> ${kw_type} { pub fn to_gecko_keyword(self) -> ${kw_type} {
% for gecko_bit in bit_map.values(): % for gecko_bit in bit_map.values():
use gecko_bindings::structs::${gecko_bit_prefix}${gecko_bit}; use crate::gecko_bindings::structs::${gecko_bit_prefix}${gecko_bit};
% endfor % endfor
let mut bits: ${kw_type} = 0; let mut bits: ${kw_type} = 0;
@ -668,8 +668,8 @@
/// ${shorthand.spec} /// ${shorthand.spec}
pub mod ${shorthand.ident} { pub mod ${shorthand.ident} {
use cssparser::Parser; use cssparser::Parser;
use parser::ParserContext; use crate::parser::ParserContext;
use properties::{PropertyDeclaration, SourcePropertyDeclaration, MaybeBoxed, longhands}; use crate::properties::{PropertyDeclaration, SourcePropertyDeclaration, MaybeBoxed, longhands};
#[allow(unused_imports)] #[allow(unused_imports)]
use selectors::parser::SelectorParseErrorKind; use selectors::parser::SelectorParseErrorKind;
#[allow(unused_imports)] #[allow(unused_imports)]
@ -772,7 +772,7 @@
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<(), ParseError<'i>> { ) -> Result<(), ParseError<'i>> {
#[allow(unused_imports)] #[allow(unused_imports)]
use properties::{NonCustomPropertyId, LonghandId}; use crate::properties::{NonCustomPropertyId, LonghandId};
input.parse_entirely(|input| parse_value(context, input)).map(|longhands| { input.parse_entirely(|input| parse_value(context, input)).map(|longhands| {
% for sub_property in shorthand.sub_properties: % for sub_property in shorthand.sub_properties:
% if sub_property.may_be_disabled_in(shorthand, product): % if sub_property.may_be_disabled_in(shorthand, product):
@ -798,9 +798,9 @@
<% sub_properties=' '.join(sub_property_pattern % side for side in PHYSICAL_SIDES) %> <% sub_properties=' '.join(sub_property_pattern % side for side in PHYSICAL_SIDES) %>
<%call expr="self.shorthand(name, sub_properties=sub_properties, **kwargs)"> <%call expr="self.shorthand(name, sub_properties=sub_properties, **kwargs)">
#[allow(unused_imports)] #[allow(unused_imports)]
use parser::Parse; use crate::parser::Parse;
use values::generics::rect::Rect; use crate::values::generics::rect::Rect;
use values::specified; use crate::values::specified;
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
context: &ParserContext, context: &ParserContext,
@ -852,7 +852,7 @@
return to_rust_ident(name.replace(side, phy_side).replace("inset-", "")) return to_rust_ident(name.replace(side, phy_side).replace("inset-", ""))
%> %>
% if side is not None: % if side is not None:
use logical_geometry::PhysicalSide; use crate::logical_geometry::PhysicalSide;
match wm.${to_rust_ident(side)}_physical_side() { match wm.${to_rust_ident(side)}_physical_side() {
% for phy_side in PHYSICAL_SIDES: % for phy_side in PHYSICAL_SIDES:
PhysicalSide::${phy_side.title()} => { PhysicalSide::${phy_side.title()} => {

View file

@ -9,40 +9,40 @@
from itertools import groupby from itertools import groupby
%> %>
#[cfg(feature = "gecko")] use gecko_bindings::structs::RawServoAnimationValueMap; #[cfg(feature = "gecko")] use crate::gecko_bindings::structs::RawServoAnimationValueMap;
#[cfg(feature = "gecko")] use gecko_bindings::structs::RawGeckoGfxMatrix4x4; #[cfg(feature = "gecko")] use crate::gecko_bindings::structs::RawGeckoGfxMatrix4x4;
#[cfg(feature = "gecko")] use gecko_bindings::structs::nsCSSPropertyID; #[cfg(feature = "gecko")] use crate::gecko_bindings::structs::nsCSSPropertyID;
#[cfg(feature = "gecko")] use gecko_bindings::sugar::ownership::{HasFFI, HasSimpleFFI}; #[cfg(feature = "gecko")] use crate::gecko_bindings::sugar::ownership::{HasFFI, HasSimpleFFI};
use itertools::{EitherOrBoth, Itertools}; use itertools::{EitherOrBoth, Itertools};
use num_traits::Zero; use num_traits::Zero;
use properties::{CSSWideKeyword, PropertyDeclaration}; use crate::properties::{CSSWideKeyword, PropertyDeclaration};
use properties::longhands; use crate::properties::longhands;
use properties::longhands::visibility::computed_value::T as Visibility; use crate::properties::longhands::visibility::computed_value::T as Visibility;
use properties::LonghandId; use crate::properties::LonghandId;
use servo_arc::Arc; use servo_arc::Arc;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::{cmp, ptr}; use std::{cmp, ptr};
use std::mem::{self, ManuallyDrop}; use std::mem::{self, ManuallyDrop};
use hash::FxHashMap; use crate::hash::FxHashMap;
use super::ComputedValues; use super::ComputedValues;
use values::CSSFloat; use crate::values::CSSFloat;
use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero}; use crate::values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
use values::animated::effects::Filter as AnimatedFilter; use crate::values::animated::effects::Filter as AnimatedFilter;
#[cfg(feature = "gecko")] use values::computed::TransitionProperty; #[cfg(feature = "gecko")] use crate::values::computed::TransitionProperty;
use values::computed::Angle; use crate::values::computed::Angle;
use values::computed::{ClipRect, Context}; use crate::values::computed::{ClipRect, Context};
use values::computed::{Length, LengthOrPercentage}; use crate::values::computed::{Length, LengthOrPercentage};
use values::computed::{Number, Percentage}; use crate::values::computed::{Number, Percentage};
use values::computed::ToComputedValue; use crate::values::computed::ToComputedValue;
use values::computed::transform::{DirectionVector, Matrix, Matrix3D}; use crate::values::computed::transform::{DirectionVector, Matrix, Matrix3D};
use values::computed::transform::TransformOperation as ComputedTransformOperation; use crate::values::computed::transform::TransformOperation as ComputedTransformOperation;
use values::computed::transform::Transform as ComputedTransform; use crate::values::computed::transform::Transform as ComputedTransform;
use values::computed::transform::Rotate as ComputedRotate; use crate::values::computed::transform::Rotate as ComputedRotate;
use values::computed::transform::Translate as ComputedTranslate; use crate::values::computed::transform::Translate as ComputedTranslate;
use values::computed::transform::Scale as ComputedScale; use crate::values::computed::transform::Scale as ComputedScale;
use values::generics::transform::{self, Rotate, Translate, Scale, Transform, TransformOperation}; use crate::values::generics::transform::{self, Rotate, Translate, Scale, Transform, TransformOperation};
use values::distance::{ComputeSquaredDistance, SquaredDistance}; use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
use values::generics::effects::Filter; use crate::values::generics::effects::Filter;
use void::{self, Void}; use void::{self, Void};
/// Convert nsCSSPropertyID to TransitionProperty /// Convert nsCSSPropertyID to TransitionProperty
@ -357,7 +357,7 @@ impl AnimationValue {
/// "Uncompute" this animation value in order to be used inside the CSS /// "Uncompute" this animation value in order to be used inside the CSS
/// cascade. /// cascade.
pub fn uncompute(&self) -> PropertyDeclaration { pub fn uncompute(&self) -> PropertyDeclaration {
use properties::longhands; use crate::properties::longhands;
use self::AnimationValue::*; use self::AnimationValue::*;
use super::PropertyDeclarationVariantRepr; use super::PropertyDeclarationVariantRepr;
@ -401,7 +401,7 @@ impl AnimationValue {
pub fn from_declaration( pub fn from_declaration(
decl: &PropertyDeclaration, decl: &PropertyDeclaration,
context: &mut Context, context: &mut Context,
extra_custom_properties: Option<<&Arc<::custom_properties::CustomPropertiesMap>>, extra_custom_properties: Option<<&Arc<crate::custom_properties::CustomPropertiesMap>>,
initial: &ComputedValues initial: &ComputedValues
) -> Option<Self> { ) -> Option<Self> {
use super::PropertyDeclarationVariantRepr; use super::PropertyDeclarationVariantRepr;
@ -815,7 +815,7 @@ impl ToAnimatedZero for Visibility {
impl Animate for ClipRect { impl Animate for ClipRect {
#[inline] #[inline]
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> { fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
use values::computed::Length; use crate::values::computed::Length;
let animate_component = |this: &Option<Length>, other: &Option<Length>| { let animate_component = |this: &Option<Length>, other: &Option<Length>| {
match (this.animate(other, procedure)?, procedure) { match (this.animate(other, procedure)?, procedure) {
(None, Procedure::Interpolate { .. }) => Ok(None), (None, Procedure::Interpolate { .. }) => Ok(None),
@ -1070,8 +1070,8 @@ impl Animate for ComputedTransformOperation {
&TransformOperation::Perspective(ref fd), &TransformOperation::Perspective(ref fd),
&TransformOperation::Perspective(ref td), &TransformOperation::Perspective(ref td),
) => { ) => {
use values::computed::CSSPixelLength; use crate::values::computed::CSSPixelLength;
use values::generics::transform::create_perspective_matrix; use crate::values::generics::transform::create_perspective_matrix;
// From https://drafts.csswg.org/css-transforms-2/#interpolation-of-transform-functions: // From https://drafts.csswg.org/css-transforms-2/#interpolation-of-transform-functions:
// //
@ -1246,7 +1246,7 @@ impl ComputeSquaredDistance for MatrixDecomposed2D {
#[inline] #[inline]
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> { fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
// Use Radian to compute the distance. // Use Radian to compute the distance.
const RAD_PER_DEG: f64 = ::std::f64::consts::PI / 180.0; const RAD_PER_DEG: f64 = std::f64::consts::PI / 180.0;
let angle1 = self.angle as f64 * RAD_PER_DEG; let angle1 = self.angle as f64 * RAD_PER_DEG;
let angle2 = other.angle as f64 * RAD_PER_DEG; let angle2 = other.angle as f64 * RAD_PER_DEG;
Ok(self.translate.compute_squared_distance(&other.translate)? + Ok(self.translate.compute_squared_distance(&other.translate)? +

View file

@ -48,8 +48,8 @@
${helpers.predefined_type( ${helpers.predefined_type(
"border-%s-width" % side_name, "border-%s-width" % side_name,
"BorderSideWidth", "BorderSideWidth",
"::values::computed::NonNegativeLength::new(3.)", "crate::values::computed::NonNegativeLength::new(3.)",
computed_type="::values::computed::NonNegativeLength", computed_type="crate::values::computed::NonNegativeLength",
alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-width"), alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-width"),
spec=maybe_logical_spec(side, "width"), spec=maybe_logical_spec(side, "width"),
animation_value_type="NonNegativeLength", animation_value_type="NonNegativeLength",
@ -64,7 +64,7 @@
${helpers.gecko_keyword_conversion( ${helpers.gecko_keyword_conversion(
Keyword('border-style', Keyword('border-style',
"none solid double dotted dashed hidden groove ridge inset outset"), "none solid double dotted dashed hidden groove ridge inset outset"),
type="::values::specified::BorderStyle", type="crate::values::specified::BorderStyle",
)} )}
// FIXME(#4126): when gfx supports painting it, make this Size2D<LengthOrPercentage> // FIXME(#4126): when gfx supports painting it, make this Size2D<LengthOrPercentage>
@ -160,11 +160,11 @@ ${helpers.predefined_type(
)} )}
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
impl ::values::computed::BorderImageWidth { impl crate::values::computed::BorderImageWidth {
pub fn to_gecko_rect(&self, sides: &mut ::gecko_bindings::structs::nsStyleSides) { pub fn to_gecko_rect(&self, sides: &mut crate::gecko_bindings::structs::nsStyleSides) {
use gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue}; use crate::gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue};
use gecko::values::GeckoStyleCoordConvertible; use crate::gecko::values::GeckoStyleCoordConvertible;
use values::generics::border::BorderImageSideWidth; use crate::values::generics::border::BorderImageSideWidth;
% for i in range(0, 4): % for i in range(0, 4):
match self.${i} { match self.${i} {
@ -182,16 +182,16 @@ impl ::values::computed::BorderImageWidth {
} }
pub fn from_gecko_rect( pub fn from_gecko_rect(
sides: &::gecko_bindings::structs::nsStyleSides, sides: &crate::gecko_bindings::structs::nsStyleSides,
) -> Option<::values::computed::BorderImageWidth> { ) -> Option<crate::values::computed::BorderImageWidth> {
use gecko_bindings::structs::nsStyleUnit::{eStyleUnit_Factor, eStyleUnit_Auto}; use crate::gecko_bindings::structs::nsStyleUnit::{eStyleUnit_Factor, eStyleUnit_Auto};
use gecko_bindings::sugar::ns_style_coord::CoordData; use crate::gecko_bindings::sugar::ns_style_coord::CoordData;
use gecko::values::GeckoStyleCoordConvertible; use crate::gecko::values::GeckoStyleCoordConvertible;
use values::computed::{LengthOrPercentage, Number}; use crate::values::computed::{LengthOrPercentage, Number};
use values::generics::border::BorderImageSideWidth; use crate::values::generics::border::BorderImageSideWidth;
Some( Some(
::values::computed::BorderImageWidth::new( crate::values::computed::BorderImageWidth::new(
% for i in range(0, 4): % for i in range(0, 4):
match sides.data_at(${i}).unit() { match sides.data_at(${i}).unit() {
eStyleUnit_Auto => { eStyleUnit_Auto => {

View file

@ -63,11 +63,11 @@ pub mod system_colors {
IMESelectedConvertedTextBackground IMESelectedConvertedTextForeground IMESelectedConvertedTextBackground IMESelectedConvertedTextForeground
IMESelectedConvertedTextUnderline SpellCheckerUnderline""".split() IMESelectedConvertedTextUnderline SpellCheckerUnderline""".split()
%> %>
use gecko_bindings::bindings::Gecko_GetLookAndFeelSystemColor; use crate::gecko_bindings::bindings::Gecko_GetLookAndFeelSystemColor;
use gecko_bindings::structs::root::mozilla::LookAndFeel_ColorID; use crate::gecko_bindings::structs::root::mozilla::LookAndFeel_ColorID;
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use style_traits::{CssWriter, ToCss}; use style_traits::{CssWriter, ToCss};
use values::computed::{Context, ToComputedValue}; use crate::values::computed::{Context, ToComputedValue};
pub type SystemColor = LookAndFeel_ColorID; pub type SystemColor = LookAndFeel_ColorID;

View file

@ -43,9 +43,9 @@ ${helpers.single_keyword(
${helpers.predefined_type( ${helpers.predefined_type(
"column-rule-width", "column-rule-width",
"BorderSideWidth", "BorderSideWidth",
"::values::computed::NonNegativeLength::new(3.)", "crate::values::computed::NonNegativeLength::new(3.)",
initial_specified_value="specified::BorderSideWidth::Medium", initial_specified_value="specified::BorderSideWidth::Medium",
computed_type="::values::computed::NonNegativeLength", computed_type="crate::values::computed::NonNegativeLength",
products="gecko", products="gecko",
spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-width", spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-width",
animation_value_type="NonNegativeLength", animation_value_type="NonNegativeLength",

View file

@ -326,12 +326,12 @@ ${helpers.predefined_type(
use app_units::Au; use app_units::Au;
use cssparser::{Parser, ToCss}; use cssparser::{Parser, ToCss};
use gecko_bindings::structs::FontFamilyType; use crate::gecko_bindings::structs::FontFamilyType;
use properties::longhands; use crate::properties::longhands;
use std::fmt; use std::fmt;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use style_traits::ParseError; use style_traits::ParseError;
use values::computed::{ToComputedValue, Context}; use crate::values::computed::{ToComputedValue, Context};
<% <%
system_fonts = """caption icon menu message-box small-caption status-bar system_fonts = """caption icon menu message-box small-caption status-bar
@ -375,12 +375,12 @@ ${helpers.predefined_type(
type ComputedValue = ComputedSystemFont; type ComputedValue = ComputedSystemFont;
fn to_computed_value(&self, cx: &Context) -> Self::ComputedValue { fn to_computed_value(&self, cx: &Context) -> Self::ComputedValue {
use gecko_bindings::bindings; use crate::gecko_bindings::bindings;
use gecko_bindings::structs::{LookAndFeel_FontID, nsFont}; use crate::gecko_bindings::structs::{LookAndFeel_FontID, nsFont};
use std::mem; use std::mem;
use values::computed::Percentage; use crate::values::computed::Percentage;
use values::computed::font::{FontSize, FontStretch, FontStyle, FontFamilyList}; use crate::values::computed::font::{FontSize, FontStretch, FontStyle, FontFamilyList};
use values::generics::NonNegative; use crate::values::generics::NonNegative;
let id = match *self { let id = match *self {
% for font in system_fonts: % for font in system_fonts:

View file

@ -39,7 +39,7 @@ ${helpers.single_keyword(
${helpers.predefined_type( ${helpers.predefined_type(
"fill", "fill",
"SVGPaint", "SVGPaint",
"::values::computed::SVGPaint::black()", "crate::values::computed::SVGPaint::black()",
products="gecko", products="gecko",
animation_value_type="IntermediateSVGPaint", animation_value_type="IntermediateSVGPaint",
boxed=True, boxed=True,
@ -87,7 +87,7 @@ ${helpers.predefined_type(
"stroke-width", "SVGWidth", "stroke-width", "SVGWidth",
"computed::SVGWidth::one()", "computed::SVGWidth::one()",
products="gecko", products="gecko",
animation_value_type="::values::computed::SVGWidth", animation_value_type="crate::values::computed::SVGWidth",
spec="https://www.w3.org/TR/SVG2/painting.html#StrokeWidth", spec="https://www.w3.org/TR/SVG2/painting.html#StrokeWidth",
)} )}
@ -112,7 +112,7 @@ ${helpers.predefined_type(
"GreaterThanOrEqualToOneNumber", "GreaterThanOrEqualToOneNumber",
"From::from(4.0)", "From::from(4.0)",
products="gecko", products="gecko",
animation_value_type="::values::computed::GreaterThanOrEqualToOneNumber", animation_value_type="crate::values::computed::GreaterThanOrEqualToOneNumber",
spec="https://www.w3.org/TR/SVG11/painting.html#StrokeMiterlimitProperty", spec="https://www.w3.org/TR/SVG11/painting.html#StrokeMiterlimitProperty",
)} )}
@ -130,7 +130,7 @@ ${helpers.predefined_type(
"SVGStrokeDashArray", "SVGStrokeDashArray",
"Default::default()", "Default::default()",
products="gecko", products="gecko",
animation_value_type="::values::computed::SVGStrokeDashArray", animation_value_type="crate::values::computed::SVGStrokeDashArray",
spec="https://www.w3.org/TR/SVG2/painting.html#StrokeDashing", spec="https://www.w3.org/TR/SVG2/painting.html#StrokeDashing",
)} )}

View file

@ -293,9 +293,9 @@ ${helpers.predefined_type(
${helpers.predefined_type( ${helpers.predefined_type(
"-webkit-text-stroke-width", "-webkit-text-stroke-width",
"BorderSideWidth", "BorderSideWidth",
"::values::computed::NonNegativeLength::new(0.)", "crate::values::computed::NonNegativeLength::new(0.)",
initial_specified_value="specified::BorderSideWidth::Length(specified::Length::zero())", initial_specified_value="specified::BorderSideWidth::Length(specified::Length::zero())",
computed_type="::values::computed::NonNegativeLength", computed_type="crate::values::computed::NonNegativeLength",
products="gecko", products="gecko",
gecko_pref="layout.css.prefixes.webkit", gecko_pref="layout.css.prefixes.webkit",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",

View file

@ -32,9 +32,9 @@ ${helpers.predefined_type(
${helpers.predefined_type( ${helpers.predefined_type(
"outline-width", "outline-width",
"BorderSideWidth", "BorderSideWidth",
"::values::computed::NonNegativeLength::new(3.)", "crate::values::computed::NonNegativeLength::new(3.)",
initial_specified_value="specified::BorderSideWidth::Medium", initial_specified_value="specified::BorderSideWidth::Medium",
computed_type="::values::computed::NonNegativeLength", computed_type="crate::values::computed::NonNegativeLength",
animation_value_type="NonNegativeLength", animation_value_type="NonNegativeLength",
spec="https://drafts.csswg.org/css-ui/#propdef-outline-width", spec="https://drafts.csswg.org/css-ui/#propdef-outline-width",
)} )}
@ -55,7 +55,7 @@ ${helpers.predefined_type(
${helpers.predefined_type( ${helpers.predefined_type(
"outline-offset", "outline-offset",
"Length", "Length",
"::values::computed::Length::new(0.)", "crate::values::computed::Length::new(0.)",
products="servo gecko", products="servo gecko",
animation_value_type="ComputedValue", animation_value_type="ComputedValue",
spec="https://drafts.csswg.org/css-ui/#propdef-outline-offset", spec="https://drafts.csswg.org/css-ui/#propdef-outline-offset",

View file

@ -42,7 +42,7 @@ macro_rules! impl_align_conversions {
($name: path) => { ($name: path) => {
impl From<u8> for $name { impl From<u8> for $name {
fn from(bits: u8) -> $name { fn from(bits: u8) -> $name {
$name(::values::specified::align::AlignFlags::from_bits(bits) $name(crate::values::specified::align::AlignFlags::from_bits(bits)
.expect("bits contain valid flag")) .expect("bits contain valid flag"))
} }
} }
@ -149,7 +149,7 @@ ${helpers.single_keyword(
)} )}
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
impl_align_conversions!(::values::specified::align::AlignItems); impl_align_conversions!(crate::values::specified::align::AlignItems);
${helpers.predefined_type( ${helpers.predefined_type(
"justify-items", "justify-items",
@ -160,7 +160,7 @@ ${helpers.single_keyword(
)} )}
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
impl_align_conversions!(::values::specified::align::JustifyItems); impl_align_conversions!(crate::values::specified::align::JustifyItems);
% endif % endif
// Flex item properties // Flex item properties
@ -214,7 +214,7 @@ ${helpers.predefined_type(
)} )}
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
impl_align_conversions!(::values::specified::align::SelfAlignment); impl_align_conversions!(crate::values::specified::align::SelfAlignment);
% endif % endif
// https://drafts.csswg.org/css-flexbox/#propdef-order // https://drafts.csswg.org/css-flexbox/#propdef-order

View file

@ -22,28 +22,28 @@ use std::mem::{self, ManuallyDrop};
use cssparser::{Parser, RGBA, TokenSerializationType}; use cssparser::{Parser, RGBA, TokenSerializationType};
use cssparser::ParserInput; use cssparser::ParserInput;
#[cfg(feature = "servo")] use euclid::SideOffsets2D; #[cfg(feature = "servo")] use euclid::SideOffsets2D;
use context::QuirksMode; use crate::context::QuirksMode;
#[cfg(feature = "gecko")] use gecko_bindings::structs::{self, nsCSSPropertyID}; #[cfg(feature = "gecko")] use crate::gecko_bindings::structs::{self, nsCSSPropertyID};
#[cfg(feature = "servo")] use logical_geometry::LogicalMargin; #[cfg(feature = "servo")] use crate::logical_geometry::LogicalMargin;
#[cfg(feature = "servo")] use computed_values; #[cfg(feature = "servo")] use crate::computed_values;
use logical_geometry::WritingMode; use crate::logical_geometry::WritingMode;
#[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use media_queries::Device; use crate::media_queries::Device;
use parser::ParserContext; use crate::parser::ParserContext;
use properties::longhands::system_font::SystemFont; use crate::properties::longhands::system_font::SystemFont;
use selector_parser::PseudoElement; use crate::selector_parser::PseudoElement;
use selectors::parser::SelectorParseErrorKind; use selectors::parser::SelectorParseErrorKind;
#[cfg(feature = "servo")] use servo_config::prefs::PREFS; #[cfg(feature = "servo")] use servo_config::prefs::PREFS;
use style_traits::{CssWriter, KeywordsCollectFn, ParseError, ParsingMode}; use style_traits::{CssWriter, KeywordsCollectFn, ParseError, ParsingMode};
use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss}; use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss};
use stylesheets::{CssRuleType, Origin, UrlExtraData}; use crate::stylesheets::{CssRuleType, Origin, UrlExtraData};
use values::generics::text::LineHeight; use crate::values::generics::text::LineHeight;
use values::computed; use crate::values::computed;
use values::computed::NonNegativeLength; use crate::values::computed::NonNegativeLength;
use values::serialize_atom_name; use crate::values::serialize_atom_name;
use rule_tree::StrongRuleNode; use crate::rule_tree::StrongRuleNode;
use self::computed_value_flags::*; use self::computed_value_flags::*;
use str::{CssString, CssStringBorrow, CssStringWriter}; use crate::str::{CssString, CssStringBorrow, CssStringWriter};
pub use self::declaration_block::*; pub use self::declaration_block::*;
pub use self::cascade::*; pub use self::cascade::*;
@ -110,12 +110,12 @@ macro_rules! unwrap_or_initial {
#[allow(missing_docs)] #[allow(missing_docs)]
pub mod shorthands { pub mod shorthands {
use cssparser::Parser; use cssparser::Parser;
use parser::{Parse, ParserContext}; use crate::parser::{Parse, ParserContext};
use style_traits::{ParseError, StyleParseErrorKind}; use style_traits::{ParseError, StyleParseErrorKind};
use values::specified; use crate::values::specified;
use style_traits::{CssWriter, ToCss}; use style_traits::{CssWriter, ToCss};
use values::specified::{BorderStyle, Color}; use crate::values::specified::{BorderStyle, Color};
use std::fmt::{self, Write}; use std::fmt::{self, Write};
fn serialize_directional_border<W, I,>( fn serialize_directional_border<W, I,>(
@ -427,7 +427,7 @@ pub const NON_CUSTOM_PROPERTY_ID_COUNT: usize =
#[allow(dead_code)] #[allow(dead_code)]
unsafe fn static_assert_nscsspropertyid() { unsafe fn static_assert_nscsspropertyid() {
% for i, property in enumerate(data.longhands + data.shorthands + data.all_aliases()): % for i, property in enumerate(data.longhands + data.shorthands + data.all_aliases()):
::std::mem::transmute::<[u8; ${i}], [u8; ${property.nscsspropertyid()} as usize]>([0; ${i}]); // ${property.name} std::mem::transmute::<[u8; ${i}], [u8; ${property.nscsspropertyid()} as usize]>([0; ${i}]); // ${property.name}
% endfor % endfor
} }
% endif % endif
@ -442,7 +442,7 @@ impl NonCustomPropertyId {
#[inline] #[inline]
fn to_nscsspropertyid(self) -> nsCSSPropertyID { fn to_nscsspropertyid(self) -> nsCSSPropertyID {
// unsafe: guaranteed by static_assert_nscsspropertyid above. // unsafe: guaranteed by static_assert_nscsspropertyid above.
unsafe { ::std::mem::transmute(self.0 as i32) } unsafe { std::mem::transmute(self.0 as i32) }
} }
/// Convert an `nsCSSPropertyID` into a `NonCustomPropertyId`. /// Convert an `nsCSSPropertyID` into a `NonCustomPropertyId`.
@ -457,7 +457,7 @@ impl NonCustomPropertyId {
return Err(()); return Err(());
} }
// unsafe: guaranteed by static_assert_nscsspropertyid above. // unsafe: guaranteed by static_assert_nscsspropertyid above.
Ok(unsafe { ::std::mem::transmute(prop as usize) }) Ok(unsafe { std::mem::transmute(prop as usize) })
} }
/// Get the property name. /// Get the property name.
@ -1301,7 +1301,7 @@ impl LonghandId {
/// shorthand, if that shorthand is enabled for all content too. /// shorthand, if that shorthand is enabled for all content too.
pub struct NonCustomPropertyIterator<Item: 'static> { pub struct NonCustomPropertyIterator<Item: 'static> {
filter: bool, filter: bool,
iter: ::std::slice::Iter<'static, Item>, iter: std::slice::Iter<'static, Item>,
} }
impl<Item> Iterator for NonCustomPropertyIterator<Item> impl<Item> Iterator for NonCustomPropertyIterator<Item>
@ -1534,11 +1534,11 @@ impl UnparsedValue {
fn substitute_variables( fn substitute_variables(
&self, &self,
longhand_id: LonghandId, longhand_id: LonghandId,
custom_properties: Option<<&Arc<::custom_properties::CustomPropertiesMap>>, custom_properties: Option<<&Arc<crate::custom_properties::CustomPropertiesMap>>,
quirks_mode: QuirksMode, quirks_mode: QuirksMode,
environment: &::custom_properties::CssEnvironment, environment: &::custom_properties::CssEnvironment,
) -> PropertyDeclaration { ) -> PropertyDeclaration {
::custom_properties::substitute( crate::custom_properties::substitute(
&self.css, &self.css,
self.first_token_type, self.first_token_type,
custom_properties, custom_properties,
@ -1617,7 +1617,7 @@ pub enum PropertyDeclarationId<'a> {
/// A longhand. /// A longhand.
Longhand(LonghandId), Longhand(LonghandId),
/// A custom property declaration. /// A custom property declaration.
Custom(&'a ::custom_properties::Name), Custom(&'a crate::custom_properties::Name),
} }
impl<'a> ToCss for PropertyDeclarationId<'a> { impl<'a> ToCss for PropertyDeclarationId<'a> {
@ -1699,7 +1699,7 @@ pub enum PropertyId {
/// An alias for a shorthand property. /// An alias for a shorthand property.
ShorthandAlias(ShorthandId, AliasId), ShorthandAlias(ShorthandId, AliasId),
/// A custom property. /// A custom property.
Custom(::custom_properties::Name), Custom(crate::custom_properties::Name),
} }
impl fmt::Debug for PropertyId { impl fmt::Debug for PropertyId {
@ -1763,8 +1763,8 @@ impl PropertyId {
return Ok(id.clone()) return Ok(id.clone())
} }
let name = ::custom_properties::parse_name(property_name)?; let name = crate::custom_properties::parse_name(property_name)?;
Ok(PropertyId::Custom(::custom_properties::Name::from(name))) Ok(PropertyId::Custom(crate::custom_properties::Name::from(name)))
} }
/// Parses a property name, and returns an error if it's unknown or isn't /// Parses a property name, and returns an error if it's unknown or isn't
@ -1948,7 +1948,7 @@ pub struct VariableDeclaration {
#[derive(Clone, PartialEq, ToCss)] #[derive(Clone, PartialEq, ToCss)]
pub enum CustomDeclarationValue { pub enum CustomDeclarationValue {
/// A value. /// A value.
Value(Arc<::custom_properties::SpecifiedValue>), Value(Arc<crate::custom_properties::SpecifiedValue>),
/// A wide keyword. /// A wide keyword.
CSSWideKeyword(CSSWideKeyword), CSSWideKeyword(CSSWideKeyword),
} }
@ -1959,7 +1959,7 @@ pub enum CustomDeclarationValue {
pub struct CustomDeclaration { pub struct CustomDeclaration {
/// The name of the custom property. /// The name of the custom property.
#[css(skip)] #[css(skip)]
pub name: ::custom_properties::Name, pub name: crate::custom_properties::Name,
/// The value of the custom property. /// The value of the custom property.
#[cfg_attr(feature = "gecko", ignore_malloc_size_of = "XXX: how to handle this?")] #[cfg_attr(feature = "gecko", ignore_malloc_size_of = "XXX: how to handle this?")]
pub value: CustomDeclarationValue, pub value: CustomDeclarationValue,
@ -2196,7 +2196,7 @@ impl PropertyDeclaration {
// This probably affects some test results. // This probably affects some test results.
let value = match input.try(CSSWideKeyword::parse) { let value = match input.try(CSSWideKeyword::parse) {
Ok(keyword) => CustomDeclarationValue::CSSWideKeyword(keyword), Ok(keyword) => CustomDeclarationValue::CSSWideKeyword(keyword),
Err(()) => match ::custom_properties::SpecifiedValue::parse(input) { Err(()) => match crate::custom_properties::SpecifiedValue::parse(input) {
Ok(value) => CustomDeclarationValue::Value(value), Ok(value) => CustomDeclarationValue::Value(value),
Err(e) => return Err(StyleParseErrorKind::new_invalid( Err(e) => return Err(StyleParseErrorKind::new_invalid(
format!("--{}", property_name), format!("--{}", property_name),
@ -2230,7 +2230,7 @@ impl PropertyDeclaration {
} }
input.reset(&start); input.reset(&start);
let (first_token_type, css) = let (first_token_type, css) =
::custom_properties::parse_non_custom_with_var(input).map_err(|e| { crate::custom_properties::parse_non_custom_with_var(input).map_err(|e| {
StyleParseErrorKind::new_invalid( StyleParseErrorKind::new_invalid(
non_custom_id.unwrap().name(), non_custom_id.unwrap().name(),
e, e,
@ -2282,7 +2282,7 @@ impl PropertyDeclaration {
input.reset(&start); input.reset(&start);
let (first_token_type, css) = let (first_token_type, css) =
::custom_properties::parse_non_custom_with_var(input).map_err(|e| { crate::custom_properties::parse_non_custom_with_var(input).map_err(|e| {
StyleParseErrorKind::new_invalid( StyleParseErrorKind::new_invalid(
non_custom_id.unwrap().name(), non_custom_id.unwrap().name(),
e, e,
@ -2424,7 +2424,7 @@ impl<'a> Iterator for AllShorthandDeclarationIterator<'a> {
} }
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use gecko_properties::style_structs; pub use crate::gecko_properties::style_structs;
/// The module where all the style structs are defined. /// The module where all the style structs are defined.
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
@ -2432,9 +2432,9 @@ pub mod style_structs {
use fxhash::FxHasher; use fxhash::FxHasher;
use super::longhands; use super::longhands;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use logical_geometry::WritingMode; use crate::logical_geometry::WritingMode;
use media_queries::Device; use crate::media_queries::Device;
use values::computed::NonNegativeLength; use crate::values::computed::NonNegativeLength;
% for style_struct in data.active_style_structs(): % for style_struct in data.active_style_structs():
% if style_struct.name == "Font": % if style_struct.name == "Font":
@ -2453,7 +2453,7 @@ pub mod style_structs {
/// ///
/// FIXME(emilio): This is technically a box-tree concept, and /// FIXME(emilio): This is technically a box-tree concept, and
/// would be nice to move away from style. /// would be nice to move away from style.
pub text_decorations_in_effect: ::values::computed::text::TextDecorationsInEffect, pub text_decorations_in_effect: crate::values::computed::text::TextDecorationsInEffect,
% endif % endif
% if style_struct.name == "Font": % if style_struct.name == "Font":
/// The font hash, used for font caching. /// The font hash, used for font caching.
@ -2700,7 +2700,7 @@ pub mod style_structs {
/// Whether this is a multicol style. /// Whether this is a multicol style.
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
pub fn is_multicol(&self) -> bool { pub fn is_multicol(&self) -> bool {
use values::Either; use crate::values::Either;
match self.column_width { match self.column_width {
Either::First(_width) => true, Either::First(_width) => true,
Either::Second(_auto) => !self.column_count.is_auto(), Either::Second(_auto) => !self.column_count.is_auto(),
@ -2736,7 +2736,7 @@ pub mod style_structs {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use gecko_properties::{ComputedValues, ComputedValuesInner}; pub use crate::gecko_properties::{ComputedValues, ComputedValuesInner};
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
#[cfg_attr(feature = "servo", derive(Clone, Debug))] #[cfg_attr(feature = "servo", derive(Clone, Debug))]
@ -2745,7 +2745,7 @@ pub struct ComputedValuesInner {
% for style_struct in data.active_style_structs(): % for style_struct in data.active_style_structs():
${style_struct.ident}: Arc<style_structs::${style_struct.name}>, ${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
% endfor % endfor
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>, custom_properties: Option<Arc<crate::custom_properties::CustomPropertiesMap>>,
/// The writing mode of this computed values struct. /// The writing mode of this computed values struct.
pub writing_mode: WritingMode, pub writing_mode: WritingMode,
@ -2804,7 +2804,7 @@ impl ComputedValues {
} }
/// Gets a reference to the custom properties map (if one exists). /// Gets a reference to the custom properties map (if one exists).
pub fn custom_properties(&self) -> Option<<&Arc<::custom_properties::CustomPropertiesMap>> { pub fn custom_properties(&self) -> Option<<&Arc<crate::custom_properties::CustomPropertiesMap>> {
self.custom_properties.as_ref() self.custom_properties.as_ref()
} }
@ -2874,7 +2874,7 @@ impl ComputedValues {
pub fn new( pub fn new(
_: &Device, _: &Device,
_: Option<<&PseudoElement>, _: Option<<&PseudoElement>,
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>, custom_properties: Option<Arc<crate::custom_properties::CustomPropertiesMap>>,
writing_mode: WritingMode, writing_mode: WritingMode,
flags: ComputedValueFlags, flags: ComputedValueFlags,
rules: Option<StrongRuleNode>, rules: Option<StrongRuleNode>,
@ -2978,7 +2978,7 @@ impl ComputedValuesInner {
/// ineffective, and would yield an empty `::before` or `::after` /// ineffective, and would yield an empty `::before` or `::after`
/// pseudo-element. /// pseudo-element.
pub fn ineffective_content_property(&self) -> bool { pub fn ineffective_content_property(&self) -> bool {
use values::generics::counters::Content; use crate::values::generics::counters::Content;
match self.get_counters().content { match self.get_counters().content {
Content::Normal | Content::None => true, Content::Normal | Content::None => true,
Content::Items(ref items) => items.is_empty(), Content::Items(ref items) => items.is_empty(),
@ -3100,7 +3100,7 @@ impl ComputedValuesInner {
/// Return true if the effects force the transform style to be Flat /// Return true if the effects force the transform style to be Flat
pub fn overrides_transform_style(&self) -> bool { pub fn overrides_transform_style(&self) -> bool {
use computed_values::mix_blend_mode::T as MixBlendMode; use crate::computed_values::mix_blend_mode::T as MixBlendMode;
let effects = self.get_effects(); let effects = self.get_effects();
// TODO(gw): Add clip-path, isolation, mask-image, mask-border-source when supported. // TODO(gw): Add clip-path, isolation, mask-image, mask-border-source when supported.
@ -3112,7 +3112,7 @@ impl ComputedValuesInner {
/// <https://drafts.csswg.org/css-transforms/#grouping-property-values> /// <https://drafts.csswg.org/css-transforms/#grouping-property-values>
pub fn get_used_transform_style(&self) -> computed_values::transform_style::T { pub fn get_used_transform_style(&self) -> computed_values::transform_style::T {
use computed_values::transform_style::T as TransformStyle; use crate::computed_values::transform_style::T as TransformStyle;
let box_ = self.get_box(); let box_ = self.get_box();
@ -3127,7 +3127,7 @@ impl ComputedValuesInner {
/// Whether given this transform value, the compositor would require a /// Whether given this transform value, the compositor would require a
/// layer. /// layer.
pub fn transform_requires_layer(&self) -> bool { pub fn transform_requires_layer(&self) -> bool {
use values::generics::transform::TransformOperation; use crate::values::generics::transform::TransformOperation;
// Check if the transform matrix is 2D or 3D // Check if the transform matrix is 2D or 3D
for transform in &self.get_box().transform.0 { for transform in &self.get_box().transform.0 {
match *transform { match *transform {
@ -3160,13 +3160,13 @@ impl ComputedValuesInner {
} }
% if product == "gecko": % if product == "gecko":
pub use ::servo_arc::RawOffsetArc as BuilderArc; pub use crate::servo_arc::RawOffsetArc as BuilderArc;
/// Clone an arc, returning a regular arc /// Clone an arc, returning a regular arc
fn clone_arc<T: 'static>(x: &BuilderArc<T>) -> Arc<T> { fn clone_arc<T: 'static>(x: &BuilderArc<T>) -> Arc<T> {
Arc::from_raw_offset(x.clone()) Arc::from_raw_offset(x.clone())
} }
% else: % else:
pub use ::servo_arc::Arc as BuilderArc; pub use crate::servo_arc::Arc as BuilderArc;
/// Clone an arc, returning a regular arc /// Clone an arc, returning a regular arc
fn clone_arc<T: 'static>(x: &BuilderArc<T>) -> Arc<T> { fn clone_arc<T: 'static>(x: &BuilderArc<T>) -> Arc<T> {
x.clone() x.clone()
@ -3301,7 +3301,7 @@ pub struct StyleBuilder<'a> {
/// node. /// node.
pub rules: Option<StrongRuleNode>, pub rules: Option<StrongRuleNode>,
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>, custom_properties: Option<Arc<crate::custom_properties::CustomPropertiesMap>>,
/// The pseudo-element this style will represent. /// The pseudo-element this style will represent.
pub pseudo: Option<<&'a PseudoElement>, pub pseudo: Option<<&'a PseudoElement>,
@ -3334,12 +3334,12 @@ impl<'a> StyleBuilder<'a> {
parent_style_ignoring_first_line: Option<<&'a ComputedValues>, parent_style_ignoring_first_line: Option<<&'a ComputedValues>,
pseudo: Option<<&'a PseudoElement>, pseudo: Option<<&'a PseudoElement>,
rules: Option<StrongRuleNode>, rules: Option<StrongRuleNode>,
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>, custom_properties: Option<Arc<crate::custom_properties::CustomPropertiesMap>>,
) -> Self { ) -> Self {
debug_assert_eq!(parent_style.is_some(), parent_style_ignoring_first_line.is_some()); debug_assert_eq!(parent_style.is_some(), parent_style_ignoring_first_line.is_some());
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
debug_assert!(parent_style.is_none() || debug_assert!(parent_style.is_none() ||
::std::ptr::eq(parent_style.unwrap(), std::ptr::eq(parent_style.unwrap(),
parent_style_ignoring_first_line.unwrap()) || parent_style_ignoring_first_line.unwrap()) ||
parent_style.unwrap().pseudo() == Some(PseudoElement::FirstLine)); parent_style.unwrap().pseudo() == Some(PseudoElement::FirstLine));
let reset_style = device.default_computed_values(); let reset_style = device.default_computed_values();
@ -3604,7 +3604,7 @@ impl<'a> StyleBuilder<'a> {
/// Returns whether this computed style represents an out of flow-positioned /// Returns whether this computed style represents an out of flow-positioned
/// object. /// object.
pub fn out_of_flow_positioned(&self) -> bool { pub fn out_of_flow_positioned(&self) -> bool {
use properties::longhands::position::computed_value::T as Position; use crate::properties::longhands::position::computed_value::T as Position;
matches!(self.get_box().clone_position(), matches!(self.get_box().clone_position(),
Position::Absolute | Position::Fixed) Position::Absolute | Position::Fixed)
} }
@ -3653,7 +3653,7 @@ impl<'a> StyleBuilder<'a> {
/// ///
/// Cloning the Arc here is fine because it only happens in the case where /// Cloning the Arc here is fine because it only happens in the case where
/// we have custom properties, and those are both rare and expensive. /// we have custom properties, and those are both rare and expensive.
fn custom_properties(&self) -> Option<<&Arc<::custom_properties::CustomPropertiesMap>> { fn custom_properties(&self) -> Option<<&Arc<crate::custom_properties::CustomPropertiesMap>> {
self.custom_properties.as_ref() self.custom_properties.as_ref()
} }
@ -3697,7 +3697,7 @@ pub use self::lazy_static_module::INITIAL_SERVO_VALUES;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
#[allow(missing_docs)] #[allow(missing_docs)]
mod lazy_static_module { mod lazy_static_module {
use logical_geometry::WritingMode; use crate::logical_geometry::WritingMode;
use servo_arc::Arc; use servo_arc::Arc;
use super::{ComputedValues, ComputedValuesInner, longhands, style_structs}; use super::{ComputedValues, ComputedValuesInner, longhands, style_structs};
use super::computed_value_flags::ComputedValueFlags; use super::computed_value_flags::ComputedValueFlags;
@ -3712,7 +3712,8 @@ mod lazy_static_module {
${longhand.ident}: longhands::${longhand.ident}::get_initial_value(), ${longhand.ident}: longhands::${longhand.ident}::get_initial_value(),
% endfor % endfor
% if style_struct.name == "InheritedText": % if style_struct.name == "InheritedText":
text_decorations_in_effect: ::values::computed::text::TextDecorationsInEffect::default(), text_decorations_in_effect:
crate::values::computed::text::TextDecorationsInEffect::default(),
% endif % endif
% if style_struct.name == "Font": % if style_struct.name == "Font":
hash: 0, hash: 0,

View file

@ -10,13 +10,13 @@
background-attachment background-image background-size background-origin background-attachment background-image background-size background-origin
background-clip" background-clip"
spec="https://drafts.csswg.org/css-backgrounds/#the-background"> spec="https://drafts.csswg.org/css-backgrounds/#the-background">
use properties::longhands::{background_position_x, background_position_y, background_repeat}; use crate::properties::longhands::{background_position_x, background_position_y, background_repeat};
use properties::longhands::{background_attachment, background_image, background_size, background_origin}; use crate::properties::longhands::{background_attachment, background_image, background_size, background_origin};
use properties::longhands::background_clip; use crate::properties::longhands::background_clip;
use properties::longhands::background_clip::single_value::computed_value::T as Clip; use crate::properties::longhands::background_clip::single_value::computed_value::T as Clip;
use properties::longhands::background_origin::single_value::computed_value::T as Origin; use crate::properties::longhands::background_origin::single_value::computed_value::T as Origin;
use values::specified::{Color, Position, PositionComponent}; use crate::values::specified::{Color, Position, PositionComponent};
use parser::Parse; use crate::parser::Parse;
// FIXME(emilio): Should be the same type! // FIXME(emilio): Should be the same type!
impl From<background_origin::single_value::SpecifiedValue> for background_clip::single_value::SpecifiedValue { impl From<background_origin::single_value::SpecifiedValue> for background_clip::single_value::SpecifiedValue {
@ -199,9 +199,9 @@
flags="SHORTHAND_IN_GETCS" flags="SHORTHAND_IN_GETCS"
sub_properties="background-position-x background-position-y" sub_properties="background-position-x background-position-y"
spec="https://drafts.csswg.org/css-backgrounds-4/#the-background-position"> spec="https://drafts.csswg.org/css-backgrounds-4/#the-background-position">
use properties::longhands::{background_position_x, background_position_y}; use crate::properties::longhands::{background_position_x, background_position_y};
use values::specified::AllowQuirks; use crate::values::specified::AllowQuirks;
use values::specified::position::Position; use crate::values::specified::position::Position;
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
context: &ParserContext, context: &ParserContext,

View file

@ -21,8 +21,8 @@ ${helpers.four_sides_shorthand(
' '.join('border-%s-width' % side ' '.join('border-%s-width' % side
for side in PHYSICAL_SIDES)}" for side in PHYSICAL_SIDES)}"
spec="https://drafts.csswg.org/css-backgrounds/#border-width"> spec="https://drafts.csswg.org/css-backgrounds/#border-width">
use values::generics::rect::Rect; use crate::values::generics::rect::Rect;
use values::specified::{AllowQuirks, BorderSideWidth}; use crate::values::specified::{AllowQuirks, BorderSideWidth};
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
context: &ParserContext, context: &ParserContext,
@ -54,7 +54,7 @@ pub fn parse_border<'i, 't>(
context: &ParserContext, context: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<(specified::Color, specified::BorderStyle, specified::BorderSideWidth), ParseError<'i>> { ) -> Result<(specified::Color, specified::BorderStyle, specified::BorderSideWidth), ParseError<'i>> {
use values::specified::{Color, BorderStyle, BorderSideWidth}; use crate::values::specified::{Color, BorderStyle, BorderSideWidth};
let _unused = context; let _unused = context;
let mut color = None; let mut color = None;
let mut style = None; let mut style = None;
@ -147,8 +147,8 @@ pub fn parse_border<'i, 't>(
context: &ParserContext, context: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Longhands, ParseError<'i>> { ) -> Result<Longhands, ParseError<'i>> {
use properties::longhands::{border_image_outset, border_image_repeat, border_image_slice}; use crate::properties::longhands::{border_image_outset, border_image_repeat, border_image_slice};
use properties::longhands::{border_image_source, border_image_width}; use crate::properties::longhands::{border_image_source, border_image_width};
let (color, style, width) = super::parse_border(context, input)?; let (color, style, width) = super::parse_border(context, input)?;
Ok(expanded! { Ok(expanded! {
@ -206,7 +206,7 @@ pub fn parse_border<'i, 't>(
// Just use the same as border-left. The border shorthand can't accept // Just use the same as border-left. The border shorthand can't accept
// any value that the sub-shorthand couldn't. // any value that the sub-shorthand couldn't.
<% <%
border_left = "<::properties::shorthands::border_left::Longhands as SpecifiedValueInfo>" border_left = "<crate::properties::shorthands::border_left::Longhands as SpecifiedValueInfo>"
%> %>
impl SpecifiedValueInfo for Longhands { impl SpecifiedValueInfo for Longhands {
const SUPPORTED_TYPES: u8 = ${border_left}::SUPPORTED_TYPES; const SUPPORTED_TYPES: u8 = ${border_left}::SUPPORTED_TYPES;
@ -220,10 +220,10 @@ pub fn parse_border<'i, 't>(
'border-%s-radius' % (corner) 'border-%s-radius' % (corner)
for corner in ['top-left', 'top-right', 'bottom-right', 'bottom-left'] for corner in ['top-left', 'top-right', 'bottom-right', 'bottom-left']
)}" extra_prefixes="webkit" spec="https://drafts.csswg.org/css-backgrounds/#border-radius"> )}" extra_prefixes="webkit" spec="https://drafts.csswg.org/css-backgrounds/#border-radius">
use values::generics::rect::Rect; use crate::values::generics::rect::Rect;
use values::generics::border::BorderCornerRadius; use crate::values::generics::border::BorderCornerRadius;
use values::specified::border::BorderRadius; use crate::values::specified::border::BorderRadius;
use parser::Parse; use crate::parser::Parse;
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
context: &ParserContext, context: &ParserContext,
@ -260,8 +260,8 @@ pub fn parse_border<'i, 't>(
border-image-repeat border-image-slice border-image-source border-image-width" border-image-repeat border-image-slice border-image-source border-image-width"
extra_prefixes="moz:layout.css.prefixes.border-image webkit" extra_prefixes="moz:layout.css.prefixes.border-image webkit"
spec="https://drafts.csswg.org/css-backgrounds-3/#border-image"> spec="https://drafts.csswg.org/css-backgrounds-3/#border-image">
use properties::longhands::{border_image_outset, border_image_repeat, border_image_slice}; use crate::properties::longhands::{border_image_outset, border_image_repeat, border_image_slice};
use properties::longhands::{border_image_source, border_image_width}; use crate::properties::longhands::{border_image_source, border_image_width};
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
context: &ParserContext, context: &ParserContext,

View file

@ -10,9 +10,9 @@
sub_properties="overflow-x overflow-y" sub_properties="overflow-x overflow-y"
spec="https://drafts.csswg.org/css-overflow/#propdef-overflow" spec="https://drafts.csswg.org/css-overflow/#propdef-overflow"
> >
use properties::longhands::overflow_x::parse as parse_overflow; use crate::properties::longhands::overflow_x::parse as parse_overflow;
% if product == "gecko": % if product == "gecko":
use properties::longhands::overflow_x::SpecifiedValue; use crate::properties::longhands::overflow_x::SpecifiedValue;
% endif % endif
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
@ -20,7 +20,7 @@
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Longhands, ParseError<'i>> { ) -> Result<Longhands, ParseError<'i>> {
% if product == "gecko": % if product == "gecko":
use gecko_bindings::structs; use crate::gecko_bindings::structs;
let moz_kw_enabled = unsafe { let moz_kw_enabled = unsafe {
structs::StaticPrefs_sVarCache_layout_css_overflow_moz_scrollbars_enabled structs::StaticPrefs_sVarCache_layout_css_overflow_moz_scrollbars_enabled
}; };
@ -82,7 +82,7 @@
"(https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)" "(https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)"
products="gecko" products="gecko"
> >
use values::specified::OverflowClipBox; use crate::values::specified::OverflowClipBox;
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
_: &ParserContext, _: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
@ -130,11 +130,11 @@ macro_rules! try_parse_one {
transition-timing-function transition-timing-function
transition-delay" transition-delay"
spec="https://drafts.csswg.org/css-transitions/#propdef-transition"> spec="https://drafts.csswg.org/css-transitions/#propdef-transition">
use parser::Parse; use crate::parser::Parse;
% for prop in "delay duration property timing_function".split(): % for prop in "delay duration property timing_function".split():
use properties::longhands::transition_${prop}; use crate::properties::longhands::transition_${prop};
% endfor % endfor
use values::specified::TransitionProperty; use crate::values::specified::TransitionProperty;
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
context: &ParserContext, context: &ParserContext,
@ -282,7 +282,7 @@ macro_rules! try_parse_one {
direction fill_mode play_state".split() direction fill_mode play_state".split()
%> %>
% for prop in props: % for prop in props:
use properties::longhands::animation_${prop}; use crate::properties::longhands::animation_${prop};
% endfor % endfor
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
@ -391,7 +391,7 @@ macro_rules! try_parse_one {
gecko_pref="layout.css.scroll-snap.enabled" gecko_pref="layout.css.scroll-snap.enabled"
sub_properties="scroll-snap-type-x scroll-snap-type-y" sub_properties="scroll-snap-type-x scroll-snap-type-y"
spec="https://drafts.csswg.org/css-scroll-snap/#propdef-scroll-snap-type"> spec="https://drafts.csswg.org/css-scroll-snap/#propdef-scroll-snap-type">
use properties::longhands::scroll_snap_type_x; use crate::properties::longhands::scroll_snap_type_x;
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
context: &ParserContext, context: &ParserContext,
@ -425,7 +425,7 @@ macro_rules! try_parse_one {
_: &ParserContext, _: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Longhands, ParseError<'i>> { ) -> Result<Longhands, ParseError<'i>> {
use values::specified::OverscrollBehavior; use crate::values::specified::OverscrollBehavior;
let behavior_x = OverscrollBehavior::parse(input)?; let behavior_x = OverscrollBehavior::parse(input)?;
let behavior_y = input.try(OverscrollBehavior::parse).unwrap_or(behavior_x); let behavior_y = input.try(OverscrollBehavior::parse).unwrap_or(behavior_x);
Ok(expanded! { Ok(expanded! {

View file

@ -9,7 +9,7 @@
servo_pref="layout.columns.enabled", servo_pref="layout.columns.enabled",
derive_serialize="True" derive_serialize="True"
extra_prefixes="moz" spec="https://drafts.csswg.org/css-multicol/#propdef-columns"> extra_prefixes="moz" spec="https://drafts.csswg.org/css-multicol/#propdef-columns">
use properties::longhands::{column_count, column_width}; use crate::properties::longhands::{column_count, column_width};
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
context: &ParserContext, context: &ParserContext,
@ -59,8 +59,8 @@
sub_properties="column-rule-width column-rule-style column-rule-color" sub_properties="column-rule-width column-rule-style column-rule-color"
derive_serialize="True" derive_serialize="True"
spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule"> spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule">
use properties::longhands::{column_rule_width, column_rule_style}; use crate::properties::longhands::{column_rule_width, column_rule_style};
use properties::longhands::column_rule_color; use crate::properties::longhands::column_rule_color;
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
context: &ParserContext, context: &ParserContext,

View file

@ -21,14 +21,14 @@
${'font-variation-settings' if product == 'gecko' else ''}" ${'font-variation-settings' if product == 'gecko' else ''}"
derive_value_info="False" derive_value_info="False"
spec="https://drafts.csswg.org/css-fonts-3/#propdef-font"> spec="https://drafts.csswg.org/css-fonts-3/#propdef-font">
use parser::Parse; use crate::parser::Parse;
use properties::longhands::{font_family, font_style, font_weight, font_stretch}; use crate::properties::longhands::{font_family, font_style, font_weight, font_stretch};
use properties::longhands::font_variant_caps; use crate::properties::longhands::font_variant_caps;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use properties::longhands::system_font::SystemFont; use crate::properties::longhands::system_font::SystemFont;
use values::specified::text::LineHeight; use crate::values::specified::text::LineHeight;
use values::specified::FontSize; use crate::values::specified::FontSize;
use values::specified::font::{FontStretch, FontStretchKeyword}; use crate::values::specified::font::{FontStretch, FontStretchKeyword};
<% <%
gecko_sub_properties = "kerning language_override size_adjust \ gecko_sub_properties = "kerning language_override size_adjust \
@ -39,7 +39,7 @@
%> %>
% if product == "gecko": % if product == "gecko":
% for prop in gecko_sub_properties: % for prop in gecko_sub_properties:
use properties::longhands::font_${prop}; use crate::properties::longhands::font_${prop};
% endfor % endfor
% endif % endif
use self::font_family::SpecifiedValue as FontFamily; use self::font_family::SpecifiedValue as FontFamily;
@ -301,10 +301,10 @@
%> %>
% for prop in sub_properties: % for prop in sub_properties:
use properties::longhands::font_variant_${prop}; use crate::properties::longhands::font_variant_${prop};
% endfor % endfor
#[allow(unused_imports)] #[allow(unused_imports)]
use values::specified::FontVariantLigatures; use crate::values::specified::FontVariantLigatures;
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
context: &ParserContext, context: &ParserContext,

View file

@ -7,13 +7,13 @@
<%helpers:shorthand name="marker" products="gecko" <%helpers:shorthand name="marker" products="gecko"
sub_properties="marker-start marker-end marker-mid" sub_properties="marker-start marker-end marker-mid"
spec="https://www.w3.org/TR/SVG2/painting.html#MarkerShorthand"> spec="https://www.w3.org/TR/SVG2/painting.html#MarkerShorthand">
use values::specified::url::UrlOrNone; use crate::values::specified::url::UrlOrNone;
pub fn parse_value<'i, 't>( pub fn parse_value<'i, 't>(
context: &ParserContext, context: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Longhands, ParseError<'i>> { ) -> Result<Longhands, ParseError<'i>> {
use parser::Parse; use crate::parser::Parse;
let url = UrlOrNone::parse(context, input)?; let url = UrlOrNone::parse(context, input)?;
Ok(expanded! { Ok(expanded! {

Some files were not shown because too many files have changed in this diff Show more