Index: third_party/WebKit/Source/core/dom/Document.cpp |
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp |
index 26eaa9784d595e6208066fc7919d128cfd9b555a..03338a756a267a2cf3f1eddee32e5f176d7bd0fb 100644 |
--- a/third_party/WebKit/Source/core/dom/Document.cpp |
+++ b/third_party/WebKit/Source/core/dom/Document.cpp |
@@ -3729,7 +3729,7 @@ void Document::setSequentialFocusNavigationStartingPoint(Node* node) |
ASSERT(node->document() == this); |
if (!m_sequentialFocusNavigationStartingPoint) |
m_sequentialFocusNavigationStartingPoint = Range::create(*this); |
- m_sequentialFocusNavigationStartingPoint->selectNodeContents(node->isElementNode() ? node : node->parentOrShadowHostElement(), ASSERT_NO_EXCEPTION); |
+ m_sequentialFocusNavigationStartingPoint->selectNodeContents(node, ASSERT_NO_EXCEPTION); |
} |
Element* Document::sequentialFocusNavigationStartingPoint(WebFocusType type) const |
@@ -3741,7 +3741,11 @@ Element* Document::sequentialFocusNavigationStartingPoint(WebFocusType type) con |
if (!m_sequentialFocusNavigationStartingPoint->collapsed()) { |
Node* node = m_sequentialFocusNavigationStartingPoint->startContainer(); |
ASSERT(node == m_sequentialFocusNavigationStartingPoint->endContainer()); |
- return node->isElementNode() ? toElement(node) : node->parentOrShadowHostElement(); |
+ if (node->isElementNode()) |
+ return toElement(node); |
+ if (Element* neighborElement = type == WebFocusTypeForward ? ElementTraversal::previous(*node) : ElementTraversal::next(*node)) |
+ return neighborElement; |
+ return node->parentOrShadowHostElement(); |
} |
// Range::selectNodeContents didn't select contents because the element had |