Changeset 150686 in webkit
- Timestamp:
- May 25, 2013 3:27:37 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r150685 r150686 1 2013-05-25 Andreas Kling <akling@apple.com> 2 3 Begin moving "focus" state logic from Node to Element. 4 <http://webkit.org/b/116760> 5 6 Reviewed by Antti Koivisto. 7 8 Only Elements can be focused, so merge the "focus" state logic from Node and ContainerNode 9 and move it into Element. There's a lot more iceberg under this tip, but we'll be starting 10 with setFocus(bool) and focused(). 11 12 * dom/Node.h: 13 * dom/ContainerNode.cpp: 14 * dom/ContainerNode.h: 15 * dom/Element.cpp: 16 (WebCore::Element::isUserActionElementFocused): 17 (WebCore::Element::setFocus): 18 * dom/Element.h: 19 (WebCore::Element::focused): 20 * dom/Node.cpp: 21 22 Move focused() and setFocus(bool) from Node/ContainerNode to Element. 23 24 * dom/Document.cpp: 25 (WebCore::Document::setFocusedNode): 26 * page/EventHandler.cpp: 27 (WebCore::EventHandler::dispatchMouseEvent): 28 29 Check if the inspected Node is an Element before asking if it's focused. 30 1 31 2013-05-25 Noam Rosenthal <noam.rosenthal@nokia.com> 2 32 -
trunk/Source/WebCore/dom/ContainerNode.cpp
r150684 r150686 969 969 } 970 970 971 void ContainerNode::setFocus(bool received)972 {973 if (focused() == received)974 return;975 976 Node::setFocus(received);977 978 // note that we need to recalc the style979 setNeedsStyleRecalc();980 }981 982 971 void ContainerNode::setActive(bool down, bool pause) 983 972 { -
trunk/Source/WebCore/dom/ContainerNode.h
r150684 r150686 110 110 virtual void detach() OVERRIDE; 111 111 virtual LayoutRect boundingBox() const OVERRIDE; 112 virtual void setFocus(bool) OVERRIDE;113 112 virtual void setActive(bool active = true, bool pause = false) OVERRIDE; 114 113 virtual void scheduleSetNeedsStyleRecalc(StyleChangeType = FullStyleChange) OVERRIDE FINAL; -
trunk/Source/WebCore/dom/Document.cpp
r150684 r150686 3342 3342 oldFocusedNode->setActive(false); 3343 3343 3344 oldFocusedNode->setFocus(false); 3344 if (oldFocusedNode->isElementNode()) 3345 toElement(oldFocusedNode.get())->setFocus(false); 3345 3346 3346 3347 // Dispatch a change event for text fields or textareas that have been edited … … 3420 3421 goto SetFocusedNodeDone; 3421 3422 } 3422 m_focusedNode->setFocus(true); 3423 3424 if (m_focusedNode->isElementNode()) 3425 toElement(m_focusedNode.get())->setFocus(true); 3423 3426 3424 3427 if (m_focusedNode->isRootEditableElement()) -
trunk/Source/WebCore/dom/Element.cpp
r150684 r150686 403 403 } 404 404 405 bool Element::isUserActionElementFocused() const 406 { 407 ASSERT(isUserActionElement()); 408 return document()->userActionElements().isFocused(this); 409 } 410 405 411 bool Element::isUserActionElementHovered() const 406 412 { 407 413 ASSERT(isUserActionElement()); 408 414 return document()->userActionElements().isHovered(this); 415 } 416 417 void Element::setFocus(bool flag) 418 { 419 if (flag == focused()) 420 return; 421 422 if (Document* document = this->document()) 423 document->userActionElements().setFocused(this, flag); 424 425 setNeedsStyleRecalc(); 409 426 } 410 427 -
trunk/Source/WebCore/dom/Element.h
r150684 r150686 428 428 429 429 bool hovered() const { return isUserActionElement() && isUserActionElementHovered(); } 430 bool focused() const { return isUserActionElement() && isUserActionElementFocused(); } 431 430 432 virtual void setHovered(bool flag = true); 433 virtual void setFocus(bool flag); 431 434 432 435 RenderStyle* computedStyle(PseudoId = NOPSEUDO); … … 658 661 659 662 private: 663 bool isUserActionElementFocused() const; 660 664 bool isUserActionElementHovered() const; 661 665 -
trunk/Source/WebCore/dom/Node.cpp
r150684 r150686 2738 2738 } 2739 2739 2740 void Node::setFocus(bool flag)2741 {2742 if (Document* document = this->document())2743 document->userActionElements().setFocused(this, flag);2744 }2745 2746 2740 void Node::setActive(bool flag, bool) 2747 2741 { … … 2762 2756 } 2763 2757 2764 bool Node::isUserActionElementFocused() const2765 {2766 ASSERT(isUserActionElement());2767 return document()->userActionElements().isFocused(this);2768 }2769 2770 2758 } // namespace WebCore 2771 2759 -
trunk/Source/WebCore/dom/Node.h
r150684 r150686 361 361 bool active() const { return isUserActionElement() && isUserActionElementActive(); } 362 362 bool inActiveChain() const { return isUserActionElement() && isUserActionElementInActiveChain(); } 363 bool focused() const { return isUserActionElement() && isUserActionElementFocused(); }364 363 365 364 bool attached() const { return getFlag(IsAttachedFlag); } … … 399 398 void lazyReattach(ShouldSetAttached = SetAttached); 400 399 401 virtual void setFocus(bool flag);402 400 virtual void setActive(bool flag = true, bool pause = false); 403 401 -
trunk/Source/WebCore/dom/UserActionElementSet.h
r150684 r150686 43 43 static PassOwnPtr<UserActionElementSet> create() { return adoptPtr(new UserActionElementSet()); } 44 44 45 bool isFocused(const Node* node) { return hasFlags(node, IsFocusedFlag); }45 bool isFocused(const Element* element) { return hasFlags(element, IsFocusedFlag); } 46 46 bool isActive(const Node* node) { return hasFlags(node, IsActiveFlag); } 47 47 bool isInActiveChain(const Node* node) { return hasFlags(node, InActiveChainFlag); } 48 bool isHovered(const Node* node) { return hasFlags(node, IsHoveredFlag); }49 void setFocused( Node* node, bool enable) { setFlags(node, enable, IsFocusedFlag); }48 bool isHovered(const Element* element) { return hasFlags(element, IsHoveredFlag); } 49 void setFocused(Element* element, bool enable) { setFlags(element, enable, IsFocusedFlag); } 50 50 void setActive(Node* node, bool enable) { setFlags(node, enable, IsActiveFlag); } 51 51 void setInActiveChain(Node* node, bool enable) { setFlags(node, enable, InActiveChainFlag); } -
trunk/Source/WebCore/page/EventHandler.cpp
r150354 r150686 2361 2361 if (!page->focusController()->setFocusedNode(node, m_frame)) 2362 2362 swallowEvent = true; 2363 } else if (!node || !node-> focused()) {2363 } else if (!node || !node->isElementNode() || !toElement(node)->focused()) { 2364 2364 if (!page->focusController()->setFocusedNode(0, m_frame)) 2365 2365 swallowEvent = true;
Note: See TracChangeset
for help on using the changeset viewer.