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

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: Checked comments 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..700e136453460d311f41918c457a96ce1bbfaa35
--- /dev/null
+++ b/content/browser/web_contents/aura/overscroll_window_animation.h
@@ -0,0 +1,97 @@
+// 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 "content/browser/renderer_host/overscroll_controller_delegate.h"
+#include "content/common/content_export.h"
+#include "ui/compositor/layer_animation_observer.h"
+
+namespace ui {
+class Layer;
+class LayerAnimator;
+}
+
+namespace content {
+
+class OverscrollLayerWrapper;
+
+// Manages the animations during an overscroll navigation by handling overscroll
+// events.
+class CONTENT_EXPORT OverscrollWindowAnimation
+ : ui::ImplicitAnimationObserver,
+ public OverscrollControllerDelegate {
+ public:
+ enum Direction { FORWARD, BACKWARD, NONE };
+
+ // Delegate class that interfaces with the window animation, responsible for
+ // navigation.
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ // The following two functions create a layer wrapper and transfer back its
+ // ownership.
+ virtual scoped_ptr<OverscrollLayerWrapper> CreateFrontLayer() = 0;
+ virtual scoped_ptr<OverscrollLayerWrapper> CreateBackLayer() = 0;
+
+ // Called when the animation has been completed. The delagate can then
+ // dismiss the overlay layer, or wait for the page to load first.
+ virtual void OnOverscrollCompleted() = 0;
mfomitchev 2015/02/27 21:33:42 consider passing the scoped ptr to the wrapper her
+
+ // Called when we know the animation is going to complete. This should start
+ // the navigation.
+ virtual void OnOverscrollCompleting() = 0;
+ };
+
+ OverscrollWindowAnimation();
+
+ ~OverscrollWindowAnimation() override;
+
+ // Returns true if there is a slide animation currently in progress.
+ bool is_animation_in_progress() const { return animation_active_; }
+
+ void set_delegate(Delegate* delegate) { delegate_ = delegate; }
+
+ // 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:
+ // 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;
+
+ // Wrapper that owns the overscroll window.
+ scoped_ptr<OverscrollLayerWrapper> layer_wrapper_;
+
+ // Delegate that provides the animation target and handles navigation.
+ Delegate* delegate_;
+
+ // The current overscroll direction.
+ Direction direction_;
+
+ // True if the overscroll animation is happening right now.
+ bool animation_active_;
mfomitchev 2015/02/27 21:33:42 nit: may be a bit ambiguous: active_ instead of an
Nina 2015/03/09 15:54:52 Done.
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_

Powered by Google App Engine
This is Rietveld 408576698