mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Rust upgrade to rustc hash b03a2755193cd756583bcf5831cf4545d75ecb8a
This commit is contained in:
parent
26045d7fcb
commit
d1b433a3b3
160 changed files with 1427 additions and 1162 deletions
|
@ -62,8 +62,9 @@ use html5ever::tree_builder::{QuirksMode, NoQuirks, LimitedQuirks, Quirks};
|
|||
use string_cache::{Atom, QualName};
|
||||
use url::Url;
|
||||
|
||||
use std::collections::hashmap::HashMap;
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::{Vacant, Occupied};
|
||||
use std::ascii::AsciiExt;
|
||||
use std::cell::Cell;
|
||||
use std::default::Default;
|
||||
use time;
|
||||
|
@ -233,7 +234,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
|||
to_unregister: JSRef<Element>,
|
||||
id: Atom) {
|
||||
let mut idmap = self.idmap.borrow_mut();
|
||||
let is_empty = match idmap.find_mut(&id) {
|
||||
let is_empty = match idmap.get_mut(&id) {
|
||||
None => false,
|
||||
Some(elements) => {
|
||||
let position = elements.iter()
|
||||
|
@ -262,29 +263,35 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
|||
let mut idmap = self.idmap.borrow_mut();
|
||||
|
||||
let root = self.GetDocumentElement().expect("The element is in the document, so there must be a document element.").root();
|
||||
idmap.find_with_or_insert_with(id, element,
|
||||
|_key, elements, element| {
|
||||
|
||||
match idmap.entry(id) {
|
||||
Vacant(entry) => {
|
||||
entry.set(vec!(element.unrooted()));
|
||||
}
|
||||
Occupied(entry) => {
|
||||
let elements = entry.into_mut();
|
||||
|
||||
let new_node: JSRef<Node> = NodeCast::from_ref(element);
|
||||
let mut head : uint = 0u;
|
||||
let mut head: uint = 0u;
|
||||
let root: JSRef<Node> = NodeCast::from_ref(*root);
|
||||
for node in root.traverse_preorder() {
|
||||
let elem: Option<JSRef<Element>> = ElementCast::to_ref(node);
|
||||
match elem {
|
||||
None => {},
|
||||
Some(elem) => {
|
||||
if *(*elements)[head].root() == elem {
|
||||
head = head + 1;
|
||||
head += 1;
|
||||
}
|
||||
if new_node == node || head == elements.len() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
||||
elements.insert_unrooted(head, &element);
|
||||
},
|
||||
|_key, element| vec![element.unrooted()]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn load_anchor_href(self, href: DOMString) {
|
||||
|
@ -514,7 +521,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
// http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
||||
fn GetElementById(self, id: DOMString) -> Option<Temporary<Element>> {
|
||||
let id = Atom::from_slice(id.as_slice());
|
||||
match self.idmap.borrow().find(&id) {
|
||||
match self.idmap.borrow().get(&id) {
|
||||
None => None,
|
||||
Some(ref elements) => Some(Temporary::new((*elements)[0].clone())),
|
||||
}
|
||||
|
@ -660,7 +667,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
fn LastModified(self) -> DOMString {
|
||||
match *self.last_modified.borrow() {
|
||||
Some(ref t) => t.clone(),
|
||||
None => time::now().strftime("%m/%d/%Y %H:%M:%S"),
|
||||
None => time::now().strftime("%m/%d/%Y %H:%M:%S").unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue