Document::setFocusedNode() should be setFocusedElement().
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 May 2013 12:46:31 +0000 (12:46 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 May 2013 12:46:31 +0000 (12:46 +0000)
<http://webkit.org/b/116857>

Reviewed by Antti Koivisto.

Source/WebCore:

Only Elements can be focused, so tighten Document's idea of what's focused.

Most of this patch is just updating call sites for the new names and removing
now-unnecessary isElementNode() checks and casts.

* WebCore.exp.in:
* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::focusedUIElementForPage):
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::canSetFocusAttribute):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::isFocused):
(WebCore::AccessibilityRenderObject::setFocused):
(WebCore::AccessibilityRenderObject::handleActiveDescendantChanged):
* bindings/objc/DOM.mm:
(-[DOMElement isFocused]):
* dom/Document.cpp:
(WebCore::Document::dispose):
(WebCore::Document::detach):
(WebCore::Document::focusedNodeRemoved):
(WebCore::Document::removeFocusedNodeOfSubtree):
(WebCore::Document::setFocusedElement):
(WebCore::Document::updateFocusAppearanceTimerFired):
(WebCore::eventTargetNodeForDocument):
* dom/Document.h:
(Document):
(WebCore::Document::focusedElement):
* dom/Element.cpp:
(WebCore::Element::attach):
(WebCore::Element::focus):
(WebCore::Element::blur):
(WebCore::Element::cancelFocusAppearanceUpdate):
* dom/Node.cpp:
(WebCore::Node::rendererIsEditable):
* dom/TreeScope.cpp:
(WebCore::TreeScope::focusedElement):
* dom/UserTypingGestureIndicator.cpp:
(WebCore::UserTypingGestureIndicator::UserTypingGestureIndicator):
* editing/Editor.cpp:
(WebCore::Editor::setBaseWritingDirection):
(WebCore::Editor::setComposition):
(WebCore::Editor::guessesForMisspelledOrUngrammatical):
* editing/EditorCommand.cpp:
(WebCore::verticalScrollDistance):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll):
(WebCore::FrameSelection::focusedOrActiveStateChanged):
(WebCore::FrameSelection::setFocusedElementIfNeeded):
(WebCore::FrameSelection::currentForm):
* history/CachedPage.cpp:
(WebCore::CachedPage::restore):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::updateType):
(WebCore::HTMLInputElement::attach):
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::setValueCommon):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::placeholderShouldBeVisible):
(WebCore::HTMLTextFormControlElement::selectionStart):
(WebCore::HTMLTextFormControlElement::selectionEnd):
(WebCore::HTMLTextFormControlElement::selectionDirection):
* html/RadioInputType.cpp:
(WebCore::RadioInputType::handleKeydownEvent):
(WebCore::RadioInputType::isKeyboardFocusable):
* html/shadow/DateTimeEditElement.cpp:
(WebCore::DateTimeEditElement::focusedFieldIndex):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::stopLoading):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::focus):
* page/EventHandler.cpp:
(WebCore::EventHandler::scrollOverflow):
(WebCore::EventHandler::logicalScrollOverflow):
(WebCore::EventHandler::dispatchMouseEvent):
(WebCore::EventHandler::sendContextMenuEventForKey):
(WebCore::EventHandler::capsLockStateMayHaveChanged):
* page/FocusController.cpp:
(WebCore::dispatchEventsOnWindowAndFocusedNode):
(WebCore::FocusController::advanceFocusInDocumentOrder):
(WebCore::FocusController::setFocusedElement):
(WebCore::FocusController::findFocusCandidateInContainer):
(WebCore::FocusController::advanceFocusDirectionallyInContainer):
(WebCore::FocusController::advanceFocusDirectionally):
* page/FrameView.cpp:
(WebCore::FrameView::scrollToAnchor):
* plugins/PluginView.cpp:
(WebCore::PluginView::focusPluginElement):
* plugins/efl/PluginViewEfl.cpp:
(WebCore::PluginView::setFocus):
* plugins/mac/PluginViewMac.mm:
(WebCore::PluginView::platformStart):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::paintAreaElementFocusRing):
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::paintItemForeground):
(WebCore::RenderListBox::paintItemBackground):
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::capsLockStateMayHaveChanged):
(WebCore::RenderTextControlSingleLine::textShouldBeTruncated):
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::isFocused):

Source/WebKit/blackberry:

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::focusNodeRect):
(BlackBerry::WebKit::WebPagePrivate::contextNode):
(BlackBerry::WebKit::WebPagePrivate::clearFocusNode):
(BlackBerry::WebKit::WebPage::setNodeFocus):
* WebCoreSupport/EditorClientBlackBerry.cpp:
(WebCore::EditorClientBlackBerry::shouldSpellCheckFocusedField):
(WebCore::EditorClientBlackBerry::shouldChangeSelectedRange):
* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::InputHandler::focusedNodeChanged):
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::SelectionHandler::setCaretPosition):
(BlackBerry::WebKit::SelectionHandler::extendSelectionToFieldBoundary):
(BlackBerry::WebKit::SelectionHandler::updateOrHandleInputSelection):
(BlackBerry::WebKit::SelectionHandler::clipPointToVisibleContainer):
(BlackBerry::WebKit::SelectionHandler::inputNodeOverridesTouch):
(BlackBerry::WebKit::SelectionHandler::selectionPositionChanged):

Source/WebKit/efl:

* ewk/ewk_frame.cpp:
(ewk_frame_focused_element_geometry_get):
* ewk/ewk_view.cpp:
(ewk_view_input_method_state_set):

Source/WebKit/gtk:

* webkit/webkitwebview.cpp:
(getFocusedNode):

Source/WebKit/mac:

* WebView/WebHTMLView.mm:
(-[WebHTMLView clearFocus]):
(-[WebHTMLView becomeFirstResponder]):

Source/WebKit/qt:

* Api/qwebelement.cpp:
(QWebElement::hasFocus):
(QWebElement::setFocus):
* WebCoreSupport/EditorClientQt.cpp:
(WebCore::EditorClientQt::setInputMethodState):
* WebCoreSupport/QWebPageAdapter.cpp:
(QWebPageAdapter::mousePressEvent):
(QWebPageAdapter::handleSoftwareInputPanel):
(QWebPageAdapter::inputMethodQuery):
(QWebPageAdapter::hasFocusedNode):

Source/WebKit/win:

* DOMCoreClasses.cpp:
(DOMElement::isFocused):
* WebView.cpp:
(WebView::setInitialFocus):

Source/WebKit2:

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::focusPluginElement):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::focusedPluginViewForFrame):
(WebKit::WebPage::setInitialFocus):

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

55 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/accessibility/AXObjectCache.cpp
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/bindings/objc/DOM.mm
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/TreeScope.cpp
Source/WebCore/dom/UserTypingGestureIndicator.cpp
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/EditorCommand.cpp
Source/WebCore/editing/FrameSelection.cpp
Source/WebCore/history/CachedPage.cpp
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLTextAreaElement.cpp
Source/WebCore/html/HTMLTextFormControlElement.cpp
Source/WebCore/html/RadioInputType.cpp
Source/WebCore/html/shadow/DateTimeEditElement.cpp
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/FocusController.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/plugins/PluginView.cpp
Source/WebCore/plugins/efl/PluginViewEfl.cpp
Source/WebCore/plugins/mac/PluginViewMac.mm
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/rendering/RenderListBox.cpp
Source/WebCore/rendering/RenderTextControlSingleLine.cpp
Source/WebCore/rendering/RenderTheme.cpp
Source/WebKit/blackberry/Api/WebPage.cpp
Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebCoreSupport/EditorClientBlackBerry.cpp
Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp
Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/ewk/ewk_frame.cpp
Source/WebKit/efl/ewk/ewk_view.cpp
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/webkit/webkitwebview.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit/qt/Api/qwebelement.cpp
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/DOMCoreClasses.cpp
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 1fca65c..ce2abba 100644 (file)
@@ -1,3 +1,112 @@
+2013-05-28  Andreas Kling  <akling@apple.com>
+
+        Document::setFocusedNode() should be setFocusedElement().
+        <http://webkit.org/b/116857>
+
+        Reviewed by Antti Koivisto.
+
+        Only Elements can be focused, so tighten Document's idea of what's focused.
+
+        Most of this patch is just updating call sites for the new names and removing
+        now-unnecessary isElementNode() checks and casts.
+
+        * WebCore.exp.in:
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::focusedUIElementForPage):
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::canSetFocusAttribute):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::isFocused):
+        (WebCore::AccessibilityRenderObject::setFocused):
+        (WebCore::AccessibilityRenderObject::handleActiveDescendantChanged):
+        * bindings/objc/DOM.mm:
+        (-[DOMElement isFocused]):
+        * dom/Document.cpp:
+        (WebCore::Document::dispose):
+        (WebCore::Document::detach):
+        (WebCore::Document::focusedNodeRemoved):
+        (WebCore::Document::removeFocusedNodeOfSubtree):
+        (WebCore::Document::setFocusedElement):
+        (WebCore::Document::updateFocusAppearanceTimerFired):
+        (WebCore::eventTargetNodeForDocument):
+        * dom/Document.h:
+        (Document):
+        (WebCore::Document::focusedElement):
+        * dom/Element.cpp:
+        (WebCore::Element::attach):
+        (WebCore::Element::focus):
+        (WebCore::Element::blur):
+        (WebCore::Element::cancelFocusAppearanceUpdate):
+        * dom/Node.cpp:
+        (WebCore::Node::rendererIsEditable):
+        * dom/TreeScope.cpp:
+        (WebCore::TreeScope::focusedElement):
+        * dom/UserTypingGestureIndicator.cpp:
+        (WebCore::UserTypingGestureIndicator::UserTypingGestureIndicator):
+        * editing/Editor.cpp:
+        (WebCore::Editor::setBaseWritingDirection):
+        (WebCore::Editor::setComposition):
+        (WebCore::Editor::guessesForMisspelledOrUngrammatical):
+        * editing/EditorCommand.cpp:
+        (WebCore::verticalScrollDistance):
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::selectAll):
+        (WebCore::FrameSelection::focusedOrActiveStateChanged):
+        (WebCore::FrameSelection::setFocusedElementIfNeeded):
+        (WebCore::FrameSelection::currentForm):
+        * history/CachedPage.cpp:
+        (WebCore::CachedPage::restore):
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::updateType):
+        (WebCore::HTMLInputElement::attach):
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::setValueCommon):
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::placeholderShouldBeVisible):
+        (WebCore::HTMLTextFormControlElement::selectionStart):
+        (WebCore::HTMLTextFormControlElement::selectionEnd):
+        (WebCore::HTMLTextFormControlElement::selectionDirection):
+        * html/RadioInputType.cpp:
+        (WebCore::RadioInputType::handleKeydownEvent):
+        (WebCore::RadioInputType::isKeyboardFocusable):
+        * html/shadow/DateTimeEditElement.cpp:
+        (WebCore::DateTimeEditElement::focusedFieldIndex):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::stopLoading):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::focus):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::scrollOverflow):
+        (WebCore::EventHandler::logicalScrollOverflow):
+        (WebCore::EventHandler::dispatchMouseEvent):
+        (WebCore::EventHandler::sendContextMenuEventForKey):
+        (WebCore::EventHandler::capsLockStateMayHaveChanged):
+        * page/FocusController.cpp:
+        (WebCore::dispatchEventsOnWindowAndFocusedNode):
+        (WebCore::FocusController::advanceFocusInDocumentOrder):
+        (WebCore::FocusController::setFocusedElement):
+        (WebCore::FocusController::findFocusCandidateInContainer):
+        (WebCore::FocusController::advanceFocusDirectionallyInContainer):
+        (WebCore::FocusController::advanceFocusDirectionally):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scrollToAnchor):
+        * plugins/PluginView.cpp:
+        (WebCore::PluginView::focusPluginElement):
+        * plugins/efl/PluginViewEfl.cpp:
+        (WebCore::PluginView::setFocus):
+        * plugins/mac/PluginViewMac.mm:
+        (WebCore::PluginView::platformStart):
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::paintAreaElementFocusRing):
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::paintItemForeground):
+        (WebCore::RenderListBox::paintItemBackground):
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::capsLockStateMayHaveChanged):
+        (WebCore::RenderTextControlSingleLine::textShouldBeTruncated):
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::isFocused):
+
 2013-05-28  Sergio Villar Senin  <svillar@igalia.com>
 
         Web Inspector: Enable CSS logging
index 1985cc3..5407f60 100644 (file)
@@ -1047,7 +1047,7 @@ __ZN7WebCore8Document11createRangeEv
 __ZN7WebCore8Document12updateLayoutEv
 __ZN7WebCore8Document13createElementERKNS_13QualifiedNameEb
 __ZN7WebCore8Document14createTextNodeERKN3WTF6StringE
-__ZN7WebCore8Document14setFocusedNodeEN3WTF10PassRefPtrINS_4NodeEEENS_14FocusDirectionE
+__ZN7WebCore8Document17setFocusedElementEN3WTF10PassRefPtrINS_7ElementEEENS_14FocusDirectionE
 __ZN7WebCore8Document16isPageBoxVisibleEi
 __ZN7WebCore8Document16shortcutIconURLsEv
 __ZN7WebCore8Document20styleResolverChangedENS_23StyleResolverUpdateFlagE
index f899a50..484416f 100644 (file)
@@ -162,14 +162,11 @@ AccessibilityObject* AXObjectCache::focusedUIElementForPage(const Page* page)
 
     // get the focused node in the page
     Document* focusedDocument = page->focusController()->focusedOrMainFrame()->document();
-    Node* focusedNode = focusedDocument->focusedNode();
-    if (!focusedNode)
-        focusedNode = focusedDocument;
+    Element* focusedElement = focusedDocument->focusedElement();
+    if (focusedElement && focusedElement->hasTagName(areaTag))
+        return focusedImageMapUIElement(static_cast<HTMLAreaElement*>(focusedElement));
 
-    if (focusedNode->hasTagName(areaTag))
-        return focusedImageMapUIElement(static_cast<HTMLAreaElement*>(focusedNode));
-    
-    AccessibilityObject* obj = focusedNode->document()->axObjectCache()->getOrCreate(focusedNode);
+    AccessibilityObject* obj = focusedDocument->axObjectCache()->getOrCreate(focusedElement ? static_cast<Node*>(focusedElement) : focusedDocument);
     if (!obj)
         return 0;
 
index d297694..e284e9a 100644 (file)
@@ -1781,8 +1781,8 @@ bool AccessibilityNodeObject::canSetFocusAttribute() const
     if (isWebArea())
         return true;
     
-    // NOTE: It would be more accurate to ask the document whether setFocusedNode() would
-    // do anything. For example, setFocusedNode() will do nothing if the current focused
+    // NOTE: It would be more accurate to ask the document whether setFocusedElement() would
+    // do anything. For example, setFocusedElement() will do nothing if the current focused
     // node will not relinquish the focus.
     if (!node)
         return false;
index 0fe6e3e..7466199 100644 (file)
@@ -1576,13 +1576,13 @@ bool AccessibilityRenderObject::isFocused() const
     if (!document)
         return false;
     
-    Node* focusedNode = document->focusedNode();
-    if (!focusedNode)
+    Element* focusedElement = document->focusedElement();
+    if (!focusedElement)
         return false;
     
     // A web area is represented by the Document node in the DOM tree, which isn't focusable.
     // Check instead if the frame's selection controller is focused
-    if (focusedNode == m_renderer->node()
+    if (focusedElement == m_renderer->node()
         || (roleValue() == WebAreaRole && document->frame()->selection()->isFocusedAndActive()))
         return true;
     
@@ -1595,21 +1595,20 @@ void AccessibilityRenderObject::setFocused(bool on)
         return;
     
     Document* document = this->document();
-    if (!on)
-        document->setFocusedNode(0);
-    else {
-        Node* node = this->node();
-        if (node && node->isElementNode()) {
-            // If this node is already the currently focused node, then calling focus() won't do anything.
-            // That is a problem when focus is removed from the webpage to chrome, and then returns.
-            // In these cases, we need to do what keyboard and mouse focus do, which is reset focus first.
-            if (document->focusedNode() == node)
-                document->setFocusedNode(0);
-            
-            toElement(node)->focus();
-        } else
-            document->setFocusedNode(node);
+    Node* node = this->node();
+
+    if (!on || !node || !node->isElementNode()) {
+        document->setFocusedElement(0);
+        return;
     }
+
+    // If this node is already the currently focused node, then calling focus() won't do anything.
+    // That is a problem when focus is removed from the webpage to chrome, and then returns.
+    // In these cases, we need to do what keyboard and mouse focus do, which is reset focus first.
+    if (document->focusedElement() == node)
+        document->setFocusedElement(0);
+
+    toElement(node)->focus();
 }
 
 void AccessibilityRenderObject::setSelectedRows(AccessibilityChildrenVector& selectedRows)
@@ -2330,7 +2329,7 @@ void AccessibilityRenderObject::handleActiveDescendantChanged()
     if (!element)
         return;
     Document* doc = renderer()->document();
-    if (!doc->frame()->selection()->isFocusedAndActive() || doc->focusedNode() != element)
+    if (!doc->frame()->selection()->isFocusedAndActive() || doc->focusedElement() != element)
         return; 
     AccessibilityRenderObject* activedescendant = static_cast<AccessibilityRenderObject*>(activeDescendant());
     
index 7145883..734c1cf 100644 (file)
@@ -405,7 +405,7 @@ id <DOMEventTarget> kit(WebCore::EventTarget* eventTarget)
 {
     // FIXME: Could we move this function to WebCore::Element and autogenerate?
     WebCore::Element* element = core(self);
-    return element->document()->focusedNode() == element;
+    return element->document()->focusedElement() == element;
 }
 
 @end
index bf23695..81d0466 100644 (file)
@@ -660,7 +660,7 @@ void Document::dispose()
     // We must make sure not to be retaining any of our children through
     // these extra pointers or we will create a reference cycle.
     m_docType = 0;
-    m_focusedNode = 0;
+    m_focusedElement = 0;
     m_hoveredElement = 0;
     m_activeElement = 0;
     m_titleElement = 0;
@@ -2104,7 +2104,7 @@ void Document::detach()
 #endif
 
     m_hoveredElement = 0;
-    m_focusedNode = 0;
+    m_focusedElement = 0;
     m_activeElement = 0;
 
     ContainerNode::detach();
@@ -3256,12 +3256,12 @@ void Document::setActiveElement(PassRefPtr<Element> newActiveElement)
 
 void Document::focusedNodeRemoved()
 {
-    setFocusedNode(0);
+    setFocusedElement(0);
 }
 
 void Document::removeFocusedNodeOfSubtree(Node* node, bool amongChildrenOnly)
 {
-    if (!m_focusedNode || this->inPageCache()) // If the document is in the page cache, then we don't need to clear out the focused node.
+    if (!m_focusedElement || this->inPageCache()) // If the document is in the page cache, then we don't need to clear out the focused node.
         return;
 
     Element* focusedElement = node->treeScope()->focusedElement();
@@ -3313,70 +3313,64 @@ void Document::setAnnotatedRegions(const Vector<AnnotatedRegionValue>& regions)
 }
 #endif
 
-bool Document::setFocusedNode(PassRefPtr<Node> prpNewFocusedNode, FocusDirection direction)
+bool Document::setFocusedElement(PassRefPtr<Element> prpNewFocusedElement, FocusDirection direction)
 {
-    RefPtr<Node> newFocusedNode = prpNewFocusedNode;
+    RefPtr<Element> newFocusedElement = prpNewFocusedElement;
 
-    // Make sure newFocusedNode is actually in this document
-    if (newFocusedNode && (newFocusedNode->document() != this))
+    // Make sure newFocusedElement is actually in this document
+    if (newFocusedElement && (newFocusedElement->document() != this))
         return true;
 
-    if (m_focusedNode == newFocusedNode)
+    if (m_focusedElement == newFocusedElement)
         return true;
 
     if (m_inPageCache)
         return false;
 
     bool focusChangeBlocked = false;
-    RefPtr<Node> oldFocusedNode = m_focusedNode;
-    m_focusedNode = 0;
+    RefPtr<Element> oldFocusedElement = m_focusedElement.release();
 
     // Remove focus from the existing focus node (if any)
-    if (oldFocusedNode) {
-        ASSERT(!oldFocusedNode->inDetach());
+    if (oldFocusedElement) {
+        ASSERT(!oldFocusedElement->inDetach());
 
-        if (oldFocusedNode->isElementNode()) {
-            Element* oldFocusedElement = toElement(oldFocusedNode.get());
-            if (oldFocusedElement->active())
-                oldFocusedElement->setActive(false);
+        if (oldFocusedElement->active())
+            oldFocusedElement->setActive(false);
 
-            toElement(oldFocusedNode.get())->setFocus(false);
-        }
+        oldFocusedElement->setFocus(false);
 
         // Dispatch a change event for form control elements that have been edited.
-        if (oldFocusedNode->isElementNode() && toElement(oldFocusedNode.get())->isFormControlElement()) {
-            HTMLFormControlElement* formControlElement = toHTMLFormControlElement(oldFocusedNode.get());
+        if (oldFocusedElement->isFormControlElement()) {
+            HTMLFormControlElement* formControlElement = toHTMLFormControlElement(oldFocusedElement.get());
             if (formControlElement->wasChangedSinceLastFormControlChangeEvent())
                 formControlElement->dispatchFormControlChangeEvent();
         }
 
         // Dispatch the blur event and let the node do any other blur related activities (important for text fields)
-        oldFocusedNode->dispatchBlurEvent(newFocusedNode);
+        oldFocusedElement->dispatchBlurEvent(newFocusedElement);
 
-        if (m_focusedNode) {
+        if (m_focusedElement) {
             // handler shifted focus
             focusChangeBlocked = true;
-            newFocusedNode = 0;
+            newFocusedElement = 0;
         }
         
-        oldFocusedNode->dispatchFocusOutEvent(eventNames().focusoutEvent, newFocusedNode); // DOM level 3 name for the bubbling blur event.
+        oldFocusedElement->dispatchFocusOutEvent(eventNames().focusoutEvent, newFocusedElement); // DOM level 3 name for the bubbling blur event.
         // FIXME: We should remove firing DOMFocusOutEvent event when we are sure no content depends
         // on it, probably when <rdar://problem/8503958> is resolved.
-        oldFocusedNode->dispatchFocusOutEvent(eventNames().DOMFocusOutEvent, newFocusedNode); // DOM level 2 name for compatibility.
+        oldFocusedElement->dispatchFocusOutEvent(eventNames().DOMFocusOutEvent, newFocusedElement); // DOM level 2 name for compatibility.
 
-        if (m_focusedNode) {
+        if (m_focusedElement) {
             // handler shifted focus
             focusChangeBlocked = true;
-            newFocusedNode = 0;
+            newFocusedElement = 0;
         }
-        if (oldFocusedNode == this && oldFocusedNode->hasOneRef())
-            return true;
             
-        if (oldFocusedNode->isRootEditableElement())
+        if (oldFocusedElement->isRootEditableElement())
             frame()->editor().didEndEditing();
 
         if (view()) {
-            Widget* oldWidget = widgetForNode(oldFocusedNode.get());
+            Widget* oldWidget = widgetForNode(oldFocusedElement.get());
             if (oldWidget)
                 oldWidget->setFocus(false);
             else
@@ -3384,27 +3378,27 @@ bool Document::setFocusedNode(PassRefPtr<Node> prpNewFocusedNode, FocusDirection
         }
     }
 
-    if (newFocusedNode && newFocusedNode->isElementNode() && toElement(newFocusedNode.get())->isFocusable()) {
-        if (newFocusedNode->isRootEditableElement() && !acceptsEditingFocus(newFocusedNode.get())) {
+    if (newFocusedElement && newFocusedElement->isFocusable()) {
+        if (newFocusedElement->isRootEditableElement() && !acceptsEditingFocus(newFocusedElement.get())) {
             // delegate blocks focus change
             focusChangeBlocked = true;
             goto SetFocusedNodeDone;
         }
         // Set focus on the new node
-        m_focusedNode = newFocusedNode;
+        m_focusedElement = newFocusedElement;
 
         // Dispatch the focus event and let the node do any other focus related activities (important for text fields)
-        m_focusedNode->dispatchFocusEvent(oldFocusedNode, direction);
+        m_focusedElement->dispatchFocusEvent(oldFocusedElement, direction);
 
-        if (m_focusedNode != newFocusedNode) {
+        if (m_focusedElement != newFocusedElement) {
             // handler shifted focus
             focusChangeBlocked = true;
             goto SetFocusedNodeDone;
         }
 
-        m_focusedNode->dispatchFocusInEvent(eventNames().focusinEvent, oldFocusedNode); // DOM level 3 bubbling focus event.
+        m_focusedElement->dispatchFocusInEvent(eventNames().focusinEvent, oldFocusedElement); // DOM level 3 bubbling focus event.
 
-        if (m_focusedNode != newFocusedNode) {
+        if (m_focusedElement != newFocusedElement) {
             // handler shifted focus
             focusChangeBlocked = true;
             goto SetFocusedNodeDone;
@@ -3412,31 +3406,30 @@ bool Document::setFocusedNode(PassRefPtr<Node> prpNewFocusedNode, FocusDirection
 
         // FIXME: We should remove firing DOMFocusInEvent event when we are sure no content depends
         // on it, probably when <rdar://problem/8503958> is m.
-        m_focusedNode->dispatchFocusInEvent(eventNames().DOMFocusInEvent, oldFocusedNode); // DOM level 2 for compatibility.
+        m_focusedElement->dispatchFocusInEvent(eventNames().DOMFocusInEvent, oldFocusedElement); // DOM level 2 for compatibility.
 
-        if (m_focusedNode != newFocusedNode) { 
+        if (m_focusedElement != newFocusedElement) {
             // handler shifted focus
             focusChangeBlocked = true;
             goto SetFocusedNodeDone;
         }
 
-        if (m_focusedNode->isElementNode())
-            toElement(m_focusedNode.get())->setFocus(true);
+        m_focusedElement->setFocus(true);
 
-        if (m_focusedNode->isRootEditableElement())
+        if (m_focusedElement->isRootEditableElement())
             frame()->editor().didBeginEditing();
 
         // eww, I suck. set the qt focus correctly
         // ### find a better place in the code for this
         if (view()) {
-            Widget* focusWidget = widgetForNode(m_focusedNode.get());
+            Widget* focusWidget = widgetForNode(m_focusedElement.get());
             if (focusWidget) {
                 // Make sure a widget has the right size before giving it focus.
                 // Otherwise, we are testing edge cases of the Widget code.
                 // Specifically, in WebCore this does not work well for text fields.
                 updateLayout();
                 // Re-get the widget in case updating the layout changed things.
-                focusWidget = widgetForNode(m_focusedNode.get());
+                focusWidget = widgetForNode(m_focusedElement.get());
             }
             if (focusWidget)
                 focusWidget->setFocus(true);
@@ -3445,14 +3438,14 @@ bool Document::setFocusedNode(PassRefPtr<Node> prpNewFocusedNode, FocusDirection
         }
     }
 
-    if (!focusChangeBlocked && m_focusedNode) {
+    if (!focusChangeBlocked && m_focusedElement) {
         // Create the AXObject cache in a focus change because GTK relies on it.
         if (AXObjectCache* cache = axObjectCache())
-            cache->handleFocusedUIElementChanged(oldFocusedNode.get(), newFocusedNode.get());
+            cache->handleFocusedUIElementChanged(oldFocusedElement.get(), newFocusedElement.get());
     }
 
     if (!focusChangeBlocked)
-        page()->chrome().focusedNodeChanged(m_focusedNode.get());
+        page()->chrome().focusedNodeChanged(m_focusedElement.get());
 
 SetFocusedNodeDone:
     updateStyleIfNeeded();
@@ -4703,15 +4696,11 @@ void Document::cancelFocusAppearanceUpdate()
 
 void Document::updateFocusAppearanceTimerFired(Timer<Document>*)
 {
-    Node* node = focusedNode();
-    if (!node)
-        return;
-    if (!node->isElementNode())
+    Element* element = focusedElement();
+    if (!element)
         return;
 
     updateLayout();
-
-    Element* element = toElement(node);
     if (element->isFocusable())
         element->updateFocusAppearance(m_updateFocusAppearanceRestoresSelection);
 }
@@ -5766,7 +5755,7 @@ Node* eventTargetNodeForDocument(Document* doc)
 {
     if (!doc)
         return 0;
-    Node* node = doc->focusedNode();
+    Node* node = doc->focusedElement();
     if (!node && doc->isPluginDocument()) {
         PluginDocument* pluginDocument = toPluginDocument(doc);
         node = pluginDocument->pluginElement();
index 7ddbf61..49ca921 100644 (file)
@@ -670,8 +670,8 @@ public:
     String selectedStylesheetSet() const;
     void setSelectedStylesheetSet(const String&);
 
-    bool setFocusedNode(PassRefPtr<Node>, FocusDirection = FocusDirectionNone);
-    Node* focusedNode() const { return m_focusedNode.get(); }
+    bool setFocusedElement(PassRefPtr<Element>, FocusDirection = FocusDirectionNone);
+    Element* focusedElement() const { return m_focusedElement.get(); }
     UserActionElementSet& userActionElements()  { return m_userActionElements; }
     const UserActionElementSet& userActionElements() const { return m_userActionElements; }
 
@@ -1345,7 +1345,7 @@ private:
 
     Color m_textColor;
 
-    RefPtr<Node> m_focusedNode;
+    RefPtr<Element> m_focusedElement;
     RefPtr<Element> m_hoveredElement;
     RefPtr<Element> m_activeElement;
     RefPtr<Element> m_documentElement;
index 4f75666..b7a91ff 100644 (file)
@@ -1443,7 +1443,7 @@ void Element::attach()
     if (hasRareData()) {   
         ElementRareData* data = elementRareData();
         if (data->needsFocusAppearanceUpdateSoonAfterAttach()) {
-            if (isFocusable() && document()->focusedNode() == this)
+            if (isFocusable() && document()->focusedElement() == this)
                 document()->updateFocusAppearanceSoon(false /* don't restore selection */);
             data->setNeedsFocusAppearanceUpdateSoonAfterAttach(false);
         }
@@ -2087,7 +2087,7 @@ void Element::focus(bool restorePreviousSelection, FocusDirection direction)
         return;
 
     Document* doc = document();
-    if (doc->focusedNode() == this)
+    if (doc->focusedElement() == this)
         return;
 
     // If the stylesheets have already been loaded we can reliably check isFocusable.
@@ -2154,7 +2154,7 @@ void Element::blur()
         if (doc->frame())
             doc->frame()->page()->focusController()->setFocusedElement(0, doc->frame());
         else
-            doc->setFocusedNode(0);
+            doc->setFocusedElement(0);
     }
 }
 
@@ -2407,7 +2407,7 @@ void Element::cancelFocusAppearanceUpdate()
 {
     if (hasRareData())
         elementRareData()->setNeedsFocusAppearanceUpdateSoonAfterAttach(false);
-    if (document()->focusedNode() == this)
+    if (document()->focusedElement() == this)
         document()->cancelFocusAppearanceUpdate();
 }
 
index 329de4e..86e8b7e 100644 (file)
@@ -685,7 +685,7 @@ bool Node::rendererIsEditable(EditableLevel editableLevel, UserSelectAllTreatmen
 
     // Ideally we'd call ASSERT(!needsStyleRecalc()) here, but
     // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion
-    // would fire in the middle of Document::setFocusedNode().
+    // would fire in the middle of Document::setFocusedElement().
 
     for (const Node* node = this; node; node = node->parentNode()) {
         if ((node->isHTMLElement() || node->isDocumentNode()) && node->renderer()) {
index 5b59d2e..3e42112 100644 (file)
@@ -392,10 +392,7 @@ static Element* focusedFrameOwnerElement(Frame* focusedFrame, Frame* currentFram
 Element* TreeScope::focusedElement()
 {
     Document* document = rootNode()->document();
-    Node* node = document->focusedNode();
-
-    ASSERT(!node || node->isElementNode());
-    Element* element = toElement(node);
+    Element* element = document->focusedElement();
 
     if (!element && document->page())
         element = focusedFrameOwnerElement(document->page()->focusController()->focusedFrame(), document->frame());
index cbe341e..50b492b 100644 (file)
@@ -27,8 +27,8 @@
 #include "UserTypingGestureIndicator.h"
 
 #include "Document.h"
+#include "Element.h"
 #include "Frame.h"
-#include "Node.h"
 #include <wtf/StdLibExtras.h>
 
 namespace WebCore {
@@ -55,7 +55,7 @@ UserTypingGestureIndicator::UserTypingGestureIndicator(Frame* frame)
     , m_previousFocusedNode(focusedNode())
 {
     s_processingUserTypingGesture = true;
-    focusedNode() = frame->document() ? frame->document()->focusedNode() : 0;
+    focusedNode() = frame->document() ? frame->document()->focusedElement() : 0;
 }
 
 UserTypingGestureIndicator::~UserTypingGestureIndicator()
index 4b51777..fcc12c1 100644 (file)
@@ -1369,12 +1369,12 @@ void Editor::toggleUnderline()
 
 void Editor::setBaseWritingDirection(WritingDirection direction)
 {
-    Node* focusedNode = frame()->document()->focusedNode();
-    if (focusedNode && isHTMLTextFormControlElement(focusedNode)) {
+    Element* focusedElement = frame()->document()->focusedElement();
+    if (focusedElement && isHTMLTextFormControlElement(focusedElement)) {
         if (direction == NaturalWritingDirection)
             return;
-        toHTMLElement(focusedNode)->setAttribute(dirAttr, direction == LeftToRightWritingDirection ? "ltr" : "rtl");
-        focusedNode->dispatchInputEvent();
+        toHTMLElement(focusedElement)->setAttribute(dirAttr, direction == LeftToRightWritingDirection ? "ltr" : "rtl");
+        focusedElement->dispatchInputEvent();
         frame()->document()->updateStyleIfNeeded();
         return;
     }
@@ -1480,7 +1480,7 @@ void Editor::setComposition(const String& text, SetCompositionMode mode)
     // Dispatch a compositionend event to the focused node.
     // We should send this event before sending a TextEvent as written in Section 6.2.2 and 6.2.3 of
     // the DOM Event specification.
-    Node* target = m_frame->document()->focusedNode();
+    Element* target = m_frame->document()->focusedElement();
     if (target) {
         RefPtr<CompositionEvent> event = CompositionEvent::create(eventNames().compositionendEvent, m_frame->document()->domWindow(), text);
         target->dispatchEvent(event, IGNORE_EXCEPTION);
@@ -1522,7 +1522,7 @@ void Editor::setComposition(const String& text, const Vector<CompositionUnderlin
         return;
     }
 
-    Node* target = m_frame->document()->focusedNode();
+    Element* target = m_frame->document()->focusedElement();
     if (target) {
         // Dispatch an appropriate composition event to the focused node.
         // We check the composition status and choose an appropriate composition event since this
@@ -1905,7 +1905,7 @@ Vector<String> Editor::guessesForMisspelledOrUngrammatical(bool& misspelled, boo
         return TextCheckingHelper(client(), range).guessesForMisspelledOrUngrammaticalRange(isGrammarCheckingEnabled(), misspelled, ungrammatical);
     }
 
-    String misspelledWord = behavior().shouldAllowSpellingSuggestionsWithoutSelection() ? misspelledWordAtCaretOrRange(m_frame->document()->focusedNode()) : misspelledSelectionString();
+    String misspelledWord = behavior().shouldAllowSpellingSuggestionsWithoutSelection() ? misspelledWordAtCaretOrRange(m_frame->document()->focusedElement()) : misspelledSelectionString();
     misspelled = !misspelledWord.isEmpty();
 
     if (misspelled) {
index 8427f77..02e4e14 100644 (file)
@@ -249,16 +249,16 @@ static TriState stateTextWritingDirection(Frame* frame, WritingDirection directi
 
 static unsigned verticalScrollDistance(Frame* frame)
 {
-    Node* focusedNode = frame->document()->focusedNode();
-    if (!focusedNode)
+    Element* focusedElement = frame->document()->focusedElement();
+    if (!focusedElement)
         return 0;
-    RenderObject* renderer = focusedNode->renderer();
+    RenderObject* renderer = focusedElement->renderer();
     if (!renderer || !renderer->isBox())
         return 0;
     RenderStyle* style = renderer->style();
     if (!style)
         return 0;
-    if (!(style->overflowY() == OSCROLL || style->overflowY() == OAUTO || focusedNode->rendererIsEditable()))
+    if (!(style->overflowY() == OSCROLL || style->overflowY() == OAUTO || focusedElement->rendererIsEditable()))
         return 0;
     int height = std::min<int>(toRenderBox(renderer)->clientHeight(), frame->view()->visibleHeight());
     return static_cast<unsigned>(max(max<int>(height * Scrollbar::minFractionToStepWhenPaging(), height - Scrollbar::maxOverlapBetweenPages()), 1));
index bd558cd..c063668 100644 (file)
@@ -1633,8 +1633,8 @@ void FrameSelection::selectAll()
 {
     Document* document = m_frame->document();
 
-    if (document->focusedNode() && document->focusedNode()->hasTagName(selectTag)) {
-        HTMLSelectElement* selectElement = toHTMLSelectElement(document->focusedNode());
+    if (document->focusedElement() && document->focusedElement()->hasTagName(selectTag)) {
+        HTMLSelectElement* selectElement = toHTMLSelectElement(document->focusedElement());
         if (selectElement->canSelectAll()) {
             selectElement->selectAll();
             return;
@@ -1722,9 +1722,9 @@ void FrameSelection::focusedOrActiveStateChanged()
     // Because StyleResolver::checkOneSelector() and
     // RenderTheme::isFocused() check if the frame is active, we have to
     // update style and theme state that depended on those.
-    if (Node* node = m_frame->document()->focusedNode()) {
-        node->setNeedsStyleRecalc();
-        if (RenderObject* renderer = node->renderer())
+    if (Element* element = m_frame->document()->focusedElement()) {
+        element->setNeedsStyleRecalc();
+        if (RenderObject* renderer = element->renderer())
             if (renderer && renderer->style()->hasAppearance())
                 renderer->theme()->stateChanged(renderer, FocusState);
     }
@@ -1901,7 +1901,7 @@ void FrameSelection::setFocusedElementIfNeeded()
             }
             target = target->parentOrShadowHostElement();
         }
-        m_frame->document()->setFocusedNode(0);
+        m_frame->document()->setFocusedElement(0);
     }
 
     if (caretBrowsing)
@@ -1987,7 +1987,7 @@ static HTMLFormElement* scanForForm(Node* start)
 HTMLFormElement* FrameSelection::currentForm() const
 {
     // Start looking either at the active (first responder) node, or where the selection is.
-    Node* start = m_frame->document()->focusedNode();
+    Node* start = m_frame->document()->focusedElement();
     if (!start)
         start = this->start().deprecatedNode();
 
index 5a9eb00..bd2e0f9 100644 (file)
@@ -84,10 +84,8 @@ void CachedPage::restore(Page* page)
     // Restore the focus appearance for the focused element.
     // FIXME: Right now we don't support pages w/ frames in the b/f cache.  This may need to be tweaked when we add support for that.
     Document* focusedDocument = page->focusController()->focusedOrMainFrame()->document();
-    if (Node* node = focusedDocument->focusedNode()) {
-        if (node->isElementNode())
-            toElement(node)->updateFocusAppearance(true);
-    }
+    if (Element* element = focusedDocument->focusedElement())
+        element->updateFocusAppearance(true);
 
     if (m_needStyleRecalcForVisitedLinks) {
         for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext())
index 53133f2..5cbbffc 100644 (file)
@@ -537,7 +537,7 @@ void HTMLInputElement::updateType()
 
     if (wasAttached) {
         attach();
-        if (document()->focusedNode() == this)
+        if (document()->focusedElement() == this)
             updateFocusAppearance(true);
     }
 
@@ -813,7 +813,7 @@ void HTMLInputElement::attach()
 
     m_inputType->attach();
 
-    if (document()->focusedNode() == this)
+    if (document()->focusedElement() == this)
         document()->updateFocusAppearanceSoon(true /* restore selection */);
 }
 
index 4e2c67a..9a31b5d 100644 (file)
@@ -389,7 +389,7 @@ void HTMLTextAreaElement::setValueCommon(const String& newValue)
     setFormControlValueMatchesRenderer(true);
 
     // Set the caret to the end of the text value.
-    if (document()->focusedNode() == this) {
+    if (document()->focusedElement() == this) {
         unsigned endOfString = m_value.length();
         setSelectionRange(endOfString, endOfString);
     }
index 3df736a..9b6fb21 100644 (file)
@@ -153,7 +153,7 @@ bool HTMLTextFormControlElement::placeholderShouldBeVisible() const
         && isEmptyValue()
         && isEmptySuggestedValue()
         && !isPlaceholderEmpty()
-        && (document()->focusedNode() != this || (renderer() && renderer()->theme()->shouldShowPlaceholderWhenFocused()))
+        && (document()->focusedElement() != this || (renderer() && renderer()->theme()->shouldShowPlaceholderWhenFocused()))
         && (!renderer() || renderer()->style()->visibility() == VISIBLE);
 }
 
@@ -362,7 +362,7 @@ int HTMLTextFormControlElement::selectionStart() const
 {
     if (!isTextFormControl())
         return 0;
-    if (document()->focusedNode() != this && hasCachedSelection())
+    if (document()->focusedElement() != this && hasCachedSelection())
         return m_cachedSelectionStart;
 
     return computeSelectionStart();
@@ -382,7 +382,7 @@ int HTMLTextFormControlElement::selectionEnd() const
 {
     if (!isTextFormControl())
         return 0;
-    if (document()->focusedNode() != this && hasCachedSelection())
+    if (document()->focusedElement() != this && hasCachedSelection())
         return m_cachedSelectionEnd;
     return computeSelectionEnd();
 }
@@ -420,7 +420,7 @@ const AtomicString& HTMLTextFormControlElement::selectionDirection() const
 {
     if (!isTextFormControl())
         return directionString(SelectionHasNoDirection);
-    if (document()->focusedNode() != this && hasCachedSelection())
+    if (document()->focusedElement() != this && hasCachedSelection())
         return directionString(m_cachedSelectionDirection);
 
     return directionString(computeSelectionDirection());
index 1c27a0b..286387c 100644 (file)
@@ -96,7 +96,7 @@ void RadioInputType::handleKeydownEvent(KeyboardEvent* event)
         if (inputElement->form() != element()->form())
             break;
         if (inputElement->isRadioButton() && inputElement->name() == element()->name() && inputElement->isFocusable()) {
-            document->setFocusedNode(inputElement);
+            document->setFocusedElement(inputElement);
             inputElement->dispatchSimulatedClick(event, SendNoEvents, DoNotShowPressedLook);
             event->setDefaultHandled();
             return;
@@ -127,7 +127,7 @@ bool RadioInputType::isKeyboardFocusable(KeyboardEvent* event) const
 
     // Never allow keyboard tabbing to leave you in the same radio group.  Always
     // skip any other elements in the group.
-    Node* currentFocusedNode = element()->document()->focusedNode();
+    Element* currentFocusedNode = element()->document()->focusedElement();
     if (currentFocusedNode && currentFocusedNode->hasTagName(inputTag)) {
         HTMLInputElement* focusedInput = static_cast<HTMLInputElement*>(currentFocusedNode);
         if (focusedInput->isRadioButton() && focusedInput->form() == element()->form() && focusedInput->name() == element()->name())
index 2be6ea1..6b2f082 100644 (file)
@@ -577,7 +577,7 @@ DateTimeFieldElement* DateTimeEditElement::focusedField() const
 
 size_t DateTimeEditElement::focusedFieldIndex() const
 {
-    Node* const focusedFieldNode = document()->focusedNode();
+    Node* const focusedFieldNode = document()->focusedElement();
     for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) {
         if (m_fields[fieldIndex] == focusedFieldNode)
             return fieldIndex;
index e2cd077..e984a2d 100644 (file)
@@ -394,9 +394,9 @@ void FrameLoader::stopLoading(UnloadEventPolicy unloadEventPolicy)
     if (unloadEventPolicy != UnloadEventPolicyNone) {
         if (m_frame->document()) {
             if (m_didCallImplicitClose && !m_wasUnloadEventEmitted) {
-                Node* currentFocusedNode = m_frame->document()->focusedNode();
-                if (currentFocusedNode && currentFocusedNode->toInputElement())
-                    currentFocusedNode->toInputElement()->endEditing();
+                Element* currentFocusedElement = m_frame->document()->focusedElement();
+                if (currentFocusedElement && currentFocusedElement->toInputElement())
+                    currentFocusedElement->toInputElement()->endEditing();
                 if (m_pageDismissalEventBeingDispatched == NoDismissal) {
                     if (unloadEventPolicy == UnloadEventPolicyUnloadAndPageHide) {
                         m_pageDismissalEventBeingDispatched = PageHideDismissal;
index d357eca..30bbb78 100644 (file)
@@ -944,7 +944,7 @@ void DOMWindow::focus(ScriptExecutionContext* context)
     // Clear the current frame's focused node if a new frame is about to be focused.
     Frame* focusedFrame = page->focusController()->focusedFrame();
     if (focusedFrame && focusedFrame != m_frame)
-        focusedFrame->document()->setFocusedNode(0);
+        focusedFrame->document()->setFocusedElement(0);
 
     m_frame->eventHandler()->focusDocumentView();
 }
index 4254ada..1767946 100644 (file)
@@ -1084,7 +1084,7 @@ bool EventHandler::scrollOverflow(ScrollDirection direction, ScrollGranularity g
     Node* node = startingNode;
 
     if (!node)
-        node = m_frame->document()->focusedNode();
+        node = m_frame->document()->focusedElement();
 
     if (!node)
         node = m_mousePressNode.get();
@@ -1105,7 +1105,7 @@ bool EventHandler::logicalScrollOverflow(ScrollLogicalDirection direction, Scrol
     Node* node = startingNode;
 
     if (!node)
-        node = m_frame->document()->focusedNode();
+        node = m_frame->document()->focusedElement();
 
     if (!node)
         node = m_mousePressNode.get();
@@ -2346,7 +2346,7 @@ bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targe
                 // will set a selection inside it, which will call setFocuseNodeIfNeeded.
                 if (m_frame->selection()->isRange()
                     && m_frame->selection()->toNormalizedRange()->compareNode(element, IGNORE_EXCEPTION) == Range::NODE_INSIDE
-                    && element->isDescendantOf(m_frame->document()->focusedNode()))
+                    && element->isDescendantOf(m_frame->document()->focusedElement()))
                     return true;
                     
                 break;
@@ -2945,7 +2945,7 @@ bool EventHandler::sendContextMenuEventForKey()
 #endif
     IntPoint location;
 
-    Node* focusedNode = doc->focusedNode();
+    Element* focusedElement = doc->focusedElement();
     FrameSelection* selection = m_frame->selection();
     Position start = selection->selection().start();
 
@@ -2957,8 +2957,8 @@ bool EventHandler::sendContextMenuEventForKey()
         // In a multiline edit, firstRect.maxY() would endup on the next line, so -1.
         int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0;
         location = IntPoint(x, y);
-    } else if (focusedNode) {
-        RenderBoxModelObject* box = focusedNode->renderBoxModelObject();
+    } else if (focusedElement) {
+        RenderBoxModelObject* box = focusedElement->renderBoxModelObject();
         if (!box)
             return false;
         IntRect clippedRect = box->pixelSnappedAbsoluteClippedOverflowRect();
@@ -2974,7 +2974,7 @@ bool EventHandler::sendContextMenuEventForKey()
     IntPoint position = view->contentsToRootView(location);
     IntPoint globalPosition = view->hostWindow()->rootViewToScreen(IntRect(position, IntSize())).location();
 
-    Node* targetNode = doc->focusedNode();
+    Node* targetNode = doc->focusedElement();
     if (!targetNode)
         targetNode = doc;
 
@@ -3775,8 +3775,8 @@ void EventHandler::defaultTabEventHandler(KeyboardEvent* event)
 void EventHandler::capsLockStateMayHaveChanged()
 {
     Document* d = m_frame->document();
-    if (Node* node = d->focusedNode()) {
-        if (RenderObject* r = node->renderer()) {
+    if (Element* element = d->focusedElement()) {
+        if (RenderObject* r = element->renderer()) {
             if (r->isTextField())
                 toRenderTextControlSingleLine(r)->capsLockStateMayHaveChanged();
         }
index 27ca370..ae40695 100644 (file)
@@ -122,11 +122,11 @@ static inline void dispatchEventsOnWindowAndFocusedNode(Document* document, bool
             return;
     }
 
-    if (!focused && document->focusedNode())
-        document->focusedNode()->dispatchBlurEvent(0);
+    if (!focused && document->focusedElement())
+        document->focusedElement()->dispatchBlurEvent(0);
     document->dispatchWindowEvent(Event::create(focused ? eventNames().focusEvent : eventNames().blurEvent, false, false));
-    if (focused && document->focusedNode())
-        document->focusedNode()->dispatchFocusEvent(0, FocusDirectionNone);
+    if (focused && document->focusedElement())
+        document->focusedElement()->dispatchFocusEvent(0, FocusDirectionNone);
 }
 
 static inline bool hasCustomFocusLogic(Node* node)
@@ -284,7 +284,7 @@ bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, Keyb
     ASSERT(frame);
     Document* document = frame->document();
 
-    Node* currentNode = document->focusedNode();
+    Node* currentNode = document->focusedElement();
     // FIXME: Not quite correct when it comes to focus transitions leaving/entering the WebView itself
     bool caretBrowsing = frame->settings() && frame->settings()->caretBrowsingEnabled();
 
@@ -298,7 +298,7 @@ bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, Keyb
     if (!node) {
         // We didn't find a node to focus, so we should try to pass focus to Chrome.
         if (!initialFocus && m_page->chrome().canTakeFocus(direction)) {
-            document->setFocusedNode(0);
+            document->setFocusedElement(0);
             setFocusedFrame(0);
             m_page->chrome().takeFocus(direction);
             return true;
@@ -314,7 +314,7 @@ bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, Keyb
 
     ASSERT(node);
 
-    if (node == document->focusedNode())
+    if (node == document->focusedElement())
         // Focus wrapped around to the same node.
         return true;
 
@@ -331,12 +331,12 @@ bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, Keyb
         if (!owner->contentFrame())
             return false;
 
-        document->setFocusedNode(0);
+        document->setFocusedElement(0);
         setFocusedFrame(owner->contentFrame());
         return true;
     }
     
-    // FIXME: It would be nice to just be able to call setFocusedNode(node) here, but we can't do
+    // FIXME: It would be nice to just be able to call setFocusedElement(node) here, but we can't do
     // that because some elements (e.g. HTMLInputElement and HTMLTextAreaElement) do extra work in
     // their focus() methods.
 
@@ -344,7 +344,7 @@ bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, Keyb
 
     if (newDocument != document)
         // Focus is going away from this document, so clear the focused node.
-        document->setFocusedNode(0);
+        document->setFocusedElement(0);
 
     if (newDocument)
         setFocusedFrame(newDocument->frame());
@@ -595,12 +595,12 @@ bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newF
     RefPtr<Frame> oldFocusedFrame = focusedFrame();
     RefPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame->document() : 0;
     
-    Node* oldFocusedNode = oldDocument ? oldDocument->focusedNode() : 0;
-    if (oldFocusedNode == element)
+    Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : 0;
+    if (oldFocusedElement == element)
         return true;
 
     // FIXME: Might want to disable this check for caretBrowsing
-    if (oldFocusedNode && oldFocusedNode->isRootEditableElement() && !relinquishesEditingFocus(oldFocusedNode))
+    if (oldFocusedElement && oldFocusedElement->isRootEditableElement() && !relinquishesEditingFocus(oldFocusedElement))
         return false;
 
     m_page->editorClient()->willSetInputMethodState();
@@ -609,20 +609,20 @@ bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newF
 
     if (!element) {
         if (oldDocument)
-            oldDocument->setFocusedNode(0);
+            oldDocument->setFocusedElement(0);
         m_page->editorClient()->setInputMethodState(false);
         return true;
     }
 
     RefPtr<Document> newDocument = element->document();
 
-    if (newDocument && newDocument->focusedNode() == element) {
+    if (newDocument && newDocument->focusedElement() == element) {
         m_page->editorClient()->setInputMethodState(element->shouldUseInputMethod());
         return true;
     }
     
     if (oldDocument && oldDocument != newDocument)
-        oldDocument->setFocusedNode(0);
+        oldDocument->setFocusedElement(0);
 
     if (newFocusedFrame && !newFocusedFrame->page()) {
         setFocusedFrame(0);
@@ -632,12 +632,12 @@ bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newF
 
     RefPtr<Element> protect(element);
     if (newDocument) {
-        bool successfullyFocused = newDocument->setFocusedNode(element, direction);
+        bool successfullyFocused = newDocument->setFocusedElement(element, direction);
         if (!successfullyFocused)
             return false;
     }
 
-    if (newDocument->focusedNode() == element)
+    if (newDocument->focusedElement() == element)
         m_page->editorClient()->setInputMethodState(element->shouldUseInputMethod());
 
     return true;
@@ -754,7 +754,7 @@ static void updateFocusCandidateIfNeeded(FocusDirection direction, const FocusCa
 void FocusController::findFocusCandidateInContainer(Node* container, const LayoutRect& startingRect, FocusDirection direction, KeyboardEvent* event, FocusCandidate& closest)
 {
     ASSERT(container);
-    Node* focusedNode = (focusedFrame() && focusedFrame()->document()) ? focusedFrame()->document()->focusedNode() : 0;
+    Node* focusedNode = (focusedFrame() && focusedFrame()->document()) ? focusedFrame()->document()->focusedElement() : 0;
 
     Element* element = ElementTraversal::firstWithin(container);
     FocusCandidate current;
@@ -813,9 +813,9 @@ bool FocusController::advanceFocusDirectionallyInContainer(Node* container, cons
         }
         // Navigate into a new frame.
         LayoutRect rect;
-        Node* focusedNode = focusedOrMainFrame()->document()->focusedNode();
-        if (focusedNode && !hasOffscreenRect(focusedNode))
-            rect = nodeRectInAbsoluteCoordinates(focusedNode, true /* ignore border */);
+        Element* focusedElement = focusedOrMainFrame()->document()->focusedElement();
+        if (focusedElement && !hasOffscreenRect(focusedElement))
+            rect = nodeRectInAbsoluteCoordinates(focusedElement, true /* ignore border */);
         frameElement->contentFrame()->document()->updateLayoutIgnorePendingStylesheets();
         if (!advanceFocusDirectionallyInContainer(frameElement->contentFrame()->document(), rect, direction, event)) {
             // The new frame had nothing interesting, need to find another candidate.
@@ -831,9 +831,9 @@ bool FocusController::advanceFocusDirectionallyInContainer(Node* container, cons
         }
         // Navigate into a new scrollable container.
         LayoutRect startingRect;
-        Node* focusedNode = focusedOrMainFrame()->document()->focusedNode();
-        if (focusedNode && !hasOffscreenRect(focusedNode))
-            startingRect = nodeRectInAbsoluteCoordinates(focusedNode, true);
+        Element* focusedElement = focusedOrMainFrame()->document()->focusedElement();
+        if (focusedElement && !hasOffscreenRect(focusedElement))
+            startingRect = nodeRectInAbsoluteCoordinates(focusedElement, true);
         return advanceFocusDirectionallyInContainer(focusCandidate.visibleNode, startingRect, direction, event);
     }
     if (focusCandidate.isOffscreenAfterScrolling) {
@@ -859,7 +859,7 @@ bool FocusController::advanceFocusDirectionally(FocusDirection direction, Keyboa
     if (!focusedDocument)
         return false;
 
-    Node* focusedNode = focusedDocument->focusedNode();
+    Element* focusedElement = focusedDocument->focusedElement();
     Node* container = focusedDocument;
 
     if (container->isDocumentNode())
@@ -867,12 +867,12 @@ bool FocusController::advanceFocusDirectionally(FocusDirection direction, Keyboa
         
     // Figure out the starting rect.
     LayoutRect startingRect;
-    if (focusedNode) {
-        if (!hasOffscreenRect(focusedNode)) {
-            container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direction, focusedNode);
-            startingRect = nodeRectInAbsoluteCoordinates(focusedNode, true /* ignore border */);
-        } else if (focusedNode->hasTagName(areaTag)) {
-            HTMLAreaElement* area = static_cast<HTMLAreaElement*>(focusedNode);
+    if (focusedElement) {
+        if (!hasOffscreenRect(focusedElement)) {
+            container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direction, focusedElement);
+            startingRect = nodeRectInAbsoluteCoordinates(focusedElement, true /* ignore border */);
+        } else if (focusedElement->hasTagName(areaTag)) {
+            HTMLAreaElement* area = static_cast<HTMLAreaElement*>(focusedElement);
             container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direction, area->imageElement());
             startingRect = virtualRectForAreaElementAndDirection(area, direction);
         }
index 005fef5..112b8b5 100644 (file)
@@ -1865,7 +1865,7 @@ bool FrameView::scrollToAnchor(const String& name)
     
     // If the anchor accepts keyboard focus, move focus there to aid users relying on keyboard navigation.
     if (anchorElement && anchorElement->isFocusable())
-        m_frame->document()->setFocusedNode(anchorElement);
+        m_frame->document()->setFocusedElement(anchorElement);
     
     return true;
 }
index 85ca0fa..e481916 100644 (file)
@@ -887,11 +887,10 @@ PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* p
 
 void PluginView::focusPluginElement()
 {
-    // Focus the plugin
     if (Page* page = m_parentFrame->page())
         page->focusController()->setFocusedElement(m_element, m_parentFrame);
     else
-        m_parentFrame->document()->setFocusedNode(m_element);
+        m_parentFrame->document()->setFocusedElement(m_element);
 }
 
 void PluginView::didReceiveResponse(const ResourceResponse& response)
index b1aa8ab..31acb12 100644 (file)
@@ -125,7 +125,7 @@ void PluginView::updatePluginWidget()
 void PluginView::setFocus(bool focused)
 {
     if (focused)
-        m_element->document()->setFocusedNode(m_element);
+        m_element->document()->setFocusedElement(m_element);
 
     Widget::setFocus(focused);
 }
index 42fa579..ab67263 100644 (file)
@@ -708,7 +708,7 @@ void PluginView::handleMouseEvent(MouseEvent* event)
             // The plugin needs focus to receive keyboard events
             if (Page* page = m_parentFrame->page())
                 page->focusController()->setFocusedFrame(m_parentFrame);
-            m_parentFrame->document()->setFocusedNode(m_element);
+            m_parentFrame->document()->setFocusedElement(m_element);
         } else if (event->type() == eventNames().mouseupEvent) {
             record.what = mouseUp;
         } else {
@@ -752,7 +752,7 @@ void PluginView::handleMouseEvent(MouseEvent* event)
                 // The plugin needs focus to receive keyboard events
                 if (Page* page = m_parentFrame->page())
                     page->focusController()->setFocusedFrame(m_parentFrame);
-                m_parentFrame->document()->setFocusedNode(m_element);
+                m_parentFrame->document()->setFocusedElement(m_element);
                 break;
                 
             case NSLeftMouseUp:
index 59541eb..9dfbc07 100644 (file)
@@ -424,11 +424,11 @@ void RenderImage::paintAreaElementFocusRing(PaintInfo& paintInfo)
     if (paintInfo.context->paintingDisabled() && !paintInfo.context->updatingControlTints())
         return;
 
-    Node* focusedNode = document->focusedNode();
-    if (!focusedNode || !focusedNode->hasTagName(areaTag))
+    Element* focusedElement = document->focusedElement();
+    if (!focusedElement || !focusedElement->hasTagName(areaTag))
         return;
 
-    HTMLAreaElement* areaElement = static_cast<HTMLAreaElement*>(focusedNode);
+    HTMLAreaElement* areaElement = static_cast<HTMLAreaElement*>(focusedElement);
     if (areaElement->imageElement() != node())
         return;
 
index 33e3ed7..3235cd4 100644 (file)
@@ -412,7 +412,7 @@ void RenderListBox::paintItemForeground(PaintInfo& paintInfo, const LayoutPoint&
 
     Color textColor = element->renderStyle() ? element->renderStyle()->visitedDependentColor(CSSPropertyColor) : style()->visitedDependentColor(CSSPropertyColor);
     if (isOptionElement && toHTMLOptionElement(element)->selected()) {
-        if (frame()->selection()->isFocusedAndActive() && document()->focusedNode() == node())
+        if (frame()->selection()->isFocusedAndActive() && document()->focusedElement() == node())
             textColor = theme()->activeListBoxSelectionForegroundColor();
         // Honor the foreground color for disabled items
         else if (!element->isDisabledFormControl() && !select->isDisabledFormControl())
@@ -445,7 +445,7 @@ void RenderListBox::paintItemBackground(PaintInfo& paintInfo, const LayoutPoint&
 
     Color backColor;
     if (element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected()) {
-        if (frame()->selection()->isFocusedAndActive() && document()->focusedNode() == node())
+        if (frame()->selection()->isFocusedAndActive() && document()->focusedElement() == node())
             backColor = theme()->activeListBoxSelectionBackgroundColor();
         else
             backColor = theme()->inactiveListBoxSelectionBackgroundColor();
index 6a7de7b..0aa0476 100644 (file)
@@ -276,7 +276,7 @@ void RenderTextControlSingleLine::capsLockStateMayHaveChanged()
     if (Frame* frame = document()->frame())
         shouldDrawCapsLockIndicator = inputElement()->isPasswordField()
                                       && frame->selection()->isFocusedAndActive()
-                                      && document()->focusedNode() == node()
+                                      && document()->focusedElement() == node()
                                       && PlatformKeyboardEvent::currentCapsLockState();
 
     if (shouldDrawCapsLockIndicator != m_shouldDrawCapsLockIndicator) {
@@ -403,7 +403,7 @@ PassRefPtr<RenderStyle> RenderTextControlSingleLine::createInnerBlockStyle(const
 
 bool RenderTextControlSingleLine::textShouldBeTruncated() const
 {
-    return document()->focusedNode() != node()
+    return document()->focusedElement() != node()
         && style()->textOverflow() == TextOverflowEllipsis;
 }
 
index 74f8ad9..02ca1a5 100644 (file)
@@ -800,7 +800,7 @@ bool RenderTheme::isFocused(const RenderObject* o) const
     Element* focusDelegate = toElement(node)->focusDelegate();
     Document* document = focusDelegate->document();
     Frame* frame = document->frame();
-    return focusDelegate == document->focusedNode() && frame && frame->selection()->isFocusedAndActive();
+    return focusDelegate == document->focusedElement() && frame && frame->selection()->isFocusedAndActive();
 }
 
 bool RenderTheme::isPressed(const RenderObject* o) const
index 450b4d9..2d214b9 100644 (file)
@@ -2556,8 +2556,8 @@ Platform::IntRect WebPagePrivate::focusNodeRect()
 
     const Platform::ViewportAccessor* viewportAccessor = m_webkitThreadViewportAccessor;
 
-    IntRect focusRect = rectForNode(doc->focusedNode());
-    focusRect = adjustRectOffsetForFrameOffset(focusRect, doc->focusedNode());
+    IntRect focusRect = rectForNode(doc->focusedElement());
+    focusRect = adjustRectOffsetForFrameOffset(focusRect, doc->focusedElement());
     focusRect = viewportAccessor->roundToPixelFromDocumentContents(WebCore::FloatRect(focusRect));
     focusRect.intersect(viewportAccessor->pixelContentsRect());
     return focusRect;
@@ -2572,7 +2572,7 @@ PassRefPtr<Node> WebPagePrivate::contextNode(TargetDetectionStrategy strategy)
     // Check if we're using LinkToLink and the user is not touching the screen.
     if (m_webSettings->doesGetFocusNodeContext() && !isTouching) {
         RefPtr<Node> node;
-        node = m_page->focusController()->focusedOrMainFrame()->document()->focusedNode();
+        node = m_page->focusController()->focusedOrMainFrame()->document()->focusedElement();
         if (node) {
             IntRect visibleRect = IntRect(IntPoint(), actualVisibleSize());
             if (!visibleRect.intersects(getNodeWindowRect(node.get())))
@@ -4168,7 +4168,7 @@ void WebPagePrivate::clearFocusNode()
         return;
     ASSERT(frame->document());
 
-    if (frame->document()->focusedNode())
+    if (frame->document()->focusedElement())
         frame->page()->focusController()->setFocusedElement(0, frame);
 }
 
@@ -4913,7 +4913,7 @@ bool WebPage::setNodeFocus(const WebDOMNode& node, bool on)
                 if (nodeImpl->isElementNode())
                     toElement(nodeImpl)->updateFocusAppearance(true);
                 d->m_inputHandler->didNodeOpenPopup(nodeImpl);
-            } else if (doc->focusedNode() == nodeImpl) // && !on
+            } else if (doc->focusedElement() == nodeImpl) // && !on
                 page->focusController()->setFocusedElement(0, doc->frame());
 
             return true;
index 730df4e..7feede5 100644 (file)
@@ -1,3 +1,28 @@
+2013-05-28  Andreas Kling  <akling@apple.com>
+
+        Document::setFocusedNode() should be setFocusedElement().
+        <http://webkit.org/b/116857>
+
+        Reviewed by Antti Koivisto.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::focusNodeRect):
+        (BlackBerry::WebKit::WebPagePrivate::contextNode):
+        (BlackBerry::WebKit::WebPagePrivate::clearFocusNode):
+        (BlackBerry::WebKit::WebPage::setNodeFocus):
+        * WebCoreSupport/EditorClientBlackBerry.cpp:
+        (WebCore::EditorClientBlackBerry::shouldSpellCheckFocusedField):
+        (WebCore::EditorClientBlackBerry::shouldChangeSelectedRange):
+        * WebKitSupport/InputHandler.cpp:
+        (BlackBerry::WebKit::InputHandler::focusedNodeChanged):
+        * WebKitSupport/SelectionHandler.cpp:
+        (BlackBerry::WebKit::SelectionHandler::setCaretPosition):
+        (BlackBerry::WebKit::SelectionHandler::extendSelectionToFieldBoundary):
+        (BlackBerry::WebKit::SelectionHandler::updateOrHandleInputSelection):
+        (BlackBerry::WebKit::SelectionHandler::clipPointToVisibleContainer):
+        (BlackBerry::WebKit::SelectionHandler::inputNodeOverridesTouch):
+        (BlackBerry::WebKit::SelectionHandler::selectionPositionChanged):
+
 2013-05-28  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Fix BlackBerry debug build after r150756.
index d5152e0..ffcf097 100644 (file)
@@ -96,7 +96,7 @@ bool EditorClientBlackBerry::shouldSpellCheckFocusedField()
     if (!frame || !frame->document() || !frame->editor())
         return false;
 
-    const Node* node = frame->document()->focusedNode();
+    const Node* node = frame->document()->focusedElement();
     // NOTE: This logic is taken from EditorClientImpl::shouldSpellcheckByDefault
     // If |node| is null, we default to allowing spellchecking. This is done in
     // order to mitigate the issue when the user clicks outside the textbox, as a
@@ -190,10 +190,10 @@ bool EditorClientBlackBerry::shouldChangeSelectedRange(Range* fromRange, Range*
 
     Frame* frame = m_webPagePrivate->focusedOrMainFrame();
     if (frame && frame->document()) {
-        if (Node* focusedNode = frame->document()->focusedNode()) {
-            if (focusedNode->hasTagName(HTMLNames::selectTag))
+        if (Element* focusedElement = frame->document()->focusedElement()) {
+            if (focusedElement->hasTagName(HTMLNames::selectTag))
                 return false;
-            if (focusedNode->isElementNode() && DOMSupport::isPopupInputField(toElement(focusedNode)))
+            if (DOMSupport::isPopupInputField(focusedElement))
                 return false;
         }
 
index 849369e..eb6bec8 100644 (file)
@@ -427,7 +427,7 @@ void InputHandler::focusedNodeChanged()
     if (!frame || !frame->document())
         return;
 
-    Node* node = frame->document()->focusedNode();
+    Node* node = frame->document()->focusedElement();
 
     if (isActiveTextEdit() && m_currentFocusElement == node) {
         notifyClientOfKeyboardVisibilityChange(true);
index f5736f1..1f42b7d 100644 (file)
@@ -246,7 +246,7 @@ bool SelectionHandler::shouldUpdateSelectionOrCaretForPoint(const WebCore::IntPo
 
 void SelectionHandler::setCaretPosition(const WebCore::IntPoint& position)
 {
-    if (!m_webPage->m_inputHandler->isInputMode() || !m_webPage->focusedOrMainFrame()->document()->focusedNode())
+    if (!m_webPage->m_inputHandler->isInputMode() || !m_webPage->focusedOrMainFrame()->document()->focusedElement())
         return;
 
     m_caretActive = true;
@@ -369,14 +369,14 @@ static bool pointIsOutsideOfBoundingBoxInDirection(unsigned direction, const Web
 unsigned SelectionHandler::extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, VisibleSelection& newSelection)
 {
     Frame* focusedFrame = m_webPage->focusedOrMainFrame();
-    if (!focusedFrame->document()->focusedNode() || !focusedFrame->document()->focusedNode()->renderer())
+    if (!focusedFrame->document()->focusedElement() || !focusedFrame->document()->focusedElement()->renderer())
         return 0;
 
     VisibleSelection activeSelection = focusedFrame->selection()->selection();
 
     WebCore::IntRect caretRect = isStartHandle ? activeSelection.visibleStart().absoluteCaretBounds() : activeSelection.visibleEnd().absoluteCaretBounds();
 
-    WebCore::IntRect nodeBoundingBox = focusedFrame->document()->focusedNode()->renderer()->absoluteBoundingBoxRect();
+    WebCore::IntRect nodeBoundingBox = focusedFrame->document()->focusedElement()->renderer()->absoluteBoundingBoxRect();
     nodeBoundingBox.inflate(-1);
 
     // Start handle is outside of the field. Treat it as the changed handle and move
@@ -414,7 +414,7 @@ bool SelectionHandler::updateOrHandleInputSelection(VisibleSelection& newSelecti
     ASSERT(m_webPage->m_inputHandler->isInputMode());
 
     Frame* focusedFrame = m_webPage->focusedOrMainFrame();
-    Node* focusedNode = focusedFrame->document()->focusedNode();
+    Node* focusedNode = focusedFrame->document()->focusedElement();
     if (!focusedNode || !focusedNode->renderer())
         return false;
 
@@ -1064,9 +1064,9 @@ WebCore::IntPoint SelectionHandler::clipPointToVisibleContainer(const WebCore::I
     WebCore::IntPoint clippedPoint = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), frame, point, true /* clampToTargetFrame */);
 
     if (m_webPage->m_inputHandler->isInputMode()
-        && frame->document()->focusedNode()
-        && frame->document()->focusedNode()->renderer()) {
-            WebCore::IntRect boundingBox(frame->document()->focusedNode()->renderer()->absoluteBoundingBoxRect());
+        && frame->document()->focusedElement()
+        && frame->document()->focusedElement()->renderer()) {
+            WebCore::IntRect boundingBox(frame->document()->focusedElement()->renderer()->absoluteBoundingBoxRect());
             boundingBox.inflate(-1);
             clippedPoint = WebCore::IntPoint(clamp(boundingBox.x(), clippedPoint.x(), boundingBox.maxX()), clamp(boundingBox.y(), clippedPoint.y(), boundingBox.maxY()));
     }
@@ -1108,7 +1108,7 @@ bool SelectionHandler::inputNodeOverridesTouch() const
     if (!m_webPage->m_inputHandler->isInputMode())
         return false;
 
-    Node* focusedNode = m_webPage->focusedOrMainFrame()->document()->focusedNode();
+    Node* focusedNode = m_webPage->focusedOrMainFrame()->document()->focusedElement();
     if (!focusedNode || !focusedNode->isElementNode())
         return false;
 
@@ -1166,7 +1166,7 @@ void SelectionHandler::selectionPositionChanged(bool forceUpdateWithoutChange)
     else if (!m_selectionActive)
         return;
 
-    if (Node* focusedNode = frame->document()->focusedNode()) {
+    if (Node* focusedNode = frame->document()->focusedElement()) {
         if (focusedNode->hasTagName(HTMLNames::selectTag) || (focusedNode->isElementNode() && DOMSupport::isPopupInputField(toElement(focusedNode)))) {
             SelectionLog(Platform::LogLevelInfo, "SelectionHandler::selectionPositionChanged selection is on a popup control, skipping rendering.");
             return;
index dd96dde..adeaa03 100644 (file)
@@ -1,3 +1,15 @@
+2013-05-28  Andreas Kling  <akling@apple.com>
+
+        Document::setFocusedNode() should be setFocusedElement().
+        <http://webkit.org/b/116857>
+
+        Reviewed by Antti Koivisto.
+
+        * ewk/ewk_frame.cpp:
+        (ewk_frame_focused_element_geometry_get):
+        * ewk/ewk_view.cpp:
+        (ewk_view_input_method_state_set):
+
 2013-05-28  Ryuan Choi  <ryuan.choi@samsung.com>
 
         [EFL] pc files should have harfbuzz dependency.
index ccf7e50..bd981aa 100644 (file)
@@ -869,7 +869,7 @@ Eina_Bool ewk_frame_focused_element_geometry_get(const Evas_Object *ewkFrame, in
     WebCore::Document* document = smartData->frame->document();
     if (!document)
         return false;
-    WebCore::Node* focusedNode = document->focusedNode();
+    WebCore::Node* focusedNode = document->focusedElement();
     if (!focusedNode)
         return false;
     WebCore::IntRect nodeRect = focusedNode->pixelSnappedBoundingBox();
index e01f40e..54f1b5a 100644 (file)
@@ -3061,11 +3061,11 @@ void ewk_view_input_method_state_set(Evas_Object* ewkView, bool active)
     priv->imh = 0;
     if (focusedFrame
         && focusedFrame->document()
-        && focusedFrame->document()->focusedNode()
-        && focusedFrame->document()->focusedNode()->hasTagName(WebCore::HTMLNames::inputTag)) {
+        && focusedFrame->document()->focusedElement()
+        && focusedFrame->document()->focusedElement()->hasTagName(WebCore::HTMLNames::inputTag)) {
         WebCore::HTMLInputElement* inputElement;
 
-        inputElement = static_cast<WebCore::HTMLInputElement*>(focusedFrame->document()->focusedNode());
+        inputElement = static_cast<WebCore::HTMLInputElement*>(focusedFrame->document()->focusedElement());
         if (inputElement) {
             // for password fields, active == false
             if (!active) {
index 6955a3c..98b2356 100644 (file)
@@ -1,3 +1,13 @@
+2013-05-28  Andreas Kling  <akling@apple.com>
+
+        Document::setFocusedNode() should be setFocusedElement().
+        <http://webkit.org/b/116857>
+
+        Reviewed by Antti Koivisto.
+
+        * webkit/webkitwebview.cpp:
+        (getFocusedNode):
+
 2013-05-24  Christophe Dumez  <ch.dumez@sisa.samsung.com>
 
         Remove custom code for webkitAudioContext global constructor getter
index fed8919..ec50a7b 100644 (file)
@@ -303,7 +303,7 @@ static void PopupMenuPositionFunc(GtkMenu* menu, gint *x, gint *y, gboolean *pus
 static Node* getFocusedNode(Frame* frame)
 {
     if (Document* doc = frame->document())
-        return doc->focusedNode();
+        return doc->focusedElement();
     return 0;
 }
 
index 0e2bc2d..81799cb 100644 (file)
@@ -1,3 +1,14 @@
+2013-05-28  Andreas Kling  <akling@apple.com>
+
+        Document::setFocusedNode() should be setFocusedElement().
+        <http://webkit.org/b/116857>
+
+        Reviewed by Antti Koivisto.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView clearFocus]):
+        (-[WebHTMLView becomeFirstResponder]):
+
 2013-05-25  Andreas Kling  <akling@apple.com>
 
         Remove Document::getFocusableNodes().
index 5848b9d..6a7f633 100644 (file)
@@ -3144,7 +3144,7 @@ static void setMenuTargets(NSMenu* menu)
     if (!document)
         return;
     
-    document->setFocusedNode(0);
+    document->setFocusedElement(0);
 }
 
 - (BOOL)isOpaque
@@ -3817,7 +3817,7 @@ static PassRefPtr<KeyboardEvent> currentKeyboardEvent(Frame* coreFrame)
         return YES;
 
     if (Document* document = frame->document())
-        document->setFocusedNode(0);
+        document->setFocusedElement(0);
     page->focusController()->setInitialFocus(direction == NSSelectingNext ? FocusDirectionForward : FocusDirectionBackward,
                                              currentKeyboardEvent(frame).get());
     return YES;
index d9a8992..ec53eff 100644 (file)
@@ -521,7 +521,7 @@ bool QWebElement::hasFocus() const
     if (!m_element)
         return false;
     if (m_element->document())
-        return m_element == m_element->document()->focusedNode();
+        return m_element == m_element->document()->focusedElement();
     return false;
 }
 
@@ -535,7 +535,7 @@ void QWebElement::setFocus()
     if (!m_element)
         return;
     if (m_element->document() && m_element->isFocusable())
-        m_element->document()->setFocusedNode(m_element);
+        m_element->document()->setFocusedElement(m_element);
 }
 
 /*!
index 14684f4..18a5c36 100644 (file)
@@ -1,3 +1,21 @@
+2013-05-28  Andreas Kling  <akling@apple.com>
+
+        Document::setFocusedNode() should be setFocusedElement().
+        <http://webkit.org/b/116857>
+
+        Reviewed by Antti Koivisto.
+
+        * Api/qwebelement.cpp:
+        (QWebElement::hasFocus):
+        (QWebElement::setFocus):
+        * WebCoreSupport/EditorClientQt.cpp:
+        (WebCore::EditorClientQt::setInputMethodState):
+        * WebCoreSupport/QWebPageAdapter.cpp:
+        (QWebPageAdapter::mousePressEvent):
+        (QWebPageAdapter::handleSoftwareInputPanel):
+        (QWebPageAdapter::inputMethodQuery):
+        (QWebPageAdapter::hasFocusedNode):
+
 2013-05-27  Jocelyn Turcotte  <jocelyn.turcotte@digia.com>
 
         [Qt][Win] Input events aren't mapped properly with windowless plugins.
index 825aca3..05b74a1 100644 (file)
@@ -618,9 +618,9 @@ void EditorClientQt::setInputMethodState(bool active)
 
         HTMLInputElement* inputElement = 0;
         Frame* frame = m_page->page->focusController()->focusedOrMainFrame();
-        if (frame && frame->document() && frame->document()->focusedNode())
-            if (frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag))
-                inputElement = static_cast<HTMLInputElement*>(frame->document()->focusedNode());
+        if (frame && frame->document() && frame->document()->focusedElement())
+            if (frame->document()->focusedElement()->hasTagName(HTMLNames::inputTag))
+                inputElement = static_cast<HTMLInputElement*>(frame->document()->focusedElement());
 
         if (inputElement) {
             // Set input method hints for "number", "tel", "email", "url" and "password" input elements.
index 5b254d3..89eff61 100644 (file)
@@ -433,7 +433,7 @@ void QWebPageAdapter::mousePressEvent(QMouseEvent* ev)
     RefPtr<WebCore::Node> oldNode;
     Frame* focusedFrame = page->focusController()->focusedFrame();
     if (Document* focusedDocument = focusedFrame ? focusedFrame->document() : 0)
-        oldNode = focusedDocument->focusedNode();
+        oldNode = focusedDocument->focusedElement();
 
     if (tripleClickTimer.isActive()
         && (ev->pos() - tripleClick).manhattanLength() < qGuiApp->styleHints()->startDragDistance()) {
@@ -451,7 +451,7 @@ void QWebPageAdapter::mousePressEvent(QMouseEvent* ev)
     RefPtr<WebCore::Node> newNode;
     focusedFrame = page->focusController()->focusedFrame();
     if (Document* focusedDocument = focusedFrame ? focusedFrame->document() : 0)
-        newNode = focusedDocument->focusedNode();
+        newNode = focusedDocument->focusedElement();
 
     if (newNode && oldNode != newNode)
         clickCausedFocus = true;
@@ -511,7 +511,7 @@ void QWebPageAdapter::handleSoftwareInputPanel(Qt::MouseButton button, const QPo
         return;
 
     if (client && client->inputMethodEnabled()
-        && frame->document()->focusedNode()
+        && frame->document()->focusedElement()
             && button == Qt::LeftButton && qGuiApp->property("autoSipEnabled").toBool()) {
         if (!clickCausedFocus || requestSoftwareInputPanel()) {
             HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(frame->view()->windowToContents(pos));
@@ -709,9 +709,9 @@ QVariant QWebPageAdapter::inputMethodQuery(Qt::InputMethodQuery property) const
     }
     case Qt::ImMaximumTextLength: {
         if (frame->selection()->isContentEditable()) {
-            if (frame->document() && frame->document()->focusedNode()) {
-                if (frame->document()->focusedNode()->hasTagName(HTMLNames::inputTag)) {
-                    HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(frame->document()->focusedNode());
+            if (frame->document() && frame->document()->focusedElement()) {
+                if (frame->document()->focusedElement()->hasTagName(HTMLNames::inputTag)) {
+                    HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(frame->document()->focusedElement());
                     return QVariant(inputElement->maxLength());
                 }
             }
@@ -1209,7 +1209,7 @@ bool QWebPageAdapter::hasFocusedNode() const
     Frame* frame = page->focusController()->focusedFrame();
     if (frame) {
         Document* document = frame->document();
-        hasFocus = document && document->focusedNode();
+        hasFocus = document && document->focusedElement();
     }
     return hasFocus;
 }
index 653928c..320d86e 100644 (file)
@@ -1,3 +1,15 @@
+2013-05-28  Andreas Kling  <akling@apple.com>
+
+        Document::setFocusedNode() should be setFocusedElement().
+        <http://webkit.org/b/116857>
+
+        Reviewed by Antti Koivisto.
+
+        * DOMCoreClasses.cpp:
+        (DOMElement::isFocused):
+        * WebView.cpp:
+        (WebView::setInitialFocus):
+
 2013-05-27  Xueqing Huang  <huangxueqing@baidu.com>
 
         Move Windows port off legacy clipboard.
index d39601d..e4f500a 100644 (file)
@@ -1216,7 +1216,7 @@ HRESULT STDMETHODCALLTYPE DOMElement::isFocused(
     if (!m_element)
         return E_FAIL;
 
-    if (m_element->document()->focusedNode() == m_element)
+    if (m_element->document()->focusedElement() == m_element)
         *result = TRUE;
     else
         *result = FALSE;
index b68a81e..34d090a 100644 (file)
@@ -5283,7 +5283,7 @@ HRESULT STDMETHODCALLTYPE WebView::setInitialFocus(
 {
     if (m_page && m_page->focusController()) {
         Frame* frame = m_page->focusController()->focusedOrMainFrame();
-        frame->document()->setFocusedNode(0);
+        frame->document()->setFocusedElement(0);
         m_page->focusController()->setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, 0);
     }
     return S_OK;
index 48415f5..33c8e1c 100644 (file)
@@ -1,3 +1,16 @@
+2013-05-28  Andreas Kling  <akling@apple.com>
+
+        Document::setFocusedNode() should be setFocusedElement().
+        <http://webkit.org/b/116857>
+
+        Reviewed by Antti Koivisto.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::focusPluginElement):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::focusedPluginViewForFrame):
+        (WebKit::WebPage::setInitialFocus):
+
 2013-05-28  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         [EFL][WK2] Clean up duplicated include files.
index d4fe090..ec791f6 100644 (file)
@@ -1041,7 +1041,7 @@ void PluginView::focusPluginElement()
     if (Page* page = frame()->page())
         page->focusController()->setFocusedElement(m_pluginElement.get(), frame());
     else
-       frame()->document()->setFocusedNode(m_pluginElement);
+        frame()->document()->setFocusedElement(m_pluginElement);
 }
 
 void PluginView::pendingURLRequestsTimerFired()
index 4d97cd9..76d64c3 100644 (file)
@@ -744,7 +744,7 @@ PluginView* WebPage::focusedPluginViewForFrame(Frame* frame)
 
     PluginDocument* pluginDocument = static_cast<PluginDocument*>(frame->document());
 
-    if (pluginDocument->focusedNode() != pluginDocument->pluginElement())
+    if (pluginDocument->focusedElement() != pluginDocument->pluginElement())
         return 0;
 
     PluginView* pluginView = static_cast<PluginView*>(pluginDocument->pluginWidget());
@@ -2048,7 +2048,7 @@ void WebPage::setInitialFocus(bool forward, bool isKeyboardEventValid, const Web
         return;
 
     Frame* frame = m_page->focusController()->focusedOrMainFrame();
-    frame->document()->setFocusedNode(0);
+    frame->document()->setFocusedElement(0);
 
     if (isKeyboardEventValid && event.type() == WebEvent::KeyDown) {
         PlatformKeyboardEvent platformEvent(platform(event));