2757472: Reland "Reland "[LSC] Remove base::string16 alias""

2757472
This commit is contained in:
John Kleinschmidt 2021-03-16 12:18:45 -04:00
parent 86d23cee40
commit 22d8f22cfb
100 changed files with 417 additions and 417 deletions

View file

@ -28,7 +28,7 @@ namespace api {
namespace {
bool HasWordCharacters(const base::string16& text, int index) {
bool HasWordCharacters(const std::u16string& text, int index) {
const char16_t* data = text.data();
int length = text.length();
while (index < length) {
@ -43,8 +43,8 @@ bool HasWordCharacters(const base::string16& text, int index) {
struct Word {
blink::WebTextCheckingResult result;
base::string16 text;
std::vector<base::string16> contraction_words;
std::u16string text;
std::vector<std::u16string> contraction_words;
};
} // namespace
@ -52,19 +52,19 @@ struct Word {
class SpellCheckClient::SpellcheckRequest {
public:
SpellcheckRequest(
const base::string16& text,
const std::u16string& text,
std::unique_ptr<blink::WebTextCheckingCompletion> completion)
: text_(text), completion_(std::move(completion)) {}
SpellcheckRequest(const SpellcheckRequest&) = delete;
SpellcheckRequest& operator=(const SpellcheckRequest&) = delete;
~SpellcheckRequest() = default;
const base::string16& text() const { return text_; }
const std::u16string& text() const { return text_; }
blink::WebTextCheckingCompletion* completion() { return completion_.get(); }
std::vector<Word>& wordlist() { return word_list_; }
private:
base::string16 text_; // Text to be checked in this task.
std::u16string text_; // Text to be checked in this task.
std::vector<Word> word_list_; // List of Words found in text
// The interface to send the misspelled ranges to WebKit.
std::unique_ptr<blink::WebTextCheckingCompletion> completion_;
@ -93,7 +93,7 @@ SpellCheckClient::~SpellCheckClient() {
void SpellCheckClient::RequestCheckingOfText(
const blink::WebString& textToCheck,
std::unique_ptr<blink::WebTextCheckingCompletion> completionCallback) {
base::string16 text(textToCheck.Utf16());
std::u16string text(textToCheck.Utf16());
// Ignore invalid requests.
if (text.empty() || !HasWordCharacters(text, 0)) {
completionCallback->DidCancelCheckingText();
@ -151,10 +151,10 @@ void SpellCheckClient::SpellCheckText() {
text_iterator_.SetText(text.c_str(), text.size());
SpellCheckScope scope(*this);
base::string16 word;
std::u16string word;
size_t word_start;
size_t word_length;
std::set<base::string16> words;
std::set<std::u16string> words;
auto& word_list = pending_request_param_->wordlist();
Word word_entry;
for (;;) { // Run until end of text
@ -186,9 +186,9 @@ void SpellCheckClient::SpellCheckText() {
}
void SpellCheckClient::OnSpellCheckDone(
const std::vector<base::string16>& misspelled_words) {
const std::vector<std::u16string>& misspelled_words) {
std::vector<blink::WebTextCheckingResult> results;
std::unordered_set<base::string16> misspelled(misspelled_words.begin(),
std::unordered_set<std::u16string> misspelled(misspelled_words.begin(),
misspelled_words.end());
auto& word_list = pending_request_param_->wordlist();
@ -216,7 +216,7 @@ void SpellCheckClient::OnSpellCheckDone(
}
void SpellCheckClient::SpellCheckWords(const SpellCheckScope& scope,
const std::set<base::string16>& words) {
const std::set<std::u16string>& words) {
DCHECK(!scope.spell_check_.IsEmpty());
v8::Local<v8::FunctionTemplate> templ = gin_helper::CreateFunctionTemplate(
@ -238,13 +238,13 @@ void SpellCheckClient::SpellCheckWords(const SpellCheckScope& scope,
// words in the contraction.
bool SpellCheckClient::IsContraction(
const SpellCheckScope& scope,
const base::string16& contraction,
std::vector<base::string16>* contraction_words) {
const std::u16string& contraction,
std::vector<std::u16string>* contraction_words) {
DCHECK(contraction_iterator_.IsInitialized());
contraction_iterator_.SetText(contraction.c_str(), contraction.length());
base::string16 word;
std::u16string word;
size_t word_start;
size_t word_length;
for (auto status =

View file

@ -69,18 +69,18 @@ class SpellCheckClient : public blink::WebSpellCheckPanelHostClient,
// The javascript function will callback OnSpellCheckDone
// with the results of all the misspelled words.
void SpellCheckWords(const SpellCheckScope& scope,
const std::set<base::string16>& words);
const std::set<std::u16string>& words);
// Returns whether or not the given word is a contraction of valid words
// (e.g. "word:word").
// Output variable contraction_words will contain individual
// words in the contraction.
bool IsContraction(const SpellCheckScope& scope,
const base::string16& word,
std::vector<base::string16>* contraction_words);
const std::u16string& word,
std::vector<std::u16string>* contraction_words);
// Callback for the JS API which returns the list of misspelled words.
void OnSpellCheckDone(const std::vector<base::string16>& misspelled_words);
void OnSpellCheckDone(const std::vector<std::u16string>& misspelled_words);
// Represents character attributes used for filtering out characters which
// are not supported by this SpellCheck object.

View file

@ -114,7 +114,7 @@ content::RenderFrame* GetRenderFrame(v8::Local<v8::Value> value) {
bool SpellCheckWord(v8::Isolate* isolate,
v8::Local<v8::Value> window,
const std::string& word,
std::vector<base::string16>* optional_suggestions) {
std::vector<std::u16string>* optional_suggestions) {
size_t start;
size_t length;
@ -123,7 +123,7 @@ bool SpellCheckWord(v8::Isolate* isolate,
if (!render_frame)
return true;
base::string16 w = base::UTF8ToUTF16(word);
std::u16string w = base::UTF8ToUTF16(word);
int id = render_frame->GetRoutingID();
return client->GetSpellCheck()->SpellCheckWord(
w.c_str(), 0, word.size(), id, &start, &length, optional_suggestions);
@ -576,7 +576,7 @@ void InsertText(gin_helper::ErrorThrower thrower,
}
}
base::string16 InsertCSS(v8::Local<v8::Value> window,
std::u16string InsertCSS(v8::Local<v8::Value> window,
const std::string& css,
gin_helper::Arguments* args) {
blink::WebDocument::CSSOrigin css_origin =
@ -591,7 +591,7 @@ base::string16 InsertCSS(v8::Local<v8::Value> window,
args->ThrowError(
"Render frame was torn down before webFrame.insertCSS could be "
"executed");
return base::string16();
return std::u16string();
}
blink::WebFrame* web_frame = render_frame->GetWebFrame();
@ -601,12 +601,12 @@ base::string16 InsertCSS(v8::Local<v8::Value> window,
.InsertStyleSheet(blink::WebString::FromUTF8(css), nullptr, css_origin)
.Utf16();
}
return base::string16();
return std::u16string();
}
void RemoveInsertedCSS(gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> window,
const base::string16& key) {
const std::u16string& key) {
auto* render_frame = GetRenderFrame(window);
if (!render_frame) {
thrower.ThrowError(
@ -624,7 +624,7 @@ void RemoveInsertedCSS(gin_helper::ErrorThrower thrower,
v8::Local<v8::Promise> ExecuteJavaScript(gin_helper::Arguments* args,
v8::Local<v8::Value> window,
const base::string16& code) {
const std::u16string& code) {
v8::Isolate* isolate = args->isolate();
gin_helper::Promise<v8::Local<v8::Value>> promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
@ -685,8 +685,8 @@ v8::Local<v8::Promise> ExecuteJavaScriptInIsolatedWorld(
std::vector<blink::WebScriptSource> sources;
for (const auto& script : scripts) {
base::string16 code;
base::string16 url;
std::u16string code;
std::u16string url;
int start_line = 1;
script.Get("url", &url);
script.Get("startLine", &start_line);
@ -766,10 +766,10 @@ bool IsWordMisspelled(v8::Isolate* isolate,
return !SpellCheckWord(isolate, window, word, nullptr);
}
std::vector<base::string16> GetWordSuggestions(v8::Isolate* isolate,
std::vector<std::u16string> GetWordSuggestions(v8::Isolate* isolate,
v8::Local<v8::Value> window,
const std::string& word) {
std::vector<base::string16> suggestions;
std::vector<std::u16string> suggestions;
SpellCheckWord(isolate, window, word, &suggestions);
return suggestions;
}