Changeset 150722 in webkit


Ignore:
Timestamp:
May 26, 2013 3:23:18 PM (11 years ago)
Author:
akling@apple.com
Message:

Move :active chain participation state from Node to Element.
<http://webkit.org/b/116786>

Reviewed by Antti Koivisto.

Only Elements can be in the :active chain so move the logic there from Node.

  • dom/Document.cpp:

(WebCore::Document::updateHoverActiveState):

Add isElementNode() type checks when updating the :active chain.

  • dom/Node.h:
  • dom/Node.cpp:

(WebCore::Node::detach):

  • dom/Element.cpp:

(WebCore::Element::detach):

Move the remaining logic for detaching from the UserActionElementSet to Element.

(WebCore::Element::isUserActionElementInActiveChain):

  • dom/Element.h:

(WebCore::Element::inActiveChain):

Move all the :active chain stuff from Node to Element.

  • dom/UserActionElementSet.cpp:

(WebCore::UserActionElementSet::didDetach):

  • dom/UserActionElementSet.h:

(WebCore::UserActionElementSet::isInActiveChain):
(WebCore::UserActionElementSet::setInActiveChain):

UserActionElementSet now only takes Element* in its API.

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r150719 r150722  
     12013-05-26  Andreas Kling  <akling@apple.com>
     2
     3        Move :active chain participation state from Node to Element.
     4        <http://webkit.org/b/116786>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Only Elements can be in the :active chain so move the logic there from Node.
     9
     10        * dom/Document.cpp:
     11        (WebCore::Document::updateHoverActiveState):
     12
     13            Add isElementNode() type checks when updating the :active chain.
     14
     15        * dom/Node.h:
     16        * dom/Node.cpp:
     17        (WebCore::Node::detach):
     18        * dom/Element.cpp:
     19        (WebCore::Element::detach):
     20
     21            Move the remaining logic for detaching from the UserActionElementSet to Element.
     22
     23        (WebCore::Element::isUserActionElementInActiveChain):
     24        * dom/Element.h:
     25        (WebCore::Element::inActiveChain):
     26
     27            Move all the :active chain stuff from Node to Element.
     28
     29        * dom/UserActionElementSet.cpp:
     30        (WebCore::UserActionElementSet::didDetach):
     31        * dom/UserActionElementSet.h:
     32        (WebCore::UserActionElementSet::isInActiveChain):
     33        (WebCore::UserActionElementSet::setInActiveChain):
     34
     35            UserActionElementSet now only takes Element* in its API.
     36
    1372013-05-26  Antti Koivisto  <antti@apple.com>
    238
  • trunk/Source/WebCore/dom/Document.cpp

    r150715 r150722  
    44 *           (C) 2001 Dirk Mueller (mueller@kde.org)
    55 *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
    6  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserved.
     6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012, 2013 Apple Inc. All rights reserved.
    77 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
    88 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
     
    58715871        // We are clearing the :active chain because the mouse has been released.
    58725872        for (RenderObject* curr = oldActiveElement->renderer(); curr; curr = curr->parent()) {
    5873             if (curr->node()) {
    5874                 ASSERT(!curr->node()->isTextNode());
    5875                 if (curr->node()->isElementNode())
    5876                     toElement(curr->node())->setActive(false);
    5877                 m_userActionElements.setInActiveChain(curr->node(), false);
    5878             }
     5873            if (!curr->node() || !curr->node()->isElementNode())
     5874                continue;
     5875            Element* element = toElement(curr->node());
     5876            element->setActive(false);
     5877            m_userActionElements.setInActiveChain(element, false);
    58795878        }
    58805879        setActiveElement(0);
     
    58855884            // will need to reference this chain.
    58865885            for (RenderObject* curr = newActiveElement->renderer(); curr; curr = curr->parent()) {
    5887                 if (curr->node() && !curr->isText())
    5888                     m_userActionElements.setInActiveChain(curr->node(), true);
     5886                if (!curr->node() || !curr->node()->isElementNode() || curr->isText())
     5887                    continue;
     5888                m_userActionElements.setInActiveChain(toElement(curr->node()), true);
    58895889            }
    58905890
     
    59505950        // The old hover path only needs to be cleared up to (and not including) the common ancestor;
    59515951        for (RenderObject* curr = oldHoverObj; curr && curr != ancestor; curr = curr->hoverAncestor()) {
    5952             if (curr->node() && !curr->isText() && (!mustBeInActiveChain || curr->node()->inActiveChain()))
     5952            if (!curr->node() || curr->isText())
     5953                continue;
     5954            if (!mustBeInActiveChain || (curr->node()->isElementNode() && toElement(curr->node())->inActiveChain()))
    59535955                nodesToRemoveFromChain.append(curr->node());
    59545956        }
     
    59625964    // Now set the hover state for our new object up to the root.
    59635965    for (RenderObject* curr = newHoverObj; curr; curr = curr->hoverAncestor()) {
    5964         if (curr->node() && !curr->isText() && (!mustBeInActiveChain || curr->node()->inActiveChain()))
     5966        if (!curr->node() || curr->isText())
     5967            continue;
     5968        if (!mustBeInActiveChain || (curr->node()->isElementNode() && toElement(curr->node())->inActiveChain()))
    59655969            nodesToAddToChain.append(curr->node());
    59665970    }
  • trunk/Source/WebCore/dom/Element.cpp

    r150715 r150722  
    458458}
    459459
     460bool Element::isUserActionElementInActiveChain() const
     461{
     462    ASSERT(isUserActionElement());
     463    return document()->userActionElements().isInActiveChain(this);
     464}
     465
    460466bool Element::isUserActionElementActive() const
    461467{
     
    14701476    }
    14711477
    1472     if (hovered())
    1473         document()->hoveredNodeDetached(this);
     1478    if (isUserActionElement()) {
     1479        if (hovered())
     1480            document()->hoveredNodeDetached(this);
     1481        if (inActiveChain())
     1482            document()->activeChainNodeDetached(this);
     1483        document()->userActionElements().didDetach(this);
     1484    }
    14741485
    14751486    ContainerNode::detach();
  • trunk/Source/WebCore/dom/Element.h

    r150715 r150722  
    427427    virtual const AtomicString& shadowPseudoId() const;
    428428
     429    bool inActiveChain() const { return isUserActionElement() && isUserActionElementInActiveChain(); }
    429430    bool active() const { return isUserActionElement() && isUserActionElementActive(); }
    430431    bool hovered() const { return isUserActionElement() && isUserActionElementHovered(); }
     
    665666
    666667private:
     668    bool isUserActionElementInActiveChain() const;
    667669    bool isUserActionElementActive() const;
    668670    bool isUserActionElementFocused() const;
  • trunk/Source/WebCore/dom/Node.cpp

    r150715 r150722  
    107107#include "UIEvent.h"
    108108#include "UIEventWithKeyState.h"
    109 #include "UserActionElementSet.h"
    110109#include "WheelEvent.h"
    111110#include "WindowEventContext.h"
     
    10511050    setRenderer(0);
    10521051
    1053     Document* doc = document();
    1054     if (isUserActionElement()) {
    1055         if (inActiveChain())
    1056             doc->activeChainNodeDetached(this);
    1057         doc->userActionElements().didDetach(this);
    1058     }
    1059 
    10601052    clearFlag(IsAttachedFlag);
    10611053
     
    26782670}
    26792671
    2680 bool Node::isUserActionElementInActiveChain() const
    2681 {
    2682     ASSERT(isUserActionElement());
    2683     return document()->userActionElements().isInActiveChain(this);
    2684 }
    2685 
    26862672} // namespace WebCore
    26872673
  • trunk/Source/WebCore/dom/Node.h

    r150715 r150722  
    359359    void setUserActionElement(bool flag) { setFlag(flag, IsUserActionElement); }
    360360
    361     bool inActiveChain() const { return isUserActionElement() && isUserActionElementInActiveChain(); }
    362 
    363361    bool attached() const { return getFlag(IsAttachedFlag); }
    364362    void setAttached() { setFlag(IsAttachedFlag); }
     
    771769    bool isEditableToAccessibility(EditableLevel) const;
    772770
    773     bool isUserActionElementInActiveChain() const;
    774 
    775771    void setStyleChange(StyleChangeType);
    776772
  • trunk/Source/WebCore/dom/UserActionElementSet.cpp

    r150684 r150722  
    11/*
    22 * Copyright (C) 2012 Google Inc. All rights reserved.
     3 * Copyright (C) 2013 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    3031#include "Document.h"
    3132#include "Element.h"
    32 #include "Node.h"
    3333
    3434namespace WebCore {
     
    4242}
    4343
    44 void UserActionElementSet::didDetach(Node* node)
     44void UserActionElementSet::didDetach(Element* element)
    4545{
    46     ASSERT(node->isUserActionElement());
    47     clearFlags(toElement(node), IsActiveFlag | InActiveChainFlag | IsHoveredFlag);
     46    ASSERT(element->isUserActionElement());
     47    clearFlags(element, IsActiveFlag | InActiveChainFlag | IsHoveredFlag);
    4848}
    4949
     
    5151{
    5252    m_elements.clear();
    53 }
    54 
    55 bool UserActionElementSet::hasFlags(const Node* node, unsigned flags) const
    56 {
    57     ASSERT(node->isUserActionElement() && node->isElementNode());
    58     return hasFlags(toElement(node), flags);
    59 }
    60 
    61 void UserActionElementSet::setFlags(Node* node, unsigned flags)
    62 {
    63     if (!node->isElementNode())
    64         return;
    65     return setFlags(toElement(node), flags);
    66 }
    67 
    68 void UserActionElementSet::clearFlags(Node* node, unsigned flags)
    69 {
    70     if (!node->isElementNode())
    71         return;
    72     return clearFlags(toElement(node), flags);
    7353}
    7454
  • trunk/Source/WebCore/dom/UserActionElementSet.h

    r150715 r150722  
    3737namespace WebCore {
    3838
    39 class Node;
    4039class Element;
    4140
     
    4645    bool isFocused(const Element* element) { return hasFlags(element, IsFocusedFlag); }
    4746    bool isActive(const Element* element) { return hasFlags(element, IsActiveFlag); }
    48     bool isInActiveChain(const Node* node) { return hasFlags(node, InActiveChainFlag); }
     47    bool isInActiveChain(const Element* element) { return hasFlags(element, InActiveChainFlag); }
    4948    bool isHovered(const Element* element) { return hasFlags(element, IsHoveredFlag); }
    5049    void setFocused(Element* element, bool enable) { setFlags(element, enable, IsFocusedFlag); }
    5150    void setActive(Element* element, bool enable) { setFlags(element, enable, IsActiveFlag); }
    52     void setInActiveChain(Node* node, bool enable) { setFlags(node, enable, InActiveChainFlag); }
     51    void setInActiveChain(Element* element, bool enable) { setFlags(element, enable, InActiveChainFlag); }
    5352    void setHovered(Element* element, bool enable) { setFlags(element, enable, IsHoveredFlag); }
    5453
     
    5655    ~UserActionElementSet();
    5756
    58     void didDetach(Node*);
     57    void didDetach(Element*);
    5958    void documentDidRemoveLastRef();
    6059
     
    6665        IsFocusedFlag     = 1 << 3
    6766    };
    68 
    69     void setFlags(Node* node, bool enable, unsigned flags) { enable ? setFlags(node, flags) : clearFlags(node, flags); }
    70     void setFlags(Node*, unsigned);
    71     void clearFlags(Node*, unsigned);
    72     bool hasFlags(const Node*, unsigned flags) const;
    7367
    7468    void setFlags(Element* element, bool enable, unsigned flags) { enable ? setFlags(element, flags) : clearFlags(element, flags); }
Note: See TracChangeset for help on using the changeset viewer.