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..dffb8dfe17ce24d55802a2cdc98540e82710997b 100644 |
| --- a/ui/views/controls/native/native_view_host_aura.h |
| +++ b/ui/views/controls/native/native_view_host_aura.h |
| @@ -7,6 +7,8 @@ |
| #include "base/basictypes.h" |
| #include "base/compiler_specific.h" |
| +#include "base/memory/scoped_ptr.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 +16,7 @@ |
| namespace views { |
| class NativeViewHost; |
| +class ClippingWindowObserver; |
| // Aura implementation of NativeViewHostWrapper. |
| class VIEWS_EXPORT NativeViewHostAura : public NativeViewHostWrapper, |
| @@ -23,7 +26,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 +39,63 @@ 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_; |
| + |
| + scoped_ptr<ClippingWindowObserver> clipping_window_observer_; |
|
sky
2013/11/19 21:00:09
AFAICT this is never NULL, as such why bother with
rharrison
2013/11/20 15:50:13
Done.
|
| + |
| + // 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); |
| }; |