mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Attempt to fix incremental layout
I have no idea how to test it, but this code builds and is close enough to what it was befor #1109. Review much needed.
This commit is contained in:
parent
9b25df1968
commit
86da932927
2 changed files with 26 additions and 25 deletions
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use css::node_style::StyledNode;
|
use css::node_style::StyledNode;
|
||||||
|
use css::node_util::NodeUtil;
|
||||||
|
use layout::incremental;
|
||||||
|
|
||||||
use script::dom::node::{AbstractNode, LayoutView};
|
use script::dom::node::{AbstractNode, LayoutView};
|
||||||
use style::Stylist;
|
use style::Stylist;
|
||||||
|
@ -39,7 +41,7 @@ impl MatchMethods for AbstractNode<LayoutView> {
|
||||||
|
|
||||||
for kid in self.children() {
|
for kid in self.children() {
|
||||||
if kid.is_element() {
|
if kid.is_element() {
|
||||||
kid.match_subtree(stylist);
|
kid.match_subtree(stylist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +56,15 @@ impl MatchMethods for AbstractNode<LayoutView> {
|
||||||
};
|
};
|
||||||
let cell = Cell::new(computed_values);
|
let cell = Cell::new(computed_values);
|
||||||
do self.write_layout_data |data| {
|
do self.write_layout_data |data| {
|
||||||
data.style = Some(cell.take());
|
let style = cell.take();
|
||||||
|
// If there was an existing style, compute the damage that
|
||||||
|
// incremental layout will need to fix.
|
||||||
|
match data.style {
|
||||||
|
None => (),
|
||||||
|
Some(ref previous_style) => self.set_restyle_damage(
|
||||||
|
incremental::compute_damage(previous_style, &style))
|
||||||
|
}
|
||||||
|
data.style = Some(style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn cascade_subtree(&self, parent: Option<AbstractNode<LayoutView>>) {
|
fn cascade_subtree(&self, parent: Option<AbstractNode<LayoutView>>) {
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use newcss::complete::CompleteSelectResults;
|
use style::ComputedValues;
|
||||||
|
|
||||||
use script::dom::node::{AbstractNode, LayoutView};
|
|
||||||
|
|
||||||
/// Individual layout actions that may be necessary after restyling.
|
/// Individual layout actions that may be necessary after restyling.
|
||||||
///
|
///
|
||||||
|
@ -113,18 +111,14 @@ impl RestyleDamage {
|
||||||
// breakage on modifications.
|
// breakage on modifications.
|
||||||
macro_rules! add_if_not_equal(
|
macro_rules! add_if_not_equal(
|
||||||
($old:ident, $new:ident, $damage:ident,
|
($old:ident, $new:ident, $damage:ident,
|
||||||
[ $($effect:ident),* ], [ $($getter:ident),* ]) => ({
|
[ $($effect:ident),* ], [ $($style_struct:ident.$name:ident),* ]) => ({
|
||||||
if $( ($old.$getter() != $new.$getter()) )||* {
|
if $( ($old.$style_struct.$name != $new.$style_struct.$name) )||* {
|
||||||
$damage.union_in_place( restyle_damage!( $($effect),* ) );
|
$damage.union_in_place( restyle_damage!( $($effect),* ) );
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
pub fn compute_damage(node: &AbstractNode<LayoutView>,
|
pub fn compute_damage(old: &ComputedValues, new: &ComputedValues) -> RestyleDamage {
|
||||||
old_results: &CompleteSelectResults, new_results: &CompleteSelectResults)
|
|
||||||
-> RestyleDamage {
|
|
||||||
let old = old_results.computed_style();
|
|
||||||
let new = new_results.computed_style();
|
|
||||||
let mut damage = RestyleDamage::none();
|
let mut damage = RestyleDamage::none();
|
||||||
|
|
||||||
// This checks every CSS property, as enumerated in
|
// This checks every CSS property, as enumerated in
|
||||||
|
@ -134,21 +128,18 @@ pub fn compute_damage(node: &AbstractNode<LayoutView>,
|
||||||
// FIXME: We can short-circuit more of this.
|
// FIXME: We can short-circuit more of this.
|
||||||
|
|
||||||
add_if_not_equal!(old, new, damage, [ Repaint ],
|
add_if_not_equal!(old, new, damage, [ Repaint ],
|
||||||
[ color, background_color, border_top_color, border_right_color,
|
[ Color.color, Background.background_color,
|
||||||
border_bottom_color, border_left_color ]);
|
Border.border_top_color, Border.border_right_color,
|
||||||
|
Border.border_bottom_color, Border.border_left_color ]);
|
||||||
|
|
||||||
add_if_not_equal!(old, new, damage, [ Repaint, BubbleWidths, Reflow ],
|
add_if_not_equal!(old, new, damage, [ Repaint, BubbleWidths, Reflow ],
|
||||||
[ border_top_width, border_right_width, border_bottom_width,
|
[ Border.border_top_width, Border.border_right_width,
|
||||||
border_left_width, margin_top, margin_right, margin_bottom, margin_left,
|
Border.border_bottom_width, Border.border_left_width,
|
||||||
padding_top, padding_right, padding_bottom, padding_left, position,
|
Margin.margin_top, Margin.margin_right, Margin.margin_bottom, Margin.margin_left,
|
||||||
width, height, float, font_family, font_size, font_style, font_weight,
|
Padding.padding_top, Padding.padding_right, Padding.padding_bottom, Padding.padding_left,
|
||||||
text_align, text_decoration, line_height ]);
|
Box.position, Box.width, Box.height, Box.float, Box.display,
|
||||||
|
Font.font_family, Font.font_size, Font.font_style, Font.font_weight,
|
||||||
// Handle 'display' specially because it has this 'is_root' parameter.
|
Text.text_align, Text.text_decoration, Box.line_height ]);
|
||||||
let is_root = node.is_root();
|
|
||||||
if old.display(is_root) != new.display(is_root) {
|
|
||||||
damage.union_in_place(restyle_damage!(Repaint, BubbleWidths, Reflow));
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: test somehow that we checked every CSS property
|
// FIXME: test somehow that we checked every CSS property
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue