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
parent 3a8f47bb4a
commit d2bed2b014

View File

@ -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();
}
});
}