Skip to content
Permalink
Browse files
Drop [UsePointersEvenForNonNullableObjectArguments] from Range
https://bugs.webkit.org/show_bug.cgi?id=156805

Reviewed by Youenn Fablet.

Source/WebCore:

No new tests, no web-exposed behavior change.

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::rangeForNodeContents):
(WebCore::characterOffsetsInOrder):
(WebCore::setRangeStartOrEndWithCharacterOffset):
(WebCore::AXObjectCache::startOrEndCharacterOffsetForRange):
(WebCore::AXObjectCache::previousBoundary):
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::selectText):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::documentBasedSelectedTextRange):
* dom/Node.cpp:
(WebCore::Node::textRects):
* dom/Range.cpp:
(WebCore::Range::Range):
(WebCore::Range::setDocument):
(WebCore::Range::setStart):
(WebCore::Range::setEnd):
(WebCore::Range::isPointInRange):
(WebCore::Range::comparePoint):
(WebCore::Range::compareNode):
(WebCore::Range::compareBoundaryPoints):
(WebCore::Range::compareBoundaryPointsForBindings):
(WebCore::Range::intersectsNode):
(WebCore::Range::processContents):
(WebCore::Range::insertNode):
(WebCore::Range::checkNodeWOffset):
(WebCore::Range::setStartAfter):
(WebCore::Range::setEndBefore):
(WebCore::Range::setEndAfter):
(WebCore::Range::selectNode):
(WebCore::Range::selectNodeContents):
(WebCore::Range::surroundContents):
(WebCore::Range::setStartBefore):
(WebCore::Range::contains):
(WebCore::rangesOverlap):
(WebCore::rangeOfContents):
(WebCore::boundaryNodeChildrenWillBeRemoved):
(WebCore::boundaryTextNodesMerged):
(WebCore::boundaryTextNodesSplit):
(WebCore::Range::expand):
(WebCore::checkForDifferentRootContainer): Deleted.
(WebCore::highestAncestorUnderCommonRoot): Deleted.
(WebCore::childOfCommonRootBeforeOffset): Deleted.
(WebCore::deleteCharacterData): Deleted.
(WebCore::Range::toString): Deleted.
(WebCore::Range::toHTML): Deleted.
(WebCore::Range::text): Deleted.
(WebCore::Range::cloneRange): Deleted.
(WebCore::Range::absoluteTextRects): Deleted.
(WebCore::Range::absoluteTextQuads): Deleted.
(WebCore::boundaryNodeChildrenChanged): Deleted.
(WebCore::boundaryNodeWillBeRemoved): Deleted.
(WebCore::Range::nodeWillBeRemoved): Deleted.
(WebCore::boundaryTextRemoved): Deleted.
(WebCore::Range::getBoundingClientRect): Deleted.
(WebCore::Range::getBorderAndTextQuads): Deleted.
* dom/Range.h:
* dom/Range.idl:
* dom/RangeBoundaryPoint.h:
(WebCore::RangeBoundaryPoint::set):
(WebCore::RangeBoundaryPoint::setToStartOfNode):
(WebCore::RangeBoundaryPoint::setToEndOfNode):
* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::applyAlternativeTextToRange):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::fixRangeAndApplyInlineStyle):
* editing/Editor.cpp:
(WebCore::Editor::advanceToNextMisspelling):
(WebCore::Editor::rangeOfString):
(WebCore::isFrameInRange):
(WebCore::Editor::countMatchesForText):
* editing/EditorCommand.cpp:
(WebCore::unionDOMRanges):
(WebCore::executeDeleteToMark):
(WebCore::executeSelectToMark):
* editing/FormatBlockCommand.cpp:
(WebCore::FormatBlockCommand::formatRange):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::respondToNodeModification):
* editing/InsertListCommand.cpp:
(WebCore::InsertListCommand::doApplyForSingleParagraph):
* editing/TextCheckingHelper.cpp:
(WebCore::TextCheckingParagraph::offsetTo):
* editing/TextIterator.cpp:
(WebCore::CharacterIterator::range):
(WebCore::BackwardsCharacterIterator::range):
(WebCore::TextIterator::rangeFromLocationAndLength):
(WebCore::TextIterator::getLocationAndLengthFromRange):
(WebCore::findPlainText):
* editing/VisiblePosition.cpp:
(WebCore::setStart):
(WebCore::setEnd):
* editing/VisibleSelection.cpp:
(WebCore::makeSearchRange):
* editing/VisibleUnits.cpp:
(WebCore::previousBoundary):
(WebCore::nextBoundary):
* editing/htmlediting.cpp:
(WebCore::visiblePositionForIndexUsingCharacterIterator):
(WebCore::isNodeVisiblyContainedWithin):
* editing/htmlediting.h:
* editing/mac/EditorMac.mm:
(WebCore::Editor::adjustedSelectionRange):
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::contextMenuItemSelected):
* page/DOMSelection.cpp:
(WebCore::DOMSelection::addRange):
* page/DragController.cpp:
(WebCore::selectElement):
* page/EventHandler.cpp:
(WebCore::EventHandler::dispatchMouseEvent):
* page/Page.cpp:
(WebCore::Page::findStringMatchingRanges):
* page/TextIndicator.cpp:
(WebCore::hasNonInlineOrReplacedElements):
* rendering/RenderNamedFlowThread.cpp:
(WebCore::RenderNamedFlowThread::getRanges):

Source/WebKit/mac:

* WebView/WebFrame.mm:
(-[WebFrame _smartDeleteRangeForProposedRange:]):

Source/WebKit2:

* WebProcess/InjectedBundle/API/mac/WKDOMRange.mm:
(-[WKDOMRange setStart:offset:]):
(-[WKDOMRange setEnd:offset:]):
(-[WKDOMRange selectNode:]):
(-[WKDOMRange selectNodeContents:]):
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::contentsAsString):

Canonical link: https://commits.webkit.org/174952@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199817 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Apr 21, 2016
1 parent 7e053c4 commit 2090a3aaa627197fddbbea981282d2b32dd5e7fc
Showing 42 changed files with 500 additions and 358 deletions.
@@ -1,3 +1,130 @@
2016-04-21 Chris Dumez <cdumez@apple.com>

Drop [UsePointersEvenForNonNullableObjectArguments] from Range
https://bugs.webkit.org/show_bug.cgi?id=156805

Reviewed by Youenn Fablet.

No new tests, no web-exposed behavior change.

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::rangeForNodeContents):
(WebCore::characterOffsetsInOrder):
(WebCore::setRangeStartOrEndWithCharacterOffset):
(WebCore::AXObjectCache::startOrEndCharacterOffsetForRange):
(WebCore::AXObjectCache::previousBoundary):
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::selectText):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::documentBasedSelectedTextRange):
* dom/Node.cpp:
(WebCore::Node::textRects):
* dom/Range.cpp:
(WebCore::Range::Range):
(WebCore::Range::setDocument):
(WebCore::Range::setStart):
(WebCore::Range::setEnd):
(WebCore::Range::isPointInRange):
(WebCore::Range::comparePoint):
(WebCore::Range::compareNode):
(WebCore::Range::compareBoundaryPoints):
(WebCore::Range::compareBoundaryPointsForBindings):
(WebCore::Range::intersectsNode):
(WebCore::Range::processContents):
(WebCore::Range::insertNode):
(WebCore::Range::checkNodeWOffset):
(WebCore::Range::setStartAfter):
(WebCore::Range::setEndBefore):
(WebCore::Range::setEndAfter):
(WebCore::Range::selectNode):
(WebCore::Range::selectNodeContents):
(WebCore::Range::surroundContents):
(WebCore::Range::setStartBefore):
(WebCore::Range::contains):
(WebCore::rangesOverlap):
(WebCore::rangeOfContents):
(WebCore::boundaryNodeChildrenWillBeRemoved):
(WebCore::boundaryTextNodesMerged):
(WebCore::boundaryTextNodesSplit):
(WebCore::Range::expand):
(WebCore::checkForDifferentRootContainer): Deleted.
(WebCore::highestAncestorUnderCommonRoot): Deleted.
(WebCore::childOfCommonRootBeforeOffset): Deleted.
(WebCore::deleteCharacterData): Deleted.
(WebCore::Range::toString): Deleted.
(WebCore::Range::toHTML): Deleted.
(WebCore::Range::text): Deleted.
(WebCore::Range::cloneRange): Deleted.
(WebCore::Range::absoluteTextRects): Deleted.
(WebCore::Range::absoluteTextQuads): Deleted.
(WebCore::boundaryNodeChildrenChanged): Deleted.
(WebCore::boundaryNodeWillBeRemoved): Deleted.
(WebCore::Range::nodeWillBeRemoved): Deleted.
(WebCore::boundaryTextRemoved): Deleted.
(WebCore::Range::getBoundingClientRect): Deleted.
(WebCore::Range::getBorderAndTextQuads): Deleted.
* dom/Range.h:
* dom/Range.idl:
* dom/RangeBoundaryPoint.h:
(WebCore::RangeBoundaryPoint::set):
(WebCore::RangeBoundaryPoint::setToStartOfNode):
(WebCore::RangeBoundaryPoint::setToEndOfNode):
* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::applyAlternativeTextToRange):
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::fixRangeAndApplyInlineStyle):
* editing/Editor.cpp:
(WebCore::Editor::advanceToNextMisspelling):
(WebCore::Editor::rangeOfString):
(WebCore::isFrameInRange):
(WebCore::Editor::countMatchesForText):
* editing/EditorCommand.cpp:
(WebCore::unionDOMRanges):
(WebCore::executeDeleteToMark):
(WebCore::executeSelectToMark):
* editing/FormatBlockCommand.cpp:
(WebCore::FormatBlockCommand::formatRange):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::respondToNodeModification):
* editing/InsertListCommand.cpp:
(WebCore::InsertListCommand::doApplyForSingleParagraph):
* editing/TextCheckingHelper.cpp:
(WebCore::TextCheckingParagraph::offsetTo):
* editing/TextIterator.cpp:
(WebCore::CharacterIterator::range):
(WebCore::BackwardsCharacterIterator::range):
(WebCore::TextIterator::rangeFromLocationAndLength):
(WebCore::TextIterator::getLocationAndLengthFromRange):
(WebCore::findPlainText):
* editing/VisiblePosition.cpp:
(WebCore::setStart):
(WebCore::setEnd):
* editing/VisibleSelection.cpp:
(WebCore::makeSearchRange):
* editing/VisibleUnits.cpp:
(WebCore::previousBoundary):
(WebCore::nextBoundary):
* editing/htmlediting.cpp:
(WebCore::visiblePositionForIndexUsingCharacterIterator):
(WebCore::isNodeVisiblyContainedWithin):
* editing/htmlediting.h:
* editing/mac/EditorMac.mm:
(WebCore::Editor::adjustedSelectionRange):
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::contextMenuItemSelected):
* page/DOMSelection.cpp:
(WebCore::DOMSelection::addRange):
* page/DragController.cpp:
(WebCore::selectElement):
* page/EventHandler.cpp:
(WebCore::EventHandler::dispatchMouseEvent):
* page/Page.cpp:
(WebCore::Page::findStringMatchingRanges):
* page/TextIndicator.cpp:
(WebCore::hasNonInlineOrReplacedElements):
* rendering/RenderNamedFlowThread.cpp:
(WebCore::RenderNamedFlowThread::getRanges):

2016-04-21 Chris Dumez <cdumez@apple.com>

Drop [UsePointersEvenForNonNullableObjectArguments] from DOMURL
@@ -1606,7 +1606,7 @@ RefPtr<Range> AXObjectCache::rangeForNodeContents(Node* node)
return nullptr;
RefPtr<Range> range = Range::create(*document);
ExceptionCode ec = 0;
range->selectNodeContents(node, ec);
range->selectNodeContents(*node, ec);
return ec ? nullptr : range;
}

@@ -1635,7 +1635,8 @@ static bool characterOffsetsInOrder(const CharacterOffset& characterOffset1, con

RefPtr<Range> range1 = AXObjectCache::rangeForNodeContents(node1);
RefPtr<Range> range2 = AXObjectCache::rangeForNodeContents(node2);
return range1->compareBoundaryPoints(Range::START_TO_START, range2.get(), IGNORE_EXCEPTION) <= 0;

return !range2 || range1->compareBoundaryPoints(Range::START_TO_START, *range2, IGNORE_EXCEPTION) <= 0;
}

static Node* resetNodeAndOffsetForReplacedNode(Node* replacedNode, int& offset, int characterCount)
@@ -1663,6 +1664,7 @@ static void setRangeStartOrEndWithCharacterOffset(RefPtr<Range> range, const Cha

int offset = characterOffset.startIndex + characterOffset.offset;
Node* node = characterOffset.node;
ASSERT(node);

bool replacedNodeOrBR = isReplacedNodeOrBR(node);
// For the non text node that has no children, we should create the range with its parent, otherwise the range would be collapsed.
@@ -1673,10 +1675,15 @@ static void setRangeStartOrEndWithCharacterOffset(RefPtr<Range> range, const Cha
if (replacedNodeOrBR || noChildren)
node = resetNodeAndOffsetForReplacedNode(node, offset, characterCount);

if (!node) {
ec = TypeError;
return;
}

if (isStart)
range->setStart(node, offset, ec);
range->setStart(*node, offset, ec);
else
range->setEnd(node, offset, ec);
range->setEnd(*node, offset, ec);
}

RefPtr<Range> AXObjectCache::rangeForUnorderedCharacterOffsets(const CharacterOffset& characterOffset1, const CharacterOffset& characterOffset2)
@@ -1743,18 +1750,18 @@ CharacterOffset AXObjectCache::startOrEndCharacterOffsetForRange(RefPtr<Range> r
// If it's end text marker, we want to go to the end of the range, and stay within the range.
bool stayWithinRange = !isStart;

RefPtr<Range> copyRange = range;
Ref<Range> copyRange = *range;
// Change the start of the range, so the character offset starts from node beginning.
int offset = 0;
Node* node = &copyRange->startContainer();
if (node->offsetInCharacters()) {
Node& node = copyRange->startContainer();
if (node.offsetInCharacters()) {
copyRange = Range::create(range->ownerDocument(), &range->startContainer(), range->startOffset(), &range->endContainer(), range->endOffset());
CharacterOffset nodeStartOffset = traverseToOffsetInRange(rangeForNodeContents(node), 0);
CharacterOffset nodeStartOffset = traverseToOffsetInRange(rangeForNodeContents(&node), 0);
offset = std::max(copyRange->startOffset() - nodeStartOffset.startIndex, 0);
copyRange->setStart(node, nodeStartOffset.startIndex);
}

return traverseToOffsetInRange(copyRange, offset, isStart ? TraverseOptionDefault : TraverseOptionToNodeEnd, stayWithinRange);
return traverseToOffsetInRange(WTFMove(copyRange), offset, isStart ? TraverseOptionDefault : TraverseOptionToNodeEnd, stayWithinRange);
}

void AXObjectCache::startOrEndTextMarkerDataForRange(TextMarkerData& textMarkerData, RefPtr<Range> range, bool isStart)
@@ -2213,7 +2220,7 @@ CharacterOffset AXObjectCache::previousBoundary(const CharacterOffset& character
ExceptionCode ec = 0;
if (requiresContextForWordBoundary(characterBefore(characterOffset))) {
RefPtr<Range> forwardsScanRange(boundary->document().createRange());
forwardsScanRange->setEndAfter(boundary, ec);
forwardsScanRange->setEndAfter(*boundary, ec);
setRangeStartOrEndWithCharacterOffset(forwardsScanRange, characterOffset, true, ec);
suffixLength = suffixLengthForRange(forwardsScanRange, string);
}
@@ -737,7 +737,7 @@ String AccessibilityObject::selectText(AccessibilitySelectTextCriteria* criteria

RefPtr<Range> selectedStringRange = selectionRange();
// When starting our search again, make this a zero length range so that search forwards will find this selected range if its appropriate.
selectedStringRange->setEnd(&selectedStringRange->startContainer(), selectedStringRange->startOffset());
selectedStringRange->setEnd(selectedStringRange->startContainer(), selectedStringRange->startOffset());

RefPtr<Range> closestAfterStringRange = nullptr;
RefPtr<Range> closestBeforeStringRange = nullptr;
@@ -1434,7 +1434,7 @@ PlainTextRange AccessibilityRenderObject::documentBasedSelectedTextRange() const

VisibleSelection visibleSelection = selection();
RefPtr<Range> currentSelectionRange = visibleSelection.toNormalizedRange();
if (!currentSelectionRange || !currentSelectionRange->intersectsNode(node, IGNORE_EXCEPTION))
if (!currentSelectionRange || !currentSelectionRange->intersectsNode(*node, IGNORE_EXCEPTION))
return PlainTextRange();

int start = indexForVisiblePosition(visibleSelection.start());
@@ -1513,8 +1513,9 @@ void AccessibilityRenderObject::setSelectedTextRange(const PlainTextRange& range
HTMLTextFormControlElement& textControl = downcast<RenderTextControl>(*m_renderer).textFormControlElement();
textControl.setSelectionRange(range.start, range.start + range.length);
} else {
VisiblePosition start = visiblePositionForIndexUsingCharacterIterator(node(), range.start);
VisiblePosition end = visiblePositionForIndexUsingCharacterIterator(node(), range.start + range.length);
ASSERT(node());
VisiblePosition start = visiblePositionForIndexUsingCharacterIterator(*node(), range.start);
VisiblePosition end = visiblePositionForIndexUsingCharacterIterator(*node(), range.start + range.length);
m_renderer->frame().selection().setSelection(VisibleSelection(start, end), FrameSelection::defaultSetSelectionOptions(UserTriggered));
}

@@ -1876,7 +1877,7 @@ VisiblePosition AccessibilityRenderObject::visiblePositionForIndex(int index) co
if (!node)
return VisiblePosition();

return visiblePositionForIndexUsingCharacterIterator(node, index);
return visiblePositionForIndexUsingCharacterIterator(*node, index);
}

int AccessibilityRenderObject::indexForVisiblePosition(const VisiblePosition& pos) const
@@ -161,7 +161,7 @@ bool selectionBelongsToObject(AccessibilityObject* coreObject, VisibleSelection&
// node is actually inside the region, at least partially.
Node* node = coreObject->node();
Node* lastDescendant = node->lastDescendant();
return (range->intersectsNode(node, IGNORE_EXCEPTION)
return (range->intersectsNode(*node, IGNORE_EXCEPTION)
&& (&range->endContainer() != node || range->endOffset())
&& (&range->startContainer() != lastDescendant || range->startOffset() != lastOffsetInNode(lastDescendant)));
}
@@ -2131,7 +2131,7 @@ - (NSRange)_convertToNSRange:(Range *)range
int startPosition = TextIterator::rangeLength(testRange.get());

ExceptionCode ec;
testRange->setEnd(&range->endContainer(), range->endOffset(), ec);
testRange->setEnd(range->endContainer(), range->endOffset(), ec);
ASSERT(&testRange->startContainer() == scope);
int endPosition = TextIterator::rangeLength(testRange.get());
return NSMakeRange(startPosition, endPosition - startPosition);
@@ -113,8 +113,10 @@ - (void)move:(UInt32)amount inDirection:(WebTextAdjustmentDirection)direction
ExceptionCode ignored;
Position start = frameSelection.selection().start().parentAnchoredEquivalent();
Position end = frameSelection.selection().end().parentAnchoredEquivalent();
range->setStart(start.containerNode(), start.offsetInContainerNode(), ignored);
range->setEnd(end.containerNode(), end.offsetInContainerNode(), ignored);
if (start.containerNode())
range->setStart(*start.containerNode(), start.offsetInContainerNode(), ignored);
if (end.containerNode())
range->setEnd(*end.containerNode(), end.offsetInContainerNode(), ignored);
}

- (void)extend:(UInt32)amount inDirection:(WebTextAdjustmentDirection)direction
@@ -129,8 +131,10 @@ - (void)extend:(UInt32)amount inDirection:(WebTextAdjustmentDirection)direction
ExceptionCode ignored;
Position start = frameSelection.selection().start().parentAnchoredEquivalent();
Position end = frameSelection.selection().end().parentAnchoredEquivalent();
range->setStart(start.containerNode(), start.offsetInContainerNode(), ignored);
range->setEnd(end.containerNode(), end.offsetInContainerNode(), ignored);
if (start.containerNode())
range->setStart(*start.containerNode(), start.offsetInContainerNode(), ignored);
if (end.containerNode())
range->setEnd(*end.containerNode(), end.offsetInContainerNode(), ignored);
}

- (DOMNode *)firstNode
@@ -2314,7 +2314,7 @@ void Node::removedLastRef()
void Node::textRects(Vector<IntRect>& rects) const
{
RefPtr<Range> range = Range::create(document());
range->selectNodeContents(const_cast<Node*>(this), IGNORE_EXCEPTION);
range->selectNodeContents(const_cast<Node&>(*this), IGNORE_EXCEPTION);
range->absoluteTextRects(rects);
}

0 comments on commit 2090a3a

Please sign in to comment.