Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: Source/core/page/FocusController.cpp

Issue 17450016: Implementation of CSS3 nav-up/down/left/right properties from CSS3 UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased once again to master, fixed layout test. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 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
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 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 consumed = advanceFocusDirectionallyInContainer(container, startingRect, type); 915 consumed = advanceFocusDirectionallyInContainer(container, startingRect, type);
913 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */); 916 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */);
914 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container); 917 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container);
915 if (container && container->isDocumentNode()) 918 if (container && container->isDocumentNode())
916 toDocument(container)->updateLayoutIgnorePendingStylesheets(); 919 toDocument(container)->updateLayoutIgnorePendingStylesheets();
917 } while (!consumed && container); 920 } while (!consumed && container);
918 921
919 return consumed; 922 return consumed;
920 } 923 }
921 924
925 bool FocusController::handleCSSFocusNavigation(FocusType type)
926 {
927 DEFINE_STATIC_LOCAL(AtomicString, Current, ("current"));
fs 2014/04/14 12:32:01 Maybe make this 'targetCurrent' or 'frameTargetCur
Krzysztof Olczyk 2014/04/17 13:48:40 Done.
928 DEFINE_STATIC_LOCAL(AtomicString, Root, ("root"));
929
930 if (!focusedOrMainFrame()->isLocalFrame())
931 return false;
932
933 LocalFrame* currentFrame = toLocalFrame(focusedOrMainFrame());
934 ASSERT(currentFrame);
fs 2014/04/14 12:32:01 Already dereference focusedOrMainFrame() above.
Krzysztof Olczyk 2014/04/17 13:48:40 Done.
935
936 Document* focusedDocument = currentFrame->document();
937 if (!focusedDocument)
938 return false;
939
940 Element* focused = focusedDocument->focusedElement();
941 RenderObject* renderer = focused ? focused->renderer() : 0;
942 if (!renderer)
943 return false;
944
945 StyleNavigationValue value;
946
947 if (StyleNavigationData* navigationData = renderer->style()->navigation()) {
948 switch (type) {
949 case FocusTypeForward:
950 case FocusTypeBackward:
951 return false;
952 case FocusTypeUp:
953 value = navigationData->up();
954 break;
955 case FocusTypeDown:
956 value = navigationData->down();
957 break;
958 case FocusTypeLeft:
959 value = navigationData->left();
960 break;
961 case FocusTypeRight:
962 value = navigationData->right();
963 break;
964 case FocusTypeNone:
965 default:
966 ASSERT_NOT_REACHED();
967 break;
968 }
969 }
970
971 if (value.id().isNull() || value.isAuto())
fs 2014/04/14 12:32:01 When will id() be the nullAtom?
Krzysztof Olczyk 2014/04/17 13:48:40 Done.
972 return false;
973
974 const AtomicString& target = value.target();
975 Frame* targetFrame = 0;
976
977 // If we were in the autoscroll/panScroll mode we want to stop it.
978 currentFrame->eventHandler().stopAutoscroll();
979
980 if (target == Current)
981 targetFrame = currentFrame;
982 else if (target == Root)
983 targetFrame = currentFrame->tree().top();
984 else
985 targetFrame = currentFrame->tree().find(target);
986
987 if (!targetFrame)
988 return false;
989
990 Element* targetElement = targetFrame->document()->getElementById(value.id()) ;
991
992 if (!targetElement)
993 return false;
994 // If it's same with the current focused, it should be consumed.
fs 2014/04/14 12:32:01 s/same with the current/the same as the currently/
Krzysztof Olczyk 2014/04/17 13:48:40 Done.
995 if (focused == targetElement)
996 return true;
997
998 return setFocusedElement(targetElement, targetFrame);
999 }
1000
922 } // namespace WebCore 1001 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698