⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 185682 in webkit


Ignore:
Timestamp:
Jun 17, 2015, 5:49:54 PM (11 years ago)
Author:
jhoneycutt@apple.com
Message:

Position::findParent() should take a reference
https://bugs.webkit.org/show_bug.cgi?id=146038

Reviewed by Darin Adler.

  • dom/Position.cpp:

(WebCore::Position::containerNode):
(WebCore::Position::parentAnchoredEquivalent):
Pass a reference; there is already a null check.
(WebCore::Position::previous):
Add a missing null check. Code below this expects that node is non-null.
(WebCore::Position::next):
Ditto.
(WebCore::Position::atStartOfTree):
(WebCore::Position::atEndOfTree):
Pass a reference.
(WebCore::Position::findParent):
Changed to take a reference.

  • dom/Position.h:

Ditto.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r185681 r185682  
     12015-06-16  Jon Honeycutt  <jhoneycutt@apple.com>
     2
     3        Position::findParent() should take a reference
     4        https://bugs.webkit.org/show_bug.cgi?id=146038
     5
     6        Reviewed by Darin Adler.
     7
     8        * dom/Position.cpp:
     9        (WebCore::Position::containerNode):
     10        (WebCore::Position::parentAnchoredEquivalent):
     11        Pass a reference; there is already a null check.
     12        (WebCore::Position::previous):
     13        Add a missing null check. Code below this expects that node is non-null.
     14        (WebCore::Position::next):
     15        Ditto.
     16        (WebCore::Position::atStartOfTree):
     17        (WebCore::Position::atEndOfTree):
     18        Pass a reference.
     19        (WebCore::Position::findParent):
     20        Changed to take a reference.
     21
     22        * dom/Position.h:
     23        Ditto.
     24
    1252015-06-17  Brent Fulgham  <bfulgham@apple.com>
    226
  • trunk/Source/WebCore/dom/Position.cpp

    r185613 r185682  
    163163    case PositionIsBeforeAnchor:
    164164    case PositionIsAfterAnchor:
    165         return findParent(m_anchorNode.get());
     165        return findParent(*m_anchorNode);
    166166    }
    167167    ASSERT_NOT_REACHED();
     
    223223    // FIXME: This should only be necessary for legacy positions, but is also needed for positions before and after Tables
    224224    if (m_offset <= 0 && (m_anchorType != PositionIsAfterAnchor && m_anchorType != PositionIsAfterChildren)) {
    225         if (findParent(m_anchorNode.get()) && (editingIgnoresContent(m_anchorNode.get()) || isRenderedTable(m_anchorNode.get())))
     225        if (findParent(*m_anchorNode) && (editingIgnoresContent(m_anchorNode.get()) || isRenderedTable(m_anchorNode.get())))
    226226            return positionInParentBeforeNode(m_anchorNode.get());
    227227        return Position(m_anchorNode.get(), 0, PositionIsOffsetInAnchor);
     
    311311    if (anchorType() == PositionIsBeforeAnchor) {
    312312        node = containerNode();
     313        if (!node)
     314            return *this;
     315
    313316        offset = computeOffsetInContainerNode();
    314317    }
     
    333336    }
    334337
    335     ContainerNode* parent = findParent(node);
     338    ContainerNode* parent = findParent(*node);
    336339    if (!parent)
    337340        return *this;
     
    361364    if (anchorType() == PositionIsAfterAnchor) {
    362365        node = containerNode();
     366        if (!node)
     367            return *this;
     368
    363369        offset = computeOffsetInContainerNode();
    364370    }
     
    377383    }
    378384
    379     ContainerNode* parent = findParent(node);
     385    ContainerNode* parent = findParent(*node);
    380386    if (!parent)
    381387        return *this;
     
    479485
    480486    Node* container = containerNode();
    481     if (container && findParent(container))
     487    if (container && findParent(*container))
    482488        return false;
    483489
     
    504510
    505511    Node* container = containerNode();
    506     if (container && findParent(container))
     512    if (container && findParent(*container))
    507513        return false;
    508514
     
    939945}
    940946
    941 ContainerNode* Position::findParent(const Node* node)
    942 {
    943     return node->nonShadowBoundaryParentNode();
     947ContainerNode* Position::findParent(const Node& node)
     948{
     949    return node.nonShadowBoundaryParentNode();
    944950}
    945951
  • trunk/Source/WebCore/dom/Position.h

    r182207 r185682  
    199199    static Node* rootUserSelectAllForNode(Node*) { return 0; }
    200200#endif
    201     static ContainerNode* findParent(const Node*);
     201    static ContainerNode* findParent(const Node&);
    202202   
    203203    void debugPosition(const char* msg = "") const;
Note: See TracChangeset for help on using the changeset viewer.