| 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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 return false; | 681 return false; |
| 682 LocalFrame* frame = toLocalFrame(focusedOrMainFrame()); | 682 LocalFrame* frame = toLocalFrame(focusedOrMainFrame()); |
| 683 ASSERT(frame); | 683 ASSERT(frame); |
| 684 Document* document = frame->document(); | 684 Document* document = frame->document(); |
| 685 | 685 |
| 686 Node* currentNode = document->focusedElement(); | 686 Node* currentNode = document->focusedElement(); |
| 687 // FIXME: Not quite correct when it comes to focus transitions leaving/enter
ing the WebView itself | 687 // FIXME: Not quite correct when it comes to focus transitions leaving/enter
ing the WebView itself |
| 688 bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEn
abled(); | 688 bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEn
abled(); |
| 689 | 689 |
| 690 if (caretBrowsing && !currentNode) | 690 if (caretBrowsing && !currentNode) |
| 691 currentNode = frame->selection().start().deprecatedNode(); | 691 currentNode = frame->selection().start().anchorNode(); |
| 692 | 692 |
| 693 document->updateLayoutIgnorePendingStylesheets(); | 693 document->updateLayoutIgnorePendingStylesheets(); |
| 694 | 694 |
| 695 RefPtrWillBeRawPtr<Element> element = findFocusableElementAcrossFocusScopes(
type, FocusNavigationScope::focusNavigationScopeOf(currentNode ? *currentNode :
*document), currentNode); | 695 RefPtrWillBeRawPtr<Element> element = findFocusableElementAcrossFocusScopes(
type, FocusNavigationScope::focusNavigationScopeOf(currentNode ? *currentNode :
*document), currentNode); |
| 696 | 696 |
| 697 if (!element) { | 697 if (!element) { |
| 698 // We didn't find an element to focus, so we should try to pass focus to
Chrome. | 698 // We didn't find an element to focus, so we should try to pass focus to
Chrome. |
| 699 if (!initialFocus && m_page->chromeClient().canTakeFocus(type)) { | 699 if (!initialFocus && m_page->chromeClient().canTakeFocus(type)) { |
| 700 document->setFocusedElement(nullptr); | 700 document->setFocusedElement(nullptr); |
| 701 setFocusedFrame(nullptr); | 701 setFocusedFrame(nullptr); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 return; | 776 return; |
| 777 | 777 |
| 778 FrameSelection& selection = oldFocusedFrame->selection(); | 778 FrameSelection& selection = oldFocusedFrame->selection(); |
| 779 if (selection.isNone()) | 779 if (selection.isNone()) |
| 780 return; | 780 return; |
| 781 | 781 |
| 782 bool caretBrowsing = oldFocusedFrame->settings()->caretBrowsingEnabled(); | 782 bool caretBrowsing = oldFocusedFrame->settings()->caretBrowsingEnabled(); |
| 783 if (caretBrowsing) | 783 if (caretBrowsing) |
| 784 return; | 784 return; |
| 785 | 785 |
| 786 Node* selectionStartNode = selection.selection().start().deprecatedNode(); | 786 Node* selectionStartNode = selection.selection().start().anchorNode(); |
| 787 if (selectionStartNode == newFocusedElement || selectionStartNode->isDescend
antOf(newFocusedElement)) | 787 if (selectionStartNode == newFocusedElement || selectionStartNode->isDescend
antOf(newFocusedElement)) |
| 788 return; | 788 return; |
| 789 | 789 |
| 790 if (!enclosingTextFormControl(selectionStartNode)) | 790 if (!enclosingTextFormControl(selectionStartNode)) |
| 791 return; | 791 return; |
| 792 | 792 |
| 793 if (selectionStartNode->isInShadowTree() && selectionStartNode->shadowHost()
== newFocusedElement) | 793 if (selectionStartNode->isInShadowTree() && selectionStartNode->shadowHost()
== newFocusedElement) |
| 794 return; | 794 return; |
| 795 | 795 |
| 796 selection.clear(); | 796 selection.clear(); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 return consumed; | 1048 return consumed; |
| 1049 } | 1049 } |
| 1050 | 1050 |
| 1051 DEFINE_TRACE(FocusController) | 1051 DEFINE_TRACE(FocusController) |
| 1052 { | 1052 { |
| 1053 visitor->trace(m_page); | 1053 visitor->trace(m_page); |
| 1054 visitor->trace(m_focusedFrame); | 1054 visitor->trace(m_focusedFrame); |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 } // namespace blink | 1057 } // namespace blink |
| OLD | NEW |