Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 graphics_layer_->SetFilters( | 275 graphics_layer_->SetFilters( |
| 276 OwningLayer().CreateCompositorFilterOperationsForFilter(style)); | 276 OwningLayer().CreateCompositorFilterOperationsForFilter(style)); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void CompositedLayerMapping::UpdateBackdropFilters(const ComputedStyle& style) { | 279 void CompositedLayerMapping::UpdateBackdropFilters(const ComputedStyle& style) { |
| 280 graphics_layer_->SetBackdropFilters( | 280 graphics_layer_->SetBackdropFilters( |
| 281 OwningLayer().CreateCompositorFilterOperationsForBackdropFilter(style)); | 281 OwningLayer().CreateCompositorFilterOperationsForBackdropFilter(style)); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void CompositedLayerMapping::UpdateStickyConstraints( | 284 void CompositedLayerMapping::UpdateStickyConstraints( |
| 285 const ComputedStyle& style, | 285 const ComputedStyle& style) { |
| 286 const PaintLayer* compositing_container) { | |
| 287 bool sticky = style.GetPosition() == EPosition::kSticky; | 286 bool sticky = style.GetPosition() == EPosition::kSticky; |
| 288 const PaintLayer* ancestor_overflow_layer = | 287 const PaintLayer* ancestor_overflow_layer = |
| 289 owning_layer_.AncestorOverflowLayer(); | 288 owning_layer_.AncestorOverflowLayer(); |
| 290 // TODO(flackr): Do we still need this? | 289 // TODO(flackr): Do we still need this? |
| 291 if (sticky) { | 290 if (sticky) { |
| 292 if (!ancestor_overflow_layer->IsRootLayer()) { | 291 if (!ancestor_overflow_layer->IsRootLayer()) { |
| 293 sticky = ancestor_overflow_layer->NeedsCompositedScrolling(); | 292 sticky = ancestor_overflow_layer->NeedsCompositedScrolling(); |
| 294 } else { | 293 } else { |
| 295 sticky = GetLayoutObject().View()->GetFrameView()->IsScrollable(); | 294 sticky = GetLayoutObject().View()->GetFrameView()->IsScrollable(); |
| 296 } | 295 } |
| 297 } | 296 } |
| 298 | 297 |
| 299 WebLayerStickyPositionConstraint web_constraint; | 298 WebLayerStickyPositionConstraint web_constraint; |
| 299 WebSize sticky_main_thread_offset; | |
|
smcgruer
2017/05/26 17:14:12
Nit; this method is explicitly about sticky, we co
yigu
2017/05/26 18:04:21
Done.
| |
| 300 if (sticky) { | 300 if (sticky) { |
| 301 const StickyConstraintsMap& constraints_map = | 301 const StickyConstraintsMap& constraints_map = |
| 302 ancestor_overflow_layer->GetScrollableArea()->GetStickyConstraintsMap(); | 302 ancestor_overflow_layer->GetScrollableArea()->GetStickyConstraintsMap(); |
| 303 const StickyPositionScrollingConstraints& constraints = | 303 const StickyPositionScrollingConstraints& constraints = |
| 304 constraints_map.at(&owning_layer_); | 304 constraints_map.at(&owning_layer_); |
| 305 | 305 |
| 306 // Find the layout offset of the unshifted sticky box within its parent | 306 // Find the layout offset of the unshifted sticky box within its parent |
| 307 // composited layer. This information is used by the compositor side to | 307 // composited layer. This information is used by the compositor side to |
| 308 // compute the additional offset required to keep the element stuck under | 308 // compute the additional offset required to keep the element stuck under |
| 309 // compositor scrolling. | 309 // compositor scrolling. |
| 310 // | 310 sticky_main_thread_offset = |
| 311 // Starting from the scroll container relative location, removing the | 311 RoundedIntSize(GetLayoutObject().StickyPositionOffset()); |
| 312 // enclosing layer's offset and the content offset in the composited layer | |
| 313 // results in the parent-layer relative offset. | |
| 314 FloatPoint parent_relative_sticky_box_offset = | |
| 315 constraints.ScrollContainerRelativeStickyBoxRect().Location(); | |
| 316 | |
| 317 // The enclosing layers offset returned from |convertToLayerCoords| must be | |
| 318 // adjusted for both scroll and ancestor sticky elements. | |
| 319 LayoutPoint enclosing_layer_offset; | |
| 320 compositing_container->ConvertToLayerCoords(ancestor_overflow_layer, | |
| 321 enclosing_layer_offset); | |
| 322 DCHECK(!ScrollParent() || ScrollParent() == ancestor_overflow_layer); | |
| 323 if (!ScrollParent() && compositing_container != ancestor_overflow_layer) { | |
| 324 enclosing_layer_offset += LayoutSize( | |
| 325 ancestor_overflow_layer->GetScrollableArea()->GetScrollOffset()); | |
| 326 } | |
| 327 // TODO(smcgruer): Until http://crbug.com/702229 is fixed, the nearest | |
| 328 // sticky ancestor may be non-composited which will make this offset wrong. | |
| 329 if (const LayoutBoxModelObject* ancestor = | |
| 330 constraints.NearestStickyAncestor()) { | |
| 331 enclosing_layer_offset -= | |
| 332 RoundedIntSize(constraints_map.at(ancestor->Layer()) | |
| 333 .GetTotalContainingBlockStickyOffset()); | |
| 334 } | |
| 335 | |
| 336 DCHECK(!content_offset_in_compositing_layer_dirty_); | |
| 337 parent_relative_sticky_box_offset.MoveBy( | |
| 338 FloatPoint(-enclosing_layer_offset) - | |
| 339 FloatSize(ContentOffsetInCompositingLayer())); | |
| 340 | |
| 341 if (compositing_container != ancestor_overflow_layer) { | |
| 342 parent_relative_sticky_box_offset.MoveBy( | |
| 343 FloatPoint(compositing_container->GetCompositedLayerMapping() | |
| 344 ->ContentOffsetInCompositingLayer())); | |
| 345 } | |
| 346 | 312 |
| 347 web_constraint.is_sticky = true; | 313 web_constraint.is_sticky = true; |
| 348 web_constraint.is_anchored_left = | 314 web_constraint.is_anchored_left = |
| 349 constraints.GetAnchorEdges() & | 315 constraints.GetAnchorEdges() & |
| 350 StickyPositionScrollingConstraints::kAnchorEdgeLeft; | 316 StickyPositionScrollingConstraints::kAnchorEdgeLeft; |
| 351 web_constraint.is_anchored_right = | 317 web_constraint.is_anchored_right = |
| 352 constraints.GetAnchorEdges() & | 318 constraints.GetAnchorEdges() & |
| 353 StickyPositionScrollingConstraints::kAnchorEdgeRight; | 319 StickyPositionScrollingConstraints::kAnchorEdgeRight; |
| 354 web_constraint.is_anchored_top = | 320 web_constraint.is_anchored_top = |
| 355 constraints.GetAnchorEdges() & | 321 constraints.GetAnchorEdges() & |
| 356 StickyPositionScrollingConstraints::kAnchorEdgeTop; | 322 StickyPositionScrollingConstraints::kAnchorEdgeTop; |
| 357 web_constraint.is_anchored_bottom = | 323 web_constraint.is_anchored_bottom = |
| 358 constraints.GetAnchorEdges() & | 324 constraints.GetAnchorEdges() & |
| 359 StickyPositionScrollingConstraints::kAnchorEdgeBottom; | 325 StickyPositionScrollingConstraints::kAnchorEdgeBottom; |
| 360 web_constraint.left_offset = constraints.LeftOffset(); | 326 web_constraint.left_offset = constraints.LeftOffset(); |
| 361 web_constraint.right_offset = constraints.RightOffset(); | 327 web_constraint.right_offset = constraints.RightOffset(); |
| 362 web_constraint.top_offset = constraints.TopOffset(); | 328 web_constraint.top_offset = constraints.TopOffset(); |
| 363 web_constraint.bottom_offset = constraints.BottomOffset(); | 329 web_constraint.bottom_offset = constraints.BottomOffset(); |
| 364 web_constraint.parent_relative_sticky_box_offset = | |
| 365 RoundedIntPoint(parent_relative_sticky_box_offset); | |
| 366 web_constraint.scroll_container_relative_sticky_box_rect = | 330 web_constraint.scroll_container_relative_sticky_box_rect = |
| 367 EnclosingIntRect(constraints.ScrollContainerRelativeStickyBoxRect()); | 331 EnclosingIntRect(constraints.ScrollContainerRelativeStickyBoxRect()); |
| 368 web_constraint.scroll_container_relative_containing_block_rect = | 332 web_constraint.scroll_container_relative_containing_block_rect = |
| 369 EnclosingIntRect( | 333 EnclosingIntRect( |
| 370 constraints.ScrollContainerRelativeContainingBlockRect()); | 334 constraints.ScrollContainerRelativeContainingBlockRect()); |
| 371 // TODO(smcgruer): Until http://crbug.com/702229 is fixed, the nearest | 335 // TODO(smcgruer): Until http://crbug.com/702229 is fixed, the nearest |
| 372 // sticky layers may not be composited and we may incorrectly end up with | 336 // sticky layers may not be composited and we may incorrectly end up with |
| 373 // invalid layer IDs. | 337 // invalid layer IDs. |
| 374 LayoutBoxModelObject* sticky_box_shifting_ancestor = | 338 LayoutBoxModelObject* sticky_box_shifting_ancestor = |
| 375 constraints.NearestStickyBoxShiftingStickyBox(); | 339 constraints.NearestStickyBoxShiftingStickyBox(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 390 web_constraint.nearest_layer_shifting_containing_block = | 354 web_constraint.nearest_layer_shifting_containing_block = |
| 391 containing_block_shifting_ancestor->Layer() | 355 containing_block_shifting_ancestor->Layer() |
| 392 ->GetCompositedLayerMapping() | 356 ->GetCompositedLayerMapping() |
| 393 ->MainGraphicsLayer() | 357 ->MainGraphicsLayer() |
| 394 ->PlatformLayer() | 358 ->PlatformLayer() |
| 395 ->Id(); | 359 ->Id(); |
| 396 } | 360 } |
| 397 } | 361 } |
| 398 | 362 |
| 399 graphics_layer_->SetStickyPositionConstraint(web_constraint); | 363 graphics_layer_->SetStickyPositionConstraint(web_constraint); |
| 364 graphics_layer_->SetStickyMainThreadOffset(sticky_main_thread_offset); | |
| 400 } | 365 } |
| 401 | 366 |
| 402 void CompositedLayerMapping::UpdateLayerBlendMode(const ComputedStyle& style) { | 367 void CompositedLayerMapping::UpdateLayerBlendMode(const ComputedStyle& style) { |
| 403 SetBlendMode(style.BlendMode()); | 368 SetBlendMode(style.BlendMode()); |
| 404 } | 369 } |
| 405 | 370 |
| 406 void CompositedLayerMapping::UpdateIsRootForIsolatedGroup() { | 371 void CompositedLayerMapping::UpdateIsRootForIsolatedGroup() { |
| 407 bool isolate = owning_layer_.ShouldIsolateCompositedDescendants(); | 372 bool isolate = owning_layer_.ShouldIsolateCompositedDescendants(); |
| 408 | 373 |
| 409 // non stacking context layers should never isolate | 374 // non stacking context layers should never isolate |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1106 FloatSize contents_size(relative_compositing_bounds.Size()); | 1071 FloatSize contents_size(relative_compositing_bounds.Size()); |
| 1107 | 1072 |
| 1108 UpdateMainGraphicsLayerGeometry(relative_compositing_bounds, | 1073 UpdateMainGraphicsLayerGeometry(relative_compositing_bounds, |
| 1109 local_compositing_bounds, | 1074 local_compositing_bounds, |
| 1110 graphics_layer_parent_location); | 1075 graphics_layer_parent_location); |
| 1111 UpdateOverflowControlsHostLayerGeometry(compositing_stacking_context, | 1076 UpdateOverflowControlsHostLayerGeometry(compositing_stacking_context, |
| 1112 compositing_container, | 1077 compositing_container, |
| 1113 graphics_layer_parent_location); | 1078 graphics_layer_parent_location); |
| 1114 UpdateContentsOffsetInCompositingLayer( | 1079 UpdateContentsOffsetInCompositingLayer( |
| 1115 snapped_offset_from_composited_ancestor, graphics_layer_parent_location); | 1080 snapped_offset_from_composited_ancestor, graphics_layer_parent_location); |
| 1116 UpdateStickyConstraints(GetLayoutObject().StyleRef(), compositing_container); | 1081 UpdateStickyConstraints(GetLayoutObject().StyleRef()); |
| 1117 UpdateSquashingLayerGeometry( | 1082 UpdateSquashingLayerGeometry( |
| 1118 graphics_layer_parent_location, compositing_container, squashed_layers_, | 1083 graphics_layer_parent_location, compositing_container, squashed_layers_, |
| 1119 squashing_layer_.get(), | 1084 squashing_layer_.get(), |
| 1120 &squashing_layer_offset_from_transformed_ancestor_, | 1085 &squashing_layer_offset_from_transformed_ancestor_, |
| 1121 layers_needing_paint_invalidation); | 1086 layers_needing_paint_invalidation); |
| 1122 | 1087 |
| 1123 // If we have a layer that clips children, position it. | 1088 // If we have a layer that clips children, position it. |
| 1124 IntRect clipping_box; | 1089 IntRect clipping_box; |
| 1125 if (child_containment_layer_ && GetLayoutObject().IsBox()) | 1090 if (child_containment_layer_ && GetLayoutObject().IsBox()) |
| 1126 clipping_box = ClipBox(ToLayoutBox(GetLayoutObject())); | 1091 clipping_box = ClipBox(ToLayoutBox(GetLayoutObject())); |
| (...skipping 2535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3662 } else if (graphics_layer == decoration_outline_layer_.get()) { | 3627 } else if (graphics_layer == decoration_outline_layer_.get()) { |
| 3663 name = "Decoration Layer"; | 3628 name = "Decoration Layer"; |
| 3664 } else { | 3629 } else { |
| 3665 NOTREACHED(); | 3630 NOTREACHED(); |
| 3666 } | 3631 } |
| 3667 | 3632 |
| 3668 return name; | 3633 return name; |
| 3669 } | 3634 } |
| 3670 | 3635 |
| 3671 } // namespace blink | 3636 } // namespace blink |
| OLD | NEW |