Title: [150709] trunk/Source/WebCore
Revision
150709
Author
akl...@apple.com
Date
2013-05-25 22:05:37 -0700 (Sat, 25 May 2013)

Log Message

Move Node::isFocusable() to Element.
<http://webkit.org/b/116777>

Reviewed by Anders Carlsson.

Nodes cannot be focusable, so move isFocusable() from Node to Element.

* dom/Node.cpp:
* dom/Node.h:
* dom/Element.h:
* dom/Element.cpp:
(WebCore::Element::isFocusable):

    Moved here from Node.

* dom/Document.cpp:
(WebCore::Document::setFocusedNode):
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::determineAccessibilityRole):

    Check that the underlying node is an Element before asking if it's focusable.

* page/FrameView.cpp:
(WebCore::FrameView::scrollToAnchor):

    Renamed the 'anchorNode' variable to 'anchorElement' because reasons.

* html/HTMLAreaElement.h:
* html/HTMLFormControlElement.h:
* html/HTMLLabelElement.h:
* html/HTMLOptionElement.h:
* svg/SVGAElement.h:

    Sprinkle OVERRIDE.

* html/ValidationMessage.cpp:
(WebCore::ValidationMessage::setMessage):

    Update a comment to refer to Element::isFocusable() instead of Node.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (150708 => 150709)


--- trunk/Source/WebCore/ChangeLog	2013-05-26 04:42:36 UTC (rev 150708)
+++ trunk/Source/WebCore/ChangeLog	2013-05-26 05:05:37 UTC (rev 150709)
@@ -1,5 +1,47 @@
 2013-05-25  Andreas Kling  <akl...@apple.com>
 
+        Move Node::isFocusable() to Element.
+        <http://webkit.org/b/116777>
+
+        Reviewed by Anders Carlsson.
+
+        Nodes cannot be focusable, so move isFocusable() from Node to Element.
+
+        * dom/Node.cpp:
+        * dom/Node.h:
+        * dom/Element.h:
+        * dom/Element.cpp:
+        (WebCore::Element::isFocusable):
+
+            Moved here from Node.
+
+        * dom/Document.cpp:
+        (WebCore::Document::setFocusedNode):
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::determineAccessibilityRole):
+
+            Check that the underlying node is an Element before asking if it's focusable.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scrollToAnchor):
+
+            Renamed the 'anchorNode' variable to 'anchorElement' because reasons.
+
+        * html/HTMLAreaElement.h:
+        * html/HTMLFormControlElement.h:
+        * html/HTMLLabelElement.h:
+        * html/HTMLOptionElement.h:
+        * svg/SVGAElement.h:
+
+            Sprinkle OVERRIDE.
+
+        * html/ValidationMessage.cpp:
+        (WebCore::ValidationMessage::setMessage):
+
+            Update a comment to refer to Element::isFocusable() instead of Node.
+
+2013-05-25  Andreas Kling  <akl...@apple.com>
+
         Move Node::tabIndex() to Element.
         <http://webkit.org/b/116772>
 

Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (150708 => 150709)


--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2013-05-26 04:42:36 UTC (rev 150708)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2013-05-26 05:05:37 UTC (rev 150709)
@@ -315,7 +315,7 @@
         return ParagraphRole;
     if (node()->hasTagName(labelTag))
         return LabelRole;
-    if (node()->isFocusable())
+    if (node()->isElementNode() && toElement(node())->isFocusable())
         return GroupRole;
     
     return UnknownRole;

Modified: trunk/Source/WebCore/dom/Document.cpp (150708 => 150709)


--- trunk/Source/WebCore/dom/Document.cpp	2013-05-26 04:42:36 UTC (rev 150708)
+++ trunk/Source/WebCore/dom/Document.cpp	2013-05-26 05:05:37 UTC (rev 150709)
@@ -3386,7 +3386,7 @@
         }
     }
 
-    if (newFocusedNode && newFocusedNode->isFocusable()) {
+    if (newFocusedNode && newFocusedNode->isElementNode() && toElement(newFocusedNode.get())->isFocusable()) {
         if (newFocusedNode->isRootEditableElement() && !acceptsEditingFocus(newFocusedNode.get())) {
             // delegate blocks focus change
             focusChangeBlocked = true;

Modified: trunk/Source/WebCore/dom/Element.cpp (150708 => 150709)


--- trunk/Source/WebCore/dom/Element.cpp	2013-05-26 04:42:36 UTC (rev 150708)
+++ trunk/Source/WebCore/dom/Element.cpp	2013-05-26 05:05:37 UTC (rev 150709)
@@ -417,6 +417,37 @@
     return nullAtom;
 }
 
+bool Element::isFocusable() const
+{
+    if (!inDocument() || !supportsFocus())
+        return false;
+
+    // Elements in canvas fallback content are not rendered, but they are allowed to be
+    // focusable as long as their canvas is displayed and visible.
+    if (isInCanvasSubtree()) {
+        const Element* e = this;
+        while (e && !e->hasLocalName(canvasTag))
+            e = e->parentElement();
+        ASSERT(e);
+        return e->renderer() && e->renderer()->style()->visibility() == VISIBLE;
+    }
+
+    if (renderer())
+        ASSERT(!renderer()->needsLayout());
+    else {
+        // If the node is in a display:none tree it might say it needs style recalc but
+        // the whole document is actually up to date.
+        ASSERT(!document()->childNeedsStyleRecalc());
+    }
+
+    // FIXME: Even if we are not visible, we might have a child that is visible.
+    // Hyatt wants to fix that some day with a "has visible content" flag or the like.
+    if (!renderer() || renderer()->style()->visibility() != VISIBLE)
+        return false;
+
+    return true;
+}
+
 bool Element::isUserActionElementFocused() const
 {
     ASSERT(isUserActionElement());

Modified: trunk/Source/WebCore/dom/Element.h (150708 => 150709)


--- trunk/Source/WebCore/dom/Element.h	2013-05-26 04:42:36 UTC (rev 150708)
+++ trunk/Source/WebCore/dom/Element.h	2013-05-26 05:05:37 UTC (rev 150709)
@@ -432,6 +432,7 @@
     virtual void setHovered(bool flag = true);
     virtual void setFocus(bool flag);
 
+    virtual bool isFocusable() const;
     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
     virtual bool isMouseFocusable() const;
 

Modified: trunk/Source/WebCore/dom/Node.cpp (150708 => 150709)


--- trunk/Source/WebCore/dom/Node.cpp	2013-05-26 04:42:36 UTC (rev 150708)
+++ trunk/Source/WebCore/dom/Node.cpp	2013-05-26 05:05:37 UTC (rev 150709)
@@ -850,36 +850,6 @@
     return false;
 }
     
-bool Node::isFocusable() const
-{
-    if (!inDocument() || !supportsFocus())
-        return false;
-    
-    // Elements in canvas fallback content are not rendered, but they are allowed to be
-    // focusable as long as their canvas is displayed and visible.
-    if (isElementNode() && toElement(this)->isInCanvasSubtree()) {
-        const Element* e = toElement(this);
-        while (e && !e->hasLocalName(canvasTag))
-            e = e->parentElement();
-        ASSERT(e);
-        return e->renderer() && e->renderer()->style()->visibility() == VISIBLE;
-    }
-
-    if (renderer())
-        ASSERT(!renderer()->needsLayout());
-    else
-        // If the node is in a display:none tree it might say it needs style recalc but
-        // the whole document is actually up to date.
-        ASSERT(!document()->childNeedsStyleRecalc());
-
-    // FIXME: Even if we are not visible, we might have a child that is visible.
-    // Hyatt wants to fix that some day with a "has visible content" flag or the like.
-    if (!renderer() || renderer()->style()->visibility() != VISIBLE)
-        return false;
-
-    return true;
-}
-
 unsigned Node::nodeIndex() const
 {
     Node *_tempNode = previousSibling();

Modified: trunk/Source/WebCore/dom/Node.h (150708 => 150709)


--- trunk/Source/WebCore/dom/Node.h	2013-05-26 04:42:36 UTC (rev 150708)
+++ trunk/Source/WebCore/dom/Node.h	2013-05-26 05:05:37 UTC (rev 150709)
@@ -402,8 +402,6 @@
     // Whether this kind of node can receive focus by default. Most nodes are
     // not focusable but some elements, such as form controls and links, are.
     virtual bool supportsFocus() const;
-    // Whether the node can actually be focused.
-    virtual bool isFocusable() const;
 
     enum UserSelectAllTreatment {
         UserSelectAllDoesNotAffectEditability,

Modified: trunk/Source/WebCore/html/HTMLAreaElement.h (150708 => 150709)


--- trunk/Source/WebCore/html/HTMLAreaElement.h	2013-05-26 04:42:36 UTC (rev 150708)
+++ trunk/Source/WebCore/html/HTMLAreaElement.h	2013-05-26 05:05:37 UTC (rev 150709)
@@ -55,7 +55,7 @@
     virtual String target() const;
     virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
     virtual bool isMouseFocusable() const OVERRIDE;
-    virtual bool isFocusable() const;
+    virtual bool isFocusable() const OVERRIDE;
     virtual void updateFocusAppearance(bool /*restorePreviousSelection*/);
     virtual void setFocus(bool) OVERRIDE;
 

Modified: trunk/Source/WebCore/html/HTMLFormControlElement.h (150708 => 150709)


--- trunk/Source/WebCore/html/HTMLFormControlElement.h	2013-05-26 04:42:36 UTC (rev 150708)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.h	2013-05-26 05:05:37 UTC (rev 150709)
@@ -66,7 +66,7 @@
 
     virtual bool isDisabledFormControl() const OVERRIDE;
 
-    virtual bool isFocusable() const;
+    virtual bool isFocusable() const OVERRIDE;
     virtual bool isEnumeratable() const { return false; }
 
     bool isRequired() const;

Modified: trunk/Source/WebCore/html/HTMLLabelElement.h (150708 => 150709)


--- trunk/Source/WebCore/html/HTMLLabelElement.h	2013-05-26 04:42:36 UTC (rev 150708)
+++ trunk/Source/WebCore/html/HTMLLabelElement.h	2013-05-26 05:05:37 UTC (rev 150709)
@@ -41,7 +41,7 @@
 private:
     HTMLLabelElement(const QualifiedName&, Document*);
 
-    virtual bool isFocusable() const;
+    virtual bool isFocusable() const OVERRIDE;
 
     virtual void accessKeyAction(bool sendMouseEvents);
 

Modified: trunk/Source/WebCore/html/HTMLOptionElement.h (150708 => 150709)


--- trunk/Source/WebCore/html/HTMLOptionElement.h	2013-05-26 04:42:36 UTC (rev 150708)
+++ trunk/Source/WebCore/html/HTMLOptionElement.h	2013-05-26 05:05:37 UTC (rev 150709)
@@ -70,7 +70,7 @@
     HTMLOptionElement(const QualifiedName&, Document*);
 
     virtual bool supportsFocus() const;
-    virtual bool isFocusable() const;
+    virtual bool isFocusable() const OVERRIDE;
     virtual bool rendererIsNeeded(const NodeRenderingContext&) { return false; }
     virtual void attach();
     virtual void detach();

Modified: trunk/Source/WebCore/html/ValidationMessage.cpp (150708 => 150709)


--- trunk/Source/WebCore/html/ValidationMessage.cpp	2013-05-26 04:42:36 UTC (rev 150708)
+++ trunk/Source/WebCore/html/ValidationMessage.cpp	2013-05-26 05:05:37 UTC (rev 150709)
@@ -110,7 +110,7 @@
     }
 
     // Don't modify the DOM tree in this context.
-    // If so, an assertion in Node::isFocusable() fails.
+    // If so, an assertion in Element::isFocusable() fails.
     ASSERT(!message.isEmpty());
     m_message = message;
     if (!m_bubble)

Modified: trunk/Source/WebCore/page/FrameView.cpp (150708 => 150709)


--- trunk/Source/WebCore/page/FrameView.cpp	2013-05-26 04:42:36 UTC (rev 150708)
+++ trunk/Source/WebCore/page/FrameView.cpp	2013-05-26 05:05:37 UTC (rev 150709)
@@ -1842,30 +1842,30 @@
 
     m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(false);
 
-    Element* anchorNode = m_frame->document()->findAnchor(name);
+    Element* anchorElement = m_frame->document()->findAnchor(name);
 
     // Setting to null will clear the current target.
-    m_frame->document()->setCSSTarget(anchorNode);
+    m_frame->document()->setCSSTarget(anchorElement);
 
 #if ENABLE(SVG)
     if (m_frame->document()->isSVGDocument()) {
         if (SVGSVGElement* svg = toSVGDocument(m_frame->document())->rootElement()) {
-            svg->setupInitialView(name, anchorNode);
-            if (!anchorNode)
+            svg->setupInitialView(name, anchorElement);
+            if (!anchorElement)
                 return true;
         }
     }
 #endif
   
     // Implement the rule that "" and "top" both mean top of page as in other browsers.
-    if (!anchorNode && !(name.isEmpty() || equalIgnoringCase(name, "top")))
+    if (!anchorElement && !(name.isEmpty() || equalIgnoringCase(name, "top")))
         return false;
 
-    maintainScrollPositionAtAnchor(anchorNode ? static_cast<Node*>(anchorNode) : m_frame->document());
+    maintainScrollPositionAtAnchor(anchorElement ? static_cast<Node*>(anchorElement) : m_frame->document());
     
     // If the anchor accepts keyboard focus, move focus there to aid users relying on keyboard navigation.
-    if (anchorNode && anchorNode->isFocusable())
-        m_frame->document()->setFocusedNode(anchorNode);
+    if (anchorElement && anchorElement->isFocusable())
+        m_frame->document()->setFocusedNode(anchorElement);
     
     return true;
 }

Modified: trunk/Source/WebCore/svg/SVGAElement.h (150708 => 150709)


--- trunk/Source/WebCore/svg/SVGAElement.h	2013-05-26 04:42:36 UTC (rev 150708)
+++ trunk/Source/WebCore/svg/SVGAElement.h	2013-05-26 05:05:37 UTC (rev 150709)
@@ -59,7 +59,7 @@
     virtual bool supportsFocus() const;
     virtual bool isMouseFocusable() const OVERRIDE;
     virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
-    virtual bool isFocusable() const;
+    virtual bool isFocusable() const OVERRIDE;
     virtual bool isURLAttribute(const Attribute&) const;
 
     virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to