mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Remove unnecessary ClipDisplayItems in box_.rs
For ScannedTextBox and ImageBox, the ClipDisplayItem's child_list is currently always empty. ClipDisplayItem is used to implement overflow hidden and should only be created for block containers, as per http://www.w3.org/TR/CSS2/visufx.html#propdef-overflow Take care of the case when a BlockFlow has no children display items - like an ImageBox with "display: block".
This commit is contained in:
parent
73d0ceac54
commit
35a869d3d6
2 changed files with 49 additions and 54 deletions
|
@ -967,18 +967,6 @@ impl Box {
|
||||||
match self.specific {
|
match self.specific {
|
||||||
UnscannedTextBox(_) => fail!("Shouldn't see unscanned boxes here."),
|
UnscannedTextBox(_) => fail!("Shouldn't see unscanned boxes here."),
|
||||||
ScannedTextBox(ref text_box) => {
|
ScannedTextBox(ref text_box) => {
|
||||||
lists.with_mut(|lists| {
|
|
||||||
let item = ~ClipDisplayItem {
|
|
||||||
base: BaseDisplayItem {
|
|
||||||
bounds: absolute_box_bounds,
|
|
||||||
extra: ExtraDisplayListData::new(self),
|
|
||||||
},
|
|
||||||
child_list: ~[],
|
|
||||||
need_clip: false
|
|
||||||
};
|
|
||||||
lists.lists[index].append_item(ClipDisplayItemClass(item));
|
|
||||||
});
|
|
||||||
|
|
||||||
let text_color = self.style().Color.color.to_gfx_color();
|
let text_color = self.style().Color.color.to_gfx_color();
|
||||||
|
|
||||||
// Set the various text display item flags.
|
// Set the various text display item flags.
|
||||||
|
@ -1104,18 +1092,6 @@ impl Box {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
ImageBox(ref image_box) => {
|
ImageBox(ref image_box) => {
|
||||||
lists.with_mut(|lists| {
|
|
||||||
let item = ~ClipDisplayItem {
|
|
||||||
base: BaseDisplayItem {
|
|
||||||
bounds: absolute_box_bounds,
|
|
||||||
extra: ExtraDisplayListData::new(self),
|
|
||||||
},
|
|
||||||
child_list: ~[],
|
|
||||||
need_clip: false
|
|
||||||
};
|
|
||||||
lists.lists[index].append_item(ClipDisplayItemClass(item));
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut image_ref = image_box.image.borrow_mut();
|
let mut image_ref = image_box.image.borrow_mut();
|
||||||
let mut bounds = absolute_box_bounds.clone();
|
let mut bounds = absolute_box_bounds.clone();
|
||||||
bounds.origin.x = bounds.origin.x + self.noncontent_left()
|
bounds.origin.x = bounds.origin.x + self.noncontent_left()
|
||||||
|
|
|
@ -167,6 +167,9 @@ pub trait ImmutableFlowUtils {
|
||||||
/// Returns the number of children that this flow possesses.
|
/// Returns the number of children that this flow possesses.
|
||||||
fn child_count(self) -> uint;
|
fn child_count(self) -> uint;
|
||||||
|
|
||||||
|
/// Return true if this flow is a Block Container.
|
||||||
|
fn is_block_container(self) -> bool;
|
||||||
|
|
||||||
/// Returns true if this flow is a block flow, an inline flow, or a float flow.
|
/// Returns true if this flow is a block flow, an inline flow, or a float flow.
|
||||||
fn starts_block_flow(self) -> bool;
|
fn starts_block_flow(self) -> bool;
|
||||||
|
|
||||||
|
@ -604,6 +607,23 @@ impl<'a> ImmutableFlowUtils for &'a Flow {
|
||||||
base(self).children.len()
|
base(self).children.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return true if this flow is a Block Container.
|
||||||
|
///
|
||||||
|
/// Except for table boxes and replaced elements, block-level boxes (`BlockFlow`) are
|
||||||
|
/// also block container boxes.
|
||||||
|
/// Non-replaced inline blocks and non-replaced table cells are also block
|
||||||
|
/// containers.
|
||||||
|
fn is_block_container(self) -> bool {
|
||||||
|
match self.class() {
|
||||||
|
// TODO: Change this when inline-blocks are supported.
|
||||||
|
InlineFlowClass => false,
|
||||||
|
BlockFlowClass => {
|
||||||
|
// FIXME: Actually check the type of the node
|
||||||
|
self.child_count() != 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns true if this flow is a block flow, an inline-block flow, or a float flow.
|
/// Returns true if this flow is a block flow, an inline-block flow, or a float flow.
|
||||||
fn starts_block_flow(self) -> bool {
|
fn starts_block_flow(self) -> bool {
|
||||||
match self.class() {
|
match self.class() {
|
||||||
|
@ -720,6 +740,7 @@ impl<'a> MutableFlowUtils for &'a mut Flow {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.is_block_container() {
|
||||||
let mut child_lists = DisplayListCollection::new();
|
let mut child_lists = DisplayListCollection::new();
|
||||||
child_lists.add_list(DisplayList::new());
|
child_lists.add_list(DisplayList::new());
|
||||||
let child_lists = RefCell::new(child_lists);
|
let child_lists = RefCell::new(child_lists);
|
||||||
|
@ -730,9 +751,6 @@ impl<'a> MutableFlowUtils for &'a mut Flow {
|
||||||
let mut child_lists = Some(child_lists.unwrap());
|
let mut child_lists = Some(child_lists.unwrap());
|
||||||
// Find parent ClipDisplayItemClass and push all child display items
|
// Find parent ClipDisplayItemClass and push all child display items
|
||||||
// under it
|
// under it
|
||||||
// FIXME: Once we have children for InlineFlow, this might lead to
|
|
||||||
// children display items being pushed under the ClipDisplayItemClass
|
|
||||||
// created by the last box of the InlineFlow. Fix the logic.
|
|
||||||
lists.with_mut(|lists| {
|
lists.with_mut(|lists| {
|
||||||
let mut child_lists = child_lists.take_unwrap();
|
let mut child_lists = child_lists.take_unwrap();
|
||||||
let result = lists.lists[index].list.mut_rev_iter().position(|item| {
|
let result = lists.lists[index].list.mut_rev_iter().position(|item| {
|
||||||
|
@ -751,6 +769,7 @@ impl<'a> MutableFlowUtils for &'a mut Flow {
|
||||||
|
|
||||||
lists.lists.push_all_move(child_lists.lists);
|
lists.lists.push_all_move(child_lists.lists);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue