Update to handle WebRender API changes

Items now only take a clipping rectangle instead of a LocalClip.
This commit is contained in:
Martin Robinson 2018-03-14 11:31:19 +01:00 committed by Glenn Watson
parent 7e74a10274
commit 41cc348fc5
4 changed files with 36 additions and 35 deletions

View file

@ -28,8 +28,8 @@ use std::fmt;
use webrender_api::{BorderRadius, BorderWidths, BoxShadowClipMode, ClipMode, ColorF}; use webrender_api::{BorderRadius, BorderWidths, BoxShadowClipMode, ClipMode, ColorF};
use webrender_api::{ComplexClipRegion, ExtendMode, ExternalScrollId, FilterOp, FontInstanceKey}; use webrender_api::{ComplexClipRegion, ExtendMode, ExternalScrollId, FilterOp, FontInstanceKey};
use webrender_api::{GlyphInstance, GradientStop, ImageBorder, ImageKey, ImageRendering}; use webrender_api::{GlyphInstance, GradientStop, ImageBorder, ImageKey, ImageRendering};
use webrender_api::{LayoutPoint, LayoutRect, LayoutSize, LayoutTransform, LayoutVector2D, LineStyle}; use webrender_api::{LayoutPoint, LayoutRect, LayoutSize, LayoutTransform, LayoutVector2D};
use webrender_api::{LocalClip, MixBlendMode, NormalBorder, ScrollPolicy, ScrollSensitivity}; use webrender_api::{LineStyle, MixBlendMode, NormalBorder, ScrollPolicy, ScrollSensitivity};
use webrender_api::{StickyOffsetBounds, TransformStyle}; use webrender_api::{StickyOffsetBounds, TransformStyle};
pub use style::dom::OpaqueNode; pub use style::dom::OpaqueNode;
@ -375,8 +375,8 @@ pub struct BaseDisplayItem {
/// Metadata attached to this display item. /// Metadata attached to this display item.
pub metadata: DisplayItemMetadata, pub metadata: DisplayItemMetadata,
/// The local clip for this item. /// The clip rectangle to use for this item.
pub local_clip: LocalClip, pub clip_rect: LayoutRect,
/// The section of the display list that this item belongs to. /// The section of the display list that this item belongs to.
pub section: DisplayListSection, pub section: DisplayListSection,
@ -392,7 +392,7 @@ impl BaseDisplayItem {
#[inline(always)] #[inline(always)]
pub fn new(bounds: LayoutRect, pub fn new(bounds: LayoutRect,
metadata: DisplayItemMetadata, metadata: DisplayItemMetadata,
local_clip: LocalClip, clip_rect: LayoutRect,
section: DisplayListSection, section: DisplayListSection,
stacking_context_id: StackingContextId, stacking_context_id: StackingContextId,
clipping_and_scrolling: ClippingAndScrolling) clipping_and_scrolling: ClippingAndScrolling)
@ -400,7 +400,7 @@ impl BaseDisplayItem {
BaseDisplayItem { BaseDisplayItem {
bounds, bounds,
metadata, metadata,
local_clip, clip_rect,
section, section,
stacking_context_id, stacking_context_id,
clipping_and_scrolling, clipping_and_scrolling,
@ -416,7 +416,7 @@ impl BaseDisplayItem {
pointing: None, pointing: None,
}, },
// Create a rectangle of maximal size. // Create a rectangle of maximal size.
local_clip: LocalClip::from(LayoutRect::max_rect()), clip_rect: LayoutRect::max_rect(),
section: DisplayListSection::Content, section: DisplayListSection::Content,
stacking_context_id: StackingContextId::root(), stacking_context_id: StackingContextId::root(),
clipping_and_scrolling: ClippingAndScrolling::simple(ClipScrollNodeIndex(0)), clipping_and_scrolling: ClippingAndScrolling::simple(ClipScrollNodeIndex(0)),
@ -958,7 +958,7 @@ impl fmt::Debug for DisplayItem {
DisplayItem::DefineClipScrollNode(_) => "".to_owned(), DisplayItem::DefineClipScrollNode(_) => "".to_owned(),
}, },
self.bounds(), self.bounds(),
self.base().local_clip self.base().clip_rect
) )
} }
} }

View file

@ -75,8 +75,8 @@ use style_traits::cursor::CursorKind;
use table_cell::CollapsedBordersForCell; use table_cell::CollapsedBordersForCell;
use webrender_api::{self, BorderRadius, BorderSide, BoxShadowClipMode, ColorF, ExternalScrollId}; use webrender_api::{self, BorderRadius, BorderSide, BoxShadowClipMode, ColorF, ExternalScrollId};
use webrender_api::{FilterOp, GlyphInstance, ImageRendering, LayoutRect, LayoutSize}; use webrender_api::{FilterOp, GlyphInstance, ImageRendering, LayoutRect, LayoutSize};
use webrender_api::{LayoutTransform, LayoutVector2D, LineStyle, LocalClip, NormalBorder}; use webrender_api::{LayoutTransform, LayoutVector2D, LineStyle, NormalBorder, ScrollPolicy};
use webrender_api::{ScrollPolicy, ScrollSensitivity, StickyOffsetBounds}; use webrender_api::{ScrollSensitivity, StickyOffsetBounds};
fn establishes_containing_block_for_absolute( fn establishes_containing_block_for_absolute(
flags: StackingContextCollectionFlags, flags: StackingContextCollectionFlags,
@ -384,7 +384,7 @@ impl<'a> DisplayListBuildState<'a> {
fn create_base_display_item( fn create_base_display_item(
&self, &self,
bounds: &Rect<Au>, bounds: &Rect<Au>,
clip: LocalClip, clip_rect: &Rect<Au>,
node: OpaqueNode, node: OpaqueNode,
cursor: Option<CursorKind>, cursor: Option<CursorKind>,
section: DisplayListSection, section: DisplayListSection,
@ -404,7 +404,7 @@ impl<'a> DisplayListBuildState<'a> {
// Store cursor id in display list. // Store cursor id in display list.
pointing: cursor.map(|x| x as u16), pointing: cursor.map(|x| x as u16),
}, },
clip, clip_rect.to_layout(),
section, section,
self.current_stacking_context_id, self.current_stacking_context_id,
clipping_and_scrolling, clipping_and_scrolling,
@ -856,7 +856,7 @@ impl FragmentDisplayListBuilding for Fragment {
let base = state.create_base_display_item( let base = state.create_base_display_item(
&bounds, &bounds,
LocalClip::Rect(bounds.to_layout()), &bounds,
self.node, self.node,
style.get_cursor(CursorKind::Default), style.get_cursor(CursorKind::Default),
display_list_section, display_list_section,
@ -973,7 +973,7 @@ impl FragmentDisplayListBuilding for Fragment {
// Create the image display item. // Create the image display item.
let base = state.create_base_display_item( let base = state.create_base_display_item(
&placement.bounds, &placement.bounds,
LocalClip::Rect(placement.css_clip.to_layout()), &placement.css_clip,
self.node, self.node,
style.get_cursor(CursorKind::Default), style.get_cursor(CursorKind::Default),
display_list_section, display_list_section,
@ -1071,7 +1071,7 @@ impl FragmentDisplayListBuilding for Fragment {
let base = state.create_base_display_item( let base = state.create_base_display_item(
&placement.bounds, &placement.bounds,
LocalClip::Rect(placement.css_clip.to_layout()), &placement.css_clip,
self.node, self.node,
style.get_cursor(CursorKind::Default), style.get_cursor(CursorKind::Default),
display_list_section, display_list_section,
@ -1132,7 +1132,7 @@ impl FragmentDisplayListBuilding for Fragment {
let base = state.create_base_display_item( let base = state.create_base_display_item(
&bounds, &bounds,
LocalClip::from(clip.to_layout()), clip,
self.node, self.node,
style.get_cursor(CursorKind::Default), style.get_cursor(CursorKind::Default),
display_list_section, display_list_section,
@ -1221,7 +1221,7 @@ impl FragmentDisplayListBuilding for Fragment {
// Append the border to the display list. // Append the border to the display list.
let base = state.create_base_display_item( let base = state.create_base_display_item(
&bounds, &bounds,
LocalClip::from(clip.to_layout()), clip,
self.node, self.node,
style.get_cursor(CursorKind::Default), style.get_cursor(CursorKind::Default),
display_list_section, display_list_section,
@ -1344,7 +1344,7 @@ impl FragmentDisplayListBuilding for Fragment {
.to_layout(); .to_layout();
let base = state.create_base_display_item( let base = state.create_base_display_item(
&bounds, &bounds,
LocalClip::from(clip.to_layout()), clip,
self.node, self.node,
style.get_cursor(CursorKind::Default), style.get_cursor(CursorKind::Default),
DisplayListSection::Outlines, DisplayListSection::Outlines,
@ -1371,7 +1371,7 @@ impl FragmentDisplayListBuilding for Fragment {
// Compute the text fragment bounds and draw a border surrounding them. // Compute the text fragment bounds and draw a border surrounding them.
let base = state.create_base_display_item( let base = state.create_base_display_item(
stacking_relative_border_box, stacking_relative_border_box,
LocalClip::from(clip.to_layout()), clip,
self.node, self.node,
style.get_cursor(CursorKind::Default), style.get_cursor(CursorKind::Default),
DisplayListSection::Content, DisplayListSection::Content,
@ -1397,7 +1397,7 @@ impl FragmentDisplayListBuilding for Fragment {
let base = state.create_base_display_item( let base = state.create_base_display_item(
&baseline, &baseline,
LocalClip::from(clip.to_layout()), clip,
self.node, self.node,
style.get_cursor(CursorKind::Default), style.get_cursor(CursorKind::Default),
DisplayListSection::Content, DisplayListSection::Content,
@ -1418,7 +1418,7 @@ impl FragmentDisplayListBuilding for Fragment {
// This prints a debug border around the border of this fragment. // This prints a debug border around the border of this fragment.
let base = state.create_base_display_item( let base = state.create_base_display_item(
stacking_relative_border_box, stacking_relative_border_box,
LocalClip::from(clip.to_layout()), clip,
self.node, self.node,
self.style.get_cursor(CursorKind::Default), self.style.get_cursor(CursorKind::Default),
DisplayListSection::Content, DisplayListSection::Content,
@ -1455,7 +1455,7 @@ impl FragmentDisplayListBuilding for Fragment {
let background_color = style.resolve_color(style.get_background().background_color); let background_color = style.resolve_color(style.get_background().background_color);
let base = state.create_base_display_item( let base = state.create_base_display_item(
stacking_relative_border_box, stacking_relative_border_box,
LocalClip::from(clip.to_layout()), clip,
self.node, self.node,
self.style.get_cursor(CursorKind::Default), self.style.get_cursor(CursorKind::Default),
display_list_section, display_list_section,
@ -1499,7 +1499,7 @@ impl FragmentDisplayListBuilding for Fragment {
let base = state.create_base_display_item( let base = state.create_base_display_item(
&insertion_point_bounds, &insertion_point_bounds,
LocalClip::from(clip.to_layout()), clip,
self.node, self.node,
self.style.get_cursor(cursor), self.style.get_cursor(cursor),
display_list_section, display_list_section,
@ -1661,20 +1661,23 @@ impl FragmentDisplayListBuilding for Fragment {
self.stacking_relative_content_box(stacking_relative_border_box); self.stacking_relative_content_box(stacking_relative_border_box);
let create_base_display_item = |state: &mut DisplayListBuildState| { let create_base_display_item = |state: &mut DisplayListBuildState| {
let layout_rect = stacking_relative_border_box.to_layout();
// Adjust the clipping region as necessary to account for `border-radius`. // Adjust the clipping region as necessary to account for `border-radius`.
let radii = let radii = build_border_radius_for_inner_rect(
build_border_radius_for_inner_rect(&stacking_relative_border_box, &self.style); &stacking_relative_border_box,
&self.style
);
if !radii.is_zero() { if !radii.is_zero() {
let clip_id = state.add_late_clip_node(layout_rect, 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); state.current_clipping_and_scrolling = ClippingAndScrolling::simple(clip_id);
} }
state.create_base_display_item( state.create_base_display_item(
&stacking_relative_content_box, &stacking_relative_content_box,
LocalClip::Rect(layout_rect), &stacking_relative_border_box,
self.node, self.node,
self.style.get_cursor(CursorKind::Default), self.style.get_cursor(CursorKind::Default),
DisplayListSection::Content, DisplayListSection::Content,
@ -1925,7 +1928,7 @@ impl FragmentDisplayListBuilding for Fragment {
// Base item for all text/shadows // Base item for all text/shadows
let base = state.create_base_display_item( let base = state.create_base_display_item(
&stacking_relative_content_box, &stacking_relative_content_box,
LocalClip::from(clip.to_layout()), clip,
self.node, self.node,
self.style().get_cursor(cursor), self.style().get_cursor(cursor),
DisplayListSection::Content, DisplayListSection::Content,
@ -2046,7 +2049,7 @@ impl FragmentDisplayListBuilding for Fragment {
stacking_relative_box.to_physical(self.style.writing_mode, container_size); stacking_relative_box.to_physical(self.style.writing_mode, container_size);
let base = state.create_base_display_item( let base = state.create_base_display_item(
&stacking_relative_box, &stacking_relative_box,
LocalClip::from(clip.to_layout()), clip,
self.node, self.node,
self.style.get_cursor(CursorKind::Default), self.style.get_cursor(CursorKind::Default),
DisplayListSection::Content, DisplayListSection::Content,
@ -2920,7 +2923,7 @@ impl BaseFlowDisplayListBuilding for BaseFlow {
color.a = 1.0; color.a = 1.0;
let base = state.create_base_display_item( let base = state.create_base_display_item(
&stacking_context_relative_bounds.inflate(Au::from_px(2), Au::from_px(2)), &stacking_context_relative_bounds.inflate(Au::from_px(2), Au::from_px(2)),
LocalClip::from(self.clip.to_layout()), &self.clip,
node, node,
None, None,
DisplayListSection::Content, DisplayListSection::Content,

View file

@ -63,7 +63,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
}; };
webrender_api::LayoutPrimitiveInfo { webrender_api::LayoutPrimitiveInfo {
rect: self.base().bounds, rect: self.base().bounds,
local_clip: self.base().local_clip, clip_rect: self.base().clip_rect,
// TODO(gw): Make use of the WR backface visibility functionality. // TODO(gw): Make use of the WR backface visibility functionality.
is_backface_visible: true, is_backface_visible: true,
tag, tag,

View file

@ -758,8 +758,6 @@ malloc_size_of_is_0!(webrender_api::ImageRendering);
#[cfg(feature = "webrender_api")] #[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::LineStyle); malloc_size_of_is_0!(webrender_api::LineStyle);
#[cfg(feature = "webrender_api")] #[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::LocalClip);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::MixBlendMode); malloc_size_of_is_0!(webrender_api::MixBlendMode);
#[cfg(feature = "webrender_api")] #[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(webrender_api::NormalBorder); malloc_size_of_is_0!(webrender_api::NormalBorder);