Changeset 113405 in webkit


Ignore:
Timestamp:
Apr 5, 2012 7:48:37 PM (12 years ago)
Author:
hbono@chromium.org
Message:

[Chromium] moving a cursor on a misspelled word should not remove a misspelled underline
https://bugs.webkit.org/show_bug.cgi?id=83214

Reviewed by Ryosuke Niwa.

When Chrome enables asynchronous spellchecking, it adds Spelling markers in the
background. For this case, moving a cursor should not remove these markers
because it requires Chrome to spellcheck text again. This change prevents
removing Spelling markers added by spellcheckers asynchronously.

Source/WebCore:

Test: platform/chromium/editing/spelling/move-cursor-to-misspelled-word.html

  • editing/Editor.cpp:

(WebCore::Editor::respondToChangedSelection):

Source/WebKit/chromium:

  • src/ContextMenuClientImpl.cpp:

(WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems): use marker descriptions instead of spellchecking text when Chrome enables asynchronous spellchecking.

LayoutTests:

  • platform/chromium/editing/spelling/move-cursor-to-misspelled-word-expected.txt: Added.
  • platform/chromium/editing/spelling/move-cursor-to-misspelled-word.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r113402 r113405  
     12012-04-05  Hironori Bono  <hbono@chromium.org>
     2
     3        [Chromium] moving a cursor on a misspelled word should not remove a misspelled underline
     4        https://bugs.webkit.org/show_bug.cgi?id=83214
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        When Chrome enables asynchronous spellchecking, it adds Spelling markers in the
     9        background. For this case, moving a cursor should not remove these markers
     10        because it requires Chrome to spellcheck text again. This change prevents
     11        removing Spelling markers added by spellcheckers asynchronously.
     12
     13        * platform/chromium/editing/spelling/move-cursor-to-misspelled-word-expected.txt: Added.
     14        * platform/chromium/editing/spelling/move-cursor-to-misspelled-word.html: Added.
     15
    1162012-04-05  Martin Robinson  <mrobinson@igalia.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r113400 r113405  
     12012-04-05  Hironori Bono  <hbono@chromium.org>
     2
     3        [Chromium] moving a cursor on a misspelled word should not remove a misspelled underline
     4        https://bugs.webkit.org/show_bug.cgi?id=83214
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        When Chrome enables asynchronous spellchecking, it adds Spelling markers in the
     9        background. For this case, moving a cursor should not remove these markers
     10        because it requires Chrome to spellcheck text again. This change prevents
     11        removing Spelling markers added by spellcheckers asynchronously.
     12
     13        Test: platform/chromium/editing/spelling/move-cursor-to-misspelled-word.html
     14
     15        * editing/Editor.cpp:
     16        (WebCore::Editor::respondToChangedSelection):
     17
    1182012-04-05  Hans Muller  <hmuller@adobe.com>
    219
  • trunk/Source/WebCore/editing/Editor.cpp

    r113127 r113405  
    29242924
    29252925#if !PLATFORM(MAC) || (PLATFORM(MAC) && (defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)))
     2926#if PLATFORM(CHROMIUM)
     2927        if (!m_frame->settings() || !m_frame->settings()->asynchronousSpellCheckingEnabled()) {
     2928            if (RefPtr<Range> wordRange = newAdjacentWords.toNormalizedRange())
     2929                m_frame->document()->markers()->removeMarkers(wordRange.get(), DocumentMarker::Spelling);
     2930        }
     2931#else
    29262932        // This only erases markers that are in the first unit (word or sentence) of the selection.
    29272933        // Perhaps peculiar, but it matches AppKit on these Mac OS X versions.
    29282934        if (RefPtr<Range> wordRange = newAdjacentWords.toNormalizedRange())
    29292935            m_frame->document()->markers()->removeMarkers(wordRange.get(), DocumentMarker::Spelling);
     2936#endif
    29302937#endif
    29312938        if (RefPtr<Range> sentenceRange = newSelectedSentence.toNormalizedRange())
  • trunk/Source/WebKit/chromium/ChangeLog

    r113372 r113405  
     12012-04-05  Hironori Bono  <hbono@chromium.org>
     2
     3        [Chromium] moving a cursor on a misspelled word should not remove a misspelled underline
     4        https://bugs.webkit.org/show_bug.cgi?id=83214
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        When Chrome enables asynchronous spellchecking, it adds Spelling markers in the
     9        background. For this case, moving a cursor should not remove these markers
     10        because it requires Chrome to spellcheck text again. This change prevents
     11        removing Spelling markers added by spellcheckers asynchronously.
     12
     13        * src/ContextMenuClientImpl.cpp:
     14        (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems): use marker descriptions instead of spellchecking text when Chrome enables asynchronous spellchecking.
     15
    1162012-04-05  Dana Jansens  <danakj@chromium.org>
    217
  • trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp

    r110348 r113405  
    3838#include "Document.h"
    3939#include "DocumentLoader.h"
     40#include "DocumentMarkerController.h"
    4041#include "Editor.h"
    4142#include "EventHandler.h"
     
    5556#include "PlatformString.h"
    5657#include "RenderWidget.h"
     58#include "Settings.h"
    5759#include "TextBreakIterator.h"
    5860#include "Widget.h"
     
    273275        } 
    274276#endif
    275         if (m_webView->focusedWebCoreFrame()->editor()->isContinuousSpellCheckingEnabled()) {
     277        // When Chrome enables asynchronous spellchecking, its spellchecker adds spelling markers to misspelled
     278        // words and attaches suggestions to these markers in the background. Therefore, when a user right-clicks
     279        // a mouse on a word, Chrome just needs to find a spelling marker on the word instread of spellchecking it.
     280        if (selectedFrame->settings() && selectedFrame->settings()->asynchronousSpellCheckingEnabled()) {
     281            RefPtr<Range> range = selectedFrame->selection()->toNormalizedRange();
     282            Vector<DocumentMarker*> markers = selectedFrame->document()->markers()->markersInRange(range.get(), DocumentMarker::Spelling);
     283            if (!markers.isEmpty()) {
     284                Vector<String> suggestions;
     285                for (size_t i = 0; i < markers.size(); ++i) {
     286                    if (!markers[i]->description().isEmpty()) {
     287                        Vector<String> descriptions;
     288                        markers[i]->description().split('\n', descriptions);
     289                        suggestions.append(descriptions);
     290                    }
     291                }
     292                data.dictionarySuggestions = suggestions;
     293                data.misspelledWord = range->text();
     294            }
     295        } else if (m_webView->focusedWebCoreFrame()->editor()->isContinuousSpellCheckingEnabled()) {
    276296            data.isSpellCheckingEnabled = true;
    277297            // Spellchecking might be enabled for the field, but could be disabled on the node.
Note: See TracChangeset for help on using the changeset viewer.