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; |
300 if (sticky) { | 299 if (sticky) { |
301 const StickyConstraintsMap& constraints_map = | 300 const StickyConstraintsMap& constraints_map = |
302 ancestor_overflow_layer->GetScrollableArea()->GetStickyConstraintsMap(); | 301 ancestor_overflow_layer->GetScrollableArea()->GetStickyConstraintsMap(); |
303 const StickyPositionScrollingConstraints& constraints = | 302 const StickyPositionScrollingConstraints& constraints = |
304 constraints_map.at(&owning_layer_); | 303 constraints_map.at(&owning_layer_); |
305 | 304 |
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 | |
308 // compute the additional offset required to keep the element stuck under | |
309 // compositor scrolling. | |
310 // | |
311 // Starting from the scroll container relative location, removing the | |
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 | |
347 web_constraint.is_sticky = true; | 305 web_constraint.is_sticky = true; |
348 web_constraint.is_anchored_left = | 306 web_constraint.is_anchored_left = |
349 constraints.GetAnchorEdges() & | 307 constraints.GetAnchorEdges() & |
350 StickyPositionScrollingConstraints::kAnchorEdgeLeft; | 308 StickyPositionScrollingConstraints::kAnchorEdgeLeft; |
351 web_constraint.is_anchored_right = | 309 web_constraint.is_anchored_right = |
352 constraints.GetAnchorEdges() & | 310 constraints.GetAnchorEdges() & |
353 StickyPositionScrollingConstraints::kAnchorEdgeRight; | 311 StickyPositionScrollingConstraints::kAnchorEdgeRight; |
354 web_constraint.is_anchored_top = | 312 web_constraint.is_anchored_top = |
355 constraints.GetAnchorEdges() & | 313 constraints.GetAnchorEdges() & |
356 StickyPositionScrollingConstraints::kAnchorEdgeTop; | 314 StickyPositionScrollingConstraints::kAnchorEdgeTop; |
357 web_constraint.is_anchored_bottom = | 315 web_constraint.is_anchored_bottom = |
358 constraints.GetAnchorEdges() & | 316 constraints.GetAnchorEdges() & |
359 StickyPositionScrollingConstraints::kAnchorEdgeBottom; | 317 StickyPositionScrollingConstraints::kAnchorEdgeBottom; |
360 web_constraint.left_offset = constraints.LeftOffset(); | 318 web_constraint.left_offset = constraints.LeftOffset(); |
361 web_constraint.right_offset = constraints.RightOffset(); | 319 web_constraint.right_offset = constraints.RightOffset(); |
362 web_constraint.top_offset = constraints.TopOffset(); | 320 web_constraint.top_offset = constraints.TopOffset(); |
363 web_constraint.bottom_offset = constraints.BottomOffset(); | 321 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 = | 322 web_constraint.scroll_container_relative_sticky_box_rect = |
367 EnclosingIntRect(constraints.ScrollContainerRelativeStickyBoxRect()); | 323 EnclosingIntRect(constraints.ScrollContainerRelativeStickyBoxRect()); |
368 web_constraint.scroll_container_relative_containing_block_rect = | 324 web_constraint.scroll_container_relative_containing_block_rect = |
369 EnclosingIntRect( | 325 EnclosingIntRect( |
370 constraints.ScrollContainerRelativeContainingBlockRect()); | 326 constraints.ScrollContainerRelativeContainingBlockRect()); |
371 // TODO(smcgruer): Until http://crbug.com/702229 is fixed, the nearest | 327 // 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 | 328 // sticky layers may not be composited and we may incorrectly end up with |
373 // invalid layer IDs. | 329 // invalid layer IDs. |
374 LayoutBoxModelObject* sticky_box_shifting_ancestor = | 330 LayoutBoxModelObject* sticky_box_shifting_ancestor = |
375 constraints.NearestStickyBoxShiftingStickyBox(); | 331 constraints.NearestStickyBoxShiftingStickyBox(); |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 FloatSize contents_size(relative_compositing_bounds.Size()); | 1062 FloatSize contents_size(relative_compositing_bounds.Size()); |
1107 | 1063 |
1108 UpdateMainGraphicsLayerGeometry(relative_compositing_bounds, | 1064 UpdateMainGraphicsLayerGeometry(relative_compositing_bounds, |
1109 local_compositing_bounds, | 1065 local_compositing_bounds, |
1110 graphics_layer_parent_location); | 1066 graphics_layer_parent_location); |
1111 UpdateOverflowControlsHostLayerGeometry(compositing_stacking_context, | 1067 UpdateOverflowControlsHostLayerGeometry(compositing_stacking_context, |
1112 compositing_container, | 1068 compositing_container, |
1113 graphics_layer_parent_location); | 1069 graphics_layer_parent_location); |
1114 UpdateContentsOffsetInCompositingLayer( | 1070 UpdateContentsOffsetInCompositingLayer( |
1115 snapped_offset_from_composited_ancestor, graphics_layer_parent_location); | 1071 snapped_offset_from_composited_ancestor, graphics_layer_parent_location); |
1116 UpdateStickyConstraints(GetLayoutObject().StyleRef(), compositing_container); | 1072 UpdateStickyConstraints(GetLayoutObject().StyleRef()); |
1117 UpdateSquashingLayerGeometry( | 1073 UpdateSquashingLayerGeometry( |
1118 graphics_layer_parent_location, compositing_container, squashed_layers_, | 1074 graphics_layer_parent_location, compositing_container, squashed_layers_, |
1119 squashing_layer_.get(), | 1075 squashing_layer_.get(), |
1120 &squashing_layer_offset_from_transformed_ancestor_, | 1076 &squashing_layer_offset_from_transformed_ancestor_, |
1121 layers_needing_paint_invalidation); | 1077 layers_needing_paint_invalidation); |
1122 | 1078 |
1123 // If we have a layer that clips children, position it. | 1079 // If we have a layer that clips children, position it. |
1124 IntRect clipping_box; | 1080 IntRect clipping_box; |
1125 if (child_containment_layer_ && GetLayoutObject().IsBox()) | 1081 if (child_containment_layer_ && GetLayoutObject().IsBox()) |
1126 clipping_box = ClipBox(ToLayoutBox(GetLayoutObject())); | 1082 clipping_box = ClipBox(ToLayoutBox(GetLayoutObject())); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 } | 1124 } |
1169 | 1125 |
1170 void CompositedLayerMapping::UpdateMainGraphicsLayerGeometry( | 1126 void CompositedLayerMapping::UpdateMainGraphicsLayerGeometry( |
1171 const IntRect& relative_compositing_bounds, | 1127 const IntRect& relative_compositing_bounds, |
1172 const IntRect& local_compositing_bounds, | 1128 const IntRect& local_compositing_bounds, |
1173 const IntPoint& graphics_layer_parent_location) { | 1129 const IntPoint& graphics_layer_parent_location) { |
1174 graphics_layer_->SetPosition(FloatPoint( | 1130 graphics_layer_->SetPosition(FloatPoint( |
1175 relative_compositing_bounds.Location() - graphics_layer_parent_location)); | 1131 relative_compositing_bounds.Location() - graphics_layer_parent_location)); |
1176 graphics_layer_->SetOffsetFromLayoutObject( | 1132 graphics_layer_->SetOffsetFromLayoutObject( |
1177 ToIntSize(local_compositing_bounds.Location())); | 1133 ToIntSize(local_compositing_bounds.Location())); |
| 1134 // Find the layout offset of the unshifted sticky box within its parent |
| 1135 // composited layer. This information is used by the compositor side to |
| 1136 // compute the additional offset required to keep the element stuck under |
| 1137 // compositor scrolling. |
| 1138 FloatSize main_thread_sticky_offset; |
| 1139 if (GetLayoutObject().Style()->GetPosition() == EPosition::kSticky) { |
| 1140 const StickyConstraintsMap& constraints_map = |
| 1141 owning_layer_.AncestorOverflowLayer() |
| 1142 ->GetScrollableArea() |
| 1143 ->GetStickyConstraintsMap(); |
| 1144 const StickyPositionScrollingConstraints& constraints = |
| 1145 constraints_map.at(&owning_layer_); |
| 1146 |
| 1147 main_thread_sticky_offset = |
| 1148 constraints.GetOffsetForStickyPosition(constraints_map); |
| 1149 } |
| 1150 graphics_layer_->SetOffsetForStickyPosition( |
| 1151 RoundedIntSize(main_thread_sticky_offset)); |
1178 | 1152 |
1179 FloatSize old_size = graphics_layer_->Size(); | 1153 FloatSize old_size = graphics_layer_->Size(); |
1180 const FloatSize contents_size(relative_compositing_bounds.Size()); | 1154 const FloatSize contents_size(relative_compositing_bounds.Size()); |
1181 if (old_size != contents_size) | 1155 if (old_size != contents_size) |
1182 graphics_layer_->SetSize(contents_size); | 1156 graphics_layer_->SetSize(contents_size); |
1183 | 1157 |
1184 // m_graphicsLayer is the corresponding GraphicsLayer for this PaintLayer and | 1158 // m_graphicsLayer is the corresponding GraphicsLayer for this PaintLayer and |
1185 // its non-compositing descendants. So, the visibility flag for | 1159 // its non-compositing descendants. So, the visibility flag for |
1186 // m_graphicsLayer should be true if there are any non-compositing visible | 1160 // m_graphicsLayer should be true if there are any non-compositing visible |
1187 // layers. | 1161 // layers. |
(...skipping 2477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3665 } else if (graphics_layer == decoration_outline_layer_.get()) { | 3639 } else if (graphics_layer == decoration_outline_layer_.get()) { |
3666 name = "Decoration Layer"; | 3640 name = "Decoration Layer"; |
3667 } else { | 3641 } else { |
3668 NOTREACHED(); | 3642 NOTREACHED(); |
3669 } | 3643 } |
3670 | 3644 |
3671 return name; | 3645 return name; |
3672 } | 3646 } |
3673 | 3647 |
3674 } // namespace blink | 3648 } // namespace blink |
OLD | NEW |