mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
parent
db05417a25
commit
3a56a69581
7 changed files with 24 additions and 19 deletions
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
use dom::attr::{Attr, ReplacedAttr, FirstSetAttr, AttrHelpersForLayout};
|
use dom::attr::{Attr, ReplacedAttr, FirstSetAttr, AttrHelpersForLayout};
|
||||||
use dom::attr::{AttrValue, StringAttrValue, UIntAttrValue, AtomAttrValue};
|
use dom::attr::{AttrValue, StringAttrValue, UIntAttrValue, AtomAttrValue};
|
||||||
use dom::attrlist::AttrList;
|
use dom::namednodemap::NamedNodeMap;
|
||||||
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
||||||
use dom::bindings::codegen::Bindings::ElementBinding;
|
use dom::bindings::codegen::Bindings::ElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
|
use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
|
||||||
|
@ -49,7 +49,7 @@ pub struct Element {
|
||||||
pub prefix: Option<DOMString>,
|
pub prefix: Option<DOMString>,
|
||||||
pub attrs: RefCell<Vec<JS<Attr>>>,
|
pub attrs: RefCell<Vec<JS<Attr>>>,
|
||||||
pub style_attribute: Traceable<RefCell<Option<style::PropertyDeclarationBlock>>>,
|
pub style_attribute: Traceable<RefCell<Option<style::PropertyDeclarationBlock>>>,
|
||||||
pub attr_list: Cell<Option<JS<AttrList>>>,
|
pub attr_list: Cell<Option<JS<NamedNodeMap>>>,
|
||||||
class_list: Cell<Option<JS<DOMTokenList>>>,
|
class_list: Cell<Option<JS<DOMTokenList>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,7 +535,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-element-attributes
|
// http://dom.spec.whatwg.org/#dom-element-attributes
|
||||||
fn Attributes(&self) -> Temporary<AttrList> {
|
fn Attributes(&self) -> Temporary<NamedNodeMap> {
|
||||||
match self.attr_list.get() {
|
match self.attr_list.get() {
|
||||||
None => (),
|
None => (),
|
||||||
Some(ref list) => return Temporary::new(list.clone()),
|
Some(ref list) => return Temporary::new(list.clone()),
|
||||||
|
@ -546,7 +546,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
node.owner_doc().root()
|
node.owner_doc().root()
|
||||||
};
|
};
|
||||||
let window = doc.deref().window.root();
|
let window = doc.deref().window.root();
|
||||||
let list = AttrList::new(&*window, self);
|
let list = NamedNodeMap::new(&*window, self);
|
||||||
self.attr_list.assign(Some(list));
|
self.attr_list.assign(Some(list));
|
||||||
Temporary::new(self.attr_list.get().get_ref().clone())
|
Temporary::new(self.attr_list.get().get_ref().clone())
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::attr::Attr;
|
use dom::attr::Attr;
|
||||||
use dom::bindings::codegen::Bindings::AttrListBinding;
|
use dom::bindings::codegen::Bindings::NamedNodeMapBinding;
|
||||||
use dom::bindings::codegen::Bindings::AttrListBinding::AttrListMethods;
|
use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods;
|
||||||
use dom::bindings::global::Window;
|
use dom::bindings::global::Window;
|
||||||
use dom::bindings::js::{JS, JSRef, Temporary};
|
use dom::bindings::js::{JS, JSRef, Temporary};
|
||||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||||
|
@ -12,26 +12,26 @@ use dom::element::Element;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
|
|
||||||
#[deriving(Encodable)]
|
#[deriving(Encodable)]
|
||||||
pub struct AttrList {
|
pub struct NamedNodeMap {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
owner: JS<Element>,
|
owner: JS<Element>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AttrList {
|
impl NamedNodeMap {
|
||||||
pub fn new_inherited(elem: &JSRef<Element>) -> AttrList {
|
pub fn new_inherited(elem: &JSRef<Element>) -> NamedNodeMap {
|
||||||
AttrList {
|
NamedNodeMap {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
owner: JS::from_rooted(elem),
|
owner: JS::from_rooted(elem),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(window: &JSRef<Window>, elem: &JSRef<Element>) -> Temporary<AttrList> {
|
pub fn new(window: &JSRef<Window>, elem: &JSRef<Element>) -> Temporary<NamedNodeMap> {
|
||||||
reflect_dom_object(box AttrList::new_inherited(elem),
|
reflect_dom_object(box NamedNodeMap::new_inherited(elem),
|
||||||
&Window(*window), AttrListBinding::Wrap)
|
&Window(*window), NamedNodeMapBinding::Wrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> AttrListMethods for JSRef<'a, AttrList> {
|
impl<'a> NamedNodeMapMethods for JSRef<'a, NamedNodeMap> {
|
||||||
fn Length(&self) -> u32 {
|
fn Length(&self) -> u32 {
|
||||||
self.owner.root().attrs.borrow().len() as u32
|
self.owner.root().attrs.borrow().len() as u32
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ impl<'a> AttrListMethods for JSRef<'a, AttrList> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reflectable for AttrList {
|
impl Reflectable for NamedNodeMap {
|
||||||
fn reflector<'a>(&'a self) -> &'a Reflector {
|
fn reflector<'a>(&'a self) -> &'a Reflector {
|
||||||
&self.reflector_
|
&self.reflector_
|
||||||
}
|
}
|
|
@ -32,7 +32,7 @@ interface Element : Node {
|
||||||
readonly attribute DOMTokenList classList;
|
readonly attribute DOMTokenList classList;
|
||||||
|
|
||||||
[Constant]
|
[Constant]
|
||||||
readonly attribute AttrList attributes;
|
readonly attribute NamedNodeMap attributes;
|
||||||
DOMString? getAttribute(DOMString name);
|
DOMString? getAttribute(DOMString name);
|
||||||
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
|
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
|
||||||
[Throws]
|
[Throws]
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
[NoInterfaceObject]
|
interface NamedNodeMap {
|
||||||
interface AttrList {
|
|
||||||
readonly attribute unsigned long length;
|
readonly attribute unsigned long length;
|
||||||
getter Attr? item(unsigned long index);
|
getter Attr? item(unsigned long index);
|
||||||
};
|
};
|
|
@ -76,7 +76,6 @@ pub mod dom {
|
||||||
pub mod macros;
|
pub mod macros;
|
||||||
|
|
||||||
pub mod attr;
|
pub mod attr;
|
||||||
pub mod attrlist;
|
|
||||||
pub mod blob;
|
pub mod blob;
|
||||||
pub mod browsercontext;
|
pub mod browsercontext;
|
||||||
pub mod canvasrenderingcontext2d;
|
pub mod canvasrenderingcontext2d;
|
||||||
|
@ -173,6 +172,7 @@ pub mod dom {
|
||||||
pub mod location;
|
pub mod location;
|
||||||
pub mod messageevent;
|
pub mod messageevent;
|
||||||
pub mod mouseevent;
|
pub mod mouseevent;
|
||||||
|
pub mod namednodemap;
|
||||||
pub mod navigator;
|
pub mod navigator;
|
||||||
pub mod node;
|
pub mod node;
|
||||||
pub mod nodeiterator;
|
pub mod nodeiterator;
|
||||||
|
|
|
@ -144,6 +144,7 @@ var interfaceNamesInGlobalScope = [
|
||||||
"Location",
|
"Location",
|
||||||
"MessageEvent",
|
"MessageEvent",
|
||||||
"MouseEvent",
|
"MouseEvent",
|
||||||
|
"NamedNodeMap",
|
||||||
"Navigator",
|
"Navigator",
|
||||||
"Node",
|
"Node",
|
||||||
"NodeIterator",
|
"NodeIterator",
|
||||||
|
|
5
src/test/wpt/metadata/dom/historical.html.ini
Normal file
5
src/test/wpt/metadata/dom/historical.html.ini
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
[historical.html]
|
||||||
|
type: testharness
|
||||||
|
[Historical DOM features must be removed: NamedNodeMap]
|
||||||
|
expected: FAIL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue