| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/shell/renderer/test_runner/mock_grammar_check.h" | 5 #include "content/shell/renderer/test_runner/mock_grammar_check.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/shell/renderer/test_runner/TestCommon.h" | 10 #include "content/shell/renderer/test_runner/test_common.h" |
| 11 #include "third_party/WebKit/public/platform/WebCString.h" | 11 #include "third_party/WebKit/public/platform/WebCString.h" |
| 12 #include "third_party/WebKit/public/platform/WebString.h" | 12 #include "third_party/WebKit/public/platform/WebString.h" |
| 13 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" | 13 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 bool MockGrammarCheck::CheckGrammarOfString( | 17 bool MockGrammarCheck::CheckGrammarOfString( |
| 18 const blink::WebString& text, | 18 const blink::WebString& text, |
| 19 std::vector<blink::WebTextCheckingResult>* results) { | 19 std::vector<blink::WebTextCheckingResult>* results) { |
| 20 DCHECK(results); | 20 DCHECK(results); |
| 21 base::string16 string_text = text; | 21 base::string16 string_text = text; |
| 22 if (std::find_if(string_text.begin(), string_text.end(), isASCIIAlpha) == | 22 if (std::find_if(string_text.begin(), string_text.end(), IsASCIIAlpha) == |
| 23 string_text.end()) | 23 string_text.end()) |
| 24 return true; | 24 return true; |
| 25 | 25 |
| 26 // Find matching grammatical errors from known ones. This function has to | 26 // Find matching grammatical errors from known ones. This function has to |
| 27 // check all errors because the given text may consist of two or more | 27 // check all errors because the given text may consist of two or more |
| 28 // sentences that have grammatical errors. | 28 // sentences that have grammatical errors. |
| 29 static const struct { | 29 static const struct { |
| 30 const char* text; | 30 const char* text; |
| 31 int location; | 31 int location; |
| 32 int length; | 32 int length; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 54 blink::WebTextCheckingResult(blink::WebTextDecorationTypeGrammar, | 54 blink::WebTextCheckingResult(blink::WebTextDecorationTypeGrammar, |
| 55 offset + kGrammarErrors[i].location, | 55 offset + kGrammarErrors[i].location, |
| 56 kGrammarErrors[i].length)); | 56 kGrammarErrors[i].length)); |
| 57 offset += kGrammarErrors[i].length; | 57 offset += kGrammarErrors[i].length; |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 return false; | 60 return false; |
| 61 } | 61 } |
| 62 | 62 |
| 63 } // namespace content | 63 } // namespace content |
| OLD | NEW |