Bug 1582273. Pass scrollbar flags from gecko to webrender so it can identify them. r=gw

Differential Revision: https://phabricator.services.mozilla.com/D46587

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Timothy Nikkel 2019-09-24 02:40:27 +00:00
Родитель 6be46fda93
Коммит 3311b640cc
20 изменённых файлов: 73 добавлений и 52 удалений

Просмотреть файл

@ -336,16 +336,17 @@ class MOZ_RAII AutoTransactionSender {
*/
struct MOZ_STACK_CLASS StackingContextParams : public WrStackingContextParams {
StackingContextParams()
: WrStackingContextParams{WrStackingContextClip::None(),
nullptr,
nullptr,
wr::TransformStyle::Flat,
wr::WrReferenceFrameKind::Transform,
nullptr,
/* is_backface_visible = */ true,
/* cache_tiles = */ false,
wr::MixBlendMode::Normal,
/* is_backdrop_root = */ false} {}
: WrStackingContextParams{
WrStackingContextClip::None(),
nullptr,
nullptr,
wr::TransformStyle::Flat,
wr::WrReferenceFrameKind::Transform,
nullptr,
/* prim_flags = */ wr::PrimitiveFlags_IS_BACKFACE_VISIBLE,
/* cache_tiles = */ false,
wr::MixBlendMode::Normal,
/* is_backdrop_root = */ false} {}
void SetPreserve3D(bool aPreserve) {
transform_style =

Просмотреть файл

@ -2065,7 +2065,7 @@ pub struct WrStackingContextParams {
pub transform_style: TransformStyle,
pub reference_frame_kind: WrReferenceFrameKind,
pub scrolling_relative_to: *const u64,
pub is_backface_visible: bool,
pub prim_flags: PrimitiveFlags,
/// True if picture caching should be enabled for this stacking context.
pub cache_tiles: bool,
pub mix_blend_mode: MixBlendMode,
@ -2185,7 +2185,7 @@ pub extern "C" fn wr_dp_push_stacking_context(
.dl_builder
.push_stacking_context(bounds.origin,
wr_spatial_id,
params.is_backface_visible,
params.prim_flags,
wr_clip_id,
params.transform_style,
params.mix_blend_mode,

Просмотреть файл

@ -37,7 +37,7 @@ impl Example for App {
builder.push_simple_stacking_context(
bounds.origin,
space_and_clip.spatial_id,
true,
PrimitiveFlags::IS_BACKFACE_VISIBLE,
);
for _ in 0 .. self.rect_count {

Просмотреть файл

@ -68,7 +68,7 @@ impl App {
builder.push_simple_stacking_context_with_filters(
LayoutPoint::zero(),
spatial_id,
true,
PrimitiveFlags::IS_BACKFACE_VISIBLE,
&filters,
&[],
&[]

Просмотреть файл

@ -197,7 +197,7 @@ impl Example for App {
builder.push_simple_stacking_context(
content_bounds.origin,
spatial_id,
true,
PrimitiveFlags::IS_BACKFACE_VISIBLE,
);
let image_mask_key = api.generate_image_key();

Просмотреть файл

@ -16,7 +16,7 @@ use rayon::{ThreadPool, ThreadPoolBuilder};
use rayon::prelude::*;
use std::collections::HashMap;
use std::sync::Arc;
use webrender::api::{self, DisplayListBuilder, DocumentId, PipelineId, RenderApi, Transaction};
use webrender::api::{self, DisplayListBuilder, DocumentId, PipelineId, PrimitiveFlags, RenderApi, Transaction};
use webrender::api::{ColorF, CommonItemProperties, SpaceAndClipInfo};
use webrender::api::units::*;
use webrender::euclid::{size2, rect};
@ -229,7 +229,7 @@ impl Example for App {
builder.push_simple_stacking_context(
LayoutPoint::zero(),
space_and_clip.spatial_id,
true,
PrimitiveFlags::IS_BACKFACE_VISIBLE,
);
let bounds = (30, 30).by(500, 500);

Просмотреть файл

@ -118,7 +118,7 @@ impl Example for App {
builder.push_simple_stacking_context(
doc.content_rect.origin,
space_and_clip.spatial_id,
true,
PrimitiveFlags::IS_BACKFACE_VISIBLE,
);
builder.push_rect(
&CommonItemProperties::new(local_rect, space_and_clip),

Просмотреть файл

@ -119,7 +119,7 @@ impl App {
builder.push_simple_stacking_context(
document.content_rect.origin,
space_and_clip.spatial_id,
true,
PrimitiveFlags::IS_BACKFACE_VISIBLE,
);
builder.push_rect(
@ -164,7 +164,7 @@ impl Example for App {
builder.push_simple_stacking_context(
bounds.origin,
space_and_clip.spatial_id,
true,
PrimitiveFlags::IS_BACKFACE_VISIBLE,
);
builder.push_image(

Просмотреть файл

@ -41,7 +41,7 @@ impl Example for App {
sub_builder.push_simple_stacking_context(
sub_bounds.origin,
space_and_clip.spatial_id,
true,
PrimitiveFlags::IS_BACKFACE_VISIBLE,
);
// green rect visible == success
@ -73,7 +73,7 @@ impl Example for App {
builder.push_simple_stacking_context(
sub_bounds.origin,
space_and_clip.spatial_id,
true,
PrimitiveFlags::IS_BACKFACE_VISIBLE,
);
// red rect under the iframe: if this is visible, things have gone wrong

Просмотреть файл

@ -44,7 +44,7 @@ impl Example for App {
builder.push_simple_stacking_context(
bounds.origin,
space_and_clip.spatial_id,
true,
PrimitiveFlags::IS_BACKFACE_VISIBLE,
);
let image_size = LayoutSize::new(100.0, 100.0);

Просмотреть файл

@ -190,7 +190,7 @@ impl Window {
builder.push_simple_stacking_context(
bounds.origin,
space_and_clip.spatial_id,
true,
PrimitiveFlags::IS_BACKFACE_VISIBLE,
);
builder.push_rect(

Просмотреть файл

@ -36,7 +36,7 @@ impl Example for App {
builder.push_simple_stacking_context(
LayoutPoint::zero(),
root_space_and_clip.spatial_id,
true,
PrimitiveFlags::IS_BACKFACE_VISIBLE,
);
if true {
@ -46,7 +46,7 @@ impl Example for App {
builder.push_simple_stacking_context(
LayoutPoint::new(10., 10.),
root_space_and_clip.spatial_id,
true,
PrimitiveFlags::IS_BACKFACE_VISIBLE,
);
// set the scrolling clip
let space_and_clip1 = builder.define_scroll_frame(

Просмотреть файл

@ -102,7 +102,7 @@ impl Example for App {
builder.push_simple_stacking_context(
bounds.origin,
space_and_clip.spatial_id,
true,
PrimitiveFlags::IS_BACKFACE_VISIBLE,
);
let x0 = 50.0;

Просмотреть файл

@ -99,7 +99,7 @@ impl Example for App {
builder.push_simple_stacking_context(
bounds.origin,
space_and_clip.spatial_id,
true,
PrimitiveFlags::IS_BACKFACE_VISIBLE,
);
let yuv_chanel1 = api.generate_image_key();

Просмотреть файл

@ -361,7 +361,7 @@ impl<'a> SceneBuilder<'a> {
root_pipeline.pipeline_id,
CompositeOps::default(),
TransformStyle::Flat,
/* is_backface_visible = */ true,
/* prim_flags = */ PrimitiveFlags::IS_BACKFACE_VISIBLE,
/* create_tile_cache = */ false,
ROOT_SPATIAL_NODE_INDEX,
ClipChainId::NONE,
@ -912,7 +912,7 @@ impl<'a> SceneBuilder<'a> {
filters: ItemRange<FilterOp>,
filter_datas: &[TempFilterData],
filter_primitives: ItemRange<FilterPrimitive>,
is_backface_visible: bool,
prim_flags: PrimitiveFlags,
apply_pipeline_clip: bool,
) {
// Avoid doing unnecessary work for empty stacking contexts.
@ -939,7 +939,7 @@ impl<'a> SceneBuilder<'a> {
pipeline_id,
composition_operations,
stacking_context.transform_style,
is_backface_visible,
prim_flags,
stacking_context.cache_tiles,
spatial_node_index,
clip_chain_id,
@ -1373,7 +1373,7 @@ impl<'a> SceneBuilder<'a> {
item.filters(),
item.filter_datas(),
item.filter_primitives(),
info.is_backface_visible,
info.prim_flags,
apply_pipeline_clip,
);
return Some(subtraversal);
@ -1771,7 +1771,7 @@ impl<'a> SceneBuilder<'a> {
pipeline_id: PipelineId,
composite_ops: CompositeOps,
transform_style: TransformStyle,
is_backface_visible: bool,
prim_flags: PrimitiveFlags,
create_tile_cache: bool,
spatial_node_index: SpatialNodeIndex,
clip_chain_id: ClipChainId,
@ -1895,12 +1895,6 @@ impl<'a> SceneBuilder<'a> {
|sc| sc.snap_to_device.clone(),
);
let prim_flags = if is_backface_visible {
PrimitiveFlags::IS_BACKFACE_VISIBLE
} else {
PrimitiveFlags::empty()
};
// Push the SC onto the stack, so we know how to handle things in
// pop_stacking_context.
self.sc_stack.push(FlattenedStackingContext {

Просмотреть файл

@ -34,12 +34,15 @@ pub const MAX_BLUR_RADIUS: f32 = 300.;
pub type ItemTag = (u64, u16);
bitflags! {
#[repr(C)]
#[derive(Deserialize, MallocSizeOf, Serialize, PeekPoke)]
pub struct PrimitiveFlags: u8 {
/// The CSS backface-visibility property (yes, it can be really granular)
const IS_BACKFACE_VISIBLE = 1 << 0;
/// If set, this primitive represents part of a scroll bar
const IS_SCROLL_BAR = 1 << 1;
/// If set, this primitive represents a scroll bar container
const IS_SCROLLBAR_CONTAINER = 1 << 1;
/// If set, this primitive represents a scroll bar thumb
const IS_SCROLLBAR_THUMB = 1 << 2;
}
}
@ -670,7 +673,7 @@ pub struct ReferenceFrame {
pub struct PushStackingContextDisplayItem {
pub origin: LayoutPoint,
pub spatial_id: SpatialId,
pub is_backface_visible: bool,
pub prim_flags: PrimitiveFlags,
pub stacking_context: StackingContext,
}

Просмотреть файл

@ -1254,7 +1254,7 @@ impl DisplayListBuilder {
&mut self,
origin: LayoutPoint,
spatial_id: di::SpatialId,
is_backface_visible: bool,
prim_flags: di::PrimitiveFlags,
clip_id: Option<di::ClipId>,
transform_style: di::TransformStyle,
mix_blend_mode: di::MixBlendMode,
@ -1270,7 +1270,7 @@ impl DisplayListBuilder {
let item = di::DisplayItem::PushStackingContext(di::PushStackingContextDisplayItem {
origin,
spatial_id,
is_backface_visible,
prim_flags,
stacking_context: di::StackingContext {
transform_style,
mix_blend_mode,
@ -1289,12 +1289,12 @@ impl DisplayListBuilder {
&mut self,
origin: LayoutPoint,
spatial_id: di::SpatialId,
is_backface_visible: bool,
prim_flags: di::PrimitiveFlags,
) {
self.push_simple_stacking_context_with_filters(
origin,
spatial_id,
is_backface_visible,
prim_flags,
&[],
&[],
&[],
@ -1306,7 +1306,7 @@ impl DisplayListBuilder {
&mut self,
origin: LayoutPoint,
spatial_id: di::SpatialId,
is_backface_visible: bool,
prim_flags: di::PrimitiveFlags,
filters: &[di::FilterOp],
filter_datas: &[di::FilterData],
filter_primitives: &[di::FilterPrimitive],
@ -1314,7 +1314,7 @@ impl DisplayListBuilder {
self.push_stacking_context(
origin,
spatial_id,
is_backface_visible,
prim_flags,
None,
di::TransformStyle::Flat,
di::MixBlendMode::Normal,

Просмотреть файл

@ -2035,7 +2035,7 @@ impl YamlFrameReader {
dl.push_stacking_context(
bounds.origin,
*self.spatial_id_stack.last().unwrap(),
info.flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE),
info.flags,
clip_node_id,
transform_style,
mix_blend_mode,

Просмотреть файл

@ -204,6 +204,8 @@ fn maybe_radius_yaml(radius: &BorderRadius) -> Option<Yaml> {
fn common_node(v: &mut Table, clip_id_mapper: &mut ClipIdMapper, info: &CommonItemProperties) {
rect_node(v, "clip-rect", &info.clip_rect);
bool_node(v, "backface-visible", info.flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE));
bool_node(v, "scrollbar-container", info.flags.contains(PrimitiveFlags::IS_SCROLLBAR_CONTAINER));
bool_node(v, "scrollbar-thumb", info.flags.contains(PrimitiveFlags::IS_SCROLLBAR_THUMB));
clip_and_scroll_node(v, clip_id_mapper, info.clip_id, info.spatial_id);
@ -1293,7 +1295,18 @@ impl YamlFrameWriter {
item.spatial_id
);
point_node(&mut v, "origin", &item.origin);
bool_node(&mut v, "backface-visible", item.is_backface_visible);
bool_node(
&mut v,
"backface-visible",
item.prim_flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE));
bool_node(
&mut v,
"scrollbar-container",
item.prim_flags.contains(PrimitiveFlags::IS_SCROLLBAR_CONTAINER));
bool_node(
&mut v,
"scrollbar-thumb",
item.prim_flags.contains(PrimitiveFlags::IS_SCROLLBAR_THUMB));
write_stacking_context(
&mut v,
&item.stacking_context,

Просмотреть файл

@ -6941,6 +6941,12 @@ bool nsDisplayOwnLayer::CreateWebRenderCommands(
params.animation = prop.ptrOr(nullptr);
params.clip =
wr::WrStackingContextClip::ClipChain(aBuilder.CurrentClipChainId());
if (IsScrollbarContainer()) {
params.prim_flags |= wr::PrimitiveFlags_IS_SCROLLBAR_CONTAINER;
}
if (IsScrollThumbLayer()) {
params.prim_flags |= wr::PrimitiveFlags_IS_SCROLLBAR_THUMB;
}
StackingContextHelper sc(aSc, GetActiveScrolledRoot(), mFrame, this, aBuilder,
params);
@ -8626,7 +8632,9 @@ bool nsDisplayTransform::CreateWebRenderCommands(
params.mBoundTransform = &newTransformMatrix;
params.animation = animationsId ? &prop : nullptr;
params.mTransformPtr = transformForSC;
params.is_backface_visible = !BackfaceIsHidden();
params.prim_flags = !BackfaceIsHidden()
? wr::PrimitiveFlags_IS_BACKFACE_VISIBLE
: wr::PrimitiveFlags{0};
params.mDeferredTransformItem = deferredTransformItem;
params.mAnimated = animated;
// Determine if we would have to rasterize any items in local raster space
@ -9329,7 +9337,9 @@ bool nsDisplayPerspective::CreateWebRenderCommands(
wr::StackingContextParams params;
params.mTransformPtr = &perspectiveMatrix;
params.reference_frame_kind = wr::WrReferenceFrameKind::Perspective;
params.is_backface_visible = !BackfaceIsHidden();
params.prim_flags = !BackfaceIsHidden()
? wr::PrimitiveFlags_IS_BACKFACE_VISIBLE
: wr::PrimitiveFlags{0};
params.SetPreserve3D(preserve3D);
params.clip =
wr::WrStackingContextClip::ClipChain(aBuilder.CurrentClipChainId());