Modified: trunk/Source/WebCore/ChangeLog (106645 => 106646)
--- trunk/Source/WebCore/ChangeLog 2012-02-03 11:05:06 UTC (rev 106645)
+++ trunk/Source/WebCore/ChangeLog 2012-02-03 11:39:51 UTC (rev 106646)
@@ -1,3 +1,20 @@
+2012-02-03 MORITA Hajime <[email protected]>
+
+ TypingCommand should be prepared against detached document.
+ https://bugs.webkit.org/show_bug.cgi?id=77216
+
+ Reviewed by Ryosuke Niwa.
+
+ Added null checks for document()->frame().
+
+ No new tests. Just tighten guards for possible codepaths.
+
+ * editing/TypingCommand.cpp:
+ (WebCore::TypingCommand::markMisspellingsAfterTyping):
+ (WebCore::TypingCommand::typingAddedToOpenCommand):
+ (WebCore::TypingCommand::deleteKeyPressed):
+ (WebCore::TypingCommand::forwardDeleteKeyPressed):
+
2012-02-03 Kentaro Hara <[email protected]>
Rename [DontEnum] IDL to [NotEnumerable] IDL
Modified: trunk/Source/WebCore/editing/TypingCommand.cpp (106645 => 106646)
--- trunk/Source/WebCore/editing/TypingCommand.cpp 2012-02-03 11:05:06 UTC (rev 106645)
+++ trunk/Source/WebCore/editing/TypingCommand.cpp 2012-02-03 11:39:51 UTC (rev 106646)
@@ -296,15 +296,19 @@
void TypingCommand::markMisspellingsAfterTyping(ETypingCommand commandType)
{
+ Frame* frame = document()->frame();
+ if (!frame)
+ return;
+
#if PLATFORM(MAC) && !defined(BUILDING_ON_LEOPARD)
- if (!document()->frame()->editor()->isContinuousSpellCheckingEnabled()
- && !document()->frame()->editor()->isAutomaticQuoteSubstitutionEnabled()
- && !document()->frame()->editor()->isAutomaticLinkDetectionEnabled()
- && !document()->frame()->editor()->isAutomaticDashSubstitutionEnabled()
- && !document()->frame()->editor()->isAutomaticTextReplacementEnabled())
+ if (!frame->editor()->isContinuousSpellCheckingEnabled()
+ && !frame->editor()->isAutomaticQuoteSubstitutionEnabled()
+ && !frame->editor()->isAutomaticLinkDetectionEnabled()
+ && !frame->editor()->isAutomaticDashSubstitutionEnabled()
+ && !frame->editor()->isAutomaticTextReplacementEnabled())
return;
#else
- if (!document()->frame()->editor()->isContinuousSpellCheckingEnabled())
+ if (!frame->editor()->isContinuousSpellCheckingEnabled())
return;
#endif
// Take a look at the selection that results after typing and determine whether we need to spellcheck.
@@ -321,25 +325,29 @@
String strippedPreviousWord;
if (range && (commandType == TypingCommand::InsertText || commandType == TypingCommand::InsertLineBreak || commandType == TypingCommand::InsertParagraphSeparator || commandType == TypingCommand::InsertParagraphSeparatorInQuotedContent))
strippedPreviousWord = plainText(range.get()).stripWhiteSpace();
- document()->frame()->editor()->markMisspellingsAfterTypingToWord(p1, endingSelection(), !strippedPreviousWord.isEmpty());
+ frame->editor()->markMisspellingsAfterTypingToWord(p1, endingSelection(), !strippedPreviousWord.isEmpty());
} else if (commandType == TypingCommand::InsertText)
- document()->frame()->editor()->startCorrectionPanelTimer();
+ frame->editor()->startCorrectionPanelTimer();
}
}
void TypingCommand::typingAddedToOpenCommand(ETypingCommand commandTypeForAddedTyping)
{
+ Frame* frame = document()->frame();
+ if (!frame)
+ return;
+
updatePreservesTypingStyle(commandTypeForAddedTyping);
#if PLATFORM(MAC) && !defined(BUILDING_ON_LEOPARD)
- document()->frame()->editor()->appliedEditing(this);
+ frame->editor()->appliedEditing(this);
// Since the spellchecking code may also perform corrections and other replacements, it should happen after the typing changes.
if (!m_shouldPreventSpellChecking)
markMisspellingsAfterTyping(commandTypeForAddedTyping);
#else
// The old spellchecking code requires that checking be done first, to prevent issues like that in 6864072, where <doesn't> is marked as misspelled.
markMisspellingsAfterTyping(commandTypeForAddedTyping);
- document()->frame()->editor()->appliedEditing(this);
+ frame->editor()->appliedEditing(this);
#endif
}
@@ -431,8 +439,12 @@
void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool killRing)
{
- document()->frame()->editor()->updateMarkersForWordsAffectedByEditing(false);
+ Frame* frame = document()->frame();
+ if (!frame)
+ return;
+ frame->editor()->updateMarkersForWordsAffectedByEditing(false);
+
VisibleSelection selectionToDelete;
VisibleSelection selectionAfterUndo;
@@ -513,11 +525,11 @@
if (selectionToDelete.isNone())
return;
- if (selectionToDelete.isCaret() || !document()->frame()->selection()->shouldDeleteSelection(selectionToDelete))
+ if (selectionToDelete.isCaret() || !frame->selection()->shouldDeleteSelection(selectionToDelete))
return;
if (killRing)
- document()->frame()->editor()->addToKillRing(selectionToDelete.toNormalizedRange().get(), false);
+ frame->editor()->addToKillRing(selectionToDelete.toNormalizedRange().get(), false);
// Make undo select everything that has been deleted, unless an undo will undo more than just this deletion.
// FIXME: This behaves like TextEdit except for the case where you open with text insertion and then delete
// more text than you insert. In that case all of the text that was around originally should be selected.
@@ -530,8 +542,12 @@
void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool killRing)
{
- document()->frame()->editor()->updateMarkersForWordsAffectedByEditing(false);
+ Frame* frame = document()->frame();
+ if (!frame)
+ return;
+ frame->editor()->updateMarkersForWordsAffectedByEditing(false);
+
VisibleSelection selectionToDelete;
VisibleSelection selectionAfterUndo;
@@ -599,11 +615,11 @@
if (selectionToDelete.isNone())
return;
- if (selectionToDelete.isCaret() || !document()->frame()->selection()->shouldDeleteSelection(selectionToDelete))
+ if (selectionToDelete.isCaret() || !frame->selection()->shouldDeleteSelection(selectionToDelete))
return;
if (killRing)
- document()->frame()->editor()->addToKillRing(selectionToDelete.toNormalizedRange().get(), false);
+ frame->editor()->addToKillRing(selectionToDelete.toNormalizedRange().get(), false);
// make undo select what was deleted
setStartingSelection(selectionAfterUndo);
CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete);