| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 } | 1281 } |
| 1282 | 1282 |
| 1283 bool WebContentsViewAura::OnOverscrollUpdate(float delta_x, float delta_y) { | 1283 bool WebContentsViewAura::OnOverscrollUpdate(float delta_x, float delta_y) { |
| 1284 if (current_overscroll_gesture_ == OVERSCROLL_NONE) | 1284 if (current_overscroll_gesture_ == OVERSCROLL_NONE) |
| 1285 return false; | 1285 return false; |
| 1286 | 1286 |
| 1287 aura::Window* target = GetWindowToAnimateForOverscroll(); | 1287 aura::Window* target = GetWindowToAnimateForOverscroll(); |
| 1288 gfx::Vector2d translate = GetTranslationForOverscroll(delta_x, delta_y); | 1288 gfx::Vector2d translate = GetTranslationForOverscroll(delta_x, delta_y); |
| 1289 gfx::Transform transform; | 1289 gfx::Transform transform; |
| 1290 | 1290 |
| 1291 // Vertical overscrolls don't participate in the navigation gesture. | 1291 if (current_overscroll_gesture_ == OVERSCROLL_NORTH || |
| 1292 if (current_overscroll_gesture_ != OVERSCROLL_NORTH && | 1292 current_overscroll_gesture_ == OVERSCROLL_SOUTH) { |
| 1293 current_overscroll_gesture_ != OVERSCROLL_SOUTH) { | 1293 OverscrollUpdateForWebContentsDelegate(translate.y()); |
| 1294 } else { |
| 1295 // Only horizontal overscrolls participate in the navigation gesture. |
| 1294 transform.Translate(translate.x(), translate.y()); | 1296 transform.Translate(translate.x(), translate.y()); |
| 1295 target->SetTransform(transform); | 1297 target->SetTransform(transform); |
| 1296 UpdateOverscrollWindowBrightness(delta_x); | 1298 UpdateOverscrollWindowBrightness(delta_x); |
| 1297 } | 1299 } |
| 1298 | 1300 |
| 1299 OverscrollUpdateForWebContentsDelegate(translate.y()); | |
| 1300 return !translate.IsZero(); | 1301 return !translate.IsZero(); |
| 1301 } | 1302 } |
| 1302 | 1303 |
| 1303 void WebContentsViewAura::OnOverscrollComplete(OverscrollMode mode) { | 1304 void WebContentsViewAura::OnOverscrollComplete(OverscrollMode mode) { |
| 1304 UMA_HISTOGRAM_ENUMERATION("Overscroll.Completed", mode, OVERSCROLL_COUNT); | 1305 UMA_HISTOGRAM_ENUMERATION("Overscroll.Completed", mode, OVERSCROLL_COUNT); |
| 1305 OverscrollUpdateForWebContentsDelegate(0); | 1306 if (web_contents_->GetDelegate() && |
| 1307 IsScrollEndEffectEnabled() && |
| 1308 (mode == OVERSCROLL_NORTH || mode == OVERSCROLL_SOUTH)) { |
| 1309 web_contents_->GetDelegate()->OverscrollComplete(); |
| 1310 } |
| 1306 NavigationControllerImpl& controller = web_contents_->GetController(); | 1311 NavigationControllerImpl& controller = web_contents_->GetController(); |
| 1307 if (ShouldNavigateForward(controller, mode) || | 1312 if (ShouldNavigateForward(controller, mode) || |
| 1308 ShouldNavigateBack(controller, mode)) { | 1313 ShouldNavigateBack(controller, mode)) { |
| 1309 CompleteOverscrollNavigation(mode); | 1314 CompleteOverscrollNavigation(mode); |
| 1310 return; | 1315 return; |
| 1311 } | 1316 } |
| 1312 | 1317 |
| 1313 ResetOverscrollTransform(); | 1318 ResetOverscrollTransform(); |
| 1314 } | 1319 } |
| 1315 | 1320 |
| 1316 void WebContentsViewAura::OnOverscrollModeChange(OverscrollMode old_mode, | 1321 void WebContentsViewAura::OnOverscrollModeChange(OverscrollMode old_mode, |
| 1317 OverscrollMode new_mode) { | 1322 OverscrollMode new_mode) { |
| 1318 // Reset any in-progress overscroll animation first. | 1323 // Reset any in-progress overscroll animation first. |
| 1319 ResetOverscrollTransform(); | 1324 ResetOverscrollTransform(); |
| 1320 | 1325 |
| 1326 if (old_mode == OVERSCROLL_NORTH || old_mode == OVERSCROLL_SOUTH) |
| 1327 OverscrollUpdateForWebContentsDelegate(0); |
| 1328 |
| 1321 if (new_mode != OVERSCROLL_NONE && touch_editable_) | 1329 if (new_mode != OVERSCROLL_NONE && touch_editable_) |
| 1322 touch_editable_->OverscrollStarted(); | 1330 touch_editable_->OverscrollStarted(); |
| 1323 | 1331 |
| 1324 if (new_mode == OVERSCROLL_NONE || | 1332 if (new_mode == OVERSCROLL_NONE || |
| 1325 !GetContentNativeView() || | 1333 !GetContentNativeView() || |
| 1326 ((new_mode == OVERSCROLL_EAST || new_mode == OVERSCROLL_WEST) && | 1334 ((new_mode == OVERSCROLL_EAST || new_mode == OVERSCROLL_WEST) && |
| 1327 navigation_overlay_.get() && navigation_overlay_->has_window())) { | 1335 navigation_overlay_.get() && navigation_overlay_->has_window())) { |
| 1328 current_overscroll_gesture_ = OVERSCROLL_NONE; | 1336 current_overscroll_gesture_ = OVERSCROLL_NONE; |
| 1329 OverscrollUpdateForWebContentsDelegate(0); | |
| 1330 } else { | 1337 } else { |
| 1331 aura::Window* target = GetWindowToAnimateForOverscroll(); | 1338 aura::Window* target = GetWindowToAnimateForOverscroll(); |
| 1332 if (target) { | 1339 if (target) { |
| 1333 StopObservingImplicitAnimations(); | 1340 StopObservingImplicitAnimations(); |
| 1334 target->layer()->GetAnimator()->AbortAllAnimations(); | 1341 target->layer()->GetAnimator()->AbortAllAnimations(); |
| 1335 } | 1342 } |
| 1336 // Cleanup state of the content window first, because that can reset the | 1343 // Cleanup state of the content window first, because that can reset the |
| 1337 // value of |current_overscroll_gesture_|. | 1344 // value of |current_overscroll_gesture_|. |
| 1338 PrepareContentWindowForOverscroll(); | 1345 PrepareContentWindowForOverscroll(); |
| 1339 | 1346 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 if (visible) { | 1611 if (visible) { |
| 1605 if (!web_contents_->should_normally_be_visible()) | 1612 if (!web_contents_->should_normally_be_visible()) |
| 1606 web_contents_->WasShown(); | 1613 web_contents_->WasShown(); |
| 1607 } else { | 1614 } else { |
| 1608 if (web_contents_->should_normally_be_visible()) | 1615 if (web_contents_->should_normally_be_visible()) |
| 1609 web_contents_->WasHidden(); | 1616 web_contents_->WasHidden(); |
| 1610 } | 1617 } |
| 1611 } | 1618 } |
| 1612 | 1619 |
| 1613 } // namespace content | 1620 } // namespace content |
| OLD | NEW |