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

Side by Side Diff: ui/android/overscroll_glow.cc

Issue 2884423003: Use scroll-boundary-behavior to control overscroll-refresh/glow on android. (Closed)
Patch Set: Fix nits and rebase Created 3 years, 3 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 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/android/overscroll_glow.h" 5 #include "ui/android/overscroll_glow.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/layers/layer.h" 9 #include "cc/layers/layer.h"
10 #include "ui/android/edge_effect_base.h" 10 #include "ui/android/edge_effect_base.h"
(...skipping 20 matching lines...) Expand all
31 return vector; 31 return vector;
32 } 32 }
33 33
34 } // namespace 34 } // namespace
35 35
36 OverscrollGlow::OverscrollGlow(OverscrollGlowClient* client) 36 OverscrollGlow::OverscrollGlow(OverscrollGlowClient* client)
37 : client_(client), 37 : client_(client),
38 edge_offsets_(), 38 edge_offsets_(),
39 initialized_(false), 39 initialized_(false),
40 allow_horizontal_overscroll_(true), 40 allow_horizontal_overscroll_(true),
41 allow_vertical_overscroll_(true) { 41 allow_vertical_overscroll_(true) {}
42 DCHECK(client);
boliu 2017/08/23 19:17:02 ditto fix test rather than relax production checks
sunyunjia 2017/08/23 23:47:05 Done.
43 }
44 42
45 OverscrollGlow::~OverscrollGlow() { 43 OverscrollGlow::~OverscrollGlow() {
46 Detach(); 44 Detach();
47 } 45 }
48 46
49 void OverscrollGlow::Reset() { 47 void OverscrollGlow::Reset() {
50 if (!initialized_) 48 if (!initialized_)
51 return; 49 return;
52 Detach(); 50 Detach();
53 for (size_t i = 0; i < EDGE_COUNT; ++i) 51 for (size_t i = 0; i < EDGE_COUNT; ++i)
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 void OverscrollGlow::Detach() { 185 void OverscrollGlow::Detach() {
188 if (root_layer_.get()) 186 if (root_layer_.get())
189 root_layer_->RemoveFromParent(); 187 root_layer_->RemoveFromParent();
190 } 188 }
191 189
192 bool OverscrollGlow::InitializeIfNecessary() { 190 bool OverscrollGlow::InitializeIfNecessary() {
193 if (initialized_) 191 if (initialized_)
194 return true; 192 return true;
195 193
196 DCHECK(!root_layer_.get()); 194 DCHECK(!root_layer_.get());
195 DCHECK(client_);
197 root_layer_ = cc::Layer::Create(); 196 root_layer_ = cc::Layer::Create();
198 for (size_t i = 0; i < EDGE_COUNT; ++i) { 197 for (size_t i = 0; i < EDGE_COUNT; ++i) {
199 edge_effects_[i] = client_->CreateEdgeEffect(); 198 edge_effects_[i] = client_->CreateEdgeEffect();
200 DCHECK(edge_effects_[i]); 199 DCHECK(edge_effects_[i]);
201 } 200 }
202 201
203 initialized_ = true; 202 initialized_ = true;
204 return true; 203 return true;
205 } 204 }
206 205
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 for (size_t i = 0; i < EDGE_COUNT; ++i) 271 for (size_t i = 0; i < EDGE_COUNT; ++i)
273 edge_effects_[i]->Release(current_time); 272 edge_effects_[i]->Release(current_time);
274 } 273 }
275 274
276 EdgeEffectBase* OverscrollGlow::GetOppositeEdge(int edge_index) { 275 EdgeEffectBase* OverscrollGlow::GetOppositeEdge(int edge_index) {
277 DCHECK(initialized_); 276 DCHECK(initialized_);
278 return edge_effects_[(edge_index + 2) % EDGE_COUNT].get(); 277 return edge_effects_[(edge_index + 2) % EDGE_COUNT].get();
279 } 278 }
280 279
281 } // namespace ui 280 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698