mirror of
https://github.com/servo/servo.git
synced 2025-08-01 19:50:30 +01:00
Remove DisplayListTraversal
It's no longer necessary because we always just walk through the display list one item at a time.
This commit is contained in:
parent
770b348091
commit
2e2ed444d5
2 changed files with 3 additions and 94 deletions
|
@ -61,8 +61,7 @@ impl DisplayList {
|
||||||
|
|
||||||
// Returns the text index within a node for the point of interest.
|
// Returns the text index within a node for the point of interest.
|
||||||
pub fn text_index(&self, node: OpaqueNode, point_in_item: &Point2D<Au>) -> Option<usize> {
|
pub fn text_index(&self, node: OpaqueNode, point_in_item: &Point2D<Au>) -> Option<usize> {
|
||||||
let mut traversal = DisplayListTraversal::new(self);
|
for item in &self.list {
|
||||||
while let Some(item) = traversal.next() {
|
|
||||||
match item {
|
match item {
|
||||||
&DisplayItem::Text(ref text) => {
|
&DisplayItem::Text(ref text) => {
|
||||||
let base = item.base();
|
let base = item.base();
|
||||||
|
@ -96,94 +95,6 @@ impl DisplayList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DisplayListTraversal<'a> {
|
|
||||||
pub display_list: &'a DisplayList,
|
|
||||||
pub next_item_index: usize,
|
|
||||||
pub first_item_index: usize,
|
|
||||||
pub last_item_index: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> DisplayListTraversal<'a> {
|
|
||||||
pub fn new(display_list: &'a DisplayList) -> DisplayListTraversal {
|
|
||||||
DisplayListTraversal {
|
|
||||||
display_list: display_list,
|
|
||||||
next_item_index: 0,
|
|
||||||
first_item_index: 0,
|
|
||||||
last_item_index: display_list.list.len(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new_partial(display_list: &'a DisplayList,
|
|
||||||
stacking_context_id: StackingContextId,
|
|
||||||
start: usize,
|
|
||||||
end: usize)
|
|
||||||
-> DisplayListTraversal {
|
|
||||||
debug_assert!(start <= end);
|
|
||||||
debug_assert!(display_list.list.len() > start);
|
|
||||||
debug_assert!(display_list.list.len() > end);
|
|
||||||
|
|
||||||
let stacking_context_start = display_list.list[0..start].iter().rposition(|item|
|
|
||||||
match item {
|
|
||||||
&DisplayItem::PushStackingContext(ref item) =>
|
|
||||||
item.stacking_context.id == stacking_context_id,
|
|
||||||
_ => false,
|
|
||||||
}).unwrap_or(start);
|
|
||||||
debug_assert!(stacking_context_start <= start);
|
|
||||||
|
|
||||||
DisplayListTraversal {
|
|
||||||
display_list: display_list,
|
|
||||||
next_item_index: stacking_context_start,
|
|
||||||
first_item_index: start,
|
|
||||||
last_item_index: end + 1,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn previous_item_id(&self) -> usize {
|
|
||||||
self.next_item_index - 1
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn skip_to_end_of_stacking_context(&mut self, id: StackingContextId) {
|
|
||||||
self.next_item_index = self.display_list.list[self.next_item_index..].iter()
|
|
||||||
.position(|item| {
|
|
||||||
match item {
|
|
||||||
&DisplayItem::PopStackingContext(ref item) => item.stacking_context_id == id,
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
}).unwrap_or(self.display_list.list.len());
|
|
||||||
debug_assert!(self.next_item_index < self.last_item_index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Iterator for DisplayListTraversal<'a> {
|
|
||||||
type Item = &'a DisplayItem;
|
|
||||||
|
|
||||||
fn next(&mut self) -> Option<&'a DisplayItem> {
|
|
||||||
while self.next_item_index < self.last_item_index {
|
|
||||||
debug_assert!(self.next_item_index <= self.last_item_index);
|
|
||||||
|
|
||||||
let reached_first_item = self.next_item_index >= self.first_item_index;
|
|
||||||
let item = &self.display_list.list[self.next_item_index];
|
|
||||||
|
|
||||||
self.next_item_index += 1;
|
|
||||||
|
|
||||||
if reached_first_item {
|
|
||||||
return Some(item)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Before we reach the starting item, we only emit stacking context boundaries. This
|
|
||||||
// is to ensure that we properly position items when we are processing a display list
|
|
||||||
// slice that is relative to a certain stacking context.
|
|
||||||
match item {
|
|
||||||
&DisplayItem::PushStackingContext(_) |
|
|
||||||
&DisplayItem::PopStackingContext(_) => return Some(item),
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Display list sections that make up a stacking context. Each section here refers
|
/// Display list sections that make up a stacking context. Each section here refers
|
||||||
/// to the steps in CSS 2.1 Appendix E.
|
/// to the steps in CSS 2.1 Appendix E.
|
||||||
///
|
///
|
||||||
|
|
|
@ -10,8 +10,7 @@
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use euclid::{Point2D, Vector2D, Rect, SideOffsets2D, Size2D};
|
use euclid::{Point2D, Vector2D, Rect, SideOffsets2D, Size2D};
|
||||||
use gfx::display_list::{BorderDetails, BorderRadii, BoxShadowClipMode, ClipScrollNodeType};
|
use gfx::display_list::{BorderDetails, BorderRadii, BoxShadowClipMode, ClipScrollNodeType};
|
||||||
use gfx::display_list::{ClippingRegion, DisplayItem, DisplayList, DisplayListTraversal};
|
use gfx::display_list::{ClippingRegion, DisplayItem, DisplayList, StackingContextType};
|
||||||
use gfx::display_list::StackingContextType;
|
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use style::computed_values::{image_rendering, mix_blend_mode, transform_style};
|
use style::computed_values::{image_rendering, mix_blend_mode, transform_style};
|
||||||
use style::values::computed::{BorderStyle, Filter};
|
use style::values::computed::{BorderStyle, Filter};
|
||||||
|
@ -222,7 +221,6 @@ impl ToTransformStyle for transform_style::T {
|
||||||
|
|
||||||
impl WebRenderDisplayListConverter for DisplayList {
|
impl WebRenderDisplayListConverter for DisplayList {
|
||||||
fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder {
|
fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder {
|
||||||
let traversal = DisplayListTraversal::new(self);
|
|
||||||
let mut builder = DisplayListBuilder::with_capacity(pipeline_id.to_webrender(),
|
let mut builder = DisplayListBuilder::with_capacity(pipeline_id.to_webrender(),
|
||||||
self.bounds().size.to_sizef(),
|
self.bounds().size.to_sizef(),
|
||||||
1024 * 1024); // 1 MB of space
|
1024 * 1024); // 1 MB of space
|
||||||
|
@ -230,7 +228,7 @@ impl WebRenderDisplayListConverter for DisplayList {
|
||||||
let mut current_clip_and_scroll_info = pipeline_id.root_clip_and_scroll_info();
|
let mut current_clip_and_scroll_info = pipeline_id.root_clip_and_scroll_info();
|
||||||
builder.push_clip_and_scroll_info(current_clip_and_scroll_info);
|
builder.push_clip_and_scroll_info(current_clip_and_scroll_info);
|
||||||
|
|
||||||
for item in traversal {
|
for item in &self.list {
|
||||||
item.convert_to_webrender(&mut builder, &mut current_clip_and_scroll_info);
|
item.convert_to_webrender(&mut builder, &mut current_clip_and_scroll_info);
|
||||||
}
|
}
|
||||||
builder
|
builder
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue