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

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: Brought back gesture cancellation by mouse and linted code. Created 5 years, 9 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..39ae5a8ddb7477d11900ea5c8d73771270eb525e
--- /dev/null
+++ b/content/browser/web_contents/aura/overscroll_window_animation.h
@@ -0,0 +1,115 @@
+// Copyright 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 "base/gtest_prod_util.h"
+#include "content/browser/renderer_host/overscroll_controller_delegate.h"
+#include "content/common/content_export.h"
+#include "ui/compositor/layer_animation_observer.h"
+
+namespace aura {
+class Window;
+}
+
+namespace ui {
+class Layer;
+class LayerAnimator;
+}
+
+namespace content {
+
+class ShadowLayerDelegate;
+class WebContentsImpl;
+
+// Manages the animations during an overscroll navigation by handling overscroll
mfomitchev 2015/03/26 15:36:00 We probably shouldn't be talking about "navigation
Nina 2015/03/27 17:52:36 Changed the comment completely. Check it out.
+// events.
+class CONTENT_EXPORT OverscrollWindowAnimation
+ : public OverscrollControllerDelegate,
+ ui::ImplicitAnimationObserver {
+ public:
+ enum Direction { SLIDE_FRONT, SLIDE_BACK, SLIDE_NONE };
+
+ // Delegate class that interfaces with the window animation, responsible for
+ // navigation.
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ // The following two functions create a slide window and transfer back its
+ // ownership.
+ virtual scoped_ptr<aura::Window> CreateFrontWindow() = 0;
+ virtual scoped_ptr<aura::Window> CreateBackWindow() = 0;
+
+ // Returns the live window that participates in the overscroll gesture.
+ virtual aura::Window* GetTargetWindow() const = 0;
mfomitchev 2015/03/26 02:41:39 "Target window" doesn't really explain what this w
Nina 2015/03/27 17:52:36 Changed to GetMainWindow.
+
+ // Called when we know the animation is going to complete successfully.
+ virtual void OnOverscrollCompleting() = 0;
+
+ // Called when the animation has been completed.
+ virtual void OnOverscrollCompleted(scoped_ptr<aura::Window> window) = 0;
+
+ // Called when the overscroll gesture has been aborted.
+ virtual void OnOverscrollAborted() = 0;
+ };
+
+ explicit OverscrollWindowAnimation(Delegate* delegate);
+
+ ~OverscrollWindowAnimation() override;
+
+ // Returns true if we are currently handling a slide animation.
+ bool is_active() const { return !!window_; }
+
+ // 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:
+ /*friend class OverscrollWindowAnimationTest;
+ FRIEND_TEST_ALL_PREFIXES(OverscrollWindowAnimationTest,
+ BasicOverscroll);*/
+
+ // 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 on the x axis for the given overscroll.
+ float GetTranslationForOverscroll(float delta_x);
+
+ // Returns the layer that is animated for the overscroll gesture.
+ ui::Layer* GetFrontLayer() const;
+
+ // ui::ImplicitAnimationObserver:
+ void OnImplicitAnimationsCompleted() override;
+
+ // Owns the new window created on the overscroll gesture.
+ scoped_ptr<aura::Window> window_;
+
+ // Shadow shown under the animated layer.
+ scoped_ptr<ShadowLayerDelegate> shadow_;
+
+ // Delegate that provides the animation target and handles navigation.
+ Delegate* delegate_;
+
+ // The current overscroll direction.
+ Direction direction_;
+
+ // Indicates if the current overscroll gesture has been cancelled.
+ bool overscroll_cancelled_;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_

Powered by Google App Engine
This is Rietveld 408576698