aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2017-10-18 17:33:32 +0200
committerMartin Robinson <mrobinson@igalia.com>2017-10-18 17:34:34 +0200
commit2e2ed444d597904ed0b6d7f4eade2747d75021a6 (patch)
tree398bd1db9076157474ee73b05ee6af0580a8365d
parent770b3480910d255e4bbd78949c30c8324c57ae94 (diff)
downloadservo-2e2ed444d597904ed0b6d7f4eade2747d75021a6.tar.gz
servo-2e2ed444d597904ed0b6d7f4eade2747d75021a6.zip
Remove DisplayListTraversal
It's no longer necessary because we always just walk through the display list one item at a time.
-rw-r--r--components/gfx/display_list/mod.rs91
-rw-r--r--components/layout/webrender_helpers.rs6
2 files changed, 3 insertions, 94 deletions
diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs
index c9e310074c3..9da7ae87b0e 100644
--- a/components/gfx/display_list/mod.rs
+++ b/components/gfx/display_list/mod.rs
@@ -61,8 +61,7 @@ impl DisplayList {
// 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> {
- let mut traversal = DisplayListTraversal::new(self);
- while let Some(item) = traversal.next() {
+ for item in &self.list {
match item {
&DisplayItem::Text(ref text) => {
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
/// to the steps in CSS 2.1 Appendix E.
///
diff --git a/components/layout/webrender_helpers.rs b/components/layout/webrender_helpers.rs
index 4477294fced..62c0792301a 100644
--- a/components/layout/webrender_helpers.rs
+++ b/components/layout/webrender_helpers.rs
@@ -10,8 +10,7 @@
use app_units::Au;
use euclid::{Point2D, Vector2D, Rect, SideOffsets2D, Size2D};
use gfx::display_list::{BorderDetails, BorderRadii, BoxShadowClipMode, ClipScrollNodeType};
-use gfx::display_list::{ClippingRegion, DisplayItem, DisplayList, DisplayListTraversal};
-use gfx::display_list::StackingContextType;
+use gfx::display_list::{ClippingRegion, DisplayItem, DisplayList, StackingContextType};
use msg::constellation_msg::PipelineId;
use style::computed_values::{image_rendering, mix_blend_mode, transform_style};
use style::values::computed::{BorderStyle, Filter};
@@ -222,7 +221,6 @@ impl ToTransformStyle for transform_style::T {
impl WebRenderDisplayListConverter for DisplayList {
fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder {
- let traversal = DisplayListTraversal::new(self);
let mut builder = DisplayListBuilder::with_capacity(pipeline_id.to_webrender(),
self.bounds().size.to_sizef(),
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();
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);
}
builder