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

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: New design with window|wrapper in OWA 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..b50e49ffb26405d0cfbb17bffad54b68a600a0aa
--- /dev/null
+++ b/content/browser/web_contents/aura/overscroll_window_animation.h
@@ -0,0 +1,113 @@
+// 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 aura {
+class Window;
+}
+
+namespace ui {
+class Layer;
+class LayerAnimator;
+}
+
+namespace content {
+
+class OverscrollLayerWrapper;
+class ShadowLayerDelegate;
+
+// Manages the animations during an overscroll navigation by handling overscroll
+// events.
+class CONTENT_EXPORT OverscrollWindowAnimation
+ : public OverscrollControllerDelegate,
+ ui::ImplicitAnimationObserver {
+ public:
+ enum Direction { FORWARD, BACKWARD, NONE };
mfomitchev 2015/03/05 23:37:06 In WindowSlider Direction was SLIDE_UNKNOWN, SLID
Nina 2015/03/09 15:54:53 In this case, FORWARD == FRONT and BACKWARD == BAC
+
+ // 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.
mfomitchev 2015/03/06 01:36:43 We shouldn't reference page load in OWA's comments
Nina 2015/03/09 15:54:53 Done.
+ virtual void OnOverscrollCompleted(
mfomitchev 2015/03/05 23:37:06 Don't fire Completed() on failures - add another m
Nina 2015/03/09 15:54:53 Done.
+ scoped_ptr<OverscrollLayerWrapper> layer_wrapper) = 0;
+
+ // Called when we know the animation is going to complete. This should start
+ // the navigation.
+ virtual void OnOverscrollCompleting() = 0;
mfomitchev 2015/03/06 01:36:43 Completing() should be declared before Completed()
Nina 2015/03/09 15:54:53 Done.
+ };
+
+ OverscrollWindowAnimation();
+
+ ~OverscrollWindowAnimation() override;
+
+ // Returns true if we are currently handling a slide animation.
+ bool is_active() const { return !!layer_wrapper_; }
+
+ void set_delegate(Delegate* delegate) { delegate_ = delegate; }
+
+ void set_live_window(aura::Window* live_window) {
+ live_window_ = live_window;
mfomitchev 2015/03/05 23:37:06 DCHECK(live_window)
Nina 2015/03/09 15:54:53 Done.
+ }
+
+ // 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 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* GetAnimatedLayer();
+
+ // ui::ImplicitAnimationObserver:
+ void OnImplicitAnimationsCompleted() override;
+
+ // Wrapper that owns the overscroll window.
+ scoped_ptr<OverscrollLayerWrapper> layer_wrapper_;
+
+ // Shadow shown under the animated layer.
+ scoped_ptr<ShadowLayerDelegate> shadow_;
+
+ // Live window holding the currently active web contents.
mfomitchev 2015/03/05 23:37:06 not web contents for slider case
Nina 2015/03/09 15:54:53 Done.
+ aura::Window* live_window_;
+
+ // Delegate that provides the animation target and handles navigation.
+ Delegate* delegate_;
+
+ // The current overscroll direction.
+ Direction direction_;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_WINDOW_ANIMATION_H_

Powered by Google App Engine
This is Rietveld 408576698