From 8a7de89b9721589a04fbea04e24322281d887419 Mon Sep 17 00:00:00 2001 From: Nitish Sakhawalkar Date: Thu, 16 May 2019 21:58:03 -0700 Subject: [PATCH] Update Spellcheck API Update WebTexhCheckingCompletion as per chromium https://chromium.googlesource.com/chromium/src/+/0e8c828e02258bc530ef540b88dc087b76616fc7 --- .../api/atom_api_spell_check_client.cc | 23 +++++++++++-------- .../api/atom_api_spell_check_client.h | 6 ++--- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/atom/renderer/api/atom_api_spell_check_client.cc b/atom/renderer/api/atom_api_spell_check_client.cc index c7f3997a92cb..1568860bd289 100644 --- a/atom/renderer/api/atom_api_spell_check_client.cc +++ b/atom/renderer/api/atom_api_spell_check_client.cc @@ -5,6 +5,7 @@ #include "atom/renderer/api/atom_api_spell_check_client.h" #include +#include #include #include "atom/common/native_mate_converters/string16_converter.h" @@ -46,22 +47,23 @@ class SpellCheckClient::SpellcheckRequest { using WordMap = std::map>; - SpellcheckRequest(const base::string16& text, - blink::WebTextCheckingCompletion* completion) - : text_(text), completion_(completion) { - DCHECK(completion); - } + SpellcheckRequest( + const base::string16& text, + std::unique_ptr completion) + : text_(text), completion_(std::move(completion)) {} ~SpellcheckRequest() {} const base::string16& text() const { return text_; } - blink::WebTextCheckingCompletion* completion() { return completion_; } + std::shared_ptr 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 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 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& misspelled_words) { std::vector results; - auto* const completion_handler = pending_request_param_->completion(); + auto completion_handler = pending_request_param_->completion(); auto& word_map = pending_request_param_->wordmap(); diff --git a/atom/renderer/api/atom_api_spell_check_client.h b/atom/renderer/api/atom_api_spell_check_client.h index a4ff1b0f2eb9..db59201c5b36 100644 --- a/atom/renderer/api/atom_api_spell_check_client.h +++ b/atom/renderer/api/atom_api_spell_check_client.h @@ -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 + completionCallback) override; bool IsSpellCheckingEnabled() const override; // blink::WebSpellCheckPanelHostClient: