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

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

Issue 2929873002: Shifting layer position for sticky element to avoid passing unnessary variable to cc (Closed)
Patch Set: Created 3 years, 6 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 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 UpdateScrollParent(ScrollParent()); 1121 UpdateScrollParent(ScrollParent());
1122 RegisterScrollingLayers(); 1122 RegisterScrollingLayers();
1123 1123
1124 UpdateCompositingReasons(); 1124 UpdateCompositingReasons();
1125 } 1125 }
1126 1126
1127 void CompositedLayerMapping::UpdateMainGraphicsLayerGeometry( 1127 void CompositedLayerMapping::UpdateMainGraphicsLayerGeometry(
1128 const IntRect& relative_compositing_bounds, 1128 const IntRect& relative_compositing_bounds,
1129 const IntRect& local_compositing_bounds, 1129 const IntRect& local_compositing_bounds,
1130 const IntPoint& graphics_layer_parent_location) { 1130 const IntPoint& graphics_layer_parent_location) {
1131 graphics_layer_->SetPosition(FloatPoint(
1132 relative_compositing_bounds.Location() - graphics_layer_parent_location));
1133 graphics_layer_->SetOffsetFromLayoutObject(
1134 ToIntSize(local_compositing_bounds.Location()));
1135 // Find the layout offset of the unshifted sticky box within its parent 1131 // Find the layout offset of the unshifted sticky box within its parent
1136 // composited layer. This information is used by the compositor side to 1132 // composited layer. This information is used to shift layer position to
1137 // compute the additional offset required to keep the element stuck under 1133 // keep the element stuck under compositor scrolling.
1138 // compositor scrolling. 1134 FloatSize offset_for_sticky_position;
1139 FloatSize main_thread_sticky_offset; 1135 if (GetLayoutObject().Style()->GetPosition() == EPosition::kSticky &&
flackr 2017/06/08 18:56:19 This definitely needs a comment at a minimum, alth
yigu 2017/06/08 23:30:03 Done.
1140 if (GetLayoutObject().Style()->GetPosition() == EPosition::kSticky) { 1136 (owning_layer_.AncestorOverflowLayer()->IsRootLayer() ||
1137 owning_layer_.AncestorOverflowLayer()->NeedsCompositedScrolling())) {
flackr 2017/06/08 22:26:55 chrishtr, trchen, I'm wondering if it's safe to tr
chrishtr 2017/06/08 22:38:40 Yes, it is safe. Paint layer compositor works in t
1141 const StickyConstraintsMap& constraints_map = 1138 const StickyConstraintsMap& constraints_map =
1142 owning_layer_.AncestorOverflowLayer() 1139 owning_layer_.AncestorOverflowLayer()
1143 ->GetScrollableArea() 1140 ->GetScrollableArea()
1144 ->GetStickyConstraintsMap(); 1141 ->GetStickyConstraintsMap();
1145 const StickyPositionScrollingConstraints& constraints = 1142 const StickyPositionScrollingConstraints& constraints =
1146 constraints_map.at(&owning_layer_); 1143 constraints_map.at(&owning_layer_);
1147 1144
1148 main_thread_sticky_offset = 1145 offset_for_sticky_position =
1149 constraints.GetOffsetForStickyPosition(constraints_map); 1146 constraints.GetOffsetForStickyPosition(constraints_map);
1150 } 1147 }
1151 graphics_layer_->SetOffsetForStickyPosition( 1148 graphics_layer_->SetPosition(
1152 RoundedIntSize(main_thread_sticky_offset)); 1149 FloatPoint(relative_compositing_bounds.Location() -
1150 graphics_layer_parent_location) -
1151 offset_for_sticky_position);
1152 graphics_layer_->SetOffsetFromLayoutObject(
1153 ToIntSize(local_compositing_bounds.Location()));
1153 1154
1154 FloatSize old_size = graphics_layer_->Size(); 1155 FloatSize old_size = graphics_layer_->Size();
1155 const FloatSize contents_size(relative_compositing_bounds.Size()); 1156 const FloatSize contents_size(relative_compositing_bounds.Size());
1156 if (old_size != contents_size) 1157 if (old_size != contents_size)
1157 graphics_layer_->SetSize(contents_size); 1158 graphics_layer_->SetSize(contents_size);
1158 1159
1159 // m_graphicsLayer is the corresponding GraphicsLayer for this PaintLayer and 1160 // m_graphicsLayer is the corresponding GraphicsLayer for this PaintLayer and
1160 // its non-compositing descendants. So, the visibility flag for 1161 // its non-compositing descendants. So, the visibility flag for
1161 // m_graphicsLayer should be true if there are any non-compositing visible 1162 // m_graphicsLayer should be true if there are any non-compositing visible
1162 // layers. 1163 // layers.
(...skipping 2477 matching lines...) Expand 10 before | Expand all | Expand 10 after
3640 } else if (graphics_layer == decoration_outline_layer_.get()) { 3641 } else if (graphics_layer == decoration_outline_layer_.get()) {
3641 name = "Decoration Layer"; 3642 name = "Decoration Layer";
3642 } else { 3643 } else {
3643 NOTREACHED(); 3644 NOTREACHED();
3644 } 3645 }
3645 3646
3646 return name; 3647 return name;
3647 } 3648 }
3648 3649
3649 } // namespace blink 3650 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698