Using TransformStyle::Preserve3D

This commit is contained in:
Dzmitry Malyshau 2017-05-05 15:23:41 -04:00
parent 0388e11db2
commit d04a64394e
9 changed files with 79 additions and 57 deletions

View file

@ -68,7 +68,8 @@ use style::values::specified::position::{X, Y};
use style_traits::CSSPixel;
use style_traits::cursor::Cursor;
use table_cell::CollapsedBordersForCell;
use webrender_traits::{ColorF, ClipId, GradientStop, RepeatMode, ScrollPolicy};
use webrender_helpers::{ToMixBlendMode, ToTransformStyle};
use webrender_traits::{ColorF, ClipId, GradientStop, RepeatMode, ScrollPolicy, TransformStyle};
trait ResolvePercentage {
fn resolve(&self, length: u32) -> u32;
@ -184,6 +185,9 @@ pub struct DisplayListBuildState<'a> {
/// A stack of clips used to cull display list entries that are outside the
/// rendered region, but only collected at containing block boundaries.
pub containing_block_clip_stack: Vec<Rect<Au>>,
/// The current transform style of the stacking context.
current_transform_style: TransformStyle,
}
impl<'a> DisplayListBuildState<'a> {
@ -201,6 +205,7 @@ impl<'a> DisplayListBuildState<'a> {
iframe_sizes: Vec::new(),
clip_stack: Vec::new(),
containing_block_clip_stack: Vec::new(),
current_transform_style: TransformStyle::Flat,
}
}
@ -212,6 +217,7 @@ impl<'a> DisplayListBuildState<'a> {
fn add_stacking_context(&mut self,
parent_id: StackingContextId,
stacking_context: StackingContext) {
self.current_transform_style = stacking_context.transform_style;
let info = self.stacking_context_info
.entry(parent_id)
.or_insert(StackingContextInfo::new());
@ -1947,8 +1953,9 @@ impl FragmentDisplayListBuilding for Fragment {
&overflow,
self.effective_z_index(),
filters,
self.style().get_effects().mix_blend_mode,
self.style().get_effects().mix_blend_mode.to_mix_blend_mode(),
self.transform_matrix(&border_box),
self.style().get_used_transform_style().to_transform_style(),
self.perspective_matrix(&border_box),
scroll_policy,
parent_scroll_id)
@ -2153,6 +2160,7 @@ pub struct PreservedDisplayListState {
containing_block_scroll_root_id: ClipId,
clips_pushed: usize,
containing_block_clips_pushed: usize,
transform_style: TransformStyle,
}
impl PreservedDisplayListState {
@ -2163,6 +2171,7 @@ impl PreservedDisplayListState {
containing_block_scroll_root_id: state.containing_block_scroll_root_id,
clips_pushed: 0,
containing_block_clips_pushed: 0,
transform_style: state.current_transform_style,
}
}
@ -2183,6 +2192,8 @@ impl PreservedDisplayListState {
let truncate_length = state.containing_block_clip_stack.len() -
self.containing_block_clips_pushed;
state.containing_block_clip_stack.truncate(truncate_length);
state.current_transform_style = self.transform_style;
}
fn push_clip(&mut self,
@ -2614,14 +2625,14 @@ impl InlineFlowDisplayListBuilding for InlineFlow {
fragment.stacking_context_id = fragment.stacking_context_id();
let current_stacking_context_id = state.current_stacking_context_id;
let current_scroll_root_id = state.current_scroll_root_id;
let stacking_context = fragment.create_stacking_context(fragment.stacking_context_id,
&self.base,
ScrollPolicy::Scrollable,
StackingContextCreationMode::Normal,
state.current_scroll_root_id);
state.add_stacking_context(current_stacking_context_id,
fragment.create_stacking_context(
fragment.stacking_context_id,
&self.base,
ScrollPolicy::Scrollable,
StackingContextCreationMode::Normal,
current_scroll_root_id));
stacking_context);
}
_ => fragment.stacking_context_id = state.current_stacking_context_id,
}