Changeset 106646 in webkit


Ignore:
Timestamp:
Feb 3, 2012 3:39:51 AM (12 years ago)
Author:
morrita@google.com
Message:

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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r106645 r106646  
     12012-02-03  MORITA Hajime  <morrita@google.com>
     2
     3        TypingCommand should be prepared against detached document.
     4        https://bugs.webkit.org/show_bug.cgi?id=77216
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Added null checks for document()->frame().
     9
     10        No new tests. Just tighten guards for possible codepaths.
     11
     12        * editing/TypingCommand.cpp:
     13        (WebCore::TypingCommand::markMisspellingsAfterTyping):
     14        (WebCore::TypingCommand::typingAddedToOpenCommand):
     15        (WebCore::TypingCommand::deleteKeyPressed):
     16        (WebCore::TypingCommand::forwardDeleteKeyPressed):
     17
    1182012-02-03  Kentaro Hara  <haraken@chromium.org>
    219
  • trunk/Source/WebCore/editing/TypingCommand.cpp

    r105441 r106646  
    297297void TypingCommand::markMisspellingsAfterTyping(ETypingCommand commandType)
    298298{
     299    Frame* frame = document()->frame();
     300    if (!frame)
     301        return;
     302
    299303#if PLATFORM(MAC) && !defined(BUILDING_ON_LEOPARD)
    300     if (!document()->frame()->editor()->isContinuousSpellCheckingEnabled()
    301      && !document()->frame()->editor()->isAutomaticQuoteSubstitutionEnabled()
    302      && !document()->frame()->editor()->isAutomaticLinkDetectionEnabled()
    303      && !document()->frame()->editor()->isAutomaticDashSubstitutionEnabled()
    304      && !document()->frame()->editor()->isAutomaticTextReplacementEnabled())
     304    if (!frame->editor()->isContinuousSpellCheckingEnabled()
     305     && !frame->editor()->isAutomaticQuoteSubstitutionEnabled()
     306     && !frame->editor()->isAutomaticLinkDetectionEnabled()
     307     && !frame->editor()->isAutomaticDashSubstitutionEnabled()
     308     && !frame->editor()->isAutomaticTextReplacementEnabled())
    305309        return;
    306310#else
    307     if (!document()->frame()->editor()->isContinuousSpellCheckingEnabled())
     311    if (!frame->editor()->isContinuousSpellCheckingEnabled())
    308312        return;
    309313#endif
     
    322326            if (range && (commandType == TypingCommand::InsertText || commandType == TypingCommand::InsertLineBreak || commandType == TypingCommand::InsertParagraphSeparator || commandType == TypingCommand::InsertParagraphSeparatorInQuotedContent))
    323327                strippedPreviousWord = plainText(range.get()).stripWhiteSpace();
    324             document()->frame()->editor()->markMisspellingsAfterTypingToWord(p1, endingSelection(), !strippedPreviousWord.isEmpty());
     328            frame->editor()->markMisspellingsAfterTypingToWord(p1, endingSelection(), !strippedPreviousWord.isEmpty());
    325329        } else if (commandType == TypingCommand::InsertText)
    326             document()->frame()->editor()->startCorrectionPanelTimer();
     330            frame->editor()->startCorrectionPanelTimer();
    327331    }
    328332}
     
    330334void TypingCommand::typingAddedToOpenCommand(ETypingCommand commandTypeForAddedTyping)
    331335{
     336    Frame* frame = document()->frame();
     337    if (!frame)
     338        return;
     339
    332340    updatePreservesTypingStyle(commandTypeForAddedTyping);
    333341
    334342#if PLATFORM(MAC) && !defined(BUILDING_ON_LEOPARD)
    335     document()->frame()->editor()->appliedEditing(this);
     343    frame->editor()->appliedEditing(this);
    336344    // Since the spellchecking code may also perform corrections and other replacements, it should happen after the typing changes.
    337345    if (!m_shouldPreventSpellChecking)
     
    340348    // The old spellchecking code requires that checking be done first, to prevent issues like that in 6864072, where <doesn't> is marked as misspelled.
    341349    markMisspellingsAfterTyping(commandTypeForAddedTyping);
    342     document()->frame()->editor()->appliedEditing(this);
     350    frame->editor()->appliedEditing(this);
    343351#endif
    344352}
     
    432440void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool killRing)
    433441{
    434     document()->frame()->editor()->updateMarkersForWordsAffectedByEditing(false);
     442    Frame* frame = document()->frame();
     443    if (!frame)
     444        return;
     445
     446    frame->editor()->updateMarkersForWordsAffectedByEditing(false);
    435447
    436448    VisibleSelection selectionToDelete;
     
    514526        return;
    515527   
    516     if (selectionToDelete.isCaret() || !document()->frame()->selection()->shouldDeleteSelection(selectionToDelete))
     528    if (selectionToDelete.isCaret() || !frame->selection()->shouldDeleteSelection(selectionToDelete))
    517529        return;
    518530   
    519531    if (killRing)
    520         document()->frame()->editor()->addToKillRing(selectionToDelete.toNormalizedRange().get(), false);
     532        frame->editor()->addToKillRing(selectionToDelete.toNormalizedRange().get(), false);
    521533    // Make undo select everything that has been deleted, unless an undo will undo more than just this deletion.
    522534    // FIXME: This behaves like TextEdit except for the case where you open with text insertion and then delete
     
    531543void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool killRing)
    532544{
    533     document()->frame()->editor()->updateMarkersForWordsAffectedByEditing(false);
     545    Frame* frame = document()->frame();
     546    if (!frame)
     547        return;
     548
     549    frame->editor()->updateMarkersForWordsAffectedByEditing(false);
    534550
    535551    VisibleSelection selectionToDelete;
     
    600616        return;
    601617   
    602     if (selectionToDelete.isCaret() || !document()->frame()->selection()->shouldDeleteSelection(selectionToDelete))
     618    if (selectionToDelete.isCaret() || !frame->selection()->shouldDeleteSelection(selectionToDelete))
    603619        return;
    604620       
    605621    if (killRing)
    606         document()->frame()->editor()->addToKillRing(selectionToDelete.toNormalizedRange().get(), false);
     622        frame->editor()->addToKillRing(selectionToDelete.toNormalizedRange().get(), false);
    607623    // make undo select what was deleted
    608624    setStartingSelection(selectionAfterUndo);
Note: See TracChangeset for help on using the changeset viewer.