Skip to content

Commit

Permalink
Allow overflow:hidden to scroll via script
Browse files Browse the repository at this point in the history
  • Loading branch information
mrobinson authored and gw3583 committed Jul 25, 2017
1 parent 316878b commit 5370258
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 63 deletions.
4 changes: 2 additions & 2 deletions components/gfx/display_list/mod.rs
Expand Up @@ -34,7 +34,7 @@ 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;

Expand Down Expand Up @@ -559,7 +559,7 @@ impl fmt::Debug for StackingContext {

#[derive(Clone, Debug, HeapSizeOf, Deserialize, Serialize)]
pub enum ScrollRootType {
ScrollFrame,
ScrollFrame(ScrollSensitivity),
Clip,
}

Expand Down
38 changes: 12 additions & 26 deletions components/layout/display_list_builder.rs
Expand Up @@ -71,7 +71,7 @@ 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 {
Expand Down Expand Up @@ -2257,7 +2257,6 @@ pub trait BlockFlowDisplayListBuilding {
-> 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,
Expand Down Expand Up @@ -2483,7 +2482,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
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);

Expand All @@ -2498,7 +2497,6 @@ impl BlockFlowDisplayListBuilding for BlockFlow {

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;
Expand Down Expand Up @@ -2526,27 +2524,12 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
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);
Expand All @@ -2555,14 +2538,17 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
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
);
Expand Down
11 changes: 6 additions & 5 deletions components/layout/webrender_helpers.rs
Expand Up @@ -16,8 +16,8 @@ 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;
Expand Down Expand Up @@ -190,7 +190,7 @@ impl ToFilterOps for Vec<Filter> {
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)),
Expand Down Expand Up @@ -506,12 +506,13 @@ impl WebRenderDisplayItemConverter for DisplayItem {
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);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 5370258

Please sign in to comment.