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

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

Issue 895543005: Refactor GestureNavigation to eliminate code redundancy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Mikhail's comments 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_layer_wrapper.h
diff --git a/content/browser/web_contents/aura/overscroll_layer_wrapper.h b/content/browser/web_contents/aura/overscroll_layer_wrapper.h
new file mode 100644
index 0000000000000000000000000000000000000000..c0ce1bffab86e5ab1ccec0ddb3c33a9e5b9b2511
--- /dev/null
+++ b/content/browser/web_contents/aura/overscroll_layer_wrapper.h
@@ -0,0 +1,62 @@
+// 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_LAYER_WRAPPER_H_
+#define CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_LAYER_WRAPPER_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "ui/aura/window.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/image/image.h"
+#include "ui/gfx/transform.h"
+
+namespace ui {
+class Layer;
+class LayerAnimator;
+}
+
+namespace content {
+
+class ImageLayerDelegate;
+class ShadowLayerDelegate;
+
+// Wraps a window or a layer, exposing some of their common API to allow
+// overscroll animations for both cases. If wrapping a layer, assumes its
+// ownership.
+class OverscrollLayerWrapper {
+ public:
+ // Takes a pointer to the |window|.
+ explicit OverscrollLayerWrapper(scoped_ptr<aura::Window> window);
+
+ // Assumes ownership of the |layer|.
+ explicit OverscrollLayerWrapper(scoped_ptr<ui::Layer> layer);
+
+ ~OverscrollLayerWrapper();
+
+ // Returns the wrapped |layer_| or the |window_| layer.
+ ui::Layer* layer() { return layer_ ? layer_.get() : window_->layer(); }
+
+ // Returns true if a window is being wrapped.
+ bool has_window() { return !!window_; }
+
+ // Transfers ownership of the wrapped |layer_|.
+ scoped_ptr<ui::Layer> AcquireLayer();
+
+ // Transfers ownership of the wrapped |window_|.
+ scoped_ptr<aura::Window> AcquireWindow();
+
+ // Returns the wrapped target layer bounds.
+ gfx::Rect GetBounds();
+
+ private:
+ // The wrapped layer.
+ scoped_ptr<ui::Layer> layer_;
+
+ // The wrapped window.
+ scoped_ptr<aura::Window> window_;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_LAYER_WRAPPER_H_

Powered by Google App Engine
This is Rietveld 408576698