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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Use focus_type kWebFocusTypePage, same as used in DispatchBlurEvent. | 373 // Use focus_type kWebFocusTypePage, same as used in DispatchBlurEvent. |
374 focused_element->SetFocused(false, kWebFocusTypePage); | 374 focused_element->SetFocused(false, kWebFocusTypePage); |
| 375 focused_element->SetHasFocusWithinUpToAncestor(false, nullptr); |
375 DispatchBlurEvent(*document, *focused_element); | 376 DispatchBlurEvent(*document, *focused_element); |
376 } | 377 } |
377 | 378 |
378 if (LocalDOMWindow* window = document->domWindow()) | 379 if (LocalDOMWindow* window = document->domWindow()) |
379 window->DispatchEvent( | 380 window->DispatchEvent( |
380 Event::Create(focused ? EventTypeNames::focus : EventTypeNames::blur)); | 381 Event::Create(focused ? EventTypeNames::focus : EventTypeNames::blur)); |
381 if (focused && document->FocusedElement()) { | 382 if (focused && document->FocusedElement()) { |
382 Element* focused_element(document->FocusedElement()); | 383 Element* focused_element(document->FocusedElement()); |
383 // Use focus_type kWebFocusTypePage, same as used in DispatchFocusEvent. | 384 // Use focus_type kWebFocusTypePage, same as used in DispatchFocusEvent. |
384 focused_element->SetFocused(true, kWebFocusTypePage); | 385 focused_element->SetFocused(true, kWebFocusTypePage); |
| 386 focused_element->SetHasFocusWithinUpToAncestor(true, nullptr); |
385 DispatchFocusEvent(*document, *focused_element); | 387 DispatchFocusEvent(*document, *focused_element); |
386 } | 388 } |
387 } | 389 } |
388 | 390 |
389 inline bool HasCustomFocusLogic(const Element& element) { | 391 inline bool HasCustomFocusLogic(const Element& element) { |
390 return element.IsHTMLElement() && | 392 return element.IsHTMLElement() && |
391 ToHTMLElement(element).HasCustomFocusLogic(); | 393 ToHTMLElement(element).HasCustomFocusLogic(); |
392 } | 394 } |
393 | 395 |
394 inline bool IsShadowHostWithoutCustomFocusLogic(const Element& element) { | 396 inline bool IsShadowHostWithoutCustomFocusLogic(const Element& element) { |
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 it->FocusedFrameChanged(); | 1398 it->FocusedFrameChanged(); |
1397 } | 1399 } |
1398 | 1400 |
1399 DEFINE_TRACE(FocusController) { | 1401 DEFINE_TRACE(FocusController) { |
1400 visitor->Trace(page_); | 1402 visitor->Trace(page_); |
1401 visitor->Trace(focused_frame_); | 1403 visitor->Trace(focused_frame_); |
1402 visitor->Trace(focus_changed_observers_); | 1404 visitor->Trace(focus_changed_observers_); |
1403 } | 1405 } |
1404 | 1406 |
1405 } // namespace blink | 1407 } // namespace blink |
OLD | NEW |