Don't borrow CharacterData.data from layout.

This should fix the most frequent intermittent wpt failure.
This commit is contained in:
Ms2ger 2014-10-14 10:49:33 +02:00
parent fd70b366ae
commit 16e071168c
2 changed files with 9 additions and 2 deletions

View file

@ -189,7 +189,7 @@ impl<'ln> TLayoutNode for LayoutNode<'ln> {
unsafe {
if self.get().is_text() {
let text: JS<Text> = self.get_jsmanaged().transmute_copy();
(*text.unsafe_get()).characterdata().data().clone()
(*text.unsafe_get()).characterdata().data_for_layout().to_string()
} else if self.get().is_htmlinputelement() {
let input: JS<HTMLInputElement> = self.get_jsmanaged().transmute_copy();
input.get_value_for_layout()
@ -765,7 +765,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
Some(TextNodeTypeId) => {
unsafe {
let text: JS<Text> = self.get_jsmanaged().transmute_copy();
if !is_whitespace((*text.unsafe_get()).characterdata().data().as_slice()) {
if !is_whitespace((*text.unsafe_get()).characterdata().data_for_layout()) {
return false
}

View file

@ -15,6 +15,7 @@ use dom::node::{CommentNodeTypeId, Node, NodeTypeId, TextNodeTypeId, ProcessingI
use servo_util::str::DOMString;
use std::cell::{Ref, RefCell};
use std::mem;
#[jstraceable]
#[must_root]
@ -57,6 +58,12 @@ impl CharacterData {
pub fn set_data(&self, data: DOMString) {
*self.data.borrow_mut() = data;
}
#[inline]
pub unsafe fn data_for_layout<'a>(&'a self) -> &'a str {
mem::transmute::<&RefCell<DOMString>, &DOMString>(&self.data).as_slice()
}
}
impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {