Changeset 150687 in webkit
- Timestamp:
- May 25, 2013 5:02:35 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r150686 r150687 1 2013-05-25 Andreas Kling <akling@apple.com> 2 3 Move Node::isKeyboardFocusable() to Element. 4 <http://webkit.org/b/116761> 5 6 Reviewed by Antti Koivisto. 7 8 Only Elements can be keyboard-focusable. Move the base isKeyboardFocusable() implementation to Element 9 and sprinkle OVERRIDE on subclass overrides. 10 FocusController gets some temporary type checks that will go away as that code moves to dealing in 11 Elements instead of Node. 12 13 * dom/Node.h: 14 * dom/Node.cpp: 15 * dom/Element.h: 16 * dom/Element.cpp: 17 (WebCore::Element::isKeyboardFocusable): 18 19 Move isKeyboardFocusable() from Node to Element. 20 21 * page/FocusController.cpp: 22 (WebCore::isNonFocusableShadowHost): 23 (WebCore::isFocusableShadowHost): 24 (WebCore::shouldVisit): 25 (WebCore::FocusController::advanceFocusInDocumentOrder): 26 27 Check that the inspected Node is an Element before querying isKeyboardFocusable(). 28 29 * html/HTMLAnchorElement.h: 30 * html/HTMLAreaElement.h: 31 * html/HTMLFormControlElement.h: 32 * html/HTMLFrameOwnerElement.h: 33 * html/HTMLInputElement.h: 34 * html/HTMLPlugInElement.h: 35 * html/HTMLSelectElement.h: 36 * html/HTMLTextAreaElement.h: 37 * svg/SVGAElement.h: 38 * svg/SVGStyledElement.h: 39 40 Sprinkle OVERRIDE. 41 1 42 2013-05-25 Andreas Kling <akling@apple.com> 2 43 -
trunk/Source/WebCore/dom/Element.cpp
r150686 r150687 250 250 } 251 251 252 bool Element::isKeyboardFocusable(KeyboardEvent*) const 253 { 254 return isFocusable() && tabIndex() >= 0; 255 } 256 252 257 DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, blur); 253 258 DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, error); -
trunk/Source/WebCore/dom/Element.h
r150686 r150687 433 433 virtual void setFocus(bool flag); 434 434 435 virtual bool isKeyboardFocusable(KeyboardEvent*) const; 436 435 437 RenderStyle* computedStyle(PseudoId = NOPSEUDO); 436 438 -
trunk/Source/WebCore/dom/Node.cpp
r150686 r150687 886 886 } 887 887 888 bool Node::isKeyboardFocusable(KeyboardEvent*) const889 {890 return isFocusable() && tabIndex() >= 0;891 }892 893 888 bool Node::isMouseFocusable() const 894 889 { -
trunk/Source/WebCore/dom/Node.h
r150686 r150687 407 407 // Whether the node can actually be focused. 408 408 virtual bool isFocusable() const; 409 virtual bool isKeyboardFocusable(KeyboardEvent*) const;410 409 virtual bool isMouseFocusable() const; 411 410 virtual Node* focusDelegate(); -
trunk/Source/WebCore/html/HTMLAnchorElement.h
r135069 r150687 111 111 virtual bool supportsFocus() const; 112 112 virtual bool isMouseFocusable() const; 113 virtual bool isKeyboardFocusable(KeyboardEvent*) const ;113 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 114 114 virtual void defaultEventHandler(Event*); 115 115 virtual void setActive(bool active = true, bool pause = false); -
trunk/Source/WebCore/html/HTMLAreaElement.h
r149960 r150687 54 54 virtual bool supportsFocus() const; 55 55 virtual String target() const; 56 virtual bool isKeyboardFocusable(KeyboardEvent*) const ;56 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 57 57 virtual bool isMouseFocusable() const; 58 58 virtual bool isFocusable() const; -
trunk/Source/WebCore/html/HTMLFormControlElement.h
r148921 r150687 117 117 118 118 virtual bool supportsFocus() const; 119 virtual bool isKeyboardFocusable(KeyboardEvent*) const ;119 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 120 120 virtual bool isMouseFocusable() const; 121 121 -
trunk/Source/WebCore/html/HTMLFrameOwnerElement.h
r141524 r150687 66 66 67 67 private: 68 virtual bool isKeyboardFocusable(KeyboardEvent*) const ;68 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 69 69 virtual bool isFrameOwnerElement() const OVERRIDE { return true; } 70 70 -
trunk/Source/WebCore/html/HTMLInputElement.h
r148921 r150687 324 324 325 325 virtual bool hasCustomFocusLogic() const OVERRIDE; 326 virtual bool isKeyboardFocusable(KeyboardEvent*) const ;326 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 327 327 virtual bool isMouseFocusable() const; 328 328 virtual bool isEnumeratable() const; -
trunk/Source/WebCore/html/HTMLPlugInElement.h
r149871 r150687 106 106 virtual bool supportsFocus() const OVERRIDE; 107 107 108 virtual bool isKeyboardFocusable(KeyboardEvent*) const ;108 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 109 109 virtual bool isPluginElement() const; 110 110 -
trunk/Source/WebCore/html/HTMLSelectElement.h
r145399 r150687 112 112 virtual const AtomicString& formControlType() const; 113 113 114 virtual bool isKeyboardFocusable(KeyboardEvent*) const ;114 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 115 115 virtual bool isMouseFocusable() const; 116 116 -
trunk/Source/WebCore/html/HTMLTextAreaElement.h
r149960 r150687 106 106 virtual bool hasCustomFocusLogic() const OVERRIDE; 107 107 virtual bool isMouseFocusable() const; 108 virtual bool isKeyboardFocusable(KeyboardEvent*) const ;108 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 109 109 virtual void updateFocusAppearance(bool restorePreviousSelection); 110 110 -
trunk/Source/WebCore/page/FocusController.cpp
r150214 r150687 138 138 { 139 139 ASSERT(node); 140 return !node->isKeyboardFocusable(event) && isShadowHost(node) && !hasCustomFocusLogic(node);140 return node->isElementNode() && !toElement(node)->isKeyboardFocusable(event) && isShadowHost(node) && !hasCustomFocusLogic(node); 141 141 } 142 142 … … 144 144 { 145 145 ASSERT(node); 146 return node->is KeyboardFocusable(event) && isShadowHost(node) && !hasCustomFocusLogic(node);146 return node->isElementNode() && toElement(node)->isKeyboardFocusable(event) && isShadowHost(node) && !hasCustomFocusLogic(node); 147 147 } 148 148 … … 156 156 { 157 157 ASSERT(node); 158 return node->isKeyboardFocusable(event) || isNonFocusableShadowHost(node, event);158 return (node->isElementNode() && toElement(node)->isKeyboardFocusable(event)) || isNonFocusableShadowHost(node, event); 159 159 } 160 160 … … 321 321 return false; 322 322 323 if (node->isFrameOwnerElement() && (!node->isPluginElement() || !node->isKeyboardFocusable(event))) { 323 Element* element = toElement(node.get()); 324 325 if (element->isFrameOwnerElement() && (!element->isPluginElement() || !element->isKeyboardFocusable(event))) { 324 326 // We focus frames rather than frame owners. 325 327 // FIXME: We should not focus frames that have no scrollbars, as focusing them isn't useful to the user. 326 HTMLFrameOwnerElement* owner = static_cast<HTMLFrameOwnerElement*>(node.get());328 HTMLFrameOwnerElement* owner = toFrameOwnerElement(element); 327 329 if (!owner->contentFrame()) 328 330 return false; -
trunk/Source/WebCore/svg/SVGAElement.h
r149960 r150687 59 59 virtual bool supportsFocus() const; 60 60 virtual bool isMouseFocusable() const; 61 virtual bool isKeyboardFocusable(KeyboardEvent*) const ;61 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 62 62 virtual bool isFocusable() const; 63 63 virtual bool isURLAttribute(const Attribute&) const; -
trunk/Source/WebCore/svg/SVGStyledElement.h
r149960 r150687 81 81 virtual bool isSVGStyledElement() const OVERRIDE FINAL { return true; } 82 82 83 virtual bool isKeyboardFocusable(KeyboardEvent*) const ;83 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 84 84 virtual bool isMouseFocusable() const; 85 85
Note: See TracChangeset
for help on using the changeset viewer.