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

Unified 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: Test update 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
index abd711d097e33fed7cec2f2ad8f59fe7989654c9..487ab655b9d5118d56574c2517c0a36739430228 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
@@ -281,22 +281,20 @@ void CompositedLayerMapping::UpdateBackdropFilters(const ComputedStyle& style) {
OwningLayer().CreateCompositorFilterOperationsForBackdropFilter(style));
}
+bool CompositedLayerMapping::UsesCompositedStickyPosition() const {
+ return GetLayoutObject().Style()->GetPosition() == EPosition::kSticky &&
+ (owning_layer_.AncestorOverflowLayer()->IsRootLayer()
+ ? GetLayoutObject().View()->GetFrameView()->IsScrollable()
+ : owning_layer_.AncestorOverflowLayer()
+ ->NeedsCompositedScrolling());
+}
+
void CompositedLayerMapping::UpdateStickyConstraints(
const ComputedStyle& style) {
- bool sticky = style.GetPosition() == EPosition::kSticky;
const PaintLayer* ancestor_overflow_layer =
owning_layer_.AncestorOverflowLayer();
- // TODO(flackr): Do we still need this?
- if (sticky) {
- if (!ancestor_overflow_layer->IsRootLayer()) {
- sticky = ancestor_overflow_layer->NeedsCompositedScrolling();
- } else {
- sticky = GetLayoutObject().View()->GetFrameView()->IsScrollable();
- }
- }
-
WebLayerStickyPositionConstraint web_constraint;
- if (sticky) {
+ if (UsesCompositedStickyPosition()) {
const StickyConstraintsMap& constraints_map =
ancestor_overflow_layer->GetScrollableArea()->GetStickyConstraintsMap();
const StickyPositionScrollingConstraints& constraints =
@@ -1128,16 +1126,11 @@ void CompositedLayerMapping::UpdateMainGraphicsLayerGeometry(
const IntRect& relative_compositing_bounds,
const IntRect& local_compositing_bounds,
const IntPoint& graphics_layer_parent_location) {
- graphics_layer_->SetPosition(FloatPoint(
- relative_compositing_bounds.Location() - graphics_layer_parent_location));
- graphics_layer_->SetOffsetFromLayoutObject(
- ToIntSize(local_compositing_bounds.Location()));
// Find the layout offset of the unshifted sticky box within its parent
- // composited layer. This information is used by the compositor side to
- // compute the additional offset required to keep the element stuck under
- // compositor scrolling.
- FloatSize main_thread_sticky_offset;
- if (GetLayoutObject().Style()->GetPosition() == EPosition::kSticky) {
+ // composited layer. This information is used to shift layer position to
+ // keep the element stuck under compositor scrolling.
flackr 2017/06/09 17:33:33 This comment is confusing because it seems like it
yigu 2017/06/09 17:41:16 Done.
+ FloatSize offset_for_sticky_position;
+ if (UsesCompositedStickyPosition()) {
const StickyConstraintsMap& constraints_map =
owning_layer_.AncestorOverflowLayer()
->GetScrollableArea()
@@ -1145,11 +1138,15 @@ void CompositedLayerMapping::UpdateMainGraphicsLayerGeometry(
const StickyPositionScrollingConstraints& constraints =
constraints_map.at(&owning_layer_);
- main_thread_sticky_offset =
+ offset_for_sticky_position =
constraints.GetOffsetForStickyPosition(constraints_map);
}
- graphics_layer_->SetOffsetForStickyPosition(
- RoundedIntSize(main_thread_sticky_offset));
+ graphics_layer_->SetPosition(
+ FloatPoint(relative_compositing_bounds.Location() -
+ graphics_layer_parent_location) -
+ offset_for_sticky_position);
+ graphics_layer_->SetOffsetFromLayoutObject(
+ ToIntSize(local_compositing_bounds.Location()));
FloatSize old_size = graphics_layer_->Size();
const FloatSize contents_size(relative_compositing_bounds.Size());

Powered by Google App Engine
This is Rietveld 408576698