Diff
Modified: trunk/Source/WebCore/ChangeLog (150686 => 150687)
--- trunk/Source/WebCore/ChangeLog 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/ChangeLog 2013-05-25 12:02:35 UTC (rev 150687)
@@ -1,5 +1,46 @@
2013-05-25 Andreas Kling <akl...@apple.com>
+ Move Node::isKeyboardFocusable() to Element.
+ <http://webkit.org/b/116761>
+
+ Reviewed by Antti Koivisto.
+
+ Only Elements can be keyboard-focusable. Move the base isKeyboardFocusable() implementation to Element
+ and sprinkle OVERRIDE on subclass overrides.
+ FocusController gets some temporary type checks that will go away as that code moves to dealing in
+ Elements instead of Node.
+
+ * dom/Node.h:
+ * dom/Node.cpp:
+ * dom/Element.h:
+ * dom/Element.cpp:
+ (WebCore::Element::isKeyboardFocusable):
+
+ Move isKeyboardFocusable() from Node to Element.
+
+ * page/FocusController.cpp:
+ (WebCore::isNonFocusableShadowHost):
+ (WebCore::isFocusableShadowHost):
+ (WebCore::shouldVisit):
+ (WebCore::FocusController::advanceFocusInDocumentOrder):
+
+ Check that the inspected Node is an Element before querying isKeyboardFocusable().
+
+ * html/HTMLAnchorElement.h:
+ * html/HTMLAreaElement.h:
+ * html/HTMLFormControlElement.h:
+ * html/HTMLFrameOwnerElement.h:
+ * html/HTMLInputElement.h:
+ * html/HTMLPlugInElement.h:
+ * html/HTMLSelectElement.h:
+ * html/HTMLTextAreaElement.h:
+ * svg/SVGAElement.h:
+ * svg/SVGStyledElement.h:
+
+ Sprinkle OVERRIDE.
+
+2013-05-25 Andreas Kling <akl...@apple.com>
+
Begin moving "focus" state logic from Node to Element.
<http://webkit.org/b/116760>
Modified: trunk/Source/WebCore/dom/Element.cpp (150686 => 150687)
--- trunk/Source/WebCore/dom/Element.cpp 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/dom/Element.cpp 2013-05-25 12:02:35 UTC (rev 150687)
@@ -249,6 +249,11 @@
return hasRareData() ? elementRareData()->tabIndex() : 0;
}
+bool Element::isKeyboardFocusable(KeyboardEvent*) const
+{
+ return isFocusable() && tabIndex() >= 0;
+}
+
DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, blur);
DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, error);
DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, focus);
Modified: trunk/Source/WebCore/dom/Element.h (150686 => 150687)
--- trunk/Source/WebCore/dom/Element.h 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/dom/Element.h 2013-05-25 12:02:35 UTC (rev 150687)
@@ -432,6 +432,8 @@
virtual void setHovered(bool flag = true);
virtual void setFocus(bool flag);
+ virtual bool isKeyboardFocusable(KeyboardEvent*) const;
+
RenderStyle* computedStyle(PseudoId = NOPSEUDO);
// Methods for indicating the style is affected by dynamic updates (e.g., children changing, our position changing in our sibling list, etc.)
Modified: trunk/Source/WebCore/dom/Node.cpp (150686 => 150687)
--- trunk/Source/WebCore/dom/Node.cpp 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/dom/Node.cpp 2013-05-25 12:02:35 UTC (rev 150687)
@@ -885,11 +885,6 @@
return true;
}
-bool Node::isKeyboardFocusable(KeyboardEvent*) const
-{
- return isFocusable() && tabIndex() >= 0;
-}
-
bool Node::isMouseFocusable() const
{
return isFocusable();
Modified: trunk/Source/WebCore/dom/Node.h (150686 => 150687)
--- trunk/Source/WebCore/dom/Node.h 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/dom/Node.h 2013-05-25 12:02:35 UTC (rev 150687)
@@ -406,7 +406,6 @@
virtual bool supportsFocus() const;
// Whether the node can actually be focused.
virtual bool isFocusable() const;
- virtual bool isKeyboardFocusable(KeyboardEvent*) const;
virtual bool isMouseFocusable() const;
virtual Node* focusDelegate();
Modified: trunk/Source/WebCore/html/HTMLAnchorElement.h (150686 => 150687)
--- trunk/Source/WebCore/html/HTMLAnchorElement.h 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.h 2013-05-25 12:02:35 UTC (rev 150687)
@@ -110,7 +110,7 @@
private:
virtual bool supportsFocus() const;
virtual bool isMouseFocusable() const;
- virtual bool isKeyboardFocusable(KeyboardEvent*) const;
+ virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
virtual void defaultEventHandler(Event*);
virtual void setActive(bool active = true, bool pause = false);
virtual void accessKeyAction(bool sendMouseEvents);
Modified: trunk/Source/WebCore/html/HTMLAreaElement.h (150686 => 150687)
--- trunk/Source/WebCore/html/HTMLAreaElement.h 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/html/HTMLAreaElement.h 2013-05-25 12:02:35 UTC (rev 150687)
@@ -53,7 +53,7 @@
virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
virtual bool supportsFocus() const;
virtual String target() const;
- virtual bool isKeyboardFocusable(KeyboardEvent*) const;
+ virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
virtual bool isMouseFocusable() const;
virtual bool isFocusable() const;
virtual void updateFocusAppearance(bool /*restorePreviousSelection*/);
Modified: trunk/Source/WebCore/html/HTMLFormControlElement.h (150686 => 150687)
--- trunk/Source/WebCore/html/HTMLFormControlElement.h 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.h 2013-05-25 12:02:35 UTC (rev 150687)
@@ -116,7 +116,7 @@
virtual void didMoveToNewDocument(Document* oldDocument) OVERRIDE;
virtual bool supportsFocus() const;
- virtual bool isKeyboardFocusable(KeyboardEvent*) const;
+ virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
virtual bool isMouseFocusable() const;
virtual void didRecalcStyle(StyleChange) OVERRIDE;
Modified: trunk/Source/WebCore/html/HTMLFrameOwnerElement.h (150686 => 150687)
--- trunk/Source/WebCore/html/HTMLFrameOwnerElement.h 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/html/HTMLFrameOwnerElement.h 2013-05-25 12:02:35 UTC (rev 150687)
@@ -65,7 +65,7 @@
void setSandboxFlags(SandboxFlags);
private:
- virtual bool isKeyboardFocusable(KeyboardEvent*) const;
+ virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
virtual bool isFrameOwnerElement() const OVERRIDE { return true; }
Frame* m_contentFrame;
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (150686 => 150687)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2013-05-25 12:02:35 UTC (rev 150687)
@@ -323,7 +323,7 @@
virtual void didMoveToNewDocument(Document* oldDocument) OVERRIDE;
virtual bool hasCustomFocusLogic() const OVERRIDE;
- virtual bool isKeyboardFocusable(KeyboardEvent*) const;
+ virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
virtual bool isMouseFocusable() const;
virtual bool isEnumeratable() const;
virtual bool supportLabels() const OVERRIDE;
Modified: trunk/Source/WebCore/html/HTMLPlugInElement.h (150686 => 150687)
--- trunk/Source/WebCore/html/HTMLPlugInElement.h 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.h 2013-05-25 12:02:35 UTC (rev 150687)
@@ -105,7 +105,7 @@
virtual bool supportsFocus() const OVERRIDE;
- virtual bool isKeyboardFocusable(KeyboardEvent*) const;
+ virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
virtual bool isPluginElement() const;
RefPtr<JSC::Bindings::Instance> m_instance;
Modified: trunk/Source/WebCore/html/HTMLSelectElement.h (150686 => 150687)
--- trunk/Source/WebCore/html/HTMLSelectElement.h 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/html/HTMLSelectElement.h 2013-05-25 12:02:35 UTC (rev 150687)
@@ -111,7 +111,7 @@
private:
virtual const AtomicString& formControlType() const;
- virtual bool isKeyboardFocusable(KeyboardEvent*) const;
+ virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
virtual bool isMouseFocusable() const;
virtual void dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode, FocusDirection) OVERRIDE;
Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.h (150686 => 150687)
--- trunk/Source/WebCore/html/HTMLTextAreaElement.h 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.h 2013-05-25 12:02:35 UTC (rev 150687)
@@ -105,7 +105,7 @@
virtual void reset();
virtual bool hasCustomFocusLogic() const OVERRIDE;
virtual bool isMouseFocusable() const;
- virtual bool isKeyboardFocusable(KeyboardEvent*) const;
+ virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
virtual void updateFocusAppearance(bool restorePreviousSelection);
virtual void accessKeyAction(bool sendMouseEvents);
Modified: trunk/Source/WebCore/page/FocusController.cpp (150686 => 150687)
--- trunk/Source/WebCore/page/FocusController.cpp 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/page/FocusController.cpp 2013-05-25 12:02:35 UTC (rev 150687)
@@ -137,13 +137,13 @@
static inline bool isNonFocusableShadowHost(Node* node, KeyboardEvent* event)
{
ASSERT(node);
- return !node->isKeyboardFocusable(event) && isShadowHost(node) && !hasCustomFocusLogic(node);
+ return node->isElementNode() && !toElement(node)->isKeyboardFocusable(event) && isShadowHost(node) && !hasCustomFocusLogic(node);
}
static inline bool isFocusableShadowHost(Node* node, KeyboardEvent* event)
{
ASSERT(node);
- return node->isKeyboardFocusable(event) && isShadowHost(node) && !hasCustomFocusLogic(node);
+ return node->isElementNode() && toElement(node)->isKeyboardFocusable(event) && isShadowHost(node) && !hasCustomFocusLogic(node);
}
static inline int adjustedTabIndex(Node* node, KeyboardEvent* event)
@@ -155,7 +155,7 @@
static inline bool shouldVisit(Node* node, KeyboardEvent* event)
{
ASSERT(node);
- return node->isKeyboardFocusable(event) || isNonFocusableShadowHost(node, event);
+ return (node->isElementNode() && toElement(node)->isKeyboardFocusable(event)) || isNonFocusableShadowHost(node, event);
}
FocusController::FocusController(Page* page)
@@ -320,10 +320,12 @@
// FIXME: May need a way to focus a document here.
return false;
- if (node->isFrameOwnerElement() && (!node->isPluginElement() || !node->isKeyboardFocusable(event))) {
+ Element* element = toElement(node.get());
+
+ if (element->isFrameOwnerElement() && (!element->isPluginElement() || !element->isKeyboardFocusable(event))) {
// We focus frames rather than frame owners.
// FIXME: We should not focus frames that have no scrollbars, as focusing them isn't useful to the user.
- HTMLFrameOwnerElement* owner = static_cast<HTMLFrameOwnerElement*>(node.get());
+ HTMLFrameOwnerElement* owner = toFrameOwnerElement(element);
if (!owner->contentFrame())
return false;
Modified: trunk/Source/WebCore/svg/SVGAElement.h (150686 => 150687)
--- trunk/Source/WebCore/svg/SVGAElement.h 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/svg/SVGAElement.h 2013-05-25 12:02:35 UTC (rev 150687)
@@ -58,7 +58,7 @@
virtual bool supportsFocus() const;
virtual bool isMouseFocusable() const;
- virtual bool isKeyboardFocusable(KeyboardEvent*) const;
+ virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
virtual bool isFocusable() const;
virtual bool isURLAttribute(const Attribute&) const;
Modified: trunk/Source/WebCore/svg/SVGStyledElement.h (150686 => 150687)
--- trunk/Source/WebCore/svg/SVGStyledElement.h 2013-05-25 10:27:37 UTC (rev 150686)
+++ trunk/Source/WebCore/svg/SVGStyledElement.h 2013-05-25 12:02:35 UTC (rev 150687)
@@ -80,7 +80,7 @@
private:
virtual bool isSVGStyledElement() const OVERRIDE FINAL { return true; }
- virtual bool isKeyboardFocusable(KeyboardEvent*) const;
+ virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
virtual bool isMouseFocusable() const;
void buildPendingResourcesIfNeeded();