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

Unified Diff: content/browser/web_contents/aura/overscroll_window_animation.h

Issue 895543005: Refactor GestureNavigation to eliminate code redundancy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Following suggestions by Mikhail, rewritten OWA to use a delegate interface (to be implemented) Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/aura/overscroll_window_animation.h
diff --git a/content/browser/web_contents/aura/overscroll_window_animation.h b/content/browser/web_contents/aura/overscroll_window_animation.h
new file mode 100644
index 0000000000000000000000000000000000000000..4d56e0709d4a6fbcd4d98ca25bad34001d251bb5
--- /dev/null
+++ b/content/browser/web_contents/aura/overscroll_window_animation.h
@@ -0,0 +1,106 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_
+#define CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_
+
+#include "content/browser/renderer_host/overscroll_controller_delegate.h"
+#include "content/common/content_export.h"
+#include "ui/compositor/layer_animation_observer.h"
+
+namespace ui {
+class LayerAnimator;
+}
+
+namespace content {
+
+// Manages the animations during an overscroll navigation by handling overscroll
+// events.
+class CONTENT_EXPORT OverscrollWindowAnimation : ui::ImplicitAnimationObserver,
+ OverscrollControllerDelegate {
+ public:
+ enum Direction { FORWARD, BACKWARD, NONE };
+
+ // Delegate class that interfaces with the window animation, responsible for
+ // navigation.
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ // Creates an OverscrollWindow if it does not exist, or adds a new layer if
+ // it does. Returns the navigation direction.
+ virtual Direction StartNavigation(OverscrollMode mode) = 0;
+
+ // Sets the transform on the OverscrollWindow, which can set it in the
+ // active layer or the overscroll window.
+ virtual void SetTransform(const gfx::Transform& transform) = 0;
+
+ // Returns the active layer animator.
+ virtual ui::LayerAnimator* GetAnimator() = 0;
+
+ // Returns the bounds of the contents window.
+ virtual gfx::Rect GetContentsBounds() const = 0;
+
+ // Called when the animation has been completed. The delagate can then
+ // dismiss the overlay window, or wait for the page to load first.
+ virtual void OnAnimationCompleted() = 0;
mfomitchev 2015/02/19 19:04:59 OnOverscrollCompleted Maybe OnOverscrollCompleted(
Nina 2015/02/27 19:32:51 I think passing the layer instead of the wrapper m
+
+ // Called when we know the animation is going to complete. This should start
+ // the navigation.
+ virtual void OnAnimationCompleting() = 0;
+ };
+
+ OverscrollWindowAnimation(Delegate* delegate);
+
+ ~OverscrollWindowAnimation() override;
+
+ // Aborts all current running animations.
+ void AbortAllAnimations();
+
+ // Returns true if there is a slide animation currently in progress.
+ bool IsSlideInProgress() const;
+
+ // Overridden from OverscrollControllerDelegate:
+ gfx::Rect GetVisibleBounds() const override;
+
+ bool OnOverscrollUpdate(float delta_x, float delta_y) override;
+
+ void OnOverscrollComplete(OverscrollMode overscroll_mode) override;
+
+ void OnOverscrollModeChange(OverscrollMode old_mode,
+ OverscrollMode new_mode) override;
+
+ private:
+ // Prepares the overscroll window to begin animating.
+ void StartAnimating();
+
+ // Starts the overscroll cancelled animation.
+ void CancelOverscroll();
+
+ // Moves the animated window according to the given scroll deltas. Returns
+ // true if the update moved the window.
+ bool UpdateForScroll(float delta_x);
+
+ // Returns a translation for the given overscroll.
+ gfx::Vector2dF GetTranslationForOverscroll(float delta_x);
+
+ // Overridden from ui::ImplicitAnimationObserver:
+ void OnImplicitAnimationsCompleted() override;
+
+ // Delegate that provides images and handles navigation.
+ Delegate* delegate_;
+
+ // The current overscroll direction.
+ Direction direction_;
+
+ // True if the overscroll gesture has been cancelled.
+ bool overscroll_cancelled_;
mfomitchev 2015/02/19 19:04:59 DOesn't seem like you need this
Nina 2015/02/27 19:32:51 Removed.
+
+ // True if the overscroll animation has been completed.
+ bool animation_completed_;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_

Powered by Google App Engine
This is Rietveld 408576698