servo: Merge #7369 - layout: Fix calculation of overflow for stacking contexts that contain position: relative fragments (from pcwalton:relative-layer-overflow); r=glennw

Fixes placement of the header on espn.go.com.

r? @glennw

Source-Repo: https://github.com/servo/servo
Source-Revision: a1cd27e6a3b961129fd4710513cc29e4f7c9cc67
This commit is contained in:
Patrick Walton 2015-08-25 17:16:34 -06:00
parent d32a3e191d
commit f9b32545e1
3 changed files with 9 additions and 7 deletions

View File

@ -382,7 +382,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
// When there is a new layer, the transforms and origin
// are handled by the compositor.
(Some(paint_layer.id),
Point2D::zero(),
-stacking_context.overflow.origin,
Matrix4::identity(),
Matrix4::identity())
}

View File

@ -1148,9 +1148,6 @@ impl FragmentDisplayListBuilding for Fragment {
layer: StackingContextLayer,
mode: StackingContextCreationMode)
-> Arc<StackingContext> {
// FIXME(pcwalton): Is this vertical-writing-direction-safe?
let margin = self.margin.to_physical(base_flow.writing_mode);
let border_box = match mode {
StackingContextCreationMode::Normal |
StackingContextCreationMode::OuterScrollWrapper => {
@ -1167,7 +1164,12 @@ impl FragmentDisplayListBuilding for Fragment {
};
let overflow = match mode {
StackingContextCreationMode::Normal => {
base_flow.overflow.translate(&-Point2D::new(margin.left, Au(0)))
// First, compute the offset of our border box (including relative positioning)
// from our flow origin, since that is what `BaseFlow::overflow` is relative to.
let border_box_offset =
border_box.translate(&-base_flow.stacking_relative_position).origin;
// Then, using that, compute our overflow region relative to our border box.
base_flow.overflow.translate(&-border_box_offset)
}
StackingContextCreationMode::InnerScrollWrapper |
StackingContextCreationMode::OuterScrollWrapper => {

View File

@ -2060,8 +2060,8 @@ impl Fragment {
// the time. Can't we handle relative positioning by just adjusting `border_box`?
let relative_position =
self.relative_position(&LogicalSize::zero(self.style.writing_mode));
border_box =
border_box.translate_by_size(&relative_position.to_physical(self.style.writing_mode));
border_box = border_box.translate_by_size(&relative_position.to_physical(
self.style.writing_mode));
let mut overflow = border_box;
// Box shadows cause us to draw outside our border box.