aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2016-10-30 19:27:43 +0100
committerSimon Sapin <simon.sapin@exyr.org>2016-11-03 16:23:05 +0100
commit53b638c0e29ba78448d07695343b7ddfa36c5141 (patch)
tree52647391f6184df815a1d9ce85ad4a84e51f0ffe /components/script/dom
parent9fcc9d9d3f59428bf19f950bd79ab257d59e3d16 (diff)
downloadservo-53b638c0e29ba78448d07695343b7ddfa36c5141.tar.gz
servo-53b638c0e29ba78448d07695343b7ddfa36c5141.zip
Update to string-cache 0.3
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/attr.rs41
-rw-r--r--components/script/dom/beforeunloadevent.rs2
-rw-r--r--components/script/dom/bindings/str.rs15
-rw-r--r--components/script/dom/bindings/trace.rs5
-rw-r--r--components/script/dom/bindings/xmlname.rs8
-rw-r--r--components/script/dom/closeevent.rs2
-rw-r--r--components/script/dom/create.rs270
-rw-r--r--components/script/dom/cssstyledeclaration.rs2
-rw-r--r--components/script/dom/customevent.rs2
-rw-r--r--components/script/dom/document.rs61
-rw-r--r--components/script/dom/documentfragment.rs4
-rw-r--r--components/script/dom/domimplementation.rs8
-rw-r--r--components/script/dom/domtokenlist.rs9
-rw-r--r--components/script/dom/element.rs183
-rw-r--r--components/script/dom/errorevent.rs2
-rw-r--r--components/script/dom/event.rs2
-rw-r--r--components/script/dom/eventtarget.rs2
-rw-r--r--components/script/dom/extendableevent.rs2
-rw-r--r--components/script/dom/extendablemessageevent.rs2
-rw-r--r--components/script/dom/filereader.rs2
-rw-r--r--components/script/dom/formdata.rs24
-rw-r--r--components/script/dom/hashchangeevent.rs2
-rw-r--r--components/script/dom/htmlanchorelement.rs28
-rw-r--r--components/script/dom/htmlappletelement.rs10
-rw-r--r--components/script/dom/htmlareaelement.rs12
-rw-r--r--components/script/dom/htmlaudioelement.rs6
-rw-r--r--components/script/dom/htmlbaseelement.rs16
-rw-r--r--components/script/dom/htmlbodyelement.rs33
-rw-r--r--components/script/dom/htmlbrelement.rs6
-rw-r--r--components/script/dom/htmlbuttonelement.rs10
-rw-r--r--components/script/dom/htmlcanvaselement.rs18
-rw-r--r--components/script/dom/htmlcollection.rs29
-rw-r--r--components/script/dom/htmldataelement.rs6
-rw-r--r--components/script/dom/htmldatalistelement.rs6
-rw-r--r--components/script/dom/htmldetailselement.rs8
-rw-r--r--components/script/dom/htmldialogelement.rs8
-rw-r--r--components/script/dom/htmldirectoryelement.rs6
-rw-r--r--components/script/dom/htmldivelement.rs6
-rw-r--r--components/script/dom/htmldlistelement.rs6
-rw-r--r--components/script/dom/htmlelement.rs28
-rw-r--r--components/script/dom/htmlembedelement.rs6
-rw-r--r--components/script/dom/htmlfieldsetelement.rs8
-rw-r--r--components/script/dom/htmlfontelement.rs23
-rw-r--r--components/script/dom/htmlformcontrolscollection.rs4
-rw-r--r--components/script/dom/htmlformelement.rs42
-rw-r--r--components/script/dom/htmlframeelement.rs6
-rw-r--r--components/script/dom/htmlframesetelement.rs6
-rw-r--r--components/script/dom/htmlheadelement.rs12
-rw-r--r--components/script/dom/htmlheadingelement.rs6
-rw-r--r--components/script/dom/htmlhrelement.rs18
-rw-r--r--components/script/dom/htmlhtmlelement.rs6
-rw-r--r--components/script/dom/htmliframeelement.rs41
-rw-r--r--components/script/dom/htmlimageelement.rs28
-rw-r--r--components/script/dom/htmlinputelement.rs55
-rw-r--r--components/script/dom/htmllabelelement.rs12
-rw-r--r--components/script/dom/htmllegendelement.rs6
-rw-r--r--components/script/dom/htmllielement.rs10
-rw-r--r--components/script/dom/htmllinkelement.rs38
-rw-r--r--components/script/dom/htmlmapelement.rs6
-rw-r--r--components/script/dom/htmlmediaelement.rs9
-rw-r--r--components/script/dom/htmlmetaelement.rs16
-rw-r--r--components/script/dom/htmlmeterelement.rs6
-rw-r--r--components/script/dom/htmlmodelement.rs6
-rw-r--r--components/script/dom/htmlobjectelement.rs12
-rw-r--r--components/script/dom/htmlolistelement.rs6
-rw-r--r--components/script/dom/htmloptgroupelement.rs8
-rw-r--r--components/script/dom/htmloptionelement.rs16
-rw-r--r--components/script/dom/htmloptionscollection.rs2
-rw-r--r--components/script/dom/htmloutputelement.rs6
-rw-r--r--components/script/dom/htmlparagraphelement.rs6
-rw-r--r--components/script/dom/htmlparamelement.rs6
-rw-r--r--components/script/dom/htmlpreelement.rs6
-rw-r--r--components/script/dom/htmlprogresselement.rs6
-rw-r--r--components/script/dom/htmlquoteelement.rs6
-rw-r--r--components/script/dom/htmlscriptelement.rs33
-rw-r--r--components/script/dom/htmlselectelement.rs12
-rw-r--r--components/script/dom/htmlsourceelement.rs6
-rw-r--r--components/script/dom/htmlspanelement.rs6
-rw-r--r--components/script/dom/htmlstyleelement.rs8
-rw-r--r--components/script/dom/htmltablecaptionelement.rs6
-rw-r--r--components/script/dom/htmltablecellelement.rs18
-rw-r--r--components/script/dom/htmltablecolelement.rs6
-rw-r--r--components/script/dom/htmltabledatacellelement.rs6
-rw-r--r--components/script/dom/htmltableelement.rs64
-rw-r--r--components/script/dom/htmltableheadercellelement.rs6
-rw-r--r--components/script/dom/htmltablerowelement.rs14
-rw-r--r--components/script/dom/htmltablesectionelement.rs14
-rw-r--r--components/script/dom/htmltemplateelement.rs6
-rw-r--r--components/script/dom/htmltextareaelement.rs20
-rw-r--r--components/script/dom/htmltimeelement.rs6
-rw-r--r--components/script/dom/htmltitleelement.rs6
-rw-r--r--components/script/dom/htmltrackelement.rs6
-rw-r--r--components/script/dom/htmlulistelement.rs6
-rw-r--r--components/script/dom/htmlunknownelement.rs6
-rw-r--r--components/script/dom/htmlvideoelement.rs6
-rw-r--r--components/script/dom/macros.rs38
-rw-r--r--components/script/dom/messageevent.rs2
-rw-r--r--components/script/dom/namednodemap.rs6
-rw-r--r--components/script/dom/node.rs27
-rw-r--r--components/script/dom/pagetransitionevent.rs2
-rw-r--r--components/script/dom/popstateevent.rs2
-rw-r--r--components/script/dom/progressevent.rs2
-rw-r--r--components/script/dom/range.rs4
-rw-r--r--components/script/dom/servoparser/html.rs2
-rw-r--r--components/script/dom/servoparser/mod.rs2
-rw-r--r--components/script/dom/servoparser/xml.rs12
-rw-r--r--components/script/dom/storageevent.rs2
-rw-r--r--components/script/dom/svgelement.rs8
-rw-r--r--components/script/dom/svggraphicselement.rs8
-rw-r--r--components/script/dom/svgsvgelement.rs16
-rw-r--r--components/script/dom/transitionevent.rs2
-rw-r--r--components/script/dom/uievent.rs2
-rw-r--r--components/script/dom/userscripts.rs2
-rw-r--r--components/script/dom/virtualmethods.rs4
-rw-r--r--components/script/dom/webglcontextevent.rs2
-rw-r--r--components/script/dom/window.rs2
-rw-r--r--components/script/dom/xmlhttprequest.rs2
117 files changed, 892 insertions, 860 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs
index 89b8e68ff7a..2aae65af920 100644
--- a/components/script/dom/attr.rs
+++ b/components/script/dom/attr.rs
@@ -13,10 +13,11 @@ use dom::bindings::str::DOMString;
use dom::element::{AttributeMutation, Element};
use dom::virtualmethods::vtable_for;
use dom::window::Window;
+use html5ever_atoms::{Prefix, LocalName, Namespace};
+use servo_atoms::Atom;
use std::borrow::ToOwned;
use std::cell::Ref;
use std::mem;
-use string_cache::{Atom, Namespace};
use style::attr::{AttrIdentifier, AttrValue};
// https://dom.spec.whatwg.org/#interface-attr
@@ -31,11 +32,11 @@ pub struct Attr {
}
impl Attr {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
value: AttrValue,
- name: Atom,
+ name: LocalName,
namespace: Namespace,
- prefix: Option<Atom>,
+ prefix: Option<Prefix>,
owner: Option<&Element>)
-> Attr {
Attr {
@@ -52,11 +53,11 @@ impl Attr {
}
pub fn new(window: &Window,
- local_name: Atom,
+ local_name: LocalName,
value: AttrValue,
- name: Atom,
+ name: LocalName,
namespace: Namespace,
- prefix: Option<Atom>,
+ prefix: Option<Prefix>,
owner: Option<&Element>)
-> Root<Attr> {
reflect_dom_object(box Attr::new_inherited(local_name,
@@ -70,7 +71,7 @@ impl Attr {
}
#[inline]
- pub fn name(&self) -> &Atom {
+ pub fn name(&self) -> &LocalName {
&self.identifier.name
}
@@ -80,7 +81,7 @@ impl Attr {
}
#[inline]
- pub fn prefix(&self) -> &Option<Atom> {
+ pub fn prefix(&self) -> &Option<Prefix> {
&self.identifier.prefix
}
}
@@ -88,7 +89,7 @@ impl Attr {
impl AttrMethods for Attr {
// https://dom.spec.whatwg.org/#dom-attr-localname
fn LocalName(&self) -> DOMString {
- // FIXME(ajeffrey): convert directly from Atom to DOMString
+ // FIXME(ajeffrey): convert directly from LocalName to DOMString
DOMString::from(&**self.local_name())
}
@@ -132,7 +133,7 @@ impl AttrMethods for Attr {
// https://dom.spec.whatwg.org/#dom-attr-name
fn Name(&self) -> DOMString {
- // FIXME(ajeffrey): convert directly from Atom to DOMString
+ // FIXME(ajeffrey): convert directly from LocalName to DOMString
DOMString::from(&*self.identifier.name)
}
@@ -143,16 +144,15 @@ impl AttrMethods for Attr {
// https://dom.spec.whatwg.org/#dom-attr-namespaceuri
fn GetNamespaceURI(&self) -> Option<DOMString> {
- let Namespace(ref atom) = self.identifier.namespace;
- match &**atom {
- "" => None,
- url => Some(DOMString::from(url)),
+ match self.identifier.namespace {
+ ns!() => None,
+ ref url => Some(DOMString::from(&**url)),
}
}
// https://dom.spec.whatwg.org/#dom-attr-prefix
fn GetPrefix(&self) -> Option<DOMString> {
- // FIXME(ajeffrey): convert directly from Atom to DOMString
+ // FIXME(ajeffrey): convert directly from LocalName to DOMString
self.prefix().as_ref().map(|p| DOMString::from(&**p))
}
@@ -192,7 +192,7 @@ impl Attr {
self.value.borrow()
}
- pub fn local_name(&self) -> &Atom {
+ pub fn local_name(&self) -> &LocalName {
&self.identifier.local_name
}
@@ -216,9 +216,8 @@ impl Attr {
}
pub fn summarize(&self) -> AttrInfo {
- let Namespace(ref ns) = self.identifier.namespace;
AttrInfo {
- namespace: (**ns).to_owned(),
+ namespace: (*self.identifier.namespace).to_owned(),
name: String::from(self.Name()),
value: String::from(self.Value()),
}
@@ -231,7 +230,7 @@ pub trait AttrHelpersForLayout {
unsafe fn value_ref_forever(&self) -> &'static str;
unsafe fn value_atom_forever(&self) -> Option<Atom>;
unsafe fn value_tokens_forever(&self) -> Option<&'static [Atom]>;
- unsafe fn local_name_atom_forever(&self) -> Atom;
+ unsafe fn local_name_atom_forever(&self) -> LocalName;
unsafe fn value_for_layout(&self) -> &AttrValue;
}
@@ -267,7 +266,7 @@ impl AttrHelpersForLayout for LayoutJS<Attr> {
}
#[inline]
- unsafe fn local_name_atom_forever(&self) -> Atom {
+ unsafe fn local_name_atom_forever(&self) -> LocalName {
(*self.unsafe_get()).identifier.local_name.clone()
}
diff --git a/components/script/dom/beforeunloadevent.rs b/components/script/dom/beforeunloadevent.rs
index 413a26a8de8..c79ca70c28e 100644
--- a/components/script/dom/beforeunloadevent.rs
+++ b/components/script/dom/beforeunloadevent.rs
@@ -12,7 +12,7 @@ use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::str::DOMString;
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::globalscope::GlobalScope;
-use string_cache::Atom;
+use servo_atoms::Atom;
// https://html.spec.whatwg.org/multipage/#beforeunloadevent
#[dom_struct]
diff --git a/components/script/dom/bindings/str.rs b/components/script/dom/bindings/str.rs
index 2e28a1b314e..d7984939e28 100644
--- a/components/script/dom/bindings/str.rs
+++ b/components/script/dom/bindings/str.rs
@@ -4,6 +4,8 @@
//! The `ByteString` struct.
+use html5ever_atoms::{LocalName, Namespace};
+use servo_atoms::Atom;
use std::ascii::AsciiExt;
use std::borrow::{Borrow, Cow, ToOwned};
use std::fmt;
@@ -12,7 +14,6 @@ use std::ops;
use std::ops::{Deref, DerefMut};
use std::str;
use std::str::{Bytes, FromStr};
-use string_cache::Atom;
/// Encapsulates the IDL `ByteString` type.
#[derive(JSTraceable, Clone, Eq, PartialEq, HeapSizeOf, Debug)]
@@ -255,6 +256,18 @@ impl<'a> From<Cow<'a, str>> for DOMString {
}
}
+impl From<DOMString> for LocalName {
+ fn from(contents: DOMString) -> LocalName {
+ LocalName::from(contents.0)
+ }
+}
+
+impl From<DOMString> for Namespace {
+ fn from(contents: DOMString) -> Namespace {
+ Namespace::from(contents.0)
+ }
+}
+
impl From<DOMString> for Atom {
fn from(contents: DOMString) -> Atom {
Atom::from(contents.0)
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs
index e0f65d9f6e1..03a1d964808 100644
--- a/components/script/dom/bindings/trace.rs
+++ b/components/script/dom/bindings/trace.rs
@@ -47,6 +47,7 @@ use euclid::length::Length as EuclidLength;
use euclid::rect::Rect;
use euclid::size::Size2D;
use html5ever::tree_builder::QuirksMode;
+use html5ever_atoms::{Prefix, LocalName, Namespace, QualName};
use hyper::header::Headers;
use hyper::method::Method;
use hyper::mime::Mime;
@@ -76,6 +77,7 @@ use script_runtime::ScriptChan;
use script_traits::{TimerEventId, TimerSource, TouchpadPressurePhase};
use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType};
use serde::{Deserialize, Serialize};
+use servo_atoms::Atom;
use smallvec::SmallVec;
use std::boxed::FnBox;
use std::cell::{Cell, UnsafeCell};
@@ -88,7 +90,6 @@ use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::sync::mpsc::{Receiver, Sender};
use std::time::{SystemTime, Instant};
-use string_cache::{Atom, Namespace, QualName};
use style::attr::{AttrIdentifier, AttrValue, LengthOrPercentageOrAuto};
use style::element_state::*;
use style::media_queries::MediaQueryList;
@@ -311,7 +312,7 @@ no_jsmanaged_fields!(Arc<T>);
no_jsmanaged_fields!(Image, ImageMetadata, ImageCacheChan, ImageCacheThread);
no_jsmanaged_fields!(Metadata);
no_jsmanaged_fields!(NetworkError);
-no_jsmanaged_fields!(Atom, Namespace, QualName);
+no_jsmanaged_fields!(Atom, Prefix, LocalName, Namespace, QualName);
no_jsmanaged_fields!(Trusted<T: Reflectable>);
no_jsmanaged_fields!(TrustedPromise);
no_jsmanaged_fields!(PropertyDeclarationBlock);
diff --git a/components/script/dom/bindings/xmlname.rs b/components/script/dom/bindings/xmlname.rs
index 11b83be7b99..4522c9c4ac0 100644
--- a/components/script/dom/bindings/xmlname.rs
+++ b/components/script/dom/bindings/xmlname.rs
@@ -6,7 +6,7 @@
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::str::DOMString;
-use string_cache::{Atom, Namespace};
+use html5ever_atoms::{Prefix, LocalName, Namespace};
/// Validate a qualified name. See https://dom.spec.whatwg.org/#validate for details.
pub fn validate_qualified_name(qualified_name: &str) -> ErrorResult {
@@ -27,7 +27,7 @@ pub fn validate_qualified_name(qualified_name: &str) -> ErrorResult {
/// See https://dom.spec.whatwg.org/#validate-and-extract for details.
pub fn validate_and_extract(namespace: Option<DOMString>,
qualified_name: &str)
- -> Fallible<(Namespace, Option<Atom>, Atom)> {
+ -> Fallible<(Namespace, Option<Prefix>, LocalName)> {
// Step 1.
let namespace = namespace_from_domstring(namespace);
@@ -75,7 +75,7 @@ pub fn validate_and_extract(namespace: Option<DOMString>,
},
(ns, p) => {
// Step 10.
- Ok((ns, p.map(Atom::from), Atom::from(local_name)))
+ Ok((ns, p.map(Prefix::from), LocalName::from(local_name)))
}
}
}
@@ -174,6 +174,6 @@ pub fn xml_name_type(name: &str) -> XMLName {
pub fn namespace_from_domstring(url: Option<DOMString>) -> Namespace {
match url {
None => ns!(),
- Some(s) => Namespace(Atom::from(s)),
+ Some(s) => Namespace::from(s),
}
}
diff --git a/components/script/dom/closeevent.rs b/components/script/dom/closeevent.rs
index a66af7bd75f..a4ad9893d80 100644
--- a/components/script/dom/closeevent.rs
+++ b/components/script/dom/closeevent.rs
@@ -12,7 +12,7 @@ use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::str::DOMString;
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::globalscope::GlobalScope;
-use string_cache::Atom;
+use servo_atoms::Atom;
#[dom_struct]
pub struct CloseEvent {
diff --git a/components/script/dom/create.rs b/components/script/dom/create.rs
index 98a2e5ad4ed..42a3c8158a1 100644
--- a/components/script/dom/create.rs
+++ b/components/script/dom/create.rs
@@ -77,7 +77,7 @@ use dom::htmlulistelement::HTMLUListElement;
use dom::htmlunknownelement::HTMLUnknownElement;
use dom::htmlvideoelement::HTMLVideoElement;
use dom::svgsvgelement::SVGSVGElement;
-use string_cache::{Atom, QualName};
+use html5ever_atoms::{Prefix, QualName};
use util::prefs::PREFS;
fn create_svg_element(name: QualName,
@@ -102,7 +102,7 @@ fn create_svg_element(name: QualName,
}
match name.local {
- atom!("svg") => make!(SVGSVGElement),
+ local_name!("svg") => make!(SVGSVGElement),
_ => Element::new(name.local, name.ns, prefix, document),
}
}
@@ -128,157 +128,157 @@ fn create_html_element(name: QualName,
// This is a big match, and the IDs for inline-interned atoms are not very structured.
// Perhaps we should build a perfect hash from those IDs instead.
match name.local {
- atom!("a") => make!(HTMLAnchorElement),
- atom!("abbr") => make!(HTMLElement),
- atom!("acronym") => make!(HTMLElement),
- atom!("address") => make!(HTMLElement),
- atom!("applet") => make!(HTMLAppletElement),
- atom!("area") => make!(HTMLAreaElement),
- atom!("article") => make!(HTMLElement),
- atom!("aside") => make!(HTMLElement),
- atom!("audio") => make!(HTMLAudioElement),
- atom!("b") => make!(HTMLElement),
- atom!("base") => make!(HTMLBaseElement),
- atom!("bdi") => make!(HTMLElement),
- atom!("bdo") => make!(HTMLElement),
+ local_name!("a") => make!(HTMLAnchorElement),
+ local_name!("abbr") => make!(HTMLElement),
+ local_name!("acronym") => make!(HTMLElement),
+ local_name!("address") => make!(HTMLElement),
+ local_name!("applet") => make!(HTMLAppletElement),
+ local_name!("area") => make!(HTMLAreaElement),
+ local_name!("article") => make!(HTMLElement),
+ local_name!("aside") => make!(HTMLElement),
+ local_name!("audio") => make!(HTMLAudioElement),
+ local_name!("b") => make!(HTMLElement),
+ local_name!("base") => make!(HTMLBaseElement),
+ local_name!("bdi") => make!(HTMLElement),
+ local_name!("bdo") => make!(HTMLElement),
// https://html.spec.whatwg.org/multipage/#other-elements,-attributes-and-apis:bgsound
- atom!("bgsound") => make!(HTMLUnknownElement),
- atom!("big") => make!(HTMLElement),
+ local_name!("bgsound") => make!(HTMLUnknownElement),
+ local_name!("big") => make!(HTMLElement),
// https://html.spec.whatwg.org/multipage/#other-elements,-attributes-and-apis:blink
- atom!("blink") => make!(HTMLUnknownElement),
+ local_name!("blink") => make!(HTMLUnknownElement),
// https://html.spec.whatwg.org/multipage/#the-blockquote-element
- atom!("blockquote") => make!(HTMLQuoteElement),
- atom!("body") => make!(HTMLBodyElement),
- atom!("br") => make!(HTMLBRElement),
- atom!("button") => make!(HTMLButtonElement),
- atom!("canvas") => make!(HTMLCanvasElement),
- atom!("caption") => make!(HTMLTableCaptionElement),
- atom!("center") => make!(HTMLElement),
- atom!("cite") => make!(HTMLElement),
- atom!("code") => make!(HTMLElement),
- atom!("col") => make!(HTMLTableColElement),
- atom!("colgroup") => make!(HTMLTableColElement),
- atom!("data") => make!(HTMLDataElement),
- atom!("datalist") => make!(HTMLDataListElement),
- atom!("dd") => make!(HTMLElement),
- atom!("del") => make!(HTMLModElement),
- atom!("details") => make!(HTMLDetailsElement),
- atom!("dfn") => make!(HTMLElement),
- atom!("dialog") => make!(HTMLDialogElement),
- atom!("dir") => make!(HTMLDirectoryElement),
- atom!("div") => make!(HTMLDivElement),
- atom!("dl") => make!(HTMLDListElement),
- atom!("dt") => make!(HTMLElement),
- atom!("em") => make!(HTMLElement),
- atom!("embed") => make!(HTMLEmbedElement),
- atom!("fieldset") => make!(HTMLFieldSetElement),
- atom!("figcaption") => make!(HTMLElement),
- atom!("figure") => make!(HTMLElement),
- atom!("font") => make!(HTMLFontElement),
- atom!("footer") => make!(HTMLElement),
- atom!("form") => make!(HTMLFormElement),
- atom!("frame") => make!(HTMLFrameElement),
- atom!("frameset") => make!(HTMLFrameSetElement),
- atom!("h1") => make!(HTMLHeadingElement, HeadingLevel::Heading1),
- atom!("h2") => make!(HTMLHeadingElement, HeadingLevel::Heading2),
- atom!("h3") => make!(HTMLHeadingElement, HeadingLevel::Heading3),
- atom!("h4") => make!(HTMLHeadingElement, HeadingLevel::Heading4),
- atom!("h5") => make!(HTMLHeadingElement, HeadingLevel::Heading5),
- atom!("h6") => make!(HTMLHeadingElement, HeadingLevel::Heading6),
- atom!("head") => make!(HTMLHeadElement),
- atom!("header") => make!(HTMLElement),
- atom!("hgroup") => make!(HTMLElement),
- atom!("hr") => make!(HTMLHRElement),
- atom!("html") => make!(HTMLHtmlElement),
- atom!("i") => make!(HTMLElement),
- atom!("iframe") => make!(HTMLIFrameElement),
- atom!("img") => make!(HTMLImageElement),
- atom!("input") => make!(HTMLInputElement),
- atom!("ins") => make!(HTMLModElement),
+ local_name!("blockquote") => make!(HTMLQuoteElement),
+ local_name!("body") => make!(HTMLBodyElement),
+ local_name!("br") => make!(HTMLBRElement),
+ local_name!("button") => make!(HTMLButtonElement),
+ local_name!("canvas") => make!(HTMLCanvasElement),
+ local_name!("caption") => make!(HTMLTableCaptionElement),
+ local_name!("center") => make!(HTMLElement),
+ local_name!("cite") => make!(HTMLElement),
+ local_name!("code") => make!(HTMLElement),
+ local_name!("col") => make!(HTMLTableColElement),
+ local_name!("colgroup") => make!(HTMLTableColElement),
+ local_name!("data") => make!(HTMLDataElement),
+ local_name!("datalist") => make!(HTMLDataListElement),
+ local_name!("dd") => make!(HTMLElement),
+ local_name!("del") => make!(HTMLModElement),
+ local_name!("details") => make!(HTMLDetailsElement),
+ local_name!("dfn") => make!(HTMLElement),
+ local_name!("dialog") => make!(HTMLDialogElement),
+ local_name!("dir") => make!(HTMLDirectoryElement),
+ local_name!("div") => make!(HTMLDivElement),
+ local_name!("dl") => make!(HTMLDListElement),
+ local_name!("dt") => make!(HTMLElement),
+ local_name!("em") => make!(HTMLElement),
+ local_name!("embed") => make!(HTMLEmbedElement),
+ local_name!("fieldset") => make!(HTMLFieldSetElement),
+ local_name!("figcaption") => make!(HTMLElement),
+ local_name!("figure") => make!(HTMLElement),
+ local_name!("font") => make!(HTMLFontElement),
+ local_name!("footer") => make!(HTMLElement),
+ local_name!("form") => make!(HTMLFormElement),
+ local_name!("frame") => make!(HTMLFrameElement),
+ local_name!("frameset") => make!(HTMLFrameSetElement),
+ local_name!("h1") => make!(HTMLHeadingElement, HeadingLevel::Heading1),
+ local_name!("h2") => make!(HTMLHeadingElement, HeadingLevel::Heading2),
+ local_name!("h3") => make!(HTMLHeadingElement, HeadingLevel::Heading3),
+ local_name!("h4") => make!(HTMLHeadingElement, HeadingLevel::Heading4),
+ local_name!("h5") => make!(HTMLHeadingElement, HeadingLevel::Heading5),
+ local_name!("h6") => make!(HTMLHeadingElement, HeadingLevel::Heading6),
+ local_name!("head") => make!(HTMLHeadElement),
+ local_name!("header") => make!(HTMLElement),
+ local_name!("hgroup") => make!(HTMLElement),
+ local_name!("hr") => make!(HTMLHRElement),
+ local_name!("html") => make!(HTMLHtmlElement),
+ local_name!("i") => make!(HTMLElement),
+ local_name!("iframe") => make!(HTMLIFrameElement),
+ local_name!("img") => make!(HTMLImageElement),
+ local_name!("input") => make!(HTMLInputElement),
+ local_name!("ins") => make!(HTMLModElement),
// https://html.spec.whatwg.org/multipage/#other-elements,-attributes-and-apis:isindex-2
- atom!("isindex") => make!(HTMLUnknownElement),
- atom!("kbd") => make!(HTMLElement),
- atom!("label") => make!(HTMLLabelElement),
- atom!("legend") => make!(HTMLLegendElement),
- atom!("li") => make!(HTMLLIElement),
- atom!("link") => make!(HTMLLinkElement, creator),
+ local_name!("isindex") => make!(HTMLUnknownElement),
+ local_name!("kbd") => make!(HTMLElement),
+ local_name!("label") => make!(HTMLLabelElement),
+ local_name!("legend") => make!(HTMLLegendElement),
+ local_name!("li") => make!(HTMLLIElement),
+ local_name!("link") => make!(HTMLLinkElement, creator),
// https://html.spec.whatwg.org/multipage/#other-elements,-attributes-and-apis:listing
- atom!("listing") => make!(HTMLPreElement),
- atom!("main") => make!(HTMLElement),
- atom!("map") => make!(HTMLMapElement),
- atom!("mark") => make!(HTMLElement),
- atom!("marquee") => make!(HTMLElement),
- atom!("meta") => make!(HTMLMetaElement),
- atom!("meter") => make!(HTMLMeterElement),
+ local_name!("listing") => make!(HTMLPreElement),
+ local_name!("main") => make!(HTMLElement),
+ local_name!("map") => make!(HTMLMapElement),
+ local_name!("mark") => make!(HTMLElement),
+ local_name!("marquee") => make!(HTMLElement),
+ local_name!("meta") => make!(HTMLMetaElement),
+ local_name!("meter") => make!(HTMLMeterElement),
// https://html.spec.whatwg.org/multipage/#other-elements,-attributes-and-apis:multicol
- atom!("multicol") => make!(HTMLUnknownElement),
- atom!("nav") => make!(HTMLElement),
+ local_name!("multicol") => make!(HTMLUnknownElement),
+ local_name!("nav") => make!(HTMLElement),
// https://html.spec.whatwg.org/multipage/#other-elements,-attributes-and-apis:nextid
- atom!("nextid") => make!(HTMLUnknownElement),
- atom!("nobr") => make!(HTMLElement),
- atom!("noframes") => make!(HTMLElement),
- atom!("noscript") => make!(HTMLElement),
- atom!("object") => make!(HTMLObjectElement),
- atom!("ol") => make!(HTMLOListElement),
- atom!("optgroup") => make!(HTMLOptGroupElement),
- atom!("option") => make!(HTMLOptionElement),
- atom!("output") => make!(HTMLOutputElement),
- atom!("p") => make!(HTMLParagraphElement),
- atom!("param") => make!(HTMLParamElement),
- atom!("plaintext") => make!(HTMLPreElement),
- atom!("pre") => make!(HTMLPreElement),
- atom!("progress") => make!(HTMLProgressElement),
- atom!("q") => make!(HTMLQuoteElement),
- atom!("rp") => make!(HTMLElement),
- atom!("rt") => make!(HTMLElement),
- atom!("ruby") => make!(HTMLElement),
- atom!("s") => make!(HTMLElement),
- atom!("samp") => make!(HTMLElement),
- atom!("script") => make!(HTMLScriptElement, creator),
- atom!("section") => make!(HTMLElement),
- atom!("select") => make!(HTMLSelectElement),
- atom!("small") => make!(HTMLElement),
- atom!("source") => make!(HTMLSourceElement),
+ local_name!("nextid") => make!(HTMLUnknownElement),
+ local_name!("nobr") => make!(HTMLElement),
+ local_name!("noframes") => make!(HTMLElement),
+ local_name!("noscript") => make!(HTMLElement),
+ local_name!("object") => make!(HTMLObjectElement),
+ local_name!("ol") => make!(HTMLOListElement),
+ local_name!("optgroup") => make!(HTMLOptGroupElement),
+ local_name!("option") => make!(HTMLOptionElement),
+ local_name!("output") => make!(HTMLOutputElement),
+ local_name!("p") => make!(HTMLParagraphElement),
+ local_name!("param") => make!(HTMLParamElement),
+ local_name!("plaintext") => make!(HTMLPreElement),
+ local_name!("pre") => make!(HTMLPreElement),
+ local_name!("progress") => make!(HTMLProgressElement),
+ local_name!("q") => make!(HTMLQuoteElement),
+ local_name!("rp") => make!(HTMLElement),
+ local_name!("rt") => make!(HTMLElement),
+ local_name!("ruby") => make!(HTMLElement),
+ local_name!("s") => make!(HTMLElement),
+ local_name!("samp") => make!(HTMLElement),
+ local_name!("script") => make!(HTMLScriptElement, creator),
+ local_name!("section") => make!(HTMLElement),
+ local_name!("select") => make!(HTMLSelectElement),
+ local_name!("small") => make!(HTMLElement),
+ local_name!("source") => make!(HTMLSourceElement),
// https://html.spec.whatwg.org/multipage/#other-elements,-attributes-and-apis:spacer
- atom!("spacer") => make!(HTMLUnknownElement),
- atom!("span") => make!(HTMLSpanElement),
- atom!("strike") => make!(HTMLElement),
- atom!("strong") => make!(HTMLElement),
- atom!("style") => make!(HTMLStyleElement),
- atom!("sub") => make!(HTMLElement),
- atom!("summary") => make!(HTMLElement),
- atom!("sup") => make!(HTMLElement),
- atom!("table") => make!(HTMLTableElement),
- atom!("tbody") => make!(HTMLTableSectionElement),
- atom!("td") => make!(HTMLTableDataCellElement),
- atom!("template") => make!(HTMLTemplateElement),
- atom!("textarea") => make!(HTMLTextAreaElement),
+ local_name!("spacer") => make!(HTMLUnknownElement),
+ local_name!("span") => make!(HTMLSpanElement),
+ local_name!("strike") => make!(HTMLElement),
+ local_name!("strong") => make!(HTMLElement),
+ local_name!("style") => make!(HTMLStyleElement),
+ local_name!("sub") => make!(HTMLElement),
+ local_name!("summary") => make!(HTMLElement),
+ local_name!("sup") => make!(HTMLElement),
+ local_name!("table") => make!(HTMLTableElement),
+ local_name!("tbody") => make!(HTMLTableSectionElement),
+ local_name!("td") => make!(HTMLTableDataCellElement),
+ local_name!("template") => make!(HTMLTemplateElement),
+ local_name!("textarea") => make!(HTMLTextAreaElement),
// https://html.spec.whatwg.org/multipage/#the-tfoot-element:concept-element-dom
- atom!("tfoot") => make!(HTMLTableSectionElement),
- atom!("th") => make!(HTMLTableHeaderCellElement),
+ local_name!("tfoot") => make!(HTMLTableSectionElement),
+ local_name!("th") => make!(HTMLTableHeaderCellElement),
// https://html.spec.whatwg.org/multipage/#the-thead-element:concept-element-dom
- atom!("thead") => make!(HTMLTableSectionElement),
- atom!("time") => make!(HTMLTimeElement),
- atom!("title") => make!(HTMLTitleElement),
- atom!("tr") => make!(HTMLTableRowElement),
- atom!("tt") => make!(HTMLElement),
- atom!("track") => make!(HTMLTrackElement),
- atom!("u") => make!(HTMLElement),
- atom!("ul") => make!(HTMLUListElement),
- atom!("var") => make!(HTMLElement),
- atom!("video") => make!(HTMLVideoElement),
- atom!("wbr") => make!(HTMLElement),
- atom!("xmp") => make!(HTMLPreElement),
+ local_name!("thead") => make!(HTMLTableSectionElement),
+ local_name!("time") => make!(HTMLTimeElement),
+ local_name!("title") => make!(HTMLTitleElement),
+ local_name!("tr") => make!(HTMLTableRowElement),
+ local_name!("tt") => make!(HTMLElement),
+ local_name!("track") => make!(HTMLTrackElement),
+ local_name!("u") => make!(HTMLElement),
+ local_name!("ul") => make!(HTMLUListElement),
+ local_name!("var") => make!(HTMLElement),
+ local_name!("video") => make!(HTMLVideoElement),
+ local_name!("wbr") => make!(HTMLElement),
+ local_name!("xmp") => make!(HTMLPreElement),
_ => make!(HTMLUnknownElement),
}
}
pub fn create_element(name: QualName,
- prefix: Option<Atom>,
+ prefix: Option<Prefix>,
document: &Document,
creator: ElementCreator)
-> Root<Element> {
- // FIXME(ajeffrey): Convert directly from Atom to DOMString.
+ // FIXME(ajeffrey): Convert directly from Prefix to DOMString.
let prefix = prefix.map(|p| DOMString::from(&*p));
diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs
index 37ff6e7a3bf..c7b607b8ae2 100644
--- a/components/script/dom/cssstyledeclaration.rs
+++ b/components/script/dom/cssstyledeclaration.rs
@@ -13,9 +13,9 @@ use dom::element::Element;
use dom::node::{Node, NodeDamage, window_from_node};
use dom::window::Window;
use parking_lot::RwLock;
+use servo_atoms::Atom;
use std::ascii::AsciiExt;
use std::sync::Arc;
-use string_cache::Atom;
use style::parser::ParserContextExtraData;
use style::properties::{Shorthand, Importance, PropertyDeclarationBlock};
use style::properties::{is_supported_property, parse_one_declaration, parse_style_attribute};
diff --git a/components/script/dom/customevent.rs b/components/script/dom/customevent.rs
index d7e026d69bc..a70aa096e43 100644
--- a/components/script/dom/customevent.rs
+++ b/components/script/dom/customevent.rs
@@ -14,7 +14,7 @@ use dom::event::Event;
use dom::globalscope::GlobalScope;
use js::jsapi::{HandleValue, JSContext};
use js::jsval::JSVal;
-use string_cache::Atom;
+use servo_atoms::Atom;
// https://dom.spec.whatwg.org/#interface-customevent
#[dom_struct]
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 1f48f8fea01..2728bc757fb 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -91,6 +91,7 @@ use encoding::EncodingRef;
use encoding::all::UTF_8;
use euclid::point::Point2D;
use html5ever::tree_builder::{LimitedQuirks, NoQuirks, Quirks, QuirksMode};
+use html5ever_atoms::{LocalName, QualName};
use ipc_channel::ipc::{self, IpcSender};
use js::jsapi::{JSContext, JSObject, JSRuntime};
use js::jsapi::JS_GetRuntime;
@@ -110,6 +111,7 @@ use script_traits::{AnimationState, CompositorEvent, MouseButton, MouseEventType
use script_traits::{ScriptMsg as ConstellationMsg, TouchpadPressurePhase};
use script_traits::{TouchEventType, TouchId};
use script_traits::UntrustedNodeAddress;
+use servo_atoms::Atom;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::boxed::FnBox;
@@ -122,7 +124,6 @@ use std::mem;
use std::rc::Rc;
use std::sync::Arc;
use std::time::{Duration, Instant};
-use string_cache::{Atom, QualName};
use style::attr::AttrValue;
use style::context::ReflowGoal;
use style::selector_impl::ElementSnapshot;
@@ -175,7 +176,7 @@ pub struct Document {
quirks_mode: Cell<QuirksMode>,
/// Caches for the getElement methods
id_map: DOMRefCell<HashMap<Atom, Vec<JS<Element>>>>,
- tag_map: DOMRefCell<HashMap<Atom, JS<HTMLCollection>>>,
+ tag_map: DOMRefCell<HashMap<LocalName, JS<HTMLCollection>>>,
tagns_map: DOMRefCell<HashMap<QualName, JS<HTMLCollection>>>,
classes_map: DOMRefCell<HashMap<Vec<Atom>, JS<HTMLCollection>>>,
images: MutNullableHeap<JS<HTMLCollection>>,
@@ -288,7 +289,7 @@ struct LinksFilter;
impl CollectionFilter for LinksFilter {
fn filter(&self, elem: &Element, _root: &Node) -> bool {
(elem.is::<HTMLAnchorElement>() || elem.is::<HTMLAreaElement>()) &&
- elem.has_attribute(&atom!("href"))
+ elem.has_attribute(&local_name!("href"))
}
}
@@ -312,7 +313,7 @@ impl CollectionFilter for ScriptsFilter {
struct AnchorsFilter;
impl CollectionFilter for AnchorsFilter {
fn filter(&self, elem: &Element, _root: &Node) -> bool {
- elem.is::<HTMLAnchorElement>() && elem.has_attribute(&atom!("href"))
+ elem.is::<HTMLAnchorElement>() && elem.has_attribute(&local_name!("href"))
}
}
@@ -428,7 +429,7 @@ impl Document {
let base = self.upcast::<Node>()
.traverse_preorder()
.filter_map(Root::downcast::<HTMLBaseElement>)
- .find(|element| element.upcast::<Element>().has_attribute(&atom!("href")));
+ .find(|element| element.upcast::<Element>().has_attribute(&local_name!("href")));
self.base_element.set(base.r());
}
@@ -577,7 +578,7 @@ impl Document {
fn get_anchor_by_name(&self, name: &str) -> Option<Root<Element>> {
let check_anchor = |node: &HTMLAnchorElement| {
let elem = node.upcast::<Element>();
- elem.get_attribute(&ns!(), &atom!("name"))
+ elem.get_attribute(&ns!(), &local_name!("name"))
.map_or(false, |attr| &**attr.value() == name)
};
let doc_node = self.upcast::<Node>();
@@ -1322,7 +1323,7 @@ impl Document {
}
}
- pub fn get_body_attribute(&self, local_name: &Atom) -> DOMString {
+ pub fn get_body_attribute(&self, local_name: &LocalName) -> DOMString {
match self.GetBody().and_then(Root::downcast::<HTMLBodyElement>) {
Some(ref body) => {
body.upcast::<Element>().get_string_attribute(local_name)
@@ -1331,7 +1332,7 @@ impl Document {
}
}
- pub fn set_body_attribute(&self, local_name: &Atom, value: DOMString) {
+ pub fn set_body_attribute(&self, local_name: &LocalName, value: DOMString) {
if let Some(ref body) = self.GetBody().and_then(Root::downcast::<HTMLBodyElement>) {
let body = body.upcast::<Element>();
let value = body.parse_attribute(&ns!(), &local_name, value);
@@ -2175,13 +2176,13 @@ impl DocumentMethods for Document {
// https://dom.spec.whatwg.org/#dom-document-getelementsbytagname
fn GetElementsByTagName(&self, tag_name: DOMString) -> Root<HTMLCollection> {
- let tag_atom = Atom::from(&*tag_name);
+ let tag_atom = LocalName::from(&*tag_name);
match self.tag_map.borrow_mut().entry(tag_atom.clone()) {
Occupied(entry) => Root::from_ref(entry.get()),
Vacant(entry) => {
let mut tag_copy = tag_name;
tag_copy.make_ascii_lowercase();
- let ascii_lower_tag = Atom::from(tag_copy);
+ let ascii_lower_tag = LocalName::from(tag_copy);
let result = HTMLCollection::by_atomic_tag_name(&self.window,
self.upcast(),
tag_atom,
@@ -2198,7 +2199,7 @@ impl DocumentMethods for Document {
tag_name: DOMString)
-> Root<HTMLCollection> {
let ns = namespace_from_domstring(maybe_ns);
- let local = Atom::from(tag_name);
+ let local = LocalName::from(tag_name);
let qname = QualName::new(ns, local);
match self.tagns_map.borrow_mut().entry(qname.clone()) {
Occupied(entry) => Root::from_ref(entry.get()),
@@ -2241,7 +2242,7 @@ impl DocumentMethods for Document {
if self.is_html_document {
local_name.make_ascii_lowercase();
}
- let name = QualName::new(ns!(html), Atom::from(local_name));
+ let name = QualName::new(ns!(html), LocalName::from(local_name));
Ok(Element::create(name, None, self, ElementCreator::ScriptCreated))
}
@@ -2265,7 +2266,7 @@ impl DocumentMethods for Document {
if self.is_html_document {
local_name.make_ascii_lowercase();
}
- let name = Atom::from(local_name);
+ let name = LocalName::from(local_name);
let value = AttrValue::String("".to_owned());
Ok(Attr::new(&self.window, name.clone(), value, name, ns!(), None, None))
@@ -2279,7 +2280,7 @@ impl DocumentMethods for Document {
let (namespace, prefix, local_name) = try!(validate_and_extract(namespace,
&qualified_name));
let value = AttrValue::String("".to_owned());
- let qualified_name = Atom::from(qualified_name);
+ let qualified_name = LocalName::from(qualified_name);
Ok(Attr::new(&self.window,
local_name,
value,
@@ -2465,12 +2466,12 @@ impl DocumentMethods for Document {
// https://html.spec.whatwg.org/multipage/#document.title
fn Title(&self) -> DOMString {
let title = self.GetDocumentElement().and_then(|root| {
- if root.namespace() == &ns!(svg) && root.local_name() == &atom!("svg") {
+ if root.namespace() == &ns!(svg) && root.local_name() == &local_name!("svg") {
// Step 1.
root.upcast::<Node>()
.child_elements()
.find(|node| {
- node.namespace() == &ns!(svg) && node.local_name() == &atom!("title")
+ node.namespace() == &ns!(svg) && node.local_name() == &local_name!("title")
})
.map(Root::upcast::<Node>)
} else {
@@ -2498,14 +2499,14 @@ impl DocumentMethods for Document {
None => return,
};
- let elem = if root.namespace() == &ns!(svg) && root.local_name() == &atom!("svg") {
+ let elem = if root.namespace() == &ns!(svg) && root.local_name() == &local_name!("svg") {
let elem = root.upcast::<Node>().child_elements().find(|node| {
- node.namespace() == &ns!(svg) && node.local_name() == &atom!("title")
+ node.namespace() == &ns!(svg) && node.local_name() == &local_name!("title")
});
match elem {
Some(elem) => Root::upcast::<Node>(elem),
None => {
- let name = QualName::new(ns!(svg), atom!("title"));
+ let name = QualName::new(ns!(svg), local_name!("title"));
let elem = Element::create(name, None, self, ElementCreator::ScriptCreated);
let parent = root.upcast::<Node>();
let child = elem.upcast::<Node>();
@@ -2522,7 +2523,7 @@ impl DocumentMethods for Document {
None => {
match self.GetHead() {
Some(head) => {
- let name = QualName::new(ns!(html), atom!("title"));
+ let name = QualName::new(ns!(html), local_name!("title"));
let elem = Element::create(name,
None,
self,
@@ -2617,7 +2618,7 @@ impl DocumentMethods for Document {
if element.namespace() != &ns!(html) {
return false;
}
- element.get_attribute(&ns!(), &atom!("name"))
+ element.get_attribute(&ns!(), &local_name!("name"))
.map_or(false, |attr| &**attr.value() == &*name)
})
}
@@ -2785,22 +2786,22 @@ impl DocumentMethods for Document {
// https://html.spec.whatwg.org/multipage/#dom-document-bgcolor
fn BgColor(&self) -> DOMString {
- self.get_body_attribute(&atom!("bgcolor"))
+ self.get_body_attribute(&local_name!("bgcolor"))
}
// https://html.spec.whatwg.org/multipage/#dom-document-bgcolor
fn SetBgColor(&self, value: DOMString) {
- self.set_body_attribute(&atom!("bgcolor"), value)
+ self.set_body_attribute(&local_name!("bgcolor"), value)
}
// https://html.spec.whatwg.org/multipage/#dom-document-fgcolor
fn FgColor(&self) -> DOMString {
- self.get_body_attribute(&atom!("text"))
+ self.get_body_attribute(&local_name!("text"))
}
// https://html.spec.whatwg.org/multipage/#dom-document-fgcolor
fn SetFgColor(&self, value: DOMString) {
- self.set_body_attribute(&atom!("text"), value)
+ self.set_body_attribute(&local_name!("text"), value)
}
#[allow(unsafe_code)]
@@ -2827,10 +2828,10 @@ impl DocumentMethods for Document {
};
match html_elem_type {
HTMLElementTypeId::HTMLAppletElement => {
- match elem.get_attribute(&ns!(), &atom!("name")) {
+ match elem.get_attribute(&ns!(), &local_name!("name")) {
Some(ref attr) if attr.value().as_atom() == name => true,
_ => {
- match elem.get_attribute(&ns!(), &atom!("id")) {
+ match elem.get_attribute(&ns!(), &local_name!("id")) {
Some(ref attr) => attr.value().as_atom() == name,
None => false,
}
@@ -2838,18 +2839,18 @@ impl DocumentMethods for Document {
}
},
HTMLElementTypeId::HTMLFormElement => {
- match elem.get_attribute(&ns!(), &atom!("name")) {
+ match elem.get_attribute(&ns!(), &local_name!("name")) {
Some(ref attr) => attr.value().as_atom() == name,
None => false,
}
},
HTMLElementTypeId::HTMLImageElement => {
- match elem.get_attribute(&ns!(), &atom!("name")) {
+ match elem.get_attribute(&ns!(), &local_name!("name")) {
Some(ref attr) => {
if attr.value().as_atom() == name {
true
} else {
- match elem.get_attribute(&ns!(), &atom!("id")) {
+ match elem.get_attribute(&ns!(), &local_name!("id")) {
Some(ref attr) => attr.value().as_atom() == name,
None => false,
}
diff --git a/components/script/dom/documentfragment.rs b/components/script/dom/documentfragment.rs
index c9692aa4b1c..334e083f1b7 100644
--- a/components/script/dom/documentfragment.rs
+++ b/components/script/dom/documentfragment.rs
@@ -16,7 +16,7 @@ use dom::globalscope::GlobalScope;
use dom::htmlcollection::HTMLCollection;
use dom::node::{Node, window_from_node};
use dom::nodelist::NodeList;
-use string_cache::Atom;
+use servo_atoms::Atom;
// https://dom.spec.whatwg.org/#documentfragment
#[dom_struct]
@@ -57,7 +57,7 @@ impl DocumentFragmentMethods for DocumentFragment {
let node = self.upcast::<Node>();
let id = Atom::from(id);
node.traverse_preorder().filter_map(Root::downcast::<Element>).find(|descendant| {
- match descendant.get_attribute(&ns!(), &atom!("id")) {
+ match descendant.get_attribute(&ns!(), &local_name!("id")) {
None => false,
Some(attr) => *attr.value().as_atom() == id,
}
diff --git a/components/script/dom/domimplementation.rs b/components/script/dom/domimplementation.rs
index 4c7de14ee91..7556e64d0a7 100644
--- a/components/script/dom/domimplementation.rs
+++ b/components/script/dom/domimplementation.rs
@@ -142,14 +142,14 @@ impl DOMImplementationMethods for DOMImplementation {
{
// Step 4.
let doc_node = doc.upcast::<Node>();
- let doc_html = Root::upcast::<Node>(HTMLHtmlElement::new(atom!("html"),
+ let doc_html = Root::upcast::<Node>(HTMLHtmlElement::new(local_name!("html"),
None,
&doc));
doc_node.AppendChild(&doc_html).expect("Appending failed");
{
// Step 5.
- let doc_head = Root::upcast::<Node>(HTMLHeadElement::new(atom!("head"),
+ let doc_head = Root::upcast::<Node>(HTMLHeadElement::new(local_name!("head"),
None,
&doc));
doc_html.AppendChild(&doc_head).unwrap();
@@ -160,7 +160,7 @@ impl DOMImplementationMethods for DOMImplementation {
Some(title_str) => {
// Step 6.1.
let doc_title =
- Root::upcast::<Node>(HTMLTitleElement::new(atom!("title"),
+ Root::upcast::<Node>(HTMLTitleElement::new(local_name!("title"),
None,
&doc));
doc_head.AppendChild(&doc_title).unwrap();
@@ -173,7 +173,7 @@ impl DOMImplementationMethods for DOMImplementation {
}
// Step 7.
- let doc_body = HTMLBodyElement::new(atom!("body"), None, &doc);
+ let doc_body = HTMLBodyElement::new(local_name!("body"), None, &doc);
doc_html.AppendChild(doc_body.upcast()).unwrap();
}
diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs
index bc6c82ac6b2..95f42d12460 100644
--- a/components/script/dom/domtokenlist.rs
+++ b/components/script/dom/domtokenlist.rs
@@ -11,18 +11,19 @@ use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::element::Element;
use dom::node::window_from_node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
+use servo_atoms::Atom;
use style::str::HTML_SPACE_CHARACTERS;
#[dom_struct]
pub struct DOMTokenList {
reflector_: Reflector,
element: JS<Element>,
- local_name: Atom,
+ local_name: LocalName,
}
impl DOMTokenList {
- pub fn new_inherited(element: &Element, local_name: Atom) -> DOMTokenList {
+ pub fn new_inherited(element: &Element, local_name: LocalName) -> DOMTokenList {
DOMTokenList {
reflector_: Reflector::new(),
element: JS::from_ref(element),
@@ -30,7 +31,7 @@ impl DOMTokenList {
}
}
- pub fn new(element: &Element, local_name: &Atom) -> Root<DOMTokenList> {
+ pub fn new(element: &Element, local_name: &LocalName) -> Root<DOMTokenList> {
let window = window_from_node(element);
reflect_dom_object(box DOMTokenList::new_inherited(element, local_name.clone()),
&*window,
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 28ab35979ba..f2123fbbec6 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -69,10 +69,12 @@ use html5ever::serialize::SerializeOpts;
use html5ever::serialize::TraversalScope;
use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode};
use html5ever::tree_builder::{LimitedQuirks, NoQuirks, Quirks};
+use html5ever_atoms::{Prefix, LocalName, Namespace, QualName};
use parking_lot::RwLock;
use selectors::matching::{ElementFlags, MatchingReason, matches};
use selectors::matching::{HAS_EDGE_CHILD_SELECTOR, HAS_SLOW_SELECTOR, HAS_SLOW_SELECTOR_LATER_SIBLINGS};
use selectors::parser::{AttrSelector, NamespaceConstraint, parse_author_origin_selector_list_from_str};
+use servo_atoms::Atom;
use std::ascii::AsciiExt;
use std::borrow::Cow;
use std::cell::{Cell, Ref};
@@ -81,7 +83,6 @@ use std::default::Default;
use std::fmt;
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
-use string_cache::{Atom, Namespace, QualName};
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
use style::element_state::*;
use style::matching::{common_style_affecting_attributes, rare_style_affecting_attributes};
@@ -102,7 +103,7 @@ use style::values::specified::{self, CSSColor, CSSRGBA, LengthOrPercentage};
#[dom_struct]
pub struct Element {
node: Node,
- local_name: Atom,
+ local_name: LocalName,
tag_name: TagName,
namespace: Namespace,
prefix: Option<DOMString>,
@@ -157,20 +158,20 @@ impl<'a> TryFrom<&'a str> for AdjacentPosition {
// Element methods
//
impl Element {
- pub fn create(name: QualName, prefix: Option<Atom>,
+ pub fn create(name: QualName, prefix: Option<Prefix>,
document: &Document, creator: ElementCreator)
-> Root<Element> {
create_element(name, prefix, document, creator)
}
- pub fn new_inherited(local_name: Atom,
+ pub fn new_inherited(local_name: LocalName,
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: Atom,
+ pub fn new_inherited_with_state(state: ElementState, local_name: LocalName,
namespace: Namespace, prefix: Option<DOMString>,
document: &Document)
-> Element {
@@ -190,7 +191,7 @@ impl Element {
}
}
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
namespace: Namespace,
prefix: Option<DOMString>,
document: &Document) -> Root<Element> {
@@ -232,16 +233,16 @@ impl Element {
#[allow(unsafe_code)]
pub trait RawLayoutElementHelpers {
- unsafe fn get_attr_for_layout<'a>(&'a self, namespace: &Namespace, name: &Atom)
+ unsafe fn get_attr_for_layout<'a>(&'a self, namespace: &Namespace, name: &LocalName)
-> Option<&'a AttrValue>;
- unsafe fn get_attr_val_for_layout<'a>(&'a self, namespace: &Namespace, name: &Atom)
+ unsafe fn get_attr_val_for_layout<'a>(&'a self, namespace: &Namespace, name: &LocalName)
-> Option<&'a str>;
- unsafe fn get_attr_vals_for_layout<'a>(&'a self, name: &Atom) -> Vec<&'a str>;
+ unsafe fn get_attr_vals_for_layout<'a>(&'a self, name: &LocalName) -> Vec<&'a str>;
}
#[inline]
#[allow(unsafe_code)]
-pub unsafe fn get_attr_for_layout<'a>(elem: &'a Element, namespace: &Namespace, name: &Atom)
+pub unsafe fn get_attr_for_layout<'a>(elem: &'a Element, namespace: &Namespace, name: &LocalName)
-> Option<LayoutJS<Attr>> {
// cast to point to T in RefCell<T> directly
let attrs = elem.attrs.borrow_for_layout();
@@ -255,14 +256,14 @@ pub unsafe fn get_attr_for_layout<'a>(elem: &'a Element, namespace: &Namespace,
#[allow(unsafe_code)]
impl RawLayoutElementHelpers for Element {
#[inline]
- unsafe fn get_attr_for_layout<'a>(&'a self, namespace: &Namespace, name: &Atom)
+ unsafe fn get_attr_for_layout<'a>(&'a self, namespace: &Namespace, name: &LocalName)
-> Option<&'a AttrValue> {
get_attr_for_layout(self, namespace, name).map(|attr| {
attr.value_forever()
})
}
- unsafe fn get_attr_val_for_layout<'a>(&'a self, namespace: &Namespace, name: &Atom)
+ unsafe fn get_attr_val_for_layout<'a>(&'a self, namespace: &Namespace, name: &LocalName)
-> Option<&'a str> {
get_attr_for_layout(self, namespace, name).map(|attr| {
attr.value_ref_forever()
@@ -270,7 +271,7 @@ impl RawLayoutElementHelpers for Element {
}
#[inline]
- unsafe fn get_attr_vals_for_layout<'a>(&'a self, name: &Atom) -> Vec<&'a str> {
+ unsafe fn get_attr_vals_for_layout<'a>(&'a self, name: &LocalName) -> Vec<&'a str> {
let attrs = self.attrs.borrow_for_layout();
attrs.iter().filter_map(|attr| {
let attr = attr.to_layout();
@@ -298,7 +299,7 @@ pub trait LayoutElementHelpers {
unsafe fn html_element_in_html_document_for_layout(&self) -> bool;
fn id_attribute(&self) -> *const Option<Atom>;
fn style_attribute(&self) -> *const Option<Arc<RwLock<PropertyDeclarationBlock>>>;
- fn local_name(&self) -> &Atom;
+ fn local_name(&self) -> &LocalName;
fn namespace(&self) -> &Namespace;
fn get_checked_state_for_layout(&self) -> bool;
fn get_indeterminate_state_for_layout(&self) -> bool;
@@ -310,7 +311,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
#[allow(unsafe_code)]
#[inline]
unsafe fn has_class_for_layout(&self, name: &Atom) -> bool {
- get_attr_for_layout(&*self.unsafe_get(), &ns!(), &atom!("class")).map_or(false, |attr| {
+ get_attr_for_layout(&*self.unsafe_get(), &ns!(), &local_name!("class")).map_or(false, |attr| {
attr.value_tokens_forever().unwrap().iter().any(|atom| atom == name)
})
}
@@ -318,7 +319,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
#[allow(unsafe_code)]
#[inline]
unsafe fn get_classes_for_layout(&self) -> Option<&'static [Atom]> {
- get_attr_for_layout(&*self.unsafe_get(), &ns!(), &atom!("class"))
+ get_attr_for_layout(&*self.unsafe_get(), &ns!(), &local_name!("class"))
.map(|attr| attr.value_tokens_forever().unwrap())
}
@@ -440,7 +441,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
let size = if let Some(this) = self.downcast::<HTMLInputElement>() {
// FIXME(pcwalton): More use of atoms, please!
- match (*self.unsafe_get()).get_attr_val_for_layout(&ns!(), &atom!("type")) {
+ match (*self.unsafe_get()).get_attr_val_for_layout(&ns!(), &local_name!("type")) {
// Not text entry widget
Some("hidden") | Some("date") | Some("month") | Some("week") |
Some("time") | Some("datetime-local") | Some("number") | Some("range") |
@@ -622,7 +623,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
}
#[allow(unsafe_code)]
- fn local_name(&self) -> &Atom {
+ fn local_name(&self) -> &LocalName {
unsafe {
&(*self.unsafe_get()).local_name
}
@@ -681,15 +682,15 @@ impl Element {
self.namespace == ns!(html) && self.upcast::<Node>().is_in_html_doc()
}
- pub fn local_name(&self) -> &Atom {
+ pub fn local_name(&self) -> &LocalName {
&self.local_name
}
- pub fn parsed_name(&self, mut name: DOMString) -> Atom {
+ pub fn parsed_name(&self, mut name: DOMString) -> LocalName {
if self.html_element_in_html_document() {
name.make_ascii_lowercase();
}
- Atom::from(name)
+ LocalName::from(name)
}
pub fn namespace(&self) -> &Namespace {
@@ -722,10 +723,14 @@ impl Element {
/* List of void elements from
https://html.spec.whatwg.org/multipage/#html-fragment-serialisation-algorithm */
- atom!("area") | atom!("base") | atom!("basefont") | atom!("bgsound") | atom!("br") |
- atom!("col") | atom!("embed") | atom!("frame") | atom!("hr") | atom!("img") |
- atom!("input") | atom!("keygen") | atom!("link") | atom!("menuitem") | atom!("meta") |
- atom!("param") | atom!("source") | atom!("track") | atom!("wbr") => true,
+ local_name!("area") | local_name!("base") | local_name!("basefont") |
+ local_name!("bgsound") | local_name!("br") |
+ local_name!("col") | local_name!("embed") | local_name!("frame") |
+ local_name!("hr") | local_name!("img") |
+ local_name!("input") | local_name!("keygen") | local_name!("link") |
+ local_name!("menuitem") | local_name!("meta") |
+ local_name!("param") | local_name!("source") | local_name!("track") |
+ local_name!("wbr") => true,
_ => false
}
}
@@ -735,7 +740,7 @@ impl Element {
pub fn set_style_attr(&self, new_value: String) {
let mut new_style = AttrValue::String(new_value);
- if let Some(style_attr) = self.attrs.borrow().iter().find(|a| a.name() == &atom!("style")) {
+ if let Some(style_attr) = self.attrs.borrow().iter().find(|a| a.name() == &local_name!("style")) {
style_attr.swap_value(&mut new_style);
return;
}
@@ -744,11 +749,11 @@ impl Element {
// in order to avoid triggering mutation events
let window = window_from_node(self);
let attr = Attr::new(&window,
- atom!("style"),
+ local_name!("style"),
new_style,
- atom!("style"),
+ local_name!("style"),
ns!(),
- Some(atom!("style")),
+ None,
Some(self));
assert!(attr.GetOwnerElement().r() == Some(self));
@@ -798,8 +803,8 @@ impl Element {
// Step 2.
for attr in element.attrs.borrow().iter() {
- if *attr.prefix() == Some(atom!("xmlns")) &&
- **attr.value() == *namespace.0 {
+ if *attr.prefix() == Some(namespace_prefix!("xmlns")) &&
+ **attr.value() == *namespace {
return Some(attr.LocalName());
}
}
@@ -856,11 +861,11 @@ impl Element {
impl Element {
pub fn push_new_attribute(&self,
- local_name: Atom,
+ local_name: LocalName,
value: AttrValue,
- name: Atom,
+ name: LocalName,
namespace: Namespace,
- prefix: Option<Atom>) {
+ prefix: Option<Prefix>) {
let window = window_from_node(self);
let attr = Attr::new(&window,
local_name,
@@ -881,7 +886,7 @@ impl Element {
}
}
- pub fn get_attribute(&self, namespace: &Namespace, local_name: &Atom) -> Option<Root<Attr>> {
+ pub fn get_attribute(&self, namespace: &Namespace, local_name: &LocalName) -> Option<Root<Attr>> {
self.attrs
.borrow()
.iter()
@@ -898,7 +903,7 @@ impl Element {
pub fn set_attribute_from_parser(&self,
qname: QualName,
value: DOMString,
- prefix: Option<Atom>) {
+ prefix: Option<Prefix>) {
// Don't set if the attribute already exists, so we can handle add_attrs_if_missing
if self.attrs
.borrow()
@@ -911,14 +916,14 @@ impl Element {
None => qname.local.clone(),
Some(ref prefix) => {
let name = format!("{}:{}", &**prefix, &*qname.local);
- Atom::from(name)
+ LocalName::from(name)
},
};
let value = self.parse_attribute(&qname.ns, &qname.local, value);
self.push_new_attribute(qname.local, value, name, qname.ns, prefix);
}
- pub fn set_attribute(&self, name: &Atom, value: AttrValue) {
+ pub fn set_attribute(&self, name: &LocalName, value: AttrValue) {
assert!(name == &name.to_ascii_lowercase());
assert!(!name.contains(":"));
@@ -938,7 +943,7 @@ impl Element {
}
// Steps 2-5.
- let name = Atom::from(name);
+ let name = LocalName::from(name);
let value = self.parse_attribute(&ns!(), &name, value);
self.set_first_matching_attribute(name.clone(),
value,
@@ -952,11 +957,11 @@ impl Element {
}
fn set_first_matching_attribute<F>(&self,
- local_name: Atom,
+ local_name: LocalName,
value: AttrValue,
- name: Atom,
+ name: LocalName,
namespace: Namespace,
- prefix: Option<Atom>,
+ prefix: Option<Prefix>,
find: F)
where F: Fn(&Attr) -> bool
{
@@ -974,7 +979,7 @@ impl Element {
pub fn parse_attribute(&self,
namespace: &Namespace,
- local_name: &Atom,
+ local_name: &LocalName,
value: DOMString)
-> AttrValue {
if *namespace == ns!() {
@@ -984,13 +989,13 @@ impl Element {
}
}
- pub fn remove_attribute(&self, namespace: &Namespace, local_name: &Atom) -> Option<Root<Attr>> {
+ pub fn remove_attribute(&self, namespace: &Namespace, local_name: &LocalName) -> Option<Root<Attr>> {
self.remove_first_matching_attribute(|attr| {
attr.namespace() == namespace && attr.local_name() == local_name
})
}
- pub fn remove_attribute_by_name(&self, name: &Atom) -> Option<Root<Attr>> {
+ pub fn remove_attribute_by_name(&self, name: &LocalName) -> Option<Root<Attr>> {
self.remove_first_matching_attribute(|attr| attr.name() == name)
}
@@ -1019,17 +1024,17 @@ impl Element {
Quirks => lhs.eq_ignore_ascii_case(&rhs),
}
};
- self.get_attribute(&ns!(), &atom!("class"))
+ self.get_attribute(&ns!(), &local_name!("class"))
.map_or(false, |attr| attr.value().as_tokens().iter().any(|atom| is_equal(name, atom)))
}
- pub fn set_atomic_attribute(&self, local_name: &Atom, value: DOMString) {
+ pub fn set_atomic_attribute(&self, local_name: &LocalName, value: DOMString) {
assert!(*local_name == local_name.to_ascii_lowercase());
let value = AttrValue::from_atomic(value.into());
self.set_attribute(local_name, value);
}
- pub fn has_attribute(&self, local_name: &Atom) -> bool {
+ pub fn has_attribute(&self, local_name: &LocalName) -> bool {
assert!(local_name.bytes().all(|b| b.to_ascii_lowercase() == b));
self.attrs
.borrow()
@@ -1037,7 +1042,7 @@ impl Element {
.any(|attr| attr.local_name() == local_name && attr.namespace() == &ns!())
}
- pub fn set_bool_attribute(&self, local_name: &Atom, value: bool) {
+ pub fn set_bool_attribute(&self, local_name: &LocalName, value: bool) {
if self.has_attribute(local_name) == value {
return;
}
@@ -1048,7 +1053,7 @@ impl Element {
}
}
- pub fn get_url_attribute(&self, local_name: &Atom) -> DOMString {
+ pub fn get_url_attribute(&self, local_name: &LocalName) -> DOMString {
assert!(*local_name == local_name.to_ascii_lowercase());
if !self.has_attribute(local_name) {
return DOMString::new();
@@ -1063,22 +1068,22 @@ impl Element {
Err(_) => DOMString::from(""),
}
}
- pub fn set_url_attribute(&self, local_name: &Atom, value: DOMString) {
+ pub fn set_url_attribute(&self, local_name: &LocalName, value: DOMString) {
self.set_string_attribute(local_name, value);
}
- pub fn get_string_attribute(&self, local_name: &Atom) -> DOMString {
+ pub fn get_string_attribute(&self, local_name: &LocalName) -> DOMString {
match self.get_attribute(&ns!(), local_name) {
Some(x) => x.Value(),
None => DOMString::new(),
}
}
- pub fn set_string_attribute(&self, local_name: &Atom, value: DOMString) {
+ pub fn set_string_attribute(&self, local_name: &LocalName, value: DOMString) {
assert!(*local_name == local_name.to_ascii_lowercase());
self.set_attribute(local_name, AttrValue::String(value.into()));
}
- pub fn get_tokenlist_attribute(&self, local_name: &Atom) -> Vec<Atom> {
+ pub fn get_tokenlist_attribute(&self, local_name: &LocalName) -> Vec<Atom> {
self.get_attribute(&ns!(), local_name).map(|attr| {
attr.value()
.as_tokens()
@@ -1086,18 +1091,18 @@ impl Element {
}).unwrap_or(vec!())
}
- pub fn set_tokenlist_attribute(&self, local_name: &Atom, value: DOMString) {
+ pub fn set_tokenlist_attribute(&self, local_name: &LocalName, value: DOMString) {
assert!(*local_name == local_name.to_ascii_lowercase());
self.set_attribute(local_name,
AttrValue::from_serialized_tokenlist(value.into()));
}
- pub fn set_atomic_tokenlist_attribute(&self, local_name: &Atom, tokens: Vec<Atom>) {
+ pub fn set_atomic_tokenlist_attribute(&self, local_name: &LocalName, tokens: Vec<Atom>) {
assert!(*local_name == local_name.to_ascii_lowercase());
self.set_attribute(local_name, AttrValue::from_atomic_tokens(tokens));
}
- pub fn get_int_attribute(&self, local_name: &Atom, default: i32) -> i32 {
+ pub fn get_int_attribute(&self, local_name: &LocalName, default: i32) -> i32 {
// TODO: Is this assert necessary?
assert!(local_name.chars().all(|ch| {
!ch.is_ascii() || ch.to_ascii_lowercase() == ch
@@ -1116,12 +1121,12 @@ impl Element {
}
}
- pub fn set_int_attribute(&self, local_name: &Atom, value: i32) {
+ pub fn set_int_attribute(&self, local_name: &LocalName, value: i32) {
assert!(*local_name == local_name.to_ascii_lowercase());
self.set_attribute(local_name, AttrValue::Int(value.to_string(), value));
}
- pub fn get_uint_attribute(&self, local_name: &Atom, default: u32) -> u32 {
+ pub fn get_uint_attribute(&self, local_name: &LocalName, default: u32) -> u32 {
assert!(local_name.chars().all(|ch| !ch.is_ascii() || ch.to_ascii_lowercase() == ch));
let attribute = self.get_attribute(&ns!(), local_name);
match attribute {
@@ -1134,7 +1139,7 @@ impl Element {
None => default,
}
}
- pub fn set_uint_attribute(&self, local_name: &Atom, value: u32) {
+ pub fn set_uint_attribute(&self, local_name: &LocalName, value: u32) {
assert!(*local_name == local_name.to_ascii_lowercase());
self.set_attribute(local_name, AttrValue::UInt(value.to_string(), value));
}
@@ -1226,7 +1231,7 @@ impl ElementMethods for Element {
// https://dom.spec.whatwg.org/#dom-element-localname
fn LocalName(&self) -> DOMString {
- // FIXME(ajeffrey): Convert directly from Atom to DOMString
+ // FIXME(ajeffrey): Convert directly from LocalName to DOMString
DOMString::from(&*self.local_name)
}
@@ -1245,9 +1250,9 @@ impl ElementMethods for Element {
None => Cow::Borrowed(&*self.local_name)
};
if self.html_element_in_html_document() {
- Atom::from(qualified_name.to_ascii_uppercase())
+ LocalName::from(qualified_name.to_ascii_uppercase())
} else {
- Atom::from(qualified_name)
+ LocalName::from(qualified_name)
}
});
DOMString::from(&*name)
@@ -1255,27 +1260,27 @@ impl ElementMethods for Element {
// https://dom.spec.whatwg.org/#dom-element-id
fn Id(&self) -> DOMString {
- self.get_string_attribute(&atom!("id"))
+ self.get_string_attribute(&local_name!("id"))
}
// https://dom.spec.whatwg.org/#dom-element-id
fn SetId(&self, id: DOMString) {
- self.set_atomic_attribute(&atom!("id"), id);
+ self.set_atomic_attribute(&local_name!("id"), id);
}
// https://dom.spec.whatwg.org/#dom-element-classname
fn ClassName(&self) -> DOMString {
- self.get_string_attribute(&atom!("class"))
+ self.get_string_attribute(&local_name!("class"))
}
// https://dom.spec.whatwg.org/#dom-element-classname
fn SetClassName(&self, class: DOMString) {
- self.set_tokenlist_attribute(&atom!("class"), class);
+ self.set_tokenlist_attribute(&local_name!("class"), class);
}
// https://dom.spec.whatwg.org/#dom-element-classlist
fn ClassList(&self) -> Root<DOMTokenList> {
- self.class_list.or_init(|| DOMTokenList::new(self, &atom!("class")))
+ self.class_list.or_init(|| DOMTokenList::new(self, &local_name!("class")))
}
// https://dom.spec.whatwg.org/#dom-element-attributes
@@ -1319,7 +1324,7 @@ impl ElementMethods for Element {
local_name: DOMString)
-> Option<Root<Attr>> {
let namespace = &namespace_from_domstring(namespace);
- self.get_attribute(namespace, &Atom::from(local_name))
+ self.get_attribute(namespace, &LocalName::from(local_name))
}
// https://dom.spec.whatwg.org/#dom-element-setattribute
@@ -1347,7 +1352,7 @@ impl ElementMethods for Element {
value: DOMString) -> ErrorResult {
let (namespace, prefix, local_name) =
try!(validate_and_extract(namespace, &qualified_name));
- let qualified_name = Atom::from(qualified_name);
+ let qualified_name = LocalName::from(qualified_name);
let value = self.parse_attribute(&namespace, &local_name, value);
self.set_first_matching_attribute(
local_name.clone(), value, qualified_name, namespace.clone(), prefix,
@@ -1413,7 +1418,7 @@ impl ElementMethods for Element {
// https://dom.spec.whatwg.org/#dom-element-removeattributens
fn RemoveAttributeNS(&self, namespace: Option<DOMString>, local_name: DOMString) {
let namespace = namespace_from_domstring(namespace);
- let local_name = Atom::from(local_name);
+ let local_name = LocalName::from(local_name);
self.remove_attribute(&namespace, &local_name);
}
@@ -1781,7 +1786,7 @@ impl ElementMethods for Element {
// Step 4.
NodeTypeId::DocumentFragment => {
- let body_elem = Element::create(QualName::new(ns!(html), atom!("body")),
+ let body_elem = Element::create(QualName::new(ns!(html), local_name!("body")),
None, &context_document,
ElementCreator::ScriptCreated);
Root::upcast(body_elem)
@@ -1944,9 +1949,9 @@ impl ElementMethods for Element {
// Step 2.
let context = match context.downcast::<Element>() {
- Some(elem) if elem.local_name() != &atom!("html") ||
+ Some(elem) if elem.local_name() != &local_name!("html") ||
!elem.html_element_in_html_document() => Root::from_ref(elem),
- _ => Root::upcast(HTMLBodyElement::new(atom!("body"), None, &*context.owner_doc())),
+ _ => Root::upcast(HTMLBodyElement::new(local_name!("body"), None, &*context.owner_doc())),
};
// Step 3.
@@ -1978,8 +1983,8 @@ impl ElementMethods for Element {
}
}
-pub fn fragment_affecting_attributes() -> [Atom; 3] {
- [atom!("width"), atom!("height"), atom!("src")]
+pub fn fragment_affecting_attributes() -> [LocalName; 3] {
+ [local_name!("width"), local_name!("height"), local_name!("src")]
}
impl VirtualMethods for Element {
@@ -1992,7 +1997,7 @@ impl VirtualMethods for Element {
let node = self.upcast::<Node>();
let doc = node.owner_doc();
match attr.local_name() {
- &atom!("style") => {
+ &local_name!("style") => {
// Modifying the `style` attribute might change style.
*self.style_attribute.borrow_mut() =
mutation.new_value(attr).map(|value| {
@@ -2007,7 +2012,7 @@ impl VirtualMethods for Element {
node.dirty(NodeDamage::NodeStyleDamaged);
}
},
- &atom!("id") => {
+ &local_name!("id") => {
*self.id_attribute.borrow_mut() =
mutation.new_value(attr).and_then(|value| {
let value = value.as_atom();
@@ -2039,7 +2044,7 @@ impl VirtualMethods for Element {
},
_ if attr.namespace() == &ns!() => {
if fragment_affecting_attributes().iter().any(|a| a == attr.local_name()) ||
- common_style_affecting_attributes().iter().any(|a| &a.atom == attr.local_name()) ||
+ common_style_affecting_attributes().iter().any(|a| &a.attr_name == attr.local_name()) ||
rare_style_affecting_attributes().iter().any(|a| a == attr.local_name())
{
node.dirty(NodeDamage::OtherNodeDamage);
@@ -2054,10 +2059,10 @@ impl VirtualMethods for Element {
node.rev_version();
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("id") => AttrValue::from_atomic(value.into()),
- &atom!("class") => AttrValue::from_serialized_tokenlist(value.into()),
+ &local_name!("id") => AttrValue::from_atomic(value.into()),
+ &local_name!("class") => AttrValue::from_serialized_tokenlist(value.into()),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
@@ -2191,7 +2196,7 @@ impl<'a> ::selectors::Element for Root<Element> {
})
}
- fn get_local_name(&self) -> &Atom {
+ fn get_local_name(&self) -> &LocalName {
self.local_name()
}
@@ -2246,7 +2251,7 @@ impl<'a> ::selectors::Element for Root<Element> {
fn each_class<F>(&self, mut callback: F)
where F: FnMut(&Atom)
{
- if let Some(ref attr) = self.get_attribute(&ns!(), &atom!("class")) {
+ if let Some(ref attr) = self.get_attribute(&ns!(), &local_name!("class")) {
let tokens = attr.value();
let tokens = tokens.as_tokens();
for token in tokens {
@@ -2357,7 +2362,7 @@ impl Element {
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) => {
- self.has_attribute(&atom!("href"))
+ self.has_attribute(&local_name!("href"))
},
_ => false,
}
@@ -2551,7 +2556,7 @@ impl Element {
}
pub fn check_disabled_attribute(&self) {
- let has_disabled_attrib = self.has_attribute(&atom!("disabled"));
+ let has_disabled_attrib = self.has_attribute(&local_name!("disabled"));
self.set_disabled_state(has_disabled_attrib);
self.set_enabled_state(!has_disabled_attrib);
}
@@ -2600,7 +2605,7 @@ impl AtomicElementFlags {
/// owner changes.
#[derive(JSTraceable, HeapSizeOf)]
struct TagName {
- ptr: DOMRefCell<Option<Atom>>,
+ ptr: DOMRefCell<Option<LocalName>>,
}
impl TagName {
@@ -2610,8 +2615,8 @@ impl TagName {
/// Retrieve a copy of the current inner value. If it is `None`, it is
/// initialized with the result of `cb` first.
- fn or_init<F>(&self, cb: F) -> Atom
- where F: FnOnce() -> Atom
+ fn or_init<F>(&self, cb: F) -> LocalName
+ where F: FnOnce() -> LocalName
{
match &mut *self.ptr.borrow_mut() {
&mut Some(ref name) => name.clone(),
diff --git a/components/script/dom/errorevent.rs b/components/script/dom/errorevent.rs
index edf1118b58c..65f3be9e32b 100644
--- a/components/script/dom/errorevent.rs
+++ b/components/script/dom/errorevent.rs
@@ -15,8 +15,8 @@ use dom::event::{Event, EventBubbles, EventCancelable};
use dom::globalscope::GlobalScope;
use js::jsapi::{HandleValue, JSContext};
use js::jsval::JSVal;
+use servo_atoms::Atom;
use std::cell::Cell;
-use string_cache::Atom;
#[dom_struct]
pub struct ErrorEvent {
diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs
index cdbfdafec2e..f50d51dbb65 100644
--- a/components/script/dom/event.rs
+++ b/components/script/dom/event.rs
@@ -14,9 +14,9 @@ use dom::eventdispatcher::EventStatus;
use dom::eventtarget::EventTarget;
use dom::globalscope::GlobalScope;
use script_thread::Runnable;
+use servo_atoms::Atom;
use std::cell::Cell;
use std::default::Default;
-use string_cache::Atom;
use time;
#[derive(JSTraceable, Copy, Clone, Debug, PartialEq, Eq)]
diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs
index a17bac4a35c..51452c0fc53 100644
--- a/components/script/dom/eventtarget.rs
+++ b/components/script/dom/eventtarget.rs
@@ -32,6 +32,7 @@ use heapsize::HeapSizeOf;
use js::jsapi::{CompileFunction, JS_GetFunctionObject, JSAutoCompartment};
use js::rust::{AutoObjectVectorWrapper, CompileOptionsWrapper};
use libc::{c_char, size_t};
+use servo_atoms::Atom;
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::default::Default;
@@ -41,7 +42,6 @@ use std::mem;
use std::ops::{Deref, DerefMut};
use std::ptr;
use std::rc::Rc;
-use string_cache::Atom;
use url::Url;
#[derive(PartialEq, Clone, JSTraceable)]
diff --git a/components/script/dom/extendableevent.rs b/components/script/dom/extendableevent.rs
index d859d8f4724..55e9500a8e4 100644
--- a/components/script/dom/extendableevent.rs
+++ b/components/script/dom/extendableevent.rs
@@ -12,7 +12,7 @@ use dom::bindings::str::DOMString;
use dom::event::Event;
use dom::globalscope::GlobalScope;
use js::jsapi::{HandleValue, JSContext};
-use string_cache::Atom;
+use servo_atoms::Atom;
// https://w3c.github.io/ServiceWorker/#extendable-event
#[dom_struct]
diff --git a/components/script/dom/extendablemessageevent.rs b/components/script/dom/extendablemessageevent.rs
index 0a5968d1d99..b3f3a5318f7 100644
--- a/components/script/dom/extendablemessageevent.rs
+++ b/components/script/dom/extendablemessageevent.rs
@@ -15,8 +15,8 @@ use dom::extendableevent::ExtendableEvent;
use dom::globalscope::GlobalScope;
use js::jsapi::{HandleValue, Heap, JSContext};
use js::jsval::JSVal;
+use servo_atoms::Atom;
use std::default::Default;
-use string_cache::Atom;
#[dom_struct]
pub struct ExtendableMessageEvent {
diff --git a/components/script/dom/filereader.rs b/components/script/dom/filereader.rs
index 72ada5a03de..2594b196918 100644
--- a/components/script/dom/filereader.rs
+++ b/components/script/dom/filereader.rs
@@ -30,10 +30,10 @@ use js::jsval::{self, JSVal};
use js::typedarray::Uint8Array;
use rustc_serialize::base64::{CharacterSet, Config, Newline, ToBase64};
use script_thread::RunnableWrapper;
+use servo_atoms::Atom;
use std::cell::Cell;
use std::ptr;
use std::sync::Arc;
-use string_cache::Atom;
use task_source::TaskSource;
use task_source::file_reading::{FileReadingTaskSource, FileReadingRunnable, FileReadingTask};
use util::thread::spawn_named;
diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs
index 2c8f99b424b..a971bb48f21 100644
--- a/components/script/dom/formdata.rs
+++ b/components/script/dom/formdata.rs
@@ -15,24 +15,24 @@ use dom::blob::{Blob, BlobImpl};
use dom::file::File;
use dom::globalscope::GlobalScope;
use dom::htmlformelement::{HTMLFormElement, FormDatumValue, FormDatum};
+use html5ever_atoms::LocalName;
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::iter;
-use string_cache::Atom;
#[dom_struct]
pub struct FormData {
reflector_: Reflector,
- data: DOMRefCell<HashMap<Atom, Vec<FormDatum>>>,
+ data: DOMRefCell<HashMap<LocalName, Vec<FormDatum>>>,
}
impl FormData {
fn new_inherited(opt_form: Option<&HTMLFormElement>) -> FormData {
- let mut hashmap: HashMap<Atom, Vec<FormDatum>> = HashMap::new();
+ let mut hashmap: HashMap<LocalName, Vec<FormDatum>> = HashMap::new();
if let Some(form) = opt_form {
for datum in form.get_form_dataset(None) {
- match hashmap.entry(Atom::from(datum.name.as_ref())) {
+ match hashmap.entry(LocalName::from(datum.name.as_ref())) {
Occupied(entry) => entry.into_mut().push(datum),
Vacant(entry) => { entry.insert(vec!(datum)); }
}
@@ -66,7 +66,7 @@ impl FormDataMethods for FormData {
};
let mut data = self.data.borrow_mut();
- match data.entry(Atom::from(name.0)) {
+ match data.entry(LocalName::from(name.0)) {
Occupied(entry) => entry.into_mut().push(datum),
Vacant(entry) => { entry.insert(vec!(datum)); }
}
@@ -83,7 +83,7 @@ impl FormDataMethods for FormData {
let mut data = self.data.borrow_mut();
- match data.entry(Atom::from(name.0)) {
+ match data.entry(LocalName::from(name.0)) {
Occupied(entry) => entry.into_mut().push(datum),
Vacant(entry) => { entry.insert(vec!(datum)); },
}
@@ -91,13 +91,13 @@ impl FormDataMethods for FormData {
// https://xhr.spec.whatwg.org/#dom-formdata-delete
fn Delete(&self, name: USVString) {
- self.data.borrow_mut().remove(&Atom::from(name.0));
+ self.data.borrow_mut().remove(&LocalName::from(name.0));
}
// https://xhr.spec.whatwg.org/#dom-formdata-get
fn Get(&self, name: USVString) -> Option<FileOrUSVString> {
self.data.borrow()
- .get(&Atom::from(name.0))
+ .get(&LocalName::from(name.0))
.map(|entry| match entry[0].value {
FormDatumValue::String(ref s) => FileOrUSVString::USVString(USVString(s.to_string())),
FormDatumValue::File(ref b) => FileOrUSVString::File(Root::from_ref(&*b)),
@@ -107,7 +107,7 @@ impl FormDataMethods for FormData {
// https://xhr.spec.whatwg.org/#dom-formdata-getall
fn GetAll(&self, name: USVString) -> Vec<FileOrUSVString> {
self.data.borrow()
- .get(&Atom::from(name.0))
+ .get(&LocalName::from(name.0))
.map_or(vec![], |data|
data.iter().map(|item| match item.value {
FormDatumValue::String(ref s) => FileOrUSVString::USVString(USVString(s.to_string())),
@@ -118,12 +118,12 @@ impl FormDataMethods for FormData {
// https://xhr.spec.whatwg.org/#dom-formdata-has
fn Has(&self, name: USVString) -> bool {
- self.data.borrow().contains_key(&Atom::from(name.0))
+ self.data.borrow().contains_key(&LocalName::from(name.0))
}
// https://xhr.spec.whatwg.org/#dom-formdata-set
fn Set(&self, name: USVString, str_value: USVString) {
- self.data.borrow_mut().insert(Atom::from(name.0.clone()), vec![FormDatum {
+ self.data.borrow_mut().insert(LocalName::from(name.0.clone()), vec![FormDatum {
ty: DOMString::from("string"),
name: DOMString::from(name.0),
value: FormDatumValue::String(DOMString::from(str_value.0)),
@@ -133,7 +133,7 @@ impl FormDataMethods for FormData {
#[allow(unrooted_must_root)]
// https://xhr.spec.whatwg.org/#dom-formdata-set
fn Set_(&self, name: USVString, blob: &Blob, filename: Option<USVString>) {
- self.data.borrow_mut().insert(Atom::from(name.0.clone()), vec![FormDatum {
+ self.data.borrow_mut().insert(LocalName::from(name.0.clone()), vec![FormDatum {
ty: DOMString::from("file"),
name: DOMString::from(name.0),
value: FormDatumValue::File(Root::from_ref(&*self.get_file(blob, filename))),
diff --git a/components/script/dom/hashchangeevent.rs b/components/script/dom/hashchangeevent.rs
index 0fd753c433c..b93b7a93631 100644
--- a/components/script/dom/hashchangeevent.rs
+++ b/components/script/dom/hashchangeevent.rs
@@ -12,7 +12,7 @@ use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::str::{DOMString, USVString};
use dom::event::Event;
use dom::globalscope::GlobalScope;
-use string_cache::Atom;
+use servo_atoms::Atom;
// https://html.spec.whatwg.org/multipage/#hashchangeevent
#[dom_struct]
diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs
index 2ed6d4fe5e5..2cd5278c4bc 100644
--- a/components/script/dom/htmlanchorelement.rs
+++ b/components/script/dom/htmlanchorelement.rs
@@ -24,11 +24,11 @@ use dom::mouseevent::MouseEvent;
use dom::node::{Node, document_from_node, window_from_node};
use dom::urlhelper::UrlHelper;
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use msg::constellation_msg::ReferrerPolicy;
use num_traits::ToPrimitive;
use script_traits::MozBrowserEvent;
use std::default::Default;
-use string_cache::Atom;
use style::attr::AttrValue;
use url::Url;
use util::prefs::PREFS;
@@ -41,7 +41,7 @@ pub struct HTMLAnchorElement {
}
impl HTMLAnchorElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLAnchorElement {
HTMLAnchorElement {
@@ -53,7 +53,7 @@ impl HTMLAnchorElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLAnchorElement> {
Node::reflect_node(box HTMLAnchorElement::new_inherited(local_name, prefix, document),
@@ -63,7 +63,7 @@ impl HTMLAnchorElement {
// https://html.spec.whatwg.org/multipage/#concept-hyperlink-url-set
fn set_url(&self) {
- let attribute = self.upcast::<Element>().get_attribute(&ns!(), &atom!("href"));
+ let attribute = self.upcast::<Element>().get_attribute(&ns!(), &local_name!("href"));
*self.url.borrow_mut() = attribute.and_then(|attribute| {
let document = document_from_node(self);
document.base_url().join(&attribute.value()).ok()
@@ -84,7 +84,7 @@ impl HTMLAnchorElement {
// https://html.spec.whatwg.org/multipage/#update-href
fn update_href(&self, url: DOMString) {
- self.upcast::<Element>().set_string_attribute(&atom!("href"), url);
+ self.upcast::<Element>().set_string_attribute(&local_name!("href"), url);
}
}
@@ -93,9 +93,9 @@ impl VirtualMethods for HTMLAnchorElement {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("rel") => AttrValue::from_serialized_tokenlist(value.into()),
+ &local_name!("rel") => AttrValue::from_serialized_tokenlist(value.into()),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
@@ -115,7 +115,7 @@ impl HTMLAnchorElementMethods for HTMLAnchorElement {
// https://html.spec.whatwg.org/multipage/#dom-a-rellist
fn RelList(&self) -> Root<DOMTokenList> {
self.rel_list.or_init(|| {
- DOMTokenList::new(self.upcast(), &atom!("rel"))
+ DOMTokenList::new(self.upcast(), &local_name!("rel"))
})
}
@@ -265,7 +265,7 @@ impl HTMLAnchorElementMethods for HTMLAnchorElement {
USVString(match *self.url.borrow() {
None => {
- match self.upcast::<Element>().get_attribute(&ns!(), &atom!("href")) {
+ match self.upcast::<Element>().get_attribute(&ns!(), &local_name!("href")) {
// Step 3.
None => String::new(),
// Step 4.
@@ -279,7 +279,7 @@ impl HTMLAnchorElementMethods for HTMLAnchorElement {
// https://html.spec.whatwg.org/multipage/#dom-hyperlink-href
fn SetHref(&self, value: USVString) {
- self.upcast::<Element>().set_string_attribute(&atom!("href"),
+ self.upcast::<Element>().set_string_attribute(&local_name!("href"),
DOMString::from_string(value.0));
self.set_url();
}
@@ -499,7 +499,7 @@ impl Activatable for HTMLAnchorElement {
// hyperlink"
// https://html.spec.whatwg.org/multipage/#the-a-element
// "The activation behaviour of a elements *that create hyperlinks*"
- self.upcast::<Element>().has_attribute(&atom!("href"))
+ self.upcast::<Element>().has_attribute(&local_name!("href"))
}
@@ -525,7 +525,7 @@ impl Activatable for HTMLAnchorElement {
let mouse_event = event.downcast::<MouseEvent>().unwrap();
let mut ismap_suffix = None;
if let Some(element) = target.downcast::<Element>() {
- if target.is::<HTMLImageElement>() && element.has_attribute(&atom!("ismap")) {
+ if target.is::<HTMLImageElement>() && element.has_attribute(&local_name!("ismap")) {
let target_node = element.upcast::<Node>();
let rect = window_from_node(target_node).content_box_query(
target_node.to_trusted_node_address());
@@ -563,10 +563,10 @@ fn follow_hyperlink(subject: &Element, hyperlink_suffix: Option<String>, referre
// Step 1: replace.
// Step 2: source browsing context.
// Step 3: target browsing context.
- let target = subject.get_attribute(&ns!(), &atom!("target"));
+ let target = subject.get_attribute(&ns!(), &local_name!("target"));
// Step 4: disown target's opener if needed.
- let attribute = subject.get_attribute(&ns!(), &atom!("href")).unwrap();
+ let attribute = subject.get_attribute(&ns!(), &local_name!("href")).unwrap();
let mut href = attribute.Value();
// Step 7: append a hyperlink suffix.
diff --git a/components/script/dom/htmlappletelement.rs b/components/script/dom/htmlappletelement.rs
index dfc43386492..081172031a3 100644
--- a/components/script/dom/htmlappletelement.rs
+++ b/components/script/dom/htmlappletelement.rs
@@ -11,7 +11,7 @@ use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
use style::attr::AttrValue;
#[dom_struct]
@@ -20,7 +20,7 @@ pub struct HTMLAppletElement {
}
impl HTMLAppletElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLAppletElement {
HTMLAppletElement {
@@ -30,7 +30,7 @@ impl HTMLAppletElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLAppletElement> {
Node::reflect_node(box HTMLAppletElement::new_inherited(local_name, prefix, document),
@@ -52,9 +52,9 @@ impl VirtualMethods for HTMLAppletElement {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("name") => AttrValue::from_atomic(value.into()),
+ &local_name!("name") => AttrValue::from_atomic(value.into()),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
diff --git a/components/script/dom/htmlareaelement.rs b/components/script/dom/htmlareaelement.rs
index 6ba229640fd..b8df3806a3f 100644
--- a/components/script/dom/htmlareaelement.rs
+++ b/components/script/dom/htmlareaelement.rs
@@ -12,8 +12,8 @@ use dom::domtokenlist::DOMTokenList;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use std::default::Default;
-use string_cache::Atom;
use style::attr::AttrValue;
#[dom_struct]
@@ -23,7 +23,7 @@ pub struct HTMLAreaElement {
}
impl HTMLAreaElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLAreaElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLAreaElement {
HTMLAreaElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
rel_list: Default::default(),
@@ -31,7 +31,7 @@ impl HTMLAreaElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLAreaElement> {
Node::reflect_node(box HTMLAreaElement::new_inherited(local_name, prefix, document),
@@ -45,9 +45,9 @@ impl VirtualMethods for HTMLAreaElement {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("rel") => AttrValue::from_serialized_tokenlist(value.into()),
+ &local_name!("rel") => AttrValue::from_serialized_tokenlist(value.into()),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
@@ -57,7 +57,7 @@ impl HTMLAreaElementMethods for HTMLAreaElement {
// https://html.spec.whatwg.org/multipage/#dom-area-rellist
fn RelList(&self) -> Root<DOMTokenList> {
self.rel_list.or_init(|| {
- DOMTokenList::new(self.upcast(), &atom!("rel"))
+ DOMTokenList::new(self.upcast(), &local_name!("rel"))
})
}
}
diff --git a/components/script/dom/htmlaudioelement.rs b/components/script/dom/htmlaudioelement.rs
index 95342e2087d..66c5b2b2fca 100644
--- a/components/script/dom/htmlaudioelement.rs
+++ b/components/script/dom/htmlaudioelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlmediaelement::HTMLMediaElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLAudioElement {
@@ -16,7 +16,7 @@ pub struct HTMLAudioElement {
}
impl HTMLAudioElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLAudioElement {
HTMLAudioElement {
@@ -26,7 +26,7 @@ impl HTMLAudioElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLAudioElement> {
Node::reflect_node(box HTMLAudioElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlbaseelement.rs b/components/script/dom/htmlbaseelement.rs
index 1a70759de44..9fd34768b36 100644
--- a/components/script/dom/htmlbaseelement.rs
+++ b/components/script/dom/htmlbaseelement.rs
@@ -13,7 +13,7 @@ use dom::element::{AttributeMutation, Element};
use dom::htmlelement::HTMLElement;
use dom::node::{Node, UnbindContext, document_from_node};
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
use style::attr::AttrValue;
use url::Url;
@@ -23,14 +23,14 @@ pub struct HTMLBaseElement {
}
impl HTMLBaseElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLBaseElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLBaseElement {
HTMLBaseElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
}
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLBaseElement> {
Node::reflect_node(box HTMLBaseElement::new_inherited(local_name, prefix, document),
@@ -40,7 +40,7 @@ impl HTMLBaseElement {
/// https://html.spec.whatwg.org/multipage/#frozen-base-url
pub fn frozen_base_url(&self) -> Url {
- let href = self.upcast::<Element>().get_attribute(&ns!(), &atom!("href"))
+ let href = self.upcast::<Element>().get_attribute(&ns!(), &local_name!("href"))
.expect("The frozen base url is only defined for base elements \
that have a base url.");
let document = document_from_node(self);
@@ -56,7 +56,7 @@ impl HTMLBaseElement {
return;
}
- if self.upcast::<Element>().has_attribute(&atom!("href")) {
+ if self.upcast::<Element>().has_attribute(&local_name!("href")) {
let document = document_from_node(self);
document.refresh_base_element();
}
@@ -69,7 +69,7 @@ impl HTMLBaseElementMethods for HTMLBaseElement {
let document = document_from_node(self);
// Step 1.
- if !self.upcast::<Element>().has_attribute(&atom!("href")) {
+ if !self.upcast::<Element>().has_attribute(&local_name!("href")) {
return DOMString::from(document.base_url().as_str());
}
@@ -77,7 +77,7 @@ impl HTMLBaseElementMethods for HTMLBaseElement {
let fallback_base_url = document.fallback_base_url();
// Step 3.
- let url = self.upcast::<Element>().get_url_attribute(&atom!("href"));
+ let url = self.upcast::<Element>().get_url_attribute(&local_name!("href"));
// Step 4.
let url_record = fallback_base_url.join(&*url);
@@ -97,7 +97,7 @@ impl VirtualMethods for HTMLBaseElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
- if *attr.local_name() == atom!("href") {
+ if *attr.local_name() == local_name!("href") {
document_from_node(self).refresh_base_element();
}
}
diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs
index 1cab444e871..e89dc21f3da 100644
--- a/components/script/dom/htmlbodyelement.rs
+++ b/components/script/dom/htmlbodyelement.rs
@@ -17,8 +17,8 @@ use dom::globalscope::GlobalScope;
use dom::htmlelement::HTMLElement;
use dom::node::{Node, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use script_traits::ScriptMsg as ConstellationMsg;
-use string_cache::Atom;
use style::attr::AttrValue;
use time;
use url::Url;
@@ -33,7 +33,7 @@ pub struct HTMLBodyElement {
}
impl HTMLBodyElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document)
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document)
-> HTMLBodyElement {
HTMLBodyElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
@@ -41,7 +41,7 @@ impl HTMLBodyElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom, prefix: Option<DOMString>, document: &Document)
+ pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document)
-> Root<HTMLBodyElement> {
Node::reflect_node(box HTMLBodyElement::new_inherited(local_name, prefix, document),
document,
@@ -93,7 +93,7 @@ impl HTMLBodyElementLayoutHelpers for LayoutJS<HTMLBodyElement> {
fn get_background_color(&self) -> Option<RGBA> {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("bgcolor"))
+ .get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
.and_then(AttrValue::as_color)
.cloned()
}
@@ -103,7 +103,7 @@ impl HTMLBodyElementLayoutHelpers for LayoutJS<HTMLBodyElement> {
fn get_color(&self) -> Option<RGBA> {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("text"))
+ .get_attr_for_layout(&ns!(), &local_name!("text"))
.and_then(AttrValue::as_color)
.cloned()
}
@@ -113,7 +113,7 @@ impl HTMLBodyElementLayoutHelpers for LayoutJS<HTMLBodyElement> {
fn get_background(&self) -> Option<Url> {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("background"))
+ .get_attr_for_layout(&ns!(), &local_name!("background"))
.and_then(AttrValue::as_url)
.cloned()
}
@@ -141,11 +141,11 @@ impl VirtualMethods for HTMLBodyElement {
window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match *name {
- atom!("bgcolor") |
- atom!("text") => AttrValue::from_legacy_color(value.into()),
- atom!("background") => {
+ local_name!("bgcolor") |
+ local_name!("text") => AttrValue::from_legacy_color(value.into()),
+ local_name!("background") => {
AttrValue::from_url(document_from_node(self).url(), value.into())
},
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
@@ -159,11 +159,14 @@ impl VirtualMethods for HTMLBodyElement {
// https://html.spec.whatwg.org/multipage/
// #event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-3
match name {
- &atom!("onfocus") | &atom!("onload") | &atom!("onscroll") | &atom!("onafterprint") |
- &atom!("onbeforeprint") | &atom!("onbeforeunload") | &atom!("onhashchange") |
- &atom!("onlanguagechange") | &atom!("onmessage") | &atom!("onoffline") | &atom!("ononline") |
- &atom!("onpagehide") | &atom!("onpageshow") | &atom!("onpopstate") | &atom!("onstorage") |
- &atom!("onresize") | &atom!("onunload") | &atom!("onerror")
+ &local_name!("onfocus") | &local_name!("onload") | &local_name!("onscroll") |
+ &local_name!("onafterprint") | &local_name!("onbeforeprint") |
+ &local_name!("onbeforeunload") | &local_name!("onhashchange") |
+ &local_name!("onlanguagechange") | &local_name!("onmessage") |
+ &local_name!("onoffline") | &local_name!("ononline") |
+ &local_name!("onpagehide") | &local_name!("onpageshow") |
+ &local_name!("onpopstate") | &local_name!("onstorage") |
+ &local_name!("onresize") | &local_name!("onunload") | &local_name!("onerror")
=> {
let evtarget = window.upcast::<EventTarget>(); // forwarded event
let source_line = 1; //TODO(#9604) obtain current JS execution line
diff --git a/components/script/dom/htmlbrelement.rs b/components/script/dom/htmlbrelement.rs
index 09c92ccf45d..498013fc6c8 100644
--- a/components/script/dom/htmlbrelement.rs
+++ b/components/script/dom/htmlbrelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLBRElement {
@@ -16,14 +16,14 @@ pub struct HTMLBRElement {
}
impl HTMLBRElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLBRElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLBRElement {
HTMLBRElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
}
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLBRElement> {
Node::reflect_node(box HTMLBRElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs
index 95b85d0da8d..b309da6466a 100644
--- a/components/script/dom/htmlbuttonelement.rs
+++ b/components/script/dom/htmlbuttonelement.rs
@@ -23,8 +23,8 @@ use dom::nodelist::NodeList;
use dom::validation::Validatable;
use dom::validitystate::ValidityState;
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use std::cell::Cell;
-use string_cache::Atom;
use style::element_state::*;
#[derive(JSTraceable, PartialEq, Copy, Clone)]
@@ -43,7 +43,7 @@ pub struct HTMLButtonElement {
}
impl HTMLButtonElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLButtonElement {
HTMLButtonElement {
@@ -55,7 +55,7 @@ impl HTMLButtonElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLButtonElement> {
Node::reflect_node(box HTMLButtonElement::new_inherited(local_name, prefix, document),
@@ -180,7 +180,7 @@ impl VirtualMethods for HTMLButtonElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!("disabled") => {
+ &local_name!("disabled") => {
let el = self.upcast::<Element>();
match mutation {
AttributeMutation::Set(Some(_)) => {}
@@ -195,7 +195,7 @@ impl VirtualMethods for HTMLButtonElement {
}
}
},
- &atom!("type") => {
+ &local_name!("type") => {
match mutation {
AttributeMutation::Set(_) => {
let value = match &**attr.value() {
diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs
index c63ab1a9531..60f6482a49f 100644
--- a/components/script/dom/htmlcanvaselement.rs
+++ b/components/script/dom/htmlcanvaselement.rs
@@ -25,6 +25,7 @@ use dom::node::{Node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use dom::webglrenderingcontext::{LayoutCanvasWebGLRenderingContextHelpers, WebGLRenderingContext};
use euclid::size::Size2D;
+use html5ever_atoms::LocalName;
use image::ColorType;
use image::png::PNGEncoder;
use ipc_channel::ipc::{self, IpcSender};
@@ -34,7 +35,6 @@ use offscreen_gl_context::GLContextAttributes;
use rustc_serialize::base64::{STANDARD, ToBase64};
use script_layout_interface::HTMLCanvasData;
use std::iter::repeat;
-use string_cache::Atom;
use style::attr::AttrValue;
const DEFAULT_WIDTH: u32 = 300;
@@ -56,7 +56,7 @@ pub struct HTMLCanvasElement {
}
impl HTMLCanvasElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLCanvasElement {
HTMLCanvasElement {
@@ -66,7 +66,7 @@ impl HTMLCanvasElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLCanvasElement> {
Node::reflect_node(box HTMLCanvasElement::new_inherited(local_name, prefix, document),
@@ -116,8 +116,8 @@ impl LayoutHTMLCanvasElementHelpers for LayoutJS<HTMLCanvasElement> {
}
});
- let width_attr = canvas.upcast::<Element>().get_attr_for_layout(&ns!(), &atom!("width"));
- let height_attr = canvas.upcast::<Element>().get_attr_for_layout(&ns!(), &atom!("height"));
+ let width_attr = canvas.upcast::<Element>().get_attr_for_layout(&ns!(), &local_name!("width"));
+ let height_attr = canvas.upcast::<Element>().get_attr_for_layout(&ns!(), &local_name!("height"));
HTMLCanvasData {
ipc_renderer: ipc_renderer,
width: width_attr.map_or(DEFAULT_WIDTH, |val| val.as_uint()),
@@ -307,15 +307,15 @@ impl VirtualMethods for HTMLCanvasElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!("width") | &atom!("height") => self.recreate_contexts(),
+ &local_name!("width") | &local_name!("height") => self.recreate_contexts(),
_ => (),
};
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("width") => AttrValue::from_u32(value.into(), DEFAULT_WIDTH),
- &atom!("height") => AttrValue::from_u32(value.into(), DEFAULT_HEIGHT),
+ &local_name!("width") => AttrValue::from_u32(value.into(), DEFAULT_WIDTH),
+ &local_name!("height") => AttrValue::from_u32(value.into(), DEFAULT_HEIGHT),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs
index 230102bd423..3507ec03fe2 100644
--- a/components/script/dom/htmlcollection.rs
+++ b/components/script/dom/htmlcollection.rs
@@ -13,9 +13,10 @@ use dom::bindings::xmlname::namespace_from_domstring;
use dom::element::Element;
use dom::node::Node;
use dom::window::Window;
+use html5ever_atoms::{LocalName, QualName};
+use servo_atoms::Atom;
use std::ascii::AsciiExt;
use std::cell::Cell;
-use string_cache::{Atom, Namespace, QualName};
use style::str::split_html_space_chars;
pub trait CollectionFilter : JSTraceable {
@@ -115,22 +116,22 @@ impl HTMLCollection {
pub fn by_tag_name(window: &Window, root: &Node, mut tag: DOMString)
-> Root<HTMLCollection> {
- let tag_atom = Atom::from(&*tag);
+ let tag_atom = LocalName::from(&*tag);
tag.make_ascii_lowercase();
- let ascii_lower_tag = Atom::from(tag); // FIXME(ajeffrey): don't clone atom if it was already lowercased.
+ let ascii_lower_tag = LocalName::from(tag); // FIXME(ajeffrey): don't clone atom if it was already lowercased.
HTMLCollection::by_atomic_tag_name(window, root, tag_atom, ascii_lower_tag)
}
- pub fn by_atomic_tag_name(window: &Window, root: &Node, tag_atom: Atom, ascii_lower_tag: Atom)
+ pub fn by_atomic_tag_name(window: &Window, root: &Node, tag_atom: LocalName, ascii_lower_tag: LocalName)
-> Root<HTMLCollection> {
#[derive(JSTraceable, HeapSizeOf)]
struct TagNameFilter {
- tag: Atom,
- ascii_lower_tag: Atom,
+ tag: LocalName,
+ ascii_lower_tag: LocalName,
}
impl CollectionFilter for TagNameFilter {
fn filter(&self, elem: &Element, _root: &Node) -> bool {
- if self.tag == atom!("*") {
+ if self.tag == local_name!("*") {
true
} else if elem.html_element_in_html_document() {
*elem.local_name() == self.ascii_lower_tag
@@ -148,7 +149,7 @@ impl HTMLCollection {
pub fn by_tag_name_ns(window: &Window, root: &Node, tag: DOMString,
maybe_ns: Option<DOMString>) -> Root<HTMLCollection> {
- let local = Atom::from(tag);
+ let local = LocalName::from(tag);
let ns = namespace_from_domstring(maybe_ns);
let qname = QualName::new(ns, local);
HTMLCollection::by_qual_tag_name(window, root, qname)
@@ -161,8 +162,8 @@ impl HTMLCollection {
}
impl CollectionFilter for TagNameNSFilter {
fn filter(&self, elem: &Element, _root: &Node) -> bool {
- ((self.qname.ns == Namespace(atom!("*"))) || (self.qname.ns == *elem.namespace())) &&
- ((self.qname.local == atom!("*")) || (self.qname.local == *elem.local_name()))
+ ((self.qname.ns == namespace_url!("*")) || (self.qname.ns == *elem.namespace())) &&
+ ((self.qname.local == local_name!("*")) || (self.qname.local == *elem.local_name()))
}
}
let filter = TagNameNSFilter {
@@ -313,8 +314,8 @@ impl HTMLCollectionMethods for HTMLCollection {
// Step 2.
self.elements_iter().find(|elem| {
- elem.get_string_attribute(&atom!("id")) == key ||
- (elem.namespace() == &ns!(html) && elem.get_string_attribute(&atom!("name")) == key)
+ elem.get_string_attribute(&local_name!("id")) == key ||
+ (elem.namespace() == &ns!(html) && elem.get_string_attribute(&local_name!("name")) == key)
})
}
@@ -336,12 +337,12 @@ impl HTMLCollectionMethods for HTMLCollection {
// Step 2
for elem in self.elements_iter() {
// Step 2.1
- let id_attr = elem.get_string_attribute(&atom!("id"));
+ let id_attr = elem.get_string_attribute(&local_name!("id"));
if !id_attr.is_empty() && !result.contains(&id_attr) {
result.push(id_attr)
}
// Step 2.2
- let name_attr = elem.get_string_attribute(&atom!("name"));
+ let name_attr = elem.get_string_attribute(&local_name!("name"));
if !name_attr.is_empty() && !result.contains(&name_attr) && *elem.namespace() == ns!(html) {
result.push(name_attr)
}
diff --git a/components/script/dom/htmldataelement.rs b/components/script/dom/htmldataelement.rs
index 2ef14159f10..dcd15f9261a 100644
--- a/components/script/dom/htmldataelement.rs
+++ b/components/script/dom/htmldataelement.rs
@@ -9,7 +9,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLDataElement {
@@ -17,7 +17,7 @@ pub struct HTMLDataElement {
}
impl HTMLDataElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLDataElement {
HTMLDataElement {
@@ -26,7 +26,7 @@ impl HTMLDataElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLDataElement> {
Node::reflect_node(box HTMLDataElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmldatalistelement.rs b/components/script/dom/htmldatalistelement.rs
index c0f3683cb97..616bcd80792 100644
--- a/components/script/dom/htmldatalistelement.rs
+++ b/components/script/dom/htmldatalistelement.rs
@@ -13,7 +13,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 html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLDataListElement {
@@ -21,7 +21,7 @@ pub struct HTMLDataListElement {
}
impl HTMLDataListElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLDataListElement {
HTMLDataListElement {
@@ -31,7 +31,7 @@ impl HTMLDataListElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLDataListElement> {
Node::reflect_node(box HTMLDataListElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmldetailselement.rs b/components/script/dom/htmldetailselement.rs
index 9a7cf6e13f8..93dfef33c7c 100644
--- a/components/script/dom/htmldetailselement.rs
+++ b/components/script/dom/htmldetailselement.rs
@@ -15,9 +15,9 @@ use dom::eventtarget::EventTarget;
use dom::htmlelement::HTMLElement;
use dom::node::{Node, window_from_node};
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use script_thread::Runnable;
use std::cell::Cell;
-use string_cache::Atom;
use task_source::TaskSource;
#[dom_struct]
@@ -27,7 +27,7 @@ pub struct HTMLDetailsElement {
}
impl HTMLDetailsElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLDetailsElement {
HTMLDetailsElement {
@@ -38,7 +38,7 @@ impl HTMLDetailsElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLDetailsElement> {
Node::reflect_node(box HTMLDetailsElement::new_inherited(local_name, prefix, document),
@@ -67,7 +67,7 @@ impl VirtualMethods for HTMLDetailsElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
- if attr.local_name() == &atom!("open") {
+ if attr.local_name() == &local_name!("open") {
let counter = self.toggle_counter.get() + 1;
self.toggle_counter.set(counter);
diff --git a/components/script/dom/htmldialogelement.rs b/components/script/dom/htmldialogelement.rs
index 8d20bb75392..80ee9499a9f 100644
--- a/components/script/dom/htmldialogelement.rs
+++ b/components/script/dom/htmldialogelement.rs
@@ -13,7 +13,7 @@ use dom::element::Element;
use dom::eventtarget::EventTarget;
use dom::htmlelement::HTMLElement;
use dom::node::{Node, window_from_node};
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLDialogElement {
@@ -22,7 +22,7 @@ pub struct HTMLDialogElement {
}
impl HTMLDialogElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLDialogElement {
HTMLDialogElement {
@@ -33,7 +33,7 @@ impl HTMLDialogElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLDialogElement> {
Node::reflect_node(box HTMLDialogElement::new_inherited(local_name, prefix, document),
@@ -67,7 +67,7 @@ impl HTMLDialogElementMethods for HTMLDialogElement {
let win = window_from_node(self);
// Step 1 & 2
- if element.remove_attribute(&ns!(), &atom!("open")).is_none() {
+ if element.remove_attribute(&ns!(), &local_name!("open")).is_none() {
return;
}
diff --git a/components/script/dom/htmldirectoryelement.rs b/components/script/dom/htmldirectoryelement.rs
index 63677ce4140..bd40c508ffe 100644
--- a/components/script/dom/htmldirectoryelement.rs
+++ b/components/script/dom/htmldirectoryelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLDirectoryElement {
@@ -16,7 +16,7 @@ pub struct HTMLDirectoryElement {
}
impl HTMLDirectoryElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLDirectoryElement {
HTMLDirectoryElement {
@@ -26,7 +26,7 @@ impl HTMLDirectoryElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLDirectoryElement> {
Node::reflect_node(box HTMLDirectoryElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmldivelement.rs b/components/script/dom/htmldivelement.rs
index 943dd8302ee..ba738ca75e2 100644
--- a/components/script/dom/htmldivelement.rs
+++ b/components/script/dom/htmldivelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLDivElement {
@@ -16,7 +16,7 @@ pub struct HTMLDivElement {
}
impl HTMLDivElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLDivElement {
HTMLDivElement {
@@ -25,7 +25,7 @@ impl HTMLDivElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLDivElement> {
Node::reflect_node(box HTMLDivElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmldlistelement.rs b/components/script/dom/htmldlistelement.rs
index 589eb7bc890..db319c37458 100644
--- a/components/script/dom/htmldlistelement.rs
+++ b/components/script/dom/htmldlistelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLDListElement {
@@ -16,7 +16,7 @@ pub struct HTMLDListElement {
}
impl HTMLDListElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLDListElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLDListElement {
HTMLDListElement {
htmlelement:
HTMLElement::new_inherited(local_name, prefix, document)
@@ -24,7 +24,7 @@ impl HTMLDListElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLDListElement> {
Node::reflect_node(box HTMLDListElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index 502242535c5..d4490357650 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -29,11 +29,11 @@ use dom::node::{Node, SEQUENTIALLY_FOCUSABLE};
use dom::node::{document_from_node, window_from_node};
use dom::nodelist::NodeList;
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::default::Default;
use std::rc::Rc;
-use string_cache::Atom;
use style::attr::AttrValue;
use style::element_state::*;
@@ -45,12 +45,12 @@ pub struct HTMLElement {
}
impl HTMLElement {
- pub fn new_inherited(tag_name: Atom, prefix: Option<DOMString>,
+ pub fn new_inherited(tag_name: LocalName, prefix: Option<DOMString>,
document: &Document) -> HTMLElement {
HTMLElement::new_inherited_with_state(ElementState::empty(), tag_name, prefix, document)
}
- pub fn new_inherited_with_state(state: ElementState, tag_name: Atom,
+ pub fn new_inherited_with_state(state: ElementState, tag_name: LocalName,
prefix: Option<DOMString>, document: &Document)
-> HTMLElement {
HTMLElement {
@@ -62,7 +62,7 @@ impl HTMLElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> Root<HTMLElement> {
+ pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> Root<HTMLElement> {
Node::reflect_node(box HTMLElement::new_inherited(local_name, prefix, document),
document,
HTMLElementBinding::Wrap)
@@ -76,7 +76,7 @@ impl HTMLElement {
fn update_sequentially_focusable_status(&self) {
let element = self.upcast::<Element>();
let node = self.upcast::<Node>();
- if element.has_attribute(&atom!("tabindex")) {
+ if element.has_attribute(&local_name!("tabindex")) {
node.set_flag(SEQUENTIALLY_FOCUSABLE, true);
} else {
match node.type_id() {
@@ -87,12 +87,12 @@ impl HTMLElement {
=> node.set_flag(SEQUENTIALLY_FOCUSABLE, true),
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) => {
- if element.has_attribute(&atom!("href")) {
+ if element.has_attribute(&local_name!("href")) {
node.set_flag(SEQUENTIALLY_FOCUSABLE, true);
}
},
_ => {
- if let Some(attr) = element.get_attribute(&ns!(), &atom!("draggable")) {
+ if let Some(attr) = element.get_attribute(&ns!(), &local_name!("draggable")) {
let value = attr.value();
let is_true = match *value {
AttrValue::String(ref string) => string == "true",
@@ -393,16 +393,16 @@ impl HTMLElement {
}
pub fn get_custom_attr(&self, local_name: DOMString) -> Option<DOMString> {
- // FIXME(ajeffrey): Convert directly from DOMString to Atom
- let local_name = Atom::from(to_snake_case(local_name));
+ // FIXME(ajeffrey): Convert directly from DOMString to LocalName
+ let local_name = LocalName::from(to_snake_case(local_name));
self.upcast::<Element>().get_attribute(&ns!(), &local_name).map(|attr| {
DOMString::from(&**attr.value()) // FIXME(ajeffrey): Convert directly from AttrValue to DOMString
})
}
pub fn delete_custom_attr(&self, local_name: DOMString) {
- // FIXME(ajeffrey): Convert directly from DOMString to Atom
- let local_name = Atom::from(to_snake_case(local_name));
+ // FIXME(ajeffrey): Convert directly from DOMString to LocalName
+ let local_name = LocalName::from(to_snake_case(local_name));
self.upcast::<Element>().remove_attribute(&ns!(), &local_name);
}
@@ -430,7 +430,7 @@ impl HTMLElement {
pub fn is_listed_element(&self) -> bool {
// Servo does not implement HTMLKeygenElement
// https://github.com/servo/servo/issues/2782
- if self.upcast::<Element>().local_name() == &atom!("keygen") {
+ if self.upcast::<Element>().local_name() == &local_name!("keygen") {
return true;
}
@@ -475,7 +475,7 @@ impl HTMLElement {
// will be a label for this HTMLElement
.take_while(|elem| !elem.is_labelable_element())
.filter_map(Root::downcast::<HTMLLabelElement>)
- .filter(|elem| !elem.upcast::<Element>().has_attribute(&atom!("for")))
+ .filter(|elem| !elem.upcast::<Element>().has_attribute(&local_name!("for")))
.filter(|elem| elem.first_labelable_descendant().r() == Some(self))
.map(Root::upcast::<Node>);
@@ -491,7 +491,7 @@ impl HTMLElement {
let children = root_node.traverse_preorder()
.filter_map(Root::downcast::<Element>)
.filter(|elem| elem.is::<HTMLLabelElement>())
- .filter(|elem| elem.get_string_attribute(&atom!("for")) == id)
+ .filter(|elem| elem.get_string_attribute(&local_name!("for")) == id)
.map(Root::upcast::<Node>);
NodeList::new_simple_list(&window, children.chain(ancestors))
diff --git a/components/script/dom/htmlembedelement.rs b/components/script/dom/htmlembedelement.rs
index c527ee2cce7..0c4610f0948 100644
--- a/components/script/dom/htmlembedelement.rs
+++ b/components/script/dom/htmlembedelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLEmbedElement {
@@ -16,14 +16,14 @@ pub struct HTMLEmbedElement {
}
impl HTMLEmbedElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLEmbedElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLEmbedElement {
HTMLEmbedElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
}
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLEmbedElement> {
Node::reflect_node(box HTMLEmbedElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlfieldsetelement.rs b/components/script/dom/htmlfieldsetelement.rs
index 8ad987f0f16..4168659b741 100644
--- a/components/script/dom/htmlfieldsetelement.rs
+++ b/components/script/dom/htmlfieldsetelement.rs
@@ -17,7 +17,7 @@ use dom::htmllegendelement::HTMLLegendElement;
use dom::node::{Node, window_from_node};
use dom::validitystate::ValidityState;
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
use style::element_state::*;
#[dom_struct]
@@ -26,7 +26,7 @@ pub struct HTMLFieldSetElement {
}
impl HTMLFieldSetElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLFieldSetElement {
HTMLFieldSetElement {
@@ -37,7 +37,7 @@ impl HTMLFieldSetElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLFieldSetElement> {
Node::reflect_node(box HTMLFieldSetElement::new_inherited(local_name, prefix, document),
@@ -88,7 +88,7 @@ impl VirtualMethods for HTMLFieldSetElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!("disabled") => {
+ &local_name!("disabled") => {
let disabled_state = match mutation {
AttributeMutation::Set(None) => true,
AttributeMutation::Set(Some(_)) => {
diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs
index ee7c67e45e5..0eca01a47f9 100644
--- a/components/script/dom/htmlfontelement.rs
+++ b/components/script/dom/htmlfontelement.rs
@@ -13,7 +13,8 @@ use dom::element::{Element, RawLayoutElementHelpers};
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
+use servo_atoms::Atom;
use style::attr::AttrValue;
use style::str::{HTML_SPACE_CHARACTERS, read_numbers};
use style::values::specified;
@@ -25,14 +26,14 @@ pub struct HTMLFontElement {
impl HTMLFontElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLFontElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLFontElement {
HTMLFontElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
}
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLFontElement> {
Node::reflect_node(box HTMLFontElement::new_inherited(local_name, prefix, document),
@@ -61,7 +62,7 @@ impl HTMLFontElementMethods for HTMLFontElement {
fn SetSize(&self, value: DOMString) {
let element = self.upcast::<Element>();
let length = parse_length(&value);
- element.set_attribute(&atom!("size"), AttrValue::Length(value.into(), length));
+ element.set_attribute(&local_name!("size"), AttrValue::Length(value.into(), length));
}
}
@@ -70,11 +71,11 @@ impl VirtualMethods for HTMLFontElement {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("face") => AttrValue::from_atomic(value.into()),
- &atom!("color") => AttrValue::from_legacy_color(value.into()),
- &atom!("size") => {
+ &local_name!("face") => AttrValue::from_atomic(value.into()),
+ &local_name!("color") => AttrValue::from_legacy_color(value.into()),
+ &local_name!("size") => {
let length = parse_length(&value);
AttrValue::Length(value.into(), length)
},
@@ -94,7 +95,7 @@ impl HTMLFontElementLayoutHelpers for LayoutJS<HTMLFontElement> {
fn get_color(&self) -> Option<RGBA> {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("color"))
+ .get_attr_for_layout(&ns!(), &local_name!("color"))
.and_then(AttrValue::as_color)
.cloned()
}
@@ -104,7 +105,7 @@ impl HTMLFontElementLayoutHelpers for LayoutJS<HTMLFontElement> {
fn get_face(&self) -> Option<Atom> {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("face"))
+ .get_attr_for_layout(&ns!(), &local_name!("face"))
.map(AttrValue::as_atom)
.cloned()
}
@@ -114,7 +115,7 @@ impl HTMLFontElementLayoutHelpers for LayoutJS<HTMLFontElement> {
fn get_size(&self) -> Option<specified::Length> {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("size"))
+ .get_attr_for_layout(&ns!(), &local_name!("size"))
.and_then(AttrValue::as_length)
.cloned()
}
diff --git a/components/script/dom/htmlformcontrolscollection.rs b/components/script/dom/htmlformcontrolscollection.rs
index 3986692099c..6fc52e099e7 100644
--- a/components/script/dom/htmlformcontrolscollection.rs
+++ b/components/script/dom/htmlformcontrolscollection.rs
@@ -50,8 +50,8 @@ impl HTMLFormControlsCollectionMethods for HTMLFormControlsCollection {
if name.is_empty() { return None; }
let mut filter_map = self.collection.elements_iter().filter_map(|elem| {
- if elem.get_string_attribute(&atom!("name")) == name
- || elem.get_string_attribute(&atom!("id")) == name {
+ if elem.get_string_attribute(&local_name!("name")) == name
+ || elem.get_string_attribute(&local_name!("id")) == name {
Some(elem)
} else { None }
});
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs
index 78167022773..fec0ec07946 100644
--- a/components/script/dom/htmlformelement.rs
+++ b/components/script/dom/htmlformelement.rs
@@ -40,6 +40,7 @@ use dom::virtualmethods::VirtualMethods;
use encoding::EncodingRef;
use encoding::all::UTF_8;
use encoding::label::encoding_from_whatwg_label;
+use html5ever_atoms::LocalName;
use hyper::header::{Charset, ContentDisposition, ContentType, DispositionParam, DispositionType};
use hyper::method::Method;
use msg::constellation_msg::PipelineId;
@@ -49,7 +50,6 @@ use script_traits::LoadData;
use std::borrow::ToOwned;
use std::cell::Cell;
use std::sync::mpsc::Sender;
-use string_cache::Atom;
use style::attr::AttrValue;
use style::str::split_html_space_chars;
use task_source::TaskSource;
@@ -66,7 +66,7 @@ pub struct HTMLFormElement {
}
impl HTMLFormElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLFormElement {
HTMLFormElement {
@@ -78,7 +78,7 @@ impl HTMLFormElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLFormElement> {
Node::reflect_node(box HTMLFormElement::new_inherited(local_name, prefix, document),
@@ -205,7 +205,7 @@ impl HTMLFormElementMethods for HTMLFormElement {
}
_ => {
debug_assert!(!elem.downcast::<HTMLElement>().unwrap().is_listed_element() ||
- elem.local_name() == &atom!("keygen"));
+ elem.local_name() == &local_name!("keygen"));
return false;
}
}
@@ -255,9 +255,9 @@ impl HTMLFormElement {
// https://html.spec.whatwg.org/multipage/#picking-an-encoding-for-the-form
fn pick_encoding(&self) -> EncodingRef {
// Step 2
- if self.upcast::<Element>().has_attribute(&atom!("accept-charset")) {
+ if self.upcast::<Element>().has_attribute(&local_name!("accept-charset")) {
// Substep 1
- let input = self.upcast::<Element>().get_string_attribute(&atom!("accept-charset"));
+ let input = self.upcast::<Element>().get_string_attribute(&local_name!("accept-charset"));
// Substep 2, 3, 4
let mut candidate_encodings = split_html_space_chars(&*input).filter_map(encoding_from_whatwg_label);
@@ -728,12 +728,12 @@ impl<'a> FormSubmitter<'a> {
match *self {
FormSubmitter::FormElement(form) => form.Action(),
FormSubmitter::InputElement(input_element) => {
- input_element.get_form_attribute(&atom!("formaction"),
+ input_element.get_form_attribute(&local_name!("formaction"),
|i| i.FormAction(),
|f| f.Action())
},
FormSubmitter::ButtonElement(button_element) => {
- button_element.get_form_attribute(&atom!("formaction"),
+ button_element.get_form_attribute(&local_name!("formaction"),
|i| i.FormAction(),
|f| f.Action())
}
@@ -744,12 +744,12 @@ impl<'a> FormSubmitter<'a> {
let attr = match *self {
FormSubmitter::FormElement(form) => form.Enctype(),
FormSubmitter::InputElement(input_element) => {
- input_element.get_form_attribute(&atom!("formenctype"),
+ input_element.get_form_attribute(&local_name!("formenctype"),
|i| i.FormEnctype(),
|f| f.Enctype())
},
FormSubmitter::ButtonElement(button_element) => {
- button_element.get_form_attribute(&atom!("formenctype"),
+ button_element.get_form_attribute(&local_name!("formenctype"),
|i| i.FormEnctype(),
|f| f.Enctype())
}
@@ -767,12 +767,12 @@ impl<'a> FormSubmitter<'a> {
let attr = match *self {
FormSubmitter::FormElement(form) => form.Method(),
FormSubmitter::InputElement(input_element) => {
- input_element.get_form_attribute(&atom!("formmethod"),
+ input_element.get_form_attribute(&local_name!("formmethod"),
|i| i.FormMethod(),
|f| f.Method())
},
FormSubmitter::ButtonElement(button_element) => {
- button_element.get_form_attribute(&atom!("formmethod"),
+ button_element.get_form_attribute(&local_name!("formmethod"),
|i| i.FormMethod(),
|f| f.Method())
}
@@ -788,12 +788,12 @@ impl<'a> FormSubmitter<'a> {
match *self {
FormSubmitter::FormElement(form) => form.Target(),
FormSubmitter::InputElement(input_element) => {
- input_element.get_form_attribute(&atom!("formtarget"),
+ input_element.get_form_attribute(&local_name!("formtarget"),
|i| i.FormTarget(),
|f| f.Target())
},
FormSubmitter::ButtonElement(button_element) => {
- button_element.get_form_attribute(&atom!("formtarget"),
+ button_element.get_form_attribute(&local_name!("formtarget"),
|i| i.FormTarget(),
|f| f.Target())
}
@@ -804,12 +804,12 @@ impl<'a> FormSubmitter<'a> {
match *self {
FormSubmitter::FormElement(form) => form.NoValidate(),
FormSubmitter::InputElement(input_element) => {
- input_element.get_form_boolean_attribute(&atom!("formnovalidate"),
+ input_element.get_form_boolean_attribute(&local_name!("formnovalidate"),
|i| i.FormNoValidate(),
|f| f.NoValidate())
}
FormSubmitter::ButtonElement(button_element) => {
- button_element.get_form_boolean_attribute(&atom!("formnovalidate"),
+ button_element.get_form_boolean_attribute(&local_name!("formnovalidate"),
|i| i.FormNoValidate(),
|f| f.NoValidate())
}
@@ -823,7 +823,7 @@ pub trait FormControl: DerivedFrom<Element> + Reflectable {
fn form_owner(&self) -> Option<Root<HTMLFormElement>> {
// https://html.spec.whatwg.org/multipage/#reset-the-form-owner
let elem = self.to_element();
- let owner = elem.get_string_attribute(&atom!("form"));
+ let owner = elem.get_string_attribute(&local_name!("form"));
if !owner.is_empty() {
let doc = document_from_node(elem);
let owner = doc.GetElementById(owner);
@@ -838,7 +838,7 @@ pub trait FormControl: DerivedFrom<Element> + Reflectable {
}
fn get_form_attribute<InputFn, OwnerFn>(&self,
- attr: &Atom,
+ attr: &LocalName,
input: InputFn,
owner: OwnerFn)
-> DOMString
@@ -853,7 +853,7 @@ pub trait FormControl: DerivedFrom<Element> + Reflectable {
}
fn get_form_boolean_attribute<InputFn, OwnerFn>(&self,
- attr: &Atom,
+ attr: &LocalName,
input: InputFn,
owner: OwnerFn)
-> bool
@@ -881,9 +881,9 @@ impl VirtualMethods for HTMLFormElement {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("name") => AttrValue::from_atomic(value.into()),
+ &local_name!("name") => AttrValue::from_atomic(value.into()),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
diff --git a/components/script/dom/htmlframeelement.rs b/components/script/dom/htmlframeelement.rs
index b8ba42bec63..919c460dee5 100644
--- a/components/script/dom/htmlframeelement.rs
+++ b/components/script/dom/htmlframeelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLFrameElement {
@@ -16,14 +16,14 @@ pub struct HTMLFrameElement {
}
impl HTMLFrameElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLFrameElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLFrameElement {
HTMLFrameElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
}
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLFrameElement> {
Node::reflect_node(box HTMLFrameElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlframesetelement.rs b/components/script/dom/htmlframesetelement.rs
index bac782288b3..b238692dc11 100644
--- a/components/script/dom/htmlframesetelement.rs
+++ b/components/script/dom/htmlframesetelement.rs
@@ -11,7 +11,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::{Node, window_from_node};
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLFrameSetElement {
@@ -19,7 +19,7 @@ pub struct HTMLFrameSetElement {
}
impl HTMLFrameSetElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLFrameSetElement {
HTMLFrameSetElement {
@@ -29,7 +29,7 @@ impl HTMLFrameSetElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLFrameSetElement> {
Node::reflect_node(box HTMLFrameSetElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlheadelement.rs b/components/script/dom/htmlheadelement.rs
index 26d966a05d1..419644c5bb3 100644
--- a/components/script/dom/htmlheadelement.rs
+++ b/components/script/dom/htmlheadelement.rs
@@ -14,7 +14,7 @@ use dom::htmlmetaelement::HTMLMetaElement;
use dom::node::{Node, document_from_node};
use dom::userscripts::load_script;
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLHeadElement {
@@ -22,7 +22,7 @@ pub struct HTMLHeadElement {
}
impl HTMLHeadElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLHeadElement {
HTMLHeadElement {
@@ -31,7 +31,7 @@ impl HTMLHeadElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLHeadElement> {
Node::reflect_node(box HTMLHeadElement::new_inherited(local_name, prefix, document),
@@ -51,11 +51,11 @@ impl HTMLHeadElement {
let candidates = node.traverse_preorder()
.filter_map(Root::downcast::<Element>)
.filter(|elem| elem.is::<HTMLMetaElement>())
- .filter(|elem| elem.get_string_attribute(&atom!("name")) == "referrer")
- .filter(|elem| elem.get_attribute(&ns!(), &atom!("content")).is_some());
+ .filter(|elem| elem.get_string_attribute(&local_name!("name")) == "referrer")
+ .filter(|elem| elem.get_attribute(&ns!(), &local_name!("content")).is_some());
for meta in candidates {
- if let Some(content) = meta.get_attribute(&ns!(), &atom!("content")).r() {
+ if let Some(content) = meta.get_attribute(&ns!(), &local_name!("content")).r() {
let content = content.value();
let content_val = content.trim();
if !content_val.is_empty() {
diff --git a/components/script/dom/htmlheadingelement.rs b/components/script/dom/htmlheadingelement.rs
index 90fbd259818..edfd894c51e 100644
--- a/components/script/dom/htmlheadingelement.rs
+++ b/components/script/dom/htmlheadingelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[derive(JSTraceable, HeapSizeOf)]
pub enum HeadingLevel {
@@ -27,7 +27,7 @@ pub struct HTMLHeadingElement {
}
impl HTMLHeadingElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document,
level: HeadingLevel) -> HTMLHeadingElement {
@@ -39,7 +39,7 @@ impl HTMLHeadingElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document,
level: HeadingLevel) -> Root<HTMLHeadingElement> {
diff --git a/components/script/dom/htmlhrelement.rs b/components/script/dom/htmlhrelement.rs
index ee2e9f4f12e..939e389e81f 100644
--- a/components/script/dom/htmlhrelement.rs
+++ b/components/script/dom/htmlhrelement.rs
@@ -12,7 +12,7 @@ use dom::element::{Element, RawLayoutElementHelpers};
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
#[dom_struct]
@@ -21,14 +21,14 @@ pub struct HTMLHRElement {
}
impl HTMLHRElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLHRElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLHRElement {
HTMLHRElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
}
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLHRElement> {
Node::reflect_node(box HTMLHRElement::new_inherited(local_name, prefix, document),
@@ -67,7 +67,7 @@ impl HTMLHRLayoutHelpers for LayoutJS<HTMLHRElement> {
fn get_color(&self) -> Option<RGBA> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("color"))
+ .get_attr_for_layout(&ns!(), &local_name!("color"))
.and_then(AttrValue::as_color)
.cloned()
}
@@ -77,7 +77,7 @@ impl HTMLHRLayoutHelpers for LayoutJS<HTMLHRElement> {
fn get_width(&self) -> LengthOrPercentageOrAuto {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("width"))
+ .get_attr_for_layout(&ns!(), &local_name!("width"))
.map(AttrValue::as_dimension)
.cloned()
.unwrap_or(LengthOrPercentageOrAuto::Auto)
@@ -91,11 +91,11 @@ impl VirtualMethods for HTMLHRElement {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("align") => AttrValue::from_dimension(value.into()),
- &atom!("color") => AttrValue::from_legacy_color(value.into()),
- &atom!("width") => AttrValue::from_dimension(value.into()),
+ &local_name!("align") => AttrValue::from_dimension(value.into()),
+ &local_name!("color") => AttrValue::from_legacy_color(value.into()),
+ &local_name!("width") => AttrValue::from_dimension(value.into()),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
diff --git a/components/script/dom/htmlhtmlelement.rs b/components/script/dom/htmlhtmlelement.rs
index 3b397c7fd04..d79fbadcae2 100644
--- a/components/script/dom/htmlhtmlelement.rs
+++ b/components/script/dom/htmlhtmlelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLHtmlElement {
@@ -16,14 +16,14 @@ pub struct HTMLHtmlElement {
}
impl HTMLHtmlElement {
- fn new_inherited(localName: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLHtmlElement {
+ fn new_inherited(localName: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLHtmlElement {
HTMLHtmlElement {
htmlelement: HTMLElement::new_inherited(localName, prefix, document)
}
}
#[allow(unrooted_must_root)]
- pub fn new(localName: Atom,
+ pub fn new(localName: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLHtmlElement> {
Node::reflect_node(box HTMLHtmlElement::new_inherited(localName, prefix, document),
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index 5215359df8a..73ef7c580d7 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -35,6 +35,7 @@ use dom::node::{Node, NodeDamage, UnbindContext, document_from_node, window_from
use dom::urlhelper::UrlHelper;
use dom::virtualmethods::VirtualMethods;
use dom::window::{ReflowReason, Window};
+use html5ever_atoms::LocalName;
use ipc_channel::ipc;
use js::jsapi::{JSAutoCompartment, JSContext, MutableHandleValue};
use js::jsval::{NullValue, UndefinedValue};
@@ -43,8 +44,8 @@ use net_traits::response::HttpsState;
use script_layout_interface::message::ReflowQueryType;
use script_traits::{IFrameLoadInfo, LoadData, MozBrowserEvent, ScriptMsg as ConstellationMsg};
use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
+use servo_atoms::Atom;
use std::cell::Cell;
-use string_cache::Atom;
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
use style::context::ReflowGoal;
use url::Url;
@@ -84,7 +85,7 @@ impl HTMLIFrameElement {
/// step 1.
fn get_url(&self) -> Url {
let element = self.upcast::<Element>();
- element.get_attribute(&ns!(), &atom!("src")).and_then(|src| {
+ element.get_attribute(&ns!(), &local_name!("src")).and_then(|src| {
let url = src.value();
if url.is_empty() {
None
@@ -178,7 +179,7 @@ impl HTMLIFrameElement {
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
}
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLIFrameElement {
HTMLIFrameElement {
@@ -193,7 +194,7 @@ impl HTMLIFrameElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLIFrameElement> {
Node::reflect_node(box HTMLIFrameElement::new_inherited(local_name, prefix, document),
@@ -255,7 +256,7 @@ impl HTMLIFrameElement {
pub fn privatebrowsing(&self) -> bool {
if self.Mozbrowser() {
let element = self.upcast::<Element>();
- element.has_attribute(&Atom::from("mozprivatebrowsing"))
+ element.has_attribute(&LocalName::from("mozprivatebrowsing"))
} else {
false
}
@@ -290,7 +291,7 @@ impl HTMLIFrameElementLayoutMethods for LayoutJS<HTMLIFrameElement> {
fn get_width(&self) -> LengthOrPercentageOrAuto {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("width"))
+ .get_attr_for_layout(&ns!(), &local_name!("width"))
.map(AttrValue::as_dimension)
.cloned()
.unwrap_or(LengthOrPercentageOrAuto::Auto)
@@ -301,7 +302,7 @@ impl HTMLIFrameElementLayoutMethods for LayoutJS<HTMLIFrameElement> {
fn get_height(&self) -> LengthOrPercentageOrAuto {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("height"))
+ .get_attr_for_layout(&ns!(), &local_name!("height"))
.map(AttrValue::as_dimension)
.cloned()
.unwrap_or(LengthOrPercentageOrAuto::Auto)
@@ -425,17 +426,17 @@ pub fn Navigate(iframe: &HTMLIFrameElement, direction: TraversalDirection) -> Er
impl HTMLIFrameElementMethods for HTMLIFrameElement {
// https://html.spec.whatwg.org/multipage/#dom-iframe-src
fn Src(&self) -> DOMString {
- self.upcast::<Element>().get_string_attribute(&atom!("src"))
+ self.upcast::<Element>().get_string_attribute(&local_name!("src"))
}
// https://html.spec.whatwg.org/multipage/#dom-iframe-src
fn SetSrc(&self, src: DOMString) {
- self.upcast::<Element>().set_url_attribute(&atom!("src"), src)
+ self.upcast::<Element>().set_url_attribute(&local_name!("src"), src)
}
// https://html.spec.whatwg.org/multipage/#dom-iframe-sandbox
fn Sandbox(&self) -> Root<DOMTokenList> {
- self.sandbox.or_init(|| DOMTokenList::new(self.upcast::<Element>(), &atom!("sandbox")))
+ self.sandbox.or_init(|| DOMTokenList::new(self.upcast::<Element>(), &local_name!("sandbox")))
}
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentwindow
@@ -469,7 +470,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
fn Mozbrowser(&self) -> bool {
if window_from_node(self).is_mozbrowser() {
let element = self.upcast::<Element>();
- element.has_attribute(&atom!("mozbrowser"))
+ element.has_attribute(&local_name!("mozbrowser"))
} else {
false
}
@@ -478,7 +479,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
fn SetMozbrowser(&self, value: bool) {
let element = self.upcast::<Element>();
- element.set_bool_attribute(&atom!("mozbrowser"), value);
+ element.set_bool_attribute(&local_name!("mozbrowser"), value);
}
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goBack
@@ -552,13 +553,13 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
// check-tidy: no specs after this line
fn SetMozprivatebrowsing(&self, value: bool) {
let element = self.upcast::<Element>();
- element.set_bool_attribute(&Atom::from("mozprivatebrowsing"), value);
+ element.set_bool_attribute(&LocalName::from("mozprivatebrowsing"), value);
}
fn Mozprivatebrowsing(&self) -> bool {
if window_from_node(self).is_mozbrowser() {
let element = self.upcast::<Element>();
- element.has_attribute(&Atom::from("mozprivatebrowsing"))
+ element.has_attribute(&LocalName::from("mozprivatebrowsing"))
} else {
false
}
@@ -573,7 +574,7 @@ impl VirtualMethods for HTMLIFrameElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!("sandbox") => {
+ &local_name!("sandbox") => {
self.sandbox_allowance.set(mutation.new_value(attr).map(|value| {
let mut modes = ALLOW_NOTHING;
for token in value.as_tokens() {
@@ -590,7 +591,7 @@ impl VirtualMethods for HTMLIFrameElement {
modes
}));
},
- &atom!("src") => {
+ &local_name!("src") => {
if let AttributeMutation::Set(_) = mutation {
if self.upcast::<Node>().is_in_doc() {
self.process_the_iframe_attributes();
@@ -601,11 +602,11 @@ impl VirtualMethods for HTMLIFrameElement {
}
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("sandbox") => AttrValue::from_serialized_tokenlist(value.into()),
- &atom!("width") => AttrValue::from_dimension(value.into()),
- &atom!("height") => AttrValue::from_dimension(value.into()),
+ &local_name!("sandbox") => AttrValue::from_serialized_tokenlist(value.into()),
+ &local_name!("width") => AttrValue::from_dimension(value.into()),
+ &local_name!("height") => AttrValue::from_dimension(value.into()),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs
index 911f305e9f9..373e7ed8480 100644
--- a/components/script/dom/htmlimageelement.rs
+++ b/components/script/dom/htmlimageelement.rs
@@ -21,6 +21,7 @@ use dom::htmlelement::HTMLElement;
use dom::node::{Node, NodeDamage, document_from_node, window_from_node};
use dom::values::UNSIGNED_LONG_MAX;
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use ipc_channel::ipc;
use ipc_channel::router::ROUTER;
use net_traits::image::base::{Image, ImageMetadata};
@@ -30,7 +31,6 @@ use script_runtime::ScriptThreadEventCategory::UpdateReplacedElement;
use script_thread::Runnable;
use std::i32;
use std::sync::Arc;
-use string_cache::Atom;
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
use task_source::TaskSource;
use url::Url;
@@ -195,7 +195,7 @@ impl HTMLImageElement {
}
}
}
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLImageElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLImageElement {
HTMLImageElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
current_request: DOMRefCell::new(ImageRequest {
@@ -216,7 +216,7 @@ impl HTMLImageElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLImageElement> {
Node::reflect_node(box HTMLImageElement::new_inherited(local_name, prefix, document),
@@ -228,7 +228,7 @@ impl HTMLImageElement {
width: Option<u32>,
height: Option<u32>) -> Fallible<Root<HTMLImageElement>> {
let document = global.as_window().Document();
- let image = HTMLImageElement::new(atom!("img"), None, &document);
+ let image = HTMLImageElement::new(local_name!("img"), None, &document);
if let Some(w) = width {
image.SetWidth(w);
}
@@ -266,7 +266,7 @@ impl LayoutHTMLImageElementHelpers for LayoutJS<HTMLImageElement> {
fn get_width(&self) -> LengthOrPercentageOrAuto {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("width"))
+ .get_attr_for_layout(&ns!(), &local_name!("width"))
.map(AttrValue::as_dimension)
.cloned()
.unwrap_or(LengthOrPercentageOrAuto::Auto)
@@ -277,7 +277,7 @@ impl LayoutHTMLImageElementHelpers for LayoutJS<HTMLImageElement> {
fn get_height(&self) -> LengthOrPercentageOrAuto {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("height"))
+ .get_attr_for_layout(&ns!(), &local_name!("height"))
.map(AttrValue::as_dimension)
.cloned()
.unwrap_or(LengthOrPercentageOrAuto::Auto)
@@ -320,7 +320,7 @@ impl HTMLImageElementMethods for HTMLImageElement {
// https://html.spec.whatwg.org/multipage/#dom-img-width
fn SetWidth(&self, value: u32) {
- image_dimension_setter(self.upcast(), atom!("width"), value);
+ image_dimension_setter(self.upcast(), local_name!("width"), value);
}
// https://html.spec.whatwg.org/multipage/#dom-img-height
@@ -332,7 +332,7 @@ impl HTMLImageElementMethods for HTMLImageElement {
// https://html.spec.whatwg.org/multipage/#dom-img-height
fn SetHeight(&self, value: u32) {
- image_dimension_setter(self.upcast(), atom!("height"), value);
+ image_dimension_setter(self.upcast(), local_name!("height"), value);
}
// https://html.spec.whatwg.org/multipage/#dom-img-naturalwidth
@@ -415,7 +415,7 @@ impl VirtualMethods for HTMLImageElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!("src") => {
+ &local_name!("src") => {
self.update_image(mutation.new_value(attr).map(|value| {
// FIXME(ajeffrey): convert directly from AttrValue to DOMString
(DOMString::from(&**value), document_from_node(self).base_url())
@@ -425,17 +425,17 @@ impl VirtualMethods for HTMLImageElement {
}
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("name") => AttrValue::from_atomic(value.into()),
- &atom!("width") | &atom!("height") => AttrValue::from_dimension(value.into()),
- &atom!("hspace") | &atom!("vspace") => AttrValue::from_u32(value.into(), 0),
+ &local_name!("name") => AttrValue::from_atomic(value.into()),
+ &local_name!("width") | &local_name!("height") => AttrValue::from_dimension(value.into()),
+ &local_name!("hspace") | &local_name!("vspace") => AttrValue::from_u32(value.into(), 0),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
}
-fn image_dimension_setter(element: &Element, attr: Atom, value: u32) {
+fn image_dimension_setter(element: &Element, attr: LocalName, value: u32) {
// This setter is a bit weird: the IDL type is unsigned long, but it's parsed as
// a dimension for rendering.
let value = if value > UNSIGNED_LONG_MAX {
diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs
index 049d765b831..f4a9a726d30 100644
--- a/components/script/dom/htmlinputelement.rs
+++ b/components/script/dom/htmlinputelement.rs
@@ -32,6 +32,7 @@ use dom::node::{document_from_node, window_from_node};
use dom::nodelist::NodeList;
use dom::validation::Validatable;
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use ipc_channel::ipc::{self, IpcSender};
use mime_guess;
use msg::constellation_msg::Key;
@@ -39,10 +40,10 @@ use net_traits::{CoreResourceMsg, IpcSend};
use net_traits::blob_url_store::get_blob_origin;
use net_traits::filemanager_thread::{FileManagerThreadMsg, FilterPattern};
use script_traits::ScriptMsg as ConstellationMsg;
+use servo_atoms::Atom;
use std::borrow::ToOwned;
use std::cell::Cell;
use std::ops::Range;
-use string_cache::Atom;
use style::attr::AttrValue;
use style::element_state::*;
use style::str::split_commas;
@@ -128,7 +129,7 @@ static DEFAULT_MAX_LENGTH: i32 = -1;
static DEFAULT_MIN_LENGTH: i32 = -1;
impl HTMLInputElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLInputElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLInputElement {
let chan = document.window().upcast::<GlobalScope>().constellation_chan().clone();
HTMLInputElement {
htmlelement:
@@ -154,7 +155,7 @@ impl HTMLInputElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLInputElement> {
Node::reflect_node(box HTMLInputElement::new_inherited(local_name, prefix, document),
@@ -164,7 +165,7 @@ impl HTMLInputElement {
pub fn type_(&self) -> Atom {
self.upcast::<Element>()
- .get_attribute(&ns!(), &atom!("type"))
+ .get_attribute(&ns!(), &local_name!("type"))
.map_or_else(|| atom!(""), |a| a.value().as_atom().to_owned())
}
@@ -209,7 +210,7 @@ impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
unsafe fn get_raw_attr_value(input: LayoutJS<HTMLInputElement>, default: &str) -> String {
let elem = input.upcast::<Element>();
let value = (*elem.unsafe_get())
- .get_attr_val_for_layout(&ns!(), &atom!("value"))
+ .get_attr_val_for_layout(&ns!(), &local_name!("value"))
.unwrap_or(default);
String::from(value)
}
@@ -371,13 +372,13 @@ impl HTMLInputElementMethods for HTMLInputElement {
ValueMode::Value => self.textinput.borrow().get_content(),
ValueMode::Default => {
self.upcast::<Element>()
- .get_attribute(&ns!(), &atom!("value"))
+ .get_attribute(&ns!(), &local_name!("value"))
.map_or(DOMString::from(""),
|a| DOMString::from(a.summarize().value))
}
ValueMode::DefaultOn => {
self.upcast::<Element>()
- .get_attribute(&ns!(), &atom!("value"))
+ .get_attribute(&ns!(), &local_name!("value"))
.map_or(DOMString::from("on"),
|a| DOMString::from(a.summarize().value))
}
@@ -407,7 +408,7 @@ impl HTMLInputElementMethods for HTMLInputElement {
}
ValueMode::Default |
ValueMode::DefaultOn => {
- self.upcast::<Element>().set_string_attribute(&atom!("value"), value);
+ self.upcast::<Element>().set_string_attribute(&local_name!("value"), value);
}
ValueMode::Filename => {
if value.is_empty() {
@@ -734,7 +735,7 @@ impl HTMLInputElement {
fn radio_group_name(&self) -> Option<Atom> {
//TODO: determine form owner
self.upcast::<Element>()
- .get_attribute(&ns!(), &atom!("name"))
+ .get_attribute(&ns!(), &local_name!("name"))
.map(|name| name.value().as_atom().clone())
}
@@ -867,7 +868,7 @@ impl VirtualMethods for HTMLInputElement {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!("disabled") => {
+ &local_name!("disabled") => {
let disabled_state = match mutation {
AttributeMutation::Set(None) => true,
AttributeMutation::Set(Some(_)) => {
@@ -886,7 +887,7 @@ impl VirtualMethods for HTMLInputElement {
el.set_read_write_state(read_write);
}
},
- &atom!("checked") if !self.checked_changed.get() => {
+ &local_name!("checked") if !self.checked_changed.get() => {
let checked_state = match mutation {
AttributeMutation::Set(None) => true,
AttributeMutation::Set(Some(_)) => {
@@ -897,13 +898,13 @@ impl VirtualMethods for HTMLInputElement {
};
self.update_checked_state(checked_state, false);
},
- &atom!("size") => {
+ &local_name!("size") => {
let size = mutation.new_value(attr).map(|value| {
value.as_uint()
});
self.size.set(size.unwrap_or(DEFAULT_INPUT_SIZE));
}
- &atom!("type") => {
+ &local_name!("type") => {
let el = self.upcast::<Element>();
match mutation {
AttributeMutation::Set(_) => {
@@ -948,7 +949,7 @@ impl VirtualMethods for HTMLInputElement {
// Step 2
(_, _, ValueMode::Value) if old_value_mode != ValueMode::Value => {
self.SetValue(self.upcast::<Element>()
- .get_attribute(&ns!(), &atom!("value"))
+ .get_attribute(&ns!(), &local_name!("value"))
.map_or(DOMString::from(""),
|a| DOMString::from(a.summarize().value)))
.expect("Failed to set input value on type change to ValueMode::Value.");
@@ -987,17 +988,17 @@ impl VirtualMethods for HTMLInputElement {
self.update_placeholder_shown_state();
},
- &atom!("value") if !self.value_changed.get() => {
+ &local_name!("value") if !self.value_changed.get() => {
let value = mutation.new_value(attr).map(|value| (**value).to_owned());
self.textinput.borrow_mut().set_content(
value.map_or(DOMString::new(), DOMString::from));
self.update_placeholder_shown_state();
},
- &atom!("name") if self.input_type.get() == InputType::InputRadio => {
+ &local_name!("name") if self.input_type.get() == InputType::InputRadio => {
self.radio_group_updated(
mutation.new_value(attr).as_ref().map(|name| name.as_atom()));
},
- &atom!("maxlength") => {
+ &local_name!("maxlength") => {
match *attr.value() {
AttrValue::Int(_, value) => {
if value < 0 {
@@ -1009,7 +1010,7 @@ impl VirtualMethods for HTMLInputElement {
_ => panic!("Expected an AttrValue::Int"),
}
},
- &atom!("minlength") => {
+ &local_name!("minlength") => {
match *attr.value() {
AttrValue::Int(_, value) => {
if value < 0 {
@@ -1021,7 +1022,7 @@ impl VirtualMethods for HTMLInputElement {
_ => panic!("Expected an AttrValue::Int"),
}
},
- &atom!("placeholder") => {
+ &local_name!("placeholder") => {
{
let mut placeholder = self.placeholder.borrow_mut();
placeholder.clear();
@@ -1032,7 +1033,7 @@ impl VirtualMethods for HTMLInputElement {
}
self.update_placeholder_shown_state();
},
- &atom!("readonly") if self.input_type.get() == InputType::InputText => {
+ &local_name!("readonly") if self.input_type.get() == InputType::InputText => {
let el = self.upcast::<Element>();
match mutation {
AttributeMutation::Set(_) => {
@@ -1047,14 +1048,14 @@ impl VirtualMethods for HTMLInputElement {
}
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("accept") => AttrValue::from_comma_separated_tokenlist(value.into()),
- &atom!("name") => AttrValue::from_atomic(value.into()),
- &atom!("size") => AttrValue::from_limited_u32(value.into(), DEFAULT_INPUT_SIZE),
- &atom!("type") => AttrValue::from_atomic(value.into()),
- &atom!("maxlength") => AttrValue::from_limited_i32(value.into(), DEFAULT_MAX_LENGTH),
- &atom!("minlength") => AttrValue::from_limited_i32(value.into(), DEFAULT_MIN_LENGTH),
+ &local_name!("accept") => AttrValue::from_comma_separated_tokenlist(value.into()),
+ &local_name!("name") => AttrValue::from_atomic(value.into()),
+ &local_name!("size") => AttrValue::from_limited_u32(value.into(), DEFAULT_INPUT_SIZE),
+ &local_name!("type") => AttrValue::from_atomic(value.into()),
+ &local_name!("maxlength") => AttrValue::from_limited_i32(value.into(), DEFAULT_MAX_LENGTH),
+ &local_name!("minlength") => AttrValue::from_limited_i32(value.into(), DEFAULT_MIN_LENGTH),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
diff --git a/components/script/dom/htmllabelelement.rs b/components/script/dom/htmllabelelement.rs
index 39869a50f49..5d954cfc5dd 100644
--- a/components/script/dom/htmllabelelement.rs
+++ b/components/script/dom/htmllabelelement.rs
@@ -16,7 +16,7 @@ use dom::htmlelement::HTMLElement;
use dom::htmlformelement::{FormControl, HTMLFormElement};
use dom::node::{document_from_node, Node};
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
use style::attr::AttrValue;
#[dom_struct]
@@ -25,7 +25,7 @@ pub struct HTMLLabelElement {
}
impl HTMLLabelElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLLabelElement {
HTMLLabelElement {
@@ -35,7 +35,7 @@ impl HTMLLabelElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLLabelElement> {
Node::reflect_node(box HTMLLabelElement::new_inherited(local_name, prefix, document),
@@ -102,7 +102,7 @@ impl HTMLLabelElementMethods for HTMLLabelElement {
return None;
}
- let for_attr = match self.upcast::<Element>().get_attribute(&ns!(), &atom!("for")) {
+ let for_attr = match self.upcast::<Element>().get_attribute(&ns!(), &local_name!("for")) {
Some(for_attr) => for_attr,
None => return self.first_labelable_descendant(),
};
@@ -121,9 +121,9 @@ impl VirtualMethods for HTMLLabelElement {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("for") => AttrValue::from_atomic(value.into()),
+ &local_name!("for") => AttrValue::from_atomic(value.into()),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
diff --git a/components/script/dom/htmllegendelement.rs b/components/script/dom/htmllegendelement.rs
index e5c5e29aae2..0b9cbf3992c 100644
--- a/components/script/dom/htmllegendelement.rs
+++ b/components/script/dom/htmllegendelement.rs
@@ -15,7 +15,7 @@ use dom::htmlfieldsetelement::HTMLFieldSetElement;
use dom::htmlformelement::{HTMLFormElement, FormControl};
use dom::node::{Node, UnbindContext};
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLLegendElement {
@@ -23,7 +23,7 @@ pub struct HTMLLegendElement {
}
impl HTMLLegendElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document)
-> HTMLLegendElement {
@@ -31,7 +31,7 @@ impl HTMLLegendElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document)
-> Root<HTMLLegendElement> {
diff --git a/components/script/dom/htmllielement.rs b/components/script/dom/htmllielement.rs
index d08b677a947..4d17eb9376d 100644
--- a/components/script/dom/htmllielement.rs
+++ b/components/script/dom/htmllielement.rs
@@ -11,7 +11,7 @@ use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
use style::attr::AttrValue;
#[dom_struct]
@@ -20,14 +20,14 @@ pub struct HTMLLIElement {
}
impl HTMLLIElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLLIElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLLIElement {
HTMLLIElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
}
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLLIElement> {
Node::reflect_node(box HTMLLIElement::new_inherited(local_name, prefix, document),
@@ -49,9 +49,9 @@ impl VirtualMethods for HTMLLIElement {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("value") => AttrValue::from_i32(value.into(), 0),
+ &local_name!("value") => AttrValue::from_i32(value.into(), 0),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs
index 903352338fc..f4cd1ae0718 100644
--- a/components/script/dom/htmllinkelement.rs
+++ b/components/script/dom/htmllinkelement.rs
@@ -24,6 +24,7 @@ use dom::node::{Node, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use encoding::EncodingRef;
use encoding::all::UTF_8;
+use html5ever_atoms::LocalName;
use hyper::header::ContentType;
use hyper::mime::{Mime, TopLevel, SubLevel};
use hyper_serde::Serde;
@@ -41,7 +42,6 @@ use std::cell::Cell;
use std::default::Default;
use std::mem;
use std::sync::{Arc, Mutex};
-use string_cache::Atom;
use style::attr::AttrValue;
use style::media_queries::{MediaQueryList, parse_media_query_list};
use style::parser::ParserContextExtraData;
@@ -63,7 +63,7 @@ pub struct HTMLLinkElement {
}
impl HTMLLinkElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document,
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document,
creator: ElementCreator) -> HTMLLinkElement {
HTMLLinkElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
@@ -74,7 +74,7 @@ impl HTMLLinkElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document,
creator: ElementCreator) -> Root<HTMLLinkElement> {
@@ -88,7 +88,7 @@ impl HTMLLinkElement {
}
}
-fn get_attr(element: &Element, local_name: &Atom) -> Option<String> {
+fn get_attr(element: &Element, local_name: &LocalName) -> Option<String> {
let elem = element.get_attribute(&ns!(), local_name);
elem.map(|e| {
let value = e.value();
@@ -139,26 +139,26 @@ impl VirtualMethods for HTMLLinkElement {
return;
}
- let rel = get_attr(self.upcast(), &atom!("rel"));
+ let rel = get_attr(self.upcast(), &local_name!("rel"));
match attr.local_name() {
- &atom!("href") => {
+ &local_name!("href") => {
if string_is_stylesheet(&rel) {
self.handle_stylesheet_url(&attr.value());
} else if is_favicon(&rel) {
- let sizes = get_attr(self.upcast(), &atom!("sizes"));
+ let sizes = get_attr(self.upcast(), &local_name!("sizes"));
self.handle_favicon_url(rel.as_ref().unwrap(), &attr.value(), &sizes);
}
},
- &atom!("sizes") => {
+ &local_name!("sizes") => {
if is_favicon(&rel) {
- if let Some(ref href) = get_attr(self.upcast(), &atom!("href")) {
+ if let Some(ref href) = get_attr(self.upcast(), &local_name!("href")) {
self.handle_favicon_url(rel.as_ref().unwrap(), href, &Some(attr.value().to_string()));
}
}
},
- &atom!("media") => {
+ &local_name!("media") => {
if string_is_stylesheet(&rel) {
- if let Some(href) = self.upcast::<Element>().get_attribute(&ns!(), &atom!("href")) {
+ if let Some(href) = self.upcast::<Element>().get_attribute(&ns!(), &local_name!("href")) {
self.handle_stylesheet_url(&href.value());
}
}
@@ -167,9 +167,9 @@ impl VirtualMethods for HTMLLinkElement {
}
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("rel") => AttrValue::from_serialized_tokenlist(value.into()),
+ &local_name!("rel") => AttrValue::from_serialized_tokenlist(value.into()),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
@@ -182,9 +182,9 @@ impl VirtualMethods for HTMLLinkElement {
if tree_in_doc {
let element = self.upcast();
- let rel = get_attr(element, &atom!("rel"));
- let href = get_attr(element, &atom!("href"));
- let sizes = get_attr(self.upcast(), &atom!("sizes"));
+ let rel = get_attr(element, &local_name!("rel"));
+ let href = get_attr(element, &local_name!("href"));
+ let sizes = get_attr(self.upcast(), &local_name!("sizes"));
match href {
Some(ref href) if string_is_stylesheet(&rel) => {
@@ -221,7 +221,7 @@ impl HTMLLinkElement {
let element = self.upcast::<Element>();
- let mq_attribute = element.get_attribute(&ns!(), &atom!("media"));
+ let mq_attribute = element.get_attribute(&ns!(), &local_name!("media"));
let value = mq_attribute.r().map(|a| a.value());
let mq_str = match value {
Some(ref value) => &***value,
@@ -398,7 +398,7 @@ impl HTMLLinkElementMethods for HTMLLinkElement {
// https://html.spec.whatwg.org/multipage/#dom-link-rel
fn SetRel(&self, rel: DOMString) {
- self.upcast::<Element>().set_tokenlist_attribute(&atom!("rel"), rel);
+ self.upcast::<Element>().set_tokenlist_attribute(&local_name!("rel"), rel);
}
// https://html.spec.whatwg.org/multipage/#dom-link-media
@@ -421,7 +421,7 @@ impl HTMLLinkElementMethods for HTMLLinkElement {
// https://html.spec.whatwg.org/multipage/#dom-link-rellist
fn RelList(&self) -> Root<DOMTokenList> {
- self.rel_list.or_init(|| DOMTokenList::new(self.upcast(), &atom!("rel")))
+ self.rel_list.or_init(|| DOMTokenList::new(self.upcast(), &local_name!("rel")))
}
// https://html.spec.whatwg.org/multipage/#dom-link-charset
diff --git a/components/script/dom/htmlmapelement.rs b/components/script/dom/htmlmapelement.rs
index 5bf05ef7747..8ef091b0762 100644
--- a/components/script/dom/htmlmapelement.rs
+++ b/components/script/dom/htmlmapelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLMapElement {
@@ -16,7 +16,7 @@ pub struct HTMLMapElement {
}
impl HTMLMapElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLMapElement {
HTMLMapElement {
@@ -25,7 +25,7 @@ impl HTMLMapElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLMapElement> {
Node::reflect_node(box HTMLMapElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs
index 203763d3e15..0627bcf0ffb 100644
--- a/components/script/dom/htmlmediaelement.rs
+++ b/components/script/dom/htmlmediaelement.rs
@@ -27,15 +27,16 @@ use dom::htmlvideoelement::HTMLVideoElement;
use dom::mediaerror::MediaError;
use dom::node::{window_from_node, document_from_node, Node, UnbindContext};
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use ipc_channel::ipc;
use ipc_channel::router::ROUTER;
use net_traits::{FetchResponseListener, FetchMetadata, Metadata, NetworkError};
use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as RequestType};
use network_listener::{NetworkListener, PreInvoke};
use script_thread::{Runnable, ScriptThread};
+use servo_atoms::Atom;
use std::cell::Cell;
use std::sync::{Arc, Mutex};
-use string_cache::Atom;
use task_source::TaskSource;
use time::{self, Timespec, Duration};
use url::Url;
@@ -224,7 +225,7 @@ pub struct HTMLMediaElement {
}
impl HTMLMediaElement {
- pub fn new_inherited(tag_name: Atom,
+ pub fn new_inherited(tag_name: LocalName,
prefix: Option<DOMString>, document: &Document)
-> HTMLMediaElement {
HTMLMediaElement {
@@ -443,7 +444,7 @@ impl HTMLMediaElement {
let mode = if false {
// TODO media provider object
ResourceSelectionMode::Object
- } else if let Some(attr) = self.upcast::<Element>().get_attribute(&ns!(), &atom!("src")) {
+ } else if let Some(attr) = self.upcast::<Element>().get_attribute(&ns!(), &local_name!("src")) {
ResourceSelectionMode::Attribute(attr.Value().to_string())
} else if false {
// TODO <source> child
@@ -770,7 +771,7 @@ impl VirtualMethods for HTMLMediaElement {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!("src") => {
+ &local_name!("src") => {
if mutation.new_value(attr).is_some() {
self.media_element_load_algorithm();
}
diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs
index 219b0cbce90..14f9cd78555 100644
--- a/components/script/dom/htmlmetaelement.rs
+++ b/components/script/dom/htmlmetaelement.rs
@@ -16,10 +16,10 @@ use dom::htmlelement::HTMLElement;
use dom::htmlheadelement::HTMLHeadElement;
use dom::node::{Node, UnbindContext, document_from_node};
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use parking_lot::RwLock;
use std::ascii::AsciiExt;
use std::sync::Arc;
-use string_cache::Atom;
use style::attr::AttrValue;
use style::str::HTML_SPACE_CHARACTERS;
use style::stylesheets::{Stylesheet, CSSRule, Origin};
@@ -33,7 +33,7 @@ pub struct HTMLMetaElement {
}
impl HTMLMetaElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLMetaElement {
HTMLMetaElement {
@@ -43,7 +43,7 @@ impl HTMLMetaElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLMetaElement> {
Node::reflect_node(box HTMLMetaElement::new_inherited(local_name, prefix, document),
@@ -57,7 +57,7 @@ impl HTMLMetaElement {
fn process_attributes(&self) {
let element = self.upcast::<Element>();
- if let Some(name) = element.get_attribute(&ns!(), &atom!("name")).r() {
+ if let Some(name) = element.get_attribute(&ns!(), &local_name!("name")).r() {
let name = name.value().to_ascii_lowercase();
let name = name.trim_matches(HTML_SPACE_CHARACTERS);
@@ -76,7 +76,7 @@ impl HTMLMetaElement {
return;
}
let element = self.upcast::<Element>();
- if let Some(content) = element.get_attribute(&ns!(), &atom!("content")).r() {
+ if let Some(content) = element.get_attribute(&ns!(), &local_name!("content")).r() {
let content = content.value();
if !content.is_empty() {
if let Some(translated_rule) = ViewportRule::from_meta(&**content) {
@@ -97,7 +97,7 @@ impl HTMLMetaElement {
fn process_referrer_attribute(&self) {
let element = self.upcast::<Element>();
- if let Some(name) = element.get_attribute(&ns!(), &atom!("name")).r() {
+ if let Some(name) = element.get_attribute(&ns!(), &local_name!("name")).r() {
let name = name.value().to_ascii_lowercase();
let name = name.trim_matches(HTML_SPACE_CHARACTERS);
@@ -146,9 +146,9 @@ impl VirtualMethods for HTMLMetaElement {
}
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("name") => AttrValue::from_atomic(value.into()),
+ &local_name!("name") => AttrValue::from_atomic(value.into()),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
diff --git a/components/script/dom/htmlmeterelement.rs b/components/script/dom/htmlmeterelement.rs
index 151ea555c1b..e323af1485b 100644
--- a/components/script/dom/htmlmeterelement.rs
+++ b/components/script/dom/htmlmeterelement.rs
@@ -10,7 +10,7 @@ use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use dom::nodelist::NodeList;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLMeterElement {
@@ -18,7 +18,7 @@ pub struct HTMLMeterElement {
}
impl HTMLMeterElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLMeterElement {
HTMLMeterElement {
@@ -27,7 +27,7 @@ impl HTMLMeterElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLMeterElement> {
Node::reflect_node(box HTMLMeterElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlmodelement.rs b/components/script/dom/htmlmodelement.rs
index 86357e820f4..6cd63d24505 100644
--- a/components/script/dom/htmlmodelement.rs
+++ b/components/script/dom/htmlmodelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLModElement {
@@ -16,7 +16,7 @@ pub struct HTMLModElement {
}
impl HTMLModElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLModElement {
HTMLModElement {
@@ -26,7 +26,7 @@ impl HTMLModElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLModElement> {
Node::reflect_node(box HTMLModElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlobjectelement.rs b/components/script/dom/htmlobjectelement.rs
index 6e82b9f9bd6..8e934b96808 100644
--- a/components/script/dom/htmlobjectelement.rs
+++ b/components/script/dom/htmlobjectelement.rs
@@ -17,9 +17,9 @@ use dom::node::{Node, window_from_node};
use dom::validation::Validatable;
use dom::validitystate::ValidityState;
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use net_traits::image::base::Image;
use std::sync::Arc;
-use string_cache::Atom;
#[dom_struct]
pub struct HTMLObjectElement {
@@ -29,7 +29,7 @@ pub struct HTMLObjectElement {
}
impl HTMLObjectElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLObjectElement {
HTMLObjectElement {
@@ -40,7 +40,7 @@ impl HTMLObjectElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLObjectElement> {
Node::reflect_node(box HTMLObjectElement::new_inherited(local_name, prefix, document),
@@ -60,8 +60,8 @@ impl<'a> ProcessDataURL for &'a HTMLObjectElement {
let elem = self.upcast::<Element>();
// TODO: support other values
- match (elem.get_attribute(&ns!(), &atom!("type")),
- elem.get_attribute(&ns!(), &atom!("data"))) {
+ match (elem.get_attribute(&ns!(), &local_name!("type")),
+ elem.get_attribute(&ns!(), &local_name!("data"))) {
(None, Some(_uri)) => {
// TODO(gw): Prefetch the image here.
}
@@ -99,7 +99,7 @@ impl VirtualMethods for HTMLObjectElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!("data") => {
+ &local_name!("data") => {
if let AttributeMutation::Set(_) = mutation {
self.process_data_url();
}
diff --git a/components/script/dom/htmlolistelement.rs b/components/script/dom/htmlolistelement.rs
index 9447053e5e8..19c731bdc0a 100644
--- a/components/script/dom/htmlolistelement.rs
+++ b/components/script/dom/htmlolistelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLOListElement {
@@ -16,7 +16,7 @@ pub struct HTMLOListElement {
}
impl HTMLOListElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLOListElement {
HTMLOListElement {
@@ -25,7 +25,7 @@ impl HTMLOListElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLOListElement> {
Node::reflect_node(box HTMLOListElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmloptgroupelement.rs b/components/script/dom/htmloptgroupelement.rs
index 3d6f020e6f1..583c32337db 100644
--- a/components/script/dom/htmloptgroupelement.rs
+++ b/components/script/dom/htmloptgroupelement.rs
@@ -14,7 +14,7 @@ use dom::htmlelement::HTMLElement;
use dom::htmloptionelement::HTMLOptionElement;
use dom::node::Node;
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
use style::element_state::*;
#[dom_struct]
@@ -23,7 +23,7 @@ pub struct HTMLOptGroupElement {
}
impl HTMLOptGroupElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLOptGroupElement {
HTMLOptGroupElement {
@@ -34,7 +34,7 @@ impl HTMLOptGroupElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLOptGroupElement> {
Node::reflect_node(box HTMLOptGroupElement::new_inherited(local_name, prefix, document),
@@ -59,7 +59,7 @@ impl VirtualMethods for HTMLOptGroupElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!("disabled") => {
+ &local_name!("disabled") => {
let disabled_state = match mutation {
AttributeMutation::Set(None) => true,
AttributeMutation::Set(Some(_)) => {
diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs
index 1b27a10b311..d1576d532e3 100644
--- a/components/script/dom/htmloptionelement.rs
+++ b/components/script/dom/htmloptionelement.rs
@@ -22,8 +22,8 @@ use dom::htmlselectelement::HTMLSelectElement;
use dom::node::{Node, UnbindContext};
use dom::text::Text;
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use std::cell::Cell;
-use string_cache::Atom;
use style::element_state::*;
use style::str::{split_html_space_chars, str_join};
@@ -39,7 +39,7 @@ pub struct HTMLOptionElement {
}
impl HTMLOptionElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLOptionElement {
HTMLOptionElement {
@@ -52,7 +52,7 @@ impl HTMLOptionElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLOptionElement> {
Node::reflect_node(box HTMLOptionElement::new_inherited(local_name, prefix, document),
@@ -82,7 +82,7 @@ impl HTMLOptionElement {
// FIXME(ajeffrey): Provide a way of buffering DOMStrings other than using Strings
fn collect_text(element: &Element, value: &mut String) {
- let svg_script = *element.namespace() == ns!(svg) && element.local_name() == &atom!("script");
+ let svg_script = *element.namespace() == ns!(svg) && element.local_name() == &local_name!("script");
let html_script = element.is::<HTMLScriptElement>();
if svg_script || html_script {
return;
@@ -133,7 +133,7 @@ impl HTMLOptionElementMethods for HTMLOptionElement {
// https://html.spec.whatwg.org/multipage/#attr-option-value
fn Value(&self) -> DOMString {
let element = self.upcast::<Element>();
- let attr = &atom!("value");
+ let attr = &local_name!("value");
if element.has_attribute(attr) {
element.get_string_attribute(attr)
} else {
@@ -147,7 +147,7 @@ impl HTMLOptionElementMethods for HTMLOptionElement {
// https://html.spec.whatwg.org/multipage/#attr-option-label
fn Label(&self) -> DOMString {
let element = self.upcast::<Element>();
- let attr = &atom!("label");
+ let attr = &local_name!("label");
if element.has_attribute(attr) {
element.get_string_attribute(attr)
} else {
@@ -185,7 +185,7 @@ impl VirtualMethods for HTMLOptionElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match attr.local_name() {
- &atom!("disabled") => {
+ &local_name!("disabled") => {
let el = self.upcast::<Element>();
match mutation {
AttributeMutation::Set(_) => {
@@ -199,7 +199,7 @@ impl VirtualMethods for HTMLOptionElement {
}
}
},
- &atom!("selected") => {
+ &local_name!("selected") => {
match mutation {
AttributeMutation::Set(_) => {
// https://html.spec.whatwg.org/multipage/#concept-option-selectedness
diff --git a/components/script/dom/htmloptionscollection.rs b/components/script/dom/htmloptionscollection.rs
index 033868f2af8..2e4ce0f9a37 100644
--- a/components/script/dom/htmloptionscollection.rs
+++ b/components/script/dom/htmloptionscollection.rs
@@ -44,7 +44,7 @@ impl HTMLOptionsCollection {
let document = document_from_node(&*root);
for _ in 0..count {
- let element = HTMLOptionElement::new(atom!("option"), None, &document);
+ let element = HTMLOptionElement::new(local_name!("option"), None, &document);
let node = element.upcast::<Node>();
try!(root.AppendChild(node));
};
diff --git a/components/script/dom/htmloutputelement.rs b/components/script/dom/htmloutputelement.rs
index 29b69f31cf2..16af40f12cc 100644
--- a/components/script/dom/htmloutputelement.rs
+++ b/components/script/dom/htmloutputelement.rs
@@ -13,7 +13,7 @@ use dom::htmlformelement::{FormControl, HTMLFormElement};
use dom::node::{Node, window_from_node};
use dom::nodelist::NodeList;
use dom::validitystate::ValidityState;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLOutputElement {
@@ -21,7 +21,7 @@ pub struct HTMLOutputElement {
}
impl HTMLOutputElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLOutputElement {
HTMLOutputElement {
@@ -31,7 +31,7 @@ impl HTMLOutputElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLOutputElement> {
Node::reflect_node(box HTMLOutputElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlparagraphelement.rs b/components/script/dom/htmlparagraphelement.rs
index f437b429b9c..f3976d8d202 100644
--- a/components/script/dom/htmlparagraphelement.rs
+++ b/components/script/dom/htmlparagraphelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLParagraphElement {
@@ -16,7 +16,7 @@ pub struct HTMLParagraphElement {
}
impl HTMLParagraphElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLParagraphElement {
HTMLParagraphElement {
@@ -26,7 +26,7 @@ impl HTMLParagraphElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLParagraphElement> {
Node::reflect_node(box HTMLParagraphElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlparamelement.rs b/components/script/dom/htmlparamelement.rs
index 8a335a90bec..d27a85bc8bd 100644
--- a/components/script/dom/htmlparamelement.rs
+++ b/components/script/dom/htmlparamelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLParamElement {
@@ -16,7 +16,7 @@ pub struct HTMLParamElement {
}
impl HTMLParamElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLParamElement {
HTMLParamElement {
@@ -26,7 +26,7 @@ impl HTMLParamElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLParamElement> {
Node::reflect_node(box HTMLParamElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlpreelement.rs b/components/script/dom/htmlpreelement.rs
index 599d9731e2e..cfe9de10999 100644
--- a/components/script/dom/htmlpreelement.rs
+++ b/components/script/dom/htmlpreelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLPreElement {
@@ -16,7 +16,7 @@ pub struct HTMLPreElement {
}
impl HTMLPreElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLPreElement {
HTMLPreElement {
@@ -26,7 +26,7 @@ impl HTMLPreElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLPreElement> {
Node::reflect_node(box HTMLPreElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlprogresselement.rs b/components/script/dom/htmlprogresselement.rs
index 81275b9fe72..258527ac368 100644
--- a/components/script/dom/htmlprogresselement.rs
+++ b/components/script/dom/htmlprogresselement.rs
@@ -10,7 +10,7 @@ use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use dom::nodelist::NodeList;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLProgressElement {
@@ -18,7 +18,7 @@ pub struct HTMLProgressElement {
}
impl HTMLProgressElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLProgressElement {
HTMLProgressElement {
@@ -28,7 +28,7 @@ impl HTMLProgressElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLProgressElement> {
Node::reflect_node(box HTMLProgressElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlquoteelement.rs b/components/script/dom/htmlquoteelement.rs
index d72f8dc67bd..72e0329fe17 100644
--- a/components/script/dom/htmlquoteelement.rs
+++ b/components/script/dom/htmlquoteelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLQuoteElement {
@@ -16,7 +16,7 @@ pub struct HTMLQuoteElement {
}
impl HTMLQuoteElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLQuoteElement {
HTMLQuoteElement {
@@ -26,7 +26,7 @@ impl HTMLQuoteElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLQuoteElement> {
Node::reflect_node(box HTMLQuoteElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs
index d441d840d90..3b2057e4338 100644
--- a/components/script/dom/htmlscriptelement.rs
+++ b/components/script/dom/htmlscriptelement.rs
@@ -28,16 +28,17 @@ use dom::virtualmethods::VirtualMethods;
use encoding::label::encoding_from_whatwg_label;
use encoding::types::{DecoderTrap, EncodingRef};
use html5ever::tree_builder::NextParserState;
+use html5ever_atoms::LocalName;
use ipc_channel::ipc;
use ipc_channel::router::ROUTER;
use js::jsval::UndefinedValue;
use net_traits::{FetchMetadata, FetchResponseListener, Metadata, NetworkError};
use net_traits::request::{CORSSettings, CredentialsMode, Destination, RequestInit, RequestMode, Type as RequestType};
use network_listener::{NetworkListener, PreInvoke};
+use servo_atoms::Atom;
use std::ascii::AsciiExt;
use std::cell::Cell;
use std::sync::{Arc, Mutex};
-use string_cache::Atom;
use style::str::{HTML_SPACE_CHARACTERS, StaticStringVec};
use url::Url;
@@ -67,7 +68,7 @@ pub struct HTMLScriptElement {
}
impl HTMLScriptElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document,
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document,
creator: ElementCreator) -> HTMLScriptElement {
HTMLScriptElement {
htmlelement:
@@ -82,7 +83,7 @@ impl HTMLScriptElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom, prefix: Option<DOMString>, document: &Document,
+ pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document,
creator: ElementCreator) -> Root<HTMLScriptElement> {
Node::reflect_node(box HTMLScriptElement::new_inherited(local_name, prefix, document, creator),
document,
@@ -286,7 +287,7 @@ impl HTMLScriptElement {
// Step 3.
let element = self.upcast::<Element>();
- let async = element.has_attribute(&atom!("async"));
+ let async = element.has_attribute(&local_name!("async"));
// Note: confusingly, this is done if the element does *not* have an "async" attribute.
if was_parser_inserted && !async {
self.non_blocking.set(true);
@@ -294,7 +295,7 @@ impl HTMLScriptElement {
// Step 4.
let text = self.Text();
- if text.is_empty() && !element.has_attribute(&atom!("src")) {
+ if text.is_empty() && !element.has_attribute(&local_name!("src")) {
return NextParserState::Continue;
}
@@ -331,8 +332,8 @@ impl HTMLScriptElement {
// TODO(#4577): Step 11: CSP.
// Step 12.
- let for_attribute = element.get_attribute(&ns!(), &atom!("for"));
- let event_attribute = element.get_attribute(&ns!(), &atom!("event"));
+ let for_attribute = element.get_attribute(&ns!(), &local_name!("for"));
+ let event_attribute = element.get_attribute(&ns!(), &local_name!("event"));
match (for_attribute.r(), event_attribute.r()) {
(Some(for_attribute), Some(event_attribute)) => {
let for_value = for_attribute.value().to_ascii_lowercase();
@@ -351,7 +352,7 @@ impl HTMLScriptElement {
}
// Step 13.
- let encoding = element.get_attribute(&ns!(), &atom!("charset"))
+ let encoding = element.get_attribute(&ns!(), &local_name!("charset"))
.and_then(|charset| encoding_from_whatwg_label(&charset.value()))
.unwrap_or_else(|| doc.encoding());
@@ -370,7 +371,7 @@ impl HTMLScriptElement {
// TODO: Step 17: environment settings object.
let base_url = doc.base_url();
- let is_external = match element.get_attribute(&ns!(), &atom!("src")) {
+ let is_external = match element.get_attribute(&ns!(), &local_name!("src")) {
// Step 18.
Some(ref src) => {
// Step 18.1.
@@ -402,7 +403,7 @@ impl HTMLScriptElement {
};
// Step 20.
- let deferred = element.has_attribute(&atom!("defer"));
+ let deferred = element.has_attribute(&local_name!("defer"));
// Step 20.a: classic, has src, has defer, was parser-inserted, is not async.
if is_external &&
deferred &&
@@ -555,7 +556,7 @@ impl HTMLScriptElement {
pub fn is_javascript(&self) -> bool {
let element = self.upcast::<Element>();
- let type_attr = element.get_attribute(&ns!(), &atom!("type"));
+ let type_attr = element.get_attribute(&ns!(), &local_name!("type"));
let is_js = match type_attr.as_ref().map(|s| s.value()) {
Some(ref s) if s.is_empty() => {
// type attr exists, but empty means js
@@ -568,7 +569,7 @@ impl HTMLScriptElement {
},
None => {
debug!("no script type");
- let language_attr = element.get_attribute(&ns!(), &atom!("language"));
+ let language_attr = element.get_attribute(&ns!(), &local_name!("language"));
let is_js = match language_attr.as_ref().map(|s| s.value()) {
Some(ref s) if s.is_empty() => {
debug!("script language empty, inferring js");
@@ -615,7 +616,7 @@ impl VirtualMethods for HTMLScriptElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match *attr.local_name() {
- atom!("src") => {
+ local_name!("src") => {
if let AttributeMutation::Set(_) = mutation {
if !self.parser_inserted.get() && self.upcast::<Node>().is_in_doc() {
self.prepare();
@@ -692,7 +693,7 @@ impl HTMLScriptElementMethods for HTMLScriptElement {
// https://html.spec.whatwg.org/multipage/#dom-script-crossorigin
fn GetCrossOrigin(&self) -> Option<DOMString> {
let element = self.upcast::<Element>();
- let attr = element.get_attribute(&ns!(), &atom!("crossorigin"));
+ let attr = element.get_attribute(&ns!(), &local_name!("crossorigin"));
if let Some(mut val) = attr.map(|v| v.Value()) {
val.make_ascii_lowercase();
@@ -708,9 +709,9 @@ impl HTMLScriptElementMethods for HTMLScriptElement {
fn SetCrossOrigin(&self, value: Option<DOMString>) {
let element = self.upcast::<Element>();
match value {
- Some(val) => element.set_string_attribute(&atom!("crossorigin"), val),
+ Some(val) => element.set_string_attribute(&local_name!("crossorigin"), val),
None => {
- element.remove_attribute(&ns!(), &atom!("crossorigin"));
+ element.remove_attribute(&ns!(), &local_name!("crossorigin"));
}
}
}
diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs
index c44dac71000..8a5f2529d6a 100644
--- a/components/script/dom/htmlselectelement.rs
+++ b/components/script/dom/htmlselectelement.rs
@@ -30,7 +30,7 @@ use dom::nodelist::NodeList;
use dom::validation::Validatable;
use dom::validitystate::ValidityState;
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
use style::attr::AttrValue;
use style::element_state::*;
@@ -64,7 +64,7 @@ pub struct HTMLSelectElement {
static DEFAULT_SELECT_SIZE: u32 = 0;
impl HTMLSelectElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLSelectElement {
HTMLSelectElement {
@@ -76,7 +76,7 @@ impl HTMLSelectElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLSelectElement> {
Node::reflect_node(box HTMLSelectElement::new_inherited(local_name, prefix, document),
@@ -338,7 +338,7 @@ impl VirtualMethods for HTMLSelectElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
- if attr.local_name() == &atom!("disabled") {
+ if attr.local_name() == &local_name!("disabled") {
let el = self.upcast::<Element>();
match mutation {
AttributeMutation::Set(_) => {
@@ -374,9 +374,9 @@ impl VirtualMethods for HTMLSelectElement {
}
}
- fn parse_plain_attribute(&self, local_name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, local_name: &LocalName, value: DOMString) -> AttrValue {
match *local_name {
- atom!("size") => AttrValue::from_u32(value.into(), DEFAULT_SELECT_SIZE),
+ local_name!("size") => AttrValue::from_u32(value.into(), DEFAULT_SELECT_SIZE),
_ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
}
}
diff --git a/components/script/dom/htmlsourceelement.rs b/components/script/dom/htmlsourceelement.rs
index 3e1b878b802..a5c93ba2b8f 100644
--- a/components/script/dom/htmlsourceelement.rs
+++ b/components/script/dom/htmlsourceelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLSourceElement {
@@ -16,7 +16,7 @@ pub struct HTMLSourceElement {
}
impl HTMLSourceElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLSourceElement {
HTMLSourceElement {
@@ -26,7 +26,7 @@ impl HTMLSourceElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLSourceElement> {
Node::reflect_node(box HTMLSourceElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlspanelement.rs b/components/script/dom/htmlspanelement.rs
index d8fb4554b49..cc8127d651a 100644
--- a/components/script/dom/htmlspanelement.rs
+++ b/components/script/dom/htmlspanelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLSpanElement {
@@ -16,14 +16,14 @@ pub struct HTMLSpanElement {
}
impl HTMLSpanElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLSpanElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLSpanElement {
HTMLSpanElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
}
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLSpanElement> {
Node::reflect_node(box HTMLSpanElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs
index 63884305010..34d5ba79ec9 100644
--- a/components/script/dom/htmlstyleelement.rs
+++ b/components/script/dom/htmlstyleelement.rs
@@ -14,9 +14,9 @@ use dom::element::Element;
use dom::htmlelement::HTMLElement;
use dom::node::{ChildrenMutation, Node, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use script_layout_interface::message::Msg;
use std::sync::Arc;
-use string_cache::Atom;
use style::media_queries::parse_media_query_list;
use style::parser::ParserContextExtraData;
use style::stylesheets::{Stylesheet, Origin};
@@ -29,7 +29,7 @@ pub struct HTMLStyleElement {
}
impl HTMLStyleElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLStyleElement {
HTMLStyleElement {
@@ -39,7 +39,7 @@ impl HTMLStyleElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLStyleElement> {
Node::reflect_node(box HTMLStyleElement::new_inherited(local_name, prefix, document),
@@ -55,7 +55,7 @@ impl HTMLStyleElement {
let win = window_from_node(node);
let url = win.get_url();
- let mq_attribute = element.get_attribute(&ns!(), &atom!("media"));
+ let mq_attribute = element.get_attribute(&ns!(), &local_name!("media"));
let mq_str = match mq_attribute {
Some(a) => String::from(&**a.value()),
None => String::new(),
diff --git a/components/script/dom/htmltablecaptionelement.rs b/components/script/dom/htmltablecaptionelement.rs
index 89c5f8307c9..e6ced76b973 100644
--- a/components/script/dom/htmltablecaptionelement.rs
+++ b/components/script/dom/htmltablecaptionelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLTableCaptionElement {
@@ -16,7 +16,7 @@ pub struct HTMLTableCaptionElement {
}
impl HTMLTableCaptionElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLTableCaptionElement {
HTMLTableCaptionElement {
@@ -26,7 +26,7 @@ impl HTMLTableCaptionElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLTableCaptionElement> {
Node::reflect_node(box HTMLTableCaptionElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs
index 5c30132b7f9..1ec389d9977 100644
--- a/components/script/dom/htmltablecellelement.rs
+++ b/components/script/dom/htmltablecellelement.rs
@@ -14,7 +14,7 @@ use dom::htmlelement::HTMLElement;
use dom::htmltablerowelement::HTMLTableRowElement;
use dom::node::Node;
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
const DEFAULT_COLSPAN: u32 = 1;
@@ -25,7 +25,7 @@ pub struct HTMLTableCellElement {
}
impl HTMLTableCellElement {
- pub fn new_inherited(tag_name: Atom,
+ pub fn new_inherited(tag_name: LocalName,
prefix: Option<DOMString>,
document: &Document)
-> HTMLTableCellElement {
@@ -88,7 +88,7 @@ impl HTMLTableCellElementLayoutHelpers for LayoutJS<HTMLTableCellElement> {
fn get_background_color(&self) -> Option<RGBA> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("bgcolor"))
+ .get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
.and_then(AttrValue::as_color)
.cloned()
}
@@ -97,7 +97,7 @@ impl HTMLTableCellElementLayoutHelpers for LayoutJS<HTMLTableCellElement> {
fn get_colspan(&self) -> Option<u32> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("colspan"))
+ .get_attr_for_layout(&ns!(), &local_name!("colspan"))
.map(AttrValue::as_uint)
}
}
@@ -105,7 +105,7 @@ impl HTMLTableCellElementLayoutHelpers for LayoutJS<HTMLTableCellElement> {
fn get_width(&self) -> LengthOrPercentageOrAuto {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("width"))
+ .get_attr_for_layout(&ns!(), &local_name!("width"))
.map(AttrValue::as_dimension)
.cloned()
.unwrap_or(LengthOrPercentageOrAuto::Auto)
@@ -118,11 +118,11 @@ impl VirtualMethods for HTMLTableCellElement {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
- fn parse_plain_attribute(&self, local_name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, local_name: &LocalName, value: DOMString) -> AttrValue {
match *local_name {
- atom!("colspan") => AttrValue::from_u32(value.into(), DEFAULT_COLSPAN),
- atom!("bgcolor") => AttrValue::from_legacy_color(value.into()),
- atom!("width") => AttrValue::from_nonzero_dimension(value.into()),
+ local_name!("colspan") => AttrValue::from_u32(value.into(), DEFAULT_COLSPAN),
+ local_name!("bgcolor") => AttrValue::from_legacy_color(value.into()),
+ local_name!("width") => AttrValue::from_nonzero_dimension(value.into()),
_ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
}
}
diff --git a/components/script/dom/htmltablecolelement.rs b/components/script/dom/htmltablecolelement.rs
index 38f839a811e..cad7ecffbcd 100644
--- a/components/script/dom/htmltablecolelement.rs
+++ b/components/script/dom/htmltablecolelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLTableColElement {
@@ -16,7 +16,7 @@ pub struct HTMLTableColElement {
}
impl HTMLTableColElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLTableColElement {
HTMLTableColElement {
@@ -26,7 +26,7 @@ impl HTMLTableColElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLTableColElement> {
Node::reflect_node(box HTMLTableColElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmltabledatacellelement.rs b/components/script/dom/htmltabledatacellelement.rs
index 989aa0e12fe..da723fe10e1 100644
--- a/components/script/dom/htmltabledatacellelement.rs
+++ b/components/script/dom/htmltabledatacellelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmltablecellelement::HTMLTableCellElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLTableDataCellElement {
@@ -16,7 +16,7 @@ pub struct HTMLTableDataCellElement {
}
impl HTMLTableDataCellElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLTableDataCellElement {
HTMLTableDataCellElement {
@@ -26,7 +26,7 @@ impl HTMLTableDataCellElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom, prefix: Option<DOMString>, document: &Document)
+ pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document)
-> Root<HTMLTableDataCellElement> {
Node::reflect_node(box HTMLTableDataCellElement::new_inherited(local_name,
prefix,
diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs
index c3ef9eaf842..e533c9acdcd 100644
--- a/components/script/dom/htmltableelement.rs
+++ b/components/script/dom/htmltableelement.rs
@@ -22,8 +22,8 @@ use dom::htmltablerowelement::HTMLTableRowElement;
use dom::htmltablesectionelement::HTMLTableSectionElement;
use dom::node::{Node, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use std::cell::Cell;
-use string_cache::Atom;
use style::attr::{AttrValue, LengthOrPercentageOrAuto, parse_unsigned_integer};
#[dom_struct]
@@ -49,7 +49,7 @@ impl CollectionFilter for TableRowFilter {
}
impl HTMLTableElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document)
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document)
-> HTMLTableElement {
HTMLTableElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
@@ -60,7 +60,7 @@ impl HTMLTableElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom, prefix: Option<DOMString>, document: &Document)
+ pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document)
-> Root<HTMLTableElement> {
Node::reflect_node(box HTMLTableElement::new_inherited(local_name, prefix, document),
document,
@@ -73,7 +73,7 @@ impl HTMLTableElement {
// https://html.spec.whatwg.org/multipage/#dom-table-thead
// https://html.spec.whatwg.org/multipage/#dom-table-tfoot
- fn get_first_section_of_type(&self, atom: &Atom) -> Option<Root<HTMLTableSectionElement>> {
+ fn get_first_section_of_type(&self, atom: &LocalName) -> Option<Root<HTMLTableSectionElement>> {
self.upcast::<Node>()
.child_elements()
.find(|n| n.is::<HTMLTableSectionElement>() && n.local_name() == atom)
@@ -83,7 +83,7 @@ impl HTMLTableElement {
// https://html.spec.whatwg.org/multipage/#dom-table-thead
// https://html.spec.whatwg.org/multipage/#dom-table-tfoot
fn set_first_section_of_type<P>(&self,
- atom: &Atom,
+ atom: &LocalName,
section: Option<&HTMLTableSectionElement>,
reference_predicate: P)
-> ErrorResult
@@ -110,7 +110,7 @@ impl HTMLTableElement {
// https://html.spec.whatwg.org/multipage/#dom-table-createthead
// https://html.spec.whatwg.org/multipage/#dom-table-createtfoot
- fn create_section_of_type(&self, atom: &Atom) -> Root<HTMLTableSectionElement> {
+ fn create_section_of_type(&self, atom: &LocalName) -> Root<HTMLTableSectionElement> {
if let Some(section) = self.get_first_section_of_type(atom) {
return section
}
@@ -119,8 +119,8 @@ impl HTMLTableElement {
None,
&document_from_node(self));
match atom {
- &atom!("thead") => self.SetTHead(Some(&section)),
- &atom!("tfoot") => self.SetTFoot(Some(&section)),
+ &local_name!("thead") => self.SetTHead(Some(&section)),
+ &local_name!("tfoot") => self.SetTFoot(Some(&section)),
_ => unreachable!("unexpected section type")
}.expect("unexpected section type");
@@ -129,7 +129,7 @@ impl HTMLTableElement {
// https://html.spec.whatwg.org/multipage/#dom-table-deletethead
// https://html.spec.whatwg.org/multipage/#dom-table-deletetfoot
- fn delete_first_section_of_type(&self, atom: &Atom) {
+ fn delete_first_section_of_type(&self, atom: &LocalName) {
if let Some(thead) = self.get_first_section_of_type(atom) {
thead.upcast::<Node>().remove_self();
}
@@ -176,7 +176,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
match self.GetCaption() {
Some(caption) => caption,
None => {
- let caption = HTMLTableCaptionElement::new(atom!("caption"),
+ let caption = HTMLTableCaptionElement::new(local_name!("caption"),
None,
&document_from_node(self));
self.SetCaption(Some(&caption));
@@ -195,41 +195,41 @@ impl HTMLTableElementMethods for HTMLTableElement {
// https://html.spec.whatwg.org/multipage/#dom-table-thead
fn GetTHead(&self) -> Option<Root<HTMLTableSectionElement>> {
- self.get_first_section_of_type(&atom!("thead"))
+ self.get_first_section_of_type(&local_name!("thead"))
}
// https://html.spec.whatwg.org/multipage/#dom-table-thead
fn SetTHead(&self, thead: Option<&HTMLTableSectionElement>) -> ErrorResult {
- self.set_first_section_of_type(&atom!("thead"), thead, |n| {
+ self.set_first_section_of_type(&local_name!("thead"), thead, |n| {
!n.is::<HTMLTableCaptionElement>() && !n.is::<HTMLTableColElement>()
})
}
// https://html.spec.whatwg.org/multipage/#dom-table-createthead
fn CreateTHead(&self) -> Root<HTMLTableSectionElement> {
- self.create_section_of_type(&atom!("thead"))
+ self.create_section_of_type(&local_name!("thead"))
}
// https://html.spec.whatwg.org/multipage/#dom-table-deletethead
fn DeleteTHead(&self) {
- self.delete_first_section_of_type(&atom!("thead"))
+ self.delete_first_section_of_type(&local_name!("thead"))
}
// https://html.spec.whatwg.org/multipage/#dom-table-tfoot
fn GetTFoot(&self) -> Option<Root<HTMLTableSectionElement>> {
- self.get_first_section_of_type(&atom!("tfoot"))
+ self.get_first_section_of_type(&local_name!("tfoot"))
}
// https://html.spec.whatwg.org/multipage/#dom-table-tfoot
fn SetTFoot(&self, tfoot: Option<&HTMLTableSectionElement>) -> ErrorResult {
- self.set_first_section_of_type(&atom!("tfoot"), tfoot, |n| {
+ self.set_first_section_of_type(&local_name!("tfoot"), tfoot, |n| {
if n.is::<HTMLTableCaptionElement>() || n.is::<HTMLTableColElement>() {
return false;
}
if n.is::<HTMLTableSectionElement>() {
let name = n.local_name();
- if name == &atom!("thead") || name == &atom!("tbody") {
+ if name == &local_name!("thead") || name == &local_name!("tbody") {
return false;
}
@@ -241,12 +241,12 @@ impl HTMLTableElementMethods for HTMLTableElement {
// https://html.spec.whatwg.org/multipage/#dom-table-createtfoot
fn CreateTFoot(&self) -> Root<HTMLTableSectionElement> {
- self.create_section_of_type(&atom!("tfoot"))
+ self.create_section_of_type(&local_name!("tfoot"))
}
// https://html.spec.whatwg.org/multipage/#dom-table-deletetfoot
fn DeleteTFoot(&self) {
- self.delete_first_section_of_type(&atom!("tfoot"))
+ self.delete_first_section_of_type(&local_name!("tfoot"))
}
// https://html.spec.whatwg.org/multipage/#dom-table-tbodies
@@ -256,7 +256,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
impl CollectionFilter for TBodiesFilter {
fn filter(&self, elem: &Element, root: &Node) -> bool {
elem.is::<HTMLTableSectionElement>() &&
- elem.local_name() == &atom!("tbody") &&
+ elem.local_name() == &local_name!("tbody") &&
elem.upcast::<Node>().GetParentNode().r() == Some(root)
}
}
@@ -271,14 +271,14 @@ impl HTMLTableElementMethods for HTMLTableElement {
// https://html.spec.whatwg.org/multipage/#dom-table-createtbody
fn CreateTBody(&self) -> Root<HTMLTableSectionElement> {
- let tbody = HTMLTableSectionElement::new(atom!("tbody"),
+ let tbody = HTMLTableSectionElement::new(local_name!("tbody"),
None,
&document_from_node(self));
let node = self.upcast::<Node>();
let last_tbody =
node.rev_children()
.filter_map(Root::downcast::<Element>)
- .find(|n| n.is::<HTMLTableSectionElement>() && n.local_name() == &atom!("tbody"));
+ .find(|n| n.is::<HTMLTableSectionElement>() && n.local_name() == &local_name!("tbody"));
let reference_element =
last_tbody.and_then(|t| t.upcast::<Node>().GetNextSibling());
@@ -296,7 +296,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
return Err(Error::IndexSize);
}
- let new_row = HTMLTableRowElement::new(atom!("tr"),
+ let new_row = HTMLTableRowElement::new(local_name!("tr"),
None,
&document_from_node(self));
let node = self.upcast::<Node>();
@@ -305,7 +305,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
// append new row to last or new tbody in table
if let Some(last_tbody) = node.rev_children()
.filter_map(Root::downcast::<Element>)
- .find(|n| n.is::<HTMLTableSectionElement>() && n.local_name() == &atom!("tbody")) {
+ .find(|n| n.is::<HTMLTableSectionElement>() && n.local_name() == &local_name!("tbody")) {
last_tbody.upcast::<Node>().AppendChild(new_row.upcast::<Node>())
.expect("InsertRow failed to append first row.");
} else {
@@ -383,7 +383,7 @@ impl HTMLTableElementLayoutHelpers for LayoutJS<HTMLTableElement> {
fn get_background_color(&self) -> Option<RGBA> {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("bgcolor"))
+ .get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
.and_then(AttrValue::as_color)
.cloned()
}
@@ -407,7 +407,7 @@ impl HTMLTableElementLayoutHelpers for LayoutJS<HTMLTableElement> {
fn get_width(&self) -> LengthOrPercentageOrAuto {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("width"))
+ .get_attr_for_layout(&ns!(), &local_name!("width"))
.map(AttrValue::as_dimension)
.cloned()
.unwrap_or(LengthOrPercentageOrAuto::Auto)
@@ -423,13 +423,13 @@ impl VirtualMethods for HTMLTableElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match *attr.local_name() {
- atom!("border") => {
+ local_name!("border") => {
// According to HTML5 § 14.3.9, invalid values map to 1px.
self.border.set(mutation.new_value(attr).map(|value| {
parse_unsigned_integer(value.chars()).unwrap_or(1)
}));
}
- atom!("cellspacing") => {
+ local_name!("cellspacing") => {
self.cellspacing.set(mutation.new_value(attr).and_then(|value| {
parse_unsigned_integer(value.chars()).ok()
}));
@@ -438,11 +438,11 @@ impl VirtualMethods for HTMLTableElement {
}
}
- fn parse_plain_attribute(&self, local_name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, local_name: &LocalName, value: DOMString) -> AttrValue {
match *local_name {
- atom!("border") => AttrValue::from_u32(value.into(), 1),
- atom!("width") => AttrValue::from_nonzero_dimension(value.into()),
- atom!("bgcolor") => AttrValue::from_legacy_color(value.into()),
+ local_name!("border") => AttrValue::from_u32(value.into(), 1),
+ local_name!("width") => AttrValue::from_nonzero_dimension(value.into()),
+ local_name!("bgcolor") => AttrValue::from_legacy_color(value.into()),
_ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
}
}
diff --git a/components/script/dom/htmltableheadercellelement.rs b/components/script/dom/htmltableheadercellelement.rs
index 9e0247f0f1b..c24c68479c8 100644
--- a/components/script/dom/htmltableheadercellelement.rs
+++ b/components/script/dom/htmltableheadercellelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmltablecellelement::HTMLTableCellElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLTableHeaderCellElement {
@@ -16,7 +16,7 @@ pub struct HTMLTableHeaderCellElement {
}
impl HTMLTableHeaderCellElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLTableHeaderCellElement {
HTMLTableHeaderCellElement {
@@ -26,7 +26,7 @@ impl HTMLTableHeaderCellElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLTableHeaderCellElement> {
Node::reflect_node(box HTMLTableHeaderCellElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmltablerowelement.rs b/components/script/dom/htmltablerowelement.rs
index 7a7273c3597..b95aba1c3e0 100644
--- a/components/script/dom/htmltablerowelement.rs
+++ b/components/script/dom/htmltablerowelement.rs
@@ -21,7 +21,7 @@ use dom::htmltableheadercellelement::HTMLTableHeaderCellElement;
use dom::htmltablesectionelement::HTMLTableSectionElement;
use dom::node::{Node, window_from_node};
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
use style::attr::AttrValue;
#[derive(JSTraceable)]
@@ -40,7 +40,7 @@ pub struct HTMLTableRowElement {
}
impl HTMLTableRowElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document)
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document)
-> HTMLTableRowElement {
HTMLTableRowElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
@@ -49,7 +49,7 @@ impl HTMLTableRowElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom, prefix: Option<DOMString>, document: &Document)
+ pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document)
-> Root<HTMLTableRowElement> {
Node::reflect_node(box HTMLTableRowElement::new_inherited(local_name, prefix, document),
document,
@@ -87,7 +87,7 @@ impl HTMLTableRowElementMethods for HTMLTableRowElement {
node.insert_cell_or_row(
index,
|| self.Cells(),
- || HTMLTableDataCellElement::new(atom!("td"), None, &node.owner_doc()))
+ || HTMLTableDataCellElement::new(local_name!("td"), None, &node.owner_doc()))
}
// https://html.spec.whatwg.org/multipage/#dom-tr-deletecell
@@ -145,7 +145,7 @@ impl HTMLTableRowElementLayoutHelpers for LayoutJS<HTMLTableRowElement> {
fn get_background_color(&self) -> Option<RGBA> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("bgcolor"))
+ .get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
.and_then(AttrValue::as_color)
.cloned()
}
@@ -157,9 +157,9 @@ impl VirtualMethods for HTMLTableRowElement {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
- fn parse_plain_attribute(&self, local_name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, local_name: &LocalName, value: DOMString) -> AttrValue {
match *local_name {
- atom!("bgcolor") => AttrValue::from_legacy_color(value.into()),
+ local_name!("bgcolor") => AttrValue::from_legacy_color(value.into()),
_ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
}
}
diff --git a/components/script/dom/htmltablesectionelement.rs b/components/script/dom/htmltablesectionelement.rs
index a64ae3fa35c..2f5fcaca566 100644
--- a/components/script/dom/htmltablesectionelement.rs
+++ b/components/script/dom/htmltablesectionelement.rs
@@ -16,7 +16,7 @@ use dom::htmlelement::HTMLElement;
use dom::htmltablerowelement::HTMLTableRowElement;
use dom::node::{Node, window_from_node};
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
use style::attr::AttrValue;
#[dom_struct]
@@ -25,7 +25,7 @@ pub struct HTMLTableSectionElement {
}
impl HTMLTableSectionElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document)
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document)
-> HTMLTableSectionElement {
HTMLTableSectionElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
@@ -33,7 +33,7 @@ impl HTMLTableSectionElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom, prefix: Option<DOMString>, document: &Document)
+ pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document)
-> Root<HTMLTableSectionElement> {
Node::reflect_node(box HTMLTableSectionElement::new_inherited(local_name, prefix, document),
document,
@@ -62,7 +62,7 @@ impl HTMLTableSectionElementMethods for HTMLTableSectionElement {
node.insert_cell_or_row(
index,
|| self.Rows(),
- || HTMLTableRowElement::new(atom!("tr"), None, &node.owner_doc()))
+ || HTMLTableRowElement::new(local_name!("tr"), None, &node.owner_doc()))
}
// https://html.spec.whatwg.org/multipage/#dom-tbody-deleterow
@@ -84,7 +84,7 @@ impl HTMLTableSectionElementLayoutHelpers for LayoutJS<HTMLTableSectionElement>
fn get_background_color(&self) -> Option<RGBA> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("bgcolor"))
+ .get_attr_for_layout(&ns!(), &local_name!("bgcolor"))
.and_then(AttrValue::as_color)
.cloned()
}
@@ -96,9 +96,9 @@ impl VirtualMethods for HTMLTableSectionElement {
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
- fn parse_plain_attribute(&self, local_name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, local_name: &LocalName, value: DOMString) -> AttrValue {
match *local_name {
- atom!("bgcolor") => AttrValue::from_legacy_color(value.into()),
+ local_name!("bgcolor") => AttrValue::from_legacy_color(value.into()),
_ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
}
}
diff --git a/components/script/dom/htmltemplateelement.rs b/components/script/dom/htmltemplateelement.rs
index bf659987620..7ee8d03b163 100644
--- a/components/script/dom/htmltemplateelement.rs
+++ b/components/script/dom/htmltemplateelement.rs
@@ -14,7 +14,7 @@ use dom::documentfragment::DocumentFragment;
use dom::htmlelement::HTMLElement;
use dom::node::{CloneChildrenFlag, Node, document_from_node};
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLTemplateElement {
@@ -25,7 +25,7 @@ pub struct HTMLTemplateElement {
}
impl HTMLTemplateElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLTemplateElement {
HTMLTemplateElement {
@@ -36,7 +36,7 @@ impl HTMLTemplateElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLTemplateElement> {
Node::reflect_node(box HTMLTemplateElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs
index 7023b47c31b..268998c8e58 100644
--- a/components/script/dom/htmltextareaelement.rs
+++ b/components/script/dom/htmltextareaelement.rs
@@ -25,11 +25,11 @@ use dom::node::{document_from_node, window_from_node};
use dom::nodelist::NodeList;
use dom::validation::Validatable;
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use ipc_channel::ipc::IpcSender;
use script_traits::ScriptMsg as ConstellationMsg;
use std::cell::Cell;
use std::ops::Range;
-use string_cache::Atom;
use style::attr::AttrValue;
use style::element_state::*;
use textinput::{KeyReaction, Lines, SelectionDirection, TextInput};
@@ -75,7 +75,7 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
fn get_cols(self) -> u32 {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("cols"))
+ .get_attr_for_layout(&ns!(), &local_name!("cols"))
.map_or(DEFAULT_COLS, AttrValue::as_uint)
}
}
@@ -84,7 +84,7 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
fn get_rows(self) -> u32 {
unsafe {
(*self.upcast::<Element>().unsafe_get())
- .get_attr_for_layout(&ns!(), &atom!("rows"))
+ .get_attr_for_layout(&ns!(), &local_name!("rows"))
.map_or(DEFAULT_ROWS, AttrValue::as_uint)
}
}
@@ -97,7 +97,7 @@ static DEFAULT_COLS: u32 = 20;
static DEFAULT_ROWS: u32 = 2;
impl HTMLTextAreaElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLTextAreaElement {
let chan = document.window().upcast::<GlobalScope>().constellation_chan().clone();
@@ -112,7 +112,7 @@ impl HTMLTextAreaElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLTextAreaElement> {
Node::reflect_node(box HTMLTextAreaElement::new_inherited(local_name, prefix, document),
@@ -291,7 +291,7 @@ impl VirtualMethods for HTMLTextAreaElement {
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
self.super_type().unwrap().attribute_mutated(attr, mutation);
match *attr.local_name() {
- atom!("disabled") => {
+ local_name!("disabled") => {
let el = self.upcast::<Element>();
match mutation {
AttributeMutation::Set(_) => {
@@ -311,7 +311,7 @@ impl VirtualMethods for HTMLTextAreaElement {
}
}
},
- atom!("readonly") => {
+ local_name!("readonly") => {
let el = self.upcast::<Element>();
match mutation {
AttributeMutation::Set(_) => {
@@ -334,10 +334,10 @@ impl VirtualMethods for HTMLTextAreaElement {
self.upcast::<Element>().check_ancestors_disabled_state_for_form_control();
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match *name {
- atom!("cols") => AttrValue::from_limited_u32(value.into(), DEFAULT_COLS),
- atom!("rows") => AttrValue::from_limited_u32(value.into(), DEFAULT_ROWS),
+ local_name!("cols") => AttrValue::from_limited_u32(value.into(), DEFAULT_COLS),
+ local_name!("rows") => AttrValue::from_limited_u32(value.into(), DEFAULT_ROWS),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
diff --git a/components/script/dom/htmltimeelement.rs b/components/script/dom/htmltimeelement.rs
index 8ba41e25a2b..e7d9e049baa 100644
--- a/components/script/dom/htmltimeelement.rs
+++ b/components/script/dom/htmltimeelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLTimeElement {
@@ -16,14 +16,14 @@ pub struct HTMLTimeElement {
}
impl HTMLTimeElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLTimeElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLTimeElement {
HTMLTimeElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
}
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLTimeElement> {
Node::reflect_node(box HTMLTimeElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmltitleelement.rs b/components/script/dom/htmltitleelement.rs
index 49994c4bcb8..c124a4a3604 100644
--- a/components/script/dom/htmltitleelement.rs
+++ b/components/script/dom/htmltitleelement.rs
@@ -14,7 +14,7 @@ use dom::htmlelement::HTMLElement;
use dom::node::{ChildrenMutation, Node};
use dom::text::Text;
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLTitleElement {
@@ -22,14 +22,14 @@ pub struct HTMLTitleElement {
}
impl HTMLTitleElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLTitleElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLTitleElement {
HTMLTitleElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
}
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLTitleElement> {
Node::reflect_node(box HTMLTitleElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmltrackelement.rs b/components/script/dom/htmltrackelement.rs
index ae96aae3306..4c4263aa949 100644
--- a/components/script/dom/htmltrackelement.rs
+++ b/components/script/dom/htmltrackelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLTrackElement {
@@ -16,14 +16,14 @@ pub struct HTMLTrackElement {
}
impl HTMLTrackElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLTrackElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLTrackElement {
HTMLTrackElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
}
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLTrackElement> {
Node::reflect_node(box HTMLTrackElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlulistelement.rs b/components/script/dom/htmlulistelement.rs
index b5da24728fc..211b77bb8b6 100644
--- a/components/script/dom/htmlulistelement.rs
+++ b/components/script/dom/htmlulistelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLUListElement {
@@ -16,14 +16,14 @@ pub struct HTMLUListElement {
}
impl HTMLUListElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLUListElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLUListElement {
HTMLUListElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
}
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLUListElement> {
Node::reflect_node(box HTMLUListElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlunknownelement.rs b/components/script/dom/htmlunknownelement.rs
index 4ae99cfae58..22930a32d78 100644
--- a/components/script/dom/htmlunknownelement.rs
+++ b/components/script/dom/htmlunknownelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLUnknownElement {
@@ -16,7 +16,7 @@ pub struct HTMLUnknownElement {
}
impl HTMLUnknownElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLUnknownElement {
HTMLUnknownElement {
@@ -26,7 +26,7 @@ impl HTMLUnknownElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLUnknownElement> {
Node::reflect_node(box HTMLUnknownElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/htmlvideoelement.rs b/components/script/dom/htmlvideoelement.rs
index d9635538e9b..940888c3466 100644
--- a/components/script/dom/htmlvideoelement.rs
+++ b/components/script/dom/htmlvideoelement.rs
@@ -8,7 +8,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlmediaelement::HTMLMediaElement;
use dom::node::Node;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLVideoElement {
@@ -16,7 +16,7 @@ pub struct HTMLVideoElement {
}
impl HTMLVideoElement {
- fn new_inherited(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> HTMLVideoElement {
+ fn new_inherited(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLVideoElement {
HTMLVideoElement {
htmlmediaelement:
HTMLMediaElement::new_inherited(local_name, prefix, document)
@@ -24,7 +24,7 @@ impl HTMLVideoElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLVideoElement> {
Node::reflect_node(box HTMLVideoElement::new_inherited(local_name, prefix, document),
diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs
index 2fa6a87b980..82800be2ff2 100644
--- a/components/script/dom/macros.rs
+++ b/components/script/dom/macros.rs
@@ -9,7 +9,7 @@ macro_rules! make_getter(
use dom::bindings::inheritance::Castable;
use dom::element::Element;
let element = self.upcast::<Element>();
- element.get_string_attribute(&atom!($htmlname))
+ element.get_string_attribute(&local_name!($htmlname))
}
);
);
@@ -21,7 +21,7 @@ macro_rules! make_bool_getter(
use dom::bindings::inheritance::Castable;
use dom::element::Element;
let element = self.upcast::<Element>();
- element.has_attribute(&atom!($htmlname))
+ element.has_attribute(&local_name!($htmlname))
}
);
);
@@ -40,7 +40,7 @@ macro_rules! make_limited_int_setter(
};
let element = self.upcast::<Element>();
- element.set_int_attribute(&atom!($htmlname), value);
+ element.set_int_attribute(&local_name!($htmlname), value);
Ok(())
}
);
@@ -54,7 +54,7 @@ macro_rules! make_int_setter(
use dom::element::Element;
let element = self.upcast::<Element>();
- element.set_int_attribute(&atom!($htmlname), value)
+ element.set_int_attribute(&local_name!($htmlname), value)
}
);
($attr:ident, $htmlname:tt) => {
@@ -69,7 +69,7 @@ macro_rules! make_int_getter(
use dom::bindings::inheritance::Castable;
use dom::element::Element;
let element = self.upcast::<Element>();
- element.get_int_attribute(&atom!($htmlname), $default)
+ element.get_int_attribute(&local_name!($htmlname), $default)
}
);
@@ -85,7 +85,7 @@ macro_rules! make_uint_getter(
use dom::bindings::inheritance::Castable;
use dom::element::Element;
let element = self.upcast::<Element>();
- element.get_uint_attribute(&atom!($htmlname), $default)
+ element.get_uint_attribute(&local_name!($htmlname), $default)
}
);
($attr:ident, $htmlname:tt) => {
@@ -100,7 +100,7 @@ macro_rules! make_url_getter(
use dom::bindings::inheritance::Castable;
use dom::element::Element;
let element = self.upcast::<Element>();
- element.get_url_attribute(&atom!($htmlname))
+ element.get_url_attribute(&local_name!($htmlname))
}
);
);
@@ -112,7 +112,7 @@ macro_rules! make_url_or_base_getter(
use dom::bindings::inheritance::Castable;
use dom::element::Element;
let element = self.upcast::<Element>();
- let url = element.get_url_attribute(&atom!($htmlname));
+ let url = element.get_url_attribute(&local_name!($htmlname));
if url.is_empty() {
let window = window_from_node(self);
DOMString::from(window.get_url().into_string())
@@ -131,7 +131,7 @@ macro_rules! make_string_or_document_url_getter(
use dom::element::Element;
use dom::node::document_from_node;
let element = self.upcast::<Element>();
- let val = element.get_string_attribute(&atom!($htmlname));
+ let val = element.get_string_attribute(&local_name!($htmlname));
if val.is_empty() {
let doc = document_from_node(self);
@@ -151,7 +151,7 @@ macro_rules! make_enumerated_getter(
use dom::element::Element;
use std::ascii::AsciiExt;
let element = self.upcast::<Element>();
- let mut val = element.get_string_attribute(&atom!($htmlname));
+ let mut val = element.get_string_attribute(&local_name!($htmlname));
val.make_ascii_lowercase();
// https://html.spec.whatwg.org/multipage/#attr-fs-method
match &*val {
@@ -171,7 +171,7 @@ macro_rules! make_setter(
use dom::bindings::inheritance::Castable;
use dom::element::Element;
let element = self.upcast::<Element>();
- element.set_string_attribute(&atom!($htmlname), value)
+ element.set_string_attribute(&local_name!($htmlname), value)
}
);
);
@@ -183,7 +183,7 @@ macro_rules! make_bool_setter(
use dom::bindings::inheritance::Castable;
use dom::element::Element;
let element = self.upcast::<Element>();
- element.set_bool_attribute(&atom!($htmlname), value)
+ element.set_bool_attribute(&local_name!($htmlname), value)
}
);
);
@@ -198,7 +198,7 @@ macro_rules! make_url_setter(
let value = AttrValue::from_url(document_from_node(self).url(),
value.into());
let element = self.upcast::<Element>();
- element.set_attribute(&atom!($htmlname), value);
+ element.set_attribute(&local_name!($htmlname), value);
}
);
);
@@ -216,7 +216,7 @@ macro_rules! make_uint_setter(
value
};
let element = self.upcast::<Element>();
- element.set_uint_attribute(&atom!($htmlname), value)
+ element.set_uint_attribute(&local_name!($htmlname), value)
}
);
($attr:ident, $htmlname:tt) => {
@@ -239,7 +239,7 @@ macro_rules! make_limited_uint_setter(
value
};
let element = self.upcast::<Element>();
- element.set_uint_attribute(&atom!($htmlname), value);
+ element.set_uint_attribute(&local_name!($htmlname), value);
Ok(())
}
);
@@ -255,7 +255,7 @@ macro_rules! make_atomic_setter(
use dom::bindings::inheritance::Castable;
use dom::element::Element;
let element = self.upcast::<Element>();
- element.set_atomic_attribute(&atom!($htmlname), value)
+ element.set_atomic_attribute(&local_name!($htmlname), value)
}
);
);
@@ -269,7 +269,7 @@ macro_rules! make_legacy_color_setter(
use style::attr::AttrValue;
let element = self.upcast::<Element>();
let value = AttrValue::from_legacy_color(value.into());
- element.set_attribute(&atom!($htmlname), value)
+ element.set_attribute(&local_name!($htmlname), value)
}
);
);
@@ -282,7 +282,7 @@ macro_rules! make_dimension_setter(
use dom::element::Element;
let element = self.upcast::<Element>();
let value = AttrValue::from_dimension(value.into());
- element.set_attribute(&atom!($htmlname), value)
+ element.set_attribute(&local_name!($htmlname), value)
}
);
);
@@ -295,7 +295,7 @@ macro_rules! make_nonzero_dimension_setter(
use dom::element::Element;
let element = self.upcast::<Element>();
let value = AttrValue::from_nonzero_dimension(value.into());
- element.set_attribute(&atom!($htmlname), value)
+ element.set_attribute(&local_name!($htmlname), value)
}
);
);
diff --git a/components/script/dom/messageevent.rs b/components/script/dom/messageevent.rs
index 53143711cf0..f3d2aa79ba4 100644
--- a/components/script/dom/messageevent.rs
+++ b/components/script/dom/messageevent.rs
@@ -15,8 +15,8 @@ use dom::eventtarget::EventTarget;
use dom::globalscope::GlobalScope;
use js::jsapi::{HandleValue, Heap, JSContext};
use js::jsval::JSVal;
+use servo_atoms::Atom;
use std::default::Default;
-use string_cache::Atom;
#[dom_struct]
pub struct MessageEvent {
diff --git a/components/script/dom/namednodemap.rs b/components/script/dom/namednodemap.rs
index 1145ff60562..148822cabb2 100644
--- a/components/script/dom/namednodemap.rs
+++ b/components/script/dom/namednodemap.rs
@@ -13,8 +13,8 @@ use dom::bindings::str::DOMString;
use dom::bindings::xmlname::namespace_from_domstring;
use dom::element::Element;
use dom::window::Window;
+use html5ever_atoms::LocalName;
use std::ascii::AsciiExt;
-use string_cache::Atom;
#[dom_struct]
pub struct NamedNodeMap {
@@ -56,7 +56,7 @@ impl NamedNodeMapMethods for NamedNodeMap {
fn GetNamedItemNS(&self, namespace: Option<DOMString>, local_name: DOMString)
-> Option<Root<Attr>> {
let ns = namespace_from_domstring(namespace);
- self.owner.get_attribute(&ns, &Atom::from(local_name))
+ self.owner.get_attribute(&ns, &LocalName::from(local_name))
}
// https://dom.spec.whatwg.org/#dom-namednodemap-setnameditem
@@ -79,7 +79,7 @@ impl NamedNodeMapMethods for NamedNodeMap {
fn RemoveNamedItemNS(&self, namespace: Option<DOMString>, local_name: DOMString)
-> Fallible<Root<Attr>> {
let ns = namespace_from_domstring(namespace);
- self.owner.remove_attribute(&ns, &Atom::from(local_name))
+ self.owner.remove_attribute(&ns, &LocalName::from(local_name))
.ok_or(Error::NotFound)
}
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 767a3132eb3..4ec6c878ad5 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -57,6 +57,7 @@ use euclid::rect::Rect;
use euclid::size::Size2D;
use heapsize::{HeapSizeOf, heap_size_of};
use html5ever::tree_builder::QuirksMode;
+use html5ever_atoms::{Prefix, LocalName, Namespace, QualName};
use js::jsapi::{JSContext, JSObject, JSRuntime};
use libc::{self, c_void, uintptr_t};
use msg::constellation_msg::PipelineId;
@@ -75,7 +76,6 @@ use std::default::Default;
use std::iter;
use std::mem;
use std::ops::Range;
-use string_cache::{Atom, Namespace, QualName};
use style::dom::OpaqueNode;
use style::selector_impl::ServoSelectorImpl;
use style::thread_state;
@@ -1752,7 +1752,7 @@ impl Node {
local: element.local_name().clone()
};
let element = Element::create(name,
- element.prefix().as_ref().map(|p| Atom::from(&**p)),
+ element.prefix().as_ref().map(|p| Prefix::from(&**p)),
&document, ElementCreator::ScriptCreated);
Root::upcast::<Node>(element)
},
@@ -1818,21 +1818,21 @@ impl Node {
pub fn namespace_to_string(namespace: Namespace) -> Option<DOMString> {
match namespace {
ns!() => None,
- // FIXME(ajeffrey): convert directly from &Atom to DOMString
- Namespace(ref ns) => Some(DOMString::from(&**ns))
+ // FIXME(ajeffrey): convert directly from Namespace to DOMString
+ _ => Some(DOMString::from(&*namespace))
}
}
// https://dom.spec.whatwg.org/#locate-a-namespace
pub fn locate_namespace(node: &Node, prefix: Option<DOMString>) -> Namespace {
fn attr_defines_namespace(attr: &Attr,
- prefix: &Option<Atom>) -> bool {
+ defined_prefix: &Option<LocalName>) -> bool {
*attr.namespace() == ns!(xmlns) &&
- match (attr.prefix(), prefix) {
- (&Some(ref attr_prefix), &Some(ref prefix)) =>
- attr_prefix == &atom!("xmlns") &&
- attr.local_name() == prefix,
- (&None, &None) => *attr.local_name() == atom!("xmlns"),
+ match (attr.prefix(), defined_prefix) {
+ (&Some(ref attr_prefix), &Some(ref defined_prefix)) =>
+ attr_prefix == &namespace_prefix!("xmlns") &&
+ attr.local_name() == defined_prefix,
+ (&None, &None) => *attr.local_name() == local_name!("xmlns"),
_ => false
}
}
@@ -1845,8 +1845,11 @@ impl Node {
return element.namespace().clone()
}
- // FIXME(ajeffrey): directly convert DOMString to Atom
- let prefix_atom = prefix.as_ref().map(|s| Atom::from(&**s));
+ // Even though this is conceptually a namespace prefix,
+ // in the `xmlns:foo="https://example.net/namespace" declaration
+ // it is a local name.
+ // FIXME(ajeffrey): directly convert DOMString to LocalName
+ let prefix_atom = prefix.as_ref().map(|s| LocalName::from(&**s));
// Step 2.
let attrs = element.attrs();
diff --git a/components/script/dom/pagetransitionevent.rs b/components/script/dom/pagetransitionevent.rs
index 883f3319394..b40f6c1ab39 100644
--- a/components/script/dom/pagetransitionevent.rs
+++ b/components/script/dom/pagetransitionevent.rs
@@ -12,8 +12,8 @@ use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::str::DOMString;
use dom::event::Event;
use dom::globalscope::GlobalScope;
+use servo_atoms::Atom;
use std::cell::Cell;
-use string_cache::Atom;
// https://html.spec.whatwg.org/multipage/#pagetransitionevent
#[dom_struct]
diff --git a/components/script/dom/popstateevent.rs b/components/script/dom/popstateevent.rs
index 7b7af62a6fe..153c30531fe 100644
--- a/components/script/dom/popstateevent.rs
+++ b/components/script/dom/popstateevent.rs
@@ -14,7 +14,7 @@ use dom::event::Event;
use dom::globalscope::GlobalScope;
use js::jsapi::{HandleValue, JSContext};
use js::jsval::JSVal;
-use string_cache::Atom;
+use servo_atoms::Atom;
// https://html.spec.whatwg.org/multipage/#the-popstateevent-interface
#[dom_struct]
diff --git a/components/script/dom/progressevent.rs b/components/script/dom/progressevent.rs
index 189f65412fe..b8d3d5ba9f7 100644
--- a/components/script/dom/progressevent.rs
+++ b/components/script/dom/progressevent.rs
@@ -12,7 +12,7 @@ use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::str::DOMString;
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::globalscope::GlobalScope;
-use string_cache::Atom;
+use servo_atoms::Atom;
#[dom_struct]
pub struct ProgressEvent {
diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs
index 08b5842dbff..c0709f17c7c 100644
--- a/components/script/dom/range.rs
+++ b/components/script/dom/range.rs
@@ -913,10 +913,10 @@ impl RangeMethods for Range {
// Step 2.
let should_create_body = element.as_ref().map_or(true, |elem| {
let elem = elem.downcast::<Element>().unwrap();
- elem.local_name() == &atom!("html") && elem.html_element_in_html_document()
+ elem.local_name() == &local_name!("html") && elem.html_element_in_html_document()
});
let element: Root<Node> = if should_create_body {
- Root::upcast(HTMLBodyElement::new(atom!("body"), None, &self.StartContainer().owner_doc()))
+ Root::upcast(HTMLBodyElement::new(local_name!("body"), None, &self.StartContainer().owner_doc()))
} else {
Root::upcast(element.unwrap())
};
diff --git a/components/script/dom/servoparser/html.rs b/components/script/dom/servoparser/html.rs
index 91e4277f4c3..fd4a5a923b9 100644
--- a/components/script/dom/servoparser/html.rs
+++ b/components/script/dom/servoparser/html.rs
@@ -32,10 +32,10 @@ use html5ever::tendril::StrTendril;
use html5ever::tokenizer::{Tokenizer as H5ETokenizer, TokenizerOpts};
use html5ever::tree_builder::{NextParserState, NodeOrText, QuirksMode};
use html5ever::tree_builder::{TreeBuilder, TreeBuilderOpts, TreeSink};
+use html5ever_atoms::QualName;
use msg::constellation_msg::PipelineId;
use std::borrow::Cow;
use std::io::{self, Write};
-use string_cache::QualName;
use super::{HtmlTokenizer, LastChunkState, ServoParser, Sink, Tokenizer};
use url::Url;
diff --git a/components/script/dom/servoparser/mod.rs b/components/script/dom/servoparser/mod.rs
index b11dd46477c..4df82a457a7 100644
--- a/components/script/dom/servoparser/mod.rs
+++ b/components/script/dom/servoparser/mod.rs
@@ -406,7 +406,7 @@ impl FetchResponseListener for ParserContext {
let doc = parser.document();
let doc_body = Root::upcast::<Node>(doc.GetBody().unwrap());
- let img = HTMLImageElement::new(atom!("img"), None, doc);
+ let img = HTMLImageElement::new(local_name!("img"), None, doc);
img.SetSrc(DOMString::from(self.url.to_string()));
doc_body.AppendChild(&Root::upcast::<Node>(img)).expect("Appending failed");
diff --git a/components/script/dom/servoparser/xml.rs b/components/script/dom/servoparser/xml.rs
index e37feb43da7..879bb9320d6 100644
--- a/components/script/dom/servoparser/xml.rs
+++ b/components/script/dom/servoparser/xml.rs
@@ -17,9 +17,9 @@ use dom::node::Node;
use dom::processinginstruction::ProcessingInstruction;
use dom::text::Text;
use html5ever;
+use html5ever_atoms::{Prefix, QualName};
use msg::constellation_msg::PipelineId;
use std::borrow::Cow;
-use string_cache::{Atom, QualName, Namespace};
use super::{LastChunkState, ServoParser, Sink, Tokenizer};
use url::Url;
use xml5ever::tendril::StrTendril;
@@ -41,17 +41,17 @@ impl<'a> TreeSink for Sink {
let elem = target.downcast::<Element>()
.expect("tried to get name of non-Element in XML parsing");
QName {
- prefix: elem.prefix().as_ref().map_or(atom!(""), |p| Atom::from(&**p)),
- namespace_url: elem.namespace().0.clone(),
+ prefix: elem.prefix().as_ref().map_or(namespace_prefix!(""), |p| Prefix::from(&**p)),
+ namespace_url: elem.namespace().clone(),
local: elem.local_name().clone(),
}
}
fn create_element(&mut self, name: QName, attrs: Vec<Attribute>)
-> JS<Node> {
- let prefix = if name.prefix == atom!("") { None } else { Some(name.prefix) };
+ let prefix = if name.prefix == namespace_prefix!("") { None } else { Some(name.prefix) };
let name = QualName {
- ns: Namespace(name.namespace_url),
+ ns: name.namespace_url,
local: name.local,
};
let elem = Element::create(name, prefix, &*self.document,
@@ -59,7 +59,7 @@ impl<'a> TreeSink for Sink {
for attr in attrs {
let name = QualName {
- ns: Namespace(attr.name.namespace_url),
+ ns: attr.name.namespace_url,
local: attr.name.local,
};
elem.set_attribute_from_parser(name, DOMString::from(String::from(attr.value)), None);
diff --git a/components/script/dom/storageevent.rs b/components/script/dom/storageevent.rs
index 21c16f1db78..172a7be9ed8 100644
--- a/components/script/dom/storageevent.rs
+++ b/components/script/dom/storageevent.rs
@@ -14,7 +14,7 @@ use dom::event::{Event, EventBubbles, EventCancelable};
use dom::globalscope::GlobalScope;
use dom::storage::Storage;
use dom::window::Window;
-use string_cache::Atom;
+use servo_atoms::Atom;
#[dom_struct]
pub struct StorageEvent {
diff --git a/components/script/dom/svgelement.rs b/components/script/dom/svgelement.rs
index 95fd42c40b6..c89bab166ee 100644
--- a/components/script/dom/svgelement.rs
+++ b/components/script/dom/svgelement.rs
@@ -10,7 +10,7 @@ use dom::document::Document;
use dom::element::Element;
use dom::node::Node;
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
use style::element_state::ElementState;
#[dom_struct]
@@ -19,12 +19,12 @@ pub struct SVGElement {
}
impl SVGElement {
- pub fn new_inherited(tag_name: Atom, prefix: Option<DOMString>,
+ pub fn new_inherited(tag_name: LocalName, prefix: Option<DOMString>,
document: &Document) -> SVGElement {
SVGElement::new_inherited_with_state(ElementState::empty(), tag_name, prefix, document)
}
- pub fn new_inherited_with_state(state: ElementState, tag_name: Atom,
+ pub fn new_inherited_with_state(state: ElementState, tag_name: LocalName,
prefix: Option<DOMString>, document: &Document)
-> SVGElement {
SVGElement {
@@ -34,7 +34,7 @@ impl SVGElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> Root<SVGElement> {
+ pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> Root<SVGElement> {
Node::reflect_node(box SVGElement::new_inherited(local_name, prefix, document),
document,
SVGElementBinding::Wrap)
diff --git a/components/script/dom/svggraphicselement.rs b/components/script/dom/svggraphicselement.rs
index bd7c8d581f7..9435cc6d6b7 100644
--- a/components/script/dom/svggraphicselement.rs
+++ b/components/script/dom/svggraphicselement.rs
@@ -10,7 +10,7 @@ use dom::document::Document;
use dom::node::Node;
use dom::svgelement::SVGElement;
use dom::virtualmethods::VirtualMethods;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
use style::element_state::ElementState;
#[dom_struct]
@@ -19,12 +19,12 @@ pub struct SVGGraphicsElement {
}
impl SVGGraphicsElement {
- pub fn new_inherited(tag_name: Atom, prefix: Option<DOMString>,
+ pub fn new_inherited(tag_name: LocalName, prefix: Option<DOMString>,
document: &Document) -> SVGGraphicsElement {
SVGGraphicsElement::new_inherited_with_state(ElementState::empty(), tag_name, prefix, document)
}
- pub fn new_inherited_with_state(state: ElementState, tag_name: Atom,
+ pub fn new_inherited_with_state(state: ElementState, tag_name: LocalName,
prefix: Option<DOMString>, document: &Document)
-> SVGGraphicsElement {
SVGGraphicsElement {
@@ -34,7 +34,7 @@ impl SVGGraphicsElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom, prefix: Option<DOMString>, document: &Document) -> Root<SVGGraphicsElement> {
+ pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> Root<SVGGraphicsElement> {
Node::reflect_node(box SVGGraphicsElement::new_inherited(local_name, prefix, document),
document,
SVGGraphicsElementBinding::Wrap)
diff --git a/components/script/dom/svgsvgelement.rs b/components/script/dom/svgsvgelement.rs
index 11c1e35b9e9..e872fc25c8e 100644
--- a/components/script/dom/svgsvgelement.rs
+++ b/components/script/dom/svgsvgelement.rs
@@ -12,8 +12,8 @@ use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
use dom::node::Node;
use dom::svggraphicselement::SVGGraphicsElement;
use dom::virtualmethods::VirtualMethods;
+use html5ever_atoms::LocalName;
use script_layout_interface::SVGSVGData;
-use string_cache::Atom;
use style::attr::AttrValue;
const DEFAULT_WIDTH: u32 = 300;
@@ -25,7 +25,7 @@ pub struct SVGSVGElement {
}
impl SVGSVGElement {
- fn new_inherited(local_name: Atom,
+ fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> SVGSVGElement {
SVGSVGElement {
@@ -35,7 +35,7 @@ impl SVGSVGElement {
}
#[allow(unrooted_must_root)]
- pub fn new(local_name: Atom,
+ pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<SVGSVGElement> {
Node::reflect_node(box SVGSVGElement::new_inherited(local_name, prefix, document),
@@ -54,8 +54,8 @@ impl LayoutSVGSVGElementHelpers for LayoutJS<SVGSVGElement> {
unsafe {
let SVG = &*self.unsafe_get();
- let width_attr = SVG.upcast::<Element>().get_attr_for_layout(&ns!(), &atom!("width"));
- let height_attr = SVG.upcast::<Element>().get_attr_for_layout(&ns!(), &atom!("height"));
+ let width_attr = SVG.upcast::<Element>().get_attr_for_layout(&ns!(), &local_name!("width"));
+ let height_attr = SVG.upcast::<Element>().get_attr_for_layout(&ns!(), &local_name!("height"));
SVGSVGData {
width: width_attr.map_or(DEFAULT_WIDTH, |val| val.as_uint()),
height: height_attr.map_or(DEFAULT_HEIGHT, |val| val.as_uint()),
@@ -73,10 +73,10 @@ impl VirtualMethods for SVGSVGElement {
self.super_type().unwrap().attribute_mutated(attr, mutation);
}
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match name {
- &atom!("width") => AttrValue::from_u32(value.into(), DEFAULT_WIDTH),
- &atom!("height") => AttrValue::from_u32(value.into(), DEFAULT_HEIGHT),
+ &local_name!("width") => AttrValue::from_u32(value.into(), DEFAULT_WIDTH),
+ &local_name!("height") => AttrValue::from_u32(value.into(), DEFAULT_HEIGHT),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}
diff --git a/components/script/dom/transitionevent.rs b/components/script/dom/transitionevent.rs
index fc454483f50..1f487cb38a5 100644
--- a/components/script/dom/transitionevent.rs
+++ b/components/script/dom/transitionevent.rs
@@ -13,7 +13,7 @@ use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::str::DOMString;
use dom::event::Event;
use dom::globalscope::GlobalScope;
-use string_cache::Atom;
+use servo_atoms::Atom;
#[dom_struct]
pub struct TransitionEvent {
diff --git a/components/script/dom/uievent.rs b/components/script/dom/uievent.rs
index 99e25b80902..08e1b0c912c 100644
--- a/components/script/dom/uievent.rs
+++ b/components/script/dom/uievent.rs
@@ -14,9 +14,9 @@ use dom::bindings::str::DOMString;
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::globalscope::GlobalScope;
use dom::window::Window;
+use servo_atoms::Atom;
use std::cell::Cell;
use std::default::Default;
-use string_cache::Atom;
// https://w3c.github.io/uievents/#interface-uievent
#[dom_struct]
diff --git a/components/script/dom/userscripts.rs b/components/script/dom/userscripts.rs
index a406041e3c4..a4051f44581 100644
--- a/components/script/dom/userscripts.rs
+++ b/components/script/dom/userscripts.rs
@@ -45,7 +45,7 @@ pub fn load_script(head: &HTMLHeadElement) {
_ => continue
};
let new_script = doc.CreateElement(DOMString::from("script")).unwrap();
- new_script.set_string_attribute(&atom!("src"), DOMString::from(name));
+ new_script.set_string_attribute(&local_name!("src"), DOMString::from(name));
node.InsertBefore(new_script.upcast(), first_child.r()).unwrap();
}
}
diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs
index c8a8a7436a4..e10e48e8ab8 100644
--- a/components/script/dom/virtualmethods.rs
+++ b/components/script/dom/virtualmethods.rs
@@ -50,7 +50,7 @@ use dom::htmltextareaelement::HTMLTextAreaElement;
use dom::htmltitleelement::HTMLTitleElement;
use dom::node::{ChildrenMutation, CloneChildrenFlag, Node, UnbindContext};
use dom::svgsvgelement::SVGSVGElement;
-use string_cache::Atom;
+use html5ever_atoms::LocalName;
use style::attr::AttrValue;
/// Trait to allow DOM nodes to opt-in to overriding (or adding to) common
@@ -71,7 +71,7 @@ pub trait VirtualMethods {
/// Returns the right AttrValue variant for the attribute with name `name`
/// on this element.
- fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
+ fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
match self.super_type() {
Some(ref s) => s.parse_plain_attribute(name, value),
_ => AttrValue::String(value.into()),
diff --git a/components/script/dom/webglcontextevent.rs b/components/script/dom/webglcontextevent.rs
index 079218ab3ae..c128515e81a 100644
--- a/components/script/dom/webglcontextevent.rs
+++ b/components/script/dom/webglcontextevent.rs
@@ -13,7 +13,7 @@ use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::str::DOMString;
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::globalscope::GlobalScope;
-use string_cache::Atom;
+use servo_atoms::Atom;
#[dom_struct]
pub struct WebGLContextEvent {
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 099e50f4820..db74bcb3240 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -74,6 +74,7 @@ use script_traits::{ConstellationControlMsg, LoadData, MozBrowserEvent, Untruste
use script_traits::{DocumentState, TimerEvent, TimerEventId};
use script_traits::{ScriptMsg as ConstellationMsg, TimerEventRequest, WindowSizeData, WindowSizeType};
use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
+use servo_atoms::Atom;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::cell::Cell;
@@ -85,7 +86,6 @@ use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{Sender, channel};
use std::sync::mpsc::TryRecvError::{Disconnected, Empty};
-use string_cache::Atom;
use style::context::ReflowGoal;
use style::error_reporting::ParseErrorReporter;
use style::media_queries;
diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs
index 1f25a9e02d1..81fe7d22b11 100644
--- a/components/script/dom/xmlhttprequest.rs
+++ b/components/script/dom/xmlhttprequest.rs
@@ -56,13 +56,13 @@ use net_traits::request::{CredentialsMode, Destination, RequestInit, RequestMode
use net_traits::trim_http_whitespace;
use network_listener::{NetworkListener, PreInvoke};
use script_runtime::ScriptChan;
+use servo_atoms::Atom;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::cell::Cell;
use std::default::Default;
use std::str;
use std::sync::{Arc, Mutex};
-use string_cache::Atom;
use time;
use timers::{OneshotTimerCallback, OneshotTimerHandle};
use url::{Position, Url};