aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/display_list_builder.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2015-10-09 17:08:35 -0700
committerMartin Robinson <mrobinson@igalia.com>2015-10-20 07:29:06 -0700
commitac5525aeeb3df60a99b503fa75f919c93c50b43b (patch)
tree99f867cb70aeb0c549ade092dbd6624efe879dcd /components/layout/display_list_builder.rs
parent90dd3cdc095d7bf54435f0fcb8a6fe134b00fc24 (diff)
downloadservo-ac5525aeeb3df60a99b503fa75f919c93c50b43b.tar.gz
servo-ac5525aeeb3df60a99b503fa75f919c93c50b43b.zip
Integrate iframes into the display list
Instead of always promoting iframes to StackingContexts, integrate them into the display list. This prevents stacking bugs when non-stacking-context elements should be drawn on top of iframes. To accomplish this, we add another step to ordering layer creation, where LayeredItems in the DisplayList are added to layers described by the LayerInfo structures collected at the end of the DisplayList. Unlayered items that follow these layered items are added to synthesized layers. Another result of this change is that iframe layers can be positioned directly at the location of the iframe fragment, eliminating the need for the SubpageLayerInfo struct entirely. Iframes are the first type of content treated this way, but this change opens up the possibility to properly order canvas and all other layered content that does not create a stacking context. Fixes #7566. Fixes #7796.
Diffstat (limited to 'components/layout/display_list_builder.rs')
-rw-r--r--components/layout/display_list_builder.rs52
1 files changed, 30 insertions, 22 deletions
diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs
index 299f0155e4d..37a3a543794 100644
--- a/components/layout/display_list_builder.rs
+++ b/components/layout/display_list_builder.rs
@@ -15,6 +15,7 @@ use azure::azure_hl::Color;
use block::BlockFlow;
use canvas_traits::{CanvasMsg, FromLayoutMsg};
use context::LayoutContext;
+use euclid::num::Zero;
use euclid::{Matrix4, Point2D, Point3D, Rect, SideOffsets2D, Size2D};
use flex::FlexFlow;
use flow::{self, BaseFlow, Flow, IS_ABSOLUTELY_POSITIONED};
@@ -25,8 +26,8 @@ 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, LayerInfo, LineDisplayItem};
-use gfx::display_list::{OpaqueNode, SolidColorDisplayItem};
+use gfx::display_list::{GradientStop, ImageDisplayItem, LayeredItem, LayerInfo};
+use gfx::display_list::{LineDisplayItem, OpaqueNode, SolidColorDisplayItem};
use gfx::display_list::{StackingContext, TextDisplayItem, TextOrientation};
use gfx::paint_task::THREAD_TINT_COLORS;
use gfx::text::glyph::CharIndex;
@@ -35,7 +36,7 @@ use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow, LAST_FRAGMENT_OF_ELEMENT};
use ipc_channel::ipc::{self, IpcSharedMemory};
use list_item::ListItemFlow;
use model::{self, MaybeAuto, ToGfxMatrix};
-use msg::compositor_msg::{ScrollPolicy, SubpageLayerInfo};
+use msg::compositor_msg::ScrollPolicy;
use net_traits::image::base::{Image, PixelFormat};
use net_traits::image_cache_task::UsePlaceholder;
use std::default::Default;
@@ -1098,7 +1099,6 @@ impl FragmentDisplayListBuilding for Fragment {
}
SpecificFragmentInfo::Generic |
SpecificFragmentInfo::GeneratedContent(..) |
- SpecificFragmentInfo::Iframe(..) |
SpecificFragmentInfo::Table |
SpecificFragmentInfo::TableCell |
SpecificFragmentInfo::TableRow |
@@ -1112,6 +1112,27 @@ impl FragmentDisplayListBuilding for Fragment {
clip);
}
}
+ SpecificFragmentInfo::Iframe(ref fragment_info) => {
+ // TODO(mrobinson): When https://github.com/servo/euclid/issues/109 is fixed this
+ // check can just become stacking_relative_content_box.is_empty().
+ if stacking_relative_content_box.size.width != Zero::zero() &&
+ stacking_relative_content_box.size.height != Zero::zero() {
+ let layer_id = self.layer_id();
+ display_list.content.push_back(DisplayItem::LayeredItemClass(box LayeredItem {
+ item: DisplayItem::NoopClass(
+ box BaseDisplayItem::new(stacking_relative_content_box,
+ DisplayItemMetadata::new(self.node,
+ &*self.style,
+ Cursor::DefaultCursor),
+ (*clip).clone())),
+ layer_id: layer_id
+ }));
+
+ display_list.layer_info.push_back(LayerInfo::new(layer_id,
+ ScrollPolicy::Scrollable,
+ Some(fragment_info.pipeline_id)));
+ }
+ }
SpecificFragmentInfo::Image(ref mut image_fragment) => {
// Place the image into the display list.
if let Some(ref image) = image_fragment.image {
@@ -1284,19 +1305,8 @@ impl FragmentDisplayListBuilding for Fragment {
filters.push(Filter::Opacity(effects.opacity))
}
- 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);
- Some(SubpageLayerInfo {
- pipeline_id: iframe_fragment_info.pipeline_id,
- origin: Point2D::new(border_padding.left, border_padding.top),
- })
- }
- _ => None,
- };
-
- let canvas_or_iframe = match self.specific {
- SpecificFragmentInfo::Canvas(_) | SpecificFragmentInfo::Iframe(_) => true,
+ let canvas = match self.specific {
+ SpecificFragmentInfo::Canvas(_) => true,
_ => false
};
@@ -1304,11 +1314,9 @@ impl FragmentDisplayListBuilding for Fragment {
// 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))
+ Some(LayerInfo::new(self.layer_id_for_overflow_scroll(), scroll_policy, None))
+ } else if self.flags.contains(HAS_LAYER) || canvas {
+ Some(LayerInfo::new(self.layer_id(), scroll_policy, None))
} else {
None
};