OLD | NEW |
---|---|
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 "base/memory/scoped_ptr.h" | |
sky
2013/10/01 15:06:43
remove include.
rharrison
2013/10/02 19:02:50
Done.
| |
11 #include "ui/aura/window.h" | |
sky
2013/10/01 15:06:43
Can you forward declare window?
rharrison
2013/10/02 19:02:50
Changed code to have clipping_window_ owned by thi
| |
10 #include "ui/aura/window_observer.h" | 12 #include "ui/aura/window_observer.h" |
13 #include "ui/compositor/layer.h" | |
sky
2013/10/01 15:06:43
Is this needed?
rharrison
2013/10/02 19:02:50
Done.
| |
11 #include "ui/views/controls/native/native_view_host_wrapper.h" | 14 #include "ui/views/controls/native/native_view_host_wrapper.h" |
12 #include "ui/views/views_export.h" | 15 #include "ui/views/views_export.h" |
13 | 16 |
14 namespace views { | 17 namespace views { |
15 | 18 |
16 class NativeViewHost; | 19 class NativeViewHost; |
17 | 20 |
18 // Aura implementation of NativeViewHostWrapper. | 21 // Aura implementation of NativeViewHostWrapper. |
19 class VIEWS_EXPORT NativeViewHostAura : public NativeViewHostWrapper, | 22 class VIEWS_EXPORT NativeViewHostAura : public NativeViewHostWrapper, |
20 public aura::WindowObserver { | 23 public aura::WindowObserver { |
21 public: | 24 public: |
22 explicit NativeViewHostAura(NativeViewHost* host); | 25 explicit NativeViewHostAura(NativeViewHost* host); |
23 virtual ~NativeViewHostAura(); | 26 virtual ~NativeViewHostAura(); |
24 | 27 |
25 // Overridden from NativeViewHostWrapper: | 28 // Overridden from NativeViewHostWrapper: |
26 virtual void NativeViewWillAttach() OVERRIDE; | 29 virtual void AttachNativeView() OVERRIDE; |
27 virtual void NativeViewDetaching(bool destroyed) OVERRIDE; | 30 virtual void NativeViewDetaching(bool destroyed) OVERRIDE; |
28 virtual void AddedToWidget() OVERRIDE; | 31 virtual void AddedToWidget() OVERRIDE; |
29 virtual void RemovedFromWidget() OVERRIDE; | 32 virtual void RemovedFromWidget() OVERRIDE; |
30 virtual void InstallClip(int x, int y, int w, int h) OVERRIDE; | 33 virtual void InstallClip(int x, int y, int w, int h) OVERRIDE; |
31 virtual bool HasInstalledClip() OVERRIDE; | 34 virtual bool HasInstalledClip() OVERRIDE; |
32 virtual void UninstallClip() OVERRIDE; | 35 virtual void UninstallClip() OVERRIDE; |
33 virtual void ShowWidget(int x, int y, int w, int h) OVERRIDE; | 36 virtual void ShowWidget(int x, int y, int w, int h) OVERRIDE; |
34 virtual void HideWidget() OVERRIDE; | 37 virtual void HideWidget() OVERRIDE; |
35 virtual void SetFocus() OVERRIDE; | 38 virtual void SetFocus() OVERRIDE; |
36 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; | 39 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; |
37 | 40 |
38 private: | 41 private: |
42 friend class NativeViewHostAuraTest; | |
43 | |
39 // Overridden from aura::WindowObserver: | 44 // Overridden from aura::WindowObserver: |
40 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; | 45 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; |
41 | 46 |
47 // Calculates the origin of the native view for the fast resize path, so it | |
48 // can be clipped correctly. This value is affected by the current gravity | |
49 // being applied. The formula for this calulation is: | |
50 // | |
51 // x' = width_scaling_factor * (content_width - clip_width) | |
52 // y' = height_scaling_factor * (content_heigth - clip_height) | |
53 // | |
54 // , where the scaling factors are either 0, 0.5, or 1.0 depending on the | |
55 // current gravity. | |
56 gfx::Point CalculateNativeViewOrigin(const gfx::Rect& input_rect, | |
57 const gfx::Rect& native_rect) const; | |
58 | |
59 // Reparents the native view with the clipping window existing between it and | |
60 // its old parent, so that the fast resize path works. | |
61 void AddClippingWindow(); | |
62 | |
63 // If the native view has been reparented via AddClippingWindow, this call | |
64 // undoes it. | |
65 void RemoveClippingWindow(); | |
66 | |
42 // Our associated NativeViewHost. | 67 // Our associated NativeViewHost. |
43 NativeViewHost* host_; | 68 NativeViewHost* host_; |
44 | 69 |
45 // Have we installed a clip region? | 70 // Have we installed a clip region? |
46 bool installed_clip_; | 71 bool installed_clip_; |
47 | 72 |
73 // Window that exists between the native view and the parent that allows for | |
74 // clipping to occur. | |
75 aura::Window* clipping_window_; // non-owned | |
76 | |
77 // The bounds of the content layer before clipping occurs on the fast resize | |
78 // path. This is restored when the clip is uninstalled. This is done since the | |
79 // contents needs to be places relatively to the clip that is about to occur. | |
80 gfx::Rect orig_bounds_; | |
81 | |
48 DISALLOW_COPY_AND_ASSIGN(NativeViewHostAura); | 82 DISALLOW_COPY_AND_ASSIGN(NativeViewHostAura); |
49 }; | 83 }; |
50 | 84 |
51 } // namespace views | 85 } // namespace views |
52 | 86 |
53 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_ | 87 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_ |
OLD | NEW |