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

Side by Side Diff: content/browser/android/overscroll_controller_android.cc

Issue 993613007: [Android] Add slack to allow refresh after overscrolling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 9 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
« no previous file with comments | « content/browser/android/edge_effect_l.cc ('k') | content/browser/android/overscroll_glow.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/android/overscroll_controller_android.h" 5 #include "content/browser/android/overscroll_controller_android.h"
6 6
7 #include "base/android/build_info.h" 7 #include "base/android/build_info.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "cc/layers/layer.h" 9 #include "cc/layers/layer.h"
10 #include "cc/output/compositor_frame_metadata.h" 10 #include "cc/output/compositor_frame_metadata.h"
(...skipping 12 matching lines...) Expand all
23 namespace content { 23 namespace content {
24 namespace { 24 namespace {
25 25
26 // Used for conditional creation of EdgeEffect types for the overscroll glow. 26 // Used for conditional creation of EdgeEffect types for the overscroll glow.
27 const int kAndroidLSDKVersion = 21; 27 const int kAndroidLSDKVersion = 21;
28 28
29 // Default offset in dips from the top of the view beyond which the refresh 29 // Default offset in dips from the top of the view beyond which the refresh
30 // action will be activated. 30 // action will be activated.
31 const int kDefaultRefreshDragTargetDips = 64; 31 const int kDefaultRefreshDragTargetDips = 64;
32 32
33 // If the glow effect alpha is greater than this value, the refresh effect will
34 // be suppressed. This value was experimentally determined to provide a
35 // reasonable balance between avoiding accidental refresh activation and
36 // minimizing the wait required to refresh after the glow has been triggered.
37 const float kMinGlowAlphaToDisableRefreshOnL = 0.085f;
38
33 bool IsAndroidLOrNewer() { 39 bool IsAndroidLOrNewer() {
34 static bool android_l_or_newer = 40 static bool android_l_or_newer =
35 base::android::BuildInfo::GetInstance()->sdk_int() >= kAndroidLSDKVersion; 41 base::android::BuildInfo::GetInstance()->sdk_int() >= kAndroidLSDKVersion;
36 return android_l_or_newer; 42 return android_l_or_newer;
37 } 43 }
38 44
39 bool ShouldDisableRefreshWhenGlowActive() { 45 // Suppressing refresh detection when the glow is still animating prevents
40 // Suppressing refresh detection when the glow is still animating prevents 46 // visual confusion and accidental activation after repeated scrolls.
41 // visual confusion and accidental activation after repeated scrolls. However, 47 float MinGlowAlphaToDisableRefresh() {
42 // only the L effect is guaranteed to be both sufficiently brief and prominent 48 // Only the L effect is guaranteed to be both sufficiently brief and prominent
43 // to provide a meaningful "wait" signal. The refresh effect on previous 49 // to provide a meaningful "wait" signal. The refresh effect on previous
44 // Android releases can be quite faint, depending on the OEM-supplied 50 // Android releases can be quite faint, depending on the OEM-supplied
45 // overscroll resources, and lasts nearly twice as long. 51 // overscroll resources, and lasts nearly twice as long.
46 return IsAndroidLOrNewer(); 52 if (IsAndroidLOrNewer())
53 return kMinGlowAlphaToDisableRefreshOnL;
54
55 // Any value greater than 1 effectively prevents the glow effect from ever
56 // suppressing the refresh effect.
57 return 1.01f;
47 } 58 }
48 59
49 scoped_ptr<EdgeEffectBase> CreateGlowEdgeEffect( 60 scoped_ptr<EdgeEffectBase> CreateGlowEdgeEffect(
50 ui::ResourceManager* resource_manager, 61 ui::ResourceManager* resource_manager,
51 float dpi_scale) { 62 float dpi_scale) {
52 DCHECK(resource_manager); 63 DCHECK(resource_manager);
53 if (IsAndroidLOrNewer()) 64 if (IsAndroidLOrNewer())
54 return scoped_ptr<EdgeEffectBase>(new EdgeEffectL(resource_manager)); 65 return scoped_ptr<EdgeEffectBase>(new EdgeEffectL(resource_manager));
55 66
56 return scoped_ptr<EdgeEffectBase>( 67 return scoped_ptr<EdgeEffectBase>(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 if (!enabled_) 120 if (!enabled_)
110 return false; 121 return false;
111 122
112 if (!refresh_effect_) 123 if (!refresh_effect_)
113 return false; 124 return false;
114 125
115 // Suppress refresh detection for fullscreen HTML5 scenarios, e.g., video. 126 // Suppress refresh detection for fullscreen HTML5 scenarios, e.g., video.
116 if (is_fullscreen_) 127 if (is_fullscreen_)
117 return false; 128 return false;
118 129
119 if (glow_effect_) { 130 // Suppress refresh detection if the glow effect is still prominent.
120 if (glow_effect_->IsActive() && ShouldDisableRefreshWhenGlowActive()) 131 if (glow_effect_ && glow_effect_->IsActive()) {
132 if (glow_effect_->GetVisibleAlpha() > MinGlowAlphaToDisableRefresh())
121 return false; 133 return false;
122 } 134 }
123 135
124 bool handled = false; 136 bool handled = false;
125 bool maybe_needs_animate = false; 137 bool maybe_needs_animate = false;
126 switch (event.type) { 138 switch (event.type) {
127 case blink::WebInputEvent::GestureScrollBegin: 139 case blink::WebInputEvent::GestureScrollBegin:
128 refresh_effect_->OnScrollBegin(); 140 refresh_effect_->OnScrollBegin();
129 break; 141 break;
130 142
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 325
314 scoped_ptr<EdgeEffectBase> OverscrollControllerAndroid::CreateEdgeEffect() { 326 scoped_ptr<EdgeEffectBase> OverscrollControllerAndroid::CreateEdgeEffect() {
315 return CreateGlowEdgeEffect(&compositor_->GetResourceManager(), dpi_scale_); 327 return CreateGlowEdgeEffect(&compositor_->GetResourceManager(), dpi_scale_);
316 } 328 }
317 329
318 void OverscrollControllerAndroid::SetNeedsAnimate() { 330 void OverscrollControllerAndroid::SetNeedsAnimate() {
319 compositor_->SetNeedsAnimate(); 331 compositor_->SetNeedsAnimate();
320 } 332 }
321 333
322 } // namespace content 334 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/edge_effect_l.cc ('k') | content/browser/android/overscroll_glow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698