| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 static ScopedFocusNavigation createForDocument(Document&); | 85 static ScopedFocusNavigation createForDocument(Document&); |
| 86 static ScopedFocusNavigation ownedByNonFocusableFocusScopeOwner(Element&); | 86 static ScopedFocusNavigation ownedByNonFocusableFocusScopeOwner(Element&); |
| 87 static ScopedFocusNavigation ownedByShadowHost(const Element&); | 87 static ScopedFocusNavigation ownedByShadowHost(const Element&); |
| 88 static ScopedFocusNavigation ownedByShadowInsertionPoint(HTMLShadowElement&)
; | 88 static ScopedFocusNavigation ownedByShadowInsertionPoint(HTMLShadowElement&)
; |
| 89 static ScopedFocusNavigation ownedByHTMLSlotElement(const HTMLSlotElement&); | 89 static ScopedFocusNavigation ownedByHTMLSlotElement(const HTMLSlotElement&); |
| 90 static ScopedFocusNavigation ownedByIFrame(const HTMLFrameOwnerElement&); | 90 static ScopedFocusNavigation ownedByIFrame(const HTMLFrameOwnerElement&); |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 ScopedFocusNavigation(TreeScope&, const Element*); | 93 ScopedFocusNavigation(TreeScope&, const Element*); |
| 94 ScopedFocusNavigation(HTMLSlotElement&, const Element*); | 94 ScopedFocusNavigation(HTMLSlotElement&, const Element*); |
| 95 RawPtrWillBeMember<ContainerNode> m_rootNode; | 95 Member<ContainerNode> m_rootNode; |
| 96 RawPtrWillBeMember<HTMLSlotElement> m_rootSlot; | 96 Member<HTMLSlotElement> m_rootSlot; |
| 97 RawPtrWillBeMember<Element> m_current; | 97 Member<Element> m_current; |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 ScopedFocusNavigation::ScopedFocusNavigation(TreeScope& treeScope, const Element
* current) | 100 ScopedFocusNavigation::ScopedFocusNavigation(TreeScope& treeScope, const Element
* current) |
| 101 : m_rootNode(treeScope.rootNode()) | 101 : m_rootNode(treeScope.rootNode()) |
| 102 , m_rootSlot(nullptr) | 102 , m_rootSlot(nullptr) |
| 103 , m_current(const_cast<Element*>(current)) | 103 , m_current(const_cast<Element*>(current)) |
| 104 { | 104 { |
| 105 } | 105 } |
| 106 | 106 |
| 107 ScopedFocusNavigation::ScopedFocusNavigation(HTMLSlotElement& slot, const Elemen
t* current) | 107 ScopedFocusNavigation::ScopedFocusNavigation(HTMLSlotElement& slot, const Elemen
t* current) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 m_current = ElementTraversal::previous(*m_current); | 142 m_current = ElementTraversal::previous(*m_current); |
| 143 while (m_current && SlotScopedTraversal::isSlotScoped(*m_current)) | 143 while (m_current && SlotScopedTraversal::isSlotScoped(*m_current)) |
| 144 m_current = ElementTraversal::previous(*m_current); | 144 m_current = ElementTraversal::previous(*m_current); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 void ScopedFocusNavigation::moveToFirst() | 148 void ScopedFocusNavigation::moveToFirst() |
| 149 { | 149 { |
| 150 if (m_rootSlot) { | 150 if (m_rootSlot) { |
| 151 if (!m_rootSlot->getAssignedNodes().isEmpty()) { | 151 if (!m_rootSlot->getAssignedNodes().isEmpty()) { |
| 152 WillBeHeapVector<RefPtrWillBeMember<Node>> assignedNodes = m_rootSlo
t->getAssignedNodes(); | 152 HeapVector<Member<Node>> assignedNodes = m_rootSlot->getAssignedNode
s(); |
| 153 for (auto assignedNode : assignedNodes) { | 153 for (auto assignedNode : assignedNodes) { |
| 154 if (assignedNode->isElementNode()) { | 154 if (assignedNode->isElementNode()) { |
| 155 m_current = toElement(assignedNode); | 155 m_current = toElement(assignedNode); |
| 156 break; | 156 break; |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 } else { | 159 } else { |
| 160 m_current = nullptr; | 160 m_current = nullptr; |
| 161 } | 161 } |
| 162 } else { | 162 } else { |
| 163 Element* first = m_rootNode->isElementNode() ? &toElement(*m_rootNode) :
ElementTraversal::next(*m_rootNode); | 163 Element* first = m_rootNode->isElementNode() ? &toElement(*m_rootNode) :
ElementTraversal::next(*m_rootNode); |
| 164 while (first && SlotScopedTraversal::isSlotScoped(*first)) | 164 while (first && SlotScopedTraversal::isSlotScoped(*first)) |
| 165 first = ElementTraversal::next(*first, m_rootNode); | 165 first = ElementTraversal::next(*first, m_rootNode); |
| 166 m_current = first; | 166 m_current = first; |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| 170 void ScopedFocusNavigation::moveToLast() | 170 void ScopedFocusNavigation::moveToLast() |
| 171 { | 171 { |
| 172 if (m_rootSlot) { | 172 if (m_rootSlot) { |
| 173 if (!m_rootSlot->getAssignedNodes().isEmpty()) { | 173 if (!m_rootSlot->getAssignedNodes().isEmpty()) { |
| 174 WillBeHeapVector<RefPtrWillBeMember<Node>> assignedNodes = m_rootSlo
t->getAssignedNodes(); | 174 HeapVector<Member<Node>> assignedNodes = m_rootSlot->getAssignedNode
s(); |
| 175 for (auto assignedNode = assignedNodes.rbegin(); assignedNode != ass
ignedNodes.rend(); ++assignedNode) { | 175 for (auto assignedNode = assignedNodes.rbegin(); assignedNode != ass
ignedNodes.rend(); ++assignedNode) { |
| 176 if ((*assignedNode)->isElementNode()) { | 176 if ((*assignedNode)->isElementNode()) { |
| 177 m_current = ElementTraversal::lastWithinOrSelf(*toElement(*a
ssignedNode)); | 177 m_current = ElementTraversal::lastWithinOrSelf(*toElement(*a
ssignedNode)); |
| 178 break; | 178 break; |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 } else { | 181 } else { |
| 182 m_current = nullptr; | 182 m_current = nullptr; |
| 183 } | 183 } |
| 184 } else { | 184 } else { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 if (document->focusedElement() && isHTMLPlugInElement(document->focusedEleme
nt())) | 280 if (document->focusedElement() && isHTMLPlugInElement(document->focusedEleme
nt())) |
| 281 toHTMLPlugInElement(document->focusedElement())->setPluginFocus(focused)
; | 281 toHTMLPlugInElement(document->focusedElement())->setPluginFocus(focused)
; |
| 282 | 282 |
| 283 // Do not fire events while modal dialogs are up. See https://bugs.webkit.o
rg/show_bug.cgi?id=33962 | 283 // Do not fire events while modal dialogs are up. See https://bugs.webkit.o
rg/show_bug.cgi?id=33962 |
| 284 if (Page* page = document->page()) { | 284 if (Page* page = document->page()) { |
| 285 if (page->defersLoading()) | 285 if (page->defersLoading()) |
| 286 return; | 286 return; |
| 287 } | 287 } |
| 288 | 288 |
| 289 if (!focused && document->focusedElement()) { | 289 if (!focused && document->focusedElement()) { |
| 290 RefPtrWillBeRawPtr<Element> focusedElement(document->focusedElement()); | 290 RawPtr<Element> focusedElement(document->focusedElement()); |
| 291 focusedElement->setFocus(false); | 291 focusedElement->setFocus(false); |
| 292 dispatchBlurEvent(*document, *focusedElement); | 292 dispatchBlurEvent(*document, *focusedElement); |
| 293 } | 293 } |
| 294 | 294 |
| 295 if (LocalDOMWindow* window = document->domWindow()) | 295 if (LocalDOMWindow* window = document->domWindow()) |
| 296 window->dispatchEvent(Event::create(focused ? EventTypeNames::focus : Ev
entTypeNames::blur)); | 296 window->dispatchEvent(Event::create(focused ? EventTypeNames::focus : Ev
entTypeNames::blur)); |
| 297 if (focused && document->focusedElement()) { | 297 if (focused && document->focusedElement()) { |
| 298 RefPtrWillBeRawPtr<Element> focusedElement(document->focusedElement()); | 298 RawPtr<Element> focusedElement(document->focusedElement()); |
| 299 focusedElement->setFocus(true); | 299 focusedElement->setFocus(true); |
| 300 dispatchFocusEvent(*document, *focusedElement); | 300 dispatchFocusEvent(*document, *focusedElement); |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 | 303 |
| 304 inline bool hasCustomFocusLogic(const Element& element) | 304 inline bool hasCustomFocusLogic(const Element& element) |
| 305 { | 305 { |
| 306 return element.isHTMLElement() && toHTMLElement(element).hasCustomFocusLogic
(); | 306 return element.isHTMLElement() && toHTMLElement(element).hasCustomFocusLogic
(); |
| 307 } | 307 } |
| 308 | 308 |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 } // anonymous namespace | 661 } // anonymous namespace |
| 662 | 662 |
| 663 FocusController::FocusController(Page* page) | 663 FocusController::FocusController(Page* page) |
| 664 : m_page(page) | 664 : m_page(page) |
| 665 , m_isActive(false) | 665 , m_isActive(false) |
| 666 , m_isFocused(false) | 666 , m_isFocused(false) |
| 667 , m_isChangingFocusedFrame(false) | 667 , m_isChangingFocusedFrame(false) |
| 668 { | 668 { |
| 669 } | 669 } |
| 670 | 670 |
| 671 PassOwnPtrWillBeRawPtr<FocusController> FocusController::create(Page* page) | 671 RawPtr<FocusController> FocusController::create(Page* page) |
| 672 { | 672 { |
| 673 return adoptPtrWillBeNoop(new FocusController(page)); | 673 return new FocusController(page); |
| 674 } | 674 } |
| 675 | 675 |
| 676 void FocusController::setFocusedFrame(PassRefPtrWillBeRawPtr<Frame> frame, bool
notifyEmbedder) | 676 void FocusController::setFocusedFrame(RawPtr<Frame> frame, bool notifyEmbedder) |
| 677 { | 677 { |
| 678 ASSERT(!frame || frame->page() == m_page); | 678 ASSERT(!frame || frame->page() == m_page); |
| 679 if (m_focusedFrame == frame || (m_isChangingFocusedFrame && frame)) | 679 if (m_focusedFrame == frame || (m_isChangingFocusedFrame && frame)) |
| 680 return; | 680 return; |
| 681 | 681 |
| 682 m_isChangingFocusedFrame = true; | 682 m_isChangingFocusedFrame = true; |
| 683 | 683 |
| 684 RefPtrWillBeRawPtr<LocalFrame> oldFrame = (m_focusedFrame && m_focusedFrame-
>isLocalFrame()) ? toLocalFrame(m_focusedFrame.get()) : nullptr; | 684 RawPtr<LocalFrame> oldFrame = (m_focusedFrame && m_focusedFrame->isLocalFram
e()) ? toLocalFrame(m_focusedFrame.get()) : nullptr; |
| 685 | 685 |
| 686 RefPtrWillBeRawPtr<LocalFrame> newFrame = (frame && frame->isLocalFrame()) ?
toLocalFrame(frame.get()) : nullptr; | 686 RawPtr<LocalFrame> newFrame = (frame && frame->isLocalFrame()) ? toLocalFram
e(frame.get()) : nullptr; |
| 687 | 687 |
| 688 m_focusedFrame = frame.get(); | 688 m_focusedFrame = frame.get(); |
| 689 | 689 |
| 690 // Now that the frame is updated, fire events and update the selection focus
ed states of both frames. | 690 // Now that the frame is updated, fire events and update the selection focus
ed states of both frames. |
| 691 if (oldFrame && oldFrame->view()) { | 691 if (oldFrame && oldFrame->view()) { |
| 692 oldFrame->selection().setFocused(false); | 692 oldFrame->selection().setFocused(false); |
| 693 oldFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::blur)
); | 693 oldFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::blur)
); |
| 694 } | 694 } |
| 695 | 695 |
| 696 if (newFrame && newFrame->view() && isFocused()) { | 696 if (newFrame && newFrame->view() && isFocused()) { |
| 697 newFrame->selection().setFocused(true); | 697 newFrame->selection().setFocused(true); |
| 698 newFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::focus
)); | 698 newFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::focus
)); |
| 699 } | 699 } |
| 700 | 700 |
| 701 m_isChangingFocusedFrame = false; | 701 m_isChangingFocusedFrame = false; |
| 702 | 702 |
| 703 // Checking client() is necessary, as the frame might have been detached as | 703 // Checking client() is necessary, as the frame might have been detached as |
| 704 // part of dispatching the focus event above. See https://crbug.com/570874. | 704 // part of dispatching the focus event above. See https://crbug.com/570874. |
| 705 if (m_focusedFrame && m_focusedFrame->client() && notifyEmbedder) | 705 if (m_focusedFrame && m_focusedFrame->client() && notifyEmbedder) |
| 706 m_focusedFrame->client()->frameFocused(); | 706 m_focusedFrame->client()->frameFocused(); |
| 707 } | 707 } |
| 708 | 708 |
| 709 void FocusController::focusDocumentView(PassRefPtrWillBeRawPtr<Frame> frame, boo
l notifyEmbedder) | 709 void FocusController::focusDocumentView(RawPtr<Frame> frame, bool notifyEmbedder
) |
| 710 { | 710 { |
| 711 ASSERT(!frame || frame->page() == m_page); | 711 ASSERT(!frame || frame->page() == m_page); |
| 712 if (m_focusedFrame == frame) | 712 if (m_focusedFrame == frame) |
| 713 return; | 713 return; |
| 714 | 714 |
| 715 RefPtrWillBeRawPtr<LocalFrame> focusedFrame = (m_focusedFrame && m_focusedFr
ame->isLocalFrame()) ? toLocalFrame(m_focusedFrame.get()) : nullptr; | 715 RawPtr<LocalFrame> focusedFrame = (m_focusedFrame && m_focusedFrame->isLocal
Frame()) ? toLocalFrame(m_focusedFrame.get()) : nullptr; |
| 716 if (focusedFrame && focusedFrame->view()) { | 716 if (focusedFrame && focusedFrame->view()) { |
| 717 RefPtrWillBeRawPtr<Document> document = focusedFrame->document(); | 717 RawPtr<Document> document = focusedFrame->document(); |
| 718 Element* focusedElement = document ? document->focusedElement() : nullpt
r; | 718 Element* focusedElement = document ? document->focusedElement() : nullpt
r; |
| 719 if (focusedElement) | 719 if (focusedElement) |
| 720 dispatchBlurEvent(*document, *focusedElement); | 720 dispatchBlurEvent(*document, *focusedElement); |
| 721 } | 721 } |
| 722 | 722 |
| 723 RefPtrWillBeRawPtr<LocalFrame> newFocusedFrame = (frame && frame->isLocalFra
me()) ? toLocalFrame(frame.get()) : nullptr; | 723 RawPtr<LocalFrame> newFocusedFrame = (frame && frame->isLocalFrame()) ? toLo
calFrame(frame.get()) : nullptr; |
| 724 if (newFocusedFrame && newFocusedFrame->view()) { | 724 if (newFocusedFrame && newFocusedFrame->view()) { |
| 725 RefPtrWillBeRawPtr<Document> document = newFocusedFrame->document(); | 725 RawPtr<Document> document = newFocusedFrame->document(); |
| 726 Element* focusedElement = document ? document->focusedElement() : nullpt
r; | 726 Element* focusedElement = document ? document->focusedElement() : nullpt
r; |
| 727 if (focusedElement) | 727 if (focusedElement) |
| 728 dispatchFocusEvent(*document, *focusedElement); | 728 dispatchFocusEvent(*document, *focusedElement); |
| 729 } | 729 } |
| 730 | 730 |
| 731 setFocusedFrame(frame, notifyEmbedder); | 731 setFocusedFrame(frame, notifyEmbedder); |
| 732 } | 732 } |
| 733 | 733 |
| 734 LocalFrame* FocusController::focusedFrame() const | 734 LocalFrame* FocusController::focusedFrame() const |
| 735 { | 735 { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 current = document->sequentialFocusNavigationStartingPoint(type); | 863 current = document->sequentialFocusNavigationStartingPoint(type); |
| 864 | 864 |
| 865 // FIXME: Not quite correct when it comes to focus transitions leaving/enter
ing the WebView itself | 865 // FIXME: Not quite correct when it comes to focus transitions leaving/enter
ing the WebView itself |
| 866 bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEn
abled(); | 866 bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEn
abled(); |
| 867 | 867 |
| 868 if (caretBrowsing && !current) | 868 if (caretBrowsing && !current) |
| 869 current = adjustToElement(frame->selection().start().anchorNode(), type)
; | 869 current = adjustToElement(frame->selection().start().anchorNode(), type)
; |
| 870 | 870 |
| 871 document->updateLayoutIgnorePendingStylesheets(); | 871 document->updateLayoutIgnorePendingStylesheets(); |
| 872 ScopedFocusNavigation scope = current ? ScopedFocusNavigation::createFor(*cu
rrent) : ScopedFocusNavigation::createForDocument(*document); | 872 ScopedFocusNavigation scope = current ? ScopedFocusNavigation::createFor(*cu
rrent) : ScopedFocusNavigation::createForDocument(*document); |
| 873 RefPtrWillBeRawPtr<Element> element = findFocusableElementAcrossFocusScopes(
type, scope); | 873 RawPtr<Element> element = findFocusableElementAcrossFocusScopes(type, scope)
; |
| 874 | 874 |
| 875 if (!element) { | 875 if (!element) { |
| 876 // If there's a RemoteFrame on the ancestor chain, we need to continue | 876 // If there's a RemoteFrame on the ancestor chain, we need to continue |
| 877 // searching for focusable elements there. | 877 // searching for focusable elements there. |
| 878 if (frame->localFrameRoot() != frame->tree().top()) { | 878 if (frame->localFrameRoot() != frame->tree().top()) { |
| 879 document->clearFocusedElement(); | 879 document->clearFocusedElement(); |
| 880 document->setSequentialFocusNavigationStartingPoint(nullptr); | 880 document->setSequentialFocusNavigationStartingPoint(nullptr); |
| 881 toRemoteFrame(frame->localFrameRoot()->tree().parent())->advanceFocu
s(type, frame->localFrameRoot()); | 881 toRemoteFrame(frame->localFrameRoot()->tree().parent())->advanceFocu
s(type, frame->localFrameRoot()); |
| 882 return true; | 882 return true; |
| 883 } | 883 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 | 992 |
| 993 if (!enclosingTextFormControl(selectionStartNode)) | 993 if (!enclosingTextFormControl(selectionStartNode)) |
| 994 return; | 994 return; |
| 995 | 995 |
| 996 if (selectionStartNode->isInShadowTree() && selectionStartNode->shadowHost()
== newFocusedElement) | 996 if (selectionStartNode->isInShadowTree() && selectionStartNode->shadowHost()
== newFocusedElement) |
| 997 return; | 997 return; |
| 998 | 998 |
| 999 selection.clear(); | 999 selection.clear(); |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 bool FocusController::setFocusedElement(Element* element, PassRefPtrWillBeRawPtr
<Frame> newFocusedFrame) | 1002 bool FocusController::setFocusedElement(Element* element, RawPtr<Frame> newFocus
edFrame) |
| 1003 { | 1003 { |
| 1004 return setFocusedElement(element, newFocusedFrame, FocusParams(SelectionBeha
viorOnFocus::None, WebFocusTypeNone, nullptr)); | 1004 return setFocusedElement(element, newFocusedFrame, FocusParams(SelectionBeha
viorOnFocus::None, WebFocusTypeNone, nullptr)); |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 bool FocusController::setFocusedElement(Element* element, PassRefPtrWillBeRawPtr
<Frame> newFocusedFrame, const FocusParams& params) | 1007 bool FocusController::setFocusedElement(Element* element, RawPtr<Frame> newFocus
edFrame, const FocusParams& params) |
| 1008 { | 1008 { |
| 1009 RefPtrWillBeRawPtr<LocalFrame> oldFocusedFrame = focusedFrame(); | 1009 RawPtr<LocalFrame> oldFocusedFrame = focusedFrame(); |
| 1010 RefPtrWillBeRawPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame
->document() : nullptr; | 1010 RawPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame->document()
: nullptr; |
| 1011 | 1011 |
| 1012 Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : n
ullptr; | 1012 Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : n
ullptr; |
| 1013 if (element && oldFocusedElement == element) | 1013 if (element && oldFocusedElement == element) |
| 1014 return true; | 1014 return true; |
| 1015 | 1015 |
| 1016 // FIXME: Might want to disable this check for caretBrowsing | 1016 // FIXME: Might want to disable this check for caretBrowsing |
| 1017 if (oldFocusedElement && oldFocusedElement->isRootEditableElement() && !reli
nquishesEditingFocus(*oldFocusedElement)) | 1017 if (oldFocusedElement && oldFocusedElement->isRootEditableElement() && !reli
nquishesEditingFocus(*oldFocusedElement)) |
| 1018 return false; | 1018 return false; |
| 1019 | 1019 |
| 1020 m_page->chromeClient().willSetInputMethodState(); | 1020 m_page->chromeClient().willSetInputMethodState(); |
| 1021 | 1021 |
| 1022 RefPtrWillBeRawPtr<Document> newDocument = nullptr; | 1022 RawPtr<Document> newDocument = nullptr; |
| 1023 if (element) | 1023 if (element) |
| 1024 newDocument = &element->document(); | 1024 newDocument = &element->document(); |
| 1025 else if (newFocusedFrame && newFocusedFrame->isLocalFrame()) | 1025 else if (newFocusedFrame && newFocusedFrame->isLocalFrame()) |
| 1026 newDocument = toLocalFrame(newFocusedFrame.get())->document(); | 1026 newDocument = toLocalFrame(newFocusedFrame.get())->document(); |
| 1027 | 1027 |
| 1028 if (newDocument && oldDocument == newDocument && newDocument->focusedElement
() == element) | 1028 if (newDocument && oldDocument == newDocument && newDocument->focusedElement
() == element) |
| 1029 return true; | 1029 return true; |
| 1030 | 1030 |
| 1031 if (newFocusedFrame && newFocusedFrame->isLocalFrame()) | 1031 if (newFocusedFrame && newFocusedFrame->isLocalFrame()) |
| 1032 clearSelectionIfNeeded(oldFocusedFrame.get(), toLocalFrame(newFocusedFra
me.get()), element); | 1032 clearSelectionIfNeeded(oldFocusedFrame.get(), toLocalFrame(newFocusedFra
me.get()), element); |
| 1033 | 1033 |
| 1034 if (oldDocument && oldDocument != newDocument) | 1034 if (oldDocument && oldDocument != newDocument) |
| 1035 oldDocument->clearFocusedElement(); | 1035 oldDocument->clearFocusedElement(); |
| 1036 | 1036 |
| 1037 if (newFocusedFrame && !newFocusedFrame->page()) { | 1037 if (newFocusedFrame && !newFocusedFrame->page()) { |
| 1038 setFocusedFrame(nullptr); | 1038 setFocusedFrame(nullptr); |
| 1039 return false; | 1039 return false; |
| 1040 } | 1040 } |
| 1041 setFocusedFrame(newFocusedFrame); | 1041 setFocusedFrame(newFocusedFrame); |
| 1042 | 1042 |
| 1043 // Setting the focused element can result in losing our last reft to element
when JS event handlers fire. | 1043 // Setting the focused element can result in losing our last reft to element
when JS event handlers fire. |
| 1044 RefPtrWillBeRawPtr<Element> protect = element; | 1044 RawPtr<Element> protect = element; |
| 1045 ALLOW_UNUSED_LOCAL(protect); | 1045 ALLOW_UNUSED_LOCAL(protect); |
| 1046 if (newDocument) { | 1046 if (newDocument) { |
| 1047 bool successfullyFocused = newDocument->setFocusedElement(element, param
s); | 1047 bool successfullyFocused = newDocument->setFocusedElement(element, param
s); |
| 1048 if (!successfullyFocused) | 1048 if (!successfullyFocused) |
| 1049 return false; | 1049 return false; |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 return true; | 1052 return true; |
| 1053 } | 1053 } |
| 1054 | 1054 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 return consumed; | 1257 return consumed; |
| 1258 } | 1258 } |
| 1259 | 1259 |
| 1260 DEFINE_TRACE(FocusController) | 1260 DEFINE_TRACE(FocusController) |
| 1261 { | 1261 { |
| 1262 visitor->trace(m_page); | 1262 visitor->trace(m_page); |
| 1263 visitor->trace(m_focusedFrame); | 1263 visitor->trace(m_focusedFrame); |
| 1264 } | 1264 } |
| 1265 | 1265 |
| 1266 } // namespace blink | 1266 } // namespace blink |
| OLD | NEW |