mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Upgrade to SM 39
This commit is contained in:
parent
a256f39796
commit
675267b782
205 changed files with 6546 additions and 5340 deletions
|
@ -7,14 +7,13 @@ use dom::attr::AttrHelpers;
|
|||
use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
|
||||
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{CharacterDataCast, ElementCast, HTMLElementCast, NodeCast};
|
||||
use dom::bindings::codegen::InheritTypes::{CharacterDataCast, ElementCast, HTMLElementCast, NodeCast, TextDerived};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLOptionElementDerived};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLScriptElementDerived};
|
||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use dom::bindings::js::{JSRef, Rootable, Temporary};
|
||||
use dom::characterdata::CharacterData;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::document::Document;
|
||||
use dom::element::{AttributeHandlers, Element, ElementHelpers};
|
||||
use dom::element::{AttributeHandlers, ElementHelpers};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
|
@ -39,7 +38,7 @@ impl HTMLOptionElementDerived for EventTarget {
|
|||
impl HTMLOptionElement {
|
||||
fn new_inherited(localName: DOMString,
|
||||
prefix: Option<DOMString>,
|
||||
document: JSRef<Document>) -> HTMLOptionElement {
|
||||
document: &Document) -> HTMLOptionElement {
|
||||
HTMLOptionElement {
|
||||
htmlelement:
|
||||
HTMLElement::new_inherited(HTMLElementTypeId::HTMLOptionElement, localName, prefix, document)
|
||||
|
@ -49,23 +48,22 @@ impl HTMLOptionElement {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub fn new(localName: DOMString,
|
||||
prefix: Option<DOMString>,
|
||||
document: JSRef<Document>) -> Temporary<HTMLOptionElement> {
|
||||
document: &Document) -> Root<HTMLOptionElement> {
|
||||
let element = HTMLOptionElement::new_inherited(localName, prefix, document);
|
||||
Node::reflect_node(box element, document, HTMLOptionElementBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
fn collect_text(node: &JSRef<Node>, value: &mut DOMString) {
|
||||
let elem: JSRef<Element> = ElementCast::to_ref(*node).unwrap();
|
||||
fn collect_text(node: &&Node, value: &mut DOMString) {
|
||||
let elem = ElementCast::to_ref(*node).unwrap();
|
||||
let svg_script = *elem.namespace() == ns!(SVG) && elem.local_name() == &atom!("script");
|
||||
let html_script = node.is_htmlscriptelement();
|
||||
if svg_script || html_script {
|
||||
return;
|
||||
} else {
|
||||
for child in node.children() {
|
||||
let child = child.root();
|
||||
if child.r().is_text() {
|
||||
let characterdata: JSRef<CharacterData> = CharacterDataCast::to_ref(child.r()).unwrap();
|
||||
let characterdata = CharacterDataCast::to_ref(child.r()).unwrap();
|
||||
value.push_str(&characterdata.Data());
|
||||
} else {
|
||||
collect_text(&child.r(), value);
|
||||
|
@ -74,19 +72,19 @@ fn collect_text(node: &JSRef<Node>, value: &mut DOMString) {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> HTMLOptionElementMethods for JSRef<'a, HTMLOptionElement> {
|
||||
impl<'a> HTMLOptionElementMethods for &'a HTMLOptionElement {
|
||||
// https://www.whatwg.org/html/#dom-option-disabled
|
||||
make_bool_getter!(Disabled);
|
||||
|
||||
// https://www.whatwg.org/html/#dom-option-disabled
|
||||
fn SetDisabled(self, disabled: bool) {
|
||||
let elem: JSRef<Element> = ElementCast::from_ref(self);
|
||||
let elem = ElementCast::from_ref(self);
|
||||
elem.set_bool_attribute(&atom!("disabled"), disabled)
|
||||
}
|
||||
|
||||
// https://www.whatwg.org/html/#dom-option-text
|
||||
fn Text(self) -> DOMString {
|
||||
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||
let node = NodeCast::from_ref(self);
|
||||
let mut content = String::new();
|
||||
collect_text(&node, &mut content);
|
||||
let v: Vec<&str> = split_html_space_chars(&content).collect();
|
||||
|
@ -95,13 +93,13 @@ impl<'a> HTMLOptionElementMethods for JSRef<'a, HTMLOptionElement> {
|
|||
|
||||
// https://www.whatwg.org/html/#dom-option-text
|
||||
fn SetText(self, value: DOMString) {
|
||||
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||
let node = NodeCast::from_ref(self);
|
||||
node.SetTextContent(Some(value))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#attr-option-value
|
||||
fn Value(self) -> DOMString {
|
||||
let element: JSRef<Element> = ElementCast::from_ref(self);
|
||||
let element = ElementCast::from_ref(self);
|
||||
let attr = &atom!("value");
|
||||
if element.has_attribute(attr) {
|
||||
element.get_string_attribute(attr)
|
||||
|
@ -115,7 +113,7 @@ impl<'a> HTMLOptionElementMethods for JSRef<'a, HTMLOptionElement> {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#attr-option-label
|
||||
fn Label(self) -> DOMString {
|
||||
let element: JSRef<Element> = ElementCast::from_ref(self);
|
||||
let element = ElementCast::from_ref(self);
|
||||
let attr = &atom!("label");
|
||||
if element.has_attribute(attr) {
|
||||
element.get_string_attribute(attr)
|
||||
|
@ -129,20 +127,20 @@ impl<'a> HTMLOptionElementMethods for JSRef<'a, HTMLOptionElement> {
|
|||
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
|
||||
impl<'a> VirtualMethods for &'a HTMLOptionElement {
|
||||
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 +148,14 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
|
|||
}
|
||||
}
|
||||
|
||||
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_parent_disabled_state_for_option();
|
||||
|
@ -171,7 +169,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
|
|||
s.bind_to_tree(tree_in_doc);
|
||||
}
|
||||
|
||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||
let node = NodeCast::from_ref(*self);
|
||||
node.check_parent_disabled_state_for_option();
|
||||
}
|
||||
|
||||
|
@ -180,7 +178,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
|
|||
s.unbind_from_tree(tree_in_doc);
|
||||
}
|
||||
|
||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||
let node = NodeCast::from_ref(*self);
|
||||
if node.GetParentNode().is_some() {
|
||||
node.check_parent_disabled_state_for_option();
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue