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

Side by Side Diff: cc/layers/layer_impl.cc

Issue 665233004: Make aborted commits inform the scroll delegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add early return and update comment Created 6 years, 1 month 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
« no previous file with comments | « no previous file | cc/layers/layer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/debug/trace_event_argument.h" 8 #include "base/debug/trace_event_argument.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 void LayerImpl::SetScrollClipLayer(int scroll_clip_layer_id) { 390 void LayerImpl::SetScrollClipLayer(int scroll_clip_layer_id) {
391 scroll_clip_layer_ = layer_tree_impl()->LayerById(scroll_clip_layer_id); 391 scroll_clip_layer_ = layer_tree_impl()->LayerById(scroll_clip_layer_id);
392 } 392 }
393 393
394 bool LayerImpl::user_scrollable(ScrollbarOrientation orientation) const { 394 bool LayerImpl::user_scrollable(ScrollbarOrientation orientation) const {
395 return (orientation == HORIZONTAL) ? user_scrollable_horizontal_ 395 return (orientation == HORIZONTAL) ? user_scrollable_horizontal_
396 : user_scrollable_vertical_; 396 : user_scrollable_vertical_;
397 } 397 }
398 398
399 void LayerImpl::ApplySentScrollDeltasFromAbortedCommit() { 399 void LayerImpl::ApplySentScrollDeltasFromAbortedCommit() {
400 if (sent_scroll_delta_.IsZero())
401 return;
402
400 // Pending tree never has sent scroll deltas 403 // Pending tree never has sent scroll deltas
401 DCHECK(layer_tree_impl()->IsActiveTree()); 404 DCHECK(layer_tree_impl()->IsActiveTree());
402 405
406 // The combination of pending tree and aborted commits with impl scrolls
407 // shouldn't happen; we don't know how to update its deltas correctly.
408 DCHECK(!layer_tree_impl()->FindPendingTreeLayerById(id()));
409
403 // Apply sent scroll deltas to scroll position / scroll delta as if the 410 // Apply sent scroll deltas to scroll position / scroll delta as if the
404 // main thread had applied them and then committed those values. 411 // main thread had applied them and then committed those values.
405 // 412 SetScrollOffsetAndDelta(
406 // This function should not change the total scroll offset; it just shifts 413 scroll_offset_ + gfx::ScrollOffset(sent_scroll_delta_),
407 // some of the scroll delta to the scroll offset. Therefore, adjust these 414 ScrollDelta() - sent_scroll_delta_);
408 // variables directly rather than calling the scroll offset delegate to 415 SetSentScrollDelta(gfx::Vector2dF());
409 // avoid sending it multiple spurious calls.
410 //
411 // Because of the way scroll delta is calculated with a delegate, this will
412 // leave the total scroll offset unchanged on this layer regardless of
413 // whether a delegate is being used.
414 scroll_offset_ += gfx::ScrollOffset(sent_scroll_delta_);
415 scroll_delta_ -= sent_scroll_delta_;
416 sent_scroll_delta_ = gfx::Vector2dF();
417 } 416 }
418 417
419 void LayerImpl::ApplyScrollDeltasSinceBeginMainFrame() { 418 void LayerImpl::ApplyScrollDeltasSinceBeginMainFrame() {
420 // Only the pending tree can have missing scrolls. 419 // Only the pending tree can have missing scrolls.
421 DCHECK(layer_tree_impl()->IsPendingTree()); 420 DCHECK(layer_tree_impl()->IsPendingTree());
422 if (!scrollable()) 421 if (!scrollable())
423 return; 422 return;
424 423
425 // Pending tree should never have sent scroll deltas. 424 // Pending tree should never have sent scroll deltas.
426 DCHECK(sent_scroll_delta().IsZero()); 425 DCHECK(sent_scroll_delta().IsZero());
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 1588
1590 void LayerImpl::NotifyAnimationFinished( 1589 void LayerImpl::NotifyAnimationFinished(
1591 base::TimeTicks monotonic_time, 1590 base::TimeTicks monotonic_time,
1592 Animation::TargetProperty target_property, 1591 Animation::TargetProperty target_property,
1593 int group) { 1592 int group) {
1594 if (target_property == Animation::ScrollOffset) 1593 if (target_property == Animation::ScrollOffset)
1595 layer_tree_impl_->InputScrollAnimationFinished(); 1594 layer_tree_impl_->InputScrollAnimationFinished();
1596 } 1595 }
1597 1596
1598 } // namespace cc 1597 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layers/layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698