| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 else if (layer()) | 945 else if (layer()) |
| 946 layer()->SetVisible(visible); | 946 layer()->SetVisible(visible); |
| 947 visible_ = visible; | 947 visible_ = visible; |
| 948 SchedulePaint(); | 948 SchedulePaint(); |
| 949 if (parent_ && parent_->layout_manager_) | 949 if (parent_ && parent_->layout_manager_) |
| 950 parent_->layout_manager_->OnChildWindowVisibilityChanged(this, visible); | 950 parent_->layout_manager_->OnChildWindowVisibilityChanged(this, visible); |
| 951 | 951 |
| 952 if (delegate_) | 952 if (delegate_) |
| 953 delegate_->OnWindowTargetVisibilityChanged(visible); | 953 delegate_->OnWindowTargetVisibilityChanged(visible); |
| 954 | 954 |
| 955 NotifyWindowVisibilityChanged(this, visible); | 955 NotifyWindowVisibilityChanged(this, visible, false); |
| 956 } | 956 } |
| 957 | 957 |
| 958 #if defined(OS_LINUX) |
| 959 void Window::SetPageVisibility(bool visible) { |
| 960 NotifyWindowVisibilityChanged(this, visible, true); |
| 961 } |
| 962 #endif |
| 963 |
| 958 void Window::SchedulePaint() { | 964 void Window::SchedulePaint() { |
| 959 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height())); | 965 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height())); |
| 960 } | 966 } |
| 961 | 967 |
| 962 void Window::Paint(gfx::Canvas* canvas) { | 968 void Window::Paint(gfx::Canvas* canvas) { |
| 963 if (delegate_) | 969 if (delegate_) |
| 964 delegate_->OnPaint(canvas); | 970 delegate_->OnPaint(canvas); |
| 965 PaintLayerlessChildren(canvas); | 971 PaintLayerlessChildren(canvas); |
| 966 } | 972 } |
| 967 | 973 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 FOR_EACH_OBSERVER(WindowObserver, observers_, | 1281 FOR_EACH_OBSERVER(WindowObserver, observers_, |
| 1276 OnWindowHierarchyChanged(local_params)); | 1282 OnWindowHierarchyChanged(local_params)); |
| 1277 break; | 1283 break; |
| 1278 default: | 1284 default: |
| 1279 NOTREACHED(); | 1285 NOTREACHED(); |
| 1280 break; | 1286 break; |
| 1281 } | 1287 } |
| 1282 } | 1288 } |
| 1283 | 1289 |
| 1284 void Window::NotifyWindowVisibilityChanged(aura::Window* target, | 1290 void Window::NotifyWindowVisibilityChanged(aura::Window* target, |
| 1285 bool visible) { | 1291 bool visible, bool content_visible) { |
| 1286 if (!NotifyWindowVisibilityChangedDown(target, visible)) { | 1292 if (!NotifyWindowVisibilityChangedDown(target, visible, content_visible)) { |
| 1287 return; // |this| has been deleted. | 1293 return; // |this| has been deleted. |
| 1288 } | 1294 } |
| 1289 NotifyWindowVisibilityChangedUp(target, visible); | 1295 NotifyWindowVisibilityChangedUp(target, visible); |
| 1290 } | 1296 } |
| 1291 | 1297 |
| 1292 bool Window::NotifyWindowVisibilityChangedAtReceiver(aura::Window* target, | 1298 bool Window::NotifyWindowVisibilityChangedAtReceiver(aura::Window* target, |
| 1293 bool visible) { | 1299 bool visible, |
| 1300 bool content_visible) { |
| 1294 // |this| may be deleted during a call to OnWindowVisibilityChanged() on one | 1301 // |this| may be deleted during a call to OnWindowVisibilityChanged() on one |
| 1295 // of the observers. We create an local observer for that. In that case we | 1302 // of the observers. We create an local observer for that. In that case we |
| 1296 // exit without further access to any members. | 1303 // exit without further access to any members. |
| 1297 WindowTracker tracker; | 1304 WindowTracker tracker; |
| 1298 tracker.Add(this); | 1305 tracker.Add(this); |
| 1299 FOR_EACH_OBSERVER(WindowObserver, observers_, | 1306 FOR_EACH_OBSERVER(WindowObserver, observers_, |
| 1300 OnWindowVisibilityChanged(target, visible)); | 1307 OnWindowVisibilityChanged(target, visible, |
| 1308 content_visible)); |
| 1301 return tracker.Contains(this); | 1309 return tracker.Contains(this); |
| 1302 } | 1310 } |
| 1303 | 1311 |
| 1304 bool Window::NotifyWindowVisibilityChangedDown(aura::Window* target, | 1312 bool Window::NotifyWindowVisibilityChangedDown(aura::Window* target, |
| 1305 bool visible) { | 1313 bool visible, |
| 1306 if (!NotifyWindowVisibilityChangedAtReceiver(target, visible)) | 1314 bool content_visible) { |
| 1315 if (!NotifyWindowVisibilityChangedAtReceiver(target, visible, |
| 1316 content_visible)) |
| 1307 return false; // |this| was deleted. | 1317 return false; // |this| was deleted. |
| 1308 std::set<const Window*> child_already_processed; | 1318 std::set<const Window*> child_already_processed; |
| 1309 bool child_destroyed = false; | 1319 bool child_destroyed = false; |
| 1310 do { | 1320 do { |
| 1311 child_destroyed = false; | 1321 child_destroyed = false; |
| 1312 for (Window::Windows::const_iterator it = children_.begin(); | 1322 for (Window::Windows::const_iterator it = children_.begin(); |
| 1313 it != children_.end(); ++it) { | 1323 it != children_.end(); ++it) { |
| 1314 if (!child_already_processed.insert(*it).second) | 1324 if (!child_already_processed.insert(*it).second) |
| 1315 continue; | 1325 continue; |
| 1316 if (!(*it)->NotifyWindowVisibilityChangedDown(target, visible)) { | 1326 if (!(*it)->NotifyWindowVisibilityChangedDown(target, visible, |
| 1327 content_visible)) { |
| 1317 // |*it| was deleted, |it| is invalid and |children_| has changed. | 1328 // |*it| was deleted, |it| is invalid and |children_| has changed. |
| 1318 // We exit the current for-loop and enter a new one. | 1329 // We exit the current for-loop and enter a new one. |
| 1319 child_destroyed = true; | 1330 child_destroyed = true; |
| 1320 break; | 1331 break; |
| 1321 } | 1332 } |
| 1322 } | 1333 } |
| 1323 } while (child_destroyed); | 1334 } while (child_destroyed); |
| 1324 return true; | 1335 return true; |
| 1325 } | 1336 } |
| 1326 | 1337 |
| 1327 void Window::NotifyWindowVisibilityChangedUp(aura::Window* target, | 1338 void Window::NotifyWindowVisibilityChangedUp(aura::Window* target, |
| 1328 bool visible) { | 1339 bool visible) { |
| 1329 // Start with the parent as we already notified |this| | 1340 // Start with the parent as we already notified |this| |
| 1330 // in NotifyWindowVisibilityChangedDown. | 1341 // in NotifyWindowVisibilityChangedDown. |
| 1331 for (Window* window = parent(); window; window = window->parent()) { | 1342 for (Window* window = parent(); window; window = window->parent()) { |
| 1332 bool ret = window->NotifyWindowVisibilityChangedAtReceiver(target, visible); | 1343 bool ret = window->NotifyWindowVisibilityChangedAtReceiver(target, visible, |
| 1344 false); |
| 1333 DCHECK(ret); | 1345 DCHECK(ret); |
| 1334 } | 1346 } |
| 1335 } | 1347 } |
| 1336 | 1348 |
| 1337 void Window::NotifyAncestorWindowTransformed(Window* source) { | 1349 void Window::NotifyAncestorWindowTransformed(Window* source) { |
| 1338 FOR_EACH_OBSERVER(WindowObserver, observers_, | 1350 FOR_EACH_OBSERVER(WindowObserver, observers_, |
| 1339 OnAncestorWindowTransformed(source, this)); | 1351 OnAncestorWindowTransformed(source, this)); |
| 1340 for (Window::Windows::const_iterator it = children_.begin(); | 1352 for (Window::Windows::const_iterator it = children_.begin(); |
| 1341 it != children_.end(); ++it) { | 1353 it != children_.end(); ++it) { |
| 1342 (*it)->NotifyAncestorWindowTransformed(source); | 1354 (*it)->NotifyAncestorWindowTransformed(source); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1464 return window; | 1476 return window; |
| 1465 if (offset) | 1477 if (offset) |
| 1466 *offset += window->bounds().OffsetFromOrigin(); | 1478 *offset += window->bounds().OffsetFromOrigin(); |
| 1467 } | 1479 } |
| 1468 if (offset) | 1480 if (offset) |
| 1469 *offset = gfx::Vector2d(); | 1481 *offset = gfx::Vector2d(); |
| 1470 return NULL; | 1482 return NULL; |
| 1471 } | 1483 } |
| 1472 | 1484 |
| 1473 } // namespace aura | 1485 } // namespace aura |
| OLD | NEW |