summaryrefslogtreecommitdiffstats
path: root/athena/util
diff options
context:
space:
mode:
authoroshima <oshima@chromium.org>2014-10-07 18:29:00 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-08 01:29:41 +0000
commit048243d548af52b47266e7c5bb8236a73cd196af (patch)
treef05edac627a00ce5cdb5548526b72fd67caf638d /athena/util
parent59cd81de01eeb5fe05cba9fc2e50c379bcabdf4e (diff)
downloadchromium_src-048243d548af52b47266e7c5bb8236a73cd196af.zip
chromium_src-048243d548af52b47266e7c5bb8236a73cd196af.tar.gz
chromium_src-048243d548af52b47266e7c5bb8236a73cd196af.tar.bz2
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}
Diffstat (limited to 'athena/util')
-rw-r--r--athena/util/DEPS1
-rw-r--r--athena/util/fill_layout_manager.cc18
-rw-r--r--athena/util/fill_layout_manager_unittest.cc22
3 files changed, 38 insertions, 3 deletions
diff --git a/athena/util/DEPS b/athena/util/DEPS
index c30254d..6f69bbe 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 8ee546b..78285d5 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 e183efe..01d5d0d 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<aura::Window> 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<aura::Window> 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