mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
style: Move DocumentStyleSheet to style.
This commit is contained in:
parent
e60266a723
commit
02b203891f
3 changed files with 35 additions and 32 deletions
|
@ -129,7 +129,6 @@ use style::context::RegisteredSpeculativePainters;
|
||||||
use style::dom::{ShowSubtree, ShowSubtreeDataAndPrimaryValues, TElement, TNode};
|
use style::dom::{ShowSubtree, ShowSubtreeDataAndPrimaryValues, TElement, TNode};
|
||||||
use style::error_reporting::{NullReporter, RustLogReporter};
|
use style::error_reporting::{NullReporter, RustLogReporter};
|
||||||
use style::invalidation::element::restyle_hints::RestyleHint;
|
use style::invalidation::element::restyle_hints::RestyleHint;
|
||||||
use style::invalidation::media_queries::{MediaListKey, ToMediaListKey};
|
|
||||||
use style::logical_geometry::LogicalPoint;
|
use style::logical_geometry::LogicalPoint;
|
||||||
use style::media_queries::{Device, MediaList, MediaType};
|
use style::media_queries::{Device, MediaList, MediaType};
|
||||||
use style::properties::PropertyId;
|
use style::properties::PropertyId;
|
||||||
|
@ -137,7 +136,7 @@ use style::selector_parser::SnapshotMap;
|
||||||
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION, STORE_OVERFLOW};
|
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION, STORE_OVERFLOW};
|
||||||
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards};
|
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards};
|
||||||
use style::stylesheet_set::StylesheetSet;
|
use style::stylesheet_set::StylesheetSet;
|
||||||
use style::stylesheets::{Origin, Stylesheet, StylesheetContents, StylesheetInDocument, UserAgentStylesheets};
|
use style::stylesheets::{Origin, Stylesheet, DocumentStyleSheet, StylesheetInDocument, UserAgentStylesheets};
|
||||||
use style::stylist::Stylist;
|
use style::stylist::Stylist;
|
||||||
use style::thread_state;
|
use style::thread_state;
|
||||||
use style::timer::Timer;
|
use style::timer::Timer;
|
||||||
|
@ -147,35 +146,6 @@ use style_traits::CSSPixel;
|
||||||
use style_traits::DevicePixel;
|
use style_traits::DevicePixel;
|
||||||
use style_traits::SpeculativePainter;
|
use style_traits::SpeculativePainter;
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
struct DocumentStyleSheet(ServoArc<Stylesheet>);
|
|
||||||
|
|
||||||
impl PartialEq for DocumentStyleSheet {
|
|
||||||
fn eq(&self, other: &Self) -> bool {
|
|
||||||
ServoArc::ptr_eq(&self.0, &other.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToMediaListKey for DocumentStyleSheet {
|
|
||||||
fn to_media_list_key(&self) -> MediaListKey {
|
|
||||||
self.0.to_media_list_key()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl StylesheetInDocument for DocumentStyleSheet {
|
|
||||||
fn contents(&self, guard: &SharedRwLockReadGuard) -> &StylesheetContents {
|
|
||||||
self.0.contents(guard)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn media<'a>(&'a self, guard: &'a SharedRwLockReadGuard) -> Option<&'a MediaList> {
|
|
||||||
self.0.media(guard)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn enabled(&self) -> bool {
|
|
||||||
self.0.enabled()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Information needed by the layout thread.
|
/// Information needed by the layout thread.
|
||||||
pub struct LayoutThread {
|
pub struct LayoutThread {
|
||||||
/// The ID of the pipeline that we belong to.
|
/// The ID of the pipeline that we belong to.
|
||||||
|
|
|
@ -49,7 +49,8 @@ pub use self::page_rule::PageRule;
|
||||||
pub use self::rule_parser::{State, TopLevelRuleParser};
|
pub use self::rule_parser::{State, TopLevelRuleParser};
|
||||||
pub use self::rule_list::{CssRules, CssRulesHelpers};
|
pub use self::rule_list::{CssRules, CssRulesHelpers};
|
||||||
pub use self::rules_iterator::{AllRules, EffectiveRules, NestedRuleIterationCondition, RulesIterator};
|
pub use self::rules_iterator::{AllRules, EffectiveRules, NestedRuleIterationCondition, RulesIterator};
|
||||||
pub use self::stylesheet::{Namespaces, Stylesheet, StylesheetContents, StylesheetInDocument, UserAgentStylesheets};
|
pub use self::stylesheet::{Namespaces, Stylesheet, DocumentStyleSheet};
|
||||||
|
pub use self::stylesheet::{StylesheetContents, StylesheetInDocument, UserAgentStylesheets};
|
||||||
pub use self::style_rule::StyleRule;
|
pub use self::style_rule::StyleRule;
|
||||||
pub use self::supports_rule::SupportsRule;
|
pub use self::supports_rule::SupportsRule;
|
||||||
pub use self::viewport_rule::ViewportRule;
|
pub use self::viewport_rule::ViewportRule;
|
||||||
|
|
|
@ -7,6 +7,7 @@ use context::QuirksMode;
|
||||||
use cssparser::{Parser, RuleListParser, ParserInput};
|
use cssparser::{Parser, RuleListParser, ParserInput};
|
||||||
use error_reporting::{ParseErrorReporter, ContextualParseError};
|
use error_reporting::{ParseErrorReporter, ContextualParseError};
|
||||||
use fnv::FnvHashMap;
|
use fnv::FnvHashMap;
|
||||||
|
use invalidation::media_queries::{MediaListKey, ToMediaListKey};
|
||||||
use media_queries::{MediaList, Device};
|
use media_queries::{MediaList, Device};
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use parser::ParserContext;
|
use parser::ParserContext;
|
||||||
|
@ -275,6 +276,37 @@ impl StylesheetInDocument for Stylesheet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A simple wrapper over an `Arc<Stylesheet>`, with pointer comparison, and
|
||||||
|
/// suitable for its use in a `StylesheetSet`.
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct DocumentStyleSheet(pub Arc<Stylesheet>);
|
||||||
|
|
||||||
|
impl PartialEq for DocumentStyleSheet {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
Arc::ptr_eq(&self.0, &other.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToMediaListKey for DocumentStyleSheet {
|
||||||
|
fn to_media_list_key(&self) -> MediaListKey {
|
||||||
|
self.0.to_media_list_key()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl StylesheetInDocument for DocumentStyleSheet {
|
||||||
|
fn contents(&self, guard: &SharedRwLockReadGuard) -> &StylesheetContents {
|
||||||
|
self.0.contents(guard)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn media<'a>(&'a self, guard: &'a SharedRwLockReadGuard) -> Option<&'a MediaList> {
|
||||||
|
self.0.media(guard)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn enabled(&self) -> bool {
|
||||||
|
self.0.enabled()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Stylesheet {
|
impl Stylesheet {
|
||||||
/// Updates an empty stylesheet from a given string of text.
|
/// Updates an empty stylesheet from a given string of text.
|
||||||
pub fn update_from_str(existing: &Stylesheet,
|
pub fn update_from_str(existing: &Stylesheet,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue