| Index: Source/core/editing/ReplaceSelectionCommand.cpp
|
| diff --git a/Source/core/editing/ReplaceSelectionCommand.cpp b/Source/core/editing/ReplaceSelectionCommand.cpp
|
| index d578d660dbea643cee00e010d4e1db27dbd92301..da4ecdd787cbc53a7084e924db55d460658ebd63 100644
|
| --- a/Source/core/editing/ReplaceSelectionCommand.cpp
|
| +++ b/Source/core/editing/ReplaceSelectionCommand.cpp
|
| @@ -359,7 +359,7 @@ inline void ReplaceSelectionCommand::InsertedNodes::didReplaceNode(Node* node, N
|
| m_lastNodeInserted = newNode;
|
| }
|
|
|
| -ReplaceSelectionCommand::ReplaceSelectionCommand(Document* document, PassRefPtr<DocumentFragment> fragment, CommandOptions options, EditAction editAction)
|
| +ReplaceSelectionCommand::ReplaceSelectionCommand(Document& document, PassRefPtr<DocumentFragment> fragment, CommandOptions options, EditAction editAction)
|
| : CompositeEditCommand(document)
|
| , m_selectReplacement(options & SelectReplacement)
|
| , m_smartReplace(options & SmartReplace)
|
| @@ -502,7 +502,7 @@ void ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline(Insert
|
| // styles from blockquoteNode are allowed to override those from the source document, see <rdar://problem/4930986> and <rdar://problem/5089327>.
|
| Node* blockquoteNode = !context || isMailPasteAsQuotationNode(context) ? context : enclosingNodeOfType(firstPositionInNode(context), isMailBlockquote, CanCrossEditingBoundary);
|
| if (blockquoteNode)
|
| - newInlineStyle->removeStyleFromRulesAndContext(element, document()->documentElement());
|
| + newInlineStyle->removeStyleFromRulesAndContext(element, document().documentElement());
|
|
|
| newInlineStyle->removeStyleFromRulesAndContext(element, context);
|
| }
|
| @@ -664,7 +664,7 @@ static inline bool nodeHasVisibleRenderText(Text* text)
|
|
|
| void ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds(InsertedNodes& insertedNodes)
|
| {
|
| - document()->updateLayoutIgnorePendingStylesheets();
|
| + document().updateLayoutIgnorePendingStylesheets();
|
|
|
| Node* lastLeafInserted = insertedNodes.lastLeafInserted();
|
| if (lastLeafInserted && lastLeafInserted->isTextNode() && !nodeHasVisibleRenderText(toText(lastLeafInserted))
|
| @@ -773,7 +773,7 @@ void ReplaceSelectionCommand::handleStyleSpans(InsertedNodes& insertedNodes)
|
| // styles from blockquoteNode are allowed to override those from the source document, see <rdar://problem/4930986> and <rdar://problem/5089327>.
|
| Node* blockquoteNode = isMailPasteAsQuotationNode(context) ? context : enclosingNodeOfType(firstPositionInNode(context), isMailBlockquote, CanCrossEditingBoundary);
|
| if (blockquoteNode)
|
| - context = document()->documentElement();
|
| + context = document().documentElement();
|
|
|
| // This operation requires that only editing styles to be removed from sourceDocumentStyle.
|
| style->prepareToApplyAt(firstPositionInNode(context));
|
| @@ -818,7 +818,7 @@ void ReplaceSelectionCommand::mergeEndIfNeeded()
|
| // Merging forward could result in deleting the destination anchor node.
|
| // To avoid this, we add a placeholder node before the start of the paragraph.
|
| if (endOfParagraph(startOfParagraphToMove) == destination) {
|
| - RefPtr<Node> placeholder = createBreakElement(document());
|
| + RefPtr<Node> placeholder = createBreakElement(&document());
|
| insertNodeBefore(placeholder, startOfParagraphToMove.deepEquivalent().deprecatedNode());
|
| destination = VisiblePosition(positionBeforeNode(placeholder.get()));
|
| }
|
| @@ -889,7 +889,7 @@ void ReplaceSelectionCommand::doApply()
|
| if (!selection.rootEditableElement())
|
| return;
|
|
|
| - ReplacementFragment fragment(document(), m_documentFragment.get(), selection);
|
| + ReplacementFragment fragment(&document(), m_documentFragment.get(), selection);
|
| if (performTrivialReplace(fragment))
|
| return;
|
|
|
| @@ -900,7 +900,7 @@ void ReplaceSelectionCommand::doApply()
|
|
|
| if (m_matchStyle) {
|
| m_insertionStyle = EditingStyle::create(selection.start());
|
| - m_insertionStyle->mergeTypingStyle(document());
|
| + m_insertionStyle->mergeTypingStyle(&document());
|
| }
|
|
|
| VisiblePosition visibleStart = selection.visibleStart();
|
| @@ -1009,7 +1009,7 @@ void ReplaceSelectionCommand::doApply()
|
|
|
| // FIXME: Can this wait until after the operation has been performed? There doesn't seem to be
|
| // any work performed after this that queries or uses the typing style.
|
| - if (Frame* frame = document()->frame())
|
| + if (Frame* frame = document().frame())
|
| frame->selection()->clearTypingStyle();
|
|
|
| removeHeadContents(fragment);
|
| @@ -1115,7 +1115,7 @@ void ReplaceSelectionCommand::doApply()
|
| // We inserted before the startBlock to prevent nesting, and the content before the startBlock wasn't in its own block and
|
| // didn't have a br after it, so the inserted content ended up in the same paragraph.
|
| if (startBlock && insertionPos.deprecatedNode() == startBlock->parentNode() && (unsigned)insertionPos.deprecatedEditingOffset() < startBlock->nodeIndex() && !isStartOfParagraph(startOfInsertedContent))
|
| - insertNodeAt(createBreakElement(document()).get(), startOfInsertedContent.deepEquivalent());
|
| + insertNodeAt(createBreakElement(&document()).get(), startOfInsertedContent.deepEquivalent());
|
|
|
| if (endBR && (plainTextFragment || shouldRemoveEndBR(endBR, originalVisPosBeforeEndBR))) {
|
| RefPtr<Node> parent = endBR->parentNode();
|
| @@ -1150,7 +1150,7 @@ void ReplaceSelectionCommand::doApply()
|
| // We insert a placeholder before the newly inserted content to avoid being merged into the inline.
|
| Node* destinationNode = destination.deepEquivalent().deprecatedNode();
|
| if (m_shouldMergeEnd && destinationNode != enclosingInline(destinationNode) && enclosingInline(destinationNode)->nextSibling())
|
| - insertNodeBefore(createBreakElement(document()), refNode.get());
|
| + insertNodeBefore(createBreakElement(&document()), refNode.get());
|
|
|
| // Merging the the first paragraph of inserted content with the content that came
|
| // before the selection that was pasted into would also move content after
|
| @@ -1161,7 +1161,7 @@ void ReplaceSelectionCommand::doApply()
|
| // comes after and prevent that from happening.
|
| VisiblePosition endOfInsertedContent = positionAtEndOfInsertedContent();
|
| if (startOfParagraph(endOfInsertedContent) == startOfParagraphToMove) {
|
| - insertNodeAt(createBreakElement(document()).get(), endOfInsertedContent.deepEquivalent());
|
| + insertNodeAt(createBreakElement(&document()).get(), endOfInsertedContent.deepEquivalent());
|
| // Mutation events (bug 22634) triggered by inserting the <br> might have removed the content we're about to move
|
| if (!startOfParagraphToMove.deepEquivalent().anchorNode()->inDocument())
|
| return;
|
| @@ -1185,7 +1185,7 @@ void ReplaceSelectionCommand::doApply()
|
| setEndingSelection(endOfInsertedContent);
|
| Node* enclosingNode = enclosingBlock(endOfInsertedContent.deepEquivalent().deprecatedNode());
|
| if (isListItem(enclosingNode)) {
|
| - RefPtr<Node> newListItem = createListItemElement(document());
|
| + RefPtr<Node> newListItem = createListItemElement(&document());
|
| insertNodeAfter(newListItem, enclosingNode);
|
| setEndingSelection(VisiblePosition(firstPositionInNode(newListItem.get())));
|
| } else {
|
| @@ -1233,7 +1233,7 @@ bool ReplaceSelectionCommand::shouldRemoveEndBR(Node* endBR, const VisiblePositi
|
| return false;
|
|
|
| // Remove the br if it is collapsed away and so is unnecessary.
|
| - if (!document()->inNoQuirksMode() && isEndOfBlock(visiblePos) && !isStartOfParagraph(visiblePos))
|
| + if (!document().inNoQuirksMode() && isEndOfBlock(visiblePos) && !isStartOfParagraph(visiblePos))
|
| return true;
|
|
|
| // A br that was originally holding a line open should be displaced by inserted content or turned into a line break.
|
| @@ -1279,13 +1279,13 @@ void ReplaceSelectionCommand::addSpacesForSmartReplace()
|
| if (m_endOfInsertedContent.containerNode() == endNode)
|
| m_endOfInsertedContent.moveToOffset(m_endOfInsertedContent.offsetInContainerNode() + 1);
|
| } else {
|
| - RefPtr<Node> node = document()->createEditingTextNode(collapseWhiteSpace ? nonBreakingSpaceString() : " ");
|
| + RefPtr<Node> node = document().createEditingTextNode(collapseWhiteSpace ? nonBreakingSpaceString() : " ");
|
| insertNodeAfter(node, endNode);
|
| updateNodesInserted(node.get());
|
| }
|
| }
|
|
|
| - document()->updateLayout();
|
| + document().updateLayout();
|
|
|
| Position startDownstream = startOfInsertedContent.deepEquivalent().downstream();
|
| Node* startNode = startDownstream.computeNodeAfterPosition();
|
| @@ -1303,7 +1303,7 @@ void ReplaceSelectionCommand::addSpacesForSmartReplace()
|
| if (m_endOfInsertedContent.containerNode() == startNode && m_endOfInsertedContent.offsetInContainerNode())
|
| m_endOfInsertedContent.moveToOffset(m_endOfInsertedContent.offsetInContainerNode() + 1);
|
| } else {
|
| - RefPtr<Node> node = document()->createEditingTextNode(collapseWhiteSpace ? nonBreakingSpaceString() : " ");
|
| + RefPtr<Node> node = document().createEditingTextNode(collapseWhiteSpace ? nonBreakingSpaceString() : " ");
|
| // Don't updateNodesInserted. Doing so would set m_endOfInsertedContent to be the node containing the leading space,
|
| // but m_endOfInsertedContent is supposed to mark the end of pasted content.
|
| insertNodeBefore(node, startNode);
|
|
|