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 e7db0e88b3fb5fee07ff302a4ae00a7ad489d90b..c18275df1464b7fa873952fc4c1621645e22d2dd 100644 |
--- a/third_party/WebKit/Source/core/page/FocusController.cpp |
+++ b/third_party/WebKit/Source/core/page/FocusController.cpp |
@@ -1,6 +1,8 @@ |
/* |
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
* Copyright (C) 2008 Nuanti Ltd. |
+ * Copyright (C) 2013, 2014 Opera Software ASA. All rights reserved. |
+ * Copyright (C) 2016 Samsung Electronics. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
@@ -32,6 +34,7 @@ |
#include "core/dom/Document.h" |
#include "core/dom/Element.h" |
#include "core/dom/ElementTraversal.h" |
+#include "core/dom/NodeComputedStyle.h" |
#include "core/dom/Range.h" |
#include "core/dom/shadow/ElementShadow.h" |
#include "core/dom/shadow/ShadowRoot.h" |
@@ -58,6 +61,7 @@ |
#include "core/page/Page.h" |
#include "core/layout/HitTestResult.h" |
#include "core/page/SpatialNavigation.h" |
+#include "core/style/StyleNavigationValue.h" |
#include <limits> |
namespace blink { |
@@ -1315,4 +1319,76 @@ DEFINE_TRACE(FocusController) |
visitor->trace(m_focusedFrame); |
} |
+bool FocusController::advanceCSSNavigationFocus(WebFocusType type) |
fs
2016/05/18 15:55:05
Could this be refactored into something that advan
|
+{ |
+ ASSERT(focusedOrMainFrame()); |
+ if (!focusedOrMainFrame()->isLocalFrame()) |
+ return false; |
+ |
+ LocalFrame* currentFrame = toLocalFrame(focusedOrMainFrame()); |
+ Document* focusedDocument = currentFrame->document(); |
+ if (!focusedDocument) |
+ return false; |
+ |
+ Element* focused = focusedDocument->focusedElement(); |
+ const ComputedStyle* style = focused ? focused->computedStyle() : 0; |
+ if (!style) |
+ return false; |
+ |
+ StyleNavigationValue value; |
+ |
+ switch (type) { |
+ case WebFocusTypeForward: |
+ case WebFocusTypeBackward: |
fs
2016/05/18 15:55:05
We should never see these in this code-path IIRC,
|
+ return false; |
+ case WebFocusTypeUp: |
+ value = style->navUp(); |
+ break; |
+ case WebFocusTypeDown: |
+ value = style->navDown(); |
+ break; |
+ case WebFocusTypeLeft: |
+ value = style->navLeft(); |
+ break; |
+ case WebFocusTypeRight: |
+ value = style->navRight(); |
+ break; |
+ case WebFocusTypeNone: |
+ default: |
+ ASSERT_NOT_REACHED(); |
+ break; |
+ } |
+ |
+ if (value.isAuto()) |
+ return false; |
+ |
+ // If we were in the autoscroll/panScroll mode we want to stop it. |
+ currentFrame->eventHandler().stopAutoscroll(); |
+ |
+ ENavigationTarget navigationTarget = value.navigationTarget(); |
+ Frame* targetFrame = 0; |
fs
2016/05/18 15:55:05
nullptr
|
+ if (navigationTarget == Current) |
+ targetFrame = currentFrame; |
+ else if (navigationTarget == Root) |
+ targetFrame = currentFrame->tree().top(); |
+ else |
+ targetFrame = currentFrame->tree().find(value.targetName()); |
+ |
+ if (!targetFrame || !targetFrame->isLocalFrame()) |
+ return false; |
+ |
+ Element* targetElement = toLocalFrame(targetFrame)->document()->getElementById(value.id()); |
+ if (!targetElement) |
+ return false; |
+ |
+ // If it's the same as the current focused, it should be considered a valid navigation, |
+ // but there is no need to change focus. |
+ if (focused == targetElement) |
+ return true; |
+ |
+ targetElement->focus(FocusParams(SelectionBehaviorOnFocus::Reset, type, nullptr)); |
+ return true; |
+// return setFocusedElement(targetElement, targetFrame); |
fs
2016/05/18 15:55:05
Remove.
|
+} |
+ |
} // namespace blink |