Index: third_party/WebKit/Source/core/page/FocusController.cpp |
diff --git a/third_party/WebKit/Source/core/page/FocusController.cpp b/third_party/WebKit/Source/core/page/FocusController.cpp |
index b12d00e65daf5be5c67ba009d8722122e1bcb590..e043a6716ca77230114b53caae4ff6671cf8605f 100644 |
--- a/third_party/WebKit/Source/core/page/FocusController.cpp |
+++ b/third_party/WebKit/Source/core/page/FocusController.cpp |
@@ -441,8 +441,10 @@ Element* nextFocusableElement(ScopedFocusNavigation& scope) |
{ |
Element* current = scope.currentElement(); |
if (current) { |
+ LOG(ERROR) << "XXX nextFocusable: " << current->outerHTML(); |
int tabIndex = adjustedTabIndex(*current); |
// If an element is excluded from the normal tabbing cycle, the next focusable element is determined by tree order |
+ LOG(ERROR) << "XXX nextFocusable: " << tabIndex; |
if (tabIndex < 0) { |
for (scope.moveToNext(); scope.currentElement(); scope.moveToNext()) { |
current = scope.currentElement(); |
@@ -533,6 +535,7 @@ Element* findFocusableElementRecursivelyForward(ScopedFocusNavigation& scope) |
// Starting element is exclusive. |
Element* found = findFocusableElementInternal(WebFocusTypeForward, scope); |
while (found) { |
+ LOG(ERROR) << "XXX findFocusable: " << found->outerHTML(); |
if (isShadowHostDelegatesFocus(*found)) { |
// If tabindex is positive, find focusable element inside its shadow tree. |
if (found->tabIndex() >= 0 && isShadowHostWithoutCustomFocusLogic(*found)) { |
@@ -863,6 +866,31 @@ bool FocusController::setInitialFocus(WebFocusType type) |
return didAdvanceFocus; |
} |
+Element* FocusController::getCurrentElementForFocusNavigation(WebFocusType type) { |
+ LocalFrame* frame = toLocalFrame(focusedOrMainFrame()); |
+ Document* document = frame->document(); |
+ document->updateStyleAndLayoutIgnorePendingStylesheets(); |
+ |
+ Element* current = document->sequentialFocusNavigationStartingPoint(type); |
+ |
+ // FIXME: Not quite correct when it comes to focus transitions leaving/entering the WebView itself |
+ bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEnabled(); |
+ |
+ if (caretBrowsing && !current) |
+ current = adjustToElement(frame->selection().start().anchorNode(), type); |
+ return current; |
+} |
+ |
+Element* FocusController::findNextFocusableElementInDocumentOrder() { |
+ LocalFrame* frame = toLocalFrame(focusedOrMainFrame()); |
+ Document* document = frame->document(); |
+ document->updateStyleAndLayoutIgnorePendingStylesheets(); |
+ WebFocusType type = WebFocusTypeForward; |
+ Element* current = getCurrentElementForFocusNavigation(type); |
+ ScopedFocusNavigation scope = current ? ScopedFocusNavigation::createFor(*current) : ScopedFocusNavigation::createForDocument(*document); |
+ return findFocusableElementAcrossFocusScopes(type, scope); |
+} |
+ |
bool FocusController::advanceFocus(WebFocusType type, bool initialFocus, InputDeviceCapabilities* sourceCapabilities) |
{ |
switch (type) { |