Chromium Code Reviews| Index: content/browser/web_contents/aura/overscroll_navigation_overlay.h |
| diff --git a/content/browser/web_contents/aura/overscroll_navigation_overlay.h b/content/browser/web_contents/aura/overscroll_navigation_overlay.h |
| index db9871c024981ff908b20bfd9b2ed1baddcc6eaa..6aa8e33d66d3d58f80fad0e95d1e730f942843fb 100644 |
| --- a/content/browser/web_contents/aura/overscroll_navigation_overlay.h |
| +++ b/content/browser/web_contents/aura/overscroll_navigation_overlay.h |
| @@ -7,9 +7,11 @@ |
| #include "base/gtest_prod_util.h" |
| #include "base/macros.h" |
| -#include "content/browser/web_contents/aura/window_slider.h" |
| +#include "content/browser/web_contents/aura/overscroll_window_animation.h" |
| +#include "content/browser/web_contents/web_contents_view_aura.h" |
| #include "content/common/content_export.h" |
| #include "content/public/browser/web_contents_observer.h" |
| +#include "ui/gfx/image/image.h" |
| struct ViewHostMsg_UpdateRect_Params; |
| @@ -20,6 +22,7 @@ class ImageWindowDelegate; |
| namespace content { |
| class ImageLayerDelegate; |
| +class OverscrollWindowDelegate; |
| class OverscrollNavigationOverlayTest; |
| // When a history navigation is triggered at the end of an overscroll |
| @@ -29,27 +32,15 @@ class OverscrollNavigationOverlayTest; |
| // painting. |
| class CONTENT_EXPORT OverscrollNavigationOverlay |
| : public WebContentsObserver, |
| - public WindowSlider::Delegate { |
| + public OverscrollWindowAnimation::Delegate { |
| public: |
| - explicit OverscrollNavigationOverlay(WebContentsImpl* web_contents); |
| - ~OverscrollNavigationOverlay() override; |
| - |
| - bool has_window() const { return !!window_.get(); } |
| + OverscrollNavigationOverlay(WebContentsImpl* web_contents, |
| + OverscrollWindowAnimation* owa, |
| + aura::Window* web_contents_window); |
| - // Resets state and starts observing |web_contents_| for page load/paint |
| - // updates. This function makes sure that the screenshot window is stacked |
| - // on top, so that it hides the content window behind it, and destroys the |
| - // screenshot window when the page is done loading/painting. |
| - // This should be called immediately after initiating the navigation, |
| - // otherwise the overlay may be dismissed prematurely. |
| - void StartObserving(); |
| + ~OverscrollNavigationOverlay() override; |
| - // Sets the screenshot window and the delegate. This takes ownership of |
| - // |window|. |
| - // Note that aura_extra::ImageWindowDelegate manages its own lifetime, so this |
| - // function does not take ownership of |delegate|. |
| - void SetOverlayWindow(scoped_ptr<aura::Window> window, |
| - aura_extra::ImageWindowDelegate* delegate); |
| + OverscrollWindowAnimation::Direction direction() { return direction_; } |
| private: |
| friend class OverscrollNavigationOverlayTest; |
| @@ -64,65 +55,84 @@ class CONTENT_EXPORT OverscrollNavigationOverlay |
| FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, |
| MultiNavigation_PaintUpdate); |
| - enum SlideDirection { |
| - SLIDE_UNKNOWN, |
| - SLIDE_BACK, |
| - SLIDE_FRONT |
| - }; |
| + // Resets state and starts observing |web_contents_| for page load/paint |
| + // updates. This function makes sure that the screenshot window is stacked |
| + // on top, so that it hides the content window behind it, and destroys the |
| + // screenshot window when the page is done loading/painting. |
| + // This should be called immediately after initiating the navigation, |
| + // otherwise the overlay may be dismissed prematurely. |
| + void StartObserving(); |
| + |
| + // Creates the overlay window. |
| + void SetupOverlayWindow(); |
| + |
| + // Returns the screenshot for the given direction. |
| + const gfx::Image GetImageForDirection( |
| + OverscrollWindowAnimation::Direction direction) const; |
| + |
| + // Creates a layer to slide on top of the overscroll window. |
| + scoped_ptr<ui::Layer> CreateSlideLayer(); |
| + |
| + // Creates the overscroll window if it does not exist or adds a layer if it |
| + // does. |
| + // TODO find a better name. |
| + scoped_ptr<OverscrollLayerWrapper> CreateLayer(); |
| // Stop observing the page and start the final overlay fade-out animation if |
| // a window-slide isn't in progress and either the page has been painted or |
| // the page-load has completed. |
| void StopObservingIfDone(); |
| + // Fades out the overscroll window and dismisses it. |
| + void FadeOutOverscrollWindow(); |
| + |
| // Creates a layer to be used for window-slide. |offset| is the offset of the |
| // NavigationEntry for the screenshot image to display. |
| ui::Layer* CreateSlideLayer(int offset); |
| - // Overridden from WindowSlider::Delegate: |
| - ui::Layer* CreateBackLayer() override; |
| - ui::Layer* CreateFrontLayer() override; |
| - void OnWindowSlideCompleting() override; |
| - void OnWindowSlideCompleted(scoped_ptr<ui::Layer> layer) override; |
| - void OnWindowSlideAborted() override; |
| - void OnWindowSliderDestroyed() override; |
| + // Overridden from OverscrollWindowAnimation::Delegate: |
| + scoped_ptr<OverscrollLayerWrapper> CreateFrontLayer() override; |
| + scoped_ptr<OverscrollLayerWrapper> CreateBackLayer() override; |
| + void OnOverscrollCompleted( |
| + scoped_ptr<OverscrollLayerWrapper> layer_wrapper) override; |
| + void OnOverscrollCompleting() override; |
| // Overridden from WebContentsObserver: |
| void DidFirstVisuallyNonEmptyPaint() override; |
| void DidStopLoading(RenderViewHost* host) override; |
| - // The WebContents which is being navigated. |
| + // The current overscroll direction. |
| + OverscrollWindowAnimation::Direction direction_; |
| + |
| + // The web contents that are being navigated. |
| WebContentsImpl* web_contents_; |
| - // The screenshot overlay window. |
| + // The window shown on top of the live window for the animations. |
|
mfomitchev
2015/03/05 23:37:06
This comment is confusing:
- live window is a conc
Nina
2015/03/09 15:54:52
Agreed, hopefully the new comment is better.
|
| scoped_ptr<aura::Window> window_; |
| - // This is the WindowDelegate of |window_|. The delegate manages its own |
| - // lifetime (destroys itself when |window_| is destroyed). |
| - aura_extra::ImageWindowDelegate* image_delegate_; |
| - |
| + // True if we have completed loading the page. |
| bool loading_complete_; |
| - bool received_paint_update_; |
| + |
| + // True if we are currently observing for a page load. |
| + bool observing_; |
|
mfomitchev
2015/03/05 23:37:06
I don't think we need observing_ - see my comment
Nina
2015/03/09 15:54:52
Brought back. The reason why it was removed is bec
mfomitchev
2015/03/10 19:25:58
Ah, I see.
|
| // URL of the NavigationEntry we are navigating to. This is needed to |
| // filter on WebContentsObserver callbacks and is used to dismiss the overlay |
| // when the relevant page loads and paints. |
| GURL pending_entry_url_; |
| - // The |WindowSlider| that allows sliding history layers while the page is |
| - // being reloaded. |
| - scoped_ptr<WindowSlider> window_slider_; |
| - |
| - // Layer to be used for the final overlay fadeout animation when the overlay |
| - // is being dismissed. |
| - scoped_ptr<ui::Layer> overlay_dismiss_layer_; |
| + // We own the mechanism to animate the windows. |
| + OverscrollWindowAnimation* owa_; |
|
mfomitchev
2015/03/05 23:37:06
Consider if ONO should own a separate instance of
Nina
2015/03/09 15:54:52
Yeah, this makes a lot of sense and will save many
|
| - // The direction of the in-progress slide (if any). |
| - SlideDirection slide_direction_; |
| + // The window that hosts the web contents. |
| + aura::Window* web_contents_window_; |
| // The LayerDelegate used for the back/front layers during a slide. |
| scoped_ptr<ImageLayerDelegate> layer_delegate_; |
| + // The layer schedule to dismiss. |
| + scoped_ptr<ui::Layer> dismiss_layer_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlay); |
| }; |