Only create scrolling overflow regions when necessary

Only create scroll roots for overflow regions when the overflow region
is actually larger than the container size. This prevents creating
scrolling roots for elements that do not have overflow scroll as a
side-effect of the way their height and width is defined. For example,
tables should never respect overflow:scroll since their height and
width should always be large enough to prevent overflow. This also
decreases the size and complexity of the display list in many other
circumstances.

As part of this change, transformed overflow calculation is moved from
display list construction to layout. This should mean that overflow is
handled more accurately earlier.

Fixes #14574.
This commit is contained in:
Martin Robinson 2017-01-10 09:49:06 +01:00
parent 14aa666a5a
commit 44b24de60f
10 changed files with 139 additions and 63 deletions

View file

@ -25,7 +25,7 @@ use ipc_channel::ipc::IpcSharedMemory;
use msg::constellation_msg::PipelineId;
use net_traits::image::base::{Image, PixelFormat};
use range::Range;
use servo_geometry::{au_rect_to_f32_rect, f32_rect_to_au_rect, max_rect};
use servo_geometry::max_rect;
use std::cmp::{self, Ordering};
use std::collections::HashMap;
use std::fmt;
@ -413,24 +413,6 @@ impl StackingContext {
ScrollRootId::root())
}
pub fn overflow_rect_in_parent_space(&self) -> Rect<Au> {
// Transform this stacking context to get it into the same space as
// the parent stacking context.
//
// TODO: Take into account 3d transforms, even though it's a fairly
// uncommon case.
let origin_x = self.bounds.origin.x.to_f32_px();
let origin_y = self.bounds.origin.y.to_f32_px();
let transform = Matrix4D::identity().pre_translated(origin_x, origin_y, 0.0)
.pre_mul(&self.transform);
let transform_2d = transform.to_2d();
let overflow = au_rect_to_f32_rect(self.overflow);
let overflow = transform_2d.transform_rect(&overflow);
f32_rect_to_au_rect(overflow)
}
pub fn to_display_list_items(self) -> (DisplayItem, DisplayItem) {
let mut base_item = BaseDisplayItem::empty();
base_item.stacking_context_id = self.id;