OLD | NEW |
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 * Copyright (C) 2013, 2014 Opera Software ASA. All rights reserved. |
4 * | 5 * |
5 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
7 * are met: | 8 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
11 * notice, this list of conditions and the following disclaimer in the | 12 * notice, this list of conditions and the following disclaimer in the |
12 * documentation and/or other materials provided with the distribution. | 13 * documentation and/or other materials provided with the distribution. |
13 * | 14 * |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "core/html/HTMLShadowElement.h" | 51 #include "core/html/HTMLShadowElement.h" |
51 #include "core/page/Chrome.h" | 52 #include "core/page/Chrome.h" |
52 #include "core/page/ChromeClient.h" | 53 #include "core/page/ChromeClient.h" |
53 #include "core/page/EventHandler.h" | 54 #include "core/page/EventHandler.h" |
54 #include "core/page/FrameTree.h" | 55 #include "core/page/FrameTree.h" |
55 #include "core/page/Page.h" | 56 #include "core/page/Page.h" |
56 #include "core/frame/Settings.h" | 57 #include "core/frame/Settings.h" |
57 #include "core/page/SpatialNavigation.h" | 58 #include "core/page/SpatialNavigation.h" |
58 #include "core/rendering/HitTestResult.h" | 59 #include "core/rendering/HitTestResult.h" |
59 #include "core/rendering/RenderLayer.h" | 60 #include "core/rendering/RenderLayer.h" |
| 61 #include "core/rendering/RenderObject.h" |
| 62 #include "core/rendering/style/StyleNavigationValue.h" |
60 | 63 |
61 namespace WebCore { | 64 namespace WebCore { |
62 | 65 |
63 using namespace HTMLNames; | 66 using namespace HTMLNames; |
64 | 67 |
65 static inline bool isShadowInsertionPointFocusScopeOwner(Node& node) | 68 static inline bool isShadowInsertionPointFocusScopeOwner(Node& node) |
66 { | 69 { |
67 return isActiveShadowInsertionPoint(node) && toHTMLShadowElement(node).older
ShadowRoot(); | 70 return isActiveShadowInsertionPoint(node) && toHTMLShadowElement(node).older
ShadowRoot(); |
68 } | 71 } |
69 | 72 |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 consumed = advanceFocusDirectionallyInContainer(container, startingRect,
type); | 919 consumed = advanceFocusDirectionallyInContainer(container, startingRect,
type); |
917 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b
order */); | 920 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b
order */); |
918 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type,
container); | 921 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type,
container); |
919 if (container && container->isDocumentNode()) | 922 if (container && container->isDocumentNode()) |
920 toDocument(container)->updateLayoutIgnorePendingStylesheets(); | 923 toDocument(container)->updateLayoutIgnorePendingStylesheets(); |
921 } while (!consumed && container); | 924 } while (!consumed && container); |
922 | 925 |
923 return consumed; | 926 return consumed; |
924 } | 927 } |
925 | 928 |
| 929 bool FocusController::handleCSSFocusNavigation(FocusType type) |
| 930 { |
| 931 DEFINE_STATIC_LOCAL(AtomicString, frameTargetCurrent, ("current")); |
| 932 DEFINE_STATIC_LOCAL(AtomicString, frameTargetRoot, ("root")); |
| 933 |
| 934 ASSERT(focusedOrMainFrame()); |
| 935 if (!focusedOrMainFrame()->isLocalFrame()) |
| 936 return false; |
| 937 |
| 938 LocalFrame* currentFrame = toLocalFrame(focusedOrMainFrame()); |
| 939 Document* focusedDocument = currentFrame->document(); |
| 940 if (!focusedDocument) |
| 941 return false; |
| 942 |
| 943 Element* focused = focusedDocument->focusedElement(); |
| 944 RenderObject* renderer = focused ? focused->renderer() : 0; |
| 945 if (!renderer) |
| 946 return false; |
| 947 |
| 948 StyleNavigationValue value; |
| 949 |
| 950 switch (type) { |
| 951 case FocusTypeForward: |
| 952 case FocusTypeBackward: |
| 953 return false; |
| 954 case FocusTypeUp: |
| 955 value = renderer->style()->navUp(); |
| 956 break; |
| 957 case FocusTypeDown: |
| 958 value = renderer->style()->navDown(); |
| 959 break; |
| 960 case FocusTypeLeft: |
| 961 value = renderer->style()->navLeft(); |
| 962 break; |
| 963 case FocusTypeRight: |
| 964 value = renderer->style()->navRight(); |
| 965 break; |
| 966 case FocusTypeNone: |
| 967 default: |
| 968 ASSERT_NOT_REACHED(); |
| 969 break; |
| 970 } |
| 971 |
| 972 if (value.isAuto()) |
| 973 return false; |
| 974 |
| 975 const AtomicString& target = value.target(); |
| 976 LocalFrame* targetFrame = 0; |
| 977 |
| 978 // If we were in the autoscroll/panScroll mode we want to stop it. |
| 979 currentFrame->eventHandler().stopAutoscroll(); |
| 980 |
| 981 if (target == frameTargetCurrent) |
| 982 targetFrame = currentFrame; |
| 983 else if (target == frameTargetRoot) |
| 984 targetFrame = currentFrame->tree().top(); |
| 985 else |
| 986 targetFrame = currentFrame->tree().find(target); |
| 987 |
| 988 if (!targetFrame) |
| 989 return false; |
| 990 |
| 991 Element* targetElement = targetFrame->document()->getElementById(value.id())
; |
| 992 |
| 993 if (!targetElement) |
| 994 return false; |
| 995 |
| 996 // If it's the same as the current focused, it should be considered a valid
navigation, |
| 997 // but there is no need to change focus. |
| 998 if (focused == targetElement) |
| 999 return true; |
| 1000 |
| 1001 return setFocusedElement(targetElement, targetFrame); |
| 1002 } |
| 1003 |
926 } // namespace WebCore | 1004 } // namespace WebCore |
OLD | NEW |