aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2016-10-19 15:14:02 +0200
committerMartin Robinson <mrobinson@igalia.com>2016-10-21 08:38:34 +0200
commitccb7ab926a3710c32d920b9ff09a0b7557639905 (patch)
tree631552b75c6b87f6498cabe402452e9f8e80f50b /components/layout
parente667e62f0ca8cd5fd21282333808cccaed8c957c (diff)
downloadservo-ccb7ab926a3710c32d920b9ff09a0b7557639905.tar.gz
servo-ccb7ab926a3710c32d920b9ff09a0b7557639905.zip
Remove concept of Layers from Servo
Layers were a feature of the legacy drawing path. If we re-add them at some point, it probably makes more sense to make them a product of display list inspection. This change also remove a bunch of dead painting code.
Diffstat (limited to 'components/layout')
-rw-r--r--components/layout/block.rs65
-rw-r--r--components/layout/context.rs6
-rw-r--r--components/layout/display_list_builder.rs12
-rw-r--r--components/layout/flow.rs16
-rw-r--r--components/layout/fragment.rs47
-rw-r--r--components/layout/query.rs19
-rw-r--r--components/layout/webrender_helpers.rs14
7 files changed, 26 insertions, 153 deletions
diff --git a/components/layout/block.rs b/components/layout/block.rs
index 2011c50c181..b860d8347d1 100644
--- a/components/layout/block.rs
+++ b/components/layout/block.rs
@@ -36,15 +36,14 @@ use floats::{ClearType, FloatKind, Floats, PlacementInfo};
use flow::{self, BaseFlow, EarlyAbsolutePositionInfo, Flow, FlowClass, ForceNonfloatedFlag};
use flow::{BLOCK_POSITION_IS_STATIC, CLEARS_LEFT, CLEARS_RIGHT};
use flow::{CONTAINS_TEXT_OR_REPLACED_FRAGMENTS, INLINE_POSITION_IS_STATIC};
-use flow::{FragmentationContext, NEEDS_LAYER, PreorderFlowTraversal};
+use flow::{FragmentationContext, PreorderFlowTraversal};
use flow::{ImmutableFlowUtils, LateAbsolutePositionInfo, MutableFlowUtils, OpaqueFlow};
use flow::IS_ABSOLUTELY_POSITIONED;
use flow_list::FlowList;
use flow_ref::FlowRef;
-use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, HAS_LAYER, Overflow};
+use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
use fragment::SpecificFragmentInfo;
use gfx::display_list::{ClippingRegion, StackingContext};
-use gfx_traits::LayerId;
use gfx_traits::print_tree::PrintTree;
use layout_debug;
use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo, MaybeAuto};
@@ -57,12 +56,12 @@ use std::cmp::{max, min};
use std::fmt;
use std::sync::Arc;
use style::computed_values::{border_collapse, box_sizing, display, float, overflow_x, overflow_y};
-use style::computed_values::{position, text_align, transform_style};
+use style::computed_values::{position, text_align};
use style::context::{SharedStyleContext, StyleContext};
use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
use style::properties::ServoComputedValues;
-use style::values::computed::{LengthOrNone, LengthOrPercentageOrNone};
-use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
+use style::values::computed::{LengthOrPercentageOrNone, LengthOrPercentage};
+use style::values::computed::LengthOrPercentageOrAuto;
use util::clamp;
/// Information specific to floated blocks.
@@ -793,8 +792,6 @@ impl BlockFlow {
let mut break_at = None;
let content_box = self.fragment.content_box();
if self.base.restyle_damage.contains(REFLOW) {
- self.determine_if_layer_needed();
-
// Our current border-box position.
let mut cur_b = Au(0);
@@ -1679,34 +1676,6 @@ impl BlockFlow {
self.base.flags = flags
}
- fn determine_if_layer_needed(&mut self) {
- // Fixed position layers get layers.
- if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) && self.is_fixed() {
- self.base.flags.insert(NEEDS_LAYER);
- return
- }
-
- // This flow needs a layer if it has a 3d transform, or provides perspective
- // to child layers. See http://dev.w3.org/csswg/css-transforms/#3d-rendering-contexts.
- let has_3d_transform = self.fragment.style().transform_requires_layer();
- let has_perspective = self.fragment.style().get_effects().perspective !=
- LengthOrNone::None;
-
- if has_3d_transform || has_perspective {
- self.base.flags.insert(NEEDS_LAYER);
- return
- }
-
- match (self.fragment.style().get_box().overflow_x,
- self.fragment.style().get_box().overflow_y.0) {
- (overflow_x::T::auto, _) | (overflow_x::T::scroll, _) |
- (_, overflow_x::T::auto) | (_, overflow_x::T::scroll) => {
- self.base.flags.insert(NEEDS_LAYER);
- }
- _ => {}
- }
- }
-
pub fn block_stacking_context_type(&self) -> BlockStackingContextType {
if self.fragment.establishes_stacking_context() {
return BlockStackingContextType::StackingContext
@@ -1956,10 +1925,6 @@ impl Flow for BlockFlow {
}
fn compute_absolute_position(&mut self, _layout_context: &SharedLayoutContext) {
- if self.base.flags.contains(NEEDS_LAYER) {
- self.fragment.flags.insert(HAS_LAYER)
- }
-
// FIXME (mbrubeck): Get the real container size, taking the container writing mode into
// account. Must handle vertical writing modes.
let container_size = Size2D::new(self.base.block_container_inline_size, Au(0));
@@ -1968,8 +1933,6 @@ impl Flow for BlockFlow {
self.base.clip = ClippingRegion::max();
}
- let transform_style = self.fragment.style().get_used_transform_style();
-
if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) {
// `overflow: auto` and `overflow: scroll` force creation of layers, since we can only
// scroll layers.
@@ -2103,16 +2066,6 @@ impl Flow for BlockFlow {
// Process children.
for kid in self.base.child_iter_mut() {
- // If this layer preserves the 3d context of children,
- // then children will need a render layer.
- // TODO(gw): This isn't always correct. In some cases
- // this may create extra layers than needed. I think
- // there are also some edge cases where children don't
- // get a layer when they should.
- if transform_style == transform_style::T::preserve_3d {
- flow::mut_base(kid).flags.insert(NEEDS_LAYER);
- }
-
if flow::base(kid).flags.contains(INLINE_POSITION_IS_STATIC) ||
flow::base(kid).flags.contains(BLOCK_POSITION_IS_STATIC) {
let kid_base = flow::mut_base(kid);
@@ -2177,14 +2130,6 @@ impl Flow for BlockFlow {
(self.fragment.border_box - self.fragment.style().logical_border_width()).size
}
- fn layer_id(&self) -> LayerId {
- self.fragment.layer_id()
- }
-
- fn layer_id_for_overflow_scroll(&self) -> LayerId {
- self.fragment.layer_id_for_overflow_scroll()
- }
-
fn is_absolute_containing_block(&self) -> bool {
self.contains_positioned_fragments()
}
diff --git a/components/layout/context.rs b/components/layout/context.rs
index 7125c6ab44d..17a484e2930 100644
--- a/components/layout/context.rs
+++ b/components/layout/context.rs
@@ -7,13 +7,10 @@
// for thread_local
#![allow(unsafe_code)]
-use app_units::Au;
-use euclid::Rect;
use fnv::FnvHasher;
use gfx::display_list::WebRenderImageInfo;
use gfx::font_cache_thread::FontCacheThread;
use gfx::font_context::FontContext;
-use gfx_traits::LayerId;
use heapsize::HeapSizeOf;
use ipc_channel::ipc;
use net_traits::image::base::Image;
@@ -87,9 +84,6 @@ pub struct SharedLayoutContext {
/// Interface to the font cache thread.
pub font_cache_thread: Mutex<FontCacheThread>,
- /// The visible rects for each layer, as reported to us by the compositor.
- pub visible_rects: Arc<HashMap<LayerId, Rect<Au>, BuildHasherDefault<FnvHasher>>>,
-
/// A cache of WebRender image info.
pub webrender_image_cache: Arc<RwLock<HashMap<(Url, UsePlaceholder),
WebRenderImageInfo,
diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs
index 2574d345466..e714df23314 100644
--- a/components/layout/display_list_builder.rs
+++ b/components/layout/display_list_builder.rs
@@ -19,13 +19,13 @@ use euclid::{Matrix4D, Point2D, Radians, Rect, SideOffsets2D, Size2D};
use flex::FlexFlow;
use flow::{BaseFlow, Flow, IS_ABSOLUTELY_POSITIONED};
use flow_ref;
-use fragment::{CoordinateSystem, Fragment, HAS_LAYER, ImageFragmentInfo, ScannedTextFragmentInfo};
+use fragment::{CoordinateSystem, Fragment, ImageFragmentInfo, ScannedTextFragmentInfo};
use fragment::SpecificFragmentInfo;
use gfx::display_list::{BLUR_INFLATION_FACTOR, BaseDisplayItem, BorderDisplayItem};
use gfx::display_list::{BorderRadii, BoxShadowClipMode, BoxShadowDisplayItem, ClippingRegion};
use gfx::display_list::{DisplayItem, DisplayItemMetadata, DisplayListSection, GradientDisplayItem};
use gfx::display_list::{GradientStop, IframeDisplayItem, ImageDisplayItem, WebGLDisplayItem};
-use gfx::display_list::{LayerInfo, LineDisplayItem, OpaqueNode};
+use gfx::display_list::{LineDisplayItem, OpaqueNode};
use gfx::display_list::{SolidColorDisplayItem, StackingContext, StackingContextType};
use gfx::display_list::{TextDisplayItem, TextOrientation, WebRenderImageInfo};
use gfx_traits::{ScrollPolicy, StackingContextId, color};
@@ -1410,12 +1410,6 @@ impl FragmentDisplayListBuilding for Fragment {
filters.push(Filter::Opacity(effects.opacity))
}
- let layer_info = if self.flags.contains(HAS_LAYER) {
- Some(LayerInfo::new(self.layer_id(), scroll_policy, None, color::transparent()))
- } else {
- None
- };
-
let transform_style = self.style().get_used_transform_style();
let establishes_3d_context = scrolls_overflow_area ||
transform_style == transform_style::T::flat;
@@ -1436,7 +1430,7 @@ impl FragmentDisplayListBuilding for Fragment {
transform,
perspective,
establishes_3d_context,
- layer_info,
+ scroll_policy,
scroll_id)
}
diff --git a/components/layout/flow.rs b/components/layout/flow.rs
index ea5d61e4cf0..0e92de265d1 100644
--- a/components/layout/flow.rs
+++ b/components/layout/flow.rs
@@ -35,7 +35,7 @@ use flow_list::{FlowList, MutFlowListIterator};
use flow_ref::{self, FlowRef, WeakFlowRef};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow, SpecificFragmentInfo};
use gfx::display_list::{ClippingRegion, StackingContext};
-use gfx_traits::{LayerId, LayerType, StackingContextId};
+use gfx_traits::StackingContextId;
use gfx_traits::print_tree::PrintTree;
use inline::InlineFlow;
use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo};
@@ -399,16 +399,6 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static {
/// implications because this can be called on parents concurrently from descendants!
fn generated_containing_block_size(&self, _: OpaqueFlow) -> LogicalSize<Au>;
- /// Returns a layer ID for the given fragment.
- fn layer_id(&self) -> LayerId {
- LayerId::new_of_type(LayerType::FragmentBody, base(self).flow_id())
- }
-
- /// Returns a layer ID for the given fragment.
- fn layer_id_for_overflow_scroll(&self) -> LayerId {
- LayerId::new_of_type(LayerType::OverflowScroll, base(self).flow_id())
- }
-
/// Attempts to perform incremental fixup of this flow by replacing its fragment's style with
/// the new style. This can only succeed if the flow has exactly one fragment.
fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>);
@@ -634,10 +624,6 @@ bitflags! {
#[doc = "Flags used in flows."]
pub flags FlowFlags: u32 {
// text align flags
- #[doc = "Whether this flow must have its own layer. Even if this flag is not set, it might"]
- #[doc = "get its own layer if it's deemed to be likely to overlap flows with their own"]
- #[doc = "layer."]
- const NEEDS_LAYER = 0b0000_0000_0000_0000_0010_0000,
#[doc = "Whether this flow is absolutely positioned. This is checked all over layout, so a"]
#[doc = "virtual call is too expensive."]
const IS_ABSOLUTELY_POSITIONED = 0b0000_0000_0000_0000_0100_0000,
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs
index 7693e111347..68faff25430 100644
--- a/components/layout/fragment.rs
+++ b/components/layout/fragment.rs
@@ -17,7 +17,7 @@ use gfx;
use gfx::display_list::{BLUR_INFLATION_FACTOR, OpaqueNode};
use gfx::text::glyph::ByteIndex;
use gfx::text::text_run::{TextRun, TextRunSlice};
-use gfx_traits::{FragmentType, LayerId, LayerType, StackingContextId};
+use gfx_traits::{FragmentType, StackingContextId};
use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFragmentContext, InlineFragmentNodeInfo};
use inline::{InlineMetrics, LAST_FRAGMENT_OF_ELEMENT, LineMetrics};
use ipc_channel::ipc::IpcSender;
@@ -48,7 +48,7 @@ use style::dom::TRestyleDamage;
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
use style::properties::ServoComputedValues;
use style::str::char_is_whitespace;
-use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
+use style::values::computed::{LengthOrNone, LengthOrPercentage, LengthOrPercentageOrAuto};
use style::values::computed::LengthOrPercentageOrNone;
use text;
use text::TextRunScanner;
@@ -122,9 +122,6 @@ pub struct Fragment {
/// The pseudo-element that this fragment represents.
pub pseudo: PseudoElementType<()>,
- /// Various flags for this fragment.
- pub flags: FragmentFlags,
-
/// A debug ID that is consistent for the life of this fragment (via transform etc).
/// This ID should not be considered stable across multiple layouts or fragment
/// manipulations.
@@ -919,7 +916,6 @@ impl Fragment {
specific: specific,
inline_context: None,
pseudo: node.get_pseudo_element_type().strip(),
- flags: FragmentFlags::empty(),
debug_id: DebugId::new(),
stacking_context_id: StackingContextId::new(0),
}
@@ -948,7 +944,6 @@ impl Fragment {
specific: specific,
inline_context: None,
pseudo: pseudo,
- flags: FragmentFlags::empty(),
debug_id: DebugId::new(),
stacking_context_id: StackingContextId::new(0),
}
@@ -976,7 +971,6 @@ impl Fragment {
specific: info,
inline_context: self.inline_context.clone(),
pseudo: self.pseudo.clone(),
- flags: FragmentFlags::empty(),
debug_id: self.debug_id.clone(),
stacking_context_id: StackingContextId::new(0),
}
@@ -2535,9 +2529,6 @@ impl Fragment {
_ => {}
}
- if self.flags.contains(HAS_LAYER) {
- return true
- }
if self.style().get_effects().opacity != 1.0 {
return true
}
@@ -2550,6 +2541,18 @@ impl Fragment {
if self.style().get_effects().transform.0.is_some() {
return true
}
+
+ // TODO(mrobinson): Determine if this is necessary, since blocks with
+ // transformations already create stacking contexts.
+ if self.style().get_effects().perspective != LengthOrNone::None {
+ return true
+ }
+
+ // Fixed position blocks always create stacking contexts.
+ if self.style.get_box().position == position::T::fixed {
+ return true
+ }
+
match self.style().get_used_transform_style() {
transform_style::T::flat | transform_style::T::preserve_3d => {
return true
@@ -2874,21 +2877,6 @@ impl Fragment {
}
}
- pub fn layer_id(&self) -> LayerId {
- let layer_type = match self.pseudo {
- PseudoElementType::Normal => LayerType::FragmentBody,
- PseudoElementType::Before(_) => LayerType::BeforePseudoContent,
- PseudoElementType::After(_) => LayerType::AfterPseudoContent,
- PseudoElementType::DetailsSummary(_) => LayerType::FragmentBody,
- PseudoElementType::DetailsContent(_) => LayerType::FragmentBody,
- };
- LayerId::new_of_type(layer_type, self.node.id() as usize)
- }
-
- pub fn layer_id_for_overflow_scroll(&self) -> LayerId {
- LayerId::new_of_type(LayerType::OverflowScroll, self.node.id() as usize)
- }
-
/// Returns true if any of the inline styles associated with this fragment have
/// `vertical-align` set to `top` or `bottom`.
pub fn is_vertically_aligned_to_top_or_bottom(&self) -> bool {
@@ -3094,13 +3082,6 @@ impl Overflow {
}
}
-bitflags! {
- pub flags FragmentFlags: u8 {
- /// Whether this fragment has a layer.
- const HAS_LAYER = 0x01,
- }
-}
-
/// Specified distances from the margin edge of a block to its content in the inline direction.
/// These are returned by `guess_inline_content_edge_offsets()` and are used in the float placement
/// speculation logic.
diff --git a/components/layout/query.rs b/components/layout/query.rs
index 822377ef86f..a71bc246113 100644
--- a/components/layout/query.rs
+++ b/components/layout/query.rs
@@ -12,14 +12,13 @@ use euclid::size::Size2D;
use flow::{self, Flow};
use fragment::{Fragment, FragmentBorderBoxIterator, SpecificFragmentInfo};
use gfx::display_list::{DisplayItemMetadata, DisplayList, OpaqueNode, ScrollOffsetMap};
-use gfx_traits::LayerId;
use ipc_channel::ipc::IpcSender;
use opaque_node::OpaqueNodeMethods;
use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse};
use script_layout_interface::rpc::{HitTestResponse, LayoutRPC};
use script_layout_interface::rpc::{MarginStyleResponse, NodeGeometryResponse};
-use script_layout_interface::rpc::{NodeLayerIdResponse, NodeOverflowResponse};
-use script_layout_interface::rpc::{OffsetParentResponse, ResolvedStyleResponse};
+use script_layout_interface::rpc::{NodeOverflowResponse, OffsetParentResponse};
+use script_layout_interface::rpc::ResolvedStyleResponse;
use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
use script_traits::LayoutMsg as ConstellationMsg;
use script_traits::UntrustedNodeAddress;
@@ -61,8 +60,6 @@ pub struct LayoutThreadData {
/// A queued response for the client {top, left, width, height} of a node in pixels.
pub client_rect_response: Rect<i32>,
- pub layer_id_response: Option<LayerId>,
-
/// A queued response for the node at a given point
pub hit_test_response: (Option<DisplayItemMetadata>, bool),
@@ -180,13 +177,6 @@ impl LayoutRPC for LayoutRPCImpl {
}
}
- fn node_layer_id(&self) -> NodeLayerIdResponse {
- NodeLayerIdResponse {
- layer_id: self.0.lock().unwrap().layer_id_response
- .expect("layer_id is not correctly fetched, see PR #9968")
- }
- }
-
/// Retrieves the resolved value for a CSS style property.
fn resolved_style(&self) -> ResolvedStyleResponse {
let &LayoutRPCImpl(ref rw_data) = self;
@@ -587,11 +577,6 @@ pub fn process_node_geometry_request<N: LayoutNode>(requested_node: N, layout_ro
iterator.client_rect
}
-pub fn process_node_layer_id_request<N: LayoutNode>(requested_node: N) -> LayerId {
- let layout_node = requested_node.to_threadsafe();
- layout_node.layer_id()
-}
-
pub fn process_node_scroll_area_request< N: LayoutNode>(requested_node: N, layout_root: &mut Flow)
-> Rect<i32> {
let mut iterator = UnioningFragmentScrollAreaIterator::new(requested_node.opaque());
diff --git a/components/layout/webrender_helpers.rs b/components/layout/webrender_helpers.rs
index 6e8821fc572..19e645c80a5 100644
--- a/components/layout/webrender_helpers.rs
+++ b/components/layout/webrender_helpers.rs
@@ -26,7 +26,6 @@ trait WebRenderStackingContextConverter {
pipeline_id: webrender_traits::PipelineId,
epoch: webrender_traits::Epoch,
scroll_layer_id: Option<webrender_traits::ScrollLayerId>,
- scroll_policy: ScrollPolicy,
frame_builder: &mut WebRenderFrameBuilder)
-> webrender_traits::StackingContextId;
@@ -36,7 +35,6 @@ trait WebRenderStackingContextConverter {
pipeline_id: webrender_traits::PipelineId,
epoch: webrender_traits::Epoch,
scroll_layer_id: Option<webrender_traits::ScrollLayerId>,
- scroll_policy: ScrollPolicy,
builder: &mut webrender_traits::DisplayListBuilder,
frame_builder: &mut WebRenderFrameBuilder,
force_positioned_stacking_level: bool);
@@ -256,7 +254,6 @@ impl WebRenderStackingContextConverter for StackingContext {
pipeline_id: webrender_traits::PipelineId,
epoch: webrender_traits::Epoch,
scroll_layer_id: Option<webrender_traits::ScrollLayerId>,
- scroll_policy: ScrollPolicy,
builder: &mut webrender_traits::DisplayListBuilder,
frame_builder: &mut WebRenderFrameBuilder,
_force_positioned_stacking_level: bool) {
@@ -278,7 +275,6 @@ impl WebRenderStackingContextConverter for StackingContext {
pipeline_id,
epoch,
scroll_layer_id_for_children,
- scroll_policy,
frame_builder);
builder.push_stacking_context(stacking_context_id);
@@ -295,14 +291,9 @@ impl WebRenderStackingContextConverter for StackingContext {
pipeline_id: webrender_traits::PipelineId,
epoch: webrender_traits::Epoch,
scroll_layer_id: Option<webrender_traits::ScrollLayerId>,
- mut scroll_policy: ScrollPolicy,
frame_builder: &mut WebRenderFrameBuilder)
-> webrender_traits::StackingContextId {
- if let Some(ref layer_info) = self.layer_info {
- scroll_policy = layer_info.scroll_policy
- }
-
- let webrender_scroll_policy = match scroll_policy {
+ let webrender_scroll_policy = match self.scroll_policy {
ScrollPolicy::Scrollable => webrender_traits::ScrollPolicy::Scrollable,
ScrollPolicy::FixedPosition => webrender_traits::ScrollPolicy::Fixed,
};
@@ -353,7 +344,6 @@ impl WebRenderStackingContextConverter for StackingContext {
pipeline_id,
epoch,
None,
- scroll_policy,
&mut inner_builder,
frame_builder,
false);
@@ -367,7 +357,6 @@ impl WebRenderStackingContextConverter for StackingContext {
pipeline_id,
epoch,
scroll_layer_id,
- scroll_policy,
&mut builder,
frame_builder,
false);
@@ -397,7 +386,6 @@ impl WebRenderDisplayListConverter for DisplayList {
pipeline_id,
epoch,
scroll_layer_id,
- ScrollPolicy::Scrollable,
frame_builder)
}
_ => unreachable!("DisplayList did not start with StackingContext."),