Skip to content
Permalink
Browse files

Remove unnecessary conversion to/from DOMString for localName.

  • Loading branch information
eefriedman committed Dec 2, 2015
1 parent 2be60be commit e42dcb3712bfc70241054aa0e25deebd675aaef9
Showing with 202 additions and 153 deletions.
  1. +3 −3 components/script/dom/create.rs
  2. +4 −4 components/script/dom/domimplementation.rs
  3. +4 −4 components/script/dom/element.rs
  4. +2 −2 components/script/dom/htmlanchorelement.rs
  5. +2 −2 components/script/dom/htmlappletelement.rs
  6. +2 −2 components/script/dom/htmlareaelement.rs
  7. +3 −2 components/script/dom/htmlaudioelement.rs
  8. +3 −2 components/script/dom/htmlbaseelement.rs
  9. +2 −2 components/script/dom/htmlbodyelement.rs
  10. +3 −2 components/script/dom/htmlbrelement.rs
  11. +3 −2 components/script/dom/htmlbuttonelement.rs
  12. +2 −2 components/script/dom/htmlcanvaselement.rs
  13. +3 −2 components/script/dom/htmldataelement.rs
  14. +3 −2 components/script/dom/htmldatalistelement.rs
  15. +3 −2 components/script/dom/htmldialogelement.rs
  16. +3 −2 components/script/dom/htmldirectoryelement.rs
  17. +3 −2 components/script/dom/htmldivelement.rs
  18. +3 −2 components/script/dom/htmldlistelement.rs
  19. +3 −3 components/script/dom/htmlelement.rs
  20. +3 −2 components/script/dom/htmlembedelement.rs
  21. +3 −2 components/script/dom/htmlfieldsetelement.rs
  22. +2 −2 components/script/dom/htmlfontelement.rs
  23. +2 −2 components/script/dom/htmlformelement.rs
  24. +3 −2 components/script/dom/htmlframeelement.rs
  25. +3 −2 components/script/dom/htmlframesetelement.rs
  26. +3 −2 components/script/dom/htmlheadelement.rs
  27. +3 −2 components/script/dom/htmlheadingelement.rs
  28. +2 −2 components/script/dom/htmlhrelement.rs
  29. +3 −2 components/script/dom/htmlhtmlelement.rs
  30. +2 −2 components/script/dom/htmliframeelement.rs
  31. +3 −3 components/script/dom/htmlimageelement.rs
  32. +2 −2 components/script/dom/htmlinputelement.rs
  33. +2 −2 components/script/dom/htmllabelelement.rs
  34. +3 −2 components/script/dom/htmllegendelement.rs
  35. +3 −2 components/script/dom/htmllielement.rs
  36. +2 −2 components/script/dom/htmllinkelement.rs
  37. +3 −2 components/script/dom/htmlmapelement.rs
  38. +2 −1 components/script/dom/htmlmediaelement.rs
  39. +3 −2 components/script/dom/htmlmetaelement.rs
  40. +3 −2 components/script/dom/htmlmeterelement.rs
  41. +3 −2 components/script/dom/htmlmodelement.rs
  42. +3 −2 components/script/dom/htmlobjectelement.rs
  43. +3 −2 components/script/dom/htmlolistelement.rs
  44. +3 −2 components/script/dom/htmloptgroupelement.rs
  45. +3 −2 components/script/dom/htmloptionelement.rs
  46. +3 −2 components/script/dom/htmloutputelement.rs
  47. +3 −2 components/script/dom/htmlparagraphelement.rs
  48. +3 −2 components/script/dom/htmlparamelement.rs
  49. +3 −2 components/script/dom/htmlpreelement.rs
  50. +3 −2 components/script/dom/htmlprogresselement.rs
  51. +3 −2 components/script/dom/htmlquoteelement.rs
  52. +3 −2 components/script/dom/htmlscriptelement.rs
  53. +2 −2 components/script/dom/htmlselectelement.rs
  54. +3 −2 components/script/dom/htmlsourceelement.rs
  55. +3 −2 components/script/dom/htmlspanelement.rs
  56. +3 −2 components/script/dom/htmlstyleelement.rs
  57. +3 −2 components/script/dom/htmltablecaptionelement.rs
  58. +1 −1 components/script/dom/htmltablecellelement.rs
  59. +3 −2 components/script/dom/htmltablecolelement.rs
  60. +3 −2 components/script/dom/htmltabledatacellelement.rs
  61. +4 −4 components/script/dom/htmltableelement.rs
  62. +3 −2 components/script/dom/htmltableheadercellelement.rs
  63. +3 −3 components/script/dom/htmltablerowelement.rs
  64. +3 −3 components/script/dom/htmltablesectionelement.rs
  65. +3 −2 components/script/dom/htmltemplateelement.rs
  66. +2 −2 components/script/dom/htmltextareaelement.rs
  67. +3 −2 components/script/dom/htmltimeelement.rs
  68. +3 −2 components/script/dom/htmltitleelement.rs
  69. +3 −2 components/script/dom/htmltrackelement.rs
  70. +3 −2 components/script/dom/htmlulistelement.rs
  71. +3 −2 components/script/dom/htmlunknownelement.rs
  72. +3 −2 components/script/dom/htmlvideoelement.rs
@@ -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)
})
);
@@ -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();
@@ -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();
@@ -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();
}

@@ -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![]),
@@ -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> {
@@ -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 {
@@ -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);
@@ -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 {
@@ -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);
@@ -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);
@@ -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]
@@ -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 {
@@ -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);
@@ -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;

@@ -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);
@@ -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),
@@ -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)
@@ -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]
@@ -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);
@@ -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)]
@@ -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 {
@@ -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);
@@ -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 {
@@ -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);
@@ -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]
@@ -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 {
@@ -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);
@@ -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]
@@ -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 {
@@ -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);
@@ -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]
@@ -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 {
@@ -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);
@@ -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]
@@ -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 {
@@ -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);

0 comments on commit e42dcb3

Please sign in to comment.
You can’t perform that action at this time.