Remove Range::create and many more uses of live ranges
https://bugs.webkit.org/show_bug.cgi?id=215004
Reviewed by Sam Weinig.
Source/WebCore:
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::boundsForVisiblePositionRange const):
Use makeSimpleRange.
* accessibility/atk/AXObjectCacheAtk.cpp:
(WebCore::AXObjectCache::nodeTextChangePlatformNotification): Use SimpleRange.
* accessibility/atk/WebKitAccessibleHyperlink.cpp:
(rangeLengthForObject): Take SimpleRange.
(webkitAccessibleHyperlinkGetStartIndex): Use makeSimpleRange.
(webkitAccessibleHyperlinkGetEndIndex): Ditto.
* accessibility/atk/WebKitAccessibleInterfaceText.cpp:
(getSelectionOffsetsForObject): Ditto.
* accessibility/atk/WebKitAccessibleUtil.cpp:
(objectFocusedAndCaretOffsetUnignored): Ditto.
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(+[WebAccessibilityTextMarker startOrEndTextMarkerForRange:isStart:cache:]):
Take SimpleRange.
(-[WebAccessibilityObjectWrapper arrayOfTextForTextMarkers:attributed:]):
Use makeSimpleRange.
(-[WebAccessibilityObjectWrapper _convertToDOMRange:]): Return SimpleRange.
(-[WebAccessibilityObjectWrapper textMarkerRange]): Remove createLiveRange.
(-[WebAccessibilityObjectWrapper textMarkerForPosition:]): Use auto.
(-[WebAccessibilityObjectWrapper misspellingTextMarkerRange:forward:]):
Remove createLiveRange.
(-[WebAccessibilityObjectWrapper rangeFromMarkers:withText:]): Return SimpleRange.
(-[WebAccessibilityObjectWrapper textRectsFromMarkers:withText:]): Add createLiveRange.
(-[WebAccessibilityObjectWrapper rangeForTextMarkers:]): Return SimpleRange.
(-[WebAccessibilityObjectWrapper startOrEndTextMarkerForTextMarkers:isStart:]):
Use auto.
(-[WebAccessibilityObjectWrapper textMarkerRangeForMarkers:]): Get rid of local.
(-[WebAccessibilityObjectWrapper textMarkersForRange:]): Take SimpleRange.
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(accessibilityTextOperationForParameterizedAttribute): Remove makeSimpleRange.
(accessibilityMisspellingSearchCriteriaForParameterizedAttribute): Return SimpleRange.
(-[WebAccessibilityObjectWrapper textMarkerRangeFromRange:]): Take SimpleRange.
(textMarkerRangeFromRange): Ditto.
(-[WebAccessibilityObjectWrapper startOrEndTextMarkerForRange:isStart:]): Ditto.
(startOrEndTextmarkerForRange): Return SimpleRange.
(-[WebAccessibilityObjectWrapper rangeForTextMarkerRange:]): Ditto.
(-[WebAccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:spellCheck:]):
Use auto.
(-[WebAccessibilityObjectWrapper doAXAttributedStringForRange:]): Remove createLiveRange.
(-[WebAccessibilityObjectWrapper textMarkerRangeAtTextMarker:forUnit:]): Ditto.
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]): Ditto.
* dom/DocumentMarkerController.cpp:
(WebCore::updateRenderedRectsForMarker): Use document marker range function.
(WebCore::range): Added.
* dom/DocumentMarkerController.h: Update for above.
* dom/Position.cpp: Removed unneeded Range.h include.
* dom/Range.cpp:
(WebCore::Range::Range): Removed unused overload that takes start/end.
(WebCore::Range::create): Removed overloads that take start/end.
(WebCore::Range::setStart): Removed overload that takes Position.
(WebCore::Range::setEnd): Ditto.
(WebCore::Range::cloneRange const): Rewrote to use setStart/End since
that's what the constructor used to do.
(WebCore::Range::contains const): Use SimpleRange/createLiveRange
instead of makeRange. Soon this function will be deleted.
(WebCore::rangeOfContents): Deleted.
(WebCore::createLiveRange): Rewrote to use setStart/End since that's
what the constructor used to do.
* dom/Range.h: Update for above removals.
* dom/SimpleRange.h: Export commonInclusiveAncestor for use outside WebCore.
* dom/StaticRange.cpp:
(WebCore::StaticRange::create): Added overload that copies the SimpleRange.
* dom/StaticRange.h: Update for above.
* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::respondToMarkerAtEndOfWord): Use document
marker range function.
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::fixRangeAndApplyInlineStyle): Use makeSimpleRange.
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::mergeParagraphs): Ditto.
(WebCore::DeleteSelectionCommand::originalStringForAutocorrectionAtBeginningOfSelection):
Ditto.
* editing/EditingStyle.cpp:
(WebCore::EditingStyle::textDirectionForSelection): Use makeSimpleRange and
intersectingNodes.
* editing/Editor.cpp:
(WebCore::Editor::replaceSelectionWithFragment): Use makeRangeSelectingNodeContents.
(WebCore::Editor::updateMarkersForWordsAffectedByEditing): Use makeSimpleRange.
(WebCore::Editor::transpose): Ditto.
(WebCore::Editor::rangeOfString): Use makeRangeSelectingNodeContents.
(WebCore::Editor::handleAcceptedCandidate): Update since rangeForTextCheckingResult
now returns an Optional<SimpleRange>.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectRangeOnElement): Use SimpleRange.
* editing/ReplaceRangeWithTextCommand.cpp:
(WebCore::ReplaceRangeWithTextCommand::ReplaceRangeWithTextCommand): Take
SimpleRange.
(WebCore::ReplaceRangeWithTextCommand::willApplyCommand): Update since
m_rangeToBeReplaced is a SimpleRange.
(WebCore::ReplaceRangeWithTextCommand::doApply): Ditto.
(WebCore::ReplaceRangeWithTextCommand::targetRanges const): Ditto.
* editing/ReplaceRangeWithTextCommand.h: Update for above.
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::insertedContentRange const):
Return a SimpleRange.
* editing/ReplaceSelectionCommand.h: Update for above.
* editing/SpellingCorrectionCommand.cpp:
(WebCore::SpellingCorrectionCommand::SpellingCorrectionCommand):
Take a SimpleRange.
(WebCore::SpellingCorrectionCommand::create): Moved here from header.
* editing/SpellingCorrectionCommand.h: Update for above.
* editing/TextCheckingHelper.cpp:
(WebCore::TextCheckingHelper::findFirstMisspelledWordOrUngrammaticalPhrase const):
Use makeSimpleRange.
* editing/TypingCommand.cpp:
(WebCore::TypingCommand::markMisspellingsAfterTyping): Use makeSimpleRange.
(WebCore::TypingCommand::willAddTypingToOpenCommand): Take SimpleRange.
(WebCore::TypingCommand::deleteKeyPressed): Remove createLiveRange.
(WebCore::TypingCommand::forwardDeleteKeyPressed): Ditto.
* editing/TypingCommand.h: Update for above.
* editing/VisiblePosition.cpp:
(WebCore::makeRange): Deleted.
(WebCore::startVisiblePosition): Deleted.
(WebCore::endVisiblePosition): Deleted.
(WebCore::setStart): Deleted.
(WebCore::setEnd): Deleted.
* editing/VisiblePosition.h: Update for above. Also export makeSimpleRange
for use outside WebCore.
* editing/VisibleUnits.cpp:
(WebCore::suffixLengthForRange): Take SimpleRange.
(WebCore::prefixLengthForRange): Ditto.
(WebCore::previousBoundary): Use makeSimpleRange.
(WebCore::nextBoundary): Ditto.
* editing/VisibleUnits.h: Update for above.
* editing/cocoa/DataDetection.mm:
(WebCore::buildQuery): Remove unused local variable.
* editing/ios/EditorIOS.mm:
(WebCore::Editor::setDictationPhrasesAsChildOfElement): Use makeRangeSelectingNodeContents.
* page/DOMSelection.cpp:
(WebCore::DOMSelection::getRangeAt): Use createLiveRange.
* page/DragController.cpp:
(WebCore::DragController::insertDroppedImagePlaceholdersAtCaret): Remove makeSimpleRange.
* page/Frame.cpp:
(WebCore::Frame::rangeForPoint): Return SimpleRange.
* page/Frame.h: Update for above.
* page/ios/FrameIOS.mm:
(WebCore::Frame::interpretationsForCurrentRoot const): Use makeRangeSelectingNodeContents,
intersectingNodes, and makeSimpleRange.
* testing/Internals.cpp:
(WebCore::Internals::markerRangeForNode): Use createLiveRange and the document
marker range function.
Source/WebKit:
* WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp:
(API::PageOverlayClientImpl::actionContextForResultAtPoint): Return a
structure that includes a SimpleRange.
* WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
(WebKit::InjectedBundleNodeHandle::visibleRange): Use makeSimpleRange.
* WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.h: Use SimpleRange.
* WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.mm:
(WebKit::TextCheckingControllerProxy::rangeAndOffsetRelativeToSelection): Use SimpleRange.
(WebKit::TextCheckingControllerProxy::replaceRelativeToSelection): Ditto.
(WebKit::TextCheckingControllerProxy::removeAnnotationRelativeToSelection): Ditto.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::characterIndexForPointAsync): Remove makeSimpleRange.
(WebKit::WebPage::deleteSurrounding): Use makeSimpleRange.
* WebProcess/WebPage/WebPageOverlay.cpp:
(WebKit::WebPageOverlay::actionContextForResultAtPoint): Use return value instead of out argument.
* WebProcess/WebPage/WebPageOverlay.h: Update for above.
* WebProcess/WebPage/glib/WebPageGLib.cpp:
(WebKit::WebPage::getPlatformEditorState const): Use makeSimpleRange.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::computeEditableRootHasContentAndPlainText): Use makeSimpleRange.
(WebKit::WebPage::getRectsForGranularityWithSelectionOffset): Removed unneeded null checks that
are already done by makeSimpleRange.
(WebKit::WebPage::getRectsAtSelectionOffsetWithText): Use makeSimpleRange.
(WebKit::WebPage::requestDictationContext): Ditto.
(WebKit::WebPage::autocorrectionContext): Ditto.
(WebKit::linkIndicatorPositionInformation): Use makeRangeSelectingNodeContents.
(WebKit::dataDetectorLinkPositionInformation): Ditto.
(WebKit::WebPage::requestDocumentEditingContext): Use makeSimpleRange.
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::performImmediateActionHitTestAtLocation): Update for change to the
actionContextForResultAtPoint return value.
Source/WebKitLegacy/ios:
* WebCoreSupport/WebFrameIOS.mm:
(-[WebFrame wordAtPoint:]): Use makeSimpleRange.
* WebCoreSupport/WebVisiblePosition.mm:
(-[WebVisiblePosition enclosingRangeWithDictationPhraseAlternatives:]): Use document
marker range function.
(-[WebVisiblePosition enclosingRangeWithCorrectionIndicator]): Ditto.
(+[DOMRange rangeForFirstPosition:second:]): Use makeSimpleRange.
Source/WebKitLegacy/mac:
* DOM/DOMUIKitExtensions.mm:
(-[DOMNode rangeOfContainingParagraph]): Use makeSimpleRange.
* WebView/WebFrame.mm:
(-[WebFrame _characterRangeAtPoint:]): Update since rangeAtPoint takes a SimpleRange.
(-[WebFrame getDictationResultRanges:andMetadatas:]): Use document marker range function.
* WebView/WebImmediateActionController.mm:
(-[WebImmediateActionController _defaultAnimationController]): Use makeRangeSelectingNodeContents.
(-[WebImmediateActionController _animationControllerForDataDetectedLink]): Ditto.
Source/WebKitLegacy/win:
* AccessibleTextImpl.cpp:
(AccessibleText::scrollSubstringTo): Use makeSimpleRange.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@265176 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/editing/TypingCommand.cpp b/Source/WebCore/editing/TypingCommand.cpp
index d015102..fc97577 100644
--- a/Source/WebCore/editing/TypingCommand.cpp
+++ b/Source/WebCore/editing/TypingCommand.cpp
@@ -449,7 +449,7 @@
VisiblePosition p1 = startOfWord(previous, LeftWordIfOnBoundary);
VisiblePosition p2 = startOfWord(start, LeftWordIfOnBoundary);
if (p1 != p2) {
- RefPtr<Range> range = makeRange(p1, p2);
+ auto range = makeSimpleRange(p1, p2);
String strippedPreviousWord;
if (range && (commandType == TypingCommand::InsertText || commandType == TypingCommand::InsertLineBreak || commandType == TypingCommand::InsertParagraphSeparator || commandType == TypingCommand::InsertParagraphSeparatorInQuotedContent))
strippedPreviousWord = plainText(*range).stripWhiteSpace();
@@ -475,7 +475,7 @@
}
}
-bool TypingCommand::willAddTypingToOpenCommand(ETypingCommand commandType, TextGranularity granularity, const String& text, RefPtr<Range>&& range)
+bool TypingCommand::willAddTypingToOpenCommand(ETypingCommand commandType, TextGranularity granularity, const String& text, const Optional<SimpleRange>& range)
{
m_currentTextToInsert = text;
m_currentTypingEditAction = editActionForTypingCommand(commandType, granularity, m_compositionType, m_isAutocompletion);
@@ -661,7 +661,7 @@
if (previousPosition.isNull() || enclosingTableCell != enclosingTableCellForPreviousPosition) {
// When the caret is at the start of the editable area in an empty list item, break out of the list item.
if (auto deleteListSelection = shouldBreakOutOfEmptyListItem()) {
- if (willAddTypingToOpenCommand(DeleteKey, granularity, { }, Range::create(document(), deleteListSelection.value().start(), deleteListSelection.value().end()))) {
+ if (willAddTypingToOpenCommand(DeleteKey, granularity, { }, *deleteListSelection.value().firstRange())) {
breakOutOfEmptyListItem();
typingAddedToOpenCommand(DeleteKey);
}
@@ -731,7 +731,7 @@
if (selectionToDelete.isCaret() || !document().selection().shouldDeleteSelection(selectionToDelete))
return;
- if (!willAddTypingToOpenCommand(DeleteKey, granularity, { }, createLiveRange(*selectionToDelete.firstRange())))
+ if (!willAddTypingToOpenCommand(DeleteKey, granularity, { }, selectionToDelete.firstRange()))
return;
if (shouldAddToKillRing)
@@ -839,7 +839,7 @@
if (selectionToDelete.isCaret() || !document().selection().shouldDeleteSelection(selectionToDelete))
return;
- if (!willAddTypingToOpenCommand(ForwardDeleteKey, granularity, { }, createLiveRange(selectionToDelete.firstRange())))
+ if (!willAddTypingToOpenCommand(ForwardDeleteKey, granularity, { }, selectionToDelete.firstRange()))
return;
// Post the accessibility notification before actually deleting the content while selectionToDelete is still valid