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/element.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/element.rs')
-rw-r--r-- | components/script/dom/element.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 66021ce6104..21dfde99f22 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -51,9 +51,11 @@ use dom::htmlimageelement::{HTMLImageElement, LayoutHTMLImageElementHelpers}; use dom::htmlinputelement::{HTMLInputElement, LayoutHTMLInputElementHelpers}; use dom::htmllabelelement::HTMLLabelElement; use dom::htmllegendelement::HTMLLegendElement; +use dom::htmllinkelement::HTMLLinkElement; use dom::htmlobjectelement::HTMLObjectElement; use dom::htmloptgroupelement::HTMLOptGroupElement; use dom::htmlselectelement::HTMLSelectElement; +use dom::htmlstyleelement::HTMLStyleElement; use dom::htmltablecellelement::{HTMLTableCellElement, HTMLTableCellElementLayoutHelpers}; use dom::htmltableelement::{HTMLTableElement, HTMLTableElementLayoutHelpers}; use dom::htmltablerowelement::{HTMLTableRowElement, HTMLTableRowElementLayoutHelpers}; @@ -109,6 +111,7 @@ use style::sink::Push; use style::stylist::ApplicableDeclarationBlock; use style::values::CSSFloat; use style::values::specified::{self, CSSColor, CSSRGBA, LengthOrPercentage}; +use stylesheet_loader::StylesheetOwner; // TODO: Update focus state when the top-level browsing context gains or loses system focus, // and when the element enters or leaves a browsing context container. @@ -2407,6 +2410,18 @@ impl Element { }) } + pub fn as_stylesheet_owner(&self) -> Option<&StylesheetOwner> { + if let Some(s) = self.downcast::<HTMLStyleElement>() { + return Some(s as &StylesheetOwner) + } + + if let Some(l) = self.downcast::<HTMLLinkElement>() { + return Some(l as &StylesheetOwner) + } + + None + } + // https://html.spec.whatwg.org/multipage/#category-submit pub fn as_maybe_validatable(&self) -> Option<&Validatable> { let element = match self.upcast::<Node>().type_id() { |