diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2017-03-14 16:09:41 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2017-03-19 22:30:31 +0100 |
commit | c5a7294e05a3b370981170ea273acb60b6116bc0 (patch) | |
tree | dbac59e9b0f90ecc0dd907d430660ef6f6f8abce /components/script/dom/document.rs | |
parent | 8feb9e80477376a529b8c5ce9951e78f6048f054 (diff) | |
download | servo-c5a7294e05a3b370981170ea273acb60b6116bc0.tar.gz servo-c5a7294e05a3b370981170ea273acb60b6116bc0.zip |
Replace RwLock<MediaList> with shared_lock::Locked<MediaList>
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r-- | components/script/dom/document.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index b85366a27d2..7a50fe5cf6c 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -134,6 +134,7 @@ use style::attr::AttrValue; use style::context::{QuirksMode, ReflowGoal}; use style::restyle_hints::{RestyleHint, RESTYLE_STYLE_ATTRIBUTE}; use style::selector_parser::{RestyleDamage, Snapshot}; +use style::shared_lock::SharedRwLock as StyleSharedRwLock; use style::str::{HTML_SPACE_CHARACTERS, split_html_space_chars, str_join}; use style::stylesheets::Stylesheet; use task_source::TaskSource; @@ -220,6 +221,9 @@ pub struct Document { scripts: MutNullableJS<HTMLCollection>, anchors: MutNullableJS<HTMLCollection>, applets: MutNullableJS<HTMLCollection>, + /// Lock use for style attributes and author-origin stylesheet objects in this document. + /// Can be acquired once for accessing many objects. + style_shared_lock: StyleSharedRwLock, /// List of stylesheets associated with nodes in this document. |None| if the list needs to be refreshed. stylesheets: DOMRefCell<Option<Vec<StylesheetInDocument>>>, /// Whether the list of stylesheets has changed since the last reflow was triggered. @@ -1964,6 +1968,7 @@ pub trait LayoutDocumentHelpers { unsafe fn needs_paint_from_layout(&self); unsafe fn will_paint(&self); unsafe fn quirks_mode(&self) -> QuirksMode; + unsafe fn style_shared_lock(&self) -> &StyleSharedRwLock; } #[allow(unsafe_code)] @@ -2000,6 +2005,11 @@ impl LayoutDocumentHelpers for LayoutJS<Document> { unsafe fn quirks_mode(&self) -> QuirksMode { (*self.unsafe_get()).quirks_mode() } + + #[inline] + unsafe fn style_shared_lock(&self) -> &StyleSharedRwLock { + (*self.unsafe_get()).style_shared_lock() + } } // https://html.spec.whatwg.org/multipage/#is-a-registrable-domain-suffix-of-or-is-equal-to @@ -2121,6 +2131,7 @@ impl Document { scripts: Default::default(), anchors: Default::default(), applets: Default::default(), + style_shared_lock: StyleSharedRwLock::new(), stylesheets: DOMRefCell::new(None), stylesheets_changed_since_reflow: Cell::new(false), stylesheet_list: MutNullableJS::new(None), @@ -2250,6 +2261,11 @@ impl Document { }; } + /// Return a reference to the per-document shared lock used in stylesheets. + pub fn style_shared_lock(&self) -> &StyleSharedRwLock { + &self.style_shared_lock + } + /// Returns the list of stylesheets associated with nodes in the document. pub fn stylesheets(&self) -> Vec<Arc<Stylesheet>> { self.ensure_stylesheets(); |