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/views/focus/focus_manager.h" | 5 #include "ui/views/focus/focus_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 return; | 308 return; |
309 | 309 |
310 keyboard_accessible_ = keyboard_accessible; | 310 keyboard_accessible_ = keyboard_accessible; |
311 // Disabling keyboard accessibility may cause the focused view to become not | 311 // Disabling keyboard accessibility may cause the focused view to become not |
312 // focusable. Hence advance focus if necessary. | 312 // focusable. Hence advance focus if necessary. |
313 AdvanceFocusIfNecessary(); | 313 AdvanceFocusIfNecessary(); |
314 } | 314 } |
315 | 315 |
316 void FocusManager::SetFocusedViewWithReason( | 316 void FocusManager::SetFocusedViewWithReason( |
317 View* view, FocusChangeReason reason) { | 317 View* view, FocusChangeReason reason) { |
318 if (focused_view_ == view) | 318 if (focused_view_ == view) { |
319 LOG(ERROR) << "equal focus!"; | |
yawano
2017/04/25 09:29:23
nit: Please remove logs which you have added for d
David Tseng
2017/04/25 22:48:03
Acknowledged.
| |
319 return; | 320 return; |
321 } | |
322 | |
323 LOG(ERROR) << "setting focus!"; | |
320 // TODO(oshima|achuith): This is to diagnose crbug.com/687232. | 324 // TODO(oshima|achuith): This is to diagnose crbug.com/687232. |
321 // Change this to DCHECK once it's resolved. | 325 // Change this to DCHECK once it's resolved. |
322 CHECK(!view || ContainsView(view)); | 326 CHECK(!view || ContainsView(view)); |
323 | 327 |
324 #if !defined(OS_MACOSX) | 328 #if !defined(OS_MACOSX) |
325 // TODO(warx): There are some AccessiblePaneViewTest failed on macosx. | 329 // TODO(warx): There are some AccessiblePaneViewTest failed on macosx. |
326 // crbug.com/650859. Remove !defined(OS_MACOSX) once that is fixed. | 330 // crbug.com/650859. Remove !defined(OS_MACOSX) once that is fixed. |
327 // | 331 // |
328 // If the widget isn't active store the focused view and then attempt to | 332 // If the widget isn't active store the focused view and then attempt to |
329 // activate the widget. If activation succeeds |view| will be focused. | 333 // activate the widget. If activation succeeds |view| will be focused. |
330 // If activation fails |view| will be focused the next time the widget is | 334 // If activation fails |view| will be focused the next time the widget is |
331 // made active. | 335 // made active. |
332 if (view && !widget_->IsActive()) { | 336 if (view && !widget_->IsActive()) { |
333 SetStoredFocusView(view); | 337 SetStoredFocusView(view); |
334 widget_->Activate(); | 338 widget_->Activate(); |
335 return; | 339 return; |
336 } | 340 } |
337 #endif | 341 #endif |
338 | 342 |
339 // Update the reason for the focus change (since this is checked by | 343 // Update the reason for the focus change (since this is checked by |
340 // some listeners), then notify all listeners. | 344 // some listeners), then notify all listeners. |
341 focus_change_reason_ = reason; | 345 focus_change_reason_ = reason; |
342 for (FocusChangeListener& observer : focus_change_listeners_) | 346 for (FocusChangeListener& observer : focus_change_listeners_) |
343 observer.OnWillChangeFocus(focused_view_, view); | 347 observer.OnWillChangeFocus(focused_view_, view); |
344 | 348 |
345 View* old_focused_view = focused_view_; | 349 View* old_focused_view = focused_view_; |
346 focused_view_ = view; | 350 focused_view_ = view; |
351 LOG(ERROR) << "focus set!"; | |
347 if (old_focused_view) { | 352 if (old_focused_view) { |
348 old_focused_view->RemoveObserver(this); | 353 old_focused_view->RemoveObserver(this); |
349 old_focused_view->Blur(); | 354 old_focused_view->Blur(); |
350 } | 355 } |
351 // Also make |focused_view_| the stored focus view. This way the stored focus | 356 // Also make |focused_view_| the stored focus view. This way the stored focus |
352 // view is remembered if focus changes are requested prior to a show or while | 357 // view is remembered if focus changes are requested prior to a show or while |
353 // hidden. | 358 // hidden. |
354 SetStoredFocusView(focused_view_); | 359 SetStoredFocusView(focused_view_); |
355 if (focused_view_) { | 360 if (focused_view_) { |
356 focused_view_->AddObserver(this); | 361 focused_view_->AddObserver(this); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
618 base::debug::Alias(&instruction_pointers_copy); | 623 base::debug::Alias(&instruction_pointers_copy); |
619 base::debug::DumpWithoutCrashing(); | 624 base::debug::DumpWithoutCrashing(); |
620 stack_when_focused_view_set_.reset(); | 625 stack_when_focused_view_set_.reset(); |
621 } | 626 } |
622 | 627 |
623 focused_view_->RemoveObserver(this); | 628 focused_view_->RemoveObserver(this); |
624 focused_view_ = nullptr; | 629 focused_view_ = nullptr; |
625 } | 630 } |
626 | 631 |
627 } // namespace views | 632 } // namespace views |
OLD | NEW |