diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2016-12-16 16:39:58 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2016-12-16 17:59:45 +0100 |
commit | b9901fbd89a9f13b7dca80789ec84398443f3bee (patch) | |
tree | 3db385950fc2d92bf8c7f7305df528220925e12b /components/script/dom/htmlstyleelement.rs | |
parent | 072db0279aab898fd2f7af263cfbf9ea5a1ea6c9 (diff) | |
download | servo-b9901fbd89a9f13b7dca80789ec84398443f3bee.tar.gz servo-b9901fbd89a9f13b7dca80789ec84398443f3bee.zip |
script: Abstract HTMLLinkElement and StyleElement into StylesheetOwner.
Diffstat (limited to 'components/script/dom/htmlstyleelement.rs')
-rw-r--r-- | components/script/dom/htmlstyleelement.rs | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index 4cf0575ed3d..2507f7bee35 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -19,13 +19,14 @@ use dom::node::{ChildrenMutation, Node, document_from_node, window_from_node}; use dom::stylesheet::StyleSheet as DOMStyleSheet; use dom::virtualmethods::VirtualMethods; use html5ever_atoms::LocalName; +use net_traits::ReferrerPolicy; use script_layout_interface::message::Msg; use std::cell::Cell; use std::sync::Arc; use style::media_queries::parse_media_query_list; use style::parser::ParserContextExtraData; use style::stylesheets::{Stylesheet, Origin}; -use stylesheet_loader::StylesheetLoader; +use stylesheet_loader::{StylesheetLoader, StylesheetOwner}; #[dom_struct] pub struct HTMLStyleElement { @@ -64,28 +65,6 @@ impl HTMLStyleElement { HTMLStyleElementBinding::Wrap) } - pub fn increment_pending_loads_count(&self) { - self.pending_loads.set(self.pending_loads.get() + 1) - } - - /// Returns None if there are still pending loads, or whether any load has - /// failed since the loads started. - pub fn load_finished(&self, succeeded: bool) -> Option<bool> { - assert!(self.pending_loads.get() > 0, "What finished?"); - if !succeeded { - self.any_failed_load.set(true); - } - - self.pending_loads.set(self.pending_loads.get() - 1); - if self.pending_loads.get() != 0 { - return None; - } - - let any_failed = self.any_failed_load.get(); - self.any_failed_load.set(false); - Some(any_failed) - } - pub fn parse_own_css(&self) { let node = self.upcast::<Node>(); let element = self.upcast::<Element>(); @@ -137,10 +116,6 @@ impl HTMLStyleElement { }) }) } - - pub fn parser_inserted(&self) -> bool { - self.parser_inserted.get() - } } impl VirtualMethods for HTMLStyleElement { @@ -168,6 +143,37 @@ impl VirtualMethods for HTMLStyleElement { } } +impl StylesheetOwner for HTMLStyleElement { + fn increment_pending_loads_count(&self) { + self.pending_loads.set(self.pending_loads.get() + 1) + } + + fn load_finished(&self, succeeded: bool) -> Option<bool> { + assert!(self.pending_loads.get() > 0, "What finished?"); + if !succeeded { + self.any_failed_load.set(true); + } + + self.pending_loads.set(self.pending_loads.get() - 1); + if self.pending_loads.get() != 0 { + return None; + } + + let any_failed = self.any_failed_load.get(); + self.any_failed_load.set(false); + Some(any_failed) + } + + fn parser_inserted(&self) -> bool { + self.parser_inserted.get() + } + + fn referrer_policy(&self) -> Option<ReferrerPolicy> { + None + } +} + + impl HTMLStyleElementMethods for HTMLStyleElement { // https://drafts.csswg.org/cssom/#dom-linkstyle-sheet fn GetSheet(&self) -> Option<Root<DOMStyleSheet>> { |