mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Make Document::idmap store a Vec.
This commit is contained in:
parent
50ab85f3ee
commit
7346992981
1 changed files with 4 additions and 6 deletions
|
@ -58,7 +58,7 @@ pub struct Document {
|
||||||
pub node: Node,
|
pub node: Node,
|
||||||
pub reflector_: Reflector,
|
pub reflector_: Reflector,
|
||||||
pub window: JS<Window>,
|
pub window: JS<Window>,
|
||||||
pub idmap: HashMap<DOMString, ~[JS<Element>]>,
|
pub idmap: HashMap<DOMString, Vec<JS<Element>>>,
|
||||||
pub implementation: Option<JS<DOMImplementation>>,
|
pub implementation: Option<JS<DOMImplementation>>,
|
||||||
pub content_type: DOMString,
|
pub content_type: DOMString,
|
||||||
pub encoding_name: DOMString,
|
pub encoding_name: DOMString,
|
||||||
|
@ -232,11 +232,9 @@ impl Document {
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
// http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
||||||
pub fn GetElementById(&self, id: DOMString) -> Option<JS<Element>> {
|
pub fn GetElementById(&self, id: DOMString) -> Option<JS<Element>> {
|
||||||
// TODO: "in tree order, within the context object's tree"
|
|
||||||
// http://dom.spec.whatwg.org/#dom-document-getelementbyid.
|
|
||||||
match self.idmap.find_equiv(&id) {
|
match self.idmap.find_equiv(&id) {
|
||||||
None => None,
|
None => None,
|
||||||
Some(ref elements) => Some(elements[0].clone()),
|
Some(ref elements) => Some(elements.get(0).clone()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -679,7 +677,7 @@ impl Document {
|
||||||
for node in root.traverse_preorder() {
|
for node in root.traverse_preorder() {
|
||||||
match ElementCast::to(&node) {
|
match ElementCast::to(&node) {
|
||||||
Some(elem) => {
|
Some(elem) => {
|
||||||
if elements[head] == elem {
|
if elements.get(head) == &elem {
|
||||||
head = head + 1;
|
head = head + 1;
|
||||||
}
|
}
|
||||||
if new_node == node || head == elements.len() {
|
if new_node == node || head == elements.len() {
|
||||||
|
@ -694,6 +692,6 @@ impl Document {
|
||||||
},
|
},
|
||||||
None => (),
|
None => (),
|
||||||
}
|
}
|
||||||
self.idmap.insert(id, ~[element.clone()]);
|
self.idmap.insert(id, vec!(element.clone()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue