diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2014-12-22 11:36:43 -0800 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2014-12-22 14:48:55 -0800 |
commit | cc7cacfd5f5d5f3dbc5f36844876e9e52f802693 (patch) | |
tree | 02d0b3e15c9e9b65a0f7fd3cdfc8d1cf5760c8dc /components/layout/flow.rs | |
parent | b22b29533a4bf3452265e90de4c0c0407ab3d989 (diff) | |
download | servo-cc7cacfd5f5d5f3dbc5f36844876e9e52f802693.tar.gz servo-cc7cacfd5f5d5f3dbc5f36844876e9e52f802693.zip |
gfx: Clip the background properly when `border-radius` is used.
Improves Reddit, GitHub, etc.
Diffstat (limited to 'components/layout/flow.rs')
-rw-r--r-- | components/layout/flow.rs | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 7574e2ec470..a36fca0df0a 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -47,6 +47,7 @@ use table_wrapper::TableWrapperFlow; use wrapper::ThreadSafeLayoutNode; use geom::{Point2D, Rect, Size2D}; +use gfx::display_list::ClippingRegion; use serialize::{Encoder, Encodable}; use servo_msg::compositor_msg::LayerId; use servo_util::geometry::Au; @@ -762,11 +763,8 @@ pub struct BaseFlow { /// FIXME(pcwalton): Merge with `absolute_static_i_offset` and `fixed_static_i_offset` above? pub absolute_position_info: AbsolutePositionInfo, - /// The clipping rectangle for this flow and its descendants, in layer coordinates. - /// - /// TODO(pcwalton): When we have `border-radius` this will need to at least support rounded - /// rectangles. - pub clip_rect: Rect<Au>, + /// The clipping region for this flow and its descendants, in layer coordinates. + pub clip: ClippingRegion, /// The results of display list building for this flow. pub display_list_building_result: DisplayListBuildingResult, @@ -909,7 +907,7 @@ impl BaseFlow { absolute_cb: ContainingBlockLink::new(), display_list_building_result: DisplayListBuildingResult::None, absolute_position_info: AbsolutePositionInfo::new(writing_mode), - clip_rect: Rect(Point2D::zero(), Size2D::zero()), + clip: ClippingRegion::max(), flags: flags, writing_mode: writing_mode, } @@ -945,16 +943,12 @@ impl BaseFlow { }; for item in all_items.iter() { - let paint_bounds = match item.base().bounds.intersection(&item.base().clip_rect) { - None => continue, - Some(rect) => rect, - }; - - if paint_bounds.is_empty() { + let paint_bounds = item.base().clip.clone().intersect_rect(&item.base().bounds); + if !paint_bounds.might_be_nonempty() { continue; } - if bounds.union(&paint_bounds) != bounds { + if bounds.union(&paint_bounds.bounding_rect()) != bounds { error!("DisplayList item {} outside of Flow overflow ({})", item, paint_bounds); } } |