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 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 } | 765 } |
766 | 766 |
767 LocalFrame* newFocusedFrame = (frame && frame->isLocalFrame()) ? toLocalFram
e(frame) : nullptr; | 767 LocalFrame* newFocusedFrame = (frame && frame->isLocalFrame()) ? toLocalFram
e(frame) : nullptr; |
768 if (newFocusedFrame && newFocusedFrame->view()) { | 768 if (newFocusedFrame && newFocusedFrame->view()) { |
769 Document* document = newFocusedFrame->document(); | 769 Document* document = newFocusedFrame->document(); |
770 Element* focusedElement = document ? document->focusedElement() : nullpt
r; | 770 Element* focusedElement = document ? document->focusedElement() : nullpt
r; |
771 if (focusedElement) | 771 if (focusedElement) |
772 dispatchFocusEvent(*document, *focusedElement); | 772 dispatchFocusEvent(*document, *focusedElement); |
773 } | 773 } |
774 | 774 |
| 775 // dispatchBlurEvent/dispatchFocusEvent could have changed the focused frame
, or |
| 776 // detached the frame. |
| 777 if (newFocusedFrame && !newFocusedFrame->view()) |
| 778 return; |
| 779 |
775 setFocusedFrame(frame, notifyEmbedder); | 780 setFocusedFrame(frame, notifyEmbedder); |
776 } | 781 } |
777 | 782 |
778 LocalFrame* FocusController::focusedFrame() const | 783 LocalFrame* FocusController::focusedFrame() const |
779 { | 784 { |
780 // TODO(alexmos): Strengthen this to DCHECK that whoever called this really | 785 // TODO(alexmos): Strengthen this to DCHECK that whoever called this really |
781 // expected a LocalFrame. Refactor call sites so that the rare cases that | 786 // expected a LocalFrame. Refactor call sites so that the rare cases that |
782 // need to know about focused RemoteFrames use a separate accessor (to be | 787 // need to know about focused RemoteFrames use a separate accessor (to be |
783 // added). | 788 // added). |
784 if (m_focusedFrame && m_focusedFrame->isRemoteFrame()) | 789 if (m_focusedFrame && m_focusedFrame->isRemoteFrame()) |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 return consumed; | 1313 return consumed; |
1309 } | 1314 } |
1310 | 1315 |
1311 DEFINE_TRACE(FocusController) | 1316 DEFINE_TRACE(FocusController) |
1312 { | 1317 { |
1313 visitor->trace(m_page); | 1318 visitor->trace(m_page); |
1314 visitor->trace(m_focusedFrame); | 1319 visitor->trace(m_focusedFrame); |
1315 } | 1320 } |
1316 | 1321 |
1317 } // namespace blink | 1322 } // namespace blink |
OLD | NEW |