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

Side by Side Diff: content/browser/web_contents/aura/gesture_nav_simple.cc

Issue 2983893002: Simpified Gesture Nav: Don't navigate if affordance isn't showing. (Closed)
Patch Set: Rebase Created 3 years, 5 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 | « no previous file | no next file » | 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/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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 378
379 bool GestureNavSimple::OnOverscrollUpdate(float delta_x, float delta_y) { 379 bool GestureNavSimple::OnOverscrollUpdate(float delta_x, float delta_y) {
380 if (!affordance_ || affordance_->IsFinishing()) 380 if (!affordance_ || affordance_->IsFinishing())
381 return false; 381 return false;
382 affordance_->SetDragProgress( 382 affordance_->SetDragProgress(
383 std::min(1.f, std::abs(delta_x) / completion_threshold_)); 383 std::min(1.f, std::abs(delta_x) / completion_threshold_));
384 return true; 384 return true;
385 } 385 }
386 386
387 void GestureNavSimple::OnOverscrollComplete(OverscrollMode overscroll_mode) { 387 void GestureNavSimple::OnOverscrollComplete(OverscrollMode overscroll_mode) {
388 if (!affordance_ || affordance_->IsFinishing())
389 return;
390
388 CompleteGestureAnimation(); 391 CompleteGestureAnimation();
389 392
390 NavigationControllerImpl& controller = web_contents_->GetController(); 393 NavigationControllerImpl& controller = web_contents_->GetController();
391 if (ShouldNavigateForward(controller, overscroll_mode)) 394 if (ShouldNavigateForward(controller, overscroll_mode))
392 controller.GoForward(); 395 controller.GoForward();
393 else if (ShouldNavigateBack(controller, overscroll_mode)) 396 else if (ShouldNavigateBack(controller, overscroll_mode))
394 controller.GoBack(); 397 controller.GoBack();
395 } 398 }
396 399
397 void GestureNavSimple::OnOverscrollModeChange(OverscrollMode old_mode, 400 void GestureNavSimple::OnOverscrollModeChange(OverscrollMode old_mode,
(...skipping 12 matching lines...) Expand all
410 ? OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHPAD 413 ? OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHPAD
411 : OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHSCREEN); 414 : OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHSCREEN);
412 const int width = source == OverscrollSource::TOUCHPAD 415 const int width = source == OverscrollSource::TOUCHPAD
413 ? GetDisplaySize().width() 416 ? GetDisplaySize().width()
414 : GetVisibleSize().width(); 417 : GetVisibleSize().width();
415 completion_threshold_ = 418 completion_threshold_ =
416 width * GetOverscrollConfig(OVERSCROLL_CONFIG_HORIZ_THRESHOLD_COMPLETE) - 419 width * GetOverscrollConfig(OVERSCROLL_CONFIG_HORIZ_THRESHOLD_COMPLETE) -
417 start_threshold; 420 start_threshold;
418 421
419 aura::Window* window = web_contents_->GetNativeView(); 422 aura::Window* window = web_contents_->GetNativeView();
420 affordance_.reset(new Affordance(this, new_mode, window->bounds())); 423 affordance_ = base::MakeUnique<Affordance>(this, new_mode, window->bounds());
421 424
422 // Adding the affordance as a child of the content window is not sufficient, 425 // Adding the affordance as a child of the content window is not sufficient,
423 // because it is possible for a new layer to be parented on top of the 426 // because it is possible for a new layer to be parented on top of the
424 // affordance layer (e.g. when the navigated-to page is displayed while the 427 // affordance layer (e.g. when the navigated-to page is displayed while the
425 // completion animation is in progress). So instead, it is installed on top of 428 // completion animation is in progress). So instead, it is installed on top of
426 // the content window as its sibling. Note that the affordance itself makes 429 // the content window as its sibling. Note that the affordance itself makes
427 // sure that its contents are clipped to the bounds given to it. 430 // sure that its contents are clipped to the bounds given to it.
428 ui::Layer* parent = window->layer()->parent(); 431 ui::Layer* parent = window->layer()->parent();
429 parent->Add(affordance_->root_layer()); 432 parent->Add(affordance_->root_layer());
430 parent->StackAtTop(affordance_->root_layer()); 433 parent->StackAtTop(affordance_->root_layer());
431 } 434 }
432 435
433 base::Optional<float> GestureNavSimple::GetMaxOverscrollDelta() const { 436 base::Optional<float> GestureNavSimple::GetMaxOverscrollDelta() const {
434 if (affordance_) 437 if (affordance_)
435 return completion_threshold_; 438 return completion_threshold_;
436 return base::nullopt; 439 return base::nullopt;
437 } 440 }
438 441
439 } // namespace content 442 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698