mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Upgrade to SM 39
This commit is contained in:
parent
a256f39796
commit
675267b782
205 changed files with 6546 additions and 5340 deletions
|
@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::HTMLButtonElementBinding;
|
|||
use dom::bindings::codegen::Bindings::HTMLButtonElementBinding::HTMLButtonElementMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, HTMLButtonElementCast, NodeCast};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLButtonElementDerived, HTMLFieldSetElementDerived};
|
||||
use dom::bindings::js::{JSRef, Rootable, Temporary};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::document::Document;
|
||||
use dom::element::{AttributeHandlers, Element, ElementTypeId};
|
||||
use dom::element::ActivationElementHelpers;
|
||||
|
@ -54,7 +54,7 @@ impl HTMLButtonElementDerived for EventTarget {
|
|||
impl HTMLButtonElement {
|
||||
fn new_inherited(localName: DOMString,
|
||||
prefix: Option<DOMString>,
|
||||
document: JSRef<Document>) -> HTMLButtonElement {
|
||||
document: &Document) -> HTMLButtonElement {
|
||||
HTMLButtonElement {
|
||||
htmlelement:
|
||||
HTMLElement::new_inherited(HTMLElementTypeId::HTMLButtonElement, localName, prefix, document),
|
||||
|
@ -66,15 +66,15 @@ impl HTMLButtonElement {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub fn new(localName: DOMString,
|
||||
prefix: Option<DOMString>,
|
||||
document: JSRef<Document>) -> Temporary<HTMLButtonElement> {
|
||||
document: &Document) -> Root<HTMLButtonElement> {
|
||||
let element = HTMLButtonElement::new_inherited(localName, prefix, document);
|
||||
Node::reflect_node(box element, document, HTMLButtonElementBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> HTMLButtonElementMethods for JSRef<'a, HTMLButtonElement> {
|
||||
fn Validity(self) -> Temporary<ValidityState> {
|
||||
let window = window_from_node(self).root();
|
||||
impl<'a> HTMLButtonElementMethods for &'a HTMLButtonElement {
|
||||
fn Validity(self) -> Root<ValidityState> {
|
||||
let window = window_from_node(self);
|
||||
ValidityState::new(window.r())
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ impl<'a> HTMLButtonElementMethods for JSRef<'a, HTMLButtonElement> {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-button-type
|
||||
fn Type(self) -> DOMString {
|
||||
let elem: JSRef<Element> = ElementCast::from_ref(self);
|
||||
let elem = ElementCast::from_ref(self);
|
||||
let ty = elem.get_string_attribute(&atom!("type")).into_ascii_lowercase();
|
||||
// https://html.spec.whatwg.org/multipage/#attr-button-type
|
||||
match &*ty {
|
||||
|
@ -129,20 +129,20 @@ impl<'a> HTMLButtonElementMethods for JSRef<'a, HTMLButtonElement> {
|
|||
make_setter!(SetValue, "value");
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
|
||||
impl<'a> VirtualMethods for &'a HTMLButtonElement {
|
||||
fn super_type<'b>(&'b self) -> Option<&'b VirtualMethods> {
|
||||
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
|
||||
let htmlelement: &&HTMLElement = HTMLElementCast::from_borrowed_ref(self);
|
||||
Some(htmlelement as &VirtualMethods)
|
||||
}
|
||||
|
||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||
fn after_set_attr(&self, attr: &Attr) {
|
||||
if let Some(ref s) = self.super_type() {
|
||||
s.after_set_attr(attr);
|
||||
}
|
||||
|
||||
match attr.local_name() {
|
||||
&atom!("disabled") => {
|
||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||
let node = NodeCast::from_ref(*self);
|
||||
node.set_disabled_state(true);
|
||||
node.set_enabled_state(false);
|
||||
},
|
||||
|
@ -150,14 +150,14 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
|
|||
}
|
||||
}
|
||||
|
||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||
fn before_remove_attr(&self, attr: &Attr) {
|
||||
if let Some(ref s) = self.super_type() {
|
||||
s.before_remove_attr(attr);
|
||||
}
|
||||
|
||||
match attr.local_name() {
|
||||
&atom!("disabled") => {
|
||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||
let node = NodeCast::from_ref(*self);
|
||||
node.set_disabled_state(false);
|
||||
node.set_enabled_state(true);
|
||||
node.check_ancestors_disabled_state_for_form_control();
|
||||
|
@ -171,7 +171,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
|
|||
s.bind_to_tree(tree_in_doc);
|
||||
}
|
||||
|
||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||
let node = NodeCast::from_ref(*self);
|
||||
node.check_ancestors_disabled_state_for_form_control();
|
||||
}
|
||||
|
||||
|
@ -180,8 +180,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
|
|||
s.unbind_from_tree(tree_in_doc);
|
||||
}
|
||||
|
||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||
if node.ancestors().any(|ancestor| ancestor.root().r().is_htmlfieldsetelement()) {
|
||||
let node = NodeCast::from_ref(*self);
|
||||
if node.ancestors().any(|ancestor| ancestor.r().is_htmlfieldsetelement()) {
|
||||
node.check_ancestors_disabled_state_for_form_control();
|
||||
} else {
|
||||
node.check_disabled_attribute();
|
||||
|
@ -189,20 +189,20 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> FormControl<'a> for JSRef<'a, HTMLButtonElement> {
|
||||
fn to_element(self) -> JSRef<'a, Element> {
|
||||
impl<'a> FormControl<'a> for &'a HTMLButtonElement {
|
||||
fn to_element(self) -> &'a Element {
|
||||
ElementCast::from_ref(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Activatable for JSRef<'a, HTMLButtonElement> {
|
||||
fn as_element(&self) -> Temporary<Element> {
|
||||
Temporary::from_rooted(ElementCast::from_ref(*self))
|
||||
impl<'a> Activatable for &'a HTMLButtonElement {
|
||||
fn as_element<'b>(&'b self) -> &'b Element {
|
||||
ElementCast::from_ref(*self)
|
||||
}
|
||||
|
||||
fn is_instance_activatable(&self) -> bool {
|
||||
//https://html.spec.whatwg.org/multipage/#the-button-element
|
||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||
let node = NodeCast::from_ref(*self);
|
||||
!(node.get_disabled_state())
|
||||
}
|
||||
|
||||
|
@ -216,14 +216,14 @@ impl<'a> Activatable for JSRef<'a, HTMLButtonElement> {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#run-post-click-activation-steps
|
||||
fn activation_behavior(&self, _event: JSRef<Event>, _target: JSRef<EventTarget>) {
|
||||
fn activation_behavior(&self, _event: &Event, _target: &EventTarget) {
|
||||
let ty = self.button_type.get();
|
||||
match ty {
|
||||
//https://html.spec.whatwg.org/multipage/#attr-button-type-submit-state
|
||||
ButtonType::ButtonSubmit => {
|
||||
self.form_owner().map(|o| {
|
||||
o.root().r().submit(SubmittedFrom::NotFromFormSubmitMethod,
|
||||
FormSubmitter::ButtonElement(self.clone()))
|
||||
o.r().submit(SubmittedFrom::NotFromFormSubmitMethod,
|
||||
FormSubmitter::ButtonElement(self.clone()))
|
||||
});
|
||||
},
|
||||
_ => ()
|
||||
|
@ -233,10 +233,10 @@ impl<'a> Activatable for JSRef<'a, HTMLButtonElement> {
|
|||
// https://html.spec.whatwg.org/multipage/#implicit-submission
|
||||
#[allow(unsafe_code)]
|
||||
fn implicit_submission(&self, ctrlKey: bool, shiftKey: bool, altKey: bool, metaKey: bool) {
|
||||
let doc = document_from_node(*self).root();
|
||||
let node: JSRef<Node> = NodeCast::from_ref(doc.r());
|
||||
let doc = document_from_node(*self);
|
||||
let node = NodeCast::from_ref(doc.r());
|
||||
let owner = self.form_owner();
|
||||
let elem: JSRef<Element> = ElementCast::from_ref(*self);
|
||||
let elem = ElementCast::from_ref(*self);
|
||||
if owner.is_none() || elem.click_in_progress() {
|
||||
return;
|
||||
}
|
||||
|
@ -244,8 +244,7 @@ impl<'a> Activatable for JSRef<'a, HTMLButtonElement> {
|
|||
// and only then performing actions which may modify the DOM tree
|
||||
unsafe {
|
||||
node.query_selector_iter("button[type=submit]".to_owned()).unwrap()
|
||||
.filter_map(HTMLButtonElementCast::to_temporary)
|
||||
.map(|t| t.root())
|
||||
.filter_map(HTMLButtonElementCast::to_root)
|
||||
.find(|r| r.r().form_owner() == owner)
|
||||
.map(|s| s.r().synthetic_click_activation(ctrlKey, shiftKey, altKey, metaKey));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue