mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Use new if let
syntax wherever possible. Fixes #4153.
This commit is contained in:
parent
09c36de8f1
commit
08ac0766ed
25 changed files with 178 additions and 262 deletions
|
@ -224,23 +224,16 @@ fn create_interface_object(cx: *mut JSContext, global: *mut JSObject,
|
||||||
let constructor = JS_GetFunctionObject(fun);
|
let constructor = JS_GetFunctionObject(fun);
|
||||||
assert!(!constructor.is_null());
|
assert!(!constructor.is_null());
|
||||||
|
|
||||||
match members.static_methods {
|
if let Some(static_methods) = members.static_methods {
|
||||||
Some(static_methods) => {
|
define_methods(cx, constructor, static_methods);
|
||||||
define_methods(cx, constructor, static_methods)
|
|
||||||
},
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match members.static_attrs {
|
if let Some(static_properties) = members.static_attrs {
|
||||||
Some(static_properties) => {
|
define_properties(cx, constructor, static_properties);
|
||||||
define_properties(cx, constructor, static_properties)
|
|
||||||
},
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match members.consts {
|
if let Some(constants) = members.consts {
|
||||||
Some(constants) => define_constants(cx, constructor, constants),
|
define_constants(cx, constructor, constants);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !proto.is_null() {
|
if !proto.is_null() {
|
||||||
|
@ -304,19 +297,16 @@ fn create_interface_prototype_object(cx: *mut JSContext, global: *mut JSObject,
|
||||||
&*parent_proto, &*global);
|
&*parent_proto, &*global);
|
||||||
assert!(!our_proto.is_null());
|
assert!(!our_proto.is_null());
|
||||||
|
|
||||||
match members.methods {
|
if let Some(methods) = members.methods {
|
||||||
Some(methods) => define_methods(cx, our_proto, methods),
|
define_methods(cx, our_proto, methods);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match members.attrs {
|
if let Some(properties) = members.attrs {
|
||||||
Some(properties) => define_properties(cx, our_proto, properties),
|
define_properties(cx, our_proto, properties);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match members.consts {
|
if let Some(constants) = members.consts {
|
||||||
Some(constants) => define_constants(cx, our_proto, constants),
|
define_constants(cx, our_proto, constants);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return our_proto;
|
return our_proto;
|
||||||
|
|
|
@ -1166,9 +1166,8 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -1218,9 +1217,8 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -1275,9 +1273,8 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, tree_in_doc: bool) {
|
fn bind_to_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.bind_to_tree(tree_in_doc),
|
s.bind_to_tree(tree_in_doc);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !tree_in_doc { return; }
|
if !tree_in_doc { return; }
|
||||||
|
@ -1296,9 +1293,8 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unbind_from_tree(&self, tree_in_doc: bool) {
|
fn unbind_from_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.unbind_from_tree(tree_in_doc),
|
s.unbind_from_tree(tree_in_doc);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !tree_in_doc { return; }
|
if !tree_in_doc { return; }
|
||||||
|
|
|
@ -85,9 +85,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLBodyElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let name = attr.local_name().as_slice();
|
let name = attr.local_name().as_slice();
|
||||||
|
|
|
@ -116,9 +116,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -132,9 +131,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -149,9 +147,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, tree_in_doc: bool) {
|
fn bind_to_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.bind_to_tree(tree_in_doc),
|
s.bind_to_tree(tree_in_doc);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
|
@ -159,9 +156,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unbind_from_tree(&self, tree_in_doc: bool) {
|
fn unbind_from_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.unbind_from_tree(tree_in_doc),
|
s.unbind_from_tree(tree_in_doc);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
|
@ -209,7 +205,7 @@ impl<'a> Activatable for JSRef<'a, HTMLButtonElement> {
|
||||||
o.root().r().submit(SubmittedFrom::NotFromFormSubmitMethod,
|
o.root().r().submit(SubmittedFrom::NotFromFormSubmitMethod,
|
||||||
FormSubmitter::ButtonElement(self.clone()))
|
FormSubmitter::ButtonElement(self.clone()))
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,9 +132,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let recreate = match attr.local_name() {
|
let recreate = match attr.local_name() {
|
||||||
|
@ -159,9 +158,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let value = attr.value();
|
let value = attr.value();
|
||||||
|
|
|
@ -126,9 +126,10 @@ impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
|
||||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-click
|
// https://html.spec.whatwg.org/multipage/interaction.html#dom-click
|
||||||
fn Click(self) {
|
fn Click(self) {
|
||||||
let maybe_input: Option<JSRef<HTMLInputElement>> = HTMLInputElementCast::to_ref(self);
|
let maybe_input: Option<JSRef<HTMLInputElement>> = HTMLInputElementCast::to_ref(self);
|
||||||
match maybe_input {
|
if let Some(i) = maybe_input {
|
||||||
Some(i) if i.Disabled() => return,
|
if i.Disabled() {
|
||||||
_ => ()
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let element: JSRef<Element> = ElementCast::from_ref(self);
|
let element: JSRef<Element> = ElementCast::from_ref(self);
|
||||||
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=27430 ?
|
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=27430 ?
|
||||||
|
@ -188,9 +189,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let name = attr.local_name().as_slice();
|
let name = attr.local_name().as_slice();
|
||||||
|
|
|
@ -84,9 +84,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLFieldSetElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -116,9 +115,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLFieldSetElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
|
|
@ -203,9 +203,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -244,9 +243,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -256,9 +254,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, tree_in_doc: bool) {
|
fn bind_to_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.bind_to_tree(tree_in_doc),
|
s.bind_to_tree(tree_in_doc);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if tree_in_doc {
|
if tree_in_doc {
|
||||||
|
|
|
@ -183,9 +183,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLImageElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -199,9 +198,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLImageElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
|
|
@ -425,9 +425,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -485,9 +484,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -540,9 +538,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, tree_in_doc: bool) {
|
fn bind_to_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.bind_to_tree(tree_in_doc),
|
s.bind_to_tree(tree_in_doc);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
|
@ -550,9 +547,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unbind_from_tree(&self, tree_in_doc: bool) {
|
fn unbind_from_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.unbind_from_tree(tree_in_doc),
|
s.unbind_from_tree(tree_in_doc);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
|
@ -564,11 +560,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_event(&self, event: JSRef<Event>) {
|
fn handle_event(&self, event: JSRef<Event>) {
|
||||||
match self.super_type() {
|
if let Some(s) = self.super_type() {
|
||||||
Some(s) => {
|
s.handle_event(event);
|
||||||
s.handle_event(event);
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if "click" == event.Type().as_slice() && !event.DefaultPrevented() {
|
if "click" == event.Type().as_slice() && !event.DefaultPrevented() {
|
||||||
|
|
|
@ -76,9 +76,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLLinkElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let element: JSRef<Element> = ElementCast::from_ref(*self);
|
let element: JSRef<Element> = ElementCast::from_ref(*self);
|
||||||
|
@ -102,9 +101,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLLinkElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, tree_in_doc: bool) {
|
fn bind_to_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.bind_to_tree(tree_in_doc),
|
s.bind_to_tree(tree_in_doc);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if tree_in_doc {
|
if tree_in_doc {
|
||||||
|
|
|
@ -102,9 +102,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLObjectElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
|
|
@ -60,9 +60,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptGroupElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -75,14 +74,13 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptGroupElement> {
|
||||||
child.set_enabled_state(false);
|
child.set_enabled_state(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => ()
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
|
|
@ -129,9 +129,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -139,15 +138,14 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
node.set_disabled_state(true);
|
node.set_disabled_state(true);
|
||||||
node.set_enabled_state(false);
|
node.set_enabled_state(false);
|
||||||
}
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -162,9 +160,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, tree_in_doc: bool) {
|
fn bind_to_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.bind_to_tree(tree_in_doc),
|
s.bind_to_tree(tree_in_doc);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
|
@ -172,9 +169,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unbind_from_tree(&self, tree_in_doc: bool) {
|
fn unbind_from_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.unbind_from_tree(tree_in_doc),
|
s.unbind_from_tree(tree_in_doc);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
|
|
|
@ -473,9 +473,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLScriptElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
if attr.local_name() == &atom!("src") && !self.parser_inserted.get() && node.is_in_doc() {
|
if attr.local_name() == &atom!("src") && !self.parser_inserted.get() && node.is_in_doc() {
|
||||||
|
@ -484,9 +483,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLScriptElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn child_inserted(&self, child: JSRef<Node>) {
|
fn child_inserted(&self, child: JSRef<Node>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.child_inserted(child),
|
s.child_inserted(child);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
if !self.parser_inserted.get() && node.is_in_doc() {
|
if !self.parser_inserted.get() && node.is_in_doc() {
|
||||||
|
@ -495,9 +493,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLScriptElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, tree_in_doc: bool) {
|
fn bind_to_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.bind_to_tree(tree_in_doc),
|
s.bind_to_tree(tree_in_doc);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if tree_in_doc && !self.parser_inserted.get() {
|
if tree_in_doc && !self.parser_inserted.get() {
|
||||||
|
@ -507,9 +504,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLScriptElement> {
|
||||||
|
|
||||||
fn cloning_steps(&self, copy: JSRef<Node>, maybe_doc: Option<JSRef<Document>>,
|
fn cloning_steps(&self, copy: JSRef<Node>, maybe_doc: Option<JSRef<Document>>,
|
||||||
clone_children: CloneChildrenFlag) {
|
clone_children: CloneChildrenFlag) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.cloning_steps(copy, maybe_doc, clone_children),
|
s.cloning_steps(copy, maybe_doc, clone_children);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://whatwg.org/html/#already-started
|
// https://whatwg.org/html/#already-started
|
||||||
|
|
|
@ -84,9 +84,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLSelectElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -100,9 +99,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLSelectElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -117,9 +115,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLSelectElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, tree_in_doc: bool) {
|
fn bind_to_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.bind_to_tree(tree_in_doc),
|
s.bind_to_tree(tree_in_doc);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
|
@ -127,9 +124,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLSelectElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unbind_from_tree(&self, tree_in_doc: bool) {
|
fn unbind_from_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.unbind_from_tree(tree_in_doc),
|
s.unbind_from_tree(tree_in_doc);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
|
|
|
@ -69,9 +69,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLStyleElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn child_inserted(&self, child: JSRef<Node>) {
|
fn child_inserted(&self, child: JSRef<Node>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.child_inserted(child),
|
s.child_inserted(child);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
|
@ -81,9 +80,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLStyleElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, tree_in_doc: bool) {
|
fn bind_to_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.bind_to_tree(tree_in_doc),
|
s.bind_to_tree(tree_in_doc);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if tree_in_doc {
|
if tree_in_doc {
|
||||||
|
|
|
@ -87,9 +87,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTableCellElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -105,9 +104,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTableCellElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
|
|
@ -118,9 +118,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTableElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -139,9 +138,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTableElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
|
|
@ -68,28 +68,28 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTableRowElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
&atom!("bgcolor") => {
|
&atom!("bgcolor") => {
|
||||||
self.background_color.set(str::parse_legacy_color(attr.value().as_slice()).ok())
|
self.background_color.set(str::parse_legacy_color(attr.value().as_slice()).ok());
|
||||||
}
|
},
|
||||||
_ => {}
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
&atom!("bgcolor") => self.background_color.set(None),
|
&atom!("bgcolor") => {
|
||||||
_ => {}
|
self.background_color.set(None);
|
||||||
|
},
|
||||||
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,28 +66,28 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTableSectionElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
&atom!("bgcolor") => {
|
&atom!("bgcolor") => {
|
||||||
self.background_color.set(str::parse_legacy_color(attr.value().as_slice()).ok())
|
self.background_color.set(str::parse_legacy_color(attr.value().as_slice()).ok());
|
||||||
}
|
},
|
||||||
_ => {}
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
&atom!("bgcolor") => self.background_color.set(None),
|
&atom!("bgcolor") => {
|
||||||
_ => {}
|
self.background_color.set(None);
|
||||||
|
},
|
||||||
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,9 +224,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -252,9 +251,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match attr.local_name() {
|
match attr.local_name() {
|
||||||
|
@ -275,9 +273,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, tree_in_doc: bool) {
|
fn bind_to_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.bind_to_tree(tree_in_doc),
|
s.bind_to_tree(tree_in_doc);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
|
@ -293,9 +290,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unbind_from_tree(&self, tree_in_doc: bool) {
|
fn unbind_from_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.unbind_from_tree(tree_in_doc),
|
s.unbind_from_tree(tree_in_doc);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
|
@ -307,11 +303,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn child_inserted(&self, child: JSRef<Node>) {
|
fn child_inserted(&self, child: JSRef<Node>) {
|
||||||
match self.super_type() {
|
if let Some(s) = self.super_type() {
|
||||||
Some(s) => {
|
s.child_inserted(child);
|
||||||
s.child_inserted(child);
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if child.is_text() && !self.value_changed.get() {
|
if child.is_text() && !self.value_changed.get() {
|
||||||
|
@ -321,11 +314,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
|
||||||
|
|
||||||
// copied and modified from htmlinputelement.rs
|
// copied and modified from htmlinputelement.rs
|
||||||
fn handle_event(&self, event: JSRef<Event>) {
|
fn handle_event(&self, event: JSRef<Event>) {
|
||||||
match self.super_type() {
|
if let Some(s) = self.super_type() {
|
||||||
Some(s) => {
|
s.handle_event(event);
|
||||||
s.handle_event(event);
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if "click" == event.Type().as_slice() && !event.DefaultPrevented() {
|
if "click" == event.Type().as_slice() && !event.DefaultPrevented() {
|
||||||
|
|
|
@ -71,9 +71,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTitleElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn child_inserted(&self, child: JSRef<Node>) {
|
fn child_inserted(&self, child: JSRef<Node>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.child_inserted(child),
|
s.child_inserted(child);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
|
|
|
@ -1284,9 +1284,10 @@ impl Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3.
|
// Step 3.
|
||||||
match child {
|
if let Some(child) = child {
|
||||||
Some(child) if !parent.is_parent_of(child) => return Err(NotFound),
|
if !parent.is_parent_of(child) {
|
||||||
_ => ()
|
return Err(NotFound);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 4-5.
|
// Step 4-5.
|
||||||
|
@ -1325,14 +1326,11 @@ impl Node {
|
||||||
if !parent.child_elements().is_empty() {
|
if !parent.child_elements().is_empty() {
|
||||||
return Err(HierarchyRequest);
|
return Err(HierarchyRequest);
|
||||||
}
|
}
|
||||||
match child {
|
if let Some(child) = child {
|
||||||
Some(child) => {
|
if child.inclusively_following_siblings()
|
||||||
if child.inclusively_following_siblings()
|
.any(|child| child.is_doctype()) {
|
||||||
.any(|child| child.is_doctype()) {
|
return Err(HierarchyRequest);
|
||||||
return Err(HierarchyRequest)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Step 6.1.1(a)
|
// Step 6.1.1(a)
|
||||||
|
@ -1344,14 +1342,11 @@ impl Node {
|
||||||
if !parent.child_elements().is_empty() {
|
if !parent.child_elements().is_empty() {
|
||||||
return Err(HierarchyRequest);
|
return Err(HierarchyRequest);
|
||||||
}
|
}
|
||||||
match child {
|
if let Some(ref child) = child {
|
||||||
Some(ref child) => {
|
if child.inclusively_following_siblings()
|
||||||
if child.inclusively_following_siblings()
|
.any(|child| child.is_doctype()) {
|
||||||
.any(|child| child.is_doctype()) {
|
return Err(HierarchyRequest);
|
||||||
return Err(HierarchyRequest)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Step 6.3
|
// Step 6.3
|
||||||
|
@ -2368,12 +2363,11 @@ impl<'a> DisabledStateHelpers for JSRef<'a, Node> {
|
||||||
|
|
||||||
fn check_parent_disabled_state_for_option(self) {
|
fn check_parent_disabled_state_for_option(self) {
|
||||||
if self.get_disabled_state() { return; }
|
if self.get_disabled_state() { return; }
|
||||||
match self.parent_node().root() {
|
if let Some(ref parent) = self.parent_node().root() {
|
||||||
Some(ref parent) if parent.r().is_htmloptgroupelement() && parent.r().get_disabled_state() => {
|
if parent.r().is_htmloptgroupelement() && parent.r().get_disabled_state() {
|
||||||
self.set_disabled_state(true);
|
self.set_disabled_state(true);
|
||||||
self.set_enabled_state(false);
|
self.set_enabled_state(false);
|
||||||
},
|
}
|
||||||
_ => ()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,18 +71,16 @@ pub trait VirtualMethods {
|
||||||
/// Called when changing or adding attributes, after the attribute's value
|
/// Called when changing or adding attributes, after the attribute's value
|
||||||
/// has been updated.
|
/// has been updated.
|
||||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(attr),
|
s.after_set_attr(attr);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called when changing or removing attributes, before any modification
|
/// Called when changing or removing attributes, before any modification
|
||||||
/// has taken place.
|
/// has taken place.
|
||||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(attr),
|
s.before_remove_attr(attr);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,45 +96,38 @@ pub trait VirtualMethods {
|
||||||
/// Called when a Node is appended to a tree, where 'tree_in_doc' indicates
|
/// Called when a Node is appended to a tree, where 'tree_in_doc' indicates
|
||||||
/// whether the tree is part of a Document.
|
/// whether the tree is part of a Document.
|
||||||
fn bind_to_tree(&self, tree_in_doc: bool) {
|
fn bind_to_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.bind_to_tree(tree_in_doc),
|
s.bind_to_tree(tree_in_doc);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called when a Node is removed from a tree, where 'tree_in_doc'
|
/// Called when a Node is removed from a tree, where 'tree_in_doc'
|
||||||
/// indicates whether the tree is part of a Document.
|
/// indicates whether the tree is part of a Document.
|
||||||
fn unbind_from_tree(&self, tree_in_doc: bool) {
|
fn unbind_from_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.unbind_from_tree(tree_in_doc),
|
s.unbind_from_tree(tree_in_doc);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called on the parent when a node is added to its child list.
|
/// Called on the parent when a node is added to its child list.
|
||||||
fn child_inserted(&self, child: JSRef<Node>) {
|
fn child_inserted(&self, child: JSRef<Node>) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.child_inserted(child),
|
s.child_inserted(child);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called during event dispatch after the bubbling phase completes.
|
/// Called during event dispatch after the bubbling phase completes.
|
||||||
fn handle_event(&self, event: JSRef<Event>) {
|
fn handle_event(&self, event: JSRef<Event>) {
|
||||||
match self.super_type() {
|
if let Some(s) = self.super_type() {
|
||||||
Some(s) => {
|
s.handle_event(event);
|
||||||
s.handle_event(event);
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://dom.spec.whatwg.org/#concept-node-clone (step 5)
|
/// https://dom.spec.whatwg.org/#concept-node-clone (step 5)
|
||||||
fn cloning_steps(&self, copy: JSRef<Node>, maybe_doc: Option<JSRef<Document>>,
|
fn cloning_steps(&self, copy: JSRef<Node>, maybe_doc: Option<JSRef<Document>>,
|
||||||
clone_children: CloneChildrenFlag) {
|
clone_children: CloneChildrenFlag) {
|
||||||
match self.super_type() {
|
if let Some(ref s) = self.super_type() {
|
||||||
Some(ref s) => s.cloning_steps(copy, maybe_doc, clone_children),
|
s.cloning_steps(copy, maybe_doc, clone_children);
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue