Disable TabDragController tests that fail with a real compositor.
[chromium-blink-merge.git] / ash / wm / status_area_layout_manager.cc
blobd9e0424d24065900d881001e7784debcbec35ced
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
3 // found in the LICENSE file.
5 #include "ash/wm/status_area_layout_manager.h"
7 #include "ash/shelf/shelf_layout_manager.h"
8 #include "ash/shelf/shelf_widget.h"
9 #include "ash/system/status_area_widget.h"
10 #include "base/auto_reset.h"
11 #include "ui/aura/window.h"
12 #include "ui/views/widget/widget.h"
14 namespace ash {
15 namespace internal {
17 ////////////////////////////////////////////////////////////////////////////////
18 // StatusAreaLayoutManager, public:
20 StatusAreaLayoutManager::StatusAreaLayoutManager(ShelfWidget* shelf)
21 : in_layout_(false),
22 shelf_(shelf) {
25 StatusAreaLayoutManager::~StatusAreaLayoutManager() {
28 ////////////////////////////////////////////////////////////////////////////////
29 // StatusAreaLayoutManager, aura::LayoutManager implementation:
31 void StatusAreaLayoutManager::OnWindowResized() {
32 LayoutStatusArea();
35 void StatusAreaLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
38 void StatusAreaLayoutManager::OnWillRemoveWindowFromLayout(
39 aura::Window* child) {
42 void StatusAreaLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
45 void StatusAreaLayoutManager::OnChildWindowVisibilityChanged(
46 aura::Window* child, bool visible) {
49 void StatusAreaLayoutManager::SetChildBounds(
50 aura::Window* child,
51 const gfx::Rect& requested_bounds) {
52 // Only need to have the shelf do a layout if the child changing is the status
53 // area and the shelf isn't in the process of doing a layout.
54 if (child != shelf_->status_area_widget()->GetNativeView() || in_layout_) {
55 SetChildBoundsDirect(child, requested_bounds);
56 return;
59 // If the size matches, no need to do anything. We don't check the location as
60 // that is managed by the shelf.
61 if (requested_bounds == child->bounds())
62 return;
64 SetChildBoundsDirect(child, requested_bounds);
65 LayoutStatusArea();
68 ////////////////////////////////////////////////////////////////////////////////
69 // StatusAreaLayoutManager, private:
71 void StatusAreaLayoutManager::LayoutStatusArea() {
72 // Shelf layout manager may be already doing layout.
73 if (shelf_->shelf_layout_manager()->updating_bounds())
74 return;
76 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
77 shelf_->shelf_layout_manager()->LayoutShelf();
80 } // namespace internal
81 } // namespace ash