Auto merge of #6291 - Ms2ger:caption, r=nox

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6291)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-06-06 07:45:43 -05:00
commit 493f96b9ab

View file

@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::HTMLTableElementBinding;
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLTableCaptionElementCast}; use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLTableCaptionElementCast};
use dom::bindings::codegen::InheritTypes::{HTMLTableElementDerived, NodeCast}; use dom::bindings::codegen::InheritTypes::{HTMLTableElementDerived, NodeCast};
use dom::bindings::js::{JSRef, Rootable, Temporary}; use dom::bindings::js::{JSRef, Rootable, Temporary, OptionalRootable, RootedReference};
use dom::document::Document; use dom::document::Document;
use dom::eventtarget::{EventTarget, EventTargetTypeId}; use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::element::ElementTypeId; use dom::element::ElementTypeId;
@ -79,21 +79,14 @@ impl<'a> HTMLTableElementMethods for JSRef<'a, HTMLTableElement> {
// https://www.whatwg.org/html/#dom-table-caption // https://www.whatwg.org/html/#dom-table-caption
fn SetCaption(self, new_caption: Option<JSRef<HTMLTableCaptionElement>>) { fn SetCaption(self, new_caption: Option<JSRef<HTMLTableCaptionElement>>) {
let node: JSRef<Node> = NodeCast::from_ref(self); let node: JSRef<Node> = NodeCast::from_ref(self);
let old_caption = self.GetCaption();
match old_caption { if let Some(ref caption) = self.GetCaption().root() {
Some(htmlelem) => { assert!(node.RemoveChild(NodeCast::from_ref(caption.r())).is_ok());
let htmlelem_root = htmlelem.root();
let old_caption_node: JSRef<Node> = NodeCast::from_ref(htmlelem_root.r());
assert!(node.RemoveChild(old_caption_node).is_ok());
}
None => ()
} }
new_caption.map(|caption| { if let Some(caption) = new_caption {
let new_caption_node: JSRef<Node> = NodeCast::from_ref(caption); assert!(node.AppendChild(NodeCast::from_ref(caption)).is_ok());
assert!(node.AppendChild(new_caption_node).is_ok()); }
});
} }
} }