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

Unified Diff: cc/trees/layer_tree_impl.cc

Issue 2194833002: Overscroll and Elasticity for views::ScrollView Base URL: https://chromium.googlesource.com/chromium/src.git@20160728-MacViews-RouteThroughInputHandler
Patch Set: Restore functionality and fix bugs \o/ Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | cc/trees/property_tree.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_impl.cc
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index 1342c662d37f22acaef8ba033e528c9913704b32..0c387796d65c754b8f834332503d3d4a397a0c22 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -24,6 +24,7 @@
#include "cc/debug/devtools_instrumentation.h"
#include "cc/debug/traced_value.h"
#include "cc/input/page_scale_animation.h"
+#include "cc/input/scroll_elasticity_helper.h"
#include "cc/input/scrollbar_animation_controller.h"
#include "cc/input/scrollbar_animation_controller_linear_fade.h"
#include "cc/input/scrollbar_animation_controller_thinning.h"
@@ -154,11 +155,11 @@ void LayerTreeImpl::DidUpdateScrollOffset(int layer_id) {
// If pending tree topology changed and we still want to notify the pending
// tree about scroll offset in the active tree, we may not find the
// corresponding pending layer.
- if (LayerById(layer_id)) {
+ if (LayerImpl* layer = LayerById(layer_id)) {
// TODO(sunxd): when we have a layer_id to property_tree index map in
// property trees, use the transform_id parameter instead of looking for
// indices from LayerImpls.
- transform_id = LayerById(layer_id)->transform_tree_index();
+ transform_id = layer->transform_tree_index();
} else {
DCHECK(!IsActiveTree());
return;
@@ -166,8 +167,11 @@ void LayerTreeImpl::DidUpdateScrollOffset(int layer_id) {
if (transform_id != -1) {
TransformNode* node = transform_tree.Node(transform_id);
- if (node->scroll_offset != scroll_tree.current_scroll_offset(layer_id)) {
- node->scroll_offset = scroll_tree.current_scroll_offset(layer_id);
+ gfx::ScrollOffset scroll_offset_with_overscroll =
+ scroll_tree.current_scroll_offset(layer_id) +
+ scroll_tree.current_overscroll(layer_id);
+ if (node->scroll_offset_with_overscroll != scroll_offset_with_overscroll) {
+ node->scroll_offset_with_overscroll = scroll_offset_with_overscroll;
node->needs_local_transform_update = true;
transform_tree.set_needs_update(true);
}
@@ -613,12 +617,20 @@ void LayerTreeImpl::SetCurrentlyScrollingLayer(LayerImpl* layer) {
ScrollbarAnimationController* old_animation_controller =
layer_tree_host_impl_->ScrollbarAnimationControllerForId(old_id);
+ ScrollElasticityHelper* old_elasticity_helper =
+ layer_tree_host_impl_->ScrollElasticityHelperForId(old_id);
ScrollbarAnimationController* new_animation_controller =
layer_tree_host_impl_->ScrollbarAnimationControllerForId(new_id);
+ ScrollElasticityHelper* new_elasticity_helper =
+ layer_tree_host_impl_->ScrollElasticityHelperForId(new_id);
+ if (old_elasticity_helper == new_elasticity_helper)
+ old_elasticity_helper = new_elasticity_helper = nullptr;
if (old_animation_controller)
old_animation_controller->DidScrollEnd();
+
scroll_tree.set_currently_scrolling_node(new_scroll_node_id);
+
if (new_animation_controller)
new_animation_controller->DidScrollBegin();
}
@@ -1375,6 +1387,13 @@ LayerTreeImpl::CreateScrollbarAnimationController(int scroll_layer_id) {
return nullptr;
}
+std::unique_ptr<ScrollElasticityHelper>
+LayerTreeImpl::CreateScrollElasticityHelper(int scroll_layer_id) {
+ DCHECK(settings().enable_elastic_overscroll);
+ return ScrollElasticityHelper::CreateForLayer(scroll_layer_id,
+ layer_tree_host_impl_);
+}
+
void LayerTreeImpl::DidAnimateScrollOffset() {
layer_tree_host_impl_->DidAnimateScrollOffset();
}
@@ -1640,6 +1659,13 @@ void LayerTreeImpl::RegisterScrollLayer(LayerImpl* layer) {
clip_scroll_map_.insert(
std::pair<int, int>(layer->scroll_clip_layer_id(), layer->id()));
+ bool can_overscroll = layer->can_overscroll();
+ if (can_overscroll && settings().enable_elastic_overscroll &&
+ (layer->user_scrollable_horizontal() ||
+ layer->user_scrollable_vertical())) {
+ layer_tree_host_impl_->RegisterScrollElasticityHelper(layer->id());
+ }
+
DidUpdateScrollState(layer->id());
}
@@ -1647,6 +1673,7 @@ void LayerTreeImpl::UnregisterScrollLayer(LayerImpl* layer) {
if (layer->scroll_clip_layer_id() == Layer::INVALID_ID)
return;
+ layer_tree_host_impl_->UnregisterScrollElasticityHelper(layer->id());
clip_scroll_map_.erase(layer->scroll_clip_layer_id());
}
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | cc/trees/property_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698