Rework how StackingContexts are dynamically added to layers

StackingContexts are added to layers when it is necessary to maintain
their ordering on top of other layered StackingContexts. Instead of
tracking the information about a layer scattered around into different
structs, combine it all into LayerInfo. LayerInfo will be used in the
future to hold layer information for DisplayItems that are layerized
independently of StackingContexts.
This commit is contained in:
Martin Robinson 2015-10-01 15:42:24 -07:00
parent ba2714f4f6
commit 553f1fc192
5 changed files with 162 additions and 115 deletions

View file

@ -25,7 +25,7 @@ use gfx::display_list::{BLUR_INFLATION_FACTOR, BaseDisplayItem, BorderDisplayIte
use gfx::display_list::{BorderRadii, BoxShadowClipMode, BoxShadowDisplayItem, ClippingRegion};
use gfx::display_list::{DisplayItem, DisplayItemMetadata, DisplayList};
use gfx::display_list::{GradientDisplayItem};
use gfx::display_list::{GradientStop, ImageDisplayItem, LineDisplayItem};
use gfx::display_list::{GradientStop, ImageDisplayItem, LayerInfo, LineDisplayItem};
use gfx::display_list::{OpaqueNode, SolidColorDisplayItem};
use gfx::display_list::{StackingContext, TextDisplayItem, TextOrientation};
use gfx::paint_task::THREAD_TINT_COLORS;
@ -1279,32 +1279,6 @@ impl FragmentDisplayListBuilding for Fragment {
filters.push(Filter::Opacity(effects.opacity))
}
let canvas_or_iframe = match self.specific {
SpecificFragmentInfo::Canvas(_) | SpecificFragmentInfo::Iframe(_) => true,
_ => false
};
// There are three situations that need layers: when the fragment has the HAS_LAYER
// flag, when this is a canvas or iframe fragment, and when we are building a layer
// tree for overflow scrolling.
let layer_id = if mode == StackingContextCreationMode::InnerScrollWrapper {
Some(self.layer_id_for_overflow_scroll())
} else if self.flags.contains(HAS_LAYER) || canvas_or_iframe {
Some(self.layer_id())
} else {
None
};
// If it's a canvas we must propagate the layer and the renderer to the paint task.
if let SpecificFragmentInfo::Canvas(ref fragment_info) = self.specific {
let layer_id = layer_id.unwrap();
if let Some(ref ipc_renderer) = fragment_info.ipc_renderer {
layout_context.shared
.canvas_layers_sender
.send((layer_id, (*ipc_renderer.lock().unwrap()).clone())).unwrap();
}
}
let subpage_layer_info = match self.specific {
SpecificFragmentInfo::Iframe(ref iframe_fragment_info) => {
let border_padding = self.border_padding.to_physical(self.style().writing_mode);
@ -1317,6 +1291,34 @@ impl FragmentDisplayListBuilding for Fragment {
_ => None,
};
let canvas_or_iframe = match self.specific {
SpecificFragmentInfo::Canvas(_) | SpecificFragmentInfo::Iframe(_) => true,
_ => false
};
// There are three situations that need layers: when the fragment has the HAS_LAYER
// flag, when this is a canvas or iframe fragment, and when we are building a layer
// tree for overflow scrolling.
let layer_info = if mode == StackingContextCreationMode::InnerScrollWrapper {
Some(LayerInfo::new(self.layer_id_for_overflow_scroll(),
scroll_policy,
subpage_layer_info))
} else if self.flags.contains(HAS_LAYER) || canvas_or_iframe {
Some(LayerInfo::new(self.layer_id(), scroll_policy, subpage_layer_info))
} else {
None
};
// If it's a canvas we must propagate the layer and the renderer to the paint task.
if let SpecificFragmentInfo::Canvas(ref fragment_info) = self.specific {
let layer_id = layer_info.unwrap().layer_id;
if let Some(ref ipc_renderer) = fragment_info.ipc_renderer {
layout_context.shared
.canvas_layers_sender
.send((layer_id, (*ipc_renderer.lock().unwrap()).clone())).unwrap();
}
}
let scrolls_overflow_area = mode == StackingContextCreationMode::OuterScrollWrapper;
let transform_style = self.style().get_used_transform_style();
let establishes_3d_context = scrolls_overflow_area ||
@ -1332,9 +1334,7 @@ impl FragmentDisplayListBuilding for Fragment {
perspective,
establishes_3d_context,
scrolls_overflow_area,
scroll_policy,
layer_id,
subpage_layer_info))
layer_info))
}
fn clipping_region_for_children(&self,

View file

@ -27,8 +27,7 @@ use flow::{self, Flow, ImmutableFlowUtils, MutableFlowUtils, MutableOwnedFlowUti
use flow_ref::{self, FlowRef};
use fnv::FnvHasher;
use fragment::{Fragment, FragmentBorderBoxIterator, SpecificFragmentInfo};
use gfx::display_list::StackingContext;
use gfx::display_list::{ClippingRegion, DisplayList, OpaqueNode};
use gfx::display_list::{ClippingRegion, DisplayList, LayerInfo, OpaqueNode, StackingContext};
use gfx::font_cache_task::FontCacheTask;
use gfx::font_context;
use gfx::paint_task::{LayoutToPaintMsg, PaintLayer};
@ -1119,7 +1118,6 @@ impl LayoutTask {
.add_to(&mut *display_list);
let origin = Rect::new(Point2D::new(Au(0), Au(0)), root_size);
let layer_id = layout_root.layer_id();
let stacking_context = Arc::new(StackingContext::new(display_list,
&origin,
&origin,
@ -1130,8 +1128,6 @@ impl LayoutTask {
Matrix4::identity(),
true,
false,
ScrollPolicy::Scrollable,
Some(layer_id),
None));
if opts::get().dump_display_list {
stacking_context.print("DisplayList".to_owned());
@ -1142,10 +1138,12 @@ impl LayoutTask {
rw_data.stacking_context = Some(stacking_context.clone());
let paint_layer = PaintLayer::new(layout_root.layer_id(),
root_background_color,
stacking_context,
ScrollPolicy::Scrollable);
let layer_info = LayerInfo::new(layout_root.layer_id(),
ScrollPolicy::Scrollable,
None);
let paint_layer = PaintLayer::new_with_stacking_context(layer_info,
stacking_context,
root_background_color);
debug!("Layout done!");