2014-12-18 21:43:51 +00:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/renderer/api/electron_api_spell_check_client.h"
|
2014-12-18 21:43:51 +00:00
|
|
|
|
2022-06-22 08:15:27 +00:00
|
|
|
#include <iterator>
|
2019-09-16 22:12:00 +00:00
|
|
|
#include <memory>
|
2019-05-31 04:19:10 +00:00
|
|
|
#include <set>
|
2024-01-11 06:33:40 +00:00
|
|
|
#include <string_view>
|
2019-05-31 04:19:10 +00:00
|
|
|
#include <unordered_set>
|
2019-05-17 04:58:03 +00:00
|
|
|
#include <utility>
|
2014-12-19 00:44:38 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2023-05-30 08:28:43 +00:00
|
|
|
#include "base/containers/contains.h"
|
2014-12-19 01:41:42 +00:00
|
|
|
#include "base/logging.h"
|
2019-02-21 16:22:53 +00:00
|
|
|
#include "base/numerics/safe_conversions.h"
|
2023-02-03 11:43:42 +00:00
|
|
|
#include "base/task/single_thread_task_runner.h"
|
2018-10-26 17:34:57 +00:00
|
|
|
#include "components/spellcheck/renderer/spellcheck_worditerator.h"
|
2019-10-31 07:56:00 +00:00
|
|
|
#include "shell/common/gin_helper/dictionary.h"
|
|
|
|
#include "shell/common/gin_helper/function_template.h"
|
2021-05-14 01:21:36 +00:00
|
|
|
#include "shell/common/gin_helper/microtasks_scope.h"
|
2018-07-20 16:08:18 +00:00
|
|
|
#include "third_party/blink/public/web/web_text_checking_completion.h"
|
|
|
|
#include "third_party/blink/public/web/web_text_checking_result.h"
|
2018-04-18 01:55:30 +00:00
|
|
|
#include "third_party/icu/source/common/unicode/uscript.h"
|
2024-07-29 17:42:57 +00:00
|
|
|
#include "v8/include/v8-function.h"
|
2014-12-19 00:44:38 +00:00
|
|
|
|
2022-06-29 19:55:47 +00:00
|
|
|
namespace electron::api {
|
2014-12-18 21:43:51 +00:00
|
|
|
|
2014-12-19 01:41:42 +00:00
|
|
|
namespace {
|
|
|
|
|
2021-03-16 16:18:45 +00:00
|
|
|
bool HasWordCharacters(const std::u16string& text, int index) {
|
2021-03-16 01:21:27 +00:00
|
|
|
const char16_t* data = text.data();
|
2014-12-19 01:41:42 +00:00
|
|
|
int length = text.length();
|
|
|
|
while (index < length) {
|
2016-03-08 04:40:10 +00:00
|
|
|
uint32_t code = 0;
|
2014-12-19 01:41:42 +00:00
|
|
|
U16_NEXT(data, index, length, code);
|
|
|
|
UErrorCode error = U_ZERO_ERROR;
|
|
|
|
if (uscript_getScript(code, &error) != USCRIPT_COMMON)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-05-31 04:19:10 +00:00
|
|
|
struct Word {
|
|
|
|
blink::WebTextCheckingResult result;
|
2021-03-16 16:18:45 +00:00
|
|
|
std::u16string text;
|
|
|
|
std::vector<std::u16string> contraction_words;
|
2019-05-31 04:19:10 +00:00
|
|
|
};
|
|
|
|
|
2014-12-19 01:41:42 +00:00
|
|
|
} // namespace
|
|
|
|
|
2018-04-09 06:18:50 +00:00
|
|
|
class SpellCheckClient::SpellcheckRequest {
|
|
|
|
public:
|
2019-05-17 04:58:03 +00:00
|
|
|
SpellcheckRequest(
|
2021-03-16 16:18:45 +00:00
|
|
|
const std::u16string& text,
|
2019-05-17 04:58:03 +00:00
|
|
|
std::unique_ptr<blink::WebTextCheckingCompletion> completion)
|
|
|
|
: text_(text), completion_(std::move(completion)) {}
|
2020-07-14 01:13:34 +00:00
|
|
|
SpellcheckRequest(const SpellcheckRequest&) = delete;
|
|
|
|
SpellcheckRequest& operator=(const SpellcheckRequest&) = delete;
|
2019-09-16 22:12:00 +00:00
|
|
|
~SpellcheckRequest() = default;
|
2018-04-09 06:18:50 +00:00
|
|
|
|
2021-03-16 16:18:45 +00:00
|
|
|
const std::u16string& text() const { return text_; }
|
2019-05-21 19:22:15 +00:00
|
|
|
blink::WebTextCheckingCompletion* completion() { return completion_.get(); }
|
2019-05-31 04:19:10 +00:00
|
|
|
std::vector<Word>& wordlist() { return word_list_; }
|
2018-04-09 06:18:50 +00:00
|
|
|
|
|
|
|
private:
|
2021-03-16 16:18:45 +00:00
|
|
|
std::u16string text_; // Text to be checked in this task.
|
2019-05-31 04:19:10 +00:00
|
|
|
std::vector<Word> word_list_; // List of Words found in text
|
2022-10-12 00:01:57 +00:00
|
|
|
// The interface to send the misspelled ranges to Blink.
|
2019-05-21 19:22:15 +00:00
|
|
|
std::unique_ptr<blink::WebTextCheckingCompletion> completion_;
|
2018-04-09 06:18:50 +00:00
|
|
|
};
|
|
|
|
|
2014-12-20 05:01:47 +00:00
|
|
|
SpellCheckClient::SpellCheckClient(const std::string& language,
|
|
|
|
v8::Isolate* isolate,
|
2015-05-22 11:11:22 +00:00
|
|
|
v8::Local<v8::Object> provider)
|
2021-01-26 18:16:21 +00:00
|
|
|
: isolate_(isolate),
|
2017-12-06 11:55:28 +00:00
|
|
|
context_(isolate, isolate->GetCurrentContext()),
|
2014-12-20 05:01:47 +00:00
|
|
|
provider_(isolate, provider) {
|
2017-12-06 11:55:28 +00:00
|
|
|
DCHECK(!context_.IsEmpty());
|
|
|
|
|
2014-12-20 04:42:19 +00:00
|
|
|
character_attributes_.SetDefaultLanguage(language);
|
|
|
|
|
|
|
|
// Persistent the method.
|
2019-10-31 07:56:00 +00:00
|
|
|
v8::Local<v8::Function> spell_check;
|
|
|
|
gin_helper::Dictionary(isolate, provider).Get("spellCheck", &spell_check);
|
|
|
|
spell_check_.Reset(isolate, spell_check);
|
2014-12-20 04:42:19 +00:00
|
|
|
}
|
2014-12-18 21:43:51 +00:00
|
|
|
|
2017-12-06 11:55:28 +00:00
|
|
|
SpellCheckClient::~SpellCheckClient() {
|
|
|
|
context_.Reset();
|
|
|
|
}
|
2014-12-18 21:43:51 +00:00
|
|
|
|
2017-06-16 20:42:33 +00:00
|
|
|
void SpellCheckClient::RequestCheckingOfText(
|
2014-12-18 21:43:51 +00:00
|
|
|
const blink::WebString& textToCheck,
|
2019-05-17 04:58:03 +00:00
|
|
|
std::unique_ptr<blink::WebTextCheckingCompletion> completionCallback) {
|
2021-03-16 16:18:45 +00:00
|
|
|
std::u16string text(textToCheck.Utf16());
|
2018-04-09 06:18:50 +00:00
|
|
|
// Ignore invalid requests.
|
2014-12-19 01:41:42 +00:00
|
|
|
if (text.empty() || !HasWordCharacters(text, 0)) {
|
2017-06-16 20:42:33 +00:00
|
|
|
completionCallback->DidCancelCheckingText();
|
2014-12-19 01:41:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-09 06:18:50 +00:00
|
|
|
// Clean up the previous request before starting a new request.
|
2018-10-18 16:11:53 +00:00
|
|
|
if (pending_request_param_) {
|
2018-04-09 06:18:50 +00:00
|
|
|
pending_request_param_->completion()->DidCancelCheckingText();
|
|
|
|
}
|
|
|
|
|
2019-09-16 22:12:00 +00:00
|
|
|
pending_request_param_ =
|
|
|
|
std::make_unique<SpellcheckRequest>(text, std::move(completionCallback));
|
2018-04-09 06:18:50 +00:00
|
|
|
|
2023-02-03 11:43:42 +00:00
|
|
|
base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
|
chore: bump chromium to 128.0.6611.0 (main) (#42779)
* chore: bump chromium in DEPS to 128.0.6577.0
* chore: bump chromium in DEPS to 128.0.6579.0
* 5675706: Reland "Reland "Reland "Reland "Add toolchains without PartitionAlloc-Everywhere for dump_syms et al""""
https://chromium-review.googlesource.com/c/chromium/src/+/5675706
* 5668597: [PDF Ink Signatures] Prompt download menu on save when there are edits
https://chromium-review.googlesource.com/c/chromium/src/+/5668597
* 5677014: Reland "Pull data_sharing_sdk from CIPD"
https://chromium-review.googlesource.com/c/chromium/src/+/5677014
* chore: fixup patch indices
* chore: bump chromium in DEPS to 128.0.6581.0
* chore: bump chromium in DEPS to 128.0.6583.0
* update patches
* 5455480: [Extensions] Allow service worker requests to continue without a cert
https://chromium-review.googlesource.com/c/chromium/src/+/5455480
* try to get some debugging output from script/push-patch.js
* chore: bump chromium in DEPS to 128.0.6585.0
* chore: bump chromium in DEPS to 128.0.6587.0
* update patches
* chore: bump chromium in DEPS to 128.0.6589.0
* more patch work
* maybe over here?
* chore: update patches
* 5673207: [HTTPS Upgrades] Disable in captive portal login webview
https://chromium-review.googlesource.com/c/chromium/src/+/5673207
* 5636785: Extensions: WAR: manifest.json's use_dynamic_url requires a dynamic url
https://chromium-review.googlesource.com/c/chromium/src/+/5636785
* chore: bump chromium in DEPS to 128.0.6591.0
* 5665458: Trigger WN2 page when feature is enabled
https://chromium-review.googlesource.com/c/chromium/src/+/5665458
* update patches
* chore: bump chromium in DEPS to 128.0.6593.0
* chore: bump chromium in DEPS to 128.0.6595.0
* chore: bump chromium in DEPS to 128.0.6597.0
* (patch update) 5694586: [compile hints] Remove the usage of v8::Isolate::SetJavaScriptCompileHintsMagicEnabledCallback API
https://chromium-review.googlesource.com/c/chromium/src/+/5694586
* update patches
* 5691287: Reland "Change blink::WebKeyboardEvent to use std::array in is members"
https://chromium-review.googlesource.com/c/chromium/src/+/5691287
The code changed here is modeled after code in `content/renderer/pepper/event_conversion.cc` that was also modified in this CL, so I took the same approach.
* 5529018: Cleanup EnableWebHidOnExtensionServiceWorker flag
https://chromium-review.googlesource.com/c/chromium/src/+/5529018
* 5526324: [Code Health] Add deprecation comment for base::SupportsWeakPtr.
https://chromium-review.googlesource.com/c/chromium/src/+/5526324
Note that this CL actually does make `SupportsWeakPtr` strictly restricted to existing implementations, no new ones. We could add a patch to add ourselves to this list, but it looks like we'll have to refactor this anyways in the near future. Since the refactor seems straightforward, let's try that first.
* chore: bump chromium in DEPS to 128.0.6598.0
* chore: update patches
* 5704737: Rename ExclusiveAccessContext::GetActiveWebContents to avoid conflict
https://chromium-review.googlesource.com/c/chromium/src/+/5704737
* chore: bump chromium in DEPS to 128.0.6601.0
* chore: update patches
* Add `base::StringPiece` header includes
Chromium is working on replacing `base::StringPiece` with `std::string_view`. (See the Chromium Bug below.) They're currently running mass codemods (across many multiple changes) to replace uses of `StringPiece` with `string_view`, including removing the header include for `StringPiece` in those files. This cascades down to our files that were implicitly depending on those includes through some other include.
They're on track to eventually deprecate and remove `StringPiece` so our code should be converted, but that can be done as an upgrade follow-up task. For now, adding the header back to files that need it should suffice for minimal upgrade changes.
Chromium Bug: https://issues.chromium.org/issues/40506050
* 5702737: GlobalRequestID: Avoid unwanted inlining and narrowing int conversions
https://chromium-review.googlesource.com/c/chromium/src/+/5702737
contender for smallest commit 2024
* 5706534: Rename GlobalFeatures to GlobalDesktopFeatures.
https://chromium-review.googlesource.com/c/chromium/src/+/5706534
* 5691321: ui: remove params variants of SelectFile listener functions
https://chromium-review.googlesource.com/c/chromium/src/+/5691321
* 5714949: [Extensions] Display re-enable dialog for MV2 disabled stage
https://chromium-review.googlesource.com/c/chromium/src/+/5714949
* chore: update libc++ filenames
* patch: disable scope reuse & associated dchecks in v8 (hopefully temp, upgrade follow-up)
* fixup! Add `base::StringPiece` header includes
* update MAS patch
5710330: Add crash keys to debug NativeWidgetMacNSWindowBorderlessFrame exception
https://chromium-review.googlesource.com/c/chromium/src/+/5710330
* chore: bump chromium in DEPS to 128.0.6603.0
* chore: update patches
* 5713258: Reland "Preparation for decoupling creation/initialization of context"
https://chromium-review.googlesource.com/c/chromium/src/+/5713258
When destroying a context, it must already be shutdown, and this change enforces it with a new CHECK.
We were overriding `BrowserContextKeyedServiceFactory::BrowserContextShutdown` with an empty implementation, which differed from the default implementation that notifies the `KeyedServiceFactory` that the context has shutdown. Since we were missing this notification, the CHECK would later trip when the service was being destoryed because it was not registered as shutdown when it was shutdown.
* chore: bump chromium in DEPS to 128.0.6605.2
* chore: update patches
* refactor: linux open/save dialog patch
Our existing implementation was relying on an opaque `void* params` parameter that was passed through `ui::SelectFileDialog`.
Recently, that parameter has been getting removed:
- 5691321: ui: remove params variants of SelectFile listener functions | https://chromium-review.googlesource.com/c/chromium/src/+/5691321
- 5709097: ui: remove SelectFileDialog impl params | https://chromium-review.googlesource.com/c/chromium/src/+/5709097
- https://issues.chromium.org/issues/340178601 "reconsider SelectFileDialog"
This restructures the patch to work with mostly the same mechanics, but directly on the `ui::SelectFileDialog` object. This nets us some wins in terms of a smaller patch.
* 5713262: DevTools UI binding AIDA client event returns response
https://chromium-review.googlesource.com/c/chromium/src/+/5713262
* fixup! refactor: linux open/save dialog patch
* chore: bump chromium in DEPS to 128.0.6606.0
* chore: update patches
* fixup! refactor: linux open/save dialog patch
* chore: bump chromium in DEPS to 128.0.6607.0
* chore: update printing.patch
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5722937
* fix: pwd error in electron-test, nan-test
fix: unshallow depot_tools before 3-way apply
* chore: e patches all
* fixup! fix: pwd error in electron-test, nan-test
* chore: bump chromium in DEPS to 128.0.6609.0
* chore: bump chromium in DEPS to 128.0.6611.0
* chore: update patches
* chore: update libcxx filenames
---------
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: Alice Zhao <alice@makenotion.com>
2024-07-23 15:59:44 +00:00
|
|
|
FROM_HERE, base::BindOnce(&SpellCheckClient::SpellCheckText,
|
|
|
|
weak_factory_.GetWeakPtr()));
|
2014-12-18 21:43:51 +00:00
|
|
|
}
|
|
|
|
|
2018-07-10 19:43:39 +00:00
|
|
|
bool SpellCheckClient::IsSpellCheckingEnabled() const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-02-06 17:18:52 +00:00
|
|
|
void SpellCheckClient::ShowSpellingUI(bool show) {}
|
2014-12-18 21:43:51 +00:00
|
|
|
|
2017-06-16 20:42:33 +00:00
|
|
|
bool SpellCheckClient::IsShowingSpellingUI() {
|
2014-12-18 21:43:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-06-16 20:42:33 +00:00
|
|
|
void SpellCheckClient::UpdateSpellingUIWithMisspelledWord(
|
2018-02-06 17:18:52 +00:00
|
|
|
const blink::WebString& word) {}
|
2014-12-18 21:43:51 +00:00
|
|
|
|
2018-10-18 16:11:53 +00:00
|
|
|
void SpellCheckClient::SpellCheckText() {
|
|
|
|
const auto& text = pending_request_param_->text();
|
|
|
|
if (text.empty() || spell_check_.IsEmpty()) {
|
|
|
|
pending_request_param_->completion()->DidCancelCheckingText();
|
|
|
|
pending_request_param_ = nullptr;
|
2014-12-20 06:13:07 +00:00
|
|
|
return;
|
2018-10-18 16:11:53 +00:00
|
|
|
}
|
2014-12-19 00:44:38 +00:00
|
|
|
|
2014-12-20 06:13:07 +00:00
|
|
|
if (!text_iterator_.IsInitialized() &&
|
|
|
|
!text_iterator_.Initialize(&character_attributes_, true)) {
|
2018-02-06 17:18:52 +00:00
|
|
|
// We failed to initialize text_iterator_, return as spelled correctly.
|
|
|
|
VLOG(1) << "Failed to initialize SpellcheckWordIterator";
|
|
|
|
return;
|
2014-12-20 06:13:07 +00:00
|
|
|
}
|
2014-12-19 00:44:38 +00:00
|
|
|
|
2017-12-06 11:55:28 +00:00
|
|
|
if (!contraction_iterator_.IsInitialized() &&
|
|
|
|
!contraction_iterator_.Initialize(&character_attributes_, false)) {
|
|
|
|
// We failed to initialize the word iterator, return as spelled correctly.
|
|
|
|
VLOG(1) << "Failed to initialize contraction_iterator_";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-01-11 06:33:40 +00:00
|
|
|
text_iterator_.SetText(text);
|
2017-12-06 11:55:28 +00:00
|
|
|
|
|
|
|
SpellCheckScope scope(*this);
|
2021-03-16 16:18:45 +00:00
|
|
|
std::u16string word;
|
2019-02-21 16:22:53 +00:00
|
|
|
size_t word_start;
|
|
|
|
size_t word_length;
|
2021-03-16 16:18:45 +00:00
|
|
|
std::set<std::u16string> words;
|
2019-05-31 04:19:10 +00:00
|
|
|
auto& word_list = pending_request_param_->wordlist();
|
|
|
|
Word word_entry;
|
2018-10-18 16:11:53 +00:00
|
|
|
for (;;) { // Run until end of text
|
|
|
|
const auto status =
|
2019-02-21 16:22:53 +00:00
|
|
|
text_iterator_.GetNextWord(&word, &word_start, &word_length);
|
2018-10-18 16:11:53 +00:00
|
|
|
if (status == SpellcheckWordIterator::IS_END_OF_TEXT)
|
|
|
|
break;
|
2018-02-06 17:18:52 +00:00
|
|
|
if (status == SpellcheckWordIterator::IS_SKIPPABLE)
|
|
|
|
continue;
|
|
|
|
|
2019-05-31 04:19:10 +00:00
|
|
|
word_entry.result.location = base::checked_cast<int>(word_start);
|
|
|
|
word_entry.result.length = base::checked_cast<int>(word_length);
|
|
|
|
word_entry.text = word;
|
|
|
|
word_entry.contraction_words.clear();
|
2019-02-21 16:22:53 +00:00
|
|
|
|
2019-05-31 04:19:10 +00:00
|
|
|
word_list.push_back(word_entry);
|
|
|
|
words.insert(word);
|
2014-12-20 06:13:07 +00:00
|
|
|
// If the given word is a concatenated word of two or more valid words
|
|
|
|
// (e.g. "hello:hello"), we should treat it as a valid word.
|
2019-05-31 04:19:10 +00:00
|
|
|
if (IsContraction(scope, word, &word_entry.contraction_words)) {
|
|
|
|
for (const auto& w : word_entry.contraction_words) {
|
|
|
|
words.insert(w);
|
2018-10-18 16:11:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-20 06:13:07 +00:00
|
|
|
|
2018-10-18 16:11:53 +00:00
|
|
|
// Send out all the words data to the spellchecker to check
|
|
|
|
SpellCheckWords(scope, words);
|
|
|
|
}
|
2014-12-20 06:13:07 +00:00
|
|
|
|
2018-10-18 16:11:53 +00:00
|
|
|
void SpellCheckClient::OnSpellCheckDone(
|
2021-03-16 16:18:45 +00:00
|
|
|
const std::vector<std::u16string>& misspelled_words) {
|
2018-10-18 16:11:53 +00:00
|
|
|
std::vector<blink::WebTextCheckingResult> results;
|
2021-03-16 16:18:45 +00:00
|
|
|
std::unordered_set<std::u16string> misspelled(misspelled_words.begin(),
|
2019-05-31 04:19:10 +00:00
|
|
|
misspelled_words.end());
|
|
|
|
|
|
|
|
auto& word_list = pending_request_param_->wordlist();
|
|
|
|
|
|
|
|
for (const auto& word : word_list) {
|
2023-05-30 08:28:43 +00:00
|
|
|
if (base::Contains(misspelled, word.text)) {
|
2019-05-31 04:19:10 +00:00
|
|
|
// If this is a contraction, iterate through parts and accept the word
|
|
|
|
// if none of them are misspelled
|
|
|
|
if (!word.contraction_words.empty()) {
|
|
|
|
auto all_correct = true;
|
|
|
|
for (const auto& contraction_word : word.contraction_words) {
|
2023-05-30 08:28:43 +00:00
|
|
|
if (base::Contains(misspelled, contraction_word)) {
|
2019-05-31 04:19:10 +00:00
|
|
|
all_correct = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (all_correct)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
results.push_back(word.result);
|
2018-10-18 16:11:53 +00:00
|
|
|
}
|
2014-12-20 06:13:07 +00:00
|
|
|
}
|
2019-05-21 19:22:15 +00:00
|
|
|
pending_request_param_->completion()->DidFinishCheckingText(results);
|
2018-10-18 16:11:53 +00:00
|
|
|
pending_request_param_ = nullptr;
|
2014-12-19 00:44:38 +00:00
|
|
|
}
|
|
|
|
|
2019-05-31 04:19:10 +00:00
|
|
|
void SpellCheckClient::SpellCheckWords(const SpellCheckScope& scope,
|
2021-03-16 16:18:45 +00:00
|
|
|
const std::set<std::u16string>& words) {
|
2018-02-06 17:18:52 +00:00
|
|
|
DCHECK(!scope.spell_check_.IsEmpty());
|
2014-12-20 04:42:19 +00:00
|
|
|
|
2023-01-11 16:59:32 +00:00
|
|
|
auto context = isolate_->GetCurrentContext();
|
2021-05-14 01:21:36 +00:00
|
|
|
gin_helper::MicrotasksScope microtasks_scope(
|
2023-01-11 16:59:32 +00:00
|
|
|
isolate_, context->GetMicrotaskQueue(),
|
|
|
|
v8::MicrotasksScope::kDoNotRunMicrotasks);
|
2021-05-14 01:21:36 +00:00
|
|
|
|
2019-10-31 07:56:00 +00:00
|
|
|
v8::Local<v8::FunctionTemplate> templ = gin_helper::CreateFunctionTemplate(
|
chore: bump chromium to 128.0.6611.0 (main) (#42779)
* chore: bump chromium in DEPS to 128.0.6577.0
* chore: bump chromium in DEPS to 128.0.6579.0
* 5675706: Reland "Reland "Reland "Reland "Add toolchains without PartitionAlloc-Everywhere for dump_syms et al""""
https://chromium-review.googlesource.com/c/chromium/src/+/5675706
* 5668597: [PDF Ink Signatures] Prompt download menu on save when there are edits
https://chromium-review.googlesource.com/c/chromium/src/+/5668597
* 5677014: Reland "Pull data_sharing_sdk from CIPD"
https://chromium-review.googlesource.com/c/chromium/src/+/5677014
* chore: fixup patch indices
* chore: bump chromium in DEPS to 128.0.6581.0
* chore: bump chromium in DEPS to 128.0.6583.0
* update patches
* 5455480: [Extensions] Allow service worker requests to continue without a cert
https://chromium-review.googlesource.com/c/chromium/src/+/5455480
* try to get some debugging output from script/push-patch.js
* chore: bump chromium in DEPS to 128.0.6585.0
* chore: bump chromium in DEPS to 128.0.6587.0
* update patches
* chore: bump chromium in DEPS to 128.0.6589.0
* more patch work
* maybe over here?
* chore: update patches
* 5673207: [HTTPS Upgrades] Disable in captive portal login webview
https://chromium-review.googlesource.com/c/chromium/src/+/5673207
* 5636785: Extensions: WAR: manifest.json's use_dynamic_url requires a dynamic url
https://chromium-review.googlesource.com/c/chromium/src/+/5636785
* chore: bump chromium in DEPS to 128.0.6591.0
* 5665458: Trigger WN2 page when feature is enabled
https://chromium-review.googlesource.com/c/chromium/src/+/5665458
* update patches
* chore: bump chromium in DEPS to 128.0.6593.0
* chore: bump chromium in DEPS to 128.0.6595.0
* chore: bump chromium in DEPS to 128.0.6597.0
* (patch update) 5694586: [compile hints] Remove the usage of v8::Isolate::SetJavaScriptCompileHintsMagicEnabledCallback API
https://chromium-review.googlesource.com/c/chromium/src/+/5694586
* update patches
* 5691287: Reland "Change blink::WebKeyboardEvent to use std::array in is members"
https://chromium-review.googlesource.com/c/chromium/src/+/5691287
The code changed here is modeled after code in `content/renderer/pepper/event_conversion.cc` that was also modified in this CL, so I took the same approach.
* 5529018: Cleanup EnableWebHidOnExtensionServiceWorker flag
https://chromium-review.googlesource.com/c/chromium/src/+/5529018
* 5526324: [Code Health] Add deprecation comment for base::SupportsWeakPtr.
https://chromium-review.googlesource.com/c/chromium/src/+/5526324
Note that this CL actually does make `SupportsWeakPtr` strictly restricted to existing implementations, no new ones. We could add a patch to add ourselves to this list, but it looks like we'll have to refactor this anyways in the near future. Since the refactor seems straightforward, let's try that first.
* chore: bump chromium in DEPS to 128.0.6598.0
* chore: update patches
* 5704737: Rename ExclusiveAccessContext::GetActiveWebContents to avoid conflict
https://chromium-review.googlesource.com/c/chromium/src/+/5704737
* chore: bump chromium in DEPS to 128.0.6601.0
* chore: update patches
* Add `base::StringPiece` header includes
Chromium is working on replacing `base::StringPiece` with `std::string_view`. (See the Chromium Bug below.) They're currently running mass codemods (across many multiple changes) to replace uses of `StringPiece` with `string_view`, including removing the header include for `StringPiece` in those files. This cascades down to our files that were implicitly depending on those includes through some other include.
They're on track to eventually deprecate and remove `StringPiece` so our code should be converted, but that can be done as an upgrade follow-up task. For now, adding the header back to files that need it should suffice for minimal upgrade changes.
Chromium Bug: https://issues.chromium.org/issues/40506050
* 5702737: GlobalRequestID: Avoid unwanted inlining and narrowing int conversions
https://chromium-review.googlesource.com/c/chromium/src/+/5702737
contender for smallest commit 2024
* 5706534: Rename GlobalFeatures to GlobalDesktopFeatures.
https://chromium-review.googlesource.com/c/chromium/src/+/5706534
* 5691321: ui: remove params variants of SelectFile listener functions
https://chromium-review.googlesource.com/c/chromium/src/+/5691321
* 5714949: [Extensions] Display re-enable dialog for MV2 disabled stage
https://chromium-review.googlesource.com/c/chromium/src/+/5714949
* chore: update libc++ filenames
* patch: disable scope reuse & associated dchecks in v8 (hopefully temp, upgrade follow-up)
* fixup! Add `base::StringPiece` header includes
* update MAS patch
5710330: Add crash keys to debug NativeWidgetMacNSWindowBorderlessFrame exception
https://chromium-review.googlesource.com/c/chromium/src/+/5710330
* chore: bump chromium in DEPS to 128.0.6603.0
* chore: update patches
* 5713258: Reland "Preparation for decoupling creation/initialization of context"
https://chromium-review.googlesource.com/c/chromium/src/+/5713258
When destroying a context, it must already be shutdown, and this change enforces it with a new CHECK.
We were overriding `BrowserContextKeyedServiceFactory::BrowserContextShutdown` with an empty implementation, which differed from the default implementation that notifies the `KeyedServiceFactory` that the context has shutdown. Since we were missing this notification, the CHECK would later trip when the service was being destoryed because it was not registered as shutdown when it was shutdown.
* chore: bump chromium in DEPS to 128.0.6605.2
* chore: update patches
* refactor: linux open/save dialog patch
Our existing implementation was relying on an opaque `void* params` parameter that was passed through `ui::SelectFileDialog`.
Recently, that parameter has been getting removed:
- 5691321: ui: remove params variants of SelectFile listener functions | https://chromium-review.googlesource.com/c/chromium/src/+/5691321
- 5709097: ui: remove SelectFileDialog impl params | https://chromium-review.googlesource.com/c/chromium/src/+/5709097
- https://issues.chromium.org/issues/340178601 "reconsider SelectFileDialog"
This restructures the patch to work with mostly the same mechanics, but directly on the `ui::SelectFileDialog` object. This nets us some wins in terms of a smaller patch.
* 5713262: DevTools UI binding AIDA client event returns response
https://chromium-review.googlesource.com/c/chromium/src/+/5713262
* fixup! refactor: linux open/save dialog patch
* chore: bump chromium in DEPS to 128.0.6606.0
* chore: update patches
* fixup! refactor: linux open/save dialog patch
* chore: bump chromium in DEPS to 128.0.6607.0
* chore: update printing.patch
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5722937
* fix: pwd error in electron-test, nan-test
fix: unshallow depot_tools before 3-way apply
* chore: e patches all
* fixup! fix: pwd error in electron-test, nan-test
* chore: bump chromium in DEPS to 128.0.6609.0
* chore: bump chromium in DEPS to 128.0.6611.0
* chore: update patches
* chore: update libcxx filenames
---------
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: Alice Zhao <alice@makenotion.com>
2024-07-23 15:59:44 +00:00
|
|
|
isolate_, base::BindRepeating(&SpellCheckClient::OnSpellCheckDone,
|
|
|
|
weak_factory_.GetWeakPtr()));
|
2019-10-31 07:56:00 +00:00
|
|
|
v8::Local<v8::Value> args[] = {gin::ConvertToV8(isolate_, words),
|
2019-01-09 19:17:05 +00:00
|
|
|
templ->GetFunction(context).ToLocalChecked()};
|
2018-10-18 16:11:53 +00:00
|
|
|
// Call javascript with the words and the callback function
|
2022-06-22 08:15:27 +00:00
|
|
|
scope.spell_check_->Call(context, scope.provider_, std::size(args), args)
|
|
|
|
.IsEmpty();
|
2014-12-20 04:42:19 +00:00
|
|
|
}
|
|
|
|
|
2018-10-18 16:11:53 +00:00
|
|
|
// Returns whether or not the given string is a contraction.
|
2014-12-20 04:42:19 +00:00
|
|
|
// This function is a fall-back when the SpellcheckWordIterator class
|
|
|
|
// returns a concatenated word which is not in the selected dictionary
|
|
|
|
// (e.g. "in'n'out") but each word is valid.
|
2018-10-18 16:11:53 +00:00
|
|
|
// Output variable contraction_words will contain individual
|
|
|
|
// words in the contraction.
|
|
|
|
bool SpellCheckClient::IsContraction(
|
|
|
|
const SpellCheckScope& scope,
|
2021-03-16 16:18:45 +00:00
|
|
|
const std::u16string& contraction,
|
|
|
|
std::vector<std::u16string>* contraction_words) {
|
2017-12-06 11:55:28 +00:00
|
|
|
DCHECK(contraction_iterator_.IsInitialized());
|
2014-12-20 04:42:19 +00:00
|
|
|
|
2024-01-11 06:33:40 +00:00
|
|
|
contraction_iterator_.SetText(contraction);
|
2014-12-20 04:42:19 +00:00
|
|
|
|
2021-03-16 16:18:45 +00:00
|
|
|
std::u16string word;
|
2019-02-21 16:22:53 +00:00
|
|
|
size_t word_start;
|
|
|
|
size_t word_length;
|
2018-02-06 17:18:52 +00:00
|
|
|
for (auto status =
|
|
|
|
contraction_iterator_.GetNextWord(&word, &word_start, &word_length);
|
|
|
|
status != SpellcheckWordIterator::IS_END_OF_TEXT;
|
|
|
|
status = contraction_iterator_.GetNextWord(&word, &word_start,
|
|
|
|
&word_length)) {
|
|
|
|
if (status == SpellcheckWordIterator::IS_SKIPPABLE)
|
|
|
|
continue;
|
|
|
|
|
2018-10-18 16:11:53 +00:00
|
|
|
contraction_words->push_back(word);
|
2014-12-20 04:42:19 +00:00
|
|
|
}
|
2018-10-18 16:11:53 +00:00
|
|
|
return contraction_words->size() > 1;
|
2018-04-09 06:18:50 +00:00
|
|
|
}
|
|
|
|
|
2017-12-06 11:55:28 +00:00
|
|
|
SpellCheckClient::SpellCheckScope::SpellCheckScope(
|
|
|
|
const SpellCheckClient& client)
|
|
|
|
: handle_scope_(client.isolate_),
|
|
|
|
context_scope_(
|
|
|
|
v8::Local<v8::Context>::New(client.isolate_, client.context_)),
|
2019-10-31 07:56:00 +00:00
|
|
|
provider_(v8::Local<v8::Object>::New(client.isolate_, client.provider_)),
|
|
|
|
spell_check_(
|
|
|
|
v8::Local<v8::Function>::New(client.isolate_, client.spell_check_)) {}
|
2017-12-06 11:55:28 +00:00
|
|
|
|
2018-04-17 23:37:22 +00:00
|
|
|
SpellCheckClient::SpellCheckScope::~SpellCheckScope() = default;
|
|
|
|
|
2022-06-29 19:55:47 +00:00
|
|
|
} // namespace electron::api
|