Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: Tools/DumpRenderTree/chromium/TestRunner/src/SpellCheckClient.cpp

Issue 15806014: Reduce usage of WebString::data (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 { 78 {
79 // Check the spelling of the given text. 79 // Check the spelling of the given text.
80 m_spellcheck.spellCheckWord(text, &misspelledOffset, &misspelledLength); 80 m_spellcheck.spellCheckWord(text, &misspelledOffset, &misspelledLength);
81 } 81 }
82 82
83 void SpellCheckClient::checkTextOfParagraph(const WebString& text, WebTextChecki ngTypeMask mask, WebVector<WebTextCheckingResult>* webResults) 83 void SpellCheckClient::checkTextOfParagraph(const WebString& text, WebTextChecki ngTypeMask mask, WebVector<WebTextCheckingResult>* webResults)
84 { 84 {
85 vector<WebTextCheckingResult> results; 85 vector<WebTextCheckingResult> results;
86 if (mask & WebTextCheckingTypeSpelling) { 86 if (mask & WebTextCheckingTypeSpelling) {
87 size_t offset = 0; 87 size_t offset = 0;
88 size_t length = text.length(); 88 string16 data = text;
89 const WebUChar* data = text.data(); 89 while (offset < data.length()) {
90 while (offset < length) {
91 int misspelledPosition = 0; 90 int misspelledPosition = 0;
92 int misspelledLength = 0; 91 int misspelledLength = 0;
93 m_spellcheck.spellCheckWord(WebString(&data[offset], length - offset ), &misspelledPosition, &misspelledLength); 92 m_spellcheck.spellCheckWord(data.substr(offset), &misspelledPosition , &misspelledLength);
94 if (!misspelledLength) 93 if (!misspelledLength)
95 break; 94 break;
96 WebTextCheckingResult result; 95 WebTextCheckingResult result;
97 result.type = WebTextCheckingTypeSpelling; 96 result.type = WebTextCheckingTypeSpelling;
98 result.location = offset + misspelledPosition; 97 result.location = offset + misspelledPosition;
99 result.length = misspelledLength; 98 result.length = misspelledLength;
100 results.push_back(result); 99 results.push_back(result);
101 offset += misspelledPosition + misspelledLength; 100 offset += misspelledPosition + misspelledLength;
102 } 101 }
103 } 102 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 WebString SpellCheckClient::autoCorrectWord(const WebString&) 150 WebString SpellCheckClient::autoCorrectWord(const WebString&)
152 { 151 {
153 // Returns an empty string as Mac WebKit ('WebKitSupport/WebEditorClient.mm' ) 152 // Returns an empty string as Mac WebKit ('WebKitSupport/WebEditorClient.mm' )
154 // does. (If this function returns a non-empty string, WebKit replaces the 153 // does. (If this function returns a non-empty string, WebKit replaces the
155 // given misspelled string with the result one. This process executes some 154 // given misspelled string with the result one. This process executes some
156 // editor commands and causes layout-test failures.) 155 // editor commands and causes layout-test failures.)
157 return WebString(); 156 return WebString();
158 } 157 }
159 158
160 } 159 }
OLDNEW
« no previous file with comments | « Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp ('k') | public/platform/WebString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698