aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/document.rs3
-rw-r--r--components/script/dom/documentorshadowroot.rs2
-rw-r--r--components/script/dom/shadowroot.rs2
-rw-r--r--components/script/lib.rs1
-rw-r--r--components/script/stylesheet_set.rs70
-rw-r--r--components/style/stylesheet_set.rs62
6 files changed, 75 insertions, 65 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index ddcdcca24dc..1a6714f5927 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -101,6 +101,7 @@ use crate::dom::windowproxy::WindowProxy;
use crate::fetch::FetchCanceller;
use crate::script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
use crate::script_thread::{MainThreadScriptMsg, ScriptThread};
+use crate::stylesheet_set::StylesheetSetRef;
use crate::task::TaskBox;
use crate::task_source::{TaskSource, TaskSourceName};
use crate::timers::OneshotTimerCallback;
@@ -154,7 +155,7 @@ use style::media_queries::{Device, MediaType};
use style::selector_parser::{RestyleDamage, Snapshot};
use style::shared_lock::SharedRwLock as StyleSharedRwLock;
use style::str::{split_html_space_chars, str_join};
-use style::stylesheet_set::{DocumentStylesheetSet, StylesheetSetRef};
+use style::stylesheet_set::DocumentStylesheetSet;
use style::stylesheets::{Origin, OriginSet, Stylesheet};
use url::percent_encoding::percent_decode;
use url::Host;
diff --git a/components/script/dom/documentorshadowroot.rs b/components/script/dom/documentorshadowroot.rs
index 5aa2a9eb625..8a29d16d013 100644
--- a/components/script/dom/documentorshadowroot.rs
+++ b/components/script/dom/documentorshadowroot.rs
@@ -12,6 +12,7 @@ use crate::dom::htmlelement::HTMLElement;
use crate::dom::htmlmetaelement::HTMLMetaElement;
use crate::dom::node::{self, Node, VecPreOrderInsertionHelper};
use crate::dom::window::Window;
+use crate::stylesheet_set::StylesheetSetRef;
use euclid::Point2D;
use js::jsapi::JS_GetRuntime;
use script_layout_interface::message::{NodesFromPointQueryType, QueryMsg};
@@ -24,7 +25,6 @@ use style::context::QuirksMode;
use style::invalidation::media_queries::{MediaListKey, ToMediaListKey};
use style::media_queries::MediaList;
use style::shared_lock::{SharedRwLock as StyleSharedRwLock, SharedRwLockReadGuard};
-use style::stylesheet_set::StylesheetSetRef;
use style::stylesheets::{CssRule, Origin, Stylesheet};
#[derive(Clone, JSTraceable, MallocSizeOf)]
diff --git a/components/script/dom/shadowroot.rs b/components/script/dom/shadowroot.rs
index 153993a1d62..ae108f8109c 100644
--- a/components/script/dom/shadowroot.rs
+++ b/components/script/dom/shadowroot.rs
@@ -17,6 +17,7 @@ use crate::dom::element::Element;
use crate::dom::node::{Node, NodeDamage, NodeFlags, ShadowIncluding};
use crate::dom::stylesheetlist::{StyleSheetList, StyleSheetListOwner};
use crate::dom::window::Window;
+use crate::stylesheet_set::StylesheetSetRef;
use dom_struct::dom_struct;
use selectors::context::QuirksMode;
use servo_arc::Arc;
@@ -25,7 +26,6 @@ use style::author_styles::AuthorStyles;
use style::dom::TElement;
use style::media_queries::Device;
use style::shared_lock::SharedRwLockReadGuard;
-use style::stylesheet_set::StylesheetSetRef;
use style::stylesheets::Stylesheet;
// https://dom.spec.whatwg.org/#interface-shadowroot
diff --git a/components/script/lib.rs b/components/script/lib.rs
index 3f48e3d9118..327209d71db 100644
--- a/components/script/lib.rs
+++ b/components/script/lib.rs
@@ -69,6 +69,7 @@ pub mod script_thread;
mod serviceworker_manager;
mod serviceworkerjob;
mod stylesheet_loader;
+mod stylesheet_set;
mod task_manager;
mod task_queue;
mod task_source;
diff --git a/components/script/stylesheet_set.rs b/components/script/stylesheet_set.rs
new file mode 100644
index 00000000000..ddb2f608e57
--- /dev/null
+++ b/components/script/stylesheet_set.rs
@@ -0,0 +1,70 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use style::media_queries::Device;
+use style::shared_lock::SharedRwLockReadGuard;
+use style::stylesheet_set::{AuthorStylesheetSet, DocumentStylesheetSet};
+use style::stylesheets::StylesheetInDocument;
+
+/// Functionality common to DocumentStylesheetSet and AuthorStylesheetSet.
+pub enum StylesheetSetRef<'a, S>
+where
+ S: StylesheetInDocument + PartialEq + 'static,
+{
+ /// Author stylesheet set.
+ Author(&'a mut AuthorStylesheetSet<S>),
+ /// Document stylesheet set.
+ Document(&'a mut DocumentStylesheetSet<S>),
+}
+
+impl<'a, S> StylesheetSetRef<'a, S>
+where
+ S: StylesheetInDocument + PartialEq + 'static,
+{
+ /// Appends a new stylesheet to the current set.
+ ///
+ /// No device implies not computing invalidations.
+ pub fn append_stylesheet(
+ &mut self,
+ device: Option<&Device>,
+ sheet: S,
+ guard: &SharedRwLockReadGuard,
+ ) {
+ match self {
+ StylesheetSetRef::Author(set) => set.append_stylesheet(device, sheet, guard),
+ StylesheetSetRef::Document(set) => set.append_stylesheet(device, sheet, guard),
+ }
+ }
+
+ /// Insert a given stylesheet before another stylesheet in the document.
+ pub fn insert_stylesheet_before(
+ &mut self,
+ device: Option<&Device>,
+ sheet: S,
+ before_sheet: S,
+ guard: &SharedRwLockReadGuard,
+ ) {
+ match self {
+ StylesheetSetRef::Author(set) => {
+ set.insert_stylesheet_before(device, sheet, before_sheet, guard)
+ },
+ StylesheetSetRef::Document(set) => {
+ set.insert_stylesheet_before(device, sheet, before_sheet, guard)
+ },
+ }
+ }
+
+ /// Remove a given stylesheet from the set.
+ pub fn remove_stylesheet(
+ &mut self,
+ device: Option<&Device>,
+ sheet: S,
+ guard: &SharedRwLockReadGuard,
+ ) {
+ match self {
+ StylesheetSetRef::Author(set) => set.remove_stylesheet(device, sheet, guard),
+ StylesheetSetRef::Document(set) => set.remove_stylesheet(device, sheet, guard),
+ }
+ }
+}
diff --git a/components/style/stylesheet_set.rs b/components/style/stylesheet_set.rs
index ed0f5781061..d2c3ad0f88e 100644
--- a/components/style/stylesheet_set.rs
+++ b/components/style/stylesheet_set.rs
@@ -373,68 +373,6 @@ where
invalidations: StylesheetInvalidationSet,
}
-/// Functionality common to DocumentStylesheetSet and AuthorStylesheetSet.
-pub enum StylesheetSetRef<'a, S>
-where
- S: StylesheetInDocument + PartialEq + 'static,
-{
- /// Author stylesheet set.
- Author(&'a mut AuthorStylesheetSet<S>),
- /// Document stylesheet set.
- Document(&'a mut DocumentStylesheetSet<S>),
-}
-
-impl<'a, S> StylesheetSetRef<'a, S>
-where
- S: StylesheetInDocument + PartialEq + 'static,
-{
- /// Appends a new stylesheet to the current set.
- ///
- /// No device implies not computing invalidations.
- pub fn append_stylesheet(
- &mut self,
- device: Option<&Device>,
- sheet: S,
- guard: &SharedRwLockReadGuard,
- ) {
- match self {
- StylesheetSetRef::Author(set) => set.append_stylesheet(device, sheet, guard),
- StylesheetSetRef::Document(set) => set.append_stylesheet(device, sheet, guard),
- }
- }
-
- /// Insert a given stylesheet before another stylesheet in the document.
- pub fn insert_stylesheet_before(
- &mut self,
- device: Option<&Device>,
- sheet: S,
- before_sheet: S,
- guard: &SharedRwLockReadGuard,
- ) {
- match self {
- StylesheetSetRef::Author(set) => {
- set.insert_stylesheet_before(device, sheet, before_sheet, guard)
- },
- StylesheetSetRef::Document(set) => {
- set.insert_stylesheet_before(device, sheet, before_sheet, guard)
- },
- }
- }
-
- /// Remove a given stylesheet from the set.
- pub fn remove_stylesheet(
- &mut self,
- device: Option<&Device>,
- sheet: S,
- guard: &SharedRwLockReadGuard,
- ) {
- match self {
- StylesheetSetRef::Author(set) => set.remove_stylesheet(device, sheet, guard),
- StylesheetSetRef::Document(set) => set.remove_stylesheet(device, sheet, guard),
- }
- }
-}
-
/// This macro defines methods common to DocumentStylesheetSet and
/// AuthorStylesheetSet.
///