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 * | 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 #include "core/page/Chrome.h" | 47 #include "core/page/Chrome.h" |
48 #include "core/page/EditorClient.h" | 48 #include "core/page/EditorClient.h" |
49 #include "core/page/EventHandler.h" | 49 #include "core/page/EventHandler.h" |
50 #include "core/page/Frame.h" | 50 #include "core/page/Frame.h" |
51 #include "core/page/FrameTree.h" | 51 #include "core/page/FrameTree.h" |
52 #include "core/page/FrameView.h" | 52 #include "core/page/FrameView.h" |
53 #include "core/page/Page.h" | 53 #include "core/page/Page.h" |
54 #include "core/page/Settings.h" | 54 #include "core/page/Settings.h" |
55 #include "core/page/SpatialNavigation.h" | 55 #include "core/page/SpatialNavigation.h" |
56 #include "core/rendering/HitTestResult.h" | 56 #include "core/rendering/HitTestResult.h" |
57 #include "core/rendering/RenderObject.h" | |
58 #include "core/rendering/style/StyleNavigationValue.h" | |
57 | 59 |
58 namespace WebCore { | 60 namespace WebCore { |
59 | 61 |
60 using namespace HTMLNames; | 62 using namespace HTMLNames; |
61 using namespace std; | 63 using namespace std; |
62 | 64 |
63 FocusNavigationScope::FocusNavigationScope(TreeScope* treeScope) | 65 FocusNavigationScope::FocusNavigationScope(TreeScope* treeScope) |
64 : m_rootTreeScope(treeScope) | 66 : m_rootTreeScope(treeScope) |
65 { | 67 { |
66 ASSERT(treeScope); | 68 ASSERT(treeScope); |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
862 consumed = advanceFocusDirectionallyInContainer(container, startingRect, direction, event); | 864 consumed = advanceFocusDirectionallyInContainer(container, startingRect, direction, event); |
863 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */); | 865 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */); |
864 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direct ion, container); | 866 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direct ion, container); |
865 if (container && container->isDocumentNode()) | 867 if (container && container->isDocumentNode()) |
866 toDocument(container)->updateLayoutIgnorePendingStylesheets(); | 868 toDocument(container)->updateLayoutIgnorePendingStylesheets(); |
867 } while (!consumed && container); | 869 } while (!consumed && container); |
868 | 870 |
869 return consumed; | 871 return consumed; |
870 } | 872 } |
871 | 873 |
874 bool FocusController::handleCSSFocusNavigation(FocusDirection direction) | |
875 { | |
876 DEFINE_STATIC_LOCAL(AtomicString, Current, ("current")); | |
877 DEFINE_STATIC_LOCAL(AtomicString, Root, ("root")); | |
878 | |
879 Frame* curFrame = focusedOrMainFrame(); | |
esprehn
2013/06/20 19:45:10
frame, or currentFrame. No abbreviations.
Krzysztof Olczyk
2013/07/22 14:14:16
Done.
| |
880 ASSERT(curFrame); | |
881 | |
882 Document* focusedDocument = curFrame->document(); | |
883 if (!focusedDocument) | |
884 return false; | |
885 | |
886 Node* focusedNode = focusedDocument->focusedNode(); | |
887 RenderObject* renderer = focusedNode ? focusedNode->renderer() : 0; | |
888 if (!renderer) | |
889 return false; | |
890 | |
891 StyleNavigationValue value; | |
892 switch (direction) { | |
893 case FocusDirectionForward: | |
894 case FocusDirectionBackward: | |
895 return false; | |
896 case FocusDirectionUp: | |
897 value = renderer->style()->navUp(); | |
898 break; | |
899 case FocusDirectionDown: | |
900 value = renderer->style()->navDown(); | |
901 break; | |
902 case FocusDirectionLeft: | |
903 value = renderer->style()->navLeft(); | |
904 break; | |
905 case FocusDirectionRight: | |
906 value = renderer->style()->navRight(); | |
907 break; | |
908 case FocusDirectionNone: | |
909 default: | |
910 ASSERT_NOT_REACHED(); | |
911 break; | |
912 } | |
913 | |
914 if (value.id().isNull() || value.isAuto()) | |
915 return false; | |
916 | |
917 const AtomicString& target = value.target(); | |
918 Frame* targetFrame = 0; | |
919 | |
920 // If we were in the autoscroll/panScroll mode we want to stop it. | |
921 curFrame->eventHandler()->stopAutoscrollTimer(); | |
922 | |
923 if (target == Current) | |
924 targetFrame = curFrame; | |
925 else if (target == Root) | |
926 targetFrame = curFrame->tree()->top(); | |
927 else | |
928 targetFrame = curFrame->tree()->find(target); | |
929 | |
930 // TODO:// which one is right? | |
esprehn
2013/06/20 19:45:10
FIXME:, also you have extra //
Krzysztof Olczyk
2013/07/22 14:14:16
Done.
| |
931 if (!targetFrame) | |
932 return false; // targetFrame = curFrame; | |
933 | |
934 Element* anchorNode = targetFrame->document()->findAnchor(value.id().string( )); | |
935 if (!anchorNode) | |
936 return false; | |
937 // If it's same with the current focused, it should be consumed. | |
938 if (focusedNode == anchorNode) | |
939 return true; | |
940 | |
941 anchorNode->scrollIntoViewIfNeeded(false); | |
942 | |
943 bool successfullyFocused = setFocusedNode(anchorNode, targetFrame); | |
944 if (successfullyFocused) | |
945 m_page->chrome().focusedNodeChanged(anchorNode); | |
946 | |
947 return true; | |
948 } | |
949 | |
872 } // namespace WebCore | 950 } // namespace WebCore |
OLD | NEW |