8000 feat: promisify webContents.printToPDF() by miniak · Pull Request #16795 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: promisify webContents.printToPDF() #16795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 11, 2019

Conversation

miniak
Copy link
Contributor
@miniak miniak commented Feb 6, 2019

Description of Change

This PR promisifies webContents.printToPDF()

/cc @codebytere

Checklist

Release Notes

Notes: Converted webContents.printToPDF() to return a Promise instead of taking a callback.

@miniak miniak requested review from codebytere and a team February 6, 2019 22:21
@miniak miniak force-pushed the miniak/promisify-print-to-pdf branch 3 times, most recently from 9065704 to 8d8fac3 Compare February 6, 2019 22:29
v8::Exception::Error(error_message), v8::Null(isolate));
}
print_to_pdf_callback_map_.erase(request_id);
v8::MicrotasksScope script_scope(isolate,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the util file deals with scoping prior to resolution; this can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove the script_scope, should I keep the context_scope though?

Copy link
Member
@codebytere codebytere Feb 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we handle it in the util, so i think you can remove that too!

  v8::Maybe<bool> Resolve() {
    v8::HandleScope handle_scope(isolate());
    v8::MicrotasksScope script_scope(isolate(),
                                     v8::MicrotasksScope::kRunMicrotasks);
    v8::Context::Scope context_scope(
        v8::Local<v8::Context>::New(isolate(), GetContext()));

    return GetInner()->Resolve(GetContext(), v8::Undefined(isolate()));
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but don't we need that because we are creating the v8::Local<v8::Value> buffer before calling the util?

@miniak miniak force-pushed the miniak/promisify-print-to-pdf branch from 8d8fac3 to a9ac096 Compare February 6, 2019 22:46
@miniak miniak self-assigned this Feb 7, 2019
@miniak miniak force-pushed the miniak/promisify-print-to-pdf branch 2 times, most recently from 3490bc6 to 398faec Compare February 7, 2019 09:54
Copy link
Member
@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@deepak1556
Copy link
Member

Lets rerun the osx test suite, to rule out flakiness before merging. Thanks!

8000
@miniak miniak force-pushed the miniak/promisify-print-to-pdf branch from 398faec to 0ff629c Compare February 8, 2019 21:16
@MarshallOfSound
Copy link
Member

I re-ran the macOS CI and the same test failed 🤔

@miniak miniak force-pushed the miniak/promisify-print-to-pdf branch from 0ff629c to a9fa543 Compare February 9, 2019 23:22
} else {
console.error('Error: Printing feature is disabled.')
return Promise.reject(new Error('Printing feature is disabled'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@jkleinsc jkleinsc merged commit 36ce3e9 into master Feb 11, 2019
@release-clerk
Copy link
release-clerk bot commented Feb 11, 2019

Release Notes Persisted

Converted webContents.printToPDF() to return a Promise instead of taking a callback.

@jkleinsc jkleinsc deleted the miniak/promisify-print-to-pdf branch February 11, 2019 19:20
@miniak
Copy link
Contributor Author
miniak commented Feb 14, 2019

/trop run backport-to 5-0-x

@trop
Copy link
Contributor
trop bot commented Feb 14, 2019

The backport process for this PR has been manually initiated,
sending your 1's and 0's to "5-0-x" here we go! :D

@trop
Copy link
Contributor
trop bot commented Feb 14, 2019

I was unable to backport this PR to "5-0-x" cleanly;
you will need to perform this backport manually.

javan added a commit to javan/electron that referenced this pull request Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0