servo: Merge #17863 - Update WR (scroll/overflow mostly) (from glennw:update-wr-scroll-stuff); r=emilio
authorGlenn Watson <github@intuitionlibrary.com>
Tue, 25 Jul 2017 19:16:34 -0700
changeset 419674 70c20fc0105491ba111c188a23e93b35d86554e7
parent 419673 1528aa401501daca942c4fd3568fe3df00fb2a69
child 419675 756aa07a185219e8340a196ad215fcd2d5b4d349
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs17863
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #17863 - Update WR (scroll/overflow mostly) (from glennw:update-wr-scroll-stuff); r=emilio Source-Repo: https://github.com/servo/servo Source-Revision: f351e6819873d208f2fc2b6b9908f8d91655296f
servo/Cargo.lock
servo/components/gfx/display_list/mod.rs
servo/components/layout/display_list_builder.rs
servo/components/layout/webrender_helpers.rs
--- a/servo/Cargo.lock
+++ b/servo/Cargo.lock
@@ -3460,17 +3460,17 @@ dependencies = [
  "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "uuid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "webdriver 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "webrender"
 version = "0.48.0"
-source = "git+https://github.com/servo/webrender#8fd634882111415a65da67e947f26eb170234f2f"
+source = "git+https://github.com/servo/webrender#283192c41743a59da87b065cbc14c659d94c90b5"
 dependencies = [
  "app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-text 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3489,17 +3489,17 @@ dependencies = [
  "thread_profiler 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
  "webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
 ]
 
 [[package]]
 name = "webrender_api"
 version = "0.48.0"
-source = "git+https://github.com/servo/webrender#8fd634882111415a65da67e947f26eb170234f2f"
+source = "git+https://github.com/servo/webrender#283192c41743a59da87b065cbc14c659d94c90b5"
 dependencies = [
  "app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
--- a/servo/components/gfx/display_list/mod.rs
+++ b/servo/components/gfx/display_list/mod.rs
@@ -29,17 +29,17 @@ use std::collections::HashMap;
 use std::fmt;
 use std::sync::Arc;
 use style::computed_values::{border_style, image_rendering};
 use style::values::computed::Filter;
 use style_traits::cursor::Cursor;
 use text::TextRun;
 use text::glyph::ByteIndex;
 use webrender_api::{self, ClipId, ColorF, GradientStop, LocalClip, MixBlendMode, ScrollPolicy};
-use webrender_api::{TransformStyle, WebGLContextId};
+use webrender_api::{ScrollSensitivity, TransformStyle, WebGLContextId};
 
 pub use style::dom::OpaqueNode;
 
 /// The factor that we multiply the blur radius by in order to inflate the boundaries of display
 /// items that involve a blur. This ensures that the display item boundaries include all the ink.
 pub static BLUR_INFLATION_FACTOR: i32 = 3;
 
 #[derive(HeapSizeOf, Deserialize, Serialize)]
@@ -554,17 +554,17 @@ impl fmt::Debug for StackingContext {
                self.bounds,
                self.overflow,
                self.id)
     }
 }
 
 #[derive(Clone, Debug, HeapSizeOf, Deserialize, Serialize)]
 pub enum ScrollRootType {
-    ScrollFrame,
+    ScrollFrame(ScrollSensitivity),
     Clip,
 }
 
 /// Defines a stacking context.
 #[derive(Clone, Debug, HeapSizeOf, Deserialize, Serialize)]
 pub struct ScrollRoot {
     /// The WebRender clip id of this scroll root based on the source of this clip
     /// and information about the fragment.
--- a/servo/components/layout/display_list_builder.rs
+++ b/servo/components/layout/display_list_builder.rs
@@ -66,17 +66,17 @@ use style::values::generics::image::{Cir
 use style::values::generics::image::{GradientItem as GenericGradientItem, GradientKind};
 use style::values::generics::image::{Image, ShapeExtent};
 use style::values::generics::image::PaintWorklet;
 use style::values::specified::position::{X, Y};
 use style_traits::CSSPixel;
 use style_traits::cursor::Cursor;
 use table_cell::CollapsedBordersForCell;
 use webrender_api::{ClipId, ColorF, ComplexClipRegion, GradientStop, LocalClip, RepeatMode};
-use webrender_api::{LineStyle, ScrollPolicy, TransformStyle};
+use webrender_api::{LineStyle, ScrollPolicy, ScrollSensitivity, TransformStyle};
 use webrender_helpers::{ToBorderRadius, ToMixBlendMode, ToRectF, ToTransformStyle};
 
 trait ResolvePercentage {
     fn resolve(&self, length: u32) -> u32;
 }
 
 impl ResolvePercentage for NumberOrPercentage {
     fn resolve(&self, length: u32) -> u32 {
@@ -2252,17 +2252,16 @@ pub trait BlockFlowDisplayListBuilding {
                                           preserved_state: &mut PreservedDisplayListState);
     fn setup_clipping_for_block(&mut self,
                                 state: &mut DisplayListBuildState,
                                 preserved_state: &mut PreservedDisplayListState,
                                 stacking_context_type: BlockStackingContextType)
                                 -> ClipId;
     fn setup_scroll_root_for_overflow(&mut self,
                                       state: &mut DisplayListBuildState,
-                                      preserved_state: &mut PreservedDisplayListState,
                                       border_box: &Rect<Au>);
     fn setup_scroll_root_for_css_clip(&mut self,
                                       state: &mut DisplayListBuildState,
                                       preserved_state: &mut PreservedDisplayListState,
                                       stacking_relative_border_box: &Rect<Au>);
     fn create_pseudo_stacking_context_for_block(&mut self,
                                                 parent_stacking_context_id: StackingContextId,
                                                 parent_scroll_root_id: ClipId,
@@ -2478,32 +2477,31 @@ impl BlockFlowDisplayListBuilding for Bl
             &self.base.early_absolute_position_info.relative_containing_block_size,
             self.base.early_absolute_position_info.relative_containing_block_mode,
             coordinate_system);
 
         if stacking_context_type == BlockStackingContextType::StackingContext {
             self.transform_clip_to_coordinate_space(state, preserved_state);
         }
 
-        self.setup_scroll_root_for_overflow(state, preserved_state, &stacking_relative_border_box);
+        self.setup_scroll_root_for_overflow(state, &stacking_relative_border_box);
         self.setup_scroll_root_for_css_clip(state, preserved_state, &stacking_relative_border_box);
         self.base.clip = state.clip_stack.last().cloned().unwrap_or_else(max_rect);
 
         match self.positioning() {
             position::T::absolute | position::T::relative | position::T::fixed =>
                 state.containing_block_scroll_root_id = state.current_scroll_root_id,
             _ => {}
         }
 
         containing_scroll_root_id
     }
 
     fn setup_scroll_root_for_overflow(&mut self,
                                       state: &mut DisplayListBuildState,
-                                      preserved_state: &mut PreservedDisplayListState,
                                       border_box: &Rect<Au>) {
         if !self.overflow_style_may_require_scroll_root() {
             return;
         }
 
         let content_box = self.fragment.stacking_relative_content_box(&border_box);
         let has_scrolling_overflow =
             self.base.overflow.scroll.origin != Point2D::zero() ||
@@ -2521,53 +2519,41 @@ impl BlockFlowDisplayListBuilding for Bl
         // when fragments map to more than one flow, such as in the case of table
         // wrappers. We just accept the first scroll root in that case.
         let new_scroll_root_id = ClipId::new(self.fragment.unique_id(IdType::OverflowClip),
                                              state.layout_context.id.to_webrender());
         if state.has_scroll_root(new_scroll_root_id) {
             return;
         }
 
-        let overflow_x = self.fragment.style.get_box().overflow_x;
-        let overflow_y = self.fragment.style.get_box().overflow_y;
-
-        let content_size = self.base.overflow.scroll.origin + self.base.overflow.scroll.size;
-        let mut content_size = Size2D::new(content_size.x, content_size.y);
-        if overflow_x::T::hidden == overflow_x {
-            content_size.width = content_box.size.width;
-        }
-
-        if overflow_x::T::hidden == overflow_y {
-            content_size.height = content_box.size.height;
-        }
-
-        if overflow_x::T::hidden == overflow_y || overflow_x::T::hidden == overflow_x {
-            preserved_state.push_clip(state, &border_box, self.positioning());
-        }
-
-        let mut root_type = ScrollRootType::ScrollFrame;
-        if overflow_x::T::hidden == overflow_y && overflow_x::T::hidden == overflow_x {
-            root_type = ScrollRootType::Clip;
-        }
+        let sensitivity = if overflow_x::T::hidden == self.fragment.style.get_box().overflow_x &&
+                             overflow_x::T::hidden == self.fragment.style.get_box().overflow_y {
+            ScrollSensitivity::Script
+        } else {
+            ScrollSensitivity::ScriptAndInputEvents
+        };
 
         let clip_rect = build_inner_border_box_for_border_rect(&border_box, &self.fragment.style);
         let mut clip = ClippingRegion::from_rect(&clip_rect);
         let radii = build_border_radius_for_inner_rect(&border_box, &self.fragment.style);
         if !radii.is_square() {
             clip.intersect_with_rounded_rect(&clip_rect, &radii)
         }
 
+        let content_size = self.base.overflow.scroll.origin + self.base.overflow.scroll.size;
+        let content_size = Size2D::new(content_size.x, content_size.y);
+
         let parent_id = self.scroll_root_id(state.layout_context.id);
         state.add_scroll_root(
             ScrollRoot {
                 id: new_scroll_root_id,
                 parent_id: parent_id,
                 clip: clip,
                 content_rect: Rect::new(content_box.origin, content_size),
-                root_type,
+                root_type: ScrollRootType::ScrollFrame(sensitivity),
             },
             self.base.stacking_context_id
         );
 
         self.base.scroll_root_id = Some(new_scroll_root_id);
         state.current_scroll_root_id = new_scroll_root_id;
     }
 
--- a/servo/components/layout/webrender_helpers.rs
+++ b/servo/components/layout/webrender_helpers.rs
@@ -11,18 +11,18 @@ use app_units::Au;
 use euclid::{Point2D, Vector2D, Rect, SideOffsets2D, Size2D};
 use gfx::display_list::{BorderDetails, BorderRadii, BoxShadowClipMode, ClippingRegion};
 use gfx::display_list::{DisplayItem, DisplayList, DisplayListTraversal, ScrollRootType};
 use gfx::display_list::StackingContextType;
 use msg::constellation_msg::PipelineId;
 use style::computed_values::{image_rendering, mix_blend_mode, transform_style};
 use style::values::computed::{BorderStyle, Filter};
 use style::values::generics::effects::Filter as GenericFilter;
-use webrender_api::{self, ComplexClipRegion, DisplayListBuilder, ExtendMode};
-use webrender_api::{LayoutTransform, ClipId};
+use webrender_api::{self, ClipId, ComplexClipRegion, DisplayListBuilder, ExtendMode};
+use webrender_api::LayoutTransform;
 
 pub trait WebRenderDisplayListConverter {
     fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder;
 }
 
 trait WebRenderDisplayItemConverter {
     fn convert_to_webrender(&self,
                             builder: &mut DisplayListBuilder,
@@ -185,17 +185,17 @@ trait ToFilterOps {
     fn to_filter_ops(&self) -> Vec<webrender_api::FilterOp>;
 }
 
 impl ToFilterOps for Vec<Filter> {
     fn to_filter_ops(&self) -> Vec<webrender_api::FilterOp> {
         let mut result = Vec::with_capacity(self.len());
         for filter in self.iter() {
             match *filter {
-                GenericFilter::Blur(radius) => result.push(webrender_api::FilterOp::Blur(radius)),
+                GenericFilter::Blur(radius) => result.push(webrender_api::FilterOp::Blur(radius.to_f32_px())),
                 GenericFilter::Brightness(amount) => result.push(webrender_api::FilterOp::Brightness(amount)),
                 GenericFilter::Contrast(amount) => result.push(webrender_api::FilterOp::Contrast(amount)),
                 GenericFilter::Grayscale(amount) => result.push(webrender_api::FilterOp::Grayscale(amount)),
                 GenericFilter::HueRotate(angle) => result.push(webrender_api::FilterOp::HueRotate(angle.radians())),
                 GenericFilter::Invert(amount) => result.push(webrender_api::FilterOp::Invert(amount)),
                 GenericFilter::Opacity(amount) => result.push(webrender_api::FilterOp::Opacity(amount.into())),
                 GenericFilter::Saturate(amount) => result.push(webrender_api::FilterOp::Saturate(amount)),
                 GenericFilter::Sepia(amount) => result.push(webrender_api::FilterOp::Sepia(amount)),
@@ -501,22 +501,23 @@ impl WebRenderDisplayItemConverter for D
                 let our_id = item.scroll_root.id;
                 let webrender_id = match item.scroll_root.root_type {
                    ScrollRootType::Clip => {
                         builder.define_clip(Some(our_id),
                                             item.scroll_root.clip.main.to_rectf(),
                                             item.scroll_root.clip.get_complex_clips(),
                                             None)
                     }
-                    ScrollRootType::ScrollFrame => {
+                    ScrollRootType::ScrollFrame(scroll_sensitivity) => {
                         builder.define_scroll_frame(Some(our_id),
                                                     item.scroll_root.content_rect.to_rectf(),
                                                     item.scroll_root.clip.main.to_rectf(),
                                                     item.scroll_root.clip.get_complex_clips(),
-                                                    None)
+                                                    None,
+                                                    scroll_sensitivity)
                     }
                 };
                 debug_assert!(our_id == webrender_id);
 
                 builder.pop_clip_id();
             }
         }
     }