| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Nuanti Ltd. | 3 * Copyright (C) 2008 Nuanti Ltd. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 | 363 |
| 364 // Do not fire events while modal dialogs are up. See | 364 // Do not fire events while modal dialogs are up. See |
| 365 // https://bugs.webkit.org/show_bug.cgi?id=33962 | 365 // https://bugs.webkit.org/show_bug.cgi?id=33962 |
| 366 if (Page* page = document->GetPage()) { | 366 if (Page* page = document->GetPage()) { |
| 367 if (page->Suspended()) | 367 if (page->Suspended()) |
| 368 return; | 368 return; |
| 369 } | 369 } |
| 370 | 370 |
| 371 if (!focused && document->FocusedElement()) { | 371 if (!focused && document->FocusedElement()) { |
| 372 Element* focused_element = document->FocusedElement(); | 372 Element* focused_element = document->FocusedElement(); |
| 373 focused_element->SetFocused(false); | 373 // Use focus_type kWebFocusTypePage, same as used in DispatchBlurEvent. |
| 374 focused_element->SetFocused(false, kWebFocusTypePage); |
| 374 DispatchBlurEvent(*document, *focused_element); | 375 DispatchBlurEvent(*document, *focused_element); |
| 375 } | 376 } |
| 376 | 377 |
| 377 if (LocalDOMWindow* window = document->domWindow()) | 378 if (LocalDOMWindow* window = document->domWindow()) |
| 378 window->DispatchEvent( | 379 window->DispatchEvent( |
| 379 Event::Create(focused ? EventTypeNames::focus : EventTypeNames::blur)); | 380 Event::Create(focused ? EventTypeNames::focus : EventTypeNames::blur)); |
| 380 if (focused && document->FocusedElement()) { | 381 if (focused && document->FocusedElement()) { |
| 381 Element* focused_element(document->FocusedElement()); | 382 Element* focused_element(document->FocusedElement()); |
| 382 focused_element->SetFocused(true); | 383 // Use focus_type kWebFocusTypePage, same as used in DispatchFocusEvent. |
| 384 focused_element->SetFocused(true, kWebFocusTypePage); |
| 383 DispatchFocusEvent(*document, *focused_element); | 385 DispatchFocusEvent(*document, *focused_element); |
| 384 } | 386 } |
| 385 } | 387 } |
| 386 | 388 |
| 387 inline bool HasCustomFocusLogic(const Element& element) { | 389 inline bool HasCustomFocusLogic(const Element& element) { |
| 388 return element.IsHTMLElement() && | 390 return element.IsHTMLElement() && |
| 389 ToHTMLElement(element).HasCustomFocusLogic(); | 391 ToHTMLElement(element).HasCustomFocusLogic(); |
| 390 } | 392 } |
| 391 | 393 |
| 392 inline bool IsShadowHostWithoutCustomFocusLogic(const Element& element) { | 394 inline bool IsShadowHostWithoutCustomFocusLogic(const Element& element) { |
| (...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1422 it->FocusedFrameChanged(); | 1424 it->FocusedFrameChanged(); |
| 1423 } | 1425 } |
| 1424 | 1426 |
| 1425 DEFINE_TRACE(FocusController) { | 1427 DEFINE_TRACE(FocusController) { |
| 1426 visitor->Trace(page_); | 1428 visitor->Trace(page_); |
| 1427 visitor->Trace(focused_frame_); | 1429 visitor->Trace(focused_frame_); |
| 1428 visitor->Trace(focus_changed_observers_); | 1430 visitor->Trace(focus_changed_observers_); |
| 1429 } | 1431 } |
| 1430 | 1432 |
| 1431 } // namespace blink | 1433 } // namespace blink |
| OLD | NEW |