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

Side by Side Diff: ui/views/controls/native/native_view_host_aura.h

Issue 48113013: Re-Reland: Implement features in NativeViewHostAura for scroll end effect Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Responded to sky's comments Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_ 5 #ifndef UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_
6 #define UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_ 6 #define UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "ui/aura/window.h"
10 #include "ui/aura/window_observer.h" 11 #include "ui/aura/window_observer.h"
11 #include "ui/views/controls/native/native_view_host_wrapper.h" 12 #include "ui/views/controls/native/native_view_host_wrapper.h"
12 #include "ui/views/views_export.h" 13 #include "ui/views/views_export.h"
13 14
14 namespace views { 15 namespace views {
15 16
16 class NativeViewHost; 17 class NativeViewHost;
18 class NativeViewHostAura;
19
20 // Watches for the clipping window to enter its destructor, so it can clear the
21 // NVHA's reference to the clipping window. The clipping window while part of
22 // the window hierarchy is not owned by the NVHA, thus may be destroyed without
sky 2013/11/20 21:10:34 Actually, this begs the question why not make the
rharrison 2013/11/21 18:38:00 Done.
23 // direction action from the NHVA.
24 class ClippingWindowObserver : public aura::WindowObserver {
25 public:
26 explicit ClippingWindowObserver(NativeViewHostAura* host);
27 virtual ~ClippingWindowObserver();
28
29 void SetClippingWindow(aura::Window* window);
30
31 // Overridden from aura::WindowObserver:
32 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
33
34 private:
35 NativeViewHostAura* host_;
36 aura::Window* clipping_window_;
37
38 DISALLOW_COPY_AND_ASSIGN(ClippingWindowObserver);
39 };
17 40
18 // Aura implementation of NativeViewHostWrapper. 41 // Aura implementation of NativeViewHostWrapper.
19 class VIEWS_EXPORT NativeViewHostAura : public NativeViewHostWrapper, 42 class VIEWS_EXPORT NativeViewHostAura : public NativeViewHostWrapper,
20 public aura::WindowObserver { 43 public aura::WindowObserver {
21 public: 44 public:
22 explicit NativeViewHostAura(NativeViewHost* host); 45 explicit NativeViewHostAura(NativeViewHost* host);
23 virtual ~NativeViewHostAura(); 46 virtual ~NativeViewHostAura();
24 47
25 // Overridden from NativeViewHostWrapper: 48 // Overridden from NativeViewHostWrapper:
26 virtual void NativeViewWillAttach() OVERRIDE; 49 virtual void AttachNativeView() OVERRIDE;
27 virtual void NativeViewDetaching(bool destroyed) OVERRIDE; 50 virtual void NativeViewDetaching(bool destroyed) OVERRIDE;
28 virtual void AddedToWidget() OVERRIDE; 51 virtual void AddedToWidget() OVERRIDE;
29 virtual void RemovedFromWidget() OVERRIDE; 52 virtual void RemovedFromWidget() OVERRIDE;
30 virtual void InstallClip(int x, int y, int w, int h) OVERRIDE; 53 virtual void InstallClip(int x, int y, int w, int h) OVERRIDE;
31 virtual bool HasInstalledClip() OVERRIDE; 54 virtual bool HasInstalledClip() OVERRIDE;
32 virtual void UninstallClip() OVERRIDE; 55 virtual void UninstallClip() OVERRIDE;
33 virtual void ShowWidget(int x, int y, int w, int h) OVERRIDE; 56 virtual void ShowWidget(int x, int y, int w, int h) OVERRIDE;
34 virtual void HideWidget() OVERRIDE; 57 virtual void HideWidget() OVERRIDE;
35 virtual void SetFocus() OVERRIDE; 58 virtual void SetFocus() OVERRIDE;
36 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; 59 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE;
37 60
38 private: 61 private:
62 friend class ClippingWindowObserver;
63 friend class NativeViewHostAuraTest;
64
39 // Overridden from aura::WindowObserver: 65 // Overridden from aura::WindowObserver:
40 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; 66 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
41 67
68 // Calculates the origin of the native view for the fast resize path, so it
69 // can be clipped correctly. This value is affected by the current gravity
70 // being applied. The formula for this calulation is:
71 //
72 // x' = width_scaling_factor * (content_width - clip_width)
73 // y' = height_scaling_factor * (content_heigth - clip_height)
74 //
75 // , where the scaling factors are either 0, 0.5, or 1.0 depending on the
76 // current gravity.
77 gfx::Point CalculateNativeViewOrigin(const gfx::Rect& input_rect,
78 const gfx::Rect& native_rect) const;
79
80
81 // Reparents the native view with the clipping window existing between it and
82 // its old parent, so that the fast resize path works. |clipping_window_| is
83 // created by this call.
84 void AddClippingWindow();
85
86 // If the native view has been reparented via AddClippingWindow, this call
87 // undoes it. |clipping_window_| is destroyed by this call.
88 void RemoveClippingWindow();
89
90 // Update the positioning of the clipping window and the attached native
91 // view. The native view is a child of the clipping window, so is positioned
92 // relative to it.
93 void UpdateClippingWindow();
94
42 // Our associated NativeViewHost. 95 // Our associated NativeViewHost.
43 NativeViewHost* host_; 96 NativeViewHost* host_;
44 97
45 // Have we installed a clip region? 98 // Have we installed a clip region?
46 bool installed_clip_; 99 bool installed_clip_;
47 100
101 // Window that exists between the native view and the parent that allows for
102 // clipping to occur.
103 aura::Window* clipping_window_;
104 ClippingWindowObserver clipping_window_observer_;
105
106 // The bounds of the content layer before any clipping actions occur. This is
107 // restored when the clip is uninstalled. This value should be in the
108 // coordinate space of host_->GetWidget().
109 gfx::Rect orig_bounds_;
110
111 // The bounds of the clipping window. When no clip is installed |orig_bounds_|
112 // and |clip_rect_| should be equal. When clip is installed |clip_rect_| is
113 // manipulated to position of the clipping window in
114 // UpdateClippingWindow. This value should be in the coordinate space of
115 // host_->GetWidget().
116 gfx::Rect clip_rect_;
117
48 DISALLOW_COPY_AND_ASSIGN(NativeViewHostAura); 118 DISALLOW_COPY_AND_ASSIGN(NativeViewHostAura);
49 }; 119 };
50 120
51 } // namespace views 121 } // namespace views
52 122
53 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_ 123 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_
OLDNEW
« no previous file with comments | « ui/views/controls/native/native_view_host.cc ('k') | ui/views/controls/native/native_view_host_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698