| Index: Source/core/editing/DeleteSelectionCommand.cpp
|
| diff --git a/Source/core/editing/DeleteSelectionCommand.cpp b/Source/core/editing/DeleteSelectionCommand.cpp
|
| index d9a41179dc3898150e0cbbf28251ceaf809a17c4..000c681d928905680723da15fa3af7543f11f5e2 100644
|
| --- a/Source/core/editing/DeleteSelectionCommand.cpp
|
| +++ b/Source/core/editing/DeleteSelectionCommand.cpp
|
| @@ -47,25 +47,25 @@ namespace WebCore {
|
|
|
| using namespace HTMLNames;
|
|
|
| -static bool isTableRow(const Node* node)
|
| +static bool isTableRow(const Handle<const Node>& node)
|
| {
|
| return node && node->hasTagName(trTag);
|
| }
|
|
|
| static bool isTableCellEmpty(const Handle<Node>& cell)
|
| {
|
| - ASSERT(isTableCell(cell.raw()));
|
| + ASSERT(isTableCell(cell));
|
| return VisiblePosition(firstPositionInNode(cell)) == VisiblePosition(lastPositionInNode(cell));
|
| }
|
|
|
| static bool isTableRowEmpty(const Handle<Node>& row)
|
| {
|
| - if (!isTableRow(row.raw()))
|
| + if (!isTableRow(row))
|
| return false;
|
|
|
| for (Handle<Node> child = row->firstChild(); child; child = child->nextSibling()) {
|
| HandleScope scope;
|
| - if (isTableCell(child.raw()) && !isTableCellEmpty(child))
|
| + if (isTableCell(child) && !isTableCellEmpty(child))
|
| return false;
|
| }
|
|
|
| @@ -111,8 +111,8 @@ DeleteSelectionCommand::DeleteSelectionCommand(const VisibleSelection& selection
|
|
|
| void DeleteSelectionCommand::initializeStartEnd(Position& start, Position& end)
|
| {
|
| - Node* startSpecialContainer = 0;
|
| - Node* endSpecialContainer = 0;
|
| + Handle<Node> startSpecialContainer;
|
| + Handle<Node> endSpecialContainer;
|
|
|
| start = m_selectionToDelete.start();
|
| end = m_selectionToDelete.end();
|
| @@ -130,8 +130,8 @@ void DeleteSelectionCommand::initializeStartEnd(Position& start, Position& end)
|
|
|
| while (1) {
|
| HandleScope scope;
|
| - startSpecialContainer = 0;
|
| - endSpecialContainer = 0;
|
| + startSpecialContainer = nullptr;
|
| + endSpecialContainer = nullptr;
|
|
|
| Position s = positionBeforeContainingSpecialElement(start, &startSpecialContainer);
|
| Position e = positionAfterContainingSpecialElement(end, &endSpecialContainer);
|
| @@ -143,18 +143,18 @@ void DeleteSelectionCommand::initializeStartEnd(Position& start, Position& end)
|
| break;
|
|
|
| // If we're going to expand to include the startSpecialContainer, it must be fully selected.
|
| - if (startSpecialContainer && !endSpecialContainer && comparePositions(positionInParentAfterNode(adoptRawResult(startSpecialContainer)), end) > -1)
|
| + if (startSpecialContainer && !endSpecialContainer && comparePositions(positionInParentAfterNode(startSpecialContainer), end) > -1)
|
| break;
|
|
|
| // If we're going to expand to include the endSpecialContainer, it must be fully selected.
|
| - if (endSpecialContainer && !startSpecialContainer && comparePositions(start, positionInParentBeforeNode(adoptRawResult(endSpecialContainer))) > -1)
|
| + if (endSpecialContainer && !startSpecialContainer && comparePositions(start, positionInParentBeforeNode(endSpecialContainer)) > -1)
|
| break;
|
|
|
| - if (startSpecialContainer && startSpecialContainer->isDescendantOf(endSpecialContainer))
|
| + if (startSpecialContainer && startSpecialContainer->isDescendantOf(endSpecialContainer.raw()))
|
| // Don't adjust the end yet, it is the end of a special element that contains the start
|
| // special element (which may or may not be fully selected).
|
| start = s;
|
| - else if (endSpecialContainer && endSpecialContainer->isDescendantOf(startSpecialContainer))
|
| + else if (endSpecialContainer && endSpecialContainer->isDescendantOf(startSpecialContainer.raw()))
|
| // Don't adjust the start yet, it is the start of a special element that contains the end
|
| // special element (which may or may not be fully selected).
|
| end = e;
|
| @@ -192,14 +192,14 @@ void DeleteSelectionCommand::initializePositionData()
|
| m_startRoot = editableRootForPosition(start);
|
| m_endRoot = editableRootForPosition(end);
|
|
|
| - m_startTableRow = adoptRawResult(enclosingNodeOfType(start, &isTableRow));
|
| - m_endTableRow = adoptRawResult(enclosingNodeOfType(end, &isTableRow));
|
| + m_startTableRow = enclosingNodeOfType(start, &isTableRow);
|
| + m_endTableRow = enclosingNodeOfType(end, &isTableRow);
|
|
|
| // Don't move content out of a table cell.
|
| // If the cell is non-editable, enclosingNodeOfType won't return it by default, so
|
| // tell that function that we don't care if it returns non-editable nodes.
|
| - Handle<Node> startCell = adoptRawResult(enclosingNodeOfType(m_upstreamStart, &isTableCell, CanCrossEditingBoundary));
|
| - Handle<Node> endCell = adoptRawResult(enclosingNodeOfType(m_downstreamEnd, &isTableCell, CanCrossEditingBoundary));
|
| + Handle<Node> startCell = enclosingNodeOfType(m_upstreamStart, &isTableCell, CanCrossEditingBoundary);
|
| + Handle<Node> endCell = enclosingNodeOfType(m_downstreamEnd, &isTableCell, CanCrossEditingBoundary);
|
| // FIXME: This isn't right. A borderless table with two rows and a single column would appear as two paragraphs.
|
| if (endCell && endCell != startCell)
|
| m_mergeBlocksAfterDelete = false;
|
| @@ -272,8 +272,8 @@ void DeleteSelectionCommand::initializePositionData()
|
| // like the one below, since editing functions should obviously accept editing positions.
|
| // FIXME: Passing false to enclosingNodeOfType tells it that it's OK to return a non-editable
|
| // node. This was done to match existing behavior, but it seems wrong.
|
| - m_startBlock = adoptRawResult(enclosingNodeOfType(m_downstreamStart.parentAnchoredEquivalent(), &isBlock, CanCrossEditingBoundary));
|
| - m_endBlock = adoptRawResult(enclosingNodeOfType(m_upstreamEnd.parentAnchoredEquivalent(), &isBlock, CanCrossEditingBoundary));
|
| + m_startBlock = enclosingNodeOfType(m_downstreamStart.parentAnchoredEquivalent(), &isBlock, CanCrossEditingBoundary);
|
| + m_endBlock = enclosingNodeOfType(m_upstreamEnd.parentAnchoredEquivalent(), &isBlock, CanCrossEditingBoundary);
|
| }
|
|
|
| void DeleteSelectionCommand::saveTypingStyleState()
|
| @@ -290,7 +290,7 @@ void DeleteSelectionCommand::saveTypingStyleState()
|
|
|
| // Figure out the typing style in effect before the delete is done.
|
| m_typingStyle = EditingStyle::create(m_selectionToDelete.start());
|
| - m_typingStyle->removeStyleAddedByNode(adoptRawResult(enclosingAnchorElement(m_selectionToDelete.start())));
|
| + m_typingStyle->removeStyleAddedByNode(enclosingAnchorElement(m_selectionToDelete.start()));
|
|
|
| // If we're deleting into a Mail blockquote, save the style at end() instead of start()
|
| // We'll use this later in computeTypingStyleAfterDelete if we end up outside of a Mail blockquote
|
| @@ -337,7 +337,7 @@ static Position firstEditablePositionInNode(const Handle<Node>& node)
|
| HandleScope scope;
|
| next = NodeTraversal::next(next, node);
|
| }
|
| - return next ? firstPositionInOrBeforeNode(next.raw()) : Position();
|
| + return next ? firstPositionInOrBeforeNode(next) : Position();
|
| }
|
|
|
| void DeleteSelectionCommand::removeNode(const Handle<Node>& node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
|
| @@ -368,7 +368,7 @@ void DeleteSelectionCommand::removeNode(const Handle<Node>& node, ShouldAssumeCo
|
| }
|
| }
|
|
|
| - if (isTableStructureNode(node.raw()) || node->isRootEditableElement()) {
|
| + if (isTableStructureNode(node) || node->isRootEditableElement()) {
|
| // Do not remove an element of table structure; remove its contents.
|
| // Likewise for the root editable element.
|
| for (Handle<Node> child = node->firstChild(); child; ) {
|
| @@ -395,9 +395,9 @@ void DeleteSelectionCommand::removeNode(const Handle<Node>& node, ShouldAssumeCo
|
| m_needPlaceholder = true;
|
|
|
| // FIXME: Update the endpoints of the range being deleted.
|
| - updatePositionForNodeRemoval(m_endingPosition, node.raw());
|
| - updatePositionForNodeRemoval(m_leadingWhitespace, node.raw());
|
| - updatePositionForNodeRemoval(m_trailingWhitespace, node.raw());
|
| + updatePositionForNodeRemoval(m_endingPosition, node);
|
| + updatePositionForNodeRemoval(m_leadingWhitespace, node);
|
| + updatePositionForNodeRemoval(m_trailingWhitespace, node);
|
|
|
| CompositeEditCommand::removeNode(node, shouldAssumeContentIsAlwaysEditable);
|
| }
|
| @@ -452,20 +452,20 @@ void DeleteSelectionCommand::handleGeneralDelete()
|
| makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss();
|
|
|
| // Never remove the start block unless it's a table, in which case we won't merge content in.
|
| - if (startNode == m_startBlock && startOffset == 0 && canHaveChildrenForEditing(startNode.raw()) && !startNode->hasTagName(tableTag)) {
|
| + if (startNode == m_startBlock && startOffset == 0 && canHaveChildrenForEditing(startNode) && !startNode->hasTagName(tableTag)) {
|
| startOffset = 0;
|
| startNode = NodeTraversal::next(startNode);
|
| if (!startNode)
|
| return;
|
| }
|
|
|
| - if (startOffset >= caretMaxOffset(startNode.raw()) && startNode->isTextNode()) {
|
| + if (startOffset >= caretMaxOffset(startNode) && startNode->isTextNode()) {
|
| Handle<Text> text = toText(startNode);
|
| - if (text->length() > (unsigned)caretMaxOffset(startNode.raw()))
|
| - deleteTextFromNode(text, caretMaxOffset(startNode.raw()), text->length() - caretMaxOffset(startNode.raw()));
|
| + if (text->length() > (unsigned)caretMaxOffset(startNode))
|
| + deleteTextFromNode(text, caretMaxOffset(startNode), text->length() - caretMaxOffset(startNode));
|
| }
|
|
|
| - if (startOffset >= lastOffsetForEditing(startNode.raw())) {
|
| + if (startOffset >= lastOffsetForEditing(startNode)) {
|
| startNode = NodeTraversal::nextSkippingChildren(startNode);
|
| startOffset = 0;
|
| }
|
| @@ -512,19 +512,19 @@ void DeleteSelectionCommand::handleGeneralDelete()
|
| // handle deleting all nodes that are completely selected
|
| while (node && node != m_downstreamEnd.deprecatedNode()) {
|
| HandleScope scope;
|
| - if (comparePositions(firstPositionInOrBeforeNode(node.raw()), m_downstreamEnd) >= 0) {
|
| + if (comparePositions(firstPositionInOrBeforeNode(node), m_downstreamEnd) >= 0) {
|
| // NodeTraversal::nextSkippingChildren just blew past the end position, so stop deleting
|
| node = nullptr;
|
| } else if (!m_downstreamEnd.deprecatedNode()->isDescendantOf(node.raw())) {
|
| Handle<Node> nextNode = NodeTraversal::nextSkippingChildren(node);
|
| // if we just removed a node from the end container, update end position so the
|
| // check above will work
|
| - updatePositionForNodeRemoval(m_downstreamEnd, node.raw());
|
| + updatePositionForNodeRemoval(m_downstreamEnd, node);
|
| removeNode(node);
|
| node = nextNode;
|
| } else {
|
| Handle<Node> n = node->lastDescendant();
|
| - if (m_downstreamEnd.deprecatedNode() == n && m_downstreamEnd.deprecatedEditingOffset() >= caretMaxOffset(n.raw())) {
|
| + if (m_downstreamEnd.deprecatedNode() == n && m_downstreamEnd.deprecatedEditingOffset() >= caretMaxOffset(n)) {
|
| removeNode(node);
|
| node = nullptr;
|
| } else
|
| @@ -532,8 +532,8 @@ void DeleteSelectionCommand::handleGeneralDelete()
|
| }
|
| }
|
|
|
| - if (m_downstreamEnd.deprecatedNode() != startNode && !m_upstreamStart.deprecatedNode()->isDescendantOf(m_downstreamEnd.deprecatedNode().handle().raw()) && m_downstreamEnd.anchorNode()->inDocument() && m_downstreamEnd.deprecatedEditingOffset() >= caretMinOffset(m_downstreamEnd.deprecatedNode().handle().raw())) {
|
| - if (m_downstreamEnd.atLastEditingPositionForNode() && !canHaveChildrenForEditing(m_downstreamEnd.deprecatedNode().handle().raw())) {
|
| + if (m_downstreamEnd.deprecatedNode() != startNode && !m_upstreamStart.deprecatedNode()->isDescendantOf(m_downstreamEnd.deprecatedNode().handle().raw()) && m_downstreamEnd.anchorNode()->inDocument() && m_downstreamEnd.deprecatedEditingOffset() >= caretMinOffset(m_downstreamEnd.deprecatedNode())) {
|
| + if (m_downstreamEnd.atLastEditingPositionForNode() && !canHaveChildrenForEditing(m_downstreamEnd.deprecatedNode())) {
|
| // The node itself is fully selected, not just its contents. Delete it.
|
| removeNode(m_downstreamEnd.deprecatedNode());
|
| } else {
|
| @@ -619,14 +619,14 @@ void DeleteSelectionCommand::mergeParagraphs()
|
|
|
| // m_downstreamEnd's block has been emptied out by deletion. There is no content inside of it to
|
| // move, so just remove it.
|
| - Handle<Element> endBlock = enclosingBlock(m_downstreamEnd.deprecatedNode().handle().raw());
|
| + Handle<Element> endBlock = enclosingBlock(m_downstreamEnd.deprecatedNode());
|
| if (!endBlock || !endBlock->contains(startOfParagraphToMove.deepEquivalent().deprecatedNode()) || !startOfParagraphToMove.deepEquivalent().deprecatedNode()) {
|
| - removeNode(enclosingBlock(m_downstreamEnd.deprecatedNode().handle().raw()));
|
| + removeNode(enclosingBlock(m_downstreamEnd.deprecatedNode()));
|
| return;
|
| }
|
|
|
| // We need to merge into m_upstreamStart's block, but it's been emptied out and collapsed by deletion.
|
| - if (!mergeDestination.deepEquivalent().deprecatedNode() || !mergeDestination.deepEquivalent().deprecatedNode()->isDescendantOf(enclosingBlock(m_upstreamStart.containerNode().handle().raw()).handle().raw()) || m_startsAtEmptyLine) {
|
| + if (!mergeDestination.deepEquivalent().deprecatedNode() || !mergeDestination.deepEquivalent().deprecatedNode()->isDescendantOf(enclosingBlock(m_upstreamStart.containerNode()).handle().raw()) || m_startsAtEmptyLine) {
|
| insertNodeAt(createBreakElement(document()), m_upstreamStart);
|
| mergeDestination = VisiblePosition(m_upstreamStart);
|
| }
|
| @@ -652,7 +652,7 @@ void DeleteSelectionCommand::mergeParagraphs()
|
| // Block images, tables and horizontal rules cannot be made inline with content at mergeDestination. If there is
|
| // any (!isStartOfParagraph(mergeDestination)), don't merge, just move the caret to just before the selection we deleted.
|
| // See https://bugs.webkit.org/show_bug.cgi?id=25439
|
| - if (isRenderedAsNonInlineTableImageOrHR(startOfParagraphToMove.deepEquivalent().deprecatedNode().handle().raw()) && !isStartOfParagraph(mergeDestination)) {
|
| + if (isRenderedAsNonInlineTableImageOrHR(startOfParagraphToMove.deepEquivalent().deprecatedNode()) && !isStartOfParagraph(mergeDestination)) {
|
| m_endingPosition = m_upstreamStart;
|
| return;
|
| }
|
| @@ -822,7 +822,7 @@ void DeleteSelectionCommand::doApply()
|
| // Don't need a placeholder when deleting a selection that starts just before a table
|
| // and ends inside it (we do need placeholders to hold open empty cells, but that's
|
| // handled elsewhere).
|
| - if (Handle<Node> table = adoptRawResult(isLastPositionBeforeTable(m_selectionToDelete.visibleStart())))
|
| + if (Handle<Node> table = isLastPositionBeforeTable(m_selectionToDelete.visibleStart()))
|
| if (m_selectionToDelete.end().deprecatedNode()->isDescendantOf(table.raw()))
|
| m_needPlaceholder = false;
|
| }
|
|
|