Chromium Code Reviews| 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/web_contents/aura/gesture_nav_simple.h" | 5 #include "content/browser/web_contents/aura/gesture_nav_simple.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "cc/paint/paint_flags.h" | 10 #include "cc/paint/paint_flags.h" |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 CompleteGestureAnimation(); | 367 CompleteGestureAnimation(); |
| 368 | 368 |
| 369 NavigationControllerImpl& controller = web_contents_->GetController(); | 369 NavigationControllerImpl& controller = web_contents_->GetController(); |
| 370 if (ShouldNavigateForward(controller, overscroll_mode)) | 370 if (ShouldNavigateForward(controller, overscroll_mode)) |
| 371 controller.GoForward(); | 371 controller.GoForward(); |
| 372 else if (ShouldNavigateBack(controller, overscroll_mode)) | 372 else if (ShouldNavigateBack(controller, overscroll_mode)) |
| 373 controller.GoBack(); | 373 controller.GoBack(); |
| 374 } | 374 } |
| 375 | 375 |
| 376 void GestureNavSimple::OnOverscrollModeChange(OverscrollMode old_mode, | 376 void GestureNavSimple::OnOverscrollModeChange(OverscrollMode old_mode, |
| 377 OverscrollMode new_mode) { | 377 OverscrollMode new_mode, |
| 378 OverscrollSource source) { | |
| 378 NavigationControllerImpl& controller = web_contents_->GetController(); | 379 NavigationControllerImpl& controller = web_contents_->GetController(); |
| 379 if (!ShouldNavigateForward(controller, new_mode) && | 380 if (!ShouldNavigateForward(controller, new_mode) && |
| 380 !ShouldNavigateBack(controller, new_mode)) { | 381 !ShouldNavigateBack(controller, new_mode)) { |
| 381 AbortGestureAnimation(); | 382 AbortGestureAnimation(); |
| 382 return; | 383 return; |
| 383 } | 384 } |
| 384 | 385 |
| 385 aura::Window* window = web_contents_->GetNativeView(); | 386 aura::Window* window = web_contents_->GetNativeView(); |
| 386 const gfx::Rect& window_bounds = window->bounds(); | 387 const gfx::Rect& window_bounds = window->bounds(); |
| 388 DCHECK_NE(source, OverscrollSource::NONE); | |
| 389 float start_threshold = | |
| 390 source == OverscrollSource::TOUCHPAD | |
| 391 ? GetOverscrollConfig( | |
| 392 OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHPAD) | |
| 393 : GetOverscrollConfig( | |
| 394 OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHSCREEN); | |
|
mohsen
2017/02/23 19:19:10
nit: I would put conditional ternary operator insi
| |
| 387 completion_threshold_ = | 395 completion_threshold_ = |
| 388 window_bounds.width() * | 396 window_bounds.width() * |
| 389 GetOverscrollConfig(OVERSCROLL_CONFIG_HORIZ_THRESHOLD_COMPLETE) - | 397 GetOverscrollConfig(OVERSCROLL_CONFIG_HORIZ_THRESHOLD_COMPLETE) - |
| 390 GetOverscrollConfig(OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHSCREEN); | 398 start_threshold; |
| 391 | 399 |
| 392 affordance_.reset(new Affordance(new_mode, window_bounds)); | 400 affordance_.reset(new Affordance(new_mode, window_bounds)); |
| 393 | 401 |
| 394 // Adding the affordance as a child of the content window is not sufficient, | 402 // Adding the affordance as a child of the content window is not sufficient, |
| 395 // because it is possible for a new layer to be parented on top of the | 403 // because it is possible for a new layer to be parented on top of the |
| 396 // affordance layer (e.g. when the navigated-to page is displayed while the | 404 // affordance layer (e.g. when the navigated-to page is displayed while the |
| 397 // completion animation is in progress). So instead, it is installed on top of | 405 // completion animation is in progress). So instead, it is installed on top of |
| 398 // the content window as its sibling. Note that the affordance itself makes | 406 // the content window as its sibling. Note that the affordance itself makes |
| 399 // sure that its contents are clipped to the bounds given to it. | 407 // sure that its contents are clipped to the bounds given to it. |
| 400 ui::Layer* parent = window->layer()->parent(); | 408 ui::Layer* parent = window->layer()->parent(); |
| 401 parent->Add(affordance_->root_layer()); | 409 parent->Add(affordance_->root_layer()); |
| 402 parent->StackAtTop(affordance_->root_layer()); | 410 parent->StackAtTop(affordance_->root_layer()); |
| 403 } | 411 } |
| 404 | 412 |
| 405 } // namespace content | 413 } // namespace content |
| OLD | NEW |