Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Unified Diff: ui/views/controls/native/native_view_host_aura.cc

Issue 397293005: Fix positioning of children of NativeViewHostAura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another test Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ed0dab43f55b6d0f35788bcd7bafce5f6de73796 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 popups relative to the screen
+// coordinate system.
+class PopupAwareLayoutManager : public aura::LayoutManager {
+ public:
+ PopupAwareLayoutManager() {}
+ virtual ~PopupAwareLayoutManager() {}
+
+ 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::Rect bounds = requested_bounds;
+ if (child->type() == ui::wm::WINDOW_TYPE_POPUP)
sky 2014/07/22 13:12:27 Ok, I get it now. But you need a comment as to why
Evan Stade 2014/07/22 21:45:30 But this isn't necessary any more (you've commente
sky 2014/07/22 21:52:33 SOrry. Yes. I want a comment there.
+ bounds.Offset(-child->parent()->GetBoundsInScreen().OffsetFromOrigin());
+ SetChildBoundsDirect(child, bounds);
+ }
+};
+
+} // namespace
+
NativeViewHostAura::NativeViewHostAura(NativeViewHost* host)
: host_(host),
clipping_window_(NULL) {
clipping_window_.Init(aura::WINDOW_LAYER_NOT_DRAWN);
+ clipping_window_.SetLayoutManager(new PopupAwareLayoutManager());
clipping_window_.set_owned_by_parent(false);
clipping_window_.SetName("NativeViewHostAuraClip");
clipping_window_.layer()->SetMasksToBounds(true);

Powered by Google App Engine
This is Rietveld 408576698