Navigation Menu

Skip to content

Commit

Permalink
Remove unnecessary conversion to/from DOMString for localName.
Browse files Browse the repository at this point in the history
  • Loading branch information
eefriedman committed Dec 2, 2015
1 parent 2be60be commit e42dcb3
Show file tree
Hide file tree
Showing 72 changed files with 202 additions and 153 deletions.
6 changes: 3 additions & 3 deletions components/script/dom/create.rs
Expand Up @@ -87,16 +87,16 @@ pub fn create_element(name: QualName,
let prefix = prefix.map(|p| DOMString::from(&*p));

if name.ns != ns!(html) {
return Element::new(DOMString::from(&*name.local), name.ns, prefix, document);
return Element::new(name.local, name.ns, prefix, document);
}

macro_rules! make(
($ctor:ident) => ({
let obj = $ctor::new(DOMString::from(&*name.local), prefix, document);
let obj = $ctor::new(name.local, prefix, document);
Root::upcast(obj)
});
($ctor:ident, $($arg:expr),+) => ({
let obj = $ctor::new(DOMString::from(&*name.local), prefix, document, $($arg),+);
let obj = $ctor::new(name.local, prefix, document, $($arg),+);
Root::upcast(obj)
})
);
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/domimplementation.rs
Expand Up @@ -132,14 +132,14 @@ impl DOMImplementationMethods for DOMImplementation {
{
// Step 4.
let doc_node = doc.upcast::<Node>();
let doc_html = Root::upcast::<Node>(HTMLHtmlElement::new(DOMString::from("html"),
let doc_html = Root::upcast::<Node>(HTMLHtmlElement::new(atom!("html"),
None,
doc.r()));
doc_node.AppendChild(&doc_html).expect("Appending failed");

{
// Step 5.
let doc_head = Root::upcast::<Node>(HTMLHeadElement::new(DOMString::from("head"),
let doc_head = Root::upcast::<Node>(HTMLHeadElement::new(atom!("head"),
None,
doc.r()));
doc_html.AppendChild(&doc_head).unwrap();
Expand All @@ -150,7 +150,7 @@ impl DOMImplementationMethods for DOMImplementation {
Some(title_str) => {
// Step 6.1.
let doc_title =
Root::upcast::<Node>(HTMLTitleElement::new(DOMString::from("title"),
Root::upcast::<Node>(HTMLTitleElement::new(atom!("title"),
None,
doc.r()));
doc_head.AppendChild(&doc_title).unwrap();
Expand All @@ -163,7 +163,7 @@ impl DOMImplementationMethods for DOMImplementation {
}

// Step 7.
let doc_body = HTMLBodyElement::new(DOMString::from("body"), None, doc.r());
let doc_body = HTMLBodyElement::new(atom!("body"), None, doc.r());
doc_html.AppendChild(doc_body.upcast()).unwrap();
}

Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/element.rs
Expand Up @@ -126,20 +126,20 @@ impl Element {
}


pub fn new_inherited(local_name: DOMString,
pub fn new_inherited(local_name: Atom,
namespace: Namespace, prefix: Option<DOMString>,
document: &Document) -> Element {
Element::new_inherited_with_state(ElementState::empty(), local_name,
namespace, prefix, document)
}

pub fn new_inherited_with_state(state: ElementState, local_name: DOMString,
pub fn new_inherited_with_state(state: ElementState, local_name: Atom,
namespace: Namespace, prefix: Option<DOMString>,
document: &Document)
-> Element {
Element {
node: Node::new_inherited(document),
local_name: Atom::from(&*local_name),
local_name: local_name,
namespace: namespace,
prefix: prefix,
attrs: DOMRefCell::new(vec![]),
Expand All @@ -151,7 +151,7 @@ impl Element {
}
}

pub fn new(local_name: DOMString,
pub fn new(local_name: Atom,
namespace: Namespace,
prefix: Option<DOMString>,
document: &Document) -> Root<Element> {
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/htmlanchorelement.rs
Expand Up @@ -35,7 +35,7 @@ pub struct HTMLAnchorElement {
}

impl HTMLAnchorElement {
fn new_inherited(localName: DOMString,
fn new_inherited(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> HTMLAnchorElement {
HTMLAnchorElement {
Expand All @@ -46,7 +46,7 @@ impl HTMLAnchorElement {
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLAnchorElement> {
let element = HTMLAnchorElement::new_inherited(localName, prefix, document);
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/htmlappletelement.rs
Expand Up @@ -20,7 +20,7 @@ pub struct HTMLAppletElement {
}

impl HTMLAppletElement {
fn new_inherited(localName: DOMString,
fn new_inherited(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> HTMLAppletElement {
HTMLAppletElement {
Expand All @@ -30,7 +30,7 @@ impl HTMLAppletElement {
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLAppletElement> {
let element = HTMLAppletElement::new_inherited(localName, prefix, document);
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/htmlareaelement.rs
Expand Up @@ -24,15 +24,15 @@ pub struct HTMLAreaElement {
}

impl HTMLAreaElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> HTMLAreaElement {
fn new_inherited(localName: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLAreaElement {
HTMLAreaElement {
htmlelement: HTMLElement::new_inherited(localName, prefix, document),
rel_list: Default::default(),
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLAreaElement> {
let element = HTMLAreaElement::new_inherited(localName, prefix, document);
Expand Down
5 changes: 3 additions & 2 deletions components/script/dom/htmlaudioelement.rs
Expand Up @@ -7,6 +7,7 @@ use dom::bindings::js::Root;
use dom::document::Document;
use dom::htmlmediaelement::HTMLMediaElement;
use dom::node::Node;
use string_cache::Atom;
use util::str::DOMString;

#[dom_struct]
Expand All @@ -15,7 +16,7 @@ pub struct HTMLAudioElement {
}

impl HTMLAudioElement {
fn new_inherited(localName: DOMString,
fn new_inherited(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> HTMLAudioElement {
HTMLAudioElement {
Expand All @@ -25,7 +26,7 @@ impl HTMLAudioElement {
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLAudioElement> {
let element = HTMLAudioElement::new_inherited(localName, prefix, document);
Expand Down
5 changes: 3 additions & 2 deletions components/script/dom/htmlbaseelement.rs
Expand Up @@ -11,6 +11,7 @@ use dom::element::{AttributeMutation, Element};
use dom::htmlelement::HTMLElement;
use dom::node::{Node, document_from_node};
use dom::virtualmethods::VirtualMethods;
use string_cache::Atom;
use url::{Url, UrlParser};
use util::str::DOMString;

Expand All @@ -20,14 +21,14 @@ pub struct HTMLBaseElement {
}

impl HTMLBaseElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> HTMLBaseElement {
fn new_inherited(localName: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLBaseElement {
HTMLBaseElement {
htmlelement: HTMLElement::new_inherited(localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLBaseElement> {
let element = HTMLBaseElement::new_inherited(localName, prefix, document);
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/htmlbodyelement.rs
Expand Up @@ -36,7 +36,7 @@ pub struct HTMLBodyElement {
}

impl HTMLBodyElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: &Document)
fn new_inherited(localName: Atom, prefix: Option<DOMString>, document: &Document)
-> HTMLBodyElement {
HTMLBodyElement {
htmlelement: HTMLElement::new_inherited(localName, prefix, document),
Expand All @@ -45,7 +45,7 @@ impl HTMLBodyElement {
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: &Document)
pub fn new(localName: Atom, prefix: Option<DOMString>, document: &Document)
-> Root<HTMLBodyElement> {
let element = HTMLBodyElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLBodyElementBinding::Wrap)
Expand Down
5 changes: 3 additions & 2 deletions components/script/dom/htmlbrelement.rs
Expand Up @@ -7,6 +7,7 @@ use dom::bindings::js::Root;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use string_cache::Atom;
use util::str::DOMString;

#[dom_struct]
Expand All @@ -15,14 +16,14 @@ pub struct HTMLBRElement {
}

impl HTMLBRElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> HTMLBRElement {
fn new_inherited(localName: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLBRElement {
HTMLBRElement {
htmlelement: HTMLElement::new_inherited(localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLBRElement> {
let element = HTMLBRElement::new_inherited(localName, prefix, document);
Expand Down
5 changes: 3 additions & 2 deletions components/script/dom/htmlbuttonelement.rs
Expand Up @@ -23,6 +23,7 @@ use dom::virtualmethods::VirtualMethods;
use selectors::states::*;
use std::ascii::AsciiExt;
use std::cell::Cell;
use string_cache::Atom;
use util::str::DOMString;

#[derive(JSTraceable, PartialEq, Copy, Clone)]
Expand All @@ -42,7 +43,7 @@ pub struct HTMLButtonElement {
}

impl HTMLButtonElement {
fn new_inherited(localName: DOMString,
fn new_inherited(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> HTMLButtonElement {
HTMLButtonElement {
Expand All @@ -55,7 +56,7 @@ impl HTMLButtonElement {
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLButtonElement> {
let element = HTMLButtonElement::new_inherited(localName, prefix, document);
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/htmlcanvaselement.rs
Expand Up @@ -60,7 +60,7 @@ impl PartialEq for HTMLCanvasElement {
}

impl HTMLCanvasElement {
fn new_inherited(localName: DOMString,
fn new_inherited(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> HTMLCanvasElement {
HTMLCanvasElement {
Expand All @@ -70,7 +70,7 @@ impl HTMLCanvasElement {
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLCanvasElement> {
let element = HTMLCanvasElement::new_inherited(localName, prefix, document);
Expand Down
5 changes: 3 additions & 2 deletions components/script/dom/htmldataelement.rs
Expand Up @@ -7,6 +7,7 @@ use dom::bindings::js::Root;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use string_cache::Atom;
use util::str::DOMString;

#[dom_struct]
Expand All @@ -15,7 +16,7 @@ pub struct HTMLDataElement {
}

impl HTMLDataElement {
fn new_inherited(localName: DOMString,
fn new_inherited(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> HTMLDataElement {
HTMLDataElement {
Expand All @@ -24,7 +25,7 @@ impl HTMLDataElement {
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLDataElement> {
let element = HTMLDataElement::new_inherited(localName, prefix, document);
Expand Down
5 changes: 3 additions & 2 deletions components/script/dom/htmldatalistelement.rs
Expand Up @@ -12,6 +12,7 @@ use dom::htmlcollection::{CollectionFilter, HTMLCollection};
use dom::htmlelement::HTMLElement;
use dom::htmloptionelement::HTMLOptionElement;
use dom::node::{Node, window_from_node};
use string_cache::Atom;
use util::str::DOMString;

#[dom_struct]
Expand All @@ -20,7 +21,7 @@ pub struct HTMLDataListElement {
}

impl HTMLDataListElement {
fn new_inherited(localName: DOMString,
fn new_inherited(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> HTMLDataListElement {
HTMLDataListElement {
Expand All @@ -30,7 +31,7 @@ impl HTMLDataListElement {
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLDataListElement> {
let element = HTMLDataListElement::new_inherited(localName, prefix, document);
Expand Down
5 changes: 3 additions & 2 deletions components/script/dom/htmldialogelement.rs
Expand Up @@ -9,6 +9,7 @@ use dom::bindings::js::Root;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use string_cache::Atom;
use util::str::DOMString;

#[dom_struct]
Expand All @@ -18,7 +19,7 @@ pub struct HTMLDialogElement {
}

impl HTMLDialogElement {
fn new_inherited(localName: DOMString,
fn new_inherited(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> HTMLDialogElement {
HTMLDialogElement {
Expand All @@ -29,7 +30,7 @@ impl HTMLDialogElement {
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLDialogElement> {
let element = HTMLDialogElement::new_inherited(localName, prefix, document);
Expand Down
5 changes: 3 additions & 2 deletions components/script/dom/htmldirectoryelement.rs
Expand Up @@ -7,6 +7,7 @@ use dom::bindings::js::Root;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use string_cache::Atom;
use util::str::DOMString;

#[dom_struct]
Expand All @@ -15,7 +16,7 @@ pub struct HTMLDirectoryElement {
}

impl HTMLDirectoryElement {
fn new_inherited(localName: DOMString,
fn new_inherited(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> HTMLDirectoryElement {
HTMLDirectoryElement {
Expand All @@ -25,7 +26,7 @@ impl HTMLDirectoryElement {
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
pub fn new(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLDirectoryElement> {
let element = HTMLDirectoryElement::new_inherited(localName, prefix, document);
Expand Down

0 comments on commit e42dcb3

Please sign in to comment.