mirror of
https://github.com/servo/servo.git
synced 2025-06-09 00:53:26 +00:00
auto merge of #3841 : pcwalton/servo/removing-whitespace-damage, r=cgaebel
Avoids total reflow of the entire document on the maze solver. I have tested Wikipedia reflow and it still works. r? @cgaebel
This commit is contained in:
commit
c20bb66aef
1 changed files with 6 additions and 18 deletions
|
@ -306,15 +306,13 @@ impl<'a> FlowConstructor<'a> {
|
||||||
match whitespace_stripping {
|
match whitespace_stripping {
|
||||||
NoWhitespaceStripping => {}
|
NoWhitespaceStripping => {}
|
||||||
StripWhitespaceFromStart => {
|
StripWhitespaceFromStart => {
|
||||||
flow::mut_base(flow.deref_mut()).restyle_damage.insert(
|
strip_ignorable_whitespace_from_start(&mut fragments);
|
||||||
strip_ignorable_whitespace_from_start(&mut fragments));
|
|
||||||
if fragments.is_empty() {
|
if fragments.is_empty() {
|
||||||
return
|
return
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
StripWhitespaceFromEnd => {
|
StripWhitespaceFromEnd => {
|
||||||
flow::mut_base(flow.deref_mut()).restyle_damage.insert(
|
strip_ignorable_whitespace_from_end(&mut fragments);
|
||||||
strip_ignorable_whitespace_from_end(&mut fragments));
|
|
||||||
if fragments.is_empty() {
|
if fragments.is_empty() {
|
||||||
return
|
return
|
||||||
};
|
};
|
||||||
|
@ -1232,36 +1230,26 @@ impl FlowConstructionUtils for FlowRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Strips ignorable whitespace from the start of a list of fragments.
|
/// Strips ignorable whitespace from the start of a list of fragments.
|
||||||
///
|
pub fn strip_ignorable_whitespace_from_start(this: &mut DList<Fragment>) {
|
||||||
/// Returns some damage that must be added to the `InlineFlow`.
|
|
||||||
pub fn strip_ignorable_whitespace_from_start(this: &mut DList<Fragment>) -> RestyleDamage {
|
|
||||||
if this.is_empty() {
|
if this.is_empty() {
|
||||||
return RestyleDamage::empty() // Fast path.
|
return // Fast path.
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut damage = RestyleDamage::empty();
|
|
||||||
while !this.is_empty() && this.front().as_ref().unwrap().is_ignorable_whitespace() {
|
while !this.is_empty() && this.front().as_ref().unwrap().is_ignorable_whitespace() {
|
||||||
debug!("stripping ignorable whitespace from start");
|
debug!("stripping ignorable whitespace from start");
|
||||||
damage = RestyleDamage::all();
|
|
||||||
drop(this.pop_front());
|
drop(this.pop_front());
|
||||||
}
|
}
|
||||||
damage
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Strips ignorable whitespace from the end of a list of fragments.
|
/// Strips ignorable whitespace from the end of a list of fragments.
|
||||||
///
|
pub fn strip_ignorable_whitespace_from_end(this: &mut DList<Fragment>) {
|
||||||
/// Returns some damage that must be added to the `InlineFlow`.
|
|
||||||
pub fn strip_ignorable_whitespace_from_end(this: &mut DList<Fragment>) -> RestyleDamage {
|
|
||||||
if this.is_empty() {
|
if this.is_empty() {
|
||||||
return RestyleDamage::empty();
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut damage = RestyleDamage::empty();
|
|
||||||
while !this.is_empty() && this.back().as_ref().unwrap().is_ignorable_whitespace() {
|
while !this.is_empty() && this.back().as_ref().unwrap().is_ignorable_whitespace() {
|
||||||
debug!("stripping ignorable whitespace from end");
|
debug!("stripping ignorable whitespace from end");
|
||||||
damage = RestyleDamage::all();
|
|
||||||
drop(this.pop());
|
drop(this.pop());
|
||||||
}
|
}
|
||||||
damage
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue