aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-11-03 11:19:44 -0500
committerGitHub <noreply@github.com>2016-11-03 11:19:44 -0500
commit5b4cc9568dbd5c15e5d2fbc62719172f11566ffa (patch)
tree596f3845740221c6748588ae1a79de79640e9922
parentdafc57e8abb3723e62e32e82ef04eb770eee2ea2 (diff)
parent53b638c0e29ba78448d07695343b7ddfa36c5141 (diff)
downloadservo-5b4cc9568dbd5c15e5d2fbc62719172f11566ffa.tar.gz
servo-5b4cc9568dbd5c15e5d2fbc62719172f11566ffa.zip
Auto merge of #14043 - servo:string-cache-up, r=nox
Update to string-cache 0.3 Previously, `string-cache` defined: * An string-like `Atom` type, * An `atom!("foo")` macro that expands to a value of that type, for a set of strings known at compile-time, * A `struct Namespace(Atom);` type * A `ns!(html)` macro that maps known prefixed to `Namespace` values with the corresponding namespace URL. Adding a string to the static set required making a change to the `string-cache` crate. With 0.3, the `Atom` type is now generic, with a type parameter that provides a set of static strings. We can have multiple such sets, defined in different crates. The `string_cache_codegen` crate, to be used in build scripts, generates code that defines such a set, a new atom type (a type alias for `Atom<_>` with the type parameter set), and an `atom!`-like macro. The html5ever repository has a new `html5ever_atoms` crate that defines three such types: `Prefix`, `Namespace`, and `LocalName` (with respective `namespace_prefix!`, `namespace_url!`, and `local_name!` macros). It also defines the `ns!` macro like before. This repository has a new `servo_atoms` crate in `components/atoms` that, for now, defines a single `Atom` type (and `atom!`) macro. (`servo_atoms::Atom` is defined as something like `type Atom = string_cache::Atom<ServoStaticStringSet>;`, so overall there’s now two types named `Atom`.) In this PR, `servo_atoms::Atom` is used for everything else that was `string_cache::Atom` before. But more atom types can be defined as needed. Two reasons to do this are to auto-generate the set of static strings (I’m planning to do this for CSS property names, which is the motivation for this change), or to have the type system help us avoid mix up unrelated things (this is why we had a `Namespace` type ever before this change). Introducing new types helped me find a bug: when creating a new attribute `dom::Element::set_style_attr`, would pass `Some(atom!("style"))` instead of `None` (now `Option<html5ever_atoms::Prefix>` instead of `Option<string_cache::Atom>`) to the `prefix` argument of `Attr::new`. I suppose the author of that code confused it with the `local_name` argument. --- Note that Stylo is not affected by any of this. The `gecko_string_cache` module is unchanged, with a single `Atom` type. The `style` crate conditionally compiles `Prefix` and `LocalName` re-exports for that are both `gecko_string_cache::Atom` on stylo. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14043) <!-- Reviewable:end -->
-rw-r--r--components/atoms/Cargo.toml16
-rw-r--r--components/atoms/build.rs19
-rw-r--r--components/atoms/lib.rs7
-rw-r--r--components/atoms/static_atoms.txt73
-rw-r--r--components/gfx/Cargo.toml2
-rw-r--r--components/gfx/font_cache_thread.rs2
-rw-r--r--components/gfx/font_template.rs2
-rw-r--r--components/gfx/lib.rs3
-rw-r--r--components/gfx/platform/dummy/font_template.rs2
-rw-r--r--components/gfx/platform/freetype/font_template.rs2
-rw-r--r--components/gfx/platform/macos/font_template.rs2
-rw-r--r--components/gfx/platform/windows/font_template.rs2
-rw-r--r--components/layout/Cargo.toml3
-rw-r--r--components/layout/construct.rs10
-rw-r--r--components/layout/fragment.rs2
-rw-r--r--components/layout/lib.rs3
-rw-r--r--components/layout/query.rs2
-rw-r--r--components/script/Cargo.toml7
-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
-rw-r--r--components/script/layout_wrapper.rs23
-rw-r--r--components/script/lib.rs3
-rw-r--r--components/script/script_thread.rs2
-rw-r--r--components/script/task_source/dom_manipulation.rs2
-rw-r--r--components/script/task_source/user_interaction.rs2
-rw-r--r--components/script_layout_interface/Cargo.toml3
-rw-r--r--components/script_layout_interface/lib.rs4
-rw-r--r--components/script_layout_interface/message.rs2
-rw-r--r--components/script_layout_interface/wrapper_traits.rs10
-rw-r--r--components/servo/Cargo.lock83
-rw-r--r--components/style/Cargo.toml5
-rw-r--r--components/style/animation.rs2
-rw-r--r--components/style/attr.rs8
-rw-r--r--components/style/custom_properties.rs2
-rw-r--r--components/style/dom.rs6
-rw-r--r--components/style/gecko_string_cache/mod.rs6
-rw-r--r--components/style/gecko_string_cache/namespace.rs8
-rw-r--r--components/style/lib.rs19
-rw-r--r--components/style/matching.rs24
-rw-r--r--components/style/media_queries.rs2
-rw-r--r--components/style/properties/helpers.mako.rs2
-rw-r--r--components/style/properties/longhand/box.mako.rs6
-rw-r--r--components/style/properties/longhand/font.mako.rs44
-rw-r--r--components/style/properties/properties.mako.rs2
-rw-r--r--components/style/restyle_hints.rs2
-rw-r--r--components/style/selector_impl.rs5
-rw-r--r--components/style/selector_matching.rs14
-rw-r--r--components/style/servo_selector_impl.rs18
-rw-r--r--components/style/stylesheets.rs8
-rw-r--r--ports/cef/Cargo.lock81
-rw-r--r--tests/unit/style/Cargo.toml3
-rw-r--r--tests/unit/style/lib.rs3
-rw-r--r--tests/unit/style/media_queries.rs2
-rw-r--r--tests/unit/style/selector_matching.rs11
-rw-r--r--tests/unit/style/stylesheets.rs31
170 files changed, 1309 insertions, 1050 deletions
diff --git a/components/atoms/Cargo.toml b/components/atoms/Cargo.toml
new file mode 100644
index 00000000000..1a470c90471
--- /dev/null
+++ b/components/atoms/Cargo.toml
@@ -0,0 +1,16 @@
+[package]
+name = "servo_atoms"
+version = "0.0.1"
+authors = ["The Servo Project Developers"]
+license = "MPL-2.0"
+publish = false
+build = "build.rs"
+
+[lib]
+path = "lib.rs"
+
+[dependencies]
+string_cache = {version = "0.3", features = ["heap_size"]}
+
+[build-dependencies]
+string_cache_codegen = "0.3"
diff --git a/components/atoms/build.rs b/components/atoms/build.rs
new file mode 100644
index 00000000000..4de629d288c
--- /dev/null
+++ b/components/atoms/build.rs
@@ -0,0 +1,19 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+extern crate string_cache_codegen;
+
+use std::env;
+use std::fs::File;
+use std::io::{BufReader, BufRead};
+use std::path::Path;
+
+fn main() {
+ let static_atoms = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("static_atoms.txt");
+ let static_atoms = BufReader::new(File::open(&static_atoms).unwrap());
+ string_cache_codegen::AtomType::new("Atom", "atom!")
+ .atoms(static_atoms.lines().map(Result::unwrap))
+ .write_to_file(&Path::new(&env::var("OUT_DIR").unwrap()).join("atom.rs"))
+ .unwrap();
+}
diff --git a/components/atoms/lib.rs b/components/atoms/lib.rs
new file mode 100644
index 00000000000..c1da7167bde
--- /dev/null
+++ b/components/atoms/lib.rs
@@ -0,0 +1,7 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+extern crate string_cache;
+
+include!(concat!(env!("OUT_DIR"), "/atom.rs"));
diff --git a/components/atoms/static_atoms.txt b/components/atoms/static_atoms.txt
new file mode 100644
index 00000000000..d050346177f
--- /dev/null
+++ b/components/atoms/static_atoms.txt
@@ -0,0 +1,73 @@
+serif
+sans-serif
+cursive
+fantasy
+monospace
+
+left
+center
+right
+
+hidden
+submit
+button
+reset
+radio
+checkbox
+file
+image
+password
+text
+search
+url
+tel
+email
+datetime
+date
+month
+week
+time
+datetime-local
+number
+
+dir
+
+bottom
+top
+left
+right
+width
+height
+margin-bottom
+margin-top
+margin-left
+margin-right
+padding-bottom
+padding-top
+padding-left
+padding-right
+
+DOMContentLoaded
+select
+input
+load
+loadstart
+loadend
+progress
+transitionend
+error
+readystatechange
+message
+close
+storage
+activate
+webglcontextcreationerror
+mouseover
+beforeunload
+message
+click
+keydown
+abort
+beforescriptexecute
+afterscriptexecute
+
diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml
index 667de0605e5..8c1eaeeea90 100644
--- a/components/gfx/Cargo.toml
+++ b/components/gfx/Cargo.toml
@@ -32,9 +32,9 @@ plugins = {path = "../plugins"}
range = {path = "../range"}
rustc-serialize = "0.3"
serde = "0.8"
+servo_atoms = {path = "../atoms"}
serde_derive = "0.8"
smallvec = "0.1"
-string_cache = {version = "0.2.26", features = ["heap_size"]}
style = {path = "../style"}
style_traits = {path = "../style_traits"}
time = "0.1.12"
diff --git a/components/gfx/font_cache_thread.rs b/components/gfx/font_cache_thread.rs
index 09ab6f12b88..77a539ea851 100644
--- a/components/gfx/font_cache_thread.rs
+++ b/components/gfx/font_cache_thread.rs
@@ -14,13 +14,13 @@ use platform::font_list::for_each_variation;
use platform::font_list::last_resort_font_families;
use platform::font_list::system_default_family;
use platform::font_template::FontTemplateData;
+use servo_atoms::Atom;
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::mem;
use std::ops::Deref;
use std::sync::{Arc, Mutex};
use std::u32;
-use string_cache::Atom;
use style::font_face::{EffectiveSources, Source};
use style::properties::longhands::font_family::computed_value::FontFamily;
use url::Url;
diff --git a/components/gfx/font_template.rs b/components/gfx/font_template.rs
index d6e549c314f..b8e45a3e922 100644
--- a/components/gfx/font_template.rs
+++ b/components/gfx/font_template.rs
@@ -6,11 +6,11 @@ use font::FontHandleMethods;
use platform::font::FontHandle;
use platform::font_context::FontContextHandle;
use platform::font_template::FontTemplateData;
+use servo_atoms::Atom;
use std::fmt::{Debug, Error, Formatter};
use std::io::Error as IoError;
use std::sync::{Arc, Weak};
use std::u32;
-use string_cache::Atom;
use style::computed_values::{font_stretch, font_weight};
/// Describes how to select a font from a given family. This is very basic at the moment and needs
diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs
index c6d4e0fc845..adf15b13c16 100644
--- a/components/gfx/lib.rs
+++ b/components/gfx/lib.rs
@@ -71,9 +71,8 @@ extern crate serde_derive;
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
extern crate simd;
+#[macro_use] extern crate servo_atoms;
extern crate smallvec;
-#[macro_use]
-extern crate string_cache;
extern crate style;
extern crate style_traits;
extern crate time;
diff --git a/components/gfx/platform/dummy/font_template.rs b/components/gfx/platform/dummy/font_template.rs
index 3e1145fcbc5..7263211fbbf 100644
--- a/components/gfx/platform/dummy/font_template.rs
+++ b/components/gfx/platform/dummy/font_template.rs
@@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use servo_atoms::Atom;
use std::io::Error;
-use string_cache::Atom;
use webrender_traits::NativeFontHandle;
#[derive(Deserialize, Serialize, Debug)]
diff --git a/components/gfx/platform/freetype/font_template.rs b/components/gfx/platform/freetype/font_template.rs
index 9319db49f9b..32ab52097d2 100644
--- a/components/gfx/platform/freetype/font_template.rs
+++ b/components/gfx/platform/freetype/font_template.rs
@@ -2,9 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use servo_atoms::Atom;
use std::fs::File;
use std::io::{Read, Error};
-use string_cache::Atom;
use webrender_traits::NativeFontHandle;
/// Platform specific font representation for Linux.
diff --git a/components/gfx/platform/macos/font_template.rs b/components/gfx/platform/macos/font_template.rs
index aa547cb2624..955c5b4df2d 100644
--- a/components/gfx/platform/macos/font_template.rs
+++ b/components/gfx/platform/macos/font_template.rs
@@ -9,13 +9,13 @@ use core_text;
use core_text::font::CTFont;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde::de::{Error, Visitor};
+use servo_atoms::Atom;
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::fs::File;
use std::io::{Read, Error as IoError};
use std::ops::Deref;
use std::sync::Mutex;
-use string_cache::Atom;
use url::Url;
/// Platform specific font representation for mac.
diff --git a/components/gfx/platform/windows/font_template.rs b/components/gfx/platform/windows/font_template.rs
index 39cf1a0b80b..933c1d596bb 100644
--- a/components/gfx/platform/windows/font_template.rs
+++ b/components/gfx/platform/windows/font_template.rs
@@ -3,11 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use gdi32;
+use servo_atoms::Atom;
use std::ffi::OsString;
use std::io::Error;
use std::os::windows::ffi::OsStrExt;
use std::ptr;
-use string_cache::Atom;
use webrender_traits::NativeFontHandle;
use winapi::{DWORD, LF_FACESIZE, LOGFONTW, OUT_TT_ONLY_PRECIS, WCHAR};
diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml
index 338a5cf4075..c5e9fd3aeb5 100644
--- a/components/layout/Cargo.toml
+++ b/components/layout/Cargo.toml
@@ -21,6 +21,7 @@ gfx = {path = "../gfx"}
gfx_traits = {path = "../gfx_traits"}
heapsize = "0.3.0"
heapsize_derive = "0.1"
+html5ever-atoms = "0.1"
ipc-channel = "0.5"
libc = "0.2"
log = "0.3.5"
@@ -36,8 +37,8 @@ script_layout_interface = {path = "../script_layout_interface"}
script_traits = {path = "../script_traits"}
selectors = "0.14"
serde_derive = "0.8"
+servo_atoms = {path = "../atoms"}
smallvec = "0.1"
-string_cache = {version = "0.2.26", features = ["heap_size"]}
style = {path = "../style"}
style_traits = {path = "../style_traits"}
unicode-bidi = "0.2"
diff --git a/components/layout/construct.rs b/components/layout/construct.rs
index 572498aad35..a0667b0b502 100644
--- a/components/layout/construct.rs
+++ b/components/layout/construct.rs
@@ -1660,7 +1660,10 @@ trait ObjectElement {
impl<N> ObjectElement for N where N: ThreadSafeLayoutNode {
fn has_object_data(&self) -> bool {
let elem = self.as_element().unwrap();
- let type_and_data = (elem.get_attr(&ns!(), &atom!("type")), elem.get_attr(&ns!(), &atom!("data")));
+ let type_and_data = (
+ elem.get_attr(&ns!(), &local_name!("type")),
+ elem.get_attr(&ns!(), &local_name!("data")),
+ );
match type_and_data {
(None, Some(uri)) => is_image_data(uri),
_ => false
@@ -1669,7 +1672,10 @@ impl<N> ObjectElement for N where N: ThreadSafeLayoutNode {
fn object_data(&self) -> Option<Url> {
let elem = self.as_element().unwrap();
- let type_and_data = (elem.get_attr(&ns!(), &atom!("type")), elem.get_attr(&ns!(), &atom!("data")));
+ let type_and_data = (
+ elem.get_attr(&ns!(), &local_name!("type")),
+ elem.get_attr(&ns!(), &local_name!("data")),
+ );
match type_and_data {
(None, Some(uri)) if is_image_data(uri) => Url::parse(uri).ok(),
_ => None
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs
index ab9563c90bc..045b50775dc 100644
--- a/components/layout/fragment.rs
+++ b/components/layout/fragment.rs
@@ -886,7 +886,7 @@ impl TableColumnFragmentInfo {
/// Create the information specific to an table column fragment.
pub fn new<N: ThreadSafeLayoutNode>(node: &N) -> TableColumnFragmentInfo {
let element = node.as_element().unwrap();
- let span = element.get_attr(&ns!(), &atom!("span"))
+ let span = element.get_attr(&ns!(), &local_name!("span"))
.and_then(|string| string.parse().ok())
.unwrap_or(0);
TableColumnFragmentInfo {
diff --git a/components/layout/lib.rs b/components/layout/lib.rs
index 59c59bed502..c0131b5064a 100644
--- a/components/layout/lib.rs
+++ b/components/layout/lib.rs
@@ -29,6 +29,7 @@ extern crate gfx;
extern crate gfx_traits;
extern crate heapsize;
#[macro_use] extern crate heapsize_derive;
+#[macro_use] extern crate html5ever_atoms;
extern crate ipc_channel;
extern crate libc;
#[macro_use]
@@ -47,8 +48,8 @@ extern crate range;
extern crate rustc_serialize;
extern crate script_layout_interface;
extern crate script_traits;
+#[macro_use] extern crate servo_atoms;
extern crate smallvec;
-#[macro_use(atom, ns)] extern crate string_cache;
extern crate style;
extern crate style_traits;
extern crate unicode_bidi;
diff --git a/components/layout/query.rs b/components/layout/query.rs
index 8b394ac8fec..f313010118c 100644
--- a/components/layout/query.rs
+++ b/components/layout/query.rs
@@ -23,10 +23,10 @@ use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutElemen
use script_traits::LayoutMsg as ConstellationMsg;
use script_traits::UntrustedNodeAddress;
use sequential;
+use servo_atoms::Atom;
use std::cmp::{min, max};
use std::ops::Deref;
use std::sync::{Arc, Mutex};
-use string_cache::Atom;
use style::computed_values;
use style::context::StyleContext;
use style::logical_geometry::{WritingMode, BlockFlowDirection, InlineBaseDirection};
diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml
index a05672bd6f4..ceaa865e628 100644
--- a/components/script/Cargo.toml
+++ b/components/script/Cargo.toml
@@ -36,7 +36,8 @@ fnv = "1.0"
gfx_traits = {path = "../gfx_traits"}
heapsize = "0.3.6"
heapsize_derive = "0.1"
-html5ever = {version = "0.8.0", features = ["heap_size", "unstable"]}
+html5ever = {version = "0.9.0", features = ["heap_size", "unstable"]}
+html5ever-atoms = {version = "0.1", features = ["heap_size"]}
hyper = "0.9.9"
hyper_serde = "0.1.4"
image = "0.10"
@@ -66,8 +67,8 @@ script_layout_interface = {path = "../script_layout_interface"}
script_traits = {path = "../script_traits"}
selectors = "0.14"
serde = "0.8"
+servo_atoms = {path = "../atoms"}
smallvec = "0.1"
-string_cache = {version = "0.2.26", features = ["heap_size", "unstable"]}
style = {path = "../style"}
style_traits = {path = "../style_traits"}
time = "0.1.12"
@@ -75,7 +76,7 @@ url = {version = "1.2", features = ["heap_size", "query_encoding"]}
util = {path = "../util"}
uuid = {version = "0.3.1", features = ["v4"]}
websocket = "0.17"
-xml5ever = {version = "0.1.2", features = ["unstable"]}
+xml5ever = {version = "0.2", features = ["unstable"]}
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"
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};
diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs
index ace0e7f40f7..c83e8232a40 100644
--- a/components/script/layout_wrapper.rs
+++ b/components/script/layout_wrapper.rs
@@ -40,6 +40,7 @@ use dom::node::{CAN_BE_FRAGMENTED, DIRTY_ON_VIEWPORT_SIZE_CHANGE, HAS_CHANGED, H
use dom::node::{LayoutNodeHelpers, Node};
use dom::text::Text;
use gfx_traits::ByteIndex;
+use html5ever_atoms::{LocalName, Namespace};
use msg::constellation_msg::PipelineId;
use parking_lot::RwLock;
use range::Range;
@@ -50,12 +51,12 @@ use script_layout_interface::wrapper_traits::{DangerousThreadSafeLayoutNode, Get
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use selectors::matching::ElementFlags;
use selectors::parser::{AttrSelector, NamespaceConstraint};
+use servo_atoms::Atom;
use std::fmt;
use std::marker::PhantomData;
use std::mem::transmute;
use std::sync::Arc;
use std::sync::atomic::Ordering;
-use string_cache::{Atom, Namespace};
use style::atomic_refcell::{AtomicRef, AtomicRefCell};
use style::attr::AttrValue;
use style::computed_values::display;
@@ -451,12 +452,12 @@ impl<'le> TElement for ServoLayoutElement<'le> {
}
#[inline]
- fn has_attr(&self, namespace: &Namespace, attr: &Atom) -> bool {
+ fn has_attr(&self, namespace: &Namespace, attr: &LocalName) -> bool {
self.get_attr(namespace, attr).is_some()
}
#[inline]
- fn attr_equals(&self, namespace: &Namespace, attr: &Atom, val: &Atom) -> bool {
+ fn attr_equals(&self, namespace: &Namespace, attr: &LocalName, val: &Atom) -> bool {
self.get_attr(namespace, attr).map_or(false, |x| x == val)
}
@@ -526,7 +527,7 @@ impl<'le> ServoLayoutElement<'le> {
}
#[inline]
- fn get_attr(&self, namespace: &Namespace, name: &Atom) -> Option<&str> {
+ fn get_attr(&self, namespace: &Namespace, name: &LocalName) -> Option<&str> {
unsafe {
(*self.element.unsafe_get()).get_attr_val_for_layout(namespace, name)
}
@@ -628,7 +629,7 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
}
#[inline]
- fn get_local_name(&self) -> &Atom {
+ fn get_local_name(&self) -> &LocalName {
self.element.local_name()
}
@@ -647,14 +648,14 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) =>
- (*self.element.unsafe_get()).get_attr_val_for_layout(&ns!(), &atom!("href")).is_some(),
+ (*self.element.unsafe_get()).get_attr_val_for_layout(&ns!(), &local_name!("href")).is_some(),
_ => false,
}
},
NonTSPseudoClass::Visited => false,
NonTSPseudoClass::ServoNonZeroBorder => unsafe {
- match (*self.element.unsafe_get()).get_attr_for_layout(&ns!(), &atom!("border")) {
+ match (*self.element.unsafe_get()).get_attr_for_layout(&ns!(), &local_name!("border")) {
None | Some(&AttrValue::UInt(_, 0)) => false,
_ => true,
}
@@ -962,7 +963,7 @@ impl<ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<ConcreteNod
loop {
let next_node = if let Some(ref node) = current_node {
if node.is_element() &&
- node.as_element().unwrap().get_local_name() == &atom!("summary") &&
+ node.as_element().unwrap().get_local_name() == &local_name!("summary") &&
node.as_element().unwrap().get_namespace() == &ns!(html) {
self.current_node = None;
return Some(node.clone());
@@ -980,7 +981,7 @@ impl<ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<ConcreteNod
let node = self.current_node.clone();
let node = node.and_then(|node| {
if node.is_element() &&
- node.as_element().unwrap().get_local_name() == &atom!("summary") &&
+ node.as_element().unwrap().get_local_name() == &local_name!("summary") &&
node.as_element().unwrap().get_namespace() == &ns!(html) {
unsafe { node.dangerous_next_sibling() }
} else {
@@ -1061,7 +1062,7 @@ impl<'le> ThreadSafeLayoutElement for ServoThreadSafeLayoutElement<'le> {
self.as_node().type_id()
}
- fn get_attr<'a>(&'a self, namespace: &Namespace, name: &Atom) -> Option<&'a str> {
+ fn get_attr<'a>(&'a self, namespace: &Namespace, name: &LocalName) -> Option<&'a str> {
self.element.get_attr(namespace, name)
}
@@ -1137,7 +1138,7 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {
}
#[inline]
- fn get_local_name(&self) -> &Atom {
+ fn get_local_name(&self) -> &LocalName {
self.element.get_local_name()
}
diff --git a/components/script/lib.rs b/components/script/lib.rs
index dd6299aa051..9443bc65f91 100644
--- a/components/script/lib.rs
+++ b/components/script/lib.rs
@@ -46,6 +46,7 @@ extern crate gfx_traits;
extern crate heapsize;
#[macro_use] extern crate heapsize_derive;
extern crate html5ever;
+#[macro_use] extern crate html5ever_atoms;
extern crate hyper;
extern crate hyper_serde;
extern crate image;
@@ -78,8 +79,8 @@ extern crate script_layout_interface;
extern crate script_traits;
extern crate selectors;
extern crate serde;
+#[macro_use] extern crate servo_atoms;
extern crate smallvec;
-#[macro_use(atom, ns)] extern crate string_cache;
#[macro_use]
extern crate style;
extern crate style_traits;
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index a028cd66ad5..6a789527f78 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -1937,7 +1937,7 @@ impl ScriptThread {
.filter_map(Root::downcast::<HTMLAnchorElement>)
.next() {
let status = anchor.upcast::<Element>()
- .get_attribute(&ns!(), &atom!("href"))
+ .get_attribute(&ns!(), &local_name!("href"))
.and_then(|href| {
let value = href.value();
let url = document.url();
diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs
index c5b4e4b5f73..75fd4021168 100644
--- a/components/script/task_source/dom_manipulation.rs
+++ b/components/script/task_source/dom_manipulation.rs
@@ -8,9 +8,9 @@ use dom::event::{EventBubbles, EventCancelable, EventRunnable, SimpleEventRunnab
use dom::eventtarget::EventTarget;
use dom::window::Window;
use script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper, ScriptThread};
+use servo_atoms::Atom;
use std::result::Result;
use std::sync::mpsc::Sender;
-use string_cache::Atom;
use task_source::TaskSource;
#[derive(JSTraceable, Clone)]
diff --git a/components/script/task_source/user_interaction.rs b/components/script/task_source/user_interaction.rs
index d3850e9f813..c97e1e1895a 100644
--- a/components/script/task_source/user_interaction.rs
+++ b/components/script/task_source/user_interaction.rs
@@ -8,9 +8,9 @@ use dom::event::{EventBubbles, EventCancelable, EventRunnable};
use dom::eventtarget::EventTarget;
use dom::window::Window;
use script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper, ScriptThread};
+use servo_atoms::Atom;
use std::result::Result;
use std::sync::mpsc::Sender;
-use string_cache::Atom;
use task_source::TaskSource;
#[derive(JSTraceable, Clone)]
diff --git a/components/script_layout_interface/Cargo.toml b/components/script_layout_interface/Cargo.toml
index ba5a7bd7449..5d81df1261d 100644
--- a/components/script_layout_interface/Cargo.toml
+++ b/components/script_layout_interface/Cargo.toml
@@ -18,6 +18,7 @@ euclid = "0.10.1"
gfx_traits = {path = "../gfx_traits"}
heapsize = "0.3.0"
heapsize_derive = "0.1"
+html5ever-atoms = "0.1"
ipc-channel = "0.5"
libc = "0.2"
log = "0.3.5"
@@ -28,6 +29,6 @@ profile_traits = {path = "../profile_traits"}
range = {path = "../range"}
script_traits = {path = "../script_traits"}
selectors = "0.14"
-string_cache = {version = "0.2.26", features = ["heap_size"]}
+servo_atoms = {path = "../atoms"}
style = {path = "../style"}
url = {version = "1.2", features = ["heap_size"]}
diff --git a/components/script_layout_interface/lib.rs b/components/script_layout_interface/lib.rs
index 2cad69cdcc8..b442e502b2b 100644
--- a/components/script_layout_interface/lib.rs
+++ b/components/script_layout_interface/lib.rs
@@ -24,6 +24,7 @@ extern crate euclid;
extern crate gfx_traits;
extern crate heapsize;
#[macro_use] extern crate heapsize_derive;
+#[macro_use] extern crate html5ever_atoms;
extern crate ipc_channel;
extern crate libc;
#[macro_use]
@@ -34,8 +35,7 @@ extern crate profile_traits;
extern crate range;
extern crate script_traits;
extern crate selectors;
-#[macro_use(atom, ns)]
-extern crate string_cache;
+#[macro_use] extern crate servo_atoms;
extern crate style;
extern crate url;
diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs
index 1d08f8e758f..cd82dc79cd7 100644
--- a/components/script_layout_interface/message.rs
+++ b/components/script_layout_interface/message.rs
@@ -14,9 +14,9 @@ use profile_traits::mem::ReportsChan;
use rpc::LayoutRPC;
use script_traits::{ConstellationControlMsg, LayoutControlMsg};
use script_traits::{LayoutMsg as ConstellationMsg, StackingContextScrollState, WindowSizeData};
+use servo_atoms::Atom;
use std::sync::Arc;
use std::sync::mpsc::{Receiver, Sender};
-use string_cache::Atom;
use style::context::ReflowGoal;
use style::selector_impl::PseudoElement;
use style::stylesheets::Stylesheet;
diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs
index 04372274cfc..a241ae12099 100644
--- a/components/script_layout_interface/wrapper_traits.rs
+++ b/components/script_layout_interface/wrapper_traits.rs
@@ -9,12 +9,12 @@ use LayoutNodeType;
use OpaqueStyleAndLayoutData;
use SVGSVGData;
use gfx_traits::ByteIndex;
+use html5ever_atoms::{Namespace, LocalName};
use msg::constellation_msg::PipelineId;
use range::Range;
use restyle_damage::RestyleDamage;
use std::fmt::Debug;
use std::sync::Arc;
-use string_cache::{Atom, Namespace};
use style::atomic_refcell::AtomicRefCell;
use style::computed_values::display;
use style::context::SharedStyleContext;
@@ -295,7 +295,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
fn type_id(&self) -> Option<LayoutNodeType>;
#[inline]
- fn get_attr(&self, namespace: &Namespace, name: &Atom) -> Option<&str>;
+ fn get_attr(&self, namespace: &Namespace, name: &LocalName) -> Option<&str>;
fn get_style_data(&self) -> Option<&AtomicRefCell<ElementData>>;
@@ -330,7 +330,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
#[inline]
fn get_details_summary_pseudo(&self) -> Option<Self> {
- if self.get_local_name() == &atom!("details") &&
+ if self.get_local_name() == &local_name!("details") &&
self.get_namespace() == &ns!(html) {
Some(self.with_pseudo(PseudoElementType::DetailsSummary(None)))
} else {
@@ -340,9 +340,9 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
#[inline]
fn get_details_content_pseudo(&self) -> Option<Self> {
- if self.get_local_name() == &atom!("details") &&
+ if self.get_local_name() == &local_name!("details") &&
self.get_namespace() == &ns!(html) {
- let display = if self.get_attr(&ns!(), &atom!("open")).is_some() {
+ let display = if self.get_attr(&ns!(), &local_name!("open")).is_some() {
None // Specified by the stylesheet
} else {
Some(display::T::none)
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 44e7091525d..c2d56f2a254 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -804,9 +804,9 @@ dependencies = [
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"servo-fontconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "servo_atoms 0.0.1",
"simd 0.1.1 (git+https://github.com/huonw/simd)",
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"style_traits 0.0.1",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -938,11 +938,6 @@ dependencies = [
]
[[package]]
-name = "heapsize_plugin"
-version = "0.1.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
name = "heartbeats-simple"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -971,23 +966,34 @@ dependencies = [
[[package]]
name = "html5ever"
-version = "0.8.0"
+version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "html5ever-atoms 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mac 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"phf 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
"phf_codegen 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tendril 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
+name = "html5ever-atoms"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "string_cache 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "string_cache_codegen 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "httparse"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1163,6 +1169,7 @@ dependencies = [
"gfx_traits 0.0.1",
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "html5ever-atoms 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1178,8 +1185,8 @@ dependencies = [
"script_traits 0.0.1",
"selectors 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "servo_atoms 0.0.1",
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"style_traits 0.0.1",
"unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1977,7 +1984,8 @@ dependencies = [
"gfx_traits 0.0.1",
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "html5ever 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "html5ever 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "html5ever-atoms 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper_serde 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2007,8 +2015,8 @@ dependencies = [
"script_traits 0.0.1",
"selectors 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "servo_atoms 0.0.1",
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"style_traits 0.0.1",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2018,7 +2026,7 @@ dependencies = [
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.8.0 (git+https://github.com/servo/webrender)",
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "xml5ever 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "xml5ever 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -2033,6 +2041,7 @@ dependencies = [
"gfx_traits 0.0.1",
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "html5ever-atoms 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2043,7 +2052,7 @@ dependencies = [
"range 0.0.1",
"script_traits 0.0.1",
"selectors 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
+ "servo_atoms 0.0.1",
"style 0.0.1",
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -2233,6 +2242,14 @@ dependencies = [
]
[[package]]
+name = "servo_atoms"
+version = "0.0.1"
+dependencies = [
+ "string_cache 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "string_cache_codegen 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "shared_library"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2281,18 +2298,32 @@ dependencies = [
[[package]]
name = "string_cache"
-version = "0.2.29"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "phf_generator 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
"phf_shared 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "string_cache_codegen 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
+name = "string_cache_codegen"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "phf_generator 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "string_cache_shared"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "style"
version = "0.0.1"
dependencies = [
@@ -2306,6 +2337,7 @@ dependencies = [
"fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "html5ever-atoms 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2324,8 +2356,8 @@ dependencies = [
"selectors 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "servo_atoms 0.0.1",
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"style_traits 0.0.1",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-segmentation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2341,11 +2373,12 @@ dependencies = [
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "html5ever-atoms 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"owning_ref 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
+ "servo_atoms 0.0.1",
"style 0.0.1",
"style_traits 0.0.1",
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2817,15 +2850,15 @@ dependencies = [
[[package]]
name = "xml5ever"
-version = "0.1.3"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
+ "html5ever-atoms 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mac 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"phf 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
"phf_codegen 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"tendril 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -2908,11 +2941,11 @@ dependencies = [
"checksum harfbuzz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6b76113246f5c089dcf272cf89c3f61168a4d77b50ec5b2c1fab8c628c9ea762"
"checksum heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8c80e194758495a9109566134dc06e42ea0423987d6ceca016edaa90381b3549"
"checksum heapsize_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "35abd70c0f2d6260b973ea908d7e4e3da729fc2acf18def91f034a2a4f824ff8"
-"checksum heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c9a70a1ef0122b54e0553f1d960b686c40d33a7953bc63029509a7649c8ee2c4"
"checksum heartbeats-simple 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "78c0810722eacd0bdd3f1f691524bd9900bf8fed1947f6b883c10ddecd2560b1"
"checksum heartbeats-simple-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53c4b67617665d7f4172f381f9843c1bec6a4fccc9a9226529e5b1be40dc1301"
"checksum hpack 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d2da7d3a34cf6406d9d700111b8eafafe9a251de41ae71d8052748259343b58"
-"checksum html5ever 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "74d996f271e5698e3eeae29754d59b2288973e20b898b53899ac7411356a0742"
+"checksum html5ever 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6a2e00f17a864dfee00d41b46fda2a669e10e96bf71f8c712b3c88f4977188d7"
+"checksum html5ever-atoms 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "860439a63e39a4d3506b9cff6107fa238f89edf7aee41ca5a055acb301a556a3"
"checksum httparse 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "46534074dbb80b070d60a5cb8ecadd8963a00a438ae1a95268850a7ef73b67ae"
"checksum hyper 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)" = "eb27e8a3e8f17ac43ffa41bbda9cf5ad3f9f13ef66fa4873409d4902310275f7"
"checksum hyper_serde 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "572d2168173019de312a050a24f2ad33ac2ac7895a2139fbf21ee6b6f470a24e"
@@ -3014,7 +3047,9 @@ dependencies = [
"checksum simd 0.1.1 (git+https://github.com/huonw/simd)" = "<none>"
"checksum smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "fcc8d19212aacecf95e4a7a2179b26f7aeb9732a915cf01f05b0d3e044865410"
"checksum solicit 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "172382bac9424588d7840732b250faeeef88942e37b6e35317dce98cafdd75b2"
-"checksum string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "f585562982abf1301fa97bd2226a3c4c5712b8beb9bcd16ed72b5e96810f8657"
+"checksum string_cache 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d192db2123fac37399e1ca61557904a5c3fb6fc24c73d2e47b15d20dc32470"
+"checksum string_cache_codegen 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff92eda33653ce0ec418b61dbb939b777cc45c0a88528d4020f1b3241b409006"
+"checksum string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc"
"checksum syn 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "76c2db66dc579998854d84ff0ff4a81cb73e69596764d144ce7cece4d04ce6b5"
"checksum synstructure 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c93b5595e44343867746223dd8de40c15e53e89f5fb252e3d20e0187a698647c"
"checksum target_build_utils 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a1be18d4d908e4e5697908de04fdd5099505463fc8eaf1ceb8133ae486936aa"
@@ -3059,4 +3094,4 @@ dependencies = [
"checksum xdg 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "77b831a5ba77110f438f0ac5583aafeb087f70432998ba6b7dcb1d32185db453"
"checksum xi-unicode 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "315c4e158d7fa277e3ea35b32e50bc07e9a0c8de9130a7cc4bdeab42ddc7b442"
"checksum xml-rs 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "65e74b96bd3179209dc70a980da6df843dff09e46eee103a0376c0949257e3ef"
-"checksum xml5ever 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fdbef89351fe48a35c50fc264fa10867a35912e9445753bdf21fbde4f4164af5"
+"checksum xml5ever 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a3aa816561c8d68419dec4c43df33974940cd6a03e376dfc497ec3e46fb7755"
diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml
index caa79f56d93..3e419213fd4 100644
--- a/components/style/Cargo.toml
+++ b/components/style/Cargo.toml
@@ -15,7 +15,7 @@ doctest = false
[features]
gecko = ["nsstring_vendor"]
servo = ["serde/unstable", "serde", "serde_derive", "heapsize_derive",
- "style_traits/servo", "app_units/plugins", "string_cache",
+ "style_traits/servo", "app_units/plugins", "servo_atoms", "html5ever-atoms",
"cssparser/heap_size", "cssparser/serde-serialization",
"url/heap_size", "plugins", "parking_lot/nightly"]
testing = []
@@ -31,6 +31,7 @@ euclid = "0.10.1"
fnv = "1.0"
heapsize = "0.3.0"
heapsize_derive = {version = "0.1", optional = true}
+html5ever-atoms = {version = "0.1", optional = true}
lazy_static = "0.2"
log = "0.3.5"
libc = "0.2"
@@ -48,8 +49,8 @@ rustc-serialize = "0.3"
selectors = "0.14"
serde = {version = "0.8", optional = true}
serde_derive = {version = "0.8", optional = true}
+servo_atoms = {path = "../atoms", optional = true}
smallvec = "0.1"
-string_cache = {version = "0.2.26", features = ["heap_size"], optional = true}
style_traits = {path = "../style_traits"}
time = "0.1"
unicode-segmentation = "0.1.2"
diff --git a/components/style/animation.rs b/components/style/animation.rs
index 898dd8ee449..b106db1812e 100644
--- a/components/style/animation.rs
+++ b/components/style/animation.rs
@@ -4,6 +4,7 @@
//! CSS transitions and animations.
+use Atom;
use bezier::Bezier;
use context::SharedStyleContext;
use dom::{OpaqueNode, UnsafeNode};
@@ -19,7 +20,6 @@ use properties::longhands::transition_timing_function::computed_value::Transitio
use selector_matching::ApplicableDeclarationBlock;
use std::sync::Arc;
use std::sync::mpsc::Sender;
-use string_cache::Atom;
use timer::Timer;
use values::computed::Time;
diff --git a/components/style/attr.rs b/components/style/attr.rs
index b62e001a4e1..ffa4fa37eed 100644
--- a/components/style/attr.rs
+++ b/components/style/attr.rs
@@ -6,6 +6,7 @@
//!
//! [attr]: https://dom.spec.whatwg.org/#interface-attr
+use {Atom, Prefix, Namespace, LocalName};
use app_units::Au;
use cssparser::{self, Color, RGBA};
use euclid::num::Zero;
@@ -15,7 +16,6 @@ use std::str::FromStr;
use str::{HTML_SPACE_CHARACTERS, read_exponent, read_fraction};
use str::{read_numbers, split_commas, split_html_space_chars};
#[cfg(not(feature = "gecko"))] use str::str_join;
-use string_cache::{Atom, Namespace};
use url::Url;
use values::specified::Length;
@@ -548,8 +548,8 @@ pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto {
#[derive(Clone, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct AttrIdentifier {
- pub local_name: Atom,
- pub name: Atom,
+ pub local_name: LocalName,
+ pub name: LocalName,
pub namespace: Namespace,
- pub prefix: Option<Atom>,
+ pub prefix: Option<Prefix>,
}
diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs
index 5189bbeaa37..9ced8a67168 100644
--- a/components/style/custom_properties.rs
+++ b/components/style/custom_properties.rs
@@ -6,6 +6,7 @@
//!
//! [custom]: https://drafts.csswg.org/css-variables/
+use Atom;
use cssparser::{Delimiter, Parser, SourcePosition, ToCss, Token, TokenSerializationType};
use properties::DeclaredValue;
use std::ascii::AsciiExt;
@@ -13,7 +14,6 @@ use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::sync::Arc;
-use string_cache::Atom;
// Does not include the `--` prefix
pub type Name = Atom;
diff --git a/components/style/dom.rs b/components/style/dom.rs
index 48979f32bcb..702d56a6f4d 100644
--- a/components/style/dom.rs
+++ b/components/style/dom.rs
@@ -6,6 +6,7 @@
#![allow(unsafe_code)]
+use {Atom, Namespace, LocalName};
use atomic_refcell::{AtomicRef, AtomicRefCell};
use data::{ElementStyles, ElementData};
use element_state::ElementState;
@@ -19,7 +20,6 @@ use sink::Push;
use std::fmt::Debug;
use std::ops::BitOr;
use std::sync::Arc;
-use string_cache::{Atom, Namespace};
use traversal::DomTraversalContext;
use util::opts;
@@ -182,8 +182,8 @@ pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + Pre
fn get_state(&self) -> ElementState;
- fn has_attr(&self, namespace: &Namespace, attr: &Atom) -> bool;
- fn attr_equals(&self, namespace: &Namespace, attr: &Atom, value: &Atom) -> bool;
+ fn has_attr(&self, namespace: &Namespace, attr: &LocalName) -> bool;
+ fn attr_equals(&self, namespace: &Namespace, attr: &LocalName, value: &Atom) -> bool;
/// Set the restyle damage field.
fn set_restyle_damage(self, damage: Self::ConcreteRestyleDamage);
diff --git a/components/style/gecko_string_cache/mod.rs b/components/style/gecko_string_cache/mod.rs
index adf2de22a47..a8798250699 100644
--- a/components/style/gecko_string_cache/mod.rs
+++ b/components/style/gecko_string_cache/mod.rs
@@ -25,7 +25,11 @@ pub mod atom_macro;
#[macro_use]
pub mod namespace;
-pub use string_cache::namespace::{Namespace, WeakNamespace};
+pub use self::namespace::{Namespace, WeakNamespace};
+
+macro_rules! local_name {
+ ($s: tt) => { atom!($s) }
+}
/// A strong reference to a Gecko atom.
#[derive(PartialEq, Eq)]
diff --git a/components/style/gecko_string_cache/namespace.rs b/components/style/gecko_string_cache/namespace.rs
index b2f464db184..a89c1873423 100644
--- a/components/style/gecko_string_cache/namespace.rs
+++ b/components/style/gecko_string_cache/namespace.rs
@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use gecko_bindings::structs::nsIAtom;
-use std::borrow::Borrow;
+use std::borrow::{Borrow, Cow};
use std::fmt;
use std::ops::Deref;
use string_cache::{Atom, WeakAtom};
@@ -31,6 +31,12 @@ impl Deref for Namespace {
}
}
+impl<'a> From<Cow<'a, str>> for Namespace {
+ fn from(s: Cow<'a, str>) -> Self {
+ Namespace(Atom::from(s))
+ }
+}
+
impl fmt::Display for Namespace {
fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
self.0.fmt(w)
diff --git a/components/style/lib.rs b/components/style/lib.rs
index b185312c9e0..687a54ca644 100644
--- a/components/style/lib.rs
+++ b/components/style/lib.rs
@@ -53,8 +53,10 @@ extern crate deque;
extern crate encoding;
extern crate euclid;
extern crate fnv;
+#[cfg(feature = "gecko")] #[macro_use] pub mod gecko_string_cache;
extern crate heapsize;
#[cfg(feature = "servo")] #[macro_use] extern crate heapsize_derive;
+#[cfg(feature = "servo")] #[macro_use] extern crate html5ever_atoms;
#[allow(unused_extern_crates)]
#[macro_use]
extern crate lazy_static;
@@ -78,8 +80,8 @@ extern crate selectors;
#[cfg(feature = "servo")]
extern crate serde;
#[cfg(feature = "servo")] #[macro_use] extern crate serde_derive;
+#[cfg(feature = "servo")] #[macro_use] extern crate servo_atoms;
extern crate smallvec;
-#[cfg(feature = "servo")] #[macro_use] extern crate string_cache;
#[macro_use]
extern crate style_traits;
extern crate time;
@@ -88,10 +90,6 @@ extern crate unicode_segmentation;
extern crate url;
extern crate util;
-#[cfg(feature = "gecko")]
-#[path = "./gecko_string_cache/mod.rs"]
-#[macro_use] pub mod string_cache;
-
pub mod animation;
pub mod atomic_refcell;
pub mod attr;
@@ -137,6 +135,17 @@ use cssparser::ToCss;
use std::fmt;
use std::sync::Arc;
+#[cfg(feature = "gecko")] pub use gecko_string_cache as string_cache;
+#[cfg(feature = "gecko")] pub use gecko_string_cache::Atom;
+#[cfg(feature = "gecko")] pub use gecko_string_cache::Namespace;
+#[cfg(feature = "gecko")] pub use gecko_string_cache::Atom as Prefix;
+#[cfg(feature = "gecko")] pub use gecko_string_cache::Atom as LocalName;
+
+#[cfg(feature = "servo")] pub use servo_atoms::Atom;
+#[cfg(feature = "servo")] pub use html5ever_atoms::Prefix;
+#[cfg(feature = "servo")] pub use html5ever_atoms::LocalName;
+#[cfg(feature = "servo")] pub use html5ever_atoms::Namespace;
+
/// The CSS properties supported by the style system.
// Generated from the properties.mako.rs template by build.rs
#[macro_use]
diff --git a/components/style/matching.rs b/components/style/matching.rs
index 6de269477a4..0887ebc823a 100644
--- a/components/style/matching.rs
+++ b/components/style/matching.rs
@@ -6,6 +6,7 @@
#![allow(unsafe_code)]
+use {Atom, LocalName};
use animation;
use arc_ptr_eq;
use atomic_refcell::AtomicRefMut;
@@ -29,7 +30,6 @@ use std::mem;
use std::ops::Deref;
use std::slice::IterMut;
use std::sync::Arc;
-use string_cache::Atom;
use util::opts;
fn create_common_style_affecting_attributes_from_element<E: TElement>(element: &E)
@@ -38,12 +38,12 @@ fn create_common_style_affecting_attributes_from_element<E: TElement>(element: &
for attribute_info in &common_style_affecting_attributes() {
match attribute_info.mode {
CommonStyleAffectingAttributeMode::IsPresent(flag) => {
- if element.has_attr(&ns!(), &attribute_info.atom) {
+ if element.has_attr(&ns!(), &attribute_info.attr_name) {
flags.insert(flag)
}
}
CommonStyleAffectingAttributeMode::IsEqual(ref target_value, flag) => {
- if element.attr_equals(&ns!(), &attribute_info.atom, target_value) {
+ if element.attr_equals(&ns!(), &attribute_info.attr_name, target_value) {
flags.insert(flag)
}
}
@@ -333,7 +333,7 @@ bitflags! {
}
pub struct CommonStyleAffectingAttributeInfo {
- pub atom: Atom,
+ pub attr_name: LocalName,
pub mode: CommonStyleAffectingAttributeMode,
}
@@ -348,23 +348,23 @@ pub enum CommonStyleAffectingAttributeMode {
pub fn common_style_affecting_attributes() -> [CommonStyleAffectingAttributeInfo; 5] {
[
CommonStyleAffectingAttributeInfo {
- atom: atom!("hidden"),
+ attr_name: local_name!("hidden"),
mode: CommonStyleAffectingAttributeMode::IsPresent(HIDDEN_ATTRIBUTE),
},
CommonStyleAffectingAttributeInfo {
- atom: atom!("nowrap"),
+ attr_name: local_name!("nowrap"),
mode: CommonStyleAffectingAttributeMode::IsPresent(NO_WRAP_ATTRIBUTE),
},
CommonStyleAffectingAttributeInfo {
- atom: atom!("align"),
+ attr_name: local_name!("align"),
mode: CommonStyleAffectingAttributeMode::IsEqual(atom!("left"), ALIGN_LEFT_ATTRIBUTE),
},
CommonStyleAffectingAttributeInfo {
- atom: atom!("align"),
+ attr_name: local_name!("align"),
mode: CommonStyleAffectingAttributeMode::IsEqual(atom!("center"), ALIGN_CENTER_ATTRIBUTE),
},
CommonStyleAffectingAttributeInfo {
- atom: atom!("align"),
+ attr_name: local_name!("align"),
mode: CommonStyleAffectingAttributeMode::IsEqual(atom!("right"), ALIGN_RIGHT_ATTRIBUTE),
}
]
@@ -373,8 +373,8 @@ pub fn common_style_affecting_attributes() -> [CommonStyleAffectingAttributeInfo
/// Attributes that, if present, disable style sharing. All legacy HTML attributes must be in
/// either this list or `common_style_affecting_attributes`. See the comment in
/// `synthesize_presentational_hints_for_legacy_attributes`.
-pub fn rare_style_affecting_attributes() -> [Atom; 3] {
- [ atom!("bgcolor"), atom!("border"), atom!("colspan") ]
+pub fn rare_style_affecting_attributes() -> [LocalName; 3] {
+ [ local_name!("bgcolor"), local_name!("border"), local_name!("colspan") ]
}
fn have_same_class<E: TElement>(element: &E,
@@ -703,7 +703,7 @@ pub trait MatchMethods : TElement {
return StyleSharingResult::CannotShare
}
- if self.has_attr(&ns!(), &atom!("id")) {
+ if self.has_attr(&ns!(), &local_name!("id")) {
return StyleSharingResult::CannotShare
}
diff --git a/components/style/media_queries.rs b/components/style/media_queries.rs
index 216e1c33a42..b8df4c0cf61 100644
--- a/components/style/media_queries.rs
+++ b/components/style/media_queries.rs
@@ -6,13 +6,13 @@
//!
//! [mq]: https://drafts.csswg.org/mediaqueries/
+use Atom;
use app_units::Au;
use cssparser::{Delimiter, Parser, ToCss, Token};
use euclid::size::{Size2D, TypedSize2D};
use properties::longhands;
use serialize_comma_separated_list;
use std::fmt::{self, Write};
-use string_cache::Atom;
use style_traits::ViewportPx;
use values::specified;
diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs
index d5e48f6970b..89ef5229882 100644
--- a/components/style/properties/helpers.mako.rs
+++ b/components/style/properties/helpers.mako.rs
@@ -191,7 +191,7 @@
use std::sync::Arc;
use values::computed::{Context, ToComputedValue};
use values::{computed, specified};
- use string_cache::Atom;
+ use Atom;
${caller.body()}
#[allow(unused_variables)]
pub fn cascade_property(declaration: &PropertyDeclaration,
diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs
index bba0eec7997..b1e19239c9f 100644
--- a/components/style/properties/longhand/box.mako.rs
+++ b/components/style/properties/longhand/box.mako.rs
@@ -648,9 +648,9 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
pub mod computed_value {
use cssparser::ToCss;
use std::fmt;
- use string_cache::Atom;
+ use Atom;
- pub use string_cache::Atom as SingleComputedValue;
+ pub use Atom as SingleComputedValue;
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
@@ -676,7 +676,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
pub use self::computed_value::T as SpecifiedValue;
impl NoViewportPercentage for SpecifiedValue {}
- pub use string_cache::Atom as SingleSpecifiedValue;
+ pub use Atom as SingleSpecifiedValue;
#[inline]
pub fn parse_one(input: &mut Parser) -> Result<SingleSpecifiedValue, ()> {
diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs
index 1033f68db11..bcd34d4c4e2 100644
--- a/components/style/properties/longhand/font.mako.rs
+++ b/components/style/properties/longhand/font.mako.rs
@@ -20,7 +20,7 @@
pub mod computed_value {
use cssparser::ToCss;
use std::fmt;
- use string_cache::Atom;
+ use Atom;
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
@@ -46,19 +46,25 @@
#[cfg(not(feature = "gecko"))] // Gecko can't borrow atoms as UTF-8.
pub fn from_atom(input: Atom) -> FontFamily {
- let option = match_ignore_ascii_case! { &input,
- &atom!("serif") => Some(atom!("serif")),
- &atom!("sans-serif") => Some(atom!("sans-serif")),
- &atom!("cursive") => Some(atom!("cursive")),
- &atom!("fantasy") => Some(atom!("fantasy")),
- &atom!("monospace") => Some(atom!("monospace")),
- _ => None
- };
-
- match option {
- Some(family) => FontFamily::Generic(family),
- None => FontFamily::FamilyName(input)
+ match input {
+ atom!("serif") |
+ atom!("sans-serif") |
+ atom!("cursive") |
+ atom!("fantasy") |
+ atom!("monospace") => {
+ return FontFamily::Generic(input)
+ }
+ _ => {}
+ }
+ match_ignore_ascii_case! { input,
+ "serif" => return FontFamily::Generic(atom!("serif")),
+ "sans-serif" => return FontFamily::Generic(atom!("sans-serif")),
+ "cursive" => return FontFamily::Generic(atom!("cursive")),
+ "fantasy" => return FontFamily::Generic(atom!("fantasy")),
+ "monospace" => return FontFamily::Generic(atom!("monospace")),
+ _ => {}
}
+ FontFamily::FamilyName(input)
}
}
impl ToCss for FontFamily {
@@ -101,12 +107,12 @@
// FIXME(bholley): The fast thing to do here would be to look up the
// string (as lowercase) in the static atoms table. We don't have an
// API to do that yet though, so we do the simple thing for now.
- match &first_ident[..] {
- s if atom!("serif").eq_str_ignore_ascii_case(s) => return Ok(FontFamily::Generic(atom!("serif"))),
- s if atom!("sans-serif").eq_str_ignore_ascii_case(s) => return Ok(FontFamily::Generic(atom!("sans-serif"))),
- s if atom!("cursive").eq_str_ignore_ascii_case(s) => return Ok(FontFamily::Generic(atom!("cursive"))),
- s if atom!("fantasy").eq_str_ignore_ascii_case(s) => return Ok(FontFamily::Generic(atom!("fantasy"))),
- s if atom!("monospace").eq_str_ignore_ascii_case(s) => return Ok(FontFamily::Generic(atom!("monospace"))),
+ match_ignore_ascii_case! { first_ident,
+ "serif" => return Ok(FontFamily::Generic(atom!("serif"))),
+ "sans-serif" => return Ok(FontFamily::Generic(atom!("sans-serif"))),
+ "cursive" => return Ok(FontFamily::Generic(atom!("cursive"))),
+ "fantasy" => return Ok(FontFamily::Generic(atom!("fantasy"))),
+ "monospace" => return Ok(FontFamily::Generic(atom!("monospace"))),
_ => {}
}
diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs
index 40871299659..c0543d7ab3f 100644
--- a/components/style/properties/properties.mako.rs
+++ b/components/style/properties/properties.mako.rs
@@ -16,6 +16,7 @@ use std::collections::HashSet;
use std::fmt::{self, Write};
use std::sync::Arc;
+use Atom;
use app_units::Au;
#[cfg(feature = "servo")] use cssparser::{Color as CSSParserColor, RGBA};
use cssparser::{Parser, ToCss, TokenSerializationType};
@@ -23,7 +24,6 @@ use error_reporting::ParseErrorReporter;
use url::Url;
#[cfg(feature = "servo")] use euclid::side_offsets::SideOffsets2D;
use euclid::size::Size2D;
-use string_cache::Atom;
use computed_values;
#[cfg(feature = "servo")] use logical_geometry::{LogicalMargin, PhysicalSide};
use logical_geometry::WritingMode;
diff --git a/components/style/restyle_hints.rs b/components/style/restyle_hints.rs
index b47180b60a9..a856d02a823 100644
--- a/components/style/restyle_hints.rs
+++ b/components/style/restyle_hints.rs
@@ -4,6 +4,7 @@
//! Restyle hints: an optimization to avoid unnecessarily matching selectors.
+use Atom;
use element_state::*;
#[cfg(feature = "servo")]
use heapsize::HeapSizeOf;
@@ -14,7 +15,6 @@ use selectors::matching::matches_complex_selector;
use selectors::parser::{AttrSelector, Combinator, ComplexSelector, SelectorImpl, SimpleSelector};
use std::clone::Clone;
use std::sync::Arc;
-use string_cache::Atom;
/// When the ElementState of an element (like IN_HOVER_STATE) changes, certain
/// pseudo-classes (like :hover) may require us to restyle that element, its
diff --git a/components/style/selector_impl.rs b/components/style/selector_impl.rs
index 6facc88fec0..3d1d7813bd2 100644
--- a/components/style/selector_impl.rs
+++ b/components/style/selector_impl.rs
@@ -104,7 +104,7 @@ pub fn attr_exists_selector_is_shareable(attr_selector: &AttrSelector<TheSelecto
// NB(pcwalton): If you update this, remember to update the corresponding list in
// `can_share_style_with()` as well.
common_style_affecting_attributes().iter().any(|common_attr_info| {
- common_attr_info.atom == attr_selector.name && match common_attr_info.mode {
+ common_attr_info.attr_name == attr_selector.name && match common_attr_info.mode {
CommonStyleAffectingAttributeMode::IsPresent(_) => true,
CommonStyleAffectingAttributeMode::IsEqual(..) => false,
}
@@ -115,9 +115,10 @@ pub fn attr_equals_selector_is_shareable(attr_selector: &AttrSelector<TheSelecto
value: &AttrValue) -> bool {
// FIXME(pcwalton): Remove once we start actually supporting RTL text. This is in
// here because the UA style otherwise disables all style sharing completely.
+ // FIXME(SimonSapin): should this be the attribute *name* rather than value?
atom!("dir") == *value ||
common_style_affecting_attributes().iter().any(|common_attr_info| {
- common_attr_info.atom == attr_selector.name && match common_attr_info.mode {
+ common_attr_info.attr_name == attr_selector.name && match common_attr_info.mode {
CommonStyleAffectingAttributeMode::IsEqual(ref target_value, _) => {
*target_value == *value
}
diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs
index ebd5e9b29eb..b97fcf9bb68 100644
--- a/components/style/selector_matching.rs
+++ b/components/style/selector_matching.rs
@@ -4,6 +4,7 @@
//! Selector matching.
+use {Atom, LocalName};
use dom::PresentationalHintsSynthetizer;
use element_state::*;
use error_reporting::StdoutErrorReporter;
@@ -19,7 +20,7 @@ use selectors::Element;
use selectors::bloom::BloomFilter;
use selectors::matching::{AFFECTED_BY_STYLE_ATTRIBUTE, AFFECTED_BY_PRESENTATIONAL_HINTS};
use selectors::matching::{MatchingReason, StyleRelations, matches_complex_selector};
-use selectors::parser::{Selector, SimpleSelector, LocalName, ComplexSelector};
+use selectors::parser::{Selector, SimpleSelector, LocalName as LocalNameSelector, ComplexSelector};
use sink::Push;
use smallvec::VecLike;
use std::borrow::Borrow;
@@ -29,7 +30,6 @@ use std::hash::BuildHasherDefault;
use std::hash::Hash;
use std::slice;
use std::sync::Arc;
-use string_cache::Atom;
use style_traits::viewport::ViewportConstraints;
use stylesheets::{CSSRule, Origin, Stylesheet, UserAgentStylesheets};
use viewport::{self, MaybeNew, ViewportRule};
@@ -661,10 +661,10 @@ pub struct SelectorMap {
// TODO: Tune the initial capacity of the HashMap
pub id_hash: FnvHashMap<Atom, Vec<Rule>>,
pub class_hash: FnvHashMap<Atom, Vec<Rule>>,
- pub local_name_hash: FnvHashMap<Atom, Vec<Rule>>,
+ pub local_name_hash: FnvHashMap<LocalName, Vec<Rule>>,
/// Same as local_name_hash, but keys are lower-cased.
/// For HTML elements in HTML documents.
- pub lower_local_name_hash: FnvHashMap<Atom, Vec<Rule>>,
+ pub lower_local_name_hash: FnvHashMap<LocalName, Vec<Rule>>,
/// Rules that don't have ID, class, or element selectors.
pub other_rules: Vec<Rule>,
/// Whether this hash is empty.
@@ -856,7 +856,7 @@ impl SelectorMap {
return;
}
- if let Some(LocalName { name, lower_name }) = SelectorMap::get_local_name(&rule) {
+ if let Some(LocalNameSelector { name, lower_name }) = SelectorMap::get_local_name(&rule) {
find_push(&mut self.local_name_hash, name, rule.clone());
find_push(&mut self.lower_local_name_hash, lower_name, rule);
return;
@@ -892,10 +892,10 @@ impl SelectorMap {
}
/// Retrieve the name if it is a type selector, or None otherwise.
- pub fn get_local_name(rule: &Rule) -> Option<LocalName<TheSelectorImpl>> {
+ pub fn get_local_name(rule: &Rule) -> Option<LocalNameSelector<TheSelectorImpl>> {
for ss in &rule.selector.compound_selector {
if let SimpleSelector::LocalName(ref n) = *ss {
- return Some(LocalName {
+ return Some(LocalNameSelector {
name: n.name.clone(),
lower_name: n.lower_name.clone(),
})
diff --git a/components/style/servo_selector_impl.rs b/components/style/servo_selector_impl.rs
index 0f0e8f985d9..f0dd0b3695c 100644
--- a/components/style/servo_selector_impl.rs
+++ b/components/style/servo_selector_impl.rs
@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use {Atom, Prefix, Namespace, LocalName};
use attr::{AttrIdentifier, AttrValue};
use cssparser::ToCss;
use element_state::ElementState;
@@ -11,7 +12,6 @@ use selector_impl::{attr_equals_selector_is_shareable, attr_exists_selector_is_s
use selectors::{Element, MatchAttrGeneric};
use selectors::parser::{AttrSelector, ParserContext, SelectorImpl};
use std::fmt;
-use string_cache::{Atom, Namespace};
/// NB: If you add to this list, be sure to update `each_pseudo_element` too.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
@@ -159,10 +159,10 @@ impl SelectorImpl for ServoSelectorImpl {
type AttrValue = String;
type Identifier = Atom;
type ClassName = Atom;
- type LocalName = Atom;
- type NamespacePrefix = Atom;
+ type LocalName = LocalName;
+ type NamespacePrefix = Prefix;
type NamespaceUrl = Namespace;
- type BorrowedLocalName = Atom;
+ type BorrowedLocalName = LocalName;
type BorrowedNamespaceUrl = Namespace;
fn attr_exists_selector_is_shareable(attr_selector: &AttrSelector<Self>) -> bool {
@@ -324,14 +324,14 @@ impl ServoElementSnapshot {
}
}
- fn get_attr(&self, namespace: &Namespace, name: &Atom) -> Option<&AttrValue> {
+ fn get_attr(&self, namespace: &Namespace, name: &LocalName) -> Option<&AttrValue> {
self.attrs.as_ref().unwrap().iter()
.find(|&&(ref ident, _)| ident.local_name == *name &&
ident.namespace == *namespace)
.map(|&(_, ref v)| v)
}
- fn get_attr_ignore_ns(&self, name: &Atom) -> Option<&AttrValue> {
+ fn get_attr_ignore_ns(&self, name: &LocalName) -> Option<&AttrValue> {
self.attrs.as_ref().unwrap().iter()
.find(|&&(ref ident, _)| ident.local_name == *name)
.map(|&(_, ref v)| v)
@@ -348,18 +348,18 @@ impl ElementSnapshot for ServoElementSnapshot {
}
fn id_attr(&self) -> Option<Atom> {
- self.get_attr(&ns!(), &atom!("id")).map(|v| v.as_atom().clone())
+ self.get_attr(&ns!(), &local_name!("id")).map(|v| v.as_atom().clone())
}
fn has_class(&self, name: &Atom) -> bool {
- self.get_attr(&ns!(), &atom!("class"))
+ self.get_attr(&ns!(), &local_name!("class"))
.map_or(false, |v| v.as_tokens().iter().any(|atom| atom == name))
}
fn each_class<F>(&self, mut callback: F)
where F: FnMut(&Atom)
{
- if let Some(v) = self.get_attr(&ns!(), &atom!("class")) {
+ if let Some(v) = self.get_attr(&ns!(), &local_name!("class")) {
for class in v.as_tokens() {
callback(class);
}
diff --git a/components/style/stylesheets.rs b/components/style/stylesheets.rs
index 715ee3fe3d3..f859e1ed549 100644
--- a/components/style/stylesheets.rs
+++ b/components/style/stylesheets.rs
@@ -4,6 +4,7 @@
//! Style sheets and their CSS rules.
+use {Atom, Prefix, Namespace};
use cssparser::{AtRuleParser, Parser, QualifiedRuleParser, decode_stylesheet_bytes};
use cssparser::{AtRuleType, RuleListParser, Token};
use encoding::EncodingRef;
@@ -18,7 +19,6 @@ use selector_impl::TheSelectorImpl;
use selectors::parser::{Selector, parse_selector_list};
use std::cell::Cell;
use std::sync::Arc;
-use string_cache::{Atom, Namespace};
use url::Url;
use viewport::ViewportRule;
@@ -99,7 +99,7 @@ impl CSSRule {
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct NamespaceRule {
/// `None` for the default Namespace
- pub prefix: Option<Atom>,
+ pub prefix: Option<Prefix>,
pub url: Namespace,
}
@@ -316,10 +316,10 @@ impl<'a> AtRuleParser for TopLevelRuleParser<'a> {
self.state.set(State::Namespaces);
let prefix_result = input.try(|input| input.expect_ident());
- let url = Namespace(Atom::from(try!(input.expect_url_or_string())));
+ let url = Namespace::from(try!(input.expect_url_or_string()));
let opt_prefix = if let Ok(prefix) = prefix_result {
- let prefix: Atom = prefix.into();
+ let prefix = Prefix::from(prefix);
self.context.selector_context.namespace_prefixes.insert(
prefix.clone(), url.clone());
Some(prefix)
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index 8aac0c5f748..2ad2a845d5f 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -720,9 +720,9 @@ dependencies = [
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"servo-fontconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "servo_atoms 0.0.1",
"simd 0.1.1 (git+https://github.com/huonw/simd)",
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"style_traits 0.0.1",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -845,11 +845,6 @@ dependencies = [
]
[[package]]
-name = "heapsize_plugin"
-version = "0.1.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
name = "heartbeats-simple"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -878,23 +873,34 @@ dependencies = [
[[package]]
name = "html5ever"
-version = "0.8.0"
+version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "html5ever-atoms 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mac 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"phf 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
"phf_codegen 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tendril 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
+name = "html5ever-atoms"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "string_cache 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "string_cache_codegen 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "httparse"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1070,6 +1076,7 @@ dependencies = [
"gfx_traits 0.0.1",
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "html5ever-atoms 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1085,8 +1092,8 @@ dependencies = [
"script_traits 0.0.1",
"selectors 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "servo_atoms 0.0.1",
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"style_traits 0.0.1",
"unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1828,7 +1835,8 @@ dependencies = [
"gfx_traits 0.0.1",
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "html5ever 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "html5ever 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "html5ever-atoms 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper_serde 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1858,8 +1866,8 @@ dependencies = [
"script_traits 0.0.1",
"selectors 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "servo_atoms 0.0.1",
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"style_traits 0.0.1",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1869,7 +1877,7 @@ dependencies = [
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.8.0 (git+https://github.com/servo/webrender)",
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "xml5ever 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "xml5ever 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1884,6 +1892,7 @@ dependencies = [
"gfx_traits 0.0.1",
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "html5ever-atoms 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1894,7 +1903,7 @@ dependencies = [
"range 0.0.1",
"script_traits 0.0.1",
"selectors 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
+ "servo_atoms 0.0.1",
"style 0.0.1",
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -2116,6 +2125,14 @@ dependencies = [
]
[[package]]
+name = "servo_atoms"
+version = "0.0.1"
+dependencies = [
+ "string_cache 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "string_cache_codegen 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "shared_library"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2164,18 +2181,33 @@ dependencies = [
[[package]]
name = "string_cache"
-version = "0.2.29"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "phf_generator 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
"phf_shared 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "string_cache_codegen 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
+name = "string_cache_codegen"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "phf_generator 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
+ "string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "string_cache_shared"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "style"
version = "0.0.1"
dependencies = [
@@ -2189,6 +2221,7 @@ dependencies = [
"fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "html5ever-atoms 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2207,8 +2240,8 @@ dependencies = [
"selectors 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "servo_atoms 0.0.1",
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"style_traits 0.0.1",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-segmentation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2675,15 +2708,15 @@ dependencies = [
[[package]]
name = "xml5ever"
-version = "0.1.3"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
+ "html5ever-atoms 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mac 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"phf 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
"phf_codegen 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)",
"tendril 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -2760,11 +2793,11 @@ dependencies = [
"checksum harfbuzz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6b76113246f5c089dcf272cf89c3f61168a4d77b50ec5b2c1fab8c628c9ea762"
"checksum heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8c80e194758495a9109566134dc06e42ea0423987d6ceca016edaa90381b3549"
"checksum heapsize_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "35abd70c0f2d6260b973ea908d7e4e3da729fc2acf18def91f034a2a4f824ff8"
-"checksum heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c9a70a1ef0122b54e0553f1d960b686c40d33a7953bc63029509a7649c8ee2c4"
"checksum heartbeats-simple 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "78c0810722eacd0bdd3f1f691524bd9900bf8fed1947f6b883c10ddecd2560b1"
"checksum heartbeats-simple-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53c4b67617665d7f4172f381f9843c1bec6a4fccc9a9226529e5b1be40dc1301"
"checksum hpack 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d2da7d3a34cf6406d9d700111b8eafafe9a251de41ae71d8052748259343b58"
-"checksum html5ever 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "74d996f271e5698e3eeae29754d59b2288973e20b898b53899ac7411356a0742"
+"checksum html5ever 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6a2e00f17a864dfee00d41b46fda2a669e10e96bf71f8c712b3c88f4977188d7"
+"checksum html5ever-atoms 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "860439a63e39a4d3506b9cff6107fa238f89edf7aee41ca5a055acb301a556a3"
"checksum httparse 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "46534074dbb80b070d60a5cb8ecadd8963a00a438ae1a95268850a7ef73b67ae"
"checksum hyper 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)" = "eb27e8a3e8f17ac43ffa41bbda9cf5ad3f9f13ef66fa4873409d4902310275f7"
"checksum hyper_serde 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "572d2168173019de312a050a24f2ad33ac2ac7895a2139fbf21ee6b6f470a24e"
@@ -2866,7 +2899,9 @@ dependencies = [
"checksum simd 0.1.1 (git+https://github.com/huonw/simd)" = "<none>"
"checksum smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "fcc8d19212aacecf95e4a7a2179b26f7aeb9732a915cf01f05b0d3e044865410"
"checksum solicit 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "172382bac9424588d7840732b250faeeef88942e37b6e35317dce98cafdd75b2"
-"checksum string_cache 0.2.29 (registry+https://github.com/rust-lang/crates.io-index)" = "f585562982abf1301fa97bd2226a3c4c5712b8beb9bcd16ed72b5e96810f8657"
+"checksum string_cache 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d192db2123fac37399e1ca61557904a5c3fb6fc24c73d2e47b15d20dc32470"
+"checksum string_cache_codegen 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0c9dfe1a7c8bba1ecb90730d269fdc08afe93d23c28dd6c4aa5cabd79a05a05e"
+"checksum string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc"
"checksum syn 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "76c2db66dc579998854d84ff0ff4a81cb73e69596764d144ce7cece4d04ce6b5"
"checksum synstructure 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c93b5595e44343867746223dd8de40c15e53e89f5fb252e3d20e0187a698647c"
"checksum target_build_utils 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a1be18d4d908e4e5697908de04fdd5099505463fc8eaf1ceb8133ae486936aa"
@@ -2911,4 +2946,4 @@ dependencies = [
"checksum xdg 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "77b831a5ba77110f438f0ac5583aafeb087f70432998ba6b7dcb1d32185db453"
"checksum xi-unicode 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "315c4e158d7fa277e3ea35b32e50bc07e9a0c8de9130a7cc4bdeab42ddc7b442"
"checksum xml-rs 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "65e74b96bd3179209dc70a980da6df843dff09e46eee103a0376c0949257e3ef"
-"checksum xml5ever 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fdbef89351fe48a35c50fc264fa10867a35912e9445753bdf21fbde4f4164af5"
+"checksum xml5ever 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a3aa816561c8d68419dec4c43df33974940cd6a03e376dfc497ec3e46fb7755"
diff --git a/tests/unit/style/Cargo.toml b/tests/unit/style/Cargo.toml
index 487105d8dcb..8e6c99670d7 100644
--- a/tests/unit/style/Cargo.toml
+++ b/tests/unit/style/Cargo.toml
@@ -17,7 +17,8 @@ owning_ref = "0.2.2"
parking_lot = "0.3"
rustc-serialize = "0.3"
selectors = "0.14"
-string_cache = {version = "0.2.26", features = ["heap_size"]}
+html5ever-atoms = "0.1"
+servo_atoms = {path = "../../../components/atoms"}
style = {path = "../../../components/style"}
style_traits = {path = "../../../components/style_traits"}
url = {version = "1.2", features = ["heap_size"]}
diff --git a/tests/unit/style/lib.rs b/tests/unit/style/lib.rs
index 1e3e7ac2313..09ff57605c7 100644
--- a/tests/unit/style/lib.rs
+++ b/tests/unit/style/lib.rs
@@ -9,11 +9,12 @@
extern crate app_units;
extern crate cssparser;
extern crate euclid;
+#[macro_use] extern crate html5ever_atoms;
extern crate owning_ref;
extern crate parking_lot;
extern crate rustc_serialize;
extern crate selectors;
-#[macro_use(atom, ns)] extern crate string_cache;
+#[macro_use] extern crate servo_atoms;
extern crate style;
extern crate style_traits;
extern crate url;
diff --git a/tests/unit/style/media_queries.rs b/tests/unit/style/media_queries.rs
index 46757bb9bf0..3d3a49afb40 100644
--- a/tests/unit/style/media_queries.rs
+++ b/tests/unit/style/media_queries.rs
@@ -6,7 +6,7 @@ use app_units::Au;
use cssparser::{Parser, SourcePosition};
use euclid::size::TypedSize2D;
use std::borrow::ToOwned;
-use string_cache::Atom;
+use style::Atom;
use style::error_reporting::ParseErrorReporter;
use style::media_queries::*;
use style::parser::ParserContextExtraData;
diff --git a/tests/unit/style/selector_matching.rs b/tests/unit/style/selector_matching.rs
index 1d5f4f8777f..15014c616a3 100644
--- a/tests/unit/style/selector_matching.rs
+++ b/tests/unit/style/selector_matching.rs
@@ -3,10 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::Parser;
+use html5ever_atoms::LocalName;
use parking_lot::RwLock;
-use selectors::parser::{LocalName, ParserContext, parse_selector_list};
+use selectors::parser::{LocalName as LocalNameSelector, ParserContext, parse_selector_list};
+use servo_atoms::Atom;
use std::sync::Arc;
-use string_cache::Atom;
use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, DeclaredValue};
use style::properties::{longhands, Importance};
use style::selector_matching::{Rule, SelectorMap};
@@ -78,9 +79,9 @@ fn test_get_local_name() {
let rules_list = get_mock_rules(&["img.foo", "#top", "IMG", "ImG"]);
let check = |i: usize, names: Option<(&str, &str)>| {
assert!(SelectorMap::get_local_name(&rules_list[i][0])
- == names.map(|(name, lower_name)| LocalName {
- name: Atom::from(name),
- lower_name: Atom::from(lower_name) }))
+ == names.map(|(name, lower_name)| LocalNameSelector {
+ name: LocalName::from(name),
+ lower_name: LocalName::from(lower_name) }))
};
check(0, Some(("img", "img")));
check(1, None);
diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs
index c664da50731..4ec9388d4c2 100644
--- a/tests/unit/style/stylesheets.rs
+++ b/tests/unit/style/stylesheets.rs
@@ -3,13 +3,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::{self, Parser, SourcePosition};
+use html5ever_atoms::{Namespace as NsAtom};
use media_queries::CSSErrorReporterTest;
use parking_lot::RwLock;
use selectors::parser::*;
+use servo_atoms::Atom;
use std::borrow::ToOwned;
use std::sync::Arc;
use std::sync::Mutex;
-use string_cache::{Atom, Namespace as NsAtom};
use style::error_reporting::ParseErrorReporter;
use style::keyframes::{Keyframe, KeyframeSelector, KeyframePercentage};
use style::parser::ParserContextExtraData;
@@ -58,7 +59,7 @@ fn test_parse_stylesheet() {
rules: vec![
CSSRule::Namespace(Arc::new(RwLock::new(NamespaceRule {
prefix: None,
- url: NsAtom(Atom::from("http://www.w3.org/1999/xhtml"))
+ url: NsAtom::from("http://www.w3.org/1999/xhtml")
}))),
CSSRule::Style(Arc::new(RwLock::new(StyleRule {
selectors: vec![
@@ -67,15 +68,15 @@ fn test_parse_stylesheet() {
compound_selector: vec![
SimpleSelector::Namespace(Namespace {
prefix: None,
- url: NsAtom(Atom::from("http://www.w3.org/1999/xhtml"))
+ url: NsAtom::from("http://www.w3.org/1999/xhtml")
}),
SimpleSelector::LocalName(LocalName {
- name: atom!("input"),
- lower_name: atom!("input"),
+ name: local_name!("input"),
+ lower_name: local_name!("input"),
}),
SimpleSelector::AttrEqual(AttrSelector {
- name: atom!("type"),
- lower_name: atom!("type"),
+ name: local_name!("type"),
+ lower_name: local_name!("type"),
namespace: NamespaceConstraint::Specific(Namespace {
prefix: None,
url: ns!()
@@ -106,11 +107,11 @@ fn test_parse_stylesheet() {
compound_selector: vec![
SimpleSelector::Namespace(Namespace {
prefix: None,
- url: NsAtom(Atom::from("http://www.w3.org/1999/xhtml"))
+ url: NsAtom::from("http://www.w3.org/1999/xhtml")
}),
SimpleSelector::LocalName(LocalName {
- name: atom!("html"),
- lower_name: atom!("html"),
+ name: local_name!("html"),
+ lower_name: local_name!("html"),
}),
],
next: None,
@@ -123,11 +124,11 @@ fn test_parse_stylesheet() {
compound_selector: vec![
SimpleSelector::Namespace(Namespace {
prefix: None,
- url: NsAtom(Atom::from("http://www.w3.org/1999/xhtml"))
+ url: NsAtom::from("http://www.w3.org/1999/xhtml")
}),
SimpleSelector::LocalName(LocalName {
- name: atom!("body"),
- lower_name: atom!("body"),
+ name: local_name!("body"),
+ lower_name: local_name!("body"),
}),
],
next: None,
@@ -152,7 +153,7 @@ fn test_parse_stylesheet() {
compound_selector: vec![
SimpleSelector::Namespace(Namespace {
prefix: None,
- url: NsAtom(Atom::from("http://www.w3.org/1999/xhtml"))
+ url: NsAtom::from("http://www.w3.org/1999/xhtml")
}),
SimpleSelector::Class(Atom::from("ok")),
],
@@ -160,7 +161,7 @@ fn test_parse_stylesheet() {
compound_selector: vec![
SimpleSelector::Namespace(Namespace {
prefix: None,
- url: NsAtom(Atom::from("http://www.w3.org/1999/xhtml"))
+ url: NsAtom::from("http://www.w3.org/1999/xhtml")
}),
SimpleSelector::ID(Atom::from("d1")),
],