Add Node::isDescendantOf() overload that takes in a reference
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Nov 2016 06:24:13 +0000 (06:24 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Nov 2016 06:24:13 +0000 (06:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164854

Reviewed by Ryosuke Niwa.

Add Node::isDescendantOf() overload that takes in a reference as a lot
of call sites have a reference or a pointer they know is not null.

No new tests, no Web-exposed behavior change.

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::press):
* dom/Document.cpp:
(WebCore::isNodeInSubtree):
(WebCore::Document::removeFullScreenElementOfSubtree):
(WebCore::Document::setAnimatingFullScreen):
* dom/Node.cpp:
(WebCore::Node::isDescendantOf):
(WebCore::Node::isDescendantOrShadowDescendantOf):
(WebCore::Node::contains):
* dom/Node.h:
(WebCore::Node::isDescendantOf):
* dom/NodeIterator.cpp:
(WebCore::NodeIterator::updateForNodeRemoval):
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::executeFastPathForIdSelector):
(WebCore::filterRootById):
* dom/TypedElementDescendantIterator.h:
(WebCore::TypedElementDescendantIteratorAdapter<ElementType>::beginAt):
(WebCore::TypedElementDescendantIteratorAdapter<ElementType>::from):
(WebCore::TypedElementDescendantConstIteratorAdapter<ElementType>::beginAt):
(WebCore::TypedElementDescendantConstIteratorAdapter<ElementType>::from):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
(WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange):
* editing/BreakBlockquoteCommand.cpp:
(WebCore::BreakBlockquoteCommand::doApply):
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::cloneParagraphUnderNewElement):
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::handleGeneralDelete):
(WebCore::DeleteSelectionCommand::removePreviouslySelectedEmptyTableRows):
(WebCore::DeleteSelectionCommand::doApply):
* editing/EditingStyle.cpp:
(WebCore::EditingStyle::textDirectionForSelection):
* editing/FormatBlockCommand.cpp:
(WebCore::FormatBlockCommand::formatRange):
* editing/TextIterator.cpp:
(WebCore::TextIterator::advance):
* editing/VisiblePosition.cpp:
(WebCore::VisiblePosition::honorEditingBoundaryAtOrBefore):
(WebCore::VisiblePosition::honorEditingBoundaryAtOrAfter):
* editing/htmlediting.cpp:
(WebCore::firstEditablePositionAfterPositionInRoot):
(WebCore::lastEditablePositionBeforePositionInRoot):
(WebCore::selectionForParagraphIteration):
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::traverseNodesForSerialization):
* html/CachedHTMLCollection.h:
(WebCore::traversalType>::namedItem):
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::formElementIndex):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::drawFocusIfNeededInternal):
* page/EventHandler.cpp:
(WebCore::EventHandler::selectClosestContextualWordOrLinkFromMouseEvent):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::getElementById):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208839 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/dom/NodeIterator.cpp
Source/WebCore/dom/SelectorQuery.cpp
Source/WebCore/dom/TypedElementDescendantIterator.h
Source/WebCore/editing/ApplyStyleCommand.cpp
Source/WebCore/editing/BreakBlockquoteCommand.cpp
Source/WebCore/editing/CompositeEditCommand.cpp
Source/WebCore/editing/DeleteSelectionCommand.cpp
Source/WebCore/editing/EditingStyle.cpp
Source/WebCore/editing/FormatBlockCommand.cpp
Source/WebCore/editing/TextIterator.cpp
Source/WebCore/editing/VisiblePosition.cpp
Source/WebCore/editing/htmlediting.cpp
Source/WebCore/editing/markup.cpp
Source/WebCore/html/CachedHTMLCollection.h
Source/WebCore/html/HTMLFormElement.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/svg/SVGSVGElement.cpp

index 574c9a9..b055f2f 100644 (file)
@@ -1,3 +1,74 @@
+2016-11-16  Chris Dumez  <cdumez@apple.com>
+
+        Add Node::isDescendantOf() overload that takes in a reference
+        https://bugs.webkit.org/show_bug.cgi?id=164854
+
+        Reviewed by Ryosuke Niwa.
+
+        Add Node::isDescendantOf() overload that takes in a reference as a lot
+        of call sites have a reference or a pointer they know is not null.
+
+        No new tests, no Web-exposed behavior change.
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::press):
+        * dom/Document.cpp:
+        (WebCore::isNodeInSubtree):
+        (WebCore::Document::removeFullScreenElementOfSubtree):
+        (WebCore::Document::setAnimatingFullScreen):
+        * dom/Node.cpp:
+        (WebCore::Node::isDescendantOf):
+        (WebCore::Node::isDescendantOrShadowDescendantOf):
+        (WebCore::Node::contains):
+        * dom/Node.h:
+        (WebCore::Node::isDescendantOf):
+        * dom/NodeIterator.cpp:
+        (WebCore::NodeIterator::updateForNodeRemoval):
+        * dom/SelectorQuery.cpp:
+        (WebCore::SelectorDataList::executeFastPathForIdSelector):
+        (WebCore::filterRootById):
+        * dom/TypedElementDescendantIterator.h:
+        (WebCore::TypedElementDescendantIteratorAdapter<ElementType>::beginAt):
+        (WebCore::TypedElementDescendantIteratorAdapter<ElementType>::from):
+        (WebCore::TypedElementDescendantConstIteratorAdapter<ElementType>::beginAt):
+        (WebCore::TypedElementDescendantConstIteratorAdapter<ElementType>::from):
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
+        (WebCore::ApplyStyleCommand::applyInlineStyleToNodeRange):
+        * editing/BreakBlockquoteCommand.cpp:
+        (WebCore::BreakBlockquoteCommand::doApply):
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::cloneParagraphUnderNewElement):
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::handleGeneralDelete):
+        (WebCore::DeleteSelectionCommand::removePreviouslySelectedEmptyTableRows):
+        (WebCore::DeleteSelectionCommand::doApply):
+        * editing/EditingStyle.cpp:
+        (WebCore::EditingStyle::textDirectionForSelection):
+        * editing/FormatBlockCommand.cpp:
+        (WebCore::FormatBlockCommand::formatRange):
+        * editing/TextIterator.cpp:
+        (WebCore::TextIterator::advance):
+        * editing/VisiblePosition.cpp:
+        (WebCore::VisiblePosition::honorEditingBoundaryAtOrBefore):
+        (WebCore::VisiblePosition::honorEditingBoundaryAtOrAfter):
+        * editing/htmlediting.cpp:
+        (WebCore::firstEditablePositionAfterPositionInRoot):
+        (WebCore::lastEditablePositionBeforePositionInRoot):
+        (WebCore::selectionForParagraphIteration):
+        * editing/markup.cpp:
+        (WebCore::StyledMarkupAccumulator::traverseNodesForSerialization):
+        * html/CachedHTMLCollection.h:
+        (WebCore::traversalType>::namedItem):
+        * html/HTMLFormElement.cpp:
+        (WebCore::HTMLFormElement::formElementIndex):
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::drawFocusIfNeededInternal):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::selectClosestContextualWordOrLinkFromMouseEvent):
+        * svg/SVGSVGElement.cpp:
+        (WebCore::SVGSVGElement::getElementById):
+
 2016-11-16  Ryosuke Niwa  <rniwa@webkit.org>
 
         Fix build on macOS Sierra when WEB_PLAYBACK_CONTROLS_MANAGER is enabled
index 9a555a4..a6acf50 100644 (file)
@@ -911,11 +911,12 @@ bool AccessibilityObject::press()
     
     // Prefer the actionElement instead of this node, if the actionElement is inside this node.
     Element* pressElement = this->element();
-    if (!pressElement || actionElem->isDescendantOf(pressElement))
+    if (!pressElement || actionElem->isDescendantOf(*pressElement))
         pressElement = actionElem;
     
+    ASSERT(pressElement);
     // Prefer the hit test element, if it is inside the target element.
-    if (hitTestElement && hitTestElement->isDescendantOf(pressElement))
+    if (hitTestElement && hitTestElement->isDescendantOf(*pressElement))
         pressElement = hitTestElement;
     
     UserGestureIndicator gestureIndicator(ProcessingUserGesture, document);
index e73c0bf..ef126bc 100644 (file)
@@ -3534,9 +3534,9 @@ void Document::pageMutedStateDidChange()
 static bool isNodeInSubtree(Node& node, Node& container, bool amongChildrenOnly)
 {
     if (amongChildrenOnly)
-        return node.isDescendantOf(&container);
+        return node.isDescendantOf(container);
     else
-        return &node == &container || node.isDescendantOf(&container);
+        return &node == &container || node.isDescendantOf(container);
 }
 
 void Document::removeFocusedNodeOfSubtree(Node& node, bool amongChildrenOnly)
@@ -5963,9 +5963,9 @@ void Document::removeFullScreenElementOfSubtree(Node& node, bool amongChildrenOn
     
     bool elementInSubtree = false;
     if (amongChildrenOnly)
-        elementInSubtree = m_fullScreenElement->isDescendantOf(&node);
+        elementInSubtree = m_fullScreenElement->isDescendantOf(node);
     else
-        elementInSubtree = (m_fullScreenElement == &node) || m_fullScreenElement->isDescendantOf(&node);
+        elementInSubtree = (m_fullScreenElement == &node) || m_fullScreenElement->isDescendantOf(node);
     
     if (elementInSubtree)
         fullScreenElementRemoved();
@@ -5982,7 +5982,7 @@ void Document::setAnimatingFullScreen(bool flag)
         return;
     m_isAnimatingFullScreen = flag;
 
-    if (m_fullScreenElement && m_fullScreenElement->isDescendantOf(this)) {
+    if (m_fullScreenElement && m_fullScreenElement->isDescendantOf(*this)) {
         m_fullScreenElement->invalidateStyleForSubtree();
         scheduleForcedStyleRecalc();
     }
index e4e80de..c1dff3a 100644 (file)
@@ -912,15 +912,15 @@ ExceptionOr<void> Node::checkSetPrefix(const AtomicString& prefix)
     return { };
 }
 
-bool Node::isDescendantOf(const Node* other) const
+bool Node::isDescendantOf(const Node& other) const
 {
     // Return true if other is an ancestor of this, otherwise false
-    if (!other || !other->hasChildNodes() || inDocument() != other->inDocument())
+    if (!other.hasChildNodes() || inDocument() != other.inDocument())
         return false;
-    if (other->isDocumentNode())
-        return &document() == other && !isDocumentNode() && inDocument();
-    for (const ContainerNode* n = parentNode(); n; n = n->parentNode()) {
-        if (n == other)
+    if (other.isDocumentNode())
+        return &document() == &other && !isDocumentNode() && inDocument();
+    for (const auto* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNode()) {
+        if (ancestor == &other)
             return true;
     }
     return false;
@@ -930,19 +930,19 @@ bool Node::isDescendantOrShadowDescendantOf(const Node* other) const
 {
     if (!other) 
         return false;
-    if (isDescendantOf(other))
+    if (isDescendantOf(*other))
         return true;
     const Node* shadowAncestorNode = deprecatedShadowAncestorNode();
     if (!shadowAncestorNode)
         return false;
-    return shadowAncestorNode == other || shadowAncestorNode->isDescendantOf(other);
+    return shadowAncestorNode == other || shadowAncestorNode->isDescendantOf(*other);
 }
 
 bool Node::contains(const Node* node) const
 {
     if (!node)
         return false;
-    return this == node || node->isDescendantOf(this);
+    return this == node || node->isDescendantOf(*this);
 }
 
 bool Node::containsIncludingShadowDOM(const Node* node) const
index d3112f5..e6e494b 100644 (file)
@@ -386,7 +386,9 @@ public:
 
     ExceptionOr<void> checkSetPrefix(const AtomicString& prefix);
 
-    WEBCORE_EXPORT bool isDescendantOf(const Node*) const;
+    WEBCORE_EXPORT bool isDescendantOf(const Node&) const;
+    WEBCORE_EXPORT bool isDescendantOf(const Node* other) const { return other && isDescendantOf(*other); }
+
     bool isDescendantOrShadowDescendantOf(const Node*) const;
     WEBCORE_EXPORT bool contains(const Node*) const;
     bool containsIncludingShadowDOM(const Node*) const;
index 5e7a4b3..cd6957a 100644 (file)
@@ -143,10 +143,10 @@ void NodeIterator::updateForNodeRemoval(Node& removedNode, NodePointer& referenc
 
     // Iterator is not affected if the removed node is the reference node and is the root.
     // or if removed node is not the reference node, or the ancestor of the reference node.
-    if (!removedNode.isDescendantOf(&root()))
+    if (!removedNode.isDescendantOf(root()))
         return;
     bool willRemoveReferenceNode = &removedNode == referenceNode.node;
-    bool willRemoveReferenceNodeAncestor = referenceNode.node && referenceNode.node->isDescendantOf(&removedNode);
+    bool willRemoveReferenceNodeAncestor = referenceNode.node && referenceNode.node->isDescendantOf(removedNode);
     if (!willRemoveReferenceNode && !willRemoveReferenceNodeAncestor)
         return;
 
@@ -155,7 +155,7 @@ void NodeIterator::updateForNodeRemoval(Node& removedNode, NodePointer& referenc
         if (node) {
             // Move out from under the node being removed if the new reference
             // node is a descendant of the node being removed.
-            while (node && node->isDescendantOf(&removedNode))
+            while (node && node->isDescendantOf(removedNode))
                 node = NodeTraversal::next(*node, &root());
             if (node)
                 referenceNode.node = node;
@@ -183,7 +183,7 @@ void NodeIterator::updateForNodeRemoval(Node& removedNode, NodePointer& referenc
             // Move out from under the node being removed if the reference node is
             // a descendant of the node being removed.
             if (willRemoveReferenceNodeAncestor) {
-                while (node && node->isDescendantOf(&removedNode))
+                while (node && node->isDescendantOf(removedNode))
                     node = NodeTraversal::previous(*node);
             }
             if (node)
@@ -194,7 +194,7 @@ void NodeIterator::updateForNodeRemoval(Node& removedNode, NodePointer& referenc
             // Move out from under the node being removed if the reference node is
             // a descendant of the node being removed.
             if (willRemoveReferenceNodeAncestor) {
-                while (node && node->isDescendantOf(&removedNode))
+                while (node && node->isDescendantOf(removedNode))
                     node = NodeTraversal::previous(*node);
             }
             if (node)
index 1d8735d..48a97c6 100644 (file)
@@ -228,7 +228,7 @@ ALWAYS_INLINE void SelectorDataList::executeFastPathForIdSelector(const Containe
         ASSERT(elements);
         bool rootNodeIsTreeScopeRoot = isTreeScopeRoot(rootNode);
         for (auto& element : *elements) {
-            if ((rootNodeIsTreeScopeRoot || element->isDescendantOf(&rootNode)) && selectorMatches(selectorData, *element, rootNode)) {
+            if ((rootNodeIsTreeScopeRoot || element->isDescendantOf(rootNode)) && selectorMatches(selectorData, *element, rootNode)) {
                 SelectorQueryTrait::appendOutputForElement(output, element);
                 if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
                     return;
@@ -238,7 +238,7 @@ ALWAYS_INLINE void SelectorDataList::executeFastPathForIdSelector(const Containe
     }
 
     Element* element = rootNode.treeScope().getElementById(idToMatch);
-    if (!element || !(isTreeScopeRoot(rootNode) || element->isDescendantOf(&rootNode)))
+    if (!element || !(isTreeScopeRoot(rootNode) || element->isDescendantOf(rootNode)))
         return;
     if (selectorMatches(selectorData, *element, rootNode))
         SelectorQueryTrait::appendOutputForElement(output, element);
@@ -269,7 +269,7 @@ static ContainerNode& filterRootById(ContainerNode& rootNode, const CSSSelector&
                 if (LIKELY(!rootNode.treeScope().containsMultipleElementsWithId(idToMatch))) {
                     if (inAdjacentChain)
                         searchRoot = searchRoot->parentNode();
-                    if (searchRoot && (isTreeScopeRoot(rootNode) || searchRoot == &rootNode || searchRoot->isDescendantOf(&rootNode)))
+                    if (searchRoot && (isTreeScopeRoot(rootNode) || searchRoot == &rootNode || searchRoot->isDescendantOf(rootNode)))
                         return *searchRoot;
                 }
             }
index 853af2b..9f35935 100644 (file)
@@ -178,14 +178,14 @@ inline TypedElementDescendantIterator<ElementType> TypedElementDescendantIterato
 template <typename ElementType>
 inline TypedElementDescendantIterator<ElementType> TypedElementDescendantIteratorAdapter<ElementType>::beginAt(ElementType& descendant)
 {
-    ASSERT(descendant.isDescendantOf(&m_root));
+    ASSERT(descendant.isDescendantOf(m_root));
     return TypedElementDescendantIterator<ElementType>(m_root, &descendant);
 }
 
 template <typename ElementType>
 inline TypedElementDescendantIterator<ElementType> TypedElementDescendantIteratorAdapter<ElementType>::from(Element& descendant)
 {
-    ASSERT(descendant.isDescendantOf(&m_root));
+    ASSERT(descendant.isDescendantOf(m_root));
     if (is<ElementType>(descendant))
         return TypedElementDescendantIterator<ElementType>(m_root, downcast<ElementType>(&descendant));
     ElementType* next = Traversal<ElementType>::next(descendant, &m_root);
@@ -227,14 +227,14 @@ inline TypedElementDescendantConstIterator<ElementType> TypedElementDescendantCo
 template <typename ElementType>
 inline TypedElementDescendantConstIterator<ElementType> TypedElementDescendantConstIteratorAdapter<ElementType>::beginAt(const ElementType& descendant) const
 {
-    ASSERT(descendant.isDescendantOf(&m_root));
+    ASSERT(descendant.isDescendantOf(m_root));
     return TypedElementDescendantConstIterator<ElementType>(m_root, &descendant);
 }
 
 template <typename ElementType>
 inline TypedElementDescendantConstIterator<ElementType> TypedElementDescendantConstIteratorAdapter<ElementType>::from(const Element& descendant) const
 {
-    ASSERT(descendant.isDescendantOf(&m_root));
+    ASSERT(descendant.isDescendantOf(m_root));
     if (is<ElementType>(descendant))
         return TypedElementDescendantConstIterator<ElementType>(m_root, downcast<ElementType>(&descendant));
     const ElementType* next = Traversal<ElementType>::next(descendant, &m_root);
index 266cf69..38e9401 100644 (file)
@@ -356,7 +356,7 @@ void ApplyStyleCommand::applyRelativeFontStyleChange(EditingStyle* style)
     Node* beyondEnd;
     ASSERT(start.deprecatedNode());
     ASSERT(end.deprecatedNode());
-    if (start.deprecatedNode()->isDescendantOf(end.deprecatedNode()))
+    if (start.deprecatedNode()->isDescendantOf(*end.deprecatedNode()))
         beyondEnd = NodeTraversal::nextSkippingChildren(*end.deprecatedNode());
     else
         beyondEnd = NodeTraversal::next(*end.deprecatedNode());
@@ -785,7 +785,7 @@ void ApplyStyleCommand::applyInlineStyleToNodeRange(EditingStyle* style, PassRef
             // This is a plaintext-only region. Only proceed if it's fully selected.
             // pastEndNode is the node after the last fully selected node, so if it's inside node then
             // node isn't fully selected.
-            if (pastEndNode && pastEndNode->isDescendantOf(node.get()))
+            if (pastEndNode && pastEndNode->isDescendantOf(*node))
                 break;
             // Add to this element's inline style and skip over its contents.
             HTMLElement& element = downcast<HTMLElement>(*node);
index 094497f..f1af20e 100644 (file)
@@ -120,7 +120,7 @@ void BreakBlockquoteCommand::doApply()
     }
     
     // If there's nothing inside topBlockquote to move, we're finished.
-    if (!startNode->isDescendantOf(topBlockquote)) {
+    if (!startNode->isDescendantOf(*topBlockquote)) {
         setEndingSelection(VisibleSelection(VisiblePosition(firstPositionInOrBeforeNode(startNode)), endingSelection().isDirectional()));
         return;
     }
index 4f6a352..cf59804 100644 (file)
@@ -1301,7 +1301,7 @@ void CompositeEditCommand::cloneParagraphUnderNewElement(const Position& start,
             auto clonedNode = node->cloneNode(true);
             insertNodeAfter(clonedNode.ptr(), lastNode);
             lastNode = WTFMove(clonedNode);
-            if (node == end.deprecatedNode() || end.deprecatedNode()->isDescendantOf(node.get()))
+            if (node == end.deprecatedNode() || end.deprecatedNode()->isDescendantOf(*node))
                 break;
         }
     }
index 8c19792..643f0b9 100644 (file)
@@ -519,7 +519,7 @@ void DeleteSelectionCommand::handleGeneralDelete()
             if (comparePositions(firstPositionInOrBeforeNode(node.get()), m_downstreamEnd) >= 0) {
                 // NodeTraversal::nextSkippingChildren just blew past the end position, so stop deleting
                 node = nullptr;
-            } else if (!m_downstreamEnd.deprecatedNode()->isDescendantOf(node.get())) {
+            } else if (!m_downstreamEnd.deprecatedNode()->isDescendantOf(*node)) {
                 RefPtr<Node> nextNode = NodeTraversal::nextSkippingChildren(*node);
                 // if we just removed a node from the end container, update end position so the
                 // check above will work
@@ -702,7 +702,7 @@ void DeleteSelectionCommand::removePreviouslySelectedEmptyTableRows()
     if (m_endTableRow && m_endTableRow->inDocument() && m_endTableRow != m_startTableRow)
         if (isTableRowEmpty(m_endTableRow.get())) {
             // Don't remove m_endTableRow if it's where we're putting the ending selection.
-            if (!m_endingPosition.deprecatedNode()->isDescendantOf(m_endTableRow.get())) {
+            if (!m_endingPosition.deprecatedNode()->isDescendantOf(*m_endTableRow)) {
                 // FIXME: We probably shouldn't remove m_endTableRow unless it's fully selected, even if it is empty.
                 // We'll need to start adjusting the selection endpoints during deletion to know whether or not m_endTableRow
                 // was fully selected here.
@@ -820,9 +820,10 @@ void DeleteSelectionCommand::doApply()
         // Don't need a placeholder when deleting a selection that starts just before a table
         // and ends inside it (we do need placeholders to hold open empty cells, but that's
         // handled elsewhere).
-        if (Node* table = isLastPositionBeforeTable(m_selectionToDelete.visibleStart()))
-            if (m_selectionToDelete.end().deprecatedNode()->isDescendantOf(table))
+        if (auto* table = isLastPositionBeforeTable(m_selectionToDelete.visibleStart())) {
+            if (m_selectionToDelete.end().deprecatedNode()->isDescendantOf(*table))
                 m_needPlaceholder = false;
+        }
     }
         
     
index 624f3ad..452a91a 100644 (file)
@@ -1531,7 +1531,7 @@ WritingDirection EditingStyle::textDirectionForSelection(const VisibleSelection&
             return NaturalWritingDirection;
 
         // In the range case, make sure that the embedding element persists until the end of the range.
-        if (selection.isRange() && !end.deprecatedNode()->isDescendantOf(node))
+        if (selection.isRange() && !end.deprecatedNode()->isDescendantOf(*node))
             return NaturalWritingDirection;
         
         foundDirection = directionValue == CSSValueLtr ? LeftToRightWritingDirection : RightToLeftWritingDirection;
index 7f12992..bb3a51d 100644 (file)
@@ -75,7 +75,7 @@ void FormatBlockCommand::formatRange(const Position& start, const Position& end,
         return;
     if (isElementForFormatBlock(refNode->tagQName()) && start == startOfBlock(start)
         && (end == endOfBlock(end) || isNodeVisiblyContainedWithin(*refNode, *range))
-        && refNode != root && !root->isDescendantOf(refNode)) {
+        && refNode != root && !root->isDescendantOf(*refNode)) {
         // Already in a block element that only contains the current paragraph
         if (refNode->hasTagName(tagName()))
             return;
index 87e4700..b05262a 100644 (file)
@@ -472,7 +472,7 @@ void TextIterator::advance()
                 bool pastEnd = NodeTraversal::next(*m_node) == m_pastEndNode;
                 Node* parentNode = m_node->parentOrShadowHostNode();
                 while (!next && parentNode) {
-                    if ((pastEnd && parentNode == m_endContainer) || m_endContainer->isDescendantOf(parentNode))
+                    if ((pastEnd && parentNode == m_endContainer) || m_endContainer->isDescendantOf(*parentNode))
                         return;
                     bool haveRenderer = m_node->renderer();
                     m_node = parentNode;
index 93c7254..819a6d3 100644 (file)
@@ -466,7 +466,7 @@ VisiblePosition VisiblePosition::honorEditingBoundaryAtOrBefore(const VisiblePos
     auto* highestRoot = highestEditableRoot(deepEquivalent());
     
     // Return empty position if pos is not somewhere inside the editable region containing this position
-    if (highestRoot && !position.deepEquivalent().deprecatedNode()->isDescendantOf(highestRoot)) {
+    if (highestRoot && !position.deepEquivalent().deprecatedNode()->isDescendantOf(*highestRoot)) {
         if (reachedBoundary)
             *reachedBoundary = true;
         return VisiblePosition();
@@ -503,7 +503,7 @@ VisiblePosition VisiblePosition::honorEditingBoundaryAtOrAfter(const VisiblePosi
     auto* highestRoot = highestEditableRoot(deepEquivalent());
     
     // Return empty position if pos is not somewhere inside the editable region containing this position
-    if (highestRoot && !pos.deepEquivalent().deprecatedNode()->isDescendantOf(highestRoot)) {
+    if (highestRoot && !pos.deepEquivalent().deprecatedNode()->isDescendantOf(*highestRoot)) {
         if (reachedBoundary)
             *reachedBoundary = true;
         return VisiblePosition();
index 0506d86..5d85573 100644 (file)
@@ -299,10 +299,10 @@ Position firstEditablePositionAfterPositionInRoot(const Position& position, Cont
         candidate = positionAfterNode(shadowAncestor);
     }
 
-    while (candidate.deprecatedNode() && !isEditablePosition(candidate) && candidate.deprecatedNode()->isDescendantOf(highestRoot))
+    while (candidate.deprecatedNode() && !isEditablePosition(candidate) && candidate.deprecatedNode()->isDescendantOf(*highestRoot))
         candidate = isAtomicNode(candidate.deprecatedNode()) ? positionInParentAfterNode(candidate.deprecatedNode()) : nextVisuallyDistinctCandidate(candidate);
 
-    if (candidate.deprecatedNode() && candidate.deprecatedNode() != highestRoot && !candidate.deprecatedNode()->isDescendantOf(highestRoot))
+    if (candidate.deprecatedNode() && candidate.deprecatedNode() != highestRoot && !candidate.deprecatedNode()->isDescendantOf(*highestRoot))
         return { };
 
     return candidate;
@@ -327,10 +327,10 @@ Position lastEditablePositionBeforePositionInRoot(const Position& position, Cont
         candidate = firstPositionInOrBeforeNode(shadowAncestor);
     }
 
-    while (candidate.deprecatedNode() && !isEditablePosition(candidate) && candidate.deprecatedNode()->isDescendantOf(highestRoot))
+    while (candidate.deprecatedNode() && !isEditablePosition(candidate) && candidate.deprecatedNode()->isDescendantOf(*highestRoot))
         candidate = isAtomicNode(candidate.deprecatedNode()) ? positionInParentBeforeNode(candidate.deprecatedNode()) : previousVisuallyDistinctCandidate(candidate);
     
-    if (candidate.deprecatedNode() && candidate.deprecatedNode() != highestRoot && !candidate.deprecatedNode()->isDescendantOf(highestRoot))
+    if (candidate.deprecatedNode() && candidate.deprecatedNode() != highestRoot && !candidate.deprecatedNode()->isDescendantOf(*highestRoot))
         return { };
     
     return candidate;
@@ -1060,7 +1060,7 @@ VisibleSelection selectionForParagraphIteration(const VisibleSelection& original
     // that we'll want modify is the last one inside the table, not the table itself
     // (a table is itself a paragraph).
     if (auto* table = isFirstPositionAfterTable(endOfSelection)) {
-        if (startOfSelection.deepEquivalent().deprecatedNode()->isDescendantOf(table))
+        if (startOfSelection.deepEquivalent().deprecatedNode()->isDescendantOf(*table))
             newSelection = VisibleSelection(startOfSelection, endOfSelection.previous(CannotCrossEditingBoundary));
     }
     
@@ -1069,7 +1069,7 @@ VisibleSelection selectionForParagraphIteration(const VisibleSelection& original
     // we'll want to modify is the first one inside the table, not the paragraph
     // containing the table itself.
     if (auto* table = isLastPositionBeforeTable(startOfSelection)) {
-        if (endOfSelection.deepEquivalent().deprecatedNode()->isDescendantOf(table))
+        if (endOfSelection.deepEquivalent().deprecatedNode()->isDescendantOf(*table))
             newSelection = VisibleSelection(startOfSelection.next(CannotCrossEditingBoundary), endOfSelection);
     }
     
index c27b1ca..47d22c2 100644 (file)
@@ -410,7 +410,7 @@ Node* StyledMarkupAccumulator::traverseNodesForSerialization(Node* startNode, No
         if (!n->renderer() && !enclosingElementWithTag(firstPositionInOrBeforeNode(n), selectTag)) {
             next = NodeTraversal::nextSkippingChildren(*n);
             // Don't skip over pastEnd.
-            if (pastEnd && pastEnd->isDescendantOf(n))
+            if (pastEnd && pastEnd->isDescendantOf(*n))
                 next = pastEnd;
         } else {
             // Add the node to the markup if we're not skipping the descendants
@@ -452,7 +452,7 @@ Node* StyledMarkupAccumulator::traverseNodesForSerialization(Node* startNode, No
                     if (!parent->renderer())
                         continue;
                     // or b) ancestors that we never encountered during a pre-order traversal starting at startNode:
-                    ASSERT(startNode->isDescendantOf(parent));
+                    ASSERT(startNode->isDescendantOf(*parent));
                     if (shouldEmit)
                         wrapWithNode(*parent);
                     lastClosed = parent;
index eec05b0..3fb4752 100644 (file)
@@ -146,7 +146,7 @@ Element* CachedHTMLCollection<HTMLCollectionClass, traversalType>::namedItem(con
             return nullptr;
 
         if (candidate && collection().elementMatches(*candidate)) {
-            if (traversalType == CollectionTraversalType::ChildrenOnly ? candidate->parentNode() == &root : candidate->isDescendantOf(&root))
+            if (traversalType == CollectionTraversalType::ChildrenOnly ? candidate->parentNode() == &root : candidate->isDescendantOf(root))
                 return candidate;
         }
     }
index 14bdef7..416a2d1 100644 (file)
@@ -537,7 +537,7 @@ unsigned HTMLFormElement::formElementIndex(FormAssociatedElement* associatedElem
     unsigned currentAssociatedElementsAfterIndex = m_associatedElementsAfterIndex;
     ++m_associatedElementsAfterIndex;
 
-    if (!associatedHTMLElement.isDescendantOf(this))
+    if (!associatedHTMLElement.isDescendantOf(*this))
         return currentAssociatedElementsAfterIndex;
 
     // Check for the special case where this element is the very last thing in
index 51197a8..0b2b3f4 100644 (file)
@@ -2051,7 +2051,7 @@ void CanvasRenderingContext2D::drawFocusIfNeededInternal(const Path& path, Eleme
 {
     GraphicsContext* context = drawingContext();
 
-    if (!element.focused() || !state().hasInvertibleTransform || path.isEmpty() || !element.isDescendantOf(&canvas()) || !context)
+    if (!element.focused() || !state().hasInvertibleTransform || path.isEmpty() || !element.isDescendantOf(canvas()) || !context)
         return;
 
     context->drawFocusRing(path, 1, 1, RenderTheme::focusRingColor());
index b4ea647..a0bb191 100644 (file)
@@ -608,7 +608,7 @@ void EventHandler::selectClosestContextualWordOrLinkFromMouseEvent(const MouseEv
     if (targetNode && targetNode->renderer() && m_mouseDownMayStartSelect) {
         VisibleSelection newSelection;
         VisiblePosition pos(targetNode->renderer()->positionForPoint(result.localPoint(), nullptr));
-        if (pos.isNotNull() && pos.deepEquivalent().deprecatedNode()->isDescendantOf(urlElement))
+        if (pos.isNotNull() && pos.deepEquivalent().deprecatedNode()->isDescendantOf(*urlElement))
             newSelection = VisibleSelection::selectionFromContentsOfNode(urlElement);
 
         updateSelectionForMouseDownDispatchingSelectStart(targetNode, expandSelectionToRespectSelectOnMouseDown(*targetNode, newSelection), WordGranularity);
index bb966d6..0741297 100644 (file)
@@ -694,11 +694,11 @@ Element* SVGSVGElement::getElementById(const AtomicString& id)
         return nullptr;
 
     Element* element = treeScope().getElementById(id);
-    if (element && element->isDescendantOf(this))
+    if (element && element->isDescendantOf(*this))
         return element;
     if (treeScope().containsMultipleElementsWithId(id)) {
         for (auto* element : *treeScope().getAllElementsById(id)) {
-            if (element->isDescendantOf(this))
+            if (element->isDescendantOf(*this))
                 return element;
         }
     }