OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. |
8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 #include "core/html/HTMLPlugInElement.h" | 101 #include "core/html/HTMLPlugInElement.h" |
102 #include "core/html/HTMLTableRowsCollection.h" | 102 #include "core/html/HTMLTableRowsCollection.h" |
103 #include "core/html/HTMLTemplateElement.h" | 103 #include "core/html/HTMLTemplateElement.h" |
104 #include "core/html/parser/HTMLParserIdioms.h" | 104 #include "core/html/parser/HTMLParserIdioms.h" |
105 #include "core/inspector/InspectorInstrumentation.h" | 105 #include "core/inspector/InspectorInstrumentation.h" |
106 #include "core/page/Chrome.h" | 106 #include "core/page/Chrome.h" |
107 #include "core/page/ChromeClient.h" | 107 #include "core/page/ChromeClient.h" |
108 #include "core/page/FocusController.h" | 108 #include "core/page/FocusController.h" |
109 #include "core/page/Page.h" | 109 #include "core/page/Page.h" |
110 #include "core/page/PointerLockController.h" | 110 #include "core/page/PointerLockController.h" |
111 #include "core/page/SpatialNavigation.h" | |
112 #include "core/rendering/RenderLayer.h" | 111 #include "core/rendering/RenderLayer.h" |
113 #include "core/rendering/RenderTextFragment.h" | 112 #include "core/rendering/RenderTextFragment.h" |
114 #include "core/rendering/RenderView.h" | 113 #include "core/rendering/RenderView.h" |
115 #include "core/rendering/compositing/RenderLayerCompositor.h" | 114 #include "core/rendering/compositing/RenderLayerCompositor.h" |
116 #include "core/svg/SVGDocumentExtensions.h" | 115 #include "core/svg/SVGDocumentExtensions.h" |
117 #include "core/svg/SVGElement.h" | 116 #include "core/svg/SVGElement.h" |
118 #include "platform/EventDispatchForbiddenScope.h" | 117 #include "platform/EventDispatchForbiddenScope.h" |
119 #include "platform/RuntimeEnabledFeatures.h" | 118 #include "platform/RuntimeEnabledFeatures.h" |
120 #include "platform/UserGestureIndicator.h" | 119 #include "platform/UserGestureIndicator.h" |
121 #include "platform/scroll/ScrollableArea.h" | 120 #include "platform/scroll/ScrollableArea.h" |
(...skipping 2091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2213 } | 2212 } |
2214 } | 2213 } |
2215 | 2214 |
2216 bool Element::supportsFocus() const | 2215 bool Element::supportsFocus() const |
2217 { | 2216 { |
2218 // FIXME: supportsFocus() can be called when layout is not up to date. | 2217 // FIXME: supportsFocus() can be called when layout is not up to date. |
2219 // Logic that deals with the renderer should be moved to rendererIsFocusable
(). | 2218 // Logic that deals with the renderer should be moved to rendererIsFocusable
(). |
2220 // But supportsFocus must return true when the element is editable, or else | 2219 // But supportsFocus must return true when the element is editable, or else |
2221 // it won't be focusable. Furthermore, supportsFocus cannot just return true | 2220 // it won't be focusable. Furthermore, supportsFocus cannot just return true |
2222 // always or else tabIndex() will change for all HTML elements. | 2221 // always or else tabIndex() will change for all HTML elements. |
2223 return hasElementFlag(TabIndexWasSetExplicitly) || (hasEditableStyle() && pa
rentNode() && !parentNode()->hasEditableStyle()) | 2222 return hasElementFlag(TabIndexWasSetExplicitly) || (hasEditableStyle() && pa
rentNode() && !parentNode()->hasEditableStyle()); |
2224 || supportsSpatialNavigationFocus(); | |
2225 } | |
2226 | |
2227 bool Element::supportsSpatialNavigationFocus() const | |
2228 { | |
2229 // This function checks whether the element satisfies the extended criteria | |
2230 // for the element to be focusable, introduced by spatial navigation feature
, | |
2231 // i.e. checks if click or keyboard event handler is specified. | |
2232 // This is the way to make it possible to navigate to (focus) elements | |
2233 // which web designer meant for being active (made them respond to click eve
nts). | |
2234 | |
2235 if (!isSpatialNavigationEnabled(document().frame())) | |
2236 return false; | |
2237 if (hasEventListeners(EventTypeNames::click) | |
2238 || hasEventListeners(EventTypeNames::keydown) | |
2239 || hasEventListeners(EventTypeNames::keypress) | |
2240 || hasEventListeners(EventTypeNames::keyup)) | |
2241 return true; | |
2242 if (!isSVGElement()) | |
2243 return false; | |
2244 return (hasEventListeners(EventTypeNames::focus) | |
2245 || hasEventListeners(EventTypeNames::blur) | |
2246 || hasEventListeners(EventTypeNames::focusin) | |
2247 || hasEventListeners(EventTypeNames::focusout)); | |
2248 } | 2223 } |
2249 | 2224 |
2250 bool Element::isFocusable() const | 2225 bool Element::isFocusable() const |
2251 { | 2226 { |
2252 return inDocument() && supportsFocus() && !isInert() && rendererIsFocusable(
); | 2227 return inDocument() && supportsFocus() && !isInert() && rendererIsFocusable(
); |
2253 } | 2228 } |
2254 | 2229 |
2255 bool Element::isKeyboardFocusable() const | 2230 bool Element::isKeyboardFocusable() const |
2256 { | 2231 { |
2257 return isFocusable() && tabIndex() >= 0; | 2232 return isFocusable() && tabIndex() >= 0; |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3421 return wrapper; | 3396 return wrapper; |
3422 | 3397 |
3423 CustomElementBinding* binding = perContextData->customElementBinding(customE
lementDefinition()); | 3398 CustomElementBinding* binding = perContextData->customElementBinding(customE
lementDefinition()); |
3424 | 3399 |
3425 wrapper->SetPrototype(binding->prototype()); | 3400 wrapper->SetPrototype(binding->prototype()); |
3426 | 3401 |
3427 return V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperType,
wrapper); | 3402 return V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperType,
wrapper); |
3428 } | 3403 } |
3429 | 3404 |
3430 } // namespace blink | 3405 } // namespace blink |
OLD | NEW |