OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 bool Window::HasFocus() const { | 366 bool Window::HasFocus() const { |
367 const internal::FocusManager* focus_manager = GetFocusManager(); | 367 const internal::FocusManager* focus_manager = GetFocusManager(); |
368 return focus_manager ? focus_manager->IsFocusedWindow(this) : false; | 368 return focus_manager ? focus_manager->IsFocusedWindow(this) : false; |
369 } | 369 } |
370 | 370 |
371 // For a given window, we determine its focusability by inspecting each sibling | 371 // For a given window, we determine its focusability by inspecting each sibling |
372 // after it (i.e. drawn in front of it in the z-order) to see if it stops | 372 // after it (i.e. drawn in front of it in the z-order) to see if it stops |
373 // propagation of events that would otherwise be targeted at windows behind it. | 373 // propagation of events that would otherwise be targeted at windows behind it. |
374 // We then perform this same check on every window up to the root. | 374 // We then perform this same check on every window up to the root. |
375 bool Window::CanFocus() const { | 375 bool Window::CanFocus() const { |
376 // TODO(beng): Figure out how to consult the delegate wrt. focusability also. | 376 if (!IsVisible() || !parent_ || (delegate_ && !delegate_->CanFocus())) |
377 if (!IsVisible() || !parent_) | |
378 return false; | 377 return false; |
379 | 378 |
380 Windows::const_iterator i = std::find(parent_->children().begin(), | 379 Windows::const_iterator i = std::find(parent_->children().begin(), |
381 parent_->children().end(), | 380 parent_->children().end(), |
382 this); | 381 this); |
383 for (++i; i != parent_->children().end(); ++i) { | 382 for (++i; i != parent_->children().end(); ++i) { |
384 if ((*i)->StopsEventPropagation()) | 383 if ((*i)->StopsEventPropagation()) |
385 return false; | 384 return false; |
386 } | 385 } |
387 return parent_->CanFocus(); | 386 return parent_->CanFocus(); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 void Window::OnStackingChanged() { | 553 void Window::OnStackingChanged() { |
555 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowStackingChanged(this)); | 554 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowStackingChanged(this)); |
556 } | 555 } |
557 | 556 |
558 void Window::OnPaintLayer(gfx::Canvas* canvas) { | 557 void Window::OnPaintLayer(gfx::Canvas* canvas) { |
559 if (delegate_) | 558 if (delegate_) |
560 delegate_->OnPaint(canvas); | 559 delegate_->OnPaint(canvas); |
561 } | 560 } |
562 | 561 |
563 } // namespace aura | 562 } // namespace aura |
OLD | NEW |