Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 2890583002: Fix incorrect use of coords conversion for sticky elements (Closed)
Patch Set: nit Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 // 310 //
311 // Starting from the scroll container relative location, removing the 311 // Starting from the scroll container relative location, removing the
312 // enclosing layer's offset and the content offset in the composited layer 312 // enclosing layer's offset and the content offset in the composited layer
313 // results in the parent-layer relative offset. 313 // results in the parent-layer relative offset.
314 FloatPoint parent_relative_sticky_box_offset = 314 FloatPoint parent_relative_sticky_box_offset =
315 constraints.ScrollContainerRelativeStickyBoxRect().Location(); 315 constraints.ScrollContainerRelativeStickyBoxRect().Location();
316 316
317 // The enclosing layers offset returned from |convertToLayerCoords| must be 317 // The enclosing layers offset returned from |convertToLayerCoords| must be
318 // adjusted for both scroll and ancestor sticky elements. 318 // adjusted for both scroll and ancestor sticky elements.
319 LayoutPoint enclosing_layer_offset; 319 LayoutPoint enclosing_layer_offset;
320 compositing_container->ConvertToLayerCoords(ancestor_overflow_layer, 320 // The offset from the compositing_container to the ancestor_overflow_layer
321 enclosing_layer_offset); 321 // when we have a scroll parent is computed by the source_to_parent vector
322 // on the transform node.
323 // TODO(yigu): Eventually we want to remove the dependancy of
324 // source_to_parent from StickyPositionOffset in property_tree.cc.
325 if (!ScrollParent()) {
326 compositing_container->ConvertToLayerCoords(ancestor_overflow_layer,
327 enclosing_layer_offset);
328 }
329
322 DCHECK(!ScrollParent() || ScrollParent() == ancestor_overflow_layer); 330 DCHECK(!ScrollParent() || ScrollParent() == ancestor_overflow_layer);
323 if (!ScrollParent() && compositing_container != ancestor_overflow_layer) { 331 if (!ScrollParent() && compositing_container != ancestor_overflow_layer) {
324 enclosing_layer_offset += LayoutSize( 332 enclosing_layer_offset += LayoutSize(
325 ancestor_overflow_layer->GetScrollableArea()->GetScrollOffset()); 333 ancestor_overflow_layer->GetScrollableArea()->GetScrollOffset());
326 } 334 }
327 // TODO(smcgruer): Until http://crbug.com/702229 is fixed, the nearest 335 // TODO(smcgruer): Until http://crbug.com/702229 is fixed, the nearest
328 // sticky ancestor may be non-composited which will make this offset wrong. 336 // sticky ancestor may be non-composited which will make this offset wrong.
329 if (const LayoutBoxModelObject* ancestor = 337 if (const LayoutBoxModelObject* ancestor =
330 constraints.NearestStickyAncestor()) { 338 constraints.NearestStickyAncestor()) {
331 enclosing_layer_offset -= 339 enclosing_layer_offset -=
332 RoundedIntSize(constraints_map.at(ancestor->Layer()) 340 RoundedIntSize(constraints_map.at(ancestor->Layer())
333 .GetTotalContainingBlockStickyOffset()); 341 .GetTotalContainingBlockStickyOffset());
334 } 342 }
335 343
336 DCHECK(!content_offset_in_compositing_layer_dirty_); 344 DCHECK(!content_offset_in_compositing_layer_dirty_);
337 parent_relative_sticky_box_offset.MoveBy( 345 parent_relative_sticky_box_offset.MoveBy(
338 FloatPoint(-enclosing_layer_offset) - 346 FloatPoint(-enclosing_layer_offset) -
339 FloatSize(ContentOffsetInCompositingLayer())); 347 FloatSize(ContentOffsetInCompositingLayer()));
340 348
341 if (compositing_container != ancestor_overflow_layer) { 349 // When we have a scroll parent, the content offset is computed by
350 // source_offset on the transform node.
351 if (!ScrollParent() && compositing_container != ancestor_overflow_layer) {
342 parent_relative_sticky_box_offset.MoveBy( 352 parent_relative_sticky_box_offset.MoveBy(
343 FloatPoint(compositing_container->GetCompositedLayerMapping() 353 FloatPoint(compositing_container->GetCompositedLayerMapping()
344 ->ContentOffsetInCompositingLayer())); 354 ->ContentOffsetInCompositingLayer()));
345 } 355 }
346 356
347 web_constraint.is_sticky = true; 357 web_constraint.is_sticky = true;
348 web_constraint.is_anchored_left = 358 web_constraint.is_anchored_left =
349 constraints.GetAnchorEdges() & 359 constraints.GetAnchorEdges() &
350 StickyPositionScrollingConstraints::kAnchorEdgeLeft; 360 StickyPositionScrollingConstraints::kAnchorEdgeLeft;
351 web_constraint.is_anchored_right = 361 web_constraint.is_anchored_right =
(...skipping 3310 matching lines...) Expand 10 before | Expand all | Expand 10 after
3662 } else if (graphics_layer == decoration_outline_layer_.get()) { 3672 } else if (graphics_layer == decoration_outline_layer_.get()) {
3663 name = "Decoration Layer"; 3673 name = "Decoration Layer";
3664 } else { 3674 } else {
3665 NOTREACHED(); 3675 NOTREACHED();
3666 } 3676 }
3667 3677
3668 return name; 3678 return name;
3669 } 3679 }
3670 3680
3671 } // namespace blink 3681 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/compositing/overflow/ancestor-overflow-layer-of-sticky-child-of-compositing-container-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698