From 048243d548af52b47266e7c5bb8236a73cd196af Mon Sep 17 00:00:00 2001 From: oshima Date: Tue, 7 Oct 2014 18:29:00 -0700 Subject: [PATCH] Don't fill menu window BUG=411878 TEST=covered by test. TBR=ben@chromium.org Review URL: https://codereview.chromium.org/640503002 Cr-Commit-Position: refs/heads/master@{#298632} --- athena/util/DEPS | 1 + athena/util/fill_layout_manager.cc | 18 +++++++++++++++--- athena/util/fill_layout_manager_unittest.cc | 22 ++++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/athena/util/DEPS b/athena/util/DEPS index c30254d30f86..6f69bbefd71d 100644 --- a/athena/util/DEPS +++ b/athena/util/DEPS @@ -3,4 +3,5 @@ include_rules = [ "+ui/aura", "+ui/compositor", "+ui/views", + "+ui/wm/public", ] diff --git a/athena/util/fill_layout_manager.cc b/athena/util/fill_layout_manager.cc index 8ee546b11add..78285d5d5c0a 100644 --- a/athena/util/fill_layout_manager.cc +++ b/athena/util/fill_layout_manager.cc @@ -8,6 +8,15 @@ #include "ui/aura/window.h" namespace athena { +namespace { + +// TODO(oshima): Implement real window/layout manager. crbug.com/388362. +bool ShouldFill(aura::Window* window) { + return window->type() != ui::wm::WINDOW_TYPE_MENU && + window->type() != ui::wm::WINDOW_TYPE_TOOLTIP; +} + +} // namespace FillLayoutManager::FillLayoutManager(aura::Window* container) : container_(container) { @@ -23,12 +32,14 @@ void FillLayoutManager::OnWindowResized() { container_->children().begin(); iter != container_->children().end(); ++iter) { - SetChildBoundsDirect(*iter, full_bounds); + if (ShouldFill(*iter)) + SetChildBoundsDirect(*iter, full_bounds); } } void FillLayoutManager::OnWindowAddedToLayout(aura::Window* child) { - SetChildBoundsDirect(child, (gfx::Rect(container_->bounds().size()))); + if (ShouldFill(child)) + SetChildBoundsDirect(child, (gfx::Rect(container_->bounds().size()))); } void FillLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { @@ -40,7 +51,8 @@ void FillLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child, } void FillLayoutManager::SetChildBounds(aura::Window* child, const gfx::Rect& requested_bounds) { - // Ignore SetBounds request. + if (!ShouldFill(child)) + SetChildBoundsDirect(child, requested_bounds); } } // namespace athena diff --git a/athena/util/fill_layout_manager_unittest.cc b/athena/util/fill_layout_manager_unittest.cc index e183efeb14ca..01d5d0d4f599 100644 --- a/athena/util/fill_layout_manager_unittest.cc +++ b/athena/util/fill_layout_manager_unittest.cc @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/aura/window.h" +#include "ui/wm/public/window_types.h" namespace athena { @@ -27,6 +28,27 @@ TEST(FillLayoutManagerTest, ChildWindowSizedCorrectly) { parent->SetBounds(gfx::Rect(0, 0, 100, 200)); EXPECT_EQ(child->bounds().size().ToString(), parent->bounds().size().ToString()); + + // Menu and tooltip should not be filled. + scoped_ptr menu(new aura::Window(NULL)); + menu->SetType(ui::wm::WINDOW_TYPE_MENU); + menu->SetBounds(gfx::Rect(0, 0, 5, 10)); + + EXPECT_EQ(menu->bounds().ToString(), "0,0 5x10"); + parent->AddChild(menu.get()); + EXPECT_EQ(menu->bounds().ToString(), "0,0 5x10"); + menu->SetBounds(gfx::Rect(0, 0, 100, 200)); + EXPECT_EQ(menu->bounds().ToString(), "0,0 100x200"); + + scoped_ptr tooltip(new aura::Window(NULL)); + tooltip->SetType(ui::wm::WINDOW_TYPE_TOOLTIP); + tooltip->SetBounds(gfx::Rect(0, 0, 5, 10)); + + EXPECT_EQ(tooltip->bounds().ToString(), "0,0 5x10"); + parent->AddChild(tooltip.get()); + EXPECT_EQ(tooltip->bounds().ToString(), "0,0 5x10"); + tooltip->SetBounds(gfx::Rect(0, 0, 100, 200)); + EXPECT_EQ(tooltip->bounds().ToString(), "0,0 100x200"); } } // namespace athena -- 2.11.4.GIT