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. | |
5 * Copyright (C) 2016 Samsung Electronics. All rights reserved. | |
4 * | 6 * |
5 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
7 * are met: | 9 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 11 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 12 * 2. Redistributions in binary form must reproduce the above copyright |
11 * notice, this list of conditions and the following disclaimer in the | 13 * notice, this list of conditions and the following disclaimer in the |
12 * documentation and/or other materials provided with the distribution. | 14 * documentation and/or other materials provided with the distribution. |
13 * | 15 * |
(...skipping 11 matching lines...) Expand all Loading... | |
25 */ | 27 */ |
26 | 28 |
27 #include "core/page/FocusController.h" | 29 #include "core/page/FocusController.h" |
28 | 30 |
29 #include "core/HTMLNames.h" | 31 #include "core/HTMLNames.h" |
30 #include "core/dom/AXObjectCache.h" | 32 #include "core/dom/AXObjectCache.h" |
31 #include "core/dom/ContainerNode.h" | 33 #include "core/dom/ContainerNode.h" |
32 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
33 #include "core/dom/Element.h" | 35 #include "core/dom/Element.h" |
34 #include "core/dom/ElementTraversal.h" | 36 #include "core/dom/ElementTraversal.h" |
37 #include "core/dom/NodeComputedStyle.h" | |
35 #include "core/dom/Range.h" | 38 #include "core/dom/Range.h" |
36 #include "core/dom/shadow/ElementShadow.h" | 39 #include "core/dom/shadow/ElementShadow.h" |
37 #include "core/dom/shadow/ShadowRoot.h" | 40 #include "core/dom/shadow/ShadowRoot.h" |
38 #include "core/dom/shadow/SlotScopedTraversal.h" | 41 #include "core/dom/shadow/SlotScopedTraversal.h" |
39 #include "core/editing/EditingUtilities.h" // For firstPositionInOrBeforeNode | 42 #include "core/editing/EditingUtilities.h" // For firstPositionInOrBeforeNode |
40 #include "core/editing/Editor.h" | 43 #include "core/editing/Editor.h" |
41 #include "core/editing/FrameSelection.h" | 44 #include "core/editing/FrameSelection.h" |
42 #include "core/events/Event.h" | 45 #include "core/events/Event.h" |
43 #include "core/frame/FrameClient.h" | 46 #include "core/frame/FrameClient.h" |
44 #include "core/frame/FrameView.h" | 47 #include "core/frame/FrameView.h" |
45 #include "core/frame/LocalDOMWindow.h" | 48 #include "core/frame/LocalDOMWindow.h" |
46 #include "core/frame/LocalFrame.h" | 49 #include "core/frame/LocalFrame.h" |
47 #include "core/frame/RemoteFrame.h" | 50 #include "core/frame/RemoteFrame.h" |
48 #include "core/frame/Settings.h" | 51 #include "core/frame/Settings.h" |
49 #include "core/html/HTMLAreaElement.h" | 52 #include "core/html/HTMLAreaElement.h" |
50 #include "core/html/HTMLImageElement.h" | 53 #include "core/html/HTMLImageElement.h" |
51 #include "core/html/HTMLPlugInElement.h" | 54 #include "core/html/HTMLPlugInElement.h" |
52 #include "core/html/HTMLShadowElement.h" | 55 #include "core/html/HTMLShadowElement.h" |
53 #include "core/html/HTMLSlotElement.h" | 56 #include "core/html/HTMLSlotElement.h" |
54 #include "core/html/HTMLTextFormControlElement.h" | 57 #include "core/html/HTMLTextFormControlElement.h" |
55 #include "core/input/EventHandler.h" | 58 #include "core/input/EventHandler.h" |
56 #include "core/page/ChromeClient.h" | 59 #include "core/page/ChromeClient.h" |
57 #include "core/page/FrameTree.h" | 60 #include "core/page/FrameTree.h" |
58 #include "core/page/Page.h" | 61 #include "core/page/Page.h" |
59 #include "core/layout/HitTestResult.h" | 62 #include "core/layout/HitTestResult.h" |
60 #include "core/page/SpatialNavigation.h" | 63 #include "core/page/SpatialNavigation.h" |
64 #include "core/style/StyleNavigationValue.h" | |
61 #include <limits> | 65 #include <limits> |
62 | 66 |
63 namespace blink { | 67 namespace blink { |
64 | 68 |
65 using namespace HTMLNames; | 69 using namespace HTMLNames; |
66 | 70 |
67 namespace { | 71 namespace { |
68 | 72 |
69 inline bool isShadowInsertionPointFocusScopeOwner(Element& element) | 73 inline bool isShadowInsertionPointFocusScopeOwner(Element& element) |
70 { | 74 { |
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1308 | 1312 |
1309 return consumed; | 1313 return consumed; |
1310 } | 1314 } |
1311 | 1315 |
1312 DEFINE_TRACE(FocusController) | 1316 DEFINE_TRACE(FocusController) |
1313 { | 1317 { |
1314 visitor->trace(m_page); | 1318 visitor->trace(m_page); |
1315 visitor->trace(m_focusedFrame); | 1319 visitor->trace(m_focusedFrame); |
1316 } | 1320 } |
1317 | 1321 |
1322 bool FocusController::advanceCSSNavigationFocus(WebFocusType type) | |
fs
2016/05/18 15:55:05
Could this be refactored into something that advan
| |
1323 { | |
1324 ASSERT(focusedOrMainFrame()); | |
1325 if (!focusedOrMainFrame()->isLocalFrame()) | |
1326 return false; | |
1327 | |
1328 LocalFrame* currentFrame = toLocalFrame(focusedOrMainFrame()); | |
1329 Document* focusedDocument = currentFrame->document(); | |
1330 if (!focusedDocument) | |
1331 return false; | |
1332 | |
1333 Element* focused = focusedDocument->focusedElement(); | |
1334 const ComputedStyle* style = focused ? focused->computedStyle() : 0; | |
1335 if (!style) | |
1336 return false; | |
1337 | |
1338 StyleNavigationValue value; | |
1339 | |
1340 switch (type) { | |
1341 case WebFocusTypeForward: | |
1342 case WebFocusTypeBackward: | |
fs
2016/05/18 15:55:05
We should never see these in this code-path IIRC,
| |
1343 return false; | |
1344 case WebFocusTypeUp: | |
1345 value = style->navUp(); | |
1346 break; | |
1347 case WebFocusTypeDown: | |
1348 value = style->navDown(); | |
1349 break; | |
1350 case WebFocusTypeLeft: | |
1351 value = style->navLeft(); | |
1352 break; | |
1353 case WebFocusTypeRight: | |
1354 value = style->navRight(); | |
1355 break; | |
1356 case WebFocusTypeNone: | |
1357 default: | |
1358 ASSERT_NOT_REACHED(); | |
1359 break; | |
1360 } | |
1361 | |
1362 if (value.isAuto()) | |
1363 return false; | |
1364 | |
1365 // If we were in the autoscroll/panScroll mode we want to stop it. | |
1366 currentFrame->eventHandler().stopAutoscroll(); | |
1367 | |
1368 ENavigationTarget navigationTarget = value.navigationTarget(); | |
1369 Frame* targetFrame = 0; | |
fs
2016/05/18 15:55:05
nullptr
| |
1370 if (navigationTarget == Current) | |
1371 targetFrame = currentFrame; | |
1372 else if (navigationTarget == Root) | |
1373 targetFrame = currentFrame->tree().top(); | |
1374 else | |
1375 targetFrame = currentFrame->tree().find(value.targetName()); | |
1376 | |
1377 if (!targetFrame || !targetFrame->isLocalFrame()) | |
1378 return false; | |
1379 | |
1380 Element* targetElement = toLocalFrame(targetFrame)->document()->getElementBy Id(value.id()); | |
1381 if (!targetElement) | |
1382 return false; | |
1383 | |
1384 // If it's the same as the current focused, it should be considered a valid navigation, | |
1385 // but there is no need to change focus. | |
1386 if (focused == targetElement) | |
1387 return true; | |
1388 | |
1389 targetElement->focus(FocusParams(SelectionBehaviorOnFocus::Reset, type, null ptr)); | |
1390 return true; | |
1391 // return setFocusedElement(targetElement, targetFrame); | |
fs
2016/05/18 15:55:05
Remove.
| |
1392 } | |
1393 | |
1318 } // namespace blink | 1394 } // namespace blink |
OLD | NEW |