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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 // FIXME: This is a temporary hack to ensure that we return a LocalFrame, ev
en when the mainFrame is remote. | 622 // FIXME: This is a temporary hack to ensure that we return a LocalFrame, ev
en when the mainFrame is remote. |
623 // FocusController needs to be refactored to deal with RemoteFrames cross-pr
ocess focus transfers. | 623 // FocusController needs to be refactored to deal with RemoteFrames cross-pr
ocess focus transfers. |
624 for (Frame* frame = m_page->mainFrame()->tree().top(); frame; frame = frame-
>tree().traverseNext()) { | 624 for (Frame* frame = m_page->mainFrame()->tree().top(); frame; frame = frame-
>tree().traverseNext()) { |
625 if (frame->isLocalRoot()) | 625 if (frame->isLocalRoot()) |
626 return frame; | 626 return frame; |
627 } | 627 } |
628 | 628 |
629 return m_page->mainFrame(); | 629 return m_page->mainFrame(); |
630 } | 630 } |
631 | 631 |
| 632 HTMLFrameOwnerElement* FocusController::focusedFrameOwnerElement(LocalFrame& cur
rentFrame) const |
| 633 { |
| 634 Frame* focusedFrame = m_focusedFrame.get(); |
| 635 for (; focusedFrame; focusedFrame = focusedFrame->tree().parent()) { |
| 636 if (focusedFrame->tree().parent() == ¤tFrame) { |
| 637 ASSERT(focusedFrame->owner()->isLocal()); |
| 638 return focusedFrame->deprecatedLocalOwner(); |
| 639 } |
| 640 } |
| 641 return nullptr; |
| 642 } |
| 643 |
632 void FocusController::setFocused(bool focused) | 644 void FocusController::setFocused(bool focused) |
633 { | 645 { |
634 if (isFocused() == focused) | 646 if (isFocused() == focused) |
635 return; | 647 return; |
636 | 648 |
637 m_isFocused = focused; | 649 m_isFocused = focused; |
638 | 650 |
639 if (!m_isFocused && focusedOrMainFrame()->isLocalFrame()) | 651 if (!m_isFocused && focusedOrMainFrame()->isLocalFrame()) |
640 toLocalFrame(focusedOrMainFrame())->eventHandler().stopAutoscroll(); | 652 toLocalFrame(focusedOrMainFrame())->eventHandler().stopAutoscroll(); |
641 | 653 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 | 837 |
826 RefPtrWillBeRawPtr<Document> newDocument = nullptr; | 838 RefPtrWillBeRawPtr<Document> newDocument = nullptr; |
827 if (element) | 839 if (element) |
828 newDocument = &element->document(); | 840 newDocument = &element->document(); |
829 else if (newFocusedFrame && newFocusedFrame->isLocalFrame()) | 841 else if (newFocusedFrame && newFocusedFrame->isLocalFrame()) |
830 newDocument = toLocalFrame(newFocusedFrame.get())->document(); | 842 newDocument = toLocalFrame(newFocusedFrame.get())->document(); |
831 | 843 |
832 if (newDocument && oldDocument == newDocument && newDocument->focusedElement
() == element) | 844 if (newDocument && oldDocument == newDocument && newDocument->focusedElement
() == element) |
833 return true; | 845 return true; |
834 | 846 |
835 clearSelectionIfNeeded(oldFocusedFrame.get(), toLocalFrame(newFocusedFrame.g
et()), element); | 847 if (newFocusedFrame && newFocusedFrame->isLocalFrame()) |
| 848 clearSelectionIfNeeded(oldFocusedFrame.get(), toLocalFrame(newFocusedFra
me.get()), element); |
836 | 849 |
837 if (oldDocument && oldDocument != newDocument) | 850 if (oldDocument && oldDocument != newDocument) |
838 oldDocument->setFocusedElement(nullptr); | 851 oldDocument->setFocusedElement(nullptr); |
839 | 852 |
840 if (newFocusedFrame && !newFocusedFrame->page()) { | 853 if (newFocusedFrame && !newFocusedFrame->page()) { |
841 setFocusedFrame(nullptr); | 854 setFocusedFrame(nullptr); |
842 return false; | 855 return false; |
843 } | 856 } |
844 setFocusedFrame(newFocusedFrame); | 857 setFocusedFrame(newFocusedFrame); |
845 | 858 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 return consumed; | 1073 return consumed; |
1061 } | 1074 } |
1062 | 1075 |
1063 DEFINE_TRACE(FocusController) | 1076 DEFINE_TRACE(FocusController) |
1064 { | 1077 { |
1065 visitor->trace(m_page); | 1078 visitor->trace(m_page); |
1066 visitor->trace(m_focusedFrame); | 1079 visitor->trace(m_focusedFrame); |
1067 } | 1080 } |
1068 | 1081 |
1069 } // namespace blink | 1082 } // namespace blink |
OLD | NEW |