Changeset 86132 in webkit


Ignore:
Timestamp:
May 10, 2011 12:46:51 AM (13 years ago)
Author:
morrita@google.com
Message:

2011-05-10 MORITA Hajime <morrita@google.com>

Reviewed by Ryosuke Niwa.

REGRESSION(r73886): Frequent crashes in replaceSelectionWithFragment
https://bugs.webkit.org/show_bug.cgi?id=60090

SpellChecker uses TextCheckerClient, which belongs Page object,
which is possibly destroyed during SpellChecker's lifetime.
This change added to a guard before using TextCheckerClient to
ensure it being live.

No new tests, this is a speculative fix for a real crash.

  • editing/Editor.cpp: (WebCore::Editor::Editor):
  • editing/SpellChecker.cpp: (WebCore::SpellChecker::SpellChecker): (WebCore::SpellChecker::client): (WebCore::SpellChecker::canCheckAsynchronously): (WebCore::SpellChecker::requestCheckingFor):
  • editing/SpellChecker.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86131 r86132  
     12011-05-10  MORITA Hajime  <morrita@google.com>
     2
     3        Reviewed by Ryosuke Niwa.
     4
     5        REGRESSION(r73886): Frequent crashes in replaceSelectionWithFragment
     6        https://bugs.webkit.org/show_bug.cgi?id=60090
     7
     8        SpellChecker uses TextCheckerClient, which belongs Page object,
     9        which is possibly destroyed during SpellChecker's lifetime.
     10        This change added to a guard before using TextCheckerClient to
     11        ensure it being live.
     12       
     13        No new tests, this is a speculative fix for a real crash.
     14
     15        * editing/Editor.cpp:
     16        (WebCore::Editor::Editor):
     17        * editing/SpellChecker.cpp:
     18        (WebCore::SpellChecker::SpellChecker):
     19        (WebCore::SpellChecker::client):
     20        (WebCore::SpellChecker::canCheckAsynchronously):
     21        (WebCore::SpellChecker::requestCheckingFor):
     22        * editing/SpellChecker.h:
     23
    1242011-05-09  Dan Bernstein  <mitz@apple.com>
    225
  • trunk/Source/WebCore/editing/Editor.cpp

    r85864 r86132  
    10531053    , m_shouldStyleWithCSS(false)
    10541054    , m_killRing(adoptPtr(new KillRing))
    1055     , m_spellChecker(adoptPtr(new SpellChecker(frame, frame->page() ? frame->page()->editorClient()->textChecker() : 0)))
     1055    , m_spellChecker(adoptPtr(new SpellChecker(frame)))
    10561056    , m_spellingCorrector(adoptPtr(new SpellingCorrectionController(frame)))
    10571057    , m_areMarkedTextMatchesHighlighted(false)
  • trunk/Source/WebCore/editing/SpellChecker.cpp

    r82952 r86132  
    3434#include "HTMLTextAreaElement.h"
    3535#include "Node.h"
     36#include "Page.h"
    3637#include "PositionIterator.h"
    3738#include "Range.h"
     
    4445namespace WebCore {
    4546
    46 SpellChecker::SpellChecker(Frame* frame, TextCheckerClient* client)
     47SpellChecker::SpellChecker(Frame* frame)
    4748    : m_frame(frame)
    48     , m_client(client)
    4949    , m_requestSequence(0)
    5050{
     
    5353SpellChecker::~SpellChecker()
    5454{
     55}
     56
     57TextCheckerClient* SpellChecker::client() const
     58{
     59    Page* page = m_frame->page();
     60    if (!page)
     61        return 0;
     62    return page->editorClient()->textChecker();
    5563}
    5664
     
    8391bool SpellChecker::canCheckAsynchronously(Node* node) const
    8492{
    85     return isCheckable(node) && isAsynchronousEnabled() && !isBusy();
     93    return client() && isCheckable(node) && isAsynchronousEnabled() && !isBusy();
    8694}
    8795
     
    107115    if (!initRequest(node))
    108116        return;
    109     m_client->requestCheckingOfString(this, m_requestSequence, mask, m_requestText);
     117    client()->requestCheckingOfString(this, m_requestSequence, mask, m_requestText);
    110118}
    111119
  • trunk/Source/WebCore/editing/SpellChecker.h

    r82952 r86132  
    4040    WTF_MAKE_NONCOPYABLE(SpellChecker);
    4141public:
    42     explicit SpellChecker(Frame*, TextCheckerClient*);
     42    explicit SpellChecker(Frame*);
    4343    ~SpellChecker();
    4444
     
    5454    bool initRequest(Node*);
    5555    void clearRequest();
     56    TextCheckerClient* client() const;
    5657
    5758    Frame* m_frame;
    58     TextCheckerClient* m_client;
    5959
    6060    RefPtr<Node> m_requestNode;
Note: See TracChangeset for help on using the changeset viewer.