Use string-cache's Namespace type

This commit is contained in:
Keegan McAllister 2014-09-29 18:30:01 -07:00
parent 6429750b33
commit d50114c41d
27 changed files with 126 additions and 183 deletions

View file

@ -57,7 +57,6 @@ use script::dom::node::{CommentNodeTypeId, DoctypeNodeTypeId, DocumentFragmentNo
use script::dom::node::{DocumentNodeTypeId, ElementNodeTypeId, ProcessingInstructionNodeTypeId};
use script::dom::node::{TextNodeTypeId};
use script::dom::htmlobjectelement::is_image_data;
use servo_util::namespace;
use std::mem;
use std::sync::atomics::Relaxed;
use style::ComputedValues;
@ -1091,7 +1090,7 @@ trait ObjectElement<'a> {
impl<'ln> ObjectElement<'ln> for ThreadSafeLayoutNode<'ln> {
fn get_type_and_data(&self) -> (Option<&'ln str>, Option<&'ln str>) {
let elem = self.as_element();
(elem.get_attr(&namespace::Null, "type"), elem.get_attr(&namespace::Null, "data"))
(elem.get_attr(&ns!(""), "type"), elem.get_attr(&ns!(""), "data"))
}
fn has_object_data(&self) -> bool {

View file

@ -13,7 +13,6 @@ use wrapper::{LayoutElement, LayoutNode, PostorderNodeMutTraversal, ThreadSafeLa
use script::dom::node::{TextNodeTypeId};
use servo_util::bloom::BloomFilter;
use servo_util::cache::{Cache, LRUCache, SimpleHashCache};
use servo_util::namespace::Null;
use servo_util::smallvec::{SmallVec, SmallVec16};
use servo_util::str::DOMString;
use std::mem;
@ -223,7 +222,7 @@ impl StyleSharingCandidate {
style: style,
parent_style: parent_style,
local_name: element.get_local_name().clone(),
class: element.get_attr(&Null, "class")
class: element.get_attr(&ns!(""), "class")
.map(|string| string.to_string()),
})
}
@ -232,7 +231,7 @@ impl StyleSharingCandidate {
if *element.get_local_name() != self.local_name {
return false
}
match (&self.class, element.get_attr(&Null, "class")) {
match (&self.class, element.get_attr(&ns!(""), "class")) {
(&None, Some(_)) | (&Some(_), None) => return false,
(&Some(ref this_class), Some(element_class)) if element_class != this_class.as_slice() => {
return false
@ -454,7 +453,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
}
let ok = {
let element = self.as_element();
element.style_attribute().is_none() && element.get_attr(&Null, "id").is_none()
element.style_attribute().is_none() && element.get_attr(&ns!(""), "id").is_none()
};
if !ok {
return CannotShare(false)
@ -501,7 +500,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
// TODO: case-sensitivity depends on the document type and quirks mode
element
.get_attr(&Null, "class")
.get_attr(&ns!(""), "class")
.map(|attr| {
for c in attr.split(style::SELECTOR_WHITESPACE) {
bf.insert(&c);
@ -520,7 +519,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
// TODO: case-sensitivity depends on the document type and quirks mode
element
.get_attr(&Null, "class")
.get_attr(&ns!(""), "class")
.map(|attr| {
for c in attr.split(style::SELECTOR_WHITESPACE) {
bf.remove(&c);

View file

@ -43,7 +43,6 @@ use servo_util::geometry::Au;
use servo_util::geometry;
use servo_util::logical_geometry::{LogicalRect, LogicalSize, LogicalMargin};
use servo_util::range::*;
use servo_util::namespace;
use servo_util::smallvec::SmallVec;
use servo_util::str::is_whitespace;
use std::cmp::{max, min};
@ -179,7 +178,7 @@ impl ImageFragmentInfo {
-> ImageFragmentInfo {
fn convert_length(node: &ThreadSafeLayoutNode, name: &str) -> Option<Au> {
let element = node.as_element();
element.get_attr(&namespace::Null, name).and_then(|string| {
element.get_attr(&ns!(""), name).and_then(|string| {
let n: Option<int> = FromStr::from_str(string);
n
}).and_then(|pixels| Some(Au::from_px(pixels)))
@ -352,7 +351,7 @@ impl TableColumnFragmentInfo {
pub fn new(node: &ThreadSafeLayoutNode) -> TableColumnFragmentInfo {
let span = {
let element = node.as_element();
element.get_attr(&namespace::Null, "span").and_then(|string| {
element.get_attr(&ns!(""), "span").and_then(|string| {
let n: Option<int> = FromStr::from_str(string);
n
})

View file

@ -48,8 +48,6 @@ use script::dom::node::{LayoutNodeHelpers, RawLayoutNodeHelpers, SharedLayoutDat
use script::dom::text::Text;
use script::layout_interface::LayoutChan;
use servo_msg::constellation_msg::{PipelineId, SubpageId};
use servo_util::namespace::Namespace;
use servo_util::namespace;
use servo_util::str::is_whitespace;
use std::cell::{RefCell, Ref, RefMut};
use std::kinds::marker::ContravariantLifetime;
@ -58,7 +56,7 @@ use style::computed_values::{content, display, white_space};
use style::{AnyNamespace, AttrSelector, PropertyDeclarationBlock, SpecificNamespace, TElement};
use style::{TNode};
use url::Url;
use string_cache::Atom;
use string_cache::{Atom, Namespace};
/// Allows some convenience methods on generic layout nodes.
pub trait TLayoutNode {
@ -413,7 +411,7 @@ impl<'le> TElement<'le> for LayoutElement<'le> {
ElementNodeTypeId(HTMLAnchorElementTypeId) |
ElementNodeTypeId(HTMLAreaElementTypeId) |
ElementNodeTypeId(HTMLLinkElementTypeId) => {
unsafe { self.element.get_attr_val_for_layout(&namespace::Null, "href") }
unsafe { self.element.get_attr_val_for_layout(&ns!(""), "href") }
}
_ => None,
}
@ -427,7 +425,7 @@ impl<'le> TElement<'le> for LayoutElement<'le> {
#[inline]
fn get_id(&self) -> Option<Atom> {
unsafe { self.element.get_attr_atom_for_layout(&namespace::Null, "id") }
unsafe { self.element.get_attr_atom_for_layout(&ns!(""), "id") }
}
fn get_disabled_state(&self) -> bool {