Compare commits

..

103 Commits

Author SHA1 Message Date
Electron Bot
a3c951b14b Bump v7.1.1 2019-11-07 13:00:09 -08:00
loc
c5abb17569 fix: allow iframe-initiated HTML fullscreen to exit while in macOS fullscreen (7-1-x) (#21021)
* fix: explicitly resize the contents when exiting html fullscreen while in OS fullscreen

* test: ensure HTML fullscreen toggles while in OS fullscreen
2019-11-07 12:58:50 -08:00
Electron Bot
1b0ba71973 chore: bump chromium in DEPS to 78.0.3904.99 (#21033) 2019-11-07 15:46:26 -05:00
Robo
8dd004235b fix: webrequest api typings (#21038)
* fix: webrequest api typings

* Update web-request.md
2019-11-07 11:46:26 -08:00
Robo
55955c3d79 fix: crash on exit in aura platforms with webview (#21022)
* fix: backport upstream patch for shutdown of X11 windows

* fix: check for validity of guest webcontents
2019-11-07 11:31:42 -05:00
trop[bot]
5b33e9d9b7 fixes widget host fetching from render view host (#21013) 2019-11-06 15:06:34 -08:00
trop[bot]
6871b448ad fix: proper i18n of recentDocuments item (#20957) 2019-11-06 13:57:53 -08:00
trop[bot]
7a1b3c5f2d fix: Fix broken globalShortcuts.registerAll() on non-macOS platforms (#20983)
This was a regression in #16125, which unintentionally put
`GlobalShortcutListener::RegisterAccelerator` into a
`#if defined(OS_MACOSX)` block.

Notes: Fix broken `globalShortcut.registerAll()` on Windows and Linux
2019-11-06 13:37:22 -08:00
trop[bot]
2e8349c520 fix: correctly emplace optional values in the value converter (#21008)
* fix: correctly emplace optional values in the value converter

* chore: replace optional with nullopt when the conversion failed
2019-11-06 13:32:38 -08:00
Electron Bot
d63150502b chore: bump chromium in DEPS to 78.0.3904.98 (#20999) 2019-11-06 10:41:22 -05:00
trop[bot]
daa61688b1 docs: fix win.setIcon ts type (#20980)
* docs: fix win.setIcon ts type

* test: update smoke tests
2019-11-05 21:25:57 -08:00
trop[bot]
0a3b0391f4 chore: emit the document-start and document-end events in a sandboxed renderer (#20991) 2019-11-05 19:25:07 -08:00
Samuel Attard
1b66c03e41 chore: upgrade ts generator for better type safety (#20975) (#20977)
* chore: upgrade ts generator for better type safety

* spec: fix tests
2019-11-05 15:20:29 -08:00
trop[bot]
92362da082 docs: update installation instructions for proxies (#20978) 2019-11-05 13:45:27 -08:00
Electron Bot
16e468137f chore: bump chromium in DEPS to 78.0.3904.95 (#20973) 2019-11-05 11:07:12 -05:00
Electron Bot
b27a34eb91 Bump v7.1.0 2019-11-04 16:16:14 -08:00
Samuel Attard
18176b48b4 chore: prepare for 7.1.0 2019-11-04 16:15:24 -08:00
Milan Burda
317f0cec68 fix: cannot access nativeTheme via electron.remote (#20938) (#20961) 2019-11-04 16:11:43 -08:00
Samuel Attard
49009236d9 fix: capture the promise global to avoid userland mutation (#20925) (#20947) 2019-11-04 15:58:55 -08:00
Samuel Attard
976c7d122a feat: add a new contextBridge module (#20789)
* feat: add a new contextBridge module (#20307)

* feat: add a new contextBridge module

* chore: fix docs linting

* feat: add support for function arguments being proxied

* chore: ensure that contextBridge can only be used when contextIsolation is enabled

* docs: getReverseBinding can be null

* docs: fix broken links in md file

* feat: add support for promises in function parameters

* fix: linting failure for explicit constructor

* Update atom_api_context_bridge.cc

* chore: update docs and API design as per feedback

* refactor: remove reverse bindings and handle GC'able functions across the bridge

* chore: only expose debugGC in testing builds

* fix: do not proxy promises as objects

* spec: add complete spec coverage for contextBridge

* spec: add tests for null/undefined and the anti-overwrite logic

* chore: fix linting

* spec: add complex nested back-and-forth function calling

* fix: expose contextBridge in sandboxed renderers

* refactor: improve security of default_app using the new contextBridge module

* s/bindAPIInMainWorld/exposeInMainWorld

* chore: sorry for this commit, its a big one, I fixed like everything and refactored a lot

* chore: remove PassedValueCache as it is unused now

Values transferred from context A to context B are now cachde in the RenderFramePersistenceStore

* chore: move to anonymous namespace

* refactor: remove PassValueToOtherContextWithCache

* chore: remove commented unused code blocks

* chore: remove .only

* chore: remote commented code

* refactor: extract RenderFramePersistenceStore

* spec: ensure it works with numbered keys

* fix: handle number keys correctly

* fix: sort out the linter

* spec: update default_app asar spec for removed file

* refactor: change signatures to return v8 objects directly rather than the mate dictionary handle

* refactor: use the v8 serializer to support cloneable buffers and other object types

* chore: fix linting

* fix: handle hash collisions with a linked list in the map

* fix: enforce a recursion limit on the context bridge

* chore: fix linting

* chore: remove TODO

* chore: adapt for PR feedback

* chore: remove .only

* chore: clean up docs and clean up the proxy map when objects are released

* chore: ensure we cache object values that are cloned through the V8 serializer

* docs: mark contextBridge as experimental (#20638)

* docs: mark contextBridge as experimental

This commit didn't make it to the original PR, quick addition here

* Update context-bridge.md

* chore: update for 7-0-x differences

* chore: update callback header

* chore: add v8 serializer converter, cherry picked from 2fad53e66b

* chore: update for 7-0-x differences
2019-11-04 14:56:03 -08:00
Samuel Attard
ef548b6592 chore: prepare for 7.1.0 2019-11-04 14:35:16 -08:00
trop[bot]
37c1df6ce1 fix: don't copy tray image when it's set (#20935) 2019-11-04 14:17:15 -08:00
Electron Bot
d9068b7175 chore: bump chromium to 78.0.3904.94 (7-0-x) (#20930)
* chore: bump chromium in DEPS to 78.0.3904.93

* chore: bump chromium in DEPS to 78.0.3904.94
2019-11-04 09:35:39 -05:00
Electron Bot
cac0a4fe3c Bump v7.0.1 2019-11-01 09:46:44 -07:00
John Kleinschmidt
e6807b387c ci: Revert CircleCI changes (#20916)
* Revert "build: lengthen wait times and retries for CircleCI releases (#20893)"

This reverts commit 41b32cf5d9.

* Revert "ci: verify CircleCI job number before returning job url (#20864)"

This reverts commit b97c3aca2d.

* Revert "build: run publish jobs in the secure context and enable sccache (#20863)"

This reverts commit 055b5d274e.

* Revert "ci: use CircleCI 2.1 config and v2 APIs (#20852)"

This reverts commit 1841742586.
2019-11-01 12:44:53 -04:00
Electron Bot
f6f73a5a78 Revert "Bump v7.0.1"
This reverts commit 7bad919bee.
2019-11-01 08:28:33 -07:00
Electron Bot
7bad919bee Bump v7.0.1 2019-11-01 08:09:20 -07:00
Electron Bot
667db6fa67 chore: bump chromium in DEPS to 78.0.3904.92 (#20913) 2019-11-01 11:06:43 -04:00
John Kleinschmidt
022ee3793b build: allow CircleCI timeout and retry to be set via env variables (7-0-x) (#20912)
* build: allow circleci timeout and retry to be set via env variables

* check for more statuses and run indefinitely
2019-11-01 11:05:57 -04:00
Electron Bot
5c0e8c5fd3 Revert "Bump v7.0.1"
This reverts commit 961436f300.
2019-11-01 05:09:48 -07:00
Electron Bot
961436f300 Bump v7.0.1 2019-11-01 05:07:26 -07:00
trop[bot]
e2c7e4b1ad fix: use Unicode version of ShellExecute() in OpenExternalOnWorkerThread() (#20905) 2019-11-01 08:05:57 -04:00
Electron Bot
d12b0eefe0 Revert "Bump v7.0.1"
This reverts commit 8dfb8c5589.
2019-10-31 13:22:22 -07:00
Electron Bot
8dfb8c5589 Bump v7.0.1 2019-10-31 13:19:55 -07:00
John Kleinschmidt
57bb08e084 Revert "Bump v7.0.1" (#20895)
This reverts commit 0de78019c8.
2019-10-31 15:11:45 -04:00
Electron Bot
03e0905519 Revert "Bump v7.0.2"
This reverts commit b6717a6644.
2019-10-31 12:07:12 -07:00
Electron Bot
b6717a6644 Bump v7.0.2 2019-10-31 11:57:41 -07:00
trop[bot]
41b32cf5d9 build: lengthen wait times and retries for CircleCI releases (#20893)
* build: lengthen wait times and retries for CircleCI releases

* Review suggestions
2019-10-31 14:53:05 -04:00
trop[bot]
176f4728d7 docs: clean up performance checklist formatting (#20887)
* docs: fix list formatting in performance checklist

* docs: remove unused link ref
2019-10-31 09:52:42 -07:00
Electron Bot
0de78019c8 Bump v7.0.1 2019-10-31 09:02:29 -07:00
trop[bot]
1926169c91 fix: swapped labels on open/save gtkdialog (#20882) 2019-10-31 08:42:35 -07:00
Electron Bot
25b3ee29cf chore: bump chromium in DEPS to 78.0.3904.88 (#20873) 2019-10-31 10:54:20 -04:00
trop[bot]
2228e5ac65 build: do not try to run non existent VSTS release builds (#20877) 2019-10-31 10:04:53 -04:00
Electron Bot
92cace3998 Revert "Bump v7.0.1"
This reverts commit 7dc858be02.
2019-10-30 17:06:52 -07:00
Electron Bot
7dc858be02 Bump v7.0.1 2019-10-30 17:05:00 -07:00
Electron Bot
7ffa127f0f Revert "Bump v7.0.1"
This reverts commit f423312090.
2019-10-30 17:01:39 -07:00
Electron Bot
f423312090 Bump v7.0.1 2019-10-30 17:00:10 -07:00
Electron Bot
4cacd15730 Revert "Bump v7.0.1"
This reverts commit 37eeaf32ad.
2019-10-30 16:45:49 -07:00
Electron Bot
37eeaf32ad Bump v7.0.1 2019-10-30 16:42:36 -07:00
trop[bot]
b97c3aca2d ci: verify CircleCI job number before returning job url (#20864) 2019-10-30 19:40:01 -04:00
Electron Bot
2e07877c28 Revert "Bump v7.0.1"
This reverts commit d8bd7654c6.
2019-10-30 16:05:51 -07:00
Electron Bot
d8bd7654c6 Bump v7.0.1 2019-10-30 16:00:48 -07:00
Electron Bot
f979e0cfbc Revert "Bump v7.0.1"
This reverts commit 1582824d33.
2019-10-30 15:59:42 -07:00
Electron Bot
1582824d33 Bump v7.0.1 2019-10-30 15:50:34 -07:00
John Kleinschmidt
71009fd61e docs: Update the sccache name (#20860)
* docs: Update the sccache name (#20462)

(cherry picked from commit b3e7657159)

* Update sccache name in circleCI
2019-10-30 18:48:55 -04:00
trop[bot]
055b5d274e build: run publish jobs in the secure context and enable sccache (#20863) 2019-10-30 18:45:47 -04:00
trop[bot]
1841742586 ci: use CircleCI 2.1 config and v2 APIs (#20852)
* ci: use circleci 2.1

* Check for pipeline status and add comments
2019-10-30 17:33:50 -04:00
Birunthan Mohanathas
3841ac9b6d fix: Disable compositor recycling only for attached views (7-0-x) (#20846)
Backport of #20829

Notes: Fix flicker when switching between `BrowserView`s
2019-10-30 16:56:49 -04:00
trop[bot]
ed1c2a47f1 build: optimize the CI path where we update the patch files (#20854)
Currently the happy checkout takes 7 minutes and the sad checkout takes
30 minutes.  This updates our CI to run checkout twice for every job to
make the sad checkout take nearer 10 minutes instead.
2019-10-30 15:43:05 -04:00
Electron Bot
bcc4f67784 chore: bump chromium to 78.0.3904.86 (7-0-x) (#20823)
* chore: bump chromium in DEPS to 78.0.3904.83

* chore: bump chromium in DEPS to 78.0.3904.86
2019-10-30 12:17:18 -04:00
Milan Burda
771d4dc374 fix: devtools extensions not loading (#20791) (#20844) 2019-10-30 11:35:50 -04:00
Milan Burda
b1fb7c7bfb fix: properly generate requestID in webContents.printToPDF() (#20769) (#20810) 2019-10-30 14:38:29 +09:00
Milan Burda
725dac35ab fix: pass frameId to v8Util.setRemoteCallbackFreer() (#20732) (#20814) 2019-10-30 14:35:37 +09:00
trop[bot]
6e32da3798 fix: prevent menu gc during popup (#20808) 2019-10-29 16:25:08 +09:00
trop[bot]
32ac551ca5 fix: deprecation warnings in Electron code (#20804) 2019-10-29 15:39:05 +09:00
trop[bot]
b90ac55d2d docs: the ipc main listener being removed can have args (#20806) 2019-10-29 15:35:06 +09:00
Electron Bot
e797639d6d chore: bump chromium to 78.0.3904.82 (7-0-x) (#20758) 2019-10-28 10:46:28 -07:00
trop[bot]
a31d041f03 docs: add the performance doc to the table of contents (#20748) 2019-10-28 10:27:35 -04:00
trop[bot]
6b70f0e8e6 docs: Performance checklist (#20757)
* docs: First draft of perf checklist

* docs: More words

* docs: Use standard in code example

* docs: fix broken link

* Update docs/tutorial/performance.md

Co-Authored-By: Charles Kerr <ckerr@github.com>

* Update docs/tutorial/performance.md

Co-Authored-By: Charles Kerr <ckerr@github.com>

* Update docs/tutorial/performance.md

Co-Authored-By: loc <andy@slack-corp.com>

* Update docs/tutorial/performance.md

Co-Authored-By: loc <andy@slack-corp.com>

* docs: Implement suggestions

* docs: Include VSCode talk

* chore: Pass linter

* Update docs/tutorial/performance.md

Co-Authored-By: Mark Lee <malept@users.noreply.github.com>

* Update docs/tutorial/performance.md

Co-Authored-By: Mark Lee <malept@users.noreply.github.com>

* Update docs/tutorial/performance.md

Co-Authored-By: Mark Lee <malept@users.noreply.github.com>

* Update docs/tutorial/performance.md

Co-Authored-By: Mark Lee <malept@users.noreply.github.com>

* Update docs/tutorial/performance.md

Co-Authored-By: Mark Lee <malept@users.noreply.github.com>

* Update docs/tutorial/performance.md

Co-Authored-By: Mark Lee <malept@users.noreply.github.com>

* Apply suggestions from code review

Co-Authored-By: Mark Lee <malept@users.noreply.github.com>

* Update performance.md

* fix: The process link
2019-10-28 09:56:55 -04:00
trop[bot]
b1357ab12b docs: fix process.getSystemVersion() type (#20768) 2019-10-27 11:21:03 -07:00
Electron Bot
ffdec7a661 chore: bump chromium to 78.0.3904.78 (7-0-x) (#20722) 2019-10-25 09:22:52 -07:00
Milan Burda
50822bc8d4 fix: send ELECTRON_BROWSER_CONTEXT_RELEASE asynchronously (#20632) (#20715) 2019-10-24 09:50:48 +09:00
trop[bot]
85164223cb chore: update build_bring_back_node_with_ltcg_configuration.patch (#20708)
* chore: update build_bring_back_node_with_ltcg_configuration.patch

set default value for node_with_ltcg=true

* fix: move ltcg definition to Release configuration
2019-10-23 17:19:16 -07:00
Jeremy Apthorp
5cb6ba2883 chore: bump chromium to 78.0.3904.68 (7-0-x) (#20643)
* chore: bump chromium to 78.0.3904.68

* update chromium patches

* explicitly cancel redirects when the mode is 'error'
2019-10-23 13:53:11 -04:00
Jeremy Apthorp
e23030b69e fix: properly free remote objects (7-0-x) (#20693) 2019-10-23 10:31:48 -07:00
trop[bot]
d417bbdcfd fix: use xib file to construct macOS Menu (#20670)
* fix: use xib file to construct macOS Menu

* add nib files back to zip manifests

* address final review comments
2019-10-22 16:48:36 +09:00
trop[bot]
e6f92f3f30 ci: add macOS debug builds (#20573)
* ci: add macOS debug builds

* Fix mac debug builds

* Fix debug build

* Update comment for desktop_capturer (from #19848)
2019-10-21 16:52:51 -04:00
Robo
3b59f12495 fix: backport libuv patch for fs.mkdir/mkdirSync on invlaid names (#20629)
Backports https://github.com/libuv/libuv/pull/2375
2019-10-21 15:43:47 -04:00
Electron Bot
3083693e67 Bump v7.0.0 2019-10-21 12:36:53 -07:00
Robo
2a2f7e7090 fix: add patch to node for native module size issue on windows (#20614) (#20626) 2019-10-18 14:40:16 -07:00
Milan Burda
f4c697d7a1 test: skip desktopCapturer / remote module tests when the features are disabled (#20576) 2019-10-16 08:09:13 -07:00
Electron Bot
944690e79b Bump v7.0.0-beta.7 2019-10-15 11:08:05 -07:00
trop[bot]
ae303ade7d spec: allow "Yu Gothic" as a Japanese sans-serif font on Windows (#20570) 2019-10-14 12:38:27 -07:00
trop[bot]
19162f4bac fix: append network switches to network service process (#20558) 2019-10-13 21:09:14 -07:00
trop[bot]
ee53f8cef6 fix: do not manually parse content-type (#20544) 2019-10-11 16:03:15 -07:00
trop[bot]
4463715714 fix: properly register custom url evt handling (#20523) 2019-10-10 23:15:53 +02:00
Milan Burda
f6894da715 fix: when building with enable_plugins=false (#20507) 2019-10-10 14:11:17 +02:00
Jaime Bernardo
1657908fa8 build: fix build with Visual Studio 2019 (7-0-x) (#20502)
* fix: build angle dependency with VS 2019

Applies upstream patch to angle, fixing build errors when building
the angle dependency with the STL shipped with Visual Studio 2019.

Can be removed after this commit comes from upstream:
755417dd79

* fix: build v8 dependency with VS 2019

Applies upstream patch to v8, fixing build errors when building
the v8 dependency with the STL shipped with Visual Studio 2019.

Can be removed after this commit comes from upstream:
53e62affd3

* fix: build perfetto dependency with VS 2019

Applies upstream patch to perfetto, fixing build errors when building
the perfetto dependency with the STL shipped with Visual Studio 2019.

Can be removed after this commit comes from upstream:
f10b2053be

* fix: build quiche dependency with VS 2019

Applies upstream patch to quiche, fixing build errors when building
the quiche dependency with the STL shipped with Visual Studio 2019.

Can be removed after this commit comes from upstream:
https://quiche.googlesource.com/quiche/+/c1e9121f16559b084bb80afc6922f0316d082160
2019-10-09 22:32:38 +02:00
Cheng Zhao
26d059b3ea fix: cookies.get should be able to filter domain (#20471) (#20496)
* fix: use GetAllCookies when url is empty

* test: get cookie without url
2019-10-09 11:32:01 -04:00
Electron Bot
49aaa2fe96 Bump v7.0.0-beta.6 2019-10-08 15:19:26 -07:00
Samuel Attard
0a9b201c34 feat: nativeTheme.themeSource and a few nativeTheme fixes (#20486)
* feat: add nativeTheme.themeSource to allow apps to override Chromiums theme choice (#19960)

* feat: add nativeTheme.shouldUseDarkColorsOverride to allow apps to override Chromiums theme choice

* spec: add tests for shouldUseDarkColorsOverride

* chore: add missing forward declarations

* refactor: rename overrideShouldUseDarkColors to themeSource

* chore: only run appLevelAppearance specs on Mojave and up

* chore: update patch with more info and no define

* Update spec-main/api-native-theme-spec.ts

Co-Authored-By: Jeremy Apthorp <jeremya@chromium.org>

* Update api-native-theme-spec.ts

* Update api-native-theme-spec.ts

* Update api-native-theme-spec.ts

* fix: don't expose nativeTheme in the renderer process (#20139)

Exposing these in the renderer didn't make sense as they weren't backed
by the same instance / value store.  This API should be browser only
especially now that we have nativeTheme.themeSource.  Exposing in
//common was a mistake from the beginning.

* fix: emit updated on NativeTheme on the UI thread to avoid DCHECK (#20137)

* fix: emit updated on NativeTheme on the UI thread to avoid DCHECK

* Update atom_api_native_theme.cc

* spec: wait a few ticks for async events to emit so that test events do not leak into each other

* chore: add SetGTKDarkThemeEnabled(enabled) internal helper to allow dynamic theme selection on linux (#19964)

This is just a after-creation setter for the `darkTheme` constructor option.  This is delibrately
a method and not a property as there is no getter.

* spec: remove leftover .only
2019-10-08 18:18:00 -04:00
Shelley Vohr
e17cd837ef fix: enable worker threads in ELECTRON_RUN_AS_NODE (#20456) 2019-10-08 15:08:46 -04:00
trop[bot]
981208b66c fix: properly free IsolateData in node_main (#20476) 2019-10-08 14:30:15 +02:00
Robo
77af675511 fix: fs.watch() behavior change in node >= 10.16.0 (#20430)
This reverts the patch from https://github.com/electron/node/pull/100
which never got merged due to reasons outlined in https://github.com/libuv/libuv/pull/2313

* Adds new patches that backports https://github.com/libuv/libuv/pull/2459
  and https://github.com/libuv/libuv/pull/2460

Based on https://github.com/nodejs/node/issues/29460
2019-10-07 13:06:08 -07:00
trop[bot]
a92ee9443d test: close window before destroying browserView (#20420) 2019-10-04 10:26:32 +02:00
trop[bot]
23a52c02a3 fix: recentDocuments menu role on macOS (#20410) 2019-10-03 09:52:24 +02:00
Milan Burda
8536f62826 fix: allow paths to asar archives to contain the .asar extension in directories (#20342) (#20401) 2019-10-02 18:03:44 +09:00
trop[bot]
312f14ee88 fix: correctly crash when there is no crashReporter (#20395)
* fix: correctly crash when there is no crashReporter

* test: correctly crash when there is crashReporter
2019-10-01 15:23:16 -04:00
Birunthan Mohanathas
1f660c67c6 fix: Make the --disable-color-correct-rendering switch work again (backport) (#20359) 2019-09-30 10:47:05 -07:00
Shelley Vohr
325bdfaf23 fix: free screen capturers after usage ends (#20280)
* fix: free screen and window capturers immediately after we're finished with them (#20156)

fix #17937, #19908

* fix: reset capturers at the very end (#20270)
2019-09-25 10:10:44 -04:00
trop[bot]
e3dcdba2db fix: correct 'Entire screen' to ' Entire Screen' (#20302) 2019-09-20 07:44:43 -07:00
John Kleinschmidt
6b5a2c550a ci: actually kill leftover processes on WOA testing (#20289)
* ci: only kill WOA processes if they are running

(cherry picked from commit 844752cd97)

* ci: actually kill leftover processes on WOA testing

(cherry picked from commit a76d2d8e53)
2019-09-19 14:34:32 -04:00
trop[bot]
21e702a563 docs: improve and add examples for clipboard (#20279)
* docs: improve and add examples for clipboard

* address feedback from jkleinsc review
2019-09-18 16:31:00 -07:00
189 changed files with 5370 additions and 1037 deletions

View File

@@ -180,7 +180,7 @@ step-setup-env-for-build: &step-setup-env-for-build
echo 'export SCCACHE_PATH="'"$SCCACHE_PATH"'"' >> $BASH_ENV
if [ "$CIRCLE_PR_NUMBER" != "" ]; then
#if building a fork set readonly access to sccache
echo 'export SCCACHE_BUCKET="electronjs-sccache"' >> $BASH_ENV
echo 'export SCCACHE_BUCKET="electronjs-sccache-ci"' >> $BASH_ENV
echo 'export SCCACHE_TWO_TIER=true' >> $BASH_ENV
fi
fi
@@ -192,6 +192,13 @@ step-restore-brew-cache: &step-restore-brew-cache
keys:
- v1-brew-cache-{{ arch }}
step-save-brew-cache: &step-save-brew-cache
save_cache:
paths:
- /usr/local/Homebrew
key: v1-brew-cache-{{ arch }}
name: Persisting brew cache
step-get-more-space-on-mac: &step-get-more-space-on-mac
run:
name: Free up space on MacOS
@@ -541,6 +548,93 @@ step-ninja-summary: &step-ninja-summary
command: |
python depot_tools/post_build_ninja_summary.py -C src/out/Default
# Checkout Steps
step-generate-deps-hash: &step-generate-deps-hash
run:
name: Generate DEPS Hash
command: node src/electron/script/generate-deps-hash.js
step-touch-sync-done: &step-touch-sync-done
run:
name: Touch Sync Done
command: touch src/electron/.circle-sync-done
# Restore exact src cache based on the hash of DEPS and patches/*
# If no cache is matched EXACTLY then the .circle-sync-done file is empty
# If a cache is matched EXACTLY then the .circle-sync-done file contains "done"
step-maybe-restore-src-cache: &step-maybe-restore-src-cache
restore_cache:
paths:
- ./src
keys:
- v5-src-cache-{{ arch }}-{{ checksum "src/electron/.depshash" }}
name: Restoring src cache
# Restore exact or closest git cache based on the hash of DEPS and .circle-sync-done
# If the src cache was restored above then this will match an empty cache
# If the src cache was not restored above then this will match a close git cache
step-maybe-restore-git-cache: &step-maybe-restore-git-cache
restore_cache:
paths:
- ~/.gclient-cache
keys:
- v2-gclient-cache-{{ arch }}-{{ checksum "src/electron/.circle-sync-done" }}-{{ checksum "src/electron/DEPS" }}
- v2-gclient-cache-{{ arch }}-{{ checksum "src/electron/.circle-sync-done" }}
name: Conditionally restoring git cache
step-set-git-cache-path: &step-set-git-cache-path
run:
name: Set GIT_CACHE_PATH to make gclient to use the cache
command: |
# CircleCI does not support interpolation when setting environment variables.
# https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-shell-command
echo 'export GIT_CACHE_PATH="$HOME/.gclient-cache"' >> $BASH_ENV
# Persist the git cache based on the hash of DEPS and .circle-sync-done
# If the src cache was restored above then this will persist an empty cache
step-save-git-cache: &step-save-git-cache
save_cache:
paths:
- ~/.gclient-cache
key: v2-gclient-cache-{{ arch }}-{{ checksum "src/electron/.circle-sync-done" }}-{{ checksum "src/electron/DEPS" }}
name: Persisting git cache
step-run-electron-only-hooks: &step-run-electron-only-hooks
run:
name: Run Electron Only Hooks
command: gclient runhooks --spec="solutions=[{'name':'src/electron','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':False},'managed':False}]"
step-generate-deps-hash-cleanly: &step-generate-deps-hash-cleanly
run:
name: Generate DEPS Hash
command: (cd src/electron && git checkout .) && node src/electron/script/generate-deps-hash.js
# Mark the sync as done for future cache saving
step-mark-sync-done: &step-mark-sync-done
run:
name: Mark Sync Done
command: echo DONE > src/electron/.circle-sync-done
# Minimize the size of the cache
step-minimize-workspace-size-from-checkout: &step-minimize-workspace-size-from-checkout
run:
name: Remove some unused data to avoid storing it in the workspace/cache
command: |
rm -rf src/android_webview
rm -rf src/ios
rm -rf src/third_party/blink/web_tests
rm -rf src/third_party/blink/perf_tests
rm -rf src/third_party/hunspell_dictionaries
rm -rf src/third_party/WebKit/LayoutTests
# Save the src cache based on the deps hash
step-save-src-cache: &step-save-src-cache
save_cache:
paths:
- ./src
key: v5-src-cache-{{ arch }}-{{ checksum "src/electron/.depshash" }}
name: Persisting src cache
# Lists of steps.
steps-lint: &steps-lint
steps:
@@ -586,7 +680,7 @@ steps-lint: &steps-lint
node script/yarn install --frozen-lockfile
node script/yarn lint
steps-checkout: &steps-checkout
steps-checkout-fast: &steps-checkout-fast
steps:
- *step-checkout-electron
- *step-depot-tools-get
@@ -595,88 +689,57 @@ steps-checkout: &steps-checkout
- *step-get-more-space-on-mac
- *step-install-gnutar-on-mac
- run:
name: Generate DEPS Hash
command: node src/electron/script/generate-deps-hash.js
- run:
name: Touch Sync Done
command: touch src/electron/.circle-sync-done
# Restore exact src cache based on the hash of DEPS and patches/*
# If no cache is matched EXACTLY then the .circle-sync-done file is empty
# If a cache is matched EXACTLY then the .circle-sync-done file contains "done"
- restore_cache:
paths:
- ./src
keys:
- v5-src-cache-{{ arch }}-{{ checksum "src/electron/.depshash" }}
name: Restoring src cache
# Restore exact or closest git cache based on the hash of DEPS and .circle-sync-done
# If the src cache was restored above then this will match an empty cache
# If the src cache was not restored above then this will match a close git cache
- restore_cache:
paths:
- ~/.gclient-cache
keys:
- v2-gclient-cache-{{ arch }}-{{ checksum "src/electron/.circle-sync-done" }}-{{ checksum "src/electron/DEPS" }}
- v2-gclient-cache-{{ arch }}-{{ checksum "src/electron/.circle-sync-done" }}
name: Conditionally restoring git cache
- run:
name: Set GIT_CACHE_PATH to make gclient to use the cache
command: |
# CircleCI does not support interpolation when setting environment variables.
# https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-shell-command
echo 'export GIT_CACHE_PATH="$HOME/.gclient-cache"' >> $BASH_ENV
- *step-generate-deps-hash
- *step-touch-sync-done
- *step-maybe-restore-src-cache
- *step-maybe-restore-git-cache
- *step-set-git-cache-path
# This sync call only runs if .circle-sync-done is an EMPTY file
- *step-gclient-sync
# Persist the git cache based on the hash of DEPS and .circle-sync-done
# If the src cache was restored above then this will persist an empty cache
- save_cache:
paths:
- ~/.gclient-cache
key: v2-gclient-cache-{{ arch }}-{{ checksum "src/electron/.circle-sync-done" }}-{{ checksum "src/electron/DEPS" }}
name: Persisting git cache
# These next few steps reset Electron to the correct commit regardless of which cache was restored
- run:
name: Wipe Electron
command: rm -rf src/electron
- *step-checkout-electron
- run:
name: Run Electron Only Hooks
command: gclient runhooks --spec="solutions=[{'name':'src/electron','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':False},'managed':False}]"
- run:
name: Generate DEPS Hash
command: (cd src/electron && git checkout .) && node src/electron/script/generate-deps-hash.js
# Mark the sync as done for future cache saving
- run:
name: Mark Sync Done
command: echo DONE > src/electron/.circle-sync-done
# Minimize the size of the cache
- run:
name: Remove some unused data to avoid storing it in the workspace/cache
command: |
rm -rf src/android_webview
rm -rf src/ios
rm -rf src/third_party/blink/web_tests
rm -rf src/third_party/blink/perf_tests
rm -rf src/third_party/hunspell_dictionaries
rm -rf src/third_party/WebKit/LayoutTests
# Save the src cache based on the deps hash
- save_cache:
paths:
- ./src
key: v5-src-cache-{{ arch }}-{{ checksum "src/electron/.depshash" }}
name: Persisting src cache
- save_cache:
paths:
- /usr/local/Homebrew
key: v1-brew-cache-{{ arch }}
name: Persisting brew cache
- *step-run-electron-only-hooks
- *step-generate-deps-hash-cleanly
- *step-mark-sync-done
- *step-minimize-workspace-size-from-checkout
- persist_to_workspace:
root: .
paths:
- depot_tools
- src
steps-checkout-and-save-cache: &steps-checkout-and-save-cache
steps:
- *step-checkout-electron
- *step-depot-tools-get
- *step-depot-tools-add-to-path
- *step-restore-brew-cache
- *step-get-more-space-on-mac
- *step-install-gnutar-on-mac
- *step-generate-deps-hash
- *step-touch-sync-done
- *step-maybe-restore-src-cache
- *step-maybe-restore-git-cache
- *step-set-git-cache-path
# This sync call only runs if .circle-sync-done is an EMPTY file
- *step-gclient-sync
- *step-save-git-cache
# These next few steps reset Electron to the correct commit regardless of which cache was restored
- run:
name: Wipe Electron
command: rm -rf src/electron
- *step-checkout-electron
- *step-run-electron-only-hooks
- *step-generate-deps-hash-cleanly
- *step-mark-sync-done
- *step-minimize-workspace-size-from-checkout
- *step-save-src-cache
- *step-save-brew-cache
steps-electron-gn-check: &steps-electron-gn-check
steps:
- attach_workspace:
@@ -713,9 +776,11 @@ steps-electron-build-for-tests: &steps-electron-build-for-tests
- *step-depot-tools-add-to-path
- *step-setup-env-for-build
- *step-restore-brew-cache
- *step-get-more-space-on-mac
- *step-install-npm-deps-on-mac
- *step-fix-sync-on-mac
- *step-gn-gen-default
- *step-delete-git-directories
# Electron app
- *step-electron-build
@@ -953,33 +1018,47 @@ jobs:
<<: *steps-lint
# Layer 1: Checkout.
linux-checkout:
linux-checkout-fast:
<<: *machine-linux-2xlarge
environment:
<<: *env-linux-2xlarge
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
<<: *steps-checkout
<<: *steps-checkout-fast
linux-checkout-and-save-cache:
<<: *machine-linux-2xlarge
environment:
<<: *env-linux-2xlarge
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
<<: *steps-checkout-and-save-cache
linux-checkout-for-native-tests:
<<: *machine-linux-2xlarge
environment:
<<: *env-linux-2xlarge
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_pyyaml=True'
<<: *steps-checkout
<<: *steps-checkout-fast
linux-checkout-for-native-tests-with-no-patches:
<<: *machine-linux-2xlarge
environment:
<<: *env-linux-2xlarge
GCLIENT_EXTRA_ARGS: '--custom-var=apply_patches=False --custom-var=checkout_pyyaml=True'
<<: *steps-checkout
<<: *steps-checkout-fast
mac-checkout:
mac-checkout-fast:
<<: *machine-linux-2xlarge
environment:
<<: *env-linux-2xlarge
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac'
<<: *steps-checkout
<<: *steps-checkout-fast
mac-checkout-and-save-cache:
<<: *machine-linux-2xlarge
environment:
<<: *env-linux-2xlarge
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac'
<<: *steps-checkout-and-save-cache
# Layer 2: Builds.
linux-x64-debug:
@@ -1228,6 +1307,15 @@ jobs:
<<: *env-ninja-status
<<: *steps-electron-build-for-tests
osx-debug:
<<: *machine-mac-large
environment:
<<: *env-mac-large
<<: *env-debug-build
<<: *env-enable-sccache
<<: *env-ninja-status
<<: *steps-electron-build-for-tests
osx-debug-gn-check:
<<: *machine-mac
environment:
@@ -1278,6 +1366,16 @@ jobs:
<<: *env-ninja-status
<<: *steps-electron-build-for-tests
mas-debug:
<<: *machine-mac-large
environment:
<<: *env-mac-large
<<: *env-mas
<<: *env-debug-build
<<: *env-enable-sccache
<<: *env-ninja-status
<<: *steps-electron-build-for-tests
mas-debug-gn-check:
<<: *machine-mac
environment:
@@ -1581,23 +1679,24 @@ workflows:
build-linux:
jobs:
- linux-checkout
- linux-checkout-fast
- linux-checkout-and-save-cache
- linux-x64-debug:
requires:
- linux-checkout
- linux-checkout-fast
- linux-x64-debug-gn-check:
requires:
- linux-checkout
- linux-checkout-fast
- linux-x64-testing:
requires:
- linux-checkout
- linux-checkout-fast
- linux-x64-testing-no-run-as-node:
requires:
- linux-checkout
- linux-checkout-fast
- linux-x64-testing-gn-check:
requires:
- linux-checkout
- linux-checkout-fast
- linux-x64-testing-tests:
requires:
- linux-x64-testing
@@ -1610,10 +1709,10 @@ workflows:
- linux-ia32-debug:
requires:
- linux-checkout
- linux-checkout-fast
- linux-ia32-testing:
requires:
- linux-checkout
- linux-checkout-fast
- linux-ia32-testing-tests:
requires:
- linux-ia32-testing
@@ -1626,37 +1725,44 @@ workflows:
- linux-arm-debug:
requires:
- linux-checkout
- linux-checkout-fast
- linux-arm-testing:
requires:
- linux-checkout
- linux-checkout-fast
- linux-arm64-debug:
requires:
- linux-checkout
- linux-checkout-fast
- linux-arm64-debug-gn-check:
requires:
- linux-checkout
- linux-checkout-fast
- linux-arm64-testing:
requires:
- linux-checkout
- linux-checkout-fast
- linux-arm64-testing-gn-check:
requires:
- linux-checkout
- linux-checkout-fast
build-mac:
jobs:
- mac-checkout
- mac-checkout-fast
- mac-checkout-and-save-cache
- osx-testing:
requires:
- mac-checkout
- mac-checkout-fast
- osx-debug:
requires:
- mac-checkout-fast
- osx-debug-gn-check:
requires:
- mac-checkout
- mac-checkout-fast
- osx-testing-gn-check:
requires:
- mac-checkout
- mac-checkout-fast
- osx-testing-tests:
requires:
@@ -1664,14 +1770,19 @@ workflows:
- mas-testing:
requires:
- mac-checkout
- mac-checkout-fast
- mas-debug:
requires:
- mac-checkout-fast
- mas-debug-gn-check:
requires:
- mac-checkout
- mac-checkout-fast
- mas-testing-gn-check:
requires:
- mac-checkout
- mac-checkout-fast
- mas-testing-tests:
requires:

View File

@@ -26,6 +26,7 @@ if (is_mac) {
import("//third_party/icu/config.gni")
import("//ui/gl/features.gni")
import("//v8/gni/v8.gni")
import("build/rules.gni")
}
if (is_linux) {
@@ -580,9 +581,10 @@ source_set("electron_lib") {
}
if (enable_desktop_capturer) {
if (is_component_build && is_win) {
if (is_component_build && !is_linux) {
# On windows the implementation relies on unexported
# DxgiDuplicatorController class.
# DxgiDuplicatorController class. On macOS the implementation
# relies on unexported webrtc::GetWindowOwnerPid method.
deps += [ "//third_party/webrtc/modules/desktop_capture" ]
}
sources += [
@@ -654,6 +656,12 @@ if (is_mac) {
electron_framework_version = "A"
electron_version = read_file("ELECTRON_VERSION", "trim string")
mac_xib_bundle_data("electron_xibs") {
sources = [
"shell/common/resources/mac/MainMenu.xib",
]
}
bundle_data("electron_framework_resources") {
public_deps = [
":packed_resources",
@@ -768,6 +776,7 @@ if (is_mac) {
":electron_framework_libraries",
":electron_framework_resources",
":electron_swiftshader_library",
":electron_xibs",
]
if (!is_mas_build) {
deps += [ ":electron_crashpad_helper" ]

2
DEPS
View File

@@ -11,7 +11,7 @@ gclient_gn_args = [
vars = {
'chromium_version':
'78.0.3905.1',
'78.0.3904.99',
'node_version':
'v12.8.1',
'nan_version':

View File

@@ -1 +1 @@
7.0.0-beta.5
7.1.1

View File

@@ -77,8 +77,8 @@ steps:
python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg
displayName: 'Verify ffmpeg'
- script: |
taskkill /F /IM electron.exe
taskkill /F /IM MicrosoftEdge.exe
- powershell: |
Get-Process | Where Name Like "electron*" | Stop-Process
Get-Process | Where Name Like "MicrosoftEdge*" | Stop-Process
displayName: 'Kill processes left running from last test run'
condition: always()

57
build/rules.gni Normal file
View File

@@ -0,0 +1,57 @@
import("//build/config/mac/mac_sdk.gni")
# This is imported from /ios becuase this functionality was moved
# after Chromium stopped using xib files for macOS menu functionality
# See https://chromium-review.googlesource.com/c/chromium/src/+/1648695
import("//build/config/ios/rules.gni")
# Template is copied here from Chromium but was removed in
# https://chromium-review.googlesource.com/c/chromium/src/+/1637981
# Template to compile and package Mac XIB files as bundle data.
# Arguments
# sources:
# list of string, sources to comiple
# output_path:
# (optional) string, the path to use for the outputs list in the
# bundle_data step. If unspecified, defaults to bundle_resources_dir.
template("mac_xib_bundle_data") {
_target_name = target_name
_compile_target_name = _target_name + "_compile_ibtool"
compile_ib_files(_compile_target_name) {
forward_variables_from(invoker, [ "testonly" ])
visibility = [ ":$_target_name" ]
sources = invoker.sources
output_extension = "nib"
ibtool_flags = [
"--minimum-deployment-target",
mac_deployment_target,
# TODO(rsesek): Enable this once all the bots are on Xcode 7+.
# "--target-device",
# "mac",
]
}
bundle_data(_target_name) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
public_deps = [
":$_compile_target_name",
]
sources = get_target_outputs(":$_compile_target_name")
_output_path = "{{bundle_resources_dir}}"
if (defined(invoker.output_path)) {
_output_path = invoker.output_path
}
outputs = [
"$_output_path/{{source_file_part}}",
]
}
}

View File

@@ -74,7 +74,10 @@ module.exports = ({
global: ['@electron/internal/renderer/webpack-provider', '_global'],
Buffer: ['@electron/internal/renderer/webpack-provider', 'Buffer'],
})
] : [])
] : []),
new webpack.ProvidePlugin({
Promise: ['@electron/internal/common/webpack-globals-provider', 'Promise'],
}),
]
})
}
}

View File

@@ -43,8 +43,6 @@ static_library("chrome") {
"//chrome/browser/predictors/proxy_lookup_client_impl.h",
"//chrome/browser/predictors/resolve_host_client_impl.cc",
"//chrome/browser/predictors/resolve_host_client_impl.h",
"//chrome/browser/printing/printing_service.cc",
"//chrome/browser/printing/printing_service.h",
"//chrome/browser/ssl/security_state_tab_helper.cc",
"//chrome/browser/ssl/security_state_tab_helper.h",
"//chrome/browser/ui/autofill/popup_view_common.cc",
@@ -164,6 +162,8 @@ static_library("chrome") {
"//chrome/browser/printing/printer_query.h",
"//chrome/browser/printing/printing_message_filter.cc",
"//chrome/browser/printing/printing_message_filter.h",
"//chrome/browser/printing/printing_service.cc",
"//chrome/browser/printing/printing_service.h",
]
public_deps += [

View File

@@ -54,6 +54,7 @@ component("pepper_flash") {
"//chrome/browser/renderer_host/pepper/monitor_finder_mac.h",
"//chrome/browser/renderer_host/pepper/monitor_finder_mac.mm",
]
libs = [ "CoreGraphics.framework" ]
}
if (is_linux) {
deps += [ "//components/services/font/public/cpp" ]

View File

@@ -2,10 +2,9 @@
<head>
<title>Electron</title>
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self'; connect-src 'self'" />
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-6PH54BfkNq/EMMhUY7nhHf3c+AxloOwfy7hWyT01CM8='; style-src 'self'; img-src 'self'; connect-src 'self'" />
<link href="./styles.css" type="text/css" rel="stylesheet" />
<link href="./octicon/build.css" type="text/css" rel="stylesheet" />
<script defer src="./index.js"></script>
</head>
<body>
@@ -84,6 +83,9 @@
</div>
</div>
</nav>
<script>
window.electronDefaultApp.initialize()
</script>
</body>
</html>

View File

@@ -1,30 +0,0 @@
async function getOcticonSvg (name: string) {
try {
const response = await fetch(`octicon/${name}.svg`)
const div = document.createElement('div')
div.innerHTML = await response.text()
return div
} catch {
return null
}
}
async function loadSVG (element: HTMLSpanElement) {
for (const cssClass of element.classList) {
if (cssClass.startsWith('octicon-')) {
const icon = await getOcticonSvg(cssClass.substr(8))
if (icon) {
for (const elemClass of element.classList) {
icon.classList.add(elemClass)
}
element.before(icon)
element.remove()
break
}
}
}
}
for (const element of document.querySelectorAll<HTMLSpanElement>('.octicon')) {
loadSVG(element)
}

View File

@@ -1,4 +1,31 @@
import { ipcRenderer } from 'electron'
import { ipcRenderer, contextBridge } from 'electron'
async function getOcticonSvg (name: string) {
try {
const response = await fetch(`octicon/${name}.svg`)
const div = document.createElement('div')
div.innerHTML = await response.text()
return div
} catch {
return null
}
}
async function loadSVG (element: HTMLSpanElement) {
for (const cssClass of element.classList) {
if (cssClass.startsWith('octicon-')) {
const icon = await getOcticonSvg(cssClass.substr(8))
if (icon) {
for (const elemClass of element.classList) {
icon.classList.add(elemClass)
}
element.before(icon)
element.remove()
break
}
}
}
}
async function initialize () {
const electronPath = await ipcRenderer.invoke('bootstrap')
@@ -15,6 +42,12 @@ async function initialize () {
replaceText('.node-version', `Node v${process.versions.node}`)
replaceText('.v8-version', `v8 v${process.versions.v8}`)
replaceText('.command-example', `${electronPath} path-to-app`)
for (const element of document.querySelectorAll<HTMLSpanElement>('.octicon')) {
loadSVG(element)
}
}
document.addEventListener('DOMContentLoaded', initialize)
contextBridge.exposeInMainWorld('electronDefaultApp', {
initialize
})

View File

@@ -39,6 +39,7 @@ an issue:
* [Using Electron's APIs](tutorial/application-architecture.md#using-electron-apis)
* [Using Node.js APIs](tutorial/application-architecture.md#using-nodejs-apis)
* [Using Native Node.js Modules](tutorial/using-native-node-modules.md)
* [Performance Strategies](tutorial/performance.md)
* Adding Features to Your App
* [Notifications](tutorial/notifications.md)
* [Recent Documents](tutorial/recent-documents.md)

View File

@@ -1553,7 +1553,7 @@ Same as `webContents.showDefinitionForSelection()`.
#### `win.setIcon(icon)` _Windows_ _Linux_
* `icon` [NativeImage](native-image.md)
* `icon` [NativeImage](native-image.md) | String
Changes window icon.

View File

@@ -4,18 +4,12 @@
Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process)
The following example shows how to write a string to the clipboard:
```javascript
const { clipboard } = require('electron')
clipboard.writeText('Example String')
```
On Linux, there is also a `selection` clipboard. To manipulate it
you need to pass `selection` to each method:
```javascript
const { clipboard } = require('electron')
clipboard.writeText('Example String', 'selection')
console.log(clipboard.readText('selection'))
```
@@ -28,56 +22,106 @@ The `clipboard` module has the following methods:
### `clipboard.readText([type])`
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
Returns `String` - The content in the clipboard as plain text.
```js
const { clipboard } = require('electron')
clipboard.writeText('hello i am a bit of text!')
const text = clipboard.readText()
console.log(text)
// hello i am a bit of text!'
```
### `clipboard.writeText(text[, type])`
* `text` String
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
Writes the `text` into the clipboard as plain text.
```js
const { clipboard } = require('electron')
const text = 'hello i am a bit of text!'
clipboard.writeText(text)
```
### `clipboard.readHTML([type])`
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
Returns `String` - The content in the clipboard as markup.
```js
const { clipboard } = require('electron')
clipboard.writeHTML('<b>Hi</b>')
const html = clipboard.readHTML()
console.log(html)
// <meta charset='utf-8'><b>Hi</b>
```
### `clipboard.writeHTML(markup[, type])`
* `markup` String
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
Writes `markup` to the clipboard.
```js
const { clipboard } = require('electron')
clipboard.writeHTML('<b>Hi</b')
```
### `clipboard.readImage([type])`
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
Returns [`NativeImage`](native-image.md) - The image content in the clipboard.
### `clipboard.writeImage(image[, type])`
* `image` [NativeImage](native-image.md)
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
Writes `image` to the clipboard.
### `clipboard.readRTF([type])`
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
Returns `String` - The content in the clipboard as RTF.
```js
const { clipboard } = require('electron')
clipboard.writeRTF('{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\nThis is some {\\b bold} text.\\par\n}')
const rtf = clipboard.readRTF()
console.log(rtf)
// {\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\nThis is some {\\b bold} text.\\par\n}
```
### `clipboard.writeRTF(text[, type])`
* `text` String
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
Writes the `text` into the clipboard in RTF.
```js
const { clipboard } = require('electron')
const rtf = '{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\nThis is some {\\b bold} text.\\par\n}'
clipboard.writeRTF(rtf)
```
### `clipboard.readBookmark()` _macOS_ _Windows_
Returns `Object`:
@@ -93,7 +137,7 @@ bookmark is unavailable.
* `title` String
* `url` String
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
Writes the `title` and `url` into the clipboard as a bookmark.
@@ -102,7 +146,9 @@ you can use `clipboard.write` to write both a bookmark and fallback text to the
clipboard.
```js
clipboard.write({
const { clipboard } = require('electron')
clipboard.writeBookmark({
text: 'https://electronjs.org',
bookmark: 'Electron Homepage'
})
@@ -110,39 +156,50 @@ clipboard.write({
### `clipboard.readFindText()` _macOS_
Returns `String` - The text on the find pasteboard. This method uses synchronous
IPC when called from the renderer process. The cached value is reread from the
find pasteboard whenever the application is activated.
Returns `String` - The text on the find pasteboard, which is the pasteboard that holds information about the current state of the active applications find panel.
This method uses synchronous IPC when called from the renderer process.
The cached value is reread from the find pasteboard whenever the application is activated.
### `clipboard.writeFindText(text)` _macOS_
* `text` String
Writes the `text` into the find pasteboard as plain text. This method uses
synchronous IPC when called from the renderer process.
Writes the `text` into the find pasteboard (the pasteboard that holds information about the current state of the active applications find panel) as plain text. This method uses synchronous IPC when called from the renderer process.
### `clipboard.clear([type])`
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
Clears the clipboard content.
### `clipboard.availableFormats([type])`
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
Returns `String[]` - An array of supported formats for the clipboard `type`.
```js
const { clipboard } = require('electron')
const formats = clipboard.availableFormats()
console.log(formats)
// [ 'text/plain', 'text/html' ]
```
### `clipboard.has(format[, type])` _Experimental_
* `format` String
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
Returns `Boolean` - Whether the clipboard supports the specified `format`.
```javascript
```js
const { clipboard } = require('electron')
console.log(clipboard.has('<p>selection</p>'))
const hasFormat = clipboard.has('<p>selection</p>')
console.log(hasFormat)
// 'true' or 'false
```
### `clipboard.read(format)` _Experimental_
@@ -157,14 +214,33 @@ Returns `String` - Reads `format` type from the clipboard.
Returns `Buffer` - Reads `format` type from the clipboard.
```js
const { clipboard } = require('electron')
const buffer = Buffer.from('this is binary', 'utf8')
clipboard.writeBuffer('public.utf8-plain-text', buffer)
const ret = clipboard.readBuffer('public.utf8-plain-text')
console.log(buffer.equals(out))
// true
```
### `clipboard.writeBuffer(format, buffer[, type])` _Experimental_
* `format` String
* `buffer` Buffer
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
Writes the `buffer` into the clipboard as `format`.
```js
const { clipboard } = require('electron')
const buffer = Buffer.from('writeBuffer', 'utf8')
clipboard.writeBuffer('public.utf8-plain-text', buffer)
```
### `clipboard.write(data[, type])`
* `data` Object
@@ -173,10 +249,29 @@ Writes the `buffer` into the clipboard as `format`.
* `image` [NativeImage](native-image.md) (optional)
* `rtf` String (optional)
* `bookmark` String (optional) - The title of the URL at `text`.
* `type` String (optional) - Can be `selection` or `clipboard`. `selection` is only available on Linux.
* `type` String (optional) - Can be `selection` or `clipboard`; default is 'clipboard'. `selection` is only available on Linux.
```javascript
const { clipboard } = require('electron')
clipboard.write({ text: 'test', html: '<b>test</b>' })
```
Writes `data` to the clipboard.
```js
const { clipboard } = require('electron')
clipboard.write({
text: 'test',
html: '<b>Hi</b>',
rtf: '{\\rtf1\\utf8 text}',
bookmark: 'a title'
})
console.log(clipboard.readText())
// 'test'
console.log(clipboard.readHTML())
// <meta charset='utf-8'><b>Hi</b>
console.log(clipboard.readRTF())
// '{\\rtf1\\utf8 text}'
console.log(clipboard.readBookmark())
// { title: 'a title', url: 'test' }
```

111
docs/api/context-bridge.md Normal file
View File

@@ -0,0 +1,111 @@
# contextBridge
> Create a safe, bi-directional, synchronous bridge across isolated contexts
Process: [Renderer](../glossary.md#renderer-process)
An example of exposing an API to a renderer from an isolated preload script is given below:
```javascript
// Preload (Isolated World)
const { contextBridge, ipcRenderer } = require('electron')
contextBridge.exposeInMainWorld(
'electron',
{
doThing: () => ipcRenderer.send('do-a-thing')
}
)
```
```javascript
// Renderer (Main World)
window.electron.doThing()
```
## Glossary
### Main World
The "Main World" is the javascript context that your main renderer code runs in. By default the page you load in your renderer
executes code in this world.
### Isolated World
When `contextIsolation` is enabled in your `webPreferences` your `preload` scripts run in an "Isolated World". You can read more about
context isolation and what it affects in the [BrowserWindow](browser-window.md) docs.
## Methods
The `contextBridge` module has the following methods:
### `contextBridge.exposeInMainWorld(apiKey, api)` _Experimental_
* `apiKey` String - The key to inject the API onto `window` with. The API will be accessible on `window[apiKey]`.
* `api` Record<String, any> - Your API object, more information on what this API can be and how it works is available below.
## Usage
### API Objects
The `api` object provided to [`exposeInMainWorld`](#contextbridgeexposeinmainworldapikey-api-experimental) must be an object
whose keys are strings and values are a `Function`, `String`, `Number`, `Array`, `Boolean` or another nested object that meets the same conditions.
`Function` values are proxied to the other context and all other values are **copied** and **frozen**. I.e. Any data / primitives sent in
the API object become immutable and updates on either side of the bridge do not result in an update on the other side.
An example of a complex API object is shown below.
```javascript
const { contextBridge } = require('electron')
contextBridge.exposeInMainWorld(
'electron',
{
doThing: () => ipcRenderer.send('do-a-thing'),
myPromises: [Promise.resolve(), Promise.reject(new Error('whoops'))],
anAsyncFunction: async () => 123,
data: {
myFlags: ['a', 'b', 'c'],
bootTime: 1234
},
nestedAPI: {
evenDeeper: {
youCanDoThisAsMuchAsYouWant: {
fn: () => ({
returnData: 123
})
}
}
}
}
)
```
### API Functions
`Function` values that you bind through the `contextBridge` are proxied through Electron to ensure that contexts remain isolated. This
results in some key limitations that we've outlined below.
#### Parameter / Error / Return Type support
Because parameters, errors and return values are **copied** when they are sent over the bridge there are only certain types that can be used.
At a high level if the type you want to use can be serialized and un-serialized into the same object it will work. A table of type support
has been included below for completeness.
| Type | Complexity | Parameter Support | Return Value Support | Limitations |
| ---- | ---------- | ----------------- | -------------------- | ----------- |
| `String` | Simple | ✅ | ✅ | N/A |
| `Number` | Simple | ✅ | ✅ | N/A |
| `Boolean` | Simple | ✅ | ✅ | N/A |
| `Object` | Complex | ✅ | ✅ | Keys must be supported "Simple" types in this table. Values must be supported in this table. Prototype modifications are dropped. Sending custom classes will copy values but not the prototype. |
| `Array` | Complex | ✅ | ✅ | Same limitations as the `Object` type |
| `Error` | Complex | ✅ | ✅ | Errors that are thrown are also copied, this can result in the message and stack trace of the error changing slightly due to being thrown in a different context |
| `Promise` | Complex | ✅ | ✅ | Promises are only proxied if they are a the return value or exact parameter. Promises nested in arrays or obejcts will be dropped. |
| `Function` | Complex | ✅ | ✅ | Prototype modifications are dropped. Sending classes or constructors will not work. |
| [Cloneable Types](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm) | Simple | ✅ | ✅ | See the linked document on cloneable types |
| `Symbol` | N/A | ❌ | ❌ | Symbols cannot be copied across contexts so they are dropped |
If the type you care about is not in the above table it is probably not supported.

View File

@@ -77,6 +77,7 @@ only the next time a message is sent to `channel`, after which it is removed.
* `channel` String
* `listener` Function
* `...args` any[]
Removes the specified `listener` from the listener array for the specified
`channel`.

View File

@@ -2,7 +2,7 @@
> Read and respond to changes in Chromium's native color theme.
Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process)
Process: [Main](../glossary.md#main-process)
## Events
@@ -22,7 +22,38 @@ The `nativeTheme` module has the following properties:
### `nativeTheme.shouldUseDarkColors` _Readonly_
A `Boolean` for if the OS / Chromium currently has a dark mode enabled or is
being instructed to show a dark-style UI.
being instructed to show a dark-style UI. If you want to modify this value you
should use `themeSource` below.
### `nativeTheme.themeSource`
A `String` property that can be `system`, `light` or `dark`. It is used to override and supercede
the value that Chromium has chosen to use internally.
Setting this property to `system` will remove the override and
everything will be reset to the OS default. By default `themeSource` is `system`.
Settings this property to `dark` will have the following effects:
* `nativeTheme.shouldUseDarkColors` will be `true` when accessed
* Any UI Electron renders on Linux and Windows including context menus, devtools, etc. will use the dark UI.
* Any UI the OS renders on macOS including menus, window frames, etc. will use the dark UI.
* The [`prefers-color-scheme`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) CSS query will match `dark` mode.
* The `updated` event will be emitted
Settings this property to `light` will have the following effects:
* `nativeTheme.shouldUseDarkColors` will be `false` when accessed
* Any UI Electron renders on Linux and Windows including context menus, devtools, etc. will use the light UI.
* Any UI the OS renders on macOS including menus, window frames, etc. will use the light UI.
* The [`prefers-color-scheme`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) CSS query will match `light` mode.
* The `updated` event will be emitted
The usage of this property should align with a classic "dark mode" state machine in your application
where the user has three options.
* `Follow OS` --> `themeSource = 'system'`
* `Dark Mode` --> `themeSource = 'dark'`
* `Light Mode` --> `themeSource = 'light'`
Your application should then always use `shouldUseDarkColors` to determine what CSS to apply.
### `nativeTheme.shouldUseHighContrastColors` _macOS_ _Windows_ _Readonly_

View File

@@ -217,11 +217,15 @@ that all statistics are reported in Kilobytes.
Returns `String` - The version of the host operating system.
Examples:
Example:
* `macOS` -> `10.13.6`
* `Windows` -> `10.0.17763`
* `Linux` -> `4.15.0-45-generic`
```js
const version = process.getSystemVersion()
console.log(version)
// On macOS -> '10.13.6'
// On Windows -> '10.0.17763'
// On Linux -> '4.15.0-45-generic'
```
**Note:** It returns the actual operating system version instead of kernel version on macOS unlike `os.release()`.

View File

@@ -389,9 +389,7 @@ which sends a `Buffer` as a response.
* `url` String
* `method` String (optional)
* `session` Session | null (optional)
* `uploadData` Object (optional)
* `contentType` String - MIME type of the content.
* `data` String - Content to be sent.
* `uploadData` [ProtocolResponseUploadData](structures/protocol-response-upload-data.md) (optional)
* `completion` Function (optional)
* `error` Error

View File

@@ -1,4 +1,4 @@
# ProtocolResponseUploadData Object
* `contentType` String - MIME type of the content.
* `data` String - Content to be sent.
* `data` String | Buffer - Content to be sent.

View File

@@ -101,14 +101,14 @@ Some examples of valid `urls`:
* `callback` Function
* `response` Object
* `cancel` Boolean (optional)
* `requestHeaders` Record<string, string> (optional) - When provided, request will be made
* `requestHeaders` Record<string, string | string[]> (optional) - When provided, request will be made
with these headers.
The `listener` will be called with `listener(details, callback)` before sending
an HTTP request, once the request headers are available. This may occur after a
TCP connection is made to the server, but before any http data is sent.
The `callback` has to be called with an `response` object.
The `callback` has to be called with a `response` object.
#### `webRequest.onSendHeaders([filter, ]listener)`
@@ -150,7 +150,7 @@ response are visible by the time this listener is fired.
* `callback` Function
* `response` Object
* `cancel` Boolean (optional)
* `responseHeaders` Record<string, string> (optional) - When provided, the server is assumed
* `responseHeaders` Record<string, string | string[]> (optional) - When provided, the server is assumed
to have responded with these headers.
* `statusLine` String (optional) - Should be provided when overriding
`responseHeaders` to change header status otherwise original response
@@ -159,7 +159,7 @@ response are visible by the time this listener is fired.
The `listener` will be called with `listener(details, callback)` when HTTP
response headers of a request have been received.
The `callback` has to be called with an `response` object.
The `callback` has to be called with a `response` object.
#### `webRequest.onResponseStarted([filter, ]listener)`
@@ -201,6 +201,7 @@ and response headers are available.
* `timestamp` Double
* `redirectURL` String
* `statusCode` Integer
* `statusLine` String
* `ip` String (optional) - The server IP address that the request was
actually sent to.
* `fromCache` Boolean

View File

@@ -46,7 +46,7 @@ You can avoid much of the wait by reusing Electron CI's build output via
optional steps (listed below) and these two environment variables:
```sh
export SCCACHE_BUCKET="electronjs-sccache"
export SCCACHE_BUCKET="electronjs-sccache-ci"
export SCCACHE_TWO_TIER=true
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@@ -38,11 +38,15 @@ npm install --platform=win32 electron
## Proxies
If you need to use an HTTP proxy you can [set these environment variables][proxy-env].
If you need to use an HTTP proxy, you need to set the `ELECTRON_GET_USE_PROXY` variable to any
value, plus additional environment variables depending on your host system's Node version:
* [Node 10 and above][proxy-env-10]
* [Before Node 10][proxy-env]
## Custom Mirrors and Caches
During installation, the `electron` module will call out to
[`electron-download`][electron-download] to download prebuilt binaries of
[`@electron/get`][electron-get] to download prebuilt binaries of
Electron for your platform. It will do so by contacting GitHub's
release download page (`https://github.com/electron/electron/releases/tag/v$VERSION`,
where `$VERSION` is the exact version of Electron).
@@ -146,7 +150,8 @@ If you need to force a re-download of the asset and the SHASUM file set the
[npm]: https://docs.npmjs.com
[versioning]: ./electron-versioning.md
[releases]: https://github.com/electron/electron/releases
[proxy-env]: https://github.com/request/request/tree/f0c4ec061141051988d1216c24936ad2e7d5c45d#controlling-proxy-behaviour-using-environment-variables
[electron-download]: https://github.com/electron-userland/electron-download
[proxy-env-10]: https://github.com/gajus/global-agent/blob/v2.1.5/README.md#environment-variables
[proxy-env]: https://github.com/np-maintain/global-tunnel/blob/v2.7.1/README.md#auto-config
[electron-get]: https://github.com/electron/get
[npm-permissions]: https://docs.npmjs.com/getting-started/fixing-npm-permissions
[unsafe-perm]: https://docs.npmjs.com/misc/config#unsafe-perm

View File

@@ -0,0 +1,431 @@
# Performance
Developers frequently ask about strategies to optimize the performance of
Electron applications. Software engineers, consumers, and framework developers
do not always agree on one single definition of what "performance" means. This
document outlines some of the Electron maintainers' favorite ways to reduce the
amount of memory, CPU, and disk resources being used while ensuring that your
app is responsive to user input and completes operations as quickly as
possible. Furthermore, we want all performance strategies to maintain a high
standard for your app's security.
Wisdom and information about how to build performant websites with JavaScript
generally applies to Electron apps, too. To a certain extent, resources
discussing how to build performant Node.js applications also apply, but be
careful to understand that the term "performance" means different things for
a Node.js backend than it does for an application running on a client.
This list is provided for your convenience and is, much like our
[security checklist][security] not meant to exhaustive. It is probably possible
to build a slow Electron app that follows all the steps outlined below. Electron
is a powerful development platform that enables you, the developer, to do more
or less whatever you want. All that freedom means that performance is largely
your responsibility.
## Measure, Measure, Measure
The list below contains a number of steps that are fairly straightforward and
easy to implement. However, building the most performant version of your app
will require you to go beyond a number of steps. Instead, you will have to
closely examine all the code running in your app by carefully profiling and
measuring. Where are the bottlenecks? When the user clicks a button, what
operations take up the brunt of the time? While the app is simply idling, which
objects take up the most memory?
Time and time again, we have seen that the most successful strategy for building
a performant Electron app is to profile the running code, find the most
resource-hungry piece of it, and to optimize it. Repeating this seemingly
laborious process over and over again will dramatically increase your app's
performance. Experience from working with major apps like Visual Studio Code or
Slack has shown that this practice is by far the most reliable strategy to
improve performance.
To learn more about how to profile your app's code, familiarize yourself with
the Chrome Developer Tools. For advanced analysis looking at multiple processes
at once, consider the [Chrome Tracing] tool.
### Recommended Reading
* [Get Started With Analyzing Runtime Performance][chrome-devtools-tutorial]
* [Talk: "Visual Studio Code - The First Second"][vscode-first-second]
## Checklist
Chances are that your app could be a little leaner, faster, and generally less
resource-hungry if you attempt these steps.
1. [Carelessly including modules](#1-carelessly-including-modules)
2. [Loading and running code too soon](#2-loading-and-running-code-too-soon)
3. [Blocking the main process](#3-blocking-the-main-process)
4. [Blocking the renderer process](#4-blocking-the-renderer-process)
5. [Unnecessary polyfills](#5-unnecessary-polyfills)
6. [Unnecessary or blocking network requests](#6-unnecessary-or-blocking-network-requests)
7. [Bundle your code](#7-bundle-your-code)
## 1) Carelessly including modules
Before adding a Node.js module to your application, examine said module. How
many dependencies does that module include? What kind of resources does
it need to simply be called in a `require()` statement? You might find
that the module with the most downloads on the NPM package registry or the most stars on GitHub
is not in fact the leanest or smallest one available.
### Why?
The reasoning behind this recommendation is best illustrated with a real-world
example. During the early days of Electron, reliable detection of network
connectivity was a problem, resulting many apps to use a module that exposed a
simple `isOnline()` method.
That module detected your network connectivity by attempting to reach out to a
number of well-known endpoints. For the list of those endpoints, it depended on
a different module, which also contained a list of well-known ports. This
dependency itself relied on a module containing information about ports, which
came in the form of a JSON file with more than 100,000 lines of content.
Whenever the module was loaded (usually in a `require('module')` statement),
it would load all its dependencies and eventually read and parse this JSON
file. Parsing many thousands lines of JSON is a very expensive operation. On
a slow machine it can take up whole seconds of time.
In many server contexts, startup time is virtually irrelevant. A Node.js server
that requires information about all ports is likely actually "more performant"
if it loads all required information into memory whenever the server boots at
the benefit of serving requests faster. The module discussed in this example is
not a "bad" module. Electron apps, however, should not be loading, parsing, and
storing in memory information that it does not actually need.
In short, a seemingly excellent module written primarily for Node.js servers
running Linux might be bad news for your app's performance. In this particular
example, the correct solution was to use no module at all, and to instead use
connectivity checks included in later versions of Chromium.
### How?
When considering a module, we recommend that you check:
1. the size of dependencies included
2) the resources required to load (`require()`) it
3. the resources required to perform the action you're interested in
Generating a CPU profile and a heap memory profile for loading a module can be done
with a single command on the command line. In the example below, we're looking at
the popular module `request`.
```sh
node --cpu-prof --heap-prof -e "require('request')"
```
Executing this command results in a `.cpuprofile` file and a `.heapprofile`
file in the directory you executed it in. Both files can be analyzed using
the Chrome Developer Tools, using the `Performance` and `Memory` tabs
respectively.
![performance-cpu-prof]
![performance-heap-prof]
In this example, on the author's machine, we saw that loading `request` took
almost half a second, whereas `node-fetch` took dramatically less memory
and less than 50ms.
## 2) Loading and running code too soon
If you have expensive setup operations, consider deferring those. Inspect all
the work being executed right after the application starts. Instead of firing
off all operations right away, consider staggering them in a sequence more
closely aligned with the user's journey.
In traditional Node.js development, we're used to putting all our `require()`
statements at the top. If you're currently writing your Electron application
using the same strategy _and_ are using sizable modules that you do not
immediately need, apply the same strategy and defer loading to a more
opportune time.
### Why?
Loading modules is a surprisingly expensive operation, especially on Windows.
When your app starts, it should not make users wait for operations that are
currently not necessary.
This might seem obvious, but many applications tend to do a large amount of
work immediately after the app has launched - like checking for updates,
downloading content used in a later flow, or performing heavy disk I/O
operations.
Let's consider Visual Studio Code as an example. When you open a file, it will
immediately display the file to you without any code highlighting, prioritizing
your ability to interact with the text. Once it has done that work, it will
move on to code highlighting.
### How?
Let's consider an example and assume that your application is parsing files
in the fictitious `.foo` format. In order to do that, it relies on the
equally fictitious `foo-parser` module. In traditional Node.js development,
you might write code that eagerly loads dependencies:
```js
const fs = require('fs')
const fooParser = require('foo-parser')
class Parser {
constructor () {
this.files = fs.readdirSync('.')
}
getParsedFiles () {
return fooParser.parse(this.files)
}
}
const parser = new Parser()
module.exports = { parser }
```
In the above example, we're doing a lot of work that's being executed as soon
as the file is loaded. Do we need to get parsed files right away? Could we
do this work a little later, when `getParsedFiles()` is actually called?
```js
// "fs" is likely already being loaded, so the `require()` call is cheap
const fs = require('fs')
class Parser {
async getFiles () {
// Touch the disk as soon as `getFiles` is called, not sooner.
// Also, ensure that we're not blocking other operations by using
// the asynchronous version.
this.files = this.files || await fs.readdir('.')
return this.files
}
async getParsedFiles () {
// Our fictitious foo-parser is a big and expensive module to load, so
// defer that work until we actually need to parse files.
// Since `require()` comes with a module cache, the `require()` call
// will only be expensive once - subsequent calls of `getParsedFiles()`
// will be faster.
const fooParser = require('foo-parser')
const files = await this.getFiles()
return fooParser.parse(files)
}
}
// This operation is now a lot cheaper than in our previous example
const parser = new Parser()
module.exports = { parser }
```
In short, allocate resources "just in time" rather than allocating them all
when your app starts.
## 3) Blocking the main process
Electron's main process (sometimes called "browser process") is special: It is
the parent process to all your app's other processes and the primary process
the operating system interacts with. It handles windows, interactions, and the
communication between various components inside your app. It also houses the
UI thread.
Under no circumstances should you block this process and the UI thread with
long-running operations. Blocking the UI thread means that your entire app
will freeze until the main process is ready to continue processing.
### Why?
The main process and its UI thread are essentially the control tower for major
operations inside your app. When the operating system tells your app about a
mouse click, it'll go through the main process before it reaches your window.
If your window is rendering a buttery-smooth animation, it'll need to talk to
the GPU process about that once again going through the main process.
Electron and Chromium are careful to put heavy disk I/O and CPU-bound operations
onto new threads to avoid blocking the UI thread. You should do the same.
### How?
Electron's powerful multi-process architecture stands ready to assist you with
your long-running tasks, but also includes a small number of performance traps.
1) For long running CPU-heavy tasks, make use of
[worker threads][worker-threads], consider moving them to the BrowserWindow, or
(as a last resort) spawn a dedicated process.
2) Avoid using the synchronous IPC and the `remote` module as much as possible.
While there are legitimate use cases, it is far too easy to unknowingly block
the UI thread using the `remote` module.
3) Avoid using blocking I/O operations in the main process. In short, whenever
core Node.js modules (like `fs` or `child_process`) offer a synchronous or an
asynchronous version, you should prefer the asynchronous and non-blocking
variant.
## 4) Blocking the renderer process
Since Electron ships with a current version of Chrome, you can make use of the
latest and greatest features the Web Platform offers to defer or offload heavy
operations in a way that keeps your app smooth and responsive.
### Why?
Your app probably has a lot of JavaScript to run in the renderer process. The
trick is to execute operations as quickly as possible without taking away
resources needed to keep scrolling smooth, respond to user input, or animations
at 60fps.
Orchestrating the flow of operations in your renderer's code is
particularly useful if users complain about your app sometimes "stuttering".
### How?
Generally speaking, all advice for building performant web apps for modern
browsers apply to Electron's renderers, too. The two primary tools at your
disposal are currently `requestIdleCallback()` for small operations and
`Web Workers` for long-running operations.
*`requestIdleCallback()`* allows developers to queue up a function to be
executed as soon as the process is entering an idle period. It enables you to
perform low-priority or background work without impacting the user experience.
For more information about how to use it,
[check out its documentation on MDN][request-idle-callback].
*Web Workers* are a powerful tool to run code on a separate thread. There are
some caveats to consider  consult Electron's
[multithreading documentation][multithreading] and the
[MDN documentation for Web Workers][web-workers]. They're an ideal solution
for any operation that requires a lot of CPU power for an extended period of
time.
## 5) Unnecessary polyfills
One of Electron's great benefits is that you know exactly which engine will
parse your JavaScript, HTML, and CSS. If you're re-purposing code that was
written for the web at large, make sure to not polyfill features included in
Electron.
### Why?
When building a web application for today's Internet, the oldest environments
dictate what features you can and cannot use. Even though Electron supports
well-performing CSS filters and animations, an older browser might not. Where
you could use WebGL, your developers may have chosen a more resource-hungry
solution to support older phones.
When it comes to JavaScript, you may have included toolkit libraries like
jQuery for DOM selectors or polyfills like the `regenerator-runtime` to support
`async/await`.
It is rare for a JavaScript-based polyfill to be faster than the equivalent
native feature in Electron. Do not slow down your Electron app by shipping your
own version of standard web platform features.
### How?
Operate under the assumption that polyfills in current versions of Electron
are unnecessary. If you have doubts, check [caniuse.com][https://caniuse.com/]
and check if the [version of Chromium used in your Electron version](../api/process.md#processversionschrome-readonly)
supports the feature you desire.
In addition, carefully examine the libraries you use. Are they really necessary?
`jQuery`, for example, was such a success that many of its features are now part
of the [standard JavaScript feature set available][jquery-need].
If you're using a transpiler/compiler like TypeScript, examine its configuration
and ensure that you're targeting the latest ECMAScript version supported by
Electron.
## 6) Unnecessary or blocking network requests
Avoid fetching rarely changing resources from the internet if they could easily
be bundled with your application.
### Why?
Many users of Electron start with an entirely web-based app that they're
turning into a desktop application. As web developers, we are used to loading
resources from a variety of content delivery networks. Now that you are
shipping a proper desktop application, attempt to "cut the cord" where possible
- and avoid letting your users wait for resources that never change and could
easily be included in your app.
A typical example is Google Fonts. Many developers make use of Google's
impressive collection of free fonts, which comes with a content delivery
network. The pitch is straightforward: Include a few lines of CSS and Google
will take care of the rest.
When building an Electron app, your users are better served if you download
the fonts and include them in your app's bundle.
### How?
In an ideal world, your application wouldn't need the network to operate at
all. To get there, you must understand what resources your app is downloading
\- and how large those resources are.
To do so, open up the developer tools. Navigate to the `Network` tab and check
the `Disable cache` option. Then, reload your renderer. Unless your app
prohibits such reloads, you can usually trigger a reload by hitting `Cmd + R`
or `Ctrl + R` with the developer tools in focus.
The tools will now meticulously record all network requests. In a first pass,
take stock of all the resources being downloaded, focusing on the larger files
first. Are any of them images, fonts, or media files that don't change and
could be included with your bundle? If so, include them.
As a next step, enable `Network Throttling`. Find the drop-down that currently
reads `Online` and select a slower speed such as `Fast 3G`. Reload your
renderer and see if there are any resources that your app is unnecessarily
waiting for. In many cases, an app will wait for a network request to complete
despite not actually needing the involved resource.
As a tip, loading resources from the Internet that you might want to change
without shipping an application update is a powerful strategy. For advanced
control over how resources are being loaded, consider investing in
[Service Workers][service-workers].
## 7) Bundle your code
As already pointed out in
"[Loading and running code too soon](#2-loading-and-running-code-too-soon)",
calling `require()` is an expensive operation. If you are able to do so,
bundle your application's code into a single file.
### Why?
Modern JavaScript development usually involves many files and modules. While
that's perfectly fine for developing with Electron, we heavily recommend that
you bundle all your code into one single file to ensure that the overhead
included in calling `require()` is only paid once when your application loads.
### How?
There are numerous JavaScript bundlers out there and we know better than to
anger the community by recommending one tool over another. We do however
recommend that you use a bundler that is able to handle Electron's unique
environment that needs to handle both Node.js and browser environments.
As of writing this article, the popular choices include [Webpack][webpack],
[Parcel][parcel], and [rollup.js][rollup].
[security]: ./security.md
[performance-cpu-prof]: ../images/performance-cpu-prof.png
[performance-heap-prof]: ../images/performance-heap-prof.png
[chrome-devtools-tutorial]: https://developers.google.com/web/tools/chrome-devtools/evaluate-performance/
[worker-threads]: https://nodejs.org/api/worker_threads.html
[web-workers]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
[request-idle-callback]: https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback
[multithreading]: ./multithreading.md
[caniuse]: https://caniuse.com/
[jquery-need]: http://youmightnotneedjquery.com/
[service-workers]: https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
[webpack]: https://webpack.js.org/
[parcel]: https://parceljs.org/
[rollup]: https://rollupjs.org/
[vscode-first-second]: https://www.youtube.com/watch?v=r0OeHRUCCb4

View File

@@ -13,7 +13,7 @@
<!-- Desktop Capturer API -->
<message name="IDS_DESKTOP_MEDIA_PICKER_SINGLE_SCREEN_NAME" desc="Name for screens in the desktop media picker UI when there is only one monitor.">
Entire screen
Entire Screen
</message>
<message name="IDS_DESKTOP_MEDIA_PICKER_MULTIPLE_SCREEN_NAME" desc="Name for screens in the desktop media picker UI when there are multiple monitors.">
{SCREEN_INDEX, plural, =1{Screen #} other{Screen #}}

View File

@@ -14,6 +14,7 @@ auto_filenames = {
"docs/api/clipboard.md",
"docs/api/command-line.md",
"docs/api/content-tracing.md",
"docs/api/context-bridge.md",
"docs/api/cookies.md",
"docs/api/crash-reporter.md",
"docs/api/debugger.md",
@@ -132,7 +133,6 @@ auto_filenames = {
"lib/common/api/deprecate.ts",
"lib/common/api/module-list.js",
"lib/common/api/native-image.js",
"lib/common/api/native-theme.ts",
"lib/common/api/shell.js",
"lib/common/buffer-utils.ts",
"lib/common/clipboard-utils.ts",
@@ -141,6 +141,8 @@ auto_filenames = {
"lib/common/error-utils.ts",
"lib/common/is-promise.ts",
"lib/common/web-view-methods.ts",
"lib/common/webpack-globals-provider.ts",
"lib/renderer/api/context-bridge.ts",
"lib/renderer/api/crash-reporter.js",
"lib/renderer/api/desktop-capturer.ts",
"lib/renderer/api/ipc-renderer.js",
@@ -175,6 +177,7 @@ auto_filenames = {
isolated_bundle_deps = [
"lib/common/electron-binding-setup.ts",
"lib/common/error-utils.ts",
"lib/common/webpack-globals-provider.ts",
"lib/isolated_renderer/init.js",
"lib/renderer/ipc-renderer-internal-utils.ts",
"lib/renderer/ipc-renderer-internal.ts",
@@ -189,6 +192,7 @@ auto_filenames = {
content_script_bundle_deps = [
"lib/common/electron-binding-setup.ts",
"lib/common/error-utils.ts",
"lib/common/webpack-globals-provider.ts",
"lib/content_script/init.js",
"lib/renderer/chrome-api.ts",
"lib/renderer/extensions/event.ts",
@@ -223,6 +227,7 @@ auto_filenames = {
"lib/browser/api/menu-utils.js",
"lib/browser/api/menu.js",
"lib/browser/api/module-list.js",
"lib/browser/api/native-theme.ts",
"lib/browser/api/net-log.js",
"lib/browser/api/net.js",
"lib/browser/api/notification.js",
@@ -264,7 +269,6 @@ auto_filenames = {
"lib/common/api/exports/electron.js",
"lib/common/api/module-list.js",
"lib/common/api/native-image.js",
"lib/common/api/native-theme.ts",
"lib/common/api/shell.js",
"lib/common/buffer-utils.ts",
"lib/common/clipboard-utils.ts",
@@ -276,6 +280,7 @@ auto_filenames = {
"lib/common/parse-features-string.js",
"lib/common/reset-search-paths.ts",
"lib/common/web-view-methods.ts",
"lib/common/webpack-globals-provider.ts",
"lib/renderer/ipc-renderer-internal-utils.ts",
"lib/renderer/ipc-renderer-internal.ts",
"package.json",
@@ -290,7 +295,6 @@ auto_filenames = {
"lib/common/api/exports/electron.js",
"lib/common/api/module-list.js",
"lib/common/api/native-image.js",
"lib/common/api/native-theme.ts",
"lib/common/api/shell.js",
"lib/common/buffer-utils.ts",
"lib/common/clipboard-utils.ts",
@@ -301,6 +305,8 @@ auto_filenames = {
"lib/common/is-promise.ts",
"lib/common/reset-search-paths.ts",
"lib/common/web-view-methods.ts",
"lib/common/webpack-globals-provider.ts",
"lib/renderer/api/context-bridge.ts",
"lib/renderer/api/crash-reporter.js",
"lib/renderer/api/desktop-capturer.ts",
"lib/renderer/api/exports/electron.js",
@@ -341,7 +347,6 @@ auto_filenames = {
"lib/common/api/exports/electron.js",
"lib/common/api/module-list.js",
"lib/common/api/native-image.js",
"lib/common/api/native-theme.ts",
"lib/common/api/shell.js",
"lib/common/buffer-utils.ts",
"lib/common/clipboard-utils.ts",
@@ -351,6 +356,8 @@ auto_filenames = {
"lib/common/init.ts",
"lib/common/is-promise.ts",
"lib/common/reset-search-paths.ts",
"lib/common/webpack-globals-provider.ts",
"lib/renderer/api/context-bridge.ts",
"lib/renderer/api/crash-reporter.js",
"lib/renderer/api/desktop-capturer.ts",
"lib/renderer/api/exports/electron.js",

View File

@@ -1,7 +1,6 @@
filenames = {
default_app_ts_sources = [
"default_app/default_app.ts",
"default_app/index.ts",
"default_app/main.ts",
"default_app/preload.ts",
]
@@ -65,6 +64,9 @@ filenames = {
"shell/browser/api/atom_api_menu_mac.mm",
"shell/browser/api/atom_api_menu_views.cc",
"shell/browser/api/atom_api_menu_views.h",
"shell/browser/api/atom_api_native_theme.cc",
"shell/browser/api/atom_api_native_theme.h",
"shell/browser/api/atom_api_native_theme_mac.mm",
"shell/browser/api/atom_api_net.cc",
"shell/browser/api/atom_api_net.h",
"shell/browser/api/atom_api_net_log.cc",
@@ -423,8 +425,6 @@ filenames = {
"shell/common/api/atom_api_native_image.cc",
"shell/common/api/atom_api_native_image.h",
"shell/common/api/atom_api_native_image_mac.mm",
"shell/common/api/atom_api_native_theme.cc",
"shell/common/api/atom_api_native_theme.h",
"shell/common/api/atom_api_shell.cc",
"shell/common/api/atom_api_v8_util.cc",
"shell/common/api/electron_bindings.cc",
@@ -536,6 +536,10 @@ filenames = {
"shell/common/promise_util.cc",
"shell/common/skia_util.h",
"shell/common/skia_util.cc",
"shell/renderer/api/context_bridge/render_frame_context_bridge_store.cc",
"shell/renderer/api/context_bridge/render_frame_context_bridge_store.h",
"shell/renderer/api/atom_api_context_bridge.cc",
"shell/renderer/api/atom_api_context_bridge.h",
"shell/renderer/api/atom_api_renderer_ipc.cc",
"shell/renderer/api/atom_api_spell_check_client.cc",
"shell/renderer/api/atom_api_spell_check_client.h",

View File

@@ -33,7 +33,7 @@ BrowserWindow.prototype._init = function () {
// Hide the auto-hide menu when webContents is focused.
this.webContents.on('activate', () => {
if (process.platform !== 'darwin' && this.isMenuBarAutoHide() && this.isMenuBarVisible()) {
if (process.platform !== 'darwin' && this.autoHideMenuBar && this.isMenuBarVisible()) {
this.setMenuBarVisibility(false)
}
})

View File

@@ -21,6 +21,7 @@ module.exports = [
{ name: 'inAppPurchase' },
{ name: 'Menu' },
{ name: 'MenuItem' },
{ name: 'nativeTheme' },
{ name: 'net' },
{ name: 'netLog' },
{ name: 'Notification' },

View File

@@ -18,6 +18,7 @@ module.exports = [
{ name: 'inAppPurchase', loader: () => require('./in-app-purchase') },
{ name: 'Menu', loader: () => require('./menu') },
{ name: 'MenuItem', loader: () => require('./menu-item') },
{ name: 'nativeTheme', loader: () => require('./native-theme') },
{ name: 'net', loader: () => require('./net') },
{ name: 'netLog', loader: () => require('./net-log') },
{ name: 'Notification', loader: () => require('./notification') },

View File

@@ -72,7 +72,6 @@ const defaultPrintingSetting = {
headerFooterEnabled: false,
marginsType: 0,
isFirstRequest: false,
requestID: getNextId(),
previewUIID: 0,
previewModifiable: true,
printToPDF: true,
@@ -205,7 +204,10 @@ WebContents.prototype.executeJavaScript = function (code, hasUserGesture) {
// Translate the options of printToPDF.
WebContents.prototype.printToPDF = function (options) {
const printingSetting = Object.assign({}, defaultPrintingSetting)
const printingSetting = {
...defaultPrintingSetting,
requestID: getNextId()
}
if (options.landscape) {
printingSetting.landscape = options.landscape
}

View File

@@ -19,7 +19,13 @@ export const getSources = (event: Electron.IpcMainEvent, options: ElectronIntern
}
const getSources = new Promise<ElectronInternal.GetSourcesResult[]>((resolve, reject) => {
let capturer: ElectronInternal.DesktopCapturer | null = createDesktopCapturer()
const stopRunning = () => {
if (capturer) {
capturer.emit = null
capturer = null
}
// Remove from currentlyRunning once we resolve or reject
currentlyRunning = currentlyRunning.filter(running => running.options !== options)
}
@@ -42,19 +48,13 @@ export const getSources = (event: Electron.IpcMainEvent, options: ElectronIntern
})))
})
let capturer: ElectronInternal.DesktopCapturer | null = createDesktopCapturer()
capturer.emit = emitter.emit.bind(emitter)
capturer.startHandling(options.captureWindow, options.captureScreen, options.thumbnailSize, options.fetchWindowIcons)
// If the WebContents is destroyed before receiving result, just remove the
// reference to emit and the capturer itself so that it never dispatches
// back to the renderer
event.sender.once('destroyed', () => {
capturer!.emit = null
capturer = null
stopRunning()
})
event.sender.once('destroyed', () => stopRunning())
})
currentlyRunning.push({

View File

@@ -188,7 +188,7 @@ const attachGuest = function (event, embedderFrameId, elementInstanceId, guestIn
nodeIntegrationInSubFrames: params.nodeintegrationinsubframes != null ? params.nodeintegrationinsubframes : false,
enableRemoteModule: params.enableremotemodule,
plugins: params.plugins,
zoomFactor: embedder.getZoomFactor(),
zoomFactor: embedder.zoomFactor,
disablePopups: !params.allowpopups,
webSecurity: !params.disablewebsecurity,
enableBlinkFeatures: params.blinkfeatures,

View File

@@ -127,6 +127,10 @@ class ObjectsRegistry {
this.clear(webContents, contextId)
}
}
// Note that the "render-view-deleted" event may not be emitted on time when
// the renderer process get destroyed because of navigation, we rely on the
// renderer process to send "ELECTRON_BROWSER_CONTEXT_RELEASE" message to
// guard this situation.
webContents.on('render-view-deleted', listener)
}
}

View File

@@ -231,7 +231,7 @@ const unwrapArgs = function (sender, frameId, contextId, args) {
v8Util.setHiddenValue(callIntoRenderer, 'location', meta.location)
Object.defineProperty(callIntoRenderer, 'length', { value: meta.length })
v8Util.setRemoteCallbackFreer(callIntoRenderer, contextId, meta.id, sender)
v8Util.setRemoteCallbackFreer(callIntoRenderer, frameId, contextId, meta.id, sender)
rendererFunctions.set(objectId, callIntoRenderer)
return callIntoRenderer
}
@@ -444,7 +444,6 @@ handleRemoteCommand('ELECTRON_BROWSER_DEREFERENCE', function (event, contextId,
handleRemoteCommand('ELECTRON_BROWSER_CONTEXT_RELEASE', (event, contextId) => {
objectsRegistry.clear(event.sender, contextId)
return null
})
handleRemoteCommand('ELECTRON_BROWSER_GUEST_WEB_CONTENTS', function (event, contextId, guestInstanceId) {

View File

@@ -4,7 +4,6 @@
module.exports = [
{ name: 'clipboard', loader: () => require('./clipboard') },
{ name: 'nativeImage', loader: () => require('./native-image') },
{ name: 'nativeTheme', loader: () => require('./native-theme') },
{ name: 'shell', loader: () => require('./shell') },
// The internal modules, invisible unless you know their names.
{ name: 'deprecate', loader: () => require('./deprecate'), private: true }

View File

@@ -8,6 +8,8 @@
const path = require('path')
const util = require('util')
const Promise = global.Promise
const envNoAsar = process.env.ELECTRON_NO_ASAR &&
process.type !== 'browser' &&
process.type !== 'renderer'
@@ -40,8 +42,6 @@
return newArchive
}
const ASAR_EXTENSION = '.asar'
// Separate asar package's path from full path.
const splitPath = archivePathOrBuffer => {
// Shortcut for disabled asar.
@@ -54,22 +54,7 @@
}
if (typeof archivePath !== 'string') return { isAsar: false }
if (archivePath.endsWith(ASAR_EXTENSION)) {
return { isAsar: true, asarPath: archivePath, filePath: '' }
}
archivePath = path.normalize(archivePath)
const index = archivePath.lastIndexOf(`${ASAR_EXTENSION}${path.sep}`)
if (index === -1) return { isAsar: false }
// E.g. for "//some/path/to/archive.asar/then/internal.file"...
return {
isAsar: true,
// "//some/path/to/archive.asar"
asarPath: archivePath.substr(0, index + ASAR_EXTENSION.length),
// "then/internal.file" (with a path separator excluded)
filePath: archivePath.substr(index + ASAR_EXTENSION.length + 1)
}
return asar.splitPath(path.normalize(archivePath))
}
// Convert asar archive's Stats object to fs's Stats object.

View File

@@ -0,0 +1,8 @@
// Captures original globals into a scope to ensure that userland modifications do
// not impact Electron. Note that users doing:
//
// global.Promise.resolve = myFn
//
// Will mutate this captured one as well and that is OK.
export const Promise = global.Promise

View File

@@ -0,0 +1,20 @@
const { hasSwitch } = process.electronBinding('command_line')
const binding = process.electronBinding('context_bridge')
const contextIsolationEnabled = hasSwitch('context-isolation')
const checkContextIsolationEnabled = () => {
if (!contextIsolationEnabled) throw new Error('contextBridge API can only be used when contextIsolation is enabled')
}
const contextBridge = {
exposeInMainWorld: (key: string, api: Record<string, any>) => {
checkContextIsolationEnabled()
return binding.exposeAPIInMainWorld(key, api)
},
debugGC: () => binding._debugGCMaps({})
}
if (!binding._debugGCMaps) delete contextBridge.debugGC
export default contextBridge

View File

@@ -8,6 +8,7 @@ const enableRemoteModule = v8Util.getHiddenValue(global, 'enableRemoteModule')
// Renderer side modules, please sort alphabetically.
// A module is `enabled` if there is no explicit condition defined.
module.exports = [
{ name: 'contextBridge', loader: () => require('./context-bridge') },
{ name: 'crashReporter', loader: () => require('./crash-reporter') },
{ name: 'ipcRenderer', loader: () => require('./ipc-renderer') },
{ name: 'webFrame', loader: () => require('./web-frame') }

View File

@@ -20,7 +20,7 @@ const contextId = v8Util.getHiddenValue(global, 'contextId')
// to guard that situation.
process.on('exit', () => {
const command = 'ELECTRON_BROWSER_CONTEXT_RELEASE'
ipcRendererInternal.sendSync(command, contextId)
ipcRendererInternal.send(command, contextId)
})
// Convert the arguments object into an array of meta data.

View File

@@ -116,7 +116,11 @@ export function injectTo (extensionId: string, context: any) {
let targetExtensionId = extensionId
let connectInfo = { name: '' }
if (args.length === 1) {
targetExtensionId = args[0]
if (typeof args[0] === 'string') {
targetExtensionId = args[0]
} else {
connectInfo = args[0]
}
} else if (args.length === 2) {
[targetExtensionId, connectInfo] = args
}

View File

@@ -3,6 +3,10 @@
const features = process.electronBinding('features')
module.exports = [
{
name: 'contextBridge',
load: () => require('@electron/internal/renderer/api/context-bridge')
},
{
name: 'crashReporter',
load: () => require('@electron/internal/renderer/api/crash-reporter')

View File

@@ -94,6 +94,8 @@ Object.defineProperty(preloadProcess, 'noDeprecation', {
process.on('loaded', () => preloadProcess.emit('loaded'))
process.on('exit', () => preloadProcess.emit('exit'))
process.on('document-start', () => preloadProcess.emit('document-start'))
process.on('document-end', () => preloadProcess.emit('document-end'))
// This is the `require` function that will be visible to the preload script
function preloadRequire (module) {

View File

@@ -27,7 +27,7 @@ class Arguments {
template <typename T>
bool GetHolder(T* out) {
return ConvertFromV8(isolate_, info_->Holder(), out);
return mate::ConvertFromV8(isolate_, info_->Holder(), out);
}
template <typename T>
@@ -53,7 +53,7 @@ class Arguments {
return false;
}
v8::Local<v8::Value> val = (*info_)[next_];
bool success = ConvertFromV8(isolate_, val, out);
bool success = mate::ConvertFromV8(isolate_, val, out);
if (success)
next_++;
return success;

View File

@@ -40,6 +40,12 @@ class Dictionary {
static Dictionary CreateEmpty(v8::Isolate* isolate);
bool Has(base::StringPiece key) const {
v8::Local<v8::Context> context = isolate_->GetCurrentContext();
v8::Local<v8::String> v8_key = StringToV8(isolate_, key);
return internal::IsTrue(GetHandle()->Has(context, v8_key));
}
template <typename T>
bool Get(base::StringPiece key, T* out) const {
// Check for existence before getting, otherwise this method will always
@@ -102,6 +108,17 @@ class Dictionary {
return !result.IsNothing() && result.FromJust();
}
template <typename T>
bool SetReadOnlyNonConfigurable(base::StringPiece key, T val) {
v8::Local<v8::Value> v8_value;
if (!TryConvertToV8(isolate_, val, &v8_value))
return false;
v8::Maybe<bool> result = GetHandle()->DefineOwnProperty(
isolate_->GetCurrentContext(), StringToV8(isolate_, key), v8_value,
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
return !result.IsNothing() && result.FromJust();
}
template <typename T>
bool SetMethod(base::StringPiece key, const T& callback) {
return GetHandle()

View File

@@ -1,11 +1,11 @@
{
"name": "electron",
"version": "7.0.0-beta.5",
"version": "7.1.1",
"repository": "https://github.com/electron/electron",
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
"devDependencies": {
"@electron/docs-parser": "^0.4.2",
"@electron/typescript-definitions": "^8.6.1",
"@electron/typescript-definitions": "^8.6.4",
"@octokit/rest": "^16.3.2",
"@primer/octicons": "^9.1.1",
"@types/chai": "^4.1.7",
@@ -14,6 +14,7 @@
"@types/fs-extra": "^5.0.5",
"@types/mocha": "^5.2.6",
"@types/node": "^12.0.10",
"@types/semver": "^6.0.1",
"@types/split": "^1.0.0",
"@types/webpack": "^4.4.32",
"@types/webpack-env": "^1.13.9",

1
patches/angle/.patches Normal file
View File

@@ -0,0 +1 @@
gles2_use_constant_initialization_for_g_mutex.patch

View File

@@ -0,0 +1,60 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jaime Bernardo <jaime@janeasystems.com>
Date: Mon, 30 Sep 2019 17:53:56 +0100
Subject: GLES2: Use require_constant_initialization for g_Mutex
A static assert to verify that the global mutex g_Mutex is trivially
constructed fails to compile with clang when using the STL shipped
with Visual Studio 2019.
Use __attribute__((require_constant_initialization)) instead to verify
for constant initialization.
BUG=angleproject:3936
Change-Id: I5969762ad5a99033143513d7c4992344da276b1a
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1832164
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
diff --git a/AUTHORS b/AUTHORS
index ab39ee01a47c15da57b531d2c711649f1685091b..7a0f3b32b101b34195c57637b227062d9b173d6a 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -58,3 +58,4 @@ Jérôme Duval
Thomas Miller
Till Rathmann
Nick Shaforostov
+Jaime Bernardo
diff --git a/src/common/angleutils.h b/src/common/angleutils.h
index 131d5796da4399df1144bc349c506cde8220973a..3a1391e29b72e7ec356e44c7ced202cc29773fb3 100644
--- a/src/common/angleutils.h
+++ b/src/common/angleutils.h
@@ -345,4 +345,10 @@ std::string ToString(const T &value)
# define ANGLE_MAYBE_UNUSED
#endif // __has_cpp_attribute(maybe_unused)
+#if __has_cpp_attribute(require_constant_initialization)
+# define ANGLE_REQUIRE_CONSTANT_INIT [[require_constant_initialization]]
+#else
+# define ANGLE_REQUIRE_CONSTANT_INIT
+#endif // __has_cpp_attribute(require_constant_initialization)
+
#endif // COMMON_ANGLEUTILS_H_
diff --git a/src/libGLESv2/global_state.cpp b/src/libGLESv2/global_state.cpp
index 8ea912eea045c912ef64dfedcfd8f07db4337a9d..c8c9a732fbad5cc50ed2a7fc4b5387a30274435b 100644
--- a/src/libGLESv2/global_state.cpp
+++ b/src/libGLESv2/global_state.cpp
@@ -35,9 +35,8 @@ namespace
{
static TLSIndex threadTLS = TLS_INVALID_INDEX;
Debug *g_Debug = nullptr;
-std::atomic<std::mutex *> g_Mutex;
-static_assert(std::is_trivially_constructible<decltype(g_Mutex)>::value,
- "global mutex is not trivially constructible");
+
+ANGLE_REQUIRE_CONSTANT_INIT std::atomic<std::mutex *> g_Mutex(nullptr);
static_assert(std::is_trivially_destructible<decltype(g_Mutex)>::value,
"global mutex is not trivially destructible");

View File

@@ -78,3 +78,6 @@ ssl_security_state_tab_helper.patch
revert_cleanup_remove_menu_subtitles_sublabels.patch
expose_setuseragent_on_networkcontext.patch
net_avoid_vector_const_elements.patch
feat_add_set_theme_source_to_allow_apps_to.patch
build_fix_when_building_with_enable_plugins_false.patch
x11_and_ozone_move_closing_logic_to_dwthplatform.patch

View File

@@ -70,10 +70,10 @@ index ac76d127b96b80c8260a7e2cda0b669cd98787ad..dcab64586700a8740262aede8dba2755
Partitions::ArrayBufferPartition()->Free(data);
}
diff --git a/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_contents.h b/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_contents.h
index 3f44cd2fdf648057be8defcf041574b4c91e0363..55c0e7c66649ae9d9cbef6179daac7ad771b755c 100644
index 4bb5e23349b3d1c2305b34f2bfc4cab6067bd79a..2b9fe575370153b2acb623d4f7b1b2e83eeaf319 100644
--- a/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_contents.h
+++ b/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_contents.h
@@ -140,6 +140,7 @@ class WTF_EXPORT ArrayBufferContents {
@@ -142,6 +142,7 @@ class WTF_EXPORT ArrayBufferContents {
void CopyTo(ArrayBufferContents& other);
static void* AllocateMemoryOrNull(size_t, InitializationPolicy);

View File

@@ -14,7 +14,7 @@ when there is code doing that.
This patch reverts the change to fix the crash in Electron.
diff --git a/third_party/blink/renderer/core/frame/local_frame.cc b/third_party/blink/renderer/core/frame/local_frame.cc
index 52f56794f2ed1cd027bccf0f1c284b138052fe99..13029678e052af1a6c7a8d0f8655fc9852eedf84 100644
index 6e2fc4a7dd2f272aabd94e96702d99f6c703f3a8..385334801d26fb41469b2e5b66cb305193033a70 100644
--- a/third_party/blink/renderer/core/frame/local_frame.cc
+++ b/third_party/blink/renderer/core/frame/local_frame.cc
@@ -338,10 +338,6 @@ void LocalFrame::DetachImpl(FrameDetachType type) {

View File

@@ -0,0 +1,74 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Tue, 8 Oct 2019 15:40:50 +0000
Subject: build: fix when building with enable_plugins=false
Bug: none
Change-Id: If878b3a7f5bb051c6e99c617418475c12754ae90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1845624
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703739}
diff --git a/AUTHORS b/AUTHORS
index 5fbb21d147f256c21bfee64cf83ed59375ece3f3..d6e0ad7887fe18e827c625b51949ff16094fa0f7 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -224,6 +224,7 @@ Debashish Samantaray <d.samantaray@samsung.com>
Debug Wang <debugwang@tencent.com>
Deepak Dilip Borade <deepak.db@samsung.com>
Deepak Mittal <deepak.m1@samsung.com>
+Deepak Mohan <hop2deep@gmail.com>
Deepak Sharma <deepak.sharma@amd.com>
Deepak Singla <deepak.s@samsung.com>
Deokjin Kim <deokjin81.kim@samsung.com>
diff --git a/content/browser/sandbox_parameters_mac.mm b/content/browser/sandbox_parameters_mac.mm
index 5eead918eb9d9df03c86b5201b3f924643707f4b..a12cc8734c45a4ebb29672306da3a695a883eb9b 100644
--- a/content/browser/sandbox_parameters_mac.mm
+++ b/content/browser/sandbox_parameters_mac.mm
@@ -25,12 +25,16 @@
#include "content/public/common/content_client.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
-#include "content/public/common/pepper_plugin_info.h"
+#include "ppapi/buildflags/buildflags.h"
#include "sandbox/mac/seatbelt_exec.h"
#include "services/service_manager/sandbox/mac/sandbox_mac.h"
#include "services/service_manager/sandbox/sandbox_type.h"
#include "services/service_manager/sandbox/switches.h"
+#if BUILDFLAG(ENABLE_PLUGINS)
+#include "content/public/common/pepper_plugin_info.h"
+#endif
+
namespace content {
namespace {
@@ -148,6 +152,7 @@ void SetupNetworkSandboxParameters(sandbox::SeatbeltExecClient* client) {
}
}
+#if BUILDFLAG(ENABLE_PLUGINS)
void SetupPPAPISandboxParameters(sandbox::SeatbeltExecClient* client) {
SetupCommonSandboxParameters(client);
@@ -172,6 +177,7 @@ void SetupPPAPISandboxParameters(sandbox::SeatbeltExecClient* client) {
// to n+1 more than the plugins added.
CHECK(index <= 5);
}
+#endif
void SetupCDMSandboxParameters(sandbox::SeatbeltExecClient* client) {
SetupCommonSandboxParameters(client);
@@ -212,9 +218,11 @@ void SetupSandboxParameters(service_manager::SandboxType sandbox_type,
case service_manager::SANDBOX_TYPE_NETWORK:
SetupNetworkSandboxParameters(client);
break;
+#if BUILDFLAG(ENABLE_PLUGINS)
case service_manager::SANDBOX_TYPE_PPAPI:
SetupPPAPISandboxParameters(client);
break;
+#endif
case service_manager::SANDBOX_TYPE_PROFILING:
case service_manager::SANDBOX_TYPE_UTILITY:
SetupUtilitySandboxParameters(client, command_line);

View File

@@ -5,7 +5,7 @@ Subject: build_gn.patch
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn
index f89e7e831b79f82bd11a5dd8cee6ab49d8de724e..f8a611bf0676ce323cdbb5d639333df9875dd0ca 100644
index 59ab7810e71916e8f0f2d69f06e3c2c3ebc99030..b144e800c94956429ca85fc0aefe6539a6246e4b 100644
--- a/build/config/BUILDCONFIG.gn
+++ b/build/config/BUILDCONFIG.gn
@@ -123,6 +123,9 @@ if (current_os == "") {
@@ -18,8 +18,8 @@ index f89e7e831b79f82bd11a5dd8cee6ab49d8de724e..f8a611bf0676ce323cdbb5d639333df9
# Set to enable the official build level of optimization. This has nothing
# to do with branding, but enables an additional level of optimization above
# release (!is_debug). This might be better expressed as a tri-state
@@ -438,6 +441,7 @@ default_compiler_configs = [
"//build/config/compiler:default_init_stack_vars",
@@ -437,6 +440,7 @@ default_compiler_configs = [
"//build/config/compiler:thin_archive",
"//build/config/coverage:default_coverage",
"//build/config/sanitizers:default_sanitizer_flags",
+ "//electron/build/config:mas_build",

View File

@@ -5,10 +5,10 @@ Subject: can_create_window.patch
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index 54be9df87a81f517ed9d324d261caffed36f0a36..88f8ced32c79ca7a6b173636002f3e2d1b1e491f 100644
index f25b4fa183726c78fb45bbb8259eaeb13ae20659..4398cd11d7fd95a1f6d41b24b3231e0006b2b012 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -3963,6 +3963,7 @@ void RenderFrameHostImpl::CreateNewWindow(
@@ -3964,6 +3964,7 @@ void RenderFrameHostImpl::CreateNewWindow(
last_committed_origin_, params->window_container_type,
params->target_url, params->referrer.To<Referrer>(),
params->frame_name, params->disposition, *params->features,
@@ -66,7 +66,7 @@ index dcb77c78114699a0017a305f140f4322d271ff83..aeb22701d036c54cb495540847e333b3
bool opener_suppressed,
bool* no_javascript_access);
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index b48225c1a805fcdcdea656a638407b154fa29b37..98e60cd94ce13130b81d1553c8ee4f9bbfea76ed 100644
index 64aaf7e694994e09bbee2e61f6691e7d39f49718..dfe6c07d9e8ef952bec7a350e80729870a990a39 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -73,6 +73,7 @@
@@ -77,7 +77,7 @@ index b48225c1a805fcdcdea656a638407b154fa29b37..98e60cd94ce13130b81d1553c8ee4f9b
#include "content/renderer/media/audio/audio_device_factory.h"
#include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
#include "content/renderer/media/webrtc/rtc_peer_connection_handler.h"
@@ -1322,6 +1323,8 @@ WebView* RenderViewImpl::CreateView(
@@ -1324,6 +1325,8 @@ WebView* RenderViewImpl::CreateView(
}
params->features = ConvertWebWindowFeaturesToMojoWindowFeatures(features);

View File

@@ -17,10 +17,10 @@ only one or two specific checks fail. Then it's better to simply comment out the
failing checks and allow the rest of the target to have them enabled.
diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc
index 3f207fcfce857692febe79df7b9ba4afb594270d..fe40d01779685ab86d5ddb3e4f5193ad89305f87 100644
index dacaa680682add5845b882289ed7f10a14a58002..f9f92b2badda20b8e9e91baaaf3838088734c1b7 100644
--- a/content/browser/frame_host/navigation_controller_impl.cc
+++ b/content/browser/frame_host/navigation_controller_impl.cc
@@ -1210,8 +1210,10 @@ NavigationType NavigationControllerImpl::ClassifyNavigation(
@@ -1211,8 +1211,10 @@ NavigationType NavigationControllerImpl::ClassifyNavigation(
return NAVIGATION_TYPE_NEW_SUBFRAME;
}
@@ -33,7 +33,7 @@ index 3f207fcfce857692febe79df7b9ba4afb594270d..fe40d01779685ab86d5ddb3e4f5193ad
if (rfh->GetParent()) {
// All manual subframes would be did_create_new_entry and handled above, so
@@ -1463,7 +1465,10 @@ void NavigationControllerImpl::RendererDidNavigateToNewPage(
@@ -1464,7 +1466,10 @@ void NavigationControllerImpl::RendererDidNavigateToNewPage(
new_entry->GetFavicon() = GetLastCommittedEntry()->GetFavicon();
}

View File

@@ -133,7 +133,7 @@ index 47401abc984e6fe26c7f4c5399aa565c687060b0..ca6a527ffac877c27aac94337ec5a7b5
protected:
virtual ~DesktopMediaListObserver() {}
diff --git a/chrome/browser/media/webrtc/native_desktop_media_list.cc b/chrome/browser/media/webrtc/native_desktop_media_list.cc
index b2005c70acbc1c05c59bb2059b190ab78fb63a68..1a7188e2df76672d66da3206d4448df35a065754 100644
index b2005c70acbc1c05c59bb2059b190ab78fb63a68..6cfc3007549b2e7992334b708e4e71a00974c2a3 100644
--- a/chrome/browser/media/webrtc/native_desktop_media_list.cc
+++ b/chrome/browser/media/webrtc/native_desktop_media_list.cc
@@ -8,14 +8,15 @@
@@ -153,3 +153,12 @@ index b2005c70acbc1c05c59bb2059b190ab78fb63a68..1a7188e2df76672d66da3206d4448df3
#include "media/base/video_util.h"
#include "third_party/libyuv/include/libyuv/scale_argb.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -218,6 +219,8 @@ void NativeDesktopMediaList::Worker::RefreshThumbnails(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&NativeDesktopMediaList::UpdateNativeThumbnailsFinished,
media_list_));
+
+ capturer_.reset();
}
void NativeDesktopMediaList::Worker::OnCaptureResult(

View File

@@ -15,10 +15,10 @@ the redraw locking mechanism, which fixes these issues. The electron issue
can be found at https://github.com/electron/electron/issues/1821
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index 67202004ea3a765dcbe92385abac8d5bd17e15b0..77b9204e6bd50fd25fdf0edb276489fe67e4fcac 100644
index 3fd5bd3d395fa14d2b31d374ec2481a952d9a5a3..0e957831c25ccbb27038b9a24587621a825ec5ee 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -331,6 +331,10 @@ constexpr int kSynthesizedMouseMessagesTimeDifference = 500;
@@ -347,6 +347,10 @@ constexpr int kSynthesizedMouseMessagesTimeDifference = 500;
} // namespace
@@ -29,7 +29,7 @@ index 67202004ea3a765dcbe92385abac8d5bd17e15b0..77b9204e6bd50fd25fdf0edb276489fe
// A scoping class that prevents a window from being able to redraw in response
// to invalidations that may occur within it for the lifetime of the object.
//
@@ -382,6 +386,7 @@ class HWNDMessageHandler::ScopedRedrawLock {
@@ -398,6 +402,7 @@ class HWNDMessageHandler::ScopedRedrawLock {
cancel_unlock_(false),
should_lock_(owner_->IsVisible() && !owner->HasChildRenderingWindow() &&
::IsWindow(hwnd_) &&
@@ -37,7 +37,7 @@ index 67202004ea3a765dcbe92385abac8d5bd17e15b0..77b9204e6bd50fd25fdf0edb276489fe
(!(GetWindowLong(hwnd_, GWL_STYLE) & WS_CAPTION) ||
!ui::win::IsAeroGlassEnabled())) {
if (should_lock_)
@@ -992,6 +997,10 @@ bool HWNDMessageHandler::HasChildRenderingWindow() {
@@ -1008,6 +1013,10 @@ bool HWNDMessageHandler::HasChildRenderingWindow() {
hwnd());
}
@@ -45,14 +45,14 @@ index 67202004ea3a765dcbe92385abac8d5bd17e15b0..77b9204e6bd50fd25fdf0edb276489fe
+ return delegate_->HasNativeFrame();
+}
+
////////////////////////////////////////////////////////////////////////////////
// HWNDMessageHandler, gfx::WindowImpl overrides:
std::unique_ptr<aura::ScopedEnableUnadjustedMouseEvents>
HWNDMessageHandler::RegisterUnadjustedMouseEvent() {
std::unique_ptr<ScopedEnableUnadjustedMouseEventsWin> scoped_enable =
diff --git a/ui/views/win/hwnd_message_handler.h b/ui/views/win/hwnd_message_handler.h
index d85486af34da6bcc11c0bc0ccd6349b161b1dac3..c59cd6f26a4ed39cff294316a9771f063712a8c0 100644
index 74a09495e7aa4cf281efd39947378ce39304b93f..3b30e785e2b628f709cb534b12884f5568e8fdd2 100644
--- a/ui/views/win/hwnd_message_handler.h
+++ b/ui/views/win/hwnd_message_handler.h
@@ -194,6 +194,8 @@ class VIEWS_EXPORT HWNDMessageHandler : public gfx::WindowImpl,
@@ -202,6 +202,8 @@ class VIEWS_EXPORT HWNDMessageHandler : public gfx::WindowImpl,
using TouchIDs = std::set<DWORD>;
enum class DwmFrameState { kOff, kOn };

View File

@@ -19,8 +19,25 @@ This can be removed once web content (including WebGL) learn how
to deal with color spaces. That is being tracked at
https://crbug.com/634542 and https://crbug.com/711107.
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 8f2e073cd68d9aa54ae08b4f6ef1c60795567575..50c3efcee1ec7508990a5db1bb6dc120223fec18 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1814,6 +1814,12 @@ const gfx::ColorSpace& LayerTreeHostImpl::GetRasterColorSpace() const {
const gfx::ColorSpace& LayerTreeHostImpl::GetRasterColorSpaceAndId(
int* id) const {
+ if (!settings_.enable_color_correct_rendering) {
+ static gfx::ColorSpace invalid_color_space;
+ *id = -1;
+ return invalid_color_space;
+ }
+
const gfx::ColorSpace* result = nullptr;
// The pending tree will have the most recently updated color space, so
// prefer that.
diff --git a/cc/trees/layer_tree_settings.h b/cc/trees/layer_tree_settings.h
index ea0dfd54283746e84f2a14108d50b5203bc6f6d8..b1d82cb13c78b1a9e0049ba73fc36aa1bfdd874b 100644
index ce1e19e291572604b51872da9cea133e4f1a169e..0c316bd7ccb5e80880c667b6e29ec511d7a17f4e 100644
--- a/cc/trees/layer_tree_settings.h
+++ b/cc/trees/layer_tree_settings.h
@@ -95,6 +95,8 @@ class CC_EXPORT LayerTreeSettings {
@@ -66,10 +83,10 @@ index f17aa1fa451f1b99d7f083e07edd49b11f7639e4..09f7c5d6a92d89c199b296771a8ff60c
!command_line->HasSwitch(switches::kUIDisablePartialSwap);
#if defined(OS_MACOSX)
diff --git a/components/viz/service/display/gl_renderer.cc b/components/viz/service/display/gl_renderer.cc
index 8c67161c4a4b970fb9393a9a73a239b5aecb95cf..99ea5a9832aca67030e92e4761209872190388eb 100644
index 64ef9025a4b26c0f2e795a33ff2f7da977ac25f3..cb51ed7e170a0bfea9164082d2afb7c42e03ab22 100644
--- a/components/viz/service/display/gl_renderer.cc
+++ b/components/viz/service/display/gl_renderer.cc
@@ -81,6 +81,9 @@
@@ -83,6 +83,9 @@
using gpu::gles2::GLES2Interface;
@@ -79,7 +96,7 @@ index 8c67161c4a4b970fb9393a9a73a239b5aecb95cf..99ea5a9832aca67030e92e4761209872
namespace viz {
namespace {
@@ -557,8 +560,9 @@ void GLRenderer::DoDrawQuad(const DrawQuad* quad,
@@ -561,8 +564,9 @@ void GLRenderer::DoDrawQuad(const DrawQuad* quad,
void GLRenderer::DrawDebugBorderQuad(const DebugBorderDrawQuad* quad) {
SetBlendEnabled(quad->ShouldDrawWithBlending());
@@ -91,7 +108,7 @@ index 8c67161c4a4b970fb9393a9a73a239b5aecb95cf..99ea5a9832aca67030e92e4761209872
// Use the full quad_rect for debug quads to not move the edges based on
// partial swaps.
@@ -1455,7 +1459,8 @@ void GLRenderer::ChooseRPDQProgram(DrawRenderPassDrawQuadParams* params,
@@ -1485,7 +1489,8 @@ void GLRenderer::ChooseRPDQProgram(DrawRenderPassDrawQuadParams* params,
params->use_color_matrix, tint_gl_composited_content_,
params->apply_shader_based_rounded_corner &&
ShouldApplyRoundedCorner(params->quad)),
@@ -101,7 +118,7 @@ index 8c67161c4a4b970fb9393a9a73a239b5aecb95cf..99ea5a9832aca67030e92e4761209872
}
void GLRenderer::UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params) {
@@ -1926,8 +1931,8 @@ void GLRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad,
@@ -1956,8 +1961,8 @@ void GLRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad,
SetUseProgram(ProgramKey::SolidColor(use_aa ? USE_AA : NO_AA,
tint_gl_composited_content_,
ShouldApplyRoundedCorner(quad)),
@@ -112,7 +129,7 @@ index 8c67161c4a4b970fb9393a9a73a239b5aecb95cf..99ea5a9832aca67030e92e4761209872
SetShaderColor(color, opacity);
if (current_program_->rounded_corner_rect_location() != -1) {
SetShaderRoundedCorner(
@@ -2082,8 +2087,8 @@ void GLRenderer::DrawContentQuadAA(const ContentDrawQuadBase* quad,
@@ -2112,8 +2117,8 @@ void GLRenderer::DrawContentQuadAA(const ContentDrawQuadBase* quad,
: NON_PREMULTIPLIED_ALPHA,
false, false, tint_gl_composited_content_,
ShouldApplyRoundedCorner(quad)),
@@ -123,7 +140,7 @@ index 8c67161c4a4b970fb9393a9a73a239b5aecb95cf..99ea5a9832aca67030e92e4761209872
if (current_program_->tint_color_matrix_location() != -1) {
auto matrix = cc::DebugColors::TintCompositedContentColorTransformMatrix();
@@ -2179,8 +2184,8 @@ void GLRenderer::DrawContentQuadNoAA(const ContentDrawQuadBase* quad,
@@ -2209,8 +2214,8 @@ void GLRenderer::DrawContentQuadNoAA(const ContentDrawQuadBase* quad,
!quad->ShouldDrawWithBlending(), has_tex_clamp_rect,
tint_gl_composited_content_,
ShouldApplyRoundedCorner(quad)),
@@ -134,7 +151,7 @@ index 8c67161c4a4b970fb9393a9a73a239b5aecb95cf..99ea5a9832aca67030e92e4761209872
if (current_program_->tint_color_matrix_location() != -1) {
auto matrix = cc::DebugColors::TintCompositedContentColorTransformMatrix();
@@ -2283,7 +2288,7 @@ void GLRenderer::DrawYUVVideoQuad(const YUVVideoDrawQuad* quad,
@@ -2313,7 +2318,7 @@ void GLRenderer::DrawYUVVideoQuad(const YUVVideoDrawQuad* quad,
DCHECK_NE(src_color_space, src_color_space.GetAsFullRangeRGB());
gfx::ColorSpace dst_color_space =
@@ -143,7 +160,7 @@ index 8c67161c4a4b970fb9393a9a73a239b5aecb95cf..99ea5a9832aca67030e92e4761209872
// Force sRGB output on Windows for overlay candidate video quads to match
// DirectComposition behavior in case these switch between overlays and
// compositing. See https://crbug.com/811118 for details.
@@ -2439,8 +2444,8 @@ void GLRenderer::DrawStreamVideoQuad(const StreamVideoDrawQuad* quad,
@@ -2469,8 +2474,8 @@ void GLRenderer::DrawStreamVideoQuad(const StreamVideoDrawQuad* quad,
SetUseProgram(ProgramKey::VideoStream(tex_coord_precision,
ShouldApplyRoundedCorner(quad)),
@@ -154,7 +171,7 @@ index 8c67161c4a4b970fb9393a9a73a239b5aecb95cf..99ea5a9832aca67030e92e4761209872
DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id());
@@ -2497,8 +2502,8 @@ void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) {
@@ -2532,8 +2537,8 @@ void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) {
draw_cache_.nearest_neighbor ? GL_NEAREST : GL_LINEAR);
// Bind the program to the GL state.
@@ -165,7 +182,7 @@ index 8c67161c4a4b970fb9393a9a73a239b5aecb95cf..99ea5a9832aca67030e92e4761209872
if (current_program_->rounded_corner_rect_location() != -1) {
SetShaderRoundedCorner(
@@ -3195,7 +3200,9 @@ void GLRenderer::PrepareGeometry(BoundGeometry binding) {
@@ -3230,7 +3235,9 @@ void GLRenderer::PrepareGeometry(BoundGeometry binding) {
void GLRenderer::SetUseProgram(const ProgramKey& program_key_no_color,
const gfx::ColorSpace& src_color_space,
const gfx::ColorSpace& dst_color_space) {
@@ -176,7 +193,7 @@ index 8c67161c4a4b970fb9393a9a73a239b5aecb95cf..99ea5a9832aca67030e92e4761209872
gfx::ColorSpace adjusted_color_space = src_color_space;
float sdr_white_level = current_frame()->sdr_white_level;
@@ -3574,7 +3581,7 @@ void GLRenderer::CopyRenderPassDrawQuadToOverlayResource(
@@ -3609,7 +3616,7 @@ void GLRenderer::CopyRenderPassDrawQuadToOverlayResource(
*overlay_texture = FindOrCreateOverlayTexture(
params.quad->render_pass_id, iosurface_width, iosurface_height,
@@ -185,7 +202,7 @@ index 8c67161c4a4b970fb9393a9a73a239b5aecb95cf..99ea5a9832aca67030e92e4761209872
*new_bounds = gfx::RectF(updated_dst_rect.origin(),
gfx::SizeF((*overlay_texture)->texture.size()));
@@ -3792,8 +3799,8 @@ void GLRenderer::FlushOverdrawFeedback(const gfx::Rect& output_rect) {
@@ -3827,8 +3834,8 @@ void GLRenderer::FlushOverdrawFeedback(const gfx::Rect& output_rect) {
PrepareGeometry(SHARED_BINDING);
@@ -196,14 +213,14 @@ index 8c67161c4a4b970fb9393a9a73a239b5aecb95cf..99ea5a9832aca67030e92e4761209872
gfx::Transform render_matrix;
render_matrix.Translate(0.5 * output_rect.width() + output_rect.x(),
@@ -3953,3 +3960,5 @@ gfx::Size GLRenderer::GetRenderPassBackingPixelSize(
@@ -3988,3 +3995,5 @@ gfx::Size GLRenderer::GetRenderPassBackingPixelSize(
}
} // namespace viz
+
+#undef PATCH_CS
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc
index 8ecb551119ccdbe8e8582c7005824073187cb600..f31208b13bf2e30656bf5696f507e3ac2cb25229 100644
index 25c87b7abbe3c373b08a516195c63f5b86fc32d2..261d9a25e9bfe8cca52a2b24f2bbc689f51c7035 100644
--- a/content/browser/gpu/gpu_process_host.cc
+++ b/content/browser/gpu/gpu_process_host.cc
@@ -193,6 +193,7 @@ GpuTerminationStatus ConvertToGpuTerminationStatus(
@@ -215,7 +232,7 @@ index 8ecb551119ccdbe8e8582c7005824073187cb600..f31208b13bf2e30656bf5696f507e3ac
service_manager::switches::kGpuSandboxAllowSysVShm,
service_manager::switches::kGpuSandboxFailuresFatal,
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 2336db9feacf5d96107155659611f64297040eac..7f89c9e3141dfa5fe88410b138d138108b8ec6ff 100644
index 83929bba02b4581f8977b29c9e0d5ada5f07e578..b9534d7136aee61541f8e3660352c2ba5a29c07b 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -218,6 +218,7 @@
@@ -235,10 +252,10 @@ index 2336db9feacf5d96107155659611f64297040eac..7f89c9e3141dfa5fe88410b138d13810
network::switches::kExplicitlyAllowedPorts,
service_manager::switches::kDisableInProcessStackTraces,
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 1598494eb013868e2ad8b6ce8aa32742e5819ae3..0fcd5dd582ffaea0b4c3867809529c4ab900f1be 100644
index 1d8ba6af8f7d8466a65a0c15184e9d8feff8d262..c8e8056740dd21e3f8b4d73d24388b7b9369595a 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -2846,6 +2846,9 @@ cc::LayerTreeSettings RenderWidget::GenerateLayerTreeSettings(
@@ -2891,6 +2891,9 @@ cc::LayerTreeSettings RenderWidget::GenerateLayerTreeSettings(
settings.main_frame_before_activation_enabled =
cmd.HasSwitch(cc::switches::kEnableMainFrameBeforeActivation);
@@ -248,6 +265,42 @@ index 1598494eb013868e2ad8b6ce8aa32742e5819ae3..0fcd5dd582ffaea0b4c3867809529c4a
// Checkerimaging is not supported for synchronous single-threaded mode, which
// is what the renderer uses if its not threaded.
settings.enable_checker_imaging =
diff --git a/third_party/blink/renderer/platform/graphics/canvas_color_params.cc b/third_party/blink/renderer/platform/graphics/canvas_color_params.cc
index 1aedba288aed698fd1b7ac6a4ef1a67fc892f84a..df2b5b120483225c2bd21a337e6085dbceca4ec4 100644
--- a/third_party/blink/renderer/platform/graphics/canvas_color_params.cc
+++ b/third_party/blink/renderer/platform/graphics/canvas_color_params.cc
@@ -12,6 +12,7 @@
#include "third_party/khronos/GLES3/gl3.h"
#include "third_party/skia/include/core/SkSurfaceProps.h"
#include "ui/gfx/color_space.h"
+#include "ui/gfx/switches.h"
namespace blink {
@@ -89,6 +90,11 @@ uint8_t CanvasColorParams::BytesPerPixel() const {
}
gfx::ColorSpace CanvasColorParams::GetSamplerGfxColorSpace() const {
+ auto* cmd_line = base::CommandLine::ForCurrentProcess();
+ if (cmd_line->HasSwitch(switches::kDisableColorCorrectRendering)) {
+ return gfx::ColorSpace();
+ }
+
gfx::ColorSpace::PrimaryID primary_id = GetPrimaryID(color_space_);
// TODO(ccameron): This needs to take into account whether or not this texture
@@ -102,6 +108,11 @@ gfx::ColorSpace CanvasColorParams::GetSamplerGfxColorSpace() const {
}
gfx::ColorSpace CanvasColorParams::GetStorageGfxColorSpace() const {
+ auto* cmd_line = base::CommandLine::ForCurrentProcess();
+ if (cmd_line->HasSwitch(switches::kDisableColorCorrectRendering)) {
+ return gfx::ColorSpace();
+ }
+
gfx::ColorSpace::PrimaryID primary_id = GetPrimaryID(color_space_);
gfx::ColorSpace::TransferID transfer_id =
diff --git a/ui/gfx/mac/io_surface.cc b/ui/gfx/mac/io_surface.cc
index 41f7fcbdd63af315f4b4e768bfef3b5004807a0b..398a4fdea3cc0ab4f5132deeb9365189f9c928c3 100644
--- a/ui/gfx/mac/io_surface.cc

View File

@@ -5,7 +5,7 @@ Subject: disable_hidden.patch
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index cfa68bf03b9934c8d83b7d81932a21300884345e..29603fc302f32765deaebbd6199a9e460372cbb9 100644
index e9e0afaa606ceb5df0ef8845dd1d634cb2446d0e..cb7a31d1b11e0280f7f9f3d2410cdd83e614284f 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -676,6 +676,9 @@ void RenderWidgetHostImpl::WasHidden() {
@@ -19,7 +19,7 @@ index cfa68bf03b9934c8d83b7d81932a21300884345e..29603fc302f32765deaebbd6199a9e46
TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::WasHidden");
diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h
index a3f9a2d865cc9b81806e03388a82f9bc9c22ee9d..960946f6e32cf60827e38961681c104363163046 100644
index 3620b4616a6e4ed3b394886d3b5045a6d789090f..3e3189dd4ecd0d4792971247bdab720f296bea2b 100644
--- a/content/browser/renderer_host/render_widget_host_impl.h
+++ b/content/browser/renderer_host/render_widget_host_impl.h
@@ -183,6 +183,9 @@ class CONTENT_EXPORT RenderWidgetHostImpl

View File

@@ -6,10 +6,10 @@ Subject: disable_user_gesture_requirement_for_beforeunload_dialogs.patch
See https://github.com/electron/electron/issues/10754
diff --git a/third_party/blink/renderer/core/dom/document.cc b/third_party/blink/renderer/core/dom/document.cc
index 5635284986003f6abb288f0dcf04c333ecd0f146..4c048f1af5a96cfdcaa64452feff5d3dacdce06a 100644
index 9265249b5e4ae62cdd84176564e12ab618710d6c..44d5a495824e12a9303c4d7bbd383c50ac334aba 100644
--- a/third_party/blink/renderer/core/dom/document.cc
+++ b/third_party/blink/renderer/core/dom/document.cc
@@ -4197,7 +4197,9 @@ bool Document::DispatchBeforeUnloadEvent(ChromeClient* chrome_client,
@@ -4159,7 +4159,9 @@ bool Document::DispatchBeforeUnloadEvent(ChromeClient* chrome_client,
"frame that never had a user gesture since its load. "
"https://www.chromestatus.com/feature/5082396709879808";
Intervention::GenerateReport(frame_, "BeforeUnloadNoGesture", message);

View File

@@ -7,10 +7,10 @@ Compilation of those files fails with the Chromium 68.
Remove the patch during the Chromium 69 upgrade.
diff --git a/third_party/blink/renderer/platform/BUILD.gn b/third_party/blink/renderer/platform/BUILD.gn
index f579983f844c07e4feb52ebab1b26ad2cee4bc43..cd08db785ffa8f8df5e4a558ae93ef0451289245 100644
index 0e85ec3df1b838bc00571de76e0537b2781b35e9..3fd41083e06f310817b146be56a9e553573a02a3 100644
--- a/third_party/blink/renderer/platform/BUILD.gn
+++ b/third_party/blink/renderer/platform/BUILD.gn
@@ -1758,7 +1758,7 @@ jumbo_source_set("blink_platform_unittests_sources") {
@@ -1754,7 +1754,7 @@ jumbo_source_set("blink_platform_unittests_sources") {
"graphics/paint/drawing_display_item_test.cc",
"graphics/paint/drawing_recorder_test.cc",
"graphics/paint/float_clip_rect_test.cc",

View File

@@ -33,10 +33,10 @@ index 0ccfe130f00ec3b6c75cd8ee04d5a2777e1fd00c..653829457d58bf92057cc36aa8a28970
DISALLOW_COPY_AND_ASSIGN(StaticHttpUserAgentSettings);
};
diff --git a/services/network/network_context.cc b/services/network/network_context.cc
index 96f99d73d7043a6fe98569aa7b8deddeb2ac9b6c..79a37775ecba02c137bb9842e285185d6fc8dbc0 100644
index 82aa0b1fc28439a35ed61cc665fb2f84b031f964..98f3c27e143809b707261c125a3d363b4451b6ba 100644
--- a/services/network/network_context.cc
+++ b/services/network/network_context.cc
@@ -1103,6 +1103,13 @@ void NetworkContext::SetNetworkConditions(
@@ -1106,6 +1106,13 @@ void NetworkContext::SetNetworkConditions(
std::move(network_conditions));
}
@@ -63,10 +63,10 @@ index 8e140617acc891ad51bf98c80d49a1255cb08af6..a662dfc7104df48cdb71d91a9227ddeb
void SetEnableReferrers(bool enable_referrers) override;
#if defined(OS_CHROMEOS)
diff --git a/services/network/public/mojom/network_context.mojom b/services/network/public/mojom/network_context.mojom
index 99ad77ca1b97b9e618bb2ad4b108bb892ed5e9d7..289fb533afe44475ee4236bd6e61301eb978a358 100644
index 510e5b6d072fe0659641df9cd3441ae304c2b869..0671ed5ff69a53e6793c7e33db092150fc783601 100644
--- a/services/network/public/mojom/network_context.mojom
+++ b/services/network/public/mojom/network_context.mojom
@@ -886,6 +886,9 @@ interface NetworkContext {
@@ -898,6 +898,9 @@ interface NetworkContext {
SetNetworkConditions(mojo_base.mojom.UnguessableToken throttling_profile_id,
NetworkConditions? conditions);

View File

@@ -0,0 +1,89 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Mon, 26 Aug 2019 14:32:41 -0700
Subject: feat: add set_theme_source to allow apps to override chromiums
internal theme choice
This patch is required as Chromium doesn't currently let folks using
//ui override the theme choice in NativeTheme. It defaults to
respecting the OS theme choice and some apps don't always want to do
that. With this patch we can override the theme value that Chromium
uses internally for things like menus and devtools.
We can remove this patch once it has in some shape been upstreamed.
diff --git a/ui/native_theme/native_theme.cc b/ui/native_theme/native_theme.cc
index 929e339487b7d2b4407cff069944f7a2cc1266a4..4abf0933df57651f36dbb6a1652b2de534a82639 100644
--- a/ui/native_theme/native_theme.cc
+++ b/ui/native_theme/native_theme.cc
@@ -40,6 +40,8 @@ NativeTheme::NativeTheme()
NativeTheme::~NativeTheme() = default;
bool NativeTheme::ShouldUseDarkColors() const {
+ if (theme_source() == ThemeSource::kForcedLight) return false;
+ if (theme_source() == ThemeSource::kForcedDark) return true;
return should_use_dark_colors_;
}
diff --git a/ui/native_theme/native_theme.h b/ui/native_theme/native_theme.h
index 70389e0245993faa2c17e9deefeb000280ef2368..cef1c0d4706e7e720a4004ca54765a39fc29c5e8 100644
--- a/ui/native_theme/native_theme.h
+++ b/ui/native_theme/native_theme.h
@@ -429,6 +429,22 @@ class NATIVE_THEME_EXPORT NativeTheme {
ColorId color_id,
ColorScheme color_scheme = ColorScheme::kDefault) const = 0;
+ enum ThemeSource {
+ kSystem,
+ kForcedDark,
+ kForcedLight,
+ };
+
+ ThemeSource theme_source() const {
+ return theme_source_;
+ }
+
+ void set_theme_source(ThemeSource theme_source) {
+ bool original = ShouldUseDarkColors();
+ theme_source_ = theme_source;
+ if (ShouldUseDarkColors() != original) NotifyObservers();
+ }
+
// Returns a shared instance of the native theme that should be used for web
// rendering. Do not use it in a normal application context (i.e. browser).
// The returned object should not be deleted by the caller. This function is
@@ -547,6 +563,8 @@ class NATIVE_THEME_EXPORT NativeTheme {
PreferredColorScheme preferred_color_scheme_ =
PreferredColorScheme::kNoPreference;
+ ThemeSource theme_source_ = ThemeSource::kSystem;
+
DISALLOW_COPY_AND_ASSIGN(NativeTheme);
};
diff --git a/ui/native_theme/native_theme_dark_aura.cc b/ui/native_theme/native_theme_dark_aura.cc
index a8fbfee3b13672902aac05fd5a65fa8ee81f9f7e..1be6369acf0b7c02a6f862636c2b2de1fbf8cb5a 100644
--- a/ui/native_theme/native_theme_dark_aura.cc
+++ b/ui/native_theme/native_theme_dark_aura.cc
@@ -20,6 +20,8 @@ SkColor NativeThemeDarkAura::GetSystemColor(ColorId color_id,
}
bool NativeThemeDarkAura::ShouldUseDarkColors() const {
+ if (theme_source() == ThemeSource::kForcedLight) return false;
+ if (theme_source() == ThemeSource::kForcedDark) return true;
return true;
}
diff --git a/ui/native_theme/native_theme_win.cc b/ui/native_theme/native_theme_win.cc
index 3003643bfb78cec2f5e84fc9e1471e1ef54aae41..06f2cbc84401958d49445f4ce6acb1b2fef0aa04 100644
--- a/ui/native_theme/native_theme_win.cc
+++ b/ui/native_theme/native_theme_win.cc
@@ -611,6 +611,8 @@ bool NativeThemeWin::ShouldUseDarkColors() const {
// ...unless --force-dark-mode was specified in which case caveat emptor.
if (UsesHighContrastColors() && !IsForcedDarkMode())
return false;
+ if (theme_source() == ThemeSource::kForcedLight) return false;
+ if (theme_source() == ThemeSource::kForcedDark) return true;
return NativeTheme::ShouldUseDarkColors();
}

View File

@@ -5,16 +5,20 @@ Subject: fix: disabling compositor recycling
Compositor recycling is useful for Chrome because there can be many tabs and spinning up a compositor for each one would be costly. In practice, Chrome uses the parent compositor code path of browser_compositor_view_mac.mm; the NSView of each tab is detached when it's hidden and attached when it's shown. For Electron, there is no parent compositor, so we're forced into the "own compositor" code path, which seems to be non-optimal and pretty ruthless in terms of the release of resources. Electron has no real concept of multiple tabs per window, so it should be okay to disable this ruthless recycling altogether in Electron.
diff --git a/content/browser/renderer_host/browser_compositor_view_mac.mm b/content/browser/renderer_host/browser_compositor_view_mac.mm
index 18019d5794f688ca07b35a665cc9800bb1d3047a..60c7e980dd322ba012c564fca68848c3188ca5dc 100644
--- a/content/browser/renderer_host/browser_compositor_view_mac.mm
+++ b/content/browser/renderer_host/browser_compositor_view_mac.mm
@@ -209,7 +209,7 @@
}
void BrowserCompositorMac::SetRenderWidgetHostIsHidden(bool hidden) {
- render_widget_host_is_hidden_ = hidden;
+ render_widget_host_is_hidden_ = false;
UpdateState();
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 9f36053c15a9895677c791e1578d16bc867c4265..e74b668f20bea632e09eb1ef016cfa52fc229668 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -487,7 +487,11 @@
return;
host()->WasHidden();
- browser_compositor_->SetRenderWidgetHostIsHidden(true);
+ // Consider the RWHV occluded only if it is not attached to a window
+ // (e.g. unattached BrowserView). Otherwise we treat it as visible to
+ // prevent unnecessary compositor recycling.
+ const bool unattached = ![GetInProcessNSView() window];
+ browser_compositor_->SetRenderWidgetHostIsHidden(unattached);
}
void RenderWidgetHostViewMac::SetSize(const gfx::Size& size) {

View File

@@ -42,10 +42,10 @@ index 906a1ee4ac58b0744a32153bbaafeac4322a60e4..c90f4aead36cbf3767dc5094728963c2
// another SiteInstance for the same site.
void RegisterSiteInstance(SiteInstanceImpl* site_instance);
diff --git a/content/browser/frame_host/render_frame_host_manager.cc b/content/browser/frame_host/render_frame_host_manager.cc
index eecfdbd9aa067f912c0d1c6feb6217b5fb6efa8a..d7fed5faea2a1096efc299bd222738d453dec3a7 100644
index 9cf70d305a6d149595e93ad5766f7abeac371205..3e7385d5cbe489a4183c10d9420abd85cd3f6e7b 100644
--- a/content/browser/frame_host/render_frame_host_manager.cc
+++ b/content/browser/frame_host/render_frame_host_manager.cc
@@ -2228,6 +2228,21 @@ bool RenderFrameHostManager::InitRenderView(
@@ -2191,6 +2191,21 @@ bool RenderFrameHostManager::InitRenderView(
scoped_refptr<SiteInstance>
RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
const NavigationRequest& request) {
@@ -67,7 +67,7 @@ index eecfdbd9aa067f912c0d1c6feb6217b5fb6efa8a..d7fed5faea2a1096efc299bd222738d4
SiteInstance* current_site_instance = render_frame_host_->GetSiteInstance();
// All children of MHTML documents must be MHTML documents. They all live in
@@ -2272,6 +2287,59 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
@@ -2235,6 +2250,59 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
request.common_params().url);
no_renderer_swap_allowed |=
request.from_begin_navigation() && !can_renderer_initiate_transfer;
@@ -127,7 +127,7 @@ index eecfdbd9aa067f912c0d1c6feb6217b5fb6efa8a..d7fed5faea2a1096efc299bd222738d4
} else {
// Subframe navigations will use the current renderer, unless specifically
// allowed to swap processes.
@@ -2283,23 +2351,28 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
@@ -2246,23 +2314,28 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
if (no_renderer_swap_allowed && !should_swap_for_error_isolation)
return scoped_refptr<SiteInstance>(current_site_instance);

View File

@@ -38,7 +38,7 @@ index 743d1364bcd13e24ecbe5ced730161d15b8c3e93..a7e81072194c00baa0aa3159a6bfe374
// is concerned.
@property(nonatomic, readonly) NSString* subrole;
diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm
index bc2344332d2b8899628cd7c01d7b66eedbd1b4d0..08b3b94153624f36035f98d387530a0daf398447 100644
index 0a6c3c488c71106f23779481ccec92c0aa8b6bbf..ac2343f648ba3db19ffcb1fc1503e5d68cdb5135 100644
--- a/content/browser/accessibility/browser_accessibility_cocoa.mm
+++ b/content/browser/accessibility/browser_accessibility_cocoa.mm
@@ -225,6 +225,7 @@
@@ -49,7 +49,7 @@ index bc2344332d2b8899628cd7c01d7b66eedbd1b4d0..08b3b94153624f36035f98d387530a0d
extern "C" {
// The following are private accessibility APIs required for cursor navigation
@@ -422,6 +423,7 @@ void AddMisspelledTextAttributes(const AXPlatformRange& ax_range,
@@ -432,6 +433,7 @@ void AddMisspelledTextAttributes(const AXPlatformRange& ax_range,
AddMisspelledTextAttributes(ax_range, attributed_text);
return attributed_text;
}
@@ -57,7 +57,7 @@ index bc2344332d2b8899628cd7c01d7b66eedbd1b4d0..08b3b94153624f36035f98d387530a0d
// Returns an autoreleased copy of the AXNodeData's attribute.
NSString* NSStringForStringAttribute(BrowserAccessibility* browserAccessibility,
@@ -689,7 +691,9 @@ + (void)initialize {
@@ -699,7 +701,9 @@ + (void)initialize {
{NSAccessibilityEditableAncestorAttribute, @"editableAncestor"},
{NSAccessibilityElementBusyAttribute, @"elementBusy"},
{NSAccessibilityEnabledAttribute, @"enabled"},
@@ -67,7 +67,7 @@ index bc2344332d2b8899628cd7c01d7b66eedbd1b4d0..08b3b94153624f36035f98d387530a0d
{NSAccessibilityExpandedAttribute, @"expanded"},
{NSAccessibilityFocusableAncestorAttribute, @"focusableAncestor"},
{NSAccessibilityFocusedAttribute, @"focused"},
@@ -724,13 +728,17 @@ + (void)initialize {
@@ -734,13 +738,17 @@ + (void)initialize {
{NSAccessibilityRowsAttribute, @"rows"},
// TODO(aboxhall): expose
// NSAccessibilityServesAsTitleForUIElementsAttribute
@@ -85,7 +85,7 @@ index bc2344332d2b8899628cd7c01d7b66eedbd1b4d0..08b3b94153624f36035f98d387530a0d
{NSAccessibilitySizeAttribute, @"size"},
{NSAccessibilitySortDirectionAttribute, @"sortDirection"},
{NSAccessibilitySubroleAttribute, @"subrole"},
@@ -1228,6 +1236,7 @@ - (NSNumber*)enabled {
@@ -1238,6 +1246,7 @@ - (NSNumber*)enabled {
ax::mojom::Restriction::kDisabled];
}
@@ -93,7 +93,7 @@ index bc2344332d2b8899628cd7c01d7b66eedbd1b4d0..08b3b94153624f36035f98d387530a0d
// Returns a text marker that points to the last character in the document that
// can be selected with VoiceOver.
- (id)endTextMarker {
@@ -1238,6 +1247,7 @@ - (id)endTextMarker {
@@ -1248,6 +1257,7 @@ - (id)endTextMarker {
BrowserAccessibilityPositionInstance position = root->CreatePositionAt(0);
return CreateTextMarker(position->CreatePositionAtEndOfAnchor());
}
@@ -101,7 +101,7 @@ index bc2344332d2b8899628cd7c01d7b66eedbd1b4d0..08b3b94153624f36035f98d387530a0d
- (NSNumber*)expanded {
if (![self instanceActive])
@@ -2109,6 +2119,7 @@ - (NSValue*)selectedTextRange {
@@ -2119,6 +2129,7 @@ - (NSValue*)selectedTextRange {
return [NSValue valueWithRange:NSMakeRange(selStart, selLength)];
}
@@ -109,7 +109,7 @@ index bc2344332d2b8899628cd7c01d7b66eedbd1b4d0..08b3b94153624f36035f98d387530a0d
- (id)selectedTextMarkerRange {
if (![self instanceActive])
return nil;
@@ -2144,6 +2155,7 @@ - (id)selectedTextMarkerRange {
@@ -2154,6 +2165,7 @@ - (id)selectedTextMarkerRange {
CreateAXPlatformRange(*anchorObject, anchorOffset, anchorAffinity,
*focusObject, focusOffset, focusAffinity));
}
@@ -117,7 +117,7 @@ index bc2344332d2b8899628cd7c01d7b66eedbd1b4d0..08b3b94153624f36035f98d387530a0d
- (NSValue*)size {
if (![self instanceActive])
@@ -2176,6 +2188,7 @@ - (NSString*)sortDirection {
@@ -2186,6 +2198,7 @@ - (NSString*)sortDirection {
return nil;
}
@@ -125,7 +125,7 @@ index bc2344332d2b8899628cd7c01d7b66eedbd1b4d0..08b3b94153624f36035f98d387530a0d
// Returns a text marker that points to the first character in the document that
// can be selected with VoiceOver.
- (id)startTextMarker {
@@ -2186,6 +2199,7 @@ - (id)startTextMarker {
@@ -2196,6 +2209,7 @@ - (id)startTextMarker {
BrowserAccessibilityPositionInstance position = root->CreatePositionAt(0);
return CreateTextMarker(position->CreatePositionAtStartOfAnchor());
}
@@ -133,7 +133,7 @@ index bc2344332d2b8899628cd7c01d7b66eedbd1b4d0..08b3b94153624f36035f98d387530a0d
// Returns a subrole based upon the role.
- (NSString*)subrole {
@@ -2477,11 +2491,13 @@ - (NSAttributedString*)attributedValueForRange:(NSRange)range {
@@ -2487,11 +2501,13 @@ - (NSAttributedString*)attributedValueForRange:(NSRange)range {
NSMutableAttributedString* attributedValue =
[[[NSMutableAttributedString alloc] initWithString:value] autorelease];
@@ -147,7 +147,7 @@ index bc2344332d2b8899628cd7c01d7b66eedbd1b4d0..08b3b94153624f36035f98d387530a0d
return [attributedValue attributedSubstringFromRange:range];
}
@@ -2564,9 +2580,8 @@ - (id)accessibilityAttributeValue:(NSString*)attribute
@@ -2574,9 +2590,8 @@ - (id)accessibilityAttributeValue:(NSString*)attribute
return ToBrowserAccessibilityCocoa(cell);
}
@@ -159,7 +159,7 @@ index bc2344332d2b8899628cd7c01d7b66eedbd1b4d0..08b3b94153624f36035f98d387530a0d
BrowserAccessibilityPositionInstance position =
CreatePositionFromTextMarker(parameter);
if (!position->IsNullPosition())
@@ -2856,6 +2871,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute
@@ -2866,6 +2881,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute
return CreateTextMarker(root->CreatePositionAt(index));
}
@@ -167,7 +167,7 @@ index bc2344332d2b8899628cd7c01d7b66eedbd1b4d0..08b3b94153624f36035f98d387530a0d
if ([attribute isEqualToString:
NSAccessibilityBoundsForRangeParameterizedAttribute]) {
@@ -2889,6 +2905,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute
@@ -2899,6 +2915,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute
return nil;
}
@@ -175,7 +175,7 @@ index bc2344332d2b8899628cd7c01d7b66eedbd1b4d0..08b3b94153624f36035f98d387530a0d
if ([attribute
isEqualToString:
NSAccessibilityLineTextMarkerRangeForTextMarkerParameterizedAttribute]) {
@@ -2969,6 +2986,7 @@ AXPlatformRange range(position->CreatePreviousLineStartPosition(
@@ -2979,6 +2996,7 @@ AXPlatformRange range(position->CreatePreviousLineStartPosition(
return @(child->GetIndexInParent());
}

View File

@@ -5,7 +5,7 @@ Subject: network_service_allow_remote_certificate_verification_logic.patch
diff --git a/services/network/network_context.cc b/services/network/network_context.cc
index 3a0e058eaefbff034e279d85007a91e874bd716c..96f99d73d7043a6fe98569aa7b8deddeb2ac9b6c 100644
index 42805ff8756d37de0aafcf478a66cbef36481f62..82aa0b1fc28439a35ed61cc665fb2f84b031f964 100644
--- a/services/network/network_context.cc
+++ b/services/network/network_context.cc
@@ -91,6 +91,11 @@
@@ -100,7 +100,7 @@ index 3a0e058eaefbff034e279d85007a91e874bd716c..96f99d73d7043a6fe98569aa7b8dedde
constexpr uint32_t NetworkContext::kMaxOutstandingRequestsPerProcess;
constexpr bool NetworkContext::enable_resource_scheduler_;
@@ -652,6 +730,13 @@ void NetworkContext::SetClient(
@@ -655,6 +733,13 @@ void NetworkContext::SetClient(
client_.Bind(std::move(client));
}
@@ -114,7 +114,7 @@ index 3a0e058eaefbff034e279d85007a91e874bd716c..96f99d73d7043a6fe98569aa7b8dedde
void NetworkContext::CreateURLLoaderFactory(
mojom::URLLoaderFactoryRequest request,
mojom::URLLoaderFactoryParamsPtr params) {
@@ -1726,12 +1811,19 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext() {
@@ -1729,12 +1814,19 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext() {
cert_net_fetcher_, /*system_trust_store_provider=*/nullptr)));
}
#endif
@@ -169,10 +169,10 @@ index 608553fccbc393ab819517b16c124c062d3c9597..8e140617acc891ad51bf98c80d49a125
// CertNetFetcher is not used by the current platform.
scoped_refptr<net::CertNetFetcherImpl> cert_net_fetcher_;
diff --git a/services/network/public/mojom/network_context.mojom b/services/network/public/mojom/network_context.mojom
index bc748d27288fd5df283cc01ecf688e62dfaee78a..99ad77ca1b97b9e618bb2ad4b108bb892ed5e9d7 100644
index 603173892e233d8e992eb2ccc32b3dea82f33f7e..510e5b6d072fe0659641df9cd3441ae304c2b869 100644
--- a/services/network/public/mojom/network_context.mojom
+++ b/services/network/public/mojom/network_context.mojom
@@ -165,6 +165,17 @@ interface TrustedURLLoaderHeaderClient {
@@ -168,6 +168,17 @@ interface TrustedURLLoaderHeaderClient {
pending_receiver<TrustedHeaderClient> header_client);
};
@@ -190,7 +190,7 @@ index bc748d27288fd5df283cc01ecf688e62dfaee78a..99ad77ca1b97b9e618bb2ad4b108bb89
// Parameters for constructing a network context.
struct NetworkContextParams {
// Name used by memory tools to identify the context.
@@ -724,6 +735,9 @@ interface NetworkContext {
@@ -736,6 +747,9 @@ interface NetworkContext {
// Sets a client for this network context.
SetClient(pending_remote<NetworkContextClient> client);

View File

@@ -394,7 +394,7 @@ index a134a000bd3ccb229a26b3e2cb3425f91a85618e..fd768d372ac15be9b0553fd7d98ce5e2
// Like PrintMsg_PrintPages, but using the print preview document's frame/node.
IPC_MESSAGE_ROUTED0(PrintMsg_PrintForSystemDialog)
diff --git a/components/printing/renderer/print_render_frame_helper.cc b/components/printing/renderer/print_render_frame_helper.cc
index 626edef2b046ad72e0a3b80cb7831be80fab3d89..6b7ca8e6132f4e5647a0e7164ffcca106a904746 100644
index 86f8ab3356344c3e617c6dc932c90f3b64c890b9..b9a4d91971034376964fdf855b5d7690e5327fe1 100644
--- a/components/printing/renderer/print_render_frame_helper.cc
+++ b/components/printing/renderer/print_render_frame_helper.cc
@@ -38,6 +38,7 @@
@@ -405,7 +405,7 @@ index 626edef2b046ad72e0a3b80cb7831be80fab3d89..6b7ca8e6132f4e5647a0e7164ffcca10
#include "printing/units.h"
#include "third_party/blink/public/common/frame/frame_owner_element_type.h"
#include "third_party/blink/public/common/frame/sandbox_flags.h"
@@ -1129,7 +1130,8 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) {
@@ -1125,7 +1126,8 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) {
web_frame->DispatchBeforePrintEvent();
if (!weak_this)
return;
@@ -415,7 +415,7 @@ index 626edef2b046ad72e0a3b80cb7831be80fab3d89..6b7ca8e6132f4e5647a0e7164ffcca10
if (weak_this)
web_frame->DispatchAfterPrintEvent();
}
@@ -1177,7 +1179,9 @@ void PrintRenderFrameHelper::OnDestruct() {
@@ -1173,7 +1175,9 @@ void PrintRenderFrameHelper::OnDestruct() {
delete this;
}
@@ -426,7 +426,7 @@ index 626edef2b046ad72e0a3b80cb7831be80fab3d89..6b7ca8e6132f4e5647a0e7164ffcca10
if (ipc_nesting_level_ > 1)
return;
@@ -1190,7 +1194,8 @@ void PrintRenderFrameHelper::OnPrintPages() {
@@ -1186,7 +1190,8 @@ void PrintRenderFrameHelper::OnPrintPages() {
// If we are printing a PDF extension frame, find the plugin node and print
// that instead.
auto plugin = delegate_->GetPdfElement(frame);
@@ -436,7 +436,7 @@ index 626edef2b046ad72e0a3b80cb7831be80fab3d89..6b7ca8e6132f4e5647a0e7164ffcca10
if (weak_this)
frame->DispatchAfterPrintEvent();
// WARNING: |this| may be gone at this point. Do not do any more work here and
@@ -1207,7 +1212,7 @@ void PrintRenderFrameHelper::OnPrintForSystemDialog() {
@@ -1203,7 +1208,7 @@ void PrintRenderFrameHelper::OnPrintForSystemDialog() {
}
auto weak_this = weak_ptr_factory_.GetWeakPtr();
Print(frame, print_preview_context_.source_node(),
@@ -445,7 +445,7 @@ index 626edef2b046ad72e0a3b80cb7831be80fab3d89..6b7ca8e6132f4e5647a0e7164ffcca10
if (weak_this)
frame->DispatchAfterPrintEvent();
// WARNING: |this| may be gone at this point. Do not do any more work here and
@@ -1243,6 +1248,8 @@ void PrintRenderFrameHelper::OnPrintPreview(
@@ -1239,6 +1244,8 @@ void PrintRenderFrameHelper::OnPrintPreview(
if (ipc_nesting_level_ > 1)
return;
@@ -454,7 +454,7 @@ index 626edef2b046ad72e0a3b80cb7831be80fab3d89..6b7ca8e6132f4e5647a0e7164ffcca10
print_preview_context_.OnPrintPreview();
UMA_HISTOGRAM_ENUMERATION("PrintPreview.PreviewEvent",
@@ -1635,7 +1642,9 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
@@ -1631,7 +1638,9 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
auto self = weak_ptr_factory_.GetWeakPtr();
Print(duplicate_node.GetDocument().GetFrame(), duplicate_node,
@@ -465,7 +465,7 @@ index 626edef2b046ad72e0a3b80cb7831be80fab3d89..6b7ca8e6132f4e5647a0e7164ffcca10
// Check if |this| is still valid.
if (!self)
return;
@@ -1646,7 +1655,9 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
@@ -1642,7 +1651,9 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
const blink::WebNode& node,
@@ -476,7 +476,7 @@ index 626edef2b046ad72e0a3b80cb7831be80fab3d89..6b7ca8e6132f4e5647a0e7164ffcca10
// If still not finished with earlier print request simply ignore.
if (prep_frame_view_)
return;
@@ -1654,7 +1665,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
@@ -1650,7 +1661,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
FrameReference frame_ref(frame);
int expected_page_count = 0;
@@ -485,7 +485,7 @@ index 626edef2b046ad72e0a3b80cb7831be80fab3d89..6b7ca8e6132f4e5647a0e7164ffcca10
DidFinishPrinting(FAIL_PRINT_INIT);
return; // Failed to init print page settings.
}
@@ -1674,8 +1685,11 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
@@ -1670,8 +1681,11 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
PrintMsg_PrintPages_Params print_settings;
auto self = weak_ptr_factory_.GetWeakPtr();
@@ -499,7 +499,7 @@ index 626edef2b046ad72e0a3b80cb7831be80fab3d89..6b7ca8e6132f4e5647a0e7164ffcca10
// Check if |this| is still valid.
if (!self)
return;
@@ -1882,10 +1896,23 @@ std::vector<int> PrintRenderFrameHelper::GetPrintedPages(
@@ -1878,10 +1892,23 @@ std::vector<int> PrintRenderFrameHelper::GetPrintedPages(
return printed_pages;
}
@@ -526,7 +526,7 @@ index 626edef2b046ad72e0a3b80cb7831be80fab3d89..6b7ca8e6132f4e5647a0e7164ffcca10
// Check if the printer returned any settings, if the settings is empty, we
// can safely assume there are no printer drivers configured. So we safely
// terminate.
@@ -1905,12 +1932,14 @@ bool PrintRenderFrameHelper::InitPrintSettings(bool fit_to_paper_size) {
@@ -1901,12 +1928,14 @@ bool PrintRenderFrameHelper::InitPrintSettings(bool fit_to_paper_size) {
return result;
}

View File

@@ -6,10 +6,10 @@ Subject: scroll_bounce_flag.patch
Patch to make scrollBounce option work.
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 03615f48d5c11932ee496da942fbc3ee193c6fa0..1219939cd51db9e4a7b260258ec371b4a01d3a15 100644
index f133e1651a27458d4bd5ba05ba341635e8d5b8f3..98e5c3b963c4fde6e55a633b686b6f6a47b49212 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -1526,7 +1526,7 @@ bool RenderThreadImpl::IsGpuMemoryBufferCompositorResourcesEnabled() {
@@ -1509,7 +1509,7 @@ bool RenderThreadImpl::IsGpuMemoryBufferCompositorResourcesEnabled() {
}
bool RenderThreadImpl::IsElasticOverscrollEnabled() {

View File

@@ -22,7 +22,7 @@ However, the patch would need to be reviewed by the security team, as it
does touch a security-sensitive class.
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 111796d24ceece54d7664954005b8fe3d86ed4e2..2336db9feacf5d96107155659611f64297040eac 100644
index 8379cdfcf922bd1d4133507c0dc3089c6b81b366..83929bba02b4581f8977b29c9e0d5ada5f07e578 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -389,6 +389,17 @@ class RendererSandboxedProcessLauncherDelegate

View File

@@ -5,7 +5,7 @@ Subject: web_contents.patch
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index a4e4a612d82c856c1e02e2d04c3dd210ffa0da9f..5613811d4a41694a6ff53f289c9b95210bd04c23 100644
index fbc1dc348385a9a1b97405342ded52e2308baf2c..b894dbb3d435ed3302bdd8e667ac0e628404a932 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2137,6 +2137,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {

View File

@@ -5,10 +5,10 @@ Subject: webview_cross_drag.patch
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc
index dda92e4006db1d9a1b68459644d252a3e1dfa4a2..3ed0b3ec3badc9f558f78adbdb31c680ff2631f4 100644
index 15e5f49d6f48c7ca33bfe6ca6a6b01629e8c07ba..05cd273a0f2df55738f437f4435b39b671ae694e 100644
--- a/content/browser/web_contents/web_contents_view_aura.cc
+++ b/content/browser/web_contents/web_contents_view_aura.cc
@@ -777,6 +777,7 @@ gfx::NativeView WebContentsViewAura::GetRenderWidgetHostViewParent() const {
@@ -781,6 +781,7 @@ gfx::NativeView WebContentsViewAura::GetRenderWidgetHostViewParent() const {
bool WebContentsViewAura::IsValidDragTarget(
RenderWidgetHostImpl* target_rwh) const {

View File

@@ -5,10 +5,10 @@ Subject: worker_context_will_destroy.patch
diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h
index f4d048c6ae7887bea203a3bf65c11ad56c0f26ac..b9f347f8ce3e7580592ee24591d85751d06a30cd 100644
index 7d53414dfbe7014b1cb11183804c10c57510c5a1..3d24f2a41ceb0577990f0f04da2d44e0f842056f 100644
--- a/content/public/renderer/content_renderer_client.h
+++ b/content/public/renderer/content_renderer_client.h
@@ -386,6 +386,11 @@ class CONTENT_EXPORT ContentRendererClient {
@@ -377,6 +377,11 @@ class CONTENT_EXPORT ContentRendererClient {
virtual void DidInitializeWorkerContextOnWorkerThread(
v8::Local<v8::Context> context) {}
@@ -21,10 +21,10 @@ index f4d048c6ae7887bea203a3bf65c11ad56c0f26ac..b9f347f8ce3e7580592ee24591d85751
// An empty URL is returned if the URL is not overriden.
virtual GURL OverrideFlashEmbedWithHTML(const GURL& url);
diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc
index 2a4eca9797a59f2c3f71c8cf646426b025cc05de..b9175d2fd166cdb9e43c226c1e98b02433e832cc 100644
index 6a81c4a2a94e3a253eb7c05dc185ac6cfeb94fdd..ae5a323636841b0dd82a031d5d5ed8acb26cb3d0 100644
--- a/content/renderer/renderer_blink_platform_impl.cc
+++ b/content/renderer/renderer_blink_platform_impl.cc
@@ -922,6 +922,12 @@ void RendererBlinkPlatformImpl::WillStopWorkerThread() {
@@ -924,6 +924,12 @@ void RendererBlinkPlatformImpl::WillStopWorkerThread() {
WorkerThreadRegistry::Instance()->WillStopCurrentWorkerThread();
}
@@ -38,10 +38,10 @@ index 2a4eca9797a59f2c3f71c8cf646426b025cc05de..b9175d2fd166cdb9e43c226c1e98b024
const v8::Local<v8::Context>& worker) {
GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread(
diff --git a/content/renderer/renderer_blink_platform_impl.h b/content/renderer/renderer_blink_platform_impl.h
index 10052275d638059754c1a75b1a262f0a2a852fb4..4d6b95c0224c73ef09222374caf7fee59f580f79 100644
index 0db3cf9498a186f7ed90f9e28f019b6ef5c897cb..ea05810a72b045d2ec407158b25a67c9d132732e 100644
--- a/content/renderer/renderer_blink_platform_impl.h
+++ b/content/renderer/renderer_blink_platform_impl.h
@@ -190,6 +190,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
@@ -189,6 +189,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
void DidStartWorkerThread() override;
void WillStopWorkerThread() override;
void WorkerContextCreated(const v8::Local<v8::Context>& worker) override;
@@ -50,10 +50,10 @@ index 10052275d638059754c1a75b1a262f0a2a852fb4..4d6b95c0224c73ef09222374caf7fee5
const blink::WebString& header_name) override;
diff --git a/third_party/blink/public/platform/platform.h b/third_party/blink/public/platform/platform.h
index 10eab390307b8991608a2e3daa0c0fc867d93683..fbc766418b546b774fe31ce387e657735717d542 100644
index 68051e35252c8ce6f8614f2708feaec2a417b19a..791577e9c421e880049f9bf76cc856c8cc37c756 100644
--- a/third_party/blink/public/platform/platform.h
+++ b/third_party/blink/public/platform/platform.h
@@ -672,6 +672,7 @@ class BLINK_PLATFORM_EXPORT Platform {
@@ -669,6 +669,7 @@ class BLINK_PLATFORM_EXPORT Platform {
virtual void DidStartWorkerThread() {}
virtual void WillStopWorkerThread() {}
virtual void WorkerContextCreated(const v8::Local<v8::Context>& worker) {}

View File

@@ -0,0 +1,318 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Maksim Sisov <msisov@igalia.com>
Date: Mon, 9 Sep 2019 08:06:33 +0000
Subject: X11 and Ozone: Move closing logic to DWTHPlatform
Close and CloseNow were move to DWTHPlatform. The same was done with the
container of children DWTH.
Bug: 990756
Change-Id: Ic09852c3a22e780738d98da3f4fdfee4a6741a52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1771407
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694665}
diff --git a/ui/ozone/platform/wayland/host/wayland_window.cc b/ui/ozone/platform/wayland/host/wayland_window.cc
index 386663f9b4b5ca0033a82521250ecf7b412f07b5..046241ea5ef656a52e647c0cd28891daac917e44 100644
--- a/ui/ozone/platform/wayland/host/wayland_window.cc
+++ b/ui/ozone/platform/wayland/host/wayland_window.cc
@@ -371,7 +371,7 @@ void WaylandWindow::Hide() {
}
void WaylandWindow::Close() {
- NOTIMPLEMENTED();
+ delegate_->OnClosed();
}
void WaylandWindow::PrepareForShutdown() {}
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.cc
index 606e37e1d8746183f93c9f268097713a9059d2d6..d124edaa9f57a8cd09a9a52ad7da8006e541580b 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.cc
@@ -100,19 +100,25 @@ DesktopWindowTreeHostPlatform::DesktopWindowTreeHostPlatform(
desktop_native_widget_aura_(desktop_native_widget_aura) {}
DesktopWindowTreeHostPlatform::~DesktopWindowTreeHostPlatform() {
-// TODO(msisov): Once destruction goes from DWTHX11 to DWTHPlatform, remove this
-// guard.
-#if !defined(USE_X11)
- DCHECK(got_on_closed_);
+ DCHECK(!platform_window()) << "The host must be closed before destroying it.";
desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this);
DestroyDispatcher();
-#endif
}
void DesktopWindowTreeHostPlatform::Init(const Widget::InitParams& params) {
if (params.type == Widget::InitParams::TYPE_WINDOW)
content_window()->SetProperty(aura::client::kAnimationsDisabledKey, true);
+ // If we have a parent, record the parent/child relationship. We use this
+ // data during destruction to make sure that when we try to close a parent
+ // window, we also destroy all child windows.
+ if (params.parent && params.parent->GetHost()) {
+ window_parent_ =
+ static_cast<DesktopWindowTreeHostPlatform*>(params.parent->GetHost());
+ DCHECK(window_parent_);
+ window_parent_->window_children_.insert(this);
+ }
+
ui::PlatformWindowInitProperties properties =
ConvertWidgetInitParamsToInitProperties(params);
AddAdditionalInitProperties(params, &properties);
@@ -182,37 +188,61 @@ DesktopWindowTreeHostPlatform::CreateDragDropClient(
}
void DesktopWindowTreeHostPlatform::Close() {
- if (waiting_for_close_now_)
+ // If we are in process of closing or the PlatformWindow has already been
+ // closed, do nothing.
+ if (close_widget_factory_.HasWeakPtrs() || !platform_window())
return;
- desktop_native_widget_aura_->content_window()->Hide();
+ content_window()->Hide();
// Hide while waiting for the close.
// Please note that it's better to call WindowTreeHost::Hide, which also calls
// PlatformWindow::Hide and Compositor::SetVisible(false).
Hide();
- waiting_for_close_now_ = true;
+ // And we delay the close so that if we are called from an ATL callback,
+ // we don't destroy the window before the callback returned (as the caller
+ // may delete ourselves on destroy and the ATL callback would still
+ // dereference us when the callback returns).
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&DesktopWindowTreeHostPlatform::CloseNow,
- weak_factory_.GetWeakPtr()));
-}
+ close_widget_factory_.GetWeakPtr()));
+} // namespace views
void DesktopWindowTreeHostPlatform::CloseNow() {
- auto weak_ref = weak_factory_.GetWeakPtr();
- SetWmDropHandler(platform_window(), nullptr);
- // Deleting the PlatformWindow may not result in OnClosed() being called, if
- // not behave as though it was.
- SetPlatformWindow(nullptr);
- if (!weak_ref || got_on_closed_)
+ if (!platform_window())
return;
- RemoveNonClientEventFilter();
+#if defined(USE_OZONE)
+ SetWmDropHandler(platform_window(), nullptr);
+#endif
+
+ platform_window()->PrepareForShutdown();
+ ReleaseCapture();
native_widget_delegate_->OnNativeWidgetDestroying();
- got_on_closed_ = true;
- desktop_native_widget_aura_->OnHostClosed();
+ // If we have children, close them. Use a copy for iteration because they'll
+ // remove themselves.
+ std::set<DesktopWindowTreeHostPlatform*> window_children_copy =
+ window_children_;
+ for (auto* child : window_children_copy)
+ child->CloseNow();
+ DCHECK(window_children_.empty());
+
+ // If we have a parent, remove ourselves from its children list.
+ if (window_parent_) {
+ window_parent_->window_children_.erase(this);
+ window_parent_ = nullptr;
+ }
+
+ // Destroy the compositor before destroying the |platform_window()| since
+ // shutdown may try to swap, and the swap without a window may cause an error
+ // in X Server or Wayland, which causes a crash with in-process renderer, for
+ // example.
+ DestroyCompositor();
+
+ platform_window()->Close();
}
aura::WindowTreeHost* DesktopWindowTreeHostPlatform::AsWindowTreeHost() {
@@ -597,7 +627,8 @@ void DesktopWindowTreeHostPlatform::DispatchEvent(ui::Event* event) {
void DesktopWindowTreeHostPlatform::OnClosed() {
RemoveNonClientEventFilter();
- got_on_closed_ = true;
+
+ SetPlatformWindow(nullptr);
desktop_native_widget_aura_->OnHostClosed();
}
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h b/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h
index 00ff41a2151d5360e97d6e4fb33385ae96e3b76a..7e426b43b21844c7df85202a1e008da6e6426d6b 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h
@@ -137,20 +137,22 @@ class VIEWS_EXPORT DesktopWindowTreeHostPlatform
internal::NativeWidgetDelegate* const native_widget_delegate_;
DesktopNativeWidgetAura* const desktop_native_widget_aura_;
- // Set to true when Close() is called.
- bool waiting_for_close_now_ = false;
-
- bool got_on_closed_ = false;
-
bool is_active_ = false;
base::string16 window_title_;
+ // We can optionally have a parent which can order us to close, or own
+ // children who we're responsible for closing when we CloseNow().
+ DesktopWindowTreeHostPlatform* window_parent_ = nullptr;
+ std::set<DesktopWindowTreeHostPlatform*> window_children_;
+
#if defined(OS_LINUX)
// A handler for events intended for non client area.
std::unique_ptr<WindowEventFilter> non_client_window_event_filter_;
#endif
+ base::WeakPtrFactory<DesktopWindowTreeHostPlatform> close_widget_factory_{
+ this};
base::WeakPtrFactory<DesktopWindowTreeHostPlatform> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostPlatform);
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
index 04ddfe73be4fd1f9ac9dc9a50c5c2dd2c93b3859..cdf96b6b4c5863dde0ac8d5003d3a3aa3cac514e 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
@@ -155,8 +155,9 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11(
DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() {
window()->ClearProperty(kHostForRootWindow);
wm::SetWindowMoveClient(window(), nullptr);
- desktop_native_widget_aura()->OnDesktopWindowTreeHostDestroyed(this);
- DestroyDispatcher();
+
+ // ~DWTHPlatform notifies the DestkopNativeWidgetAura about destruction and
+ // also destroyes the dispatcher.
}
// static
@@ -237,16 +238,6 @@ void DesktopWindowTreeHostX11::CleanUpWindowList(
// DesktopWindowTreeHostX11, DesktopWindowTreeHost implementation:
void DesktopWindowTreeHostX11::Init(const Widget::InitParams& params) {
- // If we have a parent, record the parent/child relationship. We use this
- // data during destruction to make sure that when we try to close a parent
- // window, we also destroy all child windows.
- if (params.parent && params.parent->GetHost()) {
- window_parent_ =
- static_cast<DesktopWindowTreeHostX11*>(params.parent->GetHost());
- DCHECK(window_parent_);
- window_parent_->window_children_.insert(this);
- }
-
DesktopWindowTreeHostPlatform::Init(params);
// Set XEventDelegate to receive selection, drag&drop and raw key events.
@@ -298,55 +289,6 @@ DesktopWindowTreeHostX11::CreateDragDropClient(
return base::WrapUnique(drag_drop_client_);
}
-void DesktopWindowTreeHostX11::Close() {
- content_window()->Hide();
-
- // TODO(erg): Might need to do additional hiding tasks here.
- GetXWindow()->CancelResize();
-
- if (!close_widget_factory_.HasWeakPtrs()) {
- // And we delay the close so that if we are called from an ATL callback,
- // we don't destroy the window before the callback returned (as the caller
- // may delete ourselves on destroy and the ATL callback would still
- // dereference us when the callback returns).
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindOnce(&DesktopWindowTreeHostX11::CloseNow,
- close_widget_factory_.GetWeakPtr()));
- }
-}
-
-void DesktopWindowTreeHostX11::CloseNow() {
- if (GetXWindow()->window() == x11::None)
- return;
- platform_window()->PrepareForShutdown();
-
- ReleaseCapture();
- RemoveNonClientEventFilter();
- native_widget_delegate()->OnNativeWidgetDestroying();
-
- // If we have children, close them. Use a copy for iteration because they'll
- // remove themselves.
- std::set<DesktopWindowTreeHostX11*> window_children_copy = window_children_;
- for (auto* child : window_children_copy)
- child->CloseNow();
- DCHECK(window_children_.empty());
-
- // If we have a parent, remove ourselves from its children list.
- if (window_parent_) {
- window_parent_->window_children_.erase(this);
- window_parent_ = nullptr;
- }
-
- // Destroy the compositor before destroying the |xwindow_| since shutdown
- // may try to swap, and the swap without a window causes an X error, which
- // causes a crash with in-process renderer.
- DestroyCompositor();
-
- open_windows().remove(GetAcceleratedWidget());
-
- platform_window()->Close();
-}
-
void DesktopWindowTreeHostX11::Show(ui::WindowShowState show_state,
const gfx::Rect& restore_bounds) {
if (compositor())
@@ -1034,7 +976,12 @@ void DesktopWindowTreeHostX11::DispatchEvent(ui::Event* event) {
}
void DesktopWindowTreeHostX11::OnClosed() {
- desktop_native_widget_aura()->OnHostClosed();
+ // Remove the event listeners we've installed. We need to remove these
+ // because otherwise we get assert during ~WindowEventDispatcher().
+ RemoveNonClientEventFilter();
+
+ open_windows().remove(GetAcceleratedWidget());
+ DesktopWindowTreeHostPlatform::OnClosed();
}
void DesktopWindowTreeHostX11::OnWindowStateChanged(
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h
index 5990a397802199f3d71860861dca9905d6f07335..5b79747f63d05fe854165b6aa84a68c8913c0eff 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h
@@ -100,8 +100,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
void OnNativeWidgetCreated(const Widget::InitParams& params) override;
std::unique_ptr<aura::client::DragDropClient> CreateDragDropClient(
DesktopNativeCursorManager* cursor_manager) override;
- void Close() override;
- void CloseNow() override;
void Show(ui::WindowShowState show_state,
const gfx::Rect& restore_bounds) override;
bool IsVisible() const override;
@@ -256,11 +254,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
std::unique_ptr<WindowEventFilter> non_client_event_filter_;
std::unique_ptr<X11DesktopWindowMoveClient> x11_window_move_client_;
- // We can optionally have a parent which can order us to close, or own
- // children who we're responsible for closing when we CloseNow().
- DesktopWindowTreeHostX11* window_parent_ = nullptr;
- std::set<DesktopWindowTreeHostX11*> window_children_;
-
base::ObserverList<DesktopWindowTreeHostObserverX11>::Unchecked
observer_list_;
@@ -282,7 +275,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
std::unique_ptr<CompositorObserver> compositor_observer_;
// The display and the native X window hosting the root window.
- base::WeakPtrFactory<DesktopWindowTreeHostX11> close_widget_factory_{this};
base::WeakPtrFactory<DesktopWindowTreeHostX11> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostX11);

View File

@@ -1,8 +1,14 @@
{
"src/electron/patches/chromium": "src",
"src/electron/patches/angle": "src/third_party/angle",
"src/electron/patches/quiche": "src/net/third_party/quiche/src",
"src/electron/patches/boringssl": "src/third_party/boringssl/src",
"src/electron/patches/perfetto": "src/third_party/perfetto",
"src/electron/patches/v8": "src/v8",
"src/electron/patches/node": "src/third_party/electron_node"

View File

@@ -27,7 +27,6 @@ src_disable_node_use_v8_platform_in_node_options.patch
build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.patch
refactor_allow_embedder_overriding_of_internal_fs_calls.patch
chore_add_ability_to_prevent_warn_non_context-aware_native_modules.patch
fsevents_fix_file_event_reporting.patch
chore_allow_the_node_entrypoint_to_be_a_builtin_module.patch
inherit_electron_crashpad_pipe_name_in_child_process.patch
fixme_revert_crypto_add_support_for_rsa-pss_keys.patch
@@ -38,3 +37,8 @@ chore_read_nobrowserglobals_from_global_not_process.patch
chore_split_createenvironment_into_createenvironment_and.patch
chore_handle_default_configuration_not_being_set_in_the_electron_env.patch
revert_crypto_add_outputlength_option_to_crypto_createhash.patch
fix_enable_worker_threads.patch
fsevents-stop-using-fsevents-to-watch-files.patch
fsevents-regression-in-watching.patch
build_bring_back_node_with_ltcg_configuration.patch
fix_uv_fs_mkdir_for_invalid_names.patch

View File

@@ -0,0 +1,51 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Deepak Mohan <hop2deep@gmail.com>
Date: Wed, 16 Oct 2019 13:41:12 -0700
Subject: build: bring back node_with_ltcg configuration
This was moved to code node.gyp as part of https://github.com/nodejs/node/pull/25931
which caused native modules size increase which were depending on
this configuration transitively https://github.com/nodejs/node/issues/29501.
THe fix for this should land in node-gyp as discussed in above issue,
landing this as temporary patch.
diff --git a/common.gypi b/common.gypi
index bde7d7300f44596abe5cdfac0639ecb1bb4d885f..412f613e7cfcf563fa6a000b932723166ab567da 100644
--- a/common.gypi
+++ b/common.gypi
@@ -19,7 +19,7 @@
'node_use_v8_platform%': 'true',
'node_use_bundled_v8%': 'true',
'node_module_version%': '',
- 'node_with_ltcg%': '',
+ 'node_with_ltcg%': 'true',
'node_shared_openssl%': 'false',
'node_tag%': '',
@@ -240,6 +240,26 @@
'cflags': [ '-fPIE' ],
'ldflags': [ '-fPIE', '-pie' ]
}],
+ ['node_with_ltcg=="true"', {
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'WholeProgramOptimization': 'true' # /GL, whole program optimization, needed for LTCG
+ },
+ 'VCLibrarianTool': {
+ 'AdditionalOptions': [
+ '/LTCG:INCREMENTAL', # incremental link-time code generation
+ ]
+ },
+ 'VCLinkerTool': {
+ 'OptimizeReferences': 2, # /OPT:REF
+ 'EnableCOMDATFolding': 2, # /OPT:ICF
+ 'LinkIncremental': 1, # disable incremental linking
+ 'AdditionalOptions': [
+ '/LTCG:INCREMENTAL', # incremental link-time code generation
+ ]
+ }
+ }
+ }]
],
'msvs_settings': {
'VCCLCompilerTool': {

View File

@@ -0,0 +1,29 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Thu, 3 Oct 2019 19:03:30 +0200
Subject: fix: enable worker_threads
Electron sets NODE_USE_V8_PLATFORM to false, because Electron
initializes the v8 platform itself and Node.js worker thread
initialization relies on the platform it uses having been set inside
code guarded by NODE_USE_V8_PLATFORM.
This commit fixes this problem by changing node_worker to use the three-arg
implementation of `NewIsolate` to prevent it trying to use a possibly-null ptr.
diff --git a/src/node_worker.cc b/src/node_worker.cc
index 8f97f5c351..2bfbb28e61 100644
--- a/src/node_worker.cc
+++ b/src/node_worker.cc
@@ -112,7 +112,10 @@ class WorkerThreadData {
array_buffer_allocator_(ArrayBufferAllocator::Create()) {
CHECK_EQ(uv_loop_init(&loop_), 0);
- Isolate* isolate = NewIsolate(array_buffer_allocator_.get(), &loop_);
+ Isolate* isolate = NewIsolate(
+ array_buffer_allocator_.get(),
+ &loop_,
+ w->platform_);
CHECK_NOT_NULL(isolate);
{

View File

@@ -0,0 +1,76 @@
From ecff27857dafe3f5d30a6ab8646ea69a93e4940a Mon Sep 17 00:00:00 2001
From: Bartosz Sosnowski <bartosz@janeasystems.com>
Date: Thu, 11 Jul 2019 12:45:38 +0200
Subject: [PATCH] win, fs: mkdir return UV_EINVAL for invalid names
Makes uv_fs_mkdir return UV_EINVAL for invalid filenames instead of
UV_ENOENT.
Ref: https://github.com/nodejs/node/issues/28599
PR-URL: https://github.com/libuv/libuv/pull/2375
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c
index 15094121..31242b51 100644
--- a/deps/uv/src/win/fs.c
+++ b/deps/uv/src/win/fs.c
@@ -1180,8 +1180,13 @@ void fs__unlink(uv_fs_t* req) {
void fs__mkdir(uv_fs_t* req) {
/* TODO: use req->mode. */
- int result = _wmkdir(req->file.pathw);
- SET_REQ_RESULT(req, result);
+ req->result = _wmkdir(req->file.pathw);
+ if (req->result == -1) {
+ req->sys_errno_ = _doserrno;
+ req->result = req->sys_errno_ == ERROR_INVALID_NAME
+ ? UV_EINVAL
+ : uv_translate_sys_error(req->sys_errno_);
+ }
}
diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c
index 35a992d8..95f6b5e9 100644
--- a/deps/uv/test/test-fs.c
+++ b/deps/uv/test/test-fs.c
@@ -4060,4 +4060,16 @@ TEST_IMPL(fs_fchmod_archive_readonly) {
return 0;
}
+
+TEST_IMPL(fs_invalid_mkdir_name) {
+ uv_loop_t* loop;
+ uv_fs_t req;
+ int r;
+
+ loop = uv_default_loop();
+ r = uv_fs_mkdir(loop, &req, "invalid>", 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ return 0;
+}
#endif
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index 3c5f21b9..ffa7e545 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -380,6 +380,7 @@ TEST_DECLARE (fs_exclusive_sharing_mode)
TEST_DECLARE (fs_file_flag_no_buffering)
TEST_DECLARE (fs_open_readonly_acl)
TEST_DECLARE (fs_fchmod_archive_readonly)
+TEST_DECLARE (fs_invalid_mkdir_name)
#endif
TEST_DECLARE (strscpy)
TEST_DECLARE (threadpool_queue_work_simple)
@@ -973,6 +974,7 @@ TASK_LIST_START
TEST_ENTRY (fs_file_flag_no_buffering)
TEST_ENTRY (fs_open_readonly_acl)
TEST_ENTRY (fs_fchmod_archive_readonly)
+ TEST_ENTRY (fs_invalid_mkdir_name)
#endif
TEST_ENTRY (get_osfhandle_valid_handle)
TEST_ENTRY (open_osfhandle_valid_handle)

View File

@@ -0,0 +1,158 @@
From ae12376dbb56fa080b699f00840c7b9c5230a85f Mon Sep 17 00:00:00 2001
From: Jameson Nash <vtjnash@gmail.com>
Date: Sat, 7 Sep 2019 20:45:39 -0400
Subject: [PATCH] fsevents: regression in watching /
This case got lost by accident in
https://github.com/libuv/libuv/pull/2082,
preventing the realpath `/` from ever matching.
Fixes: https://github.com/nodejs/node/issues/28917
PR-URL: https://github.com/libuv/libuv/pull/2460
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
diff --git a/deps/uv/src/unix/fsevents.c b/deps/uv/src/unix/fsevents.c
index ddacda31..deeaa63d 100644
--- a/deps/uv/src/unix/fsevents.c
+++ b/deps/uv/src/unix/fsevents.c
@@ -263,10 +263,12 @@ static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef,
if (len < handle->realpath_len)
continue;
+ /* Make sure that realpath actually named a directory,
+ * (unless watching root, which alone keeps a trailing slash on the realpath)
+ * or that we matched the whole string */
if (handle->realpath_len != len &&
+ handle->realpath_len > 1 &&
path[handle->realpath_len] != '/')
- /* Make sure that realpath actually named a directory,
- * or that we matched the whole string */
continue;
if (memcmp(path, handle->realpath, handle->realpath_len) != 0)
diff --git a/deps/uv/test/test-fs-event.c b/deps/uv/test/test-fs-event.c
index 4b8bb1ef..7725c3af 100644
--- a/deps/uv/test/test-fs-event.c
+++ b/deps/uv/test/test-fs-event.c
@@ -47,6 +47,7 @@ static const char file_prefix[] = "fsevent-";
static const int fs_event_file_count = 16;
#if defined(__APPLE__) || defined(_WIN32)
static const char file_prefix_in_subdir[] = "subdir";
+static int fs_multievent_cb_called;
#endif
static uv_timer_t timer;
static int timer_cb_called;
@@ -280,7 +281,7 @@ static void fs_event_cb_dir_multi_file_in_subdir(uv_fs_event_t* handle,
if (filename && strcmp(filename, file_prefix_in_subdir) == 0)
return;
#endif
- fs_event_cb_called++;
+ fs_multievent_cb_called++;
ASSERT(handle == &fs_event);
ASSERT(status == 0);
ASSERT(events == UV_CHANGE || events == UV_RENAME);
@@ -298,7 +299,7 @@ static void fs_event_cb_dir_multi_file_in_subdir(uv_fs_event_t* handle,
if (fs_event_created + fs_event_removed == fs_event_file_count) {
/* Once we've processed all create events, delete all files */
ASSERT(0 == uv_timer_start(&timer, fs_event_unlink_files_in_subdir, 1, 0));
- } else if (fs_event_cb_called == 2 * fs_event_file_count) {
+ } else if (fs_multievent_cb_called == 2 * fs_event_file_count) {
/* Once we've processed all create and delete events, stop watching */
uv_close((uv_handle_t*) &timer, close_cb);
uv_close((uv_handle_t*) handle, close_cb);
@@ -393,6 +394,21 @@ static void timer_cb_watch_twice(uv_timer_t* handle) {
uv_close((uv_handle_t*) handle, NULL);
}
+static void fs_event_cb_close(uv_fs_event_t* handle,
+ const char* filename,
+ int events,
+ int status) {
+ ASSERT(status == 0);
+
+ ASSERT(fs_event_cb_called < 3);
+ ++fs_event_cb_called;
+
+ if (fs_event_cb_called == 3) {
+ uv_close((uv_handle_t*) handle, close_cb);
+ }
+}
+
+
TEST_IMPL(fs_event_watch_dir) {
#if defined(NO_FS_EVENTS)
RETURN_SKIP(NO_FS_EVENTS);
@@ -434,10 +450,12 @@ TEST_IMPL(fs_event_watch_dir) {
return 0;
}
+
TEST_IMPL(fs_event_watch_dir_recursive) {
#if defined(__APPLE__) || defined(_WIN32)
uv_loop_t* loop;
int r;
+ uv_fs_event_t fs_event_root;
/* Setup */
loop = uv_default_loop();
@@ -451,17 +469,37 @@ TEST_IMPL(fs_event_watch_dir_recursive) {
r = uv_fs_event_init(loop, &fs_event);
ASSERT(r == 0);
- r = uv_fs_event_start(&fs_event, fs_event_cb_dir_multi_file_in_subdir, "watch_dir", UV_FS_EVENT_RECURSIVE);
+ r = uv_fs_event_start(&fs_event,
+ fs_event_cb_dir_multi_file_in_subdir,
+ "watch_dir",
+ UV_FS_EVENT_RECURSIVE);
ASSERT(r == 0);
r = uv_timer_init(loop, &timer);
ASSERT(r == 0);
r = uv_timer_start(&timer, fs_event_create_files_in_subdir, 100, 0);
ASSERT(r == 0);
+#ifndef _WIN32
+ /* Also try to watch the root directory.
+ * This will be noisier, so we're just checking for any couple events to happen. */
+ r = uv_fs_event_init(loop, &fs_event_root);
+ ASSERT(r == 0);
+ r = uv_fs_event_start(&fs_event_root,
+ fs_event_cb_close,
+ "/",
+ UV_FS_EVENT_RECURSIVE);
+ ASSERT(r == 0);
+#else
+ fs_event_cb_called += 3;
+ close_cb_called += 1;
+ (void)fs_event_root;
+#endif
+
uv_run(loop, UV_RUN_DEFAULT);
- ASSERT(fs_event_cb_called == fs_event_created + fs_event_removed);
- ASSERT(close_cb_called == 2);
+ ASSERT(fs_multievent_cb_called == fs_event_created + fs_event_removed);
+ ASSERT(fs_event_cb_called == 3);
+ ASSERT(close_cb_called == 3);
/* Cleanup */
fs_event_unlink_files_in_subdir(NULL);
@@ -870,18 +908,6 @@ TEST_IMPL(fs_event_close_with_pending_event) {
return 0;
}
-static void fs_event_cb_close(uv_fs_event_t* handle, const char* filename,
- int events, int status) {
- ASSERT(status == 0);
-
- ASSERT(fs_event_cb_called < 3);
- ++fs_event_cb_called;
-
- if (fs_event_cb_called == 3) {
- uv_close((uv_handle_t*) handle, close_cb);
- }
-}
-
TEST_IMPL(fs_event_close_in_callback) {
#if defined(NO_FS_EVENTS)
RETURN_SKIP(NO_FS_EVENTS);

View File

@@ -0,0 +1,120 @@
From 97b85e8b75b8f3df774b6e008dbaa143daa412b7 Mon Sep 17 00:00:00 2001
From: Jameson Nash <vtjnash@gmail.com>
Date: Sat, 7 Sep 2019 14:55:40 -0400
Subject: [PATCH] fsevents: stop using fsevents to watch files
Goes back to just using it to watch folders,
but keeps the other logic changes around.
Refs: https://github.com/libuv/libuv/pull/387
Refs: https://github.com/libuv/libuv/pull/2082
Refs: https://github.com/libuv/libuv/pull/1572
Refs: https://github.com/nodejs/node/issues/29460
Fixes: https://github.com/libuv/libuv/issues/2488
Closes: https://github.com/libuv/libuv/pull/2452
PR-URL: https://github.com/libuv/libuv/pull/2459
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
diff --git a/deps/uv/src/unix/kqueue.c b/deps/uv/src/unix/kqueue.c
index c04e7a48..ad09f403 100644
--- a/deps/uv/src/unix/kqueue.c
+++ b/deps/uv/src/unix/kqueue.c
@@ -454,10 +454,26 @@ int uv_fs_event_start(uv_fs_event_t* handle,
const char* path,
unsigned int flags) {
int fd;
+#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+ struct stat statbuf;
+#endif
if (uv__is_active(handle))
return UV_EINVAL;
+ handle->cb = cb;
+ handle->path = uv__strdup(path);
+ if (handle->path == NULL)
+ return UV_ENOMEM;
+
+ /* TODO open asynchronously - but how do we report back errors? */
+ fd = open(handle->path, O_RDONLY);
+ if (fd == -1) {
+ uv__free(handle->path);
+ handle->path = NULL;
+ return UV__ERR(errno);
+ }
+
#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
/* Nullify field to perform checks later */
handle->cf_cb = NULL;
@@ -465,14 +481,17 @@ int uv_fs_event_start(uv_fs_event_t* handle,
handle->realpath_len = 0;
handle->cf_flags = flags;
+ if (fstat(fd, &statbuf))
+ goto fallback;
+ /* FSEvents works only with directories */
+ if (!(statbuf.st_mode & S_IFDIR))
+ goto fallback;
+
if (!uv__has_forked_with_cfrunloop) {
int r;
- /* The fallback fd is not used */
+ /* The fallback fd is no longer needed */
+ uv__close_nocheckstdio(fd);
handle->event_watcher.fd = -1;
- handle->path = uv__strdup(path);
- if (handle->path == NULL)
- return UV_ENOMEM;
- handle->cb = cb;
r = uv__fsevents_init(handle);
if (r == 0) {
uv__handle_start(handle);
@@ -482,20 +501,9 @@ int uv_fs_event_start(uv_fs_event_t* handle,
}
return r;
}
+fallback:
#endif /* #if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 */
- /* TODO open asynchronously - but how do we report back errors? */
- fd = open(path, O_RDONLY);
- if (fd == -1)
- return UV__ERR(errno);
-
- handle->path = uv__strdup(path);
- if (handle->path == NULL) {
- uv__close_nocheckstdio(fd);
- return UV_ENOMEM;
- }
-
- handle->cb = cb;
uv__handle_start(handle);
uv__io_init(&handle->event_watcher, uv__fs_event, fd);
uv__io_start(handle->loop, &handle->event_watcher, POLLIN);
@@ -514,7 +522,7 @@ int uv_fs_event_stop(uv_fs_event_t* handle) {
uv__handle_stop(handle);
#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- if (!uv__has_forked_with_cfrunloop)
+ if (!uv__has_forked_with_cfrunloop && handle->cf_cb != NULL)
r = uv__fsevents_close(handle);
#endif
diff --git a/deps/uv/test/test-fs-event.c b/deps/uv/test/test-fs-event.c
index ea34bd63..4b8bb1ef 100644
--- a/deps/uv/test/test-fs-event.c
+++ b/deps/uv/test/test-fs-event.c
@@ -656,6 +656,12 @@ TEST_IMPL(fs_event_watch_file_current_dir) {
/* Setup */
remove("watch_file");
create_file("watch_file");
+#if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_12)
+ /* Empirically, kevent seems to (sometimes) report the preceeding
+ * create_file events prior to macOS 10.11.6 in the subsequent fs_event_start
+ * So let the system settle before running the test. */
+ uv_sleep(1100);
+#endif
r = uv_fs_event_init(loop, &fs_event);
ASSERT(r == 0);

View File

@@ -1,213 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ben Noordhuis <info@bnoordhuis.nl>
Date: Mon, 27 May 2019 14:31:53 +0200
Subject: fsevents: fix file event reporting
Commit 2d2af38 ("fsevents: really watch files with fsevents on macos
10.7+") from last November introduced a regression where events that
were previously reported as UV_RENAME were now reported as UV_CHANGE.
This commit rectifies that.
Fixes: https://github.com/nodejs/node/issues/27869
diff --git a/deps/uv/src/unix/fsevents.c b/deps/uv/src/unix/fsevents.c
index ddacda31fef87eee131fc2ee2ff46cc88be429d9..911023a6562319af5e9e3412ddbfd2ca14f77b05 100644
--- a/deps/uv/src/unix/fsevents.c
+++ b/deps/uv/src/unix/fsevents.c
@@ -49,19 +49,9 @@ void uv__fsevents_loop_delete(uv_loop_t* loop) {
#include <CoreFoundation/CFRunLoop.h>
#include <CoreServices/CoreServices.h>
-/* These are macros to avoid "initializer element is not constant" errors
+/* Macro to avoid "initializer element is not constant" errors
* with old versions of gcc.
*/
-#define kFSEventsModified (kFSEventStreamEventFlagItemFinderInfoMod | \
- kFSEventStreamEventFlagItemModified | \
- kFSEventStreamEventFlagItemInodeMetaMod | \
- kFSEventStreamEventFlagItemChangeOwner | \
- kFSEventStreamEventFlagItemXattrMod)
-
-#define kFSEventsRenamed (kFSEventStreamEventFlagItemCreated | \
- kFSEventStreamEventFlagItemRemoved | \
- kFSEventStreamEventFlagItemRenamed)
-
#define kFSEventsSystem (kFSEventStreamEventFlagUserDropped | \
kFSEventStreamEventFlagKernelDropped | \
kFSEventStreamEventFlagEventIdsWrapped | \
@@ -289,8 +279,6 @@ static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef,
path--;
len++;
}
- /* Created and Removed seem to be always set, but don't make sense */
- flags &= ~kFSEventsRenamed;
} else {
/* Skip forward slash */
path++;
@@ -311,12 +299,12 @@ static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef,
memset(event, 0, sizeof(*event));
memcpy(event->path, path, len + 1);
- event->events = UV_RENAME;
+ event->events = UV_CHANGE;
- if (0 == (flags & kFSEventsRenamed)) {
- if (0 != (flags & kFSEventsModified) ||
- 0 == (flags & kFSEventStreamEventFlagItemIsDir))
- event->events = UV_CHANGE;
+ if ((flags & kFSEventStreamEventFlagItemIsDir) ||
+ (flags & kFSEventStreamEventFlagItemRemoved) ||
+ (flags & kFSEventStreamEventFlagItemRenamed)) {
+ event->events = UV_RENAME;
}
QUEUE_INSERT_TAIL(&head, &event->member);
diff --git a/deps/uv/test/test-fs-event.c b/deps/uv/test/test-fs-event.c
index ea34bd63a70625c3e2c60d5a1bbb087c5f0bbb2e..38d722a27ef1a78717726272d54578c734280242 100644
--- a/deps/uv/test/test-fs-event.c
+++ b/deps/uv/test/test-fs-event.c
@@ -62,6 +62,15 @@ static char fs_event_filename[1024];
static int timer_cb_touch_called;
static int timer_cb_exact_called;
+static void expect_filename(const char* path, const char* expected) {
+#if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
+ ASSERT(0 == strcmp(path, expected));
+#else
+ if (path != NULL)
+ ASSERT(0 == strcmp(path, expected));
+#endif
+}
+
static void fs_event_fail(uv_fs_event_t* handle,
const char* filename,
int events,
@@ -130,11 +139,7 @@ static void fs_event_cb_dir(uv_fs_event_t* handle, const char* filename,
ASSERT(handle == &fs_event);
ASSERT(status == 0);
ASSERT(events == UV_CHANGE);
- #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
- ASSERT(strcmp(filename, "file1") == 0);
- #else
- ASSERT(filename == NULL || strcmp(filename, "file1") == 0);
- #endif
+ expect_filename(filename, "file1");
ASSERT(0 == uv_fs_event_stop(handle));
uv_close((uv_handle_t*)handle, close_cb);
}
@@ -312,11 +317,7 @@ static void fs_event_cb_file(uv_fs_event_t* handle, const char* filename,
ASSERT(handle == &fs_event);
ASSERT(status == 0);
ASSERT(events == UV_CHANGE);
- #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
- ASSERT(strcmp(filename, "file2") == 0);
- #else
- ASSERT(filename == NULL || strcmp(filename, "file2") == 0);
- #endif
+ expect_filename(filename, "file2");
ASSERT(0 == uv_fs_event_stop(handle));
uv_close((uv_handle_t*)handle, close_cb);
}
@@ -339,11 +340,7 @@ static void fs_event_cb_file_current_dir(uv_fs_event_t* handle,
ASSERT(handle == &fs_event);
ASSERT(status == 0);
ASSERT(events == UV_CHANGE);
- #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
- ASSERT(strcmp(filename, "watch_file") == 0);
- #else
- ASSERT(filename == NULL || strcmp(filename, "watch_file") == 0);
- #endif
+ expect_filename(filename, "watch_file");
/* Regression test for SunOS: touch should generate just one event. */
{
@@ -619,6 +616,69 @@ TEST_IMPL(fs_event_watch_file_exact_path) {
return 0;
}
+static void file_remove_cb(uv_fs_event_t* handle,
+ const char* path,
+ int events,
+ int status) {
+ fs_event_cb_called++;
+
+ expect_filename(path, "file1");
+ /* TODO(bnoordhuis) Harmonize the behavior across platforms. Right now
+ * this test merely ensures the status quo doesn't regress.
+ */
+#if defined(_AIX) || defined(__linux__)
+ ASSERT(UV_CHANGE == events);
+#else
+ ASSERT(UV_RENAME == events);
+#endif
+ ASSERT(0 == status);
+
+ uv_close((uv_handle_t*) handle, NULL);
+}
+
+static void file_remove_next(uv_timer_t* handle) {
+ uv_close((uv_handle_t*) handle, NULL);
+ remove("watch_dir/file1");
+}
+
+static void file_remove_start(uv_timer_t* handle) {
+ uv_fs_event_t* watcher;
+ uv_loop_t* loop;
+
+ loop = handle->loop;
+ watcher = handle->data;
+
+ ASSERT(0 == uv_fs_event_init(loop, watcher));
+ ASSERT(0 == uv_fs_event_start(watcher, file_remove_cb, "watch_dir/file1", 0));
+ ASSERT(0 == uv_timer_start(handle, file_remove_next, 50, 0));
+}
+
+TEST_IMPL(fs_event_watch_file_remove) {
+ uv_fs_event_t watcher;
+ uv_timer_t timer;
+ uv_loop_t* loop;
+
+#if defined(__MVS__)
+ RETURN_SKIP("test does not work on this OS");
+#endif
+
+ remove("watch_dir/file1");
+ remove("watch_dir/");
+ create_dir("watch_dir");
+ create_file("watch_dir/file1");
+
+ loop = uv_default_loop();
+ timer.data = &watcher;
+
+ ASSERT(0 == uv_timer_init(loop, &timer));
+ ASSERT(0 == uv_timer_start(&timer, file_remove_start, 500, 0));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
+ ASSERT(1 == fs_event_cb_called);
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
+
TEST_IMPL(fs_event_watch_file_twice) {
#if defined(NO_FS_EVENTS)
RETURN_SKIP(NO_FS_EVENTS);
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index a48f6f3806806af6bf844558d08fa9679e268112..f9020fc6c1ec8d076c470fa5042d062b74226ae4 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -335,6 +335,7 @@ TEST_DECLARE (fs_event_watch_dir_short_path)
#endif
TEST_DECLARE (fs_event_watch_file)
TEST_DECLARE (fs_event_watch_file_exact_path)
+TEST_DECLARE (fs_event_watch_file_remove)
TEST_DECLARE (fs_event_watch_file_twice)
TEST_DECLARE (fs_event_watch_file_current_dir)
#ifdef _WIN32
@@ -924,6 +925,7 @@ TASK_LIST_START
#endif
TEST_ENTRY (fs_event_watch_file)
TEST_ENTRY (fs_event_watch_file_exact_path)
+ TEST_ENTRY (fs_event_watch_file_remove)
TEST_ENTRY (fs_event_watch_file_twice)
TEST_ENTRY (fs_event_watch_file_current_dir)
#ifdef _WIN32

View File

@@ -0,0 +1 @@
metatrace_remove_memset_and_trivial_ctor_assumption.patch

View File

@@ -0,0 +1,80 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Primiano Tucci <primiano@google.com>
Date: Thu, 3 Oct 2019 16:24:52 +0100
Subject: metatrace: remove memset and trivial-ctor assumption
Turns out that on MSVC std::atomic<int> is not trivially constructible
(although I think is still a plain old int, it just fails the check).
Fall back on resetting each element individually.
Thankfully the compiler can see through and eventually figures out
it can do a memset: https://godbolt.org/z/wMre8O
Bug: chromium:1010616
Change-Id: I971ff888306d6bdbaf6e6b886f9ca506ddc1b30a
diff --git a/include/perfetto/ext/base/metatrace.h b/include/perfetto/ext/base/metatrace.h
index 3858f68ec5eaf130aafa7d33f52a00e370395204..2c587c3fc63093f71a05e4c757def5c6384bf703 100644
--- a/include/perfetto/ext/base/metatrace.h
+++ b/include/perfetto/ext/base/metatrace.h
@@ -116,22 +116,33 @@ struct Record {
timestamp_ns_high = static_cast<uint16_t>(diff >> 32);
}
+ // We can't just memset() this class because on MSVC std::atomic<> is not
+ // trivially constructible anymore. Also std::atomic<> has a deleted copy
+ // constructor so we cant just do "*this = Record()" either.
+ // See http://bit.ly/339Jlzd .
+ void clear() {
+ this->~Record();
+ new (this) Record();
+ }
+
// This field holds the type (counter vs event) in the MSB and event ID (as
// defined in metatrace_events.h) in the lowest 15 bits. It is also used also
// as a linearization point: this is always written after all the other
// fields with a release-store. This is so the reader can determine whether it
// can safely process the other event fields after a load-acquire.
- std::atomic<uint16_t> type_and_id;
+ std::atomic<uint16_t> type_and_id{};
// Timestamp is stored as a 48-bits value diffed against g_enabled_timestamp.
// This gives us 78 hours from Enabled().
- uint16_t timestamp_ns_high;
- uint32_t timestamp_ns_low;
+ uint16_t timestamp_ns_high = 0;
+ uint32_t timestamp_ns_low = 0;
- uint32_t thread_id;
+ uint32_t thread_id = 0;
union {
- uint32_t duration_ns; // If type == event.
+ // Only one of the two elements can be zero initialized, clang complains
+ // about "initializing multiple members of union" otherwise.
+ uint32_t duration_ns = 0; // If type == event.
int32_t counter_value; // If type == counter.
};
};
diff --git a/src/base/metatrace.cc b/src/base/metatrace.cc
index 9ef2c68777c5d497d92b12d52df4df2454feda02..67d167c8d07bc8701d261c56d11ba17afcb6ec8a 100644
--- a/src/base/metatrace.cc
+++ b/src/base/metatrace.cc
@@ -84,15 +84,9 @@ void Disable() {
// static
void RingBuffer::Reset() {
- static_assert(PERFETTO_IS_TRIVIALLY_CONSTRUCTIBLE(Record) &&
- std::is_trivially_destructible<Record>::value,
- "Record must be trivial");
- // Cast pointers to void* to suppress "-Wclass-memaccess" from gcc, which
- // triggers as we're doing a raw memory set for a class (Record) that doesn't
- // have a copy assignment operator (due to the atomic |type_and_id|).
- memset(static_cast<void*>(records_.data()), 0, sizeof(records_));
- memset(static_cast<void*>(&bankruptcy_record_), 0,
- sizeof(bankruptcy_record_));
+ bankruptcy_record_.clear();
+ for (Record& record : records_)
+ record.clear();
wr_index_ = 0;
rd_index_ = 0;
has_overruns_ = false;

1
patches/quiche/.patches Normal file
View File

@@ -0,0 +1 @@
include_ostream_in_quic_ip_address_h.patch

View File

@@ -0,0 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: vasilvv <vasilvv@google.com>
Date: Thu, 3 Oct 2019 09:37:10 -0700
Subject: [build] Include ostream in quic_ip_address.h
Explicitly #include <ostream> in quic/platform/api/quic_ip_address.h, since std::ostream is referenced in it. In the C++ STL shipped with Visual Studio 2019, none of the headers included in quic_ip_address.h ends up including the required templates, which caused a compile error.
Patch by Jaime Bernardo <jaime@janeasystems.com>: https://quiche-review.googlesource.com/c/quiche/+/10280
gfe-relnote: n/a (no functional change)
PiperOrigin-RevId: 272678937
Change-Id: I304ed7ad7f114924268ef832551fb2ddcba73402
diff --git a/quic/platform/api/quic_ip_address.h b/quic/platform/api/quic_ip_address.h
index e1a1076cbcbd0bfe72e69b4c0fefe2b21ec4426c..3585970d9d50f2b026616e758576dd466044c39b 100644
--- a/quic/platform/api/quic_ip_address.h
+++ b/quic/platform/api/quic_ip_address.h
@@ -15,6 +15,7 @@
#include <sys/types.h>
#endif
+#include <ostream>
#include <string>
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"

View File

@@ -6,3 +6,4 @@ dcheck.patch
export_symbols_needed_for_windows_build.patch
workaround_an_undefined_symbol_error.patch
do_not_export_private_v8_symbols_on_windows.patch
include_string_in_v8_h.patch

View File

@@ -0,0 +1,29 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jaime Bernardo <jaime@janeasystems.com>
Date: Tue, 1 Oct 2019 20:06:03 +0100
Subject: Include string in v8.h
Explicitly #include<string> in v8.h, since std::string is referenced
in it. In the C++ STL shipped with Visual Studio 2019, none of the
headers included in v8.h ends up including the C++ string header, which
caused a compile error.
Bug: v8:9793
Change-Id: I84a133dd10dd6dcc7b70287af393e82cf0dc97df
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1834321
Reviewed-by: Adam Klein <adamk@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64074}
diff --git a/include/v8.h b/include/v8.h
index f0c47907292b9da438347276ac240541577899ad..a8010f4dadef1636697d08888a4c5e2da68f884a 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -19,6 +19,7 @@
#include <stdint.h>
#include <stdio.h>
#include <memory>
+#include <string>
#include <type_traits>
#include <utility>
#include <vector>

View File

@@ -139,7 +139,7 @@
"parallel/test-tls-set-ciphers",
"parallel/test-tls-socket-failed-handshake-emits-error",
"parallel/test-tls-ticket",
"parallel/test-trace-events-api-worker-disabled",
"parallel/test-tls-write-error",
"parallel/test-tls-ticket-cluster",
"parallel/test-trace-events-dynamic-enable",
"parallel/test-trace-events-dynamic-enable-workers-disabled",
@@ -168,62 +168,13 @@
"parallel/test-vm-syntax-error-message",
"parallel/test-warn-sigprof",
"parallel/test-whatwg-encoding-custom-textdecoder",
"parallel/test-worker",
"parallel/test-worker-abort-on-uncaught-exception-terminate",
"parallel/test-worker-cleanexit-with-js",
"parallel/test-worker-cleanexit-with-moduleload",
"parallel/test-worker-cleanup-handles",
"parallel/test-worker-console-listeners",
"parallel/test-worker-dns-terminate",
"parallel/test-worker-error-stack-getter-throws",
"parallel/test-worker-esm-missing-main",
"parallel/test-worker-debug",
"parallel/test-worker-dns-terminate-during-query",
"parallel/test-worker-esm-exit",
"parallel/test-worker-esmodule",
"parallel/test-worker-exit-from-uncaught-exception",
"parallel/test-worker-exit-code",
"parallel/test-worker-execargv",
"parallel/test-worker-fs-stat-watcher",
"parallel/test-worker-message-channel",
"parallel/test-worker-memory",
"parallel/test-worker-http2-generic-streams-terminate",
"parallel/test-worker-message-channel-sharedarraybuffer",
"parallel/test-worker-message-not-serializable",
"parallel/test-worker-message-port-drain",
"parallel/test-worker-message-port-message-before-close",
"parallel/test-worker-message-port-transfer-duplicate",
"parallel/test-worker-message-port-transfer-target",
"parallel/test-worker-message-port-transfer-terminate",
"parallel/test-worker-message-port-wasm-module",
"parallel/test-worker-message-port-wasm-threads",
"parallel/test-worker-mjs-workerdata",
"parallel/test-worker-process-env-shared",
"parallel/test-worker-onmessage",
"parallel/test-worker-parent-port-ref",
"parallel/test-worker-nexttick-terminate",
"parallel/test-worker-no-stdin-stdout-interaction",
"parallel/test-worker-onmessage-not-a-function",
"parallel/test-worker-process-cwd",
"parallel/test-worker-process-env",
"parallel/test-worker-ref",
"parallel/test-worker-ref-onexit",
"parallel/test-worker-relative-path",
"parallel/test-worker-relative-path-double-dot",
"parallel/test-worker-safe-getters",
"parallel/test-worker-message-type-unknown",
"parallel/test-worker-stack-overflow",
"parallel/test-worker-uncaught-exception",
"parallel/test-worker-syntax-error",
"parallel/test-worker-terminate-microtask-loop",
"parallel/test-worker-vm-context-terminate",
"parallel/test-worker-sharedarraybuffer-from-worker-thread",
"parallel/test-worker-stdio",
"parallel/test-worker-syntax-error-file",
"parallel/test-worker-terminate-timers",
"parallel/test-worker-terminate-http2-respond-with-file",
"parallel/test-worker-unsupported-things",
"parallel/test-worker-uncaught-exception-async",
"parallel/test-worker-workerdata-sharedarraybuffer",
"async-hooks/test-crypto-randomBytes",
"async-hooks/test-fseventwrap",
"async-hooks/test-fsreqcallback-readFile",
@@ -256,7 +207,6 @@
"es-module/test-esm-type-flag",
"report/test-report-writereport",
"abort/test-abort-backtrace",
"abort/test-worker-abort-uncaught-exception",
"sequential/test-child-process-execsync",
"sequential/test-cli-syntax-bad",
"sequential/test-cli-syntax-good",

View File

@@ -225,7 +225,6 @@ function runRelease (targetBranch, options) {
} else {
buildCircleCI(targetBranch, options)
buildAppVeyor(targetBranch, options)
buildVSTS(targetBranch, options)
}
console.log(`${jobRequestedCount} jobs were requested.`)
}

View File

@@ -16,6 +16,7 @@ Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Librari
Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libswiftshader_libGLESv2.dylib
Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/
Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/Info.plist
Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/MainMenu.nib
Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/am.lproj/
Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/am.lproj/locale.pak
Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/ar.lproj/

View File

@@ -16,6 +16,7 @@ Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Librari
Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libswiftshader_libGLESv2.dylib
Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/
Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/Info.plist
Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/MainMenu.nib
Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/am.lproj/
Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/am.lproj/locale.pak
Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/ar.lproj/

View File

@@ -15,9 +15,8 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/pepper_plugin_info.h"
#include "electron/buildflags/buildflags.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
#include "ppapi/buildflags/buildflags.h"
#include "shell/browser/atom_paths.h"
#include "shell/common/options_switches.h"
#include "ui/base/l10n/l10n_util.h"
@@ -37,6 +36,11 @@
#include "shell/common/atom_constants.h"
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
#if BUILDFLAG(ENABLE_PLUGINS)
#include "content/public/common/pepper_plugin_info.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
#endif // BUILDFLAG(ENABLE_PLUGINS)
namespace electron {
namespace {
@@ -143,6 +147,7 @@ void AddPepperFlashFromCommandLine(
}
#endif // BUILDFLAG(ENABLE_PEPPER_FLASH)
#if BUILDFLAG(ENABLE_PLUGINS)
void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
#if BUILDFLAG(ENABLE_PDF_VIEWER)
content::PepperPluginInfo pdf_info;
@@ -163,6 +168,7 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
plugins->push_back(pdf_info);
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
}
#endif // BUILDFLAG(ENABLE_PLUGINS)
void AppendDelimitedSwitchToVector(const base::StringPiece cmd_switch,
std::vector<std::string>* append_me) {
@@ -229,7 +235,9 @@ void AtomContentClient::AddPepperPlugins(
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
AddPepperFlashFromCommandLine(command_line, plugins);
#endif // BUILDFLAG(ENABLE_PEPPER_FLASH)
#if BUILDFLAG(ENABLE_PLUGINS)
ComputeBuiltInPlugins(plugins);
#endif // BUILDFLAG(ENABLE_PLUGINS)
}
void AtomContentClient::AddContentDecryptionModules(

View File

@@ -79,9 +79,14 @@ int NodeMain(int argc, char* argv[]) {
// Initialize gin::IsolateHolder.
JavascriptEnvironment gin_env(loop);
node::Environment* env = node::CreateEnvironment(
node::CreateIsolateData(gin_env.isolate(), loop, gin_env.platform()),
gin_env.context(), argc, argv, exec_argc, exec_argv, false);
node::IsolateData* isolate_data =
node::CreateIsolateData(gin_env.isolate(), loop, gin_env.platform());
CHECK_NE(nullptr, isolate_data);
node::Environment* env =
node::CreateEnvironment(isolate_data, gin_env.context(), argc, argv,
exec_argc, exec_argv, false);
CHECK_NE(nullptr, env);
// Enable support for v8 inspector.
NodeDebugger node_debugger(env);
@@ -135,6 +140,7 @@ int NodeMain(int argc, char* argv[]) {
v8::Isolate* isolate = env->isolate();
node::FreeEnvironment(env);
node::FreeIsolateData(isolate_data);
gin_env.platform()->DrainTasks(isolate);
gin_env.platform()->CancelPendingDelayedTasks(isolate);

View File

@@ -15,6 +15,7 @@
#include "content/public/browser/storage_partition.h"
#include "gin/dictionary.h"
#include "gin/object_template_builder.h"
#include "native_mate/dictionary.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_store.h"
#include "net/cookies/cookie_util.h"
@@ -122,11 +123,9 @@ bool MatchesCookie(const base::Value& filter,
// Remove cookies from |list| not matching |filter|, and pass it to |callback|.
void FilterCookies(const base::Value& filter,
util::Promise promise,
const net::CookieStatusList& list,
const net::CookieStatusList& excluded_list) {
const net::CookieList& cookies) {
net::CookieList result;
net::CookieList stripped_cookies = net::cookie_util::StripStatuses(list);
for (const auto& cookie : stripped_cookies) {
for (const auto& cookie : cookies) {
if (MatchesCookie(filter, cookie))
result.push_back(cookie);
}
@@ -134,6 +133,14 @@ void FilterCookies(const base::Value& filter,
promise.Resolve(gin::ConvertToV8(promise.isolate(), result));
}
void FilterCookieWithStatuses(const base::Value& filter,
util::Promise promise,
const net::CookieStatusList& list,
const net::CookieStatusList& excluded_list) {
FilterCookies(filter, std::move(promise),
net::cookie_util::StripStatuses(list));
}
std::string InclusionStatusToString(
net::CanonicalCookie::CookieInclusionStatus status) {
if (status.HasExclusionReason(
@@ -170,28 +177,33 @@ Cookies::Cookies(v8::Isolate* isolate, AtomBrowserContext* browser_context)
Cookies::~Cookies() {}
v8::Local<v8::Promise> Cookies::Get(const base::DictionaryValue& filter) {
v8::Local<v8::Promise> Cookies::Get(const mate::Dictionary& filter) {
util::Promise promise(isolate());
v8::Local<v8::Promise> handle = promise.GetHandle();
std::string url_string;
filter.GetString("url", &url_string);
GURL url(url_string);
auto callback =
base::BindOnce(FilterCookies, filter.Clone(), std::move(promise));
auto* storage_partition = content::BrowserContext::GetDefaultStoragePartition(
browser_context_.get());
auto* manager = storage_partition->GetCookieManagerForBrowserProcess();
net::CookieOptions options;
options.set_include_httponly();
options.set_same_site_cookie_context(
net::CookieOptions::SameSiteCookieContext::SAME_SITE_STRICT);
options.set_do_not_update_access_time();
base::DictionaryValue dict;
mate::ConvertFromV8(isolate(), filter.GetHandle(), &dict);
manager->GetCookieList(url, options, std::move(callback));
std::string url;
filter.Get("url", &url);
if (url.empty()) {
manager->GetAllCookies(
base::BindOnce(&FilterCookies, std::move(dict), std::move(promise)));
} else {
net::CookieOptions options;
options.set_include_httponly();
options.set_same_site_cookie_context(
net::CookieOptions::SameSiteCookieContext::SAME_SITE_STRICT);
options.set_do_not_update_access_time();
manager->GetCookieList(GURL(url), options,
base::BindOnce(&FilterCookieWithStatuses,
std::move(dict), std::move(promise)));
}
return handle;
}

Some files were not shown because too many files have changed in this diff Show More