Index: ui/views/controls/native/native_view_host_aura.cc |
diff --git a/ui/views/controls/native/native_view_host_aura.cc b/ui/views/controls/native/native_view_host_aura.cc |
index f690f0574fae9569ff7a6eb73c9470770e691d34..2b1fcd0a60cf136fde0606bb7ce2539116fbc178 100644 |
--- a/ui/views/controls/native/native_view_host_aura.cc |
+++ b/ui/views/controls/native/native_view_host_aura.cc |
@@ -7,6 +7,7 @@ |
#include "base/logging.h" |
#include "ui/aura/client/aura_constants.h" |
#include "ui/aura/client/focus_client.h" |
+#include "ui/aura/layout_manager.h" |
#include "ui/aura/window.h" |
#include "ui/base/cursor/cursor.h" |
#include "ui/views/controls/native/native_view_host.h" |
@@ -15,10 +16,37 @@ |
namespace views { |
+namespace { |
+ |
+// This layout manager positions children relative to their grandparent's |
+// coordinate system. |
+class OffsettingLayoutManager : public aura::LayoutManager { |
sky
2014/07/17 21:46:03
Seems heavyweight to create this rather than conve
Evan Stade
2014/07/17 22:50:35
yes, but converting on 136 doesn't work for the au
|
+ public: |
+ OffsettingLayoutManager() {} |
+ virtual ~OffsettingLayoutManager() {} |
+ |
+ virtual void OnWindowResized() OVERRIDE {} |
+ virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE {} |
+ virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {} |
+ virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {} |
+ virtual void OnChildWindowVisibilityChanged(aura::Window* child, |
+ bool visible) OVERRIDE {} |
+ virtual void SetChildBounds(aura::Window* child, |
+ const gfx::Rect& requested_bounds) OVERRIDE { |
+ gfx::Point origin = requested_bounds.origin(); |
+ gfx::Point this_origin = child->parent()->GetTargetBounds().origin(); |
+ origin.Offset(-this_origin.x(), -this_origin.y()); |
+ SetChildBoundsDirect(child, gfx::Rect(origin, requested_bounds.size())); |
+ } |
+}; |
+ |
+} // namespace |
+ |
NativeViewHostAura::NativeViewHostAura(NativeViewHost* host) |
: host_(host), |
clipping_window_(NULL) { |
clipping_window_.Init(aura::WINDOW_LAYER_NOT_DRAWN); |
+ clipping_window_.SetLayoutManager(new OffsettingLayoutManager()); |
clipping_window_.set_owned_by_parent(false); |
clipping_window_.SetName("NativeViewHostAuraClip"); |
clipping_window_.layer()->SetMasksToBounds(true); |
@@ -105,9 +133,7 @@ void NativeViewHostAura::ShowWidget(int x, int y, int w, int h) { |
clipping_window_.SetBounds(clip_rect_ ? *clip_rect_ |
: gfx::Rect(x, y, w, h)); |
- gfx::Point clip_offset = clipping_window_.bounds().origin(); |
- host_->native_view()->SetBounds( |
- gfx::Rect(x - clip_offset.x(), y - clip_offset.y(), width, height)); |
+ host_->native_view()->SetBounds(gfx::Rect(x, y, width, height)); |
host_->native_view()->Show(); |
} |