Changeset 150692 in webkit
- Timestamp:
- May 25, 2013 4:09:29 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r150687 r150692 1 2013-05-25 Andreas Kling <akling@apple.com> 2 3 Move Node::isMouseFocusable() to Element. 4 <http://webkit.org/b/116762> 5 6 Reviewed by Anders Carlsson. 7 8 Node::isMouseFocusable() would just return isFocusable(), which is never true for a non-Element 9 since Node::supportsFocus() always returns false. So move it to Element! 10 11 * dom/Node.h: 12 * dom/Node.cpp: 13 * dom/Element.h: 14 * dom/Element.cpp: 15 (WebCore::Element::isMouseFocusable): 16 17 Moved here from Node. 18 19 * editing/FrameSelection.cpp: 20 (WebCore::FrameSelection::setFocusedNodeIfNeeded): 21 * page/EventHandler.cpp: 22 (WebCore::EventHandler::dispatchMouseEvent): 23 24 Walk up the parent chain with parentOrShadowHostElement() instead of parentOrShadowHostNode(). 25 Removed a misleading no-op hunk about mouse-focusable ShadowRoots, since ShadowRoots are not 26 Elements and thus cannot be mouse-focusable. 27 28 * page/TouchAdjustment.cpp: 29 (WebCore::TouchAdjustment::nodeRespondsToTapGesture): 30 31 Check that the Node is an Element before asking if it's mouse-focusable. 32 33 * html/HTMLAnchorElement.h: 34 * html/HTMLAreaElement.h: 35 * html/HTMLFormControlElement.h: 36 * html/HTMLInputElement.h: 37 * html/HTMLMediaElement.h: 38 * html/HTMLSelectElement.h: 39 * html/HTMLTextAreaElement.h: 40 * html/shadow/ClearButtonElement.h: 41 * html/shadow/TextControlInnerElements.h: 42 * svg/SVGAElement.h: 43 * svg/SVGStyledElement.h: 44 45 Sprinkle OVERRIDE. 46 1 47 2013-05-25 Andreas Kling <akling@apple.com> 2 48 -
trunk/Source/WebCore/dom/Element.cpp
r150687 r150692 255 255 } 256 256 257 bool Element::isMouseFocusable() const 258 { 259 return isFocusable(); 260 } 261 257 262 DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, blur); 258 263 DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, error); -
trunk/Source/WebCore/dom/Element.h
r150687 r150692 434 434 435 435 virtual bool isKeyboardFocusable(KeyboardEvent*) const; 436 virtual bool isMouseFocusable() const; 436 437 437 438 RenderStyle* computedStyle(PseudoId = NOPSEUDO); -
trunk/Source/WebCore/dom/Node.cpp
r150687 r150692 886 886 } 887 887 888 bool Node::isMouseFocusable() const889 {890 return isFocusable();891 }892 893 888 Node* Node::focusDelegate() 894 889 { -
trunk/Source/WebCore/dom/Node.h
r150687 r150692 407 407 // Whether the node can actually be focused. 408 408 virtual bool isFocusable() const; 409 virtual bool isMouseFocusable() const;410 409 virtual Node* focusDelegate(); 411 410 -
trunk/Source/WebCore/editing/FrameSelection.cpp
r150482 r150692 1890 1890 } 1891 1891 1892 if ( Node* target = rootEditableElement()) {1893 // Walk up the DOM tree to search for a node to focus.1892 if (Element* target = rootEditableElement()) { 1893 // Walk up the DOM tree to search for an element to focus. 1894 1894 while (target) { 1895 1895 // We don't want to set focus on a subframe when selecting in a parent frame, … … 1900 1900 return; 1901 1901 } 1902 target = target->parentOrShadowHost Node();1902 target = target->parentOrShadowHostElement(); 1903 1903 } 1904 1904 m_frame->document()->setFocusedNode(0); -
trunk/Source/WebCore/html/HTMLAnchorElement.h
r150687 r150692 110 110 private: 111 111 virtual bool supportsFocus() const; 112 virtual bool isMouseFocusable() const ;112 virtual bool isMouseFocusable() const OVERRIDE; 113 113 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 114 114 virtual void defaultEventHandler(Event*); -
trunk/Source/WebCore/html/HTMLAreaElement.h
r150687 r150692 55 55 virtual String target() const; 56 56 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 57 virtual bool isMouseFocusable() const ;57 virtual bool isMouseFocusable() const OVERRIDE; 58 58 virtual bool isFocusable() const; 59 59 virtual void updateFocusAppearance(bool /*restorePreviousSelection*/); -
trunk/Source/WebCore/html/HTMLFormControlElement.h
r150687 r150692 118 118 virtual bool supportsFocus() const; 119 119 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 120 virtual bool isMouseFocusable() const ;120 virtual bool isMouseFocusable() const OVERRIDE; 121 121 122 122 virtual void didRecalcStyle(StyleChange) OVERRIDE; -
trunk/Source/WebCore/html/HTMLInputElement.h
r150687 r150692 325 325 virtual bool hasCustomFocusLogic() const OVERRIDE; 326 326 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 327 virtual bool isMouseFocusable() const ;327 virtual bool isMouseFocusable() const OVERRIDE; 328 328 virtual bool isEnumeratable() const; 329 329 virtual bool supportLabels() const OVERRIDE; -
trunk/Source/WebCore/html/HTMLMediaElement.h
r150651 r150692 432 432 virtual bool hasCustomFocusLogic() const OVERRIDE; 433 433 virtual bool supportsFocus() const; 434 virtual bool isMouseFocusable() const ;434 virtual bool isMouseFocusable() const OVERRIDE; 435 435 virtual bool rendererIsNeeded(const NodeRenderingContext&); 436 436 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); -
trunk/Source/WebCore/html/HTMLSelectElement.h
r150687 r150692 113 113 114 114 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 115 virtual bool isMouseFocusable() const ;115 virtual bool isMouseFocusable() const OVERRIDE; 116 116 117 117 virtual void dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode, FocusDirection) OVERRIDE; -
trunk/Source/WebCore/html/HTMLTextAreaElement.h
r150687 r150692 105 105 virtual void reset(); 106 106 virtual bool hasCustomFocusLogic() const OVERRIDE; 107 virtual bool isMouseFocusable() const ;107 virtual bool isMouseFocusable() const OVERRIDE; 108 108 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 109 109 virtual void updateFocusAppearance(bool restorePreviousSelection); -
trunk/Source/WebCore/html/shadow/ClearButtonElement.h
r149960 r150692 49 49 ClearButtonElement(Document*, ClearButtonOwner&); 50 50 virtual void detach(); 51 virtual bool isMouseFocusable() const { return false; }51 virtual bool isMouseFocusable() const OVERRIDE { return false; } 52 52 virtual void defaultEventHandler(Event*); 53 53 -
trunk/Source/WebCore/html/shadow/TextControlInnerElements.h
r149960 r150692 53 53 54 54 private: 55 virtual bool isMouseFocusable() const { return false; }55 virtual bool isMouseFocusable() const OVERRIDE { return false; } 56 56 }; 57 57 … … 66 66 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 67 67 virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE; 68 virtual bool isMouseFocusable() const { return false; }68 virtual bool isMouseFocusable() const OVERRIDE { return false; } 69 69 }; 70 70 … … 79 79 SearchFieldResultsButtonElement(Document*); 80 80 virtual const AtomicString& shadowPseudoId() const; 81 virtual bool isMouseFocusable() const { return false; }81 virtual bool isMouseFocusable() const OVERRIDE { return false; } 82 82 }; 83 83 … … 93 93 virtual const AtomicString& shadowPseudoId() const; 94 94 virtual void detach(); 95 virtual bool isMouseFocusable() const { return false; }95 virtual bool isMouseFocusable() const OVERRIDE { return false; } 96 96 97 97 bool m_capturing; … … 131 131 void setState(SpeechInputState state); 132 132 virtual const AtomicString& shadowPseudoId() const; 133 virtual bool isMouseFocusable() const { return false; }133 virtual bool isMouseFocusable() const OVERRIDE { return false; } 134 134 virtual void attach(); 135 135 -
trunk/Source/WebCore/page/EventHandler.cpp
r150686 r150692 2331 2331 // is expected by some sites that rely on onChange handlers running 2332 2332 // from form fields before the button click is processed. 2333 Node* node = m_nodeUnderMouse.get(); 2334 2335 // Walk up the DOM tree to search for a node to focus. 2336 while (node) { 2337 if (node->isMouseFocusable()) { 2333 2334 Element* element; 2335 if (m_nodeUnderMouse) 2336 element = m_nodeUnderMouse->isElementNode() ? toElement(m_nodeUnderMouse.get()) : m_nodeUnderMouse->parentOrShadowHostElement(); 2337 else 2338 element = 0; 2339 2340 // Walk up the DOM tree to search for an element to focus. 2341 while (element) { 2342 if (element->isMouseFocusable()) { 2338 2343 // To fix <rdar://problem/4895428> Can't drag selected ToDo, we don't focus a 2339 2344 // node on mouse down if it's selected and inside a focused node. It will be 2340 2345 // focused if the user does a mouseup over it, however, because the mouseup 2341 2346 // will set a selection inside it, which will call setFocuseNodeIfNeeded. 2342 Node* n = node->isShadowRoot() ? toShadowRoot(node)->host() : node;2343 2347 if (m_frame->selection()->isRange() 2344 && m_frame->selection()->toNormalizedRange()->compareNode( n, IGNORE_EXCEPTION) == Range::NODE_INSIDE2345 && n->isDescendantOf(m_frame->document()->focusedNode()))2348 && m_frame->selection()->toNormalizedRange()->compareNode(element, IGNORE_EXCEPTION) == Range::NODE_INSIDE 2349 && element->isDescendantOf(m_frame->document()->focusedNode())) 2346 2350 return true; 2347 2351 2348 2352 break; 2349 2353 } 2350 node = node->parentOrShadowHostNode();2354 element = element->parentOrShadowHostElement(); 2351 2355 } 2352 2356 2353 2357 // Only change the focus when clicking scrollbars if it can transfered to a mouse focusable node. 2354 if ((! node || !node->isMouseFocusable()) && isInsideScrollbar(mouseEvent.position()))2358 if ((!element || !element->isMouseFocusable()) && isInsideScrollbar(mouseEvent.position())) 2355 2359 return false; 2356 2360 … … 2358 2362 // if the page already set it (e.g., by canceling default behavior). 2359 2363 if (Page* page = m_frame->page()) { 2360 if ( node && node->isMouseFocusable()) {2361 if (!page->focusController()->setFocusedNode( node, m_frame))2364 if (element && element->isMouseFocusable()) { 2365 if (!page->focusController()->setFocusedNode(element, m_frame)) 2362 2366 swallowEvent = true; 2363 } else if (! node || !node->isElementNode() || !toElement(node)->focused()) {2367 } else if (!element || !element->focused()) { 2364 2368 if (!page->focusController()->setFocusedNode(0, m_frame)) 2365 2369 swallowEvent = true; -
trunk/Source/WebCore/page/TouchAdjustment.cpp
r150140 r150692 74 74 bool nodeRespondsToTapGesture(Node* node) 75 75 { 76 if (node->isMouseFocusable())77 return true;78 76 if (node->willRespondToMouseClickEvents() || node->willRespondToMouseMoveEvents()) 79 77 return true; … … 81 79 if (node->isElementNode()) { 82 80 Element* element = toElement(node); 81 if (element->isMouseFocusable()) 82 return true; 83 83 if (element->childrenAffectedByActive() || element->childrenAffectedByHover()) 84 84 return true; -
trunk/Source/WebCore/svg/SVGAElement.h
r150687 r150692 58 58 59 59 virtual bool supportsFocus() const; 60 virtual bool isMouseFocusable() const ;60 virtual bool isMouseFocusable() const OVERRIDE; 61 61 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 62 62 virtual bool isFocusable() const; -
trunk/Source/WebCore/svg/SVGStyledElement.h
r150687 r150692 82 82 83 83 virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE; 84 virtual bool isMouseFocusable() const ;84 virtual bool isMouseFocusable() const OVERRIDE; 85 85 86 86 void buildPendingResourcesIfNeeded(); -
trunk/Source/WebKit2/ChangeLog
r150691 r150692 1 2013-05-25 Andreas Kling <akling@apple.com> 2 3 Move Node::isMouseFocusable() to Element. 4 <http://webkit.org/b/116762> 5 6 Reviewed by Anders Carlsson. 7 8 * WebProcess/WebPage/WebPage.cpp: 9 (WebKit::WebPage::highlightPotentialActivation): 10 11 Check that the potentially activated Node is an Element before asking if it's mouse-focusable. 12 1 13 2013-05-25 Andreas Kling <akling@apple.com> 2 14 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r150669 r150692 1884 1884 1885 1885 // We always highlight focusable (form-elements), image links or content-editable elements. 1886 if ( node->isMouseFocusable() || node->isLink() || node->isContentEditable())1886 if ((node->isElementNode() && toElement(node)->isMouseFocusable()) || node->isLink() || node->isContentEditable()) 1887 1887 activationNode = node; 1888 1888 else if (node->willRespondToMouseClickEvents()) {
Note: See TracChangeset
for help on using the changeset viewer.