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

Unified Diff: Source/core/editing/TypingCommand.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/TypingCommand.h ('k') | Source/core/editing/UnlinkCommand.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/TypingCommand.cpp
diff --git a/Source/core/editing/TypingCommand.cpp b/Source/core/editing/TypingCommand.cpp
index a860d5d0ca9c2beefc74af29694b1c1e7c22596b..2cf9ca57ad10e65c938af8ead894b1819db8a4ac 100644
--- a/Source/core/editing/TypingCommand.cpp
+++ b/Source/core/editing/TypingCommand.cpp
@@ -73,7 +73,7 @@ private:
const String& m_text;
};
-TypingCommand::TypingCommand(Document *document, ETypingCommand commandType, const String &textToInsert, Options options, TextGranularity granularity, TextCompositionType compositionType)
+TypingCommand::TypingCommand(Document& document, ETypingCommand commandType, const String &textToInsert, Options options, TextGranularity granularity, TextCompositionType compositionType)
: TextInsertionBaseCommand(document)
, m_commandType(commandType)
, m_textToInsert(textToInsert)
@@ -90,11 +90,9 @@ TypingCommand::TypingCommand(Document *document, ETypingCommand commandType, con
updatePreservesTypingStyle(m_commandType);
}
-void TypingCommand::deleteSelection(Document* document, Options options)
+void TypingCommand::deleteSelection(Document& document, Options options)
{
- ASSERT(document);
-
- Frame* frame = document->frame();
+ Frame* frame = document.frame();
ASSERT(frame);
if (!frame->selection()->isRange())
@@ -109,12 +107,11 @@ void TypingCommand::deleteSelection(Document* document, Options options)
TypingCommand::create(document, DeleteSelection, "", options)->apply();
}
-void TypingCommand::deleteKeyPressed(Document *document, Options options, TextGranularity granularity)
+void TypingCommand::deleteKeyPressed(Document& document, Options options, TextGranularity granularity)
{
- ASSERT(document);
if (granularity == CharacterGranularity) {
- if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document->frame())) {
- updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand.get(), document->frame());
+ if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document.frame())) {
+ updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand.get(), document.frame());
lastTypingCommand->setShouldPreventSpellChecking(options & PreventSpellChecking);
lastTypingCommand->deleteKeyPressed(granularity, options & KillRing);
return;
@@ -124,11 +121,10 @@ void TypingCommand::deleteKeyPressed(Document *document, Options options, TextGr
TypingCommand::create(document, DeleteKey, "", options, granularity)->apply();
}
-void TypingCommand::forwardDeleteKeyPressed(Document *document, Options options, TextGranularity granularity)
+void TypingCommand::forwardDeleteKeyPressed(Document& document, Options options, TextGranularity granularity)
{
// FIXME: Forward delete in TextEdit appears to open and close a new typing command.
- ASSERT(document);
- Frame* frame = document->frame();
+ Frame* frame = document.frame();
if (granularity == CharacterGranularity) {
if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(frame)) {
updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand.get(), frame);
@@ -152,25 +148,21 @@ void TypingCommand::updateSelectionIfDifferentFromCurrentSelection(TypingCommand
typingCommand->setEndingSelection(currentSelection);
}
-void TypingCommand::insertText(Document* document, const String& text, Options options, TextCompositionType composition)
+void TypingCommand::insertText(Document& document, const String& text, Options options, TextCompositionType composition)
{
- ASSERT(document);
-
- Frame* frame = document->frame();
+ Frame* frame = document.frame();
ASSERT(frame);
if (!text.isEmpty())
- document->frame()->editor().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text[0]));
+ document.frame()->editor().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text[0]));
insertText(document, text, frame->selection()->selection(), options, composition);
}
// FIXME: We shouldn't need to take selectionForInsertion. It should be identical to FrameSelection's current selection.
-void TypingCommand::insertText(Document* document, const String& text, const VisibleSelection& selectionForInsertion, Options options, TextCompositionType compositionType)
+void TypingCommand::insertText(Document& document, const String& text, const VisibleSelection& selectionForInsertion, Options options, TextCompositionType compositionType)
{
- ASSERT(document);
-
- RefPtr<Frame> frame = document->frame();
+ RefPtr<Frame> frame = document.frame();
ASSERT(frame);
VisibleSelection currentSelection = frame->selection()->selection();
@@ -197,10 +189,9 @@ void TypingCommand::insertText(Document* document, const String& text, const Vis
applyTextInsertionCommand(frame.get(), cmd, selectionForInsertion, currentSelection);
}
-void TypingCommand::insertLineBreak(Document *document, Options options)
+void TypingCommand::insertLineBreak(Document& document, Options options)
{
- ASSERT(document);
- if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document->frame())) {
+ if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document.frame())) {
lastTypingCommand->setShouldRetainAutocorrectionIndicator(options & RetainAutocorrectionIndicator);
lastTypingCommand->insertLineBreak();
return;
@@ -209,10 +200,9 @@ void TypingCommand::insertLineBreak(Document *document, Options options)
applyCommand(TypingCommand::create(document, InsertLineBreak, "", options));
}
-void TypingCommand::insertParagraphSeparatorInQuotedContent(Document *document)
+void TypingCommand::insertParagraphSeparatorInQuotedContent(Document& document)
{
- ASSERT(document);
- if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document->frame())) {
+ if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document.frame())) {
lastTypingCommand->insertParagraphSeparatorInQuotedContent();
return;
}
@@ -220,10 +210,9 @@ void TypingCommand::insertParagraphSeparatorInQuotedContent(Document *document)
applyCommand(TypingCommand::create(document, InsertParagraphSeparatorInQuotedContent));
}
-void TypingCommand::insertParagraphSeparator(Document *document, Options options)
+void TypingCommand::insertParagraphSeparator(Document& document, Options options)
{
- ASSERT(document);
- if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document->frame())) {
+ if (RefPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(document.frame())) {
lastTypingCommand->setShouldRetainAutocorrectionIndicator(options & RetainAutocorrectionIndicator);
lastTypingCommand->insertParagraphSeparator();
return;
@@ -292,7 +281,7 @@ EditAction TypingCommand::editingAction() const
void TypingCommand::markMisspellingsAfterTyping(ETypingCommand commandType)
{
- Frame* frame = document()->frame();
+ Frame* frame = document().frame();
if (!frame)
return;
@@ -317,7 +306,7 @@ void TypingCommand::markMisspellingsAfterTyping(ETypingCommand commandType)
void TypingCommand::typingAddedToOpenCommand(ETypingCommand commandTypeForAddedTyping)
{
- Frame* frame = document()->frame();
+ Frame* frame = document().frame();
if (!frame)
return;
@@ -403,7 +392,7 @@ bool TypingCommand::makeEditableRootEmpty()
void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool killRing)
{
- Frame* frame = document()->frame();
+ Frame* frame = document().frame();
if (!frame)
return;
@@ -507,7 +496,7 @@ void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool killRing)
void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool killRing)
{
- Frame* frame = document()->frame();
+ Frame* frame = document().frame();
if (!frame)
return;
« no previous file with comments | « Source/core/editing/TypingCommand.h ('k') | Source/core/editing/UnlinkCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698