Revert "script: Use atom comparison in more places, especially for attributes." for persistent test failures.

This reverts commit 874db26104.
This commit is contained in:
Josh Matthews 2014-09-18 09:20:19 -04:00
parent 7158cac2dc
commit 9607b468bc
32 changed files with 147 additions and 300 deletions

View file

@ -39,12 +39,3 @@ git = "https://github.com/servo/rust-geom"
[dependencies.url]
git = "https://github.com/servo/rust-url"
[dependencies.string_cache]
git = "https://github.com/servo/string-cache"
branch = "pre-rustup"
[dependencies.string_cache_macros]
git = "https://github.com/servo/string-cache"
branch = "pre-rustup"

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::atom::Atom;
use servo_util::namespace;
use std::mem;
use std::sync::atomics::Relaxed;
@ -1052,8 +1051,7 @@ trait ObjectElement {
impl<'ln> ObjectElement for ThreadSafeLayoutNode<'ln> {
fn get_type_and_data(&self) -> (Option<&'static str>, Option<&'static str>) {
let elem = self.as_element();
(elem.get_attr(&namespace::Null, &satom!("type")),
elem.get_attr(&namespace::Null, &satom!("data")))
(elem.get_attr(&namespace::Null, "type"), elem.get_attr(&namespace::Null, "data"))
}
fn has_object_data(&self) -> bool {

View file

@ -223,7 +223,8 @@ impl StyleSharingCandidate {
style: style,
parent_style: parent_style,
local_name: element.get_local_name().clone(),
class: element.get_attr(&Null, &satom!("class")).map(|string| string.to_string()),
class: element.get_attr(&Null, "class")
.map(|string| string.to_string()),
})
}
@ -231,7 +232,7 @@ impl StyleSharingCandidate {
if *element.get_local_name() != self.local_name {
return false
}
match (&self.class, element.get_attr(&Null, &satom!("class"))) {
match (&self.class, element.get_attr(&Null, "class")) {
(&None, Some(_)) | (&Some(_), None) => return false,
(&Some(ref this_class), Some(element_class)) if element_class != this_class.as_slice() => {
return false
@ -453,7 +454,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
}
let ok = {
let element = self.as_element();
element.style_attribute().is_none() && element.get_attr(&Null, &satom!("id")).is_none()
element.style_attribute().is_none() && element.get_attr(&Null, "id").is_none()
};
if !ok {
return CannotShare(false)
@ -500,7 +501,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
// TODO: case-sensitivity depends on the document type and quirks mode
element
.get_attr(&Null, &satom!("class"))
.get_attr(&Null, "class")
.map(|attr| {
for c in attr.split(style::SELECTOR_WHITESPACE) {
bf.insert(&c);
@ -519,7 +520,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
// TODO: case-sensitivity depends on the document type and quirks mode
element
.get_attr(&Null, &satom!("class"))
.get_attr(&Null, "class")
.map(|attr| {
for c in attr.split(style::SELECTOR_WHITESPACE) {
bf.remove(&c);

View file

@ -39,7 +39,6 @@ use serialize::{Encodable, Encoder};
use servo_msg::constellation_msg::{ConstellationChan, FrameRectMsg, PipelineId, SubpageId};
use servo_net::image::holder::ImageHolder;
use servo_net::local_image_cache::LocalImageCache;
use servo_util::atom::Atom;
use servo_util::geometry::Au;
use servo_util::geometry;
use servo_util::logical_geometry::{LogicalRect, LogicalSize, LogicalMargin};
@ -175,7 +174,7 @@ impl ImageFragmentInfo {
image_url: Url,
local_image_cache: Arc<Mutex<LocalImageCache>>)
-> ImageFragmentInfo {
fn convert_length(node: &ThreadSafeLayoutNode, name: &Atom) -> Option<Au> {
fn convert_length(node: &ThreadSafeLayoutNode, name: &str) -> Option<Au> {
let element = node.as_element();
element.get_attr(&namespace::Null, name).and_then(|string| {
let n: Option<int> = FromStr::from_str(string);
@ -184,8 +183,8 @@ impl ImageFragmentInfo {
}
let is_vertical = node.style().writing_mode.is_vertical();
let dom_width = convert_length(node, &satom!("width"));
let dom_height = convert_length(node, &satom!("height"));
let dom_width = convert_length(node, "width");
let dom_height = convert_length(node, "height");
ImageFragmentInfo {
image: ImageHolder::new(image_url, local_image_cache),
computed_inline_size: None,
@ -338,7 +337,7 @@ impl TableColumnFragmentInfo {
pub fn new(node: &ThreadSafeLayoutNode) -> TableColumnFragmentInfo {
let span = {
let element = node.as_element();
element.get_attr(&namespace::Null, &satom!("span")).and_then(|string| {
element.get_attr(&namespace::Null, "span").and_then(|string| {
let n: Option<int> = FromStr::from_str(string);
n
})

View file

@ -29,10 +29,6 @@ extern crate servo_msg = "msg";
#[phase(plugin, link)]
extern crate servo_util = "util";
#[phase(plugin)]
extern crate string_cache_macros;
extern crate string_cache;
extern crate collections;
extern crate encoding;
extern crate green;

View file

@ -273,14 +273,15 @@ impl<'ln> TNode<LayoutElement<'ln>> for LayoutNode<'ln> {
fn match_attr(&self, attr: &AttrSelector, test: |&str| -> bool) -> bool {
assert!(self.is_element())
let name = if self.is_html_element_in_html_document() {
&attr.lower_name
attr.lower_name.as_slice()
} else {
&attr.name
attr.name.as_slice()
};
match attr.namespace {
SpecificNamespace(ref ns) => {
let element = self.as_element();
element.get_attr(ns, name).map_or(false, |attr| test(attr))
element.get_attr(ns, name)
.map_or(false, |attr| test(attr))
},
// FIXME: https://github.com/mozilla/servo/issues/1558
AnyNamespace => false,
@ -382,7 +383,7 @@ impl<'le> TElement for LayoutElement<'le> {
}
#[inline]
fn get_attr(&self, namespace: &Namespace, name: &Atom) -> Option<&'static str> {
fn get_attr(&self, namespace: &Namespace, name: &str) -> Option<&'static str> {
unsafe { self.element.get_attr_val_for_layout(namespace, name) }
}
@ -394,9 +395,7 @@ impl<'le> TElement for LayoutElement<'le> {
ElementNodeTypeId(HTMLAnchorElementTypeId) |
ElementNodeTypeId(HTMLAreaElementTypeId) |
ElementNodeTypeId(HTMLLinkElementTypeId) => {
unsafe {
self.element.get_attr_val_for_layout(&namespace::Null, &satom!("href"))
}
unsafe { self.element.get_attr_val_for_layout(&namespace::Null, "href") }
}
_ => None,
}
@ -410,9 +409,7 @@ impl<'le> TElement for LayoutElement<'le> {
#[inline]
fn get_id(&self) -> Option<Atom> {
unsafe {
self.element.get_attr_atom_for_layout(&namespace::Null, &satom!("id"))
}
unsafe { self.element.get_attr_atom_for_layout(&namespace::Null, "id") }
}
fn get_disabled_state(&self) -> bool {
@ -427,24 +424,11 @@ impl<'le> TElement for LayoutElement<'le> {
}
}
fn has_class(&self, name: &Atom) -> bool {
fn has_class(&self, name: &str) -> bool {
unsafe {
self.element.has_class_for_layout(name)
}
}
fn each_class(&self, callback: |&Atom|) {
unsafe {
match self.element.get_classes_for_layout() {
None => {}
Some(ref classes) => {
for class in classes.iter() {
callback(class)
}
}
}
}
}
}
fn get_content(content_list: &content::T) -> String {
@ -774,10 +758,8 @@ pub struct ThreadSafeLayoutElement<'le> {
impl<'le> ThreadSafeLayoutElement<'le> {
#[inline]
pub fn get_attr(&self, namespace: &Namespace, name: &Atom) -> Option<&'static str> {
unsafe {
self.element.get_attr_val_for_layout(namespace, name)
}
pub fn get_attr(&self, namespace: &Namespace, name: &str) -> Option<&'static str> {
unsafe { self.element.get_attr_val_for_layout(namespace, name) }
}
}