mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Upgrade WebRender to e491e1ae637b2eed1e7195855d88357e5eb3ddf9 (#30323)
* Upgrade vendored version of WebRender * Patch WebRender: upgrade version of gleam * Restore hit testing implementation * Fix WebRender warnings * Adapt Servo to new WebRender * Update results * Add a workaround for #30313 This slightly expands text boundaries in order to take into account the fact that layout isn't measuring glyph boundaries.
This commit is contained in:
parent
c079acb3c3
commit
a9d37cb85a
563 changed files with 48524 additions and 51657 deletions
|
@ -64,8 +64,8 @@ pub(super) fn painting_area<'a>(
|
|||
};
|
||||
// The 'backgound-clip' property maps directly to `clip_rect` in `CommonItemProperties`:
|
||||
let mut common = builder.common_properties(*painting_area, &fb.fragment.style);
|
||||
if let Some(clip_id) = clip {
|
||||
common.clip_id = clip_id
|
||||
if let Some(clip_chain_id) = clip {
|
||||
common.clip_id = wr::ClipId::ClipChain(clip_chain_id)
|
||||
}
|
||||
(painting_area, common)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ impl ToWebRender for ComputedFilter {
|
|||
type Type = FilterOp;
|
||||
fn to_webrender(&self) -> Self::Type {
|
||||
match *self {
|
||||
ComputedFilter::Blur(radius) => FilterOp::Blur(radius.px()),
|
||||
ComputedFilter::Blur(radius) => FilterOp::Blur(radius.px(), radius.px()),
|
||||
ComputedFilter::Brightness(amount) => FilterOp::Brightness(amount.0),
|
||||
ComputedFilter::Contrast(amount) => FilterOp::Contrast(amount.0),
|
||||
ComputedFilter::Grayscale(amount) => FilterOp::Grayscale(amount.0),
|
||||
|
|
|
@ -26,7 +26,7 @@ use style::values::computed::{BorderStyle, Color, Length, LengthPercentage, Outl
|
|||
use style::values::specified::text::TextDecorationLine;
|
||||
use style::values::specified::ui::CursorKind;
|
||||
use style_traits::CSSPixel;
|
||||
use webrender_api::{self as wr, units};
|
||||
use webrender_api::{self as wr, units, ClipChainId, ClipId, CommonItemProperties};
|
||||
|
||||
mod background;
|
||||
mod conversions;
|
||||
|
@ -71,7 +71,7 @@ impl DisplayList {
|
|||
epoch: wr::Epoch,
|
||||
) -> Self {
|
||||
Self {
|
||||
wr: wr::DisplayListBuilder::new(pipeline_id, content_size),
|
||||
wr: wr::DisplayListBuilder::new(pipeline_id),
|
||||
compositor_info: CompositorDisplayListInfo::new(
|
||||
viewport_size,
|
||||
content_size,
|
||||
|
@ -93,7 +93,7 @@ pub(crate) struct DisplayListBuilder<'a> {
|
|||
/// only passing the builder instead passing the containing
|
||||
/// [stacking_context::StackingContextFragment] as an argument to display
|
||||
/// list building functions.
|
||||
current_clip_id: wr::ClipId,
|
||||
current_clip_chain_id: ClipChainId,
|
||||
|
||||
/// The [OpaqueNode] handle to the node used to paint the page background
|
||||
/// if the background was a canvas.
|
||||
|
@ -126,8 +126,8 @@ impl DisplayList {
|
|||
root_stacking_context: &StackingContext,
|
||||
) -> (FnvHashMap<BrowsingContextId, Size2D<f32, CSSPixel>>, bool) {
|
||||
let mut builder = DisplayListBuilder {
|
||||
current_scroll_node_id: self.compositor_info.root_scroll_node_id,
|
||||
current_clip_id: wr::ClipId::root(self.wr.pipeline_id),
|
||||
current_scroll_node_id: self.compositor_info.root_reference_frame_id,
|
||||
current_clip_chain_id: ClipChainId(0, self.compositor_info.pipeline_id),
|
||||
element_for_canvas_background: fragment_tree.canvas_background.from_element,
|
||||
is_contentful: false,
|
||||
context,
|
||||
|
@ -155,8 +155,7 @@ impl<'a> DisplayListBuilder<'a> {
|
|||
wr::CommonItemProperties {
|
||||
clip_rect,
|
||||
spatial_id: self.current_scroll_node_id.spatial_id,
|
||||
clip_id: self.current_clip_id,
|
||||
hit_info: None,
|
||||
clip_id: ClipId::ClipChain(self.current_clip_chain_id),
|
||||
flags: style.get_webrender_primitive_flags(),
|
||||
}
|
||||
}
|
||||
|
@ -281,12 +280,21 @@ impl Fragment {
|
|||
return;
|
||||
}
|
||||
|
||||
let common = builder.common_properties(rect.to_webrender(), &fragment.parent_style);
|
||||
|
||||
let hit_info = builder.hit_info(&fragment.parent_style, fragment.base.tag, Cursor::Text);
|
||||
let mut hit_test_common = common.clone();
|
||||
hit_test_common.hit_info = hit_info;
|
||||
builder.wr().push_hit_test(&hit_test_common);
|
||||
if let Some(hit_info) =
|
||||
builder.hit_info(&fragment.parent_style, fragment.base.tag, Cursor::Text)
|
||||
{
|
||||
let clip_chain_id = builder.current_clip_chain_id;
|
||||
let spatial_id = builder.current_scroll_node_id.spatial_id;
|
||||
builder.wr().push_hit_test(
|
||||
&CommonItemProperties {
|
||||
clip_rect: rect.to_webrender(),
|
||||
clip_id: ClipId::ClipChain(clip_chain_id),
|
||||
spatial_id,
|
||||
flags: fragment.parent_style.get_webrender_primitive_flags(),
|
||||
},
|
||||
hit_info,
|
||||
);
|
||||
}
|
||||
|
||||
let color = fragment.parent_style.clone_color();
|
||||
let font_metrics = &fragment.font_metrics;
|
||||
|
@ -318,6 +326,7 @@ impl Fragment {
|
|||
}
|
||||
|
||||
// Text.
|
||||
let common = builder.common_properties(rect.to_webrender(), &fragment.parent_style);
|
||||
builder.wr().push_text(
|
||||
&common,
|
||||
rect.to_webrender(),
|
||||
|
@ -376,9 +385,9 @@ struct BuilderForBoxFragment<'a> {
|
|||
padding_rect: OnceCell<units::LayoutRect>,
|
||||
content_rect: OnceCell<units::LayoutRect>,
|
||||
border_radius: wr::BorderRadius,
|
||||
border_edge_clip_id: OnceCell<Option<wr::ClipId>>,
|
||||
padding_edge_clip_id: OnceCell<Option<wr::ClipId>>,
|
||||
content_edge_clip_id: OnceCell<Option<wr::ClipId>>,
|
||||
border_edge_clip_chain_id: OnceCell<Option<ClipChainId>>,
|
||||
padding_edge_clip_chain_id: OnceCell<Option<ClipChainId>>,
|
||||
content_edge_clip_chain_id: OnceCell<Option<ClipChainId>>,
|
||||
}
|
||||
|
||||
impl<'a> BuilderForBoxFragment<'a> {
|
||||
|
@ -433,9 +442,9 @@ impl<'a> BuilderForBoxFragment<'a> {
|
|||
border_radius,
|
||||
padding_rect: OnceCell::new(),
|
||||
content_rect: OnceCell::new(),
|
||||
border_edge_clip_id: OnceCell::new(),
|
||||
padding_edge_clip_id: OnceCell::new(),
|
||||
content_edge_clip_id: OnceCell::new(),
|
||||
border_edge_clip_chain_id: OnceCell::new(),
|
||||
padding_edge_clip_chain_id: OnceCell::new(),
|
||||
content_edge_clip_chain_id: OnceCell::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -459,14 +468,14 @@ impl<'a> BuilderForBoxFragment<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
fn border_edge_clip(&self, builder: &mut DisplayListBuilder) -> Option<wr::ClipId> {
|
||||
fn border_edge_clip(&self, builder: &mut DisplayListBuilder) -> Option<ClipChainId> {
|
||||
*self
|
||||
.border_edge_clip_id
|
||||
.border_edge_clip_chain_id
|
||||
.get_or_init(|| clip_for_radii(self.border_radius, self.border_rect, builder))
|
||||
}
|
||||
|
||||
fn padding_edge_clip(&self, builder: &mut DisplayListBuilder) -> Option<wr::ClipId> {
|
||||
*self.padding_edge_clip_id.get_or_init(|| {
|
||||
fn padding_edge_clip(&self, builder: &mut DisplayListBuilder) -> Option<ClipChainId> {
|
||||
*self.padding_edge_clip_chain_id.get_or_init(|| {
|
||||
clip_for_radii(
|
||||
inner_radii(
|
||||
self.border_radius,
|
||||
|
@ -481,8 +490,8 @@ impl<'a> BuilderForBoxFragment<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
fn content_edge_clip(&self, builder: &mut DisplayListBuilder) -> Option<wr::ClipId> {
|
||||
*self.content_edge_clip_id.get_or_init(|| {
|
||||
fn content_edge_clip(&self, builder: &mut DisplayListBuilder) -> Option<ClipChainId> {
|
||||
*self.content_edge_clip_chain_id.get_or_init(|| {
|
||||
clip_for_radii(
|
||||
inner_radii(
|
||||
self.border_radius,
|
||||
|
@ -512,14 +521,16 @@ impl<'a> BuilderForBoxFragment<'a> {
|
|||
self.fragment.base.tag,
|
||||
Cursor::Default,
|
||||
);
|
||||
if hit_info.is_some() {
|
||||
let mut common = builder.common_properties(self.border_rect, &self.fragment.style);
|
||||
common.hit_info = hit_info;
|
||||
if let Some(clip_id) = self.border_edge_clip(builder) {
|
||||
common.clip_id = clip_id
|
||||
}
|
||||
builder.wr().push_hit_test(&common)
|
||||
let hit_info = match hit_info {
|
||||
Some(hit_info) => hit_info,
|
||||
None => return,
|
||||
};
|
||||
|
||||
let mut common = builder.common_properties(self.border_rect, &self.fragment.style);
|
||||
if let Some(clip_chain_id) = self.border_edge_clip(builder) {
|
||||
common.clip_id = ClipId::ClipChain(clip_chain_id);
|
||||
}
|
||||
builder.wr().push_hit_test(&common, hit_info);
|
||||
}
|
||||
|
||||
fn build_background(&mut self, builder: &mut DisplayListBuilder) {
|
||||
|
@ -868,21 +879,27 @@ fn clip_for_radii(
|
|||
radii: wr::BorderRadius,
|
||||
rect: units::LayoutRect,
|
||||
builder: &mut DisplayListBuilder,
|
||||
) -> Option<wr::ClipId> {
|
||||
) -> Option<ClipChainId> {
|
||||
if radii.is_zero() {
|
||||
None
|
||||
} else {
|
||||
let clip_chain_id = builder.current_clip_chain_id.clone();
|
||||
let parent_space_and_clip = wr::SpaceAndClipInfo {
|
||||
spatial_id: builder.current_scroll_node_id.spatial_id,
|
||||
clip_id: builder.current_clip_id,
|
||||
clip_id: ClipId::ClipChain(clip_chain_id),
|
||||
};
|
||||
Some(builder.wr().define_clip_rounded_rect(
|
||||
let new_clip_id = builder.wr().define_clip_rounded_rect(
|
||||
&parent_space_and_clip,
|
||||
wr::ComplexClipRegion {
|
||||
rect,
|
||||
radii,
|
||||
mode: wr::ClipMode::Clip,
|
||||
},
|
||||
))
|
||||
);
|
||||
Some(
|
||||
builder
|
||||
.wr()
|
||||
.define_clip_chain(Some(clip_chain_id), [new_clip_id]),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ use style::values::generics::transform;
|
|||
use style::values::specified::box_::DisplayOutside;
|
||||
use webrender_api as wr;
|
||||
use webrender_api::units::{LayoutPoint, LayoutRect, LayoutTransform, LayoutVector2D};
|
||||
use webrender_api::ScrollSensitivity;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct ContainingBlock {
|
||||
|
@ -150,17 +151,16 @@ impl DisplayList {
|
|||
external_id: wr::ExternalScrollId,
|
||||
content_rect: LayoutRect,
|
||||
clip_rect: LayoutRect,
|
||||
scroll_sensitivity: wr::ScrollSensitivity,
|
||||
external_scroll_offset: LayoutVector2D,
|
||||
scroll_sensitivity: ScrollSensitivity,
|
||||
) -> (ScrollTreeNodeId, wr::ClipChainId) {
|
||||
let parent_space_and_clip_info = wr::SpaceAndClipInfo {
|
||||
spatial_id: parent_scroll_node_id.spatial_id,
|
||||
clip_id: wr::ClipId::root(self.wr.pipeline_id),
|
||||
};
|
||||
|
||||
let new_clip_id = self
|
||||
.wr
|
||||
.define_clip_rect(&parent_space_and_clip_info, clip_rect);
|
||||
|
||||
let new_clip_chain_id = self
|
||||
.wr
|
||||
.define_clip_chain(Some(*parent_clip_chain_id), [new_clip_id]);
|
||||
|
@ -169,11 +169,11 @@ impl DisplayList {
|
|||
.wr
|
||||
.define_scroll_frame(
|
||||
&parent_space_and_clip_info,
|
||||
Some(external_id),
|
||||
external_id,
|
||||
content_rect,
|
||||
clip_rect,
|
||||
scroll_sensitivity,
|
||||
external_scroll_offset,
|
||||
LayoutVector2D::zero(), /* external_scroll_offset */
|
||||
)
|
||||
.spatial_id;
|
||||
|
||||
|
@ -202,7 +202,7 @@ pub(crate) struct StackingContextFragment {
|
|||
impl StackingContextFragment {
|
||||
fn build_display_list(&self, builder: &mut DisplayListBuilder) {
|
||||
builder.current_scroll_node_id = self.scroll_node_id;
|
||||
builder.current_clip_id = wr::ClipId::ClipChain(self.clip_chain_id);
|
||||
builder.current_clip_chain_id = self.clip_chain_id;
|
||||
self.fragment
|
||||
.borrow()
|
||||
.build_display_list(builder, &self.containing_block, self.section);
|
||||
|
@ -964,9 +964,9 @@ impl BoxFragment {
|
|||
|
||||
let sensitivity =
|
||||
if ComputedOverflow::Hidden == overflow_x && ComputedOverflow::Hidden == overflow_y {
|
||||
wr::ScrollSensitivity::Script
|
||||
ScrollSensitivity::Script
|
||||
} else {
|
||||
wr::ScrollSensitivity::ScriptAndInputEvents
|
||||
ScrollSensitivity::ScriptAndInputEvents
|
||||
};
|
||||
|
||||
let padding_rect = self
|
||||
|
@ -984,7 +984,6 @@ impl BoxFragment {
|
|||
.to_webrender(),
|
||||
padding_rect,
|
||||
sensitivity,
|
||||
LayoutVector2D::zero(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@ -1013,7 +1012,13 @@ impl BoxFragment {
|
|||
scrolling_relative_to: None,
|
||||
},
|
||||
),
|
||||
(Some(transform), None) => (transform, wr::ReferenceFrameKind::Transform),
|
||||
(Some(transform), None) => (
|
||||
transform,
|
||||
wr::ReferenceFrameKind::Transform {
|
||||
is_2d_scale_translation: false,
|
||||
should_snap: false,
|
||||
},
|
||||
),
|
||||
(Some(transform), Some(perspective)) => (
|
||||
perspective.then(&transform),
|
||||
wr::ReferenceFrameKind::Perspective {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue