Skip to content
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

feat: Exposing methods required by capturing a hidden webContents #21679

Merged
merged 1 commit into from Jan 25, 2020

Conversation

zeeker999
Copy link
Contributor

@zeeker999 zeeker999 commented Jan 5, 2020

Description of Change

This pull request adds methods required by capturing a hidden webContents. With the IncrementCapturerCount(), it's possible to capture screen shot of BrowserView which attached to
a hidden BrowserWindow.

var hiddenWin = new BrowserWindow({ width: 800, height: 600, show: false })
var view = new BrowserView({ webPreferences: { show: true } })

hiddenWin.addBrowserView(view)
view.setBounds({ x: 0, y: 0, width: 800, height: 600})

// view.webContents.capturePage()  works because the browser view is visible initially.

// show the page in a normal window.
var win = new BrowserWindow({ width: 800, height: 600 })
win.removeBrowserView(view)
win.addBrowserView(view)
win.show()

//  the capturePage() works because the browser window is really visible now.

// close the normal window and add the view back to the hidden window.
view.webContents.incrementCapturerCount()
win.removeBrowserView(view)
hiddenWin.addBrowserView(view)
win.close()

// the capturePage() works here because we ask the webContents to ignore the page
// visibility, it wont work without increasing the capturer count.

cc @MarshallOfSound @ckerr @zcbenz

Checklist

Release Notes

notes: Exposing methods required by capturing a hidden webContents。

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jan 5, 2020
@welcome
Copy link

welcome bot commented Jan 5, 2020

💖 Thanks for opening this pull request! 💖

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jan 6, 2020
@zeeker999
Copy link
Contributor Author

Could you please review my changes?

cc @MarshallOfSound @ckerr @zcbenz

Copy link
Member

@zcbenz zcbenz left a comment

Choose a reason for hiding this comment

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

Can you add documentations for the methods?

@zeeker999
Copy link
Contributor Author

Ok, no problem.

@zeeker999
Copy link
Contributor Author

@zcbenz Could you please take another look.

Copy link
Member

@zcbenz zcbenz left a comment

Choose a reason for hiding this comment

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

This looks good to me, would like to get more inputs from @electron/wg-api.

@zeeker999
Copy link
Contributor Author

@codebytere I have fixed all issues and pushed to my branch, could you please review my changes again.

@zcbenz zcbenz merged commit 852b869 into electron:master Jan 25, 2020
@welcome
Copy link

welcome bot commented Jan 25, 2020

Congrats on merging your first pull request! 🎉🎉🎉

@release-clerk
Copy link

release-clerk bot commented Jan 25, 2020

Release Notes Persisted

Exposing methods required by capturing a hidden webContents。

@trop
Copy link
Contributor

trop bot commented Jan 25, 2020

@LuoJinghua has manually backported this PR to "7-1-x", please check out #21894

@trop
Copy link
Contributor

trop bot commented Jan 25, 2020

@LuoJinghua has manually backported this PR to "8-x-y", please check out #21895

@trop
Copy link
Contributor

trop bot commented Mar 23, 2020

@LuoJinghua has manually backported this PR to "7-2-x", please check out #21894

@sofianguy sofianguy added this to Fixed in 7.2.0 in 7.2.x Apr 3, 2020
@peererror
Copy link

is this available for 6.1.x ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
7.2.x
Fixed in 7.2.0
Development

Successfully merging this pull request may close these issues.

None yet

4 participants