<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[265190] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/265190">265190</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2020-08-02 17:47:52 -0700 (Sun, 02 Aug 2020)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove some member functions of Range and many calls to createLiveRange
https://bugs.webkit.org/show_bug.cgi?id=215070

Reviewed by Sam Weinig.

Source/WebCore:

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::nextBoundary): Remove createLiveRange.
(WebCore::AXObjectCache::previousBoundary): Ditto.

* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper _convertToNSRange:]): Take SimpleRange.
(-[WebAccessibilityObjectWrapper positionForTextMarker:]): Remove createLiveRange.
(-[WebAccessibilityObjectWrapper textRectsFromMarkers:withText:]): Ditto.

* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper _convertToNSRange:]): Take SimpleRange.
(-[WebAccessibilityObjectWrapper _indexForTextMarker:]): Remove createLiveRange.
(-[WebAccessibilityObjectWrapper _textMarkerForIndex:]): Ditto.

* dom/DocumentMarkerController.cpp:
(WebCore::updateRenderedRectsForMarker): Renamed range to makeSimpleRange.
(WebCore::makeSimpleRange): Ditto.
* dom/DocumentMarkerController.h: Update for the above.

* dom/Range.cpp:
(WebCore::Range::text const): Use makeSimpleRange.
(WebCore::Range::shadowRoot const): Deleted.
(WebCore::intervalsSufficientlyOverlap): Deleted.
(WebCore::adjustLineHeightOfSelectionRects): Deleted.
(WebCore::coalesceSelectionRects): Deleted.
(WebCore::Range::collectSelectionRectsWithoutUnionInteriorLines const): Deleted.
(WebCore::Range::collectSelectionRects const): Deleted.
* dom/Range.h: Update for the above. Also make pastLastNode private since it is
only used inside the Range class's implementation.

* dom/SimpleRange.cpp:
(WebCore::SimpleRange::SimpleRange): Removed overload that takes a Range.
* dom/SimpleRange.h: Update for the above. Removed both constructor overloads
that take a Range.

* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::timerFired): Remove createLiveRange.
(WebCore::AlternativeTextController::respondToMarkerAtEndOfWord): Use
makeSimpleRange.
(WebCore::AlternativeTextController::applyAlternativeTextToRange):
Remove createLiveRange.

* editing/EditingStyle.cpp:
(WebCore::EditingStyle::styleAtSelectionStart): Remove createLiveRange.
* editing/Editor.cpp:
(WebCore::Editor::performCutOrCopy): Ditto.
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): Ditto.
(WebCore::Editor::replaceRangeForSpellChecking): Ditto.
(WebCore::correctSpellcheckingPreservingTextCheckingParagraph): Ditto.
(WebCore::Editor::changeBackToReplacedString): Ditto.
(WebCore::Editor::countMatchesForText): Ditto.
* editing/InsertListCommand.cpp:
(WebCore::InsertListCommand::doApply): Ditto.
(WebCore::InsertListCommand::doApplyForSingleParagraph): Change out
argument type to SimpleRange.
* editing/InsertListCommand.h: Update for above.

* editing/SpellChecker.cpp:
(WebCore::SpellChecker::isCheckable const): Rewrite questionable logic
to use intersectingNodes instead of firstNode.

* editing/TextCheckingHelper.cpp:
(WebCore::TextCheckingHelper::findUngrammaticalPhrases const): Remove createLiveRange.
* editing/TypingCommand.cpp:
(WebCore::TypingCommand::deleteKeyPressed): Ditto.
(WebCore::TypingCommand::forwardDeleteKeyPressed): Ditto.
* editing/markup.cpp:
(WebCore::createFragmentFromText): Ditto.

* editing/ios/EditorIOS.mm:
(WebCore::Editor::setTextAsChildOfElement): Use makeRangeSelectingNodeContents.

* editing/win/EditorWin.cpp:
(WebCore::Editor::pasteWithPasteboard): Remove createLiveRange.

* page/DOMSelection.cpp:
(WebCore::DOMSelection::addRange): Use makeSimpleRange.
(WebCore::DOMSelection::deleteFromDocument): Remove createLiveRange.

* page/DragController.cpp:
(WebCore::documentFragmentFromDragData): Take SimpleRange.
(WebCore::DragController::concludeEditDrag): Remove createLiveRange.
(WebCore::DragController::startDrag): Ditto.

* page/TextIndicator.cpp:
(WebCore::selectionRects): Deleted.
(WebCore::initializeIndicator): Call collectSelectionRects directly here,
avoiding createLiveRange and using map to convert from Vector<SelectionRect>
to Vector<FloatRect>.

* page/ios/FrameIOS.mm:
(WebCore::Frame::interpretationsForCurrentRoot const): Use makeSimpleRange.

* platform/DragImage.cpp:
(WebCore::createDragImageForRange): Take SimpleRange.
* platform/DragImage.h: Update createDragImageForRange to take SimpleRange.

* platform/Pasteboard.h: Updated Windows-only layering-violating functions
to take SimpleRange.

* platform/ios/DragImageIOS.mm:
(WebCore::createDragImageForRange): Take SimpleRange.

* platform/win/PasteboardWin.cpp:
(WebCore::Pasteboard::writeRangeToDataObject): Take SimpleRange.
(WebCore::Pasteboard::writeSelection): Ditto.
(WebCore::Pasteboard::documentFragment): Ditto.

* rendering/RenderObject.cpp:
(WebCore::intervalsSufficientlyOverlap): Added. Moved from Range. Mostly unchanged
but uses SimpleRange now instead of a live range, and intersectingNodes instead of
a loop using firstNode and pastLastNode.
(WebCore::adjustLineHeightOfSelectionRects): Ditto.
(WebCore::coalesceSelectionRects): Ditto.
(WebCore::RenderObject::collectSelectionRectsWithoutUnionInteriorLines): Ditto.
(WebCore::RenderObject::collectSelectionRectsInternal): Ditto.
(WebCore::RenderObject::collectSelectionRects): Ditto.
* rendering/RenderObject.h: Update for above.

* testing/Internals.cpp:
(WebCore::Internals::markerRangeForNode): Use makeSimplRange.
(WebCore::Internals::locationFromRange): Ditto.
(WebCore::Internals::lengthFromRange): Ditto.
(WebCore::Internals::rangeAsTextUsingBackwardsTextIterator): Ditto.
(WebCore::Internals::subrange): Ditto.
(WebCore::Internals::rangeOfStringNearLocation): Ditto.
(WebCore::Internals::textIndicatorForRange): Ditto.

Source/WebKit:

* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInRangeHandle.mm:
(-[WKWebProcessPlugInRangeHandle detectDataWithTypes:context:]): Use makeSimpleRange.
* WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp:
(API::PageOverlayClientImpl::actionContextForResultAtPoint): Ditto.
* WebProcess/InjectedBundle/API/mac/WKDOMRange.mm:
(-[WKDOMRange textRects]): Ditto.
* WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm:
(-[WKDOMTextIterator initWithRange:]): Ditto.
* WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
(WebKit::InjectedBundleRangeHandle::renderedImage): Ditto.

* WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::performDictionaryLookupAtLocation): Remove createLiveRange.
(WebKit::WebPage::performDictionaryLookupForSelection): Ditto.
* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::updateFindUIAfterPageScroll): Ditto.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getPlatformEditorState const): Ditto.
(WebKit::WebPage::computeAndSendEditDragSnapshot): Ditto.
(WebKit::WebPage::getRectsForGranularityWithSelectionOffset): Ditto.
(WebKit::WebPage::getRectsAtSelectionOffsetWithText): Ditto.
(WebKit::WebPage::requestAutocorrectionData): Ditto.

Source/WebKitLegacy/ios:

* WebCoreSupport/WebFrameIOS.mm:
(-[WebFrame selectionRectsForCoreRange:]): Remove createLiveRange.
(-[WebFrame selectionRectsForRange:]): Use makeSimpleRange.
* WebCoreSupport/WebVisiblePosition.mm:
(-[WebVisiblePosition enclosingRangeWithDictationPhraseAlternatives:]): Ditto.
(-[WebVisiblePosition enclosingRangeWithCorrectionIndicator]): Ditto.
(+[DOMRange rangeForFirstPosition:second:]): Rename firstVP/secondVP
to firstPosition/secondPosition.

Source/WebKitLegacy/mac:

* DOM/DOM.mm:
(-[DOMRange renderedImageForcingBlackText:renderedImageForcingBlackText:]):
Use makeSimpleRange.
(-[DOMRange textRects]): Ditto.

* DOM/DOMDocument.mm: Update includes.
* DOM/DOMRange.mm: Ditto.
* DOM/DOMRangeInternal.h: Ditto.
* DOM/DOMUIKitExtensions.mm: Ditto.
* DOM/DOMUtility.mm: Ditto.

* DOM/WebDOMOperations.mm:
(-[DOMRange webArchive]): Use makeSimpleRange.
(-[DOMRange markupString]): Ditto.

* WebView/WebFrame.mm:
(-[WebFrame _stringForRange:]): Use makeSimpleRange.
(-[WebFrame _convertToDOMRange:]): Return a SimpleRange.
(-[WebFrame _convertToDOMRange:rangeIsRelativeTo:]): Ditto.
(-[WebFrame _convertNSRangeToDOMRange:]): Update for above.
(-[WebFrame _convertDOMRangeToNSRange:]): Use makeSimpleRange.
(-[WebFrame _selectNSRange:]): Update for above.
(-[WebFrame selectWithoutClosingTypingNSRange:]): Ditto.
(-[WebFrame getDictationResultRanges:andMetadatas:]): Use makeSimpleRange.
(-[WebFrame dictationResultMetadataForRange:]): Ditto.
* WebView/WebFrameInternal.h: Update for above.

* WebView/WebHTMLView.mm:
(-[WebHTMLView _documentFragmentFromPasteboard:forType:inContext:subresources:]):
Use makeSimpleRange.
(-[WebHTMLView attributedSubstringFromRange:]): Use auto.
(-[WebHTMLView _attributedStringFromDOMRange:]): Deleted.
(-[WebHTMLView attributedString]): Rewrote to use SimpleRange consistently.
(-[WebHTMLView selectedAttributedString]): Ditto.

* WebView/WebImmediateActionController.mm:
(-[WebImmediateActionController _animationControllerForDataDetectedText]):
Use makeSimpleRange.
* WebView/WebTextIterator.mm:
(-[WebTextIterator initWithRange:]): Ditto.

* WebView/WebView.mm:
(-[WebView _didConcludeEditDrag]): Remove createLiveRange.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAXObjectCachecpp">trunk/Source/WebCore/accessibility/AXObjectCache.cpp</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityiosWebAccessibilityObjectWrapperIOSmm">trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreaccessibilitymacWebAccessibilityObjectWrapperMacmm">trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm</a></li>
<li><a href="#trunkSourceWebCoredomDocumentMarkerControllercpp">trunk/Source/WebCore/dom/DocumentMarkerController.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumentMarkerControllerh">trunk/Source/WebCore/dom/DocumentMarkerController.h</a></li>
<li><a href="#trunkSourceWebCoredomRangecpp">trunk/Source/WebCore/dom/Range.cpp</a></li>
<li><a href="#trunkSourceWebCoredomRangeh">trunk/Source/WebCore/dom/Range.h</a></li>
<li><a href="#trunkSourceWebCoredomSimpleRangecpp">trunk/Source/WebCore/dom/SimpleRange.cpp</a></li>
<li><a href="#trunkSourceWebCoredomSimpleRangeh">trunk/Source/WebCore/dom/SimpleRange.h</a></li>
<li><a href="#trunkSourceWebCoreeditingAlternativeTextControllercpp">trunk/Source/WebCore/editing/AlternativeTextController.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingEditingStylecpp">trunk/Source/WebCore/editing/EditingStyle.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorcpp">trunk/Source/WebCore/editing/Editor.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingInsertListCommandcpp">trunk/Source/WebCore/editing/InsertListCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingInsertListCommandh">trunk/Source/WebCore/editing/InsertListCommand.h</a></li>
<li><a href="#trunkSourceWebCoreeditingSpellCheckercpp">trunk/Source/WebCore/editing/SpellChecker.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingTextCheckingHelpercpp">trunk/Source/WebCore/editing/TextCheckingHelper.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingTypingCommandcpp">trunk/Source/WebCore/editing/TypingCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingiosEditorIOSmm">trunk/Source/WebCore/editing/ios/EditorIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreeditingmarkupcpp">trunk/Source/WebCore/editing/markup.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingwinEditorWincpp">trunk/Source/WebCore/editing/win/EditorWin.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDOMSelectioncpp">trunk/Source/WebCore/page/DOMSelection.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDragControllercpp">trunk/Source/WebCore/page/DragController.cpp</a></li>
<li><a href="#trunkSourceWebCorepageTextIndicatorcpp">trunk/Source/WebCore/page/TextIndicator.cpp</a></li>
<li><a href="#trunkSourceWebCorepageiosFrameIOSmm">trunk/Source/WebCore/page/ios/FrameIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformDragImagecpp">trunk/Source/WebCore/platform/DragImage.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformDragImageh">trunk/Source/WebCore/platform/DragImage.h</a></li>
<li><a href="#trunkSourceWebCoreplatformPasteboardh">trunk/Source/WebCore/platform/Pasteboard.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosDragImageIOSmm">trunk/Source/WebCore/platform/ios/DragImageIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformwinPasteboardWincpp">trunk/Source/WebCore/platform/win/PasteboardWin.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjectcpp">trunk/Source/WebCore/rendering/RenderObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjecth">trunk/Source/WebCore/rendering/RenderObject.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitWebProcessInjectedBundleAPICocoaWKWebProcessPlugInRangeHandlemm">trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInRangeHandle.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessInjectedBundleAPIcWKBundlePageOverlaycpp">trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessInjectedBundleAPImacWKDOMRangemm">trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessInjectedBundleAPImacWKDOMTextIteratormm">trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessInjectedBundleDOMInjectedBundleRangeHandlecpp">trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageCocoaWebPageCocoamm">trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageFindControllercpp">trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageiosWebPageIOSmm">trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
<li><a href="#trunkSourceWebKitLegacyiosChangeLog">trunk/Source/WebKitLegacy/ios/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitLegacyiosWebCoreSupportWebFrameIOSmm">trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebFrameIOS.mm</a></li>
<li><a href="#trunkSourceWebKitLegacyiosWebCoreSupportWebVisiblePositionmm">trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebVisiblePosition.mm</a></li>
<li><a href="#trunkSourceWebKitLegacymacChangeLog">trunk/Source/WebKitLegacy/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitLegacymacDOMDOMmm">trunk/Source/WebKitLegacy/mac/DOM/DOM.mm</a></li>
<li><a href="#trunkSourceWebKitLegacymacDOMDOMDocumentmm">trunk/Source/WebKitLegacy/mac/DOM/DOMDocument.mm</a></li>
<li><a href="#trunkSourceWebKitLegacymacDOMDOMRangemm">trunk/Source/WebKitLegacy/mac/DOM/DOMRange.mm</a></li>
<li><a href="#trunkSourceWebKitLegacymacDOMDOMRangeInternalh">trunk/Source/WebKitLegacy/mac/DOM/DOMRangeInternal.h</a></li>
<li><a href="#trunkSourceWebKitLegacymacDOMDOMUIKitExtensionsmm">trunk/Source/WebKitLegacy/mac/DOM/DOMUIKitExtensions.mm</a></li>
<li><a href="#trunkSourceWebKitLegacymacDOMDOMUtilitymm">trunk/Source/WebKitLegacy/mac/DOM/DOMUtility.mm</a></li>
<li><a href="#trunkSourceWebKitLegacymacDOMWebDOMOperationsmm">trunk/Source/WebKitLegacy/mac/DOM/WebDOMOperations.mm</a></li>
<li><a href="#trunkSourceWebKitLegacymacWebViewWebFramemm">trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm</a></li>
<li><a href="#trunkSourceWebKitLegacymacWebViewWebFrameInternalh">trunk/Source/WebKitLegacy/mac/WebView/WebFrameInternal.h</a></li>
<li><a href="#trunkSourceWebKitLegacymacWebViewWebHTMLViewmm">trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm</a></li>
<li><a href="#trunkSourceWebKitLegacymacWebViewWebImmediateActionControllermm">trunk/Source/WebKitLegacy/mac/WebView/WebImmediateActionController.mm</a></li>
<li><a href="#trunkSourceWebKitLegacymacWebViewWebTextIteratormm">trunk/Source/WebKitLegacy/mac/WebView/WebTextIterator.mm</a></li>
<li><a href="#trunkSourceWebKitLegacymacWebViewWebViewmm">trunk/Source/WebKitLegacy/mac/WebView/WebView.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/ChangeLog      2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -1,3 +1,138 @@
</span><ins>+2020-08-02  Darin Adler  <darin@apple.com>
+
+        Remove some member functions of Range and many calls to createLiveRange
+        https://bugs.webkit.org/show_bug.cgi?id=215070
+
+        Reviewed by Sam Weinig.
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::nextBoundary): Remove createLiveRange.
+        (WebCore::AXObjectCache::previousBoundary): Ditto.
+
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper _convertToNSRange:]): Take SimpleRange.
+        (-[WebAccessibilityObjectWrapper positionForTextMarker:]): Remove createLiveRange.
+        (-[WebAccessibilityObjectWrapper textRectsFromMarkers:withText:]): Ditto.
+
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper _convertToNSRange:]): Take SimpleRange.
+        (-[WebAccessibilityObjectWrapper _indexForTextMarker:]): Remove createLiveRange.
+        (-[WebAccessibilityObjectWrapper _textMarkerForIndex:]): Ditto.
+
+        * dom/DocumentMarkerController.cpp:
+        (WebCore::updateRenderedRectsForMarker): Renamed range to makeSimpleRange.
+        (WebCore::makeSimpleRange): Ditto.
+        * dom/DocumentMarkerController.h: Update for the above.
+
+        * dom/Range.cpp:
+        (WebCore::Range::text const): Use makeSimpleRange.
+        (WebCore::Range::shadowRoot const): Deleted.
+        (WebCore::intervalsSufficientlyOverlap): Deleted.
+        (WebCore::adjustLineHeightOfSelectionRects): Deleted.
+        (WebCore::coalesceSelectionRects): Deleted.
+        (WebCore::Range::collectSelectionRectsWithoutUnionInteriorLines const): Deleted.
+        (WebCore::Range::collectSelectionRects const): Deleted.
+        * dom/Range.h: Update for the above. Also make pastLastNode private since it is
+        only used inside the Range class's implementation.
+
+        * dom/SimpleRange.cpp:
+        (WebCore::SimpleRange::SimpleRange): Removed overload that takes a Range.
+        * dom/SimpleRange.h: Update for the above. Removed both constructor overloads
+        that take a Range.
+
+        * editing/AlternativeTextController.cpp:
+        (WebCore::AlternativeTextController::timerFired): Remove createLiveRange.
+        (WebCore::AlternativeTextController::respondToMarkerAtEndOfWord): Use
+        makeSimpleRange.
+        (WebCore::AlternativeTextController::applyAlternativeTextToRange):
+        Remove createLiveRange.
+
+        * editing/EditingStyle.cpp:
+        (WebCore::EditingStyle::styleAtSelectionStart): Remove createLiveRange.
+        * editing/Editor.cpp:
+        (WebCore::Editor::performCutOrCopy): Ditto.
+        (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): Ditto.
+        (WebCore::Editor::replaceRangeForSpellChecking): Ditto.
+        (WebCore::correctSpellcheckingPreservingTextCheckingParagraph): Ditto.
+        (WebCore::Editor::changeBackToReplacedString): Ditto.
+        (WebCore::Editor::countMatchesForText): Ditto.
+        * editing/InsertListCommand.cpp:
+        (WebCore::InsertListCommand::doApply): Ditto.
+        (WebCore::InsertListCommand::doApplyForSingleParagraph): Change out
+        argument type to SimpleRange.
+        * editing/InsertListCommand.h: Update for above.
+
+        * editing/SpellChecker.cpp:
+        (WebCore::SpellChecker::isCheckable const): Rewrite questionable logic
+        to use intersectingNodes instead of firstNode.
+
+        * editing/TextCheckingHelper.cpp:
+        (WebCore::TextCheckingHelper::findUngrammaticalPhrases const): Remove createLiveRange.
+        * editing/TypingCommand.cpp:
+        (WebCore::TypingCommand::deleteKeyPressed): Ditto.
+        (WebCore::TypingCommand::forwardDeleteKeyPressed): Ditto.
+        * editing/markup.cpp:
+        (WebCore::createFragmentFromText): Ditto.
+
+        * editing/ios/EditorIOS.mm:
+        (WebCore::Editor::setTextAsChildOfElement): Use makeRangeSelectingNodeContents.
+
+        * editing/win/EditorWin.cpp:
+        (WebCore::Editor::pasteWithPasteboard): Remove createLiveRange.
+
+        * page/DOMSelection.cpp:
+        (WebCore::DOMSelection::addRange): Use makeSimpleRange.
+        (WebCore::DOMSelection::deleteFromDocument): Remove createLiveRange.
+
+        * page/DragController.cpp:
+        (WebCore::documentFragmentFromDragData): Take SimpleRange.
+        (WebCore::DragController::concludeEditDrag): Remove createLiveRange.
+        (WebCore::DragController::startDrag): Ditto.
+
+        * page/TextIndicator.cpp:
+        (WebCore::selectionRects): Deleted.
+        (WebCore::initializeIndicator): Call collectSelectionRects directly here,
+        avoiding createLiveRange and using map to convert from Vector<SelectionRect>
+        to Vector<FloatRect>.
+
+        * page/ios/FrameIOS.mm:
+        (WebCore::Frame::interpretationsForCurrentRoot const): Use makeSimpleRange.
+
+        * platform/DragImage.cpp:
+        (WebCore::createDragImageForRange): Take SimpleRange.
+        * platform/DragImage.h: Update createDragImageForRange to take SimpleRange.
+
+        * platform/Pasteboard.h: Updated Windows-only layering-violating functions
+        to take SimpleRange.
+
+        * platform/ios/DragImageIOS.mm:
+        (WebCore::createDragImageForRange): Take SimpleRange.
+
+        * platform/win/PasteboardWin.cpp:
+        (WebCore::Pasteboard::writeRangeToDataObject): Take SimpleRange.
+        (WebCore::Pasteboard::writeSelection): Ditto.
+        (WebCore::Pasteboard::documentFragment): Ditto.
+
+        * rendering/RenderObject.cpp:
+        (WebCore::intervalsSufficientlyOverlap): Added. Moved from Range. Mostly unchanged
+        but uses SimpleRange now instead of a live range, and intersectingNodes instead of
+        a loop using firstNode and pastLastNode.
+        (WebCore::adjustLineHeightOfSelectionRects): Ditto.
+        (WebCore::coalesceSelectionRects): Ditto.
+        (WebCore::RenderObject::collectSelectionRectsWithoutUnionInteriorLines): Ditto.
+        (WebCore::RenderObject::collectSelectionRectsInternal): Ditto.
+        (WebCore::RenderObject::collectSelectionRects): Ditto.
+        * rendering/RenderObject.h: Update for above.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::markerRangeForNode): Use makeSimplRange.
+        (WebCore::Internals::locationFromRange): Ditto.
+        (WebCore::Internals::lengthFromRange): Ditto.
+        (WebCore::Internals::rangeAsTextUsingBackwardsTextIterator): Ditto.
+        (WebCore::Internals::subrange): Ditto.
+        (WebCore::Internals::rangeOfStringNearLocation): Ditto.
+        (WebCore::Internals::textIndicatorForRange): Ditto.
+
</ins><span class="cx"> 2020-08-02  Wenson Hsieh  <wenson_hsieh@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Table data is incorrectly translated in some articles on en.wikipedia.org
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAXObjectCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp     2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp        2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -2622,7 +2622,7 @@
</span><span class="cx">         auto backwardsScanRange = makeRangeSelectingNodeContents(boundary->document());
</span><span class="cx">         if (!setRangeStartOrEndWithCharacterOffset(backwardsScanRange, characterOffset, false))
</span><span class="cx">             return { };
</span><del>-        prefixLength = prefixLengthForRange(createLiveRange(backwardsScanRange), string);
</del><ins>+        prefixLength = prefixLengthForRange(backwardsScanRange, string);
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     if (!setRangeStartOrEndWithCharacterOffset(searchRange, characterOffset, true))
</span><span class="lines">@@ -2681,7 +2681,7 @@
</span><span class="cx">         forwardsScanRange.start = *afterBoundary;
</span><span class="cx">         if (!setRangeStartOrEndWithCharacterOffset(forwardsScanRange, characterOffset, true))
</span><span class="cx">             return { };
</span><del>-        suffixLength = suffixLengthForRange(createLiveRange(forwardsScanRange), string);
</del><ins>+        suffixLength = suffixLengthForRange(forwardsScanRange, string);
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     if (!setRangeStartOrEndWithCharacterOffset(searchRange, characterOffset, false))
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityiosWebAccessibilityObjectWrapperIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm       2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm  2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -2338,13 +2338,9 @@
</span><span class="cx">     return [array autorelease];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (NSRange)_convertToNSRange:(Range *)liveRange
</del><ins>+// FIXME: No reason for this to be a method instead of a function.
+- (NSRange)_convertToNSRange:(const SimpleRange&)range
</ins><span class="cx"> {
</span><del>-    if (!liveRange)
-        return NSMakeRange(NSNotFound, 0);
-
-    auto range = SimpleRange { *liveRange };
-
</del><span class="cx">     auto& document = range.start.document();
</span><span class="cx">     auto* frame = document.frame();
</span><span class="cx">     if (!frame)
</span><span class="lines">@@ -2398,7 +2394,9 @@
</span><span class="cx">         CharacterOffset characterOffset = [marker characterOffset];
</span><span class="cx">         // Create a collapsed range from the CharacterOffset object.
</span><span class="cx">         auto range = cache->rangeForUnorderedCharacterOffsets(characterOffset, characterOffset);
</span><del>-        return [self _convertToNSRange:createLiveRange(range).get()].location;
</del><ins>+        if (!range)
+            return NSNotFound;
+        return [self _convertToNSRange:*range].location;
</ins><span class="cx">     }
</span><span class="cx">     return NSNotFound;
</span><span class="cx"> }
</span><span class="lines">@@ -2756,8 +2754,7 @@
</span><span class="cx">     if (!range || range->collapsed())
</span><span class="cx">         return nil;
</span><span class="cx"> 
</span><del>-    Vector<WebCore::SelectionRect> rects;
-    createLiveRange(range)->collectSelectionRectsWithoutUnionInteriorLines(rects);
</del><ins>+    auto rects = RenderObject::collectSelectionRectsWithoutUnionInteriorLines(*range);
</ins><span class="cx">     if (rects.isEmpty())
</span><span class="cx">         return nil;
</span><span class="cx">     return createNSArray(rects, [&] (auto& rect) {
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilitymacWebAccessibilityObjectWrapperMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm       2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm  2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -3621,13 +3621,11 @@
</span><span class="cx">     return [self doAXAttributedStringForTextMarkerRange:[self textMarkerRangeFromRange:webRange] spellCheck:YES];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (NSRange)_convertToNSRange:(Range*)range
</del><ins>+// FIXME: No reason for this to be a method instead of a function; can get document from range.
+- (NSRange)_convertToNSRange:(const SimpleRange&)range
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(isMainThread());
</span><span class="cx">     
</span><del>-    if (!range)
-        return NSMakeRange(NSNotFound, 0);
-    
</del><span class="cx">     auto document = self.axBackingObject->document();
</span><span class="cx">     if (!document)
</span><span class="cx">         return NSMakeRange(NSNotFound, 0);
</span><span class="lines">@@ -3636,7 +3634,7 @@
</span><span class="cx">     if (!documentElement)
</span><span class="cx">         return NSMakeRange(NSNotFound, 0);
</span><span class="cx"> 
</span><del>-    return characterRange(makeBoundaryPointBeforeNodeContents(*documentElement), *range);
</del><ins>+    return characterRange(makeBoundaryPointBeforeNodeContents(*documentElement), range);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (NSInteger)_indexForTextMarker:(id)marker
</span><span class="lines">@@ -3646,9 +3644,10 @@
</span><span class="cx">     
</span><span class="cx">     if (AXObjectCache* cache = self.axBackingObject->axObjectCache()) {
</span><span class="cx">         CharacterOffset characterOffset = [self characterOffsetForTextMarker:marker];
</span><del>-        // Create a collapsed range from the CharacterOffset object.
</del><span class="cx">         auto range = cache->rangeForUnorderedCharacterOffsets(characterOffset, characterOffset);
</span><del>-        return [self _convertToNSRange:createLiveRange(range).get()].location;
</del><ins>+        if (!range)
+            return NSNotFound;
+        return [self _convertToNSRange:*range].location;
</ins><span class="cx">     }
</span><span class="cx">     return NSNotFound;
</span><span class="cx"> }
</span><span class="lines">@@ -3670,7 +3669,7 @@
</span><span class="cx">         return nil;
</span><span class="cx"> 
</span><span class="cx">     auto boundary = resolveCharacterLocation(makeRangeSelectingNodeContents(*documentElement), textIndex);
</span><del>-    auto characterOffset = cache->startOrEndCharacterOffsetForRange(createLiveRange({ boundary, boundary }), true);
</del><ins>+    auto characterOffset = cache->startOrEndCharacterOffsetForRange(makeSimpleRange(boundary), true);
</ins><span class="cx">     return [self textMarkerForCharacterOffset:characterOffset];
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentMarkerControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DocumentMarkerController.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DocumentMarkerController.cpp    2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/dom/DocumentMarkerController.cpp       2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -105,7 +105,7 @@
</span><span class="cx"> static void updateRenderedRectsForMarker(RenderedDocumentMarker& marker, Node& node)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!node.document().view() || !node.document().view()->needsLayout());
</span><del>-    marker.setUnclippedAbsoluteRects(boundingBoxes(RenderObject::absoluteTextQuads(range(node, marker), true)));
</del><ins>+    marker.setUnclippedAbsoluteRects(boundingBoxes(RenderObject::absoluteTextQuads(makeSimpleRange(node, marker), true)));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void DocumentMarkerController::invalidateRectsForAllMarkers()
</span><span class="lines">@@ -662,7 +662,7 @@
</span><span class="cx">     range.start.container->document().markers().removeMarkers(range, types, policy);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SimpleRange range(Node& node, const DocumentMarker& marker)
</del><ins>+SimpleRange makeSimpleRange(Node& node, const DocumentMarker& marker)
</ins><span class="cx"> {
</span><span class="cx">     unsigned startOffset = marker.startOffset();
</span><span class="cx">     unsigned endOffset = marker.endOffset();
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentMarkerControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DocumentMarkerController.h (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DocumentMarkerController.h      2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/dom/DocumentMarkerController.h 2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -115,7 +115,7 @@
</span><span class="cx"> void addMarker(Text&, unsigned startOffset, unsigned length, DocumentMarker::MarkerType, DocumentMarker::Data&& = { });
</span><span class="cx"> void removeMarkers(const SimpleRange&, OptionSet<DocumentMarker::MarkerType> = DocumentMarker::allMarkers(), RemovePartiallyOverlappingMarker = RemovePartiallyOverlappingMarker::No);
</span><span class="cx"> 
</span><del>-WEBCORE_EXPORT SimpleRange range(Node&, const DocumentMarker&);
</del><ins>+WEBCORE_EXPORT SimpleRange makeSimpleRange(Node&, const DocumentMarker&);
</ins><span class="cx"> 
</span><span class="cx"> inline bool DocumentMarkerController::hasMarkers() const
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoredomRangecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Range.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Range.cpp       2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/dom/Range.cpp  2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -888,7 +888,7 @@
</span><span class="cx">     // FIXME: As with innerText, we'd like this to work even if there are no render objects.
</span><span class="cx">     startContainer().document().updateLayout();
</span><span class="cx"> 
</span><del>-    return plainText(*this);
</del><ins>+    return plainText(makeSimpleRange(*this));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // https://w3c.github.io/DOM-Parsing/#widl-Range-createContextualFragment-DocumentFragment-DOMString-fragment
</span><span class="lines">@@ -1069,11 +1069,6 @@
</span><span class="cx">     return NodeTraversal::nextSkippingChildren(startContainer());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ShadowRoot* Range::shadowRoot() const
-{
-    return startContainer().containingShadowRoot();
-}
-
</del><span class="cx"> Node* Range::pastLastNode() const
</span><span class="cx"> {
</span><span class="cx">     if (endContainer().isCharacterDataNode())
</span><span class="lines">@@ -1144,273 +1139,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS_FAMILY)
-static bool intervalsSufficientlyOverlap(int startA, int endA, int startB, int endB)
-{
-    if (endA <= startA || endB <= startB)
-        return false;
-
-    const float sufficientOverlap = .75;
-
-    int lengthA = endA - startA;
-    int lengthB = endB - startB;
-
-    int maxStart = std::max(startA, startB);
-    int minEnd = std::min(endA, endB);
-
-    if (maxStart > minEnd)
-        return false;
-
-    return minEnd - maxStart >= sufficientOverlap * std::min(lengthA, lengthB);
-}
-
-static inline void adjustLineHeightOfSelectionRects(Vector<SelectionRect>& rects, size_t numberOfRects, int lineNumber, int lineTop, int lineHeight)
-{
-    ASSERT(rects.size() >= numberOfRects);
-    for (size_t i = numberOfRects; i; ) {
-        --i;
-        if (rects[i].lineNumber())
-            break;
-        rects[i].setLineNumber(lineNumber);
-        rects[i].setLogicalTop(lineTop);
-        rects[i].setLogicalHeight(lineHeight);
-    }
-}
-
-static SelectionRect coalesceSelectionRects(const SelectionRect& original, const SelectionRect& previous)
-{
-    SelectionRect result(unionRect(previous.rect(), original.rect()), original.isHorizontal(), original.pageNumber());
-    result.setDirection(original.containsStart() || original.containsEnd() ? original.direction() : previous.direction());
-    result.setContainsStart(previous.containsStart() || original.containsStart());
-    result.setContainsEnd(previous.containsEnd() || original.containsEnd());
-    result.setIsFirstOnLine(previous.isFirstOnLine() || original.isFirstOnLine());
-    result.setIsLastOnLine(previous.isLastOnLine() || original.isLastOnLine());
-    return result;
-}
-
-// This function is similar in spirit to addLineBoxRects, but annotates the returned rectangles
-// with additional state which helps iOS draw selections in its unique way.
-int Range::collectSelectionRectsWithoutUnionInteriorLines(Vector<SelectionRect>& rects) const
-{
-    auto& startContainer = this->startContainer();
-    auto& endContainer = this->endContainer();
-    int startOffset = m_start.offset();
-    int endOffset = m_end.offset();
-
-    Vector<SelectionRect> newRects;
-    Node* stopNode = pastLastNode();
-    bool hasFlippedWritingMode = startContainer.renderer() && startContainer.renderer()->style().isFlippedBlocksWritingMode();
-    bool containsDifferentWritingModes = false;
-    for (Node* node = firstNode(); node && node != stopNode; node = NodeTraversal::next(*node)) {
-        RenderObject* renderer = node->renderer();
-        // Only ask leaf render objects for their line box rects.
-        if (renderer && !renderer->firstChildSlow() && renderer->style().userSelect() != UserSelect::None) {
-            bool isStartNode = renderer->node() == &startContainer;
-            bool isEndNode = renderer->node() == &endContainer;
-            if (hasFlippedWritingMode != renderer->style().isFlippedBlocksWritingMode())
-                containsDifferentWritingModes = true;
-            // FIXME: Sending 0 for the startOffset is a weird way of telling the renderer that the selection
-            // doesn't start inside it, since we'll also send 0 if the selection *does* start in it, at offset 0.
-            //
-            // FIXME: Selection endpoints aren't always inside leaves, and we only build SelectionRects for leaves,
-            // so we can't accurately determine which SelectionRects contain the selection start and end using
-            // only the offsets of the start and end. We need to pass the whole Range.
-            int beginSelectionOffset = isStartNode ? startOffset : 0;
-            int endSelectionOffset = isEndNode ? endOffset : std::numeric_limits<int>::max();
-            renderer->collectSelectionRects(newRects, beginSelectionOffset, endSelectionOffset);
-            for (auto& selectionRect : newRects) {
-                if (selectionRect.containsStart() && !isStartNode)
-                    selectionRect.setContainsStart(false);
-                if (selectionRect.containsEnd() && !isEndNode)
-                    selectionRect.setContainsEnd(false);
-                if (selectionRect.logicalWidth() || selectionRect.logicalHeight())
-                    rects.append(selectionRect);
-            }
-            newRects.shrink(0);
-        }
-    }
-
-    // The range could span nodes with different writing modes.
-    // If this is the case, we use the writing mode of the common ancestor.
-    if (containsDifferentWritingModes) {
-        if (auto ancestor = commonInclusiveAncestor(startContainer, endContainer))
-            hasFlippedWritingMode = ancestor->renderer()->style().isFlippedBlocksWritingMode();
-    }
-
-    const size_t numberOfRects = rects.size();
-
-    // If the selection ends in a BR, then add the line break bit to the last
-    // rect we have. This will cause its selection rect to extend to the
-    // end of the line.
-    if (stopNode && stopNode->hasTagName(HTMLNames::brTag) && numberOfRects) {
-        // Only set the line break bit if the end of the range actually
-        // extends all the way to include the <br>. VisiblePosition helps to
-        // figure this out.
-        VisiblePosition endPosition(createLegacyEditingPosition(&endContainer, endOffset), VP_DEFAULT_AFFINITY);
-        VisiblePosition brPosition(createLegacyEditingPosition(stopNode, 0), VP_DEFAULT_AFFINITY);
-        if (endPosition == brPosition)
-            rects.last().setIsLineBreak(true);
-    }
-
-    int lineTop = std::numeric_limits<int>::max();
-    int lineBottom = std::numeric_limits<int>::min();
-    int lastLineTop = lineTop;
-    int lastLineBottom = lineBottom;
-    int lineNumber = 0;
-
-    for (size_t i = 0; i < numberOfRects; ++i) {
-        int currentRectTop = rects[i].logicalTop();
-        int currentRectBottom = currentRectTop + rects[i].logicalHeight();
-
-        // We don't want to count the ruby text as a separate line.
-        if (intervalsSufficientlyOverlap(currentRectTop, currentRectBottom, lineTop, lineBottom) || (i && rects[i].isRubyText())) {
-            // Grow the current line bounds.
-            lineTop = std::min(lineTop, currentRectTop);
-            lineBottom = std::max(lineBottom, currentRectBottom);
-            // Avoid overlap with the previous line.
-            if (!hasFlippedWritingMode)
-                lineTop = std::max(lastLineBottom, lineTop);
-            else
-                lineBottom = std::min(lastLineTop, lineBottom);
-        } else {
-            adjustLineHeightOfSelectionRects(rects, i, lineNumber, lineTop, lineBottom - lineTop);
-            if (!hasFlippedWritingMode) {
-                lastLineTop = lineTop;
-                if (currentRectBottom >= lastLineTop) {
-                    lastLineBottom = lineBottom;
-                    lineTop = lastLineBottom;
-                } else {
-                    lineTop = currentRectTop;
-                    lastLineBottom = std::numeric_limits<int>::min();
-                }
-                lineBottom = currentRectBottom;
-            } else {
-                lastLineBottom = lineBottom;
-                if (currentRectTop <= lastLineBottom && i && rects[i].pageNumber() == rects[i - 1].pageNumber()) {
-                    lastLineTop = lineTop;
-                    lineBottom = lastLineTop;
-                } else {
-                    lastLineTop = std::numeric_limits<int>::max();
-                    lineBottom = currentRectBottom;
-                }
-                lineTop = currentRectTop;
-            }
-            ++lineNumber;
-        }
-    }
-
-    // Adjust line height.
-    adjustLineHeightOfSelectionRects(rects, numberOfRects, lineNumber, lineTop, lineBottom - lineTop);
-
-    // Sort the rectangles and make sure there are no gaps. The rectangles could be unsorted when
-    // there is ruby text and we could have gaps on the line when adjacent elements on the line
-    // have a different orientation.
-    size_t firstRectWithCurrentLineNumber = 0;
-    for (size_t currentRect = 1; currentRect < numberOfRects; ++currentRect) {
-        if (rects[currentRect].lineNumber() != rects[currentRect - 1].lineNumber()) {
-            firstRectWithCurrentLineNumber = currentRect;
-            continue;
-        }
-        if (rects[currentRect].logicalLeft() >= rects[currentRect - 1].logicalLeft())
-            continue;
-
-        SelectionRect selectionRect = rects[currentRect];
-        size_t i;
-        for (i = currentRect; i > firstRectWithCurrentLineNumber && selectionRect.logicalLeft() < rects[i - 1].logicalLeft(); --i)
-            rects[i] = rects[i - 1];
-        rects[i] = selectionRect;
-    }
-
-    for (size_t j = 1; j < numberOfRects; ++j) {
-        if (rects[j].lineNumber() != rects[j - 1].lineNumber())
-            continue;
-        SelectionRect& previousRect = rects[j - 1];
-        bool previousRectMayNotReachRightEdge = (previousRect.direction() == TextDirection::LTR && previousRect.containsEnd()) || (previousRect.direction() == TextDirection::RTL && previousRect.containsStart());
-        if (previousRectMayNotReachRightEdge)
-            continue;
-        int adjustedWidth = rects[j].logicalLeft() - previousRect.logicalLeft();
-        if (adjustedWidth > previousRect.logicalWidth())
-            previousRect.setLogicalWidth(adjustedWidth);
-    }
-
-    int maxLineNumber = lineNumber;
-
-    // Extend rects out to edges as needed.
-    for (size_t i = 0; i < numberOfRects; ++i) {
-        SelectionRect& selectionRect = rects[i];
-        if (!selectionRect.isLineBreak() && selectionRect.lineNumber() >= maxLineNumber)
-            continue;
-        if (selectionRect.direction() == TextDirection::RTL && selectionRect.isFirstOnLine()) {
-            selectionRect.setLogicalWidth(selectionRect.logicalWidth() + selectionRect.logicalLeft() - selectionRect.minX());
-            selectionRect.setLogicalLeft(selectionRect.minX());
-        } else if (selectionRect.direction() == TextDirection::LTR && selectionRect.isLastOnLine())
-            selectionRect.setLogicalWidth(selectionRect.maxX() - selectionRect.logicalLeft());
-    }
-    
-    return maxLineNumber;
-}
-
-void Range::collectSelectionRects(Vector<SelectionRect>& rects) const
-{
-    int maxLineNumber = collectSelectionRectsWithoutUnionInteriorLines(rects);
-    const size_t numberOfRects = rects.size();
-    
-    // Union all the rectangles on interior lines (i.e. not first or last).
-    // On first and last lines, just avoid having overlaps by merging intersecting rectangles.
-    Vector<SelectionRect> unionedRects;
-    IntRect interiorUnionRect;
-    for (size_t i = 0; i < numberOfRects; ++i) {
-        SelectionRect& currentRect = rects[i];
-        if (currentRect.lineNumber() == 1) {
-            ASSERT(interiorUnionRect.isEmpty());
-            if (!unionedRects.isEmpty()) {
-                SelectionRect& previousRect = unionedRects.last();
-                if (previousRect.rect().intersects(currentRect.rect())) {
-                    previousRect = coalesceSelectionRects(currentRect, previousRect);
-                    continue;
-                }
-            }
-            // Couldn't merge with previous rect, so just appending.
-            unionedRects.append(currentRect);
-        } else if (currentRect.lineNumber() < maxLineNumber) {
-            if (interiorUnionRect.isEmpty()) {
-                // Start collecting interior rects.
-                interiorUnionRect = currentRect.rect();         
-            } else if (interiorUnionRect.intersects(currentRect.rect())
-                || interiorUnionRect.maxX() == currentRect.rect().x()
-                || interiorUnionRect.maxY() == currentRect.rect().y()
-                || interiorUnionRect.x() == currentRect.rect().maxX()
-                || interiorUnionRect.y() == currentRect.rect().maxY()) {
-                // Only union the lines that are attached.
-                // For iBooks, the interior lines may cross multiple horizontal pages.
-                interiorUnionRect.unite(currentRect.rect());
-            } else {
-                unionedRects.append(SelectionRect(interiorUnionRect, currentRect.isHorizontal(), currentRect.pageNumber()));
-                interiorUnionRect = currentRect.rect();
-            }
-        } else {
-            // Processing last line.
-            if (!interiorUnionRect.isEmpty()) {
-                unionedRects.append(SelectionRect(interiorUnionRect, currentRect.isHorizontal(), currentRect.pageNumber()));
-                interiorUnionRect = IntRect();
-            }
-
-            ASSERT(!unionedRects.isEmpty());
-            SelectionRect& previousRect = unionedRects.last();
-            if (previousRect.logicalTop() == currentRect.logicalTop() && previousRect.rect().intersects(currentRect.rect())) {
-                // previousRect is also on the last line, and intersects the current one.
-                previousRect = coalesceSelectionRects(currentRect, previousRect);
-                continue;
-            }
-            // Couldn't merge with previous rect, so just appending.
-            unionedRects.append(currentRect);
-        }
-    }
-
-    rects.swap(unionedRects);
-}
-#endif
-
</del><span class="cx"> #if ENABLE(TREE_DEBUGGING)
</span><span class="cx"> void Range::formatForDebugger(char* buffer, unsigned length) const
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoredomRangeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Range.h (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Range.h 2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/dom/Range.h    2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -97,10 +97,7 @@
</span><span class="cx">     Position endPosition() const { return m_end.toPosition(); }
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT Node* firstNode() const;
</span><del>-    WEBCORE_EXPORT Node* pastLastNode() const;
</del><span class="cx"> 
</span><del>-    ShadowRoot* shadowRoot() const;
-
</del><span class="cx">     enum class BoundingRectBehavior : uint8_t {
</span><span class="cx">         RespectClipping = 1 << 0,
</span><span class="cx">         UseVisibleBounds = 1 << 1,
</span><span class="lines">@@ -114,10 +111,6 @@
</span><span class="cx"> 
</span><span class="cx">     // Transform-friendly
</span><span class="cx">     WEBCORE_EXPORT FloatRect absoluteBoundingRect(OptionSet<BoundingRectBehavior> = { }) const;
</span><del>-#if PLATFORM(IOS_FAMILY)
-    WEBCORE_EXPORT void collectSelectionRects(Vector<SelectionRect>&) const;
-    WEBCORE_EXPORT int collectSelectionRectsWithoutUnionInteriorLines(Vector<SelectionRect>&) const;
-#endif
</del><span class="cx"> 
</span><span class="cx">     void nodeChildrenChanged(ContainerNode&);
</span><span class="cx">     void nodeChildrenWillBeRemoved(ContainerNode&);
</span><span class="lines">@@ -160,6 +153,8 @@
</span><span class="cx"> 
</span><span class="cx">     Vector<FloatRect> absoluteRectsForRangeInText(Node*, RenderText&, bool useSelectionHeight, bool& isFixed, OptionSet<BoundingRectBehavior>) const;
</span><span class="cx"> 
</span><ins>+    Node* pastLastNode() const;
+
</ins><span class="cx">     Ref<Document> m_ownerDocument;
</span><span class="cx">     RangeBoundaryPoint m_start;
</span><span class="cx">     RangeBoundaryPoint m_end;
</span><span class="lines">@@ -169,7 +164,7 @@
</span><span class="cx"> WEBCORE_EXPORT bool rangesOverlap(const Range*, const Range*);
</span><span class="cx"> 
</span><span class="cx"> WEBCORE_EXPORT SimpleRange makeSimpleRange(const Range&);
</span><del>-SimpleRange makeSimpleRange(const Ref<Range>&);
</del><ins>+WEBCORE_EXPORT SimpleRange makeSimpleRange(const Ref<Range>&);
</ins><span class="cx"> WEBCORE_EXPORT Optional<SimpleRange> makeSimpleRange(const Range*);
</span><span class="cx"> WEBCORE_EXPORT Optional<SimpleRange> makeSimpleRange(const RefPtr<Range>&);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomSimpleRangecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/SimpleRange.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/SimpleRange.cpp 2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/dom/SimpleRange.cpp    2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx"> 
</span><span class="cx"> #include "CharacterData.h"
</span><span class="cx"> #include "NodeTraversal.h"
</span><del>-#include "Range.h"
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -44,12 +43,6 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SimpleRange::SimpleRange(const Range& other)
-    : start(other.startContainer(), other.startOffset())
-    , end(other.endContainer(), other.endOffset())
-{
-}
-
</del><span class="cx"> bool operator==(const SimpleRange& a, const SimpleRange& b)
</span><span class="cx"> {
</span><span class="cx">     return a.start == b.start && a.end == b.end;
</span></span></pre></div>
<a id="trunkSourceWebCoredomSimpleRangeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/SimpleRange.h (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/SimpleRange.h   2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/dom/SimpleRange.h      2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -29,8 +29,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class Range;
-
</del><span class="cx"> struct SimpleRange {
</span><span class="cx">     BoundaryPoint start;
</span><span class="cx">     BoundaryPoint end;
</span><span class="lines">@@ -44,11 +42,6 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT SimpleRange(const BoundaryPoint&, const BoundaryPoint&);
</span><span class="cx">     WEBCORE_EXPORT SimpleRange(BoundaryPoint&&, BoundaryPoint&&);
</span><del>-
-    // Convenience overloads to help with transition from using a lot of live ranges.
-    // FIXME: Once transition is over, remove and change callers to use makeSimpleRange instead.
-    WEBCORE_EXPORT SimpleRange(const Range&);
-    SimpleRange(const Ref<Range>&);
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> SimpleRange makeSimpleRangeHelper(BoundaryPoint&&, BoundaryPoint&&);
</span><span class="lines">@@ -122,11 +115,6 @@
</span><span class="cx">     return { range };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline SimpleRange::SimpleRange(const Ref<Range>& range)
-    : SimpleRange(range.get())
-{
-}
-
</del><span class="cx"> inline SimpleRange makeSimpleRangeHelper(BoundaryPoint&& start, BoundaryPoint&& end)
</span><span class="cx"> {
</span><span class="cx">     return { WTFMove(start), WTFMove(end) };
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingAlternativeTextControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/AlternativeTextController.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/AlternativeTextController.cpp       2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/editing/AlternativeTextController.cpp  2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -265,7 +265,7 @@
</span><span class="cx">     case AlternativeTextTypeSpellingSuggestions: {
</span><span class="cx">         if (!m_rangeWithAlternative || plainText(*m_rangeWithAlternative) != m_originalText)
</span><span class="cx">             break;
</span><del>-        String paragraphText = plainText(TextCheckingParagraph(createLiveRange(*m_rangeWithAlternative)).paragraphRange());
</del><ins>+        String paragraphText = plainText(TextCheckingParagraph(*m_rangeWithAlternative).paragraphRange());
</ins><span class="cx">         Vector<String> suggestions;
</span><span class="cx">         textChecker()->getGuessesForWord(m_originalText, paragraphText, m_document.selection().selection(), suggestions);
</span><span class="cx">         if (suggestions.isEmpty()) {
</span><span class="lines">@@ -523,7 +523,7 @@
</span><span class="cx">     if (!shouldStartTimerFor(marker, endOfWordPosition.offsetInContainerNode()))
</span><span class="cx">         return false;
</span><span class="cx">     Node* node = endOfWordPosition.containerNode();
</span><del>-    auto wordRange = range(*node, marker);
</del><ins>+    auto wordRange = makeSimpleRange(*node, marker);
</ins><span class="cx">     String currentWord = plainText(wordRange);
</span><span class="cx">     if (!currentWord.length())
</span><span class="cx">         return false;
</span><span class="lines">@@ -591,7 +591,7 @@
</span><span class="cx">     auto correctionOffsetInParagraph = characterCount({ *paragraphStart, range.start });
</span><span class="cx">     auto paragraphOffsetInTreeScope = characterCount({ treeScopeStart, *paragraphStart });
</span><span class="cx"> 
</span><del>-    SpellingCorrectionCommand::create(createLiveRange(range), alternative)->apply();
</del><ins>+    SpellingCorrectionCommand::create(range, alternative)->apply();
</ins><span class="cx"> 
</span><span class="cx">     // Recalculate pragraphRangeContainingCorrection, since SpellingCorrectionCommand modified the DOM, such that the original paragraphRangeContainingCorrection is no longer valid. Radar: 10305315 Bugzilla: 89526
</span><span class="cx">     auto updatedParagraphStartContainingCorrection = resolveCharacterLocation(makeRangeSelectingNodeContents(treeScopeRoot), paragraphOffsetInTreeScope);
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditingStylecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/EditingStyle.cpp    2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp       2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -1514,7 +1514,7 @@
</span><span class="cx">     // and find the background color of the common ancestor.
</span><span class="cx">     if (shouldUseBackgroundColorInEffect && (selection.isRange() || hasTransparentBackgroundColor(style->m_mutableStyle.get()))) {
</span><span class="cx">         if (auto range = selection.toNormalizedRange()) {
</span><del>-            if (auto value = backgroundColorInEffect(createLiveRange(*range)->commonAncestorContainer()))
</del><ins>+            if (auto value = backgroundColorInEffect(commonInclusiveAncestor(*range).get()))
</ins><span class="cx">                 style->setProperty(CSSPropertyBackgroundColor, value->cssText());
</span><span class="cx">         }
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.cpp  2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/editing/Editor.cpp     2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -1431,7 +1431,7 @@
</span><span class="cx">             writeSelectionToPasteboard(*Pasteboard::createForCopyAndPaste());
</span><span class="cx"> #else
</span><span class="cx">             // FIXME: Delete after <http://webkit.org/b/177618> lands.
</span><del>-            Pasteboard::createForCopyAndPaste()->writeSelection(createLiveRange(*selection).get(), canSmartCopyOrDelete(), *m_document.frame(), IncludeImageAltTextForDataTransfer);
</del><ins>+            Pasteboard::createForCopyAndPaste()->writeSelection(*selection, canSmartCopyOrDelete(), *m_document.frame(), IncludeImageAltTextForDataTransfer);
</ins><span class="cx"> #endif
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -2677,7 +2677,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     auto& rangeToCheck = shouldMarkGrammar ? *grammarRange : *spellingRange;
</span><del>-    TextCheckingParagraph paragraphToCheck(createLiveRange(rangeToCheck));
</del><ins>+    TextCheckingParagraph paragraphToCheck(rangeToCheck);
</ins><span class="cx">     if (paragraphToCheck.isEmpty())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -2723,7 +2723,7 @@
</span><span class="cx"> 
</span><span class="cx"> void Editor::replaceRangeForSpellChecking(const SimpleRange& rangeToReplace, const String& replacement)
</span><span class="cx"> {
</span><del>-    SpellingCorrectionCommand::create(createLiveRange(rangeToReplace), replacement)->apply();
</del><ins>+    SpellingCorrectionCommand::create(rangeToReplace, replacement)->apply();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void correctSpellcheckingPreservingTextCheckingParagraph(TextCheckingParagraph& paragraph, const SimpleRange& rangeToReplace, const String& replacement, CharacterRange resultCharacterRange)
</span><span class="lines">@@ -2731,7 +2731,7 @@
</span><span class="cx">     auto scopeNode = makeRef(downcast<ContainerNode>(paragraph.paragraphRange().startContainer().rootNode()));
</span><span class="cx">     auto paragraphCharacterRange = characterRange(makeBoundaryPointBeforeNodeContents(scopeNode), paragraph.paragraphRange());
</span><span class="cx"> 
</span><del>-    SpellingCorrectionCommand::create(createLiveRange(rangeToReplace), replacement)->apply();
</del><ins>+    SpellingCorrectionCommand::create(rangeToReplace, replacement)->apply();
</ins><span class="cx"> 
</span><span class="cx">     // TextCheckingParagraph may be orphaned after SpellingCorrectionCommand mutated DOM.
</span><span class="cx">     // See <rdar://10305315>, http://webkit.org/b/89526.
</span><span class="lines">@@ -2921,7 +2921,7 @@
</span><span class="cx">         return;
</span><span class="cx">     
</span><span class="cx">     m_alternativeTextController->recordAutocorrectionResponse(AutocorrectionResponse::Reverted, replacedString, *selection);
</span><del>-    TextCheckingParagraph paragraph(createLiveRange(*selection));
</del><ins>+    TextCheckingParagraph paragraph(*selection);
</ins><span class="cx">     replaceSelectionWithText(replacedString, SelectReplacement::No, SmartReplace::No, EditAction::Insert);
</span><span class="cx">     auto changedRange = paragraph.subrange(CharacterRange(paragraph.checkingStart(), replacedString.length()));
</span><span class="cx">     addMarker(changedRange, DocumentMarker::Replacement, String());
</span><span class="lines">@@ -3577,7 +3577,7 @@
</span><span class="cx"> 
</span><span class="cx">         ++matchCount;
</span><span class="cx">         if (matches)
</span><del>-            matches->append(createLiveRange(resultRange));
</del><ins>+            matches->append(resultRange);
</ins><span class="cx"> 
</span><span class="cx">         if (markMatches)
</span><span class="cx">             addMarker(resultRange, DocumentMarker::TextMatch);
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingInsertListCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/InsertListCommand.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/InsertListCommand.cpp       2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/editing/InsertListCommand.cpp  2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -143,7 +143,7 @@
</span><span class="cx">             if (startOfLastParagraph.isNotNull() && startOfParagraph(startOfSelection, CanSkipOverEditingBoundary) != startOfLastParagraph) {
</span><span class="cx">                 bool forceCreateList = !selectionHasListOfType(selection, listTag);
</span><span class="cx"> 
</span><del>-                auto currentSelection = createLiveRange(endingSelection().firstRange());
</del><ins>+                auto currentSelection = *endingSelection().firstRange();
</ins><span class="cx">                 VisiblePosition startOfCurrentParagraph = startOfSelection;
</span><span class="cx">                 while (startOfCurrentParagraph.isNotNull() && !inSameParagraph(startOfCurrentParagraph, startOfLastParagraph, CanCrossEditingBoundary)) {
</span><span class="cx">                     // doApply() may operate on and remove the last paragraph of the selection from the document
</span><span class="lines">@@ -162,7 +162,7 @@
</span><span class="cx">                     // But not using index is hard because there are so many ways we can lose selection inside doApplyForSingleParagraph.
</span><span class="cx">                     RefPtr<ContainerNode> scope;
</span><span class="cx">                     int indexForEndOfSelection = indexForVisiblePosition(endOfSelection, scope);
</span><del>-                    doApplyForSingleParagraph(forceCreateList, listTag, currentSelection.get());
</del><ins>+                    doApplyForSingleParagraph(forceCreateList, listTag, currentSelection);
</ins><span class="cx">                     if (endOfSelection.isNull() || endOfSelection.isOrphan() || startOfLastParagraph.isNull() || startOfLastParagraph.isOrphan()) {
</span><span class="cx">                         endOfSelection = visiblePositionForIndex(indexForEndOfSelection, scope.get());
</span><span class="cx">                         // If endOfSelection is null, then some contents have been deleted from the document.
</span><span class="lines">@@ -183,7 +183,7 @@
</span><span class="cx">                     startOfCurrentParagraph = startOfNextParagraph(endingSelection().visibleStart());
</span><span class="cx">                 }
</span><span class="cx">                 setEndingSelection(endOfSelection);
</span><del>-                doApplyForSingleParagraph(forceCreateList, listTag, currentSelection.get());
</del><ins>+                doApplyForSingleParagraph(forceCreateList, listTag, currentSelection);
</ins><span class="cx">                 // Fetch the end of the selection, for the reason mentioned above.
</span><span class="cx">                 endOfSelection = endingSelection().visibleEnd();
</span><span class="cx">                 setEndingSelection(VisibleSelection(startOfSelection, endOfSelection, endingSelection().isDirectional()));
</span><span class="lines">@@ -192,7 +192,8 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    doApplyForSingleParagraph(false, listTag, createLiveRange(endingSelection().firstRange()).get());
</del><ins>+    auto range = endingSelection().firstRange();
+    doApplyForSingleParagraph(false, listTag, *range);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> EditAction InsertListCommand::editingAction() const
</span><span class="lines">@@ -200,7 +201,7 @@
</span><span class="cx">     return m_type == Type::OrderedList ? EditAction::InsertOrderedList : EditAction::InsertUnorderedList;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const HTMLQualifiedName& listTag, Range* currentSelection)
</del><ins>+void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const HTMLQualifiedName& listTag, SimpleRange& currentSelection)
</ins><span class="cx"> {
</span><span class="cx">     // FIXME: This will produce unexpected results for a selection that starts just before a
</span><span class="cx">     // table and ends inside the first cell, selectionForParagraphIteration should probably
</span><span class="lines">@@ -229,9 +230,9 @@
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         // If the entire list is selected, then convert the whole list.
</span><del>-        if (switchListType && isNodeVisiblyContainedWithin(*listNode, *currentSelection)) {
-            bool rangeStartIsInList = visiblePositionBeforeNode(*listNode) == currentSelection->startPosition();
-            bool rangeEndIsInList = visiblePositionAfterNode(*listNode) == currentSelection->endPosition();
</del><ins>+        if (switchListType && isNodeVisiblyContainedWithin(*listNode, currentSelection)) {
+            bool rangeStartIsInList = visiblePositionBeforeNode(*listNode) == createLegacyEditingPosition(currentSelection.start);
+            bool rangeEndIsInList = visiblePositionAfterNode(*listNode) == createLegacyEditingPosition(currentSelection.end);
</ins><span class="cx"> 
</span><span class="cx">             RefPtr<HTMLElement> newList = createHTMLElement(document(), listTag);
</span><span class="cx">             insertNodeBefore(*newList, *listNode);
</span><span class="lines">@@ -254,9 +255,9 @@
</span><span class="cx">             // Restore the start and the end of current selection if they started inside listNode
</span><span class="cx">             // because moveParagraphWithClones could have removed them.
</span><span class="cx">             if (rangeStartIsInList && newList)
</span><del>-                currentSelection->setStart(*newList, 0);
</del><ins>+                currentSelection.start = makeBoundaryPointBeforeNodeContents(*newList);
</ins><span class="cx">             if (rangeEndIsInList && newList)
</span><del>-                currentSelection->setEnd(*newList, newList->length());
</del><ins>+                currentSelection.end = makeBoundaryPointAfterNodeContents(*newList);
</ins><span class="cx"> 
</span><span class="cx">             setEndingSelection(VisiblePosition(firstPositionInNode(newList.get())));
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingInsertListCommandh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/InsertListCommand.h (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/InsertListCommand.h 2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/editing/InsertListCommand.h    2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx">     HTMLElement* fixOrphanedListChild(Node&);
</span><span class="cx">     bool selectionHasListOfType(const VisibleSelection& selection, const QualifiedName&);
</span><span class="cx">     Ref<HTMLElement> mergeWithNeighboringLists(HTMLElement&);
</span><del>-    void doApplyForSingleParagraph(bool forceCreateList, const HTMLQualifiedName&, Range* currentSelection);
</del><ins>+    void doApplyForSingleParagraph(bool forceCreateList, const HTMLQualifiedName&, SimpleRange& currentSelection);
</ins><span class="cx">     void unlistifyParagraph(const VisiblePosition& originalStart, HTMLElement* listNode, Node* listChildNode);
</span><span class="cx">     RefPtr<HTMLElement> listifyParagraph(const VisiblePosition& originalStart, const QualifiedName& listTag);
</span><span class="cx">     RefPtr<HTMLElement> m_listElement;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingSpellCheckercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/SpellChecker.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/SpellChecker.cpp    2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/editing/SpellChecker.cpp       2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -143,8 +143,14 @@
</span><span class="cx"> 
</span><span class="cx"> bool SpellChecker::isCheckable(const SimpleRange& range) const
</span><span class="cx"> {
</span><del>-    auto firstNode = createLiveRange(range)->firstNode();
-    if (!firstNode || !firstNode->renderer())
</del><ins>+    bool foundRenderer = false;
+    for (auto& node : intersectingNodes(range)) {
+        if (node.renderer()) {
+            foundRenderer = true;
+            break;
+        }
+    }
+    if (!foundRenderer)
</ins><span class="cx">         return false;
</span><span class="cx">     auto& node = range.start.container.get();
</span><span class="cx">     return !is<Element>(node) || downcast<Element>(node).isSpellCheckingEnabled();
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTextCheckingHelpercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TextCheckingHelper.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TextCheckingHelper.cpp      2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/editing/TextCheckingHelper.cpp 2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -455,7 +455,7 @@
</span><span class="cx">     // Expand the search range to encompass entire paragraphs, since grammar checking needs that much context.
</span><span class="cx">     // Determine the character offset from the start of the paragraph to the start of the original search range,
</span><span class="cx">     // since we will want to ignore results in this area.
</span><del>-    TextCheckingParagraph paragraph(createLiveRange(m_range));
</del><ins>+    TextCheckingParagraph paragraph(m_range);
</ins><span class="cx">     
</span><span class="cx">     // Start checking from beginning of paragraph, but skip past results that occur before the start of the original search range.
</span><span class="cx">     for (uint64_t startOffset = 0; startOffset < paragraph.checkingEnd(); ) {
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTypingCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TypingCommand.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TypingCommand.cpp   2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/editing/TypingCommand.cpp      2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -735,7 +735,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (shouldAddToKillRing)
</span><del>-        document().editor().addRangeToKillRing(createLiveRange(*selectionToDelete.toNormalizedRange()), Editor::KillRingInsertionMode::PrependText);
</del><ins>+        document().editor().addRangeToKillRing(*selectionToDelete.toNormalizedRange(), Editor::KillRingInsertionMode::PrependText);
</ins><span class="cx"> 
</span><span class="cx">     // Post the accessibility notification before actually deleting the content while selectionToDelete is still valid
</span><span class="cx">     postTextStateChangeNotificationForDeletion(selectionToDelete);
</span><span class="lines">@@ -846,7 +846,7 @@
</span><span class="cx">     postTextStateChangeNotificationForDeletion(selectionToDelete);
</span><span class="cx"> 
</span><span class="cx">     if (shouldAddToKillRing)
</span><del>-        document().editor().addRangeToKillRing(createLiveRange(*selectionToDelete.toNormalizedRange()), Editor::KillRingInsertionMode::AppendText);
</del><ins>+        document().editor().addRangeToKillRing(*selectionToDelete.toNormalizedRange(), Editor::KillRingInsertionMode::AppendText);
</ins><span class="cx">     // make undo select what was deleted
</span><span class="cx">     setStartingSelection(selectionAfterUndo);
</span><span class="cx">     CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete, /* mergeBlocksAfterDelete*/ true, /* replace*/ false, expandForSpecialElements, /*sanitizeMarkup*/ true);
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingiosEditorIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/ios/EditorIOS.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/ios/EditorIOS.mm    2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/editing/ios/EditorIOS.mm       2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -351,9 +351,7 @@
</span><span class="cx">         if (parent)
</span><span class="cx">             element.remove();
</span><span class="cx"> 
</span><del>-        auto context = document().createRange();
-        context->selectNodeContents(element);
-        element.appendChild(createFragmentFromText(context, text));
</del><ins>+        element.appendChild(createFragmentFromText(makeRangeSelectingNodeContents(element), text));
</ins><span class="cx"> 
</span><span class="cx">         // restore element to document
</span><span class="cx">         if (parent) {
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingmarkupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/markup.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/markup.cpp  2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/editing/markup.cpp     2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -1157,14 +1157,13 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Break string into paragraphs. Extra line breaks turn into empty paragraphs.
</span><del>-    Node* blockNode = enclosingBlock(createLiveRange(context)->firstNode());
-    Element* block = downcast<Element>(blockNode);
-    bool useClonesOfEnclosingBlock = blockNode
-        && blockNode->isElementNode()
</del><ins>+    auto start = createLegacyEditingPosition(context.start);
+    auto block = enclosingBlock(start.firstNode().get());
+    bool useClonesOfEnclosingBlock = block
</ins><span class="cx">         && !block->hasTagName(bodyTag)
</span><span class="cx">         && !block->hasTagName(htmlTag)
</span><del>-        && block != editableRootForPosition(createLegacyEditingPosition(context.start));
-    bool useLineBreak = enclosingTextFormControl(createLegacyEditingPosition(context.start));
</del><ins>+        && block != editableRootForPosition(start);
+    bool useLineBreak = enclosingTextFormControl(start);
</ins><span class="cx"> 
</span><span class="cx">     Vector<String> list = string.splitAllowingEmptyEntries('\n');
</span><span class="cx">     size_t numLines = list.size();
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingwinEditorWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/win/EditorWin.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/win/EditorWin.cpp   2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/editing/win/EditorWin.cpp      2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -43,7 +43,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     bool chosePlainText;
</span><del>-    auto fragment = pasteboard->documentFragment(*m_document.frame(), createLiveRange(*range), options.contains(PasteOption::AllowPlainText), chosePlainText);
</del><ins>+    auto fragment = pasteboard->documentFragment(*m_document.frame(), *range, options.contains(PasteOption::AllowPlainText), chosePlainText);
</ins><span class="cx"> 
</span><span class="cx">     if (fragment && options.contains(PasteOption::AsQuotation))
</span><span class="cx">         quoteFragmentForPasting(*fragment);
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMSelectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMSelection.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMSelection.cpp       2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/page/DOMSelection.cpp  2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -337,7 +337,7 @@
</span><span class="cx"> 
</span><span class="cx">     auto& selection = frame->selection();
</span><span class="cx">     if (selection.isNone()) {
</span><del>-        selection.setSelection(SimpleRange { range });
</del><ins>+        selection.setSelection(makeSimpleRange(range));
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -356,7 +356,7 @@
</span><span class="cx">                 selection.moveTo(range.startPosition(), normalizedRange->endPosition(), DOWNSTREAM);
</span><span class="cx">             } else {
</span><span class="cx">                 // The new range contains the original range.
</span><del>-                selection.setSelection(SimpleRange { range });
</del><ins>+                selection.setSelection(makeSimpleRange(range));
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     } else {
</span><span class="lines">@@ -366,7 +366,7 @@
</span><span class="cx">             result = range.compareBoundaryPoints(Range::END_TO_END, *normalizedRange);
</span><span class="cx">             if (!result.hasException() && result.releaseReturnValue() == -1) {
</span><span class="cx">                 // The original range contains the new range.
</span><del>-                selection.setSelection(SimpleRange { *normalizedRange });
</del><ins>+                selection.setSelection(makeSimpleRange(*normalizedRange));
</ins><span class="cx">             } else {
</span><span class="cx">                 // The ranges intersect.
</span><span class="cx">                 selection.moveTo(normalizedRange->startPosition(), range.endPosition(), DOWNSTREAM);
</span><span class="lines">@@ -381,14 +381,10 @@
</span><span class="cx">     if (!frame)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    auto& selection = frame->selection();
-    if (selection.isNone())
</del><ins>+    auto selectedRange = frame->selection().selection().toNormalizedRange();
+    if (!selectedRange || selectedRange->start.container->containingShadowRoot())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    auto selectedRange = selection.selection().toNormalizedRange();
-    if (!selectedRange || createLiveRange(*selectedRange)->shadowRoot())
-        return;
-
</del><span class="cx">     Ref<Frame> protector(*frame);
</span><span class="cx">     createLiveRange(*selectedRange)->deleteContents();
</span><span class="cx">     auto container = selectedRange->start.container.ptr();
</span></span></pre></div>
<a id="trunkSourceWebCorepageDragControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DragController.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DragController.cpp     2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/page/DragController.cpp        2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -142,11 +142,10 @@
</span><span class="cx"> 
</span><span class="cx"> DragController::~DragController() = default;
</span><span class="cx"> 
</span><del>-static RefPtr<DocumentFragment> documentFragmentFromDragData(const DragData& dragData, Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText)
</del><ins>+static RefPtr<DocumentFragment> documentFragmentFromDragData(const DragData& dragData, Frame& frame, const SimpleRange& context, bool allowPlainText, bool& chosePlainText)
</ins><span class="cx"> {
</span><span class="cx">     chosePlainText = false;
</span><span class="cx"> 
</span><del>-    Document& document = context.ownerDocument();
</del><span class="cx">     if (dragData.containsCompatibleContent()) {
</span><span class="cx">         if (auto fragment = frame.editor().webContentFromPasteboard(*Pasteboard::createForDragAndDrop(dragData), context, allowPlainText, chosePlainText))
</span><span class="cx">             return fragment;
</span><span class="lines">@@ -155,10 +154,11 @@
</span><span class="cx">             String title;
</span><span class="cx">             String url = dragData.asURL(DragData::DoNotConvertFilenames, &title);
</span><span class="cx">             if (!url.isEmpty()) {
</span><ins>+                auto& document = context.start.container->document();
</ins><span class="cx">                 auto anchor = HTMLAnchorElement::create(document);
</span><span class="cx">                 anchor->setHref(url);
</span><span class="cx">                 if (title.isEmpty()) {
</span><del>-                    // Try the plain text first because the url might be normalized or escaped.
</del><ins>+                    // Try the plain text first because the URL might be normalized or escaped.
</ins><span class="cx">                     if (dragData.containsPlainText())
</span><span class="cx">                         title = dragData.asPlainText();
</span><span class="cx">                     if (title.isEmpty())
</span><span class="lines">@@ -603,13 +603,13 @@
</span><span class="cx">     bool isMove = dragIsMove(innerFrame->selection(), dragData);
</span><span class="cx">     if (isMove || dragCaret.isContentRichlyEditable()) {
</span><span class="cx">         bool chosePlainText = false;
</span><del>-        RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, *innerFrame, createLiveRange(*range), true, chosePlainText);
</del><ins>+        auto fragment = documentFragmentFromDragData(dragData, *innerFrame, *range, true, chosePlainText);
</ins><span class="cx">         if (!fragment || !editor.shouldInsertFragment(*fragment, range, EditorInsertAction::Dropped))
</span><span class="cx">             return false;
</span><span class="cx"> 
</span><span class="cx">         client().willPerformDragDestinationAction(DragDestinationAction::Edit, dragData);
</span><span class="cx"> 
</span><del>-        if (editor.client() && editor.client()->performTwoStepDrop(*fragment, createLiveRange(*range), isMove))
</del><ins>+        if (editor.client() && editor.client()->performTwoStepDrop(*fragment, *range, isMove))
</ins><span class="cx">             return true;
</span><span class="cx"> 
</span><span class="cx">         if (isMove) {
</span><span class="lines">@@ -635,7 +635,7 @@
</span><span class="cx"> 
</span><span class="cx">         client().willPerformDragDestinationAction(DragDestinationAction::Edit, dragData);
</span><span class="cx">         auto fragment = createFragmentFromText(*range, text);
</span><del>-        if (editor.client() && editor.client()->performTwoStepDrop(fragment.get(), createLiveRange(*range), isMove))
</del><ins>+        if (editor.client() && editor.client()->performTwoStepDrop(fragment.get(), *range, isMove))
</ins><span class="cx">             return true;
</span><span class="cx"> 
</span><span class="cx">         if (setSelectionToDragCaret(innerFrame.get(), dragCaret, point))
</span><span class="lines">@@ -1041,7 +1041,7 @@
</span><span class="cx">                     src.editor().writeSelectionToPasteboard(dataTransfer.pasteboard());
</span><span class="cx"> #else
</span><span class="cx">                     // FIXME: Convert Windows to match the other platforms and delete this.
</span><del>-                    dataTransfer.pasteboard().writeSelection(createLiveRange(*selectionRange), src.editor().canSmartCopyOrDelete(), src, IncludeImageAltTextForDataTransfer);
</del><ins>+                    dataTransfer.pasteboard().writeSelection(*selectionRange, src.editor().canSmartCopyOrDelete(), src, IncludeImageAltTextForDataTransfer);
</ins><span class="cx"> #endif
</span><span class="cx">                 } else {
</span><span class="cx"> #if PLATFORM(COCOA)
</span></span></pre></div>
<a id="trunkSourceWebCorepageTextIndicatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/TextIndicator.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/TextIndicator.cpp      2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/page/TextIndicator.cpp 2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -177,20 +177,6 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS_FAMILY)
-
-static Vector<FloatRect> selectionRects(const SimpleRange& range)
-{
-    Vector<SelectionRect> selectionRects;
-    createLiveRange(range)->collectSelectionRects(selectionRects);
-    Vector<FloatRect> rects;
-    for (auto& selectionRect : selectionRects)
-        rects.append(selectionRect.rect());
-    return rects;
-}
-
-#endif
-
</del><span class="cx"> static bool styleContainsComplexBackground(const RenderStyle& style)
</span><span class="cx"> {
</span><span class="cx">     return style.hasBlendMode() || style.hasBackgroundImage() || style.hasBackdropFilter();
</span><span class="lines">@@ -316,8 +302,11 @@
</span><span class="cx">     } else if (useBoundingRectAndPaintAllContentForComplexRanges && (treatRangeAsComplexDueToIllegibleTextColors || hasNonInlineOrReplacedElements(range)))
</span><span class="cx">         data.options.add(TextIndicatorOption::PaintAllContent);
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><del>-    else if (data.options.contains(TextIndicatorOption::UseSelectionRectForSizing))
-        textRects = selectionRects(range);
</del><ins>+    else if (data.options.contains(TextIndicatorOption::UseSelectionRectForSizing)) {
+        textRects = RenderObject::collectSelectionRects(range).map([&](const auto& rect) -> FloatRect {
+            return rect.rect();
+        });
+    }
</ins><span class="cx"> #endif
</span><span class="cx">     else {
</span><span class="cx">         auto textRectHeight = data.options.contains(TextIndicatorOption::TightlyFitContent) ? FrameSelection::TextRectangleHeight::TextHeight : FrameSelection::TextRectangleHeight::SelectionHeight;
</span></span></pre></div>
<a id="trunkSourceWebCorepageiosFrameIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ios/FrameIOS.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ios/FrameIOS.mm        2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/page/ios/FrameIOS.mm   2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -748,7 +748,7 @@
</span><span class="cx">         for (auto* marker : document()->markers().markersFor(node, DocumentMarker::DictationPhraseWithAlternatives)) {
</span><span class="cx">             auto& alternatives = WTF::get<Vector<String>>(marker->data());
</span><span class="cx"> 
</span><del>-            auto rangeForMarker = range(node, *marker);
</del><ins>+            auto rangeForMarker = makeSimpleRange(node, *marker);
</ins><span class="cx"> 
</span><span class="cx">             if (auto precedingTextRange = makeSimpleRange(precedingTextStartPosition, rangeForMarker.start)) {
</span><span class="cx">                 String precedingText = plainText(*precedingTextRange);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformDragImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/DragImage.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/DragImage.cpp      2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/platform/DragImage.cpp 2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -31,10 +31,9 @@
</span><span class="cx"> #include "FrameView.h"
</span><span class="cx"> #include "ImageBuffer.h"
</span><span class="cx"> #include "NotImplemented.h"
</span><del>-#include "Range.h"
</del><span class="cx"> #include "RenderElement.h"
</span><del>-#include "RenderObject.h"
</del><span class="cx"> #include "RenderView.h"
</span><ins>+#include "SimpleRange.h"
</ins><span class="cx"> #include "TextIndicator.h"
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -153,7 +152,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if !PLATFORM(IOS_FAMILY)
</span><span class="cx"> 
</span><del>-DragImageRef createDragImageForRange(Frame& frame, Range& range, bool forceBlackText)
</del><ins>+DragImageRef createDragImageForRange(Frame& frame, const SimpleRange& range, bool forceBlackText)
</ins><span class="cx"> {
</span><span class="cx">     frame.document()->updateLayout();
</span><span class="cx">     RenderView* view = frame.contentRenderer();
</span><span class="lines">@@ -161,12 +160,12 @@
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="cx">     // To snapshot the range, temporarily select it and take selection snapshot.
</span><del>-    Position start = range.startPosition();
</del><ins>+    Position start = createLegacyEditingPosition(range.start);
</ins><span class="cx">     Position candidate = start.downstream();
</span><span class="cx">     if (candidate.deprecatedNode() && candidate.deprecatedNode()->renderer())
</span><span class="cx">         start = candidate;
</span><span class="cx"> 
</span><del>-    Position end = range.endPosition();
</del><ins>+    Position end = createLegacyEditingPosition(range.end);
</ins><span class="cx">     candidate = end.upstream();
</span><span class="cx">     if (candidate.deprecatedNode() && candidate.deprecatedNode()->renderer())
</span><span class="cx">         end = candidate;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformDragImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/DragImage.h (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/DragImage.h        2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/platform/DragImage.h   2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -56,7 +56,6 @@
</span><span class="cx"> class Image;
</span><span class="cx"> class IntRect;
</span><span class="cx"> class Node;
</span><del>-class Range;
</del><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="cx"> typedef RetainPtr<CGImageRef> DragImageRef;
</span><span class="lines">@@ -89,7 +88,7 @@
</span><span class="cx"> 
</span><span class="cx"> WEBCORE_EXPORT DragImageRef createDragImageForNode(Frame&, Node&);
</span><span class="cx"> WEBCORE_EXPORT DragImageRef createDragImageForSelection(Frame&, TextIndicatorData&, bool forceBlackText = false);
</span><del>-WEBCORE_EXPORT DragImageRef createDragImageForRange(Frame&, Range&, bool forceBlackText = false);
</del><ins>+WEBCORE_EXPORT DragImageRef createDragImageForRange(Frame&, const SimpleRange&, bool forceBlackText = false);
</ins><span class="cx"> DragImageRef createDragImageForColor(const Color&, const FloatRect&, float, Path&);
</span><span class="cx"> DragImageRef createDragImageForImage(Frame&, Node&, IntRect& imageRect, IntRect& elementRect);
</span><span class="cx"> DragImageRef createDragImageForLink(Element&, URL&, const String& label, TextIndicatorData&, FontRenderingMode, float deviceScaleFactor);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformPasteboardh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Pasteboard.h (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Pasteboard.h       2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/platform/Pasteboard.h  2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -65,9 +65,10 @@
</span><span class="cx"> class Element;
</span><span class="cx"> class Frame;
</span><span class="cx"> class PasteboardStrategy;
</span><del>-class Range;
</del><span class="cx"> class SharedBuffer;
</span><span class="cx"> 
</span><ins>+struct SimpleRange;
+
</ins><span class="cx"> enum class PlainTextURLReadingPolicy : bool { IgnoreURL, AllowURL };
</span><span class="cx"> enum class WebContentReadingPolicy : bool { AnyType, OnlyRichTextTypes };
</span><span class="cx"> enum ShouldSerializeSelectedTextForDataTransfer { DefaultSelectedTextType, IncludeImageAltTextForDataTransfer };
</span><span class="lines">@@ -241,9 +242,9 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(WIN)
</span><del>-    RefPtr<DocumentFragment> documentFragment(Frame&, Range&, bool allowPlainText, bool& chosePlainText); // FIXME: Layering violation.
</del><ins>+    RefPtr<DocumentFragment> documentFragment(Frame&, const SimpleRange&, bool allowPlainText, bool& chosePlainText); // FIXME: Layering violation.
</ins><span class="cx">     void writeImage(Element&, const URL&, const String& title); // FIXME: Layering violation.
</span><del>-    void writeSelection(Range&, bool canSmartCopyOrDelete, Frame&, ShouldSerializeSelectedTextForDataTransfer = DefaultSelectedTextType); // FIXME: Layering violation.
</del><ins>+    void writeSelection(const SimpleRange&, bool canSmartCopyOrDelete, Frame&, ShouldSerializeSelectedTextForDataTransfer = DefaultSelectedTextType); // FIXME: Layering violation.
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(GTK)
</span><span class="lines">@@ -312,7 +313,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(WIN)
</span><span class="cx">     void finishCreatingPasteboard();
</span><del>-    void writeRangeToDataObject(Range&, Frame&); // FIXME: Layering violation.
</del><ins>+    void writeRangeToDataObject(const SimpleRange&, Frame&); // FIXME: Layering violation.
</ins><span class="cx">     void writeURLToDataObject(const URL&, const String&);
</span><span class="cx">     void writePlainTextToDataObject(const String&, SmartReplaceOption);
</span><span class="cx">     Optional<PasteboardCustomData> readPasteboardCustomData();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosDragImageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/DragImageIOS.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/DragImageIOS.mm        2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/platform/ios/DragImageIOS.mm   2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -219,7 +219,7 @@
</span><span class="cx">     return image;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-DragImageRef createDragImageForRange(Frame& frame, Range& range, bool forceBlackText)
</del><ins>+DragImageRef createDragImageForRange(Frame& frame, const SimpleRange& range, bool forceBlackText)
</ins><span class="cx"> {
</span><span class="cx">     if (auto document = frame.document())
</span><span class="cx">         document->updateLayout();
</span><span class="lines">@@ -286,7 +286,7 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-DragImageRef createDragImageForRange(Frame&, Range&, bool)
</del><ins>+DragImageRef createDragImageForRange(Frame&, const SimpleRange&, bool)
</ins><span class="cx"> {
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformwinPasteboardWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/win/PasteboardWin.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/win/PasteboardWin.cpp      2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/platform/win/PasteboardWin.cpp 2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -478,7 +478,7 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void Pasteboard::writeRangeToDataObject(Range& selectedRange, Frame& frame)
</del><ins>+void Pasteboard::writeRangeToDataObject(const SimpleRange& selectedRange, Frame& frame)
</ins><span class="cx"> {
</span><span class="cx">     if (!m_writableDataObject)
</span><span class="cx">         return;
</span><span class="lines">@@ -488,7 +488,7 @@
</span><span class="cx"> 
</span><span class="cx">     Vector<char> data;
</span><span class="cx">     markupToCFHTML(serializePreservingVisualAppearance(selectedRange, nullptr, AnnotateForInterchange::Yes),
</span><del>-        selectedRange.startContainer().document().url().string(), data);
</del><ins>+        selectedRange.start.container->document().url().string(), data);
</ins><span class="cx">     medium.hGlobal = createGlobalData(data);
</span><span class="cx">     if (medium.hGlobal && FAILED(m_writableDataObject->SetData(htmlFormat(), &medium, TRUE)))
</span><span class="cx">         ::GlobalFree(medium.hGlobal);
</span><span class="lines">@@ -505,7 +505,7 @@
</span><span class="cx">         m_writableDataObject->SetData(smartPasteFormat(), &medium, TRUE);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Pasteboard::writeSelection(Range& selectedRange, bool canSmartCopyOrDelete, Frame& frame, ShouldSerializeSelectedTextForDataTransfer shouldSerializeSelectedTextForDataTransfer)
</del><ins>+void Pasteboard::writeSelection(const SimpleRange& selectedRange, bool canSmartCopyOrDelete, Frame& frame, ShouldSerializeSelectedTextForDataTransfer shouldSerializeSelectedTextForDataTransfer)
</ins><span class="cx"> {
</span><span class="cx">     clear();
</span><span class="cx"> 
</span><span class="lines">@@ -514,7 +514,7 @@
</span><span class="cx">         Vector<char> data;
</span><span class="cx">         // FIXME: Use ResolveURLs::YesExcludingLocalFileURLsForPrivacy.
</span><span class="cx">         markupToCFHTML(serializePreservingVisualAppearance(frame.selection().selection()),
</span><del>-            selectedRange.startContainer().document().url().string(), data);
</del><ins>+            selectedRange.start.container->document().url().string(), data);
</ins><span class="cx">         HGLOBAL cbData = createGlobalData(data);
</span><span class="cx">         if (!::SetClipboardData(HTMLClipboardFormat, cbData))
</span><span class="cx">             ::GlobalFree(cbData);
</span><span class="lines">@@ -854,7 +854,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RefPtr<DocumentFragment> Pasteboard::documentFragment(Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText)
</del><ins>+RefPtr<DocumentFragment> Pasteboard::documentFragment(Frame& frame, const SimpleRange& context, bool allowPlainText, bool& chosePlainText)
</ins><span class="cx"> {
</span><span class="cx">     chosePlainText = false;
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.cpp  2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp     2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> #include "FrameView.h"
</span><span class="cx"> #include "GeometryUtilities.h"
</span><span class="cx"> #include "GraphicsContext.h"
</span><del>-#include "HTMLElement.h"
</del><ins>+#include "HTMLBRElement.h"
</ins><span class="cx"> #include "HTMLNames.h"
</span><span class="cx"> #include "HTMLTableCellElement.h"
</span><span class="cx"> #include "HTMLTableElement.h"
</span><span class="lines">@@ -1917,6 +1917,270 @@
</span><span class="cx">     return rects;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS_FAMILY)
+
+static bool intervalsSufficientlyOverlap(int startA, int endA, int startB, int endB)
+{
+    if (endA <= startA || endB <= startB)
+        return false;
+
+    const float sufficientOverlap = .75;
+
+    int lengthA = endA - startA;
+    int lengthB = endB - startB;
+
+    int maxStart = std::max(startA, startB);
+    int minEnd = std::min(endA, endB);
+
+    if (maxStart > minEnd)
+        return false;
+
+    return minEnd - maxStart >= sufficientOverlap * std::min(lengthA, lengthB);
+}
+
+static inline void adjustLineHeightOfSelectionRects(Vector<SelectionRect>& rects, size_t numberOfRects, int lineNumber, int lineTop, int lineHeight)
+{
+    ASSERT(rects.size() >= numberOfRects);
+    for (size_t i = numberOfRects; i; ) {
+        --i;
+        if (rects[i].lineNumber())
+            break;
+        rects[i].setLineNumber(lineNumber);
+        rects[i].setLogicalTop(lineTop);
+        rects[i].setLogicalHeight(lineHeight);
+    }
+}
+
+static SelectionRect coalesceSelectionRects(const SelectionRect& original, const SelectionRect& previous)
+{
+    SelectionRect result(unionRect(previous.rect(), original.rect()), original.isHorizontal(), original.pageNumber());
+    result.setDirection(original.containsStart() || original.containsEnd() ? original.direction() : previous.direction());
+    result.setContainsStart(previous.containsStart() || original.containsStart());
+    result.setContainsEnd(previous.containsEnd() || original.containsEnd());
+    result.setIsFirstOnLine(previous.isFirstOnLine() || original.isFirstOnLine());
+    result.setIsLastOnLine(previous.isLastOnLine() || original.isLastOnLine());
+    return result;
+}
+
+Vector<SelectionRect> RenderObject::collectSelectionRectsWithoutUnionInteriorLines(const SimpleRange& range)
+{
+    return collectSelectionRectsInternal(range).rects;
+}
+
+auto RenderObject::collectSelectionRectsInternal(const SimpleRange& range) -> SelectionRects
+{
+    Vector<SelectionRect> rects;
+    Vector<SelectionRect> newRects;
+    bool hasFlippedWritingMode = range.start.container->renderer() && range.start.container->renderer()->style().isFlippedBlocksWritingMode();
+    bool containsDifferentWritingModes = false;
+    for (auto& node : intersectingNodes(range)) {
+        auto renderer = node.renderer();
+        // Only ask leaf render objects for their line box rects.
+        if (renderer && !renderer->firstChildSlow() && renderer->style().userSelect() != UserSelect::None) {
+            bool isStartNode = renderer->node() == range.start.container.ptr();
+            bool isEndNode = renderer->node() == range.end.container.ptr();
+            if (hasFlippedWritingMode != renderer->style().isFlippedBlocksWritingMode())
+                containsDifferentWritingModes = true;
+            // FIXME: Sending 0 for the startOffset is a weird way of telling the renderer that the selection
+            // doesn't start inside it, since we'll also send 0 if the selection *does* start in it, at offset 0.
+            //
+            // FIXME: Selection endpoints aren't always inside leaves, and we only build SelectionRects for leaves,
+            // so we can't accurately determine which SelectionRects contain the selection start and end using
+            // only the offsets of the start and end. We need to pass the whole Range.
+            int beginSelectionOffset = isStartNode ? range.start.offset : 0;
+            int endSelectionOffset = isEndNode ? range.end.offset : std::numeric_limits<int>::max();
+            renderer->collectSelectionRects(newRects, beginSelectionOffset, endSelectionOffset);
+            for (auto& selectionRect : newRects) {
+                if (selectionRect.containsStart() && !isStartNode)
+                    selectionRect.setContainsStart(false);
+                if (selectionRect.containsEnd() && !isEndNode)
+                    selectionRect.setContainsEnd(false);
+                if (selectionRect.logicalWidth() || selectionRect.logicalHeight())
+                    rects.append(selectionRect);
+            }
+            newRects.shrink(0);
+        }
+    }
+
+    // The range could span nodes with different writing modes.
+    // If this is the case, we use the writing mode of the common ancestor.
+    if (containsDifferentWritingModes) {
+        if (auto ancestor = commonInclusiveAncestor(range))
+            hasFlippedWritingMode = ancestor->renderer()->style().isFlippedBlocksWritingMode();
+    }
+
+    auto numberOfRects = rects.size();
+
+    // If the selection ends in a BR, then add the line break bit to the last rect we have.
+    // This will cause its selection rect to extend to the end of the line.
+    if (numberOfRects) {
+        // Only set the line break bit if the end of the range actually
+        // extends all the way to include the <br>. VisiblePosition helps to
+        // figure this out.
+        if (is<HTMLBRElement>(VisiblePosition(createLegacyEditingPosition(range.end)).deepEquivalent().firstNode()))
+            rects.last().setIsLineBreak(true);
+    }
+
+    int lineTop = std::numeric_limits<int>::max();
+    int lineBottom = std::numeric_limits<int>::min();
+    int lastLineTop = lineTop;
+    int lastLineBottom = lineBottom;
+    int lineNumber = 0;
+
+    for (size_t i = 0; i < numberOfRects; ++i) {
+        int currentRectTop = rects[i].logicalTop();
+        int currentRectBottom = currentRectTop + rects[i].logicalHeight();
+
+        // We don't want to count the ruby text as a separate line.
+        if (intervalsSufficientlyOverlap(currentRectTop, currentRectBottom, lineTop, lineBottom) || (i && rects[i].isRubyText())) {
+            // Grow the current line bounds.
+            lineTop = std::min(lineTop, currentRectTop);
+            lineBottom = std::max(lineBottom, currentRectBottom);
+            // Avoid overlap with the previous line.
+            if (!hasFlippedWritingMode)
+                lineTop = std::max(lastLineBottom, lineTop);
+            else
+                lineBottom = std::min(lastLineTop, lineBottom);
+        } else {
+            adjustLineHeightOfSelectionRects(rects, i, lineNumber, lineTop, lineBottom - lineTop);
+            if (!hasFlippedWritingMode) {
+                lastLineTop = lineTop;
+                if (currentRectBottom >= lastLineTop) {
+                    lastLineBottom = lineBottom;
+                    lineTop = lastLineBottom;
+                } else {
+                    lineTop = currentRectTop;
+                    lastLineBottom = std::numeric_limits<int>::min();
+                }
+                lineBottom = currentRectBottom;
+            } else {
+                lastLineBottom = lineBottom;
+                if (currentRectTop <= lastLineBottom && i && rects[i].pageNumber() == rects[i - 1].pageNumber()) {
+                    lastLineTop = lineTop;
+                    lineBottom = lastLineTop;
+                } else {
+                    lastLineTop = std::numeric_limits<int>::max();
+                    lineBottom = currentRectBottom;
+                }
+                lineTop = currentRectTop;
+            }
+            ++lineNumber;
+        }
+    }
+
+    // Adjust line height.
+    adjustLineHeightOfSelectionRects(rects, numberOfRects, lineNumber, lineTop, lineBottom - lineTop);
+
+    // Sort the rectangles and make sure there are no gaps. The rectangles could be unsorted when
+    // there is ruby text and we could have gaps on the line when adjacent elements on the line
+    // have a different orientation.
+    size_t firstRectWithCurrentLineNumber = 0;
+    for (size_t currentRect = 1; currentRect < numberOfRects; ++currentRect) {
+        if (rects[currentRect].lineNumber() != rects[currentRect - 1].lineNumber()) {
+            firstRectWithCurrentLineNumber = currentRect;
+            continue;
+        }
+        if (rects[currentRect].logicalLeft() >= rects[currentRect - 1].logicalLeft())
+            continue;
+
+        SelectionRect selectionRect = rects[currentRect];
+        size_t i;
+        for (i = currentRect; i > firstRectWithCurrentLineNumber && selectionRect.logicalLeft() < rects[i - 1].logicalLeft(); --i)
+            rects[i] = rects[i - 1];
+        rects[i] = selectionRect;
+    }
+
+    for (size_t j = 1; j < numberOfRects; ++j) {
+        if (rects[j].lineNumber() != rects[j - 1].lineNumber())
+            continue;
+        SelectionRect& previousRect = rects[j - 1];
+        bool previousRectMayNotReachRightEdge = (previousRect.direction() == TextDirection::LTR && previousRect.containsEnd()) || (previousRect.direction() == TextDirection::RTL && previousRect.containsStart());
+        if (previousRectMayNotReachRightEdge)
+            continue;
+        int adjustedWidth = rects[j].logicalLeft() - previousRect.logicalLeft();
+        if (adjustedWidth > previousRect.logicalWidth())
+            previousRect.setLogicalWidth(adjustedWidth);
+    }
+
+    int maxLineNumber = lineNumber;
+
+    // Extend rects out to edges as needed.
+    for (size_t i = 0; i < numberOfRects; ++i) {
+        SelectionRect& selectionRect = rects[i];
+        if (!selectionRect.isLineBreak() && selectionRect.lineNumber() >= maxLineNumber)
+            continue;
+        if (selectionRect.direction() == TextDirection::RTL && selectionRect.isFirstOnLine()) {
+            selectionRect.setLogicalWidth(selectionRect.logicalWidth() + selectionRect.logicalLeft() - selectionRect.minX());
+            selectionRect.setLogicalLeft(selectionRect.minX());
+        } else if (selectionRect.direction() == TextDirection::LTR && selectionRect.isLastOnLine())
+            selectionRect.setLogicalWidth(selectionRect.maxX() - selectionRect.logicalLeft());
+    }
+
+    return { WTFMove(rects), maxLineNumber };
+}
+
+Vector<SelectionRect> RenderObject::collectSelectionRects(const SimpleRange& range)
+{
+    auto result = RenderObject::collectSelectionRectsInternal(range);
+    auto numberOfRects = result.rects.size();
+
+    // Union all the rectangles on interior lines (i.e. not first or last).
+    // On first and last lines, just avoid having overlaps by merging intersecting rectangles.
+    Vector<SelectionRect> unionedRects;
+    IntRect interiorUnionRect;
+    for (size_t i = 0; i < numberOfRects; ++i) {
+        SelectionRect& currentRect = result.rects[i];
+        if (currentRect.lineNumber() == 1) {
+            ASSERT(interiorUnionRect.isEmpty());
+            if (!unionedRects.isEmpty()) {
+                SelectionRect& previousRect = unionedRects.last();
+                if (previousRect.rect().intersects(currentRect.rect())) {
+                    previousRect = coalesceSelectionRects(currentRect, previousRect);
+                    continue;
+                }
+            }
+            // Couldn't merge with previous rect, so just appending.
+            unionedRects.append(currentRect);
+        } else if (currentRect.lineNumber() < result.maxLineNumber) {
+            if (interiorUnionRect.isEmpty()) {
+                // Start collecting interior rects.
+                interiorUnionRect = currentRect.rect();
+            } else if (interiorUnionRect.intersects(currentRect.rect())
+                || interiorUnionRect.maxX() == currentRect.rect().x()
+                || interiorUnionRect.maxY() == currentRect.rect().y()
+                || interiorUnionRect.x() == currentRect.rect().maxX()
+                || interiorUnionRect.y() == currentRect.rect().maxY()) {
+                // Only union the lines that are attached.
+                // For iBooks, the interior lines may cross multiple horizontal pages.
+                interiorUnionRect.unite(currentRect.rect());
+            } else {
+                unionedRects.append(SelectionRect(interiorUnionRect, currentRect.isHorizontal(), currentRect.pageNumber()));
+                interiorUnionRect = currentRect.rect();
+            }
+        } else {
+            // Processing last line.
+            if (!interiorUnionRect.isEmpty()) {
+                unionedRects.append(SelectionRect(interiorUnionRect, currentRect.isHorizontal(), currentRect.pageNumber()));
+                interiorUnionRect = IntRect();
+            }
+
+            ASSERT(!unionedRects.isEmpty());
+            SelectionRect& previousRect = unionedRects.last();
+            if (previousRect.logicalTop() == currentRect.logicalTop() && previousRect.rect().intersects(currentRect.rect())) {
+                // previousRect is also on the last line, and intersects the current one.
+                previousRect = coalesceSelectionRects(currentRect, previousRect);
+                continue;
+            }
+            // Couldn't merge with previous rect, so just appending.
+            unionedRects.append(currentRect);
+        }
+    }
+
+    return unionedRects;
+}
+
+#endif
+
</ins><span class="cx"> String RenderObject::debugDescription() const
</span><span class="cx"> {
</span><span class="cx">     StringBuilder builder;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.h (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.h    2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/rendering/RenderObject.h       2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -547,6 +547,8 @@
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="cx">     virtual void collectSelectionRects(Vector<SelectionRect>&, unsigned startOffset = 0, unsigned endOffset = std::numeric_limits<unsigned>::max());
</span><span class="cx">     virtual void absoluteQuadsForSelection(Vector<FloatQuad>& quads) const { absoluteQuads(quads); }
</span><ins>+    WEBCORE_EXPORT static Vector<SelectionRect> collectSelectionRects(const SimpleRange&);
+    WEBCORE_EXPORT static Vector<SelectionRect> collectSelectionRectsWithoutUnionInteriorLines(const SimpleRange&);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint&) const { }
</span><span class="lines">@@ -758,6 +760,14 @@
</span><span class="cx">     void setLayerNeedsFullRepaint();
</span><span class="cx">     void setLayerNeedsFullRepaintForPositionedMovementLayout();
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS_FAMILY)
+    struct SelectionRects {
+        Vector<SelectionRect> rects;
+        int maxLineNumber;
+    };
+    WEBCORE_EXPORT static SelectionRects collectSelectionRectsInternal(const SimpleRange&);
+#endif
+
</ins><span class="cx">     Node* generatingPseudoHostElement() const;
</span><span class="cx"> 
</span><span class="cx">     void propagateRepaintToParentWithOutlineAutoIfNeeded(const RenderLayerModelObject& repaintContainer, const LayoutRect& repaintRect) const;
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp       2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebCore/testing/Internals.cpp  2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -1775,7 +1775,7 @@
</span><span class="cx">     auto marker = result.releaseReturnValue();
</span><span class="cx">     if (!marker)
</span><span class="cx">         return nullptr;
</span><del>-    return { createLiveRange(range(node, *marker)) };
</del><ins>+    return { createLiveRange(makeSimpleRange(node, *marker)) };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ExceptionOr<String> Internals::markerDescriptionForNode(Node& node, const String& markerType, unsigned index)
</span><span class="lines">@@ -2154,12 +2154,12 @@
</span><span class="cx"> 
</span><span class="cx"> unsigned Internals::locationFromRange(Element& scope, const Range& range)
</span><span class="cx"> {
</span><del>-    return clampTo<unsigned>(characterRange(makeBoundaryPointBeforeNodeContents(scope), range).location);
</del><ins>+    return clampTo<unsigned>(characterRange(makeBoundaryPointBeforeNodeContents(scope), makeSimpleRange(range)).location);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> unsigned Internals::lengthFromRange(Element& scope, const Range& range)
</span><span class="cx"> {
</span><del>-    return clampTo<unsigned>(characterRange(makeBoundaryPointBeforeNodeContents(scope), range).length);
</del><ins>+    return clampTo<unsigned>(characterRange(makeBoundaryPointBeforeNodeContents(scope), makeSimpleRange(range)).length);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String Internals::rangeAsText(const Range& range)
</span><span class="lines">@@ -2170,7 +2170,7 @@
</span><span class="cx"> String Internals::rangeAsTextUsingBackwardsTextIterator(const Range& range)
</span><span class="cx"> {
</span><span class="cx">     String result;
</span><del>-    for (SimplifiedBackwardsTextIterator backwardsIterator(range); !backwardsIterator.atEnd(); backwardsIterator.advance())
</del><ins>+    for (SimplifiedBackwardsTextIterator backwardsIterator(makeSimpleRange(range)); !backwardsIterator.atEnd(); backwardsIterator.advance())
</ins><span class="cx">         result.insert(backwardsIterator.text().toString(), 0);
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="lines">@@ -2177,12 +2177,12 @@
</span><span class="cx"> 
</span><span class="cx"> Ref<Range> Internals::subrange(Range& range, unsigned rangeLocation, unsigned rangeLength)
</span><span class="cx"> {
</span><del>-    return createLiveRange(resolveCharacterRange(range, { rangeLocation, rangeLength }));
</del><ins>+    return createLiveRange(resolveCharacterRange(makeSimpleRange(range), { rangeLocation, rangeLength }));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-RefPtr<Range> Internals::rangeOfStringNearLocation(const Range& searchRange, const String& text, unsigned targetOffset)
</del><ins>+RefPtr<Range> Internals::rangeOfStringNearLocation(const Range& range, const String& text, unsigned targetOffset)
</ins><span class="cx"> {
</span><del>-    return createLiveRange(findClosestPlainText(searchRange, text, { }, targetOffset));
</del><ins>+    return createLiveRange(findClosestPlainText(makeSimpleRange(range), text, { }, targetOffset));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if !PLATFORM(MAC)
</span><span class="lines">@@ -5756,7 +5756,7 @@
</span><span class="cx"> 
</span><span class="cx"> Internals::TextIndicatorInfo Internals::textIndicatorForRange(const Range& range, TextIndicatorOptions options)
</span><span class="cx"> {
</span><del>-    auto indicator = TextIndicator::createWithRange(range, options.coreOptions(), TextIndicatorPresentationTransition::None);
</del><ins>+    auto indicator = TextIndicator::createWithRange(makeSimpleRange(range), options.coreOptions(), TextIndicatorPresentationTransition::None);
</ins><span class="cx">     return indicator->data();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKit/ChangeLog       2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2020-08-02  Darin Adler  <darin@apple.com>
+
+        Remove some member functions of Range and many calls to createLiveRange
+        https://bugs.webkit.org/show_bug.cgi?id=215070
+
+        Reviewed by Sam Weinig.
+
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInRangeHandle.mm:
+        (-[WKWebProcessPlugInRangeHandle detectDataWithTypes:context:]): Use makeSimpleRange.
+        * WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp:
+        (API::PageOverlayClientImpl::actionContextForResultAtPoint): Ditto.
+        * WebProcess/InjectedBundle/API/mac/WKDOMRange.mm:
+        (-[WKDOMRange textRects]): Ditto.
+        * WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm:
+        (-[WKDOMTextIterator initWithRange:]): Ditto.
+        * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
+        (WebKit::InjectedBundleRangeHandle::renderedImage): Ditto.
+
+        * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
+        (WebKit::WebPage::performDictionaryLookupAtLocation): Remove createLiveRange.
+        (WebKit::WebPage::performDictionaryLookupForSelection): Ditto.
+        * WebProcess/WebPage/FindController.cpp:
+        (WebKit::FindController::updateFindUIAfterPageScroll): Ditto.
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getPlatformEditorState const): Ditto.
+        (WebKit::WebPage::computeAndSendEditDragSnapshot): Ditto.
+        (WebKit::WebPage::getRectsForGranularityWithSelectionOffset): Ditto.
+        (WebKit::WebPage::getRectsAtSelectionOffsetWithText): Ditto.
+        (WebKit::WebPage::requestAutocorrectionData): Ditto.
+
</ins><span class="cx"> 2020-08-01  Darin Adler  <darin@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Fix and further refine makefile rule for WebKit messages generated files
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessInjectedBundleAPICocoaWKWebProcessPlugInRangeHandlemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInRangeHandle.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInRangeHandle.mm 2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInRangeHandle.mm    2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx"> - (NSArray *)detectDataWithTypes:(WKDataDetectorTypes)types context:(NSDictionary *)context
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(DATA_DETECTION)
</span><del>-    return WebCore::DataDetection::detectContentInRange(_rangeHandle->coreRange(), fromWKDataDetectorTypes(types), context);
</del><ins>+    return WebCore::DataDetection::detectContentInRange(makeSimpleRange(_rangeHandle->coreRange()), fromWKDataDetectorTypes(types), context);
</ins><span class="cx"> #else
</span><span class="cx">     return nil;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessInjectedBundleAPIcWKBundlePageOverlaycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp      2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp 2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> #include <WebCore/GraphicsContext.h>
</span><span class="cx"> #include <WebCore/PageOverlay.h>
</span><span class="cx"> #include <WebCore/PlatformMouseEvent.h>
</span><ins>+#include <WebCore/Range.h>
</ins><span class="cx"> 
</span><span class="cx"> namespace API {
</span><span class="cx"> 
</span><span class="lines">@@ -138,7 +139,7 @@
</span><span class="cx">         if (!actionContext || !apiRange)
</span><span class="cx">             return WTF::nullopt;
</span><span class="cx"> 
</span><del>-        return { { actionContext, WebKit::toImpl(apiRange)->coreRange() } };
</del><ins>+        return { { actionContext, makeSimpleRange(WebKit::toImpl(apiRange)->coreRange()) } };
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     void dataDetectorsDidPresentUI(WebKit::WebPageOverlay& pageOverlay) override
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessInjectedBundleAPImacWKDOMRangemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm      2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMRange.mm 2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -129,7 +129,7 @@
</span><span class="cx"> - (NSArray *)textRects
</span><span class="cx"> {
</span><span class="cx">     _impl->ownerDocument().updateLayoutIgnorePendingStylesheets();
</span><del>-    return createNSArray(WebCore::RenderObject::absoluteTextRects(*_impl)).autorelease();
</del><ins>+    return createNSArray(WebCore::RenderObject::absoluteTextRects(makeSimpleRange(*_impl))).autorelease();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (WKDOMRange *)rangeByExpandingToWordBoundaryByCharacters:(NSUInteger)characters inDirection:(WKDOMRangeDirection)direction
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessInjectedBundleAPImacWKDOMTextIteratormm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm       2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm  2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx">     if (!range)
</span><span class="cx">         return self;
</span><span class="cx"> 
</span><del>-    _textIterator = makeUnique<WebCore::TextIterator>(*WebKit::toWebCoreRange(range));
</del><ins>+    _textIterator = makeUnique<WebCore::TextIterator>(makeSimpleRange(*WebKit::toWebCoreRange(range)));
</ins><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessInjectedBundleDOMInjectedBundleRangeHandlecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp  2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp     2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -124,7 +124,7 @@
</span><span class="cx">     Ref<Frame> protector(*frame);
</span><span class="cx"> 
</span><span class="cx">     VisibleSelection oldSelection = frame->selection().selection();
</span><del>-    frame->selection().setSelection(VisibleSelection(m_range));
</del><ins>+    frame->selection().setSelection(makeSimpleRange(m_range));
</ins><span class="cx"> 
</span><span class="cx">     float scaleFactor = (options & SnapshotOptionsExcludeDeviceScaleFactor) ? 1 : frame->page()->deviceScaleFactor();
</span><span class="cx">     IntRect paintRect = enclosingIntRect(m_range->absoluteBoundingRect());
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageCocoaWebPageCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm     2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm        2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -129,7 +129,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     auto [range, options] = WTFMove(*rangeResult);
</span><del>-    performDictionaryLookupForRange(*frame, createLiveRange(range), options, TextIndicatorPresentationTransition::Bounce);
</del><ins>+    performDictionaryLookupForRange(*frame, range, options, TextIndicatorPresentationTransition::Bounce);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPage::performDictionaryLookupForSelection(Frame& frame, const VisibleSelection& selection, TextIndicatorPresentationTransition presentationTransition)
</span><span class="lines">@@ -139,7 +139,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     auto [range, options] = WTFMove(*result);
</span><del>-    performDictionaryLookupForRange(frame, createLiveRange(range), options, presentationTransition);
</del><ins>+    performDictionaryLookupForRange(frame, range, options, presentationTransition);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPage::performDictionaryLookupOfCurrentSelection()
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageFindControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp        2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp   2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -204,7 +204,7 @@
</span><span class="cx">             Vector<IntRect> matchRects;
</span><span class="cx">             if (auto range = m_webPage->corePage()->selection().firstRange()) {
</span><span class="cx">                 matchRects = RenderObject::absoluteTextRects(*range);
</span><del>-                m_findMatches.append(createLiveRange(*range));
</del><ins>+                m_findMatches.append(*range);
</ins><span class="cx">             }
</span><span class="cx">             m_webPage->send(Messages::WebPageProxy::DidFindString(string, matchRects, matchCount, m_foundStringMatchIndex, didWrap == DidWrap::Yes));
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm    2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -268,7 +268,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (frame.editor().hasComposition()) {
</span><span class="cx">         if (auto compositionRange = frame.editor().compositionRange()) {
</span><del>-            createLiveRange(*compositionRange)->collectSelectionRects(postLayoutData.markedTextRects);
</del><ins>+            postLayoutData.markedTextRects = RenderObject::collectSelectionRects(*compositionRange);
</ins><span class="cx">             convertContentToRootViewSelectionRects(view, postLayoutData.markedTextRects);
</span><span class="cx"> 
</span><span class="cx">             postLayoutData.markedText = plainTextForContext(*compositionRange);
</span><span class="lines">@@ -298,7 +298,7 @@
</span><span class="cx">         auto selectedRange = selection.toNormalizedRange();
</span><span class="cx">         String selectedText;
</span><span class="cx">         if (selectedRange) {
</span><del>-            createLiveRange(*selectedRange)->collectSelectionRects(postLayoutData.selectionRects);
</del><ins>+            postLayoutData.selectionRects = RenderObject::collectSelectionRects(*selectedRange);
</ins><span class="cx">             convertContentToRootViewSelectionRects(view, postLayoutData.selectionRects);
</span><span class="cx">             selectedText = plainTextForDisplay(*selectedRange);
</span><span class="cx">             postLayoutData.selectedTextLength = selectedText.length();
</span><span class="lines">@@ -1024,7 +1024,7 @@
</span><span class="cx">         TextIndicatorOption::IncludeSnapshotWithSelectionHighlight
</span><span class="cx">     };
</span><span class="cx">     if (auto range = std::exchange(m_rangeForDropSnapshot, WTF::nullopt)) {
</span><del>-        if (auto textIndicator = TextIndicator::createWithRange(createLiveRange(*range), defaultTextIndicatorOptionsForEditDrag, TextIndicatorPresentationTransition::None, { }))
</del><ins>+        if (auto textIndicator = TextIndicator::createWithRange(*range, defaultTextIndicatorOptionsForEditDrag, TextIndicatorPresentationTransition::None, { }))
</ins><span class="cx">             textIndicatorData = textIndicator->data();
</span><span class="cx">     }
</span><span class="cx">     send(Messages::WebPageProxy::DidReceiveEditDragSnapshot(WTFMove(textIndicatorData)));
</span><span class="lines">@@ -1982,8 +1982,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Vector<WebCore::SelectionRect> selectionRects;
-    createLiveRange(*range)->collectSelectionRectsWithoutUnionInteriorLines(selectionRects);
</del><ins>+    auto selectionRects = RenderObject::collectSelectionRectsWithoutUnionInteriorLines(*range);
</ins><span class="cx">     convertContentToRootViewSelectionRects(*frame.view(), selectionRects);
</span><span class="cx">     send(Messages::WebPageProxy::SelectionRectsCallback(selectionRects, callbackID));
</span><span class="cx"> }
</span><span class="lines">@@ -2029,8 +2028,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Vector<WebCore::SelectionRect> selectionRects;
-    createLiveRange(range)->collectSelectionRectsWithoutUnionInteriorLines(selectionRects);
</del><ins>+    auto selectionRects = RenderObject::collectSelectionRectsWithoutUnionInteriorLines(*range);
</ins><span class="cx">     convertContentToRootViewSelectionRects(*frame.view(), selectionRects);
</span><span class="cx">     send(Messages::WebPageProxy::SelectionRectsCallback(selectionRects, callbackID));
</span><span class="cx"> }
</span><span class="lines">@@ -2332,7 +2330,7 @@
</span><span class="cx"> 
</span><span class="cx">     Vector<SelectionRect> selectionRects;
</span><span class="cx">     if (textForRange == textForAutocorrection)
</span><del>-        createLiveRange(range)->collectSelectionRects(selectionRects);
</del><ins>+        selectionRects = RenderObject::collectSelectionRects(*range);
</ins><span class="cx"> 
</span><span class="cx">     auto rootViewSelectionRects = selectionRects.map([&](const auto& selectionRect) -> FloatRect { return frame.view()->contentsToRootView(selectionRect.rect()); });
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitLegacyiosChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/ios/ChangeLog (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/ios/ChangeLog  2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/ios/ChangeLog     2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2020-08-02  Darin Adler  <darin@apple.com>
+
+        Remove some member functions of Range and many calls to createLiveRange
+        https://bugs.webkit.org/show_bug.cgi?id=215070
+
+        Reviewed by Sam Weinig.
+
+        * WebCoreSupport/WebFrameIOS.mm:
+        (-[WebFrame selectionRectsForCoreRange:]): Remove createLiveRange.
+        (-[WebFrame selectionRectsForRange:]): Use makeSimpleRange.
+        * WebCoreSupport/WebVisiblePosition.mm:
+        (-[WebVisiblePosition enclosingRangeWithDictationPhraseAlternatives:]): Ditto.
+        (-[WebVisiblePosition enclosingRangeWithCorrectionIndicator]): Ditto.
+        (+[DOMRange rangeForFirstPosition:second:]): Rename firstVP/secondVP
+        to firstPosition/secondPosition.
+
</ins><span class="cx"> 2020-08-01  Darin Adler  <darin@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Remove Range::create and many more uses of live ranges
</span></span></pre></div>
<a id="trunkSourceWebKitLegacyiosWebCoreSupportWebFrameIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebFrameIOS.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebFrameIOS.mm      2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebFrameIOS.mm 2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -206,10 +206,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (NSArray *)selectionRectsForCoreRange:(const SimpleRange&)range
</span><span class="cx"> {
</span><del>-    Vector<SelectionRect> rects;
-    createLiveRange(range)->collectSelectionRects(rects);
-
-    return createNSArray(rects, [] (auto& coreRect) {
</del><ins>+    return createNSArray(RenderObject::collectSelectionRects(range), [] (auto& coreRect) {
</ins><span class="cx">         auto webRect = [WebSelectionRect selectionRect];
</span><span class="cx">         webRect.rect = coreRect.rect();
</span><span class="cx">         webRect.writingDirection = coreRect.direction() == TextDirection::LTR ? WKWritingDirectionLeftToRight : WKWritingDirectionRightToLeft;
</span><span class="lines">@@ -226,7 +223,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (NSArray *)selectionRectsForRange:(DOMRange *)domRange
</span><span class="cx"> {
</span><del>-    auto range = core(domRange);
</del><ins>+    auto range = makeSimpleRange(core(domRange));
</ins><span class="cx">     return range ? [self selectionRectsForCoreRange:*range] : nil;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitLegacyiosWebCoreSupportWebVisiblePositionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebVisiblePosition.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebVisiblePosition.mm       2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebVisiblePosition.mm  2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -416,7 +416,7 @@
</span><span class="cx">     for (auto marker : document.markers().markersFor(*node, DocumentMarker::DictationPhraseWithAlternatives)) {
</span><span class="cx">         if (marker->startOffset() <= offset && marker->endOffset() >= offset) {
</span><span class="cx">             *alternatives = createNSArray(WTF::get<Vector<String>>(marker->data())).autorelease();
</span><del>-            return kit(range(*node, *marker));
</del><ins>+            return kit(makeSimpleRange(*node, *marker));
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     return nil;
</span><span class="lines">@@ -433,7 +433,7 @@
</span><span class="cx">     auto& document = node->document();
</span><span class="cx">     for (auto marker : document.markers().markersFor(*node, DocumentMarker::Spelling)) {
</span><span class="cx">         if (marker->startOffset() <= offset && marker->endOffset() >= offset)
</span><del>-            return kit(range(*node, *marker));
</del><ins>+            return kit(makeSimpleRange(*node, *marker));
</ins><span class="cx">     }
</span><span class="cx">     return nil;
</span><span class="cx"> }
</span><span class="lines">@@ -475,11 +475,11 @@
</span><span class="cx"> 
</span><span class="cx"> + (DOMRange *)rangeForFirstPosition:(WebVisiblePosition *)first second:(WebVisiblePosition *)second
</span><span class="cx"> {
</span><del>-    auto firstVP = [first _visiblePosition];
-    auto secondVP = [second _visiblePosition];
-    if (firstVP < secondVP)
-        std::swap(firstVP, secondVP);
-    return kit(makeSimpleRange(firstVP, secondVP));
</del><ins>+    auto firstPosition = [first _visiblePosition];
+    auto secondPosition = [second _visiblePosition];
+    if (firstPosition < secondPosition)
+        std::swap(firstPosition, secondPosition);
+    return kit(makeSimpleRange(firstPosition, secondPosition));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/ChangeLog  2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog     2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -1,3 +1,54 @@
</span><ins>+2020-08-02  Darin Adler  <darin@apple.com>
+
+        Remove some member functions of Range and many calls to createLiveRange
+        https://bugs.webkit.org/show_bug.cgi?id=215070
+
+        Reviewed by Sam Weinig.
+
+        * DOM/DOM.mm:
+        (-[DOMRange renderedImageForcingBlackText:renderedImageForcingBlackText:]):
+        Use makeSimpleRange.
+        (-[DOMRange textRects]): Ditto.
+
+        * DOM/DOMDocument.mm: Update includes.
+        * DOM/DOMRange.mm: Ditto.
+        * DOM/DOMRangeInternal.h: Ditto.
+        * DOM/DOMUIKitExtensions.mm: Ditto.
+        * DOM/DOMUtility.mm: Ditto.
+
+        * DOM/WebDOMOperations.mm:
+        (-[DOMRange webArchive]): Use makeSimpleRange.
+        (-[DOMRange markupString]): Ditto.
+
+        * WebView/WebFrame.mm:
+        (-[WebFrame _stringForRange:]): Use makeSimpleRange.
+        (-[WebFrame _convertToDOMRange:]): Return a SimpleRange.
+        (-[WebFrame _convertToDOMRange:rangeIsRelativeTo:]): Ditto.
+        (-[WebFrame _convertNSRangeToDOMRange:]): Update for above.
+        (-[WebFrame _convertDOMRangeToNSRange:]): Use makeSimpleRange.
+        (-[WebFrame _selectNSRange:]): Update for above.
+        (-[WebFrame selectWithoutClosingTypingNSRange:]): Ditto.
+        (-[WebFrame getDictationResultRanges:andMetadatas:]): Use makeSimpleRange.
+        (-[WebFrame dictationResultMetadataForRange:]): Ditto.
+        * WebView/WebFrameInternal.h: Update for above.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _documentFragmentFromPasteboard:forType:inContext:subresources:]):
+        Use makeSimpleRange.
+        (-[WebHTMLView attributedSubstringFromRange:]): Use auto.
+        (-[WebHTMLView _attributedStringFromDOMRange:]): Deleted.
+        (-[WebHTMLView attributedString]): Rewrote to use SimpleRange consistently.
+        (-[WebHTMLView selectedAttributedString]): Ditto.
+
+        * WebView/WebImmediateActionController.mm:
+        (-[WebImmediateActionController _animationControllerForDataDetectedText]):
+        Use makeSimpleRange.
+        * WebView/WebTextIterator.mm:
+        (-[WebTextIterator initWithRange:]): Ditto.
+
+        * WebView/WebView.mm:
+        (-[WebView _didConcludeEditDrag]): Remove createLiveRange.
+
</ins><span class="cx"> 2020-08-01  Darin Adler  <darin@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Remove Range::create and many more uses of live ranges
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacDOMDOMmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/DOM/DOM.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/DOM/DOM.mm 2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOM.mm    2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -581,31 +581,27 @@
</span><span class="cx"> - (CGImageRef)renderedImageForcingBlackText:(BOOL)forceBlackText
</span><span class="cx"> #endif
</span><span class="cx"> {
</span><del>-    auto& range = *core(self);
-    auto* frame = range.ownerDocument().frame();
</del><ins>+    auto range = makeSimpleRange(*core(self));
+    auto frame = makeRefPtr(range.start.container->document().frame());
</ins><span class="cx">     if (!frame)
</span><span class="cx">         return nil;
</span><span class="cx"> 
</span><del>-    Ref<Frame> protectedFrame(*frame);
</del><ins>+    auto renderedImage = createDragImageForRange(*frame, range, forceBlackText);
</ins><span class="cx"> 
</span><ins>+#if PLATFORM(MAC)
</ins><span class="cx">     // iOS uses CGImageRef for drag images, which doesn't support separate logical/physical sizes.
</span><del>-#if PLATFORM(MAC)
-    RetainPtr<NSImage> renderedImage = createDragImageForRange(*frame, range, forceBlackText);
-
</del><span class="cx">     IntSize size([renderedImage size]);
</span><span class="cx">     size.scale(1 / frame->page()->deviceScaleFactor());
</span><span class="cx">     [renderedImage setSize:size];
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     return renderedImage.autorelease();
</span><del>-#else
-    return createDragImageForRange(*frame, range, forceBlackText).autorelease();
-#endif
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (NSArray *)textRects
</span><span class="cx"> {
</span><del>-    auto& range = *core(self);
-    range.ownerDocument().updateLayoutIgnorePendingStylesheets();
</del><ins>+    auto range = makeSimpleRange(*core(self));
+    range.start.container->document().updateLayoutIgnorePendingStylesheets();
</ins><span class="cx">     return createNSArray(RenderObject::absoluteTextRects(range)).autorelease();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacDOMDOMDocumentmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMDocument.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/DOM/DOMDocument.mm 2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMDocument.mm    2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -76,6 +76,7 @@
</span><span class="cx"> #import <WebCore/ProcessingInstruction.h>
</span><span class="cx"> #import <WebCore/Range.h>
</span><span class="cx"> #import <WebCore/SecurityOrigin.h>
</span><ins>+#import <WebCore/SimpleRange.h>
</ins><span class="cx"> #import <WebCore/StyleProperties.h>
</span><span class="cx"> #import <WebCore/StyleSheetList.h>
</span><span class="cx"> #import <WebCore/Text.h>
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacDOMDOMRangemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMRange.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/DOM/DOMRange.mm    2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMRange.mm       2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -31,8 +31,8 @@
</span><span class="cx"> #import <WebCore/DocumentFragment.h>
</span><span class="cx"> #import "ExceptionHandlers.h"
</span><span class="cx"> #import <WebCore/JSExecState.h>
</span><del>-#import <WebCore/Node.h>
</del><span class="cx"> #import <WebCore/Range.h>
</span><ins>+#import <WebCore/SimpleRange.h>
</ins><span class="cx"> #import <WebCore/ThreadCheck.h>
</span><span class="cx"> #import <WebCore/WebCoreObjCExtras.h>
</span><span class="cx"> #import <WebCore/WebScriptObjectPrivate.h>
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacDOMDOMRangeInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMRangeInternal.h (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/DOM/DOMRangeInternal.h     2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMRangeInternal.h        2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -23,9 +23,14 @@
</span><span class="cx">  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-#import <WebCore/SimpleRange.h>
-#import <WebKitLegacy/DOMRange.h>
</del><ins>+#import "DOMRange.h"
+#import <wtf/Forward.h>
</ins><span class="cx"> 
</span><ins>+namespace WebCore {
+class Range;
+struct SimpleRange;
+}
+
</ins><span class="cx"> WebCore::Range* core(DOMRange *);
</span><span class="cx"> DOMRange *kit(WebCore::Range*);
</span><span class="cx"> DOMRange *kit(const Optional<WebCore::SimpleRange>&);
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacDOMDOMUIKitExtensionsmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMUIKitExtensions.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/DOM/DOMUIKitExtensions.mm  2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMUIKitExtensions.mm     2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx"> #import <WebCore/RenderText.h>
</span><span class="cx"> #import <WebCore/RoundedRect.h>
</span><span class="cx"> #import <WebCore/SharedBuffer.h>
</span><ins>+#import <WebCore/SimpleRange.h>
</ins><span class="cx"> #import <WebCore/VisiblePosition.h>
</span><span class="cx"> #import <WebCore/VisibleUnits.h>
</span><span class="cx"> #import <WebCore/WAKAppKitStubs.h>
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacDOMDOMUtilitymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMUtility.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/DOM/DOMUtility.mm  2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMUtility.mm     2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -70,6 +70,7 @@
</span><span class="cx"> #import <WebCore/JSWindowProxy.h>
</span><span class="cx"> #import <WebCore/JSXPathExpression.h>
</span><span class="cx"> #import <WebCore/JSXPathResult.h>
</span><ins>+#import <WebCore/SimpleRange.h>
</ins><span class="cx"> #import <WebCore/WebScriptObjectPrivate.h>
</span><span class="cx"> 
</span><span class="cx"> static WebScriptObject *createDOMWrapper(JSC::JSObject& jsWrapper)
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacDOMWebDOMOperationsmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/DOM/WebDOMOperations.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/DOM/WebDOMOperations.mm    2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/mac/DOM/WebDOMOperations.mm       2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx"> #import <WebCore/RenderElement.h>
</span><span class="cx"> #import <WebCore/RenderTreeAsText.h>
</span><span class="cx"> #import <WebCore/ShadowRoot.h>
</span><ins>+#import <WebCore/SimpleRange.h>
</ins><span class="cx"> #import <WebCore/WheelEvent.h>
</span><span class="cx"> #import <WebCore/markup.h>
</span><span class="cx"> #import <WebKitLegacy/DOMExtensions.h>
</span><span class="lines">@@ -185,13 +186,13 @@
</span><span class="cx"> 
</span><span class="cx"> - (WebArchive *)webArchive
</span><span class="cx"> {
</span><del>-    return [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(*core(self))] autorelease];
</del><ins>+    return [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(makeSimpleRange(*core(self)))] autorelease];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (NSString *)markupString
</span><span class="cx"> {
</span><span class="cx">     auto& range = *core(self);
</span><del>-    return String { documentTypeString(range.startContainer().document()) + serializePreservingVisualAppearance(range, nullptr, AnnotateForInterchange::Yes) };
</del><ins>+    return String { documentTypeString(range.ownerDocument()) + serializePreservingVisualAppearance(makeSimpleRange(range), nullptr, AnnotateForInterchange::Yes) };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacWebViewWebFramemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm        2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm   2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -582,7 +582,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (!range)
</span><span class="cx">         return @"";
</span><del>-    return plainText(*core(range), WebCore::TextIteratorDefaultBehavior, true);
</del><ins>+    return plainText(makeSimpleRange(*core(range)), WebCore::TextIteratorDefaultBehavior, true);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (OptionSet<WebCore::PaintBehavior>)_paintBehaviorForDestinationContext:(CGContextRef)context
</span><span class="lines">@@ -809,15 +809,15 @@
</span><span class="cx">     return characterRange(makeBoundaryPointBeforeNodeContents(*element), range);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (RefPtr<WebCore::Range>)_convertToDOMRange:(NSRange)nsrange
</del><ins>+- (Optional<WebCore::SimpleRange>)_convertToDOMRange:(NSRange)nsrange
</ins><span class="cx"> {
</span><span class="cx">     return [self _convertToDOMRange:nsrange rangeIsRelativeTo:WebRangeIsRelativeTo::EditableRoot];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (RefPtr<WebCore::Range>)_convertToDOMRange:(NSRange)range rangeIsRelativeTo:(WebRangeIsRelativeTo)rangeIsRelativeTo
</del><ins>+- (Optional<WebCore::SimpleRange>)_convertToDOMRange:(NSRange)range rangeIsRelativeTo:(WebRangeIsRelativeTo)rangeIsRelativeTo
</ins><span class="cx"> {
</span><span class="cx">     if (range.location == NSNotFound)
</span><del>-        return nullptr;
</del><ins>+        return WTF::nullopt;
</ins><span class="cx"> 
</span><span class="cx">     if (rangeIsRelativeTo == WebRangeIsRelativeTo::EditableRoot) {
</span><span class="cx">         // Our critical assumption is that this code path is only called by input methods that
</span><span class="lines">@@ -828,8 +828,8 @@
</span><span class="cx">         // That fits with AppKit's idea of an input context.
</span><span class="cx">         auto* element = _private->coreFrame->selection().rootEditableElementOrDocumentElement();
</span><span class="cx">         if (!element)
</span><del>-            return nullptr;
-        return createLiveRange(resolveCharacterRange(makeRangeSelectingNodeContents(*element), range));
</del><ins>+            return WTF::nullopt;
+        return resolveCharacterRange(makeRangeSelectingNodeContents(*element), range);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT(rangeIsRelativeTo == WebRangeIsRelativeTo::Paragraph);
</span><span class="lines">@@ -836,15 +836,15 @@
</span><span class="cx"> 
</span><span class="cx">     auto paragraphStart = makeBoundaryPoint(startOfParagraph(_private->coreFrame->selection().selection().visibleStart()));
</span><span class="cx">     if (!paragraphStart)
</span><del>-        return nullptr;
</del><ins>+        return WTF::nullopt;
</ins><span class="cx"> 
</span><span class="cx">     auto scopeEnd = makeBoundaryPointAfterNodeContents(paragraphStart->container->treeScope().rootNode());
</span><del>-    return createLiveRange(WebCore::resolveCharacterRange({ WTFMove(*paragraphStart), WTFMove(scopeEnd) }, range));
</del><ins>+    return WebCore::resolveCharacterRange({ WTFMove(*paragraphStart), WTFMove(scopeEnd) }, range);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (DOMRange *)_convertNSRangeToDOMRange:(NSRange)nsrange
</span><span class="cx"> {
</span><del>-    return kit([self _convertToDOMRange:nsrange].get());
</del><ins>+    return kit([self _convertToDOMRange:nsrange]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (NSRange)_convertDOMRangeToNSRange:(DOMRange *)range
</span><span class="lines">@@ -851,7 +851,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (!range)
</span><span class="cx">         return NSMakeRange(NSNotFound, 0);
</span><del>-    return [self _convertToNSRange:*core(range)];
</del><ins>+    return [self _convertToNSRange:makeSimpleRange(*core(range))];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (DOMRange *)_markDOMRange
</span><span class="lines">@@ -1129,8 +1129,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_selectNSRange:(NSRange)range
</span><span class="cx"> {
</span><del>-    RefPtr<WebCore::Range> domRange = [self _convertToDOMRange:range];
-    if (domRange)
</del><ins>+    if (auto domRange = [self _convertToDOMRange:range])
</ins><span class="cx">         _private->coreFrame->selection().setSelection(WebCore::VisibleSelection(*domRange, WebCore::SEL_DEFAULT_AFFINITY));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1217,11 +1216,8 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)selectWithoutClosingTypingNSRange:(NSRange)range
</span><span class="cx"> {
</span><del>-    RefPtr<WebCore::Range> domRange = [self _convertToDOMRange:range];
-    if (domRange) {
-        const auto& newSelection = WebCore::VisibleSelection(*domRange, WebCore::SEL_DEFAULT_AFFINITY);
-        _private->coreFrame->selection().setSelection(newSelection, { });
-        
</del><ins>+    if (auto domRange = [self _convertToDOMRange:range]) {
+        _private->coreFrame->selection().setSelection(*domRange, { });
</ins><span class="cx">         _private->coreFrame->editor().ensureLastEditCommandHasCurrentSelectionIfOpenForMoreTyping();
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -1741,7 +1737,7 @@
</span><span class="cx">             if (!metadata)
</span><span class="cx">                 continue;
</span><span class="cx">             
</span><del>-            DOMRange *domRange = kit(range(*node, *marker));
</del><ins>+            DOMRange *domRange = kit(makeSimpleRange(*node, *marker));
</ins><span class="cx"> 
</span><span class="cx">             if (metadata != previousMetadata) {
</span><span class="cx">                 [metadatas addObject:metadata];
</span><span class="lines">@@ -1774,7 +1770,7 @@
</span><span class="cx">     if (!range)
</span><span class="cx">         return nil;
</span><span class="cx"> 
</span><del>-    auto markers = core(self)->document()->markers().markersInRange(*core(range), WebCore::DocumentMarker::DictationResult);
</del><ins>+    auto markers = core(self)->document()->markers().markersInRange(makeSimpleRange(*core(range)), WebCore::DocumentMarker::DictationResult);
</ins><span class="cx"> 
</span><span class="cx">     // UIKit should only ever give us a DOMRange for a phrase with alternatives, which should not be part of more than one result.
</span><span class="cx">     ASSERT(markers.size() <= 1);
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacWebViewWebFrameInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/WebView/WebFrameInternal.h (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/WebView/WebFrameInternal.h 2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebFrameInternal.h    2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -166,8 +166,8 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> - (NSRange)_convertToNSRange:(const WebCore::SimpleRange&)range;
</span><del>-- (RefPtr<WebCore::Range>)_convertToDOMRange:(NSRange)range;
-- (RefPtr<WebCore::Range>)_convertToDOMRange:(NSRange)range rangeIsRelativeTo:(WebRangeIsRelativeTo)rangeIsRelativeTo;
</del><ins>+- (Optional<WebCore::SimpleRange>)_convertToDOMRange:(NSRange)range;
+- (Optional<WebCore::SimpleRange>)_convertToDOMRange:(NSRange)range rangeIsRelativeTo:(WebRangeIsRelativeTo)rangeIsRelativeTo;
</ins><span class="cx"> 
</span><span class="cx"> - (DOMDocumentFragment *)_documentFragmentWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString;
</span><span class="cx"> - (DOMDocumentFragment *)_documentFragmentWithNodesAsParagraphs:(NSArray *)nodes;
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacWebViewWebHTMLViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm     2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm        2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -2376,7 +2376,8 @@
</span><span class="cx">     if ([pboardType isEqualToString:WebCore::legacyStringPasteboardType()]) {
</span><span class="cx">         if (!context)
</span><span class="cx">             return nil;
</span><del>-        return kit(createFragmentFromText(*core(context), [[pasteboard stringForType:WebCore::legacyStringPasteboardType()] precomposedStringWithCanonicalMapping]).ptr());
</del><ins>+        auto string = [[pasteboard stringForType:WebCore::legacyStringPasteboardType()] precomposedStringWithCanonicalMapping];
+        return kit(createFragmentFromText(makeSimpleRange(*core(context)), string).ptr());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return nil;
</span><span class="lines">@@ -6413,7 +6414,7 @@
</span><span class="cx">         LOG(TextInput, "attributedSubstringFromRange:(%u, %u) -> nil", nsRange.location, nsRange.length);
</span><span class="cx">         return nil;
</span><span class="cx">     }
</span><del>-    RefPtr<WebCore::Range> range = [frame _convertToDOMRange:nsRange];
</del><ins>+    auto range = [frame _convertToDOMRange:nsRange];
</ins><span class="cx">     if (!range) {
</span><span class="cx">         LOG(TextInput, "attributedSubstringFromRange:(%u, %u) -> nil", nsRange.location, nsRange.length);
</span><span class="cx">         return nil;
</span><span class="lines">@@ -6981,21 +6982,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> 
</span><del>-- (NSAttributedString *)_attributedStringFromDOMRange:(DOMRange *)range
-{
-    if (!range)
-        return nil;
-#if !LOG_DISABLED
-    double start = CFAbsoluteTimeGetCurrent();
-#endif
-    auto result = attributedString(*core(range)).string.autorelease();
-#if !LOG_DISABLED
-    double duration = CFAbsoluteTimeGetCurrent() - start;
-    LOG(Timing, "creating attributed string from selection took %f seconds.", duration);
-#endif
-    return result;
-}
-
</del><span class="cx"> - (NSAttributedString *)_legacyAttributedStringFrom:(DOMNode *)startContainer offset:(int)startOffset to:(DOMNode *)endContainer offset:(int)endOffset
</span><span class="cx"> {
</span><span class="cx">     if (!startContainer || !endContainer)
</span><span class="lines">@@ -7006,28 +6992,26 @@
</span><span class="cx"> 
</span><span class="cx"> - (NSAttributedString *)attributedString
</span><span class="cx"> {
</span><del>-    DOMDocument *document = [[self _frame] DOMDocument];
</del><ins>+    auto document = core([[self _frame] DOMDocument]);
</ins><span class="cx">     if (!document)
</span><span class="cx">         return [[[NSAttributedString alloc] init] autorelease];
</span><del>-    if (auto attributedString = [self _attributedStringFromDOMRange:[document _documentRange]])
-        return attributedString;
-    return editingAttributedString(makeRangeSelectingNodeContents(*core(document))).string.autorelease();
</del><ins>+    auto range = makeRangeSelectingNodeContents(*document);
+    if (auto result = attributedString(range).string)
+        return result.autorelease();
+    return editingAttributedString(range).string.autorelease();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (NSAttributedString *)selectedAttributedString
</span><span class="cx"> {
</span><del>-    auto attributedString = retainPtr([self _attributedStringFromDOMRange:[self _selectedRange]]);
-    if (!attributedString) {
-        auto* coreFrame = core([self _frame]);
-        if (coreFrame) {
-            auto range = coreFrame->selection().selection().toNormalizedRange();
-            if (range)
-                attributedString = editingAttributedString(*range).string;
-            else
-                attributedString = adoptNS([[NSAttributedString alloc] init]);
-        }
-    }
-    return attributedString.autorelease();
</del><ins>+    auto frame = core([self _frame]);
+    if (!frame)
+        return [[[NSAttributedString alloc] init] autorelease];
+    auto range = frame->selection().selection().firstRange();
+    if (!range)
+        return [[[NSAttributedString alloc] init] autorelease];
+    if (auto result = attributedString(*range).string)
+        return result.autorelease();
+    return editingAttributedString(*range).string.autorelease();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacWebViewWebImmediateActionControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/WebView/WebImmediateActionController.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/WebView/WebImmediateActionController.mm    2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebImmediateActionController.mm       2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -422,7 +422,7 @@
</span><span class="cx">             detectedItem = { {
</span><span class="cx">                 actionContext,
</span><span class="cx">                 { }, // FIXME: Seems like an empty rect isn't really OK.
</span><del>-                *core(customDataDetectorsRange)
</del><ins>+                makeSimpleRange(*core(customDataDetectorsRange))
</ins><span class="cx">             } };
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -439,7 +439,7 @@
</span><span class="cx">     if (![[getDDActionsManagerClass() sharedManager] hasActionsForResult:[detectedItem->actionContext mainResult] actionContext:detectedItem->actionContext.get()])
</span><span class="cx">         return nil;
</span><span class="cx"> 
</span><del>-    auto indicator = WebCore::TextIndicator::createWithRange(createLiveRange(detectedItem->range), { }, WebCore::TextIndicatorPresentationTransition::FadeIn);
</del><ins>+    auto indicator = WebCore::TextIndicator::createWithRange(detectedItem->range, { }, WebCore::TextIndicatorPresentationTransition::FadeIn);
</ins><span class="cx"> 
</span><span class="cx">     _currentActionContext = [detectedItem->actionContext contextForView:_webView altMode:YES interactionStartedHandler:^() {
</span><span class="cx">     } interactionChangedHandler:^() {
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacWebViewWebTextIteratormm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/WebView/WebTextIterator.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/WebView/WebTextIterator.mm 2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebTextIterator.mm    2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx">     if (!range)
</span><span class="cx">         return self;
</span><span class="cx"> 
</span><del>-    _private->_textIterator = makeUnique<WebCore::TextIterator>(*core(range));
</del><ins>+    _private->_textIterator = makeUnique<WebCore::TextIterator>(makeSimpleRange(*core(range)));
</ins><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (265189 => 265190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2020-08-02 23:05:35 UTC (rev 265189)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm    2020-08-03 00:47:52 UTC (rev 265190)
</span><span class="lines">@@ -2137,7 +2137,7 @@
</span><span class="cx">     };
</span><span class="cx">     auto& frame = page->focusController().focusedOrMainFrame();
</span><span class="cx">     if (auto range = frame.selection().selection().toNormalizedRange()) {
</span><del>-        if (auto textIndicator = WebCore::TextIndicator::createWithRange(createLiveRange(*range), defaultEditDragTextIndicatorOptions, WebCore::TextIndicatorPresentationTransition::None, WebCore::FloatSize()))
</del><ins>+        if (auto textIndicator = WebCore::TextIndicator::createWithRange(*range, defaultEditDragTextIndicatorOptions, WebCore::TextIndicatorPresentationTransition::None, WebCore::FloatSize()))
</ins><span class="cx">             _private->dataOperationTextIndicator = adoptNS([[WebUITextIndicatorData alloc] initWithImage:nil textIndicatorData:textIndicator->data() scale:page->deviceScaleFactor()]);
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>