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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
776 DCHECK(!frame || frame->page() == m_page); | 776 DCHECK(!frame || frame->page() == m_page); |
777 if (m_focusedFrame == frame) | 777 if (m_focusedFrame == frame) |
778 return; | 778 return; |
779 | 779 |
780 LocalFrame* focusedFrame = (m_focusedFrame && m_focusedFrame->isLocalFrame()) | 780 LocalFrame* focusedFrame = (m_focusedFrame && m_focusedFrame->isLocalFrame()) |
781 ? toLocalFrame(m_focusedFrame.get()) | 781 ? toLocalFrame(m_focusedFrame.get()) |
782 : nullptr; | 782 : nullptr; |
783 if (focusedFrame && focusedFrame->view()) { | 783 if (focusedFrame && focusedFrame->view()) { |
784 Document* document = focusedFrame->document(); | 784 Document* document = focusedFrame->document(); |
785 Element* focusedElement = document ? document->focusedElement() : nullptr; | 785 Element* focusedElement = document ? document->focusedElement() : nullptr; |
786 if (focusedElement) | 786 if (focusedElement) { |
alexmos
2017/03/30 17:16:11
I think this needs a comment to explain what's goi
avallee
2017/04/02 02:27:30
I don't believe that focusing a frame requires a f
| |
787 dispatchBlurEvent(*document, *focusedElement); | 787 if (frame && frame->isRemoteFrame()) |
alexmos
2017/03/30 17:16:11
Were you referring to this in the description, say
avallee
2017/04/02 02:27:30
I am not sure. They are secondary assertions that
| |
788 document->clearFocusedElement(); | |
789 else | |
790 dispatchBlurEvent(*document, *focusedElement); | |
791 } | |
788 } | 792 } |
789 | 793 |
790 LocalFrame* newFocusedFrame = | 794 LocalFrame* newFocusedFrame = |
791 (frame && frame->isLocalFrame()) ? toLocalFrame(frame) : nullptr; | 795 (frame && frame->isLocalFrame()) ? toLocalFrame(frame) : nullptr; |
792 if (newFocusedFrame && newFocusedFrame->view()) { | 796 if (newFocusedFrame && newFocusedFrame->view()) { |
793 Document* document = newFocusedFrame->document(); | 797 Document* document = newFocusedFrame->document(); |
794 Element* focusedElement = document ? document->focusedElement() : nullptr; | 798 Element* focusedElement = document ? document->focusedElement() : nullptr; |
795 if (focusedElement) | 799 if (focusedElement) |
796 dispatchFocusEvent(*document, *focusedElement); | 800 dispatchFocusEvent(*document, *focusedElement); |
797 } | 801 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
927 // If we are shifting focus from a child frame to its parent, the | 931 // If we are shifting focus from a child frame to its parent, the |
928 // child frame has no more focusable elements, and we should continue | 932 // child frame has no more focusable elements, and we should continue |
929 // looking for focusable elements in the parent, starting from the <iframe> | 933 // looking for focusable elements in the parent, starting from the <iframe> |
930 // element of the child frame. | 934 // element of the child frame. |
931 Element* start = nullptr; | 935 Element* start = nullptr; |
932 if (from->tree().parent() == to) { | 936 if (from->tree().parent() == to) { |
933 DCHECK(from->owner()->isLocal()); | 937 DCHECK(from->owner()->isLocal()); |
934 start = toHTMLFrameOwnerElement(from->owner()); | 938 start = toHTMLFrameOwnerElement(from->owner()); |
935 } | 939 } |
936 | 940 |
937 return advanceFocusInDocumentOrder(to, start, type, false, | 941 // If we're coming from a parent or sibling frame, we need to restart from the |
942 // first or last focusable element. | |
alexmos
2017/03/30 17:16:11
Why did the old code fail to do this? It seems in
avallee
2017/04/02 02:27:30
|start| is null but sequentialFocusNavigationStart
| |
943 bool initialFocus = to->tree().parent() == from || | |
944 to->tree().parent() == from->tree().parent(); | |
alexmos
2017/03/30 17:16:11
Hmm, can we actually get here for a sibling frame?
| |
945 | |
946 return advanceFocusInDocumentOrder(to, start, type, initialFocus, | |
938 sourceCapabilities); | 947 sourceCapabilities); |
939 } | 948 } |
940 | 949 |
941 #if DCHECK_IS_ON() | 950 #if DCHECK_IS_ON() |
942 inline bool isNonFocusableShadowHost(const Element& element) { | 951 inline bool isNonFocusableShadowHost(const Element& element) { |
943 return isShadowHostWithoutCustomFocusLogic(element) && !element.isFocusable(); | 952 return isShadowHostWithoutCustomFocusLogic(element) && !element.isFocusable(); |
944 } | 953 } |
945 #endif | 954 #endif |
946 | 955 |
947 bool FocusController::advanceFocusInDocumentOrder( | 956 bool FocusController::advanceFocusInDocumentOrder( |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1394 it->focusedFrameChanged(); | 1403 it->focusedFrameChanged(); |
1395 } | 1404 } |
1396 | 1405 |
1397 DEFINE_TRACE(FocusController) { | 1406 DEFINE_TRACE(FocusController) { |
1398 visitor->trace(m_page); | 1407 visitor->trace(m_page); |
1399 visitor->trace(m_focusedFrame); | 1408 visitor->trace(m_focusedFrame); |
1400 visitor->trace(m_focusChangedObservers); | 1409 visitor->trace(m_focusChangedObservers); |
1401 } | 1410 } |
1402 | 1411 |
1403 } // namespace blink | 1412 } // namespace blink |
OLD | NEW |