Move DL items from gfx to layout

Implement corner clipping.
Remove PixelFormat from WebrenderImageInfo.
Use WebRender text shadow.
Remove MallocSizeOf and Deserialize for DL items.

Closes #19649, #19680, #19802
This commit is contained in:
Pyfisch 2018-03-24 21:50:15 +01:00
parent 782d4d4af6
commit c0be925bed
26 changed files with 417 additions and 287 deletions

View file

@ -5,9 +5,9 @@
//! CSS transitions and animations.
use context::LayoutContext;
use display_list::items::OpaqueNode;
use flow::{Flow, GetBaseFlow};
use fnv::FnvHashMap;
use gfx::display_list::OpaqueNode;
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::PipelineId;
use opaque_node::OpaqueNodeMethods;

View file

@ -32,13 +32,13 @@ use context::LayoutContext;
use display_list::{BlockFlowDisplayListBuilding, BorderPaintingMode};
use display_list::{DisplayListBuildState, StackingContextCollectionFlags};
use display_list::StackingContextCollectionState;
use display_list::items::DisplayListSection;
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
use floats::{ClearType, FloatKind, Floats, PlacementInfo};
use flow::{BaseFlow, EarlyAbsolutePositionInfo, Flow, FlowClass, ForceNonfloatedFlag, GetBaseFlow};
use flow::{ImmutableFlowUtils, LateAbsolutePositionInfo, OpaqueFlow, FragmentationContext, FlowFlags};
use flow_list::FlowList;
use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow, FragmentFlags};
use gfx::display_list::DisplayListSection;
use gfx_traits::print_tree::PrintTree;
use incremental::RelayoutMode;
use layout_debug;

View file

@ -17,6 +17,7 @@ use ServoArc;
use block::BlockFlow;
use context::{LayoutContext, with_thread_local_font_context};
use data::{LayoutDataFlags, LayoutData};
use display_list::items::OpaqueNode;
use flex::FlexFlow;
use floats::FloatKind;
use flow::{AbsoluteDescendants, Flow, FlowClass, GetBaseFlow, ImmutableFlowUtils};
@ -27,7 +28,6 @@ use fragment::{Fragment, GeneratedContentInfo, IframeFragmentInfo, FragmentFlags
use fragment::{InlineAbsoluteHypotheticalFragmentInfo, TableColumnFragmentInfo};
use fragment::{InlineBlockFragmentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo};
use fragment::WhitespaceStrippingResult;
use gfx::display_list::OpaqueNode;
use inline::{InlineFlow, InlineFragmentNodeInfo, InlineFragmentNodeFlags};
use linked_list::prepend_from;
use list_item::{ListItemFlow, ListStyleTypeContent};

View file

@ -4,8 +4,8 @@
//! Data needed by the layout thread.
use display_list::items::{WebRenderImageInfo, OpaqueNode};
use fnv::FnvHasher;
use gfx::display_list::{WebRenderImageInfo, OpaqueNode};
use gfx::font_cache_thread::FontCacheThread;
use gfx::font_context::FontContext;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};

View file

@ -13,8 +13,8 @@
use app_units::Au;
use display_list::ToLayout;
use display_list::items::{BorderDetails, Gradient, RadialGradient, WebRenderImageInfo};
use euclid::{Point2D, Rect, SideOffsets2D, Size2D, Vector2D};
use gfx::display_list::{self, BorderDetails, WebRenderImageInfo};
use model::{self, MaybeAuto};
use style::computed_values::background_attachment::single_value::T as BackgroundAttachment;
use style::computed_values::background_clip::single_value::T as BackgroundClip;
@ -56,7 +56,9 @@ pub struct BackgroundPlacement {
pub tile_spacing: Size2D<Au>,
/// A clip area. While the background is rendered according to all the
/// measures above it is only shown within these bounds.
pub css_clip: Rect<Au>,
pub clip_rect: Rect<Au>,
/// Rounded corners for the clip_rect.
pub clip_radii: BorderRadius,
/// Whether or not the background is fixed to the viewport.
pub fixed: bool,
}
@ -149,6 +151,26 @@ fn compute_background_image_size(
}
}
pub fn compute_background_clip(
bg_clip: BackgroundClip,
absolute_bounds: Rect<Au>,
border: SideOffsets2D<Au>,
border_padding: SideOffsets2D<Au>,
border_radii: BorderRadius,
) -> (Rect<Au>, BorderRadius) {
match bg_clip {
BackgroundClip::BorderBox => (absolute_bounds, border_radii),
BackgroundClip::PaddingBox => (
absolute_bounds.inner_rect(border),
calculate_inner_border_radii(border_radii, border),
),
BackgroundClip::ContentBox => (
absolute_bounds.inner_rect(border_padding),
calculate_inner_border_radii(border_radii, border_padding),
),
}
}
/// Determines where to place an element background image or gradient.
///
/// Photos have their resolution as intrinsic size while gradients have
@ -160,6 +182,7 @@ pub fn compute_background_placement(
intrinsic_size: Option<Size2D<Au>>,
border: SideOffsets2D<Au>,
border_padding: SideOffsets2D<Au>,
border_radii: BorderRadius,
index: usize,
) -> BackgroundPlacement {
let bg_attachment = *get_cyclic(&bg.background_attachment.0, index);
@ -170,11 +193,13 @@ pub fn compute_background_placement(
let bg_repeat = get_cyclic(&bg.background_repeat.0, index);
let bg_size = *get_cyclic(&bg.background_size.0, index);
let css_clip = match bg_clip {
BackgroundClip::BorderBox => absolute_bounds,
BackgroundClip::PaddingBox => absolute_bounds.inner_rect(border),
BackgroundClip::ContentBox => absolute_bounds.inner_rect(border_padding),
};
let (clip_rect, clip_radii) = compute_background_clip(
bg_clip,
absolute_bounds,
border,
border_padding,
border_radii,
);
let mut fixed = false;
let mut bounds = match bg_attachment {
@ -202,8 +227,8 @@ pub fn compute_background_placement(
&mut tile_size.width,
&mut tile_spacing.width,
pos_x,
css_clip.origin.x,
css_clip.size.width,
clip_rect.origin.x,
clip_rect.size.width,
);
tile_image_axis(
bg_repeat.1,
@ -212,15 +237,16 @@ pub fn compute_background_placement(
&mut tile_size.height,
&mut tile_spacing.height,
pos_y,
css_clip.origin.y,
css_clip.size.height,
clip_rect.origin.y,
clip_rect.size.height,
);
BackgroundPlacement {
bounds,
tile_size,
tile_spacing,
css_clip,
clip_rect,
clip_radii,
fixed,
}
}
@ -508,7 +534,7 @@ pub fn convert_linear_gradient(
stops: &[GradientItem],
direction: LineDirection,
repeating: bool,
) -> display_list::Gradient {
) -> Gradient {
let angle = match direction {
LineDirection::Angle(angle) => angle.radians(),
LineDirection::Horizontal(x) => match x {
@ -556,7 +582,7 @@ pub fn convert_linear_gradient(
let center = Point2D::new(size.width / 2, size.height / 2);
display_list::Gradient {
Gradient {
start_point: (center - delta).to_layout(),
end_point: (center + delta).to_layout(),
stops: stops,
@ -570,7 +596,7 @@ pub fn convert_radial_gradient(
shape: EndingShape,
center: Position,
repeating: bool,
) -> display_list::RadialGradient {
) -> RadialGradient {
let center = Point2D::new(
center.horizontal.to_used_value(size.width),
center.vertical.to_used_value(size.height),
@ -593,7 +619,7 @@ pub fn convert_radial_gradient(
let stops = convert_gradient_stops(stops, radius.width);
display_list::RadialGradient {
RadialGradient {
center: center.to_layout(),
radius: radius.to_layout(),
stops: stops,

View file

@ -17,8 +17,18 @@ use context::LayoutContext;
use display_list::ToLayout;
use display_list::background::{build_border_radius, build_image_border_details};
use display_list::background::{calculate_inner_border_radii, compute_background_placement};
use display_list::background::{convert_linear_gradient, convert_radial_gradient};
use display_list::background::{convert_radial_gradient, convert_linear_gradient};
use display_list::background::{get_cyclic, simple_normal_border};
use display_list::items::{BaseDisplayItem, BorderDetails, BorderDisplayItem, BLUR_INFLATION_FACTOR};
use display_list::items::{BoxShadowDisplayItem, ClipScrollNode};
use display_list::items::{ClipScrollNodeIndex, ClipScrollNodeType, ClippingAndScrolling};
use display_list::items::{ClippingRegion, DisplayItem, DisplayItemMetadata, DisplayList};
use display_list::items::{DisplayListSection, GradientBorder, GradientDisplayItem};
use display_list::items::{IframeDisplayItem, ImageDisplayItem, LineDisplayItem, OpaqueNode};
use display_list::items::{PopAllTextShadowsDisplayItem, PushTextShadowDisplayItem};
use display_list::items::{RadialGradientBorder, RadialGradientDisplayItem, SolidColorDisplayItem};
use display_list::items::{StackingContext, StackingContextType, StickyFrameData, TextDisplayItem};
use display_list::items::{TextOrientation, WebRenderImageInfo};
use euclid::{rect, Point2D, Rect, SideOffsets2D, Size2D, TypedSize2D, Vector2D};
use flex::FlexFlow;
use flow::{BaseFlow, Flow, FlowFlags};
@ -26,17 +36,6 @@ use flow_ref::FlowRef;
use fnv::FnvHashMap;
use fragment::{CanvasFragmentSource, CoordinateSystem, Fragment, ScannedTextFragmentInfo};
use fragment::SpecificFragmentInfo;
use gfx::display_list;
use gfx::display_list::{BaseDisplayItem, BorderDetails, BorderDisplayItem, BLUR_INFLATION_FACTOR};
use gfx::display_list::{BoxShadowDisplayItem, ClipScrollNode};
use gfx::display_list::{ClipScrollNodeIndex, ClipScrollNodeType, ClippingAndScrolling};
use gfx::display_list::{ClippingRegion, DisplayItem, DisplayItemMetadata, DisplayList};
use gfx::display_list::{DisplayListSection, GradientDisplayItem, IframeDisplayItem};
use gfx::display_list::{ImageDisplayItem, LineDisplayItem, OpaqueNode};
use gfx::display_list::{PopAllTextShadowsDisplayItem, PushTextShadowDisplayItem};
use gfx::display_list::{RadialGradientDisplayItem, SolidColorDisplayItem, StackingContext};
use gfx::display_list::{StackingContextType, StickyFrameData, TextDisplayItem, TextOrientation};
use gfx::display_list::WebRenderImageInfo;
use gfx::text::TextRun;
use gfx::text::glyph::ByteIndex;
use gfx_traits::{combine_id_with_fragment_type, FragmentType, StackingContextId};
@ -45,7 +44,6 @@ use ipc_channel::ipc;
use list_item::ListItemFlow;
use model::MaybeAuto;
use msg::constellation_msg::{BrowsingContextId, PipelineId};
use net_traits::image::base::PixelFormat;
use net_traits::image_cache::UsePlaceholder;
use range::Range;
use servo_config::opts;
@ -61,7 +59,7 @@ use style::computed_values::pointer_events::T as PointerEvents;
use style::computed_values::position::T as StylePosition;
use style::computed_values::visibility::T as Visibility;
use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect};
use style::properties::{ComputedValues, style_structs};
use style::properties::{style_structs, ComputedValues};
use style::servo::restyle_damage::ServoRestyleDamage;
use style::values::{Either, RGBA};
use style::values::computed::Gradient;
@ -240,7 +238,7 @@ impl StackingContextCollectionState {
let mut stacking_context_info = FnvHashMap::default();
stacking_context_info.insert(
StackingContextId::root(),
StackingContextInfo::new(StackingContextId::root())
StackingContextInfo::new(StackingContextId::root()),
);
StackingContextCollectionState {
@ -261,7 +259,7 @@ impl StackingContextCollectionState {
fn allocate_stacking_context_info(
&mut self,
stacking_context_type: StackingContextType
stacking_context_type: StackingContextType,
) -> StackingContextId {
let next_stacking_context_id = self.next_stacking_context_id.next();
let allocated_id =
@ -274,7 +272,7 @@ impl StackingContextCollectionState {
self.stacking_context_info.insert(
allocated_id,
StackingContextInfo::new(real_stacking_context_id)
StackingContextInfo::new(real_stacking_context_id),
);
allocated_id
@ -285,7 +283,11 @@ impl StackingContextCollectionState {
parent_id: StackingContextId,
stacking_context: StackingContext,
) {
self.stacking_context_info.get_mut(&parent_id).unwrap().children.push(stacking_context);
self.stacking_context_info
.get_mut(&parent_id)
.unwrap()
.children
.push(stacking_context);
}
fn add_clip_scroll_node(&mut self, clip_scroll_node: ClipScrollNode) -> ClipScrollNodeIndex {
@ -462,7 +464,9 @@ impl<'a> DisplayListBuildState<'a> {
child_items.sort_by(|a, b| a.base().section.cmp(&b.base().section));
child_items.reverse();
let mut info = self.stacking_context_info.remove(&stacking_context.id).unwrap();
let mut info = self.stacking_context_info
.remove(&stacking_context.id)
.unwrap();
info.children.sort();
@ -806,7 +810,13 @@ impl FragmentDisplayListBuilding for Fragment {
// XXXManishearth the below method should ideally use an iterator over
// backgrounds
self.build_display_list_for_background_if_applicable_with_background(
state, style, background, background_color, display_list_section, absolute_bounds)
state,
style,
background,
background_color,
display_list_section,
absolute_bounds,
)
}
fn build_display_list_for_background_if_applicable_with_background(
@ -955,6 +965,9 @@ impl FragmentDisplayListBuilding for Fragment {
index: usize,
) {
debug!("(building display list) building background image");
if webrender_image.key.is_none() {
return;
}
let image = Size2D::new(
Au::from_px(webrender_image.width as i32),
@ -967,13 +980,21 @@ impl FragmentDisplayListBuilding for Fragment {
Some(image),
style.logical_border_width().to_physical(style.writing_mode),
self.border_padding.to_physical(style.writing_mode),
build_border_radius(&absolute_bounds, style.get_border()),
index,
);
let previous_clipping_and_scrolling = state.current_clipping_and_scrolling;
if !placement.clip_radii.is_zero() {
let clip_id =
state.add_late_clip_node(placement.clip_rect.to_layout(), placement.clip_radii);
state.current_clipping_and_scrolling = ClippingAndScrolling::simple(clip_id);
}
// Create the image display item.
let base = state.create_base_display_item(
&placement.bounds,
&placement.css_clip,
&placement.clip_rect,
self.node,
style.get_cursor(CursorKind::Default),
display_list_section,
@ -982,11 +1003,13 @@ impl FragmentDisplayListBuilding for Fragment {
debug!("(building display list) adding background image.");
state.add_display_item(DisplayItem::Image(Box::new(ImageDisplayItem {
base: base,
webrender_image: webrender_image,
id: webrender_image.key.unwrap(),
stretch_size: placement.tile_size.to_layout(),
tile_spacing: placement.tile_spacing.to_layout(),
image_rendering: style.get_inheritedbox().image_rendering.to_layout(),
})));
state.current_clipping_and_scrolling = previous_clipping_and_scrolling;
}
fn get_webrender_image_for_paint_worklet(
@ -1032,7 +1055,6 @@ impl FragmentDisplayListBuilding for Fragment {
let webrender_image = WebRenderImageInfo {
width: draw_result.width,
height: draw_result.height,
format: draw_result.format,
key: draw_result.image_key,
};
@ -1066,12 +1088,20 @@ impl FragmentDisplayListBuilding for Fragment {
None,
style.logical_border_width().to_physical(style.writing_mode),
self.border_padding.to_physical(style.writing_mode),
build_border_radius(&absolute_bounds, style.get_border()),
index,
);
let previous_clipping_and_scrolling = state.current_clipping_and_scrolling;
if !placement.clip_radii.is_zero() {
let clip_id =
state.add_late_clip_node(placement.clip_rect.to_layout(), placement.clip_radii);
state.current_clipping_and_scrolling = ClippingAndScrolling::simple(clip_id);
}
let base = state.create_base_display_item(
&placement.bounds,
&placement.css_clip,
&placement.clip_rect,
self.node,
style.get_cursor(CursorKind::Default),
display_list_section,
@ -1109,6 +1139,7 @@ impl FragmentDisplayListBuilding for Fragment {
},
};
state.add_display_item(display_item);
state.current_clipping_and_scrolling = previous_clipping_and_scrolling;
}
fn build_display_list_for_box_shadow_if_applicable(
@ -1252,7 +1283,7 @@ impl FragmentDisplayListBuilding for Fragment {
Either::Second(Image::Gradient(ref gradient)) => {
Some(match gradient.kind {
GradientKind::Linear(angle_or_corner) => {
BorderDetails::Gradient(display_list::GradientBorder {
BorderDetails::Gradient(GradientBorder {
gradient: convert_linear_gradient(
bounds.size,
&gradient.items[..],
@ -1264,7 +1295,7 @@ impl FragmentDisplayListBuilding for Fragment {
})
},
GradientKind::Radial(shape, center, _angle) => {
BorderDetails::RadialGradient(display_list::RadialGradientBorder {
BorderDetails::RadialGradient(RadialGradientBorder {
gradient: convert_radial_gradient(
bounds.size,
&gradient.items[..],
@ -1519,8 +1550,13 @@ impl FragmentDisplayListBuilding for Fragment {
clip: &Rect<Au>,
) {
self.restyle_damage.remove(ServoRestyleDamage::REPAINT);
self.build_display_list_no_damage(state, stacking_relative_border_box,
border_painting_mode, display_list_section, clip)
self.build_display_list_no_damage(
state,
stacking_relative_border_box,
border_painting_mode,
display_list_section,
clip,
)
}
fn build_display_list_no_damage(
@ -1662,16 +1698,12 @@ impl FragmentDisplayListBuilding for Fragment {
let create_base_display_item = |state: &mut DisplayListBuildState| {
// Adjust the clipping region as necessary to account for `border-radius`.
let radii = build_border_radius_for_inner_rect(
&stacking_relative_border_box,
&self.style
);
let radii =
build_border_radius_for_inner_rect(&stacking_relative_border_box, &self.style);
if !radii.is_zero() {
let clip_id = state.add_late_clip_node(
stacking_relative_border_box.to_layout(),
radii
);
let clip_id =
state.add_late_clip_node(stacking_relative_border_box.to_layout(), radii);
state.current_clipping_and_scrolling = ClippingAndScrolling::simple(clip_id);
}
@ -1779,22 +1811,24 @@ impl FragmentDisplayListBuilding for Fragment {
SpecificFragmentInfo::Image(ref image_fragment) => {
// Place the image into the display list.
if let Some(ref image) = image_fragment.image {
let base = create_base_display_item(state);
state.add_display_item(DisplayItem::Image(Box::new(ImageDisplayItem {
base,
webrender_image: WebRenderImageInfo::from_image(image),
stretch_size: stacking_relative_content_box.size.to_layout(),
tile_spacing: LayoutSize::zero(),
image_rendering: self.style.get_inheritedbox().image_rendering.to_layout(),
})));
if let Some(id) = image.id {
let base = create_base_display_item(state);
state.add_display_item(DisplayItem::Image(Box::new(ImageDisplayItem {
base,
id,
stretch_size: stacking_relative_content_box.size.to_layout(),
tile_spacing: LayoutSize::zero(),
image_rendering: self.style
.get_inheritedbox()
.image_rendering
.to_layout(),
})));
}
}
},
SpecificFragmentInfo::Canvas(ref canvas_fragment_info) => {
let computed_width = canvas_fragment_info.dom_width.to_px();
let computed_height = canvas_fragment_info.dom_height.to_px();
let (image_key, format) = match canvas_fragment_info.source {
CanvasFragmentSource::WebGL(image_key) => (image_key, PixelFormat::BGRA8),
let image_key = match canvas_fragment_info.source {
CanvasFragmentSource::WebGL(image_key) => image_key,
CanvasFragmentSource::Image(ref ipc_renderer) => match *ipc_renderer {
Some(ref ipc_renderer) => {
let ipc_renderer = ipc_renderer.lock().unwrap();
@ -1802,7 +1836,7 @@ impl FragmentDisplayListBuilding for Fragment {
ipc_renderer
.send(CanvasMsg::FromLayout(FromLayoutMsg::SendData(sender)))
.unwrap();
(receiver.recv().unwrap().image_key, PixelFormat::BGRA8)
receiver.recv().unwrap().image_key
},
None => return,
},
@ -1811,12 +1845,7 @@ impl FragmentDisplayListBuilding for Fragment {
let base = create_base_display_item(state);
let display_item = DisplayItem::Image(Box::new(ImageDisplayItem {
base,
webrender_image: WebRenderImageInfo {
width: computed_width as u32,
height: computed_height as u32,
format: format,
key: Some(image_key),
},
id: image_key,
stretch_size: stacking_relative_content_box.size.to_layout(),
tile_spacing: LayoutSize::zero(),
image_rendering: ImageRendering::Auto,
@ -1942,12 +1971,14 @@ impl FragmentDisplayListBuilding for Fragment {
state.add_display_item(DisplayItem::PushTextShadow(Box::new(
PushTextShadowDisplayItem {
base: base.clone(),
blur_radius: shadow.blur.px(),
offset: LayoutVector2D::new(shadow.horizontal.px(), shadow.vertical.px()),
color: shadow
.color
.unwrap_or(self.style().get_color().color)
.to_layout(),
shadow: webrender_api::Shadow {
offset: LayoutVector2D::new(shadow.horizontal.px(), shadow.vertical.px()),
color: shadow
.color
.unwrap_or(self.style().get_color().color)
.to_layout(),
blur_radius: shadow.blur.px(),
},
},
)));
}
@ -2146,7 +2177,8 @@ pub trait BlockFlowDisplayListBuilding {
&self,
state: &mut DisplayListBuildState,
background: &style_structs::Background,
background_color: RGBA);
background_color: RGBA,
);
fn stacking_context_type(
&self,
@ -2679,8 +2711,8 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
let background_border_section = self.background_border_section();
state.processing_scrolling_overflow_element = self.has_scrolling_overflow();
let stacking_relative_border_box =
self.base.stacking_relative_border_box_for_display_list(&self.fragment);
let stacking_relative_border_box = self.base
.stacking_relative_border_box_for_display_list(&self.fragment);
// Add the box that starts the block context.
self.fragment.build_display_list_no_damage(
state,
@ -2701,7 +2733,9 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
state: &mut DisplayListBuildState,
border_painting_mode: BorderPaintingMode,
) {
self.fragment.restyle_damage.remove(ServoRestyleDamage::REPAINT);
self.fragment
.restyle_damage
.remove(ServoRestyleDamage::REPAINT);
self.build_display_list_for_block_no_damage(state, border_painting_mode);
}
@ -2709,23 +2743,28 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
&self,
state: &mut DisplayListBuildState,
background: &style_structs::Background,
background_color: RGBA) {
let stacking_relative_border_box =
self.base.stacking_relative_border_box_for_display_list(&self.fragment);
background_color: RGBA,
) {
let stacking_relative_border_box = self.base
.stacking_relative_border_box_for_display_list(&self.fragment);
let background_border_section = self.background_border_section();
self.fragment.build_display_list_for_background_if_applicable_with_background(
state, self.fragment.style(), background, background_color,
background_border_section, &stacking_relative_border_box
)
self.fragment
.build_display_list_for_background_if_applicable_with_background(
state,
self.fragment.style(),
background,
background_color,
background_border_section,
&stacking_relative_border_box,
)
}
#[inline]
fn stacking_context_type(
&self,
flags: StackingContextCollectionFlags,
) -> Option<StackingContextType>{
) -> Option<StackingContextType> {
if flags.contains(StackingContextCollectionFlags::NEVER_CREATES_STACKING_CONTEXT) {
return None;
}
@ -2734,7 +2773,10 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
return Some(StackingContextType::Real);
}
if self.base.flags.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) {
if self.base
.flags
.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED)
{
return Some(StackingContextType::PseudoPositioned);
}
@ -2810,8 +2852,8 @@ impl InlineFlowDisplayListBuilding for InlineFlow {
index: usize,
) {
let fragment = self.fragments.fragments.get_mut(index).unwrap();
let stacking_relative_border_box =
self.base.stacking_relative_border_box_for_display_list(fragment);
let stacking_relative_border_box = self.base
.stacking_relative_border_box_for_display_list(fragment);
fragment.build_display_list(
state,
stacking_relative_border_box,
@ -2866,8 +2908,9 @@ impl ListItemFlowDisplayListBuilding for ListItemFlow {
fn build_display_list_for_list_item(&mut self, state: &mut DisplayListBuildState) {
// Draw the marker, if applicable.
for marker in &mut self.marker_fragments {
let stacking_relative_border_box =
self.block_flow.base.stacking_relative_border_box_for_display_list(marker);
let stacking_relative_border_box = self.block_flow
.base
.stacking_relative_border_box_for_display_list(marker);
marker.build_display_list(
state,
stacking_relative_border_box,
@ -3057,6 +3100,10 @@ impl IndexableText {
// TODO(#20020): access all elements
let point = point_in_item + item[0].origin.to_vector();
let offset = point - item[0].baseline_origin;
Some(item[0].text_run.range_index_of_advance(&item[0].range, offset.x))
Some(
item[0]
.text_run
.range_index_of_advance(&item[0].range, offset.x),
)
}
}

File diff suppressed because it is too large Load diff

View file

@ -17,4 +17,5 @@ pub use self::webrender_helpers::WebRenderDisplayListConverter;
mod background;
mod builder;
mod conversions;
pub mod items;
mod webrender_helpers;

View file

@ -7,9 +7,9 @@
// This might be achieved by sharing types between WR and Servo display lists, or
// completely converting layout to directly generate WebRender display lists, for example.
use gfx::display_list::{BorderDetails, ClipScrollNode};
use gfx::display_list::{ClipScrollNodeIndex, ClipScrollNodeType, DisplayItem};
use gfx::display_list::{DisplayList, StackingContextType};
use display_list::items::{BorderDetails, ClipScrollNode};
use display_list::items::{ClipScrollNodeIndex, ClipScrollNodeType, DisplayItem};
use display_list::items::{DisplayList, StackingContextType};
use msg::constellation_msg::PipelineId;
use webrender_api::{self, ClipAndScrollInfo, ClipId, DisplayListBuilder};
@ -111,17 +111,15 @@ impl WebRenderDisplayItemConverter for DisplayItem {
);
},
DisplayItem::Image(ref item) => {
if let Some(id) = item.webrender_image.key {
if item.stretch_size.width > 0.0 && item.stretch_size.height > 0.0 {
builder.push_image(
&self.prim_info(),
item.stretch_size,
item.tile_spacing,
item.image_rendering,
webrender_api::AlphaType::PremultipliedAlpha,
id,
);
}
if item.stretch_size.width > 0.0 && item.stretch_size.height > 0.0 {
builder.push_image(
&self.prim_info(),
item.stretch_size,
item.tile_spacing,
item.image_rendering,
webrender_api::AlphaType::PremultipliedAlpha,
item.id,
);
}
},
DisplayItem::Border(ref item) => {
@ -204,14 +202,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
);
},
DisplayItem::PushTextShadow(ref item) => {
builder.push_shadow(
&self.prim_info(),
webrender_api::Shadow {
blur_radius: item.blur_radius,
offset: item.offset,
color: item.color,
},
);
builder.push_shadow(&self.prim_info(), item.shadow);
},
DisplayItem::PopAllTextShadows(_) => {
builder.pop_all_shadows();

View file

@ -29,13 +29,13 @@ use app_units::Au;
use block::{BlockFlow, FormattingContextType};
use context::LayoutContext;
use display_list::{DisplayListBuildState, StackingContextCollectionState};
use display_list::items::ClippingAndScrolling;
use euclid::{Point2D, Vector2D, Rect, Size2D};
use flex::FlexFlow;
use floats::{Floats, SpeculatedFloatPlacement};
use flow_list::{FlowList, FlowListIterator, MutFlowListIterator};
use flow_ref::{FlowRef, WeakFlowRef};
use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
use gfx::display_list::ClippingAndScrolling;
use gfx_traits::StackingContextId;
use gfx_traits::print_tree::PrintTree;
use inline::InlineFlow;

View file

@ -11,12 +11,12 @@ use app_units::Au;
use canvas_traits::canvas::CanvasMsg;
use context::{LayoutContext, with_thread_local_font_context};
use display_list::ToLayout;
use display_list::items::{BLUR_INFLATION_FACTOR, OpaqueNode};
use euclid::{Point2D, Vector2D, Rect, Size2D};
use floats::ClearType;
use flow::{GetBaseFlow, ImmutableFlowUtils};
use flow_ref::FlowRef;
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::StackingContextId;

View file

@ -9,9 +9,9 @@
//! as possible.
use context::{LayoutContext, with_thread_local_font_context};
use display_list::items::OpaqueNode;
use flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils};
use fragment::{Fragment, GeneratedContentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo};
use gfx::display_list::OpaqueNode;
use script_layout_interface::wrapper_traits::PseudoElementType;
use smallvec::SmallVec;
use std::collections::{HashMap, LinkedList};

View file

@ -10,6 +10,7 @@ use block::AbsoluteAssignBSizesTraversal;
use context::{LayoutContext, LayoutFontContext};
use display_list::{DisplayListBuildState, InlineFlowDisplayListBuilding};
use display_list::StackingContextCollectionState;
use display_list::items::OpaqueNode;
use euclid::{Point2D, Size2D};
use floats::{FloatKind, Floats, PlacementInfo};
use flow::{BaseFlow, Flow, FlowClass, ForceNonfloatedFlag};
@ -18,7 +19,6 @@ use flow_ref::FlowRef;
use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
use fragment::FragmentFlags;
use fragment::SpecificFragmentInfo;
use gfx::display_list::OpaqueNode;
use gfx::font::FontMetrics;
use gfx_traits::print_tree::PrintTree;
use layout_debug;

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use gfx::display_list::OpaqueNode;
use display_list::items::OpaqueNode;
use libc::c_void;
use script_traits::UntrustedNodeAddress;

View file

@ -8,10 +8,10 @@ use app_units::Au;
use construct::ConstructionResult;
use context::LayoutContext;
use display_list::IndexableText;
use display_list::items::{DisplayList, OpaqueNode, ScrollOffsetMap};
use euclid::{Point2D, Vector2D, Rect, Size2D};
use flow::{Flow, GetBaseFlow};
use fragment::{Fragment, FragmentBorderBoxIterator, SpecificFragmentInfo};
use gfx::display_list::{DisplayList, OpaqueNode, ScrollOffsetMap};
use inline::InlineFragmentNodeFlags;
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::PipelineId;