Changeset 100050 in webkit
- Timestamp:
- Nov 11, 2011 5:21:44 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r99961 r100050 1 2011-11-11 Shinya Kawanaka <shinyak@google.com> 2 3 Implement legacy text check emulation in unified text check interface. 4 https://bugs.webkit.org/show_bug.cgi?id=70299 5 6 Reviewed by Hajime Morita. 7 8 * Source/autotools/symbols.filter: 9 1 10 2011-11-11 Alexis Menard <alexis.menard@openbossa.org> 2 11 -
trunk/LayoutTests/ChangeLog
r100046 r100050 1 2011-11-11 Shinya Kawanaka <shinyak@google.com> 2 3 Implement legacy text check emulation in unified text check interface. 4 https://bugs.webkit.org/show_bug.cgi?id=70299 5 6 Reviewed by Hajime Morita. 7 8 Added tests for the case unified text checker is used when WebCore::checkTextOfParagraph() is not supported. 9 10 * editing/spelling/spelling-unified-emulation-expected.txt: Added. 11 * editing/spelling/spelling-unified-emulation.html: Added. 12 1 13 2011-11-11 Stephen Chenney <schenney@chromium.org> 2 14 -
trunk/Source/WebCore/ChangeLog
r100049 r100050 1 2011-11-11 Shinya Kawanaka <shinyak@google.com> 2 3 Implement legacy text check emulation in unified text check interface. 4 https://bugs.webkit.org/show_bug.cgi?id=70299 5 6 Reviewed by Hajime Morita. 7 8 When UNIFIED_TEXT_CHECKING is off, WebCore::checkTextOfParagraph() emulates 9 TextCheckerClient::checkTextOfParagraph() using checkSpellingOfString and checkGrammarOfString. 10 11 This emulation can be used by setting the flag on. 12 This can be done by WebCore::Internals::setUnifiedTextCheckingEnabled. 13 14 Test: editing/spelling/spelling-unified-emulation.html 15 16 * editing/TextCheckingHelper.cpp: 17 (WebCore::findBadGrammars): Added. 18 (WebCore::findMisspellings): Added. 19 (WebCore::checkTextOfParagraph): 20 Emulates TextCheckerClients::checkTextOfParagraph if UNIFIED_TEXT_CHECKING is off. 21 * testing/Internals.cpp: 22 (WebCore::Internals::setUnifiedTextCheckingEnabled): flag setter. 23 (WebCore::Internals::unifiedTextCheckingEnabled): flag getter. 24 * testing/Internals.h: 25 * testing/Internals.idl: 26 1 27 2011-11-11 Gyuyoung Kim <gyuyoung.kim@samsung.com> 2 28 -
trunk/Source/WebCore/editing/TextCheckingHelper.cpp
r98598 r100050 33 33 #include "Range.h" 34 34 #include "Settings.h" 35 #include "TextBreakIterator.h" 35 36 #include "TextCheckerClient.h" 36 37 #include "TextIterator.h" … … 39 40 40 41 namespace WebCore { 42 43 #if !USE(UNIFIED_TEXT_CHECKING) 44 static void findBadGrammars(TextCheckerClient* client, const UChar* text, int start, int length, Vector<TextCheckingResult>& results) 45 { 46 ASSERT(WTF_USE_GRAMMAR_CHECKING); 47 48 int checkLocation = start; 49 int checkLength = length; 50 51 while (0 < checkLength) { 52 int badGrammarLocation = -1; 53 int badGrammarLength = 0; 54 Vector<GrammarDetail> badGrammarDetails; 55 client->checkGrammarOfString(text + checkLocation, checkLength, badGrammarDetails, &badGrammarLocation, &badGrammarLength); 56 if (!badGrammarLength) 57 break; 58 ASSERT(0 <= badGrammarLocation && badGrammarLocation <= checkLength); 59 ASSERT(0 < badGrammarLength && badGrammarLocation + badGrammarLength <= checkLength); 60 TextCheckingResult badGrammar; 61 badGrammar.type = TextCheckingTypeGrammar; 62 badGrammar.location = checkLocation + badGrammarLocation; 63 badGrammar.length = badGrammarLength; 64 badGrammar.details.swap(badGrammarDetails); 65 results.append(badGrammar); 66 67 checkLocation += (badGrammarLocation + badGrammarLength); 68 checkLength -= (badGrammarLocation + badGrammarLength); 69 } 70 } 71 72 static void findMisspellings(TextCheckerClient* client, const UChar* text, int start, int length, Vector<TextCheckingResult>& results) 73 { 74 TextBreakIterator* iterator = wordBreakIterator(text + start, length); 75 if (!iterator) 76 return; 77 int wordStart = textBreakCurrent(iterator); 78 while (0 <= wordStart) { 79 int wordEnd = textBreakNext(iterator); 80 if (wordEnd < 0) 81 break; 82 int wordLength = wordEnd - wordStart; 83 int misspellingLocation = -1; 84 int misspellingLength = 0; 85 client->checkSpellingOfString(text + start + wordStart, wordLength, &misspellingLocation, &misspellingLength); 86 if (0 < misspellingLength) { 87 ASSERT(0 <= misspellingLocation && misspellingLocation <= wordLength); 88 ASSERT(0 < misspellingLength && misspellingLocation + misspellingLength <= wordLength); 89 TextCheckingResult misspelling; 90 misspelling.type = TextCheckingTypeSpelling; 91 misspelling.location = start + wordStart + misspellingLocation; 92 misspelling.length = misspellingLength; 93 misspelling.replacement = client->getAutoCorrectSuggestionForMisspelledWord(String(text + misspelling.location, misspelling.length)); 94 results.append(misspelling); 95 } 96 97 wordStart = wordEnd; 98 } 99 } 100 #endif 41 101 42 102 static PassRefPtr<Range> expandToParagraphBoundary(PassRefPtr<Range> range) … … 600 660 client->checkTextOfParagraph(text, length, checkingTypes, results); 601 661 #else 602 // Should implement later to unify unified spell-checking code path and 603 // legacy spell-checking code path. 604 ASSERT_NOT_REACHED(); 605 UNUSED_PARAM(client); 606 UNUSED_PARAM(text); 607 UNUSED_PARAM(length); 608 UNUSED_PARAM(checkingTypes); 609 UNUSED_PARAM(results); 662 Vector<TextCheckingResult> spellingResult; 663 if (checkingTypes & TextCheckingTypeSpelling) 664 findMisspellings(client, text, 0, length, spellingResult); 665 666 Vector<TextCheckingResult> grammarResult; 667 if (checkingTypes & TextCheckingTypeGrammar) { 668 // Only checks grammartical error before the first misspellings 669 int grammarCheckLength = length; 670 for (size_t i = 0; i < spellingResult.size(); ++i) { 671 if (spellingResult[i].location < grammarCheckLength) 672 grammarCheckLength = spellingResult[i].location; 673 } 674 675 findBadGrammars(client, text, 0, grammarCheckLength, grammarResult); 676 } 677 678 if (grammarResult.size()) 679 results.swap(grammarResult); 680 681 if (spellingResult.size()) { 682 if (results.isEmpty()) 683 results.swap(spellingResult); 684 else 685 results.append(spellingResult); 686 } 610 687 #endif 611 688 } -
trunk/Source/WebCore/testing/Internals.cpp
r99814 r100050 568 568 } 569 569 570 } 570 void Internals::setUnifiedTextCheckingEnabled(Document* document, bool enabled, ExceptionCode& ec) 571 { 572 if (!document || !document->frame() || !document->frame()->settings()) { 573 ec = INVALID_ACCESS_ERR; 574 return; 575 } 576 577 document->frame()->settings()->setUnifiedTextCheckerEnabled(enabled); 578 } 579 580 bool Internals::unifiedTextCheckingEnabled(Document* document, ExceptionCode& ec) 581 { 582 if (!document || !document->frame() || !document->frame()->settings()) { 583 ec = INVALID_ACCESS_ERR; 584 return false; 585 } 586 587 return document->frame()->settings()->unifiedTextCheckerEnabled(); 588 } 589 590 } -
trunk/Source/WebCore/testing/Internals.h
r99814 r100050 104 104 unsigned lengthFromRange(Element* scope, const Range*, ExceptionCode&); 105 105 106 void setUnifiedTextCheckingEnabled(Document*, bool, ExceptionCode&); 107 bool unifiedTextCheckingEnabled(Document*, ExceptionCode&); 108 106 109 static const char* internalsId; 107 110 -
trunk/Source/WebCore/testing/Internals.idl
r99814 r100050 76 76 unsigned long locationFromRange(in Element scope, in Range range) raises (DOMException); 77 77 unsigned long lengthFromRange(in Element scope, in Range range) raises (DOMException); 78 79 void setUnifiedTextCheckingEnabled(in Document document, in boolean enabled) raises (DOMException); 80 boolean unifiedTextCheckingEnabled(in Document document) raises (DOMException); 78 81 }; 79 82 } -
trunk/Source/WebKit2/ChangeLog
r100033 r100050 1 2011-11-11 Shinya Kawanaka <shinyak@google.com> 2 3 Implement legacy text check emulation in unified text check interface. 4 https://bugs.webkit.org/show_bug.cgi?id=70299 5 6 Reviewed by Hajime Morita. 7 8 * win/WebKit2.def: 9 * win/WebKit2CFLite.def: 10 1 11 2011-11-11 Alexey Proskuryakov <ap@apple.com> 2 12 -
trunk/Source/WebKit2/win/WebKit2.def
r99814 r100050 177 177 ?setSuggestedValue@HTMLInputElement@WebCore@@QAEXABVString@WTF@@@Z 178 178 ?settings@Document@WebCore@@QBEPAVSettings@2@XZ 179 ?settings@Frame@WebCore@@QBEPAVSettings@2@XZ 179 180 ?shadowRoot@Element@WebCore@@QBEPAVShadowRoot@2@XZ 180 181 ?suggestedValue@HTMLInputElement@WebCore@@QBEABVString@WTF@@XZ -
trunk/Source/WebKit2/win/WebKit2CFLite.def
r99814 r100050 170 170 ?setSuggestedValue@HTMLInputElement@WebCore@@QAEXABVString@WTF@@@Z 171 171 ?settings@Document@WebCore@@QBEPAVSettings@2@XZ 172 ?settings@Frame@WebCore@@QBEPAVSettings@2@XZ 172 173 ?shadowRoot@Element@WebCore@@QBEPAVShadowRoot@2@XZ 173 174 ?suggestedValue@HTMLInputElement@WebCore@@QBEABVString@WTF@@XZ -
trunk/Source/autotools/symbols.filter
r99814 r100050 72 72 _ZNK7WebCore20CachedResourceLoader11isPreloadedERKN3WTF6StringE; 73 73 _ZNK7WebCore26HTMLTextFormControlElement21lastChangeWasUserEditEv; 74 _ZNK7WebCore5Frame8settingsEv; 74 75 _ZNK7WebCore6JSNode21pushEventHandlerScopeEPN3JSC9ExecStateEPNS1_14ScopeChainNodeE; 75 76 _ZNK7WebCore7Element10shadowRootEv;
Note: See TracChangeset
for help on using the changeset viewer.