Chromium Code Reviews| Index: ui/views/controls/native/native_view_host_aura.h |
| diff --git a/ui/views/controls/native/native_view_host_aura.h b/ui/views/controls/native/native_view_host_aura.h |
| index eba4b99c9fdf2c0b5cb45c7c571e7b5dc0aca9cc..4f0c5e3b7078a72dd177454387b6ad033f77c896 100644 |
| --- a/ui/views/controls/native/native_view_host_aura.h |
| +++ b/ui/views/controls/native/native_view_host_aura.h |
| @@ -7,6 +7,7 @@ |
| #include "base/basictypes.h" |
| #include "base/compiler_specific.h" |
| +#include "ui/aura/window.h" |
| #include "ui/aura/window_observer.h" |
| #include "ui/views/controls/native/native_view_host_wrapper.h" |
| #include "ui/views/views_export.h" |
| @@ -14,6 +15,28 @@ |
| namespace views { |
| class NativeViewHost; |
| +class NativeViewHostAura; |
| + |
| +// Watches for the clipping window to enter its destructor, so it can clear the |
| +// NVHA's reference to the clipping window. The clipping window while part of |
| +// 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.
|
| +// direction action from the NHVA. |
| +class ClippingWindowObserver : public aura::WindowObserver { |
| + public: |
| + explicit ClippingWindowObserver(NativeViewHostAura* host); |
| + virtual ~ClippingWindowObserver(); |
| + |
| + void SetClippingWindow(aura::Window* window); |
| + |
| + // Overridden from aura::WindowObserver: |
| + virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
| + |
| + private: |
| + NativeViewHostAura* host_; |
| + aura::Window* clipping_window_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ClippingWindowObserver); |
| +}; |
| // Aura implementation of NativeViewHostWrapper. |
| class VIEWS_EXPORT NativeViewHostAura : public NativeViewHostWrapper, |
| @@ -23,7 +46,7 @@ class VIEWS_EXPORT NativeViewHostAura : public NativeViewHostWrapper, |
| virtual ~NativeViewHostAura(); |
| // Overridden from NativeViewHostWrapper: |
| - virtual void NativeViewWillAttach() OVERRIDE; |
| + virtual void AttachNativeView() OVERRIDE; |
| virtual void NativeViewDetaching(bool destroyed) OVERRIDE; |
| virtual void AddedToWidget() OVERRIDE; |
| virtual void RemovedFromWidget() OVERRIDE; |
| @@ -36,15 +59,62 @@ class VIEWS_EXPORT NativeViewHostAura : public NativeViewHostWrapper, |
| virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; |
| private: |
| + friend class ClippingWindowObserver; |
| + friend class NativeViewHostAuraTest; |
| + |
| // Overridden from aura::WindowObserver: |
| virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; |
| + // Calculates the origin of the native view for the fast resize path, so it |
| + // can be clipped correctly. This value is affected by the current gravity |
| + // being applied. The formula for this calulation is: |
| + // |
| + // x' = width_scaling_factor * (content_width - clip_width) |
| + // y' = height_scaling_factor * (content_heigth - clip_height) |
| + // |
| + // , where the scaling factors are either 0, 0.5, or 1.0 depending on the |
| + // current gravity. |
| + gfx::Point CalculateNativeViewOrigin(const gfx::Rect& input_rect, |
| + const gfx::Rect& native_rect) const; |
| + |
| + |
| + // Reparents the native view with the clipping window existing between it and |
| + // its old parent, so that the fast resize path works. |clipping_window_| is |
| + // created by this call. |
| + void AddClippingWindow(); |
| + |
| + // If the native view has been reparented via AddClippingWindow, this call |
| + // undoes it. |clipping_window_| is destroyed by this call. |
| + void RemoveClippingWindow(); |
| + |
| + // Update the positioning of the clipping window and the attached native |
| + // view. The native view is a child of the clipping window, so is positioned |
| + // relative to it. |
| + void UpdateClippingWindow(); |
| + |
| // Our associated NativeViewHost. |
| NativeViewHost* host_; |
| // Have we installed a clip region? |
| bool installed_clip_; |
| + // Window that exists between the native view and the parent that allows for |
| + // clipping to occur. |
| + aura::Window* clipping_window_; |
| + ClippingWindowObserver clipping_window_observer_; |
| + |
| + // The bounds of the content layer before any clipping actions occur. This is |
| + // restored when the clip is uninstalled. This value should be in the |
| + // coordinate space of host_->GetWidget(). |
| + gfx::Rect orig_bounds_; |
| + |
| + // The bounds of the clipping window. When no clip is installed |orig_bounds_| |
| + // and |clip_rect_| should be equal. When clip is installed |clip_rect_| is |
| + // manipulated to position of the clipping window in |
| + // UpdateClippingWindow. This value should be in the coordinate space of |
| + // host_->GetWidget(). |
| + gfx::Rect clip_rect_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(NativeViewHostAura); |
| }; |