Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(743)

Unified Diff: Source/core/editing/InsertParagraphSeparatorCommand.cpp

Issue 23822003: Have EditCommand classes deal with Document references, not pointers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/InsertParagraphSeparatorCommand.h ('k') | Source/core/editing/InsertTextCommand.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/InsertParagraphSeparatorCommand.cpp
diff --git a/Source/core/editing/InsertParagraphSeparatorCommand.cpp b/Source/core/editing/InsertParagraphSeparatorCommand.cpp
index 92d8b4cfbc3b7d8102f1900507b0e09d02bee834..4f8c8d3004e374198ffcce6e454e7128ef792522 100644
--- a/Source/core/editing/InsertParagraphSeparatorCommand.cpp
+++ b/Source/core/editing/InsertParagraphSeparatorCommand.cpp
@@ -58,7 +58,7 @@ static Element* highestVisuallyEquivalentDivBelowRoot(Element* startBlock)
return curBlock;
}
-InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand(Document *document, bool mustUseDefaultParagraphElement, bool pasteBlockqutoeIntoUnquotedArea)
+InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand(Document& document, bool mustUseDefaultParagraphElement, bool pasteBlockqutoeIntoUnquotedArea)
: CompositeEditCommand(document)
, m_mustUseDefaultParagraphElement(mustUseDefaultParagraphElement)
, m_pasteBlockqutoeIntoUnquotedArea(pasteBlockqutoeIntoUnquotedArea)
@@ -201,12 +201,13 @@ void InsertParagraphSeparatorCommand::doApply()
// Create block to be inserted.
RefPtr<Element> blockToInsert;
if (startBlock->isRootEditableElement()) {
- blockToInsert = createDefaultParagraphElement(document());
+ blockToInsert = createDefaultParagraphElement(&document());
nestNewBlock = true;
- } else if (shouldUseDefaultParagraphElement(startBlock.get()))
- blockToInsert = createDefaultParagraphElement(document());
- else
+ } else if (shouldUseDefaultParagraphElement(startBlock.get())) {
+ blockToInsert = createDefaultParagraphElement(&document());
+ } else {
blockToInsert = startBlock->cloneElementWithoutChildren();
+ }
//---------------------------------------------------------------------
// Handle case when position is in the last visible position in its block,
@@ -216,7 +217,7 @@ void InsertParagraphSeparatorCommand::doApply()
if (isFirstInBlock && !lineBreakExistsAtVisiblePosition(visiblePos)) {
// The block is empty. Create an empty block to
// represent the paragraph that we're leaving.
- RefPtr<Element> extraBlock = createDefaultParagraphElement(document());
+ RefPtr<Element> extraBlock = createDefaultParagraphElement(&document());
appendNode(extraBlock, startBlock);
appendBlockPlaceholder(extraBlock);
}
@@ -296,7 +297,7 @@ void InsertParagraphSeparatorCommand::doApply()
// it if visiblePos is at the start of a paragraph so that the
// content will move down a line.
if (isStartOfParagraph(visiblePos)) {
- RefPtr<Element> br = createBreakElement(document());
+ RefPtr<Element> br = createBreakElement(&document());
insertNodeAt(br.get(), insertionPosition);
insertionPosition = positionInParentAfterNode(br.get());
// If the insertion point is a break element, there is nothing else
@@ -359,13 +360,13 @@ void InsertParagraphSeparatorCommand::doApply()
else
insertNodeAfter(blockToInsert.get(), startBlock);
- document()->updateLayoutIgnorePendingStylesheets();
+ document().updateLayoutIgnorePendingStylesheets();
// If the paragraph separator was inserted at the end of a paragraph, an empty line must be
// created. All of the nodes, starting at visiblePos, are about to be added to the new paragraph
// element. If the first node to be inserted won't be one that will hold an empty line open, add a br.
if (isEndOfParagraph(visiblePos) && !lineBreakExistsAtVisiblePosition(visiblePos))
- appendNode(createBreakElement(document()).get(), blockToInsert.get());
+ appendNode(createBreakElement(&document()).get(), blockToInsert.get());
// Move the start node and the siblings of the start node.
if (VisiblePosition(insertionPosition) != VisiblePosition(positionBeforeNode(blockToInsert.get()))) {
@@ -391,7 +392,7 @@ void InsertParagraphSeparatorCommand::doApply()
// Handle whitespace that occurs after the split
if (positionAfterSplit.isNotNull()) {
- document()->updateLayoutIgnorePendingStylesheets();
+ document().updateLayoutIgnorePendingStylesheets();
if (!positionAfterSplit.isRenderedCharacter()) {
// Clear out all whitespace and insert one non-breaking space
ASSERT(!positionAfterSplit.containerNode()->renderer() || positionAfterSplit.containerNode()->renderer()->style()->collapseWhiteSpace());
« no previous file with comments | « Source/core/editing/InsertParagraphSeparatorCommand.h ('k') | Source/core/editing/InsertTextCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698