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

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

Issue 2392463002: DO NOT SUBMIT: Fix input action type for Android
Patch Set: Created 4 years, 2 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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 winningTabIndex = currentTabIndex; 434 winningTabIndex = currentTabIndex;
435 } 435 }
436 } 436 }
437 return winner; 437 return winner;
438 } 438 }
439 439
440 Element* nextFocusableElement(ScopedFocusNavigation& scope) 440 Element* nextFocusableElement(ScopedFocusNavigation& scope)
441 { 441 {
442 Element* current = scope.currentElement(); 442 Element* current = scope.currentElement();
443 if (current) { 443 if (current) {
444 LOG(ERROR) << "XXX nextFocusable: " << current->outerHTML();
444 int tabIndex = adjustedTabIndex(*current); 445 int tabIndex = adjustedTabIndex(*current);
445 // If an element is excluded from the normal tabbing cycle, the next foc usable element is determined by tree order 446 // If an element is excluded from the normal tabbing cycle, the next foc usable element is determined by tree order
447 LOG(ERROR) << "XXX nextFocusable: " << tabIndex;
446 if (tabIndex < 0) { 448 if (tabIndex < 0) {
447 for (scope.moveToNext(); scope.currentElement(); scope.moveToNext()) { 449 for (scope.moveToNext(); scope.currentElement(); scope.moveToNext()) {
448 current = scope.currentElement(); 450 current = scope.currentElement();
449 if (shouldVisit(*current) && adjustedTabIndex(*current) >= 0) 451 if (shouldVisit(*current) && adjustedTabIndex(*current) >= 0)
450 return current; 452 return current;
451 } 453 }
452 } else { 454 } else {
453 // First try to find an element with the same tabindex as start that comes after start in the scope. 455 // First try to find an element with the same tabindex as start that comes after start in the scope.
454 scope.moveToNext(); 456 scope.moveToNext();
455 if (Element* winner = findElementWithExactTabIndex(scope, tabIndex, WebFocusTypeForward)) 457 if (Element* winner = findElementWithExactTabIndex(scope, tabIndex, WebFocusTypeForward))
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 { 528 {
527 Element* found = (type == WebFocusTypeForward) ? nextFocusableElement(scope) : previousFocusableElement(scope); 529 Element* found = (type == WebFocusTypeForward) ? nextFocusableElement(scope) : previousFocusableElement(scope);
528 return found; 530 return found;
529 } 531 }
530 532
531 Element* findFocusableElementRecursivelyForward(ScopedFocusNavigation& scope) 533 Element* findFocusableElementRecursivelyForward(ScopedFocusNavigation& scope)
532 { 534 {
533 // Starting element is exclusive. 535 // Starting element is exclusive.
534 Element* found = findFocusableElementInternal(WebFocusTypeForward, scope); 536 Element* found = findFocusableElementInternal(WebFocusTypeForward, scope);
535 while (found) { 537 while (found) {
538 LOG(ERROR) << "XXX findFocusable: " << found->outerHTML();
536 if (isShadowHostDelegatesFocus(*found)) { 539 if (isShadowHostDelegatesFocus(*found)) {
537 // If tabindex is positive, find focusable element inside its shadow tree. 540 // If tabindex is positive, find focusable element inside its shadow tree.
538 if (found->tabIndex() >= 0 && isShadowHostWithoutCustomFocusLogic(*f ound)) { 541 if (found->tabIndex() >= 0 && isShadowHostWithoutCustomFocusLogic(*f ound)) {
539 ScopedFocusNavigation innerScope = ScopedFocusNavigation::ownedB yShadowHost(*found); 542 ScopedFocusNavigation innerScope = ScopedFocusNavigation::ownedB yShadowHost(*found);
540 if (Element* foundInInnerFocusScope = findFocusableElementRecurs ivelyForward(innerScope)) 543 if (Element* foundInInnerFocusScope = findFocusableElementRecurs ivelyForward(innerScope))
541 return foundInInnerFocusScope; 544 return foundInInnerFocusScope;
542 } 545 }
543 // Skip to the next element in the same scope. 546 // Skip to the next element in the same scope.
544 found = findFocusableElementInternal(WebFocusTypeForward, scope); 547 found = findFocusableElementInternal(WebFocusTypeForward, scope);
545 continue; 548 continue;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 // of handleFocusedUIElementChanged, because this will send the notification even if the element is the same. 859 // of handleFocusedUIElementChanged, because this will send the notification even if the element is the same.
857 if (focusedOrMainFrame()->isLocalFrame()) { 860 if (focusedOrMainFrame()->isLocalFrame()) {
858 Document* document = toLocalFrame(focusedOrMainFrame())->document(); 861 Document* document = toLocalFrame(focusedOrMainFrame())->document();
859 if (AXObjectCache* cache = document->existingAXObjectCache()) 862 if (AXObjectCache* cache = document->existingAXObjectCache())
860 cache->handleInitialFocus(); 863 cache->handleInitialFocus();
861 } 864 }
862 865
863 return didAdvanceFocus; 866 return didAdvanceFocus;
864 } 867 }
865 868
869 Element* FocusController::getCurrentElementForFocusNavigation(WebFocusType type) {
870 LocalFrame* frame = toLocalFrame(focusedOrMainFrame());
871 Document* document = frame->document();
872 document->updateStyleAndLayoutIgnorePendingStylesheets();
873
874 Element* current = document->sequentialFocusNavigationStartingPoint(type);
875
876 // FIXME: Not quite correct when it comes to focus transitions leaving/enter ing the WebView itself
877 bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEn abled();
878
879 if (caretBrowsing && !current)
880 current = adjustToElement(frame->selection().start().anchorNode(), type) ;
881 return current;
882 }
883
884 Element* FocusController::findNextFocusableElementInDocumentOrder() {
885 LocalFrame* frame = toLocalFrame(focusedOrMainFrame());
886 Document* document = frame->document();
887 document->updateStyleAndLayoutIgnorePendingStylesheets();
888 WebFocusType type = WebFocusTypeForward;
889 Element* current = getCurrentElementForFocusNavigation(type);
890 ScopedFocusNavigation scope = current ? ScopedFocusNavigation::createFor(*cu rrent) : ScopedFocusNavigation::createForDocument(*document);
891 return findFocusableElementAcrossFocusScopes(type, scope);
892 }
893
866 bool FocusController::advanceFocus(WebFocusType type, bool initialFocus, InputDe viceCapabilities* sourceCapabilities) 894 bool FocusController::advanceFocus(WebFocusType type, bool initialFocus, InputDe viceCapabilities* sourceCapabilities)
867 { 895 {
868 switch (type) { 896 switch (type) {
869 case WebFocusTypeForward: 897 case WebFocusTypeForward:
870 case WebFocusTypeBackward: { 898 case WebFocusTypeBackward: {
871 // We should never hit this when a RemoteFrame is focused, since the key 899 // We should never hit this when a RemoteFrame is focused, since the key
872 // event that initiated focus advancement should've been routed to that 900 // event that initiated focus advancement should've been routed to that
873 // frame's process from the beginning. 901 // frame's process from the beginning.
874 LocalFrame* startingFrame = toLocalFrame(focusedOrMainFrame()); 902 LocalFrame* startingFrame = toLocalFrame(focusedOrMainFrame());
875 return advanceFocusInDocumentOrder(startingFrame, nullptr, type, initial Focus, sourceCapabilities); 903 return advanceFocusInDocumentOrder(startingFrame, nullptr, type, initial Focus, sourceCapabilities);
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 return consumed; 1342 return consumed;
1315 } 1343 }
1316 1344
1317 DEFINE_TRACE(FocusController) 1345 DEFINE_TRACE(FocusController)
1318 { 1346 {
1319 visitor->trace(m_page); 1347 visitor->trace(m_page);
1320 visitor->trace(m_focusedFrame); 1348 visitor->trace(m_focusedFrame);
1321 } 1349 }
1322 1350
1323 } // namespace blink 1351 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/FocusController.h ('k') | third_party/WebKit/Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698