Diff
Modified: trunk/ChangeLog (98555 => 98556)
--- trunk/ChangeLog 2011-10-27 12:37:41 UTC (rev 98555)
+++ trunk/ChangeLog 2011-10-27 12:52:16 UTC (rev 98556)
@@ -1,3 +1,12 @@
+2011-10-27 Shinya Kawanaka <[email protected]>
+
+ Implement legacy text check emulation in unified text check interface.
+ https://bugs.webkit.org/show_bug.cgi?id=70299
+
+ Reviewed by Hajime Morita.
+
+ * Source/autotools/symbols.filter:
+
2011-10-27 Philippe Normand <[email protected]> and Zan Dobersek <[email protected]>
[GStreamer] WebAudio AudioFileReader implementation
Modified: trunk/LayoutTests/ChangeLog (98555 => 98556)
--- trunk/LayoutTests/ChangeLog 2011-10-27 12:37:41 UTC (rev 98555)
+++ trunk/LayoutTests/ChangeLog 2011-10-27 12:52:16 UTC (rev 98556)
@@ -1,3 +1,15 @@
+2011-10-27 Shinya Kawanaka <[email protected]>
+
+ Implement legacy text check emulation in unified text check interface.
+ https://bugs.webkit.org/show_bug.cgi?id=70299
+
+ Reviewed by Hajime Morita.
+
+ Added tests for the case unified text checker is used when WebCore::checkTextOfParagraph() is not supported.
+
+ * editing/spelling/spelling-unified-emulation-expected.txt: Added.
+ * editing/spelling/spelling-unified-emulation.html: Added.
+
2011-10-27 Philippe Normand <[email protected]>
Unreviewed, GTK rebaseline after r98507.
Added: trunk/LayoutTests/editing/spelling/spelling-unified-emulation-expected.txt (0 => 98556)
--- trunk/LayoutTests/editing/spelling/spelling-unified-emulation-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/spelling/spelling-unified-emulation-expected.txt 2011-10-27 12:52:16 UTC (rev 98556)
@@ -0,0 +1,31 @@
+The spellchecker should work correctly if unified spellcheck path is used.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS numMarked is length
+PASS str is markedStr
+PASS numMarked is length
+PASS str is markedStr
+PASS numMarked is length
+PASS str is markedStr
+PASS str is markedStr
+PASS numMarked is length
+PASS str is markedStr
+PASS str is markedStr
+PASS str is markedStr
+PASS numMarked is length
+PASS str is markedStr
+PASS str is markedStr
+PASS str is markedStr
+PASS numMarked is length
+PASS str is markedStr
+PASS numMarked is length
+PASS str is markedStr
+PASS numMarked is length
+PASS str is markedStr
+PASS numMarked is length
+PASS numMarked is length
+PASS successfullyParsed is true
+
+TEST COMPLETE
+I would like to sleep, zzz.
Added: trunk/LayoutTests/editing/spelling/spelling-unified-emulation.html (0 => 98556)
--- trunk/LayoutTests/editing/spelling/spelling-unified-emulation.html (rev 0)
+++ trunk/LayoutTests/editing/spelling/spelling-unified-emulation.html 2011-10-27 12:52:16 UTC (rev 98556)
@@ -0,0 +1,91 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<style>
+.editing {
+ border: 2px solid red;
+ padding: 6px;
+ font-size: 18px;
+}
+</style>
+</head>
+<body>
+<pre id="description"></pre>
+<pre id="console"></pre>
+<div id="container"></div>
+
+<script>
+description("The spellchecker should work correctly if unified spellcheck path is used.");
+
+var container = document.getElementById('container');
+function removeChildren(node) {
+ while (node.firstChild)
+ node.removeChild(node.firstChild);
+}
+
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+}
+
+if (window.internals)
+ internals.setUnifiedTextCheckingEnabled(document, true);
+
+var testData = [
+ { text: 'zz', marked: ['zz'] },
+ { text: 'apple,zz,orange', marked: ['zz'] },
+ { text: 'zz,zz', marked: ['zz','zz'] },
+ { text: 'zz zz zz', marked: ['zz', 'zz', 'zz'] },
+ { text: ' zz zz zz ', marked: ['zz', 'zz', 'zz'] },
+ { text: 'zz apple orange', marked: ['zz'] },
+ { text: 'apple zz orange', marked: ['zz'] },
+ { text: 'apple orange zz', marked: ['zz'] },
+ { text: 'zzz', marked: [] },
+ { text: 'I would like to sleep, zzz', marked: [] }
+];
+
+var numMarked;
+var len;
+var str;
+var markedStr;
+function performTest(id, data) {
+ removeChildren(container);
+ var e = document.createElement('div');
+ e.setAttribute("contentEditable", "true");
+ e.className = 'editing';
+ e.id = id;
+ container.appendChild(e);
+
+ e.focus();
+ for (var i = 0; i < data.text.length; ++i) {
+ typeCharacterCommand(data.text[i]);
+ }
+ typeCharacterCommand('.');
+
+ if (!window.internals)
+ return;
+
+ var e = document.getElementById(id);
+ numMarked = internals.markerCountForNode(e.firstChild);
+ length = data.marked.length;
+ shouldBe('numMarked', 'length');
+
+ for (var i = 0; i < numMarked; ++i) {
+ var range = internals.markerRangeForNode(e.firstChild, i);
+ str = range.toString();
+ markedStr = data.marked[i];
+ shouldBe('str', 'markedStr');
+ }
+}
+
+for (var i = 0; i < testData.length; ++i) {
+ performTest('test', testData[i]);
+}
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (98555 => 98556)
--- trunk/Source/WebCore/ChangeLog 2011-10-27 12:37:41 UTC (rev 98555)
+++ trunk/Source/WebCore/ChangeLog 2011-10-27 12:52:16 UTC (rev 98556)
@@ -1,3 +1,29 @@
+2011-10-27 Shinya Kawanaka <[email protected]>
+
+ Implement legacy text check emulation in unified text check interface.
+ https://bugs.webkit.org/show_bug.cgi?id=70299
+
+ Reviewed by Hajime Morita.
+
+ When UNIFIED_TEXT_CHECKING is off, WebCore::checkTextOfParagraph() emulates
+ TextCheckerClient::checkTextOfParagraph() using checkSpellingOfString and checkGrammarOfString.
+
+ This emulation can be used by setting the flag on.
+ This can be done by WebCore::Internals::setUnifiedTextCheckingEnabled.
+
+ Test: editing/spelling/spelling-unified-emulation.html
+
+ * editing/TextCheckingHelper.cpp:
+ (WebCore::findBadGrammars): Added.
+ (WebCore::findMisspellings): Added.
+ (WebCore::checkTextOfParagraph):
+ Emulates TextCheckerClients::checkTextOfParagraph if UNIFIED_TEXT_CHECKING is off.
+ * testing/Internals.cpp:
+ (WebCore::Internals::setUnifiedTextCheckingEnabled): flag setter.
+ (WebCore::Internals::unifiedTextCheckingEnabled): flag getter.
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
2011-10-27 Philippe Normand <[email protected]>
Unreviewed, remove those un-needed files committed by error in
Modified: trunk/Source/WebCore/editing/TextCheckingHelper.cpp (98555 => 98556)
--- trunk/Source/WebCore/editing/TextCheckingHelper.cpp 2011-10-27 12:37:41 UTC (rev 98555)
+++ trunk/Source/WebCore/editing/TextCheckingHelper.cpp 2011-10-27 12:52:16 UTC (rev 98556)
@@ -32,6 +32,7 @@
#include "Frame.h"
#include "Range.h"
#include "Settings.h"
+#include "TextBreakIterator.h"
#include "TextCheckerClient.h"
#include "TextIterator.h"
#include "VisiblePosition.h"
@@ -39,6 +40,65 @@
namespace WebCore {
+#if !USE(UNIFIED_TEXT_CHECKING)
+static void findBadGrammars(TextCheckerClient* client, const UChar* text, int start, int length, Vector<TextCheckingResult>& results)
+{
+ ASSERT(WTF_USE_GRAMMAR_CHECKING);
+
+ int checkLocation = start;
+ int checkLength = length;
+
+ while (0 < checkLength) {
+ int badGrammarLocation = -1;
+ int badGrammarLength = 0;
+ Vector<GrammarDetail> badGrammarDetails;
+ client->checkGrammarOfString(text + checkLocation, checkLength, badGrammarDetails, &badGrammarLocation, &badGrammarLength);
+ if (!badGrammarLength)
+ break;
+ ASSERT(0 <= badGrammarLocation && badGrammarLocation <= checkLength);
+ ASSERT(0 < badGrammarLength && badGrammarLocation + badGrammarLength <= checkLength);
+ TextCheckingResult badGrammar;
+ badGrammar.type = TextCheckingTypeGrammar;
+ badGrammar.location = checkLocation + badGrammarLocation;
+ badGrammar.length = badGrammarLength;
+ badGrammar.details.swap(badGrammarDetails);
+ results.append(badGrammar);
+
+ checkLocation += (badGrammarLocation + badGrammarLength);
+ checkLength -= (badGrammarLocation + badGrammarLength);
+ }
+}
+
+static void findMisspellings(TextCheckerClient* client, const UChar* text, int start, int length, Vector<TextCheckingResult>& results)
+{
+ TextBreakIterator* iterator = wordBreakIterator(text + start, length);
+ if (!iterator)
+ return;
+ int wordStart = textBreakCurrent(iterator);
+ while (0 <= wordStart) {
+ int wordEnd = textBreakNext(iterator);
+ if (wordEnd < 0)
+ break;
+ int wordLength = wordEnd - wordStart;
+ int misspellingLocation = -1;
+ int misspellingLength = 0;
+ client->checkSpellingOfString(text + start + wordStart, wordLength, &misspellingLocation, &misspellingLength);
+ if (0 < misspellingLength) {
+ ASSERT(0 <= misspellingLocation && misspellingLocation <= wordLength);
+ ASSERT(0 < misspellingLength && misspellingLocation + misspellingLength <= wordLength);
+ TextCheckingResult misspelling;
+ misspelling.type = TextCheckingTypeSpelling;
+ misspelling.location = start + wordStart + misspellingLocation;
+ misspelling.length = misspellingLength;
+ misspelling.replacement = client->getAutoCorrectSuggestionForMisspelledWord(String(text + misspelling.location, misspelling.length));
+ results.append(misspelling);
+ }
+
+ wordStart = wordEnd;
+ }
+}
+#endif
+
static PassRefPtr<Range> expandToParagraphBoundary(PassRefPtr<Range> range)
{
ExceptionCode ec = 0;
@@ -599,14 +659,31 @@
#if USE(UNIFIED_TEXT_CHECKING)
client->checkTextOfParagraph(text, length, checkingTypes, results);
#else
- // Should implement later to unify unified spell-checking code path and
- // legacy spell-checking code path.
- ASSERT_NOT_REACHED();
- UNUSED_PARAM(client);
- UNUSED_PARAM(text);
- UNUSED_PARAM(length);
- UNUSED_PARAM(checkingTypes);
- UNUSED_PARAM(results);
+ Vector<TextCheckingResult> spellingResult;
+ if (checkingTypes & TextCheckingTypeSpelling)
+ findMisspellings(client, text, 0, length, spellingResult);
+
+ Vector<TextCheckingResult> grammarResult;
+ if (checkingTypes & TextCheckingTypeGrammar) {
+ // Only checks grammartical error before the first misspellings
+ int grammarCheckLength = length;
+ for (size_t i = 0; i < spellingResult.size(); ++i) {
+ if (spellingResult[i].location < grammarCheckLength)
+ grammarCheckLength = spellingResult[i].location;
+ }
+
+ findBadGrammars(client, text, 0, grammarCheckLength, grammarResult);
+ }
+
+ if (grammarResult.size())
+ results.swap(grammarResult);
+
+ if (spellingResult.size()) {
+ if (results.isEmpty())
+ results.swap(spellingResult);
+ else
+ results.append(spellingResult);
+ }
#endif
}
Modified: trunk/Source/WebCore/testing/Internals.cpp (98555 => 98556)
--- trunk/Source/WebCore/testing/Internals.cpp 2011-10-27 12:37:41 UTC (rev 98555)
+++ trunk/Source/WebCore/testing/Internals.cpp 2011-10-27 12:52:16 UTC (rev 98556)
@@ -474,4 +474,24 @@
return length;
}
+void Internals::setUnifiedTextCheckingEnabled(Document* document, bool enabled, ExceptionCode& ec)
+{
+ if (!document || !document->frame() || !document->frame()->settings()) {
+ ec = INVALID_ACCESS_ERR;
+ return;
+ }
+
+ document->frame()->settings()->setUnifiedTextCheckerEnabled(enabled);
}
+
+bool Internals::unifiedTextCheckingEnabled(Document* document, ExceptionCode& ec)
+{
+ if (!document || !document->frame() || !document->frame()->settings()) {
+ ec = INVALID_ACCESS_ERR;
+ return false;
+ }
+
+ return document->frame()->settings()->unifiedTextCheckerEnabled();
+}
+
+}
Modified: trunk/Source/WebCore/testing/Internals.h (98555 => 98556)
--- trunk/Source/WebCore/testing/Internals.h 2011-10-27 12:37:41 UTC (rev 98555)
+++ trunk/Source/WebCore/testing/Internals.h 2011-10-27 12:52:16 UTC (rev 98556)
@@ -98,6 +98,9 @@
unsigned locationFromRange(Element* scope, const Range*, ExceptionCode&);
unsigned lengthFromRange(Element* scope, const Range*, ExceptionCode&);
+ void setUnifiedTextCheckingEnabled(Document*, bool, ExceptionCode&);
+ bool unifiedTextCheckingEnabled(Document*, ExceptionCode&);
+
static const char* internalsId;
private:
Modified: trunk/Source/WebCore/testing/Internals.idl (98555 => 98556)
--- trunk/Source/WebCore/testing/Internals.idl 2011-10-27 12:37:41 UTC (rev 98555)
+++ trunk/Source/WebCore/testing/Internals.idl 2011-10-27 12:52:16 UTC (rev 98556)
@@ -71,6 +71,9 @@
Range rangeFromLocationAndLength(in Element scope, in long rangeLocation, in long rangeLength) raises (DOMException);
unsigned long locationFromRange(in Element scope, in Range range) raises (DOMException);
unsigned long lengthFromRange(in Element scope, in Range range) raises (DOMException);
+
+ void setUnifiedTextCheckingEnabled(in Document document, in boolean enabled) raises (DOMException);
+ boolean unifiedTextCheckingEnabled(in Document document) raises (DOMException);
};
}
Modified: trunk/Source/WebKit2/ChangeLog (98555 => 98556)
--- trunk/Source/WebKit2/ChangeLog 2011-10-27 12:37:41 UTC (rev 98555)
+++ trunk/Source/WebKit2/ChangeLog 2011-10-27 12:52:16 UTC (rev 98556)
@@ -1,3 +1,13 @@
+2011-10-27 Shinya Kawanaka <[email protected]>
+
+ Implement legacy text check emulation in unified text check interface.
+ https://bugs.webkit.org/show_bug.cgi?id=70299
+
+ Reviewed by Hajime Morita.
+
+ * win/WebKit2.def:
+ * win/WebKit2CFLite.def:
+
2011-10-27 Philippe Normand <[email protected]>
[GStreamer] WebAudio AudioFileReader implementation
Modified: trunk/Source/WebKit2/win/WebKit2.def (98555 => 98556)
--- trunk/Source/WebKit2/win/WebKit2.def 2011-10-27 12:37:41 UTC (rev 98555)
+++ trunk/Source/WebKit2/win/WebKit2.def 2011-10-27 12:52:16 UTC (rev 98556)
@@ -172,6 +172,7 @@
?setScrollOffsetFromInternals@ScrollableArea@WebCore@@QAEXABVIntPoint@2@@Z
?setSuggestedValue@HTMLInputElement@WebCore@@QAEXABVString@WTF@@@Z
?settings@Document@WebCore@@QBEPAVSettings@2@XZ
+ ?settings@Frame@WebCore@@QBEPAVSettings@2@XZ
?shadowRoot@Element@WebCore@@QBEPAVShadowRoot@2@XZ
?suggestedValue@HTMLInputElement@WebCore@@QBEABVString@WTF@@XZ
?toDocument@WebCore@@YAPAVDocument@1@VJSValue@JSC@@@Z
Modified: trunk/Source/WebKit2/win/WebKit2CFLite.def (98555 => 98556)
--- trunk/Source/WebKit2/win/WebKit2CFLite.def 2011-10-27 12:37:41 UTC (rev 98555)
+++ trunk/Source/WebKit2/win/WebKit2CFLite.def 2011-10-27 12:52:16 UTC (rev 98556)
@@ -165,6 +165,7 @@
?setScrollOffsetFromInternals@ScrollableArea@WebCore@@QAEXABVIntPoint@2@@Z
?setSuggestedValue@HTMLInputElement@WebCore@@QAEXABVString@WTF@@@Z
?settings@Document@WebCore@@QBEPAVSettings@2@XZ
+ ?settings@Frame@WebCore@@QBEPAVSettings@2@XZ
?shadowRoot@Element@WebCore@@QBEPAVShadowRoot@2@XZ
?suggestedValue@HTMLInputElement@WebCore@@QBEABVString@WTF@@XZ
?toDocument@WebCore@@YAPAVDocument@1@VJSValue@JSC@@@Z
Modified: trunk/Source/autotools/symbols.filter (98555 => 98556)
--- trunk/Source/autotools/symbols.filter 2011-10-27 12:37:41 UTC (rev 98555)
+++ trunk/Source/autotools/symbols.filter 2011-10-27 12:52:16 UTC (rev 98556)
@@ -70,6 +70,7 @@
_ZNK7WebCore16HTMLInputElement14suggestedValueEv;
_ZNK7WebCore20CachedResourceLoader11isPreloadedERKN3WTF6StringE;
_ZNK7WebCore26HTMLTextFormControlElement21lastChangeWasUserEditEv;
+_ZNK7WebCore5Frame8settingsEv;
_ZNK7WebCore6JSNode21pushEventHandlerScopeEPN3JSC9ExecStateEPNS1_14ScopeChainNodeE;
_ZNK7WebCore7Element10shadowRootEv;
_ZNK7WebCore8Document4pageEv;