Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: third_party/WebKit/Source/core/page/FocusController.cpp

Issue 1718153002: Implement 'sequential focus navigation starting point.' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Actual fix for non-oilpan test failures Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 } 736 }
737 737
738 bool FocusController::advanceFocusInDocumentOrder(LocalFrame* frame, Element* st art, WebFocusType type, bool initialFocus, InputDeviceCapabilities* sourceCapabi lities) 738 bool FocusController::advanceFocusInDocumentOrder(LocalFrame* frame, Element* st art, WebFocusType type, bool initialFocus, InputDeviceCapabilities* sourceCapabi lities)
739 { 739 {
740 ASSERT(frame); 740 ASSERT(frame);
741 Document* document = frame->document(); 741 Document* document = frame->document();
742 ASSERT(document->documentElement()); 742 ASSERT(document->documentElement());
743 743
744 Element* current = start; 744 Element* current = start;
745 if (!current) 745 if (!current)
746 current = document->focusedElement(); 746 current = document->sequentialFocusNavigationStartingPoint(type);
747 747
748 // FIXME: Not quite correct when it comes to focus transitions leaving/enter ing the WebView itself 748 // FIXME: Not quite correct when it comes to focus transitions leaving/enter ing the WebView itself
749 bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEn abled(); 749 bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEn abled();
750 750
751 if (caretBrowsing && !current) 751 if (caretBrowsing && !current)
752 current = adjustToElement(frame->selection().start().anchorNode(), type) ; 752 current = adjustToElement(frame->selection().start().anchorNode(), type) ;
753 753
754 document->updateLayoutIgnorePendingStylesheets(); 754 document->updateLayoutIgnorePendingStylesheets();
755 755
756 RefPtrWillBeRawPtr<Element> element = findFocusableElementAcrossFocusScopes( type, FocusNavigationScope::focusNavigationScopeOf(current ? *current : *documen t->documentElement()), current); 756 RefPtrWillBeRawPtr<Element> element = findFocusableElementAcrossFocusScopes( type, FocusNavigationScope::focusNavigationScopeOf(current ? *current : *documen t->documentElement()), current);
757 757
758 if (!element) { 758 if (!element) {
759 // If there's a RemoteFrame on the ancestor chain, we need to continue 759 // If there's a RemoteFrame on the ancestor chain, we need to continue
760 // searching for focusable elements there. 760 // searching for focusable elements there.
761 if (frame->localFrameRoot() != frame->tree().top()) { 761 if (frame->localFrameRoot() != frame->tree().top()) {
762 document->clearFocusedElement(); 762 document->clearFocusedElement();
763 document->setSequentialFocusNavigationStartingPoint(nullptr);
763 toRemoteFrame(frame->localFrameRoot()->tree().parent())->advanceFocu s(type, frame->localFrameRoot()); 764 toRemoteFrame(frame->localFrameRoot()->tree().parent())->advanceFocu s(type, frame->localFrameRoot());
764 return true; 765 return true;
765 } 766 }
766 767
767 // We didn't find an element to focus, so we should try to pass focus to Chrome. 768 // We didn't find an element to focus, so we should try to pass focus to Chrome.
768 if (!initialFocus && m_page->chromeClient().canTakeFocus(type)) { 769 if (!initialFocus && m_page->chromeClient().canTakeFocus(type)) {
769 document->clearFocusedElement(); 770 document->clearFocusedElement();
771 document->setSequentialFocusNavigationStartingPoint(nullptr);
770 setFocusedFrame(nullptr); 772 setFocusedFrame(nullptr);
771 m_page->chromeClient().takeFocus(type); 773 m_page->chromeClient().takeFocus(type);
772 return true; 774 return true;
773 } 775 }
774 776
775 // Chrome doesn't want focus, so we should wrap focus. 777 // Chrome doesn't want focus, so we should wrap focus.
776 element = findFocusableElementRecursively(type, FocusNavigationScope::fo cusNavigationScopeOf(*toLocalFrame(m_page->mainFrame())->document()->documentEle ment()), nullptr); 778 element = findFocusableElementRecursively(type, FocusNavigationScope::fo cusNavigationScopeOf(*toLocalFrame(m_page->mainFrame())->document()->documentEle ment()), nullptr);
777 element = findFocusableElementDescendingDownIntoFrameDocument(type, elem ent.get()); 779 element = findFocusableElementDescendingDownIntoFrameDocument(type, elem ent.get());
778 780
779 if (!element) 781 if (!element)
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 return consumed; 1137 return consumed;
1136 } 1138 }
1137 1139
1138 DEFINE_TRACE(FocusController) 1140 DEFINE_TRACE(FocusController)
1139 { 1141 {
1140 visitor->trace(m_page); 1142 visitor->trace(m_page);
1141 visitor->trace(m_focusedFrame); 1143 visitor->trace(m_focusedFrame);
1142 } 1144 }
1143 1145
1144 } // namespace blink 1146 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698