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

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

Issue 202183003: Fixing race conditions in ui::content::WindowSlider which could cause the overscroll overlay to nev… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implementing some of the review feedback. Created 6 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/window_slider.h
diff --git a/content/browser/web_contents/aura/window_slider.h b/content/browser/web_contents/aura/window_slider.h
index 0ebe79239fd35277d712dba0163d84629c51e506..d70f7955fdad4fdd293f06c215c86c45509bfcbc 100644
--- a/content/browser/web_contents/aura/window_slider.h
+++ b/content/browser/web_contents/aura/window_slider.h
@@ -10,6 +10,7 @@
#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
#include "ui/aura/window_observer.h"
+#include "ui/compositor/layer_animator.h"
#include "ui/events/event_handler.h"
namespace ui {
@@ -28,25 +29,34 @@ class CONTENT_EXPORT WindowSlider : public ui::EventHandler,
public:
virtual ~Delegate() {}
- // Creates a layer to show in the background, as the window-layer slides
- // with the scroll gesture.
- // The WindowSlider takes ownership of the created layer.
- virtual ui::Layer* CreateBackLayer() = 0;
-
- // Creates a layer to slide on top of the window-layer with the scroll
+ // Called when the slide in the backward direction starts. Returns a layer
+ // to show in the background, as the window-layer slides with the scroll
// gesture.
// The WindowSlider takes ownership of the created layer.
- virtual ui::Layer* CreateFrontLayer() = 0;
+ virtual ui::Layer* OnSlideBackStartedCreateLayer() = 0;
- // Called when the slide is complete. Note that at the end of a completed
- // slide, the window-layer may have been transformed. The callback here
- // should reset the transform if necessary.
- virtual void OnWindowSlideComplete() = 0;
+ // Called when the slide in the forward direction starts. Returns a layer
+ // to slide on top of the window-layer with the scroll gesture.
+ // The WindowSlider takes ownership of the created layer.
+ virtual ui::Layer* OnSlideForwardStartedCreateLayer() = 0;
// Called when the slide is aborted. Note that when the slide is aborted,
// the WindowSlider resets any transform it applied on the window-layer.
virtual void OnWindowSlideAborted() = 0;
+ // Called when the slide is about to be complete. The delegate can take
+ // action with the assumption that slide will complete soon (within the
+ // duration of the final transition animation effect).
+ // This callback is always preceeded by OnSlideBackStartedCreateLayer() or
+ // by OnSlideForwardStartedCreateLayer() callback, and is guaranteed to be
+ // followed by the OnWindowSlideCompleted() callback.
+ virtual void OnWindowSlideCompleting() = 0;
+
+ // Called when the window slide completes. Note that at the end the
+ // window-layer may have been transformed. The callback here should reset
+ // the transform if necessary.
+ virtual void OnWindowSlideCompleted() = 0;
+
// Called when the slider is destroyed.
virtual void OnWindowSliderDestroyed() = 0;
};
@@ -76,16 +86,20 @@ class CONTENT_EXPORT WindowSlider : public ui::EventHandler,
void UpdateForFling(float x_velocity, float y_velocity);
- // Resets any in-progress slide.
- void ResetScroll();
+ // Stops all slider-owned animations, progressing them to their end-points.
+ // Note that depending on the sate of the Delegate and the WindowSlider, this
+ // may destroy the WindowSlider through animation callbacks.
+ void CompleteActiveAnimations();
- // Cancels any scroll/animation in progress.
- void CancelScroll();
+ // Resets in-progress slide if any, and starts the animation of the slidden
+ // window to its original position.
+ void ResetSlide();
// The following callbacks are triggered after an animation.
- void CompleteWindowSlideAfterAnimation();
+ void FlingAnimationCompleted(ui::Layer* layer, ShadowLayerDelegate* shadow);
sadrul 2014/03/24 20:20:47 A window-slide can complete without a fling. We sh
mfomitchev 2014/03/24 22:36:47 True, but this callback is used (only) by the Upda
- void AbortWindowSlideAfterAnimation();
+ void ResetSlideAnimationCompleted(ui::Layer* layer,
+ ShadowLayerDelegate* shadow);
// Overridden from ui::EventHandler:
virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
@@ -109,6 +123,10 @@ class CONTENT_EXPORT WindowSlider : public ui::EventHandler,
// destroy |owner_|.
aura::Window* owner_;
+ // Set to the Animator of the currently active animation. If no animation is
+ // active, this is set to NULL.
+ ui::LayerAnimator* active_animator_;
+
// The accumulated amount of horizontal scroll.
float delta_x_;

Powered by Google App Engine
This is Rietveld 408576698