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

Unified Diff: cc/layers/layer.cc

Issue 2189583004: [not for review - epic CL] Adding Elastic+Momentum+Layered scrolling to views::ScrollView Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Combined rebase Created 4 years, 5 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: cc/layers/layer.cc
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 4b2df1cd73cf01669a5c87bc7c5aedb328a3e604..acb8253c971e1e45bc4f0c22882a7b9cc3fa55a2 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -782,8 +782,10 @@ void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) {
return;
PropertyTrees* property_trees = layer_tree_host_->property_trees();
- if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable())
- property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset);
+ if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable()) {
+ property_trees->scroll_tree.SetScrollOffset(id(), inputs_.scroll_offset,
+ inputs_.overscroll);
+ }
if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
id())) {
@@ -791,7 +793,8 @@ void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) {
property_trees->transform_id_to_index_map[id()]);
TransformNode* transform_node =
property_trees->transform_tree.Node(transform_tree_index());
- transform_node->scroll_offset = CurrentScrollOffset();
+ transform_node->scroll_offset_with_overscroll =
+ inputs_.scroll_offset + inputs_.overscroll;
transform_node->needs_local_transform_update = true;
property_trees->transform_tree.set_needs_update(true);
SetNeedsCommitNoRebuild();
@@ -801,22 +804,33 @@ void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) {
SetNeedsCommit();
}
-void Layer::SetScrollOffsetFromImplSide(
- const gfx::ScrollOffset& scroll_offset) {
+void Layer::SetScrollOffsetFromImplSide(const gfx::ScrollOffset& scroll_offset,
+ gfx::Vector2dF* overscroll_delta) {
DCHECK(IsPropertyChangeAllowed());
// This function only gets called during a BeginMainFrame, so there
// is no need to call SetNeedsUpdate here.
DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested());
- if (inputs_.scroll_offset == scroll_offset)
+
+ gfx::ScrollOffset overscroll = inputs_.overscroll;
+ if (inputs_.can_overscroll && overscroll_delta) {
+ overscroll = gfx::ScrollOffsetWithDelta(overscroll, *overscroll_delta);
+ *overscroll_delta = gfx::Vector2dF();
+ }
+ if (inputs_.scroll_offset == scroll_offset &&
+ inputs_.overscroll == overscroll)
return;
+
inputs_.scroll_offset = scroll_offset;
+ inputs_.overscroll = overscroll;
SetNeedsPushProperties();
bool needs_rebuild = true;
PropertyTrees* property_trees = layer_tree_host_->property_trees();
- if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable())
- property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset);
+ if (scroll_tree_index() != ScrollTree::kInvalidNodeId && scrollable()) {
+ property_trees->scroll_tree.SetScrollOffset(id(), inputs_.scroll_offset,
+ inputs_.overscroll);
+ }
if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
id())) {
@@ -824,7 +838,8 @@ void Layer::SetScrollOffsetFromImplSide(
property_trees->transform_id_to_index_map[id()]);
TransformNode* transform_node =
property_trees->transform_tree.Node(transform_tree_index());
- transform_node->scroll_offset = CurrentScrollOffset();
+ transform_node->scroll_offset_with_overscroll =
+ inputs_.scroll_offset + inputs_.overscroll;
transform_node->needs_local_transform_update = true;
property_trees->transform_tree.set_needs_update(true);
needs_rebuild = false;
@@ -839,11 +854,14 @@ void Layer::SetScrollOffsetFromImplSide(
// "this" may have been destroyed during the process.
}
-void Layer::SetScrollClipLayerId(int clip_layer_id) {
+void Layer::SetScrollClipAndCanOverscroll(int clip_layer_id,
+ bool can_overscroll) {
DCHECK(IsPropertyChangeAllowed());
- if (inputs_.scroll_clip_layer_id == clip_layer_id)
+ if (inputs_.scroll_clip_layer_id == clip_layer_id &&
+ inputs_.can_overscroll == can_overscroll)
return;
inputs_.scroll_clip_layer_id = clip_layer_id;
+ inputs_.can_overscroll = can_overscroll;
SetNeedsCommit();
}
@@ -1171,7 +1189,8 @@ void Layer::PushPropertiesTo(LayerImpl* layer) {
layer->SetTransform(inputs_.transform);
layer->Set3dSortingContextId(inputs_.sorting_context_id);
- layer->SetScrollClipLayer(inputs_.scroll_clip_layer_id);
+ layer->SetScrollClipAndCanOverscroll(inputs_.scroll_clip_layer_id,
+ inputs_.can_overscroll);
layer->set_user_scrollable_horizontal(inputs_.user_scrollable_horizontal);
layer->set_user_scrollable_vertical(inputs_.user_scrollable_vertical);
layer->SetElementId(inputs_.element_id);
@@ -1395,6 +1414,7 @@ void Layer::LayerSpecificPropertiesToProto(proto::LayerProperties* proto) {
base->set_scroll_clip_layer_id(inputs_.scroll_clip_layer_id);
base->set_user_scrollable_horizontal(inputs_.user_scrollable_horizontal);
base->set_user_scrollable_vertical(inputs_.user_scrollable_vertical);
+ base->set_can_overscroll(inputs_.can_overscroll);
int scroll_parent_id =
inputs_.scroll_parent ? inputs_.scroll_parent->id() : INVALID_ID;
@@ -1415,6 +1435,7 @@ void Layer::LayerSpecificPropertiesToProto(proto::LayerProperties* proto) {
}
ScrollOffsetToProto(inputs_.scroll_offset, base->mutable_scroll_offset());
+ ScrollOffsetToProto(inputs_.overscroll, base->mutable_overscroll());
// TODO(nyquist): Figure out what to do with CopyRequests.
// See crbug.com/570374.
@@ -1479,6 +1500,7 @@ void Layer::FromLayerSpecificPropertiesProto(
inputs_.scroll_clip_layer_id = base.scroll_clip_layer_id();
inputs_.user_scrollable_horizontal = base.user_scrollable_horizontal();
inputs_.user_scrollable_vertical = base.user_scrollable_vertical();
+ inputs_.can_overscroll = base.can_overscroll();
inputs_.scroll_parent =
base.scroll_parent_id() == INVALID_ID
@@ -1521,6 +1543,7 @@ void Layer::FromLayerSpecificPropertiesProto(
}
inputs_.scroll_offset = ProtoToScrollOffset(base.scroll_offset());
+ inputs_.overscroll = ProtoToScrollOffset(base.overscroll());
inputs_.update_rect.Union(ProtoToRect(base.update_rect()));
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | ui/events/event_constants.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698