| Index: Source/core/editing/VisibleUnits.cpp
|
| diff --git a/Source/core/editing/VisibleUnits.cpp b/Source/core/editing/VisibleUnits.cpp
|
| index 91ccddea34b9d50c7d90d62526019b22e4013b68..319d2525ee0c03bd3b0a9782d64a6b8452ebe5ab 100644
|
| --- a/Source/core/editing/VisibleUnits.cpp
|
| +++ b/Source/core/editing/VisibleUnits.cpp
|
| @@ -79,20 +79,22 @@ static Result<Node> nextLeafWithSameEditability(const Handle<Node>& node, Editab
|
| // FIXME: consolidate with code in previousLinePosition.
|
| static Position previousRootInlineBoxCandidatePosition(Node* node, const VisiblePosition& visiblePosition, EditableType editableType)
|
| {
|
| - Node* highestRoot = highestEditableRoot(visiblePosition.deepEquivalent(), editableType);
|
| + Handle<Node> highestRoot = highestEditableRoot(visiblePosition.deepEquivalent(), editableType);
|
| Handle<Node> previousNode = previousLeafWithSameEditability(adoptRawResult(node), editableType);
|
|
|
| - while (previousNode && inSameLine(firstPositionInOrBeforeNode(previousNode.raw()), visiblePosition)) {
|
| + while (true) {
|
| HandleScope scope;
|
| + if (!previousNode || !inSameLine(firstPositionInOrBeforeNode(previousNode), visiblePosition))
|
| + break;
|
| previousNode = previousLeafWithSameEditability(previousNode, editableType);
|
| }
|
|
|
| while (previousNode && !previousNode->isShadowRoot()) {
|
| HandleScope scope;
|
| - if (highestEditableRoot(firstPositionInOrBeforeNode(previousNode.raw()), editableType) != highestRoot)
|
| + if (highestEditableRoot(firstPositionInOrBeforeNode(previousNode), editableType) != highestRoot)
|
| break;
|
|
|
| - Position pos = previousNode->hasTagName(brTag) ? positionBeforeNode(previousNode) : createLegacyEditingPosition(previousNode, caretMaxOffset(previousNode.raw()));
|
| + Position pos = previousNode->hasTagName(brTag) ? positionBeforeNode(previousNode) : createLegacyEditingPosition(previousNode, caretMaxOffset(previousNode));
|
|
|
| if (pos.isCandidate())
|
| return pos;
|
| @@ -104,20 +106,22 @@ static Position previousRootInlineBoxCandidatePosition(Node* node, const Visible
|
|
|
| static Position nextRootInlineBoxCandidatePosition(Node* node, const VisiblePosition& visiblePosition, EditableType editableType)
|
| {
|
| - Node* highestRoot = highestEditableRoot(visiblePosition.deepEquivalent(), editableType);
|
| + Handle<Node> highestRoot = highestEditableRoot(visiblePosition.deepEquivalent(), editableType);
|
| Handle<Node> nextNode = nextLeafWithSameEditability(adoptRawResult(node), editableType);
|
| - while (nextNode && inSameLine(firstPositionInOrBeforeNode(nextNode.raw()), visiblePosition)) {
|
| + while (true) {
|
| HandleScope scope;
|
| + if (!nextNode || !inSameLine(firstPositionInOrBeforeNode(nextNode), visiblePosition))
|
| + break;
|
| nextNode = nextLeafWithSameEditability(nextNode, ContentIsEditable);
|
| }
|
|
|
| while (nextNode && !nextNode->isShadowRoot()) {
|
| HandleScope scope;
|
| - if (highestEditableRoot(firstPositionInOrBeforeNode(nextNode.raw()), editableType) != highestRoot)
|
| + if (highestEditableRoot(firstPositionInOrBeforeNode(nextNode), editableType) != highestRoot)
|
| break;
|
|
|
| Position pos;
|
| - pos = createLegacyEditingPosition(nextNode, caretMinOffset(nextNode.raw()));
|
| + pos = createLegacyEditingPosition(nextNode, caretMinOffset(nextNode));
|
|
|
| if (pos.isCandidate())
|
| return pos;
|
| @@ -771,9 +775,9 @@ static VisiblePosition startOfLine(const VisiblePosition& c, LineEndpointComputa
|
| VisiblePosition visPos = startPositionForLine(c, mode);
|
|
|
| if (mode == UseLogicalOrdering) {
|
| - if (Node* editableRoot = highestEditableRoot(c.deepEquivalent())) {
|
| + if (Handle<Node> editableRoot = highestEditableRoot(c.deepEquivalent())) {
|
| if (!editableRoot->contains(visPos.deepEquivalent().containerNode()))
|
| - return firstPositionInNode(adoptRawResult(editableRoot));
|
| + return firstPositionInNode(editableRoot);
|
| }
|
| }
|
|
|
| @@ -867,9 +871,9 @@ static VisiblePosition endOfLine(const VisiblePosition& c, LineEndpointComputati
|
| if (!inSameLogicalLine(c, visPos))
|
| visPos = visPos.previous();
|
|
|
| - if (Node* editableRoot = highestEditableRoot(c.deepEquivalent())) {
|
| + if (Handle<Node> editableRoot = highestEditableRoot(c.deepEquivalent())) {
|
| if (!editableRoot->contains(visPos.deepEquivalent().containerNode()))
|
| - return lastPositionInNode(adoptRawResult(editableRoot));
|
| + return lastPositionInNode(editableRoot);
|
| }
|
|
|
| return c.honorEditingBoundaryAtOrAfter(visPos);
|
| @@ -971,7 +975,7 @@ VisiblePosition previousLinePosition(const VisiblePosition &visiblePosition, int
|
| IntPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(root, lineDirectionPoint);
|
| RenderObject* renderer = root->closestLeafChildForPoint(pointInLine, isEditablePosition(p))->renderer();
|
| Handle<Node> node = renderer->node();
|
| - if (node && editingIgnoresContent(node.raw()))
|
| + if (node && editingIgnoresContent(node))
|
| return positionInParentBeforeNode(node);
|
| return renderer->positionForPoint(pointInLine);
|
| }
|
| @@ -1029,7 +1033,7 @@ VisiblePosition nextLinePosition(const VisiblePosition &visiblePosition, int lin
|
| IntPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(root, lineDirectionPoint);
|
| RenderObject* renderer = root->closestLeafChildForPoint(pointInLine, isEditablePosition(p))->renderer();
|
| Handle<Node> node = renderer->node();
|
| - if (node && editingIgnoresContent(node.raw()))
|
| + if (node && editingIgnoresContent(node))
|
| return positionInParentBeforeNode(node);
|
| return renderer->positionForPoint(pointInLine);
|
| }
|
| @@ -1105,13 +1109,13 @@ VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi
|
| if (!startNode)
|
| return VisiblePosition();
|
|
|
| - if (isRenderedAsNonInlineTableImageOrHR(startNode.raw()))
|
| + if (isRenderedAsNonInlineTableImageOrHR(startNode))
|
| return positionBeforeNode(startNode);
|
|
|
| - Handle<Node> startBlock = enclosingBlock(startNode.raw());
|
| + Handle<Node> startBlock = enclosingBlock(startNode);
|
|
|
| Handle<Node> node = startNode;
|
| - Node* highestRoot = highestEditableRoot(p);
|
| + Handle<Node> highestRoot = highestEditableRoot(p);
|
| int offset = p.deprecatedEditingOffset();
|
| Position::AnchorType type = p.anchorType();
|
|
|
| @@ -1126,7 +1130,7 @@ VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi
|
| if (boundaryCrossingRule == CanSkipOverEditingBoundary) {
|
| while (n && n->rendererIsEditable() != startNode->rendererIsEditable())
|
| n = NodeTraversal::previousPostOrder(n, startBlock);
|
| - if (!n || !n->isDescendantOf(highestRoot))
|
| + if (!n || !n->isDescendantOf(highestRoot.raw()))
|
| break;
|
| }
|
| RenderObject* r = n->renderer();
|
| @@ -1140,7 +1144,7 @@ VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi
|
| continue;
|
| }
|
|
|
| - if (r->isBR() || isBlock(n.raw()))
|
| + if (r->isBR() || isBlock(n))
|
| break;
|
|
|
| if (r->isText() && toRenderText(r)->renderedTextLength()) {
|
| @@ -1160,7 +1164,7 @@ VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi
|
| node = n;
|
| offset = 0;
|
| n = NodeTraversal::previousPostOrder(n, startBlock);
|
| - } else if (editingIgnoresContent(n.raw()) || isTableElement(n.raw())) {
|
| + } else if (editingIgnoresContent(n) || isTableElement(n)) {
|
| node = n;
|
| type = Position::PositionIsBeforeAnchor;
|
| n = n->previousSibling() ? n->previousSibling() : NodeTraversal::previousPostOrder(n, startBlock);
|
| @@ -1184,14 +1188,14 @@ VisiblePosition endOfParagraph(const VisiblePosition &c, EditingBoundaryCrossing
|
| Position p = c.deepEquivalent();
|
| Handle<Node> startNode = p.deprecatedNode();
|
|
|
| - if (isRenderedAsNonInlineTableImageOrHR(startNode.raw()))
|
| + if (isRenderedAsNonInlineTableImageOrHR(startNode))
|
| return positionAfterNode(startNode);
|
|
|
| - Handle<Node> startBlock = enclosingBlock(startNode.raw());
|
| + Handle<Node> startBlock = enclosingBlock(startNode);
|
| Handle<Node> stayInsideBlock = startBlock;
|
|
|
| Handle<Node> node = startNode;
|
| - Handle<Node> highestRoot = adoptRawResult(highestEditableRoot(p));
|
| + Handle<Node> highestRoot = highestEditableRoot(p);
|
| int offset = p.deprecatedEditingOffset();
|
| Position::AnchorType type = p.anchorType();
|
|
|
| @@ -1223,7 +1227,7 @@ VisiblePosition endOfParagraph(const VisiblePosition &c, EditingBoundaryCrossing
|
| continue;
|
| }
|
|
|
| - if (r->isBR() || isBlock(n.raw()))
|
| + if (r->isBR() || isBlock(n))
|
| break;
|
|
|
| // FIXME: We avoid returning a position where the renderer can't accept the caret.
|
| @@ -1242,7 +1246,7 @@ VisiblePosition endOfParagraph(const VisiblePosition &c, EditingBoundaryCrossing
|
| node = n;
|
| offset = r->caretMaxOffset();
|
| n = NodeTraversal::next(n, stayInsideBlock);
|
| - } else if (editingIgnoresContent(n.raw()) || isTableElement(n.raw())) {
|
| + } else if (editingIgnoresContent(n) || isTableElement(n)) {
|
| node = n;
|
| type = Position::PositionIsAfterAnchor;
|
| n = NodeTraversal::nextSkippingChildren(n, stayInsideBlock);
|
| @@ -1313,7 +1317,7 @@ VisiblePosition startOfBlock(const VisiblePosition& visiblePosition, EditingBoun
|
| {
|
| Position position = visiblePosition.deepEquivalent();
|
| Handle<Node> startBlock;
|
| - if (!position.containerNode() || !(startBlock = enclosingBlock(position.containerNode().handle().raw(), rule)))
|
| + if (!position.containerNode() || !(startBlock = enclosingBlock(position.containerNode(), rule)))
|
| return VisiblePosition();
|
| return firstPositionInNode(startBlock);
|
| }
|
| @@ -1322,14 +1326,14 @@ VisiblePosition endOfBlock(const VisiblePosition& visiblePosition, EditingBounda
|
| {
|
| Position position = visiblePosition.deepEquivalent();
|
| Handle<Node> endBlock;
|
| - if (!position.containerNode() || !(endBlock = enclosingBlock(position.containerNode().handle().raw(), rule)))
|
| + if (!position.containerNode() || !(endBlock = enclosingBlock(position.containerNode(), rule)))
|
| return VisiblePosition();
|
| return lastPositionInNode(endBlock);
|
| }
|
|
|
| bool inSameBlock(const VisiblePosition &a, const VisiblePosition &b)
|
| {
|
| - return !a.isNull() && enclosingBlock(a.deepEquivalent().containerNode().handle().raw()) == enclosingBlock(b.deepEquivalent().containerNode().handle().raw());
|
| + return !a.isNull() && enclosingBlock(a.deepEquivalent().containerNode()) == enclosingBlock(b.deepEquivalent().containerNode());
|
| }
|
|
|
| bool isStartOfBlock(const VisiblePosition &pos)
|
| @@ -1399,20 +1403,20 @@ bool isEndOfDocument(const VisiblePosition &p)
|
|
|
| VisiblePosition startOfEditableContent(const VisiblePosition& visiblePosition)
|
| {
|
| - Node* highestRoot = highestEditableRoot(visiblePosition.deepEquivalent());
|
| + Handle<Node> highestRoot = highestEditableRoot(visiblePosition.deepEquivalent());
|
| if (!highestRoot)
|
| return VisiblePosition();
|
|
|
| - return firstPositionInNode(adoptRawResult(highestRoot));
|
| + return firstPositionInNode(highestRoot);
|
| }
|
|
|
| VisiblePosition endOfEditableContent(const VisiblePosition& visiblePosition)
|
| {
|
| - Node* highestRoot = highestEditableRoot(visiblePosition.deepEquivalent());
|
| + Handle<Node> highestRoot = highestEditableRoot(visiblePosition.deepEquivalent());
|
| if (!highestRoot)
|
| return VisiblePosition();
|
|
|
| - return lastPositionInNode(adoptRawResult(highestRoot));
|
| + return lastPositionInNode(highestRoot);
|
| }
|
|
|
| bool isEndOfEditableOrNonEditableContent(const VisiblePosition &p)
|
|
|