mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
auto merge of #1728 : june0cho/servo/whitespace_nbsp, r=SimonSapin
Fix #1727.
This commit is contained in:
commit
013010ddd5
3 changed files with 10 additions and 5 deletions
|
@ -22,6 +22,7 @@ use servo_util::geometry::Au;
|
||||||
use servo_util::geometry;
|
use servo_util::geometry;
|
||||||
use servo_util::range::*;
|
use servo_util::range::*;
|
||||||
use servo_util::namespace;
|
use servo_util::namespace;
|
||||||
|
use servo_util::str::is_whitespace;
|
||||||
|
|
||||||
use std::cast;
|
use std::cast;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
@ -1428,7 +1429,7 @@ impl Box {
|
||||||
/// Returns true if this box is an unscanned text box that consists entirely of whitespace.
|
/// Returns true if this box is an unscanned text box that consists entirely of whitespace.
|
||||||
pub fn is_whitespace_only(&self) -> bool {
|
pub fn is_whitespace_only(&self) -> bool {
|
||||||
match self.specific {
|
match self.specific {
|
||||||
UnscannedTextBox(ref text_box_info) => text_box_info.text.is_whitespace(),
|
UnscannedTextBox(ref text_box_info) => is_whitespace(text_box_info.text),
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ use style::ComputedValues;
|
||||||
use servo_util::namespace;
|
use servo_util::namespace;
|
||||||
use servo_util::url::parse_url;
|
use servo_util::url::parse_url;
|
||||||
use servo_util::url::is_image_data;
|
use servo_util::url::is_image_data;
|
||||||
|
use servo_util::str::is_whitespace;
|
||||||
|
|
||||||
use extra::url::Url;
|
use extra::url::Url;
|
||||||
use extra::arc::Arc;
|
use extra::arc::Arc;
|
||||||
|
@ -724,10 +725,7 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
|
||||||
match self.type_id() {
|
match self.type_id() {
|
||||||
TextNodeTypeId => {
|
TextNodeTypeId => {
|
||||||
unsafe {
|
unsafe {
|
||||||
if !self.with_text(|text| text.characterdata
|
if !self.with_text(|text| is_whitespace(text.characterdata.data)) {
|
||||||
.data
|
|
||||||
.chars()
|
|
||||||
.all(|c| c.is_whitespace())) {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,3 +19,9 @@ pub fn null_str_as_empty_ref<'a>(s: &'a Option<DOMString>) -> &'a str {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_whitespace(s: &str) -> bool {
|
||||||
|
s.chars().all(|c| match c {
|
||||||
|
'\u0020' | '\u0009' | '\u000D' | '\u000A' => true,
|
||||||
|
_ => false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue