Move child_inserted into VirtualMethods.

Follow-up from #1984.
This commit is contained in:
Matt Brubeck 2014-04-14 11:12:00 -07:00
parent 18b5453e09
commit 28a013cfc5
3 changed files with 34 additions and 16 deletions

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::HTMLStyleElementBinding;
use dom::bindings::codegen::InheritTypes::{HTMLStyleElementDerived, NodeCast};
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLStyleElementDerived, NodeCast};
use dom::bindings::js::JS;
use dom::bindings::error::ErrorResult;
use dom::document::Document;
@ -11,6 +11,7 @@ use dom::element::HTMLStyleElementTypeId;
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlelement::HTMLElement;
use dom::node::{Node, ElementNodeTypeId, window_from_node};
use dom::virtualmethods::VirtualMethods;
use html::cssparse::parse_inline_css;
use layout_interface::{AddStylesheetMsg, LayoutChan};
use servo_util::str::DOMString;
@ -91,3 +92,18 @@ impl StyleElementHelpers for JS<HTMLStyleElement> {
layout_chan.send(AddStylesheetMsg(sheet));
}
}
impl VirtualMethods for JS<HTMLStyleElement> {
fn super_type(&self) -> Option<~VirtualMethods:> {
let htmlelement: JS<HTMLElement> = HTMLElementCast::from(self);
Some(~htmlelement as ~VirtualMethods:)
}
fn child_inserted(&mut self, child: &JS<Node>) {
match self.super_type() {
Some(ref mut s) => s.child_inserted(child),
_ => (),
}
self.parse_own_css();
}
}