| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ui/views/controls/native/native_view_host_aura.h" | 5 #include "ui/views/controls/native/native_view_host_aura.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/aura/client/aura_constants.h" | 8 #include "ui/aura/client/aura_constants.h" |
| 9 #include "ui/aura/client/focus_client.h" | 9 #include "ui/aura/client/focus_client.h" |
| 10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| 11 #include "ui/aura/window_delegate.h" | 11 #include "ui/aura/window_delegate.h" |
| 12 #include "ui/base/cursor/cursor.h" | 12 #include "ui/base/cursor/cursor.h" |
| 13 #include "ui/base/hit_test.h" | 13 #include "ui/base/hit_test.h" |
| 14 #include "ui/views/controls/native/native_view_host.h" | 14 #include "ui/views/controls/native/native_view_host.h" |
| 15 #include "ui/views/view_constants_aura.h" | 15 #include "ui/views/view_constants_aura.h" |
| 16 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 17 | 17 |
| 18 namespace views { | 18 namespace views { |
| 19 | 19 |
| 20 class NativeViewHostAura::ClippingWindowDelegate : public aura::WindowDelegate { | 20 class NativeViewHostAura::ClippingWindowDelegate : public aura::WindowDelegate { |
| 21 public: | 21 public: |
| 22 ClippingWindowDelegate() : native_view_(NULL) {} | 22 ClippingWindowDelegate() : native_view_(NULL) {} |
| 23 virtual ~ClippingWindowDelegate() {} | 23 ~ClippingWindowDelegate() override {} |
| 24 | 24 |
| 25 void set_native_view(aura::Window* native_view) { | 25 void set_native_view(aura::Window* native_view) { |
| 26 native_view_ = native_view; | 26 native_view_ = native_view; |
| 27 } | 27 } |
| 28 | 28 |
| 29 virtual gfx::Size GetMinimumSize() const override { return gfx::Size(); } | 29 gfx::Size GetMinimumSize() const override { return gfx::Size(); } |
| 30 virtual gfx::Size GetMaximumSize() const override { return gfx::Size(); } | 30 gfx::Size GetMaximumSize() const override { return gfx::Size(); } |
| 31 virtual void OnBoundsChanged(const gfx::Rect& old_bounds, | 31 void OnBoundsChanged(const gfx::Rect& old_bounds, |
| 32 const gfx::Rect& new_bounds) override {} | 32 const gfx::Rect& new_bounds) override {} |
| 33 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) override { | 33 gfx::NativeCursor GetCursor(const gfx::Point& point) override { |
| 34 return gfx::kNullCursor; | 34 return gfx::kNullCursor; |
| 35 } | 35 } |
| 36 virtual int GetNonClientComponent(const gfx::Point& point) const override { | 36 int GetNonClientComponent(const gfx::Point& point) const override { |
| 37 return HTCLIENT; | 37 return HTCLIENT; |
| 38 } | 38 } |
| 39 virtual bool ShouldDescendIntoChildForEventHandling( | 39 bool ShouldDescendIntoChildForEventHandling( |
| 40 aura::Window* child, | 40 aura::Window* child, |
| 41 const gfx::Point& location) override { return true; } | 41 const gfx::Point& location) override { |
| 42 virtual bool CanFocus() override { | 42 return true; |
| 43 } |
| 44 bool CanFocus() override { |
| 43 // Ask the hosted native view's delegate because directly calling | 45 // Ask the hosted native view's delegate because directly calling |
| 44 // aura::Window::CanFocus() will call back into this when checking whether | 46 // aura::Window::CanFocus() will call back into this when checking whether |
| 45 // parents can focus. | 47 // parents can focus. |
| 46 return native_view_ && native_view_->delegate() | 48 return native_view_ && native_view_->delegate() |
| 47 ? native_view_->delegate()->CanFocus() | 49 ? native_view_->delegate()->CanFocus() |
| 48 : true; | 50 : true; |
| 49 } | 51 } |
| 50 virtual void OnCaptureLost() override {} | 52 void OnCaptureLost() override {} |
| 51 virtual void OnPaint(gfx::Canvas* canvas) override {} | 53 void OnPaint(gfx::Canvas* canvas) override {} |
| 52 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) override {} | 54 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} |
| 53 virtual void OnWindowDestroying(aura::Window* window) override {} | 55 void OnWindowDestroying(aura::Window* window) override {} |
| 54 virtual void OnWindowDestroyed(aura::Window* window) override {} | 56 void OnWindowDestroyed(aura::Window* window) override {} |
| 55 virtual void OnWindowTargetVisibilityChanged(bool visible) override {} | 57 void OnWindowTargetVisibilityChanged(bool visible) override {} |
| 56 virtual bool HasHitTestMask() const override { return false; } | 58 bool HasHitTestMask() const override { return false; } |
| 57 virtual void GetHitTestMask(gfx::Path* mask) const override {} | 59 void GetHitTestMask(gfx::Path* mask) const override {} |
| 58 | 60 |
| 59 private: | 61 private: |
| 60 aura::Window* native_view_; | 62 aura::Window* native_view_; |
| 61 }; | 63 }; |
| 62 | 64 |
| 63 NativeViewHostAura::NativeViewHostAura(NativeViewHost* host) | 65 NativeViewHostAura::NativeViewHostAura(NativeViewHost* host) |
| 64 : host_(host), | 66 : host_(host), |
| 65 clipping_window_delegate_(new ClippingWindowDelegate()), | 67 clipping_window_delegate_(new ClippingWindowDelegate()), |
| 66 clipping_window_(clipping_window_delegate_.get()) { | 68 clipping_window_(clipping_window_delegate_.get()) { |
| 67 // Set the type so descendant views (including popups) get positioned | 69 // Set the type so descendant views (including popups) get positioned |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } else { | 228 } else { |
| 227 clipping_window_.RemoveChild(host_->native_view()); | 229 clipping_window_.RemoveChild(host_->native_view()); |
| 228 } | 230 } |
| 229 host_->native_view()->SetBounds(clipping_window_.bounds()); | 231 host_->native_view()->SetBounds(clipping_window_.bounds()); |
| 230 } | 232 } |
| 231 if (clipping_window_.parent()) | 233 if (clipping_window_.parent()) |
| 232 clipping_window_.parent()->RemoveChild(&clipping_window_); | 234 clipping_window_.parent()->RemoveChild(&clipping_window_); |
| 233 } | 235 } |
| 234 | 236 |
| 235 } // namespace views | 237 } // namespace views |
| OLD | NEW |