Remove more functions that implicitly use composed tree
https://bugs.webkit.org/show_bug.cgi?id=218544

Reviewed by Ryosuke Niwa.

Source/WebCore:

* dom/Node.cpp:
(WebCore::commonInclusiveAncestor): Changed this into a function template.
* dom/Node.h: Ditto. Note this defaults to the traditional tree, and callers
have all been modified to use composed tree explicitly.

* dom/Position.cpp:
(WebCore::commonInclusiveAncestor): Changed return type to a raw pointer.
Since I created this returning a smart pointer, Ryosuke clarified that our
approach to object lifetime does not involve returning smart pointers in
cases like this. Call commonInclusiveAncestor<ComposedTree>.
(WebCore::documentOrder): Ditto.
* dom/Position.h: Updated return value.

* dom/Range.cpp:
(WebCore::Range::commonAncestorContainer const): Made this non-inline.
Note that this now calls the non-composed-tree version of
commonInclusiveAncestor, which is what we want, but since live ranges
maintain the invariant that both containers are in the same tree, this is
not an observable change.

* dom/Range.h: Made commonAncestorContainer non-inline. Not critical to
optimize out the function call.

* dom/SimpleRange.cpp:
(WebCore::commonInclusiveAncestor): Changed this into a function template.
* dom/SimpleRange.h: Updated for the above.

* editing/ChangeListTypeCommand.cpp:
(WebCore::listConversionTypeForSelection): Use commonInclusiveAncestor<ComposedTree>.
* editing/EditingStyle.cpp:
(WebCore::EditingStyle::styleAtSelectionStart): Ditto.
* editing/Editor.cpp:
(WebCore::Editor::adjustedSelectionRange): Ditto.
* editing/FormatBlockCommand.cpp:
(WebCore::FormatBlockCommand::elementForFormatBlockCommand): Ditto.
* editing/TextManipulationController.cpp:
(WebCore::TextManipulationController::scheduleObservationUpdate): Ditto.
(WebCore::TextManipulationController::replace): Ditto.

* editing/VisiblePosition.cpp:
(WebCore::commonInclusiveAncestor): Added.
(WebCore::intersects): Added.
(WebCore::contains): Added.
(WebCore::intersection): Added.
(WebCore::midpoint): Added.
* editing/VisiblePosition.h: Added functions that work with VisiblePositionRange.
These are used in WebKit editing-related code for iOS, and having these higher
level operations is starting to make that code more readable. This was originally
motivated because it was a use of a function template outside WebCore and I wanted
to sidestep the need to export, which I can't figure out how to do yet. But the
refactoring ended up changing the code completely.

* editing/cocoa/HTMLConverter.mm:
(HTMLConverterCaches::cacheAncestorsOfStartToBeConverted): Updated since
commonInclusiveAncestor does not return a smart pointer any more.
* editing/markup.cpp:
(WebCore::serializePreservingVisualAppearanceInternal): Ditto.

* page/DragController.cpp:
(WebCore::DragController::insertDroppedImagePlaceholdersAtCaret): Use
commonInclusiveAncestor<ComposedTree>.
* page/EventHandler.cpp:
(WebCore::targetNodeForClickEvent): Ditto.
* page/TextIndicator.cpp:
(WebCore::estimatedBackgroundColorForRange): Ditto.
(WebCore::initializeIndicator): Ditto.
* rendering/RenderObject.cpp:
(WebCore::RenderObject::collectSelectionRectsInternal): Ditto.

Source/WebKit:

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::constrainRangeToSelection): Factored this function out of the
requestDocumentEditingContext and also rewrote it to use higher level operations.
(WebKit::WebPage::requestDocumentEditingContext): Refactored to use the new
constrainRangeToSelection.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@269442 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/editing/TextManipulationController.cpp b/Source/WebCore/editing/TextManipulationController.cpp
index e5bd15c..611f733 100644
--- a/Source/WebCore/editing/TextManipulationController.cpp
+++ b/Source/WebCore/editing/TextManipulationController.cpp
@@ -603,7 +603,7 @@
             if (!commonAncestor)
                 commonAncestor = is<ContainerNode>(node.get()) ? node.ptr() : node->parentNode();
             else if (!node->isDescendantOf(commonAncestor.get()))
-                commonAncestor = commonInclusiveAncestor(*commonAncestor, node.get());
+                commonAncestor = commonInclusiveAncestor<ComposedTree>(*commonAncestor, node.get());
         }
 
         auto start = firstPositionInOrBeforeNode(commonAncestor.get());
@@ -825,7 +825,7 @@
         if (!commonAncestor)
             commonAncestor = parentNode;
         else if (!parentNode->isDescendantOf(commonAncestor.get())) {
-            commonAncestor = commonInclusiveAncestor(*commonAncestor, *parentNode);
+            commonAncestor = commonInclusiveAncestor<ComposedTree>(*commonAncestor, *parentNode);
             ASSERT(commonAncestor);
         }
     }