2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
#include "BrowserChild.h"
|
2012-08-02 10:02:29 +04:00
|
|
|
|
2015-05-21 20:04:58 +03:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
# include "mozilla/a11y/DocAccessibleChild.h"
|
|
|
|
#endif
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include <algorithm>
|
|
|
|
#include <utility>
|
|
|
|
|
Bug 1645528 - Connect nsRefreshDrivers in content processes with a widget-local vsync source r=mattwoodrow,emilio
To allow `requestAnimationFrame()` and similar things to run at monitor
speed if there is only a window-specific vsyncsource available.
This is the case for Wayland and, in the future, EGL/X11. Other backends
may opt for window specific vsyncsources as well at some point.
The idea is to, instead of using global vsync objects, expose a vsyncsource
from nsWindow and use it for refresh drivers. For the content process, move
VsyncChild to BrowserChild, so for each Browserchild there is only one
VsyncChild to which all refresh drivers connect.
IPC in managed either by PBrowser or PBackground. Right now, PBrowser is
only used on Wayland, as both PBrowser and the Wayland vsyncsource run
on the main thread. Other backends keep using the background thread for
now.
While at it, make it so that we constantly update the refresh rate. This
is necessary for Wayland, but also on other platforms variable refresh rates
are increasingly common. Do that by transimitting the vsync rate `SendNotify()`.
How to test:
- run the Wayland backend
- enable `widget.wayland_vsync.enabled`
- optionally: disable `privacy.reduceTimerPrecision`
- run `vsynctester.com` or `testufo.com`
Expected results:
Instead of fixed 60Hz, things should update at monitor refresh rate -
e.g. 144Hz
Original patch by Kenny Levinsen.
Depends on D98254
Differential Revision: https://phabricator.services.mozilla.com/D93173
2020-12-02 12:47:53 +03:00
|
|
|
#include "BackgroundChild.h"
|
2019-04-10 00:38:15 +03:00
|
|
|
#include "BrowserParent.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "ClientLayerManager.h"
|
|
|
|
#include "ContentChild.h"
|
|
|
|
#include "DocumentInlines.h"
|
|
|
|
#include "EventStateManager.h"
|
|
|
|
#include "FrameLayerBuilder.h"
|
2020-12-09 11:58:06 +03:00
|
|
|
#include "GeckoProfiler.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "Layers.h"
|
|
|
|
#include "MMPrinter.h"
|
|
|
|
#include "PermissionMessageUtils.h"
|
|
|
|
#include "PuppetWidget.h"
|
|
|
|
#include "StructuredCloneData.h"
|
|
|
|
#include "UnitTransforms.h"
|
|
|
|
#include "Units.h"
|
|
|
|
#include "VRManagerChild.h"
|
|
|
|
#include "ipc/nsGUIEventIPC.h"
|
2018-08-20 17:54:45 +03:00
|
|
|
#include "js/JSON.h"
|
2019-10-26 00:05:48 +03:00
|
|
|
#include "mozilla/AsyncEventDispatcher.h"
|
2012-08-29 19:26:18 +04:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "mozilla/EventForwards.h"
|
2014-03-17 10:56:53 +04:00
|
|
|
#include "mozilla/EventListenerManager.h"
|
2020-11-23 19:21:38 +03:00
|
|
|
#include "mozilla/HoldDropJSObjects.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "mozilla/IMEStateManager.h"
|
|
|
|
#include "mozilla/LookAndFeel.h"
|
|
|
|
#include "mozilla/MouseEvents.h"
|
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
#include "mozilla/PresShell.h"
|
|
|
|
#include "mozilla/ProcessHangMonitor.h"
|
|
|
|
#include "mozilla/ResultExtensions.h"
|
|
|
|
#include "mozilla/ScopeExit.h"
|
|
|
|
#include "mozilla/Services.h"
|
|
|
|
#include "mozilla/StaticPrefs_dom.h"
|
2020-09-16 17:51:01 +03:00
|
|
|
#include "mozilla/StaticPrefs_fission.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "mozilla/StaticPrefs_layout.h"
|
|
|
|
#include "mozilla/StaticPtr.h"
|
|
|
|
#include "mozilla/Telemetry.h"
|
|
|
|
#include "mozilla/TextEvents.h"
|
|
|
|
#include "mozilla/TouchEvents.h"
|
2020-09-28 03:36:32 +03:00
|
|
|
#include "mozilla/ToString.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2020-09-22 12:57:27 +03:00
|
|
|
#include "mozilla/dom/AutoPrintEventDispatcher.h"
|
2019-09-20 21:15:18 +03:00
|
|
|
#include "mozilla/dom/BrowserBridgeChild.h"
|
2018-03-13 23:23:59 +03:00
|
|
|
#include "mozilla/dom/DataTransfer.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "mozilla/dom/DocGroup.h"
|
|
|
|
#include "mozilla/dom/Element.h"
|
2018-04-20 07:49:29 +03:00
|
|
|
#include "mozilla/dom/Event.h"
|
2019-09-20 21:15:18 +03:00
|
|
|
#include "mozilla/dom/JSWindowActorChild.h"
|
2019-01-11 14:43:39 +03:00
|
|
|
#include "mozilla/dom/LoadURIOptionsBinding.h"
|
2017-07-19 15:59:02 +03:00
|
|
|
#include "mozilla/dom/MessageManagerBinding.h"
|
2018-03-20 07:16:06 +03:00
|
|
|
#include "mozilla/dom/MouseEventBinding.h"
|
2019-01-02 16:26:56 +03:00
|
|
|
#include "mozilla/dom/Nullable.h"
|
2019-01-25 17:44:09 +03:00
|
|
|
#include "mozilla/dom/PBrowser.h"
|
2019-09-20 21:15:18 +03:00
|
|
|
#include "mozilla/dom/PaymentRequestChild.h"
|
2020-11-23 19:21:38 +03:00
|
|
|
#include "mozilla/dom/PointerEventHandler.h"
|
2019-05-04 13:42:52 +03:00
|
|
|
#include "mozilla/dom/SessionStoreListener.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "mozilla/dom/WindowGlobalChild.h"
|
2019-09-20 21:15:18 +03:00
|
|
|
#include "mozilla/dom/WindowProxyHolder.h"
|
2018-09-25 05:48:02 +03:00
|
|
|
#include "mozilla/gfx/CrossProcessPaint.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "mozilla/gfx/Matrix.h"
|
2019-03-22 21:28:42 +03:00
|
|
|
#include "mozilla/gfx/gfxVars.h"
|
2019-06-14 00:08:40 +03:00
|
|
|
#include "mozilla/ipc/BackgroundUtils.h"
|
Bug 1645528 - Connect nsRefreshDrivers in content processes with a widget-local vsync source r=mattwoodrow,emilio
To allow `requestAnimationFrame()` and similar things to run at monitor
speed if there is only a window-specific vsyncsource available.
This is the case for Wayland and, in the future, EGL/X11. Other backends
may opt for window specific vsyncsources as well at some point.
The idea is to, instead of using global vsync objects, expose a vsyncsource
from nsWindow and use it for refresh drivers. For the content process, move
VsyncChild to BrowserChild, so for each Browserchild there is only one
VsyncChild to which all refresh drivers connect.
IPC in managed either by PBrowser or PBackground. Right now, PBrowser is
only used on Wayland, as both PBrowser and the Wayland vsyncsource run
on the main thread. Other backends keep using the background thread for
now.
While at it, make it so that we constantly update the refresh rate. This
is necessary for Wayland, but also on other platforms variable refresh rates
are increasingly common. Do that by transimitting the vsync rate `SendNotify()`.
How to test:
- run the Wayland backend
- enable `widget.wayland_vsync.enabled`
- optionally: disable `privacy.reduceTimerPrecision`
- run `vsynctester.com` or `testufo.com`
Expected results:
Instead of fixed 60Hz, things should update at monitor refresh rate -
e.g. 144Hz
Original patch by Kenny Levinsen.
Depends on D98254
Differential Revision: https://phabricator.services.mozilla.com/D93173
2020-12-02 12:47:53 +03:00
|
|
|
#include "mozilla/ipc/PBackgroundChild.h"
|
2015-12-04 02:04:28 +03:00
|
|
|
#include "mozilla/ipc/URIUtils.h"
|
2014-04-17 15:54:25 +04:00
|
|
|
#include "mozilla/layers/APZCCallbackHelper.h"
|
2016-11-29 07:21:27 +03:00
|
|
|
#include "mozilla/layers/APZCTreeManagerChild.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "mozilla/layers/APZChild.h"
|
2015-02-09 22:05:18 +03:00
|
|
|
#include "mozilla/layers/APZEventState.h"
|
2016-03-22 21:08:38 +03:00
|
|
|
#include "mozilla/layers/CompositorBridgeChild.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "mozilla/layers/ContentProcessController.h"
|
2015-07-27 21:07:58 +03:00
|
|
|
#include "mozilla/layers/DoubleTapToZoom.h"
|
2016-11-29 07:21:27 +03:00
|
|
|
#include "mozilla/layers/IAPZCTreeManager.h"
|
2013-06-24 09:28:22 +04:00
|
|
|
#include "mozilla/layers/ImageBridgeChild.h"
|
2015-09-28 21:44:37 +03:00
|
|
|
#include "mozilla/layers/InputAPZContext.h"
|
2017-11-01 05:58:10 +03:00
|
|
|
#include "mozilla/layers/LayerTransactionChild.h"
|
2013-08-12 03:15:10 +04:00
|
|
|
#include "mozilla/layers/ShadowLayers.h"
|
2016-11-16 16:54:51 +03:00
|
|
|
#include "mozilla/layers/WebRenderLayerManager.h"
|
2017-02-09 19:53:50 +03:00
|
|
|
#include "mozilla/plugins/PPluginWidgetChild.h"
|
2019-04-03 20:29:15 +03:00
|
|
|
#include "nsBrowserStatusFilter.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "nsColorPickerProxy.h"
|
|
|
|
#include "nsCommandParams.h"
|
|
|
|
#include "nsContentPermissionHelper.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "nsContentUtils.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "nsDeviceContext.h"
|
2014-08-22 12:32:00 +04:00
|
|
|
#include "nsDocShell.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "nsDocShellLoadState.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "nsEmbedCID.h"
|
2013-01-07 18:42:32 +04:00
|
|
|
#include "nsExceptionHandler.h"
|
2014-02-18 04:30:06 +04:00
|
|
|
#include "nsFilePickerProxy.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "nsFocusManager.h"
|
2016-05-25 09:41:54 +03:00
|
|
|
#include "nsGlobalWindow.h"
|
2009-07-01 00:39:22 +04:00
|
|
|
#include "nsIBaseWindow.h"
|
2014-06-20 22:07:47 +04:00
|
|
|
#include "nsIBrowserDOMWindow.h"
|
2019-01-25 17:44:09 +03:00
|
|
|
#include "nsIClassifiedChannel.h"
|
2010-08-13 12:06:40 +04:00
|
|
|
#include "nsIDocShell.h"
|
2014-11-22 06:10:18 +03:00
|
|
|
#include "nsIFrame.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "nsILoadContext.h"
|
|
|
|
#include "nsISHEntry.h"
|
|
|
|
#include "nsISHistory.h"
|
|
|
|
#include "nsIScriptError.h"
|
2019-12-06 12:24:56 +03:00
|
|
|
#include "nsISecureBrowserUI.h"
|
2010-03-26 21:39:39 +03:00
|
|
|
#include "nsIURI.h"
|
2019-06-14 00:08:40 +03:00
|
|
|
#include "nsIURIMutator.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "nsIWeakReferenceUtils.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "nsIWebBrowser.h"
|
|
|
|
#include "nsIWebProgress.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "nsLayoutUtils.h"
|
|
|
|
#include "nsNetUtil.h"
|
2020-04-08 00:39:32 +03:00
|
|
|
#include "nsIOpenWindowInfo.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
#include "nsPIWindowRoot.h"
|
2017-09-13 06:59:35 +03:00
|
|
|
#include "nsPointerHashKeys.h"
|
2012-07-20 10:48:27 +04:00
|
|
|
#include "nsPrintfCString.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "nsQueryActor.h"
|
|
|
|
#include "nsQueryObject.h"
|
2020-08-05 00:17:50 +03:00
|
|
|
#include "nsRefreshDriver.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "nsSandboxFlags.h"
|
|
|
|
#include "nsString.h"
|
2017-09-13 06:59:35 +03:00
|
|
|
#include "nsTHashtable.h"
|
2017-03-21 10:44:12 +03:00
|
|
|
#include "nsThreadManager.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "nsThreadUtils.h"
|
2016-07-23 02:36:45 +03:00
|
|
|
#include "nsViewManager.h"
|
2012-12-18 01:24:41 +04:00
|
|
|
#include "nsViewportInfo.h"
|
2018-08-03 22:21:03 +03:00
|
|
|
#include "nsWebBrowser.h"
|
Bug 1609996 - Reorder some includes affected by the previous patches. r=froydnj
This was done by:
This was done by applying:
```
diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
index 789affde7bbf..fe33c4c7d4d1 100644
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -2007,7 +2007,7 @@ class StaticAnalysis(MachCommandBase):
from subprocess import Popen, PIPE, check_output, CalledProcessError
diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
- args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format]
+ args = [sys.executable, clang_format_diff, "-p1", "-binary=%s" % clang_format, '-sort-includes']
if not output_file:
args.append("-i")
```
Then running `./mach clang-format -c <commit-hash>`
Then undoing that patch.
Then running check_spidermonkey_style.py --fixup
Then running `./mach clang-format`
I had to fix four things:
* I needed to move <utility> back down in GuardObjects.h because I was hitting
obscure problems with our system include wrappers like this:
0:03.94 /usr/include/stdlib.h:550:14: error: exception specification in declaration does not match previous declaration
0:03.94 extern void *realloc (void *__ptr, size_t __size)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/malloc_decls.h:53:1: note: previous declaration is here
0:03.94 MALLOC_DECL(realloc, void*, void*, size_t)
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozilla/mozalloc.h:22:32: note: expanded from macro 'MALLOC_DECL'
0:03.94 MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);
0:03.94 ^
0:03.94 <scratch space>:178:1: note: expanded from here
0:03.94 realloc_impl
0:03.94 ^
0:03.94 /home/emilio/src/moz/gecko-2/obj-debug/dist/include/mozmemory_wrap.h:142:41: note: expanded from macro 'realloc_impl'
0:03.94 #define realloc_impl mozmem_malloc_impl(realloc)
Which I really didn't feel like digging into.
* I had to restore the order of TrustOverrideUtils.h and related files in nss
because the .inc files depend on TrustOverrideUtils.h being included earlier.
* I had to add a missing include to RollingNumber.h
* Also had to partially restore include order in JsepSessionImpl.cpp to avoid
some -WError issues due to some static inline functions being defined in a
header but not used in the rest of the compilation unit.
Differential Revision: https://phabricator.services.mozilla.com/D60327
--HG--
extra : moz-landing-system : lando
2020-01-20 19:19:48 +03:00
|
|
|
#include "nsWindowWatcher.h"
|
2020-09-28 15:01:12 +03:00
|
|
|
#include "nsIXULRuntime.h"
|
2014-02-24 00:19:43 +04:00
|
|
|
|
2017-02-09 19:53:50 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
# include "mozilla/plugins/PluginWidgetChild.h"
|
|
|
|
#endif
|
|
|
|
|
Bug 1645528 - Connect nsRefreshDrivers in content processes with a widget-local vsync source r=mattwoodrow,emilio
To allow `requestAnimationFrame()` and similar things to run at monitor
speed if there is only a window-specific vsyncsource available.
This is the case for Wayland and, in the future, EGL/X11. Other backends
may opt for window specific vsyncsources as well at some point.
The idea is to, instead of using global vsync objects, expose a vsyncsource
from nsWindow and use it for refresh drivers. For the content process, move
VsyncChild to BrowserChild, so for each Browserchild there is only one
VsyncChild to which all refresh drivers connect.
IPC in managed either by PBrowser or PBackground. Right now, PBrowser is
only used on Wayland, as both PBrowser and the Wayland vsyncsource run
on the main thread. Other backends keep using the background thread for
now.
While at it, make it so that we constantly update the refresh rate. This
is necessary for Wayland, but also on other platforms variable refresh rates
are increasingly common. Do that by transimitting the vsync rate `SendNotify()`.
How to test:
- run the Wayland backend
- enable `widget.wayland_vsync.enabled`
- optionally: disable `privacy.reduceTimerPrecision`
- run `vsynctester.com` or `testufo.com`
Expected results:
Instead of fixed 60Hz, things should update at monitor refresh rate -
e.g. 144Hz
Original patch by Kenny Levinsen.
Depends on D98254
Differential Revision: https://phabricator.services.mozilla.com/D93173
2020-12-02 12:47:53 +03:00
|
|
|
#ifdef MOZ_WAYLAND
|
|
|
|
# include "nsAppRunner.h"
|
|
|
|
#endif
|
|
|
|
|
2016-05-16 12:40:54 +03:00
|
|
|
#ifdef NS_PRINTING
|
|
|
|
# include "nsIPrintSession.h"
|
|
|
|
# include "nsIPrintSettings.h"
|
|
|
|
# include "nsIPrintSettingsService.h"
|
|
|
|
# include "nsIWebBrowserPrint.h"
|
|
|
|
#endif
|
|
|
|
|
2020-02-24 19:31:04 +03:00
|
|
|
static mozilla::LazyLogModule sApzChildLog("apz.child");
|
2014-08-06 20:41:05 +04:00
|
|
|
|
2012-08-02 10:02:29 +04:00
|
|
|
using namespace mozilla;
|
2009-08-12 20:18:08 +04:00
|
|
|
using namespace mozilla::dom;
|
2012-09-28 09:43:12 +04:00
|
|
|
using namespace mozilla::dom::ipc;
|
2010-10-27 02:20:53 +04:00
|
|
|
using namespace mozilla::ipc;
|
2010-08-21 03:24:41 +04:00
|
|
|
using namespace mozilla::layers;
|
2010-08-21 03:24:41 +04:00
|
|
|
using namespace mozilla::layout;
|
2010-10-20 21:12:32 +04:00
|
|
|
using namespace mozilla::docshell;
|
2012-08-12 05:42:34 +04:00
|
|
|
using namespace mozilla::widget;
|
2016-07-05 20:24:54 +03:00
|
|
|
using mozilla::layers::GeckoContentController;
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(ContentListener, nsIDOMEventListener)
|
2009-11-17 17:22:23 +03:00
|
|
|
|
2012-09-29 06:18:18 +04:00
|
|
|
static const char BEFORE_FIRST_PAINT[] = "before-first-paint";
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
typedef nsDataHashtable<nsUint64HashKey, BrowserChild*> BrowserChildMap;
|
|
|
|
static BrowserChildMap* sBrowserChildren;
|
|
|
|
StaticMutex sBrowserChildrenMutex;
|
2014-03-07 07:24:32 +04:00
|
|
|
|
2019-06-03 23:04:46 +03:00
|
|
|
already_AddRefed<Document> BrowserChild::GetTopLevelDocument() const {
|
2019-01-02 16:05:23 +03:00
|
|
|
nsCOMPtr<Document> doc;
|
2018-05-11 20:46:15 +03:00
|
|
|
WebNavigation()->GetDocument(getter_AddRefs(doc));
|
2014-03-25 06:28:46 +04:00
|
|
|
return doc.forget();
|
|
|
|
}
|
|
|
|
|
2019-06-03 23:04:46 +03:00
|
|
|
PresShell* BrowserChild::GetTopLevelPresShell() const {
|
2019-04-13 04:53:10 +03:00
|
|
|
if (RefPtr<Document> doc = GetTopLevelDocument()) {
|
|
|
|
return doc->GetPresShell();
|
2015-04-14 23:44:59 +03:00
|
|
|
}
|
2019-04-13 04:53:10 +03:00
|
|
|
return nullptr;
|
2015-04-14 23:44:59 +03:00
|
|
|
}
|
|
|
|
|
2019-06-03 23:04:46 +03:00
|
|
|
bool BrowserChild::UpdateFrame(const RepaintRequest& aRequest) {
|
2018-11-01 23:15:46 +03:00
|
|
|
MOZ_ASSERT(aRequest.GetScrollId() != ScrollableLayerGuid::NULL_SCROLL_ID);
|
2014-03-25 06:28:46 +04:00
|
|
|
|
2018-09-19 21:50:20 +03:00
|
|
|
if (aRequest.IsRootContent()) {
|
2019-04-13 04:53:10 +03:00
|
|
|
if (PresShell* presShell = GetTopLevelPresShell()) {
|
2015-04-14 23:44:59 +03:00
|
|
|
// Guard against stale updates (updates meant for a pres shell which
|
|
|
|
// has since been torn down and destroyed).
|
2019-04-13 04:53:10 +03:00
|
|
|
if (aRequest.GetPresShellId() == presShell->GetPresShellId()) {
|
2020-06-05 00:43:24 +03:00
|
|
|
APZCCallbackHelper::UpdateRootFrame(aRequest);
|
2015-04-14 23:44:59 +03:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-25 06:28:46 +04:00
|
|
|
}
|
|
|
|
} else {
|
2018-09-19 21:50:20 +03:00
|
|
|
// aRequest.mIsRoot is false, so we are trying to update a subframe.
|
2014-03-25 06:28:46 +04:00
|
|
|
// This requires special handling.
|
2018-09-19 21:50:20 +03:00
|
|
|
APZCCallbackHelper::UpdateSubFrame(aRequest);
|
2015-06-15 21:39:06 +03:00
|
|
|
return true;
|
2014-03-25 06:28:46 +04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-11-17 17:22:23 +03:00
|
|
|
NS_IMETHODIMP
|
2018-04-20 07:49:29 +03:00
|
|
|
ContentListener::HandleEvent(Event* aEvent) {
|
2009-11-17 17:22:23 +03:00
|
|
|
RemoteDOMEvent remoteEvent;
|
2018-04-20 07:49:30 +03:00
|
|
|
remoteEvent.mEvent = aEvent;
|
2009-11-17 17:22:23 +03:00
|
|
|
NS_ENSURE_STATE(remoteEvent.mEvent);
|
2019-04-10 01:39:01 +03:00
|
|
|
mBrowserChild->SendEvent(remoteEvent);
|
2009-11-17 17:22:23 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
class BrowserChild::DelayedDeleteRunnable final : public Runnable,
|
|
|
|
public nsIRunnablePriority {
|
|
|
|
RefPtr<BrowserChild> mBrowserChild;
|
2014-07-11 22:15:10 +04:00
|
|
|
|
2020-12-22 20:56:28 +03:00
|
|
|
// In order to try that this runnable runs after everything that could
|
|
|
|
// possibly touch this tab, we send it through the event queue twice.
|
Bug 1382922 - Refactor event queue to allow multiple implementations (r=erahm)
This patch refactors the nsThread event queue to clean it up and to make it easier to restructure. The fundamental concepts are as follows:
Each nsThread will have a pointer to a refcounted SynchronizedEventQueue. A SynchronizedEQ takes care of doing the locking and condition variable work when posting and popping events. For the actual storage of events, it delegates to an AbstractEventQueue data structure. It keeps a UniquePtr to the AbstractEventQueue that it uses for storage.
Both SynchronizedEQ and AbstractEventQueue are abstract classes. There is only one concrete implementation of SynchronizedEQ in this patch, which is called ThreadEventQueue. ThreadEventQueue uses locks and condition variables to post and pop events the same way nsThread does. It also encapsulates the functionality that DOM workers need to implement their special event loops (PushEventQueue and PopEventQueue). In later Quantum DOM work, I plan to have another SynchronizedEQ implementation for the main thread, called SchedulerEventQueue. It will have special code for the cooperatively scheduling threads in Quantum DOM.
There are two concrete implementations of AbstractEventQueue in this patch: EventQueue and PrioritizedEventQueue. EventQueue replaces the old nsEventQueue. The other AbstractEventQueue implementation is PrioritizedEventQueue, which uses multiple queues for different event priorities.
The final major piece here is ThreadEventTarget, which splits some of the code for posting events out of nsThread. Eventually, my plan is for multiple cooperatively scheduled nsThreads to be able to share a ThreadEventTarget. In this patch, though, each nsThread has its own ThreadEventTarget. The class's purpose is just to collect some related code together.
One final note: I tried to avoid virtual dispatch overhead as much as possible. Calls to SynchronizedEQ methods do use virtual dispatch, since I plan to use different implementations for different threads with Quantum DOM. But all the calls to EventQueue methods should be non-virtual. Although the methods are declared virtual, all the classes used are final and the concrete classes involved should all be known through templatization.
MozReview-Commit-ID: 9Evtr9oIJvx
2017-06-21 05:42:13 +03:00
|
|
|
bool mReadyToDelete = false;
|
|
|
|
|
2014-07-11 22:15:10 +04:00
|
|
|
public:
|
2019-04-10 01:39:01 +03:00
|
|
|
explicit DelayedDeleteRunnable(BrowserChild* aBrowserChild)
|
|
|
|
: Runnable("BrowserChild::DelayedDeleteRunnable"),
|
|
|
|
mBrowserChild(aBrowserChild) {
|
2014-07-11 22:15:10 +04:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2019-04-10 01:39:01 +03:00
|
|
|
MOZ_ASSERT(aBrowserChild);
|
2014-07-11 22:15:10 +04:00
|
|
|
}
|
|
|
|
|
Bug 1382922 - Refactor event queue to allow multiple implementations (r=erahm)
This patch refactors the nsThread event queue to clean it up and to make it easier to restructure. The fundamental concepts are as follows:
Each nsThread will have a pointer to a refcounted SynchronizedEventQueue. A SynchronizedEQ takes care of doing the locking and condition variable work when posting and popping events. For the actual storage of events, it delegates to an AbstractEventQueue data structure. It keeps a UniquePtr to the AbstractEventQueue that it uses for storage.
Both SynchronizedEQ and AbstractEventQueue are abstract classes. There is only one concrete implementation of SynchronizedEQ in this patch, which is called ThreadEventQueue. ThreadEventQueue uses locks and condition variables to post and pop events the same way nsThread does. It also encapsulates the functionality that DOM workers need to implement their special event loops (PushEventQueue and PopEventQueue). In later Quantum DOM work, I plan to have another SynchronizedEQ implementation for the main thread, called SchedulerEventQueue. It will have special code for the cooperatively scheduling threads in Quantum DOM.
There are two concrete implementations of AbstractEventQueue in this patch: EventQueue and PrioritizedEventQueue. EventQueue replaces the old nsEventQueue. The other AbstractEventQueue implementation is PrioritizedEventQueue, which uses multiple queues for different event priorities.
The final major piece here is ThreadEventTarget, which splits some of the code for posting events out of nsThread. Eventually, my plan is for multiple cooperatively scheduled nsThreads to be able to share a ThreadEventTarget. In this patch, though, each nsThread has its own ThreadEventTarget. The class's purpose is just to collect some related code together.
One final note: I tried to avoid virtual dispatch overhead as much as possible. Calls to SynchronizedEQ methods do use virtual dispatch, since I plan to use different implementations for different threads with Quantum DOM. But all the calls to EventQueue methods should be non-virtual. Although the methods are declared virtual, all the classes used are final and the concrete classes involved should all be known through templatization.
MozReview-Commit-ID: 9Evtr9oIJvx
2017-06-21 05:42:13 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2016-08-08 05:18:10 +03:00
|
|
|
private:
|
|
|
|
~DelayedDeleteRunnable() {
|
2014-07-11 22:15:10 +04:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2019-04-10 01:39:01 +03:00
|
|
|
MOZ_ASSERT(!mBrowserChild);
|
2017-03-21 10:44:12 +03:00
|
|
|
}
|
Bug 1382922 - Refactor event queue to allow multiple implementations (r=erahm)
This patch refactors the nsThread event queue to clean it up and to make it easier to restructure. The fundamental concepts are as follows:
Each nsThread will have a pointer to a refcounted SynchronizedEventQueue. A SynchronizedEQ takes care of doing the locking and condition variable work when posting and popping events. For the actual storage of events, it delegates to an AbstractEventQueue data structure. It keeps a UniquePtr to the AbstractEventQueue that it uses for storage.
Both SynchronizedEQ and AbstractEventQueue are abstract classes. There is only one concrete implementation of SynchronizedEQ in this patch, which is called ThreadEventQueue. ThreadEventQueue uses locks and condition variables to post and pop events the same way nsThread does. It also encapsulates the functionality that DOM workers need to implement their special event loops (PushEventQueue and PopEventQueue). In later Quantum DOM work, I plan to have another SynchronizedEQ implementation for the main thread, called SchedulerEventQueue. It will have special code for the cooperatively scheduling threads in Quantum DOM.
There are two concrete implementations of AbstractEventQueue in this patch: EventQueue and PrioritizedEventQueue. EventQueue replaces the old nsEventQueue. The other AbstractEventQueue implementation is PrioritizedEventQueue, which uses multiple queues for different event priorities.
The final major piece here is ThreadEventTarget, which splits some of the code for posting events out of nsThread. Eventually, my plan is for multiple cooperatively scheduled nsThreads to be able to share a ThreadEventTarget. In this patch, though, each nsThread has its own ThreadEventTarget. The class's purpose is just to collect some related code together.
One final note: I tried to avoid virtual dispatch overhead as much as possible. Calls to SynchronizedEQ methods do use virtual dispatch, since I plan to use different implementations for different threads with Quantum DOM. But all the calls to EventQueue methods should be non-virtual. Although the methods are declared virtual, all the classes used are final and the concrete classes involved should all be known through templatization.
MozReview-Commit-ID: 9Evtr9oIJvx
2017-06-21 05:42:13 +03:00
|
|
|
|
2016-11-12 00:04:09 +03:00
|
|
|
NS_IMETHOD GetPriority(uint32_t* aPriority) override {
|
2020-12-22 20:56:28 +03:00
|
|
|
*aPriority = nsIRunnablePriority::PRIORITY_NORMAL;
|
2018-08-21 03:58:31 +03:00
|
|
|
return NS_OK;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2018-08-21 03:58:31 +03:00
|
|
|
NS_IMETHOD
|
|
|
|
Run() override {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2019-04-10 01:39:01 +03:00
|
|
|
MOZ_ASSERT(mBrowserChild);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-08-21 03:58:31 +03:00
|
|
|
if (!mReadyToDelete) {
|
|
|
|
// This time run this runnable at input priority.
|
|
|
|
mReadyToDelete = true;
|
|
|
|
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToCurrentThread(this));
|
Bug 1382922 - Refactor event queue to allow multiple implementations (r=erahm)
This patch refactors the nsThread event queue to clean it up and to make it easier to restructure. The fundamental concepts are as follows:
Each nsThread will have a pointer to a refcounted SynchronizedEventQueue. A SynchronizedEQ takes care of doing the locking and condition variable work when posting and popping events. For the actual storage of events, it delegates to an AbstractEventQueue data structure. It keeps a UniquePtr to the AbstractEventQueue that it uses for storage.
Both SynchronizedEQ and AbstractEventQueue are abstract classes. There is only one concrete implementation of SynchronizedEQ in this patch, which is called ThreadEventQueue. ThreadEventQueue uses locks and condition variables to post and pop events the same way nsThread does. It also encapsulates the functionality that DOM workers need to implement their special event loops (PushEventQueue and PopEventQueue). In later Quantum DOM work, I plan to have another SynchronizedEQ implementation for the main thread, called SchedulerEventQueue. It will have special code for the cooperatively scheduling threads in Quantum DOM.
There are two concrete implementations of AbstractEventQueue in this patch: EventQueue and PrioritizedEventQueue. EventQueue replaces the old nsEventQueue. The other AbstractEventQueue implementation is PrioritizedEventQueue, which uses multiple queues for different event priorities.
The final major piece here is ThreadEventTarget, which splits some of the code for posting events out of nsThread. Eventually, my plan is for multiple cooperatively scheduled nsThreads to be able to share a ThreadEventTarget. In this patch, though, each nsThread has its own ThreadEventTarget. The class's purpose is just to collect some related code together.
One final note: I tried to avoid virtual dispatch overhead as much as possible. Calls to SynchronizedEQ methods do use virtual dispatch, since I plan to use different implementations for different threads with Quantum DOM. But all the calls to EventQueue methods should be non-virtual. Although the methods are declared virtual, all the classes used are final and the concrete classes involved should all be known through templatization.
MozReview-Commit-ID: 9Evtr9oIJvx
2017-06-21 05:42:13 +03:00
|
|
|
return NS_OK;
|
2016-11-12 00:04:09 +03:00
|
|
|
}
|
|
|
|
|
2014-07-11 22:15:10 +04:00
|
|
|
// Check in case ActorDestroy was called after RecvDestroy message.
|
2020-02-27 20:39:15 +03:00
|
|
|
if (mBrowserChild->IPCOpen()) {
|
2019-04-10 01:39:01 +03:00
|
|
|
Unused << PBrowserChild::Send__delete__(mBrowserChild);
|
2014-07-11 22:15:10 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mBrowserChild = nullptr;
|
Bug 1382922 - Refactor event queue to allow multiple implementations (r=erahm)
This patch refactors the nsThread event queue to clean it up and to make it easier to restructure. The fundamental concepts are as follows:
Each nsThread will have a pointer to a refcounted SynchronizedEventQueue. A SynchronizedEQ takes care of doing the locking and condition variable work when posting and popping events. For the actual storage of events, it delegates to an AbstractEventQueue data structure. It keeps a UniquePtr to the AbstractEventQueue that it uses for storage.
Both SynchronizedEQ and AbstractEventQueue are abstract classes. There is only one concrete implementation of SynchronizedEQ in this patch, which is called ThreadEventQueue. ThreadEventQueue uses locks and condition variables to post and pop events the same way nsThread does. It also encapsulates the functionality that DOM workers need to implement their special event loops (PushEventQueue and PopEventQueue). In later Quantum DOM work, I plan to have another SynchronizedEQ implementation for the main thread, called SchedulerEventQueue. It will have special code for the cooperatively scheduling threads in Quantum DOM.
There are two concrete implementations of AbstractEventQueue in this patch: EventQueue and PrioritizedEventQueue. EventQueue replaces the old nsEventQueue. The other AbstractEventQueue implementation is PrioritizedEventQueue, which uses multiple queues for different event priorities.
The final major piece here is ThreadEventTarget, which splits some of the code for posting events out of nsThread. Eventually, my plan is for multiple cooperatively scheduled nsThreads to be able to share a ThreadEventTarget. In this patch, though, each nsThread has its own ThreadEventTarget. The class's purpose is just to collect some related code together.
One final note: I tried to avoid virtual dispatch overhead as much as possible. Calls to SynchronizedEQ methods do use virtual dispatch, since I plan to use different implementations for different threads with Quantum DOM. But all the calls to EventQueue methods should be non-virtual. Although the methods are declared virtual, all the classes used are final and the concrete classes involved should all be known through templatization.
MozReview-Commit-ID: 9Evtr9oIJvx
2017-06-21 05:42:13 +03:00
|
|
|
return NS_OK;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2014-07-11 22:15:10 +04:00
|
|
|
};
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(BrowserChild::DelayedDeleteRunnable, Runnable,
|
Bug 1382922 - Refactor event queue to allow multiple implementations (r=erahm)
This patch refactors the nsThread event queue to clean it up and to make it easier to restructure. The fundamental concepts are as follows:
Each nsThread will have a pointer to a refcounted SynchronizedEventQueue. A SynchronizedEQ takes care of doing the locking and condition variable work when posting and popping events. For the actual storage of events, it delegates to an AbstractEventQueue data structure. It keeps a UniquePtr to the AbstractEventQueue that it uses for storage.
Both SynchronizedEQ and AbstractEventQueue are abstract classes. There is only one concrete implementation of SynchronizedEQ in this patch, which is called ThreadEventQueue. ThreadEventQueue uses locks and condition variables to post and pop events the same way nsThread does. It also encapsulates the functionality that DOM workers need to implement their special event loops (PushEventQueue and PopEventQueue). In later Quantum DOM work, I plan to have another SynchronizedEQ implementation for the main thread, called SchedulerEventQueue. It will have special code for the cooperatively scheduling threads in Quantum DOM.
There are two concrete implementations of AbstractEventQueue in this patch: EventQueue and PrioritizedEventQueue. EventQueue replaces the old nsEventQueue. The other AbstractEventQueue implementation is PrioritizedEventQueue, which uses multiple queues for different event priorities.
The final major piece here is ThreadEventTarget, which splits some of the code for posting events out of nsThread. Eventually, my plan is for multiple cooperatively scheduled nsThreads to be able to share a ThreadEventTarget. In this patch, though, each nsThread has its own ThreadEventTarget. The class's purpose is just to collect some related code together.
One final note: I tried to avoid virtual dispatch overhead as much as possible. Calls to SynchronizedEQ methods do use virtual dispatch, since I plan to use different implementations for different threads with Quantum DOM. But all the calls to EventQueue methods should be non-virtual. Although the methods are declared virtual, all the classes used are final and the concrete classes involved should all be known through templatization.
MozReview-Commit-ID: 9Evtr9oIJvx
2017-06-21 05:42:13 +03:00
|
|
|
nsIRunnablePriority)
|
|
|
|
|
2015-01-30 12:07:12 +03:00
|
|
|
namespace {
|
2019-04-10 01:39:01 +03:00
|
|
|
std::map<TabId, RefPtr<BrowserChild>>& NestedBrowserChildMap() {
|
2014-06-11 09:44:36 +04:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2019-04-10 01:39:01 +03:00
|
|
|
static std::map<TabId, RefPtr<BrowserChild>> sNestedBrowserChildMap;
|
|
|
|
return sNestedBrowserChildMap;
|
2014-06-11 09:44:36 +04:00
|
|
|
}
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace
|
2015-01-30 12:07:12 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
already_AddRefed<BrowserChild> BrowserChild::FindBrowserChild(
|
|
|
|
const TabId& aTabId) {
|
|
|
|
auto iter = NestedBrowserChildMap().find(aTabId);
|
|
|
|
if (iter == NestedBrowserChildMap().end()) {
|
2015-01-30 12:07:12 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
2019-04-10 01:39:01 +03:00
|
|
|
RefPtr<BrowserChild> browserChild = iter->second;
|
|
|
|
return browserChild.forget();
|
2015-01-30 12:07:12 +03:00
|
|
|
}
|
2014-06-11 09:44:36 +04:00
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/*static*/
|
2019-04-10 01:39:01 +03:00
|
|
|
already_AddRefed<BrowserChild> BrowserChild::Create(
|
2020-04-07 18:17:47 +03:00
|
|
|
ContentChild* aManager, const TabId& aTabId, const TabContext& aContext,
|
|
|
|
BrowsingContext* aBrowsingContext, uint32_t aChromeFlags,
|
|
|
|
bool aIsTopLevel) {
|
|
|
|
RefPtr<BrowserChild> iframe = new BrowserChild(
|
|
|
|
aManager, aTabId, aContext, aBrowsingContext, aChromeFlags, aIsTopLevel);
|
2017-04-07 02:46:18 +03:00
|
|
|
return iframe.forget();
|
2012-08-29 19:26:18 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::BrowserChild(ContentChild* aManager, const TabId& aTabId,
|
2020-04-07 18:17:47 +03:00
|
|
|
const TabContext& aContext,
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowsingContext* aBrowsingContext,
|
2019-05-29 19:35:37 +03:00
|
|
|
uint32_t aChromeFlags, bool aIsTopLevel)
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
: TabContext(aContext),
|
2019-06-03 23:04:46 +03:00
|
|
|
mBrowserChildMessageManager(nullptr),
|
2013-07-10 21:07:51 +04:00
|
|
|
mManager(aManager),
|
2019-03-14 21:50:45 +03:00
|
|
|
mBrowsingContext(aBrowsingContext),
|
2010-07-19 22:33:33 +04:00
|
|
|
mChromeFlags(aChromeFlags),
|
2017-03-15 02:48:41 +03:00
|
|
|
mMaxTouchPoints(0),
|
2018-04-13 16:01:28 +03:00
|
|
|
mLayersId{0},
|
2019-05-24 17:25:34 +03:00
|
|
|
mEffectsInfo{EffectsInfo::FullyHidden()},
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones DONTBUILD
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
(Re-landing changeset a6a847452dbf, backed out in 5091aa6083c4, because it was originally landed with the incorrect bug number.)
2012-10-31 00:13:21 +04:00
|
|
|
mDidFakeShow(false),
|
2012-08-29 19:26:18 +04:00
|
|
|
mTriedBrowserInit(false),
|
2018-08-29 23:54:56 +03:00
|
|
|
mOrientation(hal::eScreenOrientation_PortraitPrimary),
|
Bug 1645528 - Connect nsRefreshDrivers in content processes with a widget-local vsync source r=mattwoodrow,emilio
To allow `requestAnimationFrame()` and similar things to run at monitor
speed if there is only a window-specific vsyncsource available.
This is the case for Wayland and, in the future, EGL/X11. Other backends
may opt for window specific vsyncsources as well at some point.
The idea is to, instead of using global vsync objects, expose a vsyncsource
from nsWindow and use it for refresh drivers. For the content process, move
VsyncChild to BrowserChild, so for each Browserchild there is only one
VsyncChild to which all refresh drivers connect.
IPC in managed either by PBrowser or PBackground. Right now, PBrowser is
only used on Wayland, as both PBrowser and the Wayland vsyncsource run
on the main thread. Other backends keep using the background thread for
now.
While at it, make it so that we constantly update the refresh rate. This
is necessary for Wayland, but also on other platforms variable refresh rates
are increasingly common. Do that by transimitting the vsync rate `SendNotify()`.
How to test:
- run the Wayland backend
- enable `widget.wayland_vsync.enabled`
- optionally: disable `privacy.reduceTimerPrecision`
- run `vsynctester.com` or `testufo.com`
Expected results:
Instead of fixed 60Hz, things should update at monitor refresh rate -
e.g. 144Hz
Original patch by Kenny Levinsen.
Depends on D98254
Differential Revision: https://phabricator.services.mozilla.com/D93173
2020-12-02 12:47:53 +03:00
|
|
|
mVsyncChild(nullptr),
|
2014-03-12 07:13:38 +04:00
|
|
|
mIgnoreKeyPressEvent(false),
|
2014-04-25 19:40:23 +04:00
|
|
|
mHasValidInnerSize(false),
|
2014-08-24 11:16:32 +04:00
|
|
|
mDestroyed(false),
|
2019-11-14 08:59:47 +03:00
|
|
|
mDynamicToolbarMaxHeight(0),
|
2014-10-29 21:11:00 +03:00
|
|
|
mUniqueId(aTabId),
|
2019-05-29 19:35:37 +03:00
|
|
|
mIsTopLevel(aIsTopLevel),
|
2018-07-19 21:05:35 +03:00
|
|
|
mHasSiblings(false),
|
2016-05-16 05:56:09 +03:00
|
|
|
mIsTransparent(false),
|
2018-11-28 03:57:32 +03:00
|
|
|
mIPCOpen(false),
|
2015-10-30 16:24:57 +03:00
|
|
|
mDidSetRealShowInfo(false),
|
2016-03-12 01:31:55 +03:00
|
|
|
mDidLoadURLInit(false),
|
2017-01-16 12:29:37 +03:00
|
|
|
mSkipKeyPress(false),
|
2019-05-23 21:48:18 +03:00
|
|
|
mLayersObserverEpoch{1},
|
2016-09-15 22:37:04 +03:00
|
|
|
#if defined(XP_WIN) && defined(ACCESSIBILITY)
|
2019-05-23 21:48:18 +03:00
|
|
|
mNativeWindowHandle(0),
|
2016-09-15 22:37:04 +03:00
|
|
|
#endif
|
2017-05-02 00:04:55 +03:00
|
|
|
#if defined(ACCESSIBILITY)
|
2019-05-23 21:48:18 +03:00
|
|
|
mTopLevelDocAccessibleChild(nullptr),
|
2017-05-02 00:04:55 +03:00
|
|
|
#endif
|
2019-05-23 21:48:18 +03:00
|
|
|
mShouldSendWebProgressEventsToParent(false),
|
2019-05-15 23:29:22 +03:00
|
|
|
mRenderLayers(true),
|
2019-05-23 21:48:18 +03:00
|
|
|
mPendingDocShellIsActive(false),
|
|
|
|
mPendingDocShellReceivedMessage(false),
|
|
|
|
mPendingRenderLayers(false),
|
|
|
|
mPendingRenderLayersReceivedMessage(false),
|
|
|
|
mPendingLayersObserverEpoch{0},
|
|
|
|
mPendingDocShellBlockers(0),
|
|
|
|
mCancelContentJSEpoch(0),
|
2019-10-14 22:10:39 +03:00
|
|
|
mWidgetNativeData(0) {
|
2017-10-02 17:58:52 +03:00
|
|
|
mozilla::HoldJSObjects(this);
|
|
|
|
|
2015-09-11 19:27:49 +03:00
|
|
|
nsWeakPtr weakPtrThis(do_GetWeakReference(
|
2019-04-10 02:15:02 +03:00
|
|
|
static_cast<nsIBrowserChild*>(this))); // for capture by the lambda
|
2015-09-11 19:27:49 +03:00
|
|
|
mSetAllowedTouchBehaviorCallback =
|
|
|
|
[weakPtrThis](uint64_t aInputBlockId,
|
|
|
|
const nsTArray<TouchBehaviorFlags>& aFlags) {
|
2019-04-10 01:39:01 +03:00
|
|
|
if (nsCOMPtr<nsIBrowserChild> browserChild =
|
2019-04-10 02:15:02 +03:00
|
|
|
do_QueryReferent(weakPtrThis)) {
|
2019-04-10 01:39:01 +03:00
|
|
|
static_cast<BrowserChild*>(browserChild.get())
|
2016-01-08 22:17:39 +03:00
|
|
|
->SetAllowedTouchBehavior(aInputBlockId, aFlags);
|
2015-09-11 19:27:49 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
// preloaded BrowserChild should not be added to child map
|
2014-10-29 21:11:00 +03:00
|
|
|
if (mUniqueId) {
|
2019-04-10 01:39:01 +03:00
|
|
|
MOZ_ASSERT(NestedBrowserChildMap().find(mUniqueId) ==
|
|
|
|
NestedBrowserChildMap().end());
|
|
|
|
NestedBrowserChildMap()[mUniqueId] = this;
|
2014-10-29 21:11:00 +03:00
|
|
|
}
|
2017-08-11 09:58:08 +03:00
|
|
|
mCoalesceMouseMoveEvents =
|
|
|
|
Preferences::GetBool("dom.event.coalesce_mouse_move");
|
|
|
|
if (mCoalesceMouseMoveEvents) {
|
|
|
|
mCoalescedMouseEventFlusher = new CoalescedMouseMoveFlusher(this);
|
|
|
|
}
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
const CompositorOptions& BrowserChild::GetCompositorOptions() const {
|
2017-11-03 10:38:34 +03:00
|
|
|
// If you're calling this before mCompositorOptions is set, well.. don't.
|
|
|
|
MOZ_ASSERT(mCompositorOptions);
|
|
|
|
return mCompositorOptions.ref();
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
bool BrowserChild::AsyncPanZoomEnabled() const {
|
2017-06-30 21:51:33 +03:00
|
|
|
// This might get called by the TouchEvent::PrefEnabled code before we have
|
|
|
|
// mCompositorOptions populated (bug 1370089). In that case we just assume
|
2019-04-10 01:39:01 +03:00
|
|
|
// APZ is enabled because we're in a content process (because BrowserChild)
|
|
|
|
// and APZ is probably going to be enabled here since e10s is enabled.
|
2017-06-30 21:51:33 +03:00
|
|
|
return mCompositorOptions ? mCompositorOptions->UseAPZ() : true;
|
2017-01-13 01:29:41 +03:00
|
|
|
}
|
|
|
|
|
2012-09-29 06:18:18 +04:00
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::Observe(nsISupports* aSubject, const char* aTopic,
|
|
|
|
const char16_t* aData) {
|
2015-07-27 21:07:58 +03:00
|
|
|
if (!strcmp(aTopic, BEFORE_FIRST_PAINT)) {
|
2015-06-04 23:51:10 +03:00
|
|
|
if (AsyncPanZoomEnabled()) {
|
2019-01-02 16:05:23 +03:00
|
|
|
nsCOMPtr<Document> subject(do_QueryInterface(aSubject));
|
2019-04-13 04:53:10 +03:00
|
|
|
nsCOMPtr<Document> doc(GetTopLevelDocument());
|
2012-09-29 06:18:18 +04:00
|
|
|
|
2019-06-11 15:57:23 +03:00
|
|
|
if (subject == doc && doc->IsTopLevelContentDocument()) {
|
2019-03-29 18:12:47 +03:00
|
|
|
RefPtr<PresShell> presShell = doc->GetPresShell();
|
|
|
|
if (presShell) {
|
|
|
|
presShell->SetIsFirstPaint(true);
|
2015-04-14 23:44:59 +03:00
|
|
|
}
|
2012-09-29 06:18:18 +04:00
|
|
|
|
2019-03-29 18:12:47 +03:00
|
|
|
APZCCallbackHelper::InitializeRootDisplayport(presShell);
|
2012-09-29 06:18:18 +04:00
|
|
|
}
|
|
|
|
}
|
2012-08-09 00:37:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-07 01:14:40 +03:00
|
|
|
void BrowserChild::ContentReceivedInputBlock(uint64_t aInputBlockId,
|
2019-04-10 01:39:01 +03:00
|
|
|
bool aPreventDefault) const {
|
2016-07-31 22:39:00 +03:00
|
|
|
if (mApzcTreeManager) {
|
|
|
|
mApzcTreeManager->ContentReceivedInputBlock(aInputBlockId, aPreventDefault);
|
2016-01-08 22:17:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::SetTargetAPZC(
|
2016-01-08 22:17:39 +03:00
|
|
|
uint64_t aInputBlockId,
|
2020-03-27 20:44:21 +03:00
|
|
|
const nsTArray<ScrollableLayerGuid>& aTargets) const {
|
2016-07-31 22:39:00 +03:00
|
|
|
if (mApzcTreeManager) {
|
|
|
|
mApzcTreeManager->SetTargetAPZC(aInputBlockId, aTargets);
|
2016-01-08 22:17:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::SetAllowedTouchBehavior(
|
2016-01-08 22:17:39 +03:00
|
|
|
uint64_t aInputBlockId,
|
|
|
|
const nsTArray<TouchBehaviorFlags>& aTargets) const {
|
2016-07-31 22:39:00 +03:00
|
|
|
if (mApzcTreeManager) {
|
|
|
|
mApzcTreeManager->SetAllowedTouchBehavior(aInputBlockId, aTargets);
|
2016-01-08 22:17:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
bool BrowserChild::DoUpdateZoomConstraints(
|
2014-03-25 06:28:46 +04:00
|
|
|
const uint32_t& aPresShellId, const ViewID& aViewId,
|
2015-06-17 19:32:41 +03:00
|
|
|
const Maybe<ZoomConstraints>& aConstraints) {
|
2018-07-30 17:00:34 +03:00
|
|
|
if (!mApzcTreeManager || mDestroyed) {
|
2016-01-08 22:17:39 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-03-27 20:44:21 +03:00
|
|
|
ScrollableLayerGuid guid =
|
|
|
|
ScrollableLayerGuid(mLayersId, aPresShellId, aViewId);
|
2016-07-31 22:39:00 +03:00
|
|
|
|
|
|
|
mApzcTreeManager->UpdateZoomConstraints(guid, aConstraints);
|
|
|
|
return true;
|
2012-09-29 06:18:18 +04:00
|
|
|
}
|
|
|
|
|
2019-08-08 19:07:05 +03:00
|
|
|
nsresult BrowserChild::Init(mozIDOMWindowProxy* aParent,
|
|
|
|
WindowGlobalChild* aInitialWindowChild) {
|
|
|
|
MOZ_ASSERT_IF(aInitialWindowChild,
|
|
|
|
aInitialWindowChild->BrowsingContext() == mBrowsingContext);
|
2017-04-07 02:46:18 +03:00
|
|
|
|
2015-06-17 11:44:50 +03:00
|
|
|
nsCOMPtr<nsIWidget> widget = nsIWidget::CreatePuppetWidget(this);
|
|
|
|
mPuppetWidget = static_cast<PuppetWidget*>(widget.get());
|
|
|
|
if (!mPuppetWidget) {
|
2012-08-29 19:26:18 +04:00
|
|
|
NS_ERROR("couldn't create fake widget");
|
2012-09-07 17:23:23 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
2012-08-29 19:26:18 +04:00
|
|
|
}
|
2018-11-27 12:59:44 +03:00
|
|
|
mPuppetWidget->InfallibleCreate(nullptr,
|
|
|
|
nullptr, // no parents
|
|
|
|
LayoutDeviceIntRect(0, 0, 0, 0),
|
2019-08-08 19:07:05 +03:00
|
|
|
nullptr); // HandleWidgetEvent
|
2012-08-29 19:26:18 +04:00
|
|
|
|
2020-05-08 01:18:54 +03:00
|
|
|
mWebBrowser = nsWebBrowser::Create(this, mPuppetWidget, mBrowsingContext,
|
|
|
|
aInitialWindowChild);
|
2018-11-27 12:59:44 +03:00
|
|
|
nsIWebBrowser* webBrowser = mWebBrowser;
|
|
|
|
|
|
|
|
mWebNav = do_QueryInterface(webBrowser);
|
|
|
|
NS_ASSERTION(mWebNav, "nsWebBrowser doesn't implement nsIWebNavigation?");
|
2012-08-29 19:26:18 +04:00
|
|
|
|
2016-06-03 00:02:29 +03:00
|
|
|
// Set the tab context attributes then pass to docShell
|
2020-04-08 00:38:54 +03:00
|
|
|
NotifyTabContextUpdated();
|
2012-08-29 19:26:18 +04:00
|
|
|
|
|
|
|
// IPC uses a WebBrowser object for which DNS prefetching is turned off
|
|
|
|
// by default. But here we really want it, so enable it explicitly
|
2018-08-03 22:21:03 +03:00
|
|
|
mWebBrowser->SetAllowDNSPrefetch(true);
|
2012-08-09 00:37:57 +04:00
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
|
2012-09-29 06:18:18 +04:00
|
|
|
MOZ_ASSERT(docShell);
|
2013-05-07 08:10:31 +04:00
|
|
|
|
2019-04-03 20:29:15 +03:00
|
|
|
mStatusFilter = new nsBrowserStatusFilter();
|
|
|
|
|
2019-08-28 21:55:45 +03:00
|
|
|
nsresult rv =
|
|
|
|
mStatusFilter->AddProgressListener(this, nsIWebProgress::NOTIFY_ALL);
|
2019-01-25 17:44:09 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2019-04-03 20:29:15 +03:00
|
|
|
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWebProgress> webProgress = do_QueryInterface(docShell);
|
2019-08-28 21:55:45 +03:00
|
|
|
rv = webProgress->AddProgressListener(mStatusFilter,
|
|
|
|
nsIWebProgress::NOTIFY_ALL);
|
2019-04-03 20:29:15 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
2019-01-25 17:44:09 +03:00
|
|
|
|
2013-05-07 08:10:31 +04:00
|
|
|
docShell->SetAffectPrivateSessionLifetime(
|
2020-04-23 11:58:06 +03:00
|
|
|
mBrowsingContext->UsePrivateBrowsing() ||
|
2013-05-07 08:10:31 +04:00
|
|
|
mChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME);
|
2020-04-08 00:39:16 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(WebNavigation());
|
2013-05-07 08:10:31 +04:00
|
|
|
MOZ_ASSERT(loadContext);
|
2020-04-08 00:39:16 +03:00
|
|
|
MOZ_ASSERT(loadContext->UseRemoteTabs() ==
|
|
|
|
!!(mChromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW));
|
|
|
|
MOZ_ASSERT(loadContext->UseRemoteSubframes() ==
|
|
|
|
!!(mChromeFlags & nsIWebBrowserChrome::CHROME_FISSION_WINDOW));
|
|
|
|
#endif // defined(DEBUG)
|
2013-05-07 08:10:31 +04:00
|
|
|
|
2014-04-09 09:15:00 +04:00
|
|
|
// Few lines before, baseWindow->Create() will end up creating a new
|
|
|
|
// window root in nsGlobalWindow::SetDocShell.
|
|
|
|
// Then this chrome event handler, will be inherited to inner windows.
|
|
|
|
// We want to also set it to the docshell so that inner windows
|
|
|
|
// and any code that has access to the docshell
|
|
|
|
// can all listen to the same chrome event handler.
|
|
|
|
// XXX: ideally, we would set a chrome event handler earlier,
|
|
|
|
// and all windows, even the root one, will use the docshell one.
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(WebNavigation());
|
2014-04-09 09:15:00 +04:00
|
|
|
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
2018-08-13 12:05:19 +03:00
|
|
|
nsCOMPtr<EventTarget> chromeHandler = window->GetChromeEventHandler();
|
2014-04-09 09:15:00 +04:00
|
|
|
docShell->SetChromeEventHandler(chromeHandler);
|
|
|
|
|
2016-07-29 05:28:50 +03:00
|
|
|
if (window->GetCurrentInnerWindow()) {
|
2019-06-03 18:29:06 +03:00
|
|
|
window->SetKeyboardIndicators(ShowFocusRings());
|
2016-07-29 05:28:50 +03:00
|
|
|
} else {
|
|
|
|
// Skip ShouldShowFocusRing check if no inner window is available
|
2019-06-03 18:29:06 +03:00
|
|
|
window->SetInitialKeyboardIndicators(ShowFocusRings());
|
2016-07-29 05:28:50 +03:00
|
|
|
}
|
2016-06-09 14:59:31 +03:00
|
|
|
|
2019-10-15 17:32:18 +03:00
|
|
|
// Window scrollbar flags only affect top level remote frames, not fission
|
|
|
|
// frames.
|
|
|
|
if (mIsTopLevel) {
|
|
|
|
nsContentUtils::SetScrollbarsVisibility(
|
2020-08-11 19:42:46 +03:00
|
|
|
docShell, !!(mChromeFlags & nsIWebBrowserChrome::CHROME_SCROLLBARS));
|
2019-10-15 17:32:18 +03:00
|
|
|
}
|
2016-03-12 02:10:13 +03:00
|
|
|
|
2015-09-11 19:52:43 +03:00
|
|
|
nsWeakPtr weakPtrThis = do_GetWeakReference(
|
2019-04-10 02:15:02 +03:00
|
|
|
static_cast<nsIBrowserChild*>(this)); // for capture by the lambda
|
2015-09-11 19:52:43 +03:00
|
|
|
ContentReceivedInputBlockCallback callback(
|
2019-05-07 01:14:40 +03:00
|
|
|
[weakPtrThis](uint64_t aInputBlockId, bool aPreventDefault) {
|
2019-04-10 01:39:01 +03:00
|
|
|
if (nsCOMPtr<nsIBrowserChild> browserChild =
|
2019-04-10 02:15:02 +03:00
|
|
|
do_QueryReferent(weakPtrThis)) {
|
2019-04-10 01:39:01 +03:00
|
|
|
static_cast<BrowserChild*>(browserChild.get())
|
2019-05-07 01:14:40 +03:00
|
|
|
->ContentReceivedInputBlock(aInputBlockId, aPreventDefault);
|
2015-09-11 19:52:43 +03:00
|
|
|
}
|
|
|
|
});
|
2018-05-30 22:15:35 +03:00
|
|
|
mAPZEventState = new APZEventState(mPuppetWidget, std::move(callback));
|
2015-02-09 22:05:18 +03:00
|
|
|
|
2018-11-28 03:57:32 +03:00
|
|
|
mIPCOpen = true;
|
|
|
|
|
Bug 1581855:Part 2 - Present VR output to VR Host r=kip,jrmuizel,sotaro,bryce
This change is a continuation of Part 1 (Bug 1570128), where the 2D content rendered by Firefox for Firefox Reality on Desktop is marshalled through VRHost so that it can be presented in a VR environment.
A new class, FxrOutputHandler, is created to manage creating a sharable texture, sharing it through VRShMem, and updating it when content updates. This class updates content with both WebRender and conventional rendering output.
This initial iteration of FxrOutputHandler does not have synchronization between reading and writing this shared texture across processes. A subsequent fix (Bug 1581881) is pending, which will reuse WebVR code to manage writing to and reading from a pool of textures.
This also presents issues with rendering protected media, so an additional class, FxrWindowManager, is created to manage all windows created for Firefox Reality on Desktop so that it can inform whether or not protected media can be presented.
The automated manual tests in vrhosttest.cpp now show the real shared texture handle rather than a fake value, which shows that marshaling succeeded.
Differential Revision: https://phabricator.services.mozilla.com/D46179
--HG--
extra : moz-landing-system : lando
2019-09-26 15:50:44 +03:00
|
|
|
#if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_THUNDERBIRD) && \
|
|
|
|
!defined(MOZ_SUITE)
|
2019-05-04 13:42:52 +03:00
|
|
|
mSessionStoreListener = new TabListener(docShell, nullptr);
|
|
|
|
rv = mSessionStoreListener->Init();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2019-07-24 11:05:55 +03:00
|
|
|
#endif
|
2020-08-11 19:42:46 +03:00
|
|
|
|
|
|
|
// We've all set up, make sure our visibility state is consistent. This is
|
|
|
|
// important for OOP iframes, which start off as hidden.
|
|
|
|
UpdateVisibility();
|
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-08 00:38:54 +03:00
|
|
|
void BrowserChild::NotifyTabContextUpdated() {
|
2016-02-16 10:04:14 +03:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
|
|
|
|
MOZ_ASSERT(docShell);
|
2016-01-20 02:28:00 +03:00
|
|
|
|
2016-02-16 10:04:14 +03:00
|
|
|
if (!docShell) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-21 21:31:00 +03:00
|
|
|
// Set SANDBOXED_AUXILIARY_NAVIGATION flag if this is a receiver page.
|
|
|
|
if (!PresentationURL().IsEmpty()) {
|
2020-07-31 16:37:00 +03:00
|
|
|
// Return value of setting synced field should be checked. See bug 1656492.
|
|
|
|
Unused << mBrowsingContext->SetSandboxFlags(SANDBOXED_AUXILIARY_NAVIGATION);
|
2016-06-21 21:31:00 +03:00
|
|
|
}
|
2012-08-29 19:26:18 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(BrowserChild)
|
2017-10-02 17:58:52 +03:00
|
|
|
|
2019-06-03 23:04:46 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(BrowserChild)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mBrowserChildMessageManager)
|
|
|
|
tmp->nsMessageManagerScriptExecutor::Unlink();
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mWebBrowserChrome)
|
2019-04-03 20:29:15 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mStatusFilter)
|
2017-10-02 17:58:52 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mWebNav)
|
2019-03-14 21:51:13 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mBrowsingContext)
|
2020-02-25 22:44:39 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_WEAK_REFERENCE
|
2017-10-02 17:58:52 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2019-06-03 23:04:46 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(BrowserChild)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBrowserChildMessageManager)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWebBrowserChrome)
|
2019-04-03 20:29:15 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStatusFilter)
|
2017-10-02 17:58:52 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWebNav)
|
2019-03-14 21:51:13 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBrowsingContext)
|
2017-10-02 17:58:52 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2019-06-03 23:04:46 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(BrowserChild)
|
|
|
|
tmp->nsMessageManagerScriptExecutor::Trace(aCallbacks, aClosure);
|
2017-10-02 17:58:52 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BrowserChild)
|
2010-05-17 15:25:22 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWindowProvider)
|
2019-04-10 02:15:02 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIBrowserChild)
|
2012-09-29 06:18:18 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
2014-03-28 12:40:13 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
2014-01-23 00:27:23 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsITooltipListener)
|
2019-01-25 17:44:09 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
2019-08-28 21:56:02 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener2)
|
2019-06-03 23:04:46 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIBrowserChild)
|
|
|
|
NS_INTERFACE_MAP_END
|
2010-05-17 15:25:22 +04:00
|
|
|
|
2019-06-03 23:04:46 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(BrowserChild)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(BrowserChild)
|
2009-11-05 21:14:22 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::GetChromeFlags(uint32_t* aChromeFlags) {
|
2010-07-19 22:33:33 +04:00
|
|
|
*aChromeFlags = mChromeFlags;
|
|
|
|
return NS_OK;
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::SetChromeFlags(uint32_t aChromeFlags) {
|
2016-01-08 23:40:26 +03:00
|
|
|
NS_WARNING("trying to SetChromeFlags from content process?");
|
2010-11-03 16:00:49 +03:00
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::RemoteSizeShellTo(int32_t aWidth, int32_t aHeight,
|
|
|
|
int32_t aShellItemWidth,
|
|
|
|
int32_t aShellItemHeight) {
|
2016-05-11 12:44:57 +03:00
|
|
|
nsCOMPtr<nsIDocShell> ourDocShell = do_GetInterface(WebNavigation());
|
|
|
|
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(ourDocShell));
|
2017-11-28 18:56:51 +03:00
|
|
|
NS_ENSURE_STATE(docShellAsWin);
|
|
|
|
|
2016-05-11 12:44:57 +03:00
|
|
|
int32_t width, height;
|
|
|
|
docShellAsWin->GetSize(&width, &height);
|
|
|
|
|
|
|
|
uint32_t flags = 0;
|
|
|
|
if (width == aWidth) {
|
|
|
|
flags |= nsIEmbeddingSiteWindow::DIM_FLAGS_IGNORE_CX;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (height == aHeight) {
|
|
|
|
flags |= nsIEmbeddingSiteWindow::DIM_FLAGS_IGNORE_CY;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool sent = SendSizeShellTo(flags, aWidth, aHeight, aShellItemWidth,
|
|
|
|
aShellItemHeight);
|
|
|
|
|
|
|
|
return sent ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2015-11-11 01:35:12 +03:00
|
|
|
NS_IMETHODIMP
|
2019-05-15 23:58:08 +03:00
|
|
|
BrowserChild::RemoteDropLinks(
|
|
|
|
const nsTArray<RefPtr<nsIDroppedLinkItem>>& aLinks) {
|
2015-11-11 01:35:12 +03:00
|
|
|
nsTArray<nsString> linksArray;
|
|
|
|
nsresult rv = NS_OK;
|
2019-05-15 23:58:08 +03:00
|
|
|
for (nsIDroppedLinkItem* link : aLinks) {
|
2015-11-11 01:35:12 +03:00
|
|
|
nsString tmp;
|
2019-05-15 23:58:08 +03:00
|
|
|
rv = link->GetUrl(tmp);
|
2015-11-11 01:35:12 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
linksArray.AppendElement(tmp);
|
|
|
|
|
2019-05-15 23:58:08 +03:00
|
|
|
rv = link->GetName(tmp);
|
2015-11-11 01:35:12 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
linksArray.AppendElement(tmp);
|
|
|
|
|
2019-05-15 23:58:08 +03:00
|
|
|
rv = link->GetType(tmp);
|
2015-11-11 01:35:12 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
linksArray.AppendElement(tmp);
|
|
|
|
}
|
2017-06-07 15:25:46 +03:00
|
|
|
bool sent = SendDropLinks(linksArray);
|
2015-11-11 01:35:12 +03:00
|
|
|
|
|
|
|
return sent ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::ShowAsModal() {
|
|
|
|
NS_WARNING("BrowserChild::ShowAsModal not supported in BrowserChild");
|
2010-11-03 16:00:49 +03:00
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::IsWindowModal(bool* aRetVal) {
|
2011-10-17 18:59:28 +04:00
|
|
|
*aRetVal = false;
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-12-05 13:36:12 +03:00
|
|
|
BrowserChild::SetLinkStatus(const nsAString& aStatusText) {
|
2018-11-05 21:45:06 +03:00
|
|
|
// We can only send the status after the ipc machinery is set up
|
|
|
|
if (IPCOpen()) {
|
2019-12-05 13:36:12 +03:00
|
|
|
SendSetLinkStatus(nsString(aStatusText));
|
2018-11-05 21:45:06 +03:00
|
|
|
}
|
2011-07-07 19:11:58 +04:00
|
|
|
return NS_OK;
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::SetDimensions(uint32_t aFlags, int32_t aX, int32_t aY,
|
|
|
|
int32_t aCx, int32_t aCy) {
|
2016-05-11 12:44:57 +03:00
|
|
|
// The parent is in charge of the dimension changes. If JS code wants to
|
|
|
|
// change the dimensions (moveTo, screenX, etc.) we send a message to the
|
|
|
|
// parent about the new requested dimension, the parent does the resize/move
|
|
|
|
// then send a message to the child to update itself. For APIs like screenX
|
|
|
|
// this function is called with the current value for the non-changed values.
|
|
|
|
// In a series of calls like window.screenX = 10; window.screenY = 10; for
|
|
|
|
// the second call, since screenX is not yet updated we might accidentally
|
|
|
|
// reset back screenX to it's old value. To avoid this if a parameter did not
|
|
|
|
// change we want the parent to ignore its value.
|
|
|
|
int32_t x, y, cx, cy;
|
|
|
|
GetDimensions(aFlags, &x, &y, &cx, &cy);
|
|
|
|
|
|
|
|
if (x == aX) {
|
|
|
|
aFlags |= nsIEmbeddingSiteWindow::DIM_FLAGS_IGNORE_X;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (y == aY) {
|
|
|
|
aFlags |= nsIEmbeddingSiteWindow::DIM_FLAGS_IGNORE_Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cx == aCx) {
|
|
|
|
aFlags |= nsIEmbeddingSiteWindow::DIM_FLAGS_IGNORE_CX;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cy == aCy) {
|
|
|
|
aFlags |= nsIEmbeddingSiteWindow::DIM_FLAGS_IGNORE_CY;
|
|
|
|
}
|
|
|
|
|
2019-12-10 11:23:06 +03:00
|
|
|
double scale = mPuppetWidget ? mPuppetWidget->GetDefaultScale().scale : 1.0;
|
|
|
|
|
|
|
|
Unused << SendSetDimensions(aFlags, aX, aY, aCx, aCy, scale);
|
2010-11-03 16:00:49 +03:00
|
|
|
|
2015-01-13 03:41:53 +03:00
|
|
|
return NS_OK;
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::GetDimensions(uint32_t aFlags, int32_t* aX, int32_t* aY,
|
|
|
|
int32_t* aCx, int32_t* aCy) {
|
2015-06-08 08:39:28 +03:00
|
|
|
ScreenIntRect rect = GetOuterRect();
|
2011-07-16 01:46:56 +04:00
|
|
|
if (aX) {
|
2018-02-19 23:15:23 +03:00
|
|
|
*aX = rect.x;
|
2011-07-16 01:46:56 +04:00
|
|
|
}
|
|
|
|
if (aY) {
|
2018-02-19 23:15:23 +03:00
|
|
|
*aY = rect.y;
|
2011-07-16 01:46:56 +04:00
|
|
|
}
|
|
|
|
if (aCx) {
|
2018-02-19 23:15:23 +03:00
|
|
|
*aCx = rect.width;
|
2011-07-16 01:46:56 +04:00
|
|
|
}
|
|
|
|
if (aCy) {
|
2018-02-19 23:15:23 +03:00
|
|
|
*aCy = rect.height;
|
2011-07-16 01:46:56 +04:00
|
|
|
}
|
2010-11-03 16:00:49 +03:00
|
|
|
|
2011-07-16 01:46:56 +04:00
|
|
|
return NS_OK;
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::SetFocus() { return NS_ERROR_NOT_IMPLEMENTED; }
|
2009-11-05 21:14:22 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::GetVisibility(bool* aVisibility) {
|
2011-10-17 18:59:28 +04:00
|
|
|
*aVisibility = true;
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::SetVisibility(bool aVisibility) {
|
2011-06-23 00:43:05 +04:00
|
|
|
// should the platform support this? Bug 666365
|
|
|
|
return NS_OK;
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::GetTitle(nsAString& aTitle) {
|
|
|
|
NS_WARNING("BrowserChild::GetTitle not supported in BrowserChild");
|
2010-11-03 16:00:49 +03:00
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::SetTitle(const nsAString& aTitle) {
|
2013-08-06 20:35:39 +04:00
|
|
|
// JavaScript sends the "DOMTitleChanged" event to the parent
|
|
|
|
// via the message manager.
|
2011-01-04 19:40:54 +03:00
|
|
|
return NS_OK;
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::GetSiteWindow(void** aSiteWindow) {
|
|
|
|
NS_WARNING("BrowserChild::GetSiteWindow not supported in BrowserChild");
|
2010-11-03 16:00:49 +03:00
|
|
|
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::Blur() { return NS_ERROR_NOT_IMPLEMENTED; }
|
2009-11-05 21:14:22 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::FocusNextElement(bool aForDocumentNavigation) {
|
2015-07-13 13:07:49 +03:00
|
|
|
SendMoveFocus(true, aForDocumentNavigation);
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::FocusPrevElement(bool aForDocumentNavigation) {
|
2015-07-13 13:07:49 +03:00
|
|
|
SendMoveFocus(false, aForDocumentNavigation);
|
2009-11-05 21:14:22 +03:00
|
|
|
return NS_OK;
|
2009-10-28 23:41:46 +03:00
|
|
|
}
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2010-01-01 04:34:06 +03:00
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::GetInterface(const nsIID& aIID, void** aSink) {
|
2014-09-03 01:43:08 +04:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIWebBrowserChrome3))) {
|
2019-09-20 21:15:18 +03:00
|
|
|
return GetWebBrowserChrome(reinterpret_cast<nsIWebBrowserChrome3**>(aSink));
|
2014-09-03 01:43:08 +04:00
|
|
|
}
|
|
|
|
|
2010-01-01 04:34:06 +03:00
|
|
|
// XXXbz should we restrict the set of interfaces we hand out here?
|
|
|
|
// See bug 537429
|
|
|
|
return QueryInterface(aIID, aSink);
|
|
|
|
}
|
|
|
|
|
2010-01-01 04:35:55 +03:00
|
|
|
NS_IMETHODIMP
|
2020-04-08 00:39:32 +03:00
|
|
|
BrowserChild::ProvideWindow(nsIOpenWindowInfo* aOpenWindowInfo,
|
|
|
|
uint32_t aChromeFlags, bool aCalledFromJS,
|
|
|
|
bool aWidthSpecified, nsIURI* aURI,
|
|
|
|
const nsAString& aName, const nsACString& aFeatures,
|
|
|
|
bool aForceNoOpener, bool aForceNoReferrer,
|
2019-04-10 01:39:01 +03:00
|
|
|
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
|
2019-08-02 23:48:33 +03:00
|
|
|
BrowsingContext** aReturn) {
|
2012-07-30 18:20:58 +04:00
|
|
|
*aReturn = nullptr;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-04-08 00:39:32 +03:00
|
|
|
RefPtr<BrowsingContext> parent = aOpenWindowInfo->GetParent();
|
|
|
|
|
2020-04-08 00:39:52 +03:00
|
|
|
int32_t openLocation = nsWindowWatcher::GetWindowOpenLocation(
|
Bug 1636728 - Centralize printing entry points in nsGlobalWindowOuter, and move cloning out of nsPrintJob. r=jwatt,geckoview-reviewers,smaug,agi
This centralizes our print and preview setup in nsGlobalWindowOuter so
that we never re-clone a clone, and so that we reuse the window.open()
codepath to create the browsing context to clone into.
For window.print, for both old print dialog / silent printing and new
print preview UI, we now create a hidden browser (as in with visibility:
collapse, which takes no space but still gets a layout box).
* In the modern UI case, this browser is swapped with the actual print
preview clone, and the UI takes care of removing the browser.
* In the print dialog / silent printing case, the printing code calls
window.close() from nsDocumentViewer::OnDonePrinting().
* We don't need to care about the old print preview UI for this case
because it can't be open from window.print().
We need to fall back to an actual window when there's no
nsIBrowserDOMWindow around for WPT print tests and the like, which don't
have one. That seems fine, we could special-case this code path more if
needed but it doesn't seem worth it.
Differential Revision: https://phabricator.services.mozilla.com/D87063
2020-08-25 20:45:12 +03:00
|
|
|
parent->GetDOMWindow(), aChromeFlags, aCalledFromJS, aWidthSpecified,
|
|
|
|
aOpenWindowInfo->GetIsForPrinting());
|
2020-04-08 00:39:52 +03:00
|
|
|
|
|
|
|
// If it turns out we're opening in the current browser, just hand over the
|
|
|
|
// current browser's docshell.
|
|
|
|
if (openLocation == nsIBrowserDOMWindow::OPEN_CURRENTWINDOW) {
|
|
|
|
nsCOMPtr<nsIWebBrowser> browser = do_GetInterface(WebNavigation());
|
|
|
|
*aWindowIsNew = false;
|
|
|
|
|
|
|
|
nsCOMPtr<mozIDOMWindowProxy> win;
|
|
|
|
MOZ_TRY(browser->GetContentDOMWindow(getter_AddRefs(win)));
|
|
|
|
|
|
|
|
RefPtr<BrowsingContext> bc(
|
|
|
|
nsPIDOMWindowOuter::From(win)->GetBrowsingContext());
|
|
|
|
bc.forget(aReturn);
|
|
|
|
return NS_OK;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2015-01-16 21:07:50 +03:00
|
|
|
// Note that ProvideWindowCommon may return NS_ERROR_ABORT if the
|
|
|
|
// open window call was canceled. It's important that we pass this error
|
|
|
|
// code back to our caller.
|
2015-10-30 02:30:57 +03:00
|
|
|
ContentChild* cc = ContentChild::GetSingleton();
|
2020-04-08 00:39:52 +03:00
|
|
|
return cc->ProvideWindowCommon(this, aOpenWindowInfo, aChromeFlags,
|
2020-03-19 12:13:12 +03:00
|
|
|
aCalledFromJS, aWidthSpecified, aURI, aName,
|
|
|
|
aFeatures, aForceNoOpener, aForceNoReferrer,
|
|
|
|
aLoadState, aWindowIsNew, aReturn);
|
2012-06-13 02:01:25 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::DestroyWindow() {
|
2019-08-03 04:19:53 +03:00
|
|
|
mBrowsingContext = nullptr;
|
|
|
|
|
2019-04-03 20:29:15 +03:00
|
|
|
if (mStatusFilter) {
|
|
|
|
if (nsCOMPtr<nsIWebProgress> webProgress =
|
|
|
|
do_QueryInterface(WebNavigation())) {
|
|
|
|
webProgress->RemoveProgressListener(mStatusFilter);
|
|
|
|
}
|
|
|
|
|
|
|
|
mStatusFilter->RemoveProgressListener(this);
|
|
|
|
mStatusFilter = nullptr;
|
|
|
|
}
|
|
|
|
|
2017-08-11 09:58:08 +03:00
|
|
|
if (mCoalescedMouseEventFlusher) {
|
|
|
|
mCoalescedMouseEventFlusher->RemoveObserver();
|
|
|
|
mCoalescedMouseEventFlusher = nullptr;
|
|
|
|
}
|
2017-10-12 04:05:40 +03:00
|
|
|
|
2019-05-04 13:42:52 +03:00
|
|
|
if (mSessionStoreListener) {
|
|
|
|
mSessionStoreListener->RemoveListeners();
|
|
|
|
mSessionStoreListener = nullptr;
|
|
|
|
}
|
|
|
|
|
2017-10-12 04:05:40 +03:00
|
|
|
// In case we don't have chance to process all entries, clean all data in
|
|
|
|
// the queue.
|
|
|
|
while (mToBeDispatchedMouseData.GetSize() > 0) {
|
|
|
|
UniquePtr<CoalescedMouseData> data(
|
|
|
|
static_cast<CoalescedMouseData*>(mToBeDispatchedMouseData.PopFront()));
|
|
|
|
data.reset();
|
|
|
|
}
|
|
|
|
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(WebNavigation());
|
2009-10-28 23:41:46 +03:00
|
|
|
if (baseWindow) baseWindow->Destroy();
|
2009-07-07 20:26:49 +04:00
|
|
|
|
2015-06-17 11:44:50 +03:00
|
|
|
if (mPuppetWidget) {
|
|
|
|
mPuppetWidget->Destroy();
|
2010-03-01 22:05:48 +03:00
|
|
|
}
|
2009-07-07 20:26:49 +04:00
|
|
|
|
2018-11-05 23:52:47 +03:00
|
|
|
mLayersConnected = Nothing();
|
2014-03-07 07:24:32 +04:00
|
|
|
|
2018-03-25 02:06:01 +03:00
|
|
|
if (mLayersId.IsValid()) {
|
2019-04-10 01:39:01 +03:00
|
|
|
StaticMutexAutoLock lock(sBrowserChildrenMutex);
|
2017-04-10 23:42:36 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
MOZ_ASSERT(sBrowserChildren);
|
|
|
|
sBrowserChildren->Remove(uint64_t(mLayersId));
|
|
|
|
if (!sBrowserChildren->Count()) {
|
|
|
|
delete sBrowserChildren;
|
|
|
|
sBrowserChildren = nullptr;
|
2014-03-07 07:24:32 +04:00
|
|
|
}
|
2018-03-25 02:06:01 +03:00
|
|
|
mLayersId = layers::LayersId{0};
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
2009-07-14 11:33:50 +04:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::ActorDestroy(ActorDestroyReason why) {
|
2018-11-28 03:57:32 +03:00
|
|
|
mIPCOpen = false;
|
|
|
|
|
2014-09-26 00:01:33 +04:00
|
|
|
DestroyWindow();
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
if (mBrowserChildMessageManager) {
|
2017-01-18 03:28:39 +03:00
|
|
|
// We should have a message manager if the global is alive, but it
|
|
|
|
// seems sometimes we don't. Assert in aurora/nightly, but don't
|
|
|
|
// crash in release builds.
|
2019-04-10 01:39:01 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mBrowserChildMessageManager->GetMessageManager());
|
|
|
|
if (mBrowserChildMessageManager->GetMessageManager()) {
|
|
|
|
// The messageManager relays messages via the BrowserChild which
|
2017-01-18 03:28:39 +03:00
|
|
|
// no longer exists.
|
2019-04-10 01:39:01 +03:00
|
|
|
mBrowserChildMessageManager->DisconnectMessageManager();
|
2017-01-18 03:28:39 +03:00
|
|
|
}
|
2011-08-09 23:38:26 +04:00
|
|
|
}
|
2014-08-22 03:37:00 +04:00
|
|
|
|
2018-02-15 02:07:53 +03:00
|
|
|
CompositorBridgeChild* compositorChild = CompositorBridgeChild::Get();
|
|
|
|
if (compositorChild) {
|
|
|
|
compositorChild->CancelNotifyAfterRemotePaint(this);
|
|
|
|
}
|
2014-09-04 16:20:45 +04:00
|
|
|
|
2014-10-29 21:11:00 +03:00
|
|
|
if (GetTabId() != 0) {
|
2019-04-10 01:39:01 +03:00
|
|
|
NestedBrowserChildMap().erase(GetTabId());
|
2014-06-11 09:44:36 +04:00
|
|
|
}
|
2010-07-22 03:23:03 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::~BrowserChild() {
|
2019-06-03 23:04:46 +03:00
|
|
|
mAnonymousGlobalScopes.Clear();
|
2017-07-20 02:10:48 +03:00
|
|
|
|
2016-10-14 10:31:02 +03:00
|
|
|
DestroyWindow();
|
2012-08-29 19:26:18 +04:00
|
|
|
|
2016-10-14 10:31:02 +03:00
|
|
|
nsCOMPtr<nsIWebBrowser> webBrowser = do_QueryInterface(WebNavigation());
|
|
|
|
if (webBrowser) {
|
|
|
|
webBrowser->SetContainerWindow(nullptr);
|
|
|
|
}
|
|
|
|
|
2017-10-02 17:58:52 +03:00
|
|
|
mozilla::DropJSObjects(this);
|
2009-07-01 00:39:22 +04:00
|
|
|
}
|
|
|
|
|
2020-02-06 22:07:56 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvWillChangeProcess(
|
|
|
|
WillChangeProcessResolver&& aResolve) {
|
2020-03-23 16:28:09 +03:00
|
|
|
if (mWebBrowser) {
|
|
|
|
mWebBrowser->SetWillChangeProcess();
|
2019-04-04 01:40:28 +03:00
|
|
|
}
|
2019-09-09 14:50:35 +03:00
|
|
|
aResolve(true);
|
2019-04-04 01:40:28 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2020-05-19 23:22:34 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvLoadURL(
|
2020-08-28 20:20:30 +03:00
|
|
|
nsDocShellLoadState* aLoadState, const ParentShowInfo& aInfo) {
|
2016-03-12 01:31:55 +03:00
|
|
|
if (!mDidLoadURLInit) {
|
|
|
|
mDidLoadURLInit = true;
|
2019-04-10 01:39:01 +03:00
|
|
|
if (!InitBrowserChildMessageManager()) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2015-04-07 05:56:10 +03:00
|
|
|
}
|
|
|
|
|
2020-01-05 23:58:21 +03:00
|
|
|
ApplyParentShowInfo(aInfo);
|
2016-03-12 01:31:55 +03:00
|
|
|
}
|
2020-08-28 20:20:30 +03:00
|
|
|
nsAutoCString spec;
|
|
|
|
aLoadState->URI()->GetSpec(spec);
|
2015-12-04 02:04:28 +03:00
|
|
|
|
2019-04-17 18:01:53 +03:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
|
2020-08-28 20:20:30 +03:00
|
|
|
MOZ_ASSERT(docShell);
|
|
|
|
if (!docShell) {
|
|
|
|
NS_WARNING("WebNavigation does not have a docshell");
|
2020-10-23 18:53:57 +03:00
|
|
|
return IPC_OK();
|
2019-04-17 18:01:53 +03:00
|
|
|
}
|
2020-08-28 20:20:30 +03:00
|
|
|
docShell->LoadURI(aLoadState, true);
|
2019-04-17 18:01:53 +03:00
|
|
|
|
2020-08-28 20:20:30 +03:00
|
|
|
nsDocShell::Cast(docShell)->MaybeClearStorageAccessFlag();
|
2015-12-04 02:04:28 +03:00
|
|
|
|
2020-08-28 20:20:30 +03:00
|
|
|
CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::URL, spec);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-12-04 02:04:28 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvResumeLoad(
|
2020-01-05 23:58:21 +03:00
|
|
|
const uint64_t& aPendingSwitchID, const ParentShowInfo& aInfo) {
|
2019-04-17 03:53:28 +03:00
|
|
|
if (!mDidLoadURLInit) {
|
|
|
|
mDidLoadURLInit = true;
|
2019-04-10 01:39:01 +03:00
|
|
|
if (!InitBrowserChildMessageManager()) {
|
2019-04-17 03:53:28 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
|
2020-01-05 23:58:21 +03:00
|
|
|
ApplyParentShowInfo(aInfo);
|
2019-04-17 03:53:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = WebNavigation()->ResumeRedirectedLoad(aPendingSwitchID, -1);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("WebNavigation()->ResumeRedirectedLoad failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2020-09-22 12:57:27 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvCloneDocumentTreeIntoSelf(
|
|
|
|
const MaybeDiscarded<BrowsingContext>& aSourceBC) {
|
|
|
|
if (NS_WARN_IF(aSourceBC.IsNullOrDiscarded())) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
nsCOMPtr<Document> sourceDocument = aSourceBC.get()->GetDocument();
|
|
|
|
if (NS_WARN_IF(!sourceDocument)) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> ourDocShell = do_GetInterface(WebNavigation());
|
|
|
|
if (NS_WARN_IF(!ourDocShell)) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContentViewer> cv;
|
|
|
|
ourDocShell->GetContentViewer(getter_AddRefs(cv));
|
|
|
|
if (NS_WARN_IF(!cv)) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<Document> clone;
|
|
|
|
{
|
|
|
|
AutoPrintEventDispatcher dispatcher(*sourceDocument);
|
|
|
|
nsAutoScriptBlocker scriptBlocker;
|
|
|
|
bool hasInProcessCallbacks = false;
|
|
|
|
clone = sourceDocument->CreateStaticClone(ourDocShell, cv,
|
|
|
|
&hasInProcessCallbacks);
|
|
|
|
if (NS_WARN_IF(!clone)) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Since the clone document is not parsed-created, we need to initialize
|
|
|
|
// layout manually. This is usually done in ReflowPrintObject for non-remote
|
|
|
|
// documents.
|
|
|
|
if (RefPtr<PresShell> ps = clone->GetPresShell()) {
|
|
|
|
if (!ps->DidInitialize()) {
|
|
|
|
nsresult rv = ps->Initialize();
|
|
|
|
Unused << NS_WARN_IF(NS_FAILED(rv));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2020-01-05 23:58:21 +03:00
|
|
|
void BrowserChild::DoFakeShow(const ParentShowInfo& aParentShowInfo) {
|
2020-01-13 14:30:44 +03:00
|
|
|
OwnerShowInfo ownerInfo{ScreenIntSize(), ScrollbarPreference::Auto,
|
2020-11-20 18:16:58 +03:00
|
|
|
nsSizeMode_Normal};
|
2020-01-05 23:58:21 +03:00
|
|
|
RecvShow(aParentShowInfo, ownerInfo);
|
2012-06-13 02:01:25 +04:00
|
|
|
mDidFakeShow = true;
|
|
|
|
}
|
|
|
|
|
2020-01-05 23:58:21 +03:00
|
|
|
void BrowserChild::ApplyParentShowInfo(const ParentShowInfo& aInfo) {
|
2017-05-19 13:20:18 +03:00
|
|
|
// Even if we already set real show info, the dpi / rounding & scale may still
|
2019-04-10 00:38:15 +03:00
|
|
|
// be invalid (if BrowserParent wasn't able to get widget it would just send
|
|
|
|
// 0). So better to always set up-to-date values here.
|
2017-05-19 13:20:18 +03:00
|
|
|
if (aInfo.dpi() > 0) {
|
|
|
|
mPuppetWidget->UpdateBackingScaleCache(aInfo.dpi(), aInfo.widgetRounding(),
|
|
|
|
aInfo.defaultScale());
|
|
|
|
}
|
|
|
|
|
2015-10-30 16:24:57 +03:00
|
|
|
if (mDidSetRealShowInfo) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aInfo.fakeShowInfo()) {
|
|
|
|
// Once we've got one ShowInfo from parent, no need to update the values
|
|
|
|
// anymore.
|
|
|
|
mDidSetRealShowInfo = true;
|
|
|
|
}
|
|
|
|
|
2016-05-16 05:56:09 +03:00
|
|
|
mIsTransparent = aInfo.isTransparent();
|
2014-11-24 22:05:35 +03:00
|
|
|
}
|
|
|
|
|
2020-01-05 23:58:21 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvShow(
|
|
|
|
const ParentShowInfo& aParentInfo, const OwnerShowInfo& aOwnerInfo) {
|
2017-01-17 23:52:45 +03:00
|
|
|
bool res = true;
|
2012-06-13 02:01:25 +04:00
|
|
|
|
2020-01-05 23:58:21 +03:00
|
|
|
mPuppetWidget->SetSizeMode(aOwnerInfo.sizeMode());
|
2017-01-17 23:52:45 +03:00
|
|
|
if (!mDidFakeShow) {
|
2014-03-25 06:28:46 +04:00
|
|
|
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(WebNavigation());
|
2010-08-21 03:24:40 +04:00
|
|
|
if (!baseWindow) {
|
2014-03-25 06:28:46 +04:00
|
|
|
NS_ERROR("WebNavigation() doesn't QI to nsIBaseWindow");
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2010-08-21 03:24:40 +04:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
baseWindow->SetVisibility(true);
|
2019-04-10 01:39:01 +03:00
|
|
|
res = InitBrowserChildMessageManager();
|
2017-01-17 23:52:45 +03:00
|
|
|
}
|
2010-08-21 03:24:40 +04:00
|
|
|
|
2020-01-05 23:58:21 +03:00
|
|
|
ApplyParentShowInfo(aParentInfo);
|
2020-11-20 18:16:58 +03:00
|
|
|
|
2020-01-13 14:30:44 +03:00
|
|
|
if (!mIsTopLevel) {
|
|
|
|
RecvScrollbarPreferenceChanged(aOwnerInfo.scrollbarPreference());
|
|
|
|
}
|
2015-06-04 23:51:10 +03:00
|
|
|
|
2017-01-17 23:52:45 +03:00
|
|
|
if (!res) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
2018-08-14 03:40:15 +03:00
|
|
|
|
2019-09-27 16:11:51 +03:00
|
|
|
UpdateVisibility();
|
2019-05-15 23:29:22 +03:00
|
|
|
|
2017-01-17 23:52:45 +03:00
|
|
|
return IPC_OK();
|
2009-07-01 00:39:22 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvInitRendering(
|
2017-01-17 23:52:45 +03:00
|
|
|
const TextureFactoryIdentifier& aTextureFactoryIdentifier,
|
2018-03-25 02:06:01 +03:00
|
|
|
const layers::LayersId& aLayersId,
|
2017-04-10 00:30:27 +03:00
|
|
|
const CompositorOptions& aCompositorOptions, const bool& aLayersConnected) {
|
2017-10-13 17:32:36 +03:00
|
|
|
mLayersConnected = Some(aLayersConnected);
|
2018-11-06 00:03:15 +03:00
|
|
|
InitRenderingState(aTextureFactoryIdentifier, aLayersId, aCompositorOptions);
|
2017-01-17 23:52:45 +03:00
|
|
|
return IPC_OK();
|
2009-07-01 00:39:22 +04:00
|
|
|
}
|
|
|
|
|
2020-01-13 14:30:44 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvScrollbarPreferenceChanged(
|
|
|
|
ScrollbarPreference aPreference) {
|
|
|
|
MOZ_ASSERT(!mIsTopLevel,
|
|
|
|
"Scrollbar visibility should be derived from chrome flags for "
|
|
|
|
"top-level windows");
|
2020-04-02 18:00:44 +03:00
|
|
|
if (nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation())) {
|
|
|
|
nsDocShell::Cast(docShell)->SetScrollbarPreference(aPreference);
|
|
|
|
}
|
2020-01-13 14:30:44 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-11-19 02:13:55 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvCompositorOptionsChanged(
|
|
|
|
const CompositorOptions& aNewOptions) {
|
|
|
|
MOZ_ASSERT(mCompositorOptions);
|
|
|
|
|
|
|
|
// The only compositor option we currently support changing is APZ
|
|
|
|
// enablement. Even that is only partially supported for now:
|
|
|
|
// * Going from APZ to non-APZ is fine - we just flip the stored flag.
|
|
|
|
// Note that we keep the actors (mApzcTreeManager, and the APZChild
|
|
|
|
// created in InitAPZState()) around (read on for why).
|
|
|
|
// * Going from non-APZ to APZ is only supported if we were using
|
|
|
|
// APZ initially (at InitRendering() time) and we are transitioning
|
|
|
|
// back. In this case, we just reuse the actors which we kept around.
|
|
|
|
// Fully supporting a non-APZ to APZ transition (i.e. even in cases
|
|
|
|
// where we initialized as non-APZ) would require setting up the actors
|
|
|
|
// here. (In that case, we would also have the options of destroying
|
|
|
|
// the actors in the APZ --> non-APZ case, and always re-creating them
|
|
|
|
// during a non-APZ --> APZ transition).
|
|
|
|
mCompositorOptions->SetUseAPZ(aNewOptions.UseAPZ());
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvUpdateDimensions(
|
2017-06-07 21:36:46 +03:00
|
|
|
const DimensionInfo& aDimensionInfo) {
|
2020-02-27 20:39:15 +03:00
|
|
|
if (mLayersConnected.isNothing()) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-08-09 23:38:26 +04:00
|
|
|
}
|
|
|
|
|
2017-06-07 21:36:46 +03:00
|
|
|
mUnscaledOuterRect = aDimensionInfo.rect();
|
|
|
|
mClientOffset = aDimensionInfo.clientOffset();
|
2017-11-22 22:21:37 +03:00
|
|
|
mChromeOffset = aDimensionInfo.chromeOffset();
|
2020-12-03 13:42:55 +03:00
|
|
|
MOZ_ASSERT_IF(!IsTopLevel(), mChromeOffset == LayoutDeviceIntPoint());
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2017-06-07 21:36:46 +03:00
|
|
|
mOrientation = aDimensionInfo.orientation();
|
|
|
|
SetUnscaledInnerSize(aDimensionInfo.size());
|
|
|
|
if (!mHasValidInnerSize && aDimensionInfo.size().width != 0 &&
|
|
|
|
aDimensionInfo.size().height != 0) {
|
2014-04-25 19:40:23 +04:00
|
|
|
mHasValidInnerSize = true;
|
|
|
|
}
|
2014-02-22 03:12:43 +04:00
|
|
|
|
2015-07-21 17:51:55 +03:00
|
|
|
ScreenIntSize screenSize = GetInnerSize();
|
2015-06-08 08:39:28 +03:00
|
|
|
ScreenIntRect screenRect = GetOuterRect();
|
2009-07-01 00:39:22 +04:00
|
|
|
|
2020-06-24 16:29:18 +03:00
|
|
|
// Make sure to set the size on the document viewer first. The
|
|
|
|
// MobileViewportManager needs the content viewer size to be updated before
|
|
|
|
// the reflow, otherwise it gets a stale size when it computes a new CSS
|
|
|
|
// viewport.
|
|
|
|
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
|
|
|
|
baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height,
|
|
|
|
nsIBaseWindow::eRepaint);
|
2011-07-16 01:46:56 +04:00
|
|
|
|
2020-06-24 16:29:18 +03:00
|
|
|
mPuppetWidget->Resize(screenRect.x + mClientOffset.x + mChromeOffset.x,
|
|
|
|
screenRect.y + mClientOffset.y + mChromeOffset.y,
|
|
|
|
screenSize.width, screenSize.height, true);
|
2012-09-29 06:18:18 +04:00
|
|
|
|
2020-03-04 11:16:31 +03:00
|
|
|
RecvSafeAreaInsetsChanged(mPuppetWidget->GetSafeAreaInsets());
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2009-07-01 00:39:22 +04:00
|
|
|
}
|
2009-10-29 20:58:31 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvSizeModeChanged(
|
2016-02-23 19:10:00 +03:00
|
|
|
const nsSizeMode& aSizeMode) {
|
|
|
|
mPuppetWidget->SetSizeMode(aSizeMode);
|
2016-04-20 06:41:42 +03:00
|
|
|
if (!mPuppetWidget->IsVisible()) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-04-20 06:41:42 +03:00
|
|
|
}
|
2019-04-13 04:53:10 +03:00
|
|
|
nsCOMPtr<Document> document(GetTopLevelDocument());
|
2020-02-25 03:07:04 +03:00
|
|
|
if (!document) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2018-02-21 01:00:10 +03:00
|
|
|
nsPresContext* presContext = document->GetPresContext();
|
|
|
|
if (presContext) {
|
|
|
|
presContext->SizeModeChanged(aSizeMode);
|
2016-02-23 19:10:00 +03:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-02-23 19:10:00 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvChildToParentMatrix(
|
2020-02-15 10:23:51 +03:00
|
|
|
const Maybe<gfx::Matrix4x4>& aMatrix,
|
|
|
|
const ScreenRect& aTopLevelViewportVisibleRectInBrowserCoords) {
|
2019-04-09 13:26:31 +03:00
|
|
|
mChildToParentConversionMatrix =
|
2019-08-20 09:37:05 +03:00
|
|
|
LayoutDeviceToLayoutDeviceMatrix4x4::FromUnknownMatrix(aMatrix);
|
2020-02-11 06:35:56 +03:00
|
|
|
mTopLevelViewportVisibleRectInBrowserCoords =
|
|
|
|
aTopLevelViewportVisibleRectInBrowserCoords;
|
2020-02-11 06:35:38 +03:00
|
|
|
|
2020-02-15 10:23:51 +03:00
|
|
|
// Trigger an intersection observation update since ancestor viewports
|
|
|
|
// changed.
|
2020-02-11 06:35:38 +03:00
|
|
|
if (RefPtr<Document> toplevelDoc = GetTopLevelDocument()) {
|
2020-02-15 10:23:51 +03:00
|
|
|
if (nsPresContext* pc = toplevelDoc->GetPresContext()) {
|
|
|
|
pc->RefreshDriver()->EnsureIntersectionObservationsUpdateHappens();
|
2020-02-11 06:35:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-09 13:26:31 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-05-13 04:49:07 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvSetIsUnderHiddenEmbedderElement(
|
|
|
|
const bool& aIsUnderHiddenEmbedderElement) {
|
|
|
|
if (RefPtr<PresShell> presShell = GetTopLevelPresShell()) {
|
|
|
|
presShell->SetIsUnderHiddenEmbedderElement(aIsUnderHiddenEmbedderElement);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-11-14 08:59:47 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvDynamicToolbarMaxHeightChanged(
|
|
|
|
const ScreenIntCoord& aHeight) {
|
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
mDynamicToolbarMaxHeight = aHeight;
|
|
|
|
|
|
|
|
RefPtr<Document> document = GetTopLevelDocument();
|
|
|
|
if (!document) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RefPtr<nsPresContext> presContext = document->GetPresContext()) {
|
|
|
|
presContext->SetDynamicToolbarMaxHeight(aHeight);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-11-22 00:15:46 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvDynamicToolbarOffsetChanged(
|
|
|
|
const ScreenIntCoord& aOffset) {
|
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
RefPtr<Document> document = GetTopLevelDocument();
|
|
|
|
if (!document) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsPresContext* presContext = document->GetPresContext()) {
|
|
|
|
presContext->UpdateDynamicToolbarOffset(aOffset);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvSuppressDisplayport(
|
2015-08-20 00:08:41 +03:00
|
|
|
const bool& aEnabled) {
|
2019-04-13 04:53:10 +03:00
|
|
|
if (RefPtr<PresShell> presShell = GetTopLevelPresShell()) {
|
|
|
|
presShell->SuppressDisplayport(aEnabled);
|
2015-08-20 00:08:41 +03:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-08-20 00:08:41 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::HandleDoubleTap(const CSSPoint& aPoint,
|
|
|
|
const Modifiers& aModifiers,
|
|
|
|
const ScrollableLayerGuid& aGuid) {
|
2020-02-24 19:31:04 +03:00
|
|
|
MOZ_LOG(
|
|
|
|
sApzChildLog, LogLevel::Debug,
|
2020-09-28 03:36:32 +03:00
|
|
|
("Handling double tap at %s with %p %p\n", ToString(aPoint).c_str(),
|
2020-02-24 19:31:04 +03:00
|
|
|
mBrowserChildMessageManager ? mBrowserChildMessageManager->GetWrapper()
|
|
|
|
: nullptr,
|
|
|
|
mBrowserChildMessageManager.get()));
|
2014-09-12 01:25:27 +04:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
if (!mBrowserChildMessageManager) {
|
2016-01-08 22:17:39 +03:00
|
|
|
return;
|
|
|
|
}
|
2012-08-09 08:39:02 +04:00
|
|
|
|
2016-01-08 22:17:39 +03:00
|
|
|
// Note: there is nothing to do with the modifiers here, as we are not
|
|
|
|
// synthesizing any sort of mouse event.
|
2019-04-13 04:53:10 +03:00
|
|
|
RefPtr<Document> document = GetTopLevelDocument();
|
2016-07-29 21:44:29 +03:00
|
|
|
CSSRect zoomToRect = CalculateRectToZoomTo(document, aPoint);
|
2016-01-08 22:17:39 +03:00
|
|
|
// The double-tap can be dispatched by any scroll frame (so |aGuid| could be
|
|
|
|
// the guid of any scroll frame), but the zoom-to-rect operation must be
|
|
|
|
// performed by the root content scroll frame, so query its identifiers
|
|
|
|
// for the SendZoomToRect() call rather than using the ones from |aGuid|.
|
|
|
|
uint32_t presShellId;
|
|
|
|
ViewID viewId;
|
|
|
|
if (APZCCallbackHelper::GetOrCreateScrollIdentifiers(
|
2016-07-31 22:39:00 +03:00
|
|
|
document->GetDocumentElement(), &presShellId, &viewId) &&
|
|
|
|
mApzcTreeManager) {
|
2020-03-27 20:44:21 +03:00
|
|
|
ScrollableLayerGuid guid(mLayersId, presShellId, viewId);
|
2016-07-31 22:39:00 +03:00
|
|
|
|
|
|
|
mApzcTreeManager->ZoomToRect(guid, zoomToRect, DEFAULT_BEHAVIOR);
|
2016-01-08 22:17:39 +03:00
|
|
|
}
|
2012-07-20 10:48:27 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvHandleTap(
|
2016-09-21 17:26:33 +03:00
|
|
|
const GeckoContentController::TapType& aType,
|
|
|
|
const LayoutDevicePoint& aPoint, const Modifiers& aModifiers,
|
|
|
|
const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId) {
|
2019-03-07 01:54:58 +03:00
|
|
|
// IPDL doesn't hold a strong reference to protocols as they're not required
|
|
|
|
// to be refcounted. This function can run script, which may trigger a nested
|
|
|
|
// event loop, which may release this, so we hold a strong reference here.
|
2019-04-10 01:39:01 +03:00
|
|
|
RefPtr<BrowserChild> kungFuDeathGrip(this);
|
2019-04-13 05:23:07 +03:00
|
|
|
RefPtr<PresShell> presShell = GetTopLevelPresShell();
|
2016-07-29 21:44:29 +03:00
|
|
|
if (!presShell) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-07-29 21:44:29 +03:00
|
|
|
}
|
|
|
|
if (!presShell->GetPresContext()) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-07-29 21:44:29 +03:00
|
|
|
}
|
|
|
|
CSSToLayoutDeviceScale scale(
|
|
|
|
presShell->GetPresContext()->CSSToDevPixelScale());
|
2020-05-05 22:37:26 +03:00
|
|
|
CSSPoint point = aPoint / scale;
|
|
|
|
|
|
|
|
// Stash the guid in InputAPZContext so that when the visual-to-layout
|
|
|
|
// transform is applied to the event's coordinates, we use the right transform
|
|
|
|
// based on the scroll frame being targeted.
|
|
|
|
// The other values don't really matter.
|
|
|
|
InputAPZContext context(aGuid, aInputBlockId, nsEventStatus_eSentinel);
|
2016-07-29 21:44:29 +03:00
|
|
|
|
2016-07-05 20:24:54 +03:00
|
|
|
switch (aType) {
|
|
|
|
case GeckoContentController::TapType::eSingleTap:
|
2019-04-10 01:39:01 +03:00
|
|
|
if (mBrowserChildMessageManager) {
|
2019-05-07 01:14:40 +03:00
|
|
|
mAPZEventState->ProcessSingleTap(point, scale, aModifiers, 1);
|
2016-07-05 20:24:54 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GeckoContentController::TapType::eDoubleTap:
|
2016-07-29 21:44:29 +03:00
|
|
|
HandleDoubleTap(point, aModifiers, aGuid);
|
2016-07-05 20:24:54 +03:00
|
|
|
break;
|
2016-09-29 17:05:25 +03:00
|
|
|
case GeckoContentController::TapType::eSecondTap:
|
2019-04-10 01:39:01 +03:00
|
|
|
if (mBrowserChildMessageManager) {
|
2019-05-07 01:14:40 +03:00
|
|
|
mAPZEventState->ProcessSingleTap(point, scale, aModifiers, 2);
|
2016-09-29 17:05:25 +03:00
|
|
|
}
|
|
|
|
break;
|
2016-07-05 20:24:54 +03:00
|
|
|
case GeckoContentController::TapType::eLongTap:
|
2019-04-10 01:39:01 +03:00
|
|
|
if (mBrowserChildMessageManager) {
|
2019-03-13 03:30:11 +03:00
|
|
|
RefPtr<APZEventState> eventState(mAPZEventState);
|
2019-05-07 01:14:40 +03:00
|
|
|
eventState->ProcessLongTap(presShell, point, scale, aModifiers,
|
2019-03-13 03:30:11 +03:00
|
|
|
aInputBlockId);
|
2016-07-05 20:24:54 +03:00
|
|
|
}
|
|
|
|
break;
|
2016-07-05 20:24:54 +03:00
|
|
|
case GeckoContentController::TapType::eLongTapUp:
|
2019-04-10 01:39:01 +03:00
|
|
|
if (mBrowserChildMessageManager) {
|
2019-03-13 03:30:11 +03:00
|
|
|
RefPtr<APZEventState> eventState(mAPZEventState);
|
2019-04-13 05:23:07 +03:00
|
|
|
eventState->ProcessLongTapUp(presShell, point, scale, aModifiers);
|
2016-07-05 20:24:54 +03:00
|
|
|
}
|
|
|
|
break;
|
2012-11-08 23:35:02 +04:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-11-08 23:35:02 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvNormalPriorityHandleTap(
|
2017-07-28 10:14:54 +03:00
|
|
|
const GeckoContentController::TapType& aType,
|
|
|
|
const LayoutDevicePoint& aPoint, const Modifiers& aModifiers,
|
|
|
|
const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId) {
|
2019-03-07 01:54:58 +03:00
|
|
|
// IPDL doesn't hold a strong reference to protocols as they're not required
|
|
|
|
// to be refcounted. This function can run script, which may trigger a nested
|
|
|
|
// event loop, which may release this, so we hold a strong reference here.
|
2019-04-10 01:39:01 +03:00
|
|
|
RefPtr<BrowserChild> kungFuDeathGrip(this);
|
2017-07-28 10:14:54 +03:00
|
|
|
return RecvHandleTap(aType, aPoint, aModifiers, aGuid, aInputBlockId);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
bool BrowserChild::NotifyAPZStateChange(
|
2016-01-08 22:17:39 +03:00
|
|
|
const ViewID& aViewId,
|
|
|
|
const layers::GeckoContentController::APZStateChange& aChange,
|
|
|
|
const int& aArg) {
|
2016-11-04 17:27:02 +03:00
|
|
|
mAPZEventState->ProcessAPZStateChange(aViewId, aChange, aArg);
|
2016-07-04 21:44:08 +03:00
|
|
|
if (aChange ==
|
|
|
|
layers::GeckoContentController::APZStateChange::eTransformEnd) {
|
2015-06-20 05:51:35 +03:00
|
|
|
// This is used by tests to determine when the APZ is done doing whatever
|
|
|
|
// it's doing. XXX generify this as needed when writing additional tests.
|
2016-02-25 19:15:14 +03:00
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
observerService->NotifyObservers(nullptr, "APZ:TransformEnd", nullptr);
|
2015-06-20 05:51:35 +03:00
|
|
|
}
|
2013-12-10 07:14:55 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::StartScrollbarDrag(
|
2016-01-08 22:17:39 +03:00
|
|
|
const layers::AsyncDragMetrics& aDragMetrics) {
|
2020-03-27 20:44:21 +03:00
|
|
|
ScrollableLayerGuid guid(mLayersId, aDragMetrics.mPresShellId,
|
|
|
|
aDragMetrics.mViewId);
|
2016-07-31 22:39:00 +03:00
|
|
|
|
|
|
|
if (mApzcTreeManager) {
|
|
|
|
mApzcTreeManager->StartScrollbarDrag(guid, aDragMetrics);
|
2016-01-08 22:17:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::ZoomToRect(const uint32_t& aPresShellId,
|
|
|
|
const ScrollableLayerGuid::ViewID& aViewId,
|
|
|
|
const CSSRect& aRect, const uint32_t& aFlags) {
|
2020-03-27 20:44:21 +03:00
|
|
|
ScrollableLayerGuid guid(mLayersId, aPresShellId, aViewId);
|
2016-07-31 22:39:00 +03:00
|
|
|
|
|
|
|
if (mApzcTreeManager) {
|
|
|
|
mApzcTreeManager->ZoomToRect(guid, aRect, aFlags);
|
2016-01-08 22:17:39 +03:00
|
|
|
}
|
2015-06-19 15:25:41 +03:00
|
|
|
}
|
|
|
|
|
2020-11-16 22:16:20 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvActivate(uint64_t aActionId) {
|
2018-08-04 04:49:11 +03:00
|
|
|
MOZ_ASSERT(mWebBrowser);
|
2020-11-16 22:16:20 +03:00
|
|
|
mWebBrowser->FocusActivate(aActionId);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2009-11-05 21:14:22 +03:00
|
|
|
}
|
|
|
|
|
2020-11-16 22:16:20 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvDeactivate(uint64_t aActionId) {
|
2018-08-04 04:49:11 +03:00
|
|
|
MOZ_ASSERT(mWebBrowser);
|
2020-11-16 22:16:20 +03:00
|
|
|
mWebBrowser->FocusDeactivate(aActionId);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-06-18 04:08:32 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvSetKeyboardIndicators(
|
2016-11-15 06:26:00 +03:00
|
|
|
const UIStateChangeType& aShowFocusRings) {
|
2016-06-09 14:59:31 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(WebNavigation());
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(window, IPC_OK());
|
2019-06-03 18:29:06 +03:00
|
|
|
window->SetKeyboardIndicators(aShowFocusRings);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-06-09 14:59:31 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvStopIMEStateManagement() {
|
2015-07-01 16:19:11 +03:00
|
|
|
IMEStateManager::StopIMEStateManagement();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-07-01 16:19:11 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvMouseEvent(
|
2010-07-19 22:33:33 +04:00
|
|
|
const nsString& aType, const float& aX, const float& aY,
|
2012-08-22 19:56:38 +04:00
|
|
|
const int32_t& aButton, const int32_t& aClickCount,
|
2020-05-18 06:05:32 +03:00
|
|
|
const int32_t& aModifiers) {
|
2019-03-07 01:54:58 +03:00
|
|
|
// IPDL doesn't hold a strong reference to protocols as they're not required
|
|
|
|
// to be refcounted. This function can run script, which may trigger a nested
|
|
|
|
// event loop, which may release this, so we hold a strong reference here.
|
2019-04-10 01:39:01 +03:00
|
|
|
RefPtr<BrowserChild> kungFuDeathGrip(this);
|
2019-04-13 05:23:07 +03:00
|
|
|
RefPtr<PresShell> presShell = GetTopLevelPresShell();
|
2020-05-18 06:07:12 +03:00
|
|
|
APZCCallbackHelper::DispatchMouseEvent(presShell, aType, CSSPoint(aX, aY),
|
|
|
|
aButton, aClickCount, aModifiers,
|
|
|
|
MouseEvent_Binding::MOZ_SOURCE_UNKNOWN,
|
|
|
|
0 /* Use the default value here. */);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2009-11-05 21:21:09 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::ProcessPendingCoalescedMouseDataAndDispatchEvents() {
|
2017-10-12 04:05:40 +03:00
|
|
|
if (!mCoalesceMouseMoveEvents || !mCoalescedMouseEventFlusher) {
|
2019-04-10 01:39:01 +03:00
|
|
|
// We don't enable mouse coalescing or we are destroying BrowserChild.
|
2017-08-11 09:58:08 +03:00
|
|
|
return;
|
|
|
|
}
|
2017-10-12 04:05:40 +03:00
|
|
|
|
|
|
|
// We may reentry the event loop and push more data to
|
|
|
|
// mToBeDispatchedMouseData while dispatching an event.
|
|
|
|
|
|
|
|
// We may have some pending coalesced data while dispatch an event and reentry
|
|
|
|
// the event loop. In that case we don't have chance to consume the remainding
|
|
|
|
// pending data until we get new mouse events. Get some helps from
|
|
|
|
// mCoalescedMouseEventFlusher to trigger it.
|
|
|
|
mCoalescedMouseEventFlusher->StartObserver();
|
|
|
|
|
|
|
|
while (mToBeDispatchedMouseData.GetSize() > 0) {
|
|
|
|
UniquePtr<CoalescedMouseData> data(
|
|
|
|
static_cast<CoalescedMouseData*>(mToBeDispatchedMouseData.PopFront()));
|
|
|
|
|
|
|
|
UniquePtr<WidgetMouseEvent> event = data->TakeCoalescedEvent();
|
|
|
|
if (event) {
|
|
|
|
// Dispatch the pending events. Using HandleRealMouseButtonEvent
|
|
|
|
// to bypass the coalesce handling in RecvRealMouseMoveEvent. Can't use
|
|
|
|
// RecvRealMouseButtonEvent because we may also put some mouse events
|
|
|
|
// other than mousemove.
|
|
|
|
HandleRealMouseButtonEvent(*event, data->GetScrollableLayerGuid(),
|
|
|
|
data->GetInputBlockId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// mCoalescedMouseEventFlusher may be destroyed when reentrying the event
|
|
|
|
// loop.
|
|
|
|
if (mCoalescedMouseEventFlusher) {
|
|
|
|
mCoalescedMouseEventFlusher->RemoveObserver();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
LayoutDeviceToLayoutDeviceMatrix4x4
|
|
|
|
BrowserChild::GetChildToParentConversionMatrix() const {
|
2019-04-09 13:26:31 +03:00
|
|
|
if (mChildToParentConversionMatrix) {
|
|
|
|
return *mChildToParentConversionMatrix;
|
|
|
|
}
|
|
|
|
LayoutDevicePoint offset(GetChromeOffset());
|
|
|
|
return LayoutDeviceToLayoutDeviceMatrix4x4::Translation(offset);
|
|
|
|
}
|
|
|
|
|
2020-02-11 06:35:56 +03:00
|
|
|
ScreenRect BrowserChild::GetTopLevelViewportVisibleRectInBrowserCoords() const {
|
|
|
|
return mTopLevelViewportVisibleRectInBrowserCoords;
|
2019-09-12 11:08:45 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::FlushAllCoalescedMouseData() {
|
2017-10-12 04:05:40 +03:00
|
|
|
MOZ_ASSERT(mCoalesceMouseMoveEvents);
|
|
|
|
|
|
|
|
// Move all entries from mCoalescedMouseData to mToBeDispatchedMouseData.
|
2017-09-20 06:57:56 +03:00
|
|
|
for (auto iter = mCoalescedMouseData.Iter(); !iter.Done(); iter.Next()) {
|
|
|
|
CoalescedMouseData* data = iter.UserData();
|
|
|
|
if (!data || data->IsEmpty()) {
|
|
|
|
continue;
|
|
|
|
}
|
2017-10-12 04:05:40 +03:00
|
|
|
UniquePtr<CoalescedMouseData> dispatchData =
|
|
|
|
MakeUnique<CoalescedMouseData>();
|
|
|
|
|
|
|
|
dispatchData->RetrieveDataFrom(*data);
|
|
|
|
mToBeDispatchedMouseData.Push(dispatchData.release());
|
2017-08-31 07:00:08 +03:00
|
|
|
}
|
2017-10-12 04:05:40 +03:00
|
|
|
mCoalescedMouseData.Clear();
|
2017-08-11 09:58:08 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvRealMouseMoveEvent(
|
2015-09-28 21:44:37 +03:00
|
|
|
const WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId) {
|
2017-08-31 07:00:08 +03:00
|
|
|
if (mCoalesceMouseMoveEvents && mCoalescedMouseEventFlusher) {
|
2018-10-01 12:55:42 +03:00
|
|
|
CoalescedMouseData* data =
|
|
|
|
mCoalescedMouseData.LookupOrAdd(aEvent.pointerId);
|
|
|
|
MOZ_ASSERT(data);
|
2017-09-20 06:57:56 +03:00
|
|
|
if (data->CanCoalesce(aEvent, aGuid, aInputBlockId)) {
|
|
|
|
data->Coalesce(aEvent, aGuid, aInputBlockId);
|
2017-08-11 09:58:08 +03:00
|
|
|
mCoalescedMouseEventFlusher->StartObserver();
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2017-10-12 04:05:40 +03:00
|
|
|
// Can't coalesce current mousemove event. Put the coalesced mousemove data
|
|
|
|
// with the same pointer id to mToBeDispatchedMouseData, coalesce the
|
|
|
|
// current one, and process all pending data in mToBeDispatchedMouseData.
|
|
|
|
UniquePtr<CoalescedMouseData> dispatchData =
|
|
|
|
MakeUnique<CoalescedMouseData>();
|
|
|
|
|
|
|
|
dispatchData->RetrieveDataFrom(*data);
|
|
|
|
mToBeDispatchedMouseData.Push(dispatchData.release());
|
|
|
|
|
|
|
|
// Put new data to replace the old one in the hash table.
|
|
|
|
CoalescedMouseData* newData = new CoalescedMouseData();
|
|
|
|
mCoalescedMouseData.Put(aEvent.pointerId, newData);
|
|
|
|
newData->Coalesce(aEvent, aGuid, aInputBlockId);
|
|
|
|
|
|
|
|
// Dispatch all pending mouse events.
|
|
|
|
ProcessPendingCoalescedMouseDataAndDispatchEvents();
|
2017-08-11 09:58:08 +03:00
|
|
|
mCoalescedMouseEventFlusher->StartObserver();
|
|
|
|
} else if (!RecvRealMouseButtonEvent(aEvent, aGuid, aInputBlockId)) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2015-02-14 02:34:04 +03:00
|
|
|
}
|
|
|
|
|
2020-12-11 09:43:44 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvRealMouseMoveEventForTests(
|
|
|
|
const WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId) {
|
|
|
|
return RecvRealMouseMoveEvent(aEvent, aGuid, aInputBlockId);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvNormalPriorityRealMouseMoveEvent(
|
2017-07-28 10:14:54 +03:00
|
|
|
const WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId) {
|
|
|
|
return RecvRealMouseMoveEvent(aEvent, aGuid, aInputBlockId);
|
|
|
|
}
|
|
|
|
|
2020-12-11 09:43:44 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
BrowserChild::RecvNormalPriorityRealMouseMoveEventForTests(
|
|
|
|
const WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId) {
|
|
|
|
return RecvRealMouseMoveEvent(aEvent, aGuid, aInputBlockId);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvSynthMouseMoveEvent(
|
2015-09-28 21:44:37 +03:00
|
|
|
const WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId) {
|
2016-11-15 06:26:00 +03:00
|
|
|
if (!RecvRealMouseButtonEvent(aEvent, aGuid, aInputBlockId)) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2015-07-28 01:35:51 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvNormalPrioritySynthMouseMoveEvent(
|
2017-07-28 10:14:54 +03:00
|
|
|
const WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId) {
|
|
|
|
return RecvSynthMouseMoveEvent(aEvent, aGuid, aInputBlockId);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvRealMouseButtonEvent(
|
2015-09-28 21:44:37 +03:00
|
|
|
const WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId) {
|
2017-10-12 04:05:40 +03:00
|
|
|
if (mCoalesceMouseMoveEvents && mCoalescedMouseEventFlusher &&
|
|
|
|
aEvent.mMessage != eMouseMove) {
|
|
|
|
// When receiving a mouse event other than mousemove, we have to dispatch
|
|
|
|
// all coalesced events before it. However, we can't dispatch all pending
|
|
|
|
// coalesced events directly because we may reentry the event loop while
|
|
|
|
// dispatching. To make sure we won't dispatch disorder events, we move all
|
|
|
|
// coalesced mousemove events and current event to a deque to dispatch them.
|
|
|
|
// When reentrying the event loop and dispatching more events, we put new
|
|
|
|
// events in the end of the nsQueue and dispatch events from the beginning.
|
|
|
|
FlushAllCoalescedMouseData();
|
|
|
|
|
|
|
|
UniquePtr<CoalescedMouseData> dispatchData =
|
|
|
|
MakeUnique<CoalescedMouseData>();
|
|
|
|
|
|
|
|
dispatchData->Coalesce(aEvent, aGuid, aInputBlockId);
|
|
|
|
mToBeDispatchedMouseData.Push(dispatchData.release());
|
|
|
|
|
|
|
|
ProcessPendingCoalescedMouseDataAndDispatchEvents();
|
|
|
|
return IPC_OK();
|
2017-08-11 09:58:08 +03:00
|
|
|
}
|
2017-10-12 04:05:40 +03:00
|
|
|
HandleRealMouseButtonEvent(aEvent, aGuid, aInputBlockId);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::HandleRealMouseButtonEvent(const WidgetMouseEvent& aEvent,
|
|
|
|
const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId) {
|
2020-05-05 22:37:26 +03:00
|
|
|
WidgetMouseEvent localEvent(aEvent);
|
|
|
|
localEvent.mWidget = mPuppetWidget;
|
|
|
|
|
|
|
|
// We need one InputAPZContext here to propagate |aGuid| to places in
|
|
|
|
// SendSetTargetAPZCNotification() which apply the visual-to-layout transform,
|
|
|
|
// and another below to propagate the |postLayerization| flag (whose value
|
|
|
|
// we don't know until SendSetTargetAPZCNotification() returns) into
|
|
|
|
// the event dispatch code.
|
|
|
|
InputAPZContext context1(aGuid, aInputBlockId, nsEventStatus_eSentinel);
|
|
|
|
|
2016-06-20 19:52:47 +03:00
|
|
|
// Mouse events like eMouseEnterIntoWidget, that are created in the parent
|
|
|
|
// process EventStateManager code, have an input block id which they get from
|
|
|
|
// the InputAPZContext in the parent process stack. However, they did not
|
|
|
|
// actually go through the APZ code and so their mHandledByAPZ flag is false.
|
2017-01-19 11:57:20 +03:00
|
|
|
// Since thos events didn't go through APZ, we don't need to send
|
|
|
|
// notifications for them.
|
2018-06-16 01:13:47 +03:00
|
|
|
UniquePtr<DisplayportSetListener> postLayerization;
|
2020-05-05 22:37:26 +03:00
|
|
|
if (aInputBlockId && localEvent.mFlags.mHandledByAPZ) {
|
2019-04-13 04:53:10 +03:00
|
|
|
nsCOMPtr<Document> document(GetTopLevelDocument());
|
2018-06-16 01:13:47 +03:00
|
|
|
postLayerization = APZCCallbackHelper::SendSetTargetAPZCNotification(
|
2020-05-05 22:37:26 +03:00
|
|
|
mPuppetWidget, document, localEvent, aGuid.mLayersId, aInputBlockId);
|
2016-06-07 18:07:55 +03:00
|
|
|
}
|
|
|
|
|
2020-05-05 22:37:26 +03:00
|
|
|
InputAPZContext context2(aGuid, aInputBlockId, nsEventStatus_eSentinel,
|
|
|
|
postLayerization != nullptr);
|
2015-09-28 21:44:37 +03:00
|
|
|
|
Bug 1333459 - part2-2: EventStateManager should check if it needs to wait reply from remote content before handling access keys r=smaug
Currently, access key is handled in EventStateManager::PreHandleEvent() with eKeyPress event, i.e., before dispatching it into the DOM tree, if the access key is registered in EventStateManager. So, the main process does not check if the preceding eKeyDown event is consumed in focused remote process.
When preceding eKeyDown event is consumed in the main process, eKeyPress event won't be dispatched by widget. However, if remote process has focus, it's impossible widget to stop dispatching eKeyPress event because preceding eKeyDown event hasn't been handled in the focused remote process yet. Therefore, main process needs to post eKeyPress event to check if preceding eKeyDown event was consumed. When eKeyPress event is marked as "waiting reply from remote process", TabChild sends it back to the main process only when preceding eKeyDown event wasn't consumed. So, only when eKeyPress event is back to the main process, main process should handle accesskey with it.
This patch makes EventStateManager::PreHandleEvent() check if a remote target has focus before handling accesskey. If a remote process has accesskey and there is an accesskey matching with eKeyPress event, it marks the event as "waiting reply from remote content" and stop propagation in the process.
Finally, when eKeyPress event is sent back to TabParent, TabParent::RecvReplyKeyEvent() calls EventStateManager::HandleAccessKey() before dispatching the reply event into the DOM tree.
MozReview-Commit-ID: KsOkakaIVzb
--HG--
extra : rebase_source : 7e0c6966a1bde085e34d45bca4b0166b9fc2f3f1
2017-07-22 04:50:41 +03:00
|
|
|
DispatchWidgetEventViaAPZ(localEvent);
|
2015-10-26 23:06:49 +03:00
|
|
|
|
2020-05-05 22:37:26 +03:00
|
|
|
if (aInputBlockId && localEvent.mFlags.mHandledByAPZ) {
|
|
|
|
mAPZEventState->ProcessMouseEvent(localEvent, aInputBlockId);
|
2015-10-26 23:06:49 +03:00
|
|
|
}
|
2018-06-16 01:13:47 +03:00
|
|
|
|
|
|
|
// Do this after the DispatchWidgetEventViaAPZ call above, so that if the
|
|
|
|
// mouse event triggered a post-refresh AsyncDragMetrics message to be sent
|
|
|
|
// to APZ (from scrollbar dragging in nsSliderFrame), then that will reach
|
|
|
|
// APZ before the SetTargetAPZC message. This ensures the drag input block
|
|
|
|
// gets the drag metrics before handling the input events.
|
|
|
|
if (postLayerization && postLayerization->Register()) {
|
|
|
|
Unused << postLayerization.release();
|
|
|
|
}
|
2011-06-22 04:32:43 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvNormalPriorityRealMouseButtonEvent(
|
2017-07-28 10:14:54 +03:00
|
|
|
const WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId) {
|
|
|
|
return RecvRealMouseButtonEvent(aEvent, aGuid, aInputBlockId);
|
|
|
|
}
|
2017-02-21 12:56:46 +03:00
|
|
|
|
|
|
|
// In case handling repeated mouse wheel takes much time, we skip firing current
|
|
|
|
// wheel event if it may be coalesced to the next one.
|
2019-04-10 01:39:01 +03:00
|
|
|
bool BrowserChild::MaybeCoalesceWheelEvent(const WidgetWheelEvent& aEvent,
|
|
|
|
const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId,
|
|
|
|
bool* aIsNextWheelEvent) {
|
2017-02-21 12:56:46 +03:00
|
|
|
MOZ_ASSERT(aIsNextWheelEvent);
|
|
|
|
if (aEvent.mMessage == eWheel) {
|
|
|
|
GetIPCChannel()->PeekMessages(
|
|
|
|
[aIsNextWheelEvent](const IPC::Message& aMsg) -> bool {
|
|
|
|
if (aMsg.type() == mozilla::dom::PBrowser::Msg_MouseWheelEvent__ID) {
|
|
|
|
*aIsNextWheelEvent = true;
|
|
|
|
}
|
|
|
|
return false; // Stop peeking.
|
|
|
|
});
|
|
|
|
// We only coalesce the current event when
|
|
|
|
// 1. It's eWheel (we don't coalesce eOperationStart and eWheelOperationEnd)
|
|
|
|
// 2. It's not the first wheel event.
|
|
|
|
// 3. It's not the last wheel event.
|
2017-05-12 14:13:59 +03:00
|
|
|
// 4. It's dispatched before the last wheel event was processed +
|
|
|
|
// the processing time of the last event.
|
|
|
|
// This way pages spending lots of time in wheel listeners get wheel
|
|
|
|
// events coalesced more aggressively.
|
2017-02-21 12:56:46 +03:00
|
|
|
// 5. It has same attributes as the coalesced wheel event which is not yet
|
|
|
|
// fired.
|
|
|
|
if (!mLastWheelProcessedTimeFromParent.IsNull() && *aIsNextWheelEvent &&
|
2017-05-12 14:13:59 +03:00
|
|
|
aEvent.mTimeStamp < (mLastWheelProcessedTimeFromParent +
|
|
|
|
mLastWheelProcessingDuration) &&
|
2017-02-21 12:56:46 +03:00
|
|
|
(mCoalescedWheelData.IsEmpty() ||
|
|
|
|
mCoalescedWheelData.CanCoalesce(aEvent, aGuid, aInputBlockId))) {
|
|
|
|
mCoalescedWheelData.Coalesce(aEvent, aGuid, aInputBlockId);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
nsEventStatus BrowserChild::DispatchWidgetEventViaAPZ(WidgetGUIEvent& aEvent) {
|
Bug 1333459 - part2-2: EventStateManager should check if it needs to wait reply from remote content before handling access keys r=smaug
Currently, access key is handled in EventStateManager::PreHandleEvent() with eKeyPress event, i.e., before dispatching it into the DOM tree, if the access key is registered in EventStateManager. So, the main process does not check if the preceding eKeyDown event is consumed in focused remote process.
When preceding eKeyDown event is consumed in the main process, eKeyPress event won't be dispatched by widget. However, if remote process has focus, it's impossible widget to stop dispatching eKeyPress event because preceding eKeyDown event hasn't been handled in the focused remote process yet. Therefore, main process needs to post eKeyPress event to check if preceding eKeyDown event was consumed. When eKeyPress event is marked as "waiting reply from remote process", TabChild sends it back to the main process only when preceding eKeyDown event wasn't consumed. So, only when eKeyPress event is back to the main process, main process should handle accesskey with it.
This patch makes EventStateManager::PreHandleEvent() check if a remote target has focus before handling accesskey. If a remote process has accesskey and there is an accesskey matching with eKeyPress event, it marks the event as "waiting reply from remote content" and stop propagation in the process.
Finally, when eKeyPress event is sent back to TabParent, TabParent::RecvReplyKeyEvent() calls EventStateManager::HandleAccessKey() before dispatching the reply event into the DOM tree.
MozReview-Commit-ID: KsOkakaIVzb
--HG--
extra : rebase_source : 7e0c6966a1bde085e34d45bca4b0166b9fc2f3f1
2017-07-22 04:50:41 +03:00
|
|
|
aEvent.ResetWaitingReplyFromRemoteProcessState();
|
|
|
|
return APZCCallbackHelper::DispatchWidgetEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::MaybeDispatchCoalescedWheelEvent() {
|
2017-02-21 12:56:46 +03:00
|
|
|
if (mCoalescedWheelData.IsEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
2017-10-12 06:22:36 +03:00
|
|
|
UniquePtr<WidgetWheelEvent> wheelEvent =
|
|
|
|
mCoalescedWheelData.TakeCoalescedEvent();
|
2017-02-21 12:56:46 +03:00
|
|
|
MOZ_ASSERT(wheelEvent);
|
|
|
|
DispatchWheelEvent(*wheelEvent, mCoalescedWheelData.GetScrollableLayerGuid(),
|
|
|
|
mCoalescedWheelData.GetInputBlockId());
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::DispatchWheelEvent(const WidgetWheelEvent& aEvent,
|
|
|
|
const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId) {
|
2017-02-21 12:56:46 +03:00
|
|
|
WidgetWheelEvent localEvent(aEvent);
|
2016-06-20 19:52:47 +03:00
|
|
|
if (aInputBlockId && aEvent.mFlags.mHandledByAPZ) {
|
2019-04-13 04:53:10 +03:00
|
|
|
nsCOMPtr<Document> document(GetTopLevelDocument());
|
2018-06-16 01:13:47 +03:00
|
|
|
UniquePtr<DisplayportSetListener> postLayerization =
|
|
|
|
APZCCallbackHelper::SendSetTargetAPZCNotification(
|
2019-05-07 01:14:42 +03:00
|
|
|
mPuppetWidget, document, aEvent, aGuid.mLayersId, aInputBlockId);
|
2018-06-16 01:13:47 +03:00
|
|
|
if (postLayerization && postLayerization->Register()) {
|
|
|
|
Unused << postLayerization.release();
|
|
|
|
}
|
2014-12-09 13:40:26 +03:00
|
|
|
}
|
|
|
|
|
2016-04-14 11:03:14 +03:00
|
|
|
localEvent.mWidget = mPuppetWidget;
|
2020-05-05 22:37:26 +03:00
|
|
|
|
|
|
|
// Stash the guid in InputAPZContext so that when the visual-to-layout
|
|
|
|
// transform is applied to the event's coordinates, we use the right transform
|
|
|
|
// based on the scroll frame being targeted.
|
|
|
|
// The other values don't really matter.
|
|
|
|
InputAPZContext context(aGuid, aInputBlockId, nsEventStatus_eSentinel);
|
|
|
|
|
Bug 1333459 - part2-2: EventStateManager should check if it needs to wait reply from remote content before handling access keys r=smaug
Currently, access key is handled in EventStateManager::PreHandleEvent() with eKeyPress event, i.e., before dispatching it into the DOM tree, if the access key is registered in EventStateManager. So, the main process does not check if the preceding eKeyDown event is consumed in focused remote process.
When preceding eKeyDown event is consumed in the main process, eKeyPress event won't be dispatched by widget. However, if remote process has focus, it's impossible widget to stop dispatching eKeyPress event because preceding eKeyDown event hasn't been handled in the focused remote process yet. Therefore, main process needs to post eKeyPress event to check if preceding eKeyDown event was consumed. When eKeyPress event is marked as "waiting reply from remote process", TabChild sends it back to the main process only when preceding eKeyDown event wasn't consumed. So, only when eKeyPress event is back to the main process, main process should handle accesskey with it.
This patch makes EventStateManager::PreHandleEvent() check if a remote target has focus before handling accesskey. If a remote process has accesskey and there is an accesskey matching with eKeyPress event, it marks the event as "waiting reply from remote content" and stop propagation in the process.
Finally, when eKeyPress event is sent back to TabParent, TabParent::RecvReplyKeyEvent() calls EventStateManager::HandleAccessKey() before dispatching the reply event into the DOM tree.
MozReview-Commit-ID: KsOkakaIVzb
--HG--
extra : rebase_source : 7e0c6966a1bde085e34d45bca4b0166b9fc2f3f1
2017-07-22 04:50:41 +03:00
|
|
|
DispatchWidgetEventViaAPZ(localEvent);
|
2014-12-09 13:40:26 +03:00
|
|
|
|
2016-03-11 02:25:48 +03:00
|
|
|
if (localEvent.mCanTriggerSwipe) {
|
|
|
|
SendRespondStartSwipeEvent(aInputBlockId, localEvent.TriggersSwipe());
|
2015-11-27 19:33:50 +03:00
|
|
|
}
|
|
|
|
|
2016-06-20 19:52:47 +03:00
|
|
|
if (aInputBlockId && aEvent.mFlags.mHandledByAPZ) {
|
2019-05-07 01:14:40 +03:00
|
|
|
mAPZEventState->ProcessWheelEvent(localEvent, aInputBlockId);
|
2014-12-09 13:40:26 +03:00
|
|
|
}
|
2017-02-21 12:56:46 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvMouseWheelEvent(
|
2017-02-21 12:56:46 +03:00
|
|
|
const WidgetWheelEvent& aEvent, const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId) {
|
|
|
|
bool isNextWheelEvent = false;
|
|
|
|
if (MaybeCoalesceWheelEvent(aEvent, aGuid, aInputBlockId,
|
|
|
|
&isNextWheelEvent)) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
if (isNextWheelEvent) {
|
|
|
|
// Update mLastWheelProcessedTimeFromParent so that we can compare the end
|
|
|
|
// time of the current event with the dispatched time of the next event.
|
|
|
|
mLastWheelProcessedTimeFromParent = aEvent.mTimeStamp;
|
|
|
|
mozilla::TimeStamp beforeDispatchingTime = TimeStamp::Now();
|
|
|
|
MaybeDispatchCoalescedWheelEvent();
|
|
|
|
DispatchWheelEvent(aEvent, aGuid, aInputBlockId);
|
2017-05-12 14:13:59 +03:00
|
|
|
mLastWheelProcessingDuration = (TimeStamp::Now() - beforeDispatchingTime);
|
|
|
|
mLastWheelProcessedTimeFromParent += mLastWheelProcessingDuration;
|
2017-02-21 12:56:46 +03:00
|
|
|
} else {
|
|
|
|
// This is the last wheel event. Set mLastWheelProcessedTimeFromParent to
|
|
|
|
// null moment to avoid coalesce the next incoming wheel event.
|
|
|
|
mLastWheelProcessedTimeFromParent = TimeStamp();
|
|
|
|
MaybeDispatchCoalescedWheelEvent();
|
|
|
|
DispatchWheelEvent(aEvent, aGuid, aInputBlockId);
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-06-22 04:32:43 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvNormalPriorityMouseWheelEvent(
|
2017-07-28 10:14:54 +03:00
|
|
|
const WidgetWheelEvent& aEvent, const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId) {
|
|
|
|
return RecvMouseWheelEvent(aEvent, aGuid, aInputBlockId);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvRealTouchEvent(
|
2014-10-24 21:29:30 +04:00
|
|
|
const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
|
2015-05-14 15:16:00 +03:00
|
|
|
const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse) {
|
2020-02-24 19:31:04 +03:00
|
|
|
MOZ_LOG(sApzChildLog, LogLevel::Debug,
|
|
|
|
("Receiving touch event of type %d\n", aEvent.mMessage));
|
2014-09-12 01:25:27 +04:00
|
|
|
|
2015-02-06 02:02:27 +03:00
|
|
|
WidgetTouchEvent localEvent(aEvent);
|
2016-04-14 11:03:14 +03:00
|
|
|
localEvent.mWidget = mPuppetWidget;
|
2015-02-06 02:02:27 +03:00
|
|
|
|
2020-05-05 22:37:26 +03:00
|
|
|
// Stash the guid in InputAPZContext so that when the visual-to-layout
|
|
|
|
// transform is applied to the event's coordinates, we use the right transform
|
|
|
|
// based on the scroll frame being targeted.
|
|
|
|
// The other values don't really matter.
|
|
|
|
InputAPZContext context(aGuid, aInputBlockId, aApzResponse);
|
2014-03-12 23:27:45 +04:00
|
|
|
|
2020-09-09 22:57:36 +03:00
|
|
|
nsTArray<TouchBehaviorFlags> allowedTouchBehaviors;
|
2015-09-14 18:14:34 +03:00
|
|
|
if (localEvent.mMessage == eTouchStart && AsyncPanZoomEnabled()) {
|
2019-04-13 04:53:10 +03:00
|
|
|
nsCOMPtr<Document> document = GetTopLevelDocument();
|
2019-06-13 12:00:59 +03:00
|
|
|
if (StaticPrefs::layout_css_touch_action_enabled()) {
|
2020-09-09 22:57:36 +03:00
|
|
|
allowedTouchBehaviors =
|
|
|
|
APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification(
|
|
|
|
mPuppetWidget, document, localEvent, aInputBlockId,
|
|
|
|
mSetAllowedTouchBehaviorCallback);
|
2015-03-19 13:33:33 +03:00
|
|
|
}
|
2018-06-16 01:13:47 +03:00
|
|
|
UniquePtr<DisplayportSetListener> postLayerization =
|
|
|
|
APZCCallbackHelper::SendSetTargetAPZCNotification(
|
2019-05-15 23:58:08 +03:00
|
|
|
mPuppetWidget, document, localEvent, aGuid.mLayersId,
|
|
|
|
aInputBlockId);
|
2018-06-16 01:13:47 +03:00
|
|
|
if (postLayerization && postLayerization->Register()) {
|
|
|
|
Unused << postLayerization.release();
|
|
|
|
}
|
2014-11-22 05:36:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Dispatch event to content (potentially a long-running operation)
|
Bug 1333459 - part2-2: EventStateManager should check if it needs to wait reply from remote content before handling access keys r=smaug
Currently, access key is handled in EventStateManager::PreHandleEvent() with eKeyPress event, i.e., before dispatching it into the DOM tree, if the access key is registered in EventStateManager. So, the main process does not check if the preceding eKeyDown event is consumed in focused remote process.
When preceding eKeyDown event is consumed in the main process, eKeyPress event won't be dispatched by widget. However, if remote process has focus, it's impossible widget to stop dispatching eKeyPress event because preceding eKeyDown event hasn't been handled in the focused remote process yet. Therefore, main process needs to post eKeyPress event to check if preceding eKeyDown event was consumed. When eKeyPress event is marked as "waiting reply from remote process", TabChild sends it back to the main process only when preceding eKeyDown event wasn't consumed. So, only when eKeyPress event is back to the main process, main process should handle accesskey with it.
This patch makes EventStateManager::PreHandleEvent() check if a remote target has focus before handling accesskey. If a remote process has accesskey and there is an accesskey matching with eKeyPress event, it marks the event as "waiting reply from remote content" and stop propagation in the process.
Finally, when eKeyPress event is sent back to TabParent, TabParent::RecvReplyKeyEvent() calls EventStateManager::HandleAccessKey() before dispatching the reply event into the DOM tree.
MozReview-Commit-ID: KsOkakaIVzb
--HG--
extra : rebase_source : 7e0c6966a1bde085e34d45bca4b0166b9fc2f3f1
2017-07-22 04:50:41 +03:00
|
|
|
nsEventStatus status = DispatchWidgetEventViaAPZ(localEvent);
|
2012-09-15 05:16:32 +04:00
|
|
|
|
2015-06-04 23:51:10 +03:00
|
|
|
if (!AsyncPanZoomEnabled()) {
|
2015-10-31 05:20:58 +03:00
|
|
|
// We shouldn't have any e10s platforms that have touch events enabled
|
|
|
|
// without APZ.
|
|
|
|
MOZ_ASSERT(false);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-12-20 13:11:01 +04:00
|
|
|
}
|
|
|
|
|
2015-10-31 05:22:28 +03:00
|
|
|
mAPZEventState->ProcessTouchEvent(localEvent, aGuid, aInputBlockId,
|
2020-09-09 22:57:36 +03:00
|
|
|
aApzResponse, status,
|
|
|
|
std::move(allowedTouchBehaviors));
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-07-16 06:58:43 +04:00
|
|
|
}
|
2011-06-22 04:32:43 +04:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvNormalPriorityRealTouchEvent(
|
2017-07-28 10:14:54 +03:00
|
|
|
const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse) {
|
|
|
|
return RecvRealTouchEvent(aEvent, aGuid, aInputBlockId, aApzResponse);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvRealTouchMoveEvent(
|
2014-10-24 21:29:30 +04:00
|
|
|
const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
|
2015-05-14 15:16:00 +03:00
|
|
|
const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse) {
|
2016-11-15 06:26:00 +03:00
|
|
|
if (!RecvRealTouchEvent(aEvent, aGuid, aInputBlockId, aApzResponse)) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2012-08-22 14:54:20 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvNormalPriorityRealTouchMoveEvent(
|
2017-07-28 10:14:54 +03:00
|
|
|
const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
|
|
|
|
const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse) {
|
|
|
|
return RecvRealTouchMoveEvent(aEvent, aGuid, aInputBlockId, aApzResponse);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvRealDragEvent(
|
2015-04-08 21:48:11 +03:00
|
|
|
const WidgetDragEvent& aEvent, const uint32_t& aDragAction,
|
2019-08-20 15:43:02 +03:00
|
|
|
const uint32_t& aDropEffect, nsIPrincipal* aPrincipal,
|
|
|
|
nsIContentSecurityPolicy* aCsp) {
|
2015-04-08 21:48:11 +03:00
|
|
|
WidgetDragEvent localEvent(aEvent);
|
2016-04-14 11:03:14 +03:00
|
|
|
localEvent.mWidget = mPuppetWidget;
|
2015-04-08 21:48:11 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
|
|
|
|
if (dragSession) {
|
|
|
|
dragSession->SetDragAction(aDragAction);
|
2019-01-04 06:16:46 +03:00
|
|
|
dragSession->SetTriggeringPrincipal(aPrincipal);
|
2019-08-20 15:43:02 +03:00
|
|
|
dragSession->SetCsp(aCsp);
|
2018-03-13 23:23:59 +03:00
|
|
|
RefPtr<DataTransfer> initialDataTransfer = dragSession->GetDataTransfer();
|
2015-04-08 21:48:11 +03:00
|
|
|
if (initialDataTransfer) {
|
|
|
|
initialDataTransfer->SetDropEffectInt(aDropEffect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-02 09:08:01 +03:00
|
|
|
if (aEvent.mMessage == eDrop) {
|
2015-04-08 21:48:11 +03:00
|
|
|
bool canDrop = true;
|
|
|
|
if (!dragSession || NS_FAILED(dragSession->GetCanDrop(&canDrop)) ||
|
|
|
|
!canDrop) {
|
2015-09-02 09:08:02 +03:00
|
|
|
localEvent.mMessage = eDragExit;
|
2015-04-08 21:48:11 +03:00
|
|
|
}
|
2015-09-02 09:08:02 +03:00
|
|
|
} else if (aEvent.mMessage == eDragOver) {
|
2015-04-08 21:48:11 +03:00
|
|
|
nsCOMPtr<nsIDragService> dragService =
|
|
|
|
do_GetService("@mozilla.org/widget/dragservice;1");
|
|
|
|
if (dragService) {
|
|
|
|
// This will dispatch 'drag' event at the source if the
|
|
|
|
// drag transaction started in this process.
|
2017-02-17 06:29:42 +03:00
|
|
|
dragService->FireDragEventAtSource(eDrag, aEvent.mModifiers);
|
2015-04-08 21:48:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Bug 1333459 - part2-2: EventStateManager should check if it needs to wait reply from remote content before handling access keys r=smaug
Currently, access key is handled in EventStateManager::PreHandleEvent() with eKeyPress event, i.e., before dispatching it into the DOM tree, if the access key is registered in EventStateManager. So, the main process does not check if the preceding eKeyDown event is consumed in focused remote process.
When preceding eKeyDown event is consumed in the main process, eKeyPress event won't be dispatched by widget. However, if remote process has focus, it's impossible widget to stop dispatching eKeyPress event because preceding eKeyDown event hasn't been handled in the focused remote process yet. Therefore, main process needs to post eKeyPress event to check if preceding eKeyDown event was consumed. When eKeyPress event is marked as "waiting reply from remote process", TabChild sends it back to the main process only when preceding eKeyDown event wasn't consumed. So, only when eKeyPress event is back to the main process, main process should handle accesskey with it.
This patch makes EventStateManager::PreHandleEvent() check if a remote target has focus before handling accesskey. If a remote process has accesskey and there is an accesskey matching with eKeyPress event, it marks the event as "waiting reply from remote content" and stop propagation in the process.
Finally, when eKeyPress event is sent back to TabParent, TabParent::RecvReplyKeyEvent() calls EventStateManager::HandleAccessKey() before dispatching the reply event into the DOM tree.
MozReview-Commit-ID: KsOkakaIVzb
--HG--
extra : rebase_source : 7e0c6966a1bde085e34d45bca4b0166b9fc2f3f1
2017-07-22 04:50:41 +03:00
|
|
|
DispatchWidgetEventViaAPZ(localEvent);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-04-08 21:48:11 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::RequestEditCommands(nsIWidget::NativeKeyBindingsType aType,
|
|
|
|
const WidgetKeyboardEvent& aEvent,
|
|
|
|
nsTArray<CommandInt>& aCommands) {
|
2017-05-19 11:49:41 +03:00
|
|
|
MOZ_ASSERT(aCommands.IsEmpty());
|
|
|
|
|
|
|
|
if (NS_WARN_IF(aEvent.IsEditCommandsInitialized(aType))) {
|
2020-04-30 12:37:05 +03:00
|
|
|
aCommands = aEvent.EditCommandsConstRef(aType).Clone();
|
2017-05-19 11:49:41 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aType) {
|
|
|
|
case nsIWidget::NativeKeyBindingsForSingleLineEditor:
|
|
|
|
case nsIWidget::NativeKeyBindingsForMultiLineEditor:
|
|
|
|
case nsIWidget::NativeKeyBindingsForRichTextEditor:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Invalid native key bindings type");
|
2014-04-22 00:40:09 +04:00
|
|
|
}
|
2017-05-19 12:46:02 +03:00
|
|
|
|
2017-07-05 12:59:44 +03:00
|
|
|
// Don't send aEvent to the parent process directly because it'll be marked
|
|
|
|
// as posted to remote process.
|
|
|
|
WidgetKeyboardEvent localEvent(aEvent);
|
|
|
|
SendRequestNativeKeyBindings(aType, localEvent, &aCommands);
|
2014-04-22 00:40:09 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvNativeSynthesisResponse(
|
2015-04-14 18:36:36 +03:00
|
|
|
const uint64_t& aObserverId, const nsCString& aResponse) {
|
2017-01-19 11:57:20 +03:00
|
|
|
mozilla::widget::AutoObserverNotifier::NotifySavedObserver(aObserverId,
|
|
|
|
aResponse.get());
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-04-14 18:36:36 +03:00
|
|
|
}
|
|
|
|
|
2019-05-04 13:42:52 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvFlushTabState(
|
2019-05-22 12:06:14 +03:00
|
|
|
const uint32_t& aFlushId, const bool& aIsFinal) {
|
|
|
|
UpdateSessionStore(aFlushId, aIsFinal);
|
2019-05-04 13:42:52 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-07-11 12:46:14 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvUpdateEpoch(const uint32_t& aEpoch) {
|
|
|
|
mSessionStoreListener->SetEpoch(aEpoch);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2020-03-19 17:31:52 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvUpdateSHistory(
|
|
|
|
const bool& aImmediately) {
|
|
|
|
if (mSessionStoreListener) {
|
|
|
|
mSessionStoreListener->UpdateSHistoryChanges(aImmediately);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-01-16 12:29:37 +03:00
|
|
|
// In case handling repeated keys takes much time, we skip firing new ones.
|
2019-04-10 01:39:01 +03:00
|
|
|
bool BrowserChild::SkipRepeatedKeyEvent(const WidgetKeyboardEvent& aEvent) {
|
2017-01-16 12:29:37 +03:00
|
|
|
if (mRepeatedKeyEventTime.IsNull() || !aEvent.CanSkipInRemoteProcess() ||
|
|
|
|
(aEvent.mMessage != eKeyDown && aEvent.mMessage != eKeyPress)) {
|
|
|
|
mRepeatedKeyEventTime = TimeStamp();
|
|
|
|
mSkipKeyPress = false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((aEvent.mMessage == eKeyDown &&
|
|
|
|
(mRepeatedKeyEventTime > aEvent.mTimeStamp)) ||
|
|
|
|
(mSkipKeyPress && (aEvent.mMessage == eKeyPress))) {
|
|
|
|
// If we skip a keydown event, also the following keypress events should be
|
|
|
|
// skipped.
|
|
|
|
mSkipKeyPress |= aEvent.mMessage == eKeyDown;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aEvent.mMessage == eKeyDown) {
|
|
|
|
// If keydown wasn't skipped, nor should the possible following keypress.
|
|
|
|
mRepeatedKeyEventTime = TimeStamp();
|
|
|
|
mSkipKeyPress = false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::UpdateRepeatedKeyEventEndTime(
|
2017-01-16 12:29:37 +03:00
|
|
|
const WidgetKeyboardEvent& aEvent) {
|
|
|
|
if (aEvent.mIsRepeat &&
|
|
|
|
(aEvent.mMessage == eKeyDown || aEvent.mMessage == eKeyPress)) {
|
|
|
|
mRepeatedKeyEventTime = TimeStamp::Now();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvRealKeyEvent(
|
2017-05-19 11:24:20 +03:00
|
|
|
const WidgetKeyboardEvent& aEvent) {
|
2017-01-19 11:27:15 +03:00
|
|
|
if (SkipRepeatedKeyEvent(aEvent)) {
|
2017-01-16 12:29:37 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-05-19 11:24:20 +03:00
|
|
|
MOZ_ASSERT(
|
|
|
|
aEvent.mMessage != eKeyPress || aEvent.AreAllEditCommandsInitialized(),
|
|
|
|
"eKeyPress event should have native key binding information");
|
2014-04-22 00:40:09 +04:00
|
|
|
|
2017-05-19 11:24:20 +03:00
|
|
|
// If content code called preventDefault() on a keydown event, then we don't
|
|
|
|
// want to process any following keypress events.
|
|
|
|
if (aEvent.mMessage == eKeyPress && mIgnoreKeyPressEvent) {
|
|
|
|
return IPC_OK();
|
2014-03-20 19:46:29 +04:00
|
|
|
}
|
2014-03-12 07:13:38 +04:00
|
|
|
|
2017-01-19 11:27:15 +03:00
|
|
|
WidgetKeyboardEvent localEvent(aEvent);
|
2016-04-14 11:03:14 +03:00
|
|
|
localEvent.mWidget = mPuppetWidget;
|
2017-05-16 05:59:35 +03:00
|
|
|
localEvent.mUniqueId = aEvent.mUniqueId;
|
Bug 1333459 - part2-2: EventStateManager should check if it needs to wait reply from remote content before handling access keys r=smaug
Currently, access key is handled in EventStateManager::PreHandleEvent() with eKeyPress event, i.e., before dispatching it into the DOM tree, if the access key is registered in EventStateManager. So, the main process does not check if the preceding eKeyDown event is consumed in focused remote process.
When preceding eKeyDown event is consumed in the main process, eKeyPress event won't be dispatched by widget. However, if remote process has focus, it's impossible widget to stop dispatching eKeyPress event because preceding eKeyDown event hasn't been handled in the focused remote process yet. Therefore, main process needs to post eKeyPress event to check if preceding eKeyDown event was consumed. When eKeyPress event is marked as "waiting reply from remote process", TabChild sends it back to the main process only when preceding eKeyDown event wasn't consumed. So, only when eKeyPress event is back to the main process, main process should handle accesskey with it.
This patch makes EventStateManager::PreHandleEvent() check if a remote target has focus before handling accesskey. If a remote process has accesskey and there is an accesskey matching with eKeyPress event, it marks the event as "waiting reply from remote content" and stop propagation in the process.
Finally, when eKeyPress event is sent back to TabParent, TabParent::RecvReplyKeyEvent() calls EventStateManager::HandleAccessKey() before dispatching the reply event into the DOM tree.
MozReview-Commit-ID: KsOkakaIVzb
--HG--
extra : rebase_source : 7e0c6966a1bde085e34d45bca4b0166b9fc2f3f1
2017-07-22 04:50:41 +03:00
|
|
|
nsEventStatus status = DispatchWidgetEventViaAPZ(localEvent);
|
2014-03-12 07:13:38 +04:00
|
|
|
|
2017-01-16 12:29:37 +03:00
|
|
|
// Update the end time of the possible repeated event so that we can skip
|
|
|
|
// some incoming events in case event handling took long time.
|
|
|
|
UpdateRepeatedKeyEventEndTime(localEvent);
|
|
|
|
|
2017-01-19 11:27:15 +03:00
|
|
|
if (aEvent.mMessage == eKeyDown) {
|
2014-03-12 07:13:38 +04:00
|
|
|
mIgnoreKeyPressEvent = status == nsEventStatus_eConsumeNoDefault;
|
|
|
|
}
|
|
|
|
|
2016-11-21 14:55:00 +03:00
|
|
|
if (localEvent.mFlags.mIsSuppressedOrDelayed) {
|
|
|
|
localEvent.PreventDefault();
|
|
|
|
}
|
|
|
|
|
2016-05-11 15:56:42 +03:00
|
|
|
// If a response is desired from the content process, resend the key event.
|
Bug 1333459 - part2-2: EventStateManager should check if it needs to wait reply from remote content before handling access keys r=smaug
Currently, access key is handled in EventStateManager::PreHandleEvent() with eKeyPress event, i.e., before dispatching it into the DOM tree, if the access key is registered in EventStateManager. So, the main process does not check if the preceding eKeyDown event is consumed in focused remote process.
When preceding eKeyDown event is consumed in the main process, eKeyPress event won't be dispatched by widget. However, if remote process has focus, it's impossible widget to stop dispatching eKeyPress event because preceding eKeyDown event hasn't been handled in the focused remote process yet. Therefore, main process needs to post eKeyPress event to check if preceding eKeyDown event was consumed. When eKeyPress event is marked as "waiting reply from remote process", TabChild sends it back to the main process only when preceding eKeyDown event wasn't consumed. So, only when eKeyPress event is back to the main process, main process should handle accesskey with it.
This patch makes EventStateManager::PreHandleEvent() check if a remote target has focus before handling accesskey. If a remote process has accesskey and there is an accesskey matching with eKeyPress event, it marks the event as "waiting reply from remote content" and stop propagation in the process.
Finally, when eKeyPress event is sent back to TabParent, TabParent::RecvReplyKeyEvent() calls EventStateManager::HandleAccessKey() before dispatching the reply event into the DOM tree.
MozReview-Commit-ID: KsOkakaIVzb
--HG--
extra : rebase_source : 7e0c6966a1bde085e34d45bca4b0166b9fc2f3f1
2017-07-22 04:50:41 +03:00
|
|
|
if (aEvent.WantReplyFromContentProcess()) {
|
|
|
|
// If the event's default isn't prevented but the status is no default,
|
|
|
|
// That means that the event was consumed by EventStateManager or something
|
|
|
|
// which is not a usual event handler. In such case, prevent its default
|
|
|
|
// as a default handler. For example, when an eKeyPress event matches
|
|
|
|
// with a content accesskey, and it's executed, peventDefault() of the
|
|
|
|
// event won't be called but the status is set to "no default". Then,
|
|
|
|
// the event shouldn't be handled by nsMenuBarListener in the main process.
|
|
|
|
if (!localEvent.DefaultPrevented() &&
|
|
|
|
status == nsEventStatus_eConsumeNoDefault) {
|
|
|
|
localEvent.PreventDefault();
|
|
|
|
}
|
Bug 1435717 - Make calling WidgetEvent::PreventDefault*() stop cross process forwarding too r=smaug
Currently, if an event is consumed in the main process, EventStateManager
does not send it to remote process. However, this is unexpected behavior
for some WidgetKeyboardEvent dispatchers. OS sometimes has consumed native
key events before sending applications. For example, Alt key on Windows
should activate menu bar of focused window but Alt key may be consumed before
focused window receives the event. In such case, we mark Alt keyboard event
as "consumed before dispatch", and chrome treat it like as its preventDefault()
is called in web content. (Note that for compatibility with other browsers,
the consumed state is not exposed to web content. So, Event.defaultPrevented
returns false in web content.)
Therefore, we need to treat "consumed" state and "cross process forwarding"
state separately. This patch makes calling WidgetEvent::PreventDefault()
always stops cross process forwarding for backward compatibility. Additionally,
for the special case mentioned above, this patch makes
WidgetEvent::PreventDefaultBeforeDispatch() take additional argument,
|aIfStopCrossProcessForwarding|. If this is CrossProcessForwarding::eStop,
the event won't be sent to remote process as same as calling PreventDefault().
Otherwise, CrossProcessForwarding::eHold, PreventDefaultBeforeDispatch() call
does not change "cross process forwarding" state. I.e., if the event's
StopCrossProcessForwarding() and PreventDefault() are not called until
EventStateManager::PostHandleEvent(), the event will be sent to remote process
as usual.
MozReview-Commit-ID: IQGWJvXetxV
--HG--
extra : rebase_source : 4ccdd500e80b8fe29e469ac3b85578e1c07c8358
2018-06-25 12:17:18 +03:00
|
|
|
// This is an ugly hack, mNoRemoteProcessDispatch is set to true when the
|
|
|
|
// event's PreventDefault() or StopScrollProcessForwarding() is called.
|
|
|
|
// And then, it'll be checked by ParamTraits<mozilla::WidgetEvent>::Write()
|
|
|
|
// whether the event is being sent to remote process unexpectedly.
|
|
|
|
// However, unfortunately, it cannot check the destination. Therefore,
|
|
|
|
// we need to clear the flag explicitly here because ParamTraits should
|
|
|
|
// keep checking the flag for avoiding regression.
|
|
|
|
localEvent.mFlags.mNoRemoteProcessDispatch = false;
|
2014-03-18 19:16:47 +04:00
|
|
|
SendReplyKeyEvent(localEvent);
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-06-22 04:32:43 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvNormalPriorityRealKeyEvent(
|
2017-07-28 10:14:54 +03:00
|
|
|
const WidgetKeyboardEvent& aEvent) {
|
|
|
|
return RecvRealKeyEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvCompositionEvent(
|
2017-01-19 11:27:15 +03:00
|
|
|
const WidgetCompositionEvent& aEvent) {
|
|
|
|
WidgetCompositionEvent localEvent(aEvent);
|
2016-04-14 11:03:14 +03:00
|
|
|
localEvent.mWidget = mPuppetWidget;
|
Bug 1333459 - part2-2: EventStateManager should check if it needs to wait reply from remote content before handling access keys r=smaug
Currently, access key is handled in EventStateManager::PreHandleEvent() with eKeyPress event, i.e., before dispatching it into the DOM tree, if the access key is registered in EventStateManager. So, the main process does not check if the preceding eKeyDown event is consumed in focused remote process.
When preceding eKeyDown event is consumed in the main process, eKeyPress event won't be dispatched by widget. However, if remote process has focus, it's impossible widget to stop dispatching eKeyPress event because preceding eKeyDown event hasn't been handled in the focused remote process yet. Therefore, main process needs to post eKeyPress event to check if preceding eKeyDown event was consumed. When eKeyPress event is marked as "waiting reply from remote process", TabChild sends it back to the main process only when preceding eKeyDown event wasn't consumed. So, only when eKeyPress event is back to the main process, main process should handle accesskey with it.
This patch makes EventStateManager::PreHandleEvent() check if a remote target has focus before handling accesskey. If a remote process has accesskey and there is an accesskey matching with eKeyPress event, it marks the event as "waiting reply from remote content" and stop propagation in the process.
Finally, when eKeyPress event is sent back to TabParent, TabParent::RecvReplyKeyEvent() calls EventStateManager::HandleAccessKey() before dispatching the reply event into the DOM tree.
MozReview-Commit-ID: KsOkakaIVzb
--HG--
extra : rebase_source : 7e0c6966a1bde085e34d45bca4b0166b9fc2f3f1
2017-07-22 04:50:41 +03:00
|
|
|
DispatchWidgetEventViaAPZ(localEvent);
|
2017-01-19 11:27:15 +03:00
|
|
|
Unused << SendOnEventNeedingAckHandled(aEvent.mMessage);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-08-17 12:07:42 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvNormalPriorityCompositionEvent(
|
2017-09-29 16:03:25 +03:00
|
|
|
const WidgetCompositionEvent& aEvent) {
|
|
|
|
return RecvCompositionEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvSelectionEvent(
|
2017-01-19 11:27:15 +03:00
|
|
|
const WidgetSelectionEvent& aEvent) {
|
|
|
|
WidgetSelectionEvent localEvent(aEvent);
|
2016-04-14 11:03:14 +03:00
|
|
|
localEvent.mWidget = mPuppetWidget;
|
Bug 1333459 - part2-2: EventStateManager should check if it needs to wait reply from remote content before handling access keys r=smaug
Currently, access key is handled in EventStateManager::PreHandleEvent() with eKeyPress event, i.e., before dispatching it into the DOM tree, if the access key is registered in EventStateManager. So, the main process does not check if the preceding eKeyDown event is consumed in focused remote process.
When preceding eKeyDown event is consumed in the main process, eKeyPress event won't be dispatched by widget. However, if remote process has focus, it's impossible widget to stop dispatching eKeyPress event because preceding eKeyDown event hasn't been handled in the focused remote process yet. Therefore, main process needs to post eKeyPress event to check if preceding eKeyDown event was consumed. When eKeyPress event is marked as "waiting reply from remote process", TabChild sends it back to the main process only when preceding eKeyDown event wasn't consumed. So, only when eKeyPress event is back to the main process, main process should handle accesskey with it.
This patch makes EventStateManager::PreHandleEvent() check if a remote target has focus before handling accesskey. If a remote process has accesskey and there is an accesskey matching with eKeyPress event, it marks the event as "waiting reply from remote content" and stop propagation in the process.
Finally, when eKeyPress event is sent back to TabParent, TabParent::RecvReplyKeyEvent() calls EventStateManager::HandleAccessKey() before dispatching the reply event into the DOM tree.
MozReview-Commit-ID: KsOkakaIVzb
--HG--
extra : rebase_source : 7e0c6966a1bde085e34d45bca4b0166b9fc2f3f1
2017-07-22 04:50:41 +03:00
|
|
|
DispatchWidgetEventViaAPZ(localEvent);
|
2017-01-19 11:27:15 +03:00
|
|
|
Unused << SendOnEventNeedingAckHandled(aEvent.mMessage);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-08-17 12:07:42 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvNormalPrioritySelectionEvent(
|
2017-09-29 16:03:25 +03:00
|
|
|
const WidgetSelectionEvent& aEvent) {
|
|
|
|
return RecvSelectionEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvPasteTransferable(
|
2016-08-31 04:30:45 +03:00
|
|
|
const IPCDataTransfer& aDataTransfer, const bool& aIsPrivateData,
|
2020-12-16 14:36:47 +03:00
|
|
|
nsIPrincipal* aRequestingPrincipal,
|
|
|
|
const nsContentPolicyType& aContentPolicyType) {
|
2016-08-31 04:30:45 +03:00
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsITransferable> trans =
|
|
|
|
do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
2016-08-31 04:30:45 +03:00
|
|
|
trans->Init(nullptr);
|
|
|
|
|
|
|
|
rv = nsContentUtils::IPCTransferableToTransferable(
|
|
|
|
aDataTransfer, aIsPrivateData, aRequestingPrincipal, aContentPolicyType,
|
|
|
|
trans, nullptr, this);
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
2016-08-31 04:30:45 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> ourDocShell = do_GetInterface(WebNavigation());
|
|
|
|
if (NS_WARN_IF(!ourDocShell)) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-08-31 04:30:45 +03:00
|
|
|
}
|
|
|
|
|
2018-07-10 14:04:21 +03:00
|
|
|
RefPtr<nsCommandParams> params = new nsCommandParams();
|
|
|
|
rv = params->SetISupports("transferable", trans);
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
2016-08-31 04:30:45 +03:00
|
|
|
|
|
|
|
ourDocShell->DoCommandWithParams("cmd_pasteTransferable", params);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-08-31 04:30:45 +03:00
|
|
|
}
|
|
|
|
|
2019-12-02 09:25:40 +03:00
|
|
|
#ifdef ACCESSIBILITY
|
2019-04-10 01:39:01 +03:00
|
|
|
a11y::PDocAccessibleChild* BrowserChild::AllocPDocAccessibleChild(
|
2016-12-02 02:28:54 +03:00
|
|
|
PDocAccessibleChild*, const uint64_t&, const uint32_t&,
|
|
|
|
const IAccessibleHolder&) {
|
2015-05-21 20:04:58 +03:00
|
|
|
MOZ_ASSERT(false, "should never call this!");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
bool BrowserChild::DeallocPDocAccessibleChild(
|
|
|
|
a11y::PDocAccessibleChild* aChild) {
|
2015-05-21 20:04:58 +03:00
|
|
|
delete static_cast<mozilla::a11y::DocAccessibleChild*>(aChild);
|
|
|
|
return true;
|
|
|
|
}
|
2019-12-02 09:25:40 +03:00
|
|
|
#endif
|
2015-05-21 20:04:58 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
PColorPickerChild* BrowserChild::AllocPColorPickerChild(const nsString&,
|
|
|
|
const nsString&) {
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("unused");
|
2014-02-24 00:19:43 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
bool BrowserChild::DeallocPColorPickerChild(PColorPickerChild* aColorPicker) {
|
2014-02-24 00:19:43 +04:00
|
|
|
nsColorPickerProxy* picker = static_cast<nsColorPickerProxy*>(aColorPicker);
|
|
|
|
NS_RELEASE(picker);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
PFilePickerChild* BrowserChild::AllocPFilePickerChild(const nsString&,
|
|
|
|
const int16_t&) {
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("unused");
|
2014-02-18 04:30:06 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
bool BrowserChild::DeallocPFilePickerChild(PFilePickerChild* actor) {
|
2014-02-18 04:30:06 +04:00
|
|
|
nsFilePickerProxy* filePicker = static_cast<nsFilePickerProxy*>(actor);
|
|
|
|
NS_RELEASE(filePicker);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Bug 1645528 - Connect nsRefreshDrivers in content processes with a widget-local vsync source r=mattwoodrow,emilio
To allow `requestAnimationFrame()` and similar things to run at monitor
speed if there is only a window-specific vsyncsource available.
This is the case for Wayland and, in the future, EGL/X11. Other backends
may opt for window specific vsyncsources as well at some point.
The idea is to, instead of using global vsync objects, expose a vsyncsource
from nsWindow and use it for refresh drivers. For the content process, move
VsyncChild to BrowserChild, so for each Browserchild there is only one
VsyncChild to which all refresh drivers connect.
IPC in managed either by PBrowser or PBackground. Right now, PBrowser is
only used on Wayland, as both PBrowser and the Wayland vsyncsource run
on the main thread. Other backends keep using the background thread for
now.
While at it, make it so that we constantly update the refresh rate. This
is necessary for Wayland, but also on other platforms variable refresh rates
are increasingly common. Do that by transimitting the vsync rate `SendNotify()`.
How to test:
- run the Wayland backend
- enable `widget.wayland_vsync.enabled`
- optionally: disable `privacy.reduceTimerPrecision`
- run `vsynctester.com` or `testufo.com`
Expected results:
Instead of fixed 60Hz, things should update at monitor refresh rate -
e.g. 144Hz
Original patch by Kenny Levinsen.
Depends on D98254
Differential Revision: https://phabricator.services.mozilla.com/D93173
2020-12-02 12:47:53 +03:00
|
|
|
PVsyncChild* BrowserChild::AllocPVsyncChild() {
|
|
|
|
RefPtr<dom::VsyncChild> actor = new VsyncChild();
|
|
|
|
// There still has one ref-count after return, and it will be released in
|
|
|
|
// DeallocPVsyncChild().
|
|
|
|
return actor.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BrowserChild::DeallocPVsyncChild(PVsyncChild* aActor) {
|
|
|
|
MOZ_ASSERT(aActor);
|
|
|
|
|
|
|
|
// This actor already has one ref-count. Please check AllocPVsyncChild().
|
|
|
|
RefPtr<VsyncChild> actor = dont_AddRef(static_cast<VsyncChild*>(aActor));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-12-27 02:26:49 +03:00
|
|
|
RefPtr<VsyncChild> BrowserChild::GetVsyncChild() {
|
|
|
|
// Initializing mVsyncChild here turns on per-BrowserChild Vsync for a
|
|
|
|
// given platform. Note: this only makes sense if nsWindow returns a
|
|
|
|
// window-specific VsyncSource.
|
|
|
|
#if defined(MOZ_WAYLAND)
|
|
|
|
if (!IsWaylandDisabled() && !mVsyncChild) {
|
|
|
|
PVsyncChild* actor = SendPVsyncConstructor();
|
|
|
|
mVsyncChild = static_cast<VsyncChild*>(actor);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return mVsyncChild;
|
|
|
|
}
|
Bug 1645528 - Connect nsRefreshDrivers in content processes with a widget-local vsync source r=mattwoodrow,emilio
To allow `requestAnimationFrame()` and similar things to run at monitor
speed if there is only a window-specific vsyncsource available.
This is the case for Wayland and, in the future, EGL/X11. Other backends
may opt for window specific vsyncsources as well at some point.
The idea is to, instead of using global vsync objects, expose a vsyncsource
from nsWindow and use it for refresh drivers. For the content process, move
VsyncChild to BrowserChild, so for each Browserchild there is only one
VsyncChild to which all refresh drivers connect.
IPC in managed either by PBrowser or PBackground. Right now, PBrowser is
only used on Wayland, as both PBrowser and the Wayland vsyncsource run
on the main thread. Other backends keep using the background thread for
now.
While at it, make it so that we constantly update the refresh rate. This
is necessary for Wayland, but also on other platforms variable refresh rates
are increasingly common. Do that by transimitting the vsync rate `SendNotify()`.
How to test:
- run the Wayland backend
- enable `widget.wayland_vsync.enabled`
- optionally: disable `privacy.reduceTimerPrecision`
- run `vsynctester.com` or `testufo.com`
Expected results:
Instead of fixed 60Hz, things should update at monitor refresh rate -
e.g. 144Hz
Original patch by Kenny Levinsen.
Depends on D98254
Differential Revision: https://phabricator.services.mozilla.com/D93173
2020-12-02 12:47:53 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvActivateFrameEvent(
|
|
|
|
const nsString& aType, const bool& capture) {
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(WebNavigation());
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(window, IPC_OK());
|
2018-08-13 12:05:19 +03:00
|
|
|
nsCOMPtr<EventTarget> chromeHandler = window->GetChromeEventHandler();
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(chromeHandler, IPC_OK());
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ContentListener> listener = new ContentListener(this);
|
2009-11-17 17:22:23 +03:00
|
|
|
chromeHandler->AddEventListener(aType, listener, capture);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2009-11-17 17:22:23 +03:00
|
|
|
}
|
2010-02-20 20:05:20 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvLoadRemoteScript(
|
2013-11-24 09:32:45 +04:00
|
|
|
const nsString& aURL, const bool& aRunInGlobalScope) {
|
2019-04-10 01:39:01 +03:00
|
|
|
if (!InitBrowserChildMessageManager())
|
2011-08-09 23:38:26 +04:00
|
|
|
// This can happen if we're half-destroyed. It's not a fatal
|
|
|
|
// error.
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-08-24 21:01:28 +04:00
|
|
|
|
2018-08-11 00:03:18 +03:00
|
|
|
JS::Rooted<JSObject*> mm(RootingCx(),
|
2019-04-10 01:39:01 +03:00
|
|
|
mBrowserChildMessageManager->GetOrCreateWrapper());
|
2018-08-11 00:03:18 +03:00
|
|
|
if (!mm) {
|
2017-07-19 15:59:02 +03:00
|
|
|
// This can happen if we're half-destroyed. It's not a fatal error.
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2018-08-14 03:43:24 +03:00
|
|
|
|
2018-08-11 00:03:18 +03:00
|
|
|
LoadScriptInternal(mm, aURL, !aRunInGlobalScope);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-02-20 20:05:20 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvAsyncMessage(
|
2020-04-21 17:07:57 +03:00
|
|
|
const nsString& aMessage, const ClonedMessageData& aData) {
|
2019-04-10 01:39:01 +03:00
|
|
|
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING("BrowserChild::RecvAsyncMessage",
|
2018-05-19 00:36:30 +03:00
|
|
|
OTHER, aMessage);
|
2019-04-10 01:39:01 +03:00
|
|
|
MMPrinter::Print("BrowserChild::RecvAsyncMessage", aMessage, aData);
|
2017-03-30 00:43:21 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
if (!mBrowserChildMessageManager) {
|
2017-01-18 03:28:39 +03:00
|
|
|
return IPC_OK();
|
2010-02-20 20:05:20 +03:00
|
|
|
}
|
2017-01-18 03:28:39 +03:00
|
|
|
|
2018-08-11 00:03:18 +03:00
|
|
|
RefPtr<nsFrameMessageManager> mm =
|
2019-04-10 01:39:01 +03:00
|
|
|
mBrowserChildMessageManager->GetMessageManager();
|
2017-07-19 15:59:02 +03:00
|
|
|
|
2017-01-18 03:28:39 +03:00
|
|
|
// We should have a message manager if the global is alive, but it
|
|
|
|
// seems sometimes we don't. Assert in aurora/nightly, but don't
|
|
|
|
// crash in release builds.
|
2017-07-19 15:59:02 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mm);
|
|
|
|
if (!mm) {
|
2017-01-18 03:28:39 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
JS::Rooted<JSObject*> kungFuDeathGrip(
|
|
|
|
dom::RootingCx(), mBrowserChildMessageManager->GetWrapper());
|
2017-01-18 03:28:39 +03:00
|
|
|
StructuredCloneData data;
|
|
|
|
UnpackClonedMessageDataForChild(aData, data);
|
2019-04-10 01:39:01 +03:00
|
|
|
mm->ReceiveMessage(static_cast<EventTarget*>(mBrowserChildMessageManager),
|
2020-04-21 17:07:57 +03:00
|
|
|
nullptr, aMessage, false, &data, nullptr, IgnoreErrors());
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-02-20 20:05:20 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvSwappedWithOtherRemoteLoader(
|
2016-04-29 01:04:52 +03:00
|
|
|
const IPCTabContext& aContext) {
|
2015-05-07 18:43:40 +03:00
|
|
|
nsCOMPtr<nsIDocShell> ourDocShell = do_GetInterface(WebNavigation());
|
|
|
|
if (NS_WARN_IF(!ourDocShell)) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-05-07 18:43:40 +03:00
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> ourWindow = ourDocShell->GetWindow();
|
2015-05-07 18:43:40 +03:00
|
|
|
if (NS_WARN_IF(!ourWindow)) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-05-07 18:43:40 +03:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsDocShell> docShell = static_cast<nsDocShell*>(ourDocShell.get());
|
2015-08-06 17:03:24 +03:00
|
|
|
|
2018-08-16 06:06:49 +03:00
|
|
|
nsCOMPtr<EventTarget> ourEventTarget = nsGlobalWindowOuter::Cast(ourWindow);
|
2015-05-07 18:43:40 +03:00
|
|
|
|
2015-08-06 17:03:24 +03:00
|
|
|
docShell->SetInFrameSwap(true);
|
|
|
|
|
2019-09-23 13:16:44 +03:00
|
|
|
nsContentUtils::FirePageShowEventForFrameLoaderSwap(
|
|
|
|
ourDocShell, ourEventTarget, false, true);
|
|
|
|
nsContentUtils::FirePageHideEventForFrameLoaderSwap(ourDocShell,
|
|
|
|
ourEventTarget, true);
|
2016-04-29 01:04:52 +03:00
|
|
|
|
|
|
|
// Owner content type may have changed, so store the possibly updated context
|
|
|
|
// and notify others.
|
|
|
|
MaybeInvalidTabContext maybeContext(aContext);
|
|
|
|
if (!maybeContext.IsValid()) {
|
|
|
|
NS_ERROR(nsPrintfCString("Received an invalid TabContext from "
|
|
|
|
"the parent process. (%s)",
|
|
|
|
maybeContext.GetInvalidReason())
|
|
|
|
.get());
|
|
|
|
MOZ_CRASH("Invalid TabContext received from the parent process.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!UpdateTabContextAfterSwap(maybeContext.GetTabContext())) {
|
|
|
|
MOZ_CRASH("Update to TabContext after swap was denied.");
|
|
|
|
}
|
2016-05-16 06:07:09 +03:00
|
|
|
|
2016-04-29 01:04:52 +03:00
|
|
|
// Ignore previous value of mTriedBrowserInit since owner content has changed.
|
|
|
|
mTriedBrowserInit = true;
|
|
|
|
|
2019-09-23 13:16:44 +03:00
|
|
|
nsContentUtils::FirePageShowEventForFrameLoaderSwap(
|
|
|
|
ourDocShell, ourEventTarget, true, true);
|
2015-08-06 17:03:24 +03:00
|
|
|
|
|
|
|
docShell->SetInFrameSwap(false);
|
|
|
|
|
2019-09-23 13:16:44 +03:00
|
|
|
// This is needed to get visibility state right in cases when we swapped a
|
|
|
|
// visible tab (foreground in visible window) with a non-visible tab.
|
|
|
|
if (RefPtr<Document> doc = docShell->GetDocument()) {
|
|
|
|
doc->UpdateVisibilityState();
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-05-07 18:43:40 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvHandleAccessKey(
|
2016-05-11 15:56:42 +03:00
|
|
|
const WidgetKeyboardEvent& aEvent, nsTArray<uint32_t>&& aCharCodes) {
|
2019-04-13 04:53:10 +03:00
|
|
|
nsCOMPtr<Document> document(GetTopLevelDocument());
|
2018-02-21 01:00:10 +03:00
|
|
|
RefPtr<nsPresContext> pc = document->GetPresContext();
|
|
|
|
if (pc) {
|
|
|
|
if (!pc->EventStateManager()->HandleAccessKey(
|
|
|
|
&(const_cast<WidgetKeyboardEvent&>(aEvent)), pc, aCharCodes)) {
|
|
|
|
// If no accesskey was found, inform the parent so that accesskeys on
|
|
|
|
// menus can be handled.
|
|
|
|
WidgetKeyboardEvent localEvent(aEvent);
|
|
|
|
localEvent.mWidget = mPuppetWidget;
|
|
|
|
SendAccessKeyNotHandled(localEvent);
|
2015-09-18 15:19:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-09-18 15:19:13 +03:00
|
|
|
}
|
|
|
|
|
2020-09-01 14:00:36 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvPrintPreview(
|
|
|
|
const PrintData& aPrintData,
|
|
|
|
const mozilla::Maybe<uint64_t>& aSourceOuterWindowID,
|
|
|
|
PrintPreviewResolver&& aCallback) {
|
|
|
|
#ifdef NS_PRINTING
|
|
|
|
// If we didn't succeed in passing off ownership of aCallback, then something
|
|
|
|
// went wrong.
|
|
|
|
auto sendCallbackError = MakeScopeExit([&] {
|
|
|
|
if (aCallback) {
|
2020-12-10 13:52:41 +03:00
|
|
|
aCallback(
|
|
|
|
PrintPreviewResultInfo(0, 0, false, false, false)); // signal error
|
2020-09-01 14:00:36 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
RefPtr<nsGlobalWindowOuter> sourceWindow;
|
|
|
|
if (aSourceOuterWindowID) {
|
|
|
|
sourceWindow =
|
|
|
|
nsGlobalWindowOuter::GetOuterWindowWithId(aSourceOuterWindowID.value());
|
|
|
|
if (NS_WARN_IF(!sourceWindow)) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> ourWindow = do_GetInterface(WebNavigation());
|
|
|
|
if (NS_WARN_IF(!ourWindow)) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
sourceWindow = nsGlobalWindowOuter::Cast(ourWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<nsIPrintSettings> printSettings;
|
|
|
|
nsCOMPtr<nsIPrintSettingsService> printSettingsSvc =
|
|
|
|
do_GetService("@mozilla.org/gfx/printsettings-service;1");
|
|
|
|
if (NS_WARN_IF(!printSettingsSvc)) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
printSettingsSvc->GetNewPrintSettings(getter_AddRefs(printSettings));
|
|
|
|
if (NS_WARN_IF(!printSettings)) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
printSettingsSvc->DeserializeToPrintSettings(aPrintData, printSettings);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> docShellToCloneInto;
|
|
|
|
if (aSourceOuterWindowID) {
|
|
|
|
docShellToCloneInto = do_GetInterface(WebNavigation());
|
|
|
|
if (NS_WARN_IF(!docShellToCloneInto)) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceWindow->Print(printSettings,
|
|
|
|
/* aListener = */ nullptr, docShellToCloneInto,
|
2020-09-03 20:03:06 +03:00
|
|
|
nsGlobalWindowOuter::IsPreview::Yes,
|
2020-10-09 17:59:46 +03:00
|
|
|
nsGlobalWindowOuter::IsForWindowDotPrint::No,
|
2020-09-03 20:03:06 +03:00
|
|
|
std::move(aCallback), IgnoreErrors());
|
2020-09-01 14:00:36 +03:00
|
|
|
#endif
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvExitPrintPreview() {
|
|
|
|
#ifdef NS_PRINTING
|
|
|
|
nsCOMPtr<nsIWebBrowserPrint> webBrowserPrint =
|
|
|
|
do_GetInterface(ToSupports(WebNavigation()));
|
|
|
|
if (NS_WARN_IF(!webBrowserPrint)) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
webBrowserPrint->ExitPrintPreview();
|
|
|
|
#endif
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvPrint(const uint64_t& aOuterWindowID,
|
|
|
|
const PrintData& aPrintData) {
|
2016-05-16 12:40:54 +03:00
|
|
|
#ifdef NS_PRINTING
|
Bug 1636728 - Centralize printing entry points in nsGlobalWindowOuter, and move cloning out of nsPrintJob. r=jwatt,geckoview-reviewers,smaug,agi
This centralizes our print and preview setup in nsGlobalWindowOuter so
that we never re-clone a clone, and so that we reuse the window.open()
codepath to create the browsing context to clone into.
For window.print, for both old print dialog / silent printing and new
print preview UI, we now create a hidden browser (as in with visibility:
collapse, which takes no space but still gets a layout box).
* In the modern UI case, this browser is swapped with the actual print
preview clone, and the UI takes care of removing the browser.
* In the print dialog / silent printing case, the printing code calls
window.close() from nsDocumentViewer::OnDonePrinting().
* We don't need to care about the old print preview UI for this case
because it can't be open from window.print().
We need to fall back to an actual window when there's no
nsIBrowserDOMWindow around for WPT print tests and the like, which don't
have one. That seems fine, we could special-case this code path more if
needed but it doesn't seem worth it.
Differential Revision: https://phabricator.services.mozilla.com/D87063
2020-08-25 20:45:12 +03:00
|
|
|
RefPtr<nsGlobalWindowOuter> outerWindow =
|
2017-11-06 21:09:35 +03:00
|
|
|
nsGlobalWindowOuter::GetOuterWindowWithId(aOuterWindowID);
|
2016-05-25 09:41:54 +03:00
|
|
|
if (NS_WARN_IF(!outerWindow)) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-05-25 09:41:54 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 12:40:54 +03:00
|
|
|
nsCOMPtr<nsIPrintSettingsService> printSettingsSvc =
|
|
|
|
do_GetService("@mozilla.org/gfx/printsettings-service;1");
|
|
|
|
if (NS_WARN_IF(!printSettingsSvc)) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-05-16 12:40:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrintSettings> printSettings;
|
|
|
|
nsresult rv =
|
|
|
|
printSettingsSvc->GetNewPrintSettings(getter_AddRefs(printSettings));
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-05-16 12:40:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrintSession> printSession =
|
|
|
|
do_CreateInstance("@mozilla.org/gfx/printsession;1", &rv);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-05-16 12:40:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
printSettings->SetPrintSession(printSession);
|
|
|
|
printSettingsSvc->DeserializeToPrintSettings(aPrintData, printSettings);
|
Bug 1636728 - Centralize printing entry points in nsGlobalWindowOuter, and move cloning out of nsPrintJob. r=jwatt,geckoview-reviewers,smaug,agi
This centralizes our print and preview setup in nsGlobalWindowOuter so
that we never re-clone a clone, and so that we reuse the window.open()
codepath to create the browsing context to clone into.
For window.print, for both old print dialog / silent printing and new
print preview UI, we now create a hidden browser (as in with visibility:
collapse, which takes no space but still gets a layout box).
* In the modern UI case, this browser is swapped with the actual print
preview clone, and the UI takes care of removing the browser.
* In the print dialog / silent printing case, the printing code calls
window.close() from nsDocumentViewer::OnDonePrinting().
* We don't need to care about the old print preview UI for this case
because it can't be open from window.print().
We need to fall back to an actual window when there's no
nsIBrowserDOMWindow around for WPT print tests and the like, which don't
have one. That seems fine, we could special-case this code path more if
needed but it doesn't seem worth it.
Differential Revision: https://phabricator.services.mozilla.com/D87063
2020-08-25 20:45:12 +03:00
|
|
|
{
|
|
|
|
IgnoredErrorResult rv;
|
|
|
|
outerWindow->Print(printSettings,
|
|
|
|
/* aListener = */ nullptr,
|
|
|
|
/* aWindowToCloneInto = */ nullptr,
|
2020-09-03 20:03:06 +03:00
|
|
|
nsGlobalWindowOuter::IsPreview::No,
|
2020-10-09 17:59:46 +03:00
|
|
|
nsGlobalWindowOuter::IsForWindowDotPrint::No,
|
2020-09-01 14:00:36 +03:00
|
|
|
/* aPrintPreviewCallback = */ nullptr, rv);
|
Bug 1636728 - Centralize printing entry points in nsGlobalWindowOuter, and move cloning out of nsPrintJob. r=jwatt,geckoview-reviewers,smaug,agi
This centralizes our print and preview setup in nsGlobalWindowOuter so
that we never re-clone a clone, and so that we reuse the window.open()
codepath to create the browsing context to clone into.
For window.print, for both old print dialog / silent printing and new
print preview UI, we now create a hidden browser (as in with visibility:
collapse, which takes no space but still gets a layout box).
* In the modern UI case, this browser is swapped with the actual print
preview clone, and the UI takes care of removing the browser.
* In the print dialog / silent printing case, the printing code calls
window.close() from nsDocumentViewer::OnDonePrinting().
* We don't need to care about the old print preview UI for this case
because it can't be open from window.print().
We need to fall back to an actual window when there's no
nsIBrowserDOMWindow around for WPT print tests and the like, which don't
have one. That seems fine, we could special-case this code path more if
needed but it doesn't seem worth it.
Differential Revision: https://phabricator.services.mozilla.com/D87063
2020-08-25 20:45:12 +03:00
|
|
|
if (NS_WARN_IF(rv.Failed())) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2016-05-16 12:40:54 +03:00
|
|
|
}
|
|
|
|
#endif
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-05-16 12:40:54 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvUpdateNativeWindowHandle(
|
2016-09-15 22:37:04 +03:00
|
|
|
const uintptr_t& aNewHandle) {
|
|
|
|
#if defined(XP_WIN) && defined(ACCESSIBILITY)
|
|
|
|
mNativeWindowHandle = aNewHandle;
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-09-15 22:37:04 +03:00
|
|
|
#else
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2016-09-15 22:37:04 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvDestroy() {
|
2014-08-24 11:16:32 +04:00
|
|
|
MOZ_ASSERT(mDestroyed == false);
|
|
|
|
mDestroyed = true;
|
|
|
|
|
2015-11-09 03:55:08 +03:00
|
|
|
nsTArray<PContentPermissionRequestChild*> childArray =
|
|
|
|
nsContentPermissionUtils::GetContentPermissionRequestChildById(
|
|
|
|
GetTabId());
|
|
|
|
|
|
|
|
// Need to close undeleted ContentPermissionRequestChilds before tab is
|
|
|
|
// closed.
|
|
|
|
for (auto& permissionRequestChild : childArray) {
|
|
|
|
auto child = static_cast<RemotePermissionRequest*>(permissionRequestChild);
|
|
|
|
child->Destroy();
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
if (mBrowserChildMessageManager) {
|
2015-02-27 08:35:26 +03:00
|
|
|
// Message handlers are called from the event loop, so it better be safe to
|
|
|
|
// run script.
|
|
|
|
MOZ_ASSERT(nsContentUtils::IsSafeToRunScript());
|
2019-04-10 01:39:01 +03:00
|
|
|
mBrowserChildMessageManager->DispatchTrustedEvent(u"unload"_ns);
|
2011-08-09 23:38:26 +04:00
|
|
|
}
|
2010-08-06 02:11:23 +04:00
|
|
|
|
2012-09-29 06:18:18 +04:00
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
2013-10-21 16:58:12 +04:00
|
|
|
mozilla::services::GetObserverService();
|
2012-09-29 06:18:18 +04:00
|
|
|
|
|
|
|
observerService->RemoveObserver(this, BEFORE_FIRST_PAINT);
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
// XXX what other code in ~BrowserChild() should we be running here?
|
2010-08-21 03:24:40 +04:00
|
|
|
DestroyWindow();
|
2010-08-06 02:11:23 +04:00
|
|
|
|
2014-07-11 22:15:10 +04:00
|
|
|
// Bounce through the event loop once to allow any delayed teardown runnables
|
|
|
|
// that were just generated to have a chance to run.
|
|
|
|
nsCOMPtr<nsIRunnable> deleteRunnable = new DelayedDeleteRunnable(this);
|
2016-03-28 20:28:15 +03:00
|
|
|
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToCurrentThread(deleteRunnable));
|
2014-07-11 22:15:10 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-08-06 02:11:23 +04:00
|
|
|
}
|
2010-02-20 20:05:20 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvRenderLayers(
|
2019-09-27 01:11:17 +03:00
|
|
|
const bool& aEnabled, const layers::LayersObserverEpoch& aEpoch) {
|
2018-01-09 01:53:09 +03:00
|
|
|
if (mPendingDocShellBlockers > 0) {
|
|
|
|
mPendingRenderLayersReceivedMessage = true;
|
|
|
|
mPendingRenderLayers = aEnabled;
|
2018-07-30 16:24:50 +03:00
|
|
|
mPendingLayersObserverEpoch = aEpoch;
|
2018-01-09 01:53:09 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-11-03 17:27:05 +03:00
|
|
|
// Since requests to change the rendering state come in from both the hang
|
|
|
|
// monitor channel and the PContent channel, we have an ordering problem. This
|
|
|
|
// code ensures that we respect the order in which the requests were made and
|
|
|
|
// ignore stale requests.
|
2018-07-30 16:24:50 +03:00
|
|
|
if (mLayersObserverEpoch >= aEpoch) {
|
2017-11-03 17:27:05 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
2018-07-30 16:24:50 +03:00
|
|
|
mLayersObserverEpoch = aEpoch;
|
2017-11-03 17:27:05 +03:00
|
|
|
|
2018-05-15 09:45:00 +03:00
|
|
|
auto clearPaintWhileInterruptingJS = MakeScopeExit([&] {
|
2016-10-21 21:56:46 +03:00
|
|
|
// We might force a paint, or we might already have painted and this is a
|
|
|
|
// no-op. In either case, once we exit this scope, we need to alert the
|
|
|
|
// ProcessHangMonitor that we've finished responding to what might have
|
|
|
|
// been a request to force paint. This is so that the BackgroundHangMonitor
|
|
|
|
// for force painting can be made to wait again.
|
2017-11-03 17:27:05 +03:00
|
|
|
if (aEnabled) {
|
2018-07-30 16:24:50 +03:00
|
|
|
ProcessHangMonitor::ClearPaintWhileInterruptingJS(mLayersObserverEpoch);
|
2016-10-21 21:56:46 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-18 21:44:19 +03:00
|
|
|
if (aEnabled) {
|
2018-05-15 09:45:00 +03:00
|
|
|
ProcessHangMonitor::MaybeStartPaintWhileInterruptingJS();
|
2018-03-18 21:44:19 +03:00
|
|
|
}
|
|
|
|
|
2017-01-24 16:03:08 +03:00
|
|
|
if (mCompositorOptions) {
|
|
|
|
MOZ_ASSERT(mPuppetWidget);
|
2017-08-30 22:39:26 +03:00
|
|
|
RefPtr<LayerManager> lm = mPuppetWidget->GetLayerManager();
|
|
|
|
MOZ_ASSERT(lm);
|
2017-01-24 16:03:08 +03:00
|
|
|
|
|
|
|
// We send the current layer observer epoch to the compositor so that
|
2019-04-10 00:38:15 +03:00
|
|
|
// BrowserParent knows whether a layer update notification corresponds to
|
|
|
|
// the latest RecvRenderLayers request that was made.
|
2018-07-30 16:24:50 +03:00
|
|
|
lm->SetLayersObserverEpoch(mLayersObserverEpoch);
|
2017-01-24 16:03:08 +03:00
|
|
|
}
|
2016-07-23 02:36:45 +03:00
|
|
|
|
2019-05-15 23:29:22 +03:00
|
|
|
mRenderLayers = aEnabled;
|
|
|
|
|
2019-09-27 16:11:51 +03:00
|
|
|
if (aEnabled && IsVisible()) {
|
|
|
|
// This request is a no-op.
|
2019-09-27 01:11:17 +03:00
|
|
|
// In this case, we still want a MozLayerTreeReady notification to fire
|
|
|
|
// in the parent (so that it knows that the child has updated its epoch).
|
|
|
|
// PaintWhileInterruptingJSNoOp does that.
|
|
|
|
if (IPCOpen()) {
|
|
|
|
Unused << SendPaintWhileInterruptingJSNoOp(mLayersObserverEpoch);
|
2016-07-23 02:36:45 +03:00
|
|
|
}
|
2019-09-27 16:11:51 +03:00
|
|
|
return IPC_OK();
|
2016-07-23 02:36:45 +03:00
|
|
|
}
|
|
|
|
|
2019-09-27 16:11:51 +03:00
|
|
|
// FIXME(emilio): Probably / maybe this shouldn't be needed? See the comment
|
|
|
|
// in MakeVisible(), having the two separate states is not great.
|
|
|
|
UpdateVisibility();
|
2019-05-15 23:29:22 +03:00
|
|
|
|
2019-09-27 16:11:51 +03:00
|
|
|
if (!aEnabled) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
|
|
|
|
if (!docShell) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
// We don't use BrowserChildBase::GetPresShell() here because that would
|
|
|
|
// create a content viewer if one doesn't exist yet. Creating a content
|
|
|
|
// viewer can cause JS to run, which we want to avoid.
|
|
|
|
// nsIDocShell::GetPresShell returns null if no content viewer exists yet.
|
|
|
|
RefPtr<PresShell> presShell = docShell->GetPresShell();
|
|
|
|
if (!presShell) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsIFrame* root = presShell->GetRootFrame()) {
|
|
|
|
FrameLayerBuilder::InvalidateAllLayersForFrame(
|
|
|
|
nsLayoutUtils::GetDisplayRootFrame(root));
|
|
|
|
root->SchedulePaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
Telemetry::AutoTimer<Telemetry::TABCHILD_PAINT_TIME> timer;
|
|
|
|
// If we need to repaint, let's do that right away. No sense waiting until
|
|
|
|
// we get back to the event loop again. We suppress the display port so
|
|
|
|
// that we only paint what's visible. This ensures that the tab we're
|
|
|
|
// switching to paints as quickly as possible.
|
|
|
|
presShell->SuppressDisplayport(true);
|
|
|
|
if (nsContentUtils::IsSafeToRunScript()) {
|
|
|
|
WebWidget()->PaintNowIfNeeded();
|
|
|
|
} else {
|
|
|
|
RefPtr<nsViewManager> vm = presShell->GetViewManager();
|
|
|
|
if (nsView* view = vm->GetRootView()) {
|
|
|
|
presShell->Paint(view, view->GetBounds(), PaintFlags::PaintLayers);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
presShell->SuppressDisplayport(false);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-02-20 15:26:13 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvNavigateByKey(
|
2015-07-23 17:04:15 +03:00
|
|
|
const bool& aForward, const bool& aForDocumentNavigation) {
|
2020-04-14 12:58:42 +03:00
|
|
|
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
|
|
|
if (!fm) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<Element> result;
|
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(WebNavigation());
|
2015-07-13 13:07:49 +03:00
|
|
|
|
2020-04-14 12:58:42 +03:00
|
|
|
// Move to the first or last document.
|
|
|
|
{
|
2015-07-23 17:04:15 +03:00
|
|
|
uint32_t type =
|
|
|
|
aForward
|
|
|
|
? (aForDocumentNavigation
|
|
|
|
? static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_FIRSTDOC)
|
|
|
|
: static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_ROOT))
|
|
|
|
: (aForDocumentNavigation
|
|
|
|
? static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_LASTDOC)
|
|
|
|
: static_cast<uint32_t>(nsIFocusManager::MOVEFOCUS_LAST));
|
2020-04-14 12:58:42 +03:00
|
|
|
uint32_t flags = nsIFocusManager::FLAG_BYKEY;
|
|
|
|
if (aForward || aForDocumentNavigation) {
|
|
|
|
flags |= nsIFocusManager::FLAG_NOSCROLL;
|
2015-07-23 17:04:15 +03:00
|
|
|
}
|
2020-04-14 12:58:42 +03:00
|
|
|
fm->MoveFocus(window, nullptr, type, flags, getter_AddRefs(result));
|
|
|
|
}
|
2015-07-23 17:04:15 +03:00
|
|
|
|
2020-04-14 12:58:42 +03:00
|
|
|
// No valid root element was found, so move to the first focusable element.
|
|
|
|
if (!result && aForward && !aForDocumentNavigation) {
|
|
|
|
fm->MoveFocus(window, nullptr, nsIFocusManager::MOVEFOCUS_FIRST,
|
|
|
|
nsIFocusManager::FLAG_BYKEY, getter_AddRefs(result));
|
2015-07-13 13:07:49 +03:00
|
|
|
}
|
|
|
|
|
2020-04-14 12:58:42 +03:00
|
|
|
SendRequestFocus(false, CallerType::System);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-07-13 13:07:49 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvHandledWindowedPluginKeyEvent(
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 14:09:37 +03:00
|
|
|
const NativeEventData& aKeyEventData, const bool& aIsConsumed) {
|
|
|
|
if (NS_WARN_IF(!mPuppetWidget)) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 14:09:37 +03:00
|
|
|
}
|
|
|
|
mPuppetWidget->HandledWindowedPluginKeyEvent(aKeyEventData, aIsConsumed);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 14:09:37 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
bool BrowserChild::InitBrowserChildMessageManager() {
|
|
|
|
if (!mBrowserChildMessageManager) {
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(WebNavigation());
|
2012-08-29 19:26:18 +04:00
|
|
|
NS_ENSURE_TRUE(window, false);
|
2018-08-13 12:05:19 +03:00
|
|
|
nsCOMPtr<EventTarget> chromeHandler = window->GetChromeEventHandler();
|
2012-08-29 19:26:18 +04:00
|
|
|
NS_ENSURE_TRUE(chromeHandler, false);
|
2010-02-20 20:05:20 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
RefPtr<BrowserChildMessageManager> scope = mBrowserChildMessageManager =
|
|
|
|
new BrowserChildMessageManager(this);
|
2012-09-29 06:18:18 +04:00
|
|
|
|
2018-08-11 00:03:18 +03:00
|
|
|
MOZ_ALWAYS_TRUE(nsMessageManagerScriptExecutor::Init());
|
2010-02-20 20:05:20 +03:00
|
|
|
|
2012-08-29 19:26:18 +04:00
|
|
|
nsCOMPtr<nsPIWindowRoot> root = do_QueryInterface(chromeHandler);
|
2017-07-19 15:59:02 +03:00
|
|
|
if (NS_WARN_IF(!root)) {
|
2019-04-10 01:39:01 +03:00
|
|
|
mBrowserChildMessageManager = nullptr;
|
2017-07-19 15:59:02 +03:00
|
|
|
return false;
|
|
|
|
}
|
2012-08-29 19:26:18 +04:00
|
|
|
root->SetParentTarget(scope);
|
|
|
|
}
|
2012-06-22 05:17:52 +04:00
|
|
|
|
2016-10-19 04:54:12 +03:00
|
|
|
if (!mTriedBrowserInit) {
|
2012-08-29 19:26:18 +04:00
|
|
|
mTriedBrowserInit = true;
|
2012-06-22 05:17:52 +04:00
|
|
|
}
|
|
|
|
|
2010-02-20 20:05:20 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::InitRenderingState(
|
2015-02-26 16:47:01 +03:00
|
|
|
const TextureFactoryIdentifier& aTextureFactoryIdentifier,
|
2018-03-25 02:06:01 +03:00
|
|
|
const layers::LayersId& aLayersId,
|
2018-11-06 00:03:15 +03:00
|
|
|
const CompositorOptions& aCompositorOptions) {
|
2015-06-17 11:44:50 +03:00
|
|
|
mPuppetWidget->InitIMEState();
|
2010-08-21 03:24:41 +04:00
|
|
|
|
2018-03-25 02:06:01 +03:00
|
|
|
MOZ_ASSERT(aLayersId.IsValid());
|
2014-11-16 21:23:22 +03:00
|
|
|
mTextureFactoryIdentifier = aTextureFactoryIdentifier;
|
2014-08-22 04:16:44 +04:00
|
|
|
|
|
|
|
// Pushing layers transactions directly to a separate
|
|
|
|
// compositor context.
|
2016-03-22 21:08:38 +03:00
|
|
|
PCompositorBridgeChild* compositorChild = CompositorBridgeChild::Get();
|
2014-08-22 04:16:44 +04:00
|
|
|
if (!compositorChild) {
|
2017-10-13 17:32:36 +03:00
|
|
|
mLayersConnected = Some(false);
|
2016-03-22 21:08:38 +03:00
|
|
|
NS_WARNING("failed to get CompositorBridgeChild instance");
|
2016-11-15 01:58:22 +03:00
|
|
|
return;
|
2014-08-22 04:16:44 +04:00
|
|
|
}
|
2010-08-21 03:24:41 +04:00
|
|
|
|
2017-04-10 00:30:27 +03:00
|
|
|
mCompositorOptions = Some(aCompositorOptions);
|
2017-01-13 01:29:41 +03:00
|
|
|
|
2018-03-25 02:06:01 +03:00
|
|
|
if (aLayersId.IsValid()) {
|
2019-04-10 01:39:01 +03:00
|
|
|
StaticMutexAutoLock lock(sBrowserChildrenMutex);
|
2017-04-10 23:42:36 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
if (!sBrowserChildren) {
|
|
|
|
sBrowserChildren = new BrowserChildMap;
|
2017-01-30 18:05:43 +03:00
|
|
|
}
|
2019-04-10 01:39:01 +03:00
|
|
|
MOZ_ASSERT(!sBrowserChildren->Get(uint64_t(aLayersId)));
|
|
|
|
sBrowserChildren->Put(uint64_t(aLayersId), this);
|
2017-01-30 18:05:43 +03:00
|
|
|
mLayersId = aLayersId;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2017-01-30 18:05:43 +03:00
|
|
|
|
2020-11-12 05:22:02 +03:00
|
|
|
// Depending on timing, we might paint too early and fall back to basic
|
|
|
|
// layers. CreateRemoteLayerManager will destroy us if we manage to get a
|
|
|
|
// remote layer manager though, so that's fine.
|
|
|
|
MOZ_ASSERT(!mPuppetWidget->HasLayerManager() ||
|
|
|
|
mPuppetWidget->GetLayerManager()->GetBackendType() ==
|
|
|
|
layers::LayersBackend::LAYERS_BASIC);
|
2017-10-13 17:32:36 +03:00
|
|
|
bool success = false;
|
2017-10-13 17:32:52 +03:00
|
|
|
if (mLayersConnected == Some(true)) {
|
|
|
|
success = CreateRemoteLayerManager(compositorChild);
|
2017-10-13 17:32:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
MOZ_ASSERT(mLayersConnected == Some(true));
|
|
|
|
// Succeeded to create "remote" layer manager
|
2016-12-01 06:02:37 +03:00
|
|
|
ImageBridgeChild::IdentifyCompositorTextureHost(mTextureFactoryIdentifier);
|
|
|
|
gfx::VRManagerChild::IdentifyTextureHost(mTextureFactoryIdentifier);
|
2017-01-31 17:46:32 +03:00
|
|
|
InitAPZState();
|
2017-11-20 19:41:11 +03:00
|
|
|
RefPtr<LayerManager> lm = mPuppetWidget->GetLayerManager();
|
|
|
|
MOZ_ASSERT(lm);
|
2018-07-30 16:24:50 +03:00
|
|
|
lm->SetLayersObserverEpoch(mLayersObserverEpoch);
|
2017-10-13 17:32:36 +03:00
|
|
|
} else {
|
2017-11-01 05:58:10 +03:00
|
|
|
NS_WARNING("Fallback to BasicLayerManager");
|
2017-10-13 17:32:36 +03:00
|
|
|
mLayersConnected = Some(false);
|
2016-11-08 18:42:26 +03:00
|
|
|
}
|
2010-08-21 03:24:41 +04:00
|
|
|
|
2012-08-29 19:26:18 +04:00
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
2013-10-21 16:58:12 +04:00
|
|
|
mozilla::services::GetObserverService();
|
2012-08-29 19:26:18 +04:00
|
|
|
|
|
|
|
if (observerService) {
|
|
|
|
observerService->AddObserver(this, BEFORE_FIRST_PAINT, false);
|
|
|
|
}
|
2010-08-21 03:24:41 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
bool BrowserChild::CreateRemoteLayerManager(
|
2017-10-13 17:32:52 +03:00
|
|
|
mozilla::layers::PCompositorBridgeChild* aCompositorChild) {
|
|
|
|
MOZ_ASSERT(aCompositorChild);
|
|
|
|
|
|
|
|
bool success = false;
|
2017-11-03 10:38:34 +03:00
|
|
|
if (mCompositorOptions->UseWebRender()) {
|
2017-10-13 17:32:52 +03:00
|
|
|
success = mPuppetWidget->CreateRemoteLayerManager(
|
|
|
|
[&](LayerManager* aLayerManager) -> bool {
|
|
|
|
MOZ_ASSERT(aLayerManager->AsWebRenderLayerManager());
|
2020-09-08 05:03:26 +03:00
|
|
|
nsCString error;
|
2017-10-13 17:32:52 +03:00
|
|
|
return aLayerManager->AsWebRenderLayerManager()->Initialize(
|
|
|
|
aCompositorChild, wr::AsPipelineId(mLayersId),
|
2020-09-08 05:03:26 +03:00
|
|
|
&mTextureFactoryIdentifier, error);
|
2017-10-13 17:32:52 +03:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
nsTArray<LayersBackend> ignored;
|
2018-03-25 02:06:01 +03:00
|
|
|
PLayerTransactionChild* shadowManager =
|
|
|
|
aCompositorChild->SendPLayerTransactionConstructor(ignored,
|
|
|
|
GetLayersId());
|
2017-10-13 17:32:52 +03:00
|
|
|
if (shadowManager &&
|
|
|
|
shadowManager->SendGetTextureFactoryIdentifier(
|
|
|
|
&mTextureFactoryIdentifier) &&
|
|
|
|
mTextureFactoryIdentifier.mParentBackend !=
|
|
|
|
LayersBackend::LAYERS_NONE) {
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
if (!success) {
|
2017-11-01 05:58:10 +03:00
|
|
|
// Since no LayerManager is associated with the tab's widget, we will
|
|
|
|
// never have an opportunity to destroy the PLayerTransaction on the next
|
|
|
|
// device or compositor reset. Therefore, we make sure to forcefully close
|
|
|
|
// it here. Failure to do so will cause the next layer tree to fail to
|
|
|
|
// attach due since the compositor requires the old layer tree to be
|
|
|
|
// disassociated.
|
|
|
|
if (shadowManager) {
|
|
|
|
static_cast<LayerTransactionChild*>(shadowManager)->Destroy();
|
|
|
|
shadowManager = nullptr;
|
|
|
|
}
|
2017-10-13 17:32:52 +03:00
|
|
|
NS_WARNING("failed to allocate layer transaction");
|
|
|
|
} else {
|
|
|
|
success = mPuppetWidget->CreateRemoteLayerManager(
|
|
|
|
[&](LayerManager* aLayerManager) -> bool {
|
|
|
|
ShadowLayerForwarder* lf = aLayerManager->AsShadowForwarder();
|
|
|
|
lf->SetShadowManager(shadowManager);
|
|
|
|
lf->IdentifyTextureHost(mTextureFactoryIdentifier);
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::InitAPZState() {
|
2017-01-13 01:29:41 +03:00
|
|
|
if (!mCompositorOptions->UseAPZ()) {
|
2016-11-29 07:21:27 +03:00
|
|
|
return;
|
|
|
|
}
|
2017-01-13 01:29:41 +03:00
|
|
|
auto cbc = CompositorBridgeChild::Get();
|
2016-11-29 07:21:27 +03:00
|
|
|
|
|
|
|
// Initialize the ApzcTreeManager. This takes multiple casts because of ugly
|
|
|
|
// multiple inheritance.
|
|
|
|
PAPZCTreeManagerChild* baseProtocol =
|
|
|
|
cbc->SendPAPZCTreeManagerConstructor(mLayersId);
|
|
|
|
APZCTreeManagerChild* derivedProtocol =
|
|
|
|
static_cast<APZCTreeManagerChild*>(baseProtocol);
|
|
|
|
|
|
|
|
mApzcTreeManager = RefPtr<IAPZCTreeManager>(derivedProtocol);
|
|
|
|
|
|
|
|
// Initialize the GeckoContentController for this tab. We don't hold a
|
|
|
|
// reference because we don't need it. The ContentProcessController will hold
|
|
|
|
// a reference to the tab, and will be destroyed by the compositor or ipdl
|
|
|
|
// during destruction.
|
|
|
|
RefPtr<GeckoContentController> contentController =
|
|
|
|
new ContentProcessController(this);
|
2017-03-23 09:16:38 +03:00
|
|
|
APZChild* apzChild = new APZChild(contentController);
|
|
|
|
cbc->SendPAPZConstructor(apzChild, mLayersId);
|
2016-11-29 07:21:27 +03:00
|
|
|
}
|
|
|
|
|
2019-05-15 23:26:25 +03:00
|
|
|
IPCResult BrowserChild::RecvUpdateEffects(const EffectsInfo& aEffects) {
|
2020-03-09 01:19:10 +03:00
|
|
|
bool needInvalidate = false;
|
|
|
|
if (mEffectsInfo.IsVisible() && aEffects.IsVisible() &&
|
|
|
|
mEffectsInfo != aEffects) {
|
|
|
|
// if we are staying visible and either the visrect or scale changed we need
|
|
|
|
// to invalidate
|
|
|
|
needInvalidate = true;
|
|
|
|
}
|
|
|
|
|
2019-05-15 23:26:25 +03:00
|
|
|
mEffectsInfo = aEffects;
|
2019-09-27 16:11:51 +03:00
|
|
|
UpdateVisibility();
|
2020-03-09 01:19:10 +03:00
|
|
|
|
|
|
|
if (needInvalidate) {
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
|
|
|
|
if (docShell) {
|
|
|
|
// We don't use BrowserChildBase::GetPresShell() here because that would
|
|
|
|
// create a content viewer if one doesn't exist yet. Creating a content
|
|
|
|
// viewer can cause JS to run, which we want to avoid.
|
|
|
|
// nsIDocShell::GetPresShell returns null if no content viewer exists yet.
|
|
|
|
RefPtr<PresShell> presShell = docShell->GetPresShell();
|
|
|
|
if (presShell) {
|
|
|
|
if (nsIFrame* root = presShell->GetRootFrame()) {
|
|
|
|
root->InvalidateFrame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-15 23:26:25 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-05-15 23:29:22 +03:00
|
|
|
bool BrowserChild::IsVisible() {
|
|
|
|
return mPuppetWidget && mPuppetWidget->IsVisible();
|
|
|
|
}
|
|
|
|
|
2019-09-27 16:11:51 +03:00
|
|
|
void BrowserChild::UpdateVisibility() {
|
2019-06-11 15:50:40 +03:00
|
|
|
bool shouldBeVisible = mIsTopLevel ? mRenderLayers : mEffectsInfo.IsVisible();
|
2019-05-15 23:29:22 +03:00
|
|
|
bool isVisible = IsVisible();
|
|
|
|
|
|
|
|
if (shouldBeVisible != isVisible) {
|
|
|
|
if (shouldBeVisible) {
|
2019-09-27 16:11:51 +03:00
|
|
|
MakeVisible();
|
2019-05-15 23:29:22 +03:00
|
|
|
} else {
|
|
|
|
MakeHidden();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-27 16:11:51 +03:00
|
|
|
void BrowserChild::MakeVisible() {
|
2017-11-03 17:27:05 +03:00
|
|
|
if (IsVisible()) {
|
2016-07-23 02:36:45 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-17 11:44:50 +03:00
|
|
|
if (mPuppetWidget) {
|
|
|
|
mPuppetWidget->Show(true);
|
2015-05-05 09:32:47 +03:00
|
|
|
}
|
2019-05-15 23:29:22 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
|
|
|
|
if (!docShell) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-12-11 18:43:19 +03:00
|
|
|
// The browser / tab-switcher is responsible of fixing the browsingContext
|
|
|
|
// state up explicitly via SetDocShellIsActive, which propagates to children
|
|
|
|
// automatically.
|
2019-09-27 16:11:51 +03:00
|
|
|
//
|
|
|
|
// We need it not to be observable, as this used via RecvRenderLayers and co.,
|
|
|
|
// for stuff like async tab warming.
|
|
|
|
//
|
|
|
|
// We don't want to go through the docshell because we don't want to change
|
|
|
|
// the visibility state of the document, which has side effects like firing
|
2020-12-11 18:43:19 +03:00
|
|
|
// events to content, unblocking media playback, unthrottling timeouts...
|
|
|
|
if (RefPtr<PresShell> presShell = docShell->GetPresShell()) {
|
|
|
|
presShell->SetIsActive(true);
|
2019-05-15 23:29:22 +03:00
|
|
|
}
|
2012-11-08 07:51:55 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::MakeHidden() {
|
2017-11-03 17:27:05 +03:00
|
|
|
if (!IsVisible()) {
|
2016-07-23 02:36:45 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-11-20 19:41:11 +03:00
|
|
|
// Due to the nested event loop in ContentChild::ProvideWindowCommon,
|
|
|
|
// it's possible to be told to become hidden before we're finished
|
|
|
|
// setting up a layer manager. We should skip clearing cached layers
|
|
|
|
// in that case, since doing so might accidentally put is into
|
|
|
|
// BasicLayers mode.
|
|
|
|
if (mPuppetWidget && mPuppetWidget->HasLayerManager()) {
|
|
|
|
ClearCachedResources();
|
|
|
|
}
|
2015-05-05 09:32:47 +03:00
|
|
|
|
2019-09-27 16:11:51 +03:00
|
|
|
if (nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation())) {
|
2019-04-10 01:39:01 +03:00
|
|
|
// Hide all plugins in this tab. We don't use
|
|
|
|
// BrowserChildBase::GetPresShell() here because that would create a content
|
|
|
|
// viewer if one doesn't exist yet. Creating a content viewer can cause JS
|
|
|
|
// to run, which we want to avoid. nsIDocShell::GetPresShell returns null if
|
|
|
|
// no content viewer exists yet.
|
2019-04-13 04:03:13 +03:00
|
|
|
if (RefPtr<PresShell> presShell = docShell->GetPresShell()) {
|
2017-11-22 00:52:48 +03:00
|
|
|
if (nsPresContext* presContext = presShell->GetPresContext()) {
|
|
|
|
nsRootPresContext* rootPresContext = presContext->GetRootPresContext();
|
2018-03-06 12:25:21 +03:00
|
|
|
nsIFrame* rootFrame = presShell->GetRootFrame();
|
2017-11-22 00:52:48 +03:00
|
|
|
rootPresContext->ComputePluginGeometryUpdates(rootFrame, nullptr,
|
|
|
|
nullptr);
|
|
|
|
rootPresContext->ApplyPluginGeometryUpdates();
|
|
|
|
}
|
2020-12-11 18:43:19 +03:00
|
|
|
presShell->SetIsActive(false);
|
2017-11-22 00:52:48 +03:00
|
|
|
}
|
2020-12-11 18:43:19 +03:00
|
|
|
}
|
|
|
|
|
2015-06-17 11:44:50 +03:00
|
|
|
if (mPuppetWidget) {
|
|
|
|
mPuppetWidget->Show(false);
|
2015-05-05 09:32:47 +03:00
|
|
|
}
|
2012-11-08 07:51:55 +04:00
|
|
|
}
|
|
|
|
|
2012-05-28 13:27:25 +04:00
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::GetMessageManager(ContentFrameMessageManager** aResult) {
|
|
|
|
RefPtr<ContentFrameMessageManager> mm(mBrowserChildMessageManager);
|
2018-03-01 22:19:56 +03:00
|
|
|
mm.forget(aResult);
|
|
|
|
return *aResult ? NS_OK : NS_ERROR_FAILURE;
|
2012-05-28 13:27:25 +04:00
|
|
|
}
|
|
|
|
|
2014-09-03 01:43:08 +04:00
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::GetWebBrowserChrome(nsIWebBrowserChrome3** aWebBrowserChrome) {
|
2020-08-05 00:34:29 +03:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
|
2019-09-20 21:15:18 +03:00
|
|
|
if (nsCOMPtr<nsIWebBrowserChrome3> chrome =
|
2020-08-05 00:34:29 +03:00
|
|
|
do_QueryActor("WebBrowserChrome", docShell->GetDocument())) {
|
2019-09-20 21:15:18 +03:00
|
|
|
chrome.forget(aWebBrowserChrome);
|
|
|
|
} else {
|
|
|
|
// TODO: remove fallback
|
|
|
|
NS_IF_ADDREF(*aWebBrowserChrome = mWebBrowserChrome);
|
|
|
|
}
|
|
|
|
|
2014-09-03 01:43:08 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::SetWebBrowserChrome(nsIWebBrowserChrome3* aWebBrowserChrome) {
|
2014-09-03 01:43:08 +04:00
|
|
|
mWebBrowserChrome = aWebBrowserChrome;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2020-01-16 17:38:40 +03:00
|
|
|
void BrowserChild::SendRequestFocus(bool aCanFocus, CallerType aCallerType) {
|
2020-10-26 17:19:59 +03:00
|
|
|
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
|
|
|
if (!fm) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(WebNavigation());
|
|
|
|
if (!window) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
BrowsingContext* focusedBC = fm->GetFocusedBrowsingContext();
|
|
|
|
if (focusedBC == window->GetBrowsingContext()) {
|
|
|
|
// BrowsingContext has the focus already, do not request again.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-16 17:38:40 +03:00
|
|
|
PBrowserChild::SendRequestFocus(aCanFocus, aCallerType);
|
2013-11-05 18:16:25 +04:00
|
|
|
}
|
|
|
|
|
2015-01-22 12:40:17 +03:00
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::GetTabId(uint64_t* aId) {
|
2015-01-22 12:40:17 +03:00
|
|
|
*aId = GetTabId();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::SetTabId(const TabId& aTabId) {
|
2015-01-30 12:07:12 +03:00
|
|
|
MOZ_ASSERT(mUniqueId == 0);
|
|
|
|
|
|
|
|
mUniqueId = aTabId;
|
2019-04-10 01:39:01 +03:00
|
|
|
NestedBrowserChildMap()[mUniqueId] = this;
|
2015-01-30 12:07:12 +03:00
|
|
|
}
|
|
|
|
|
2020-10-09 20:36:22 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
BrowserChild::GetChromeOuterWindowID(uint64_t* aId) {
|
|
|
|
*aId = ChromeOuterWindowID();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-21 17:07:57 +03:00
|
|
|
bool BrowserChild::DoSendBlockingMessage(
|
|
|
|
const nsAString& aMessage, StructuredCloneData& aData,
|
|
|
|
nsTArray<StructuredCloneData>* aRetVal) {
|
2012-08-02 10:02:29 +04:00
|
|
|
ClonedMessageData data;
|
2015-09-10 23:50:58 +03:00
|
|
|
if (!BuildClonedMessageDataForChild(Manager(), aData, data)) {
|
2013-01-24 06:39:27 +04:00
|
|
|
return false;
|
2012-08-02 10:02:29 +04:00
|
|
|
}
|
2020-04-21 17:07:57 +03:00
|
|
|
return SendSyncMessage(PromiseFlatString(aMessage), data, aRetVal);
|
2010-02-20 20:05:20 +03:00
|
|
|
}
|
|
|
|
|
2020-04-21 17:07:57 +03:00
|
|
|
nsresult BrowserChild::DoSendAsyncMessage(const nsAString& aMessage,
|
|
|
|
StructuredCloneData& aData) {
|
2012-08-02 10:02:29 +04:00
|
|
|
ClonedMessageData data;
|
2015-09-10 23:50:58 +03:00
|
|
|
if (!BuildClonedMessageDataForChild(Manager(), aData, data)) {
|
2015-10-07 13:42:43 +03:00
|
|
|
return NS_ERROR_DOM_DATA_CLONE_ERR;
|
2012-08-02 10:02:29 +04:00
|
|
|
}
|
2020-04-21 17:07:57 +03:00
|
|
|
if (!SendAsyncMessage(PromiseFlatString(aMessage), data)) {
|
2015-10-07 13:42:43 +03:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2013-07-11 02:05:39 +04:00
|
|
|
}
|
2015-10-07 13:42:43 +03:00
|
|
|
return NS_OK;
|
2010-02-20 20:05:20 +03:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* static */
|
2019-04-10 01:39:01 +03:00
|
|
|
nsTArray<RefPtr<BrowserChild>> BrowserChild::GetAll() {
|
|
|
|
StaticMutexAutoLock lock(sBrowserChildrenMutex);
|
2017-04-10 23:42:36 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
nsTArray<RefPtr<BrowserChild>> list;
|
|
|
|
if (!sBrowserChildren) {
|
2016-09-20 11:19:32 +03:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
for (auto iter = sBrowserChildren->Iter(); !iter.Done(); iter.Next()) {
|
2016-09-20 11:19:32 +03:00
|
|
|
list.AppendElement(iter.Data());
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild* BrowserChild::GetFrom(PresShell* aPresShell) {
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* doc = aPresShell->GetDocument();
|
2013-10-03 00:08:30 +04:00
|
|
|
if (!doc) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-11-15 20:32:12 +04:00
|
|
|
nsCOMPtr<nsIDocShell> docShell(doc->GetDocShell());
|
2013-10-03 00:08:30 +04:00
|
|
|
return GetFrom(docShell);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild* BrowserChild::GetFrom(layers::LayersId aLayersId) {
|
|
|
|
StaticMutexAutoLock lock(sBrowserChildrenMutex);
|
|
|
|
if (!sBrowserChildren) {
|
2014-03-07 07:24:32 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
2019-04-10 01:39:01 +03:00
|
|
|
return sBrowserChildren->Get(uint64_t(aLayersId));
|
2014-03-07 07:24:32 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::DidComposite(mozilla::layers::TransactionId aTransactionId,
|
|
|
|
const TimeStamp& aCompositeStart,
|
|
|
|
const TimeStamp& aCompositeEnd) {
|
2015-06-17 11:44:50 +03:00
|
|
|
MOZ_ASSERT(mPuppetWidget);
|
2017-08-30 22:39:26 +03:00
|
|
|
RefPtr<LayerManager> lm = mPuppetWidget->GetLayerManager();
|
|
|
|
MOZ_ASSERT(lm);
|
2015-08-25 08:51:58 +03:00
|
|
|
|
2017-08-30 22:39:26 +03:00
|
|
|
lm->DidComposite(aTransactionId, aCompositeStart, aCompositeEnd);
|
2014-03-07 07:24:32 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::DidRequestComposite(const TimeStamp& aCompositeReqStart,
|
|
|
|
const TimeStamp& aCompositeReqEnd) {
|
2015-10-22 00:10:05 +03:00
|
|
|
nsCOMPtr<nsIDocShell> docShellComPtr = do_GetInterface(WebNavigation());
|
|
|
|
if (!docShellComPtr) {
|
2015-09-11 08:59:53 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:10:05 +03:00
|
|
|
nsDocShell* docShell = static_cast<nsDocShell*>(docShellComPtr.get());
|
|
|
|
RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get();
|
|
|
|
|
|
|
|
if (timelines && timelines->HasConsumer(docShell)) {
|
2016-10-14 22:01:49 +03:00
|
|
|
// Since we're assuming that it's impossible for content JS to directly
|
|
|
|
// trigger a synchronous paint, we can avoid capturing a stack trace here,
|
|
|
|
// which means we won't run into JS engine reentrancy issues like bug
|
|
|
|
// 1310014.
|
2015-10-22 00:10:05 +03:00
|
|
|
timelines->AddMarkerForDocShell(
|
2016-10-14 22:01:49 +03:00
|
|
|
docShell, "CompositeForwardTransaction", aCompositeReqStart,
|
|
|
|
MarkerTracingType::START, MarkerStackRequest::NO_STACK);
|
2015-10-22 00:10:05 +03:00
|
|
|
timelines->AddMarkerForDocShell(docShell, "CompositeForwardTransaction",
|
2016-10-14 22:01:49 +03:00
|
|
|
aCompositeReqEnd, MarkerTracingType::END,
|
|
|
|
MarkerStackRequest::NO_STACK);
|
2015-10-22 00:10:05 +03:00
|
|
|
}
|
2015-09-11 08:59:53 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::ClearCachedResources() {
|
2015-06-17 11:44:50 +03:00
|
|
|
MOZ_ASSERT(mPuppetWidget);
|
2017-08-30 22:39:26 +03:00
|
|
|
RefPtr<LayerManager> lm = mPuppetWidget->GetLayerManager();
|
|
|
|
MOZ_ASSERT(lm);
|
2015-05-05 09:32:47 +03:00
|
|
|
|
2017-08-30 22:39:26 +03:00
|
|
|
lm->ClearCachedResources();
|
2020-08-19 18:24:14 +03:00
|
|
|
|
|
|
|
if (nsCOMPtr<Document> document = GetTopLevelDocument()) {
|
|
|
|
nsPresContext* presContext = document->GetPresContext();
|
|
|
|
if (presContext) {
|
|
|
|
presContext->NotifyPaintStatusReset();
|
|
|
|
}
|
|
|
|
}
|
2015-05-05 09:32:47 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::InvalidateLayers() {
|
2016-02-29 09:53:12 +03:00
|
|
|
MOZ_ASSERT(mPuppetWidget);
|
|
|
|
RefPtr<LayerManager> lm = mPuppetWidget->GetLayerManager();
|
2017-08-30 22:39:26 +03:00
|
|
|
MOZ_ASSERT(lm);
|
|
|
|
|
2016-02-29 09:53:12 +03:00
|
|
|
FrameLayerBuilder::InvalidateAllLayers(lm);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::SchedulePaint() {
|
2018-10-01 04:12:22 +03:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
|
|
|
|
if (!docShell) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
// We don't use BrowserChildBase::GetPresShell() here because that would
|
|
|
|
// create a content viewer if one doesn't exist yet. Creating a content viewer
|
|
|
|
// can cause JS to run, which we want to avoid. nsIDocShell::GetPresShell
|
2018-10-01 04:12:22 +03:00
|
|
|
// returns null if no content viewer exists yet.
|
2019-04-13 04:03:13 +03:00
|
|
|
if (RefPtr<PresShell> presShell = docShell->GetPresShell()) {
|
2018-10-01 04:12:22 +03:00
|
|
|
if (nsIFrame* root = presShell->GetRootFrame()) {
|
|
|
|
root->SchedulePaint();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::ReinitRendering() {
|
2018-03-25 02:06:01 +03:00
|
|
|
MOZ_ASSERT(mLayersId.IsValid());
|
2016-09-20 11:19:32 +03:00
|
|
|
|
|
|
|
// Before we establish a new PLayerTransaction, we must connect our layer tree
|
|
|
|
// id, CompositorBridge, and the widget compositor all together again.
|
2019-04-10 01:39:01 +03:00
|
|
|
// Normally this happens in BrowserParent before BrowserChild is given
|
|
|
|
// rendering information.
|
2016-09-20 11:19:32 +03:00
|
|
|
//
|
2019-04-10 00:38:15 +03:00
|
|
|
// In this case, we will send a sync message to our BrowserParent, which in
|
|
|
|
// turn will send a sync message to the Compositor of the widget owning this
|
|
|
|
// tab. This guarantees the correct association is in place before our
|
2016-09-20 11:19:32 +03:00
|
|
|
// PLayerTransaction constructor message arrives on the cross-process
|
|
|
|
// compositor bridge.
|
2017-01-13 01:29:41 +03:00
|
|
|
CompositorOptions options;
|
2017-04-10 00:31:24 +03:00
|
|
|
SendEnsureLayersConnected(&options);
|
2017-01-13 01:29:41 +03:00
|
|
|
mCompositorOptions = Some(options);
|
|
|
|
|
2017-07-18 16:35:07 +03:00
|
|
|
bool success = false;
|
2017-04-10 00:31:24 +03:00
|
|
|
RefPtr<CompositorBridgeChild> cb = CompositorBridgeChild::Get();
|
2016-09-20 11:19:32 +03:00
|
|
|
|
2017-10-13 17:32:52 +03:00
|
|
|
if (cb) {
|
|
|
|
success = CreateRemoteLayerManager(cb);
|
2017-07-18 16:35:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!success) {
|
|
|
|
NS_WARNING("failed to recreate layer manager");
|
|
|
|
return;
|
2017-04-06 19:56:10 +03:00
|
|
|
}
|
2016-09-20 11:19:32 +03:00
|
|
|
|
2017-10-13 17:32:36 +03:00
|
|
|
mLayersConnected = Some(true);
|
2017-05-12 08:45:16 +03:00
|
|
|
ImageBridgeChild::IdentifyCompositorTextureHost(mTextureFactoryIdentifier);
|
|
|
|
gfx::VRManagerChild::IdentifyTextureHost(mTextureFactoryIdentifier);
|
|
|
|
|
2016-11-29 07:21:27 +03:00
|
|
|
InitAPZState();
|
2018-06-21 16:39:45 +03:00
|
|
|
RefPtr<LayerManager> lm = mPuppetWidget->GetLayerManager();
|
|
|
|
MOZ_ASSERT(lm);
|
2018-07-30 16:24:50 +03:00
|
|
|
lm->SetLayersObserverEpoch(mLayersObserverEpoch);
|
2016-11-08 05:23:12 +03:00
|
|
|
|
2019-04-13 04:53:10 +03:00
|
|
|
nsCOMPtr<Document> doc(GetTopLevelDocument());
|
2016-11-08 05:23:12 +03:00
|
|
|
doc->NotifyLayerManagerRecreated();
|
2016-09-20 11:19:32 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::ReinitRenderingForDeviceReset() {
|
2017-05-12 08:44:27 +03:00
|
|
|
InvalidateLayers();
|
|
|
|
|
|
|
|
RefPtr<LayerManager> lm = mPuppetWidget->GetLayerManager();
|
2017-06-29 21:46:36 +03:00
|
|
|
if (WebRenderLayerManager* wlm = lm->AsWebRenderLayerManager()) {
|
|
|
|
wlm->DoDestroy(/* aIsSync */ true);
|
|
|
|
} else if (ClientLayerManager* clm = lm->AsClientLayerManager()) {
|
|
|
|
if (ShadowLayerForwarder* fwd = clm->AsShadowForwarder()) {
|
|
|
|
// Force the LayerTransactionChild to synchronously shutdown. It is
|
|
|
|
// okay to do this early, we'll simply stop sending messages. This
|
|
|
|
// step is necessary since otherwise the compositor will think we
|
|
|
|
// are trying to attach two layer trees to the same ID.
|
|
|
|
fwd->SynchronouslyShutdown();
|
|
|
|
}
|
|
|
|
} else {
|
2017-11-01 05:58:10 +03:00
|
|
|
if (mLayersConnected.isNothing()) {
|
|
|
|
return;
|
|
|
|
}
|
2017-05-12 08:44:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Proceed with destroying and recreating the layer manager.
|
|
|
|
ReinitRendering();
|
|
|
|
}
|
|
|
|
|
2014-01-23 00:27:23 +04:00
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::OnShowTooltip(int32_t aXCoords, int32_t aYCoords,
|
|
|
|
const nsAString& aTipText,
|
|
|
|
const nsAString& aTipDir) {
|
2014-01-23 00:27:23 +04:00
|
|
|
nsString str(aTipText);
|
2016-04-12 23:47:25 +03:00
|
|
|
nsString dir(aTipDir);
|
|
|
|
SendShowTooltip(aXCoords, aYCoords, str, dir);
|
2014-01-23 00:27:23 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChild::OnHideTooltip() {
|
2014-01-23 00:27:23 +04:00
|
|
|
SendHideTooltip();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-08-02 10:02:29 +04:00
|
|
|
|
2020-07-05 14:45:01 +03:00
|
|
|
void BrowserChild::NotifyJankedAnimations(
|
|
|
|
const nsTArray<uint64_t>& aJankedAnimations) {
|
|
|
|
MOZ_ASSERT(mPuppetWidget);
|
|
|
|
RefPtr<LayerManager> lm = mPuppetWidget->GetLayerManager();
|
|
|
|
MOZ_ASSERT(lm);
|
|
|
|
lm->UpdatePartialPrerenderedAnimations(aJankedAnimations);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvRequestNotifyAfterRemotePaint() {
|
2016-03-22 21:08:38 +03:00
|
|
|
// Get the CompositorBridgeChild instance for this content thread.
|
|
|
|
CompositorBridgeChild* compositor = CompositorBridgeChild::Get();
|
2014-05-23 22:19:00 +04:00
|
|
|
|
2016-03-22 21:08:38 +03:00
|
|
|
// Tell the CompositorBridgeChild that, when it gets a RemotePaintIsReady
|
2014-05-23 22:19:00 +04:00
|
|
|
// message that it should forward it us so that we can bounce it to our
|
2019-04-10 00:38:15 +03:00
|
|
|
// BrowserParent.
|
2014-05-23 22:19:00 +04:00
|
|
|
compositor->RequestNotifyAfterRemotePaint(this);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-05-23 22:19:00 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvUIResolutionChanged(
|
2016-09-27 09:37:07 +03:00
|
|
|
const float& aDpi, const int32_t& aRounding, const double& aScale) {
|
2020-02-25 21:05:57 +03:00
|
|
|
nsCOMPtr<Document> document(GetTopLevelDocument());
|
|
|
|
if (!document) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2015-06-08 08:39:28 +03:00
|
|
|
ScreenIntSize oldScreenSize = GetInnerSize();
|
2017-05-19 13:20:18 +03:00
|
|
|
if (aDpi > 0) {
|
|
|
|
mPuppetWidget->UpdateBackingScaleCache(aDpi, aRounding, aScale);
|
|
|
|
}
|
2018-02-21 01:00:10 +03:00
|
|
|
RefPtr<nsPresContext> presContext = document->GetPresContext();
|
|
|
|
if (presContext) {
|
|
|
|
presContext->UIResolutionChangedSync();
|
2015-04-22 17:58:33 +03:00
|
|
|
}
|
2015-06-08 08:39:28 +03:00
|
|
|
|
|
|
|
ScreenIntSize screenSize = GetInnerSize();
|
|
|
|
if (mHasValidInnerSize && oldScreenSize != screenSize) {
|
|
|
|
ScreenIntRect screenRect = GetOuterRect();
|
|
|
|
|
2020-06-24 16:29:18 +03:00
|
|
|
// See RecvUpdateDimensions for the order of these operations.
|
2015-06-08 08:39:28 +03:00
|
|
|
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
|
|
|
|
baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height,
|
2016-05-12 03:07:45 +03:00
|
|
|
nsIBaseWindow::eRepaint);
|
2020-06-24 16:29:18 +03:00
|
|
|
|
|
|
|
mPuppetWidget->Resize(screenRect.x + mClientOffset.x + mChromeOffset.x,
|
|
|
|
screenRect.y + mClientOffset.y + mChromeOffset.y,
|
|
|
|
screenSize.width, screenSize.height, true);
|
2015-06-08 08:39:28 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-04-22 17:58:33 +03:00
|
|
|
}
|
|
|
|
|
2020-03-04 11:16:31 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvSafeAreaInsetsChanged(
|
|
|
|
const mozilla::ScreenIntMargin& aSafeAreaInsets) {
|
|
|
|
mPuppetWidget->UpdateSafeAreaInsets(aSafeAreaInsets);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScreenManager> screenMgr =
|
|
|
|
do_GetService("@mozilla.org/gfx/screenmanager;1");
|
|
|
|
ScreenIntMargin currentSafeAreaInsets;
|
|
|
|
if (screenMgr) {
|
|
|
|
// aSafeAreaInsets is for current screen. But we have to calculate
|
|
|
|
// safe insets for content window.
|
|
|
|
int32_t x, y, cx, cy;
|
|
|
|
GetDimensions(0, &x, &y, &cx, &cy);
|
|
|
|
nsCOMPtr<nsIScreen> screen;
|
|
|
|
screenMgr->ScreenForRect(x, y, cx, cy, getter_AddRefs(screen));
|
|
|
|
|
|
|
|
if (screen) {
|
|
|
|
LayoutDeviceIntRect windowRect(x + mClientOffset.x + mChromeOffset.x,
|
|
|
|
y + mClientOffset.y + mChromeOffset.y, cx,
|
|
|
|
cy);
|
|
|
|
currentSafeAreaInsets = nsContentUtils::GetWindowSafeAreaInsets(
|
|
|
|
screen, aSafeAreaInsets, windowRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsCOMPtr<Document> document = GetTopLevelDocument()) {
|
|
|
|
nsPresContext* presContext = document->GetPresContext();
|
|
|
|
if (presContext) {
|
|
|
|
presContext->SetSafeAreaInsets(currentSafeAreaInsets);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// https://github.com/w3c/csswg-drafts/issues/4670
|
|
|
|
// Actually we don't set this value on sub document. This behaviour is
|
|
|
|
// same as Blink that safe area insets isn't set on sub document.
|
|
|
|
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvAllowScriptsToClose() {
|
2018-09-15 11:26:33 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(WebNavigation());
|
|
|
|
if (window) {
|
|
|
|
nsGlobalWindowOuter::Cast(window)->AllowScriptsToClose();
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvSetWidgetNativeData(
|
2017-06-13 20:37:31 +03:00
|
|
|
const WindowsHandle& aWidgetNativeData) {
|
|
|
|
mWidgetNativeData = aWidgetNativeData;
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2020-10-27 00:00:50 +03:00
|
|
|
mozilla::ipc::IPCResult BrowserChild::RecvReleaseAllPointerCapture() {
|
|
|
|
PointerEventHandler::ReleaseAllPointerCapture();
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
mozilla::plugins::PPluginWidgetChild* BrowserChild::AllocPPluginWidgetChild() {
|
2017-02-09 19:53:50 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
return new mozilla::plugins::PluginWidgetChild();
|
|
|
|
#else
|
2017-10-25 09:52:56 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("AllocPPluginWidgetChild only supports Windows");
|
2017-02-09 19:53:50 +03:00
|
|
|
return nullptr;
|
|
|
|
#endif
|
2014-11-12 23:59:19 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
bool BrowserChild::DeallocPPluginWidgetChild(
|
2014-11-12 23:59:19 +03:00
|
|
|
mozilla::plugins::PPluginWidgetChild* aActor) {
|
2017-02-09 19:53:50 +03:00
|
|
|
delete aActor;
|
|
|
|
return true;
|
2014-11-12 23:59:19 +03:00
|
|
|
}
|
|
|
|
|
2017-02-09 19:53:50 +03:00
|
|
|
#ifdef XP_WIN
|
2019-04-10 01:39:01 +03:00
|
|
|
nsresult BrowserChild::CreatePluginWidget(nsIWidget* aParent,
|
|
|
|
nsIWidget** aOut) {
|
2015-02-06 00:48:44 +03:00
|
|
|
*aOut = nullptr;
|
2014-11-12 23:59:19 +03:00
|
|
|
mozilla::plugins::PluginWidgetChild* child =
|
|
|
|
static_cast<mozilla::plugins::PluginWidgetChild*>(
|
|
|
|
SendPPluginWidgetConstructor());
|
|
|
|
if (!child) {
|
|
|
|
NS_ERROR("couldn't create PluginWidgetChild");
|
2015-02-06 00:48:44 +03:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2014-11-12 23:59:19 +03:00
|
|
|
}
|
|
|
|
nsCOMPtr<nsIWidget> pluginWidget =
|
|
|
|
nsIWidget::CreatePluginProxyWidget(this, child);
|
|
|
|
if (!pluginWidget) {
|
|
|
|
NS_ERROR("couldn't create PluginWidgetProxy");
|
2015-02-06 00:48:44 +03:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2014-11-12 23:59:19 +03:00
|
|
|
}
|
|
|
|
|
2014-11-12 23:59:20 +03:00
|
|
|
nsWidgetInitData initData;
|
|
|
|
initData.mWindowType = eWindowType_plugin_ipc_content;
|
|
|
|
initData.clipChildren = true;
|
|
|
|
initData.clipSiblings = true;
|
2015-11-16 11:35:18 +03:00
|
|
|
nsresult rv = pluginWidget->Create(
|
|
|
|
aParent, nullptr, LayoutDeviceIntRect(0, 0, 0, 0), &initData);
|
2014-11-12 23:59:19 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("Creating native plugin widget on the chrome side failed.");
|
|
|
|
}
|
2015-02-06 00:48:44 +03:00
|
|
|
pluginWidget.forget(aOut);
|
|
|
|
return rv;
|
2014-11-12 23:59:19 +03:00
|
|
|
}
|
2017-02-09 19:53:50 +03:00
|
|
|
#endif // XP_WIN
|
2014-11-12 23:59:19 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
PPaymentRequestChild* BrowserChild::AllocPPaymentRequestChild() {
|
2017-05-25 20:50:32 +03:00
|
|
|
MOZ_CRASH(
|
|
|
|
"We should never be manually allocating PPaymentRequestChild actors");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
bool BrowserChild::DeallocPPaymentRequestChild(PPaymentRequestChild* actor) {
|
2018-05-31 23:30:29 +03:00
|
|
|
delete actor;
|
2017-05-25 20:50:32 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
ScreenIntSize BrowserChild::GetInnerSize() {
|
2015-06-08 08:39:28 +03:00
|
|
|
LayoutDeviceIntSize innerSize =
|
2015-06-17 11:44:50 +03:00
|
|
|
RoundedToInt(mUnscaledInnerSize * mPuppetWidget->GetDefaultScale());
|
2015-06-08 08:39:28 +03:00
|
|
|
return ViewAs<ScreenPixel>(
|
|
|
|
innerSize, PixelCastJustification::LayoutDeviceIsScreenForTabDims);
|
|
|
|
};
|
|
|
|
|
2020-09-25 12:38:06 +03:00
|
|
|
Maybe<nsRect> BrowserChild::GetVisibleRect() const {
|
2019-06-14 05:45:09 +03:00
|
|
|
if (mIsTopLevel) {
|
|
|
|
// We are conservative about visible rects for top-level browsers to avoid
|
|
|
|
// artifacts when resizing
|
2019-06-25 06:16:31 +03:00
|
|
|
return Nothing();
|
2019-06-11 15:52:12 +03:00
|
|
|
}
|
2020-09-25 12:38:06 +03:00
|
|
|
|
|
|
|
return Some(mEffectsInfo.mVisibleRect);
|
2019-06-11 15:52:12 +03:00
|
|
|
}
|
|
|
|
|
2020-02-11 06:59:14 +03:00
|
|
|
Maybe<LayoutDeviceRect>
|
|
|
|
BrowserChild::GetTopLevelViewportVisibleRectInSelfCoords() const {
|
|
|
|
if (mIsTopLevel) {
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mChildToParentConversionMatrix) {
|
2020-02-12 01:04:01 +03:00
|
|
|
// We have no way to tell this remote document visible rect right now.
|
|
|
|
return Nothing();
|
2020-02-11 06:59:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Maybe<LayoutDeviceToLayoutDeviceMatrix4x4> inverse =
|
|
|
|
mChildToParentConversionMatrix->MaybeInverse();
|
|
|
|
if (!inverse) {
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert the remote document visible rect to the coordinate system of the
|
|
|
|
// iframe document.
|
|
|
|
Maybe<LayoutDeviceRect> rect = UntransformBy(
|
|
|
|
*inverse,
|
|
|
|
ViewAs<LayoutDevicePixel>(
|
|
|
|
mTopLevelViewportVisibleRectInBrowserCoords,
|
|
|
|
PixelCastJustification::ContentProcessIsLayerInUiProcess),
|
|
|
|
LayoutDeviceRect::MaxIntRect());
|
|
|
|
if (!rect) {
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
ScreenIntRect BrowserChild::GetOuterRect() {
|
2015-06-08 08:39:28 +03:00
|
|
|
LayoutDeviceIntRect outerRect =
|
2015-06-17 11:44:50 +03:00
|
|
|
RoundedToInt(mUnscaledOuterRect * mPuppetWidget->GetDefaultScale());
|
2015-06-08 08:39:28 +03:00
|
|
|
return ViewAs<ScreenPixel>(
|
|
|
|
outerRect, PixelCastJustification::LayoutDeviceIsScreenForTabDims);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChild::PaintWhileInterruptingJS(
|
2019-09-27 01:11:17 +03:00
|
|
|
const layers::LayersObserverEpoch& aEpoch) {
|
2017-11-20 19:41:11 +03:00
|
|
|
if (!IPCOpen() || !mPuppetWidget || !mPuppetWidget->HasLayerManager()) {
|
2016-09-21 02:02:37 +03:00
|
|
|
// Don't bother doing anything now. Better to wait until we receive the
|
|
|
|
// message on the PContent channel.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-31 13:29:32 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(nsContentUtils::IsSafeToRunScript());
|
2016-07-23 02:36:45 +03:00
|
|
|
nsAutoScriptBlocker scriptBlocker;
|
2019-09-27 01:11:17 +03:00
|
|
|
RecvRenderLayers(true /* aEnabled */, aEpoch);
|
2016-07-23 02:36:45 +03:00
|
|
|
}
|
|
|
|
|
2019-05-01 02:31:36 +03:00
|
|
|
nsresult BrowserChild::CanCancelContentJS(
|
|
|
|
nsIRemoteTab::NavigationType aNavigationType, int32_t aNavigationIndex,
|
2019-05-01 02:31:46 +03:00
|
|
|
nsIURI* aNavigationURI, int32_t aEpoch, bool* aCanCancel) {
|
2019-05-01 02:31:36 +03:00
|
|
|
nsresult rv;
|
|
|
|
*aCanCancel = false;
|
|
|
|
|
2019-05-01 02:31:46 +03:00
|
|
|
if (aEpoch <= mCancelContentJSEpoch) {
|
|
|
|
// The next page loaded before we got here, so we shouldn't try to cancel
|
|
|
|
// the content JS.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2020-09-16 17:51:01 +03:00
|
|
|
// If we have session history in the parent we've already performed
|
|
|
|
// the checks following, so we can return early.
|
2020-09-28 15:01:12 +03:00
|
|
|
if (mozilla::SessionHistoryInParent()) {
|
2020-09-16 17:51:01 +03:00
|
|
|
*aCanCancel = true;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
|
|
|
|
nsCOMPtr<nsISHistory> history;
|
|
|
|
if (docShell) {
|
|
|
|
history = nsDocShell::Cast(docShell)->GetSessionHistory()->LegacySHistory();
|
|
|
|
}
|
|
|
|
|
2019-05-01 02:31:36 +03:00
|
|
|
if (!history) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t current;
|
|
|
|
rv = history->GetIndex(¤t);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (current == -1) {
|
|
|
|
// This tab has no history! Just return.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsISHEntry> entry;
|
|
|
|
rv = history->GetEntryAtIndex(current, getter_AddRefs(entry));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2019-06-04 19:19:27 +03:00
|
|
|
nsCOMPtr<nsIURI> currentURI = entry->GetURI();
|
|
|
|
if (!currentURI->SchemeIs("http") && !currentURI->SchemeIs("https") &&
|
|
|
|
!currentURI->SchemeIs("file")) {
|
|
|
|
// Only cancel content JS for http(s) and file URIs. Other URIs are probably
|
|
|
|
// internal and we should just let them run to completion.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-01 02:31:36 +03:00
|
|
|
if (aNavigationType == nsIRemoteTab::NAVIGATE_BACK) {
|
|
|
|
aNavigationIndex = current - 1;
|
|
|
|
} else if (aNavigationType == nsIRemoteTab::NAVIGATE_FORWARD) {
|
|
|
|
aNavigationIndex = current + 1;
|
|
|
|
} else if (aNavigationType == nsIRemoteTab::NAVIGATE_URL) {
|
|
|
|
if (!aNavigationURI) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2019-11-08 05:43:00 +03:00
|
|
|
if (aNavigationURI->SchemeIs("javascript")) {
|
|
|
|
// "javascript:" URIs don't (necessarily) trigger navigation to a
|
|
|
|
// different page, so don't allow the current page's JS to terminate.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-06-04 19:19:27 +03:00
|
|
|
// If navigating directly to a URL (e.g. via hitting Enter in the location
|
|
|
|
// bar), then we can cancel anytime the next URL is different from the
|
|
|
|
// current, *excluding* the ref ("#").
|
|
|
|
bool equals;
|
|
|
|
rv = currentURI->EqualsExceptRef(aNavigationURI, &equals);
|
2019-05-01 02:31:36 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2019-06-04 19:19:27 +03:00
|
|
|
*aCanCancel = !equals;
|
2019-05-01 02:31:36 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
// Note: aNavigationType may also be NAVIGATE_INDEX, in which case we don't
|
|
|
|
// need to do anything special.
|
|
|
|
|
|
|
|
int32_t delta = aNavigationIndex > current ? 1 : -1;
|
|
|
|
for (int32_t i = current + delta; i != aNavigationIndex + delta; i += delta) {
|
|
|
|
nsCOMPtr<nsISHEntry> nextEntry;
|
|
|
|
// If `i` happens to be negative, this call will fail (which is what we
|
|
|
|
// would want to happen).
|
|
|
|
rv = history->GetEntryAtIndex(i, getter_AddRefs(nextEntry));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsISHEntry> laterEntry = delta == 1 ? nextEntry : entry;
|
2019-06-04 19:19:27 +03:00
|
|
|
nsCOMPtr<nsIURI> thisURI = entry->GetURI();
|
2019-05-01 02:31:36 +03:00
|
|
|
nsCOMPtr<nsIURI> nextURI = nextEntry->GetURI();
|
|
|
|
|
|
|
|
// If we changed origin and the load wasn't in a subframe, we know it was
|
|
|
|
// a full document load, so we can cancel the content JS safely.
|
|
|
|
if (!laterEntry->GetIsSubFrame()) {
|
2019-06-04 19:19:27 +03:00
|
|
|
nsAutoCString thisHost;
|
|
|
|
rv = thisURI->GetPrePath(thisHost);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsAutoCString nextHost;
|
|
|
|
rv = nextURI->GetPrePath(nextHost);
|
2019-05-01 02:31:36 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2019-06-04 19:19:27 +03:00
|
|
|
|
|
|
|
if (!thisHost.Equals(nextHost)) {
|
|
|
|
*aCanCancel = true;
|
2019-05-01 02:31:36 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
entry = nextEntry;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-23 21:48:18 +03:00
|
|
|
NS_IMETHODIMP BrowserChild::BeginSendingWebProgressEventsToParent() {
|
|
|
|
mShouldSendWebProgressEventsToParent = true;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
nsresult BrowserChild::GetHasSiblings(bool* aHasSiblings) {
|
2018-07-19 21:05:35 +03:00
|
|
|
*aHasSiblings = mHasSiblings;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
nsresult BrowserChild::SetHasSiblings(bool aHasSiblings) {
|
2018-07-19 21:05:35 +03:00
|
|
|
mHasSiblings = aHasSiblings;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-11-04 21:13:52 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMETHODIMP BrowserChild::OnStateChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
uint32_t aStateFlags,
|
|
|
|
nsresult aStatus) {
|
2019-05-23 21:49:08 +03:00
|
|
|
if (!IPCOpen() || !mShouldSendWebProgressEventsToParent) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
|
|
|
|
if (!docShell) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2020-03-17 03:50:29 +03:00
|
|
|
// We shouldn't need to notify the parent of redirect state changes, since
|
|
|
|
// with DocumentChannel that only happens when we switch to the real channel,
|
|
|
|
// and that's an implementation detail that we can hide.
|
|
|
|
if (aStateFlags & nsIWebProgressListener::STATE_IS_REDIRECTED_DOCUMENT) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-23 21:49:08 +03:00
|
|
|
RefPtr<Document> document;
|
|
|
|
if (nsCOMPtr<nsPIDOMWindowOuter> outerWindow = do_GetInterface(docShell)) {
|
|
|
|
document = outerWindow->GetExtantDoc();
|
|
|
|
} else {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
Maybe<WebProgressData> webProgressData;
|
|
|
|
Maybe<WebProgressStateChangeData> stateChangeData;
|
|
|
|
RequestData requestData;
|
|
|
|
|
|
|
|
MOZ_TRY(PrepareProgressListenerData(aWebProgress, aRequest, webProgressData,
|
|
|
|
requestData));
|
|
|
|
|
|
|
|
if (webProgressData->isTopLevel()) {
|
|
|
|
stateChangeData.emplace();
|
|
|
|
|
|
|
|
stateChangeData->isNavigating() = docShell->GetIsNavigating();
|
|
|
|
stateChangeData->mayEnableCharacterEncodingMenu() =
|
|
|
|
docShell->GetMayEnableCharacterEncodingMenu();
|
2019-06-14 00:08:40 +03:00
|
|
|
stateChangeData->charsetAutodetected() = docShell->GetCharsetAutodetected();
|
2019-05-23 21:49:08 +03:00
|
|
|
|
|
|
|
if (document && aStateFlags & nsIWebProgressListener::STATE_STOP) {
|
|
|
|
document->GetContentType(stateChangeData->contentType());
|
|
|
|
document->GetCharacterSet(stateChangeData->charset());
|
|
|
|
stateChangeData->documentURI() = document->GetDocumentURIObject();
|
|
|
|
} else {
|
|
|
|
stateChangeData->contentType().SetIsVoid(true);
|
|
|
|
stateChangeData->charset().SetIsVoid(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Unused << SendOnStateChange(webProgressData, requestData, aStateFlags,
|
|
|
|
aStatus, stateChangeData);
|
|
|
|
|
|
|
|
return NS_OK;
|
2019-01-25 17:44:09 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMETHODIMP BrowserChild::OnProgressChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
int32_t aCurSelfProgress,
|
|
|
|
int32_t aMaxSelfProgress,
|
|
|
|
int32_t aCurTotalProgress,
|
|
|
|
int32_t aMaxTotalProgress) {
|
2019-05-23 21:48:18 +03:00
|
|
|
if (!IPCOpen() || !mShouldSendWebProgressEventsToParent) {
|
2019-04-03 20:32:41 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
Maybe<WebProgressData> webProgressData;
|
|
|
|
RequestData requestData;
|
|
|
|
|
|
|
|
nsresult rv = PrepareProgressListenerData(aWebProgress, aRequest,
|
|
|
|
webProgressData, requestData);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
Unused << SendOnProgressChange(webProgressData, requestData, aCurSelfProgress,
|
|
|
|
aMaxSelfProgress, aCurTotalProgress,
|
|
|
|
aMaxTotalProgress);
|
|
|
|
|
|
|
|
return NS_OK;
|
2019-01-25 17:44:09 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMETHODIMP BrowserChild::OnLocationChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
nsIURI* aLocation,
|
|
|
|
uint32_t aFlags) {
|
2019-06-14 00:08:40 +03:00
|
|
|
if (!IPCOpen() || !mShouldSendWebProgressEventsToParent) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWebNavigation> webNav = WebNavigation();
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(webNav);
|
|
|
|
if (!docShell) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<Document> document;
|
|
|
|
if (nsCOMPtr<nsPIDOMWindowOuter> outerWindow = do_GetInterface(docShell)) {
|
|
|
|
document = outerWindow->GetExtantDoc();
|
|
|
|
} else {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!document) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
Maybe<WebProgressData> webProgressData;
|
|
|
|
RequestData requestData;
|
|
|
|
|
|
|
|
MOZ_TRY(PrepareProgressListenerData(aWebProgress, aRequest, webProgressData,
|
|
|
|
requestData));
|
|
|
|
|
|
|
|
Maybe<WebProgressLocationChangeData> locationChangeData;
|
|
|
|
|
|
|
|
bool canGoBack = false;
|
|
|
|
bool canGoForward = false;
|
|
|
|
|
|
|
|
MOZ_TRY(webNav->GetCanGoBack(&canGoBack));
|
|
|
|
MOZ_TRY(webNav->GetCanGoForward(&canGoForward));
|
|
|
|
|
|
|
|
if (aWebProgress && webProgressData->isTopLevel()) {
|
|
|
|
locationChangeData.emplace();
|
|
|
|
|
|
|
|
document->GetContentType(locationChangeData->contentType());
|
|
|
|
locationChangeData->isNavigating() = docShell->GetIsNavigating();
|
|
|
|
locationChangeData->documentURI() = document->GetDocumentURIObject();
|
|
|
|
document->GetTitle(locationChangeData->title());
|
|
|
|
document->GetCharacterSet(locationChangeData->charset());
|
|
|
|
|
|
|
|
locationChangeData->mayEnableCharacterEncodingMenu() =
|
|
|
|
docShell->GetMayEnableCharacterEncodingMenu();
|
|
|
|
locationChangeData->charsetAutodetected() =
|
|
|
|
docShell->GetCharsetAutodetected();
|
|
|
|
|
2019-08-28 21:56:44 +03:00
|
|
|
locationChangeData->contentPrincipal() = document->NodePrincipal();
|
2020-06-03 09:09:52 +03:00
|
|
|
locationChangeData->contentPartitionedPrincipal() =
|
|
|
|
document->PartitionedPrincipal();
|
2019-08-28 21:56:44 +03:00
|
|
|
locationChangeData->csp() = document->GetCsp();
|
2019-07-29 18:34:30 +03:00
|
|
|
locationChangeData->referrerInfo() = document->ReferrerInfo();
|
2019-06-14 00:08:40 +03:00
|
|
|
locationChangeData->isSyntheticDocument() = document->IsSyntheticDocument();
|
|
|
|
|
|
|
|
if (nsCOMPtr<nsILoadGroup> loadGroup = document->GetDocumentLoadGroup()) {
|
|
|
|
uint64_t requestContextID = 0;
|
|
|
|
MOZ_TRY(loadGroup->GetRequestContextID(&requestContextID));
|
|
|
|
locationChangeData->requestContextID() = Some(requestContextID);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
if (CrashReporter::GetEnabled()) {
|
|
|
|
nsCOMPtr<nsIURI> annotationURI;
|
|
|
|
|
2020-09-23 18:17:15 +03:00
|
|
|
nsresult rv =
|
|
|
|
NS_MutateURI(aLocation).SetUserPass(""_ns).Finalize(annotationURI);
|
2019-06-14 00:08:40 +03:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// Ignore failures on about: URIs.
|
|
|
|
annotationURI = aLocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::URL,
|
|
|
|
annotationURI->GetSpecOrDefault());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
Unused << SendOnLocationChange(webProgressData, requestData, aLocation,
|
|
|
|
aFlags, canGoBack, canGoForward,
|
|
|
|
locationChangeData);
|
|
|
|
|
|
|
|
return NS_OK;
|
2019-01-25 17:44:09 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMETHODIMP BrowserChild::OnStatusChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
nsresult aStatus,
|
|
|
|
const char16_t* aMessage) {
|
2019-05-23 21:48:18 +03:00
|
|
|
if (!IPCOpen() || !mShouldSendWebProgressEventsToParent) {
|
2019-04-03 20:31:54 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
Maybe<WebProgressData> webProgressData;
|
|
|
|
RequestData requestData;
|
|
|
|
|
|
|
|
nsresult rv = PrepareProgressListenerData(aWebProgress, aRequest,
|
|
|
|
webProgressData, requestData);
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
const nsString message(aMessage);
|
|
|
|
|
|
|
|
Unused << SendOnStatusChange(webProgressData, requestData, aStatus, message);
|
|
|
|
|
|
|
|
return NS_OK;
|
2019-01-25 17:44:09 +03:00
|
|
|
}
|
2019-04-03 20:31:54 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMETHODIMP BrowserChild::OnSecurityChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
uint32_t aState) {
|
2020-05-27 03:28:59 +03:00
|
|
|
// Security changes are now handled entirely in the parent process
|
|
|
|
// so we don't need to worry about forwarding them (and we shouldn't
|
|
|
|
// be receiving any to forward).
|
2019-08-28 21:55:45 +03:00
|
|
|
return NS_OK;
|
2019-01-25 17:44:09 +03:00
|
|
|
}
|
2019-08-28 21:55:45 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMETHODIMP BrowserChild::OnContentBlockingEvent(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
uint32_t aEvent) {
|
2020-01-13 17:08:53 +03:00
|
|
|
// The OnContentBlockingEvent only happenes in the parent process. It should
|
|
|
|
// not be seen in the content process.
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(
|
|
|
|
false, "OnContentBlockingEvent should not be seen in content process.");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2019-01-25 17:44:09 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMETHODIMP BrowserChild::OnProgressChange64(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
int64_t aCurSelfProgress,
|
|
|
|
int64_t aMaxSelfProgress,
|
|
|
|
int64_t aCurTotalProgress,
|
|
|
|
int64_t aMaxTotalProgress) {
|
2019-04-03 20:32:41 +03:00
|
|
|
// All the events we receive are filtered through an nsBrowserStatusFilter,
|
|
|
|
// which accepts ProgressChange64 events, but truncates the progress values to
|
|
|
|
// uint32_t and calls OnProgressChange.
|
2019-04-03 20:32:21 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMETHODIMP BrowserChild::OnRefreshAttempted(nsIWebProgress* aWebProgress,
|
|
|
|
nsIURI* aRefreshURI,
|
|
|
|
int32_t aMillis, bool aSameURI,
|
|
|
|
bool* aOut) {
|
2019-04-03 20:32:56 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aOut);
|
|
|
|
*aOut = true;
|
|
|
|
|
|
|
|
return NS_OK;
|
2019-04-03 20:32:21 +03:00
|
|
|
}
|
|
|
|
|
2019-06-14 00:00:34 +03:00
|
|
|
NS_IMETHODIMP BrowserChild::NotifyNavigationFinished() {
|
|
|
|
Unused << SendNavigationFinished();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
nsresult BrowserChild::PrepareProgressListenerData(
|
2019-01-25 17:44:09 +03:00
|
|
|
nsIWebProgress* aWebProgress, nsIRequest* aRequest,
|
2019-04-03 20:29:28 +03:00
|
|
|
Maybe<WebProgressData>& aWebProgressData, RequestData& aRequestData) {
|
2019-01-25 17:44:09 +03:00
|
|
|
if (aWebProgress) {
|
2019-04-03 20:29:28 +03:00
|
|
|
aWebProgressData.emplace();
|
|
|
|
|
2019-01-25 17:44:09 +03:00
|
|
|
bool isTopLevel = false;
|
|
|
|
nsresult rv = aWebProgress->GetIsTopLevel(&isTopLevel);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2019-04-03 20:29:28 +03:00
|
|
|
aWebProgressData->isTopLevel() = isTopLevel;
|
2019-01-25 17:44:09 +03:00
|
|
|
|
|
|
|
bool isLoadingDocument = false;
|
|
|
|
rv = aWebProgress->GetIsLoadingDocument(&isLoadingDocument);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2019-04-03 20:29:28 +03:00
|
|
|
aWebProgressData->isLoadingDocument() = isLoadingDocument;
|
2019-01-25 17:44:09 +03:00
|
|
|
|
|
|
|
uint32_t loadType = 0;
|
|
|
|
rv = aWebProgress->GetLoadType(&loadType);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2019-04-03 20:29:28 +03:00
|
|
|
aWebProgressData->loadType() = loadType;
|
2019-01-25 17:44:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
|
|
|
|
if (channel) {
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
nsresult rv = channel->GetURI(getter_AddRefs(uri));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
aRequestData.requestURI() = uri;
|
|
|
|
|
|
|
|
rv = channel->GetOriginalURI(getter_AddRefs(uri));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
aRequestData.originalRequestURI() = uri;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
|
|
|
|
do_QueryInterface(channel);
|
|
|
|
if (classifiedChannel) {
|
|
|
|
nsAutoCString matchedList;
|
|
|
|
rv = classifiedChannel->GetMatchedList(matchedList);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
aRequestData.matchedList() = std::move(matchedList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-22 12:06:14 +03:00
|
|
|
bool BrowserChild::UpdateSessionStore(uint32_t aFlushId, bool aIsFinal) {
|
2019-05-04 13:42:52 +03:00
|
|
|
if (!mSessionStoreListener) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
RefPtr<ContentSessionStore> store = mSessionStoreListener->GetSessionStore();
|
|
|
|
|
|
|
|
Maybe<nsCString> docShellCaps;
|
|
|
|
if (store->IsDocCapChanged()) {
|
|
|
|
docShellCaps.emplace(store->GetDocShellCaps());
|
|
|
|
}
|
|
|
|
|
|
|
|
Maybe<bool> privatedMode;
|
|
|
|
if (store->IsPrivateChanged()) {
|
|
|
|
privatedMode.emplace(store->GetPrivateModeEnabled());
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<int32_t> positionDescendants;
|
|
|
|
nsTArray<nsCString> positions;
|
|
|
|
if (store->IsScrollPositionChanged()) {
|
|
|
|
store->GetScrollPositions(positions, positionDescendants);
|
|
|
|
}
|
|
|
|
|
2019-08-02 17:19:00 +03:00
|
|
|
nsTArray<InputFormData> inputs;
|
|
|
|
nsTArray<CollectedInputDataValue> idVals, xPathVals;
|
|
|
|
if (store->IsFormDataChanged()) {
|
|
|
|
inputs = store->GetInputs(idVals, xPathVals);
|
|
|
|
}
|
|
|
|
|
2019-08-27 17:47:27 +03:00
|
|
|
nsTArray<nsCString> origins;
|
|
|
|
nsTArray<nsString> keys, values;
|
|
|
|
bool isFullStorage = false;
|
|
|
|
if (store->IsStorageUpdated()) {
|
|
|
|
isFullStorage = store->GetAndClearStorageChanges(origins, keys, values);
|
|
|
|
}
|
|
|
|
|
2019-08-02 17:19:00 +03:00
|
|
|
Unused << SendSessionStoreUpdate(
|
|
|
|
docShellCaps, privatedMode, positions, positionDescendants, inputs,
|
2020-03-19 17:31:52 +03:00
|
|
|
idVals, xPathVals, origins, keys, values, isFullStorage,
|
|
|
|
store->GetAndClearSHistoryChanged(), aFlushId, aIsFinal,
|
|
|
|
mSessionStoreListener->GetEpoch());
|
2019-05-04 13:42:52 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Bug 1581855:Part 2 - Present VR output to VR Host r=kip,jrmuizel,sotaro,bryce
This change is a continuation of Part 1 (Bug 1570128), where the 2D content rendered by Firefox for Firefox Reality on Desktop is marshalled through VRHost so that it can be presented in a VR environment.
A new class, FxrOutputHandler, is created to manage creating a sharable texture, sharing it through VRShMem, and updating it when content updates. This class updates content with both WebRender and conventional rendering output.
This initial iteration of FxrOutputHandler does not have synchronization between reading and writing this shared texture across processes. A subsequent fix (Bug 1581881) is pending, which will reuse WebVR code to manage writing to and reading from a pool of textures.
This also presents issues with rendering protected media, so an additional class, FxrWindowManager, is created to manage all windows created for Firefox Reality on Desktop so that it can inform whether or not protected media can be presented.
The automated manual tests in vrhosttest.cpp now show the real shared texture handle rather than a fake value, which shows that marshaling succeeded.
Differential Revision: https://phabricator.services.mozilla.com/D46179
--HG--
extra : moz-landing-system : lando
2019-09-26 15:50:44 +03:00
|
|
|
#ifdef XP_WIN
|
2019-10-14 22:10:39 +03:00
|
|
|
RefPtr<PBrowserChild::IsWindowSupportingProtectedMediaPromise>
|
|
|
|
BrowserChild::DoesWindowSupportProtectedMedia() {
|
|
|
|
MOZ_ASSERT(
|
|
|
|
NS_IsMainThread(),
|
|
|
|
"Protected media support check should be done on main thread only.");
|
|
|
|
if (mWindowSupportsProtectedMedia) {
|
|
|
|
// If we've already checked and have a cached result, resolve with that.
|
|
|
|
return IsWindowSupportingProtectedMediaPromise::CreateAndResolve(
|
|
|
|
mWindowSupportsProtectedMedia.value(), __func__);
|
|
|
|
}
|
|
|
|
RefPtr<BrowserChild> self = this;
|
|
|
|
// We chain off the promise rather than passing it directly so we can cache
|
|
|
|
// the result and use that for future calls.
|
|
|
|
return SendIsWindowSupportingProtectedMedia(ChromeOuterWindowID())
|
|
|
|
->Then(
|
2020-06-23 08:05:36 +03:00
|
|
|
GetCurrentSerialEventTarget(), __func__,
|
2019-10-14 22:10:39 +03:00
|
|
|
[self](bool isSupported) {
|
|
|
|
// If a result was cached while this check was inflight, ensure the
|
|
|
|
// results match.
|
|
|
|
MOZ_ASSERT_IF(
|
|
|
|
self->mWindowSupportsProtectedMedia,
|
|
|
|
self->mWindowSupportsProtectedMedia.value() == isSupported);
|
|
|
|
// Cache the response as it will not change during the lifetime
|
|
|
|
// of this object.
|
|
|
|
self->mWindowSupportsProtectedMedia = Some(isSupported);
|
|
|
|
return IsWindowSupportingProtectedMediaPromise::CreateAndResolve(
|
|
|
|
self->mWindowSupportsProtectedMedia.value(), __func__);
|
|
|
|
},
|
|
|
|
[](ResponseRejectReason reason) {
|
|
|
|
return IsWindowSupportingProtectedMediaPromise::CreateAndReject(
|
|
|
|
reason, __func__);
|
|
|
|
});
|
Bug 1581855:Part 2 - Present VR output to VR Host r=kip,jrmuizel,sotaro,bryce
This change is a continuation of Part 1 (Bug 1570128), where the 2D content rendered by Firefox for Firefox Reality on Desktop is marshalled through VRHost so that it can be presented in a VR environment.
A new class, FxrOutputHandler, is created to manage creating a sharable texture, sharing it through VRShMem, and updating it when content updates. This class updates content with both WebRender and conventional rendering output.
This initial iteration of FxrOutputHandler does not have synchronization between reading and writing this shared texture across processes. A subsequent fix (Bug 1581881) is pending, which will reuse WebVR code to manage writing to and reading from a pool of textures.
This also presents issues with rendering protected media, so an additional class, FxrWindowManager, is created to manage all windows created for Firefox Reality on Desktop so that it can inform whether or not protected media can be presented.
The automated manual tests in vrhosttest.cpp now show the real shared texture handle rather than a fake value, which shows that marshaling succeeded.
Differential Revision: https://phabricator.services.mozilla.com/D46179
--HG--
extra : moz-landing-system : lando
2019-09-26 15:50:44 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-01-13 17:08:25 +03:00
|
|
|
void BrowserChild::NotifyContentBlockingEvent(
|
2020-02-11 12:33:32 +03:00
|
|
|
uint32_t aEvent, nsIChannel* aChannel, bool aBlocked,
|
|
|
|
const nsACString& aTrackingOrigin,
|
2020-01-13 17:08:25 +03:00
|
|
|
const nsTArray<nsCString>& aTrackingFullHashes,
|
2020-06-03 09:12:06 +03:00
|
|
|
const Maybe<
|
|
|
|
mozilla::ContentBlockingNotifier::StorageAccessPermissionGrantedReason>&
|
2020-01-13 17:08:25 +03:00
|
|
|
aReason) {
|
|
|
|
if (!IPCOpen()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Maybe<WebProgressData> webProgressData;
|
|
|
|
RequestData requestData;
|
|
|
|
nsresult rv = PrepareProgressListenerData(nullptr, aChannel, webProgressData,
|
|
|
|
requestData);
|
|
|
|
NS_ENSURE_SUCCESS_VOID(rv);
|
|
|
|
|
2020-02-11 12:33:32 +03:00
|
|
|
Unused << SendNotifyContentBlockingEvent(aEvent, requestData, aBlocked,
|
|
|
|
PromiseFlatCString(aTrackingOrigin),
|
|
|
|
aTrackingFullHashes, aReason);
|
2020-01-13 17:08:25 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
BrowserChildMessageManager::BrowserChildMessageManager(
|
|
|
|
BrowserChild* aBrowserChild)
|
|
|
|
: ContentFrameMessageManager(new nsFrameMessageManager(aBrowserChild)),
|
|
|
|
mBrowserChild(aBrowserChild) {}
|
2012-04-27 00:56:46 +04:00
|
|
|
|
2020-03-06 12:11:40 +03:00
|
|
|
BrowserChildMessageManager::~BrowserChildMessageManager() = default;
|
2014-07-09 01:23:17 +04:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(BrowserChildMessageManager)
|
2015-05-07 10:05:43 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BrowserChildMessageManager,
|
2015-05-07 10:05:43 +03:00
|
|
|
DOMEventTargetHelper)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMessageManager);
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mBrowserChild);
|
2020-02-25 22:44:39 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_WEAK_REFERENCE
|
2015-05-07 10:05:43 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(BrowserChildMessageManager,
|
2015-05-07 10:05:43 +03:00
|
|
|
DOMEventTargetHelper)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMessageManager)
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBrowserChild)
|
2015-05-07 10:05:43 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
2010-02-20 20:05:20 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BrowserChildMessageManager)
|
2012-08-27 18:13:02 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIMessageSender)
|
2018-08-18 02:14:43 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(ContentFrameMessageManager)
|
2015-01-18 06:17:06 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
2010-02-20 20:05:20 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
NS_IMPL_ADDREF_INHERITED(BrowserChildMessageManager, DOMEventTargetHelper)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(BrowserChildMessageManager, DOMEventTargetHelper)
|
2010-02-20 20:05:20 +03:00
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
JSObject* BrowserChildMessageManager::WrapObject(
|
2018-08-11 00:03:18 +03:00
|
|
|
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
|
|
|
|
return ContentFrameMessageManager_Binding::Wrap(aCx, this, aGivenProto);
|
2017-07-19 15:59:02 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
void BrowserChildMessageManager::MarkForCC() {
|
|
|
|
if (mBrowserChild) {
|
|
|
|
mBrowserChild->MarkScopesForCC();
|
2015-02-25 01:23:53 +03:00
|
|
|
}
|
2015-07-11 16:45:49 +03:00
|
|
|
EventListenerManager* elm = GetExistingListenerManager();
|
|
|
|
if (elm) {
|
|
|
|
elm->MarkForCC();
|
|
|
|
}
|
2018-02-16 17:28:31 +03:00
|
|
|
MessageManagerGlobal::MarkForCC();
|
2017-07-19 15:59:02 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
Nullable<WindowProxyHolder> BrowserChildMessageManager::GetContent(
|
2018-08-11 00:04:23 +03:00
|
|
|
ErrorResult& aError) {
|
2019-01-02 16:27:05 +03:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = GetDocShell(aError);
|
|
|
|
if (!docShell) {
|
2019-01-02 16:26:56 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
2019-08-07 19:59:30 +03:00
|
|
|
return WindowProxyHolder(docShell->GetBrowsingContext());
|
2012-08-09 12:33:38 +04:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
already_AddRefed<nsIDocShell> BrowserChildMessageManager::GetDocShell(
|
2018-08-11 00:04:23 +03:00
|
|
|
ErrorResult& aError) {
|
2019-04-10 01:39:01 +03:00
|
|
|
if (!mBrowserChild) {
|
2017-07-19 15:59:02 +03:00
|
|
|
aError.Throw(NS_ERROR_NULL_POINTER);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2019-04-10 01:39:01 +03:00
|
|
|
nsCOMPtr<nsIDocShell> window =
|
|
|
|
do_GetInterface(mBrowserChild->WebNavigation());
|
2017-07-19 15:59:02 +03:00
|
|
|
return window.forget();
|
2010-02-20 20:05:20 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
already_AddRefed<nsIEventTarget>
|
|
|
|
BrowserChildMessageManager::GetTabEventTarget() {
|
2017-07-19 15:59:02 +03:00
|
|
|
nsCOMPtr<nsIEventTarget> target = EventTargetFor(TaskCategory::Other);
|
|
|
|
return target.forget();
|
2010-03-03 23:30:25 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
nsresult BrowserChildMessageManager::Dispatch(
|
2017-07-05 11:23:23 +03:00
|
|
|
TaskCategory aCategory, already_AddRefed<nsIRunnable>&& aRunnable) {
|
2018-05-30 22:15:35 +03:00
|
|
|
return DispatcherTrait::Dispatch(aCategory, std::move(aRunnable));
|
2017-07-05 11:23:23 +03:00
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
nsISerialEventTarget* BrowserChildMessageManager::EventTargetFor(
|
2018-08-11 00:04:23 +03:00
|
|
|
TaskCategory aCategory) const {
|
2017-07-05 11:23:23 +03:00
|
|
|
return DispatcherTrait::EventTargetFor(aCategory);
|
|
|
|
}
|
|
|
|
|
2019-04-10 01:39:01 +03:00
|
|
|
AbstractThread* BrowserChildMessageManager::AbstractMainThreadFor(
|
2018-08-11 00:04:23 +03:00
|
|
|
TaskCategory aCategory) {
|
2017-07-05 11:23:23 +03:00
|
|
|
return DispatcherTrait::AbstractMainThreadFor(aCategory);
|
|
|
|
}
|