Compare commits
381
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
610e44320c | ||
|
|
10476e27da | ||
|
|
a4777b1c21 | ||
|
|
9f6e448f78 | ||
|
|
19a21bac1b | ||
|
|
c7867ce130 | ||
|
|
34c068e611 | ||
|
|
a48e621048 | ||
|
|
de5d3b1034 | ||
|
|
f8737bbf4f | ||
|
|
d9c70eaba2 | ||
|
|
9308c63ce6 | ||
|
|
6314e01691 | ||
|
|
b7b2f1de84 | ||
|
|
b838d6634c | ||
|
|
dc4ea7f680 | ||
|
|
2132ea4a22 | ||
|
|
33bff10b1c | ||
|
|
9493e8c3de | ||
|
|
7631297112 | ||
|
|
5e381b021c | ||
|
|
5c9a1efa7c | ||
|
|
93ddeb613e | ||
|
|
2fae5d3e6b | ||
|
|
5fd365cb76 | ||
|
|
d7f8e56f04 | ||
|
|
6ee56b0a60 | ||
|
|
165ef56547 | ||
|
|
9d333be11b | ||
|
|
aff6fbf36c | ||
|
|
ef8447ad4b | ||
|
|
21face45d3 | ||
|
|
ff4d550c80 | ||
|
|
45b9cfbe93 | ||
|
|
4321dbddcc | ||
|
|
3a67a9510b | ||
|
|
ea464a764f | ||
|
|
72a2a5f2bd | ||
|
|
0b70c77657 | ||
|
|
ca04aefa67 | ||
|
|
89dec27643 | ||
|
|
53a8a408f2 | ||
|
|
a653f74576 | ||
|
|
5fa394b169 | ||
|
|
3d92b82125 | ||
|
|
ccb41c645c | ||
|
|
98c3aa5743 | ||
|
|
2c2ddd98d2 | ||
|
|
b15a36452d | ||
|
|
a71597905c | ||
|
|
028aa731ed | ||
|
|
688ed9a114 | ||
|
|
c30be25773 | ||
|
|
72f30730e7 | ||
|
|
782202963e | ||
|
|
dd2fbc763a | ||
|
|
f4d408dffe | ||
|
|
f7c0599e1e | ||
|
|
855109b028 | ||
|
|
c48055d6ea | ||
|
|
8b746b6c12 | ||
|
|
1889edcea8 | ||
|
|
6df4c18747 | ||
|
|
d5231ca7e7 | ||
|
|
93823836d7 | ||
|
|
1e3301e987 | ||
|
|
ccbeea30aa | ||
|
|
398486a64b | ||
|
|
4554cb9929 | ||
|
|
8f62ed27eb | ||
|
|
3e71cd6b93 | ||
|
|
6c6c16b7f0 | ||
|
|
6ad6cc9c2d | ||
|
|
5b5672fd56 | ||
|
|
0e427867e3 | ||
|
|
8137a4e122 | ||
|
|
f2ec6ef34d | ||
|
|
42c8b9470c | ||
|
|
d0d6e8edf5 | ||
|
|
30d3325148 | ||
|
|
0451648c60 | ||
|
|
7a10dcaadf | ||
|
|
a63cf31989 | ||
|
|
ea3785a6d7 | ||
|
|
d0d9e63809 | ||
|
|
e80bbcfe91 | ||
|
|
08406731e5 | ||
|
|
6076431d7c | ||
|
|
60b4d804bd | ||
|
|
2b1281f2c9 | ||
|
|
087febcc4b | ||
|
|
6430adfb2d | ||
|
|
d5020b69bd | ||
|
|
46138995f6 | ||
|
|
aeb9de40a5 | ||
|
|
3d693801f9 | ||
|
|
3b39358c84 | ||
|
|
4df8e7664a | ||
|
|
14fa712b8c | ||
|
|
7d93034fd0 | ||
|
|
1769e74839 | ||
|
|
cdfd243b5a | ||
|
|
b326873871 | ||
|
|
0ea78ba5fa | ||
|
|
95a8edc5fc | ||
|
|
38dfadad45 | ||
|
|
9bee3a8b72 | ||
|
|
c8218f73b7 | ||
|
|
81cf4413e2 | ||
|
|
09e6d13d6b | ||
|
|
69cfed48da | ||
|
|
1b2c1d8eac | ||
|
|
e0746ccf31 | ||
|
|
8f6d5c5ba0 | ||
|
|
78120a7693 | ||
|
|
ecc90c09ef | ||
|
|
8698518416 | ||
|
|
cf178171a4 | ||
|
|
92ad63b579 | ||
|
|
8c63b950f5 | ||
|
|
9aed582fc1 | ||
|
|
1b5b970a53 | ||
|
|
bf6ed5545d | ||
|
|
302411b4df | ||
|
|
2cb4813adb | ||
|
|
c5ba4dd2a4 | ||
|
|
322bbcad1b | ||
|
|
a2f69c22f8 | ||
|
|
9d69fa3c37 | ||
|
|
5d76f35990 | ||
|
|
054f135a54 | ||
|
|
5c8336d123 | ||
|
|
0f0adfa1b4 | ||
|
|
ec38250eea | ||
|
|
682e5a4727 | ||
|
|
16e405f818 | ||
|
|
bfae2ed943 | ||
|
|
1337373ee1 | ||
|
|
efc3e99b90 | ||
|
|
eaf9a3cc57 | ||
|
|
b7a5d73ba9 | ||
|
|
aa1caf5ade | ||
|
|
bc4d5cec6a | ||
|
|
7d55641d43 | ||
|
|
3f799def4d | ||
|
|
796863b719 | ||
|
|
aced9bbc94 | ||
|
|
b1d111ab6b | ||
|
|
99c25d8e98 | ||
|
|
8a45238908 | ||
|
|
1b588e0d73 | ||
|
|
c9020fed9c | ||
|
|
4c6e382f47 | ||
|
|
26cb9b0802 | ||
|
|
1fd5023fdc | ||
|
|
8a0c7bde63 | ||
|
|
cc43ec658c | ||
|
|
07df24f00f | ||
|
|
ed7b08e608 | ||
|
|
1a429629d2 | ||
|
|
03ec9c095b | ||
|
|
24edfc1652 | ||
|
|
efd2b96387 | ||
|
|
4a179ff885 | ||
|
|
8c5a0f0de9 | ||
|
|
cc8f43bf79 | ||
|
|
552d964ae7 | ||
|
|
0099fc1627 | ||
|
|
8ce17f02ee | ||
|
|
269a703200 | ||
|
|
582fd0dd81 | ||
|
|
395caa8780 | ||
|
|
f31471e689 | ||
|
|
be4b71b580 | ||
|
|
de91800956 | ||
|
|
7a48dfc066 | ||
|
|
4769b2a9fa | ||
|
|
b12c222c61 | ||
|
|
2ac006763b | ||
|
|
3edbfa6b6e | ||
|
|
fcb74a0fb6 | ||
|
|
bfda40bce9 | ||
|
|
8b4aae99b4 | ||
|
|
4e1d7760d5 | ||
|
|
1b2961f93f | ||
|
|
8775eedca5 | ||
|
|
8ffb592b72 | ||
|
|
522d8c66a5 | ||
|
|
7df5060161 | ||
|
|
73a150b1c1 | ||
|
|
89f280a78e | ||
|
|
6aeae2ba74 | ||
|
|
5fd783135d | ||
|
|
1b2be9536f | ||
|
|
2ad1f8f08d | ||
|
|
85734b9adf | ||
|
|
2b46202164 | ||
|
|
18ec63e459 | ||
|
|
004a3d003b | ||
|
|
9c72ce666b | ||
|
|
47f213c878 | ||
|
|
d2eb2ce9f4 | ||
|
|
dba1e36601 | ||
|
|
bb39e1e38f | ||
|
|
7003ea7dc4 | ||
|
|
dca8417ba7 | ||
|
|
99184b1764 | ||
|
|
8f26f1a873 | ||
|
|
53ce814858 | ||
|
|
33d4be58a5 | ||
|
|
8635073418 | ||
|
|
f122b231e5 | ||
|
|
1a7f79ef9a | ||
|
|
281497201e | ||
|
|
dce6745dec | ||
|
|
a9bb437550 | ||
|
|
01ee4539cb | ||
|
|
47fbe9552a | ||
|
|
ee97a5dad4 | ||
|
|
c94c303447 | ||
|
|
a15cbf9256 | ||
|
|
7a4b850150 | ||
|
|
7de2732e7f | ||
|
|
f20e3f4dd1 | ||
|
|
ca691c8d2d | ||
|
|
226f97e2f4 | ||
|
|
7fdc866b5a | ||
|
|
e112df8849 | ||
|
|
45ec6b3a86 | ||
|
|
8b9d69f912 | ||
|
|
92ecaaeaa9 | ||
|
|
ebf4f559e0 | ||
|
|
d9eb5d3e2b | ||
|
|
9e85eb2816 | ||
|
|
32ef10e763 | ||
|
|
ac24db13ef | ||
|
|
8ac0957072 | ||
|
|
7178ca44ef | ||
|
|
178a43839d | ||
|
|
da947c5045 | ||
|
|
6d65f1d192 | ||
|
|
4ddaf0f490 | ||
|
|
ff81f4969c | ||
|
|
369ba2e7d6 | ||
|
|
a0fb8c06de | ||
|
|
d16b014115 | ||
|
|
3bb0c18a59 | ||
|
|
53b548e31a | ||
|
|
2a6187709b | ||
|
|
cd98dce5fa | ||
|
|
9bfeaab2e6 | ||
|
|
3b32a66cb6 | ||
|
|
edfb29e1a2 | ||
|
|
41f38134f1 | ||
|
|
20ac6059ce | ||
|
|
d9aa76f5c2 | ||
|
|
9dda91e5cb | ||
|
|
39d52370dc | ||
|
|
8b1222c5f8 | ||
|
|
e748187360 | ||
|
|
13cca807e6 | ||
|
|
7f8ea9ae2f | ||
|
|
1851f19271 | ||
|
|
3dc659b86d | ||
|
|
83daf83360 | ||
|
|
5a7348a8d1 | ||
|
|
fa32034f30 | ||
|
|
56a82b8ed4 | ||
|
|
7a5b68c98e | ||
|
|
1edc4e41d3 | ||
|
|
edacbbd965 | ||
|
|
a3096d09f9 | ||
|
|
b4ddadd8b9 | ||
|
|
f359533b82 | ||
|
|
94609cf97b | ||
|
|
6257513c7e | ||
|
|
0587c85114 | ||
|
|
f4c134225c | ||
|
|
24e4a09270 | ||
|
|
f193a4a7dc | ||
|
|
2b198142f0 | ||
|
|
700bead8ba | ||
|
|
f734e4f724 | ||
|
|
32acbcb96b | ||
|
|
0da765e156 | ||
|
|
a816a6b6de | ||
|
|
37e02a4bd4 | ||
|
|
93a10f9e2f | ||
|
|
94240c9002 | ||
|
|
069fa50258 | ||
|
|
7175868124 | ||
|
|
8c25550baf | ||
|
|
cd0c08484d | ||
|
|
3c37b8857d | ||
|
|
1eccb6f42a | ||
|
|
cb1aa7f456 | ||
|
|
42cf583a57 | ||
|
|
3aeea5f9d0 | ||
|
|
b2ae4d3885 | ||
|
|
eb7a856c76 | ||
|
|
8e0e86face | ||
|
|
0980b1e936 | ||
|
|
f0b08a209d | ||
|
|
3284e449a7 | ||
|
|
377625e539 | ||
|
|
eae076209f | ||
|
|
7a2f114334 | ||
|
|
af5dbfc120 | ||
|
|
3d87998c59 | ||
|
|
6f46768035 | ||
|
|
b98ca4be18 | ||
|
|
d9c5b3bde5 | ||
|
|
b3f6b7a224 | ||
|
|
05d58b4aa1 | ||
|
|
90aaa1fdfb | ||
|
|
e40bea1e04 | ||
|
|
569f23eb6a | ||
|
|
af47a256b5 | ||
|
|
e96f965422 | ||
|
|
7c3aa6a8b6 | ||
|
|
1a9d6d6372 | ||
|
|
2f940bdc9d | ||
|
|
6808e659ad | ||
|
|
371ae1639a | ||
|
|
33ec3d04f2 | ||
|
|
f168e0afe9 | ||
|
|
9eb285a9fb | ||
|
|
bbe3b8e12f | ||
|
|
73c366766a | ||
|
|
388733cd1d | ||
|
|
35f1a49cf2 | ||
|
|
c2019fa28c | ||
|
|
bed754c21c | ||
|
|
85efbc0c1e | ||
|
|
93bd7fc61e | ||
|
|
1ec5d757e6 | ||
|
|
1a3f3da99d | ||
|
|
b238bb079f | ||
|
|
c3d4cec8ad | ||
|
|
a666c05d68 | ||
|
|
14836b0c17 | ||
|
|
30829b7a07 | ||
|
|
2fe6bb5c36 | ||
|
|
773cbb1a3e | ||
|
|
5f6b2407e7 | ||
|
|
adfb8133d1 | ||
|
|
559d2ed26f | ||
|
|
2004256c89 | ||
|
|
32751e3d8f | ||
|
|
c11311fd5b | ||
|
|
4253a2a893 | ||
|
|
6e35a8566e | ||
|
|
281a8854d0 | ||
|
|
370e66ecce | ||
|
|
beabbde706 | ||
|
|
ac5101015f | ||
|
|
0627dc7639 | ||
|
|
c58f825821 | ||
|
|
e4eb31879f | ||
|
|
709d0bde73 | ||
|
|
2a730d59f9 | ||
|
|
5ee57767e0 | ||
|
|
61d8ec5478 | ||
|
|
3f09edfde0 | ||
|
|
b116ab7a1e | ||
|
|
ddf3f39070 | ||
|
|
e56b7b826d | ||
|
|
19650c6f8a | ||
|
|
d2a86d81f3 | ||
|
|
ccb51f2f40 | ||
|
|
ecf05312e6 | ||
|
|
c7ca649bd1 | ||
|
|
b2889d844f | ||
|
|
fdfe7a8245 | ||
|
|
709c34a448 | ||
|
|
0adb8cc71f | ||
|
|
286e18e40c | ||
|
|
4c2a1920b8 | ||
|
|
29bdffbb54 | ||
|
|
ef31c426b1 | ||
|
|
30b5a4d830 |
No files matched your search
@@ -22,4 +22,4 @@
|
||||
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
|
||||
# don't change CLOBBER for WebIDL changes any more.
|
||||
|
||||
Touching ICU's build system requires a CLOBBER. (Issue #2165)
|
||||
Switching to C++17 requires CLOBBER to pick up compiler conf. (Issue #2281)
|
||||
@@ -176,7 +176,7 @@ private:
|
||||
uint32_t AddSubtree(ProxyAccessible* aParent,
|
||||
const nsTArray<AccessibleData>& aNewTree, uint32_t aIdx,
|
||||
uint32_t aIdxInParent);
|
||||
MOZ_MUST_USE bool CheckDocTree() const;
|
||||
[[nodiscard]] bool CheckDocTree() const;
|
||||
xpcAccessibleGeneric* GetXPCAccessible(ProxyAccessible* aProxy);
|
||||
|
||||
nsTArray<DocAccessibleParent*> mChildDocs;
|
||||
|
||||
@@ -173,7 +173,7 @@ public: // construction, destruction
|
||||
/**
|
||||
* Find an accessible by the given child ID in cached documents.
|
||||
*/
|
||||
MOZ_MUST_USE already_AddRefed<IAccessible>
|
||||
[[nodiscard]] already_AddRefed<IAccessible>
|
||||
GetIAccessibleFor(const VARIANT& aVarChild, bool* aIsDefunct);
|
||||
|
||||
virtual void GetNativeInterface(void **aOutAccessible) override;
|
||||
@@ -198,7 +198,7 @@ protected:
|
||||
/**
|
||||
* Find a remote accessible by the given child ID.
|
||||
*/
|
||||
MOZ_MUST_USE already_AddRefed<IAccessible>
|
||||
[[nodiscard]] already_AddRefed<IAccessible>
|
||||
GetRemoteIAccessibleFor(const VARIANT& aVarChild);
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,7 @@ MOZ_ARG_ENABLE_BOOL(address-sanitizer,
|
||||
MOZ_ASAN= )
|
||||
if test -n "$MOZ_ASAN"; then
|
||||
MOZ_LLVM_HACKS=1
|
||||
if test -n "$CLANG_CL"; then
|
||||
if test "$OS_ARCH" = "WINNT"; then
|
||||
# Look for the ASan runtime binary
|
||||
if test "$CPU_ARCH" = "x86_64"; then
|
||||
MOZ_CLANG_RT_ASAN_LIB=clang_rt.asan_dynamic-x86_64.dll
|
||||
@@ -27,14 +27,14 @@ if test -n "$MOZ_ASAN"; then
|
||||
fi
|
||||
AC_SUBST(MOZ_CLANG_RT_ASAN_LIB_PATH)
|
||||
# Suppressing errors in recompiled code.
|
||||
if test "$OS_ARCH" = "WINNT"; then
|
||||
if test -n "$CLANG_CL"; then
|
||||
CFLAGS="-fsanitize-blacklist=$_topsrcdir/build/sanitizers/asan_blacklist_win.txt $CFLAGS"
|
||||
CXXFLAGS="-fsanitize-blacklist=$_topsrcdir/build/sanitizers/asan_blacklist_win.txt $CXXFLAGS"
|
||||
fi
|
||||
fi
|
||||
CFLAGS="-fsanitize=address $CFLAGS"
|
||||
CXXFLAGS="-fsanitize=address $CXXFLAGS"
|
||||
if test -z "$CLANG_CL"; then
|
||||
if test "$OS_ARCH" != "WINNT"; then
|
||||
LDFLAGS="-fsanitize=address $LDFLAGS"
|
||||
fi
|
||||
AC_DEFINE(MOZ_ASAN)
|
||||
@@ -80,6 +80,40 @@ if test -n "$MOZ_TSAN"; then
|
||||
fi
|
||||
AC_SUBST(MOZ_TSAN)
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Use Leak Sanitizer
|
||||
dnl ========================================================
|
||||
MOZ_ARG_ENABLE_BOOL(leak-sanitizer,
|
||||
[ --enable-leak-sanitizer Enable Leak Sanitizer (default=no)],
|
||||
MOZ_LSAN=1,
|
||||
MOZ_LSAN= )
|
||||
if test -n "$MOZ_LSAN"; then
|
||||
MOZ_LLVM_HACKS=1
|
||||
LDFLAGS="-fsanitize=leak $LDFLAGS"
|
||||
AC_DEFINE(MOZ_LSAN)
|
||||
MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
|
||||
fi
|
||||
AC_SUBST(MOZ_LSAN)
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Use Undefined Behavior Sanitizer
|
||||
dnl ========================================================
|
||||
MOZ_ARG_ENABLE_BOOL(undefined-sanitizer,
|
||||
[ --enable-undefined-sanitizer Enable Undefined Behavior Sanitizer (default=no)],
|
||||
MOZ_UBSAN=1,
|
||||
MOZ_UBSAN= )
|
||||
if test -n "$MOZ_UBSAN"; then
|
||||
MOZ_LLVM_HACKS=1
|
||||
CFLAGS="-fsanitize=undefined $CFLAGS"
|
||||
CXXFLAGS="-fsanitize=undefined $CXXFLAGS"
|
||||
if test -z "$CLANG_CL"; then
|
||||
LDFLAGS="-fsanitize=undefined $LDFLAGS"
|
||||
fi
|
||||
AC_DEFINE(MOZ_UBSAN)
|
||||
MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
|
||||
fi
|
||||
AC_SUBST(MOZ_UBSAN)
|
||||
|
||||
# The LLVM symbolizer is used by all sanitizers
|
||||
AC_SUBST(LLVM_SYMBOLIZER)
|
||||
|
||||
|
||||
+5
-3
@@ -58,9 +58,11 @@ FINAL_TARGET_FILES += ['/.gdbinit']
|
||||
FINAL_TARGET_PP_FILES += ['.gdbinit_python.in']
|
||||
OBJDIR_FILES += ['!/dist/bin/.gdbinit_python']
|
||||
|
||||
# Install the clang-cl runtime library for ASAN next to the binaries we produce.
|
||||
if CONFIG['MOZ_ASAN'] and CONFIG['CLANG_CL']:
|
||||
FINAL_TARGET_FILES += ['%' + CONFIG['MOZ_CLANG_RT_ASAN_LIB_PATH']]
|
||||
# Install the clang runtime library for ASAN next to the binaries we produce.
|
||||
if CONFIG['MOZ_ASAN'] and CONFIG['MOZ_CLANG_RT_ASAN_LIB_PATH']:
|
||||
FINAL_TARGET_FILES += [CONFIG['MOZ_CLANG_RT_ASAN_LIB_PATH']]
|
||||
if CONFIG['LLVM_SYMBOLIZER']:
|
||||
FINAL_TARGET_FILES += ['/' + CONFIG['LLVM_SYMBOLIZER']]
|
||||
|
||||
if CONFIG['MOZ_APP_BASENAME']:
|
||||
FINAL_TARGET_PP_FILES += ['application.ini']
|
||||
|
||||
@@ -74,6 +74,61 @@ def check_headers(*headers, **kwargs):
|
||||
return checks
|
||||
|
||||
|
||||
# Determine whether to add a given flag to the given lists of flags for C or
|
||||
# C++ compilation.
|
||||
# - `flag` is the flag to test
|
||||
# - `cflags` is a @depends function for the list of C compiler flags to add to
|
||||
# - `cxxflags` is a @depends function for the list of C++ compiler flags to
|
||||
# add to
|
||||
# - `test_flags` is a list of flags to pass to the compiler instead of merely
|
||||
# passing `flag`. This is especially useful for checking warning flags. If
|
||||
# this list is empty, `flag` will be passed on its own.
|
||||
# - `compiler` (optional) is the compiler to test against (c_compiler or
|
||||
# cxx_compiler, from toolchain.configure). When omitted, both compilers
|
||||
# are tested; the list of flags added to is dependent on the compiler tested.
|
||||
# - `when` (optional) is a @depends function or option name conditioning
|
||||
# when the warning flag is wanted.
|
||||
# - `check`, when not set, skips checking whether the flag is supported and
|
||||
# adds it to the list of flags unconditionally.
|
||||
@template
|
||||
def check_and_add_flags(flag, cflags, cxxflags, test_flags,
|
||||
compiler=None, when=None, check=True):
|
||||
if compiler is not None:
|
||||
compilers = (compiler,)
|
||||
else:
|
||||
compilers = (c_compiler, cxx_compiler)
|
||||
|
||||
if when is None:
|
||||
when = always
|
||||
|
||||
if test_flags:
|
||||
flags = test_flags
|
||||
else:
|
||||
flags = [flag]
|
||||
|
||||
for c in compilers:
|
||||
assert c in (c_compiler, cxx_compiler)
|
||||
lang, list_of_flags = {
|
||||
c_compiler: ('C', cflags),
|
||||
cxx_compiler: ('C++', cxxflags),
|
||||
}[c]
|
||||
|
||||
@depends(c, when)
|
||||
def result(c, when):
|
||||
if when and c.type in ('clang', 'gcc'):
|
||||
return True
|
||||
|
||||
if check:
|
||||
result = c.try_compile(
|
||||
flags=flags, when=result,
|
||||
check_msg='whether the %s compiler supports %s' % (lang, flag))
|
||||
|
||||
@depends(result, list_of_flags)
|
||||
def maybe_add_flag(result, list_of_flags):
|
||||
if result:
|
||||
list_of_flags.append(flag)
|
||||
|
||||
|
||||
@depends(c_compiler)
|
||||
def warnings_cflags(c_compiler):
|
||||
return []
|
||||
@@ -96,48 +151,21 @@ def warnings_cxxflags(cxx_compiler):
|
||||
# for add_gcc_warning().
|
||||
@template
|
||||
def check_and_add_gcc_warning(warning, compiler=None, when=None, check=True):
|
||||
if compiler:
|
||||
compilers = (compiler,)
|
||||
# GCC and clang will fail if given an unknown warning option like
|
||||
# -Wfoobar. But later versions won't fail if given an unknown negated
|
||||
# warning option like -Wno-foobar. So when we are checking for support
|
||||
# of a negated warning option, we actually test the positive form, but
|
||||
# add the negated form to the flags variable.
|
||||
if warning.startswith('-Wno-') and not warning.startswith('-Wno-error='):
|
||||
flags = ['-Werror', '-W' + warning[5:]]
|
||||
elif warning.startswith('-Werror='):
|
||||
flags = [warning]
|
||||
else:
|
||||
compilers = (c_compiler, cxx_compiler)
|
||||
flags = ['-Werror', warning]
|
||||
|
||||
when = when or always
|
||||
check_and_add_flags(warning, warnings_cflags, warnings_cxxflags,
|
||||
flags, compiler=compiler, when=when, check=check)
|
||||
|
||||
for c in compilers:
|
||||
assert c in (c_compiler, cxx_compiler)
|
||||
lang, warnings_flags = {
|
||||
c_compiler: ('C', warnings_cflags),
|
||||
cxx_compiler: ('C++', warnings_cxxflags),
|
||||
}[c]
|
||||
|
||||
# GCC and clang will fail if given an unknown warning option like
|
||||
# -Wfoobar. But later versions won't fail if given an unknown negated
|
||||
# warning option like -Wno-foobar. So when we are checking for support
|
||||
# of a negated warning option, we actually test the positive form, but
|
||||
# add the negated form to the flags variable.
|
||||
if (warning.startswith('-Wno-') and
|
||||
not warning.startswith('-Wno-error=')):
|
||||
flags = ['-Werror', '-W' + warning[5:]]
|
||||
elif warning.startswith('-Werror='):
|
||||
flags = [warning]
|
||||
else:
|
||||
flags = ['-Werror', warning]
|
||||
|
||||
@depends(c, when)
|
||||
def result(c, when):
|
||||
if when and c.type in ('clang', 'gcc'):
|
||||
return True
|
||||
|
||||
if check:
|
||||
result = c.try_compile(
|
||||
flags=flags, when=result,
|
||||
check_msg='whether the %s compiler supports %s' % (lang,
|
||||
warning))
|
||||
|
||||
@depends(result, warnings_flags)
|
||||
def maybe_add_flag(result, warnings_flags):
|
||||
if result:
|
||||
warnings_flags.append(warning)
|
||||
|
||||
# Add the given warning to the list of warning flags for the build.
|
||||
# - `warning` is the warning flag (e.g. -Wfoo)
|
||||
@@ -149,3 +177,45 @@ def check_and_add_gcc_warning(warning, compiler=None, when=None, check=True):
|
||||
@template
|
||||
def add_gcc_warning(warning, compiler=None, when=None):
|
||||
check_and_add_gcc_warning(warning, compiler, when, check=False)
|
||||
|
||||
|
||||
# Like the warning checks above, but for general compilation flags.
|
||||
@dependable
|
||||
def compilation_cflags():
|
||||
return []
|
||||
|
||||
|
||||
@dependable
|
||||
def compilation_cxxflags():
|
||||
return []
|
||||
|
||||
|
||||
# Tests whether GCC or clang support the given compilation flag; if the flag
|
||||
# is supported, add it to the list of compilation flags for the build.
|
||||
# - `flag` is the flag to test
|
||||
# - `compiler` (optional) is the compiler to test against (c_compiler or
|
||||
# cxx_compiler, from toolchain.configure). When omitted, both compilers
|
||||
# are tested.
|
||||
# - `when` (optional) is a @depends function or option name conditioning
|
||||
# when the warning flag is wanted.
|
||||
# - `check`, when not set, skips checking whether the flag is supported and
|
||||
# adds it to the list of flags unconditionally. This is only meant for
|
||||
# add_gcc_flag().
|
||||
@template
|
||||
def check_and_add_gcc_flag(flag, compiler=None, when=None, check=True):
|
||||
flags = ['-Werror', flag]
|
||||
|
||||
check_and_add_flags(flag, compilation_cflags, compilation_cxxflags,
|
||||
flags, compiler=compiler, when=when, check=check)
|
||||
|
||||
|
||||
# Add the given flag to the list of flags for the build.
|
||||
# - `flag` is the flag (e.g. -fno-sized-deallocation)
|
||||
# - `compiler` (optional) is the compiler to add the flag for (c_compiler or
|
||||
# cxx_compiler, from toolchain.configure). When omitted, the flag is added
|
||||
# for both compilers.
|
||||
# - `when` (optional) is a @depends function or option name conditioning
|
||||
# when the flag is wanted.
|
||||
@template
|
||||
def add_gcc_flag(warning, compiler=None, when=None):
|
||||
check_and_add_gcc_flag(warning, compiler, when, check=False)
|
||||
@@ -0,0 +1,13 @@
|
||||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
# We support C++14, but we don't want to enable the sized deallocation
|
||||
# facilities in C++14 yet.
|
||||
check_and_add_gcc_flag('-fno-sized-deallocation', compiler=cxx_compiler)
|
||||
|
||||
# Please keep these last in this file.
|
||||
add_old_configure_assignment('_COMPILATION_CFLAGS', compilation_cflags)
|
||||
add_old_configure_assignment('_COMPILATION_CXXFLAGS', compilation_cxxflags)
|
||||
@@ -179,7 +179,6 @@ def old_configure_options(*options):
|
||||
'--enable-directshow',
|
||||
'--enable-dtrace',
|
||||
'--enable-dump-painting',
|
||||
'--enable-eme',
|
||||
'--enable-elf-hack',
|
||||
'--enable-extensions',
|
||||
'--enable-faststripe',
|
||||
@@ -197,6 +196,7 @@ def old_configure_options(*options):
|
||||
'--enable-ios-target',
|
||||
'--enable-jitspew',
|
||||
'--enable-js-lto',
|
||||
'--enable-leak-sanitizer',
|
||||
'--enable-libjpeg-turbo',
|
||||
'--enable-libproxy',
|
||||
'--enable-llvm-hacks',
|
||||
@@ -246,6 +246,7 @@ def old_configure_options(*options):
|
||||
'--enable-thread-sanitizer',
|
||||
'--enable-trace-logging',
|
||||
'--enable-ui-locale',
|
||||
'--enable-undefined-sanitizer',
|
||||
'--enable-universalchardet',
|
||||
'--enable-updater',
|
||||
'--enable-url-classifier',
|
||||
@@ -276,7 +277,9 @@ def old_configure_options(*options):
|
||||
'--with-ios-sdk',
|
||||
'--with-jitreport-granularity',
|
||||
'--with-macbundlename-prefix',
|
||||
'--with-macbundle-entitlement',
|
||||
'--with-macbundle-identity',
|
||||
'--with-macbundle-type',
|
||||
'--with-macos-private-frameworks',
|
||||
'--with-macos-sdk',
|
||||
'--with-nspr-cflags',
|
||||
@@ -303,6 +306,8 @@ def old_configure_options(*options):
|
||||
'--enable-ldap',
|
||||
'--enable-mapi',
|
||||
'--enable-calendar',
|
||||
'--enable-inspector',
|
||||
'--enable-irc',
|
||||
'--enable-incomplete-external-linkage',
|
||||
'--enable-mailnews',
|
||||
'--enable-mailnews-oauth2',
|
||||
|
||||
@@ -171,6 +171,9 @@ include('compilers-util.configure')
|
||||
def try_preprocess(compiler, language, source):
|
||||
return try_invoke_compiler(compiler, language, source, ['-E'])
|
||||
|
||||
def msvc_std14(): return '-std:c++14'
|
||||
def msvc_std17(): return '-std:c++17'
|
||||
|
||||
@imports(_from='mozbuild.configure.constants', _import='CompilerType')
|
||||
@imports(_from='mozbuild.configure.constants',
|
||||
_import='CPU_preprocessor_checks')
|
||||
@@ -279,6 +282,13 @@ def get_compiler_info(compiler, language):
|
||||
'Unknown compiler or compiler not supported.')
|
||||
|
||||
cplusplus = int(data.get('cplusplus', '0L').rstrip('L'))
|
||||
if language == 'C++' and type=='msvc' and cplusplus == 199711:
|
||||
# Note: MSVC still reports 199711L for __cplusplus. Fix the report by
|
||||
# assuming it does what we asked it to do.
|
||||
if msvc_std14() in compiler:
|
||||
cplusplus = 201402
|
||||
elif msvc_std17() in compiler:
|
||||
cplusplus = 201703
|
||||
stdc_version = int(data.get('STDC_VERSION', '0L').rstrip('L'))
|
||||
|
||||
version = data.get('VERSION')
|
||||
@@ -330,16 +340,16 @@ def check_compiler(compiler, language, target):
|
||||
if info.type in ('clang-cl', 'clang', 'gcc'):
|
||||
append_flag('-std=gnu99')
|
||||
|
||||
# Note: MSVC, while supporting C++11, still reports 199711L for __cplusplus.
|
||||
# Note: this is a strict version check because we used to always add
|
||||
# -std=gnu++11.
|
||||
cxx17_version = 201703
|
||||
if info.language == 'C++':
|
||||
if info.type in ('clang', 'gcc') and info.language_version != 201103:
|
||||
append_flag('-std=gnu++11')
|
||||
# MSVC 2015 headers include C++14 features, but don't guard them
|
||||
# with appropriate checks.
|
||||
if info.type == 'clang-cl' and info.language_version != 201402:
|
||||
append_flag('-std=c++14')
|
||||
if info.language_version != cxx17_version:
|
||||
# Compiler doesn't default to C++17, so add the appropriate flag.
|
||||
if info.type in ('clang', 'gcc'):
|
||||
# We're on Clang or GCC, enable C++17 and add GNU extensions.
|
||||
append_flag('-std=gnu++17')
|
||||
else:
|
||||
# We're on MSVC; enable C++17 language mode.
|
||||
append_flag('-std:c++17')
|
||||
|
||||
# We force clang-cl to emulate Visual C++ 2015 Update 3 with fallback to
|
||||
# cl.exe.
|
||||
@@ -644,11 +654,17 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
|
||||
host_or_target)
|
||||
|
||||
# Check that the additional flags we got are enough to not require any
|
||||
# more flags.
|
||||
if info.flags:
|
||||
flags += info.flags
|
||||
info = check_compiler(wrapper + [compiler] + flags, language,
|
||||
host_or_target)
|
||||
# more flags. If we get an exception, just ignore it; it's liable to be
|
||||
# invalid command-line flags, which means the compiler we're checking
|
||||
# doesn't support those command-line flags and will fail one or more of
|
||||
# the checks below.
|
||||
try:
|
||||
if info.flags:
|
||||
flags += info.flags
|
||||
info = check_compiler(wrapper + [compiler] + flags, language,
|
||||
host_or_target)
|
||||
except FatalCheckError:
|
||||
pass
|
||||
|
||||
if not info.target_cpu or info.target_cpu != host_or_target.cpu:
|
||||
raise FatalCheckError(
|
||||
@@ -674,10 +690,6 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
|
||||
info.target_endianness or 'unknown', host_or_target_str,
|
||||
host_or_target.endianness))
|
||||
|
||||
if info.flags:
|
||||
raise FatalCheckError(
|
||||
'Unknown compiler or compiler not supported.')
|
||||
|
||||
# Compiler version checks
|
||||
# ===================================================
|
||||
# Check the compiler version here instead of in `compiler_version` so
|
||||
@@ -689,7 +701,7 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
|
||||
% info.version)
|
||||
|
||||
# If you want to bump the version check here search for
|
||||
# __cpp_static_assert above, and see the associated comment.
|
||||
# cxx_alignof above, and see the associated comment.
|
||||
if info.type == 'clang' and not info.version:
|
||||
raise FatalCheckError(
|
||||
'Only clang/llvm 3.6 or newer is supported.')
|
||||
@@ -704,6 +716,10 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
|
||||
'See https://developer.mozilla.org/en/'
|
||||
'Windows_Build_Prerequisites' % info.version)
|
||||
|
||||
if info.flags:
|
||||
raise FatalCheckError(
|
||||
'Unknown compiler or compiler not supported.')
|
||||
|
||||
return namespace(
|
||||
wrapper=wrapper,
|
||||
compiler=compiler,
|
||||
|
||||
@@ -18,9 +18,6 @@ add_old_configure_assignment(
|
||||
# lots of useful warnings
|
||||
add_gcc_warning('-Wall')
|
||||
|
||||
# catches C++ version forward-compat issues
|
||||
add_gcc_warning('-Wc++11-compat', cxx_compiler)
|
||||
|
||||
# catches bugs, e.g. "if (c); foo();", few false positives
|
||||
add_gcc_warning('-Wempty-body')
|
||||
|
||||
@@ -55,10 +52,7 @@ check_and_add_gcc_warning('-Wclass-varargs')
|
||||
check_and_add_gcc_warning('-Wloop-analysis')
|
||||
|
||||
# catches C++ version forward-compat issues
|
||||
check_and_add_gcc_warning('-Wc++11-compat-pedantic', cxx_compiler)
|
||||
check_and_add_gcc_warning('-Wc++14-compat', cxx_compiler)
|
||||
check_and_add_gcc_warning('-Wc++14-compat-pedantic', cxx_compiler)
|
||||
check_and_add_gcc_warning('-Wc++1z-compat', cxx_compiler)
|
||||
# check_and_add_gcc_warning('-Wc++2a-compat', cxx_compiler)
|
||||
|
||||
# catches unintentional switch case fallthroughs
|
||||
check_and_add_gcc_warning('-Wimplicit-fallthrough', cxx_compiler)
|
||||
|
||||
@@ -9,9 +9,6 @@ if CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION'] or CONFIG['MOZ_LIBSTDCXX_HOST_VERSION'
|
||||
if CONFIG['USE_ELF_HACK']:
|
||||
DIRS += ['elfhack']
|
||||
|
||||
if CONFIG['LLVM_SYMBOLIZER']:
|
||||
FINAL_TARGET_FILES += ['/' + CONFIG['LLVM_SYMBOLIZER']]
|
||||
|
||||
SDK_FILES.bin += [
|
||||
'run-mozilla.sh',
|
||||
]
|
||||
|
||||
@@ -51,12 +51,12 @@ public:
|
||||
// Don't use this method for anything else than debugging!
|
||||
void CreateAnonymizedSuffix(nsACString& aStr) const;
|
||||
|
||||
MOZ_MUST_USE bool PopulateFromSuffix(const nsACString& aStr);
|
||||
[[nodiscard]] bool PopulateFromSuffix(const nsACString& aStr);
|
||||
|
||||
// Populates the attributes from a string like
|
||||
// |uri!key1=value1&key2=value2| and returns the uri without the suffix.
|
||||
MOZ_MUST_USE bool PopulateFromOrigin(const nsACString& aOrigin,
|
||||
nsACString& aOriginNoSuffix);
|
||||
[[nodiscard]] bool PopulateFromOrigin(const nsACString& aOrigin,
|
||||
nsACString& aOriginNoSuffix);
|
||||
|
||||
// Helper function to match mIsPrivateBrowsing to existing private browsing
|
||||
// flags. Once all other flags are removed, this can be removed too.
|
||||
|
||||
@@ -82,6 +82,7 @@ included_inclnames_to_ignore = set([
|
||||
'unicode/plurrule.h', # ICU
|
||||
'unicode/timezone.h', # ICU
|
||||
'unicode/ucal.h', # ICU
|
||||
'unicode/uchar.h', # ICU
|
||||
'unicode/uclean.h', # ICU
|
||||
'unicode/ucol.h', # ICU
|
||||
'unicode/udat.h', # ICU
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
; 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/.
|
||||
|
||||
LIBRARY lgpllibs.dll
|
||||
|
||||
EXPORTS
|
||||
av_rdft_init
|
||||
av_rdft_calc
|
||||
av_rdft_end
|
||||
Vendored
+2
-6
@@ -4,14 +4,10 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
# The lgpllibs library stores symbols from third-party LGPL licensed libraries,
|
||||
# such as libav and libsoundtouch. It fulfills the requirement of dynamically
|
||||
# linking these symbols into gecko.
|
||||
# such as libsoundtouch. It fulfills the requirement of dynamically linking
|
||||
# these symbols into Goanna.
|
||||
#
|
||||
# Any library added here should also be reflected in the about:license page.
|
||||
|
||||
GeckoSharedLibrary('lgpllibs', linkage=None)
|
||||
SHARED_LIBRARY_NAME = 'lgpllibs'
|
||||
|
||||
if CONFIG['MOZ_LIBAV_FFT']:
|
||||
DIRS += ['/media/libav']
|
||||
DEFFILE = SRCDIR + '/lgpllibs.def'
|
||||
@@ -8,4 +8,4 @@
|
||||
# Referenced by milestone.py.
|
||||
#--------------------------------------------------------
|
||||
|
||||
6.2.0
|
||||
6.5.0
|
||||
+24801
-12689
File diff suppressed because it is too large.
Load diff
+896
-181
File diff suppressed because it is too large.
Load diff
@@ -2509,6 +2509,10 @@ var Debugger =
|
||||
|
||||
var Attribute = _require9.Attribute;
|
||||
|
||||
var _require23 = __webpack_require__(460);
|
||||
|
||||
var BigInt = _require23.BigInt;
|
||||
|
||||
var _require10 = __webpack_require__(47);
|
||||
|
||||
var DateTime = _require10.DateTime;
|
||||
@@ -2565,7 +2569,7 @@ var Debugger =
|
||||
// XXX there should be a way for extensions to register a new
|
||||
// or modify an existing rep.
|
||||
|
||||
var reps = [RegExp, StyleSheet, Event, DateTime, TextNode, Attribute, Func, ArrayRep, Document, Window, ObjectWithText, ObjectWithURL, GripArray, GripMap, Grip, Undefined, Null, StringRep, Number, SymbolRep];
|
||||
var reps = [RegExp, StyleSheet, Event, DateTime, TextNode, Attribute, Func, ArrayRep, Document, Window, ObjectWithText, ObjectWithURL, GripArray, GripMap, Grip, Undefined, Null, StringRep, Number, BigInt, SymbolRep];
|
||||
|
||||
/**
|
||||
* Generic rep that is using for rendering native JS types or an object.
|
||||
@@ -2605,10 +2609,12 @@ var Debugger =
|
||||
var defaultRep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Obj;
|
||||
|
||||
var type = typeof object;
|
||||
if (type == "object" && object instanceof String) {
|
||||
type = "string";
|
||||
} else if (type == "object" && object.type === "symbol") {
|
||||
type = "symbol";
|
||||
if (type == "object") {
|
||||
if (object instanceof String) {
|
||||
type = "string";
|
||||
} else if (["symbol", "BigInt"].includes(object.type)) {
|
||||
type = object.type;
|
||||
}
|
||||
}
|
||||
|
||||
if (isGrip(object)) {
|
||||
@@ -58325,6 +58331,59 @@ var Debugger =
|
||||
setBundle
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 460 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var __WEBPACK_AMD_DEFINE_RESULT__;/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Make this available to both AMD and CJS environments
|
||||
|
||||
!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require, exports, module) {
|
||||
// Dependencies
|
||||
var React = __webpack_require__(2);
|
||||
|
||||
// Shortcuts
|
||||
var span = React.DOM.span;
|
||||
|
||||
/**
|
||||
* Renders a number
|
||||
*/
|
||||
|
||||
var BigInt = React.createClass({
|
||||
displayName: "BigInt",
|
||||
|
||||
propTypes: {
|
||||
object: React.PropTypes.object.isRequired
|
||||
},
|
||||
|
||||
render: function () {
|
||||
let {object} = this.props;
|
||||
let {text} = object;
|
||||
|
||||
return span({ className: "objectBox objectBox-number" }, `${text}n`);
|
||||
}
|
||||
});
|
||||
|
||||
function supportsObject(object, type) {
|
||||
return type == "BigInt";
|
||||
}
|
||||
|
||||
// Exports from this module
|
||||
|
||||
exports.BigInt = {
|
||||
rep: BigInt,
|
||||
supportsObject: supportsObject
|
||||
};
|
||||
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
||||
|
||||
|
||||
/***/ }
|
||||
/******/ ]);
|
||||
//# sourceMappingURL=bundle.js.map
|
||||
@@ -1068,7 +1068,7 @@ var Debugger =
|
||||
// be either 3, or 5, or 6. This influences support for strict
|
||||
// mode, the set of reserved words, support for getters and
|
||||
// setters and other features.
|
||||
ecmaVersion: 5,
|
||||
ecmaVersion: 6,
|
||||
// Turn on `strictSemicolons` to prevent the parser from doing
|
||||
// automatic semicolon insertion.
|
||||
strictSemicolons: false,
|
||||
|
||||
+3
-3
@@ -39,14 +39,14 @@ add_task(function* () {
|
||||
|
||||
// Calculate offsets to click in the middle of the first box quad.
|
||||
let rect = prop.editor.valueSpan.getBoundingClientRect();
|
||||
let firstQuad = prop.editor.valueSpan.getBoxQuads()[0];
|
||||
let firstQuadBounds = prop.editor.valueSpan.getBoxQuads()[0].getBounds();
|
||||
// For a multiline value, the first quad left edge is not aligned with the
|
||||
// bounding rect left edge. The offsets expected by focusEditableField are
|
||||
// relative to the bouding rectangle, so we need to translate the x-offset.
|
||||
let x = firstQuad.bounds.left - rect.left + firstQuad.bounds.width / 2;
|
||||
let x = firstQuadBounds.left - rect.left + firstQuadBounds.width / 2;
|
||||
// The first quad top edge is aligned with the bounding top edge, no
|
||||
// translation needed here.
|
||||
let y = firstQuad.bounds.height / 2;
|
||||
let y = firstQuadBounds.height / 2;
|
||||
|
||||
info("Focusing the css property editable value");
|
||||
let editor = yield focusEditableField(view, prop.editor.valueSpan, x, y);
|
||||
|
||||
@@ -283,7 +283,7 @@ AutocompletePopup.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
let {top, height} = quads[0].bounds;
|
||||
let {top, height} = quads[0].getBounds();
|
||||
let containerHeight = this._tooltip.panel.getBoundingClientRect().height;
|
||||
if (top < 0) {
|
||||
// Element is above container.
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Make this available to both AMD and CJS environments
|
||||
define(function (require, exports, module) {
|
||||
// Dependencies
|
||||
const React = require("devtools/client/shared/vendor/react");
|
||||
|
||||
// Shortcuts
|
||||
const { span } = React.DOM;
|
||||
|
||||
/**
|
||||
* Renders a BigInt
|
||||
*/
|
||||
const BigInt = React.createClass({
|
||||
displayName: "BigInt",
|
||||
|
||||
propTypes: {
|
||||
object: React.PropTypes.object.isRequired
|
||||
},
|
||||
|
||||
render: function () {
|
||||
let {object} = this.props;
|
||||
let {text} = object;
|
||||
|
||||
return (
|
||||
span({className: "objectBox objectBox-number"},
|
||||
`${text}n`
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
function supportsObject(object, type) {
|
||||
return (type == "BigInt");
|
||||
}
|
||||
|
||||
// Exports from this module
|
||||
|
||||
exports.BigInt = {
|
||||
rep: BigInt,
|
||||
supportsObject: supportsObject
|
||||
};
|
||||
});
|
||||
@@ -6,6 +6,7 @@
|
||||
DevToolsModules(
|
||||
'array.js',
|
||||
'attribute.js',
|
||||
'big-int.js',
|
||||
'caption.js',
|
||||
'comment-node.js',
|
||||
'date-time.js',
|
||||
|
||||
@@ -26,6 +26,7 @@ define(function (require, exports, module) {
|
||||
|
||||
// DOM types (grips)
|
||||
const { Attribute } = require("./attribute");
|
||||
const { BigInt } = require("./big-int");
|
||||
const { DateTime } = require("./date-time");
|
||||
const { Document } = require("./document");
|
||||
const { Event } = require("./event");
|
||||
@@ -70,6 +71,7 @@ define(function (require, exports, module) {
|
||||
Null,
|
||||
StringRep,
|
||||
Number,
|
||||
BigInt,
|
||||
SymbolRep,
|
||||
InfinityRep,
|
||||
NaNRep,
|
||||
@@ -111,10 +113,12 @@ define(function (require, exports, module) {
|
||||
*/
|
||||
function getRep(object, defaultRep = Obj) {
|
||||
let type = typeof object;
|
||||
if (type == "object" && object instanceof String) {
|
||||
type = "string";
|
||||
} else if (object && type == "object" && object.type) {
|
||||
type = object.type;
|
||||
if (type == "object") {
|
||||
if (object instanceof String) {
|
||||
type = "string";
|
||||
} else if (["symbol", "BigInt"].includes(object.type)) {
|
||||
type = object.type;
|
||||
}
|
||||
}
|
||||
|
||||
if (isGrip(object)) {
|
||||
|
||||
@@ -85,9 +85,9 @@ function* runTests(doc) {
|
||||
ok(arrow, "Tooltip has an arrow");
|
||||
|
||||
// Get the geometry of the anchor, the tooltip panel & arrow.
|
||||
let arrowBounds = arrow.getBoxQuads({relativeTo: doc})[0].bounds;
|
||||
let panelBounds = tooltip.panel.getBoxQuads({relativeTo: doc})[0].bounds;
|
||||
let anchorBounds = el.getBoxQuads({relativeTo: doc})[0].bounds;
|
||||
let arrowBounds = arrow.getBoxQuads({relativeTo: doc})[0].getBounds();
|
||||
let panelBounds = tooltip.panel.getBoxQuads({relativeTo: doc})[0].getBounds();
|
||||
let anchorBounds = el.getBoxQuads({relativeTo: doc})[0].getBounds();
|
||||
|
||||
let intersects = arrowBounds.left <= anchorBounds.right &&
|
||||
arrowBounds.right >= anchorBounds.left;
|
||||
|
||||
@@ -78,9 +78,9 @@ function* runTests(doc) {
|
||||
ok(arrow, "Tooltip has an arrow");
|
||||
|
||||
// Get the geometry of the anchor, the tooltip panel & arrow.
|
||||
let arrowBounds = arrow.getBoxQuads({relativeTo: doc})[0].bounds;
|
||||
let panelBounds = tooltip.panel.getBoxQuads({relativeTo: doc})[0].bounds;
|
||||
let anchorBounds = el.getBoxQuads({relativeTo: doc})[0].bounds;
|
||||
let arrowBounds = arrow.getBoxQuads({relativeTo: doc})[0].getBounds();
|
||||
let panelBounds = tooltip.panel.getBoxQuads({relativeTo: doc})[0].getBounds();
|
||||
let anchorBounds = el.getBoxQuads({relativeTo: doc})[0].getBounds();
|
||||
|
||||
let intersects = arrowBounds.left <= anchorBounds.right &&
|
||||
arrowBounds.right >= anchorBounds.left;
|
||||
|
||||
@@ -114,5 +114,5 @@ let runAutocompletionTest = Task.async(function* (editor) {
|
||||
*/
|
||||
function getPopupOffset({popup, input}) {
|
||||
let popupQuads = popup._panel.getBoxQuads({relativeTo: input});
|
||||
return popupQuads[0].bounds.left;
|
||||
return popupQuads[0].getBounds().left;
|
||||
}
|
||||
@@ -3236,14 +3236,6 @@ VariablesView.prototype.isOverridden = function (aItem) {
|
||||
* The variable's descriptor.
|
||||
*/
|
||||
VariablesView.isPrimitive = function (aDescriptor) {
|
||||
// For accessor property descriptors, the getter and setter need to be
|
||||
// contained in 'get' and 'set' properties.
|
||||
let getter = aDescriptor.get;
|
||||
let setter = aDescriptor.set;
|
||||
if (getter || setter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// As described in the remote debugger protocol, the value grip
|
||||
// must be contained in a 'value' property.
|
||||
let grip = aDescriptor.value;
|
||||
@@ -3261,7 +3253,8 @@ VariablesView.isPrimitive = function (aDescriptor) {
|
||||
type == "NaN" ||
|
||||
type == "-0" ||
|
||||
type == "symbol" ||
|
||||
type == "longString") {
|
||||
type == "longString" ||
|
||||
type == "BigInt") {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3354,6 +3347,10 @@ VariablesView.getGrip = function (aValue) {
|
||||
return { type: "-0" };
|
||||
}
|
||||
return aValue;
|
||||
case "bigint":
|
||||
return { type: "BigInt",
|
||||
text: aValue.toString(),
|
||||
};
|
||||
case "undefined":
|
||||
// document.all is also "undefined"
|
||||
if (aValue === undefined) {
|
||||
@@ -3496,6 +3493,10 @@ VariablesView.stringifiers.byType = {
|
||||
return keyString + " \u2192 " + valueString;
|
||||
},
|
||||
|
||||
BigInt: function (aGrip, aOptions) {
|
||||
return aGrip.text + "n";
|
||||
},
|
||||
|
||||
}; // VariablesView.stringifiers.byType
|
||||
|
||||
VariablesView.stringifiers.byObjectClass = {
|
||||
|
||||
@@ -176,9 +176,9 @@ const getRelativeRect = function (node, relativeTo) {
|
||||
// Width and Height can be taken from the rect.
|
||||
let {width, height} = node.getBoundingClientRect();
|
||||
|
||||
let quads = node.getBoxQuads({relativeTo});
|
||||
let top = quads[0].bounds.top;
|
||||
let left = quads[0].bounds.left;
|
||||
let quadBounds = node.getBoxQuads({relativeTo})[0].getBounds();
|
||||
let top = quadBounds.top;
|
||||
let left = quadBounds.left;
|
||||
|
||||
// Compute right and bottom coordinates using the rest of the data.
|
||||
let right = left + width;
|
||||
|
||||
@@ -1293,6 +1293,7 @@ Messages.Extended.prototype = extend(Messages.Simple.prototype, {
|
||||
{
|
||||
let map = {
|
||||
"number": "cm-number",
|
||||
"bigint": "cm-number",
|
||||
"longstring": "console-string",
|
||||
"string": "console-string",
|
||||
"regexp": "cm-string-2",
|
||||
@@ -3364,6 +3365,15 @@ Widgets.ObjectRenderers.add({
|
||||
render: WrappedPrimitiveRenderer,
|
||||
});
|
||||
|
||||
/**
|
||||
* The widget used for displaying BigInt previews.
|
||||
*/
|
||||
Widgets.ObjectRenderers.add({
|
||||
byClass: "BigInt",
|
||||
|
||||
render: WrappedPrimitiveRenderer,
|
||||
});
|
||||
|
||||
/**
|
||||
* The widget used for displaying String previews.
|
||||
*/
|
||||
|
||||
@@ -3071,7 +3071,10 @@ function nodeHasSize(node) {
|
||||
}
|
||||
|
||||
let quads = node.getBoxQuads();
|
||||
return quads.length && quads.some(quad => quad.bounds.width && quad.bounds.height);
|
||||
return quads.some(quad => {
|
||||
let bounds = quad.getBounds();
|
||||
return bounds.width && bounds.height;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2159,6 +2159,12 @@ function createValueGrip(value, pool, makeObjectGrip) {
|
||||
}
|
||||
return value;
|
||||
|
||||
case "bigint":
|
||||
return {
|
||||
type: "BigInt",
|
||||
text: value.toString(),
|
||||
};
|
||||
|
||||
case "undefined":
|
||||
return { type: "undefined" };
|
||||
|
||||
|
||||
@@ -41,25 +41,15 @@ function test_object_grip()
|
||||
|
||||
let objClient = gThreadClient.pauseGrip(args[0]);
|
||||
objClient.getPrototypeAndProperties(function (aResponse) {
|
||||
do_check_eq(aResponse.ownProperties.a.configurable, true);
|
||||
do_check_eq(aResponse.ownProperties.a.enumerable, true);
|
||||
do_check_eq(aResponse.ownProperties.a.writable, true);
|
||||
do_check_eq(aResponse.ownProperties.a.value.type, "Infinity");
|
||||
const {a, b, c, d, e, f, g} = aResponse.ownProperties;
|
||||
|
||||
do_check_eq(aResponse.ownProperties.b.configurable, true);
|
||||
do_check_eq(aResponse.ownProperties.b.enumerable, true);
|
||||
do_check_eq(aResponse.ownProperties.b.writable, true);
|
||||
do_check_eq(aResponse.ownProperties.b.value.type, "-Infinity");
|
||||
|
||||
do_check_eq(aResponse.ownProperties.c.configurable, true);
|
||||
do_check_eq(aResponse.ownProperties.c.enumerable, true);
|
||||
do_check_eq(aResponse.ownProperties.c.writable, true);
|
||||
do_check_eq(aResponse.ownProperties.c.value.type, "NaN");
|
||||
|
||||
do_check_eq(aResponse.ownProperties.d.configurable, true);
|
||||
do_check_eq(aResponse.ownProperties.d.enumerable, true);
|
||||
do_check_eq(aResponse.ownProperties.d.writable, true);
|
||||
do_check_eq(aResponse.ownProperties.d.value.type, "-0");
|
||||
testPropertyType(a, "Infinity");
|
||||
testPropertyType(b, "-Infinity");
|
||||
testPropertyType(c, "NaN");
|
||||
testPropertyType(d, "-0");
|
||||
testPropertyType(e, "BigInt");
|
||||
testPropertyType(f, "BigInt");
|
||||
testPropertyType(g, "BigInt");
|
||||
|
||||
gThreadClient.resume(function () {
|
||||
gClient.close().then(gCallback);
|
||||
@@ -67,6 +57,20 @@ function test_object_grip()
|
||||
});
|
||||
});
|
||||
|
||||
gDebuggee.eval("stopMe({ a: Infinity, b: -Infinity, c: NaN, d: -0 })");
|
||||
gDebuggee.eval(`stopMe({
|
||||
a: Infinity,
|
||||
b: -Infinity,
|
||||
c: NaN,
|
||||
d: -0,
|
||||
e: 1n,
|
||||
f: -2n,
|
||||
g: 0n,
|
||||
})`);
|
||||
}
|
||||
|
||||
function testPropertyType(prop, expectedType) {
|
||||
do_check_eq(prop.configurable, true);
|
||||
do_check_eq(prop.enumerable, true);
|
||||
do_check_eq(prop.writable, true);
|
||||
do_check_eq(prop.value.type, expectedType);
|
||||
}
|
||||
@@ -1299,7 +1299,7 @@ var defaultOptions = {
|
||||
// be either 3, or 5, or 6. This influences support for strict
|
||||
// mode, the set of reserved words, support for getters and
|
||||
// setters and other features.
|
||||
ecmaVersion: 5,
|
||||
ecmaVersion: 6,
|
||||
// Source type ("script" or "module") for different semantics
|
||||
sourceType: "script",
|
||||
// `onInsertedSemicolon` can be a callback that will be called
|
||||
|
||||
@@ -175,6 +175,11 @@ exports.getFrameOffsets = getFrameOffsets;
|
||||
/**
|
||||
* Get box quads adjusted for iframes and zoom level.
|
||||
*
|
||||
* Warning: this function returns things that look like DOMQuad objects but
|
||||
* aren't (they resemble an old version of the spec). Unlike the return value
|
||||
* of node.getBoxQuads, they have a .bounds property and not a .getBounds()
|
||||
* method.
|
||||
*
|
||||
* @param {DOMWindow} boundaryWindow
|
||||
* The window where to stop to iterate. If `null` is given, the top
|
||||
* window is used.
|
||||
@@ -206,6 +211,7 @@ function getAdjustedQuads(boundaryWindow, node, region) {
|
||||
|
||||
let adjustedQuads = [];
|
||||
for (let quad of quads) {
|
||||
let bounds = quad.getBounds();
|
||||
adjustedQuads.push({
|
||||
p1: {
|
||||
w: quad.p1.w * scale,
|
||||
@@ -232,14 +238,14 @@ function getAdjustedQuads(boundaryWindow, node, region) {
|
||||
z: quad.p4.z * scale
|
||||
},
|
||||
bounds: {
|
||||
bottom: quad.bounds.bottom * scale + yOffset,
|
||||
height: quad.bounds.height * scale,
|
||||
left: quad.bounds.left * scale + xOffset,
|
||||
right: quad.bounds.right * scale + xOffset,
|
||||
top: quad.bounds.top * scale + yOffset,
|
||||
width: quad.bounds.width * scale,
|
||||
x: quad.bounds.x * scale + xOffset,
|
||||
y: quad.bounds.y * scale + yOffset
|
||||
bottom: bounds.bottom * scale + yOffset,
|
||||
height: bounds.height * scale,
|
||||
left: bounds.left * scale + xOffset,
|
||||
right: bounds.right * scale + xOffset,
|
||||
top: bounds.top * scale + yOffset,
|
||||
width: bounds.width * scale,
|
||||
x: bounds.x * scale + xOffset,
|
||||
y: bounds.y * scale + yOffset
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -75,6 +75,8 @@ Crypto::GetRandomValues(JSContext* aCx, const ArrayBufferView& aArray,
|
||||
case js::Scalar::Uint16:
|
||||
case js::Scalar::Int32:
|
||||
case js::Scalar::Uint32:
|
||||
case js::Scalar::BigInt64:
|
||||
case js::Scalar::BigUint64:
|
||||
break;
|
||||
default:
|
||||
aRv.Throw(NS_ERROR_DOM_TYPE_MISMATCH_ERR);
|
||||
@@ -113,6 +115,27 @@ Crypto::GetRandomValues(JSContext* aCx, const ArrayBufferView& aArray,
|
||||
aRetval.set(view);
|
||||
}
|
||||
|
||||
void Crypto::RandomUUID(nsAString& aRetVal)
|
||||
{
|
||||
// NSID_LENGTH == 39 == 36 UUID chars + 2 curly braces + 1 NUL byte
|
||||
static_assert(NSID_LENGTH == 39, "Crypto:RandomUUID: NSID_LENGTH must be 39");
|
||||
|
||||
nsCOMPtr<nsIUUIDGenerator> uuidgen =
|
||||
do_GetService("@mozilla.org/uuid-generator;1");
|
||||
|
||||
nsID uuid;
|
||||
|
||||
nsresult rv = uuidgen->GenerateUUIDInPlace(&uuid);
|
||||
|
||||
char uuidBuffer[NSID_LENGTH];
|
||||
uuid.ToProvidedString(uuidBuffer);
|
||||
|
||||
nsCString asciiString(uuidBuffer);
|
||||
|
||||
// Convert UUID chars to UTF-16 retval, omitting the curly braces and NUL
|
||||
CopyASCIItoUTF16(Substring(asciiString, 1, NSID_LENGTH - 3), aRetVal);
|
||||
}
|
||||
|
||||
SubtleCrypto*
|
||||
Crypto::Subtle()
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "mozilla/dom/SubtleCrypto.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "mozilla/dom/TypedArray.h"
|
||||
#define NS_DOMCRYPTO_CID \
|
||||
@@ -39,6 +40,8 @@ public:
|
||||
JS::MutableHandle<JSObject*> aRetval,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void RandomUUID(nsAString& aRetVal);
|
||||
|
||||
SubtleCrypto*
|
||||
Subtle();
|
||||
|
||||
|
||||
+379
-29
@@ -17,9 +17,15 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "js/Equality.h" // JS::SameValueZero
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
template <typename T>
|
||||
static void
|
||||
SetDataInMatrix(DOMMatrixReadOnly* aMatrix, const T* aData, int aLength, ErrorResult& aRv);
|
||||
|
||||
static const double radPerDegree = 2.0 * M_PI / 360.0;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMMatrixReadOnly, mParent)
|
||||
@@ -27,6 +33,210 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMMatrixReadOnly, mParent)
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMMatrixReadOnly, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMMatrixReadOnly, Release)
|
||||
|
||||
JSObject*
|
||||
DOMMatrixReadOnly::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return DOMMatrixReadOnlyBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry/#matrix-validate-and-fixup-2d
|
||||
static bool
|
||||
ValidateAndFixupMatrix2DInit(DOMMatrix2DInit& aMatrixInit, ErrorResult& aRv)
|
||||
{
|
||||
#define ValidateAliases(field, alias, fieldName, aliasName) \
|
||||
if ((field).WasPassed() && (alias).WasPassed() && \
|
||||
!JS::SameValueZero((field).Value(), (alias).Value())) { \
|
||||
aRv.ThrowTypeError<MSG_MATRIX_INIT_CONFLICTING_VALUE>((fieldName), \
|
||||
(aliasName)); \
|
||||
return false; \
|
||||
}
|
||||
#define SetFromAliasOrDefault(field, alias, defaultValue) \
|
||||
if (!(field).WasPassed()) { \
|
||||
if ((alias).WasPassed()) { \
|
||||
(field).Construct((alias).Value()); \
|
||||
} else { \
|
||||
(field).Construct(defaultValue); \
|
||||
} \
|
||||
}
|
||||
#define ValidateAndSet(field, alias, fieldName, aliasName, defaultValue) \
|
||||
ValidateAliases((field), (alias), NS_LITERAL_STRING(fieldName), \
|
||||
NS_LITERAL_STRING(aliasName)); \
|
||||
SetFromAliasOrDefault((field), (alias), (defaultValue));
|
||||
|
||||
ValidateAndSet(aMatrixInit.mM11, aMatrixInit.mA, "m11", "a", 1);
|
||||
ValidateAndSet(aMatrixInit.mM12, aMatrixInit.mB, "m12", "b", 0);
|
||||
ValidateAndSet(aMatrixInit.mM21, aMatrixInit.mC, "m21", "c", 0);
|
||||
ValidateAndSet(aMatrixInit.mM22, aMatrixInit.mD, "m22", "d", 1);
|
||||
ValidateAndSet(aMatrixInit.mM41, aMatrixInit.mE, "m41", "e", 0);
|
||||
ValidateAndSet(aMatrixInit.mM42, aMatrixInit.mF, "m42", "f", 0);
|
||||
|
||||
return true;
|
||||
|
||||
#undef ValidateAliases
|
||||
#undef SetFromAliasOrDefault
|
||||
#undef ValidateAndSet
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry/#matrix-validate-and-fixup
|
||||
static bool
|
||||
ValidateAndFixupMatrixInit(DOMMatrixInit& aMatrixInit, ErrorResult& aRv)
|
||||
{
|
||||
#define Check3DField(field, fieldName, defaultValue) \
|
||||
if ((field) != (defaultValue)) { \
|
||||
if (!aMatrixInit.mIs2D.WasPassed()) { \
|
||||
aMatrixInit.mIs2D.Construct(false); \
|
||||
return true; \
|
||||
} \
|
||||
if (aMatrixInit.mIs2D.Value()) { \
|
||||
aRv.ThrowTypeError<MSG_MATRIX_INIT_EXCEEDS_2D>( \
|
||||
NS_LITERAL_STRING(fieldName)); \
|
||||
return false; \
|
||||
} \
|
||||
}
|
||||
|
||||
if (!ValidateAndFixupMatrix2DInit(aMatrixInit, aRv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Check3DField(aMatrixInit.mM13, "m13", 0);
|
||||
Check3DField(aMatrixInit.mM14, "m14", 0);
|
||||
Check3DField(aMatrixInit.mM23, "m23", 0);
|
||||
Check3DField(aMatrixInit.mM24, "m24", 0);
|
||||
Check3DField(aMatrixInit.mM31, "m31", 0);
|
||||
Check3DField(aMatrixInit.mM32, "m32", 0);
|
||||
Check3DField(aMatrixInit.mM34, "m34", 0);
|
||||
Check3DField(aMatrixInit.mM43, "m43", 0);
|
||||
Check3DField(aMatrixInit.mM33, "m33", 1);
|
||||
Check3DField(aMatrixInit.mM44, "m44", 1);
|
||||
|
||||
if (!aMatrixInit.mIs2D.WasPassed()) {
|
||||
aMatrixInit.mIs2D.Construct(true);
|
||||
}
|
||||
return true;
|
||||
|
||||
#undef Check3DField
|
||||
}
|
||||
|
||||
void
|
||||
DOMMatrixReadOnly::SetDataFromMatrixInit(DOMMatrixInit& aMatrixInit)
|
||||
{
|
||||
const bool is2D = aMatrixInit.mIs2D.Value();
|
||||
MOZ_ASSERT(is2D == Is2D());
|
||||
if (is2D) {
|
||||
mMatrix2D->_11 = aMatrixInit.mM11.Value();
|
||||
mMatrix2D->_12 = aMatrixInit.mM12.Value();
|
||||
mMatrix2D->_21 = aMatrixInit.mM21.Value();
|
||||
mMatrix2D->_22 = aMatrixInit.mM22.Value();
|
||||
mMatrix2D->_31 = aMatrixInit.mM41.Value();
|
||||
mMatrix2D->_32 = aMatrixInit.mM42.Value();
|
||||
} else {
|
||||
mMatrix3D->_11 = aMatrixInit.mM11.Value();
|
||||
mMatrix3D->_12 = aMatrixInit.mM12.Value();
|
||||
mMatrix3D->_13 = aMatrixInit.mM13;
|
||||
mMatrix3D->_14 = aMatrixInit.mM14;
|
||||
mMatrix3D->_21 = aMatrixInit.mM21.Value();
|
||||
mMatrix3D->_22 = aMatrixInit.mM22.Value();
|
||||
mMatrix3D->_23 = aMatrixInit.mM23;
|
||||
mMatrix3D->_24 = aMatrixInit.mM24;
|
||||
mMatrix3D->_31 = aMatrixInit.mM31;
|
||||
mMatrix3D->_32 = aMatrixInit.mM32;
|
||||
mMatrix3D->_33 = aMatrixInit.mM33;
|
||||
mMatrix3D->_34 = aMatrixInit.mM34;
|
||||
mMatrix3D->_41 = aMatrixInit.mM41.Value();
|
||||
mMatrix3D->_42 = aMatrixInit.mM42.Value();
|
||||
mMatrix3D->_43 = aMatrixInit.mM43;
|
||||
mMatrix3D->_44 = aMatrixInit.mM44;
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<DOMMatrixReadOnly>
|
||||
DOMMatrixReadOnly::FromMatrix(const GlobalObject& aGlobal, const DOMMatrixInit& aMatrixInit, ErrorResult& aRv)
|
||||
{
|
||||
DOMMatrixInit matrixInit(aMatrixInit);
|
||||
if (!ValidateAndFixupMatrixInit(matrixInit, aRv)) {
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
RefPtr<DOMMatrixReadOnly> rval =
|
||||
new DOMMatrixReadOnly(aGlobal.GetAsSupports(), matrixInit.mIs2D.Value());
|
||||
rval->SetDataFromMatrixInit(matrixInit);
|
||||
return rval.forget();
|
||||
}
|
||||
|
||||
|
||||
already_AddRefed<DOMMatrixReadOnly>
|
||||
DOMMatrixReadOnly::FromFloat32Array(const GlobalObject& aGlobal, const Float32Array& aArray32, ErrorResult& aRv)
|
||||
{
|
||||
aArray32.ComputeLengthAndData();
|
||||
|
||||
const int length = aArray32.Length();
|
||||
const bool is2D = length == 6;
|
||||
RefPtr<DOMMatrixReadOnly> obj =
|
||||
new DOMMatrixReadOnly(aGlobal.GetAsSupports(), is2D);
|
||||
SetDataInMatrix(obj, aArray32.Data(), length, aRv);
|
||||
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMMatrixReadOnly>
|
||||
DOMMatrixReadOnly::FromFloat64Array(const GlobalObject& aGlobal, const Float64Array& aArray64, ErrorResult& aRv)
|
||||
{
|
||||
aArray64.ComputeLengthAndData();
|
||||
|
||||
const int length = aArray64.Length();
|
||||
const bool is2D = length == 6;
|
||||
RefPtr<DOMMatrixReadOnly> obj =
|
||||
new DOMMatrixReadOnly(aGlobal.GetAsSupports(), is2D);
|
||||
SetDataInMatrix(obj, aArray64.Data(), length, aRv);
|
||||
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMMatrixReadOnly>
|
||||
DOMMatrixReadOnly::Constructor(
|
||||
const GlobalObject& aGlobal,
|
||||
const Optional<StringOrUnrestrictedDoubleSequence>& aArg,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<DOMMatrixReadOnly> rval = new DOMMatrixReadOnly(aGlobal.GetAsSupports());
|
||||
if (!aArg.WasPassed()) {
|
||||
return rval.forget();
|
||||
}
|
||||
|
||||
const auto& arg = aArg.Value();
|
||||
if (arg.IsString()) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!win) {
|
||||
aRv.ThrowTypeError<MSG_ILLEGAL_CONSTRUCTOR>();
|
||||
return nullptr;
|
||||
}
|
||||
rval->SetMatrixValue(arg.GetAsString(), aRv);
|
||||
} else {
|
||||
const auto& sequence = arg.GetAsUnrestrictedDoubleSequence();
|
||||
SetDataInMatrix(rval, sequence.Elements(), sequence.Length(), aRv);
|
||||
}
|
||||
|
||||
return rval.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMMatrixReadOnly>
|
||||
DOMMatrixReadOnly::ReadStructuredClone(nsISupports* aParent, JSStructuredCloneReader* aReader)
|
||||
{
|
||||
uint8_t is2D;
|
||||
|
||||
if (!JS_ReadBytes(aReader, &is2D, 1)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<DOMMatrixReadOnly> rval = new DOMMatrixReadOnly(aParent, is2D);
|
||||
|
||||
if (!ReadStructuredCloneElements(aReader, rval)) {
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
return rval.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMMatrix>
|
||||
DOMMatrixReadOnly::Translate(double aTx,
|
||||
double aTy,
|
||||
@@ -127,10 +337,10 @@ DOMMatrixReadOnly::SkewY(double aSy) const
|
||||
}
|
||||
|
||||
already_AddRefed<DOMMatrix>
|
||||
DOMMatrixReadOnly::Multiply(const DOMMatrix& other) const
|
||||
DOMMatrixReadOnly::Multiply(const DOMMatrixInit& other, ErrorResult& aRv) const
|
||||
{
|
||||
RefPtr<DOMMatrix> retval = new DOMMatrix(mParent, *this);
|
||||
retval->MultiplySelf(other);
|
||||
retval->MultiplySelf(other, aRv);
|
||||
|
||||
return retval.forget();
|
||||
}
|
||||
@@ -307,6 +517,117 @@ DOMMatrixReadOnly::Stringify(nsAString& aResult)
|
||||
aResult = matrixStr;
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry/#structured-serialization
|
||||
bool
|
||||
DOMMatrixReadOnly::WriteStructuredClone(JSStructuredCloneWriter* aWriter) const
|
||||
{
|
||||
#define WriteFloatPair(f1, f2) \
|
||||
JS_WriteUint32Pair(aWriter, BitwiseCast<uint32_t>(f1), \
|
||||
BitwiseCast<uint32_t>(f2))
|
||||
|
||||
const uint8_t is2D = Is2D();
|
||||
|
||||
if (!JS_WriteBytes(aWriter, &is2D, 1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is2D == 1) {
|
||||
return WriteFloatPair(mMatrix2D->_11, mMatrix2D->_12) &&
|
||||
WriteFloatPair(mMatrix2D->_21, mMatrix2D->_22) &&
|
||||
WriteFloatPair(mMatrix2D->_31, mMatrix2D->_32);
|
||||
}
|
||||
|
||||
return WriteFloatPair(mMatrix3D->_11, mMatrix3D->_12) &&
|
||||
WriteFloatPair(mMatrix3D->_13, mMatrix3D->_14) &&
|
||||
WriteFloatPair(mMatrix3D->_21, mMatrix3D->_22) &&
|
||||
WriteFloatPair(mMatrix3D->_23, mMatrix3D->_24) &&
|
||||
WriteFloatPair(mMatrix3D->_31, mMatrix3D->_32) &&
|
||||
WriteFloatPair(mMatrix3D->_33, mMatrix3D->_34) &&
|
||||
WriteFloatPair(mMatrix3D->_41, mMatrix3D->_42) &&
|
||||
WriteFloatPair(mMatrix3D->_43, mMatrix3D->_44);
|
||||
#undef WriteFloatPair
|
||||
}
|
||||
|
||||
bool
|
||||
DOMMatrixReadOnly::ReadStructuredCloneElements(JSStructuredCloneReader* aReader, DOMMatrixReadOnly* matrix)
|
||||
{
|
||||
uint32_t high;
|
||||
uint32_t low;
|
||||
|
||||
#define ReadFloatPair(f1, f2) \
|
||||
if (!JS_ReadUint32Pair(aReader, &high, &low)) { \
|
||||
return false; \
|
||||
} \
|
||||
(*(f1) = BitwiseCast<float>(high)); \
|
||||
(*(f2) = BitwiseCast<float>(low));
|
||||
|
||||
if (matrix->Is2D() == 1) {
|
||||
ReadFloatPair(&(matrix->mMatrix2D->_11), &(matrix->mMatrix2D->_12));
|
||||
ReadFloatPair(&(matrix->mMatrix2D->_21), &(matrix->mMatrix2D->_22));
|
||||
ReadFloatPair(&(matrix->mMatrix2D->_31), &(matrix->mMatrix2D->_32));
|
||||
} else {
|
||||
ReadFloatPair(&(matrix->mMatrix3D->_11), &(matrix->mMatrix3D->_12));
|
||||
ReadFloatPair(&(matrix->mMatrix3D->_13), &(matrix->mMatrix3D->_14));
|
||||
ReadFloatPair(&(matrix->mMatrix3D->_21), &(matrix->mMatrix3D->_22));
|
||||
ReadFloatPair(&(matrix->mMatrix3D->_23), &(matrix->mMatrix3D->_24));
|
||||
ReadFloatPair(&(matrix->mMatrix3D->_31), &(matrix->mMatrix3D->_32));
|
||||
ReadFloatPair(&(matrix->mMatrix3D->_33), &(matrix->mMatrix3D->_34));
|
||||
ReadFloatPair(&(matrix->mMatrix3D->_41), &(matrix->mMatrix3D->_42));
|
||||
ReadFloatPair(&(matrix->mMatrix3D->_43), &(matrix->mMatrix3D->_44));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
#undef ReadFloatPair
|
||||
}
|
||||
|
||||
already_AddRefed<DOMMatrix>
|
||||
DOMMatrix::FromMatrix(nsISupports* aParent, const DOMMatrixInit& aMatrixInit, ErrorResult& aRv)
|
||||
{
|
||||
DOMMatrixInit matrixInit(aMatrixInit);
|
||||
if (!ValidateAndFixupMatrixInit(matrixInit, aRv)) {
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
RefPtr<DOMMatrix> matrix = new DOMMatrix(aParent, matrixInit.mIs2D.Value());
|
||||
matrix->SetDataFromMatrixInit(matrixInit);
|
||||
return matrix.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMMatrix>
|
||||
DOMMatrix::FromMatrix(const GlobalObject& aGlobal, const DOMMatrixInit& aMatrixInit, ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<DOMMatrix> matrix =
|
||||
FromMatrix(aGlobal.GetAsSupports(), aMatrixInit, aRv);
|
||||
return matrix.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMMatrix>
|
||||
DOMMatrix::FromFloat32Array(const GlobalObject& aGlobal, const Float32Array& aArray32, ErrorResult& aRv)
|
||||
{
|
||||
aArray32.ComputeLengthAndData();
|
||||
|
||||
const int length = aArray32.Length();
|
||||
const bool is2D = length == 6;
|
||||
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports(), is2D);
|
||||
SetDataInMatrix(obj, aArray32.Data(), length, aRv);
|
||||
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMMatrix>
|
||||
DOMMatrix::FromFloat64Array(const GlobalObject& aGlobal, const Float64Array& aArray64, ErrorResult& aRv)
|
||||
{
|
||||
aArray64.ComputeLengthAndData();
|
||||
|
||||
const int length = aArray64.Length();
|
||||
const bool is2D = length == 6;
|
||||
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports(), is2D);
|
||||
SetDataInMatrix(obj, aArray64.Data(), length, aRv);
|
||||
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMMatrix>
|
||||
DOMMatrix::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
{
|
||||
@@ -317,6 +638,11 @@ DOMMatrix::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
already_AddRefed<DOMMatrix>
|
||||
DOMMatrix::Constructor(const GlobalObject& aGlobal, const nsAString& aTransformList, ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!win) {
|
||||
aRv.ThrowTypeError<MSG_ILLEGAL_CONSTRUCTOR>();
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports());
|
||||
|
||||
obj = obj->SetMatrixValue(aTransformList, aRv);
|
||||
@@ -330,7 +656,9 @@ DOMMatrix::Constructor(const GlobalObject& aGlobal, const DOMMatrixReadOnly& aOt
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
template <typename T> void SetDataInMatrix(DOMMatrix* aMatrix, const T* aData, int aLength, ErrorResult& aRv)
|
||||
template <typename T>
|
||||
static void
|
||||
SetDataInMatrix(DOMMatrixReadOnly* aMatrix, const T* aData, int aLength, ErrorResult& aRv)
|
||||
{
|
||||
if (aLength == 16) {
|
||||
aMatrix->SetM11(aData[0]);
|
||||
@@ -357,28 +685,22 @@ template <typename T> void SetDataInMatrix(DOMMatrix* aMatrix, const T* aData, i
|
||||
aMatrix->SetE(aData[4]);
|
||||
aMatrix->SetF(aData[5]);
|
||||
} else {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
nsAutoString lengthStr;
|
||||
lengthStr.AppendInt(aLength);
|
||||
aRv.ThrowTypeError<MSG_MATRIX_INIT_LENGTH_WRONG>(lengthStr);
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<DOMMatrix>
|
||||
DOMMatrix::Constructor(const GlobalObject& aGlobal, const Float32Array& aArray32, ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports());
|
||||
aArray32.ComputeLengthAndData();
|
||||
SetDataInMatrix(obj, aArray32.Data(), aArray32.Length(), aRv);
|
||||
|
||||
return obj.forget();
|
||||
return FromFloat32Array(aGlobal, aArray32, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMMatrix>
|
||||
DOMMatrix::Constructor(const GlobalObject& aGlobal, const Float64Array& aArray64, ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports());
|
||||
aArray64.ComputeLengthAndData();
|
||||
SetDataInMatrix(obj, aArray64.Data(), aArray64.Length(), aRv);
|
||||
|
||||
return obj.forget();
|
||||
return FromFloat64Array(aGlobal, aArray64, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMMatrix>
|
||||
@@ -390,7 +712,26 @@ DOMMatrix::Constructor(const GlobalObject& aGlobal, const Sequence<double>& aNum
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
void DOMMatrix::Ensure3DMatrix()
|
||||
already_AddRefed<DOMMatrix>
|
||||
DOMMatrix::ReadStructuredClone(nsISupports* aParent, JSStructuredCloneReader* aReader)
|
||||
{
|
||||
uint8_t is2D;
|
||||
|
||||
if (!JS_ReadBytes(aReader, &is2D, 1)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<DOMMatrix> rval = new DOMMatrix(aParent, is2D);
|
||||
|
||||
if (!ReadStructuredCloneElements(aReader, rval)) {
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
return rval.forget();
|
||||
}
|
||||
|
||||
void
|
||||
DOMMatrixReadOnly::Ensure3DMatrix()
|
||||
{
|
||||
if (!mMatrix3D) {
|
||||
mMatrix3D = new gfx::Matrix4x4(gfx::Matrix4x4::From2D(*mMatrix2D));
|
||||
@@ -399,42 +740,44 @@ void DOMMatrix::Ensure3DMatrix()
|
||||
}
|
||||
|
||||
DOMMatrix*
|
||||
DOMMatrix::MultiplySelf(const DOMMatrix& aOther)
|
||||
DOMMatrix::MultiplySelf(const DOMMatrixInit& aOtherInit, ErrorResult& aRv)
|
||||
{
|
||||
if (aOther.Identity()) {
|
||||
RefPtr<DOMMatrix> other = FromMatrix(mParent, aOtherInit, aRv);
|
||||
if (other->Identity()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (aOther.Is2D()) {
|
||||
if (other->Is2D()) {
|
||||
if (mMatrix3D) {
|
||||
*mMatrix3D = gfx::Matrix4x4::From2D(*aOther.mMatrix2D) * *mMatrix3D;
|
||||
*mMatrix3D = gfx::Matrix4x4::From2D(*other->mMatrix2D) * *mMatrix3D;
|
||||
} else {
|
||||
*mMatrix2D = *aOther.mMatrix2D * *mMatrix2D;
|
||||
*mMatrix2D = *other->mMatrix2D * *mMatrix2D;
|
||||
}
|
||||
} else {
|
||||
Ensure3DMatrix();
|
||||
*mMatrix3D = *aOther.mMatrix3D * *mMatrix3D;
|
||||
*mMatrix3D = *other->mMatrix3D * *mMatrix3D;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
DOMMatrix*
|
||||
DOMMatrix::PreMultiplySelf(const DOMMatrix& aOther)
|
||||
DOMMatrix::PreMultiplySelf(const DOMMatrixInit& aOtherInit, ErrorResult& aRv)
|
||||
{
|
||||
if (aOther.Identity()) {
|
||||
RefPtr<DOMMatrix> other = FromMatrix(mParent, aOtherInit, aRv);
|
||||
if (other->Identity()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (aOther.Is2D()) {
|
||||
if (other->Is2D()) {
|
||||
if (mMatrix3D) {
|
||||
*mMatrix3D = *mMatrix3D * gfx::Matrix4x4::From2D(*aOther.mMatrix2D);
|
||||
*mMatrix3D = *mMatrix3D * gfx::Matrix4x4::From2D(*other->mMatrix2D);
|
||||
} else {
|
||||
*mMatrix2D = *mMatrix2D * *aOther.mMatrix2D;
|
||||
*mMatrix2D = *mMatrix2D * *other->mMatrix2D;
|
||||
}
|
||||
} else {
|
||||
Ensure3DMatrix();
|
||||
*mMatrix3D = *mMatrix3D * *aOther.mMatrix3D;
|
||||
*mMatrix3D = *mMatrix3D * *other->mMatrix3D;
|
||||
}
|
||||
|
||||
return this;
|
||||
@@ -617,8 +960,8 @@ DOMMatrix::InvertSelf()
|
||||
return this;
|
||||
}
|
||||
|
||||
DOMMatrix*
|
||||
DOMMatrix::SetMatrixValue(const nsAString& aTransformList, ErrorResult& aRv)
|
||||
DOMMatrixReadOnly*
|
||||
DOMMatrixReadOnly::SetMatrixValue(const nsAString& aTransformList, ErrorResult& aRv)
|
||||
{
|
||||
SVGTransformListParser parser(aTransformList);
|
||||
if (!parser.Parse()) {
|
||||
@@ -644,6 +987,13 @@ DOMMatrix::SetMatrixValue(const nsAString& aTransformList, ErrorResult& aRv)
|
||||
return this;
|
||||
}
|
||||
|
||||
DOMMatrix*
|
||||
DOMMatrix::SetMatrixValue(const nsAString& aTransformList, ErrorResult& aRv)
|
||||
{
|
||||
DOMMatrixReadOnly::SetMatrixValue(aTransformList, aRv);
|
||||
return this;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
DOMMatrix::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
|
||||
+157
-86
@@ -6,6 +6,7 @@
|
||||
#ifndef MOZILLA_DOM_DOMMATRIX_H_
|
||||
#define MOZILLA_DOM_DOMMATRIX_H_
|
||||
|
||||
#include "js/StructuredClone.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
@@ -22,7 +23,9 @@ namespace dom {
|
||||
class GlobalObject;
|
||||
class DOMMatrix;
|
||||
class DOMPoint;
|
||||
class StringOrUnrestrictedDoubleSequence;
|
||||
struct DOMPointInit;
|
||||
struct DOMMatrixInit;
|
||||
|
||||
class DOMMatrixReadOnly : public nsWrapperCache
|
||||
{
|
||||
@@ -42,9 +45,36 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
DOMMatrixReadOnly(nsISupports* aParent, const gfx::Matrix4x4& aMatrix)
|
||||
: mParent(aParent)
|
||||
{
|
||||
mMatrix3D = new gfx::Matrix4x4(aMatrix);
|
||||
}
|
||||
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMMatrixReadOnly)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMMatrixReadOnly)
|
||||
|
||||
nsISupports* GetParentObject() const { return mParent; }
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
static already_AddRefed<DOMMatrixReadOnly>
|
||||
FromMatrix(const GlobalObject& aGlobal, const DOMMatrixInit& aMatrixInit, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<DOMMatrixReadOnly>
|
||||
FromFloat32Array(const GlobalObject& aGlobal, const Float32Array& aArray32, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<DOMMatrixReadOnly>
|
||||
FromFloat64Array(const GlobalObject& aGlobal, const Float64Array& aArray64, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<DOMMatrixReadOnly>
|
||||
Constructor(const GlobalObject& aGlobal, const Optional<StringOrUnrestrictedDoubleSequence>& aArg, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<DOMMatrixReadOnly>
|
||||
ReadStructuredClone(nsISupports* aParent, JSStructuredCloneReader* aReader);
|
||||
|
||||
static bool
|
||||
ReadStructuredCloneElements(JSStructuredCloneReader* aReader, DOMMatrixReadOnly* matrix);
|
||||
|
||||
#define GetMatrixMember(entry2D, entry3D, default) \
|
||||
{ \
|
||||
if (mMatrix3D) { \
|
||||
@@ -88,88 +118,7 @@ public:
|
||||
#undef GetMatrixMember
|
||||
#undef Get3DMatrixMember
|
||||
|
||||
already_AddRefed<DOMMatrix> Translate(double aTx,
|
||||
double aTy,
|
||||
double aTz = 0) const;
|
||||
already_AddRefed<DOMMatrix> Scale(double aScale,
|
||||
double aOriginX = 0,
|
||||
double aOriginY = 0) const;
|
||||
already_AddRefed<DOMMatrix> Scale3d(double aScale,
|
||||
double aOriginX = 0,
|
||||
double aOriginY = 0,
|
||||
double aOriginZ = 0) const;
|
||||
already_AddRefed<DOMMatrix> ScaleNonUniform(double aScaleX,
|
||||
double aScaleY = 1.0,
|
||||
double aScaleZ = 1.0,
|
||||
double aOriginX = 0,
|
||||
double aOriginY = 0,
|
||||
double aOriginZ = 0) const;
|
||||
already_AddRefed<DOMMatrix> Rotate(double aAngle,
|
||||
double aOriginX = 0,
|
||||
double aOriginY = 0) const;
|
||||
already_AddRefed<DOMMatrix> RotateFromVector(double aX,
|
||||
double aY) const;
|
||||
already_AddRefed<DOMMatrix> RotateAxisAngle(double aX,
|
||||
double aY,
|
||||
double aZ,
|
||||
double aAngle) const;
|
||||
already_AddRefed<DOMMatrix> SkewX(double aSx) const;
|
||||
already_AddRefed<DOMMatrix> SkewY(double aSy) const;
|
||||
already_AddRefed<DOMMatrix> Multiply(const DOMMatrix& aOther) const;
|
||||
already_AddRefed<DOMMatrix> FlipX() const;
|
||||
already_AddRefed<DOMMatrix> FlipY() const;
|
||||
already_AddRefed<DOMMatrix> Inverse() const;
|
||||
|
||||
bool Is2D() const;
|
||||
bool Identity() const;
|
||||
already_AddRefed<DOMPoint> TransformPoint(const DOMPointInit& aPoint) const;
|
||||
void ToFloat32Array(JSContext* aCx,
|
||||
JS::MutableHandle<JSObject*> aResult,
|
||||
ErrorResult& aRv) const;
|
||||
void ToFloat64Array(JSContext* aCx,
|
||||
JS::MutableHandle<JSObject*> aResult,
|
||||
ErrorResult& aRv) const;
|
||||
void Stringify(nsAString& aResult);
|
||||
protected:
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
nsAutoPtr<gfx::Matrix> mMatrix2D;
|
||||
nsAutoPtr<gfx::Matrix4x4> mMatrix3D;
|
||||
|
||||
virtual ~DOMMatrixReadOnly() {}
|
||||
|
||||
private:
|
||||
DOMMatrixReadOnly() = delete;
|
||||
DOMMatrixReadOnly(const DOMMatrixReadOnly&) = delete;
|
||||
DOMMatrixReadOnly& operator=(const DOMMatrixReadOnly&) = delete;
|
||||
};
|
||||
|
||||
class DOMMatrix : public DOMMatrixReadOnly
|
||||
{
|
||||
public:
|
||||
explicit DOMMatrix(nsISupports* aParent)
|
||||
: DOMMatrixReadOnly(aParent)
|
||||
{}
|
||||
|
||||
DOMMatrix(nsISupports* aParent, const DOMMatrixReadOnly& other)
|
||||
: DOMMatrixReadOnly(aParent, other)
|
||||
{}
|
||||
|
||||
static already_AddRefed<DOMMatrix>
|
||||
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
||||
static already_AddRefed<DOMMatrix>
|
||||
Constructor(const GlobalObject& aGlobal, const nsAString& aTransformList, ErrorResult& aRv);
|
||||
static already_AddRefed<DOMMatrix>
|
||||
Constructor(const GlobalObject& aGlobal, const DOMMatrixReadOnly& aOther, ErrorResult& aRv);
|
||||
static already_AddRefed<DOMMatrix>
|
||||
Constructor(const GlobalObject& aGlobal, const Float32Array& aArray32, ErrorResult& aRv);
|
||||
static already_AddRefed<DOMMatrix>
|
||||
Constructor(const GlobalObject& aGlobal, const Float64Array& aArray64, ErrorResult& aRv);
|
||||
static already_AddRefed<DOMMatrix>
|
||||
Constructor(const GlobalObject& aGlobal, const Sequence<double>& aNumberSequence, ErrorResult& aRv);
|
||||
|
||||
nsISupports* GetParentObject() const { return mParent; }
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
// Defined here so we can construct DOMMatrixReadOnly objects.
|
||||
#define Set2DMatrixMember(entry2D, entry3D) \
|
||||
{ \
|
||||
if (mMatrix3D) { \
|
||||
@@ -214,8 +163,128 @@ public:
|
||||
#undef Set2DMatrixMember
|
||||
#undef Set3DMatrixMember
|
||||
|
||||
DOMMatrix* MultiplySelf(const DOMMatrix& aOther);
|
||||
DOMMatrix* PreMultiplySelf(const DOMMatrix& aOther);
|
||||
already_AddRefed<DOMMatrix> Translate(double aTx,
|
||||
double aTy,
|
||||
double aTz = 0) const;
|
||||
already_AddRefed<DOMMatrix> Scale(double aScale,
|
||||
double aOriginX = 0,
|
||||
double aOriginY = 0) const;
|
||||
already_AddRefed<DOMMatrix> Scale3d(double aScale,
|
||||
double aOriginX = 0,
|
||||
double aOriginY = 0,
|
||||
double aOriginZ = 0) const;
|
||||
already_AddRefed<DOMMatrix> ScaleNonUniform(double aScaleX,
|
||||
double aScaleY = 1.0,
|
||||
double aScaleZ = 1.0,
|
||||
double aOriginX = 0,
|
||||
double aOriginY = 0,
|
||||
double aOriginZ = 0) const;
|
||||
already_AddRefed<DOMMatrix> Rotate(double aAngle,
|
||||
double aOriginX = 0,
|
||||
double aOriginY = 0) const;
|
||||
already_AddRefed<DOMMatrix> RotateFromVector(double aX,
|
||||
double aY) const;
|
||||
already_AddRefed<DOMMatrix> RotateAxisAngle(double aX,
|
||||
double aY,
|
||||
double aZ,
|
||||
double aAngle) const;
|
||||
already_AddRefed<DOMMatrix> SkewX(double aSx) const;
|
||||
already_AddRefed<DOMMatrix> SkewY(double aSy) const;
|
||||
already_AddRefed<DOMMatrix> Multiply(const DOMMatrixInit& aOther,
|
||||
ErrorResult& aRv) const;
|
||||
already_AddRefed<DOMMatrix> FlipX() const;
|
||||
already_AddRefed<DOMMatrix> FlipY() const;
|
||||
already_AddRefed<DOMMatrix> Inverse() const;
|
||||
|
||||
bool Is2D() const;
|
||||
bool Identity() const;
|
||||
already_AddRefed<DOMPoint> TransformPoint(const DOMPointInit& aPoint) const;
|
||||
void ToFloat32Array(JSContext* aCx,
|
||||
JS::MutableHandle<JSObject*> aResult,
|
||||
ErrorResult& aRv) const;
|
||||
void ToFloat64Array(JSContext* aCx,
|
||||
JS::MutableHandle<JSObject*> aResult,
|
||||
ErrorResult& aRv) const;
|
||||
void Stringify(nsAString& aResult);
|
||||
bool WriteStructuredClone(JSStructuredCloneWriter* aWriter) const;
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
nsAutoPtr<gfx::Matrix> mMatrix2D;
|
||||
nsAutoPtr<gfx::Matrix4x4> mMatrix3D;
|
||||
|
||||
virtual ~DOMMatrixReadOnly() {}
|
||||
|
||||
/**
|
||||
* Sets data from a fully validated and fixed-up matrix init,
|
||||
* where all of its members are properly defined.
|
||||
* The init dictionary's dimension must match the matrix one.
|
||||
*/
|
||||
void SetDataFromMatrixInit(DOMMatrixInit& aMatrixInit);
|
||||
|
||||
DOMMatrixReadOnly* SetMatrixValue(const nsAString& aTransformList, ErrorResult& aRv);
|
||||
void Ensure3DMatrix();
|
||||
|
||||
DOMMatrixReadOnly(nsISupports* aParent, bool is2D) : mParent(aParent) {
|
||||
if (is2D) {
|
||||
mMatrix2D = new gfx::Matrix();
|
||||
} else {
|
||||
mMatrix3D = new gfx::Matrix4x4();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
DOMMatrixReadOnly() = delete;
|
||||
DOMMatrixReadOnly(const DOMMatrixReadOnly&) = delete;
|
||||
DOMMatrixReadOnly& operator=(const DOMMatrixReadOnly&) = delete;
|
||||
};
|
||||
|
||||
class DOMMatrix : public DOMMatrixReadOnly
|
||||
{
|
||||
public:
|
||||
explicit DOMMatrix(nsISupports* aParent)
|
||||
: DOMMatrixReadOnly(aParent)
|
||||
{}
|
||||
|
||||
DOMMatrix(nsISupports* aParent, const DOMMatrixReadOnly& other)
|
||||
: DOMMatrixReadOnly(aParent, other)
|
||||
{}
|
||||
|
||||
DOMMatrix(nsISupports* aParent, const gfx::Matrix4x4& aMatrix)
|
||||
: DOMMatrixReadOnly(aParent, aMatrix)
|
||||
{}
|
||||
|
||||
static already_AddRefed<DOMMatrix>
|
||||
FromMatrix(nsISupports* aParent, const DOMMatrixInit& aMatrixInit, ErrorResult& aRv);
|
||||
static already_AddRefed<DOMMatrix>
|
||||
FromMatrix(const GlobalObject& aGlobal, const DOMMatrixInit& aMatrixInit, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<DOMMatrix>
|
||||
FromFloat32Array(const GlobalObject& aGlobal, const Float32Array& aArray32, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<DOMMatrix>
|
||||
FromFloat64Array(const GlobalObject& aGlobal, const Float64Array& aArray64, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<DOMMatrix>
|
||||
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
||||
static already_AddRefed<DOMMatrix>
|
||||
Constructor(const GlobalObject& aGlobal, const nsAString& aTransformList, ErrorResult& aRv);
|
||||
static already_AddRefed<DOMMatrix>
|
||||
Constructor(const GlobalObject& aGlobal, const DOMMatrixReadOnly& aOther, ErrorResult& aRv);
|
||||
static already_AddRefed<DOMMatrix>
|
||||
Constructor(const GlobalObject& aGlobal, const Float32Array& aArray32, ErrorResult& aRv);
|
||||
static already_AddRefed<DOMMatrix>
|
||||
Constructor(const GlobalObject& aGlobal, const Float64Array& aArray64, ErrorResult& aRv);
|
||||
static already_AddRefed<DOMMatrix>
|
||||
Constructor(const GlobalObject& aGlobal, const Sequence<double>& aNumberSequence, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<DOMMatrix>
|
||||
ReadStructuredClone(nsISupports* aParent, JSStructuredCloneReader* aReader);
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
DOMMatrix* MultiplySelf(const DOMMatrixInit& aOther, ErrorResult& aRv);
|
||||
DOMMatrix* PreMultiplySelf(const DOMMatrixInit& aOther, ErrorResult& aRv);
|
||||
DOMMatrix* TranslateSelf(double aTx,
|
||||
double aTy,
|
||||
double aTz = 0);
|
||||
@@ -245,10 +314,12 @@ public:
|
||||
DOMMatrix* SkewYSelf(double aSy);
|
||||
DOMMatrix* InvertSelf();
|
||||
DOMMatrix* SetMatrixValue(const nsAString& aTransformList, ErrorResult& aRv);
|
||||
protected:
|
||||
void Ensure3DMatrix();
|
||||
|
||||
virtual ~DOMMatrix() {}
|
||||
|
||||
private:
|
||||
DOMMatrix(nsISupports* aParent, bool is2D)
|
||||
: DOMMatrixReadOnly(aParent, is2D) {}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
||||
+61
-2
@@ -16,9 +16,68 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMPointReadOnly, mParent)
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMPointReadOnly, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMPointReadOnly, Release)
|
||||
|
||||
already_AddRefed<DOMPointReadOnly>
|
||||
DOMPointReadOnly::FromPoint(const GlobalObject& aGlobal, const DOMPointInit& aParams)
|
||||
{
|
||||
RefPtr<DOMPointReadOnly> obj =
|
||||
new DOMPointReadOnly(aGlobal.GetAsSupports(), aParams.mX, aParams.mY,
|
||||
aParams.mZ, aParams.mW);
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMPointReadOnly>
|
||||
DOMPointReadOnly::Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
||||
double aZ, double aW, ErrorResult& aRV)
|
||||
{
|
||||
RefPtr<DOMPointReadOnly> obj =
|
||||
new DOMPointReadOnly(aGlobal.GetAsSupports(), aX, aY, aZ, aW);
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
JSObject*
|
||||
DOMPointReadOnly::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return DOMPointReadOnlyBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry/#structured-serialization
|
||||
bool
|
||||
DOMPointReadOnly::WriteStructuredClone(JSStructuredCloneWriter* aWriter) const
|
||||
{
|
||||
#define WriteDouble(d) \
|
||||
JS_WriteUint32Pair(aWriter, (BitwiseCast<uint64_t>(d) >> 32) & 0xffffffff, \
|
||||
BitwiseCast<uint64_t>(d) & 0xffffffff)
|
||||
|
||||
return WriteDouble(mX) && WriteDouble(mY) && WriteDouble(mZ) &&
|
||||
WriteDouble(mW);
|
||||
|
||||
#undef WriteDouble
|
||||
}
|
||||
|
||||
bool
|
||||
DOMPointReadOnly::ReadStructuredClone(JSStructuredCloneReader* aReader)
|
||||
{
|
||||
uint32_t high;
|
||||
uint32_t low;
|
||||
|
||||
#define ReadDouble(d) \
|
||||
if (!JS_ReadUint32Pair(aReader, &high, &low)) { \
|
||||
return false; \
|
||||
} \
|
||||
(*(d) = BitwiseCast<double>(static_cast<uint64_t>(high) << 32 | low))
|
||||
|
||||
ReadDouble(&mX);
|
||||
ReadDouble(&mY);
|
||||
ReadDouble(&mZ);
|
||||
ReadDouble(&mW);
|
||||
|
||||
return true;
|
||||
|
||||
#undef ReadDouble
|
||||
}
|
||||
|
||||
already_AddRefed<DOMPoint>
|
||||
DOMPoint::Constructor(const GlobalObject& aGlobal, const DOMPointInit& aParams,
|
||||
ErrorResult& aRV)
|
||||
DOMPoint::FromPoint(const GlobalObject& aGlobal, const DOMPointInit& aParams)
|
||||
{
|
||||
RefPtr<DOMPoint> obj =
|
||||
new DOMPoint(aGlobal.GetAsSupports(), aParams.mX, aParams.mY,
|
||||
|
||||
+17
-5
@@ -6,6 +6,7 @@
|
||||
#ifndef MOZILLA_DOMPOINT_H_
|
||||
#define MOZILLA_DOMPOINT_H_
|
||||
|
||||
#include "js/StructuredClone.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
@@ -23,8 +24,8 @@ struct DOMPointInit;
|
||||
class DOMPointReadOnly : public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
DOMPointReadOnly(nsISupports* aParent, double aX, double aY,
|
||||
double aZ, double aW)
|
||||
explicit DOMPointReadOnly(nsISupports* aParent, double aX = 0.0,
|
||||
double aY = 0.0, double aZ = 0.0, double aW = 1.0)
|
||||
: mParent(aParent)
|
||||
, mX(aX)
|
||||
, mY(aY)
|
||||
@@ -33,6 +34,12 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
static already_AddRefed<DOMPointReadOnly>
|
||||
FromPoint(const GlobalObject& aGlobal, const DOMPointInit& aParams);
|
||||
static already_AddRefed<DOMPointReadOnly>
|
||||
Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
||||
double aZ, double aW, ErrorResult& aRV);
|
||||
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMPointReadOnly)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMPointReadOnly)
|
||||
|
||||
@@ -41,6 +48,13 @@ public:
|
||||
double Z() const { return mZ; }
|
||||
double W() const { return mW; }
|
||||
|
||||
nsISupports* GetParentObject() const { return mParent; }
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
bool WriteStructuredClone(JSStructuredCloneWriter* aWriter) const;
|
||||
|
||||
bool ReadStructuredClone(JSStructuredCloneReader* aReader);
|
||||
|
||||
protected:
|
||||
virtual ~DOMPointReadOnly() {}
|
||||
|
||||
@@ -57,13 +71,11 @@ public:
|
||||
{}
|
||||
|
||||
static already_AddRefed<DOMPoint>
|
||||
Constructor(const GlobalObject& aGlobal, const DOMPointInit& aParams,
|
||||
ErrorResult& aRV);
|
||||
FromPoint(const GlobalObject& aGlobal, const DOMPointInit& aParams);
|
||||
static already_AddRefed<DOMPoint>
|
||||
Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
||||
double aZ, double aW, ErrorResult& aRV);
|
||||
|
||||
nsISupports* GetParentObject() const { return mParent; }
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
void SetX(double aX) { mX = aX; }
|
||||
|
||||
+103
-78
@@ -43,6 +43,32 @@ DOMQuad::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
return DOMQuadBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMQuad>
|
||||
DOMQuad::FromRect(const GlobalObject& aGlobal, const DOMRectInit& aInit)
|
||||
{
|
||||
nsISupports* parent = aGlobal.GetAsSupports();
|
||||
RefPtr<DOMQuad> obj = new DOMQuad(parent);
|
||||
obj->mPoints[0] = new DOMPoint(parent, aInit.mX, aInit.mY, 0, 1);
|
||||
obj->mPoints[1] =
|
||||
new DOMPoint(parent, aInit.mX + aInit.mWidth, aInit.mY, 0, 1);
|
||||
obj->mPoints[2] = new DOMPoint(parent, aInit.mX + aInit.mWidth,
|
||||
aInit.mY + aInit.mHeight, 0, 1);
|
||||
obj->mPoints[3] =
|
||||
new DOMPoint(parent, aInit.mX, aInit.mY + aInit.mHeight, 0, 1);
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMQuad>
|
||||
DOMQuad::FromQuad(const GlobalObject& aGlobal, const DOMQuadInit& aInit)
|
||||
{
|
||||
RefPtr<DOMQuad> obj = new DOMQuad(aGlobal.GetAsSupports());
|
||||
obj->mPoints[0] = DOMPoint::FromPoint(aGlobal, aInit.mP1);
|
||||
obj->mPoints[1] = DOMPoint::FromPoint(aGlobal, aInit.mP2);
|
||||
obj->mPoints[2] = DOMPoint::FromPoint(aGlobal, aInit.mP3);
|
||||
obj->mPoints[3] = DOMPoint::FromPoint(aGlobal, aInit.mP4);
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMQuad>
|
||||
DOMQuad::Constructor(const GlobalObject& aGlobal,
|
||||
const DOMPointInit& aP1,
|
||||
@@ -52,10 +78,10 @@ DOMQuad::Constructor(const GlobalObject& aGlobal,
|
||||
ErrorResult& aRV)
|
||||
{
|
||||
RefPtr<DOMQuad> obj = new DOMQuad(aGlobal.GetAsSupports());
|
||||
obj->mPoints[0] = DOMPoint::Constructor(aGlobal, aP1, aRV);
|
||||
obj->mPoints[1] = DOMPoint::Constructor(aGlobal, aP2, aRV);
|
||||
obj->mPoints[2] = DOMPoint::Constructor(aGlobal, aP3, aRV);
|
||||
obj->mPoints[3] = DOMPoint::Constructor(aGlobal, aP4, aRV);
|
||||
obj->mPoints[0] = DOMPoint::FromPoint(aGlobal, aP1);
|
||||
obj->mPoints[1] = DOMPoint::FromPoint(aGlobal, aP2);
|
||||
obj->mPoints[2] = DOMPoint::FromPoint(aGlobal, aP3);
|
||||
obj->mPoints[3] = DOMPoint::FromPoint(aGlobal, aP4);
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
@@ -73,87 +99,86 @@ DOMQuad::Constructor(const GlobalObject& aGlobal, const DOMRectReadOnly& aRect,
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
class DOMQuad::QuadBounds final : public DOMRectReadOnly
|
||||
void
|
||||
DOMQuad::GetHorizontalMinMax(double* aX1, double* aX2) const
|
||||
{
|
||||
public:
|
||||
explicit QuadBounds(DOMQuad* aQuad)
|
||||
: DOMRectReadOnly(aQuad->GetParentObject())
|
||||
, mQuad(aQuad)
|
||||
{}
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(QuadBounds, DOMRectReadOnly)
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
virtual double X() const override
|
||||
{
|
||||
double x1, x2;
|
||||
GetHorizontalMinMax(&x1, &x2);
|
||||
return x1;
|
||||
double x1, x2;
|
||||
x1 = x2 = Point(0)->X();
|
||||
for (uint32_t i = 1; i < 4; ++i) {
|
||||
double x = Point(i)->X();
|
||||
x1 = std::min(x1, x);
|
||||
x2 = std::max(x2, x);
|
||||
}
|
||||
virtual double Y() const override
|
||||
{
|
||||
double y1, y2;
|
||||
GetVerticalMinMax(&y1, &y2);
|
||||
return y1;
|
||||
*aX1 = x1;
|
||||
*aX2 = x2;
|
||||
}
|
||||
|
||||
void
|
||||
DOMQuad::GetVerticalMinMax(double* aY1, double* aY2) const
|
||||
{
|
||||
double y1, y2;
|
||||
y1 = y2 = Point(0)->Y();
|
||||
for (uint32_t i = 1; i < 4; ++i) {
|
||||
double y = Point(i)->Y();
|
||||
y1 = std::min(y1, y);
|
||||
y2 = std::max(y2, y);
|
||||
}
|
||||
virtual double Width() const override
|
||||
{
|
||||
double x1, x2;
|
||||
GetHorizontalMinMax(&x1, &x2);
|
||||
return x2 - x1;
|
||||
}
|
||||
virtual double Height() const override
|
||||
{
|
||||
double y1, y2;
|
||||
GetVerticalMinMax(&y1, &y2);
|
||||
return y2 - y1;
|
||||
}
|
||||
|
||||
void GetHorizontalMinMax(double* aX1, double* aX2) const
|
||||
{
|
||||
double x1, x2;
|
||||
x1 = x2 = mQuad->Point(0)->X();
|
||||
for (uint32_t i = 1; i < 4; ++i) {
|
||||
double x = mQuad->Point(i)->X();
|
||||
x1 = std::min(x1, x);
|
||||
x2 = std::max(x2, x);
|
||||
}
|
||||
*aX1 = x1;
|
||||
*aX2 = x2;
|
||||
}
|
||||
|
||||
void GetVerticalMinMax(double* aY1, double* aY2) const
|
||||
{
|
||||
double y1, y2;
|
||||
y1 = y2 = mQuad->Point(0)->Y();
|
||||
for (uint32_t i = 1; i < 4; ++i) {
|
||||
double y = mQuad->Point(i)->Y();
|
||||
y1 = std::min(y1, y);
|
||||
y2 = std::max(y2, y);
|
||||
}
|
||||
*aY1 = y1;
|
||||
*aY2 = y2;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~QuadBounds() {}
|
||||
|
||||
RefPtr<DOMQuad> mQuad;
|
||||
};
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(DOMQuad::QuadBounds, DOMRectReadOnly, mQuad)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DOMQuad::QuadBounds)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMRectReadOnly)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(DOMQuad::QuadBounds, DOMRectReadOnly)
|
||||
NS_IMPL_RELEASE_INHERITED(DOMQuad::QuadBounds, DOMRectReadOnly)
|
||||
*aY1 = y1;
|
||||
*aY2 = y2;
|
||||
}
|
||||
|
||||
DOMRectReadOnly*
|
||||
DOMQuad::Bounds() const
|
||||
DOMQuad::Bounds()
|
||||
{
|
||||
if (!mBounds) {
|
||||
mBounds = new QuadBounds(const_cast<DOMQuad*>(this));
|
||||
mBounds = GetBounds();
|
||||
}
|
||||
return mBounds;
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRectReadOnly>
|
||||
DOMQuad::GetBounds() const
|
||||
{
|
||||
double x1, x2;
|
||||
double y1, y2;
|
||||
|
||||
GetHorizontalMinMax(&x1, &x2);
|
||||
GetVerticalMinMax(&y1, &y2);
|
||||
|
||||
RefPtr<DOMRectReadOnly> rval = new DOMRectReadOnly(GetParentObject(),
|
||||
x1, y1, x2 - x1, y2 - y1);
|
||||
return rval.forget();
|
||||
}
|
||||
|
||||
void
|
||||
DOMQuad::ToJSON(DOMQuadJSON& aInit)
|
||||
{
|
||||
aInit.mP1.Construct(RefPtr<DOMPoint>(P1()).forget());
|
||||
aInit.mP2.Construct(RefPtr<DOMPoint>(P2()).forget());
|
||||
aInit.mP3.Construct(RefPtr<DOMPoint>(P3()).forget());
|
||||
aInit.mP4.Construct(RefPtr<DOMPoint>(P4()).forget());
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry/#structured-serialization
|
||||
bool
|
||||
DOMQuad::WriteStructuredClone(JSStructuredCloneWriter* aWriter) const
|
||||
{
|
||||
for (const auto& point : mPoints) {
|
||||
if (!point->WriteStructuredClone(aWriter)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
DOMQuad::ReadStructuredClone(JSStructuredCloneReader* aReader)
|
||||
{
|
||||
for (auto& point : mPoints) {
|
||||
point = new DOMPoint(mParent);
|
||||
if (!point->ReadStructuredClone(aReader)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
+22
-4
@@ -6,6 +6,7 @@
|
||||
#ifndef MOZILLA_DOMQUAD_H_
|
||||
#define MOZILLA_DOMQUAD_H_
|
||||
|
||||
#include "js/StructuredClone.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
@@ -20,7 +21,10 @@ namespace dom {
|
||||
|
||||
class DOMRectReadOnly;
|
||||
class DOMPoint;
|
||||
struct DOMQuadJSON;
|
||||
struct DOMPointInit;
|
||||
struct DOMQuadInit;
|
||||
struct DOMRectInit;
|
||||
|
||||
class DOMQuad final : public nsWrapperCache
|
||||
{
|
||||
@@ -36,6 +40,12 @@ public:
|
||||
nsISupports* GetParentObject() const { return mParent; }
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
static already_AddRefed<DOMQuad>
|
||||
FromRect(const GlobalObject& aGlobal, const DOMRectInit& aInit);
|
||||
|
||||
static already_AddRefed<DOMQuad>
|
||||
FromQuad(const GlobalObject& aGlobal, const DOMQuadInit& aInit);
|
||||
|
||||
static already_AddRefed<DOMQuad>
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
const DOMPointInit& aP1,
|
||||
@@ -47,20 +57,28 @@ public:
|
||||
Constructor(const GlobalObject& aGlobal, const DOMRectReadOnly& aRect,
|
||||
ErrorResult& aRV);
|
||||
|
||||
DOMRectReadOnly* Bounds() const;
|
||||
DOMRectReadOnly* Bounds();
|
||||
already_AddRefed<DOMRectReadOnly> GetBounds() const;
|
||||
DOMPoint* P1() const { return mPoints[0]; }
|
||||
DOMPoint* P2() const { return mPoints[1]; }
|
||||
DOMPoint* P3() const { return mPoints[2]; }
|
||||
DOMPoint* P4() const { return mPoints[3]; }
|
||||
|
||||
DOMPoint* Point(uint32_t aIndex) { return mPoints[aIndex]; }
|
||||
DOMPoint* Point(uint32_t aIndex) const { return mPoints[aIndex]; }
|
||||
|
||||
void ToJSON(DOMQuadJSON& aInit);
|
||||
|
||||
bool WriteStructuredClone(JSStructuredCloneWriter* aWriter) const;
|
||||
|
||||
bool ReadStructuredClone(JSStructuredCloneReader* aReader);
|
||||
|
||||
protected:
|
||||
class QuadBounds;
|
||||
void GetHorizontalMinMax(double* aX1, double* aX2) const;
|
||||
void GetVerticalMinMax(double* aY1, double* aY2) const;
|
||||
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
RefPtr<DOMPoint> mPoints[4];
|
||||
mutable RefPtr<QuadBounds> mBounds; // allocated lazily
|
||||
RefPtr<DOMRectReadOnly> mBounds;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
||||
+57
-4
@@ -27,6 +27,59 @@ DOMRectReadOnly::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
return DOMRectReadOnlyBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRectReadOnly>
|
||||
DOMRectReadOnly::FromRect(const GlobalObject& aGlobal, const DOMRectInit& aInit)
|
||||
{
|
||||
RefPtr<DOMRectReadOnly> obj = new DOMRectReadOnly(
|
||||
aGlobal.GetAsSupports(), aInit.mX, aInit.mY, aInit.mWidth, aInit.mHeight);
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRectReadOnly>
|
||||
DOMRectReadOnly::Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
||||
double aWidth, double aHeight, ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<DOMRectReadOnly> obj =
|
||||
new DOMRectReadOnly(aGlobal.GetAsSupports(), aX, aY, aWidth, aHeight);
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
// https://drafts.fxtf.org/geometry/#structured-serialization
|
||||
bool
|
||||
DOMRectReadOnly::WriteStructuredClone(JSStructuredCloneWriter* aWriter) const
|
||||
{
|
||||
#define WriteDouble(d) \
|
||||
JS_WriteUint32Pair(aWriter, (BitwiseCast<uint64_t>(d) >> 32) & 0xffffffff, \
|
||||
BitwiseCast<uint64_t>(d) & 0xffffffff)
|
||||
|
||||
return WriteDouble(mX) && WriteDouble(mY) && WriteDouble(mWidth) &&
|
||||
WriteDouble(mHeight);
|
||||
|
||||
#undef WriteDouble
|
||||
}
|
||||
|
||||
bool
|
||||
DOMRectReadOnly::ReadStructuredClone(JSStructuredCloneReader* aReader)
|
||||
{
|
||||
uint32_t high;
|
||||
uint32_t low;
|
||||
|
||||
#define ReadDouble(d) \
|
||||
if (!JS_ReadUint32Pair(aReader, &high, &low)) { \
|
||||
return false; \
|
||||
} \
|
||||
(*(d) = BitwiseCast<double>(static_cast<uint64_t>(high) << 32 | low))
|
||||
|
||||
ReadDouble(&mX);
|
||||
ReadDouble(&mY);
|
||||
ReadDouble(&mWidth);
|
||||
ReadDouble(&mHeight);
|
||||
|
||||
return true;
|
||||
|
||||
#undef ReadDouble
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(DOMRect, DOMRectReadOnly, nsIDOMClientRect)
|
||||
@@ -54,16 +107,16 @@ DOMRect::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRect>
|
||||
DOMRect::Constructor(const GlobalObject& aGlobal, ErrorResult& aRV)
|
||||
DOMRect::FromRect(const GlobalObject& aGlobal, const DOMRectInit& aInit)
|
||||
{
|
||||
RefPtr<DOMRect> obj =
|
||||
new DOMRect(aGlobal.GetAsSupports(), 0.0, 0.0, 0.0, 0.0);
|
||||
RefPtr<DOMRect> obj = new DOMRect(aGlobal.GetAsSupports(), aInit.mX, aInit.mY,
|
||||
aInit.mWidth, aInit.mHeight);
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRect>
|
||||
DOMRect::Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
||||
double aWidth, double aHeight, ErrorResult& aRV)
|
||||
double aWidth, double aHeight, ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<DOMRect> obj =
|
||||
new DOMRect(aGlobal.GetAsSupports(), aX, aY, aWidth, aHeight);
|
||||
|
||||
+43
-34
@@ -6,6 +6,7 @@
|
||||
#ifndef MOZILLA_DOMRECT_H_
|
||||
#define MOZILLA_DOMRECT_H_
|
||||
|
||||
#include "js/StructuredClone.h"
|
||||
#include "nsIDOMClientRect.h"
|
||||
#include "nsIDOMClientRectList.h"
|
||||
#include "nsTArray.h"
|
||||
@@ -22,6 +23,8 @@ struct nsRect;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
struct DOMRectInit;
|
||||
|
||||
class DOMRectReadOnly : public nsISupports
|
||||
, public nsWrapperCache
|
||||
{
|
||||
@@ -32,8 +35,13 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMRectReadOnly)
|
||||
|
||||
explicit DOMRectReadOnly(nsISupports* aParent)
|
||||
explicit DOMRectReadOnly(nsISupports* aParent, double aX = 0, double aY = 0,
|
||||
double aWidth = 0, double aHeight = 0)
|
||||
: mParent(aParent)
|
||||
, mX(aX)
|
||||
, mY(aY)
|
||||
, mWidth(aWidth)
|
||||
, mHeight(aHeight)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,10 +52,29 @@ public:
|
||||
}
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
virtual double X() const = 0;
|
||||
virtual double Y() const = 0;
|
||||
virtual double Width() const = 0;
|
||||
virtual double Height() const = 0;
|
||||
static already_AddRefed<DOMRectReadOnly>
|
||||
FromRect(const GlobalObject& aGlobal, const DOMRectInit& aInit);
|
||||
|
||||
static already_AddRefed<DOMRectReadOnly>
|
||||
Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
||||
double aWidth, double aHeight, ErrorResult& aRv);
|
||||
|
||||
double X() const
|
||||
{
|
||||
return mX;
|
||||
}
|
||||
double Y() const
|
||||
{
|
||||
return mY;
|
||||
}
|
||||
double Width() const
|
||||
{
|
||||
return mWidth;
|
||||
}
|
||||
double Height() const
|
||||
{
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
double Left() const
|
||||
{
|
||||
@@ -70,8 +97,13 @@ public:
|
||||
return std::max(y, y + h);
|
||||
}
|
||||
|
||||
bool WriteStructuredClone(JSStructuredCloneWriter* aWriter) const;
|
||||
|
||||
bool ReadStructuredClone(JSStructuredCloneReader* aReader);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
double mX, mY, mWidth, mHeight;
|
||||
};
|
||||
|
||||
class DOMRect final : public DOMRectReadOnly
|
||||
@@ -80,22 +112,19 @@ class DOMRect final : public DOMRectReadOnly
|
||||
public:
|
||||
explicit DOMRect(nsISupports* aParent, double aX = 0, double aY = 0,
|
||||
double aWidth = 0, double aHeight = 0)
|
||||
: DOMRectReadOnly(aParent)
|
||||
, mX(aX)
|
||||
, mY(aY)
|
||||
, mWidth(aWidth)
|
||||
, mHeight(aHeight)
|
||||
: DOMRectReadOnly(aParent, aX, aY, aWidth, aHeight)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMCLIENTRECT
|
||||
|
||||
static already_AddRefed<DOMRect>
|
||||
Constructor(const GlobalObject& aGlobal, ErrorResult& aRV);
|
||||
FromRect(const GlobalObject& aGlobal, const DOMRectInit& aInit);
|
||||
|
||||
static already_AddRefed<DOMRect>
|
||||
Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
||||
double aWidth, double aHeight, ErrorResult& aRV);
|
||||
double aWidth, double aHeight, ErrorResult& aRv);
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
@@ -104,23 +133,6 @@ public:
|
||||
}
|
||||
void SetLayoutRect(const nsRect& aLayoutRect);
|
||||
|
||||
virtual double X() const override
|
||||
{
|
||||
return mX;
|
||||
}
|
||||
virtual double Y() const override
|
||||
{
|
||||
return mY;
|
||||
}
|
||||
virtual double Width() const override
|
||||
{
|
||||
return mWidth;
|
||||
}
|
||||
virtual double Height() const override
|
||||
{
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
void SetX(double aX)
|
||||
{
|
||||
mX = aX;
|
||||
@@ -138,11 +150,8 @@ public:
|
||||
mHeight = aHeight;
|
||||
}
|
||||
|
||||
protected:
|
||||
double mX, mY, mWidth, mHeight;
|
||||
|
||||
private:
|
||||
~DOMRect() {};
|
||||
~DOMRect() {}
|
||||
};
|
||||
|
||||
class DOMRectList final : public nsIDOMClientRectList,
|
||||
|
||||
@@ -398,7 +398,7 @@ FormData::Constructor(const GlobalObject& aGlobal,
|
||||
|
||||
NS_IMETHODIMP
|
||||
FormData::GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
|
||||
nsACString& aContentType, nsACString& aCharset)
|
||||
nsACString& aContentTypeWithCharset, nsACString& aCharset)
|
||||
{
|
||||
FSMultipartFormData fs(NS_LITERAL_CSTRING("UTF-8"), nullptr);
|
||||
|
||||
@@ -419,7 +419,7 @@ FormData::GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
|
||||
}
|
||||
}
|
||||
|
||||
fs.GetContentType(aContentType);
|
||||
fs.GetContentType(aContentTypeWithCharset);
|
||||
aCharset.Truncate();
|
||||
*aContentLength = 0;
|
||||
NS_ADDREF(*aBody = fs.GetSubmissionBody(aContentLength));
|
||||
|
||||
@@ -1022,7 +1022,12 @@ nsIContent::GetEventTargetParent(EventChainPreVisitor& aVisitor)
|
||||
nsContentUtils::Retarget(relatedTargetAsNode, this);
|
||||
nsCOMPtr<nsINode> targetInKnownToBeHandledScope =
|
||||
FindChromeAccessOnlySubtreeOwner(aVisitor.mTargetInKnownToBeHandledScope);
|
||||
if (nsContentUtils::ContentIsShadowIncludingDescendantOf(
|
||||
// If aVisitor.mTargetInKnownToBeHandledScope wasn't nsINode,
|
||||
// targetInKnownToBeHandledScope will be null. This may happen when
|
||||
// dispatching event to Window object in a content page and
|
||||
// propagating the event to a chrome Element.
|
||||
if (targetInKnownToBeHandledScope &&
|
||||
nsContentUtils::ContentIsShadowIncludingDescendantOf(
|
||||
this, targetInKnownToBeHandledScope->SubtreeRoot())) {
|
||||
// Part of step 11.4.
|
||||
// "If target's root is a shadow-including inclusive ancestor of
|
||||
|
||||
@@ -147,8 +147,7 @@ public:
|
||||
virtual bool TextIsOnlyWhitespace() override;
|
||||
virtual bool HasTextForTranslation() override;
|
||||
virtual void AppendTextTo(nsAString& aResult) override;
|
||||
MOZ_MUST_USE
|
||||
virtual bool AppendTextTo(nsAString& aResult, const mozilla::fallible_t&) override;
|
||||
[[nodiscard]] virtual bool AppendTextTo(nsAString& aResult, const mozilla::fallible_t&) override;
|
||||
virtual nsIContent *GetBindingParent() const override;
|
||||
virtual nsXBLBinding *GetXBLBinding() const override;
|
||||
virtual void SetXBLBinding(nsXBLBinding* aBinding,
|
||||
|
||||
+66
-206
@@ -11,7 +11,9 @@
|
||||
#include "nsPluginArray.h"
|
||||
#include "nsMimeTypeArray.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/dom/BodyExtractor.h"
|
||||
#include "mozilla/dom/DesktopNotification.h"
|
||||
#include "mozilla/dom/FetchBinding.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "nsGeolocation.h"
|
||||
#include "nsIClassOfService.h"
|
||||
@@ -38,6 +40,7 @@
|
||||
#include "mozilla/dom/ServiceWorkerContainer.h"
|
||||
#include "mozilla/dom/StorageManager.h"
|
||||
#include "mozilla/dom/TCPSocket.h"
|
||||
#include "mozilla/dom/URLSearchParams.h"
|
||||
#include "mozilla/dom/workers/RuntimeService.h"
|
||||
#include "mozilla/Hal.h"
|
||||
#include "nsISiteSpecificUserAgent.h"
|
||||
@@ -88,11 +91,6 @@
|
||||
#endif
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
|
||||
#ifdef MOZ_EME
|
||||
#include "mozilla/EMEUtils.h"
|
||||
#include "mozilla/DetailedPromise.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
@@ -195,9 +193,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mServiceWorkerContainer)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
|
||||
#ifdef MOZ_EME
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaKeySystemAccessManager)
|
||||
#endif
|
||||
#ifdef MOZ_GAMEPAD
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGamepadServiceTest)
|
||||
#endif
|
||||
@@ -258,13 +253,6 @@ Navigator::Invalidate()
|
||||
|
||||
mServiceWorkerContainer = nullptr;
|
||||
|
||||
#ifdef MOZ_EME
|
||||
if (mMediaKeySystemAccessManager) {
|
||||
mMediaKeySystemAccessManager->Shutdown();
|
||||
mMediaKeySystemAccessManager = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_GAMEPAD
|
||||
if (mGamepadServiceTest) {
|
||||
mGamepadServiceTest->Shutdown();
|
||||
@@ -845,8 +833,52 @@ BeaconStreamListener::OnDataAvailable(nsIRequest *aRequest,
|
||||
|
||||
bool
|
||||
Navigator::SendBeacon(const nsAString& aUrl,
|
||||
const Nullable<ArrayBufferViewOrBlobOrStringOrFormData>& aData,
|
||||
const Nullable<fetch::BodyInit>& aData,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (aData.IsNull()) {
|
||||
return SendBeaconInternal(aUrl, nullptr, eBeaconTypeOther, aRv);
|
||||
}
|
||||
|
||||
if (aData.Value().IsArrayBuffer()) {
|
||||
BodyExtractor<const ArrayBuffer> body(&aData.Value().GetAsArrayBuffer());
|
||||
return SendBeaconInternal(aUrl, &body, eBeaconTypeOther, aRv);
|
||||
}
|
||||
|
||||
if (aData.Value().IsArrayBufferView()) {
|
||||
BodyExtractor<const ArrayBufferView> body(&aData.Value().GetAsArrayBufferView());
|
||||
return SendBeaconInternal(aUrl, &body, eBeaconTypeOther, aRv);
|
||||
}
|
||||
|
||||
if (aData.Value().IsBlob()) {
|
||||
BodyExtractor<nsIXHRSendable> body(&aData.Value().GetAsBlob());
|
||||
return SendBeaconInternal(aUrl, &body, eBeaconTypeOther, aRv);
|
||||
}
|
||||
|
||||
if (aData.Value().IsFormData()) {
|
||||
BodyExtractor<nsIXHRSendable> body(&aData.Value().GetAsFormData());
|
||||
return SendBeaconInternal(aUrl, &body, eBeaconTypeOther, aRv);
|
||||
}
|
||||
|
||||
if (aData.Value().IsUSVString()) {
|
||||
BodyExtractor<const nsAString> body(&aData.Value().GetAsUSVString());
|
||||
return SendBeaconInternal(aUrl, &body, eBeaconTypeOther, aRv);
|
||||
}
|
||||
|
||||
if (aData.Value().IsURLSearchParams()) {
|
||||
BodyExtractor<nsIXHRSendable> body(&aData.Value().GetAsURLSearchParams());
|
||||
return SendBeaconInternal(aUrl, &body, eBeaconTypeOther, aRv);
|
||||
}
|
||||
|
||||
MOZ_CRASH("Invalid data type.");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
Navigator::SendBeaconInternal(const nsAString& aUrl,
|
||||
BodyExtractorBase* aBody,
|
||||
BeaconType aType,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!mWindow) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
@@ -887,9 +919,9 @@ Navigator::SendBeacon(const nsAString& aUrl,
|
||||
nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL;
|
||||
|
||||
// No need to use CORS for sendBeacon unless it's a BLOB
|
||||
nsSecurityFlags securityFlags = (!aData.IsNull() && aData.Value().IsBlob())
|
||||
? nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS
|
||||
: nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS;
|
||||
nsSecurityFlags securityFlags = aType == eBeaconTypeBlob
|
||||
? nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS
|
||||
: nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS;
|
||||
securityFlags |= nsILoadInfo::SEC_COOKIES_INCLUDE;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
@@ -915,76 +947,30 @@ Navigator::SendBeacon(const nsAString& aUrl,
|
||||
}
|
||||
httpChannel->SetReferrer(documentURI);
|
||||
|
||||
nsCString mimeType;
|
||||
if (!aData.IsNull()) {
|
||||
nsCOMPtr<nsIInputStream> in;
|
||||
nsCOMPtr<nsIInputStream> in;
|
||||
nsAutoCString contentTypeWithCharset;
|
||||
nsAutoCString charset;
|
||||
uint64_t length = 0;
|
||||
|
||||
if (aData.Value().IsString()) {
|
||||
nsCString stringData = NS_ConvertUTF16toUTF8(aData.Value().GetAsString());
|
||||
nsCOMPtr<nsIStringInputStream> strStream = do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
rv = strStream->SetData(stringData.BeginReading(), stringData.Length());
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
mimeType.AssignLiteral("text/plain;charset=UTF-8");
|
||||
in = strStream;
|
||||
|
||||
} else if (aData.Value().IsArrayBufferView()) {
|
||||
|
||||
nsCOMPtr<nsIStringInputStream> strStream = do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
|
||||
const ArrayBufferView& view = aData.Value().GetAsArrayBufferView();
|
||||
view.ComputeLengthAndData();
|
||||
rv = strStream->SetData(reinterpret_cast<char*>(view.Data()),
|
||||
view.Length());
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
mimeType.AssignLiteral("application/octet-stream");
|
||||
in = strStream;
|
||||
|
||||
} else if (aData.Value().IsBlob()) {
|
||||
Blob& blob = aData.Value().GetAsBlob();
|
||||
blob.GetInternalStream(getter_AddRefs(in), aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsAutoString type;
|
||||
blob.GetType(type);
|
||||
mimeType = NS_ConvertUTF16toUTF8(type);
|
||||
|
||||
} else if (aData.Value().IsFormData()) {
|
||||
FormData& form = aData.Value().GetAsFormData();
|
||||
uint64_t len;
|
||||
nsAutoCString charset;
|
||||
form.GetSendInfo(getter_AddRefs(in),
|
||||
&len,
|
||||
mimeType,
|
||||
charset);
|
||||
} else {
|
||||
MOZ_ASSERT(false, "switch statements not in sync");
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
if (aBody) {
|
||||
aRv = aBody->GetAsStream(getter_AddRefs(in), &length,
|
||||
contentTypeWithCharset, charset);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aType == eBeaconTypeArrayBuffer) {
|
||||
MOZ_ASSERT(contentTypeWithCharset.IsEmpty());
|
||||
MOZ_ASSERT(charset.IsEmpty());
|
||||
contentTypeWithCharset.Assign("application/octet-stream");
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIUploadChannel2> uploadChannel = do_QueryInterface(channel);
|
||||
if (!uploadChannel) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
uploadChannel->ExplicitSetUploadStream(in, mimeType, -1,
|
||||
uploadChannel->ExplicitSetUploadStream(in, contentTypeWithCharset, length,
|
||||
NS_LITERAL_CSTRING("POST"),
|
||||
false);
|
||||
} else {
|
||||
@@ -1503,131 +1489,5 @@ Navigator::GetUserAgent(nsPIDOMWindowInner* aWindow, nsIURI* aURI,
|
||||
return siteSpecificUA->GetUserAgentForURIAndWindow(aURI, aWindow, aUserAgent);
|
||||
}
|
||||
|
||||
#ifdef MOZ_EME
|
||||
static nsCString
|
||||
ToCString(const nsString& aString)
|
||||
{
|
||||
nsCString str("'");
|
||||
str.Append(NS_ConvertUTF16toUTF8(aString));
|
||||
str.AppendLiteral("'");
|
||||
return str;
|
||||
}
|
||||
|
||||
static nsCString
|
||||
ToCString(const MediaKeysRequirement aValue)
|
||||
{
|
||||
nsCString str("'");
|
||||
str.Append(nsDependentCString(MediaKeysRequirementValues::strings[static_cast<uint32_t>(aValue)].value));
|
||||
str.AppendLiteral("'");
|
||||
return str;
|
||||
}
|
||||
|
||||
static nsCString
|
||||
ToCString(const MediaKeySystemMediaCapability& aValue)
|
||||
{
|
||||
nsCString str;
|
||||
str.AppendLiteral("{contentType=");
|
||||
str.Append(ToCString(aValue.mContentType));
|
||||
str.AppendLiteral(", robustness=");
|
||||
str.Append(ToCString(aValue.mRobustness));
|
||||
str.AppendLiteral("}");
|
||||
return str;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
static nsCString
|
||||
ToCString(const Sequence<Type>& aSequence)
|
||||
{
|
||||
nsCString str;
|
||||
str.AppendLiteral("[");
|
||||
for (size_t i = 0; i < aSequence.Length(); i++) {
|
||||
if (i != 0) {
|
||||
str.AppendLiteral(",");
|
||||
}
|
||||
str.Append(ToCString(aSequence[i]));
|
||||
}
|
||||
str.AppendLiteral("]");
|
||||
return str;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
static nsCString
|
||||
ToCString(const Optional<Sequence<Type>>& aOptional)
|
||||
{
|
||||
nsCString str;
|
||||
if (aOptional.WasPassed()) {
|
||||
str.Append(ToCString(aOptional.Value()));
|
||||
} else {
|
||||
str.AppendLiteral("[]");
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
static nsCString
|
||||
ToCString(const MediaKeySystemConfiguration& aConfig)
|
||||
{
|
||||
nsCString str;
|
||||
str.AppendLiteral("{label=");
|
||||
str.Append(ToCString(aConfig.mLabel));
|
||||
|
||||
str.AppendLiteral(", initDataTypes=");
|
||||
str.Append(ToCString(aConfig.mInitDataTypes));
|
||||
|
||||
str.AppendLiteral(", audioCapabilities=");
|
||||
str.Append(ToCString(aConfig.mAudioCapabilities));
|
||||
|
||||
str.AppendLiteral(", videoCapabilities=");
|
||||
str.Append(ToCString(aConfig.mVideoCapabilities));
|
||||
|
||||
str.AppendLiteral(", distinctiveIdentifier=");
|
||||
str.Append(ToCString(aConfig.mDistinctiveIdentifier));
|
||||
|
||||
str.AppendLiteral(", persistentState=");
|
||||
str.Append(ToCString(aConfig.mPersistentState));
|
||||
|
||||
str.AppendLiteral(", sessionTypes=");
|
||||
str.Append(ToCString(aConfig.mSessionTypes));
|
||||
|
||||
str.AppendLiteral("}");
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
static nsCString
|
||||
RequestKeySystemAccessLogString(const nsAString& aKeySystem,
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfigs)
|
||||
{
|
||||
nsCString str;
|
||||
str.AppendPrintf("Navigator::RequestMediaKeySystemAccess(keySystem='%s' options=",
|
||||
NS_ConvertUTF16toUTF8(aKeySystem).get());
|
||||
str.Append(ToCString(aConfigs));
|
||||
str.AppendLiteral(")");
|
||||
return str;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
Navigator::RequestMediaKeySystemAccess(const nsAString& aKeySystem,
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfigs,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
EME_LOG("%s", RequestKeySystemAccessLogString(aKeySystem, aConfigs).get());
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(mWindow);
|
||||
RefPtr<DetailedPromise> promise =
|
||||
DetailedPromise::Create(go, aRv,
|
||||
NS_LITERAL_CSTRING("navigator.requestMediaKeySystemAccess"));
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!mMediaKeySystemAccessManager) {
|
||||
mMediaKeySystemAccessManager = new MediaKeySystemAccessManager(mWindow);
|
||||
}
|
||||
|
||||
mMediaKeySystemAccessManager->Request(promise, aKeySystem, aConfigs);
|
||||
return promise.forget();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
+17
-14
@@ -7,6 +7,7 @@
|
||||
#define mozilla_dom_Navigator_h
|
||||
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/dom/Fetch.h"
|
||||
#include "mozilla/dom/Nullable.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsIDOMNavigator.h"
|
||||
@@ -17,9 +18,6 @@
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#ifdef MOZ_EME
|
||||
#include "mozilla/dom/MediaKeySystemAccessManager.h"
|
||||
#endif
|
||||
|
||||
class nsPluginArray;
|
||||
class nsMimeTypeArray;
|
||||
@@ -30,12 +28,13 @@ class nsIURI;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class BodyExtractorBase;
|
||||
class Geolocation;
|
||||
class systemMessageCallback;
|
||||
class MediaDevices;
|
||||
struct MediaStreamConstraints;
|
||||
class WakeLock;
|
||||
class ArrayBufferViewOrBlobOrStringOrFormData;
|
||||
class ArrayBufferOrArrayBufferViewOrBlobOrFormDataOrUSVStringOrURLSearchParams;
|
||||
class ServiceWorkerContainer;
|
||||
class DOMRequest;
|
||||
} // namespace dom
|
||||
@@ -196,7 +195,7 @@ public:
|
||||
#endif // MOZ_AUDIO_CHANNEL_MANAGER
|
||||
|
||||
bool SendBeacon(const nsAString& aUrl,
|
||||
const Nullable<ArrayBufferViewOrBlobOrStringOrFormData>& aData,
|
||||
const Nullable<fetch::BodyInit>& aData,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void MozGetUserMedia(const MediaStreamConstraints& aConstraints,
|
||||
@@ -238,21 +237,25 @@ public:
|
||||
// any, else null.
|
||||
static already_AddRefed<nsPIDOMWindowInner> GetWindowFromGlobal(JSObject* aGlobal);
|
||||
|
||||
#ifdef MOZ_EME
|
||||
already_AddRefed<Promise>
|
||||
RequestMediaKeySystemAccess(const nsAString& aKeySystem,
|
||||
const Sequence<MediaKeySystemConfiguration>& aConfig,
|
||||
ErrorResult& aRv);
|
||||
private:
|
||||
RefPtr<MediaKeySystemAccessManager> mMediaKeySystemAccessManager;
|
||||
#endif
|
||||
|
||||
private:
|
||||
virtual ~Navigator();
|
||||
|
||||
bool CheckPermission(const char* type);
|
||||
static bool CheckPermission(nsPIDOMWindowInner* aWindow, const char* aType);
|
||||
|
||||
// This enum helps SendBeaconInternal to apply different behaviors to body
|
||||
// types.
|
||||
enum BeaconType {
|
||||
eBeaconTypeBlob,
|
||||
eBeaconTypeArrayBuffer,
|
||||
eBeaconTypeOther
|
||||
};
|
||||
|
||||
bool SendBeaconInternal(const nsAString& aUrl,
|
||||
BodyExtractorBase* aBody,
|
||||
BeaconType aType,
|
||||
ErrorResult& aRv);
|
||||
|
||||
RefPtr<nsMimeTypeArray> mMimeTypes;
|
||||
RefPtr<nsPluginArray> mPlugins;
|
||||
RefPtr<Permissions> mPermissions;
|
||||
|
||||
@@ -303,6 +303,30 @@ ResizeObserverEntry::Constructor(const GlobalObject& aGlobal,
|
||||
return observerEntry.forget();
|
||||
}
|
||||
|
||||
void ResizeObserverEntry::GetBorderBoxSize(
|
||||
nsTArray<RefPtr<ResizeObserverSize>>& aRetVal) const {
|
||||
// In the resize-observer-1 spec, there will only be a single
|
||||
// ResizeObserverSize returned in the FrozenArray.
|
||||
//
|
||||
// Note: the usage of FrozenArray is to support elements that have multiple
|
||||
// fragments, which occur in multi-column scenarios. See:
|
||||
// https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface
|
||||
aRetVal.Clear();
|
||||
aRetVal.AppendElement(mBorderBoxSize);
|
||||
}
|
||||
|
||||
void ResizeObserverEntry::GetContentBoxSize(
|
||||
nsTArray<RefPtr<ResizeObserverSize>>& aRetVal) const {
|
||||
// In the resize-observer-1 spec, there will only be a single
|
||||
// ResizeObserverSize returned in the FrozenArray.
|
||||
//
|
||||
// Note: the usage of FrozenArray is to support elements that have multiple
|
||||
// fragments, which occur in multi-column scenarios.
|
||||
// https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface
|
||||
aRetVal.Clear();
|
||||
aRetVal.AppendElement(mContentBoxSize);
|
||||
}
|
||||
|
||||
void
|
||||
ResizeObserverEntry::SetBorderBoxSize(const nsSize& aSize) {
|
||||
nsIFrame* frame = mTarget->GetPrimaryFrame();
|
||||
|
||||
@@ -163,14 +163,10 @@ public:
|
||||
|
||||
/**
|
||||
* Returns target's logical border-box size and content-box size as
|
||||
* ResizeObserverSize.
|
||||
* a ResizeObserverSize array.
|
||||
*/
|
||||
ResizeObserverSize* BorderBoxSize() const {
|
||||
return mBorderBoxSize;
|
||||
}
|
||||
ResizeObserverSize* ContentBoxSize() const {
|
||||
return mContentBoxSize;
|
||||
}
|
||||
void GetBorderBoxSize(nsTArray<RefPtr<ResizeObserverSize>>& aRetVal) const;
|
||||
void GetContentBoxSize(nsTArray<RefPtr<ResizeObserverSize>>& aRetVal) const;
|
||||
|
||||
// Set borderBoxSize.
|
||||
void SetBorderBoxSize(const nsSize& aSize);
|
||||
|
||||
@@ -11,6 +11,14 @@
|
||||
#include "mozilla/dom/CryptoKey.h"
|
||||
#include "mozilla/dom/Directory.h"
|
||||
#include "mozilla/dom/DirectoryBinding.h"
|
||||
#include "mozilla/dom/DOMMatrix.h"
|
||||
#include "mozilla/dom/DOMMatrixBinding.h"
|
||||
#include "mozilla/dom/DOMPoint.h"
|
||||
#include "mozilla/dom/DOMPointBinding.h"
|
||||
#include "mozilla/dom/DOMQuad.h"
|
||||
#include "mozilla/dom/DOMQuadBinding.h"
|
||||
#include "mozilla/dom/DOMRect.h"
|
||||
#include "mozilla/dom/DOMRectBinding.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/FileList.h"
|
||||
#include "mozilla/dom/FileListBinding.h"
|
||||
@@ -355,7 +363,11 @@ StructuredCloneHolder::ReadFullySerializableObjects(JSContext* aCx,
|
||||
return ReadStructuredCloneImageData(aCx, aReader);
|
||||
}
|
||||
|
||||
if (aTag == SCTAG_DOM_WEBCRYPTO_KEY || aTag == SCTAG_DOM_URLSEARCHPARAMS) {
|
||||
if (aTag == SCTAG_DOM_WEBCRYPTO_KEY || aTag == SCTAG_DOM_URLSEARCHPARAMS ||
|
||||
aTag == SCTAG_DOM_DOMPOINT || aTag == SCTAG_DOM_DOMPOINT_READONLY ||
|
||||
aTag == SCTAG_DOM_DOMRECT || aTag == SCTAG_DOM_DOMRECT_READONLY ||
|
||||
aTag == SCTAG_DOM_DOMQUAD || aTag == SCTAG_DOM_DOMMATRIX ||
|
||||
aTag == SCTAG_DOM_DOMMATRIX_READONLY) {
|
||||
nsIGlobalObject *global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
|
||||
if (!global) {
|
||||
return nullptr;
|
||||
@@ -378,6 +390,57 @@ StructuredCloneHolder::ReadFullySerializableObjects(JSContext* aCx,
|
||||
} else {
|
||||
result = usp->WrapObject(aCx, nullptr);
|
||||
}
|
||||
} else if (aTag == SCTAG_DOM_DOMPOINT) {
|
||||
RefPtr<DOMPoint> domPoint = new DOMPoint(global);
|
||||
if (!domPoint->ReadStructuredClone(aReader)) {
|
||||
result = nullptr;
|
||||
} else {
|
||||
result = domPoint->WrapObject(aCx, nullptr);
|
||||
}
|
||||
} else if (aTag == SCTAG_DOM_DOMPOINT_READONLY) {
|
||||
RefPtr<DOMPointReadOnly> domPoint = new DOMPointReadOnly(global);
|
||||
if (!domPoint->ReadStructuredClone(aReader)) {
|
||||
result = nullptr;
|
||||
} else {
|
||||
result = domPoint->WrapObject(aCx, nullptr);
|
||||
}
|
||||
} else if (aTag == SCTAG_DOM_DOMRECT) {
|
||||
RefPtr<DOMRect> domRect = new DOMRect(global);
|
||||
if (!domRect->ReadStructuredClone(aReader)) {
|
||||
result = nullptr;
|
||||
} else {
|
||||
result = domRect->WrapObject(aCx, nullptr);
|
||||
}
|
||||
} else if (aTag == SCTAG_DOM_DOMRECT_READONLY) {
|
||||
RefPtr<DOMRectReadOnly> domRect = new DOMRectReadOnly(global);
|
||||
if (!domRect->ReadStructuredClone(aReader)) {
|
||||
result = nullptr;
|
||||
} else {
|
||||
result = domRect->WrapObject(aCx, nullptr);
|
||||
}
|
||||
} else if (aTag == SCTAG_DOM_DOMQUAD) {
|
||||
RefPtr<DOMQuad> domQuad = new DOMQuad(global);
|
||||
if (!domQuad->ReadStructuredClone(aReader)) {
|
||||
result = nullptr;
|
||||
} else {
|
||||
result = domQuad->WrapObject(aCx, nullptr);
|
||||
}
|
||||
} else if (aTag == SCTAG_DOM_DOMMATRIX) {
|
||||
RefPtr<DOMMatrix> domMatrix =
|
||||
DOMMatrix::ReadStructuredClone(global, aReader);
|
||||
if (!domMatrix) {
|
||||
result = nullptr;
|
||||
} else {
|
||||
result = domMatrix->WrapObject(aCx, nullptr);
|
||||
}
|
||||
} else if (aTag == SCTAG_DOM_DOMMATRIX_READONLY) {
|
||||
RefPtr<DOMMatrixReadOnly> domMatrix =
|
||||
DOMMatrixReadOnly::ReadStructuredClone(global, aReader);
|
||||
if (!domMatrix) {
|
||||
result = nullptr;
|
||||
} else {
|
||||
result = domMatrix->WrapObject(aCx, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -483,6 +546,75 @@ StructuredCloneHolder::WriteFullySerializableObjects(JSContext* aCx,
|
||||
}
|
||||
#endif
|
||||
|
||||
// Handle DOMPoint cloning
|
||||
// Should be done before DOMPointeReadOnly check
|
||||
// because every DOMPoint is also a DOMPointReadOnly
|
||||
{
|
||||
DOMPoint* domPoint = nullptr;
|
||||
if (NS_SUCCEEDED(UNWRAP_OBJECT(DOMPoint, &obj, domPoint))) {
|
||||
return JS_WriteUint32Pair(aWriter, SCTAG_DOM_DOMPOINT, 0) &&
|
||||
domPoint->WriteStructuredClone(aWriter);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle DOMPointReadOnly cloning
|
||||
{
|
||||
DOMPointReadOnly* domPoint = nullptr;
|
||||
if (NS_SUCCEEDED(UNWRAP_OBJECT(DOMPointReadOnly, &obj, domPoint))) {
|
||||
return JS_WriteUint32Pair(aWriter, SCTAG_DOM_DOMPOINT_READONLY, 0) &&
|
||||
domPoint->WriteStructuredClone(aWriter);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle DOMRect cloning
|
||||
// Should be done before DOMRecteReadOnly check
|
||||
// because every DOMRect is also a DOMRectReadOnly
|
||||
{
|
||||
DOMRect* domRect = nullptr;
|
||||
if (NS_SUCCEEDED(UNWRAP_OBJECT(DOMRect, &obj, domRect))) {
|
||||
return JS_WriteUint32Pair(aWriter, SCTAG_DOM_DOMRECT, 0) &&
|
||||
domRect->WriteStructuredClone(aWriter);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle DOMRectReadOnly cloning
|
||||
{
|
||||
DOMRectReadOnly* domRect = nullptr;
|
||||
if (NS_SUCCEEDED(UNWRAP_OBJECT(DOMRectReadOnly, &obj, domRect))) {
|
||||
return JS_WriteUint32Pair(aWriter, SCTAG_DOM_DOMRECT_READONLY, 0) &&
|
||||
domRect->WriteStructuredClone(aWriter);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle DOMQuad cloning
|
||||
{
|
||||
DOMQuad* domQuad = nullptr;
|
||||
if (NS_SUCCEEDED(UNWRAP_OBJECT(DOMQuad, &obj, domQuad))) {
|
||||
return JS_WriteUint32Pair(aWriter, SCTAG_DOM_DOMQUAD, 0) &&
|
||||
domQuad->WriteStructuredClone(aWriter);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle DOMMatrix cloning
|
||||
// Should be done before DOMMatrixeReadOnly check
|
||||
// because every DOMMatrix is also a DOMMatrixReadOnly
|
||||
{
|
||||
DOMMatrix* domMatrix = nullptr;
|
||||
if (NS_SUCCEEDED(UNWRAP_OBJECT(DOMMatrix, &obj, domMatrix))) {
|
||||
return JS_WriteUint32Pair(aWriter, SCTAG_DOM_DOMMATRIX, 0) &&
|
||||
domMatrix->WriteStructuredClone(aWriter);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle DOMMatrixReadOnly cloning
|
||||
{
|
||||
DOMMatrixReadOnly* domMatrix = nullptr;
|
||||
if (NS_SUCCEEDED(UNWRAP_OBJECT(DOMMatrixReadOnly, &obj, domMatrix))) {
|
||||
return JS_WriteUint32Pair(aWriter, SCTAG_DOM_DOMMATRIX_READONLY, 0) &&
|
||||
domMatrix->WriteStructuredClone(aWriter);
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_IsMainThread() && xpc::IsReflector(obj)) {
|
||||
nsCOMPtr<nsISupports> base = xpc::UnwrapReflectorToISupports(obj);
|
||||
nsCOMPtr<nsIPrincipal> principal = do_QueryInterface(base);
|
||||
|
||||
@@ -30,6 +30,15 @@ enum StructuredCloneTags {
|
||||
|
||||
// New IDB tags go here!
|
||||
|
||||
// Tags for Geometry interfaces.
|
||||
SCTAG_DOM_DOMPOINT,
|
||||
SCTAG_DOM_DOMPOINT_READONLY,
|
||||
SCTAG_DOM_DOMQUAD,
|
||||
SCTAG_DOM_DOMRECT,
|
||||
SCTAG_DOM_DOMRECT_READONLY,
|
||||
SCTAG_DOM_DOMMATRIX,
|
||||
SCTAG_DOM_DOMMATRIX_READONLY,
|
||||
|
||||
// These tags are used for both main thread and workers.
|
||||
SCTAG_DOM_IMAGEDATA,
|
||||
SCTAG_DOM_MAP_MESSAGEPORT,
|
||||
|
||||
@@ -20,8 +20,7 @@ static const double sRadPerDegree = 2.0 * M_PI / 360.0;
|
||||
bool
|
||||
WebKitCSSMatrix::FeatureEnabled(JSContext* aCx, JSObject* aObj)
|
||||
{
|
||||
return Preferences::GetBool("layout.css.DOMMatrix.enabled", false) &&
|
||||
Preferences::GetBool("layout.css.prefixes.webkit", false);
|
||||
return Preferences::GetBool("layout.css.prefixes.webkit", false);
|
||||
}
|
||||
|
||||
already_AddRefed<WebKitCSSMatrix>
|
||||
@@ -115,10 +114,10 @@ WebKitCSSMatrix::SetMatrixValue(const nsAString& aTransformList,
|
||||
}
|
||||
|
||||
already_AddRefed<WebKitCSSMatrix>
|
||||
WebKitCSSMatrix::Multiply(const WebKitCSSMatrix& other) const
|
||||
WebKitCSSMatrix::Multiply(const DOMMatrixInit& aOtherInit, ErrorResult& aRv) const
|
||||
{
|
||||
RefPtr<WebKitCSSMatrix> retval = new WebKitCSSMatrix(mParent, *this);
|
||||
retval->MultiplySelf(other);
|
||||
retval->MultiplySelf(aOtherInit, aRv);
|
||||
|
||||
return retval.forget();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@ public:
|
||||
WebKitCSSMatrix* SetMatrixValue(const nsAString& aTransformList,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<WebKitCSSMatrix> Multiply(const WebKitCSSMatrix& aOther) const;
|
||||
already_AddRefed<WebKitCSSMatrix> Multiply(const DOMMatrixInit& aOtherInit,
|
||||
ErrorResult& aRv) const;
|
||||
already_AddRefed<WebKitCSSMatrix> Inverse(ErrorResult& aRv) const;
|
||||
already_AddRefed<WebKitCSSMatrix> Translate(double aTx,
|
||||
double aTy,
|
||||
|
||||
@@ -84,7 +84,7 @@ private:
|
||||
nsIContent **outImageOrLinkNode,
|
||||
bool* outDragSelectedText);
|
||||
static already_AddRefed<nsIContent> FindParentLinkNode(nsIContent* inNode);
|
||||
static MOZ_MUST_USE nsresult
|
||||
static [[nodiscard]] nsresult
|
||||
GetAnchorURL(nsIContent* inNode, nsAString& outURL);
|
||||
static void GetNodeString(nsIContent* inNode, nsAString & outNodeString);
|
||||
static void CreateLinkText(const nsAString& inURL, const nsAString & inText,
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/CustomElementRegistry.h"
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
#include "mozilla/dom/DOMException.h"
|
||||
#include "mozilla/dom/DOMExceptionBinding.h"
|
||||
#include "mozilla/dom/DOMTypes.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/FileSystemSecurity.h"
|
||||
@@ -8733,6 +8735,25 @@ nsContentUtils::PushEnabled(JSContext* aCx, JSObject* aObj)
|
||||
return workerPrivate->PushEnabled();
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
nsContentUtils::StreamsEnabled(JSContext* aCx, JSObject* aObj)
|
||||
{
|
||||
if (NS_IsMainThread()) {
|
||||
return Preferences::GetBool("dom.streams.enabled", false);
|
||||
}
|
||||
|
||||
using namespace workers;
|
||||
|
||||
// Otherwise, check the pref via the WorkerPrivate
|
||||
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
|
||||
if (!workerPrivate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return workerPrivate->StreamsEnabled();
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
nsContentUtils::IsNonSubresourceRequest(nsIChannel* aChannel)
|
||||
@@ -10060,3 +10081,72 @@ void nsContentUtils::StructuredClone(JSContext* aCx,
|
||||
nsTArray<RefPtr<MessagePort>> ports = holder.TakeTransferredPorts();
|
||||
Unused << ports;
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsContentUtils::ExtractErrorValues(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aValue,
|
||||
nsACString& aSourceSpecOut,
|
||||
uint32_t* aLineOut,
|
||||
uint32_t* aColumnOut,
|
||||
nsString& aMessageOut)
|
||||
{
|
||||
MOZ_ASSERT(aLineOut);
|
||||
MOZ_ASSERT(aColumnOut);
|
||||
|
||||
if (aValue.isObject()) {
|
||||
JS::Rooted<JSObject*> obj(aCx, &aValue.toObject());
|
||||
RefPtr<dom::DOMException> domException;
|
||||
|
||||
// Try to process as an Error object. Use the file/line/column values
|
||||
// from the Error as they will be more specific to the root cause of
|
||||
// the problem.
|
||||
JSErrorReport* err = obj ? JS_ErrorFromException(aCx, obj) : nullptr;
|
||||
if (err) {
|
||||
// Use xpc to extract the error message only. We don't actually send
|
||||
// this report anywhere.
|
||||
RefPtr<xpc::ErrorReport> report = new xpc::ErrorReport();
|
||||
report->Init(err,
|
||||
"<unknown>", // toString result
|
||||
false, // chrome
|
||||
0); // window ID
|
||||
|
||||
if (!report->mFileName.IsEmpty()) {
|
||||
CopyUTF16toUTF8(report->mFileName, aSourceSpecOut);
|
||||
*aLineOut = report->mLineNumber;
|
||||
*aColumnOut = report->mColumn;
|
||||
}
|
||||
aMessageOut.Assign(report->mErrorMsg);
|
||||
}
|
||||
|
||||
// Next, try to unwrap the rejection value as a DOMException.
|
||||
else if(NS_SUCCEEDED(UNWRAP_OBJECT(DOMException, obj, domException))) {
|
||||
|
||||
nsAutoString filename;
|
||||
domException->GetFilename(aCx, filename);
|
||||
if (!filename.IsEmpty()) {
|
||||
CopyUTF16toUTF8(filename, aSourceSpecOut);
|
||||
*aLineOut = domException->LineNumber(aCx);
|
||||
*aColumnOut = domException->ColumnNumber();
|
||||
}
|
||||
|
||||
domException->GetName(aMessageOut);
|
||||
aMessageOut.AppendLiteral(": ");
|
||||
|
||||
nsAutoString message;
|
||||
domException->GetMessageMoz(message);
|
||||
aMessageOut.Append(message);
|
||||
}
|
||||
}
|
||||
|
||||
// If we could not unwrap a specific error type, then perform default safe
|
||||
// string conversions on primitives. Objects will result in "[Object]"
|
||||
// unfortunately.
|
||||
if (aMessageOut.IsEmpty()) {
|
||||
nsAutoJSString jsString;
|
||||
if (jsString.init(aCx, aValue)) {
|
||||
aMessageOut = jsString;
|
||||
} else {
|
||||
JS_ClearPendingException(aCx);
|
||||
}
|
||||
}
|
||||
}
|
||||
+26
-19
@@ -1010,6 +1010,10 @@ public:
|
||||
|
||||
static bool PrefetchEnabled(nsIDocShell* aDocShell);
|
||||
|
||||
static void ExtractErrorValues(JSContext* aCx, JS::Handle<JS::Value> aValue,
|
||||
nsACString& aSourceSpecOut, uint32_t *aLineOut,
|
||||
uint32_t *aColumnOut, nsString& aMessageOut);
|
||||
|
||||
static nsresult CalculateBufferSizeForImage(const uint32_t& aStride,
|
||||
const mozilla::gfx::IntSize& aImageSize,
|
||||
const mozilla::gfx::SurfaceFormat& aFormat,
|
||||
@@ -1504,9 +1508,10 @@ public:
|
||||
* @param aResult the result. Out param.
|
||||
* @return false on out of memory errors, true otherwise.
|
||||
*/
|
||||
MOZ_MUST_USE
|
||||
static bool GetNodeTextContent(nsINode* aNode, bool aDeep,
|
||||
nsAString& aResult, const mozilla::fallible_t&);
|
||||
[[nodiscard]] static bool GetNodeTextContent(nsINode* aNode,
|
||||
bool aDeep,
|
||||
nsAString& aResult,
|
||||
const mozilla::fallible_t&);
|
||||
|
||||
static void GetNodeTextContent(nsINode* aNode, bool aDeep,
|
||||
nsAString& aResult);
|
||||
@@ -1865,28 +1870,29 @@ public:
|
||||
*/
|
||||
static bool CanAccessNativeAnon();
|
||||
|
||||
MOZ_MUST_USE
|
||||
static nsresult WrapNative(JSContext *cx, nsISupports *native,
|
||||
const nsIID* aIID, JS::MutableHandle<JS::Value> vp,
|
||||
bool aAllowWrapping = true)
|
||||
[[nodiscard]] static nsresult WrapNative(JSContext* cx,
|
||||
nsISupports* native,
|
||||
const nsIID* aIID,
|
||||
JS::MutableHandle<JS::Value> vp,
|
||||
bool aAllowWrapping = true)
|
||||
{
|
||||
return WrapNative(cx, native, nullptr, aIID, vp, aAllowWrapping);
|
||||
}
|
||||
|
||||
// Same as the WrapNative above, but use this one if aIID is nsISupports' IID.
|
||||
MOZ_MUST_USE
|
||||
static nsresult WrapNative(JSContext *cx, nsISupports *native,
|
||||
JS::MutableHandle<JS::Value> vp,
|
||||
bool aAllowWrapping = true)
|
||||
[[nodiscard]] static nsresult WrapNative(JSContext* cx,
|
||||
nsISupports* native,
|
||||
JS::MutableHandle<JS::Value> vp,
|
||||
bool aAllowWrapping = true)
|
||||
{
|
||||
return WrapNative(cx, native, nullptr, nullptr, vp, aAllowWrapping);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE
|
||||
static nsresult WrapNative(JSContext *cx, nsISupports *native,
|
||||
nsWrapperCache *cache,
|
||||
JS::MutableHandle<JS::Value> vp,
|
||||
bool aAllowWrapping = true)
|
||||
[[nodiscard]] static nsresult WrapNative(JSContext* cx,
|
||||
nsISupports* native,
|
||||
nsWrapperCache* cache,
|
||||
JS::MutableHandle<JS::Value> vp,
|
||||
bool aAllowWrapping = true)
|
||||
{
|
||||
return WrapNative(cx, native, cache, nullptr, vp, aAllowWrapping);
|
||||
}
|
||||
@@ -1910,9 +1916,8 @@ public:
|
||||
* @param aString the string to convert the newlines inside [in/out]
|
||||
*/
|
||||
static void PlatformToDOMLineBreaks(nsString &aString);
|
||||
MOZ_MUST_USE
|
||||
static bool PlatformToDOMLineBreaks(nsString &aString,
|
||||
const mozilla::fallible_t&);
|
||||
[[nodiscard]] static bool PlatformToDOMLineBreaks(nsString &aString,
|
||||
const mozilla::fallible_t&);
|
||||
|
||||
/**
|
||||
* Populates aResultString with the contents of the string-buffer aBuf, up
|
||||
@@ -2679,6 +2684,8 @@ public:
|
||||
static mozilla::net::ReferrerPolicy GetReferrerPolicyFromHeader(const nsAString& aHeader);
|
||||
|
||||
static bool PushEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
static bool StreamsEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
static bool IsNonSubresourceRequest(nsIChannel* aChannel);
|
||||
|
||||
|
||||
@@ -47,3 +47,4 @@ DEPRECATED_OPERATION(PrefixedFullscreenAPI)
|
||||
DEPRECATED_OPERATION(LenientSetter)
|
||||
DEPRECATED_OPERATION(FileLastModifiedDate)
|
||||
DEPRECATED_OPERATION(ImageBitmapRenderingContext_TransferImageBitmap)
|
||||
DEPRECATED_OPERATION(DOMQuadBoundsAttr)
|
||||
@@ -4206,32 +4206,6 @@ nsDocument::SetScopeObject(nsIGlobalObject* aGlobal)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_EME
|
||||
static void
|
||||
CheckIfContainsEMEContent(nsISupports* aSupports, void* aContainsEME)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLMediaElement> domMediaElem(do_QueryInterface(aSupports));
|
||||
if (domMediaElem) {
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(domMediaElem));
|
||||
MOZ_ASSERT(content, "aSupports is not a content");
|
||||
HTMLMediaElement* mediaElem = static_cast<HTMLMediaElement*>(content.get());
|
||||
bool* contains = static_cast<bool*>(aContainsEME);
|
||||
if (mediaElem->GetMediaKeys()) {
|
||||
*contains = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::ContainsEMEContent()
|
||||
{
|
||||
bool containsEME = false;
|
||||
EnumerateActivityObservers(CheckIfContainsEMEContent,
|
||||
static_cast<void*>(&containsEME));
|
||||
return containsEME;
|
||||
}
|
||||
#endif // MOZ_EME
|
||||
|
||||
static void
|
||||
CheckIfContainsMSEContent(nsISupports* aSupports, void* aContainsMSE)
|
||||
{
|
||||
@@ -8036,14 +8010,6 @@ nsDocument::CanSavePresentation(nsIRequest *aNewRequest)
|
||||
}
|
||||
#endif // MOZ_WEBRTC
|
||||
|
||||
#ifdef MOZ_EME
|
||||
// Don't save presentations for documents containing EME content, so that
|
||||
// CDMs reliably shutdown upon user navigation.
|
||||
if (ContainsEMEContent()) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Don't save presentations for documents containing MSE content, to
|
||||
// reduce memory usage.
|
||||
if (ContainsMSEContent()) {
|
||||
|
||||
@@ -1104,10 +1104,6 @@ public:
|
||||
|
||||
js::ExpandoAndGeneration mExpandoAndGeneration;
|
||||
|
||||
#ifdef MOZ_EME
|
||||
bool ContainsEMEContent();
|
||||
#endif
|
||||
|
||||
bool ContainsMSEContent();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -144,9 +144,8 @@ public:
|
||||
virtual bool TextIsOnlyWhitespace() override;
|
||||
virtual bool HasTextForTranslation() override;
|
||||
virtual void AppendTextTo(nsAString& aResult) override;
|
||||
MOZ_MUST_USE
|
||||
virtual bool AppendTextTo(nsAString& aResult,
|
||||
const mozilla::fallible_t&) override;
|
||||
[[nodiscard]] virtual bool AppendTextTo(nsAString& aResult,
|
||||
const mozilla::fallible_t&) override;
|
||||
virtual void SaveSubtreeState() override;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
+13
-23
@@ -4222,6 +4222,15 @@ nsGlobalWindow::GetPerformance()
|
||||
return AsInner()->GetPerformance();
|
||||
}
|
||||
|
||||
void
|
||||
nsPIDOMWindowInner::QueuePerformanceNavigationTiming()
|
||||
{
|
||||
CreatePerformanceObjectIfNeeded();
|
||||
if (mPerformance) {
|
||||
mPerformance->QueueNavigationTimingEntry();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsPIDOMWindowInner::CreatePerformanceObjectIfNeeded()
|
||||
{
|
||||
@@ -12685,41 +12694,22 @@ nsGlobalWindow::SetTimeout(JSContext* aCx, const nsAString& aHandler,
|
||||
return SetTimeoutOrInterval(aCx, aHandler, aTimeout, false, aError);
|
||||
}
|
||||
|
||||
static bool
|
||||
IsInterval(const Optional<int32_t>& aTimeout, int32_t& aResultTimeout)
|
||||
{
|
||||
if (aTimeout.WasPassed()) {
|
||||
aResultTimeout = aTimeout.Value();
|
||||
return true;
|
||||
}
|
||||
|
||||
// If no interval was specified, treat this like a timeout, to avoid setting
|
||||
// an interval of 0 milliseconds.
|
||||
aResultTimeout = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t
|
||||
nsGlobalWindow::SetInterval(JSContext* aCx, Function& aFunction,
|
||||
const Optional<int32_t>& aTimeout,
|
||||
const int32_t aTimeout,
|
||||
const Sequence<JS::Value>& aArguments,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
int32_t timeout;
|
||||
bool isInterval = IsInterval(aTimeout, timeout);
|
||||
return SetTimeoutOrInterval(aCx, aFunction, timeout, aArguments, isInterval,
|
||||
aError);
|
||||
return SetTimeoutOrInterval(aCx, aFunction, aTimeout, aArguments, true, aError);
|
||||
}
|
||||
|
||||
int32_t
|
||||
nsGlobalWindow::SetInterval(JSContext* aCx, const nsAString& aHandler,
|
||||
const Optional<int32_t>& aTimeout,
|
||||
const int32_t aTimeout,
|
||||
const Sequence<JS::Value>& /* unused */,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
int32_t timeout;
|
||||
bool isInterval = IsInterval(aTimeout, timeout);
|
||||
return SetTimeoutOrInterval(aCx, aHandler, timeout, isInterval, aError);
|
||||
return SetTimeoutOrInterval(aCx, aHandler, aTimeout, true, aError);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
||||
@@ -953,11 +953,11 @@ public:
|
||||
mozilla::ErrorResult& aError);
|
||||
void ClearTimeout(int32_t aHandle);
|
||||
int32_t SetInterval(JSContext* aCx, mozilla::dom::Function& aFunction,
|
||||
const mozilla::dom::Optional<int32_t>& aTimeout,
|
||||
const int32_t aTimeout,
|
||||
const mozilla::dom::Sequence<JS::Value>& aArguments,
|
||||
mozilla::ErrorResult& aError);
|
||||
int32_t SetInterval(JSContext* aCx, const nsAString& aHandler,
|
||||
const mozilla::dom::Optional<int32_t>& aTimeout,
|
||||
const int32_t aTimeout,
|
||||
const mozilla::dom::Sequence<JS::Value>& /* unused */,
|
||||
mozilla::ErrorResult& aError);
|
||||
void ClearInterval(int32_t aHandle);
|
||||
|
||||
@@ -37,18 +37,16 @@ class nsHTMLContentSerializer final : public nsXHTMLContentSerializer {
|
||||
nsAString& aStr) override;
|
||||
protected:
|
||||
|
||||
MOZ_MUST_USE
|
||||
virtual bool SerializeHTMLAttributes(nsIContent* aContent,
|
||||
nsIContent *aOriginalElement,
|
||||
nsAString& aTagPrefix,
|
||||
const nsAString& aTagNamespaceURI,
|
||||
nsIAtom* aTagName,
|
||||
int32_t aNamespace,
|
||||
nsAString& aStr);
|
||||
[[nodiscard]] virtual bool SerializeHTMLAttributes(nsIContent* aContent,
|
||||
nsIContent* aOriginalElement,
|
||||
nsAString& aTagPrefix,
|
||||
const nsAString& aTagNamespaceURI,
|
||||
nsIAtom* aTagName,
|
||||
int32_t aNamespace,
|
||||
nsAString& aStr);
|
||||
|
||||
MOZ_MUST_USE
|
||||
virtual bool AppendAndTranslateEntities(const nsAString& aStr,
|
||||
nsAString& aOutputStr) override;
|
||||
[[nodiscard]] virtual bool AppendAndTranslateEntities(const nsAString& aStr,
|
||||
nsAString& aOutputStr) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -576,8 +576,7 @@ public:
|
||||
* Append the text content to aResult.
|
||||
* NOTE: This asserts and returns for elements
|
||||
*/
|
||||
MOZ_MUST_USE
|
||||
virtual bool AppendTextTo(nsAString& aResult, const mozilla::fallible_t&) = 0;
|
||||
[[nodiscard]] virtual bool AppendTextTo(nsAString& aResult, const mozilla::fallible_t&) = 0;
|
||||
|
||||
/**
|
||||
* Check if this content is focusable and in the current tab order.
|
||||
|
||||
@@ -2513,8 +2513,8 @@ public:
|
||||
mozilla::ErrorResult& rv);
|
||||
virtual mozilla::dom::DOMImplementation*
|
||||
GetImplementation(mozilla::ErrorResult& rv) = 0;
|
||||
MOZ_MUST_USE nsresult GetURL(nsString& retval) const;
|
||||
MOZ_MUST_USE nsresult GetDocumentURI(nsString& retval) const;
|
||||
[[nodiscard]] nsresult GetURL(nsString& retval) const;
|
||||
[[nodiscard]] nsresult GetDocumentURI(nsString& retval) const;
|
||||
// Return the URI for the document.
|
||||
// The returned value may differ if the document is loaded via XHR, and
|
||||
// when accessed from chrome privileged script and
|
||||
|
||||
+1
-1
@@ -1873,7 +1873,7 @@ public:
|
||||
aNodeName.SetStringBuffer(nsStringBuffer::FromString(nodeName),
|
||||
nodeName.Length());
|
||||
}
|
||||
MOZ_MUST_USE nsresult GetBaseURI(nsAString& aBaseURI) const;
|
||||
[[nodiscard]] nsresult GetBaseURI(nsAString& aBaseURI) const;
|
||||
// Return the base URI for the document.
|
||||
// The returned value may differ if the document is loaded via XHR, and
|
||||
// when accessed from chrome privileged script and
|
||||
|
||||
@@ -143,7 +143,7 @@ public:
|
||||
// After getting a notification that an off-thread compilation terminated,
|
||||
// this function will take the result of the parser and move it to the main
|
||||
// thread.
|
||||
MOZ_MUST_USE nsresult JoinCompile(void** aOffThreadToken);
|
||||
[[nodiscard]] nsresult JoinCompile(void** aOffThreadToken);
|
||||
|
||||
// Compile a script contained in a SourceText.
|
||||
nsresult Compile(JS::CompileOptions& aCompileOptions,
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
JSScript* GetScript();
|
||||
|
||||
// Execute the compiled script and ignore the return value.
|
||||
MOZ_MUST_USE nsresult ExecScript();
|
||||
[[nodiscard]] nsresult ExecScript();
|
||||
|
||||
// Execute the compiled script a get the return value.
|
||||
//
|
||||
@@ -180,10 +180,10 @@ public:
|
||||
// compartment given as argument to the ExecutionContext constructor. If the
|
||||
// caller is in a different compartment, then the out-param value should be
|
||||
// wrapped by calling |JS_WrapValue|.
|
||||
MOZ_MUST_USE nsresult
|
||||
[[nodiscard]] nsresult
|
||||
ExtractReturnValue(JS::MutableHandle<JS::Value> aRetValue);
|
||||
|
||||
MOZ_MUST_USE nsresult ExecScript(JS::MutableHandle<JS::Value> aRetValue);
|
||||
[[nodiscard]] nsresult ExecScript(JS::MutableHandle<JS::Value> aRetValue);
|
||||
};
|
||||
|
||||
static nsresult CompileModule(JSContext* aCx,
|
||||
|
||||
@@ -382,7 +382,7 @@ class nsObjectLoadingContent : public nsImageLoadingContent
|
||||
void GetNestedParams(nsTArray<mozilla::dom::MozPluginParameter>& aParameters,
|
||||
bool aIgnoreCodebase);
|
||||
|
||||
MOZ_MUST_USE nsresult BuildParametersArray();
|
||||
[[nodiscard]] nsresult BuildParametersArray();
|
||||
|
||||
/**
|
||||
* Loads fallback content with the specified FallbackType
|
||||
|
||||
@@ -727,6 +727,8 @@ public:
|
||||
|
||||
mozilla::dom::Performance* GetPerformance();
|
||||
|
||||
void QueuePerformanceNavigationTiming();
|
||||
|
||||
bool HasMutationListeners(uint32_t aMutationEventType) const
|
||||
{
|
||||
if (!mOuterWindow) {
|
||||
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
* Append the contents of this string fragment to aString
|
||||
* @return false if an out of memory condition is detected, true otherwise
|
||||
*/
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
bool AppendTo(nsAString& aString,
|
||||
const mozilla::fallible_t& aFallible) const {
|
||||
if (mState.mIs2b) {
|
||||
@@ -170,7 +170,7 @@ public:
|
||||
* @param aLength the length of the substring
|
||||
* @return false if an out of memory condition is detected, true otherwise
|
||||
*/
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
bool AppendTo(nsAString& aString, int32_t aOffset, int32_t aLength,
|
||||
const mozilla::fallible_t& aFallible) const
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
|
||||
nsAString& aStr,
|
||||
nsresult& aResult) override;
|
||||
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
virtual bool AfterElementStart(nsIContent* aContent,
|
||||
nsIContent* aOriginalElement,
|
||||
nsAString& aStr) override;
|
||||
@@ -70,7 +70,7 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
|
||||
virtual void MaybeEnterInPreContent(nsIContent* aNode) override;
|
||||
virtual void MaybeLeaveFromPreContent(nsIContent* aNode) override;
|
||||
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
virtual bool SerializeAttributes(nsIContent* aContent,
|
||||
nsIContent *aOriginalElement,
|
||||
nsAString& aTagPrefix,
|
||||
@@ -82,13 +82,13 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
|
||||
|
||||
bool IsFirstChildOfOL(nsIContent* aElement);
|
||||
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
bool SerializeLIValueAttribute(nsIContent* aElement,
|
||||
nsAString& aStr);
|
||||
bool IsShorthandAttr(const nsIAtom* aAttrName,
|
||||
const nsIAtom* aElementName);
|
||||
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
virtual bool AppendAndTranslateEntities(const nsAString& aStr,
|
||||
nsAString& aOutputStr) override;
|
||||
|
||||
|
||||
@@ -72,23 +72,21 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
||||
/**
|
||||
* Appends a char16_t character and increments the column position
|
||||
*/
|
||||
MOZ_MUST_USE
|
||||
bool AppendToString(const char16_t aChar,
|
||||
nsAString& aOutputStr);
|
||||
[[nodiscard]] bool AppendToString(const char16_t aChar,
|
||||
nsAString& aOutputStr);
|
||||
|
||||
/**
|
||||
* Appends a nsAString string and increments the column position
|
||||
*/
|
||||
MOZ_MUST_USE
|
||||
bool AppendToString(const nsAString& aStr,
|
||||
nsAString& aOutputStr);
|
||||
[[nodiscard]] bool AppendToString(const nsAString& aStr,
|
||||
nsAString& aOutputStr);
|
||||
|
||||
/**
|
||||
* Appends a string by replacing all line-endings
|
||||
* by mLineBreak, except in the case of raw output.
|
||||
* It increments the column position.
|
||||
*/
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
bool AppendToStringConvertLF(const nsAString& aStr,
|
||||
nsAString& aOutputStr);
|
||||
|
||||
@@ -96,7 +94,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
||||
* Appends a string by wrapping it when necessary.
|
||||
* It updates the column position.
|
||||
*/
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
bool AppendToStringWrapped(const nsASingleFragmentString& aStr,
|
||||
nsAString& aOutputStr);
|
||||
|
||||
@@ -104,12 +102,12 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
||||
* Appends a string by formating and wrapping it when necessary
|
||||
* It updates the column position.
|
||||
*/
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
bool AppendToStringFormatedWrapped(const nsASingleFragmentString& aStr,
|
||||
nsAString& aOutputStr);
|
||||
|
||||
// used by AppendToStringWrapped
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
bool AppendWrapped_WhitespaceSequence(
|
||||
nsASingleFragmentString::const_char_iterator &aPos,
|
||||
const nsASingleFragmentString::const_char_iterator aEnd,
|
||||
@@ -117,7 +115,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
||||
nsAString &aOutputStr);
|
||||
|
||||
// used by AppendToStringFormatedWrapped
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
bool AppendFormatedWrapped_WhitespaceSequence(
|
||||
nsASingleFragmentString::const_char_iterator &aPos,
|
||||
const nsASingleFragmentString::const_char_iterator aEnd,
|
||||
@@ -126,7 +124,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
||||
nsAString &aOutputStr);
|
||||
|
||||
// used by AppendToStringWrapped and AppendToStringFormatedWrapped
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
bool AppendWrapped_NonWhitespaceSequence(
|
||||
nsASingleFragmentString::const_char_iterator &aPos,
|
||||
const nsASingleFragmentString::const_char_iterator aEnd,
|
||||
@@ -139,7 +137,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
||||
* add mLineBreak to the string
|
||||
* It updates the column position and other flags.
|
||||
*/
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
bool AppendNewLineToString(nsAString& aOutputStr);
|
||||
|
||||
|
||||
@@ -147,7 +145,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
||||
* Appends a string by translating entities
|
||||
* It doesn't increment the column position
|
||||
*/
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
virtual bool AppendAndTranslateEntities(const nsAString& aStr,
|
||||
nsAString& aOutputStr);
|
||||
|
||||
@@ -197,7 +195,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
||||
nsIContent *aOriginalElement,
|
||||
const nsAString& aTagNamespaceURI);
|
||||
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
virtual bool SerializeAttributes(nsIContent* aContent,
|
||||
nsIContent *aOriginalElement,
|
||||
nsAString& aTagPrefix,
|
||||
@@ -207,7 +205,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
||||
uint32_t aSkipAttr,
|
||||
bool aAddNSAttr);
|
||||
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
bool SerializeAttr(const nsAString& aPrefix,
|
||||
const nsAString& aName,
|
||||
const nsAString& aValue,
|
||||
@@ -239,7 +237,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
||||
* aElement and aOriginalElement are the same as the corresponding arguments
|
||||
* to AppendElementStart.
|
||||
*/
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
bool AppendEndOfElementStart(mozilla::dom::Element* aEleemnt,
|
||||
mozilla::dom::Element* aOriginalElement,
|
||||
nsAString& aStr);
|
||||
@@ -249,7 +247,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
||||
* after the serialization ot the start tag.
|
||||
* (called at the end of AppendElementStart)
|
||||
*/
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
virtual bool AfterElementStart(nsIContent* aContent,
|
||||
nsIContent* aOriginalElement,
|
||||
nsAString& aStr) { return true; };
|
||||
@@ -299,17 +297,14 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
||||
* add intendation. Call only in the case of formating and if the current
|
||||
* position is at 0. It updates the column position.
|
||||
*/
|
||||
MOZ_MUST_USE
|
||||
bool AppendIndentation(nsAString& aStr);
|
||||
[[nodiscard]] bool AppendIndentation(nsAString& aStr);
|
||||
|
||||
MOZ_MUST_USE
|
||||
bool IncrIndentation(nsIAtom* aName);
|
||||
[[nodiscard]] bool IncrIndentation(nsIAtom* aName);
|
||||
void DecrIndentation(nsIAtom* aName);
|
||||
|
||||
// Functions to check for newlines that needs to be added between nodes in
|
||||
// the root of a document. See mAddNewlineForRootNode
|
||||
MOZ_MUST_USE
|
||||
bool MaybeAddNewlineForRootNode(nsAString& aStr);
|
||||
[[nodiscard]] bool MaybeAddNewlineForRootNode(nsAString& aStr);
|
||||
void MaybeFlagNewlineForRootNode(nsINode* aNode);
|
||||
|
||||
// Functions to check if we enter in or leave from a preformated content
|
||||
|
||||
@@ -1037,11 +1037,17 @@ MaybeWrapValue(JSContext* cx, JS::MutableHandle<JS::Value> rval)
|
||||
return MaybeWrapStringValue(cx, rval);
|
||||
}
|
||||
|
||||
if (!rval.isObject()) {
|
||||
return true;
|
||||
if (rval.isObject()) {
|
||||
return MaybeWrapObjectValue(cx, rval);
|
||||
}
|
||||
|
||||
return MaybeWrapObjectValue(cx, rval);
|
||||
// This could be optimized by checking the zone first, similar to
|
||||
// the way strings are handled. At present, this is used primarily
|
||||
// for structured cloning, so avoiding the overhead of JS_WrapValue
|
||||
// calls is less important than for other types.
|
||||
if (rval.isBigInt()) {
|
||||
return JS_WrapValue(cx, rval);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace binding_detail {
|
||||
|
||||
@@ -103,11 +103,13 @@ DOMInterfaces = {
|
||||
},
|
||||
|
||||
'Cache': {
|
||||
'implicitJSContext': [ 'add', 'addAll' ],
|
||||
'implicitJSContext': [ 'add', 'addAll', 'match', 'matchAll', 'put',
|
||||
'delete', 'keys' ],
|
||||
'nativeType': 'mozilla::dom::cache::Cache',
|
||||
},
|
||||
|
||||
'CacheStorage': {
|
||||
'implicitJSContext': [ 'match' ],
|
||||
'nativeType': 'mozilla::dom::cache::CacheStorage',
|
||||
},
|
||||
|
||||
@@ -236,12 +238,10 @@ DOMInterfaces = {
|
||||
|
||||
'DOMMatrixReadOnly': {
|
||||
'headerFile': 'mozilla/dom/DOMMatrix.h',
|
||||
'concrete': False,
|
||||
},
|
||||
|
||||
'DOMPointReadOnly': {
|
||||
'headerFile': 'mozilla/dom/DOMPoint.h',
|
||||
'concrete': False,
|
||||
},
|
||||
|
||||
'DOMRectList': {
|
||||
@@ -707,6 +707,7 @@ DOMInterfaces = {
|
||||
'headers': 'headers_',
|
||||
'referrerPolicy': 'referrerPolicy_'
|
||||
},
|
||||
'implicitJSContext': [ 'arrayBuffer', 'blob', 'formData', 'json', 'text' ],
|
||||
},
|
||||
|
||||
'ResizeObservation': {
|
||||
@@ -731,6 +732,8 @@ DOMInterfaces = {
|
||||
|
||||
'Response': {
|
||||
'binaryNames': { 'headers': 'headers_' },
|
||||
'implicitJSContext': [ 'arrayBuffer', 'blob', 'formData', 'json', 'text',
|
||||
'clone', 'cloneUnfiltered' ],
|
||||
},
|
||||
|
||||
'RGBColor': {
|
||||
|
||||
+90
-74
@@ -1156,7 +1156,10 @@ class CGHeaders(CGWrapper):
|
||||
# just include their header if we need to have functions
|
||||
# taking references to them declared in that header.
|
||||
headerSet = declareIncludes
|
||||
headerSet.add("mozilla/dom/TypedArray.h")
|
||||
if unrolled.isReadableStream():
|
||||
headerSet.add("mozilla/dom/ReadableStream.h")
|
||||
else:
|
||||
headerSet.add("mozilla/dom/TypedArray.h")
|
||||
else:
|
||||
try:
|
||||
typeDesc = config.getDescriptor(unrolled.inner.identifier.name)
|
||||
@@ -1371,7 +1374,10 @@ def UnionTypes(unionTypes, config):
|
||||
elif f.isInterface():
|
||||
if f.isSpiderMonkeyInterface():
|
||||
headers.add("jsfriendapi.h")
|
||||
headers.add("mozilla/dom/TypedArray.h")
|
||||
if f.isReadableStream():
|
||||
headers.add("mozilla/dom/ReadableStream.h")
|
||||
else:
|
||||
headers.add("mozilla/dom/TypedArray.h")
|
||||
else:
|
||||
try:
|
||||
typeDesc = config.getDescriptor(f.inner.identifier.name)
|
||||
@@ -1457,7 +1463,10 @@ def UnionConversions(unionTypes, config):
|
||||
elif f.isInterface():
|
||||
if f.isSpiderMonkeyInterface():
|
||||
headers.add("jsfriendapi.h")
|
||||
headers.add("mozilla/dom/TypedArray.h")
|
||||
if f.isReadableStream():
|
||||
headers.add("mozilla/dom/ReadableStream.h")
|
||||
else:
|
||||
headers.add("mozilla/dom/TypedArray.h")
|
||||
elif f.inner.isExternal():
|
||||
try:
|
||||
typeDesc = config.getDescriptor(f.inner.identifier.name)
|
||||
@@ -5582,8 +5591,8 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||
if type.isSpiderMonkeyInterface():
|
||||
assert not isEnforceRange and not isClamp
|
||||
name = type.unroll().name # unroll() because it may be nullable
|
||||
arrayType = CGGeneric(name)
|
||||
declType = arrayType
|
||||
interfaceType = CGGeneric(name)
|
||||
declType = interfaceType
|
||||
if type.nullable():
|
||||
declType = CGTemplatedType("Nullable", declType)
|
||||
objRef = "${declName}.SetValue()"
|
||||
@@ -5607,22 +5616,23 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||
# This is a bit annoying. In a union we don't want to have a
|
||||
# holder, since unions don't support that. But if we're optional we
|
||||
# want to have a holder, so that the callee doesn't see
|
||||
# Optional<RootedTypedArray<ArrayType> >. So do a holder if we're
|
||||
# optional and use a RootedTypedArray otherwise.
|
||||
# Optional<RootedSpiderMonkeyInterface<InterfaceType>>. So do a
|
||||
# holder if we're optional and use a RootedSpiderMonkeyInterface
|
||||
# otherwise.
|
||||
if isOptional:
|
||||
holderType = CGTemplatedType("TypedArrayRooter", arrayType)
|
||||
# If our typed array is nullable, this will set the Nullable to
|
||||
# be not-null, but that's ok because we make an explicit
|
||||
# SetNull() call on it as needed if our JS value is actually
|
||||
# null. XXXbz Because "Maybe" takes const refs for constructor
|
||||
# arguments, we can't pass a reference here; have to pass a
|
||||
# pointer.
|
||||
holderType = CGTemplatedType("SpiderMonkeyInterfaceRooter", interfaceType)
|
||||
# If our SpiderMonkey interface is nullable, this will set the
|
||||
# Nullable to be not-null, but that's ok because we make an
|
||||
# explicit SetNull() call on it as needed if our JS value is
|
||||
# actually null. XXXbz Because "Maybe" takes const refs for
|
||||
# constructor arguments, we can't pass a reference here; have
|
||||
# to pass a pointer.
|
||||
holderArgs = "cx, &%s" % objRef
|
||||
declArgs = None
|
||||
else:
|
||||
holderType = None
|
||||
holderArgs = None
|
||||
declType = CGTemplatedType("RootedTypedArray", declType)
|
||||
declType = CGTemplatedType("RootedSpiderMonkeyInterface", declType)
|
||||
declArgs = "cx"
|
||||
else:
|
||||
holderType = None
|
||||
@@ -6371,7 +6381,7 @@ def getMaybeWrapValueFuncForType(type):
|
||||
if type.nullable():
|
||||
return "MaybeWrapObjectOrNullValue"
|
||||
return "MaybeWrapObjectValue"
|
||||
# Spidermonkey interfaces are never DOM objects. Neither are sequences or
|
||||
# SpiderMonkey interfaces are never DOM objects. Neither are sequences or
|
||||
# dictionaries, since those are always plain JS objects.
|
||||
if type.isSpiderMonkeyInterface() or type.isDictionary() or type.isSequence():
|
||||
if type.nullable():
|
||||
@@ -6391,7 +6401,8 @@ recordWrapLevel = 0
|
||||
|
||||
|
||||
def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
||||
returnsNewObject, exceptionCode, typedArraysAreStructs,
|
||||
returnsNewObject, exceptionCode,
|
||||
spiderMonkeyInterfacesAreStructs,
|
||||
isConstructorRetval=False):
|
||||
"""
|
||||
Reflect a C++ value stored in "result", of IDL type "type" into JS. The
|
||||
@@ -6401,8 +6412,9 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
||||
doing a 'break' if the entire conversion template is inside a block that
|
||||
the 'break' will exit).
|
||||
|
||||
If typedArraysAreStructs is true, then if the type is a typed array,
|
||||
"result" is one of the dom::TypedArray subclasses, not a JSObject*.
|
||||
If spiderMonkeyInterfacesAreStructs is true, then if the type is a
|
||||
SpiderMonkey interface, "result" is one of the
|
||||
dom::SpiderMonkeyInterfaceObjectStorage subclasses, not a JSObject*.
|
||||
|
||||
The resulting string should be used with string.Template. It
|
||||
needs the following keys when substituting:
|
||||
@@ -6497,7 +6509,7 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
||||
recTemplate, recInfall = getWrapTemplateForType(type.inner, descriptorProvider,
|
||||
"%s.Value()" % result, successCode,
|
||||
returnsNewObject, exceptionCode,
|
||||
typedArraysAreStructs)
|
||||
spiderMonkeyInterfacesAreStructs)
|
||||
code = fill(
|
||||
"""
|
||||
|
||||
@@ -6529,7 +6541,7 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
||||
'returnsNewObject': returnsNewObject,
|
||||
'exceptionCode': exceptionCode,
|
||||
'obj': "returnArray",
|
||||
'typedArraysAreStructs': typedArraysAreStructs
|
||||
'spiderMonkeyInterfacesAreStructs': spiderMonkeyInterfacesAreStructs
|
||||
})
|
||||
sequenceWrapLevel -= 1
|
||||
code = fill(
|
||||
@@ -6583,7 +6595,7 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
||||
'returnsNewObject': returnsNewObject,
|
||||
'exceptionCode': exceptionCode,
|
||||
'obj': "returnObj",
|
||||
'typedArraysAreStructs': typedArraysAreStructs
|
||||
'spiderMonkeyInterfacesAreStructs': spiderMonkeyInterfacesAreStructs
|
||||
})
|
||||
recordWrapLevel -= 1
|
||||
if type.keyType.isByteString():
|
||||
@@ -6749,7 +6761,7 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
||||
return (head + _setValue(result, wrapAsType=type), False)
|
||||
|
||||
if (type.isObject() or (type.isSpiderMonkeyInterface() and
|
||||
not typedArraysAreStructs)):
|
||||
not spiderMonkeyInterfacesAreStructs)):
|
||||
# See comments in GetOrCreateDOMReflector explaining why we need
|
||||
# to wrap here.
|
||||
if type.nullable():
|
||||
@@ -6768,21 +6780,21 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
||||
|
||||
if not (type.isUnion() or type.isPrimitive() or type.isDictionary() or
|
||||
type.isDate() or
|
||||
(type.isSpiderMonkeyInterface() and typedArraysAreStructs)):
|
||||
(type.isSpiderMonkeyInterface() and spiderMonkeyInterfacesAreStructs)):
|
||||
raise TypeError("Need to learn to wrap %s" % type)
|
||||
|
||||
if type.nullable():
|
||||
recTemplate, recInfal = getWrapTemplateForType(type.inner, descriptorProvider,
|
||||
"%s.Value()" % result, successCode,
|
||||
returnsNewObject, exceptionCode,
|
||||
typedArraysAreStructs)
|
||||
spiderMonkeyInterfacesAreStructs)
|
||||
return ("if (%s.IsNull()) {\n" % result +
|
||||
indent(setNull()) +
|
||||
"}\n" +
|
||||
recTemplate, recInfal)
|
||||
|
||||
if type.isSpiderMonkeyInterface():
|
||||
assert typedArraysAreStructs
|
||||
assert spiderMonkeyInterfacesAreStructs
|
||||
# See comments in GetOrCreateDOMReflector explaining why we need
|
||||
# to wrap here.
|
||||
# NB: setObject(..., some-object-type) calls JS_WrapValue(), so is fallible
|
||||
@@ -6864,7 +6876,7 @@ def wrapForType(type, descriptorProvider, templateValues):
|
||||
templateValues.get('successCode', None),
|
||||
templateValues.get('returnsNewObject', False),
|
||||
templateValues.get('exceptionCode', "return false;\n"),
|
||||
templateValues.get('typedArraysAreStructs', False),
|
||||
templateValues.get('spiderMonkeyInterfacesAreStructs', False),
|
||||
isConstructorRetval=templateValues.get('isConstructorRetval', False))[0]
|
||||
|
||||
defaultValues = {'obj': 'obj'}
|
||||
@@ -8193,10 +8205,10 @@ class CGMethodCall(CGThing):
|
||||
# "object" arg.
|
||||
|
||||
# First grab all the overloads that have a non-callback interface
|
||||
# (which includes typed arrays and arraybuffers) at the
|
||||
# distinguishing index. We can also include the ones that have an
|
||||
# "object" here, since if those are present no other object-typed
|
||||
# argument will be.
|
||||
# (which includes SpiderMonkey interfaces) at the distinguishing
|
||||
# index. We can also include the ones that have an "object" here,
|
||||
# since if those are present no other object-typed argument will
|
||||
# be.
|
||||
objectSigs = [
|
||||
s for s in possibleSignatures
|
||||
if (distinguishingType(s).isObject() or
|
||||
@@ -8227,16 +8239,17 @@ class CGMethodCall(CGThing):
|
||||
# There might be more than one thing in objectSigs; we need to check
|
||||
# which ones we unwrap to.
|
||||
if len(objectSigs) > 0:
|
||||
# Here it's enough to guard on our argument being an object. The
|
||||
# code for unwrapping non-callback interfaces, typed arrays,
|
||||
# sequences, and Dates will just bail out and move on to
|
||||
# the next overload if the object fails to unwrap correctly,
|
||||
# while "object" accepts any object anyway. We could even not
|
||||
# do the isObject() check up front here, but in cases where we
|
||||
# have multiple object overloads it makes sense to do it only
|
||||
# once instead of for each overload. That will also allow the
|
||||
# unwrapping test to skip having to do codegen for the
|
||||
# null-or-undefined case, which we already handled above.
|
||||
# Here it's enough to guard on our argument being an object.
|
||||
# The code for unwrapping non-callback interfaces, spiderMonkey
|
||||
# interfaces, sequences, and Dates will just bail out and move
|
||||
# on to the next overload if the object fails to unwrap
|
||||
# correctly, while "object" accepts any object anyway. We
|
||||
# could even not do the isObject() check up front here, but in
|
||||
# cases where we have multiple object overloads it makes sense
|
||||
# to do it only once instead of for each overload. That will
|
||||
# also allow the unwrapping test to skip having to do codegen
|
||||
# for the null-or-undefined case, which we already handled
|
||||
# above.
|
||||
caseBody.append(CGGeneric("if (%s.isObject()) {\n" %
|
||||
distinguishingArg))
|
||||
for sig in objectSigs:
|
||||
@@ -10239,7 +10252,7 @@ class CGUnionStruct(CGThing):
|
||||
"jsvalHandle": "rval",
|
||||
"obj": "scopeObj",
|
||||
"result": val,
|
||||
"typedArraysAreStructs": True
|
||||
"spiderMonkeyInterfacesAreStructs": True
|
||||
})
|
||||
return CGGeneric(wrapCode)
|
||||
|
||||
@@ -13219,7 +13232,7 @@ class CGDictionary(CGThing):
|
||||
# 'obj' can just be allowed to be the string "obj", since that
|
||||
# will be our dictionary object, which is presumably itself in
|
||||
# the right scope.
|
||||
'typedArraysAreStructs': True
|
||||
'spiderMonkeyInterfacesAreStructs': True
|
||||
})
|
||||
conversion = CGGeneric(innerTemplate)
|
||||
conversion = CGWrapper(conversion,
|
||||
@@ -13679,7 +13692,7 @@ class ForwardDeclarationBuilder:
|
||||
except NoSuchDescriptorError:
|
||||
pass
|
||||
|
||||
# Note: Spidermonkey interfaces are typedefs, so can't be
|
||||
# Note: SpiderMonkey interfaces are typedefs, so can't be
|
||||
# forward-declared
|
||||
elif t.isPromise():
|
||||
self.addInMozillaDom("Promise")
|
||||
@@ -13988,7 +14001,7 @@ class CGBindingRoot(CGThing):
|
||||
return {desc.getDescriptor(desc.interface.parent.identifier.name)}
|
||||
for x in dependencySortObjects(jsImplemented, getParentDescriptor,
|
||||
lambda d: d.interface.identifier.name):
|
||||
cgthings.append(CGCallbackInterface(x, typedArraysAreStructs=True))
|
||||
cgthings.append(CGCallbackInterface(x, spiderMonkeyInterfacesAreStructs=True))
|
||||
cgthings.append(CGJSImplClass(x))
|
||||
|
||||
# And make sure we have the right number of newlines at the end
|
||||
@@ -14050,14 +14063,13 @@ class CGBindingRoot(CGThing):
|
||||
class CGNativeMember(ClassMethod):
|
||||
def __init__(self, descriptorProvider, member, name, signature, extendedAttrs,
|
||||
breakAfter=True, passJSBitsAsNeeded=True, visibility="public",
|
||||
typedArraysAreStructs=True, variadicIsSequence=False,
|
||||
resultNotAddRefed=False,
|
||||
virtual=False,
|
||||
override=False):
|
||||
spiderMonkeyInterfacesAreStructs=True,
|
||||
variadicIsSequence=False, resultNotAddRefed=False,
|
||||
virtual=False, override=False):
|
||||
"""
|
||||
If typedArraysAreStructs is false, typed arrays will be passed as
|
||||
JS::Handle<JSObject*>. If it's true they will be passed as one of the
|
||||
dom::TypedArray subclasses.
|
||||
If spiderMonkeyInterfacesAreStructs is false, SpiderMonkey interfaces
|
||||
will be passed as JS::Handle<JSObject*>. If it's true they will be
|
||||
passed as one of the dom::SpiderMonkeyInterfaceObjectStorage subclasses.
|
||||
|
||||
If passJSBitsAsNeeded is false, we don't automatically pass in a
|
||||
JSContext* or a JSObject* based on the return and argument types. We
|
||||
@@ -14068,7 +14080,7 @@ class CGNativeMember(ClassMethod):
|
||||
self.extendedAttrs = extendedAttrs
|
||||
self.resultAlreadyAddRefed = not resultNotAddRefed
|
||||
self.passJSBitsAsNeeded = passJSBitsAsNeeded
|
||||
self.typedArraysAreStructs = typedArraysAreStructs
|
||||
self.spiderMonkeyInterfacesAreStructs = spiderMonkeyInterfacesAreStructs
|
||||
self.variadicIsSequence = variadicIsSequence
|
||||
breakAfterSelf = "\n" if breakAfter else ""
|
||||
ClassMethod.__init__(self, name,
|
||||
@@ -14375,7 +14387,7 @@ class CGNativeMember(ClassMethod):
|
||||
False, False)
|
||||
|
||||
if type.isSpiderMonkeyInterface():
|
||||
if not self.typedArraysAreStructs:
|
||||
if not self.spiderMonkeyInterfacesAreStructs:
|
||||
return "JS::Handle<JSObject*>", False, False
|
||||
|
||||
# Unroll for the name, in case we're nullable.
|
||||
@@ -15547,16 +15559,16 @@ class CGFastCallback(CGClass):
|
||||
|
||||
|
||||
class CGCallbackInterface(CGCallback):
|
||||
def __init__(self, descriptor, typedArraysAreStructs=False):
|
||||
def __init__(self, descriptor, spiderMonkeyInterfacesAreStructs=False):
|
||||
iface = descriptor.interface
|
||||
attrs = [m for m in iface.members if m.isAttr() and not m.isStatic()]
|
||||
getters = [CallbackGetter(a, descriptor, typedArraysAreStructs)
|
||||
getters = [CallbackGetter(a, descriptor, spiderMonkeyInterfacesAreStructs)
|
||||
for a in attrs]
|
||||
setters = [CallbackSetter(a, descriptor, typedArraysAreStructs)
|
||||
setters = [CallbackSetter(a, descriptor, spiderMonkeyInterfacesAreStructs)
|
||||
for a in attrs if not a.readonly]
|
||||
methods = [m for m in iface.members
|
||||
if m.isMethod() and not m.isStatic() and not m.isIdentifierLess()]
|
||||
methods = [CallbackOperation(m, sig, descriptor, typedArraysAreStructs)
|
||||
methods = [CallbackOperation(m, sig, descriptor, spiderMonkeyInterfacesAreStructs)
|
||||
for m in methods for sig in m.signatures()]
|
||||
if iface.isJSImplemented() and iface.ctor():
|
||||
sigs = descriptor.interface.ctor().signatures()
|
||||
@@ -15601,7 +15613,8 @@ class CallbackMember(CGNativeMember):
|
||||
# CallSetup already handled the unmark-gray bits for us. we don't have
|
||||
# anything better to use for 'obj', really...
|
||||
def __init__(self, sig, name, descriptorProvider, needThisHandling,
|
||||
rethrowContentException=False, typedArraysAreStructs=False,
|
||||
rethrowContentException=False,
|
||||
spiderMonkeyInterfacesAreStructs=False,
|
||||
wrapScope='CallbackKnownNotGray()'):
|
||||
"""
|
||||
needThisHandling is True if we need to be able to accept a specified
|
||||
@@ -15636,7 +15649,7 @@ class CallbackMember(CGNativeMember):
|
||||
extendedAttrs={},
|
||||
passJSBitsAsNeeded=False,
|
||||
visibility=visibility,
|
||||
typedArraysAreStructs=typedArraysAreStructs)
|
||||
spiderMonkeyInterfacesAreStructs=spiderMonkeyInterfacesAreStructs)
|
||||
# We have to do all the generation of our body now, because
|
||||
# the caller relies on us throwing if we can't manage it.
|
||||
self.exceptionCode = ("aRv.Throw(NS_ERROR_UNEXPECTED);\n"
|
||||
@@ -15753,7 +15766,7 @@ class CallbackMember(CGNativeMember):
|
||||
'obj': self.wrapScope,
|
||||
'returnsNewObject': False,
|
||||
'exceptionCode': self.exceptionCode,
|
||||
'typedArraysAreStructs': self.typedArraysAreStructs
|
||||
'spiderMonkeyInterfacesAreStructs': self.spiderMonkeyInterfacesAreStructs
|
||||
})
|
||||
except MethodNotNewObjectError as err:
|
||||
raise TypeError("%s being passed as an argument to %s but is not "
|
||||
@@ -15857,10 +15870,11 @@ class CallbackMember(CGNativeMember):
|
||||
|
||||
class CallbackMethod(CallbackMember):
|
||||
def __init__(self, sig, name, descriptorProvider, needThisHandling,
|
||||
rethrowContentException=False, typedArraysAreStructs=False):
|
||||
rethrowContentException=False,
|
||||
spiderMonkeyInterfacesAreStructs=False):
|
||||
CallbackMember.__init__(self, sig, name, descriptorProvider,
|
||||
needThisHandling, rethrowContentException,
|
||||
typedArraysAreStructs=typedArraysAreStructs)
|
||||
spiderMonkeyInterfacesAreStructs=spiderMonkeyInterfacesAreStructs)
|
||||
|
||||
def getRvalDecl(self):
|
||||
return "JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());\n"
|
||||
@@ -15919,12 +15933,12 @@ class CallbackOperationBase(CallbackMethod):
|
||||
"""
|
||||
def __init__(self, signature, jsName, nativeName, descriptor,
|
||||
singleOperation, rethrowContentException=False,
|
||||
typedArraysAreStructs=False):
|
||||
spiderMonkeyInterfacesAreStructs=False):
|
||||
self.singleOperation = singleOperation
|
||||
self.methodName = descriptor.binaryNameFor(jsName)
|
||||
CallbackMethod.__init__(self, signature, nativeName, descriptor,
|
||||
singleOperation, rethrowContentException,
|
||||
typedArraysAreStructs=typedArraysAreStructs)
|
||||
spiderMonkeyInterfacesAreStructs=spiderMonkeyInterfacesAreStructs)
|
||||
|
||||
def getThisDecl(self):
|
||||
if not self.singleOperation:
|
||||
@@ -15975,7 +15989,8 @@ class CallbackOperation(CallbackOperationBase):
|
||||
"""
|
||||
Codegen actual WebIDL operations on callback interfaces.
|
||||
"""
|
||||
def __init__(self, method, signature, descriptor, typedArraysAreStructs):
|
||||
def __init__(self, method, signature, descriptor,
|
||||
spiderMonkeyInterfacesAreStructs):
|
||||
self.ensureASCIIName(method)
|
||||
self.method = method
|
||||
jsName = method.identifier.name
|
||||
@@ -15984,7 +15999,7 @@ class CallbackOperation(CallbackOperationBase):
|
||||
MakeNativeName(descriptor.binaryNameFor(jsName)),
|
||||
descriptor, descriptor.interface.isSingleOperationInterface(),
|
||||
rethrowContentException=descriptor.interface.isJSImplemented(),
|
||||
typedArraysAreStructs=typedArraysAreStructs)
|
||||
spiderMonkeyInterfacesAreStructs=spiderMonkeyInterfacesAreStructs)
|
||||
|
||||
def getPrettyName(self):
|
||||
return "%s.%s" % (self.descriptorProvider.interface.identifier.name,
|
||||
@@ -15995,13 +16010,14 @@ class CallbackAccessor(CallbackMember):
|
||||
"""
|
||||
Shared superclass for CallbackGetter and CallbackSetter.
|
||||
"""
|
||||
def __init__(self, attr, sig, name, descriptor, typedArraysAreStructs):
|
||||
def __init__(self, attr, sig, name, descriptor,
|
||||
spiderMonkeyInterfacesAreStructs):
|
||||
self.ensureASCIIName(attr)
|
||||
self.attrName = attr.identifier.name
|
||||
CallbackMember.__init__(self, sig, name, descriptor,
|
||||
needThisHandling=False,
|
||||
rethrowContentException=descriptor.interface.isJSImplemented(),
|
||||
typedArraysAreStructs=typedArraysAreStructs)
|
||||
spiderMonkeyInterfacesAreStructs=spiderMonkeyInterfacesAreStructs)
|
||||
|
||||
def getPrettyName(self):
|
||||
return "%s.%s" % (self.descriptorProvider.interface.identifier.name,
|
||||
@@ -16009,12 +16025,12 @@ class CallbackAccessor(CallbackMember):
|
||||
|
||||
|
||||
class CallbackGetter(CallbackAccessor):
|
||||
def __init__(self, attr, descriptor, typedArraysAreStructs):
|
||||
def __init__(self, attr, descriptor, spiderMonkeyInterfacesAreStructs):
|
||||
CallbackAccessor.__init__(self, attr,
|
||||
(attr.type, []),
|
||||
callbackGetterName(attr, descriptor),
|
||||
descriptor,
|
||||
typedArraysAreStructs)
|
||||
spiderMonkeyInterfacesAreStructs)
|
||||
|
||||
def getRvalDecl(self):
|
||||
return "JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());\n"
|
||||
@@ -16036,12 +16052,12 @@ class CallbackGetter(CallbackAccessor):
|
||||
|
||||
|
||||
class CallbackSetter(CallbackAccessor):
|
||||
def __init__(self, attr, descriptor, typedArraysAreStructs):
|
||||
def __init__(self, attr, descriptor, spiderMonkeyInterfacesAreStructs):
|
||||
CallbackAccessor.__init__(self, attr,
|
||||
(BuiltinTypes[IDLBuiltinType.Types.void],
|
||||
[FakeArgument(attr.type, attr)]),
|
||||
callbackSetterName(attr, descriptor),
|
||||
descriptor, typedArraysAreStructs)
|
||||
descriptor, spiderMonkeyInterfacesAreStructs)
|
||||
|
||||
def getRvalDecl(self):
|
||||
# We don't need an rval
|
||||
@@ -16076,7 +16092,7 @@ class CGJSImplInitOperation(CallbackOperationBase):
|
||||
"__init", "__Init", descriptor,
|
||||
singleOperation=False,
|
||||
rethrowContentException=True,
|
||||
typedArraysAreStructs=True)
|
||||
spiderMonkeyInterfacesAreStructs=True)
|
||||
|
||||
def getPrettyName(self):
|
||||
return "__init"
|
||||
|
||||
@@ -100,6 +100,9 @@ MSG_DEF(MSG_TIME_VALUE_OUT_OF_RANGE, 1, JSEXN_TYPEERR, "{0} is outside the suppo
|
||||
MSG_DEF(MSG_ONLY_IF_CACHED_WITHOUT_SAME_ORIGIN, 1, JSEXN_TYPEERR, "Request mode '{0}' was used, but request cache mode 'only-if-cached' can only be used with request mode 'same-origin'.")
|
||||
MSG_DEF(MSG_THRESHOLD_RANGE_ERROR, 0, JSEXN_RANGEERR, "Threshold values must all be in the range [0, 1].")
|
||||
MSG_DEF(MSG_CACHE_OPEN_FAILED, 0, JSEXN_TYPEERR, "CacheStorage.open() failed to access the storage system.")
|
||||
MSG_DEF(MSG_MATRIX_INIT_CONFLICTING_VALUE, 2, JSEXN_TYPEERR, "Matrix init unexpectedly got different values for '{0}' and '{1}'.")
|
||||
MSG_DEF(MSG_MATRIX_INIT_EXCEEDS_2D, 1, JSEXN_TYPEERR, "Matrix init has an unexpected 3D element '{0}' which cannot coexist with 'is2D: true'.")
|
||||
MSG_DEF(MSG_MATRIX_INIT_LENGTH_WRONG, 1, JSEXN_TYPEERR, "Matrix init sequence must have a length of 6 or 16 (actual value: {0})")
|
||||
MSG_DEF(MSG_NO_NEGATIVE_ATTR, 1, JSEXN_TYPEERR, "Given attribute {0} cannot be negative.")
|
||||
MSG_DEF(MSG_PMO_NO_SEPARATE_ENDMARK, 0, JSEXN_TYPEERR, "Cannot provide separate endMark argument if PerformanceMeasureOptions argument is given.")
|
||||
MSG_DEF(MSG_PMO_MISSING_STARTENDMARK, 0, JSEXN_TYPEERR, "PerformanceMeasureOptions must have start and/or end member.")
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_ReadableStream_h
|
||||
#define mozilla_dom_ReadableStream_h
|
||||
|
||||
#include "mozilla/dom/SpiderMonkeyInterface.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
struct ReadableStream : public SpiderMonkeyInterfaceObjectStorage
|
||||
{
|
||||
inline bool Init(JSObject* obj)
|
||||
{
|
||||
MOZ_ASSERT(!inited());
|
||||
mImplObj = mWrappedObj = js::UnwrapReadableStream(obj);
|
||||
return inited();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* mozilla_dom_ReadableStream_h */
|
||||
@@ -0,0 +1,144 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_SpiderMonkeyInterface_h
|
||||
#define mozilla_dom_SpiderMonkeyInterface_h
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/TracingAPI.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/*
|
||||
* Class that just handles the JSObject storage and tracing for spidermonkey
|
||||
* interfaces
|
||||
*/
|
||||
struct SpiderMonkeyInterfaceObjectStorage
|
||||
{
|
||||
protected:
|
||||
JSObject* mImplObj;
|
||||
JSObject* mWrappedObj;
|
||||
|
||||
SpiderMonkeyInterfaceObjectStorage()
|
||||
: mImplObj(nullptr),
|
||||
mWrappedObj(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
SpiderMonkeyInterfaceObjectStorage(SpiderMonkeyInterfaceObjectStorage&& aOther)
|
||||
: mImplObj(aOther.mImplObj),
|
||||
mWrappedObj(aOther.mWrappedObj)
|
||||
{
|
||||
aOther.mImplObj = nullptr;
|
||||
aOther.mWrappedObj = nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
inline void TraceSelf(JSTracer* trc)
|
||||
{
|
||||
JS::UnsafeTraceRoot(trc, &mImplObj, "SpiderMonkeyInterfaceObjectStorage.mImplObj");
|
||||
JS::UnsafeTraceRoot(trc, &mWrappedObj, "SpiderMonkeyInterfaceObjectStorage.mWrappedObj");
|
||||
}
|
||||
|
||||
inline bool inited() const
|
||||
{
|
||||
return !!mImplObj;
|
||||
}
|
||||
|
||||
inline bool WrapIntoNewCompartment(JSContext* cx)
|
||||
{
|
||||
return JS_WrapObject(cx,
|
||||
JS::MutableHandle<JSObject*>::fromMarkedLocation(&mWrappedObj));
|
||||
}
|
||||
|
||||
inline JSObject *Obj() const
|
||||
{
|
||||
MOZ_ASSERT(inited());
|
||||
return mWrappedObj;
|
||||
}
|
||||
|
||||
private:
|
||||
SpiderMonkeyInterfaceObjectStorage(const SpiderMonkeyInterfaceObjectStorage&) = delete;
|
||||
};
|
||||
|
||||
// A class for rooting an existing SpiderMonkey Interface struct
|
||||
template<typename InterfaceType>
|
||||
class MOZ_RAII SpiderMonkeyInterfaceRooter : private JS::CustomAutoRooter
|
||||
{
|
||||
public:
|
||||
template <typename CX>
|
||||
SpiderMonkeyInterfaceRooter(const CX& cx,
|
||||
InterfaceType* aInterface MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
|
||||
mInterface(aInterface)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void trace(JSTracer* trc) override
|
||||
{
|
||||
mInterface->TraceSelf(trc);
|
||||
}
|
||||
|
||||
private:
|
||||
SpiderMonkeyInterfaceObjectStorage* const mInterface;
|
||||
};
|
||||
|
||||
// And a specialization for dealing with nullable SpiderMonkey interfaces
|
||||
template<typename Inner> struct Nullable;
|
||||
template<typename InterfaceType>
|
||||
class MOZ_RAII SpiderMonkeyInterfaceRooter<Nullable<InterfaceType>> :
|
||||
private JS::CustomAutoRooter
|
||||
{
|
||||
public:
|
||||
template <typename CX>
|
||||
SpiderMonkeyInterfaceRooter(const CX& cx,
|
||||
Nullable<InterfaceType>* aInterface MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
|
||||
mInterface(aInterface)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void trace(JSTracer* trc) override
|
||||
{
|
||||
if (!mInterface->IsNull()) {
|
||||
mInterface->Value().TraceSelf(trc);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Nullable<InterfaceType>* const mInterface;
|
||||
};
|
||||
|
||||
// Class for easily setting up a rooted SpiderMonkey interface object on the
|
||||
// stack
|
||||
template<typename InterfaceType>
|
||||
class MOZ_RAII RootedSpiderMonkeyInterface final : public InterfaceType,
|
||||
private SpiderMonkeyInterfaceRooter<InterfaceType>
|
||||
{
|
||||
public:
|
||||
template <typename CX>
|
||||
explicit RootedSpiderMonkeyInterface(const CX& cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: InterfaceType(),
|
||||
SpiderMonkeyInterfaceRooter<InterfaceType>(cx, this
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename CX>
|
||||
RootedSpiderMonkeyInterface(const CX& cx, JSObject* obj MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: InterfaceType(obj),
|
||||
SpiderMonkeyInterfaceRooter<InterfaceType>(cx, this
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* mozilla_dom_SpiderMonkeyInterface_h */
|
||||
+23
-23
@@ -24,7 +24,7 @@ class Promise;
|
||||
// JSContext.
|
||||
|
||||
// Accept strings.
|
||||
MOZ_MUST_USE bool
|
||||
[[nodiscard]] bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
const nsAString& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue);
|
||||
@@ -35,7 +35,7 @@ ToJSValue(JSContext* aCx,
|
||||
// desirable. So make this a template that only gets used if the argument type
|
||||
// is actually boolean
|
||||
template<typename T>
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
typename EnableIf<IsSame<T, bool>::value, bool>::Type
|
||||
ToJSValue(JSContext* aCx,
|
||||
T aArgument,
|
||||
@@ -123,7 +123,7 @@ ToJSValue(JSContext* aCx,
|
||||
}
|
||||
|
||||
// Accept CallbackObjects
|
||||
MOZ_MUST_USE inline bool
|
||||
[[nodiscard]] inline bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
CallbackObject& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
@@ -139,7 +139,7 @@ ToJSValue(JSContext* aCx,
|
||||
// Accept objects that inherit from nsWrapperCache (e.g. most
|
||||
// DOM objects).
|
||||
template <class T>
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
typename EnableIf<IsBaseOf<nsWrapperCache, T>::value, bool>::Type
|
||||
ToJSValue(JSContext* aCx,
|
||||
T& aArgument,
|
||||
@@ -155,7 +155,7 @@ ToJSValue(JSContext* aCx,
|
||||
|
||||
// Accept typed arrays built from appropriate nsTArray values
|
||||
template<typename T>
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
typename EnableIf<IsBaseOf<AllTypedArraysBase, T>::value, bool>::Type
|
||||
ToJSValue(JSContext* aCx,
|
||||
const TypedArrayCreator<T>& aArgument,
|
||||
@@ -175,7 +175,7 @@ ToJSValue(JSContext* aCx,
|
||||
// Accept objects that inherit from nsISupports but not nsWrapperCache (e.g.
|
||||
// DOM File).
|
||||
template <class T>
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
typename EnableIf<!IsBaseOf<nsWrapperCache, T>::value &&
|
||||
!IsBaseOf<CallbackObject, T>::value &&
|
||||
IsBaseOf<nsISupports, T>::value, bool>::Type
|
||||
@@ -193,7 +193,7 @@ ToJSValue(JSContext* aCx,
|
||||
|
||||
// Accept nsRefPtr/nsCOMPtr
|
||||
template <typename T>
|
||||
MOZ_MUST_USE bool
|
||||
[[nodiscard]] bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
const nsCOMPtr<T>& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
@@ -202,7 +202,7 @@ ToJSValue(JSContext* aCx,
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MOZ_MUST_USE bool
|
||||
[[nodiscard]] bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
const RefPtr<T>& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
@@ -211,7 +211,7 @@ ToJSValue(JSContext* aCx,
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MOZ_MUST_USE bool
|
||||
[[nodiscard]] bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
const NonNull<T>& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
@@ -221,7 +221,7 @@ ToJSValue(JSContext* aCx,
|
||||
|
||||
// Accept WebIDL dictionaries
|
||||
template <class T>
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
typename EnableIf<IsBaseOf<DictionaryBase, T>::value, bool>::Type
|
||||
ToJSValue(JSContext* aCx,
|
||||
const T& aArgument,
|
||||
@@ -231,7 +231,7 @@ ToJSValue(JSContext* aCx,
|
||||
}
|
||||
|
||||
// Accept existing JS values (which may not be same-compartment with us
|
||||
MOZ_MUST_USE inline bool
|
||||
[[nodiscard]] inline bool
|
||||
ToJSValue(JSContext* aCx, JS::Handle<JS::Value> aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
{
|
||||
@@ -240,7 +240,7 @@ ToJSValue(JSContext* aCx, JS::Handle<JS::Value> aArgument,
|
||||
}
|
||||
|
||||
// Accept existing JS values on the Heap (which may not be same-compartment with us
|
||||
MOZ_MUST_USE inline bool
|
||||
[[nodiscard]] inline bool
|
||||
ToJSValue(JSContext* aCx, const JS::Heap<JS::Value>& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
{
|
||||
@@ -249,7 +249,7 @@ ToJSValue(JSContext* aCx, const JS::Heap<JS::Value>& aArgument,
|
||||
}
|
||||
|
||||
// Accept existing rooted JS values (which may not be same-compartment with us
|
||||
MOZ_MUST_USE inline bool
|
||||
[[nodiscard]] inline bool
|
||||
ToJSValue(JSContext* aCx, const JS::Rooted<JS::Value>& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
{
|
||||
@@ -259,7 +259,7 @@ ToJSValue(JSContext* aCx, const JS::Rooted<JS::Value>& aArgument,
|
||||
|
||||
// Accept existing rooted JS objects (which may not be same-compartment with
|
||||
// us).
|
||||
MOZ_MUST_USE inline bool
|
||||
[[nodiscard]] inline bool
|
||||
ToJSValue(JSContext* aCx, const JS::Rooted<JSObject*>& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
{
|
||||
@@ -269,7 +269,7 @@ ToJSValue(JSContext* aCx, const JS::Rooted<JSObject*>& aArgument,
|
||||
|
||||
// Accept nsresult, for use in rejections, and create an XPCOM
|
||||
// exception object representing that nsresult.
|
||||
MOZ_MUST_USE bool
|
||||
[[nodiscard]] bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
nsresult aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue);
|
||||
@@ -277,14 +277,14 @@ ToJSValue(JSContext* aCx,
|
||||
// Accept ErrorResult, for use in rejections, and create an exception
|
||||
// representing the failure. Note, the ErrorResult must indicate a failure
|
||||
// with aArgument.Failure() returning true.
|
||||
MOZ_MUST_USE bool
|
||||
[[nodiscard]] bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
ErrorResult& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue);
|
||||
|
||||
// Accept owning WebIDL unions.
|
||||
template <typename T>
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
typename EnableIf<IsBaseOf<AllOwningUnionBase, T>::value, bool>::Type
|
||||
ToJSValue(JSContext* aCx,
|
||||
const T& aArgument,
|
||||
@@ -296,7 +296,7 @@ ToJSValue(JSContext* aCx,
|
||||
|
||||
// Accept pointers to other things we accept
|
||||
template <typename T>
|
||||
MOZ_MUST_USE
|
||||
[[nodiscard]]
|
||||
typename EnableIf<IsPointer<T>::value, bool>::Type
|
||||
ToJSValue(JSContext* aCx,
|
||||
T aArgument,
|
||||
@@ -306,14 +306,14 @@ ToJSValue(JSContext* aCx,
|
||||
}
|
||||
|
||||
// Accept Promise objects, which need special handling.
|
||||
MOZ_MUST_USE bool
|
||||
[[nodiscard]] bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
Promise& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue);
|
||||
|
||||
// Accept arrays of other things we accept
|
||||
template <typename T>
|
||||
MOZ_MUST_USE bool
|
||||
[[nodiscard]] bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
T* aArguments,
|
||||
size_t aLength,
|
||||
@@ -340,7 +340,7 @@ ToJSValue(JSContext* aCx,
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MOZ_MUST_USE bool
|
||||
[[nodiscard]] bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
const nsTArray<T>& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
@@ -350,7 +350,7 @@ ToJSValue(JSContext* aCx,
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MOZ_MUST_USE bool
|
||||
[[nodiscard]] bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
const FallibleTArray<T>& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
@@ -360,7 +360,7 @@ ToJSValue(JSContext* aCx,
|
||||
}
|
||||
|
||||
template <typename T, int N>
|
||||
MOZ_MUST_USE bool
|
||||
[[nodiscard]] bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
const T(&aArgument)[N],
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
|
||||
+7
-127
@@ -6,51 +6,15 @@
|
||||
#ifndef mozilla_dom_TypedArray_h
|
||||
#define mozilla_dom_TypedArray_h
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/RootingAPI.h"
|
||||
#include "js/TracingAPI.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Move.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/SpiderMonkeyInterface.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/*
|
||||
* Class that just handles the JSObject storage and tracing for typed arrays
|
||||
*/
|
||||
struct TypedArrayObjectStorage : AllTypedArraysBase {
|
||||
protected:
|
||||
JSObject* mTypedObj;
|
||||
JSObject* mWrappedObj;
|
||||
|
||||
TypedArrayObjectStorage()
|
||||
: mTypedObj(nullptr),
|
||||
mWrappedObj(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
TypedArrayObjectStorage(TypedArrayObjectStorage&& aOther)
|
||||
: mTypedObj(aOther.mTypedObj),
|
||||
mWrappedObj(aOther.mWrappedObj)
|
||||
{
|
||||
aOther.mTypedObj = nullptr;
|
||||
aOther.mWrappedObj = nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
inline void TraceSelf(JSTracer* trc)
|
||||
{
|
||||
JS::UnsafeTraceRoot(trc, &mTypedObj, "TypedArray.mTypedObj");
|
||||
JS::UnsafeTraceRoot(trc, &mWrappedObj, "TypedArray.mWrappedObj");
|
||||
}
|
||||
|
||||
private:
|
||||
TypedArrayObjectStorage(const TypedArrayObjectStorage&) = delete;
|
||||
};
|
||||
|
||||
/*
|
||||
* Various typed array classes for argument conversion. We have a base class
|
||||
* that has a way of initializing a TypedArray from an existing typed array, and
|
||||
@@ -60,7 +24,9 @@ private:
|
||||
template<typename T,
|
||||
JSObject* UnwrapArray(JSObject*),
|
||||
void GetLengthAndDataAndSharedness(JSObject*, uint32_t*, bool*, T**)>
|
||||
struct TypedArray_base : public TypedArrayObjectStorage {
|
||||
struct TypedArray_base : public SpiderMonkeyInterfaceObjectStorage,
|
||||
AllTypedArraysBase
|
||||
{
|
||||
typedef T element_type;
|
||||
|
||||
TypedArray_base()
|
||||
@@ -72,7 +38,7 @@ struct TypedArray_base : public TypedArrayObjectStorage {
|
||||
}
|
||||
|
||||
TypedArray_base(TypedArray_base&& aOther)
|
||||
: TypedArrayObjectStorage(Move(aOther)),
|
||||
: SpiderMonkeyInterfaceObjectStorage(Move(aOther)),
|
||||
mData(aOther.mData),
|
||||
mLength(aOther.mLength),
|
||||
mShared(aOther.mShared),
|
||||
@@ -94,14 +60,10 @@ public:
|
||||
inline bool Init(JSObject* obj)
|
||||
{
|
||||
MOZ_ASSERT(!inited());
|
||||
mTypedObj = mWrappedObj = UnwrapArray(obj);
|
||||
mImplObj = mWrappedObj = UnwrapArray(obj);
|
||||
return inited();
|
||||
}
|
||||
|
||||
inline bool inited() const {
|
||||
return !!mTypedObj;
|
||||
}
|
||||
|
||||
// About shared memory:
|
||||
//
|
||||
// Any DOM TypedArray as well as any DOM ArrayBufferView that does
|
||||
@@ -173,22 +135,11 @@ public:
|
||||
return mLength;
|
||||
}
|
||||
|
||||
inline JSObject *Obj() const {
|
||||
MOZ_ASSERT(inited());
|
||||
return mWrappedObj;
|
||||
}
|
||||
|
||||
inline bool WrapIntoNewCompartment(JSContext* cx)
|
||||
{
|
||||
return JS_WrapObject(cx,
|
||||
JS::MutableHandle<JSObject*>::fromMarkedLocation(&mWrappedObj));
|
||||
}
|
||||
|
||||
inline void ComputeLengthAndData() const
|
||||
{
|
||||
MOZ_ASSERT(inited());
|
||||
MOZ_ASSERT(!mComputed);
|
||||
GetLengthAndDataAndSharedness(mTypedObj, &mLength, &mShared, &mData);
|
||||
GetLengthAndDataAndSharedness(mImplObj, &mLength, &mShared, &mData);
|
||||
mComputed = true;
|
||||
}
|
||||
|
||||
@@ -363,77 +314,6 @@ class TypedArrayCreator
|
||||
const ArrayType& mArray;
|
||||
};
|
||||
|
||||
// A class for rooting an existing TypedArray struct
|
||||
template<typename ArrayType>
|
||||
class MOZ_RAII TypedArrayRooter : private JS::CustomAutoRooter
|
||||
{
|
||||
public:
|
||||
template <typename CX>
|
||||
TypedArrayRooter(const CX& cx,
|
||||
ArrayType* aArray MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
|
||||
mArray(aArray)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void trace(JSTracer* trc) override
|
||||
{
|
||||
mArray->TraceSelf(trc);
|
||||
}
|
||||
|
||||
private:
|
||||
TypedArrayObjectStorage* const mArray;
|
||||
};
|
||||
|
||||
// And a specialization for dealing with nullable typed arrays
|
||||
template<typename Inner> struct Nullable;
|
||||
template<typename ArrayType>
|
||||
class MOZ_RAII TypedArrayRooter<Nullable<ArrayType> > :
|
||||
private JS::CustomAutoRooter
|
||||
{
|
||||
public:
|
||||
template <typename CX>
|
||||
TypedArrayRooter(const CX& cx,
|
||||
Nullable<ArrayType>* aArray MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
JS::CustomAutoRooter(cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT),
|
||||
mArray(aArray)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void trace(JSTracer* trc) override
|
||||
{
|
||||
if (!mArray->IsNull()) {
|
||||
mArray->Value().TraceSelf(trc);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Nullable<ArrayType>* const mArray;
|
||||
};
|
||||
|
||||
// Class for easily setting up a rooted typed array object on the stack
|
||||
template<typename ArrayType>
|
||||
class MOZ_RAII RootedTypedArray final : public ArrayType,
|
||||
private TypedArrayRooter<ArrayType>
|
||||
{
|
||||
public:
|
||||
template <typename CX>
|
||||
explicit RootedTypedArray(const CX& cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
ArrayType(),
|
||||
TypedArrayRooter<ArrayType>(cx, this
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename CX>
|
||||
RootedTypedArray(const CX& cx, JSObject* obj MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
ArrayType(obj),
|
||||
TypedArrayRooter<ArrayType>(cx, this
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
||||
@@ -38,9 +38,11 @@ EXPORTS.mozilla.dom += [
|
||||
'NonRefcountedDOMObject.h',
|
||||
'Nullable.h',
|
||||
'PrimitiveConversions.h',
|
||||
'ReadableStream.h',
|
||||
'Record.h',
|
||||
'RootedDictionary.h',
|
||||
'SimpleGlobalObject.h',
|
||||
'SpiderMonkeyInterface.h',
|
||||
'StructuredClone.h',
|
||||
'ToJSValue.h',
|
||||
'TypedArray.h',
|
||||
|
||||
@@ -2054,6 +2054,9 @@ class IDLType(IDLObject):
|
||||
def isRecord(self):
|
||||
return False
|
||||
|
||||
def isReadableStream(self):
|
||||
return False
|
||||
|
||||
def isArrayBuffer(self):
|
||||
return False
|
||||
|
||||
@@ -2081,12 +2084,12 @@ class IDLType(IDLObject):
|
||||
|
||||
def isSpiderMonkeyInterface(self):
|
||||
""" Returns a boolean indicating whether this type is an 'interface'
|
||||
type that is implemented in Spidermonkey. At the moment, this
|
||||
only returns true for the types from the TypedArray spec. """
|
||||
type that is implemented in SpiderMonkey. """
|
||||
return self.isInterface() and (self.isArrayBuffer() or
|
||||
self.isArrayBufferView() or
|
||||
self.isSharedArrayBuffer() or
|
||||
self.isTypedArray())
|
||||
self.isTypedArray() or
|
||||
self.isReadableStream())
|
||||
|
||||
def isDictionary(self):
|
||||
return False
|
||||
@@ -2275,6 +2278,9 @@ class IDLNullableType(IDLParameterizedType):
|
||||
def isRecord(self):
|
||||
return self.inner.isRecord()
|
||||
|
||||
def isReadableStream(self):
|
||||
return self.inner.isReadableStream()
|
||||
|
||||
def isArrayBuffer(self):
|
||||
return self.inner.isArrayBuffer()
|
||||
|
||||
@@ -2634,6 +2640,9 @@ class IDLTypedefType(IDLType):
|
||||
def isRecord(self):
|
||||
return self.inner.isRecord()
|
||||
|
||||
def isReadableStream(self):
|
||||
return self.inner.isReadableStream()
|
||||
|
||||
def isDictionary(self):
|
||||
return self.inner.isDictionary()
|
||||
|
||||
@@ -2945,7 +2954,8 @@ class IDLBuiltinType(IDLType):
|
||||
'Int32Array',
|
||||
'Uint32Array',
|
||||
'Float32Array',
|
||||
'Float64Array'
|
||||
'Float64Array',
|
||||
'ReadableStream',
|
||||
)
|
||||
|
||||
TagLookup = {
|
||||
@@ -2980,7 +2990,8 @@ class IDLBuiltinType(IDLType):
|
||||
Types.Int32Array: IDLType.Tags.interface,
|
||||
Types.Uint32Array: IDLType.Tags.interface,
|
||||
Types.Float32Array: IDLType.Tags.interface,
|
||||
Types.Float64Array: IDLType.Tags.interface
|
||||
Types.Float64Array: IDLType.Tags.interface,
|
||||
Types.ReadableStream: IDLType.Tags.interface,
|
||||
}
|
||||
|
||||
def __init__(self, location, name, type):
|
||||
@@ -3027,6 +3038,9 @@ class IDLBuiltinType(IDLType):
|
||||
return (self._typeTag >= IDLBuiltinType.Types.Int8Array and
|
||||
self._typeTag <= IDLBuiltinType.Types.Float64Array)
|
||||
|
||||
def isReadableStream(self):
|
||||
return self._typeTag == IDLBuiltinType.Types.ReadableStream
|
||||
|
||||
def isInterface(self):
|
||||
# TypedArray things are interface types per the TypedArray spec,
|
||||
# but we handle them as builtins because SpiderMonkey implements
|
||||
@@ -3034,7 +3048,8 @@ class IDLBuiltinType(IDLType):
|
||||
return (self.isArrayBuffer() or
|
||||
self.isArrayBufferView() or
|
||||
self.isSharedArrayBuffer() or
|
||||
self.isTypedArray())
|
||||
self.isTypedArray() or
|
||||
self.isReadableStream())
|
||||
|
||||
def isNonCallbackInterface(self):
|
||||
# All the interfaces we can be are non-callback
|
||||
@@ -3104,6 +3119,7 @@ class IDLBuiltinType(IDLType):
|
||||
# that's not an ArrayBuffer or a callback interface
|
||||
(self.isArrayBuffer() and not other.isArrayBuffer()) or
|
||||
(self.isSharedArrayBuffer() and not other.isSharedArrayBuffer()) or
|
||||
(self.isReadableStream() and not other.isReadableStream()) or
|
||||
# ArrayBufferView is distinguishable from everything
|
||||
# that's not an ArrayBufferView or typed array.
|
||||
(self.isArrayBufferView() and not other.isArrayBufferView() and
|
||||
@@ -3213,7 +3229,10 @@ BuiltinTypes = {
|
||||
IDLBuiltinType.Types.Float32Array),
|
||||
IDLBuiltinType.Types.Float64Array:
|
||||
IDLBuiltinType(BuiltinLocation("<builtin type>"), "Float64Array",
|
||||
IDLBuiltinType.Types.Float64Array)
|
||||
IDLBuiltinType.Types.Float64Array),
|
||||
IDLBuiltinType.Types.ReadableStream:
|
||||
IDLBuiltinType(BuiltinLocation("<builtin type>"), "ReadableStream",
|
||||
IDLBuiltinType.Types.ReadableStream),
|
||||
}
|
||||
|
||||
|
||||
@@ -5232,7 +5251,8 @@ class Tokenizer(object):
|
||||
"maplike": "MAPLIKE",
|
||||
"setlike": "SETLIKE",
|
||||
"iterable": "ITERABLE",
|
||||
"namespace": "NAMESPACE"
|
||||
"namespace": "NAMESPACE",
|
||||
"ReadableStream": "READABLESTREAM",
|
||||
}
|
||||
|
||||
tokens.extend(keywords.values())
|
||||
@@ -6420,6 +6440,7 @@ class Parser(Tokenizer):
|
||||
NonAnyType : PrimitiveType Null
|
||||
| ARRAYBUFFER Null
|
||||
| SHAREDARRAYBUFFER Null
|
||||
| READABLESTREAM Null
|
||||
| OBJECT Null
|
||||
"""
|
||||
if p[1] == "object":
|
||||
@@ -6428,6 +6449,8 @@ class Parser(Tokenizer):
|
||||
type = BuiltinTypes[IDLBuiltinType.Types.ArrayBuffer]
|
||||
elif p[1] == "SharedArrayBuffer":
|
||||
type = BuiltinTypes[IDLBuiltinType.Types.SharedArrayBuffer]
|
||||
elif p[1] == "ReadableStream":
|
||||
type = BuiltinTypes[IDLBuiltinType.Types.ReadableStream]
|
||||
else:
|
||||
type = BuiltinTypes[p[1]]
|
||||
|
||||
|
||||
Vendored
+4
-4
@@ -289,9 +289,9 @@ MatchInPutList(InternalRequest* aRequest,
|
||||
} // namespace
|
||||
|
||||
void
|
||||
AutoChildOpArgs::Add(InternalRequest* aRequest, BodyAction aBodyAction,
|
||||
SchemeAction aSchemeAction, Response& aResponse,
|
||||
ErrorResult& aRv)
|
||||
AutoChildOpArgs::Add(JSContext* aCx, InternalRequest* aRequest,
|
||||
BodyAction aBodyAction, SchemeAction aSchemeAction,
|
||||
Response& aResponse, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(!mSent);
|
||||
|
||||
@@ -329,7 +329,7 @@ AutoChildOpArgs::Add(InternalRequest* aRequest, BodyAction aBodyAction,
|
||||
mTypeUtils->ToCacheRequest(pair.request(), aRequest, aBodyAction,
|
||||
aSchemeAction, mStreamCleanupList, aRv);
|
||||
if (!aRv.Failed()) {
|
||||
mTypeUtils->ToCacheResponse(pair.response(), aResponse,
|
||||
mTypeUtils->ToCacheResponse(aCx, pair.response(), aResponse,
|
||||
mStreamCleanupList, aRv);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
void Add(InternalRequest* aRequest, BodyAction aBodyAction,
|
||||
SchemeAction aSchemeAction, ErrorResult& aRv);
|
||||
void Add(InternalRequest* aRequest, BodyAction aBodyAction,
|
||||
void Add(JSContext* aCx, InternalRequest* aRequest, BodyAction aBodyAction,
|
||||
SchemeAction aSchemeAction, Response& aResponse, ErrorResult& aRv);
|
||||
|
||||
const CacheOpArgs& SendAsOpArgs();
|
||||
|
||||
Vendored
+23
-17
@@ -184,7 +184,10 @@ public:
|
||||
|
||||
// Now store the unwrapped Response list in the Cache.
|
||||
ErrorResult result;
|
||||
RefPtr<Promise> put = mCache->PutAll(mRequestList, responseList, result);
|
||||
// TODO: Here we use the JSContext as received by the ResolvedCallback, and
|
||||
// its state could be the wrong one. The spec doesn't say anything
|
||||
// about it, yet (bug 1384006)
|
||||
RefPtr<Promise> put = mCache->PutAll(aCx, mRequestList, responseList, result);
|
||||
if (NS_WARN_IF(result.Failed())) {
|
||||
// TODO: abort the fetch requests we have running (bug 1157434)
|
||||
mPromise->MaybeReject(result);
|
||||
@@ -245,7 +248,7 @@ Cache::Cache(nsIGlobalObject* aGlobal, CacheChild* aActor)
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
Cache::Match(const RequestOrUSVString& aRequest,
|
||||
Cache::Match(JSContext* aCx, const RequestOrUSVString& aRequest,
|
||||
const CacheQueryOptions& aOptions, ErrorResult& aRv)
|
||||
{
|
||||
if (NS_WARN_IF(!mActor)) {
|
||||
@@ -255,7 +258,8 @@ Cache::Match(const RequestOrUSVString& aRequest,
|
||||
|
||||
CacheChild::AutoLock actorLock(mActor);
|
||||
|
||||
RefPtr<InternalRequest> ir = ToInternalRequest(aRequest, IgnoreBody, aRv);
|
||||
RefPtr<InternalRequest> ir =
|
||||
ToInternalRequest(aCx, aRequest, IgnoreBody, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -274,7 +278,7 @@ Cache::Match(const RequestOrUSVString& aRequest,
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
Cache::MatchAll(const Optional<RequestOrUSVString>& aRequest,
|
||||
Cache::MatchAll(JSContext* aCx, const Optional<RequestOrUSVString>& aRequest,
|
||||
const CacheQueryOptions& aOptions, ErrorResult& aRv)
|
||||
{
|
||||
if (NS_WARN_IF(!mActor)) {
|
||||
@@ -290,8 +294,8 @@ Cache::MatchAll(const Optional<RequestOrUSVString>& aRequest,
|
||||
AutoChildOpArgs args(this, CacheMatchAllArgs(void_t(), params), 1);
|
||||
|
||||
if (aRequest.WasPassed()) {
|
||||
RefPtr<InternalRequest> ir = ToInternalRequest(aRequest.Value(),
|
||||
IgnoreBody, aRv);
|
||||
RefPtr<InternalRequest> ir = ToInternalRequest(aCx, aRequest.Value(),
|
||||
IgnoreBody, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -390,8 +394,8 @@ Cache::AddAll(JSContext* aContext,
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
Cache::Put(const RequestOrUSVString& aRequest, Response& aResponse,
|
||||
ErrorResult& aRv)
|
||||
Cache::Put(JSContext* aCx, const RequestOrUSVString& aRequest,
|
||||
Response& aResponse, ErrorResult& aRv)
|
||||
{
|
||||
if (NS_WARN_IF(!mActor)) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
@@ -404,14 +408,14 @@ Cache::Put(const RequestOrUSVString& aRequest, Response& aResponse,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<InternalRequest> ir = ToInternalRequest(aRequest, ReadBody, aRv);
|
||||
RefPtr<InternalRequest> ir = ToInternalRequest(aCx, aRequest, ReadBody, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AutoChildOpArgs args(this, CachePutAllArgs(), 1);
|
||||
|
||||
args.Add(ir, ReadBody, TypeErrorOnInvalidScheme,
|
||||
args.Add(aCx, ir, ReadBody, TypeErrorOnInvalidScheme,
|
||||
aResponse, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
@@ -421,7 +425,7 @@ Cache::Put(const RequestOrUSVString& aRequest, Response& aResponse,
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
Cache::Delete(const RequestOrUSVString& aRequest,
|
||||
Cache::Delete(JSContext* aCx, const RequestOrUSVString& aRequest,
|
||||
const CacheQueryOptions& aOptions, ErrorResult& aRv)
|
||||
{
|
||||
if (NS_WARN_IF(!mActor)) {
|
||||
@@ -431,7 +435,8 @@ Cache::Delete(const RequestOrUSVString& aRequest,
|
||||
|
||||
CacheChild::AutoLock actorLock(mActor);
|
||||
|
||||
RefPtr<InternalRequest> ir = ToInternalRequest(aRequest, IgnoreBody, aRv);
|
||||
RefPtr<InternalRequest> ir =
|
||||
ToInternalRequest(aCx, aRequest, IgnoreBody, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -450,7 +455,7 @@ Cache::Delete(const RequestOrUSVString& aRequest,
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
Cache::Keys(const Optional<RequestOrUSVString>& aRequest,
|
||||
Cache::Keys(JSContext* aCx, const Optional<RequestOrUSVString>& aRequest,
|
||||
const CacheQueryOptions& aOptions, ErrorResult& aRv)
|
||||
{
|
||||
if (NS_WARN_IF(!mActor)) {
|
||||
@@ -466,8 +471,8 @@ Cache::Keys(const Optional<RequestOrUSVString>& aRequest,
|
||||
AutoChildOpArgs args(this, CacheKeysArgs(void_t(), params), 1);
|
||||
|
||||
if (aRequest.WasPassed()) {
|
||||
RefPtr<InternalRequest> ir = ToInternalRequest(aRequest.Value(),
|
||||
IgnoreBody, aRv);
|
||||
RefPtr<InternalRequest> ir =
|
||||
ToInternalRequest(aCx, aRequest.Value(), IgnoreBody, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -627,7 +632,7 @@ Cache::AddAll(const GlobalObject& aGlobal,
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
Cache::PutAll(const nsTArray<RefPtr<Request>>& aRequestList,
|
||||
Cache::PutAll(JSContext* aCx, const nsTArray<RefPtr<Request>>& aRequestList,
|
||||
const nsTArray<RefPtr<Response>>& aResponseList,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
@@ -644,7 +649,8 @@ Cache::PutAll(const nsTArray<RefPtr<Request>>& aRequestList,
|
||||
|
||||
for (uint32_t i = 0; i < aRequestList.Length(); ++i) {
|
||||
RefPtr<InternalRequest> ir = aRequestList[i]->GetInternalRequest();
|
||||
args.Add(ir, ReadBody, TypeErrorOnInvalidScheme, *aResponseList[i], aRv);
|
||||
args.Add(aCx, ir, ReadBody, TypeErrorOnInvalidScheme, *aResponseList[i],
|
||||
aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Vendored
+8
-8
@@ -43,10 +43,10 @@ public:
|
||||
|
||||
// webidl interface methods
|
||||
already_AddRefed<Promise>
|
||||
Match(const RequestOrUSVString& aRequest, const CacheQueryOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
Match(JSContext* aCx, const RequestOrUSVString& aRequest,
|
||||
const CacheQueryOptions& aOptions, ErrorResult& aRv);
|
||||
already_AddRefed<Promise>
|
||||
MatchAll(const Optional<RequestOrUSVString>& aRequest,
|
||||
MatchAll(JSContext* aCx, const Optional<RequestOrUSVString>& aRequest,
|
||||
const CacheQueryOptions& aOptions, ErrorResult& aRv);
|
||||
already_AddRefed<Promise>
|
||||
Add(JSContext* aContext, const RequestOrUSVString& aRequest,
|
||||
@@ -55,13 +55,13 @@ public:
|
||||
AddAll(JSContext* aContext,
|
||||
const Sequence<OwningRequestOrUSVString>& aRequests, ErrorResult& aRv);
|
||||
already_AddRefed<Promise>
|
||||
Put(const RequestOrUSVString& aRequest, Response& aResponse,
|
||||
Put(JSContext* aCx, const RequestOrUSVString& aRequest, Response& aResponse,
|
||||
ErrorResult& aRv);
|
||||
already_AddRefed<Promise>
|
||||
Delete(const RequestOrUSVString& aRequest, const CacheQueryOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
Delete(JSContext* aCx, const RequestOrUSVString& aRequest,
|
||||
const CacheQueryOptions& aOptions, ErrorResult& aRv);
|
||||
already_AddRefed<Promise>
|
||||
Keys(const Optional<RequestOrUSVString>& aRequest,
|
||||
Keys(JSContext* aCx, const Optional<RequestOrUSVString>& aRequest,
|
||||
const CacheQueryOptions& aParams, ErrorResult& aRv);
|
||||
|
||||
// binding methods
|
||||
@@ -100,7 +100,7 @@ private:
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise>
|
||||
PutAll(const nsTArray<RefPtr<Request>>& aRequestList,
|
||||
PutAll(JSContext* aCx, const nsTArray<RefPtr<Request>>& aRequestList,
|
||||
const nsTArray<RefPtr<Response>>& aResponseList,
|
||||
ErrorResult& aRv);
|
||||
|
||||
|
||||
Vendored
+10
-2
@@ -74,7 +74,11 @@ CacheOpChild::CacheOpChild(CacheWorkerHolder* aWorkerHolder,
|
||||
MOZ_DIAGNOSTIC_ASSERT(mPromise);
|
||||
|
||||
MOZ_ASSERT_IF(!NS_IsMainThread(), aWorkerHolder);
|
||||
SetWorkerHolder(aWorkerHolder);
|
||||
RefPtr<CacheWorkerHolder> workerHolder =
|
||||
CacheWorkerHolder::PreferBehavior(aWorkerHolder,
|
||||
CacheWorkerHolder::PreventIdleShutdownStart);
|
||||
|
||||
SetWorkerHolder(workerHolder);
|
||||
}
|
||||
|
||||
CacheOpChild::~CacheOpChild()
|
||||
@@ -165,7 +169,11 @@ CacheOpChild::Recv__delete__(const ErrorResult& aRv,
|
||||
break;
|
||||
}
|
||||
|
||||
actor->SetWorkerHolder(GetWorkerHolder());
|
||||
RefPtr<CacheWorkerHolder> workerHolder =
|
||||
CacheWorkerHolder::PreferBehavior(GetWorkerHolder(),
|
||||
CacheWorkerHolder::AllowIdleShutdownStart);
|
||||
|
||||
actor->SetWorkerHolder(workerHolder);
|
||||
RefPtr<Cache> cache = new Cache(mGlobal, actor);
|
||||
mPromise->MaybeResolve(cache);
|
||||
break;
|
||||
|
||||
Vendored
+5
-4
@@ -204,7 +204,8 @@ CacheStorage::CreateOnWorker(Namespace aNamespace, nsIGlobalObject* aGlobal,
|
||||
}
|
||||
|
||||
RefPtr<CacheWorkerHolder> workerHolder =
|
||||
CacheWorkerHolder::Create(aWorkerPrivate);
|
||||
CacheWorkerHolder::Create(aWorkerPrivate,
|
||||
CacheWorkerHolder::AllowIdleShutdownStart);
|
||||
if (!workerHolder) {
|
||||
NS_WARNING("Worker thread is shutting down.");
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
@@ -315,7 +316,7 @@ CacheStorage::CacheStorage(nsresult aFailureResult)
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
CacheStorage::Match(const RequestOrUSVString& aRequest,
|
||||
CacheStorage::Match(JSContext* aCx, const RequestOrUSVString& aRequest,
|
||||
const CacheQueryOptions& aOptions, ErrorResult& aRv)
|
||||
{
|
||||
NS_ASSERT_OWNINGTHREAD(CacheStorage);
|
||||
@@ -325,8 +326,8 @@ CacheStorage::Match(const RequestOrUSVString& aRequest,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<InternalRequest> request = ToInternalRequest(aRequest, IgnoreBody,
|
||||
aRv);
|
||||
RefPtr<InternalRequest> request =
|
||||
ToInternalRequest(aCx, aRequest, IgnoreBody, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -59,9 +59,9 @@ public:
|
||||
DefineCaches(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
|
||||
|
||||
// webidl interface methods
|
||||
already_AddRefed<Promise> Match(const RequestOrUSVString& aRequest,
|
||||
const CacheQueryOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
already_AddRefed<Promise>
|
||||
Match(JSContext* aCx, const RequestOrUSVString& aRequest,
|
||||
const CacheQueryOptions& aOptions, ErrorResult& aRv);
|
||||
already_AddRefed<Promise> Has(const nsAString& aKey, ErrorResult& aRv);
|
||||
already_AddRefed<Promise> Open(const nsAString& aKey, ErrorResult& aRv);
|
||||
already_AddRefed<Promise> Delete(const nsAString& aKey, ErrorResult& aRv);
|
||||
|
||||
Vendored
+27
-4
@@ -18,11 +18,11 @@ using mozilla::dom::workers::WorkerPrivate;
|
||||
|
||||
// static
|
||||
already_AddRefed<CacheWorkerHolder>
|
||||
CacheWorkerHolder::Create(WorkerPrivate* aWorkerPrivate)
|
||||
CacheWorkerHolder::Create(WorkerPrivate* aWorkerPrivate, Behavior aBehavior)
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(aWorkerPrivate);
|
||||
|
||||
RefPtr<CacheWorkerHolder> workerHolder = new CacheWorkerHolder();
|
||||
RefPtr<CacheWorkerHolder> workerHolder = new CacheWorkerHolder(aBehavior);
|
||||
if (NS_WARN_IF(!workerHolder->HoldWorker(aWorkerPrivate, Terminating))) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -30,6 +30,28 @@ CacheWorkerHolder::Create(WorkerPrivate* aWorkerPrivate)
|
||||
return workerHolder.forget();
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<CacheWorkerHolder>
|
||||
CacheWorkerHolder::PreferBehavior(CacheWorkerHolder* aCurrentHolder,
|
||||
Behavior aBehavior)
|
||||
{
|
||||
if (!aCurrentHolder) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<CacheWorkerHolder> orig = aCurrentHolder;
|
||||
if (orig->GetBehavior() == aBehavior) {
|
||||
return orig.forget();
|
||||
}
|
||||
|
||||
RefPtr<CacheWorkerHolder> replace = Create(orig->mWorkerPrivate, aBehavior);
|
||||
if (!replace) {
|
||||
return orig.forget();
|
||||
}
|
||||
|
||||
return replace.forget();
|
||||
}
|
||||
|
||||
void
|
||||
CacheWorkerHolder::AddActor(ActorChild* aActor)
|
||||
{
|
||||
@@ -88,8 +110,9 @@ CacheWorkerHolder::Notify(Status aStatus)
|
||||
return true;
|
||||
}
|
||||
|
||||
CacheWorkerHolder::CacheWorkerHolder()
|
||||
: mNotified(false)
|
||||
CacheWorkerHolder::CacheWorkerHolder(Behavior aBehavior)
|
||||
: WorkerHolder(aBehavior)
|
||||
, mNotified(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Vendored
+6
-2
@@ -25,7 +25,11 @@ class CacheWorkerHolder final : public workers::WorkerHolder
|
||||
{
|
||||
public:
|
||||
static already_AddRefed<CacheWorkerHolder>
|
||||
Create(workers::WorkerPrivate* aWorkerPrivate);
|
||||
Create(workers::WorkerPrivate* aWorkerPrivate,
|
||||
Behavior aBehavior);
|
||||
|
||||
static already_AddRefed<CacheWorkerHolder>
|
||||
PreferBehavior(CacheWorkerHolder* aCurrentHolder, Behavior aBehavior);
|
||||
|
||||
void AddActor(ActorChild* aActor);
|
||||
void RemoveActor(ActorChild* aActor);
|
||||
@@ -36,7 +40,7 @@ public:
|
||||
virtual bool Notify(workers::Status aStatus) override;
|
||||
|
||||
private:
|
||||
CacheWorkerHolder();
|
||||
explicit CacheWorkerHolder(Behavior aBehavior);
|
||||
~CacheWorkerHolder();
|
||||
|
||||
nsTArray<ActorChild*> mActorList;
|
||||
|
||||
Vendored
+17
-10
@@ -79,7 +79,7 @@ ToHeadersEntryList(nsTArray<HeadersEntry>& aOut, InternalHeaders* aHeaders)
|
||||
} // namespace
|
||||
|
||||
already_AddRefed<InternalRequest>
|
||||
TypeUtils::ToInternalRequest(const RequestOrUSVString& aIn,
|
||||
TypeUtils::ToInternalRequest(JSContext* aCx, const RequestOrUSVString& aIn,
|
||||
BodyAction aBodyAction, ErrorResult& aRv)
|
||||
{
|
||||
if (aIn.IsRequest()) {
|
||||
@@ -87,7 +87,7 @@ TypeUtils::ToInternalRequest(const RequestOrUSVString& aIn,
|
||||
|
||||
// Check and set bodyUsed flag immediately because its on Request
|
||||
// instead of InternalRequest.
|
||||
CheckAndSetBodyUsed(&request, aBodyAction, aRv);
|
||||
CheckAndSetBodyUsed(aCx, &request, aBodyAction, aRv);
|
||||
if (aRv.Failed()) { return nullptr; }
|
||||
|
||||
return request.GetInternalRequest();
|
||||
@@ -97,7 +97,8 @@ TypeUtils::ToInternalRequest(const RequestOrUSVString& aIn,
|
||||
}
|
||||
|
||||
already_AddRefed<InternalRequest>
|
||||
TypeUtils::ToInternalRequest(const OwningRequestOrUSVString& aIn,
|
||||
TypeUtils::ToInternalRequest(JSContext* aCx,
|
||||
const OwningRequestOrUSVString& aIn,
|
||||
BodyAction aBodyAction, ErrorResult& aRv)
|
||||
{
|
||||
|
||||
@@ -106,7 +107,7 @@ TypeUtils::ToInternalRequest(const OwningRequestOrUSVString& aIn,
|
||||
|
||||
// Check and set bodyUsed flag immediately because its on Request
|
||||
// instead of InternalRequest.
|
||||
CheckAndSetBodyUsed(request, aBodyAction, aRv);
|
||||
CheckAndSetBodyUsed(aCx, request, aBodyAction, aRv);
|
||||
if (aRv.Failed()) { return nullptr; }
|
||||
|
||||
return request->GetInternalRequest();
|
||||
@@ -189,7 +190,7 @@ TypeUtils::ToCacheResponseWithoutBody(CacheResponse& aOut,
|
||||
aOut.statusText() = aIn.GetUnfilteredStatusText();
|
||||
RefPtr<InternalHeaders> headers = aIn.UnfilteredHeaders();
|
||||
MOZ_DIAGNOSTIC_ASSERT(headers);
|
||||
if (HasVaryStar(headers)) {
|
||||
if (aIn.Type() != ResponseType::Opaque && HasVaryStar(headers)) {
|
||||
aRv.ThrowTypeError<MSG_RESPONSE_HAS_VARY_STAR>();
|
||||
return;
|
||||
}
|
||||
@@ -204,7 +205,7 @@ TypeUtils::ToCacheResponseWithoutBody(CacheResponse& aOut,
|
||||
}
|
||||
|
||||
void
|
||||
TypeUtils::ToCacheResponse(CacheResponse& aOut, Response& aIn,
|
||||
TypeUtils::ToCacheResponse(JSContext* aCx, CacheResponse& aOut, Response& aIn,
|
||||
nsTArray<UniquePtr<AutoIPCStream>>& aStreamCleanupList,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
@@ -222,7 +223,10 @@ TypeUtils::ToCacheResponse(CacheResponse& aOut, Response& aIn,
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
ir->GetUnfilteredBody(getter_AddRefs(stream));
|
||||
if (stream) {
|
||||
aIn.SetBodyUsed();
|
||||
aIn.SetBodyUsed(aCx, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SerializeCacheStream(stream, &aOut.body(), aStreamCleanupList, aRv);
|
||||
@@ -426,8 +430,8 @@ TypeUtils::ProcessURL(nsACString& aUrl, bool* aSchemeValidOut,
|
||||
}
|
||||
|
||||
void
|
||||
TypeUtils::CheckAndSetBodyUsed(Request* aRequest, BodyAction aBodyAction,
|
||||
ErrorResult& aRv)
|
||||
TypeUtils::CheckAndSetBodyUsed(JSContext* aCx, Request* aRequest,
|
||||
BodyAction aBodyAction, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(aRequest);
|
||||
|
||||
@@ -443,7 +447,10 @@ TypeUtils::CheckAndSetBodyUsed(Request* aRequest, BodyAction aBodyAction,
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
aRequest->GetBody(getter_AddRefs(stream));
|
||||
if (stream) {
|
||||
aRequest->SetBodyUsed();
|
||||
aRequest->SetBodyUsed(aCx, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+6
-6
@@ -73,12 +73,12 @@ public:
|
||||
GetIPCManager() = 0;
|
||||
|
||||
already_AddRefed<InternalRequest>
|
||||
ToInternalRequest(const RequestOrUSVString& aIn, BodyAction aBodyAction,
|
||||
ErrorResult& aRv);
|
||||
ToInternalRequest(JSContext* aCx, const RequestOrUSVString& aIn,
|
||||
BodyAction aBodyAction, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<InternalRequest>
|
||||
ToInternalRequest(const OwningRequestOrUSVString& aIn, BodyAction aBodyAction,
|
||||
ErrorResult& aRv);
|
||||
ToInternalRequest(JSContext* aCx, const OwningRequestOrUSVString& aIn,
|
||||
BodyAction aBodyAction, ErrorResult& aRv);
|
||||
|
||||
void
|
||||
ToCacheRequest(CacheRequest& aOut, InternalRequest* aIn,
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
ErrorResult& aRv);
|
||||
|
||||
void
|
||||
ToCacheResponse(CacheResponse& aOut, Response& aIn,
|
||||
ToCacheResponse(JSContext* aCx, CacheResponse& aOut, Response& aIn,
|
||||
nsTArray<UniquePtr<mozilla::ipc::AutoIPCStream>>& aStreamCleanupList,
|
||||
ErrorResult& aRv);
|
||||
|
||||
@@ -133,7 +133,7 @@ public:
|
||||
|
||||
private:
|
||||
void
|
||||
CheckAndSetBodyUsed(Request* aRequest, BodyAction aBodyAction,
|
||||
CheckAndSetBodyUsed(JSContext* aCx, Request* aRequest, BodyAction aBodyAction,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<InternalRequest>
|
||||
|
||||
@@ -2974,8 +2974,8 @@ ValidateRect(double& aX, double& aY, double& aWidth, double& aHeight, bool aIsZe
|
||||
// The values of canvas API input are in double precision, but Moz2D APIs are
|
||||
// using float precision. Bypass canvas API calls when the input is out of
|
||||
// float precision to avoid precision problem
|
||||
if (!std::isfinite((float)aX) | !std::isfinite((float)aY) |
|
||||
!std::isfinite((float)aWidth) | !std::isfinite((float)aHeight)) {
|
||||
if (!std::isfinite((float)aX) || !std::isfinite((float)aY) ||
|
||||
!std::isfinite((float)aWidth) || !std::isfinite((float)aHeight)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -5012,13 +5012,6 @@ CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage,
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef MOZ_EME
|
||||
if (video->ContainsRestrictedContent()) {
|
||||
aError.Throw(NS_ERROR_NOT_AVAILABLE);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t readyState;
|
||||
if (NS_SUCCEEDED(video->GetReadyState(&readyState)) &&
|
||||
readyState < nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA) {
|
||||
@@ -5959,7 +5952,7 @@ void
|
||||
CanvasRenderingContext2D::PutImageData(ImageData& aImageData, double aDx,
|
||||
double aDy, ErrorResult& aError)
|
||||
{
|
||||
RootedTypedArray<Uint8ClampedArray> arr(RootingCx());
|
||||
RootedSpiderMonkeyInterface<Uint8ClampedArray> arr(RootingCx());
|
||||
DebugOnly<bool> inited = arr.Init(aImageData.GetDataObject());
|
||||
MOZ_ASSERT(inited);
|
||||
|
||||
@@ -5975,7 +5968,7 @@ CanvasRenderingContext2D::PutImageData(ImageData& aImageData, double aDx,
|
||||
double aDirtyHeight,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
RootedTypedArray<Uint8ClampedArray> arr(RootingCx());
|
||||
RootedSpiderMonkeyInterface<Uint8ClampedArray> arr(RootingCx());
|
||||
DebugOnly<bool> inited = arr.Init(aImageData.GetDataObject());
|
||||
MOZ_ASSERT(inited);
|
||||
|
||||
|
||||
@@ -929,7 +929,7 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, ImageData& aImageData,
|
||||
const Maybe<IntRect>& aCropRect, ErrorResult& aRv)
|
||||
{
|
||||
// Copy data into SourceSurface.
|
||||
RootedTypedArray<Uint8ClampedArray> array(RootingCx());
|
||||
RootedSpiderMonkeyInterface<Uint8ClampedArray> array(RootingCx());
|
||||
DebugOnly<bool> inited = array.Init(aImageData.GetDataObject());
|
||||
MOZ_ASSERT(inited);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "gfxPrefs.h"
|
||||
#include "GLContextTypes.h"
|
||||
#include "GLDefs.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
@@ -1397,6 +1398,7 @@ protected:
|
||||
CheckedUint32 mGeneration;
|
||||
|
||||
WebGLContextOptions mOptions;
|
||||
const uint32_t mMaxVertIdsPerDraw = gfxPrefs::WebglMaxVertIDsPerDraw();
|
||||
|
||||
bool mInvalidated;
|
||||
bool mCapturedFrameInvalidated;
|
||||
|
||||
Loaded 100 of 3005 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user