| OLD | NEW |
| 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 "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 if (!refresh_effect_) | 119 if (!refresh_effect_) |
| 120 return false; | 120 return false; |
| 121 | 121 |
| 122 // Suppress refresh detection if the glow effect is still prominent. | 122 // Suppress refresh detection if the glow effect is still prominent. |
| 123 if (glow_effect_ && glow_effect_->IsActive()) { | 123 if (glow_effect_ && glow_effect_->IsActive()) { |
| 124 if (glow_effect_->GetVisibleAlpha() > MinGlowAlphaToDisableRefresh()) | 124 if (glow_effect_->GetVisibleAlpha() > MinGlowAlphaToDisableRefresh()) |
| 125 return false; | 125 return false; |
| 126 } | 126 } |
| 127 | 127 |
| 128 bool handled = false; | 128 bool handled = false; |
| 129 switch (event.type) { | 129 switch (event.type()) { |
| 130 case blink::WebInputEvent::GestureScrollBegin: | 130 case blink::WebInputEvent::GestureScrollBegin: |
| 131 refresh_effect_->OnScrollBegin(); | 131 refresh_effect_->OnScrollBegin(); |
| 132 break; | 132 break; |
| 133 | 133 |
| 134 case blink::WebInputEvent::GestureScrollUpdate: { | 134 case blink::WebInputEvent::GestureScrollUpdate: { |
| 135 gfx::Vector2dF scroll_delta(event.data.scrollUpdate.deltaX, | 135 gfx::Vector2dF scroll_delta(event.data.scrollUpdate.deltaX, |
| 136 event.data.scrollUpdate.deltaY); | 136 event.data.scrollUpdate.deltaY); |
| 137 scroll_delta.Scale(dpi_scale_); | 137 scroll_delta.Scale(dpi_scale_); |
| 138 handled = refresh_effect_->WillHandleScrollUpdate(scroll_delta); | 138 handled = refresh_effect_->WillHandleScrollUpdate(scroll_delta); |
| 139 } break; | 139 } break; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 174 } |
| 175 | 175 |
| 176 void OverscrollControllerAndroid::OnGestureEventAck( | 176 void OverscrollControllerAndroid::OnGestureEventAck( |
| 177 const blink::WebGestureEvent& event, | 177 const blink::WebGestureEvent& event, |
| 178 InputEventAckState ack_result) { | 178 InputEventAckState ack_result) { |
| 179 if (!enabled_) | 179 if (!enabled_) |
| 180 return; | 180 return; |
| 181 | 181 |
| 182 // The overscroll effect requires an explicit release signal that may not be | 182 // The overscroll effect requires an explicit release signal that may not be |
| 183 // sent from the renderer compositor. | 183 // sent from the renderer compositor. |
| 184 if (event.type == blink::WebInputEvent::GestureScrollEnd || | 184 if (event.type() == blink::WebInputEvent::GestureScrollEnd || |
| 185 event.type == blink::WebInputEvent::GestureFlingStart) { | 185 event.type() == blink::WebInputEvent::GestureFlingStart) { |
| 186 OnOverscrolled(DidOverscrollParams()); | 186 OnOverscrolled(DidOverscrollParams()); |
| 187 } | 187 } |
| 188 | 188 |
| 189 if (event.type == blink::WebInputEvent::GestureScrollUpdate && | 189 if (event.type() == blink::WebInputEvent::GestureScrollUpdate && |
| 190 refresh_effect_) { | 190 refresh_effect_) { |
| 191 // The effect should only be allowed if both the causal touch events go | 191 // The effect should only be allowed if both the causal touch events go |
| 192 // unconsumed and the generated scroll events go unconsumed. | 192 // unconsumed and the generated scroll events go unconsumed. |
| 193 bool consumed = ack_result == INPUT_EVENT_ACK_STATE_CONSUMED || | 193 bool consumed = ack_result == INPUT_EVENT_ACK_STATE_CONSUMED || |
| 194 event.data.scrollUpdate.previousUpdateInSequencePrevented; | 194 event.data.scrollUpdate.previousUpdateInSequencePrevented; |
| 195 refresh_effect_->OnScrollUpdateAck(consumed); | 195 refresh_effect_->OnScrollUpdateAck(consumed); |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 | 198 |
| 199 void OverscrollControllerAndroid::OnOverscrolled( | 199 void OverscrollControllerAndroid::OnOverscrolled( |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 std::unique_ptr<EdgeEffectBase> | 274 std::unique_ptr<EdgeEffectBase> |
| 275 OverscrollControllerAndroid::CreateEdgeEffect() { | 275 OverscrollControllerAndroid::CreateEdgeEffect() { |
| 276 return CreateGlowEdgeEffect(&compositor_->GetResourceManager(), dpi_scale_); | 276 return CreateGlowEdgeEffect(&compositor_->GetResourceManager(), dpi_scale_); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void OverscrollControllerAndroid::SetNeedsAnimate() { | 279 void OverscrollControllerAndroid::SetNeedsAnimate() { |
| 280 compositor_->SetNeedsAnimate(); | 280 compositor_->SetNeedsAnimate(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 } // namespace content | 283 } // namespace content |
| OLD | NEW |