Update Spellcheck API
Update WebTexhCheckingCompletion as per chromium 0e8c828e02
This commit is contained in:
parent
2d14a0e90d
commit
8a7de89b97
2 changed files with 16 additions and 13 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "atom/renderer/api/atom_api_spell_check_client.h"
|
||||
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
|
@ -46,22 +47,23 @@ class SpellCheckClient::SpellcheckRequest {
|
|||
using WordMap =
|
||||
std::map<base::string16, std::vector<blink::WebTextCheckingResult>>;
|
||||
|
||||
SpellcheckRequest(const base::string16& text,
|
||||
blink::WebTextCheckingCompletion* completion)
|
||||
: text_(text), completion_(completion) {
|
||||
DCHECK(completion);
|
||||
}
|
||||
SpellcheckRequest(
|
||||
const base::string16& text,
|
||||
std::unique_ptr<blink::WebTextCheckingCompletion> completion)
|
||||
: text_(text), completion_(std::move(completion)) {}
|
||||
~SpellcheckRequest() {}
|
||||
|
||||
const base::string16& text() const { return text_; }
|
||||
blink::WebTextCheckingCompletion* completion() { return completion_; }
|
||||
std::shared_ptr<blink::WebTextCheckingCompletion> completion() {
|
||||
return completion_;
|
||||
}
|
||||
WordMap& wordmap() { return word_map_; }
|
||||
|
||||
private:
|
||||
base::string16 text_; // Text to be checked in this task.
|
||||
WordMap word_map_; // WordMap to hold distinct words in text
|
||||
// The interface to send the misspelled ranges to WebKit.
|
||||
blink::WebTextCheckingCompletion* completion_;
|
||||
std::shared_ptr<blink::WebTextCheckingCompletion> completion_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(SpellcheckRequest);
|
||||
};
|
||||
|
@ -88,7 +90,7 @@ SpellCheckClient::~SpellCheckClient() {
|
|||
|
||||
void SpellCheckClient::RequestCheckingOfText(
|
||||
const blink::WebString& textToCheck,
|
||||
blink::WebTextCheckingCompletion* completionCallback) {
|
||||
std::unique_ptr<blink::WebTextCheckingCompletion> completionCallback) {
|
||||
base::string16 text(textToCheck.Utf16());
|
||||
// Ignore invalid requests.
|
||||
if (text.empty() || !HasWordCharacters(text, 0)) {
|
||||
|
@ -101,7 +103,8 @@ void SpellCheckClient::RequestCheckingOfText(
|
|||
pending_request_param_->completion()->DidCancelCheckingText();
|
||||
}
|
||||
|
||||
pending_request_param_.reset(new SpellcheckRequest(text, completionCallback));
|
||||
pending_request_param_.reset(
|
||||
new SpellcheckRequest(text, std::move(completionCallback)));
|
||||
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE,
|
||||
|
@ -188,7 +191,7 @@ void SpellCheckClient::SpellCheckText() {
|
|||
void SpellCheckClient::OnSpellCheckDone(
|
||||
const std::vector<base::string16>& misspelled_words) {
|
||||
std::vector<blink::WebTextCheckingResult> results;
|
||||
auto* const completion_handler = pending_request_param_->completion();
|
||||
auto completion_handler = pending_request_param_->completion();
|
||||
|
||||
auto& word_map = pending_request_param_->wordmap();
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ class SpellCheckClient : public blink::WebSpellCheckPanelHostClient,
|
|||
private:
|
||||
class SpellcheckRequest;
|
||||
// blink::WebTextCheckClient:
|
||||
void RequestCheckingOfText(
|
||||
const blink::WebString& textToCheck,
|
||||
blink::WebTextCheckingCompletion* completionCallback) override;
|
||||
void RequestCheckingOfText(const blink::WebString& textToCheck,
|
||||
std::unique_ptr<blink::WebTextCheckingCompletion>
|
||||
completionCallback) override;
|
||||
bool IsSpellCheckingEnabled() const override;
|
||||
|
||||
// blink::WebSpellCheckPanelHostClient:
|
||||
|
|
Loading…
Reference in a new issue