servo: Merge #2692 - HTMLStyleElement only applies CSS in the document; r=Ms2ger (from Martiusweb:style_is_in_doc)

Source-Repo: https://github.com/servo/servo
Source-Revision: 1a349369f10c9e031e302a0e3cbc36eec34e08ff
This commit is contained in:
Martin Richard 2014-06-21 19:38:31 +02:00
Родитель 4f30524c0c
Коммит 69973c3cc4
1 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -9,7 +9,7 @@ use dom::document::Document;
use dom::element::HTMLStyleElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlelement::HTMLElement;
use dom::node::{Node, NodeMethods, ElementNodeTypeId, window_from_node};
use dom::node::{Node, NodeMethods, NodeHelpers, ElementNodeTypeId, window_from_node};
use dom::virtualmethods::VirtualMethods;
use html::cssparse::parse_inline_css;
use layout_interface::{AddStylesheetMsg, LayoutChan};
@ -49,6 +49,11 @@ pub trait StyleElementHelpers {
impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> {
fn parse_own_css(&self) {
let node: &JSRef<Node> = NodeCast::from_ref(self);
if !node.is_in_doc() {
return;
}
let win = window_from_node(node).root();
let url = win.deref().page().get_url();
@ -72,4 +77,12 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLStyleElement> {
}
self.parse_own_css();
}
fn bind_to_tree(&self) {
match self.super_type() {
Some(ref s) => s.bind_to_tree(),
_ => ()
}
self.parse_own_css();
}
}