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

Add layout support for View API #13044

Merged
merged 3 commits into from May 24, 2018

Conversation

Projects
None yet
3 participants
@zcbenz
Contributor

zcbenz commented May 23, 2018

This PR adds some bindings for Chromium's LayoutManager system. The JavaScript APIs are directly mapped from the C++ APIs, and they are not very easy to use, the APIs are very likely to change in future.

const {app, webContents, BoxLayout, TopLevelWindow, View, WebContentsView} = require('electron')

let win = null
app.once('ready', () => {
  const web = webContents.create({})
  const webview = new WebContentsView(web)
  web.loadURL('http://github.com')

  const layout = new BoxLayout('vertical')

  const view = new View()
  view.setLayoutManager(layout)
  view.addChildView(webview)

  layout.setFlexForView(webview, 1)

  win = new TopLevelWindow({frame: false})
  win.setContentView(view)
})

@zcbenz zcbenz requested a review from electron/reviewers as a code owner May 23, 2018

@MarshallOfSound

This comment has been minimized.

Member

MarshallOfSound commented May 23, 2018

@zcbenz Should we put these things behind a build flag?

/cc @alexeykuzmin

@miniak

This comment has been minimized.

Contributor

miniak commented May 23, 2018

@zcbenz webContents.create is not documented, is that deliberate?

@zcbenz

This comment has been minimized.

Contributor

zcbenz commented May 24, 2018

@zcbenz Should we put these things behind a build flag?

I'm not quite sure, most Chromium APIs I used here have not been changed for years. But if it is causing problems for Chromium upgrades, I can easily hide them under build flags.

@zcbenz webContents.create is not documented, is that deliberate?

Yeah it is currently only used in internal code and not supposed to be used by users, using it requires cautious otherwise crashes can easily happen. I'll make it a stable interface once the View API is ready for public.

@MarshallOfSound

This comment has been minimized.

Member

MarshallOfSound commented May 24, 2018

Until the stable release of this view API I'd ❤️it if these were put behind a build flag just so

  • it doesn't block chromium upgrades
  • we don't get people trying to use it and raising issues for it when it isn't ready yet
@zcbenz

This comment has been minimized.

Contributor

zcbenz commented May 24, 2018

Until the stable release of this view API I'd ❤️it if these were put behind a build flag

👍

@zcbenz zcbenz merged commit a798a40 into master May 24, 2018

11 checks passed

WIP ready for review
Details
ci/circleci: electron-linux-arm Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-arm-test Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-arm64 Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-arm64-test Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-ia32 Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-x64 Your tests passed on CircleCI!
Details
ci/circleci: electron-mas-x64 Your tests passed on CircleCI!
Details
ci/circleci: electron-osx-x64 Your tests passed on CircleCI!
Details
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details

@zcbenz zcbenz deleted the more-view-apis branch May 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment