Diff
Modified: trunk/Source/WebCore/ChangeLog (150691 => 150692)
--- trunk/Source/WebCore/ChangeLog 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/ChangeLog 2013-05-25 23:09:29 UTC (rev 150692)
@@ -1,5 +1,51 @@
2013-05-25 Andreas Kling <akl...@apple.com>
+ Move Node::isMouseFocusable() to Element.
+ <http://webkit.org/b/116762>
+
+ Reviewed by Anders Carlsson.
+
+ Node::isMouseFocusable() would just return isFocusable(), which is never true for a non-Element
+ since Node::supportsFocus() always returns false. So move it to Element!
+
+ * dom/Node.h:
+ * dom/Node.cpp:
+ * dom/Element.h:
+ * dom/Element.cpp:
+ (WebCore::Element::isMouseFocusable):
+
+ Moved here from Node.
+
+ * editing/FrameSelection.cpp:
+ (WebCore::FrameSelection::setFocusedNodeIfNeeded):
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::dispatchMouseEvent):
+
+ Walk up the parent chain with parentOrShadowHostElement() instead of parentOrShadowHostNode().
+ Removed a misleading no-op hunk about mouse-focusable ShadowRoots, since ShadowRoots are not
+ Elements and thus cannot be mouse-focusable.
+
+ * page/TouchAdjustment.cpp:
+ (WebCore::TouchAdjustment::nodeRespondsToTapGesture):
+
+ Check that the Node is an Element before asking if it's mouse-focusable.
+
+ * html/HTMLAnchorElement.h:
+ * html/HTMLAreaElement.h:
+ * html/HTMLFormControlElement.h:
+ * html/HTMLInputElement.h:
+ * html/HTMLMediaElement.h:
+ * html/HTMLSelectElement.h:
+ * html/HTMLTextAreaElement.h:
+ * html/shadow/ClearButtonElement.h:
+ * html/shadow/TextControlInnerElements.h:
+ * svg/SVGAElement.h:
+ * svg/SVGStyledElement.h:
+
+ Sprinkle OVERRIDE.
+
+2013-05-25 Andreas Kling <akl...@apple.com>
+
Move Node::isKeyboardFocusable() to Element.
<http://webkit.org/b/116761>
Modified: trunk/Source/WebCore/dom/Element.cpp (150691 => 150692)
--- trunk/Source/WebCore/dom/Element.cpp 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/dom/Element.cpp 2013-05-25 23:09:29 UTC (rev 150692)
@@ -254,6 +254,11 @@
return isFocusable() && tabIndex() >= 0;
}
+bool Element::isMouseFocusable() const
+{
+ return isFocusable();
+}
+
DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, blur);
DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, error);
DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, focus);
Modified: trunk/Source/WebCore/dom/Element.h (150691 => 150692)
--- trunk/Source/WebCore/dom/Element.h 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/dom/Element.h 2013-05-25 23:09:29 UTC (rev 150692)
@@ -433,6 +433,7 @@
virtual void setFocus(bool flag);
virtual bool isKeyboardFocusable(KeyboardEvent*) const;
+ virtual bool isMouseFocusable() const;
RenderStyle* computedStyle(PseudoId = NOPSEUDO);
Modified: trunk/Source/WebCore/dom/Node.cpp (150691 => 150692)
--- trunk/Source/WebCore/dom/Node.cpp 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/dom/Node.cpp 2013-05-25 23:09:29 UTC (rev 150692)
@@ -885,11 +885,6 @@
return true;
}
-bool Node::isMouseFocusable() const
-{
- return isFocusable();
-}
-
Node* Node::focusDelegate()
{
return this;
Modified: trunk/Source/WebCore/dom/Node.h (150691 => 150692)
--- trunk/Source/WebCore/dom/Node.h 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/dom/Node.h 2013-05-25 23:09:29 UTC (rev 150692)
@@ -406,7 +406,6 @@
virtual bool supportsFocus() const;
// Whether the node can actually be focused.
virtual bool isFocusable() const;
- virtual bool isMouseFocusable() const;
virtual Node* focusDelegate();
enum UserSelectAllTreatment {
Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (150691 => 150692)
--- trunk/Source/WebCore/editing/FrameSelection.cpp 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp 2013-05-25 23:09:29 UTC (rev 150692)
@@ -1889,8 +1889,8 @@
}
}
- if (Node* target = rootEditableElement()) {
- // Walk up the DOM tree to search for a node to focus.
+ if (Element* target = rootEditableElement()) {
+ // Walk up the DOM tree to search for an element to focus.
while (target) {
// We don't want to set focus on a subframe when selecting in a parent frame,
// so add the !isFrameElement check here. There's probably a better way to make this
@@ -1899,7 +1899,7 @@
m_frame->page()->focusController()->setFocusedNode(target, m_frame);
return;
}
- target = target->parentOrShadowHostNode();
+ target = target->parentOrShadowHostElement();
}
m_frame->document()->setFocusedNode(0);
}
Modified: trunk/Source/WebCore/html/HTMLAnchorElement.h (150691 => 150692)
--- trunk/Source/WebCore/html/HTMLAnchorElement.h 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.h 2013-05-25 23:09:29 UTC (rev 150692)
@@ -109,7 +109,7 @@
private:
virtual bool supportsFocus() const;
- virtual bool isMouseFocusable() const;
+ virtual bool isMouseFocusable() const OVERRIDE;
virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
virtual void defaultEventHandler(Event*);
virtual void setActive(bool active = true, bool pause = false);
Modified: trunk/Source/WebCore/html/HTMLAreaElement.h (150691 => 150692)
--- trunk/Source/WebCore/html/HTMLAreaElement.h 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/html/HTMLAreaElement.h 2013-05-25 23:09:29 UTC (rev 150692)
@@ -54,7 +54,7 @@
virtual bool supportsFocus() const;
virtual String target() const;
virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
- virtual bool isMouseFocusable() const;
+ virtual bool isMouseFocusable() const OVERRIDE;
virtual bool isFocusable() const;
virtual void updateFocusAppearance(bool /*restorePreviousSelection*/);
virtual void setFocus(bool) OVERRIDE;
Modified: trunk/Source/WebCore/html/HTMLFormControlElement.h (150691 => 150692)
--- trunk/Source/WebCore/html/HTMLFormControlElement.h 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.h 2013-05-25 23:09:29 UTC (rev 150692)
@@ -117,7 +117,7 @@
virtual bool supportsFocus() const;
virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
- virtual bool isMouseFocusable() const;
+ virtual bool isMouseFocusable() const OVERRIDE;
virtual void didRecalcStyle(StyleChange) OVERRIDE;
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (150691 => 150692)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2013-05-25 23:09:29 UTC (rev 150692)
@@ -324,7 +324,7 @@
virtual bool hasCustomFocusLogic() const OVERRIDE;
virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
- virtual bool isMouseFocusable() const;
+ virtual bool isMouseFocusable() const OVERRIDE;
virtual bool isEnumeratable() const;
virtual bool supportLabels() const OVERRIDE;
virtual void updateFocusAppearance(bool restorePreviousSelection);
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (150691 => 150692)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2013-05-25 23:09:29 UTC (rev 150692)
@@ -431,7 +431,7 @@
virtual bool hasCustomFocusLogic() const OVERRIDE;
virtual bool supportsFocus() const;
- virtual bool isMouseFocusable() const;
+ virtual bool isMouseFocusable() const OVERRIDE;
virtual bool rendererIsNeeded(const NodeRenderingContext&);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OVERRIDE;
Modified: trunk/Source/WebCore/html/HTMLSelectElement.h (150691 => 150692)
--- trunk/Source/WebCore/html/HTMLSelectElement.h 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/html/HTMLSelectElement.h 2013-05-25 23:09:29 UTC (rev 150692)
@@ -112,7 +112,7 @@
virtual const AtomicString& formControlType() const;
virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
- virtual bool isMouseFocusable() const;
+ virtual bool isMouseFocusable() const OVERRIDE;
virtual void dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode, FocusDirection) OVERRIDE;
virtual void dispatchBlurEvent(PassRefPtr<Node> newFocusedNode);
Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.h (150691 => 150692)
--- trunk/Source/WebCore/html/HTMLTextAreaElement.h 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.h 2013-05-25 23:09:29 UTC (rev 150692)
@@ -104,7 +104,7 @@
virtual bool appendFormData(FormDataList&, bool);
virtual void reset();
virtual bool hasCustomFocusLogic() const OVERRIDE;
- virtual bool isMouseFocusable() const;
+ virtual bool isMouseFocusable() const OVERRIDE;
virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
virtual void updateFocusAppearance(bool restorePreviousSelection);
Modified: trunk/Source/WebCore/html/shadow/ClearButtonElement.h (150691 => 150692)
--- trunk/Source/WebCore/html/shadow/ClearButtonElement.h 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/html/shadow/ClearButtonElement.h 2013-05-25 23:09:29 UTC (rev 150692)
@@ -48,7 +48,7 @@
private:
ClearButtonElement(Document*, ClearButtonOwner&);
virtual void detach();
- virtual bool isMouseFocusable() const { return false; }
+ virtual bool isMouseFocusable() const OVERRIDE { return false; }
virtual void defaultEventHandler(Event*);
ClearButtonOwner* m_clearButtonOwner;
Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.h (150691 => 150692)
--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.h 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.h 2013-05-25 23:09:29 UTC (rev 150692)
@@ -52,7 +52,7 @@
virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
private:
- virtual bool isMouseFocusable() const { return false; }
+ virtual bool isMouseFocusable() const OVERRIDE { return false; }
};
class TextControlInnerTextElement FINAL : public HTMLDivElement {
@@ -65,7 +65,7 @@
TextControlInnerTextElement(Document*);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
- virtual bool isMouseFocusable() const { return false; }
+ virtual bool isMouseFocusable() const OVERRIDE { return false; }
};
class SearchFieldResultsButtonElement FINAL : public HTMLDivElement {
@@ -78,7 +78,7 @@
private:
SearchFieldResultsButtonElement(Document*);
virtual const AtomicString& shadowPseudoId() const;
- virtual bool isMouseFocusable() const { return false; }
+ virtual bool isMouseFocusable() const OVERRIDE { return false; }
};
class SearchFieldCancelButtonElement FINAL : public HTMLDivElement {
@@ -92,7 +92,7 @@
SearchFieldCancelButtonElement(Document*);
virtual const AtomicString& shadowPseudoId() const;
virtual void detach();
- virtual bool isMouseFocusable() const { return false; }
+ virtual bool isMouseFocusable() const OVERRIDE { return false; }
bool m_capturing;
};
@@ -130,7 +130,7 @@
SpeechInput* speechInput();
void setState(SpeechInputState state);
virtual const AtomicString& shadowPseudoId() const;
- virtual bool isMouseFocusable() const { return false; }
+ virtual bool isMouseFocusable() const OVERRIDE { return false; }
virtual void attach();
bool m_capturing;
Modified: trunk/Source/WebCore/page/EventHandler.cpp (150691 => 150692)
--- trunk/Source/WebCore/page/EventHandler.cpp 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2013-05-25 23:09:29 UTC (rev 150692)
@@ -2330,37 +2330,41 @@
// Blur current focus node when a link/button is clicked; this
// is expected by some sites that rely on onChange handlers running
// from form fields before the button click is processed.
- Node* node = m_nodeUnderMouse.get();
- // Walk up the DOM tree to search for a node to focus.
- while (node) {
- if (node->isMouseFocusable()) {
+ Element* element;
+ if (m_nodeUnderMouse)
+ element = m_nodeUnderMouse->isElementNode() ? toElement(m_nodeUnderMouse.get()) : m_nodeUnderMouse->parentOrShadowHostElement();
+ else
+ element = 0;
+
+ // Walk up the DOM tree to search for an element to focus.
+ while (element) {
+ if (element->isMouseFocusable()) {
// To fix <rdar://problem/4895428> Can't drag selected ToDo, we don't focus a
// node on mouse down if it's selected and inside a focused node. It will be
// focused if the user does a mouseup over it, however, because the mouseup
// will set a selection inside it, which will call setFocuseNodeIfNeeded.
- Node* n = node->isShadowRoot() ? toShadowRoot(node)->host() : node;
if (m_frame->selection()->isRange()
- && m_frame->selection()->toNormalizedRange()->compareNode(n, IGNORE_EXCEPTION) == Range::NODE_INSIDE
- && n->isDescendantOf(m_frame->document()->focusedNode()))
+ && m_frame->selection()->toNormalizedRange()->compareNode(element, IGNORE_EXCEPTION) == Range::NODE_INSIDE
+ && element->isDescendantOf(m_frame->document()->focusedNode()))
return true;
break;
}
- node = node->parentOrShadowHostNode();
+ element = element->parentOrShadowHostElement();
}
// Only change the focus when clicking scrollbars if it can transfered to a mouse focusable node.
- if ((!node || !node->isMouseFocusable()) && isInsideScrollbar(mouseEvent.position()))
+ if ((!element || !element->isMouseFocusable()) && isInsideScrollbar(mouseEvent.position()))
return false;
// If focus shift is blocked, we eat the event. Note we should never clear swallowEvent
// if the page already set it (e.g., by canceling default behavior).
if (Page* page = m_frame->page()) {
- if (node && node->isMouseFocusable()) {
- if (!page->focusController()->setFocusedNode(node, m_frame))
+ if (element && element->isMouseFocusable()) {
+ if (!page->focusController()->setFocusedNode(element, m_frame))
swallowEvent = true;
- } else if (!node || !node->isElementNode() || !toElement(node)->focused()) {
+ } else if (!element || !element->focused()) {
if (!page->focusController()->setFocusedNode(0, m_frame))
swallowEvent = true;
}
Modified: trunk/Source/WebCore/page/TouchAdjustment.cpp (150691 => 150692)
--- trunk/Source/WebCore/page/TouchAdjustment.cpp 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/page/TouchAdjustment.cpp 2013-05-25 23:09:29 UTC (rev 150692)
@@ -73,13 +73,13 @@
// Takes non-const Node* because isContentEditable is a non-const function.
bool nodeRespondsToTapGesture(Node* node)
{
- if (node->isMouseFocusable())
- return true;
if (node->willRespondToMouseClickEvents() || node->willRespondToMouseMoveEvents())
return true;
// Accept nodes that has a CSS effect when touched.
if (node->isElementNode()) {
Element* element = toElement(node);
+ if (element->isMouseFocusable())
+ return true;
if (element->childrenAffectedByActive() || element->childrenAffectedByHover())
return true;
}
Modified: trunk/Source/WebCore/svg/SVGAElement.h (150691 => 150692)
--- trunk/Source/WebCore/svg/SVGAElement.h 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/svg/SVGAElement.h 2013-05-25 23:09:29 UTC (rev 150692)
@@ -57,7 +57,7 @@
virtual void defaultEventHandler(Event*);
virtual bool supportsFocus() const;
- virtual bool isMouseFocusable() const;
+ virtual bool isMouseFocusable() const OVERRIDE;
virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
virtual bool isFocusable() const;
virtual bool isURLAttribute(const Attribute&) const;
Modified: trunk/Source/WebCore/svg/SVGStyledElement.h (150691 => 150692)
--- trunk/Source/WebCore/svg/SVGStyledElement.h 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebCore/svg/SVGStyledElement.h 2013-05-25 23:09:29 UTC (rev 150692)
@@ -81,7 +81,7 @@
virtual bool isSVGStyledElement() const OVERRIDE FINAL { return true; }
virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE;
- virtual bool isMouseFocusable() const;
+ virtual bool isMouseFocusable() const OVERRIDE;
void buildPendingResourcesIfNeeded();
Modified: trunk/Source/WebKit2/ChangeLog (150691 => 150692)
--- trunk/Source/WebKit2/ChangeLog 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebKit2/ChangeLog 2013-05-25 23:09:29 UTC (rev 150692)
@@ -1,5 +1,17 @@
2013-05-25 Andreas Kling <akl...@apple.com>
+ Move Node::isMouseFocusable() to Element.
+ <http://webkit.org/b/116762>
+
+ Reviewed by Anders Carlsson.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::highlightPotentialActivation):
+
+ Check that the potentially activated Node is an Element before asking if it's mouse-focusable.
+
+2013-05-25 Andreas Kling <akl...@apple.com>
+
REGRESSION: WebProcess is terminated when all Safari windows are closed.
<rdar://problem/13990901>
<http://webkit.org/b/116766>
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (150691 => 150692)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2013-05-25 21:34:26 UTC (rev 150691)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2013-05-25 23:09:29 UTC (rev 150692)
@@ -1883,7 +1883,7 @@
break;
// We always highlight focusable (form-elements), image links or content-editable elements.
- if (node->isMouseFocusable() || node->isLink() || node->isContentEditable())
+ if ((node->isElementNode() && toElement(node)->isMouseFocusable()) || node->isLink() || node->isContentEditable())
activationNode = node;
else if (node->willRespondToMouseClickEvents()) {
// Highlight elements with default mouse-click handlers, but highlight only inline elements with