Bug 1784554 - Return Input Stream Earlier for GeckoView Save to PDF r=geckoview-reviewers,amejiamarmol,owlish,emilio

Patch returns the input stream earlier for save to PDF. It now uses
SendError when the PDF does not process.

Differential Revision: https://phabricator.services.mozilla.com/D158702
This commit is contained in:
Olivia Hall 2022-10-10 18:08:34 +00:00
Родитель 3a8f47bb4a
Коммит d2bed2b014
1 изменённых файлов: 3 добавлений и 5 удалений

Просмотреть файл

@ -1808,17 +1808,15 @@ void GeckoViewSupport::PrintToPdf(
RefPtr<CanonicalBrowsingContext::PrintPromise> print =
cbc->Print(printSettings);
geckoResult->Complete(stream);
print->Then(
mozilla::GetCurrentSerialEventTarget(), __func__,
[result = java::GeckoResult::GlobalRef(geckoResult), stream, pdfErrorMsg](
const CanonicalBrowsingContext::PrintPromise::ResolveOrRejectValue&
aValue) {
if (aValue.IsReject()) {
result->CompleteExceptionally(
IllegalStateException::New(pdfErrorMsg).Cast<jni::Throwable>());
GVS_LOG("Could not print.");
} else {
result->Complete(stream);
GVS_LOG("Could not print. %s", pdfErrorMsg);
stream->SendError();
}
});
}