| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/spellcheck/renderer/spellcheck_provider.h" | 5 #include "components/spellcheck/renderer/spellcheck_provider.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "components/spellcheck/common/spellcheck_marker.h" | 9 #include "components/spellcheck/common/spellcheck_marker.h" |
| 10 #include "components/spellcheck/common/spellcheck_messages.h" | 10 #include "components/spellcheck/common/spellcheck_messages.h" |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 // substring of the cached text. | 323 // substring of the cached text. |
| 324 if (text_length < last_length && | 324 if (text_length < last_length && |
| 325 !last_request_.compare(0, text_length, request)) { | 325 !last_request_.compare(0, text_length, request)) { |
| 326 size_t result_size = 0; | 326 size_t result_size = 0; |
| 327 for (size_t i = 0; i < last_results_.size(); ++i) { | 327 for (size_t i = 0; i < last_results_.size(); ++i) { |
| 328 size_t start = last_results_[i].location; | 328 size_t start = last_results_[i].location; |
| 329 size_t end = start + last_results_[i].length; | 329 size_t end = start + last_results_[i].length; |
| 330 if (start <= text_length && end <= text_length) | 330 if (start <= text_length && end <= text_length) |
| 331 ++result_size; | 331 ++result_size; |
| 332 } | 332 } |
| 333 if (result_size > 0) { | 333 blink::WebVector<blink::WebTextCheckingResult> results(last_results_.data(), |
| 334 blink::WebVector<blink::WebTextCheckingResult> results(result_size); | 334 result_size); |
| 335 for (size_t i = 0; i < result_size; ++i) { | 335 completion->didFinishCheckingText(results); |
| 336 results[i].decoration = last_results_[i].decoration; | 336 return true; |
| 337 results[i].location = last_results_[i].location; | |
| 338 results[i].length = last_results_[i].length; | |
| 339 results[i].replacement = last_results_[i].replacement; | |
| 340 } | |
| 341 completion->didFinishCheckingText(results); | |
| 342 return true; | |
| 343 } | |
| 344 } | 337 } |
| 345 | 338 |
| 346 return false; | 339 return false; |
| 347 } | 340 } |
| 348 | 341 |
| 349 void SpellCheckProvider::OnDestruct() { | 342 void SpellCheckProvider::OnDestruct() { |
| 350 delete this; | 343 delete this; |
| 351 } | 344 } |
| OLD | NEW |