Move Node::focusDelegate() to Element.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 26 May 2013 02:22:04 +0000 (02:22 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 26 May 2013 02:22:04 +0000 (02:22 +0000)
<http://webkit.org/b/116768>

Reviewed by Anders Carlsson.

Only Element can be a focus delegate (it's currently only ever HTMLInputElement actually)
so move Node::focusDelegate() to Element. Sprinkled isElementNode() checks as needed.

* dom/Node.cpp:
* dom/Node.h:
* dom/Element.h:
* dom/Element.cpp:
* html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::focusDelegate):
* html/shadow/SliderThumbElement.h:
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::isFocused):
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintSliderThumb):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@150697 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/html/shadow/SliderThumbElement.cpp
Source/WebCore/html/shadow/SliderThumbElement.h
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderThemeMac.mm

index 5ac8aba..170f817 100644 (file)
@@ -1,3 +1,25 @@
+2013-05-25  Andreas Kling  <akling@apple.com>
+
+        Move Node::focusDelegate() to Element.
+        <http://webkit.org/b/116768>
+
+        Reviewed by Anders Carlsson.
+
+        Only Element can be a focus delegate (it's currently only ever HTMLInputElement actually)
+        so move Node::focusDelegate() to Element. Sprinkled isElementNode() checks as needed.
+
+        * dom/Node.cpp:
+        * dom/Node.h:
+        * dom/Element.h:
+        * dom/Element.cpp:
+        * html/shadow/SliderThumbElement.cpp:
+        (WebCore::SliderThumbElement::focusDelegate):
+        * html/shadow/SliderThumbElement.h:
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::isFocused):
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::paintSliderThumb):
+
 2013-05-25  Alberto Garcia  <agarcia@igalia.com>
 
         Path: clean up addPathForRoundedRect()
index d91b99e..ad80ac5 100644 (file)
@@ -244,6 +244,11 @@ bool Element::supportsFocus() const
     return hasRareData() && elementRareData()->tabIndexSetExplicitly();
 }
 
+Element* Element::focusDelegate()
+{
+    return this;
+}
+
 short Element::tabIndex() const
 {
     return hasRareData() ? elementRareData()->tabIndex() : 0;
index 6bb4ae4..08a6553 100644 (file)
@@ -435,6 +435,8 @@ public:
     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
     virtual bool isMouseFocusable() const;
 
+    virtual Element* focusDelegate();
+
     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.)
index 7cdaf27..933e8e7 100644 (file)
@@ -885,11 +885,6 @@ bool Node::isFocusable() const
     return true;
 }
 
-Node* Node::focusDelegate()
-{
-    return this;
-}
-
 unsigned Node::nodeIndex() const
 {
     Node *_tempNode = previousSibling();
index 2bbf76b..c1572d2 100644 (file)
@@ -406,7 +406,6 @@ public:
     virtual bool supportsFocus() const;
     // Whether the node can actually be focused.
     virtual bool isFocusable() const;
-    virtual Node* focusDelegate();
 
     enum UserSelectAllTreatment {
         UserSelectAllDoesNotAffectEditability,
index 9fbeb5a..57d33b5 100644 (file)
@@ -237,7 +237,7 @@ bool SliderThumbElement::matchesReadWritePseudoClass() const
     return hostInput()->matchesReadWritePseudoClass();
 }
 
-Node* SliderThumbElement::focusDelegate()
+Element* SliderThumbElement::focusDelegate()
 {
     return hostInput();
 }
index 8f94a56..89015f5 100644 (file)
@@ -68,7 +68,7 @@ private:
     virtual bool isDisabledFormControl() const OVERRIDE;
     virtual bool matchesReadOnlyPseudoClass() const OVERRIDE;
     virtual bool matchesReadWritePseudoClass() const OVERRIDE;
-    virtual Node* focusDelegate();
+    virtual Element* focusDelegate() OVERRIDE;
     void startDragging();
     void stopDragging();
 
index 2537519..8077f55 100644 (file)
@@ -794,13 +794,13 @@ bool RenderTheme::isEnabled(const RenderObject* o) const
 bool RenderTheme::isFocused(const RenderObject* o) const
 {
     Node* node = o->node();
-    if (!node)
+    if (!node || !node->isElementNode())
         return false;
 
-    node = node->focusDelegate();
-    Document* document = node->document();
+    Element* focusDelegate = toElement(node)->focusDelegate();
+    Document* document = focusDelegate->document();
     Frame* frame = document->frame();
-    return node == document->focusedNode() && frame && frame->selection()->isFocusedAndActive();
+    return focusDelegate == document->focusedNode() && frame && frame->selection()->isFocusedAndActive();
 }
 
 bool RenderTheme::isPressed(const RenderObject* o) const
index 0a4d286..5636744 100644 (file)
@@ -1762,7 +1762,8 @@ bool RenderThemeMac::paintSliderThumb(RenderObject* o, const PaintInfo& paintInf
     // Update the various states we respond to.
     updateActiveState(sliderThumbCell, o);
     updateEnabledState(sliderThumbCell, o);
-    updateFocusedState(sliderThumbCell, (o->node() && o->node()->focusDelegate()->renderer()) ? o->node()->focusDelegate()->renderer() : o);
+    Element* focusDelegate = (o->node() && o->node()->isElementNode()) ? toElement(o->node())->focusDelegate() : 0;
+    updateFocusedState(sliderThumbCell, focusDelegate ? focusDelegate->renderer() : 0);
 
     // Update the pressed state using the NSCell tracking methods, since that's how NSSliderCell keeps track of it.
     bool oldPressed;