From dc0961cbf0934cf07f09658aed8f59fd0adb5c59 Mon Sep 17 00:00:00 2001 From: Evan Tseng Date: Thu, 15 Dec 2016 12:03:53 +0800 Subject: [PATCH 01/64] No bug - Update readability from github repo, includes fix for Bug 1142312 and Bug 1285543, r=Gijs MozReview-Commit-ID: 5hi1iuDO3XE --HG-- extra : rebase_source : 724cd2af8b9ce4a6620e367665784636c223db6a --- toolkit/components/reader/Readability.js | 44 ++++++++++++++++-------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/toolkit/components/reader/Readability.js b/toolkit/components/reader/Readability.js index 99ae6f874f83..4705d8dc42a8 100644 --- a/toolkit/components/reader/Readability.js +++ b/toolkit/components/reader/Readability.js @@ -119,7 +119,7 @@ Readability.prototype = { // All of the regular expressions in use within readability. // Defined up here so we don't instantiate them repeatedly in loops. REGEXPS: { - unlikelyCandidates: /banner|combx|comment|community|disqus|extra|foot|header|legends|menu|modal|related|remark|rss|shoutbox|sidebar|skyscraper|sponsor|ad-break|agegate|pagination|pager|popup/i, + unlikelyCandidates: /banner|combx|comment|community|cover-wrap|disqus|extra|foot|header|legends|menu|modal|related|remark|rss|shoutbox|sidebar|skyscraper|sponsor|ad-break|agegate|pagination|pager|popup|yom-remote/i, okMaybeItsACandidate: /and|article|body|column|main|shadow/i, positive: /article|body|content|entry|hentry|h-entry|main|page|pagination|post|text|blog|story/i, negative: /hidden|^hid$| hid$| hid |^hid |banner|combx|comment|com-|contact|foot|footer|footnote|masthead|media|meta|modal|outbrain|promo|related|scroll|share|shoutbox|sidebar|skyscraper|sponsor|shopping|tags|tool|widget/i, @@ -155,8 +155,8 @@ Readability.prototype = { * * If function is not passed, removes all the nodes in node list. * - * @param NodeList nodeList The no - * @param Function filterFn + * @param NodeList nodeList The nodes to operate on + * @param Function filterFn the function to use as a filter * @return void */ _removeNodes: function(nodeList, filterFn) { @@ -171,6 +171,20 @@ Readability.prototype = { } }, + /** + * Iterates over a NodeList, and calls _setNodeTag for each node. + * + * @param NodeList nodeList The nodes to operate on + * @param String newTagName the new tag name to use + * @return void + */ + _replaceNodeTags: function(nodeList, newTagName) { + for (var i = nodeList.length - 1; i >= 0; i--) { + var node = nodeList[i]; + this._setNodeTag(node, newTagName); + } + }, + /** * Iterate over a NodeList, which doesn't natively fully implement the Array * interface. @@ -180,10 +194,9 @@ Readability.prototype = { * * @param NodeList nodeList The NodeList. * @param Function fn The iterate function. - * @param Boolean backward Whether to use backward iteration. * @return void */ - _forEachNode: function(nodeList, fn, backward) { + _forEachNode: function(nodeList, fn) { Array.prototype.forEach.call(nodeList, fn, this); }, @@ -362,9 +375,7 @@ Readability.prototype = { this._replaceBrs(doc.body); } - this._forEachNode(doc.getElementsByTagName("font"), function(fontNode) { - this._setNodeTag(fontNode, "SPAN"); - }); + this._replaceNodeTags(doc.getElementsByTagName("font"), "SPAN"); }, /** @@ -1062,12 +1073,15 @@ Readability.prototype = { metadata.excerpt = values["twitter:description"]; } - if ("og:title" in values) { - // Use facebook open graph title. - metadata.title = values["og:title"]; - } else if ("twitter:title" in values) { - // Use twitter cards title. - metadata.title = values["twitter:title"]; + metadata.title = this._getArticleTitle(); + if (!metadata.title) { + if ("og:title" in values) { + // Use facebook open graph title. + metadata.title = values["og:title"]; + } else if ("twitter:title" in values) { + // Use twitter cards title. + metadata.title = values["twitter:title"]; + } } return metadata; @@ -1857,7 +1871,7 @@ Readability.prototype = { this._prepDocument(); var metadata = this._getArticleMetadata(); - var articleTitle = metadata.title || this._getArticleTitle(); + var articleTitle = metadata.title; var articleContent = this._grabArticle(); if (!articleContent) From 2f1583e05dd13730bd2d8ec2c97747e4da9e2798 Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Wed, 30 Nov 2016 15:08:15 -0800 Subject: [PATCH 02/64] Bug 1283898 - Add rust to more automation builds. r=mshal Jobs using these additional tooltool manifests need an appropriate rust toolchain when rust code is enabled. MozReview-Commit-ID: YM7yjJk3w5 --HG-- extra : rebase_source : d98f3a9c2b1bcba337eedcaa06125ac5fb9dfd40 --- browser/config/tooltool-manifests/linux64/asan.manifest | 8 ++++++++ browser/config/tooltool-manifests/linux64/clang.manifest | 8 ++++++++ .../tooltool-manifests/linux64/clang.manifest.centos6 | 8 ++++++++ browser/config/tooltool-manifests/linux64/msan.manifest | 8 ++++++++ browser/config/tooltool-manifests/macosx64/clang.manifest | 8 ++++++++ .../android-gradle-dependencies/releng.manifest | 8 ++++++++ 6 files changed, 48 insertions(+) diff --git a/browser/config/tooltool-manifests/linux64/asan.manifest b/browser/config/tooltool-manifests/linux64/asan.manifest index 9642de0b0f47..5e475fc6b169 100644 --- a/browser/config/tooltool-manifests/linux64/asan.manifest +++ b/browser/config/tooltool-manifests/linux64/asan.manifest @@ -16,6 +16,14 @@ "unpack": true }, { +"version": "rustc 1.14.0-beta.2 (e627a2e6e 2016-11-16) repack", +"size": 96275316, +"digest": "26c11e34df81f5d7ffafc3492df9c6821f644a2e2eda5cfbbcdb1ac23e4ee196007b417c862c60a97bbf66e4be9c801400990938cd3aefec19b1cf9eaf1a9b54", +"algorithm": "sha512", +"filename": "rustc.tar.xz", +"unpack": true +}, +{ "size": 12072532, "digest": "3915f8ec396c56a8a92e6f9695b70f09ce9d1582359d1258e37e3fd43a143bc974410e4cfc27f500e095f34a8956206e0ebf799b7287f0f38def0d5e34ed71c9", "algorithm": "sha512", diff --git a/browser/config/tooltool-manifests/linux64/clang.manifest b/browser/config/tooltool-manifests/linux64/clang.manifest index 43e758cf3a9c..b068b6f21b42 100644 --- a/browser/config/tooltool-manifests/linux64/clang.manifest +++ b/browser/config/tooltool-manifests/linux64/clang.manifest @@ -16,6 +16,14 @@ "unpack": true }, { +"version": "rustc 1.14.0-beta.2 (e627a2e6e 2016-11-16) repack", +"size": 96275316, +"digest": "26c11e34df81f5d7ffafc3492df9c6821f644a2e2eda5cfbbcdb1ac23e4ee196007b417c862c60a97bbf66e4be9c801400990938cd3aefec19b1cf9eaf1a9b54", +"algorithm": "sha512", +"filename": "rustc.tar.xz", +"unpack": true +}, +{ "version": "sccache rev b21198a7183a2fe226ff49348b1c0b51bae9f4f8", "algorithm": "sha512", "visibility": "public", diff --git a/browser/config/tooltool-manifests/linux64/clang.manifest.centos6 b/browser/config/tooltool-manifests/linux64/clang.manifest.centos6 index a496d2b14f0d..06dbcade9a0f 100644 --- a/browser/config/tooltool-manifests/linux64/clang.manifest.centos6 +++ b/browser/config/tooltool-manifests/linux64/clang.manifest.centos6 @@ -16,6 +16,14 @@ "unpack": true }, { +"version": "rustc 1.14.0-beta.2 (e627a2e6e 2016-11-16) repack", +"size": 96275316, +"digest": "26c11e34df81f5d7ffafc3492df9c6821f644a2e2eda5cfbbcdb1ac23e4ee196007b417c862c60a97bbf66e4be9c801400990938cd3aefec19b1cf9eaf1a9b54", +"algorithm": "sha512", +"filename": "rustc.tar.xz", +"unpack": true +}, +{ "version": "sccache rev b21198a7183a2fe226ff49348b1c0b51bae9f4f8", "algorithm": "sha512", "filename": "sccache2.tar.xz", diff --git a/browser/config/tooltool-manifests/linux64/msan.manifest b/browser/config/tooltool-manifests/linux64/msan.manifest index 9642de0b0f47..5e475fc6b169 100644 --- a/browser/config/tooltool-manifests/linux64/msan.manifest +++ b/browser/config/tooltool-manifests/linux64/msan.manifest @@ -16,6 +16,14 @@ "unpack": true }, { +"version": "rustc 1.14.0-beta.2 (e627a2e6e 2016-11-16) repack", +"size": 96275316, +"digest": "26c11e34df81f5d7ffafc3492df9c6821f644a2e2eda5cfbbcdb1ac23e4ee196007b417c862c60a97bbf66e4be9c801400990938cd3aefec19b1cf9eaf1a9b54", +"algorithm": "sha512", +"filename": "rustc.tar.xz", +"unpack": true +}, +{ "size": 12072532, "digest": "3915f8ec396c56a8a92e6f9695b70f09ce9d1582359d1258e37e3fd43a143bc974410e4cfc27f500e095f34a8956206e0ebf799b7287f0f38def0d5e34ed71c9", "algorithm": "sha512", diff --git a/browser/config/tooltool-manifests/macosx64/clang.manifest b/browser/config/tooltool-manifests/macosx64/clang.manifest index a419ccb1bfa7..fbbe6a4a7cb5 100644 --- a/browser/config/tooltool-manifests/macosx64/clang.manifest +++ b/browser/config/tooltool-manifests/macosx64/clang.manifest @@ -8,6 +8,14 @@ "unpack": true }, { +"version": "rustc 1.13.0 (2c6933acc 2016-11-07) repack", +"size": 104593379, +"digest": "9cbc4a6d4d647dd79629e97c0e7b177443d30e669ccd761ab520728d8c2b7e1cc4ab38ec444c1957649338c4088861db3bfe4f840ec3fedcc01f9f1a74da200a", +"algorithm": "sha512", +"filename": "rustc.tar.bz2", +"unpack": true +}, +{ "version": "sccache rev b21198a7183a2fe226ff49348b1c0b51bae9f4f8", "algorithm": "sha512", "visibility": "public", diff --git a/mobile/android/config/tooltool-manifests/android-gradle-dependencies/releng.manifest b/mobile/android/config/tooltool-manifests/android-gradle-dependencies/releng.manifest index e78205e68b36..5af6239cae53 100644 --- a/mobile/android/config/tooltool-manifests/android-gradle-dependencies/releng.manifest +++ b/mobile/android/config/tooltool-manifests/android-gradle-dependencies/releng.manifest @@ -15,6 +15,14 @@ "unpack": true }, { +"version": "rustc 1.14.0-beta.2 (e627a2e6e 2016-11-16) repack", +"size": 75964276, +"digest": "3a83a42330cdc42fbffcd91aa80f8e33749c716068047699fbd0ee5b5c51ec350f60285b34fd45d9bb038a5af9118e16ab66cbf0a7167eed5a6d239f50e32462", +"algorithm": "sha512", +"filename": "rustc.tar.xz", +"unpack": true +}, +{ "version": "sccache rev b21198a7183a2fe226ff49348b1c0b51bae9f4f8", "algorithm": "sha512", "visibility": "public", From 5b2ab8bfe0252b329353118f6b3abf7c58d51646 Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Wed, 30 Nov 2016 17:40:02 -0800 Subject: [PATCH 03/64] Bug 1283898 - Put rust in path for Spidermonkey automation. r=gps When rust is enabled, the Spidermonkey package tests need to be able to find the rust toolchain. It's available, because the job uses the linux64/releng.manifest, but the corresponding path directives from mozconfig are not imported. So we set them manually here, falling back to the rustc and cargo in PATH, like we do for the C++ toolchain. MozReview-Commit-ID: 8lZSQ0Ffr0c --HG-- extra : rebase_source : a9df6559a4b5d7f179f697a1fef692cc2a3ec45d --- js/src/devtools/automation/autospider.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/src/devtools/automation/autospider.py b/js/src/devtools/automation/autospider.py index 5962dd7ef5b7..08de8c372025 100755 --- a/js/src/devtools/automation/autospider.py +++ b/js/src/devtools/automation/autospider.py @@ -178,6 +178,14 @@ else: env.setdefault('CC', compiler) env.setdefault('CXX', cxx) +rust_dir = os.path.join(DIR.tooltool, 'rustc') +if os.path.exists(os.path.join(rust_dir, 'bin', 'rustc')): + env.setdefault('RUSTC', os.path.join(rust_dir, 'bin', 'rustc')) + env.setdefault('CARGO', os.path.join(rust_dir, 'bin', 'cargo')) +else: + env.setdefault('RUSTC', 'rustc') + env.setdefault('CARGO', 'cargo') + if platform.system() == 'Darwin': os.environ['SOURCE'] = DIR.source set_vars_from_script(os.path.join(DIR.scripts, 'macbuildenv.sh'), From 3a9dd658c4e61d9fe9bf672057019b49a574f036 Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Thu, 24 Nov 2016 16:11:27 -0800 Subject: [PATCH 04/64] Bug 1283898 - Enable rust by default. r=ted Switch from --enable-rust to optionally enable rust code to --disable-rust to optionally disable it. MozReview-Commit-ID: C8cQr5MXUzV --HG-- extra : rebase_source : 0372be3cc3da56b49104b80c41974139a488ecb2 --- build/moz.configure/rust.configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/moz.configure/rust.configure b/build/moz.configure/rust.configure index fbfd4fe9074e..e1a7c82c299d 100644 --- a/build/moz.configure/rust.configure +++ b/build/moz.configure/rust.configure @@ -4,7 +4,7 @@ # 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/. -option('--enable-rust', help='Include Rust language sources') +option('--disable-rust', help='Don\'t include Rust language sources') @depends('--enable-rust') def rust_compiler_names(value): From 175aa9f527493ea2de76701341154f6af1a617ea Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Wed, 30 Nov 2016 16:10:33 -0800 Subject: [PATCH 05/64] Bug 1283898 - Make tooltool rust available in all automation. r=gps Include mozconfig.rust in the common mozconfig so all jobs will have the same rust config. Automation mozconfigs all inherit from mozconfig.common, so we can include mozconfig.rust there and not need it anywhere else. Remove --enable-rust from mozconfig.rust now that it's the default. We only need the RUSTC and CARGO path variables so jobs can find the toolchain installed from the tooltool manifest. Also some automation jobs reject the configure option if we set it unconditionally. The --enable-rpath comment is no longer necessary; rust has been consistently built this way for some time. MozReview-Commit-ID: 2IeIIIinnPL --HG-- extra : rebase_source : 79dadcc5ed13f2db312042d755a57698f267e902 --- browser/config/mozconfigs/linux32/beta | 1 - browser/config/mozconfigs/linux32/debug | 1 - browser/config/mozconfigs/linux32/nightly | 1 - browser/config/mozconfigs/linux32/release | 1 - browser/config/mozconfigs/linux64/beta | 1 - browser/config/mozconfigs/linux64/debug | 1 - browser/config/mozconfigs/linux64/nightly | 1 - browser/config/mozconfigs/linux64/release | 1 - browser/config/mozconfigs/macosx-universal/beta | 1 - browser/config/mozconfigs/macosx-universal/nightly | 1 - browser/config/mozconfigs/macosx-universal/release | 1 - browser/config/mozconfigs/macosx64/beta | 1 - browser/config/mozconfigs/macosx64/debug | 1 - browser/config/mozconfigs/macosx64/nightly | 1 - browser/config/mozconfigs/macosx64/opt-static-analysis | 1 - browser/config/mozconfigs/macosx64/release | 1 - browser/config/mozconfigs/win32/beta | 2 -- browser/config/mozconfigs/win32/clang | 2 -- browser/config/mozconfigs/win32/clang-debug | 2 -- browser/config/mozconfigs/win32/debug | 2 -- browser/config/mozconfigs/win32/debug-static-analysis | 2 -- browser/config/mozconfigs/win32/nightly | 2 -- browser/config/mozconfigs/win32/release | 2 -- browser/config/mozconfigs/win64/beta | 2 -- browser/config/mozconfigs/win64/clang | 2 -- browser/config/mozconfigs/win64/clang-debug | 2 -- browser/config/mozconfigs/win64/debug | 2 -- browser/config/mozconfigs/win64/nightly | 2 -- browser/config/mozconfigs/win64/release | 2 -- build/mozconfig.common | 1 + build/mozconfig.rust | 5 ----- .../android/config/mozconfigs/android-api-15-gradle/nightly | 1 - .../config/mozconfigs/android-api-15-gradle/nightly-artifact | 1 - mobile/android/config/mozconfigs/android-api-15/debug | 1 - mobile/android/config/mozconfigs/android-api-15/l10n-nightly | 1 - mobile/android/config/mozconfigs/android-api-15/l10n-release | 1 - mobile/android/config/mozconfigs/android-api-15/nightly | 1 - .../config/mozconfigs/android-api-15/nightly-artifact | 1 - mobile/android/config/mozconfigs/android-api-15/release | 1 - mobile/android/config/mozconfigs/android-x86/debug | 1 - mobile/android/config/mozconfigs/android-x86/l10n-nightly | 1 - mobile/android/config/mozconfigs/android-x86/l10n-release | 1 - mobile/android/config/mozconfigs/android-x86/nightly | 1 - mobile/android/config/mozconfigs/android-x86/release | 1 - .../mozconfigs/public-partner/distribution_sample/mozconfig1 | 1 - 45 files changed, 1 insertion(+), 61 deletions(-) diff --git a/browser/config/mozconfigs/linux32/beta b/browser/config/mozconfigs/linux32/beta index 315c32b843ac..346a8bdaa7d0 100644 --- a/browser/config/mozconfigs/linux32/beta +++ b/browser/config/mozconfigs/linux32/beta @@ -11,5 +11,4 @@ ac_add_options --enable-verify-mar mk_add_options MOZ_PGO=1 -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" diff --git a/browser/config/mozconfigs/linux32/debug b/browser/config/mozconfigs/linux32/debug index de97087d2a8b..542c20f2c453 100644 --- a/browser/config/mozconfigs/linux32/debug +++ b/browser/config/mozconfigs/linux32/debug @@ -19,6 +19,5 @@ export MOZ_PACKAGE_JSSHELL=1 ac_add_options --with-branding=browser/branding/nightly -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/linux32/nightly b/browser/config/mozconfigs/linux32/nightly index ce1c5e7f643e..468c3d263fe9 100644 --- a/browser/config/mozconfigs/linux32/nightly +++ b/browser/config/mozconfigs/linux32/nightly @@ -10,6 +10,5 @@ STRIP_FLAGS="--strip-debug" ac_add_options --with-branding=browser/branding/nightly -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/linux32/release b/browser/config/mozconfigs/linux32/release index b17186666b91..8982e2716660 100644 --- a/browser/config/mozconfigs/linux32/release +++ b/browser/config/mozconfigs/linux32/release @@ -18,5 +18,4 @@ mk_add_options MOZ_PGO=1 # defines.sh during the beta cycle export BUILDING_RELEASE=1 -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" diff --git a/browser/config/mozconfigs/linux64/beta b/browser/config/mozconfigs/linux64/beta index f349ee9f8355..34e1b63c7e6b 100644 --- a/browser/config/mozconfigs/linux64/beta +++ b/browser/config/mozconfigs/linux64/beta @@ -11,5 +11,4 @@ ac_add_options --enable-verify-mar mk_add_options MOZ_PGO=1 -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" diff --git a/browser/config/mozconfigs/linux64/debug b/browser/config/mozconfigs/linux64/debug index a879da75e6e9..8196af81bbf4 100644 --- a/browser/config/mozconfigs/linux64/debug +++ b/browser/config/mozconfigs/linux64/debug @@ -17,6 +17,5 @@ export MOZ_PACKAGE_JSSHELL=1 ac_add_options --with-branding=browser/branding/nightly -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/linux64/nightly b/browser/config/mozconfigs/linux64/nightly index 41f5c2249590..ac48aa4fd4c3 100644 --- a/browser/config/mozconfigs/linux64/nightly +++ b/browser/config/mozconfigs/linux64/nightly @@ -10,6 +10,5 @@ STRIP_FLAGS="--strip-debug" ac_add_options --with-branding=browser/branding/nightly -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/linux64/release b/browser/config/mozconfigs/linux64/release index 2090f3525de1..d38600b9e47e 100644 --- a/browser/config/mozconfigs/linux64/release +++ b/browser/config/mozconfigs/linux64/release @@ -18,5 +18,4 @@ mk_add_options MOZ_PGO=1 # defines.sh during the beta cycle export BUILDING_RELEASE=1 -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" diff --git a/browser/config/mozconfigs/macosx-universal/beta b/browser/config/mozconfigs/macosx-universal/beta index 07f089a679ab..64e7ca847816 100644 --- a/browser/config/mozconfigs/macosx-universal/beta +++ b/browser/config/mozconfigs/macosx-universal/beta @@ -10,6 +10,5 @@ fi ac_add_options --enable-official-branding ac_add_options --enable-verify-mar -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/macosx-universal/nightly b/browser/config/mozconfigs/macosx-universal/nightly index 1928d79afd1a..e8280983e40f 100644 --- a/browser/config/mozconfigs/macosx-universal/nightly +++ b/browser/config/mozconfigs/macosx-universal/nightly @@ -16,6 +16,5 @@ fi ac_add_options --with-branding=browser/branding/nightly -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/macosx-universal/release b/browser/config/mozconfigs/macosx-universal/release index c352022e3615..8942f6229eed 100644 --- a/browser/config/mozconfigs/macosx-universal/release +++ b/browser/config/mozconfigs/macosx-universal/release @@ -16,6 +16,5 @@ ac_add_options --enable-verify-mar # defines.sh during the beta cycle export BUILDING_RELEASE=1 -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/macosx64/beta b/browser/config/mozconfigs/macosx64/beta index 64cf69d866f7..53608e59761d 100644 --- a/browser/config/mozconfigs/macosx64/beta +++ b/browser/config/mozconfigs/macosx64/beta @@ -10,6 +10,5 @@ fi ac_add_options --enable-official-branding ac_add_options --enable-verify-mar -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/macosx64/debug b/browser/config/mozconfigs/macosx64/debug index 4b052aa00d03..923d020a9cdf 100644 --- a/browser/config/mozconfigs/macosx64/debug +++ b/browser/config/mozconfigs/macosx64/debug @@ -19,6 +19,5 @@ export MOZ_PACKAGE_JSSHELL=1 ac_add_options --with-branding=browser/branding/nightly -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/macosx64/nightly b/browser/config/mozconfigs/macosx64/nightly index 0a915da54660..d75737fa41cf 100644 --- a/browser/config/mozconfigs/macosx64/nightly +++ b/browser/config/mozconfigs/macosx64/nightly @@ -16,6 +16,5 @@ fi ac_add_options --with-branding=browser/branding/nightly -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/macosx64/opt-static-analysis b/browser/config/mozconfigs/macosx64/opt-static-analysis index 72ed3d6bdd58..50739c01ff99 100644 --- a/browser/config/mozconfigs/macosx64/opt-static-analysis +++ b/browser/config/mozconfigs/macosx64/opt-static-analysis @@ -10,7 +10,6 @@ ac_add_options --enable-dmd ac_add_options --enable-clang-plugin -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/macosx64/release b/browser/config/mozconfigs/macosx64/release index 562a16b50ebe..d033c780c8e0 100644 --- a/browser/config/mozconfigs/macosx64/release +++ b/browser/config/mozconfigs/macosx64/release @@ -16,6 +16,5 @@ ac_add_options --enable-verify-mar # defines.sh during the beta cycle export BUILDING_RELEASE=1 -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/win32/beta b/browser/config/mozconfigs/win32/beta index cc14d6800ac5..c83335fbd123 100644 --- a/browser/config/mozconfigs/win32/beta +++ b/browser/config/mozconfigs/win32/beta @@ -13,6 +13,4 @@ mk_add_options MOZ_PGO=1 ac_add_options --enable-official-branding ac_add_options --enable-verify-mar -. "$topsrcdir/build/mozconfig.rust" - . "$topsrcdir/build/mozconfig.common.override" diff --git a/browser/config/mozconfigs/win32/clang b/browser/config/mozconfigs/win32/clang index a79bc780e0d3..426958d45568 100644 --- a/browser/config/mozconfigs/win32/clang +++ b/browser/config/mozconfigs/win32/clang @@ -12,8 +12,6 @@ ac_add_options --enable-optimize . $topsrcdir/build/win32/mozconfig.vs-latest -. "$topsrcdir/build/mozconfig.rust" - . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" . "$topsrcdir/build/mozconfig.clang-cl" diff --git a/browser/config/mozconfigs/win32/clang-debug b/browser/config/mozconfigs/win32/clang-debug index 958741bf4daf..b354d25acfbe 100644 --- a/browser/config/mozconfigs/win32/clang-debug +++ b/browser/config/mozconfigs/win32/clang-debug @@ -13,8 +13,6 @@ ac_add_options --enable-debug . $topsrcdir/build/win32/mozconfig.vs-latest -. "$topsrcdir/build/mozconfig.rust" - . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" . "$topsrcdir/build/mozconfig.clang-cl" diff --git a/browser/config/mozconfigs/win32/debug b/browser/config/mozconfigs/win32/debug index 6beee93c284f..e8bb581a0703 100644 --- a/browser/config/mozconfigs/win32/debug +++ b/browser/config/mozconfigs/win32/debug @@ -21,7 +21,5 @@ export MOZ_PACKAGE_JSSHELL=1 ac_add_options --with-branding=browser/branding/nightly -. "$topsrcdir/build/mozconfig.rust" - . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/win32/debug-static-analysis b/browser/config/mozconfigs/win32/debug-static-analysis index efc0820b5fa7..29bfb2fddb2b 100644 --- a/browser/config/mozconfigs/win32/debug-static-analysis +++ b/browser/config/mozconfigs/win32/debug-static-analysis @@ -12,8 +12,6 @@ ac_add_options --enable-clang-plugin . $topsrcdir/build/win32/mozconfig.vs-latest -. "$topsrcdir/build/mozconfig.rust" - . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" . "$topsrcdir/build/mozconfig.clang-cl" diff --git a/browser/config/mozconfigs/win32/nightly b/browser/config/mozconfigs/win32/nightly index 54fbc93f174d..7cd328b54772 100644 --- a/browser/config/mozconfigs/win32/nightly +++ b/browser/config/mozconfigs/win32/nightly @@ -6,7 +6,5 @@ ac_add_options --enable-verify-mar ac_add_options --with-branding=browser/branding/nightly -. "$topsrcdir/build/mozconfig.rust" - . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/win32/release b/browser/config/mozconfigs/win32/release index daaa45f89823..ea1f242efbdd 100644 --- a/browser/config/mozconfigs/win32/release +++ b/browser/config/mozconfigs/win32/release @@ -19,6 +19,4 @@ ac_add_options --enable-verify-mar # defines.sh during the beta cycle export BUILDING_RELEASE=1 -. "$topsrcdir/build/mozconfig.rust" - . "$topsrcdir/build/mozconfig.common.override" diff --git a/browser/config/mozconfigs/win64/beta b/browser/config/mozconfigs/win64/beta index 6fc4ebe36743..6b9960abc3c5 100644 --- a/browser/config/mozconfigs/win64/beta +++ b/browser/config/mozconfigs/win64/beta @@ -14,6 +14,4 @@ mk_add_options MOZ_PGO=1 ac_add_options --enable-official-branding ac_add_options --enable-verify-mar -. "$topsrcdir/build/mozconfig.rust" - . "$topsrcdir/build/mozconfig.common.override" diff --git a/browser/config/mozconfigs/win64/clang b/browser/config/mozconfigs/win64/clang index 0bc3a7ebebe4..8de249b45190 100644 --- a/browser/config/mozconfigs/win64/clang +++ b/browser/config/mozconfigs/win64/clang @@ -14,8 +14,6 @@ ac_add_options --enable-optimize . $topsrcdir/build/win64/mozconfig.vs-latest -. "$topsrcdir/build/mozconfig.rust" - . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" . "$topsrcdir/build/mozconfig.clang-cl" diff --git a/browser/config/mozconfigs/win64/clang-debug b/browser/config/mozconfigs/win64/clang-debug index e254d76622ee..ba416e22fc04 100644 --- a/browser/config/mozconfigs/win64/clang-debug +++ b/browser/config/mozconfigs/win64/clang-debug @@ -15,8 +15,6 @@ ac_add_options --enable-debug . $topsrcdir/build/win64/mozconfig.vs-latest -. "$topsrcdir/build/mozconfig.rust" - . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" . "$topsrcdir/build/mozconfig.clang-cl" diff --git a/browser/config/mozconfigs/win64/debug b/browser/config/mozconfigs/win64/debug index db4eb59406ad..723fa0e0b08a 100644 --- a/browser/config/mozconfigs/win64/debug +++ b/browser/config/mozconfigs/win64/debug @@ -23,7 +23,5 @@ ac_add_options --with-branding=browser/branding/nightly . $topsrcdir/build/win64/mozconfig.vs-latest -. "$topsrcdir/build/mozconfig.rust" - . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/win64/nightly b/browser/config/mozconfigs/win64/nightly index f710aabe3a01..9c31c44644ee 100644 --- a/browser/config/mozconfigs/win64/nightly +++ b/browser/config/mozconfigs/win64/nightly @@ -7,7 +7,5 @@ ac_add_options --enable-verify-mar ac_add_options --with-branding=browser/branding/nightly -. "$topsrcdir/build/mozconfig.rust" - . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/win64/release b/browser/config/mozconfigs/win64/release index 62e83205f803..389a1ea4b40e 100644 --- a/browser/config/mozconfigs/win64/release +++ b/browser/config/mozconfigs/win64/release @@ -20,6 +20,4 @@ ac_add_options --enable-verify-mar # defines.sh during the beta cycle export BUILDING_RELEASE=1 -. "$topsrcdir/build/mozconfig.rust" - . "$topsrcdir/build/mozconfig.common.override" diff --git a/build/mozconfig.common b/build/mozconfig.common index 6e19ae80ecac..e817b77bf5be 100644 --- a/build/mozconfig.common +++ b/build/mozconfig.common @@ -24,3 +24,4 @@ MOZ_REQUIRE_SIGNING=${MOZ_REQUIRE_SIGNING-0} ac_add_options --enable-js-shell . "$topsrcdir/build/mozconfig.automation" +. "$topsrcdir/build/mozconfig.rust" diff --git a/build/mozconfig.rust b/build/mozconfig.rust index 27936c3b3c23..b5efe131b9c8 100644 --- a/build/mozconfig.rust +++ b/build/mozconfig.rust @@ -1,10 +1,5 @@ # Options to enable rust in automation builds. # Tell configure to use the tooltool rustc. -# Assume this is compiled with --enable-rpath so we don't -# have to set LD_LIBRARY_PATH. RUSTC="$topsrcdir/rustc/bin/rustc" CARGO="$topsrcdir/rustc/bin/cargo" - -# Enable rust in the build. -ac_add_options --enable-rust diff --git a/mobile/android/config/mozconfigs/android-api-15-gradle/nightly b/mobile/android/config/mozconfigs/android-api-15-gradle/nightly index ecf25e313f08..2edb158376b8 100644 --- a/mobile/android/config/mozconfigs/android-api-15-gradle/nightly +++ b/mobile/android/config/mozconfigs/android-api-15-gradle/nightly @@ -1,5 +1,4 @@ . "$topsrcdir/mobile/android/config/mozconfigs/common" -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/mobile/android/config/mozconfigs/android-api-15/nightly" diff --git a/mobile/android/config/mozconfigs/android-api-15-gradle/nightly-artifact b/mobile/android/config/mozconfigs/android-api-15-gradle/nightly-artifact index 27885f0f577d..6c0bc7c553fa 100644 --- a/mobile/android/config/mozconfigs/android-api-15-gradle/nightly-artifact +++ b/mobile/android/config/mozconfigs/android-api-15-gradle/nightly-artifact @@ -5,7 +5,6 @@ NO_CACHE=1 NO_NDK=1 . "$topsrcdir/mobile/android/config/mozconfigs/common" -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/mobile/android/config/mozconfigs/android-api-15-gradle/nightly" diff --git a/mobile/android/config/mozconfigs/android-api-15/debug b/mobile/android/config/mozconfigs/android-api-15/debug index 5b2bf124afd6..d62f33d167d7 100644 --- a/mobile/android/config/mozconfigs/android-api-15/debug +++ b/mobile/android/config/mozconfigs/android-api-15/debug @@ -1,5 +1,4 @@ . "$topsrcdir/mobile/android/config/mozconfigs/common" -. "$topsrcdir/build/mozconfig.rust" # Global options ac_add_options --enable-debug diff --git a/mobile/android/config/mozconfigs/android-api-15/l10n-nightly b/mobile/android/config/mozconfigs/android-api-15/l10n-nightly index 5582493160ad..09adf8590aa6 100644 --- a/mobile/android/config/mozconfigs/android-api-15/l10n-nightly +++ b/mobile/android/config/mozconfigs/android-api-15/l10n-nightly @@ -1,5 +1,4 @@ . "$topsrcdir/mobile/android/config/mozconfigs/common" -. "$topsrcdir/build/mozconfig.rust" # L10n ac_add_options --with-l10n-base=../../l10n-central diff --git a/mobile/android/config/mozconfigs/android-api-15/l10n-release b/mobile/android/config/mozconfigs/android-api-15/l10n-release index 8e302df8f297..0255ffc65484 100644 --- a/mobile/android/config/mozconfigs/android-api-15/l10n-release +++ b/mobile/android/config/mozconfigs/android-api-15/l10n-release @@ -1,5 +1,4 @@ . "$topsrcdir/mobile/android/config/mozconfigs/common" -. "$topsrcdir/build/mozconfig.rust" # L10n ac_add_options --with-l10n-base=.. diff --git a/mobile/android/config/mozconfigs/android-api-15/nightly b/mobile/android/config/mozconfigs/android-api-15/nightly index 559bffb09dfa..70393787f841 100644 --- a/mobile/android/config/mozconfigs/android-api-15/nightly +++ b/mobile/android/config/mozconfigs/android-api-15/nightly @@ -1,5 +1,4 @@ . "$topsrcdir/mobile/android/config/mozconfigs/common" -. "$topsrcdir/build/mozconfig.rust" ac_add_options --enable-profiling diff --git a/mobile/android/config/mozconfigs/android-api-15/nightly-artifact b/mobile/android/config/mozconfigs/android-api-15/nightly-artifact index fe16bfdac370..c2a1000f360b 100644 --- a/mobile/android/config/mozconfigs/android-api-15/nightly-artifact +++ b/mobile/android/config/mozconfigs/android-api-15/nightly-artifact @@ -5,7 +5,6 @@ NO_CACHE=1 NO_NDK=1 . "$topsrcdir/mobile/android/config/mozconfigs/common" -. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/mobile/android/config/mozconfigs/android-api-15/nightly" diff --git a/mobile/android/config/mozconfigs/android-api-15/release b/mobile/android/config/mozconfigs/android-api-15/release index 17f10ce824d0..5d3fb3a8b131 100644 --- a/mobile/android/config/mozconfigs/android-api-15/release +++ b/mobile/android/config/mozconfigs/android-api-15/release @@ -1,5 +1,4 @@ . "$topsrcdir/mobile/android/config/mozconfigs/common" -. "$topsrcdir/build/mozconfig.rust" # Android ac_add_options --with-android-min-sdk=15 diff --git a/mobile/android/config/mozconfigs/android-x86/debug b/mobile/android/config/mozconfigs/android-x86/debug index 7ed8fe6c9e13..1fe83f54e231 100644 --- a/mobile/android/config/mozconfigs/android-x86/debug +++ b/mobile/android/config/mozconfigs/android-x86/debug @@ -1,5 +1,4 @@ . "$topsrcdir/mobile/android/config/mozconfigs/common" -. "$topsrcdir/build/mozconfig.rust" # Global options ac_add_options --enable-debug diff --git a/mobile/android/config/mozconfigs/android-x86/l10n-nightly b/mobile/android/config/mozconfigs/android-x86/l10n-nightly index bcbf75978b58..b98f2512698f 100644 --- a/mobile/android/config/mozconfigs/android-x86/l10n-nightly +++ b/mobile/android/config/mozconfigs/android-x86/l10n-nightly @@ -1,5 +1,4 @@ . "$topsrcdir/mobile/android/config/mozconfigs/common" -. "$topsrcdir/build/mozconfig.rust" # L10n ac_add_options --with-l10n-base=../../l10n-central diff --git a/mobile/android/config/mozconfigs/android-x86/l10n-release b/mobile/android/config/mozconfigs/android-x86/l10n-release index 27c60dd3e2af..7d7eca9b2ddd 100644 --- a/mobile/android/config/mozconfigs/android-x86/l10n-release +++ b/mobile/android/config/mozconfigs/android-x86/l10n-release @@ -1,5 +1,4 @@ . "$topsrcdir/mobile/android/config/mozconfigs/common" -. "$topsrcdir/build/mozconfig.rust" # L10n ac_add_options --with-l10n-base=.. diff --git a/mobile/android/config/mozconfigs/android-x86/nightly b/mobile/android/config/mozconfigs/android-x86/nightly index 3f6a5c809fc7..beab3d7463c2 100644 --- a/mobile/android/config/mozconfigs/android-x86/nightly +++ b/mobile/android/config/mozconfigs/android-x86/nightly @@ -1,5 +1,4 @@ . "$topsrcdir/mobile/android/config/mozconfigs/common" -. "$topsrcdir/build/mozconfig.rust" ac_add_options --target=i386-linux-android ac_add_options --with-android-min-sdk=15 diff --git a/mobile/android/config/mozconfigs/android-x86/release b/mobile/android/config/mozconfigs/android-x86/release index 63ca59a84afe..83d2cfc23a50 100644 --- a/mobile/android/config/mozconfigs/android-x86/release +++ b/mobile/android/config/mozconfigs/android-x86/release @@ -1,5 +1,4 @@ . "$topsrcdir/mobile/android/config/mozconfigs/common" -. "$topsrcdir/build/mozconfig.rust" # Android ac_add_options --target=i386-linux-android diff --git a/mobile/android/config/mozconfigs/public-partner/distribution_sample/mozconfig1 b/mobile/android/config/mozconfigs/public-partner/distribution_sample/mozconfig1 index 38e0e83eac46..b790769c6978 100644 --- a/mobile/android/config/mozconfigs/public-partner/distribution_sample/mozconfig1 +++ b/mobile/android/config/mozconfigs/public-partner/distribution_sample/mozconfig1 @@ -1,6 +1,5 @@ # currently a copy of mobile/android/config/mozconfigs/android-api-15/nightly . "$topsrcdir/mobile/android/config/mozconfigs/common" -. "$topsrcdir/build/mozconfig.rust" ac_add_options --enable-profiling From 43f1fe54f394e4885ccd2535d9fce55f4f2e8e01 Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Tue, 13 Dec 2016 10:49:02 -0800 Subject: [PATCH 06/64] Bug 1283898 - Update linux64 tooltool rust to support i686. r=gps Update the linux64 releng tooltool manifest to to same repack of rustc 1.14.0-beta.2 with support for x86_64 and i686 targets we're using for the linux32 builds. This is necessary for --enable-rust to work on 32-bit Spidermonkey cross builds. MozReview-Commit-ID: 1xfOBHOZ4iB --HG-- extra : rebase_source : a1ec78464be1d82929c25c35fe18b8f9e4fae148 --- browser/config/tooltool-manifests/linux64/releng.manifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/browser/config/tooltool-manifests/linux64/releng.manifest b/browser/config/tooltool-manifests/linux64/releng.manifest index b3ad33ce24cd..819df48fd339 100644 --- a/browser/config/tooltool-manifests/linux64/releng.manifest +++ b/browser/config/tooltool-manifests/linux64/releng.manifest @@ -17,8 +17,8 @@ }, { "version": "rustc 1.14.0-beta.2 (e627a2e6e 2016-11-16) repack", -"size": 96275316, -"digest": "26c11e34df81f5d7ffafc3492df9c6821f644a2e2eda5cfbbcdb1ac23e4ee196007b417c862c60a97bbf66e4be9c801400990938cd3aefec19b1cf9eaf1a9b54", +"size": 94830820, +"digest": "6f2a1cf325d957f0328d2d853fc07944a857e872f6e44df15f6ebb45c032c0ebbf52f56c872bc72927ebcdd830002d759dd92e8fc90048b52c07058955c69c4c", "algorithm": "sha512", "filename": "rustc.tar.xz", "unpack": true From 4dc898d784a0b1c4ffc648e91607a5b900682249 Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Tue, 13 Dec 2016 10:56:52 -0800 Subject: [PATCH 07/64] Bug 1283898 - Add tooltool rust to path for js hazard jobs. r=gps Tasks calling these generally use tooltool and the hazard manifest to provide toolchains, but the setup job doesn't they don't use a mozconfig to configure paths, and the analysis job uses a different TOOLTOOL_DIR. The build calls configure, which defaults to --enable-rust, so we need to add the correct rust toolchain path to the environment like we do for C++. MozReview-Commit-ID: gFnZ0SK1f7 --HG-- extra : rebase_source : f7cabb5b15551f5b00ff8271ceddeb4b47146c03 --- browser/config/mozconfigs/linux64/hazards | 5 +++++ taskcluster/scripts/builder/hazard-analysis.sh | 2 ++ 2 files changed, 7 insertions(+) diff --git a/browser/config/mozconfigs/linux64/hazards b/browser/config/mozconfigs/linux64/hazards index 03d72ef7ec28..3767d941e68f 100644 --- a/browser/config/mozconfigs/linux64/hazards +++ b/browser/config/mozconfigs/linux64/hazards @@ -29,6 +29,11 @@ CFLAGS="$CFLAGS -Wno-attributes" CPPFLAGS="$CPPFLAGS -Wno-attributes" CXXFLAGS="$CXXFLAGS -Wno-attributes" +# Override rust toolchain paths. In this build they're in $TOOLTOOL_DIR +# instead of $topsrcdir as referenced by mozconfig.common. +RUSTC=$TOOLTOOL_DIR/rustc/bin/rustc +CARGO=$TOOLTOOL_DIR/rustc/bin/cargo + export PKG_CONFIG_LIBDIR=/usr/lib64/pkgconfig:/usr/share/pkgconfig . $topsrcdir/build/unix/mozconfig.gtk diff --git a/taskcluster/scripts/builder/hazard-analysis.sh b/taskcluster/scripts/builder/hazard-analysis.sh index d3e574742811..f6e2fadfa1df 100755 --- a/taskcluster/scripts/builder/hazard-analysis.sh +++ b/taskcluster/scripts/builder/hazard-analysis.sh @@ -10,6 +10,8 @@ ANALYSIS_SRCDIR=$JS_SRCDIR/devtools/rootAnalysis export CC="$TOOLTOOL_DIR/gcc/bin/gcc" export CXX="$TOOLTOOL_DIR/gcc/bin/g++" +export RUSTC="$TOOLTOOL_DIR/rustc/bin/rustc" +export CARGO="$TOOLTOOL_DIR/rustc/bin/cargo" PYTHON=python2.7 if ! which $PYTHON; then From f556d427fbbec2a8eeaa6bc93dd960992842f53b Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Tue, 13 Dec 2016 11:16:53 -0800 Subject: [PATCH 08/64] Bug 1283898 - Don't set RUSTC for artifact builds. r=gps The --disable-compile-environment configure option used by the artifact builds removes all support for toolchains, including setting paths for them with environment options. Unset the RUSTC and CARGO vars inherited from mozconfig.rust in the artifact mozconfigs to accommodate the invalid option check, just like we do for the CC and CXX options. MozReview-Commit-ID: IwPetRaIY25 --HG-- extra : rebase_source : 37fb4bf9e69d3082cc0ed6b0013e6363a7e8e8e5 --- browser/config/mozconfigs/linux32/artifact | 2 ++ browser/config/mozconfigs/linux32/debug-artifact | 2 ++ browser/config/mozconfigs/linux64/artifact | 2 ++ browser/config/mozconfigs/linux64/debug-artifact | 2 ++ browser/config/mozconfigs/macosx64/artifact | 2 ++ browser/config/mozconfigs/macosx64/debug-artifact | 2 ++ .../android/config/mozconfigs/android-api-15-frontend/nightly | 2 ++ .../mozconfigs/android-api-15-gradle-dependencies/nightly | 2 ++ .../config/mozconfigs/android-api-15-gradle/nightly-artifact | 2 ++ mobile/android/config/mozconfigs/android-api-15/debug-artifact | 2 ++ .../android/config/mozconfigs/android-api-15/nightly-artifact | 2 ++ mobile/android/config/mozconfigs/android-x86/nightly-artifact | 2 ++ 12 files changed, 24 insertions(+) diff --git a/browser/config/mozconfigs/linux32/artifact b/browser/config/mozconfigs/linux32/artifact index 29eb8ba1c227..b52d41e2adf7 100644 --- a/browser/config/mozconfigs/linux32/artifact +++ b/browser/config/mozconfigs/linux32/artifact @@ -8,3 +8,5 @@ ac_add_options --enable-artifact-builds ac_add_options --enable-artifact-build-symbols unset CC unset CXX +unset RUSTC +unset CARGO diff --git a/browser/config/mozconfigs/linux32/debug-artifact b/browser/config/mozconfigs/linux32/debug-artifact index 3fc3faf89e1a..1d368e98134a 100644 --- a/browser/config/mozconfigs/linux32/debug-artifact +++ b/browser/config/mozconfigs/linux32/debug-artifact @@ -8,5 +8,7 @@ ac_add_options --enable-artifact-builds ac_add_options --enable-artifact-build-symbols unset CC unset CXX +unset RUSTC +unset CARGO ac_add_options --enable-debug diff --git a/browser/config/mozconfigs/linux64/artifact b/browser/config/mozconfigs/linux64/artifact index 524a25e69022..4e13ca2509b9 100644 --- a/browser/config/mozconfigs/linux64/artifact +++ b/browser/config/mozconfigs/linux64/artifact @@ -8,3 +8,5 @@ ac_add_options --enable-artifact-builds ac_add_options --enable-artifact-build-symbols unset CC unset CXX +unset RUSTC +unset CARGO diff --git a/browser/config/mozconfigs/linux64/debug-artifact b/browser/config/mozconfigs/linux64/debug-artifact index 6dc4d13cea88..f95e7c01df72 100644 --- a/browser/config/mozconfigs/linux64/debug-artifact +++ b/browser/config/mozconfigs/linux64/debug-artifact @@ -8,6 +8,8 @@ ac_add_options --enable-artifact-builds ac_add_options --enable-artifact-build-symbols unset CC unset CXX +unset RUSTC +unset CARGO ac_add_options --enable-debug diff --git a/browser/config/mozconfigs/macosx64/artifact b/browser/config/mozconfigs/macosx64/artifact index 303b180b7d46..9a5bfbb11c5d 100644 --- a/browser/config/mozconfigs/macosx64/artifact +++ b/browser/config/mozconfigs/macosx64/artifact @@ -11,3 +11,5 @@ ac_add_options --enable-artifact-builds ac_add_options --enable-artifact-build-symbols unset CC unset CXX +unset RUSTC +unset CARGO diff --git a/browser/config/mozconfigs/macosx64/debug-artifact b/browser/config/mozconfigs/macosx64/debug-artifact index 3afa8e4bf645..38feec6337c8 100644 --- a/browser/config/mozconfigs/macosx64/debug-artifact +++ b/browser/config/mozconfigs/macosx64/debug-artifact @@ -8,5 +8,7 @@ ac_add_options --enable-artifact-builds ac_add_options --enable-artifact-build-symbols unset CC unset CXX +unset RUSTC +unset CARGO ac_add_options --enable-debug diff --git a/mobile/android/config/mozconfigs/android-api-15-frontend/nightly b/mobile/android/config/mozconfigs/android-api-15-frontend/nightly index 6fb88b0f52e8..21bfedef5aaa 100644 --- a/mobile/android/config/mozconfigs/android-api-15-frontend/nightly +++ b/mobile/android/config/mozconfigs/android-api-15-frontend/nightly @@ -19,6 +19,8 @@ export GRADLE_MAVEN_REPOSITORY="file://$topsrcdir/jcentral" unset HOST_CC unset HOST_CXX +unset RUSTC +unset CARGO ac_add_options --disable-compile-environment ac_add_options --disable-tests diff --git a/mobile/android/config/mozconfigs/android-api-15-gradle-dependencies/nightly b/mobile/android/config/mozconfigs/android-api-15-gradle-dependencies/nightly index 99789543c591..177b1aa07a64 100644 --- a/mobile/android/config/mozconfigs/android-api-15-gradle-dependencies/nightly +++ b/mobile/android/config/mozconfigs/android-api-15-gradle-dependencies/nightly @@ -24,6 +24,8 @@ export GRADLE_MAVEN_REPOSITORY="http://localhost:8081/nexus/content/repositories ac_add_options --disable-compile-environment unset HOST_CC unset HOST_CXX +unset RUSTC +unset CARGO ac_add_options --disable-tests diff --git a/mobile/android/config/mozconfigs/android-api-15-gradle/nightly-artifact b/mobile/android/config/mozconfigs/android-api-15-gradle/nightly-artifact index 6c0bc7c553fa..ff86aa46b05a 100644 --- a/mobile/android/config/mozconfigs/android-api-15-gradle/nightly-artifact +++ b/mobile/android/config/mozconfigs/android-api-15-gradle/nightly-artifact @@ -12,6 +12,8 @@ unset CC unset CXX unset HOST_CC unset HOST_CXX +unset RUSTC +unset CARGO ac_add_options --enable-artifact-builds diff --git a/mobile/android/config/mozconfigs/android-api-15/debug-artifact b/mobile/android/config/mozconfigs/android-api-15/debug-artifact index 5f7219b71515..4f6f03d8d761 100644 --- a/mobile/android/config/mozconfigs/android-api-15/debug-artifact +++ b/mobile/android/config/mozconfigs/android-api-15/debug-artifact @@ -16,6 +16,8 @@ unset CC unset CXX unset HOST_CC unset HOST_CXX +unset RUSTC +unset CARGO ac_add_options --enable-artifact-builds diff --git a/mobile/android/config/mozconfigs/android-api-15/nightly-artifact b/mobile/android/config/mozconfigs/android-api-15/nightly-artifact index c2a1000f360b..e51090182f23 100644 --- a/mobile/android/config/mozconfigs/android-api-15/nightly-artifact +++ b/mobile/android/config/mozconfigs/android-api-15/nightly-artifact @@ -12,6 +12,8 @@ unset CC unset CXX unset HOST_CC unset HOST_CXX +unset RUSTC +unset CARGO ac_add_options --enable-artifact-builds diff --git a/mobile/android/config/mozconfigs/android-x86/nightly-artifact b/mobile/android/config/mozconfigs/android-x86/nightly-artifact index 8dd7c092ac06..de5407218ba8 100644 --- a/mobile/android/config/mozconfigs/android-x86/nightly-artifact +++ b/mobile/android/config/mozconfigs/android-x86/nightly-artifact @@ -12,6 +12,8 @@ unset CC unset CXX unset HOST_CC unset HOST_CXX +unset RUSTC +unset CARGO ac_add_options --enable-artifact-builds From 7c7028af89876a923bc12e6ec47a2b93af8cbe95 Mon Sep 17 00:00:00 2001 From: Timothy Guan-tin Chien Date: Fri, 2 Dec 2016 14:26:26 +0800 Subject: [PATCH 09/64] Bug 1318203 - Don't show autocomplete UI on Password Field if it is already populated with text, r=MattN MozReview-Commit-ID: L3cUxHYIE5R --HG-- extra : rebase_source : 0a01f8d0ded5728a5778aa63267248c7c6715c4e --- toolkit/components/passwordmgr/nsLoginManager.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/toolkit/components/passwordmgr/nsLoginManager.js b/toolkit/components/passwordmgr/nsLoginManager.js index 4ef29f88fc39..f5bfe1d64b35 100644 --- a/toolkit/components/passwordmgr/nsLoginManager.js +++ b/toolkit/components/passwordmgr/nsLoginManager.js @@ -485,14 +485,17 @@ LoginManager.prototype = { let form = LoginFormFactory.createFromField(aElement); let isSecure = InsecurePasswordUtils.isFormSecure(form); let isPasswordField = aElement.type == "password"; - if (isPasswordField) { - // The login items won't be filtered for password field. - aSearchString = ""; + if (isPasswordField && aSearchString) { + // Return empty result on password fields with password already filled. + setTimeout(function() { + aCallback.onSearchCompletion(new UserAutoCompleteResult(aSearchString, [], {isSecure, isPasswordField})); + }, 0); + return; } if (!this._remember) { setTimeout(function() { - aCallback.onSearchCompletion(new UserAutoCompleteResult(aSearchString, [], {isSecure})); + aCallback.onSearchCompletion(new UserAutoCompleteResult(aSearchString, [], {isSecure, isPasswordField})); }, 0); return; } From 87d622dd83a852f2672ac3e6d774d62ba1a631b4 Mon Sep 17 00:00:00 2001 From: Milan Sreckovic Date: Thu, 1 Dec 2016 15:14:42 -0500 Subject: [PATCH 10/64] Bug 1321630: Allow remote desktop (RDP) acceleration on window versions higher than 8. r=vlad MozReview-Commit-ID: 964xgsCIxij --HG-- extra : rebase_source : f5553124e2730ea8cc9296f9551762dd8eef90a4 --- widget/windows/GfxInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widget/windows/GfxInfo.cpp b/widget/windows/GfxInfo.cpp index 544e2700bd90..0a21811e472c 100644 --- a/widget/windows/GfxInfo.cpp +++ b/widget/windows/GfxInfo.cpp @@ -338,7 +338,7 @@ GfxInfo::Init() // Unfortunately, the Device ID is nullptr, and we can't enumerate // it using the setup infrastructure (SetupDiGetClassDevsW below // will return INVALID_HANDLE_VALUE). - if (mWindowsVersion == kWindows8 && + if (mWindowsVersion >= kWindows8 && mDeviceID.Length() == 0 && mDeviceString.EqualsLiteral("RDPUDD Chained DD")) { From 0510cb3db25785171b33653856966bb369472dff Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Thu, 8 Dec 2016 10:39:36 -1000 Subject: [PATCH 11/64] bug 1322120 use text node for field and selected colors r=stransky+263117 This adjustment is required for changes to MOZ_GTK_TEXT_VIEW in a6aabcb07a6e. MOZ_GTK_TEXT_VIEW_TEXT now retrieves the equivalent node from WidgetStyleCache. MozReview-Commit-ID: 2zfHCKMT0ov --HG-- extra : rebase_source : 39edee068f44cf9d2f6cccffc89dcd7c2c2616d5 --- widget/gtk/nsLookAndFeel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widget/gtk/nsLookAndFeel.cpp b/widget/gtk/nsLookAndFeel.cpp index 13f79db2422a..a6766f23811a 100644 --- a/widget/gtk/nsLookAndFeel.cpp +++ b/widget/gtk/nsLookAndFeel.cpp @@ -1284,7 +1284,7 @@ nsLookAndFeel::Init() } #else // Text colors - style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW); + style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW_TEXT); gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color); sMozFieldBackground = GDK_RGBA_TO_NS_RGBA(color); gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color); From 6820dcff6dee924f7e5dbc0e445a65627e3752ac Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Thu, 15 Dec 2016 14:33:31 -0800 Subject: [PATCH 12/64] Backed out changeset 57ab844a366f (bug 1142312) for robocop bustage a=backout --- toolkit/components/reader/Readability.js | 44 ++++++++---------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/toolkit/components/reader/Readability.js b/toolkit/components/reader/Readability.js index 4705d8dc42a8..99ae6f874f83 100644 --- a/toolkit/components/reader/Readability.js +++ b/toolkit/components/reader/Readability.js @@ -119,7 +119,7 @@ Readability.prototype = { // All of the regular expressions in use within readability. // Defined up here so we don't instantiate them repeatedly in loops. REGEXPS: { - unlikelyCandidates: /banner|combx|comment|community|cover-wrap|disqus|extra|foot|header|legends|menu|modal|related|remark|rss|shoutbox|sidebar|skyscraper|sponsor|ad-break|agegate|pagination|pager|popup|yom-remote/i, + unlikelyCandidates: /banner|combx|comment|community|disqus|extra|foot|header|legends|menu|modal|related|remark|rss|shoutbox|sidebar|skyscraper|sponsor|ad-break|agegate|pagination|pager|popup/i, okMaybeItsACandidate: /and|article|body|column|main|shadow/i, positive: /article|body|content|entry|hentry|h-entry|main|page|pagination|post|text|blog|story/i, negative: /hidden|^hid$| hid$| hid |^hid |banner|combx|comment|com-|contact|foot|footer|footnote|masthead|media|meta|modal|outbrain|promo|related|scroll|share|shoutbox|sidebar|skyscraper|sponsor|shopping|tags|tool|widget/i, @@ -155,8 +155,8 @@ Readability.prototype = { * * If function is not passed, removes all the nodes in node list. * - * @param NodeList nodeList The nodes to operate on - * @param Function filterFn the function to use as a filter + * @param NodeList nodeList The no + * @param Function filterFn * @return void */ _removeNodes: function(nodeList, filterFn) { @@ -171,20 +171,6 @@ Readability.prototype = { } }, - /** - * Iterates over a NodeList, and calls _setNodeTag for each node. - * - * @param NodeList nodeList The nodes to operate on - * @param String newTagName the new tag name to use - * @return void - */ - _replaceNodeTags: function(nodeList, newTagName) { - for (var i = nodeList.length - 1; i >= 0; i--) { - var node = nodeList[i]; - this._setNodeTag(node, newTagName); - } - }, - /** * Iterate over a NodeList, which doesn't natively fully implement the Array * interface. @@ -194,9 +180,10 @@ Readability.prototype = { * * @param NodeList nodeList The NodeList. * @param Function fn The iterate function. + * @param Boolean backward Whether to use backward iteration. * @return void */ - _forEachNode: function(nodeList, fn) { + _forEachNode: function(nodeList, fn, backward) { Array.prototype.forEach.call(nodeList, fn, this); }, @@ -375,7 +362,9 @@ Readability.prototype = { this._replaceBrs(doc.body); } - this._replaceNodeTags(doc.getElementsByTagName("font"), "SPAN"); + this._forEachNode(doc.getElementsByTagName("font"), function(fontNode) { + this._setNodeTag(fontNode, "SPAN"); + }); }, /** @@ -1073,15 +1062,12 @@ Readability.prototype = { metadata.excerpt = values["twitter:description"]; } - metadata.title = this._getArticleTitle(); - if (!metadata.title) { - if ("og:title" in values) { - // Use facebook open graph title. - metadata.title = values["og:title"]; - } else if ("twitter:title" in values) { - // Use twitter cards title. - metadata.title = values["twitter:title"]; - } + if ("og:title" in values) { + // Use facebook open graph title. + metadata.title = values["og:title"]; + } else if ("twitter:title" in values) { + // Use twitter cards title. + metadata.title = values["twitter:title"]; } return metadata; @@ -1871,7 +1857,7 @@ Readability.prototype = { this._prepDocument(); var metadata = this._getArticleMetadata(); - var articleTitle = metadata.title; + var articleTitle = metadata.title || this._getArticleTitle(); var articleContent = this._grabArticle(); if (!articleContent) From 36952d2ae06c7baf01d69acce9bc7da3ae76c436 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 15 Dec 2016 13:40:06 -0800 Subject: [PATCH 13/64] Bug 1283898 - Don't check for rust outside of toolkit builds. r=rillian Spidermonkey doesn't currently depend on rust code, and this unblocks enabling rust by default on gecko builds until we can get the appropriate toolchain hooked up to all of the SM automation jobs. The include must be conditional to avoid breaking artifact builds. MozReview-Commit-ID: 1PmcFvcZLM2 --HG-- extra : rebase_source : 1a22232e064dd253b80ebaa55decfde1ba7e1ea0 --- build/moz.configure/toolchain.configure | 1 - toolkit/moz.configure | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index 765e0b0e8863..cc90f6517a95 100644 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -972,4 +972,3 @@ def is_windows(target): return target.kernel == 'WINNT' include('windows.configure', when=is_windows) -include('rust.configure') diff --git a/toolkit/moz.configure b/toolkit/moz.configure index e94dd3cc52c4..08522120bdd5 100644 --- a/toolkit/moz.configure +++ b/toolkit/moz.configure @@ -86,6 +86,12 @@ set_define('MOZ_JACK', jack) include('../js/moz.configure') +# Rust +# ============================================================== +include('../build/moz.configure/rust.configure', + when='--enable-compile-environment') + + # L10N # ============================================================== option('--with-l10n-base', nargs=1, env='L10NBASEDIR', From e022c25cf8932968a6c238f805df7e1f2a401a31 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Thu, 15 Dec 2016 14:30:36 +0000 Subject: [PATCH 14/64] Bug 1322726 - add UITour API to support opening about:newtab in the current tab, r=MattN When running the tests by dir, I noticed the tracking protection test requires extra files to work, but don't list those, so I fixed that. MozReview-Commit-ID: FUi8XQImvbI --HG-- extra : rebase_source : 22cda58541764b624b9d75fbe0fd76275203aa18 --- browser/components/uitour/UITour-lib.js | 4 ++++ browser/components/uitour/UITour.jsm | 9 +++++++++ browser/components/uitour/test/browser.ini | 4 ++++ .../uitour/test/browser_UITour_showNewTab.js | 17 +++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 browser/components/uitour/test/browser_UITour_showNewTab.js diff --git a/browser/components/uitour/UITour-lib.js b/browser/components/uitour/UITour-lib.js index a0f782f24d7b..40c1a82b4d99 100644 --- a/browser/components/uitour/UITour-lib.js +++ b/browser/components/uitour/UITour-lib.js @@ -220,6 +220,10 @@ if (typeof Mozilla == 'undefined') { }); }; + Mozilla.UITour.showNewTab = function() { + _sendEvent('showNewTab'); + }; + Mozilla.UITour.getConfiguration = function(configName, callback) { _sendEvent('getConfiguration', { callbackID: _waitForCallback(callback), diff --git a/browser/components/uitour/UITour.jsm b/browser/components/uitour/UITour.jsm index cd4e1743438b..2e25fdd458f4 100644 --- a/browser/components/uitour/UITour.jsm +++ b/browser/components/uitour/UITour.jsm @@ -527,6 +527,11 @@ this.UITour = { break; } + case "showNewTab": { + this.showNewTab(window, browser); + break; + } + case "getConfiguration": { if (typeof data.configuration != "string") { log.warn("getConfiguration: No configuration option specified"); @@ -1744,6 +1749,10 @@ this.UITour = { } }, + showNewTab: function(aWindow, aBrowser) { + aWindow.openLinkIn("about:newtab", "current", {targetBrowser: aBrowser}); + }, + hideAnnotationsForPanel: function(aEvent, aTargetPositionCallback) { let win = aEvent.target.ownerGlobal; let annotationElements = new Map([ diff --git a/browser/components/uitour/test/browser.ini b/browser/components/uitour/test/browser.ini index fd1205d45d05..ae027a738a90 100644 --- a/browser/components/uitour/test/browser.ini +++ b/browser/components/uitour/test/browser.ini @@ -16,6 +16,9 @@ skip-if = true # Bug 1113038 - Intermittent "Popup was opened" [browser_trackingProtection.js] skip-if = os == "linux" # Intermittent NS_ERROR_NOT_AVAILABLE [nsIUrlClassifierDBService.beginUpdate] tag = trackingprotection +support-files = + !/browser/base/content/test/general/benignPage.html + !/browser/base/content/test/general/trackingPage.html [browser_trackingProtection_tour.js] tag = trackingprotection [browser_showMenu_controlCenter.js] @@ -41,5 +44,6 @@ skip-if = true # Disabled due to frequent failures, bugs 1026310 and 1032137 skip-if = true # Disabled pending removal of pocket UI Tour [browser_UITour_registerPageID.js] [browser_UITour_resetProfile.js] +[browser_UITour_showNewTab.js] [browser_UITour_sync.js] [browser_UITour_toggleReaderMode.js] diff --git a/browser/components/uitour/test/browser_UITour_showNewTab.js b/browser/components/uitour/test/browser_UITour_showNewTab.js new file mode 100644 index 000000000000..2deb08148aca --- /dev/null +++ b/browser/components/uitour/test/browser_UITour_showNewTab.js @@ -0,0 +1,17 @@ +"use strict"; + +var gTestTab; +var gContentAPI; +var gContentWindow; + +add_task(setup_UITourTest); + +// Test that we can switch to about:newtab +add_UITour_task(function* test_aboutNewTab() { + let newTabLoaded = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, "about:newtab"); + info("Showing about:newtab"); + yield gContentAPI.showNewTab(); + info("Waiting for about:newtab to load"); + yield newTabLoaded; + is(gBrowser.selectedBrowser.currentURI.spec, "about:newtab", "Loaded about:newtab"); +}); From 0b983f77d20c608c6236698df238d54ea738375f Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Thu, 15 Dec 2016 15:24:13 -0800 Subject: [PATCH 15/64] Backed out changeset a41f5558f860 (bug 1318203) for browser-chrome-3 bustage a=backout --- toolkit/components/passwordmgr/nsLoginManager.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/toolkit/components/passwordmgr/nsLoginManager.js b/toolkit/components/passwordmgr/nsLoginManager.js index f5bfe1d64b35..4ef29f88fc39 100644 --- a/toolkit/components/passwordmgr/nsLoginManager.js +++ b/toolkit/components/passwordmgr/nsLoginManager.js @@ -485,17 +485,14 @@ LoginManager.prototype = { let form = LoginFormFactory.createFromField(aElement); let isSecure = InsecurePasswordUtils.isFormSecure(form); let isPasswordField = aElement.type == "password"; - if (isPasswordField && aSearchString) { - // Return empty result on password fields with password already filled. - setTimeout(function() { - aCallback.onSearchCompletion(new UserAutoCompleteResult(aSearchString, [], {isSecure, isPasswordField})); - }, 0); - return; + if (isPasswordField) { + // The login items won't be filtered for password field. + aSearchString = ""; } if (!this._remember) { setTimeout(function() { - aCallback.onSearchCompletion(new UserAutoCompleteResult(aSearchString, [], {isSecure, isPasswordField})); + aCallback.onSearchCompletion(new UserAutoCompleteResult(aSearchString, [], {isSecure})); }, 0); return; } From f97b3eef3b313e5964ba5d9bf83a0b51fc821f2c Mon Sep 17 00:00:00 2001 From: Kit Cambridge Date: Wed, 7 Dec 2016 11:46:36 -1000 Subject: [PATCH 16/64] Bug 1322408 - Use `gBrowser.loadTabs` to open all tabs when middle-clicking a client in Synced Tabs. r=markh MozReview-Commit-ID: 6phgHjAAXUs --HG-- extra : rebase_source : 44260c7a8f407c1efa869912e6407e81e68fb2eb --- .../syncedtabs/SyncedTabsDeckComponent.js | 1 + .../components/syncedtabs/TabListComponent.js | 11 +++++---- browser/components/syncedtabs/TabListView.js | 2 +- .../test/xpcshell/test_TabListComponent.js | 23 +++++++++++++------ 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/browser/components/syncedtabs/SyncedTabsDeckComponent.js b/browser/components/syncedtabs/SyncedTabsDeckComponent.js index d9d93da75d2f..dfbec056ca0b 100644 --- a/browser/components/syncedtabs/SyncedTabsDeckComponent.js +++ b/browser/components/syncedtabs/SyncedTabsDeckComponent.js @@ -52,6 +52,7 @@ function SyncedTabsDeckComponent({ SyncedTabs: SyncedTabs, clipboardHelper: Cc["@mozilla.org/widget/clipboardhelper;1"] .getService(Ci.nsIClipboardHelper), + getChromeWindow: this._getChromeWindow, }); } diff --git a/browser/components/syncedtabs/TabListComponent.js b/browser/components/syncedtabs/TabListComponent.js index 08269a4131f5..d3aace8f9ced 100644 --- a/browser/components/syncedtabs/TabListComponent.js +++ b/browser/components/syncedtabs/TabListComponent.js @@ -29,11 +29,13 @@ this.EXPORTED_SYMBOLS = [ * to state changes so it can rerender. */ -function TabListComponent({window, store, View, SyncedTabs, clipboardHelper}) { +function TabListComponent({window, store, View, SyncedTabs, clipboardHelper, + getChromeWindow}) { this._window = window; this._store = store; this._View = View; this._clipboardHelper = clipboardHelper; + this._getChromeWindow = getChromeWindow; // used to trigger Sync from context menu this._SyncedTabs = SyncedTabs; } @@ -116,7 +118,7 @@ TabListComponent.prototype = { BrowserUITelemetry.countSyncedTabEvent("open", "sidebar"); }, - onOpenTabs(urls, where, params) { + onOpenTabs(urls, where) { if (!PlacesUIUtils.confirmOpenInTabs(urls.length, this._window)) { return; } @@ -124,9 +126,8 @@ TabListComponent.prototype = { this._window.openDialog(this._window.getBrowserURL(), "_blank", "chrome,dialog=no,all", urls.join("|")); } else { - for (let url of urls) { - this._window.openUILinkIn(url, where, params); - } + let loadInBackground = where == "tabshifted" ? true : false; + this._getChromeWindow(this._window).gBrowser.loadTabs(urls, loadInBackground, false); } BrowserUITelemetry.countSyncedTabEvent("openmultiple", "sidebar"); }, diff --git a/browser/components/syncedtabs/TabListView.js b/browser/components/syncedtabs/TabListView.js index 31d04d4f945d..dab15101bf83 100644 --- a/browser/components/syncedtabs/TabListView.js +++ b/browser/components/syncedtabs/TabListView.js @@ -289,7 +289,7 @@ TabListView.prototype = { if (where != "current") { const tabs = itemNode.querySelector(".item-tabs-list").childNodes; const urls = [...tabs].map(tab => tab.dataset.url); - this.props.onOpenTabs(urls, where, {}); + this.props.onOpenTabs(urls, where); } } diff --git a/browser/components/syncedtabs/test/xpcshell/test_TabListComponent.js b/browser/components/syncedtabs/test/xpcshell/test_TabListComponent.js index 4a8951f9a189..0b0665a1b3de 100644 --- a/browser/components/syncedtabs/test/xpcshell/test_TabListComponent.js +++ b/browser/components/syncedtabs/test/xpcshell/test_TabListComponent.js @@ -68,6 +68,13 @@ add_task(function* testInitUninit() { add_task(function* testActions() { let store = new SyncedTabsListStore(); + let chromeWindowMock = { + gBrowser: { + loadTabs() {}, + }, + }; + let getChromeWindowMock = sinon.stub(); + getChromeWindowMock.returns(chromeWindowMock); let clipboardHelperMock = { copyString() {}, }; @@ -84,7 +91,8 @@ add_task(function* testActions() { }; let component = new TabListComponent({ window: windowMock, store, View: null, SyncedTabs, - clipboardHelper: clipboardHelperMock}); + clipboardHelper: clipboardHelperMock, + getChromeWindow: getChromeWindowMock }); sinon.stub(store, "getData"); component.onFilter("query"); @@ -127,12 +135,13 @@ add_task(function* testActions() { component.onOpenTab("uri", "where", "params"); Assert.ok(windowMock.openUILinkIn.calledWith("uri", "where", "params")); - component.onOpenTabs(["uri1", "uri2"], "where", "params"); - Assert.ok(windowMock.openUILinkIn.calledWith("uri1", "where", "params")); - Assert.ok(windowMock.openUILinkIn.calledWith("uri2", "where", "params")); - sinon.spy(windowMock, "openDialog"); - component.onOpenTabs(["uri1", "uri2"], "window", "params"); - Assert.deepEqual(windowMock.openDialog.args[0][3], ["uri1", "uri2"].join("|")); + sinon.spy(chromeWindowMock.gBrowser, "loadTabs"); + let tabsToOpen = ["uri1", "uri2"]; + component.onOpenTabs(tabsToOpen, "where"); + Assert.ok(getChromeWindowMock.calledWith(windowMock)); + Assert.ok(chromeWindowMock.gBrowser.loadTabs.calledWith(tabsToOpen, false, false)); + component.onOpenTabs(tabsToOpen, "tabshifted"); + Assert.ok(chromeWindowMock.gBrowser.loadTabs.calledWith(tabsToOpen, true, false)); sinon.spy(clipboardHelperMock, "copyString"); component.onCopyTabLocation("uri"); From 554abfa33e77b0bd90c2d2a6200d031bc309ff2b Mon Sep 17 00:00:00 2001 From: John Lin Date: Thu, 15 Dec 2016 18:10:14 +0800 Subject: [PATCH 17/64] Bug 1323687 - re-query output buffers after format change. r=esawin MozReview-Commit-ID: 8L1MH3ODU8d --HG-- extra : rebase_source : 9269938ff6495a392aaa3fa3e2fc7d5705c0aac4 --- .../base/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java | 1 + 1 file changed, 1 insertion(+) diff --git a/mobile/android/base/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java b/mobile/android/base/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java index d2e7f28fa118..fc7f286952a2 100644 --- a/mobile/android/base/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java +++ b/mobile/android/base/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java @@ -233,6 +233,7 @@ final class JellyBeanAsyncCodec implements AsyncCodec { } else if (result == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) { mOutputBuffers = mCodec.getOutputBuffers(); } else if (result == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) { + mOutputBuffers = mCodec.getOutputBuffers(); mCallbackSender.notifyOutputFormat(mCodec.getOutputFormat()); } else if (result == MediaCodec.INFO_TRY_AGAIN_LATER) { // When input ended, keep polling remaining output buffer until EOS. From c2a23d7e570c40941a05f5519c1ab920fdd75f80 Mon Sep 17 00:00:00 2001 From: Ricky Chien Date: Tue, 22 Nov 2016 21:59:12 +0800 Subject: [PATCH 18/64] Bug 1317659 - Implement Preview Panel r=Honza,jsnajdr MozReview-Commit-ID: G9vmDrz97pR --HG-- extra : rebase_source : 57d3a35f6432be990288e85c2edb39c033ff402a --- .../netmonitor/components/filter-buttons.js | 2 +- devtools/client/netmonitor/details-view.js | 37 ++++------------ devtools/client/netmonitor/events.js | 3 -- devtools/client/netmonitor/netmonitor.xul | 5 +-- .../client/netmonitor/requests-menu-view.js | 17 +++++-- .../netmonitor/shared/components/moz.build | 1 + .../shared/components/preview-panel.js | 44 +++++++++++++++++++ .../test/browser_net_html-preview.js | 3 +- devtools/client/themes/netmonitor.css | 3 ++ 9 files changed, 76 insertions(+), 39 deletions(-) create mode 100644 devtools/client/netmonitor/shared/components/preview-panel.js diff --git a/devtools/client/netmonitor/components/filter-buttons.js b/devtools/client/netmonitor/components/filter-buttons.js index 26c9d0ca10eb..45b348e38d48 100644 --- a/devtools/client/netmonitor/components/filter-buttons.js +++ b/devtools/client/netmonitor/components/filter-buttons.js @@ -31,7 +31,7 @@ function FilterButtons({ return div({ id: "requests-menu-filter-buttons" }, buttons); } -FilterButtons.PropTypes = { +FilterButtons.propTypes = { state: PropTypes.object.isRequired, triggerFilterType: PropTypes.func.iRequired, }; diff --git a/devtools/client/netmonitor/details-view.js b/devtools/client/netmonitor/details-view.js index 77fa5a33d870..03c52ce9818b 100644 --- a/devtools/client/netmonitor/details-view.js +++ b/devtools/client/netmonitor/details-view.js @@ -29,6 +29,7 @@ const { const { createFactory } = require("devtools/client/shared/vendor/react"); const ReactDOM = require("devtools/client/shared/vendor/react-dom"); const Provider = createFactory(require("devtools/client/shared/vendor/react-redux").Provider); +const PreviewPanel = createFactory(require("./shared/components/preview-panel")); const SecurityPanel = createFactory(require("./shared/components/security-panel")); const TimingsPanel = createFactory(require("./shared/components/timings-panel")); @@ -93,6 +94,13 @@ DetailsView.prototype = { initialize: function (store) { dumpn("Initializing the DetailsView"); + this._previewPanelNode = $("#react-preview-tabpanel-hook"); + + ReactDOM.render(Provider( + { store }, + PreviewPanel() + ), this._previewPanelNode); + this._securityPanelNode = $("#react-security-tabpanel-hook"); ReactDOM.render(Provider( @@ -152,6 +160,7 @@ DetailsView.prototype = { */ destroy: function () { dumpn("Destroying the DetailsView"); + ReactDOM.unmountComponentAtNode(this._previewPanelNode); ReactDOM.unmountComponentAtNode(this._securityPanelNode); ReactDOM.unmountComponentAtNode(this._timingsPanelNode); this.sidebar.destroy(); @@ -263,10 +272,6 @@ DetailsView.prototype = { case 3: yield view._setResponseBody(src.url, src.responseContent); break; - // "Preview" - case 6: - yield view._setHtmlPreview(src.responseContent); - break; } viewState.updating[tab] = false; }).then(() => { @@ -697,30 +702,6 @@ DetailsView.prototype = { window.emit(EVENTS.RESPONSE_BODY_DISPLAYED); }), - /** - * Sets the preview for HTML responses shown in this view. - * - * @param object response - * The message received from the server. - * @return object - * A promise that is resolved when the html preview is rendered. - */ - _setHtmlPreview: Task.async(function* (response) { - if (!response) { - return promise.resolve(); - } - let { text } = response.content; - let responseBody = yield gNetwork.getString(text); - - // Always disable JS when previewing HTML responses. - let iframe = $("#response-preview"); - iframe.contentDocument.docShell.allowJavascript = false; - iframe.contentDocument.documentElement.innerHTML = responseBody; - - window.emit(EVENTS.RESPONSE_HTML_PREVIEW_DISPLAYED); - return undefined; - }), - _dataSrc: null, _headers: null, _cookies: null, diff --git a/devtools/client/netmonitor/events.js b/devtools/client/netmonitor/events.js index ce77365047de..e0a5eb98f90d 100644 --- a/devtools/client/netmonitor/events.js +++ b/devtools/client/netmonitor/events.js @@ -58,9 +58,6 @@ const EVENTS = { // When the response body is displayed in the UI. RESPONSE_BODY_DISPLAYED: "NetMonitor:ResponseBodyAvailable", - // When the html response preview is displayed in the UI. - RESPONSE_HTML_PREVIEW_DISPLAYED: "NetMonitor:ResponseHtmlPreviewAvailable", - // When the image response thumbnail is displayed in the UI. RESPONSE_IMAGE_THUMBNAIL_DISPLAYED: "NetMonitor:ResponseImageThumbnailAvailable", diff --git a/devtools/client/netmonitor/netmonitor.xul b/devtools/client/netmonitor/netmonitor.xul index 3d0f5ace3fb8..a16e26abde8d 100644 --- a/devtools/client/netmonitor/netmonitor.xul +++ b/devtools/client/netmonitor/netmonitor.xul @@ -272,9 +272,8 @@ - + diff --git a/devtools/client/netmonitor/requests-menu-view.js b/devtools/client/netmonitor/requests-menu-view.js index aa37d4704f61..dd74f2050c2a 100644 --- a/devtools/client/netmonitor/requests-menu-view.js +++ b/devtools/client/netmonitor/requests-menu-view.js @@ -210,15 +210,16 @@ RequestsMenuView.prototype = { const action = Actions.updateRequest(id, data, true); yield this.store.dispatch(action); - const { responseContent, requestPostData } = action.data; + let { responseContent, requestPostData } = action.data; - // Fetch response data if the response is an image (to display thumbnail) if (responseContent && responseContent.content) { let request = getRequestById(this.store.getState(), action.id); + let { text, encoding } = responseContent.content; if (request) { let { mimeType } = request; + + // Fetch response data if the response is an image (to display thumbnail) if (mimeType.includes("image/")) { - let { text, encoding } = responseContent.content; let responseBody = yield gNetwork.getString(text); const dataUri = formDataURI(mimeType, encoding, responseBody); yield this.store.dispatch(Actions.updateRequest( @@ -227,6 +228,16 @@ RequestsMenuView.prototype = { true )); window.emit(EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED); + // Fetch response text only if the response is html, but not all text/* + } else if (mimeType.includes("text/html") && typeof text !== "string") { + let responseBody = yield gNetwork.getString(text); + responseContent.content.text = responseBody; + responseContent = Object.assign({}, responseContent); + yield this.store.dispatch(Actions.updateRequest( + action.id, + { responseContent }, + true + )); } } } diff --git a/devtools/client/netmonitor/shared/components/moz.build b/devtools/client/netmonitor/shared/components/moz.build index 2c7ccfea5118..8d6644af7b7b 100644 --- a/devtools/client/netmonitor/shared/components/moz.build +++ b/devtools/client/netmonitor/shared/components/moz.build @@ -3,6 +3,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. DevToolsModules( + 'preview-panel.js', 'security-panel.js', 'timings-panel.js', ) diff --git a/devtools/client/netmonitor/shared/components/preview-panel.js b/devtools/client/netmonitor/shared/components/preview-panel.js new file mode 100644 index 000000000000..a7e646572f8d --- /dev/null +++ b/devtools/client/netmonitor/shared/components/preview-panel.js @@ -0,0 +1,44 @@ +/* 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"; + +const { DOM, PropTypes } = require("devtools/client/shared/vendor/react"); +const { connect } = require("devtools/client/shared/vendor/react-redux"); +const { getSelectedRequest } = require("../../selectors/index"); + +const { iframe } = DOM; + +/* + * Preview panel component + * Display HTML content within a sandbox enabled iframe + */ +function PreviewPanel({ + srcDoc = "", +}) { + return iframe({ + id: "response-preview", + sandbox: "", + srcDoc, + }); +} + +PreviewPanel.displayName = "PreviewPanel"; + +PreviewPanel.propTypes = { + srcDoc: PropTypes.string, +}; + +module.exports = connect( + (state) => { + const selectedRequest = getSelectedRequest(state); + const htmlBody = selectedRequest && selectedRequest.responseContent ? + selectedRequest.responseContent.content.text : ""; + const srcDoc = typeof htmlBody === "string" ? htmlBody : ""; + + return { + srcDoc, + }; + } +)(PreviewPanel); diff --git a/devtools/client/netmonitor/test/browser_net_html-preview.js b/devtools/client/netmonitor/test/browser_net_html-preview.js index 351009de561a..ea0492a8d959 100644 --- a/devtools/client/netmonitor/test/browser_net_html-preview.js +++ b/devtools/client/netmonitor/test/browser_net_html-preview.js @@ -40,8 +40,9 @@ add_task(function* () { is($("#preview-tab").hidden, false, "The preview tab should be visible now."); - yield monitor.panelWin.once(EVENTS.RESPONSE_HTML_PREVIEW_DISPLAYED); let iframe = $("#response-preview"); + yield once(iframe, "DOMContentLoaded"); + ok(iframe, "There should be a response preview iframe available."); ok(iframe.contentDocument, diff --git a/devtools/client/themes/netmonitor.css b/devtools/client/themes/netmonitor.css index aafb6b16ed63..a5745dda16ca 100644 --- a/devtools/client/themes/netmonitor.css +++ b/devtools/client/themes/netmonitor.css @@ -742,7 +742,9 @@ } #response-preview { + border: none; display: -moz-box; + -moz-box-orient: vertical; -moz-box-flex: 1; } @@ -1138,6 +1140,7 @@ * FIXME: normal html block element cannot fill outer XUL element * This workaround should be removed after sidebar is migrated to react */ +#react-preview-tabpanel-hook, #react-security-tabpanel-hook, #react-timings-tabpanel-hook { display: -moz-box; From 4f285bd583bf94abf700b31874638f4c838dae22 Mon Sep 17 00:00:00 2001 From: Ting-Yu Chou Date: Wed, 14 Dec 2016 16:34:12 +0800 Subject: [PATCH 19/64] Bug 1322458 - Fix kungFuDeathGrip errors that clang plugin reports on Windows. r=aklotz,Ehsan MozReview-Commit-ID: FLTLZSg2yh9 --HG-- extra : rebase_source : e8aad8f35cffb3312e043a4fcec6296371baf432 --- gfx/layers/d3d9/CompositorD3D9.cpp | 1 + ipc/mscom/EnsureMTA.h | 2 ++ ipc/mscom/WeakRef.cpp | 2 +- widget/windows/TSFTextStore.cpp | 20 ++++++++++---------- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/gfx/layers/d3d9/CompositorD3D9.cpp b/gfx/layers/d3d9/CompositorD3D9.cpp index 0f7e942c18ff..cf38bae12c8b 100644 --- a/gfx/layers/d3d9/CompositorD3D9.cpp +++ b/gfx/layers/d3d9/CompositorD3D9.cpp @@ -215,6 +215,7 @@ CompositorD3D9::SetRenderTarget(CompositingRenderTarget *aRenderTarget) { MOZ_ASSERT(aRenderTarget && mDeviceManager); RefPtr oldRT = mCurrentRT; + Unused << oldRT; mCurrentRT = static_cast(aRenderTarget); mCurrentRT->BindRenderTarget(device()); PrepareViewport(mCurrentRT->GetSize()); diff --git a/ipc/mscom/EnsureMTA.h b/ipc/mscom/EnsureMTA.h index d5ae2a7a5a04..4cf667038747 100644 --- a/ipc/mscom/EnsureMTA.h +++ b/ipc/mscom/EnsureMTA.h @@ -10,6 +10,7 @@ #include "MainThreadUtils.h" #include "mozilla/Attributes.h" #include "mozilla/DebugOnly.h" +#include "mozilla/Unused.h" #include "mozilla/mscom/COMApartmentRegion.h" #include "mozilla/mscom/Utils.h" #include "nsCOMPtr.h" @@ -33,6 +34,7 @@ public: MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr thread = GetMTAThread(); MOZ_ASSERT(thread); + Unused << thread; } template diff --git a/ipc/mscom/WeakRef.cpp b/ipc/mscom/WeakRef.cpp index e44027059d7b..26fd0810feb4 100644 --- a/ipc/mscom/WeakRef.cpp +++ b/ipc/mscom/WeakRef.cpp @@ -40,7 +40,7 @@ WeakReferenceSupport::QueryInterface(REFIID riid, void** ppv) *ppv = nullptr; // Raise the refcount for stabilization purposes during aggregation - RefPtr kungFuDeathGrip(static_cast(this)); + RefPtr kungFuDeathGrip(this); if (riid == IID_IUnknown || riid == IID_IWeakReferenceSource) { punk = static_cast(this); diff --git a/widget/windows/TSFTextStore.cpp b/widget/windows/TSFTextStore.cpp index 2b3ed2a43fd9..ebcfea9d8170 100644 --- a/widget/windows/TSFTextStore.cpp +++ b/widget/windows/TSFTextStore.cpp @@ -1719,7 +1719,7 @@ TSFTextStore::FlushPendingActions() return; } - RefPtr kungFuDeathGrip(mWidget); + RefPtr widget(mWidget); nsresult rv = mDispatcher->BeginNativeInputTransaction(); if (NS_WARN_IF(NS_FAILED(rv))) { MOZ_LOG(sTextStoreLog, LogLevel::Error, @@ -1748,8 +1748,8 @@ TSFTextStore::FlushPendingActions() if (action.mAdjustSelection) { // Select composition range so the new composition replaces the range - WidgetSelectionEvent selectionSet(true, eSetSelection, mWidget); - mWidget->InitEvent(selectionSet); + WidgetSelectionEvent selectionSet(true, eSetSelection, widget); + widget->InitEvent(selectionSet); selectionSet.mOffset = static_cast(action.mSelectionStart); selectionSet.mLength = static_cast(action.mSelectionLength); selectionSet.mReversed = false; @@ -1770,7 +1770,7 @@ TSFTextStore::FlushPendingActions() MOZ_LOG(sTextStoreLog, LogLevel::Debug, ("0x%p TSFTextStore::FlushPendingActions() " "dispatching compositionstart event...", this)); - WidgetEventTime eventTime = mWidget->CurrentMessageWidgetEventTime(); + WidgetEventTime eventTime = widget->CurrentMessageWidgetEventTime(); nsEventStatus status; rv = mDispatcher->StartComposition(status, &eventTime); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -1781,7 +1781,7 @@ TSFTextStore::FlushPendingActions() this, GetBoolName(!IsComposingInContent()))); mDeferClearingContentForTSF = !IsComposingInContent(); } - if (!mWidget || mWidget->Destroyed()) { + if (!widget || widget->Destroyed()) { break; } break; @@ -1814,7 +1814,7 @@ TSFTextStore::FlushPendingActions() MOZ_LOG(sTextStoreLog, LogLevel::Debug, ("0x%p TSFTextStore::FlushPendingActions() " "dispatching compositionchange event...", this)); - WidgetEventTime eventTime = mWidget->CurrentMessageWidgetEventTime(); + WidgetEventTime eventTime = widget->CurrentMessageWidgetEventTime(); nsEventStatus status; rv = mDispatcher->FlushPendingComposition(status, &eventTime); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -1844,7 +1844,7 @@ TSFTextStore::FlushPendingActions() MOZ_LOG(sTextStoreLog, LogLevel::Debug, ("0x%p TSFTextStore::FlushPendingActions(), " "dispatching compositioncommit event...", this)); - WidgetEventTime eventTime = mWidget->CurrentMessageWidgetEventTime(); + WidgetEventTime eventTime = widget->CurrentMessageWidgetEventTime(); nsEventStatus status; rv = mDispatcher->CommitComposition(status, &action.mData, &eventTime); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -1875,8 +1875,8 @@ TSFTextStore::FlushPendingActions() break; } - WidgetSelectionEvent selectionSet(true, eSetSelection, mWidget); - selectionSet.mOffset = + WidgetSelectionEvent selectionSet(true, eSetSelection, widget); + selectionSet.mOffset = static_cast(action.mSelectionStart); selectionSet.mLength = static_cast(action.mSelectionLength); @@ -1887,7 +1887,7 @@ TSFTextStore::FlushPendingActions() MOZ_CRASH("unexpected action type"); } - if (mWidget && !mWidget->Destroyed()) { + if (widget && !widget->Destroyed()) { continue; } From d9cd33f4056d2df3f53a93692eb319086318dbf7 Mon Sep 17 00:00:00 2001 From: Scott Wu Date: Thu, 1 Dec 2016 16:45:16 +0800 Subject: [PATCH 20/64] Bug 1323109 - Fixed date time pickers popup position; r=mconley MozReview-Commit-ID: DuY4ZVyszBE --HG-- extra : rebase_source : 68e42287c3526bffd5785c20ffd3c12ab3a7fe0b --- toolkit/content/widgets/datetimepopup.xml | 3 +++ toolkit/modules/DateTimePickerHelper.jsm | 2 +- toolkit/themes/shared/datetimepopup.css | 11 +++++++++++ toolkit/themes/shared/jar.inc.mn | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 toolkit/themes/shared/datetimepopup.css diff --git a/toolkit/content/widgets/datetimepopup.xml b/toolkit/content/widgets/datetimepopup.xml index 327f453684c1..69edffe259de 100644 --- a/toolkit/content/widgets/datetimepopup.xml +++ b/toolkit/content/widgets/datetimepopup.xml @@ -11,6 +11,9 @@ xmlns:xbl="http://www.mozilla.org/xbl"> + + + this.querySelector("#dateTimePopupFrame"); diff --git a/toolkit/modules/DateTimePickerHelper.jsm b/toolkit/modules/DateTimePickerHelper.jsm index 914b68d924e1..9969ef1c9ee6 100644 --- a/toolkit/modules/DateTimePickerHelper.jsm +++ b/toolkit/modules/DateTimePickerHelper.jsm @@ -140,7 +140,7 @@ this.DateTimePickerHelper = { this.picker.loadPicker(type, detail); // The arrow panel needs an anchor to work. The popupAnchor (this._anchor) // is a transparent div that the arrow can point to. - this.picker.openPopup(this._anchor, "after_start", rect.left, rect.top); + this.picker.openPopup(this._anchor, "after_start", 0, 0); this.addPickerListeners(); }, diff --git a/toolkit/themes/shared/datetimepopup.css b/toolkit/themes/shared/datetimepopup.css new file mode 100644 index 000000000000..52f6fc7a2d72 --- /dev/null +++ b/toolkit/themes/shared/datetimepopup.css @@ -0,0 +1,11 @@ +/* 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/. */ + +@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); + +panel[type="arrow"][side="top"], +panel[type="arrow"][side="bottom"] { + margin-left: 0; + margin-right: 0; +} diff --git a/toolkit/themes/shared/jar.inc.mn b/toolkit/themes/shared/jar.inc.mn index 5cad40ec635e..f0661782f3e4 100644 --- a/toolkit/themes/shared/jar.inc.mn +++ b/toolkit/themes/shared/jar.inc.mn @@ -22,6 +22,7 @@ toolkit.jar: skin/classic/global/appPicker.css (../../shared/appPicker.css) skin/classic/global/config.css (../../shared/config.css) skin/classic/global/datetimeinputpickers.css (../../shared/datetimeinputpickers.css) + skin/classic/global/datetimepopup.css (../../shared/datetimepopup.css) skin/classic/global/filters.svg (../../shared/filters.svg) skin/classic/global/icons/find-arrows.svg (../../shared/icons/find-arrows.svg) skin/classic/global/icons/info.svg (../../shared/incontent-icons/info.svg) From f2b5ca039b43bacb21beb1f07ed058aecfd8938c Mon Sep 17 00:00:00 2001 From: John Lin Date: Thu, 15 Dec 2016 17:57:21 +0800 Subject: [PATCH 21/64] Bug 1323631 - update original frame timestamp or duration rather than creating shallow copy. r=jwwang MozReview-Commit-ID: 4oSheJwFNOE --HG-- extra : rebase_source : a4eaa1c9914e2cbc500c0de44ccc274b84bbe505 --- dom/media/MediaData.cpp | 57 ++++++------------------ dom/media/MediaData.h | 26 ++--------- dom/media/MediaDecoderStateMachine.cpp | 6 +-- dom/media/android/AndroidMediaReader.cpp | 7 ++- 4 files changed, 21 insertions(+), 75 deletions(-) diff --git a/dom/media/MediaData.cpp b/dom/media/MediaData.cpp index 0d771887965a..eae9981530b7 100644 --- a/dom/media/MediaData.cpp +++ b/dom/media/MediaData.cpp @@ -177,55 +177,24 @@ VideoData::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const return size; } -/* static */ -already_AddRefed -VideoData::ShallowCopyUpdateDuration(const VideoData* aOther, - int64_t aDuration) +void +VideoData::UpdateDuration(int64_t aDuration) { - RefPtr v = new VideoData(aOther->mOffset, - aOther->mTime, - aDuration, - aOther->mKeyframe, - aOther->mTimecode, - aOther->mDisplay, - aOther->mFrameID); - v->mImage = aOther->mImage; - return v.forget(); + MOZ_ASSERT(aDuration >= 0); + + mDuration = aDuration; } -/* static */ -already_AddRefed -VideoData::ShallowCopyUpdateTimestamp(const VideoData* aOther, - int64_t aTimestamp) +void +VideoData::UpdateTimestamp(int64_t aTimestamp) { - NS_ENSURE_TRUE(aOther, nullptr); - RefPtr v = new VideoData(aOther->mOffset, - aTimestamp, - aOther->GetEndTime() - aTimestamp, - aOther->mKeyframe, - aOther->mTimecode, - aOther->mDisplay, - aOther->mFrameID); - v->mImage = aOther->mImage; - return v.forget(); -} + MOZ_ASSERT(aTimestamp >= 0); -/* static */ -already_AddRefed -VideoData::ShallowCopyUpdateTimestampAndDuration(const VideoData* aOther, - int64_t aTimestamp, - int64_t aDuration) -{ - NS_ENSURE_TRUE(aOther, nullptr); - RefPtr v = new VideoData(aOther->mOffset, - aTimestamp, - aDuration, - aOther->mKeyframe, - aOther->mTimecode, - aOther->mDisplay, - aOther->mFrameID); - v->mImage = aOther->mImage; - return v.forget(); + int64_t updatedDuration = GetEndTime() - aTimestamp; + MOZ_ASSERT(updatedDuration >= 0); + + mTime = aTimestamp; + mDuration = updatedDuration; } /* static */ diff --git a/dom/media/MediaData.h b/dom/media/MediaData.h index 7bebad017a9d..98904e311afc 100644 --- a/dom/media/MediaData.h +++ b/dom/media/MediaData.h @@ -493,29 +493,6 @@ public: int64_t aTimecode, const IntRect& aPicture); - // Creates a new VideoData identical to aOther, but with a different - // specified duration. All data from aOther is copied into the new - // VideoData. The new VideoData's mImage field holds a reference to - // aOther's mImage, i.e. the Image is not copied. This function is useful - // in reader backends that can't determine the duration of a VideoData - // until the next frame is decoded, i.e. it's a way to change the const - // duration field on a VideoData. - static already_AddRefed ShallowCopyUpdateDuration(const VideoData* aOther, - int64_t aDuration); - - // Creates a new VideoData identical to aOther, but with a different - // specified timestamp. All data from aOther is copied into the new - // VideoData, as ShallowCopyUpdateDuration() does. - static already_AddRefed ShallowCopyUpdateTimestamp(const VideoData* aOther, - int64_t aTimestamp); - - // Creates a new VideoData identical to aOther, but with a different - // specified timestamp and duration. All data from aOther is copied - // into the new VideoData, as ShallowCopyUpdateDuration() does. - static already_AddRefed - ShallowCopyUpdateTimestampAndDuration(const VideoData* aOther, int64_t aTimestamp, - int64_t aDuration); - // Initialize PlanarYCbCrImage. Only When aCopyData is true, // video data is copied to PlanarYCbCrImage. static bool SetVideoDataToImage(PlanarYCbCrImage* aVideoImage, @@ -548,6 +525,9 @@ public: void MarkSentToCompositor(); bool IsSentToCompositor() { return mSentToCompositor; } + void UpdateDuration(int64_t aDuration); + void UpdateTimestamp(int64_t aTimestamp); + protected: ~VideoData(); diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 19a179dd4a28..207d36af13a3 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -1242,10 +1242,8 @@ private: } else { if (target >= video->mTime && video->GetEndTime() >= target) { // The seek target lies inside this frame's time slice. Adjust the frame's - // start time to match the seek target. We do this by replacing the - // first frame with a shallow copy which has the new timestamp. - RefPtr temp = VideoData::ShallowCopyUpdateTimestamp(video.get(), target); - video = temp; + // start time to match the seek target. + video->UpdateTimestamp(target); } mFirstVideoFrameAfterSeek = nullptr; diff --git a/dom/media/android/AndroidMediaReader.cpp b/dom/media/android/AndroidMediaReader.cpp index c5333f8345ca..c98f741b6c98 100644 --- a/dom/media/android/AndroidMediaReader.cpp +++ b/dom/media/android/AndroidMediaReader.cpp @@ -141,9 +141,8 @@ bool AndroidMediaReader::DecodeVideoFrame(bool &aKeyframeSkip, int64_t durationUs; mPlugin->GetDuration(mPlugin, &durationUs); durationUs = std::max(durationUs - mLastVideoFrame->mTime, 0); - RefPtr data = VideoData::ShallowCopyUpdateDuration(mLastVideoFrame, - durationUs); - mVideoQueue.Push(data); + mLastVideoFrame->UpdateDuration(durationUs); + mVideoQueue.Push(mLastVideoFrame); mLastVideoFrame = nullptr; } return false; @@ -261,7 +260,7 @@ bool AndroidMediaReader::DecodeVideoFrame(bool &aKeyframeSkip, // timestamp of the previous frame. We can then return the previously // decoded frame, and it will have a valid timestamp. int64_t duration = v->mTime - mLastVideoFrame->mTime; - mLastVideoFrame = VideoData::ShallowCopyUpdateDuration(mLastVideoFrame, duration); + mLastVideoFrame->UpdateDuration(duration); // We have the start time of the next frame, so we can push the previous // frame into the queue, except if the end time is below the threshold, From eaee45d5475b3775cd9431d2948fd8c0ff09b927 Mon Sep 17 00:00:00 2001 From: Makoto Kato Date: Fri, 16 Dec 2016 10:52:23 +0900 Subject: [PATCH 22/64] Bug 1323695 - Conflict SHLoadLibraryFromKnownFolder when bumping up to WINVER=0x0601. r=froydnj When setting WINVER=0x601, we cannot compile SpecialSystemDirectory.cpp due to the following. 0:13.17 c:/Development/hg.mozilla.org/mozilla-inbound/xpcom/io/SpecialSystemDirectory.cpp(123): error C2084: function 'HRESULT SHLoadLibraryFromKnownFolder(const KNOWNFOLDERID &,DWORD,const IID &,void **)' already has a body 0:13.17 C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\shobjidl.h(32834): note: see previous definition of 'SHLoadLibraryFromKnownFolder' 0:13.17 c:/Development/hg.mozilla.org/mozilla-inbound/xpcom/io/SpecialSystemDirectory.cpp(158): error C2440: 'initializing': cannot convert from 'HRESULT (__cdecl *)(const KNOWNFOLDERID &,DWORD,const IID &,void **)' to 'HRESULT' 0:13.17 c:/Development/hg.mozilla.org/mozilla-inbound/xpcom/io/SpecialSystemDirectory.cpp(158): note: There is no context in which this conversion is possible MozReview-Commit-ID: 2KZEzcn21S7 --HG-- extra : rebase_source : b13f2fb11c9e006a83c7d5c3175af001e384b55e --- xpcom/io/SpecialSystemDirectory.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xpcom/io/SpecialSystemDirectory.cpp b/xpcom/io/SpecialSystemDirectory.cpp index b9731a5b9ecf..873ad955678c 100644 --- a/xpcom/io/SpecialSystemDirectory.cpp +++ b/xpcom/io/SpecialSystemDirectory.cpp @@ -116,6 +116,7 @@ GetWindowsFolder(int aFolder, nsIFile** aFile) return NS_NewLocalFile(nsDependentString(path, len), true, aFile); } +#if WINVER < 0x0601 __inline HRESULT SHLoadLibraryFromKnownFolder(REFKNOWNFOLDERID aFolderId, DWORD aMode, REFIID riid, void** ppv) @@ -134,6 +135,7 @@ SHLoadLibraryFromKnownFolder(REFKNOWNFOLDERID aFolderId, DWORD aMode, } return hr; } +#endif /* * Check to see if we're on Win7 and up, and if so, returns the default From a0a96efb0fceda734dd274d8137d4fcc36d168ea Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Mon, 28 Nov 2016 21:08:01 +1100 Subject: [PATCH 23/64] Bug 1319992: P1. Run demuxing operations on its own task queue. r=jwwang We runs all demuxing operations on a dedicated task queue. MediaDataDemuxer's members using a synchronous API are handled via thread-safe copy that are updated along the operations. The buffered range calculation is now handled separately and the entire operation is made asynchronous. MozReview-Commit-ID: Gd4DCC8Ix6n --HG-- extra : rebase_source : fb157f58e38c2f3199ed96095634bf8e4ab6065b --- dom/media/MediaDecoderReader.h | 41 ++- dom/media/MediaFormatReader.cpp | 518 +++++++++++++++++++++++++++----- dom/media/MediaFormatReader.h | 15 +- 3 files changed, 465 insertions(+), 109 deletions(-) diff --git a/dom/media/MediaDecoderReader.h b/dom/media/MediaDecoderReader.h index 9ce04a7058f8..d15c39c051fb 100644 --- a/dom/media/MediaDecoderReader.h +++ b/dom/media/MediaDecoderReader.h @@ -194,11 +194,10 @@ public: virtual size_t SizeOfVideoQueueInFrames(); virtual size_t SizeOfAudioQueueInFrames(); - void NotifyDataArrived() + virtual void NotifyDataArrived() { MOZ_ASSERT(OnTaskQueue()); NS_ENSURE_TRUE_VOID(!mShutdown); - NotifyDataArrivedInternal(); UpdateBuffered(); } @@ -254,24 +253,6 @@ protected: // Recomputes mBuffered. virtual void UpdateBuffered(); - // Populates aBuffered with the time ranges which are buffered. This may only - // be called on the decode task queue, and should only be used internally by - // UpdateBuffered - mBuffered (or mirrors of it) should be used for everything - // else. - // - // This base implementation in MediaDecoderReader estimates the time ranges - // buffered by interpolating the cached byte ranges with the duration - // of the media. Reader subclasses should override this method if they - // can quickly calculate the buffered ranges more accurately. - // - // The primary advantage of this implementation in the reader base class - // is that it's a fast approximation, which does not perform any I/O. - // - // The OggReader relies on this base implementation not performing I/O, - // since in FirefoxOS we can't do I/O on the main thread, where this is - // called. - virtual media::TimeIntervals GetBuffered(); - RefPtr DecodeToFirstVideoData(); // Queue of audio frames. This queue is threadsafe, and is accessed from @@ -344,8 +325,6 @@ private: virtual void VisibilityChanged(); - virtual void NotifyDataArrivedInternal() {} - // Overrides of this function should decodes an unspecified amount of // audio data, enqueuing the audio data in mAudioQueue. Returns true // when there's more audio to decode, false if the audio is finished, @@ -366,6 +345,24 @@ private: return false; } + // Populates aBuffered with the time ranges which are buffered. This may only + // be called on the decode task queue, and should only be used internally by + // UpdateBuffered - mBuffered (or mirrors of it) should be used for everything + // else. + // + // This base implementation in MediaDecoderReader estimates the time ranges + // buffered by interpolating the cached byte ranges with the duration + // of the media. Reader subclasses should override this method if they + // can quickly calculate the buffered ranges more accurately. + // + // The primary advantage of this implementation in the reader base class + // is that it's a fast approximation, which does not perform any I/O. + // + // The OggReader relies on this base implementation not performing I/O, + // since in FirefoxOS we can't do I/O on the main thread, where this is + // called. + media::TimeIntervals GetBuffered(); + // Promises used only for the base-class (sync->async adapter) implementation // of Request{Audio,Video}Data. MozPromiseHolder mBaseAudioPromise; diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index 8f7de2bc8829..8bb75acebe89 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -4,24 +4,27 @@ * 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/. */ -#include "mozilla/CDMProxy.h" -#include "mozilla/ClearOnShutdown.h" -#include "mozilla/dom/HTMLMediaElement.h" -#include "mozilla/Preferences.h" -#include "mozilla/Telemetry.h" -#include "nsContentUtils.h" -#include "nsPrintfCString.h" -#include "nsSize.h" +#include "AutoTaskQueue.h" #include "Layers.h" #include "MediaData.h" #include "MediaInfo.h" #include "MediaFormatReader.h" #include "MediaPrefs.h" #include "MediaResource.h" -#include "mozilla/SharedThreadPool.h" #include "VideoUtils.h" #include "VideoFrameContainer.h" +#include "mozilla/dom/HTMLMediaElement.h" #include "mozilla/layers/ShadowLayers.h" +#include "mozilla/CDMProxy.h" +#include "mozilla/ClearOnShutdown.h" +#include "mozilla/Preferences.h" +#include "mozilla/Telemetry.h" +#include "mozilla/Mutex.h" +#include "mozilla/SharedThreadPool.h" +#include "mozilla/SyncRunnable.h" +#include "nsContentUtils.h" +#include "nsPrintfCString.h" +#include "nsSize.h" #include #include @@ -427,6 +430,347 @@ MediaFormatReader::DecoderFactory::DoInitDecoder(TrackType aTrack) })); } +// DemuxerProxy ensures that the original main demuxer is only ever accessed +// via its own dedicated task queue. +// This ensure that the reader's taskqueue will never blocked while a demuxer +// is itself blocked attempting to access the MediaCache or the MediaResource. +class MediaFormatReader::DemuxerProxy +{ + using TrackType = TrackInfo::TrackType; + +public: + explicit DemuxerProxy(MediaDataDemuxer* aDemuxer) + : mTaskQueue(new AutoTaskQueue( + GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER))) + , mData(new Data(aDemuxer)) + { + MOZ_COUNT_CTOR(DemuxerProxy); + } + + ~DemuxerProxy() + { + MOZ_COUNT_DTOR(DemuxerProxy); + RefPtr data = mData.forget(); + mTaskQueue->Dispatch( + // We need to clear our reference to the demuxer now. So that in the event + // the init promise wasn't resolved, such as what can happen with the + // mediasource demuxer that is waiting on more data, it will force the + // init promise to be rejected. + NS_NewRunnableFunction([data]() { + if (data->mAudioDemuxer) { + data->mAudioDemuxer->BreakCycles(); + data->mAudioDemuxer = nullptr; + } + if (data->mVideoDemuxer) { + data->mVideoDemuxer->BreakCycles(); + data->mVideoDemuxer = nullptr; + } + data->mDemuxer = nullptr; + })); + } + + RefPtr Init(); + + already_AddRefed GetTrackDemuxer(TrackType aTrack, uint32_t aTrackNumber) + { + MOZ_RELEASE_ASSERT(mData && mData->mInitDone); + + switch (aTrack) { + case TrackInfo::kAudioTrack: + return mData->mAudioDemuxer.forget(); + case TrackInfo::kVideoTrack: + return mData->mVideoDemuxer.forget(); + default: + return nullptr; + } + } + + uint32_t GetNumberTracks(TrackType aTrack) + { + MOZ_RELEASE_ASSERT(mData && mData->mInitDone); + + switch (aTrack) { + case TrackInfo::kAudioTrack: + return mData->mNumAudioTrack; + case TrackInfo::kVideoTrack: + return mData->mNumVideoTrack; + default: + return 0; + } + } + + bool IsSeekable() + { + MOZ_RELEASE_ASSERT(mData && mData->mInitDone); + + return mData->mSeekable; + } + + bool IsSeekableOnlyInBufferedRanges() + { + MOZ_RELEASE_ASSERT(mData && mData->mInitDone); + + return mData->mSeekableOnlyInBufferedRange; + } + + UniquePtr GetCrypto() + { + MOZ_RELEASE_ASSERT(mData && mData->mInitDone); + + if (!mData->mCrypto) { + return nullptr; + } + auto crypto = MakeUnique(); + *crypto = *mData->mCrypto; + return crypto; + } + + RefPtr NotifyDataArrived(); + + bool ShouldComputeStartTime() const + { + MOZ_RELEASE_ASSERT(mData && mData->mInitDone); + + return mData->mShouldComputeStartTime; + } + +private: + const RefPtr mTaskQueue; + class Wrapper; + struct Data + { + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Data) + + explicit Data(MediaDataDemuxer* aDemuxer) + : mInitDone(false) + , mDemuxer(aDemuxer) + { } + + Atomic mInitDone; + // Only ever accessed over mTaskQueue once. + RefPtr mDemuxer; + // Only accessed once InitPromise has been resolved and immutable after. + // So we can safely access them without the use of the mutex. + uint32_t mNumVideoTrack = 0; + RefPtr mVideoDemuxer; + uint32_t mNumAudioTrack = 0; + RefPtr mAudioDemuxer; + bool mSeekable = false; + bool mSeekableOnlyInBufferedRange = false; + bool mShouldComputeStartTime = true; + UniquePtr mCrypto; + private: + ~Data() { } + }; + RefPtr mData; +}; + +class MediaFormatReader::DemuxerProxy::Wrapper : public MediaTrackDemuxer +{ +public: + Wrapper(MediaTrackDemuxer* aTrackDemuxer, AutoTaskQueue* aTaskQueue) + : mMutex("TrackDemuxer Mutex") + , mTaskQueue(aTaskQueue) + , mGetSamplesMayBlock(aTrackDemuxer->GetSamplesMayBlock()) + , mInfo(aTrackDemuxer->GetInfo()) + , mTrackDemuxer(aTrackDemuxer) + { } + + UniquePtr GetInfo() const override + { + if (!mInfo) { + return nullptr; + } + return mInfo->Clone(); + } + + RefPtr Seek(const media::TimeUnit& aTime) override + { + RefPtr self = this; + return InvokeAsync( + mTaskQueue, __func__, + [self, aTime]() { return self->mTrackDemuxer->Seek(aTime); }) + ->Then(mTaskQueue, __func__, + [self]() { self->UpdateRandomAccessPoint(); }, + [self]() { self->UpdateRandomAccessPoint(); }); + } + + RefPtr GetSamples(int32_t aNumSamples) override + { + RefPtr self = this; + return InvokeAsync(mTaskQueue, __func__, + [self, aNumSamples]() { + return self->mTrackDemuxer->GetSamples(aNumSamples); + }) + ->Then(mTaskQueue, __func__, + [self]() { self->UpdateRandomAccessPoint(); }, + [self]() { self->UpdateRandomAccessPoint(); }); + } + + bool GetSamplesMayBlock() const override + { + return mGetSamplesMayBlock; + } + + void Reset() override + { + RefPtr self = this; + mTaskQueue->Dispatch(NS_NewRunnableFunction([self]() { + self->mTrackDemuxer->Reset(); + })); + } + + nsresult GetNextRandomAccessPoint(TimeUnit* aTime) override + { + MutexAutoLock lock(mMutex); + if (NS_SUCCEEDED(mNextRandomAccessPointResult)) { + *aTime = mNextRandomAccessPoint; + } + return mNextRandomAccessPointResult; + } + + RefPtr + SkipToNextRandomAccessPoint(const media::TimeUnit& aTimeThreshold) override + { + RefPtr self = this; + return InvokeAsync( + mTaskQueue, __func__, + [self, aTimeThreshold]() { + return self->mTrackDemuxer->SkipToNextRandomAccessPoint( + aTimeThreshold); + }) + ->Then(mTaskQueue, __func__, + [self]() { self->UpdateRandomAccessPoint(); }, + [self]() { self->UpdateRandomAccessPoint(); }); + } + + TimeIntervals GetBuffered() override + { + MutexAutoLock lock(mMutex); + return mBuffered; + } + + void BreakCycles() override + { + RefPtr self = this; + nsCOMPtr runnable = NS_NewRunnableFunction([self]() { + self->mTrackDemuxer->BreakCycles(); + self->mTrackDemuxer = nullptr; + }); + SyncRunnable::DispatchToThread(mTaskQueue, runnable); + } + +private: + Mutex mMutex; + const RefPtr mTaskQueue; + const bool mGetSamplesMayBlock; + const UniquePtr mInfo; + // mTrackDemuxer is only ever accessed on demuxer's task queue. + RefPtr mTrackDemuxer; + // All following members are protected by mMutex + nsresult mNextRandomAccessPointResult = NS_OK; + TimeUnit mNextRandomAccessPoint; + TimeIntervals mBuffered; + friend class DemuxerProxy; + + void UpdateRandomAccessPoint() + { + MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn()); + if (!mTrackDemuxer) { + // Detached. + return; + } + MutexAutoLock lock(mMutex); + mNextRandomAccessPointResult = + mTrackDemuxer->GetNextRandomAccessPoint(&mNextRandomAccessPoint); + } + + void UpdateBuffered() + { + MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn()); + if (!mTrackDemuxer) { + // Detached. + return; + } + MutexAutoLock lock(mMutex); + mBuffered = mTrackDemuxer->GetBuffered(); + } +}; + +RefPtr +MediaFormatReader::DemuxerProxy::Init() +{ + RefPtr data = mData; + RefPtr taskQueue = mTaskQueue; + return InvokeAsync(mTaskQueue, __func__, + [data, taskQueue]() { + if (!data->mDemuxer) { + return MediaDataDemuxer::InitPromise::CreateAndReject( + NS_ERROR_DOM_MEDIA_CANCELED, __func__); + } + return data->mDemuxer->Init(); + }) + ->Then(taskQueue, __func__, + [data, taskQueue]() { + if (!data->mDemuxer) { // Was shutdown. + return; + } + data->mNumVideoTrack = + data->mDemuxer->GetNumberTracks(TrackInfo::kVideoTrack); + if (data->mNumVideoTrack) { + RefPtr d = + data->mDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0); + if (d) { + RefPtr wrapper = + new DemuxerProxy::Wrapper(d, taskQueue); + wrapper->UpdateBuffered(); + data->mVideoDemuxer = wrapper; + } + } + data->mNumAudioTrack = + data->mDemuxer->GetNumberTracks(TrackInfo::kAudioTrack); + if (data->mNumAudioTrack) { + RefPtr d = + data->mDemuxer->GetTrackDemuxer(TrackInfo::kAudioTrack, 0); + if (d) { + RefPtr wrapper = + new DemuxerProxy::Wrapper(d, taskQueue); + wrapper->UpdateBuffered(); + data->mAudioDemuxer = wrapper; + } + } + data->mCrypto = data->mDemuxer->GetCrypto(); + data->mSeekable = data->mDemuxer->IsSeekable(); + data->mSeekableOnlyInBufferedRange = + data->mDemuxer->IsSeekableOnlyInBufferedRanges(); + data->mShouldComputeStartTime = + data->mDemuxer->ShouldComputeStartTime(); + data->mInitDone = true; + }, + []() {}); +} + +RefPtr +MediaFormatReader::DemuxerProxy::NotifyDataArrived() +{ + RefPtr data = mData; + return InvokeAsync(mTaskQueue, __func__, [data]() { + if (!data->mDemuxer) { + // Was shutdown. + return NotifyDataArrivedPromise::CreateAndReject( + NS_ERROR_DOM_MEDIA_CANCELED, __func__); + } + data->mDemuxer->NotifyDataArrived(); + if (data->mVideoDemuxer) { + static_cast(data->mVideoDemuxer.get())->UpdateBuffered(); + } + if (data->mAudioDemuxer) { + static_cast(data->mAudioDemuxer.get())->UpdateBuffered(); + } + return NotifyDataArrivedPromise::CreateAndResolve(true, __func__); + }); +} + static const char* TrackTypeToStr(TrackInfo::TrackType aTrack) { @@ -453,7 +797,7 @@ MediaFormatReader::MediaFormatReader(AbstractMediaDecoder* aDecoder, Preferences::GetUint("media.audio-max-decode-error", 3)) , mVideo(this, MediaData::VIDEO_DATA, Preferences::GetUint("media.video-max-decode-error", 2)) - , mDemuxer(aDemuxer) + , mDemuxer(new DemuxerProxy(aDemuxer)) , mDemuxerInitDone(false) , mLastReportedNumDecodedFrames(0) , mPreviousDecodedKeyframeTime_us(sNoPreviousDecodedKeyframe) @@ -689,7 +1033,6 @@ MediaFormatReader::OnDemuxerInitDone(nsresult) } mVideo.mOriginalInfo = Move(videoInfo); mVideo.mCallback = new DecoderCallback(this, TrackInfo::kVideoTrack); - mVideo.mTimeRanges = mVideo.mTrackDemuxer->GetBuffered(); mTrackDemuxersMayBlock |= mVideo.mTrackDemuxer->GetSamplesMayBlock(); } else { mVideo.mTrackDemuxer->BreakCycles(); @@ -718,7 +1061,6 @@ MediaFormatReader::OnDemuxerInitDone(nsresult) } mAudio.mOriginalInfo = Move(audioInfo); mAudio.mCallback = new DecoderCallback(this, TrackInfo::kAudioTrack); - mAudio.mTimeRanges = mAudio.mTrackDemuxer->GetBuffered(); mTrackDemuxersMayBlock |= mAudio.mTrackDemuxer->GetSamplesMayBlock(); } else { mAudio.mTrackDemuxer->BreakCycles(); @@ -794,12 +1136,15 @@ MediaFormatReader::MaybeResolveMetadataPromise() mInfo.mStartTime = startTime; // mInfo.mStartTime is initialized to 0. } - mHasStartTime = true; - UpdateBuffered(); - RefPtr metadata = new MetadataHolder(); metadata->mInfo = mInfo; metadata->mTags = mTags->Count() ? mTags.release() : nullptr; + + // We now have all the informations required to calculate the initial buffered + // range. + mHasStartTime = true; + UpdateBuffered(); + mMetadataPromise.Resolve(metadata, __func__); } @@ -1155,9 +1500,6 @@ MediaFormatReader::UpdateReceivedNewData(TrackType aTrack) return false; } - // Update our cached TimeRange. - decoder.mTimeRanges = decoder.mTrackDemuxer->GetBuffered(); - // We do not want to clear mWaitingForData while there are pending // demuxing or seeking operations that could affect the value of this flag. // This is in order to ensure that we will retry once they complete as we may @@ -1185,16 +1527,6 @@ MediaFormatReader::UpdateReceivedNewData(TrackType aTrack) return false; } - bool hasLastEnd; - media::TimeUnit lastEnd = decoder.mTimeRanges.GetEnd(&hasLastEnd); - if (hasLastEnd) { - if (decoder.mLastTimeRangesEnd && decoder.mLastTimeRangesEnd.ref() < lastEnd) { - // New data was added after our previous end, we can clear the EOS flag. - decoder.mDemuxEOS = false; - } - decoder.mLastTimeRangesEnd = Some(lastEnd); - } - decoder.mReceivedNewData = false; if (decoder.mTimeThreshold) { decoder.mTimeThreshold.ref().mWaiting = false; @@ -2186,47 +2518,6 @@ MediaFormatReader::OnAudioSeekFailed(const MediaResult& aError) OnSeekFailed(TrackType::kAudioTrack, aError); } -media::TimeIntervals -MediaFormatReader::GetBuffered() -{ - MOZ_ASSERT(OnTaskQueue()); - media::TimeIntervals videoti; - media::TimeIntervals audioti; - media::TimeIntervals intervals; - - if (!mInitDone || !mHasStartTime) { - return intervals; - } - - // Ensure we have up to date buffered time range. - if (HasVideo()) { - UpdateReceivedNewData(TrackType::kVideoTrack); - } - if (HasAudio()) { - UpdateReceivedNewData(TrackType::kAudioTrack); - } - if (HasVideo()) { - videoti = mVideo.mTimeRanges; - } - if (HasAudio()) { - audioti = mAudio.mTimeRanges; - } - if (HasAudio() && HasVideo()) { - intervals = media::Intersection(Move(videoti), Move(audioti)); - } else if (HasAudio()) { - intervals = Move(audioti); - } else if (HasVideo()) { - intervals = Move(videoti); - } - - if (!intervals.Length() || - intervals.GetStart() == media::TimeUnit::FromMicroseconds(0)) { - // IntervalSet already starts at 0 or is empty, nothing to shift. - return intervals; - } - return intervals.Shift(media::TimeUnit() - mInfo.mStartTime); -} - void MediaFormatReader::ReleaseResources() { mVideo.ShutdownDecoder(); @@ -2240,22 +2531,16 @@ MediaFormatReader::VideoIsHardwareAccelerated() const } void -MediaFormatReader::NotifyDemuxer() +MediaFormatReader::NotifyTrackDemuxers() { MOZ_ASSERT(OnTaskQueue()); - if (mShutdown || !mDemuxer || - (!mDemuxerInitDone && !mDemuxerInitRequest.Exists())) { - return; - } - LOGV(""); - mDemuxer->NotifyDataArrived(); - if (!mInitDone) { return; } + if (HasVideo()) { mVideo.mReceivedNewData = true; ScheduleUpdate(TrackType::kVideoTrack); @@ -2267,10 +2552,85 @@ MediaFormatReader::NotifyDemuxer() } void -MediaFormatReader::NotifyDataArrivedInternal() +MediaFormatReader::NotifyDataArrived() { MOZ_ASSERT(OnTaskQueue()); - NotifyDemuxer(); + + if (mShutdown || !mDemuxer || + (!mDemuxerInitDone && !mDemuxerInitRequest.Exists())) { + return; + } + + RefPtr self = this; + mDemuxer->NotifyDataArrived()->Then( + OwnerThread(), __func__, + [self]() { + self->UpdateBuffered(); + self->NotifyTrackDemuxers(); + }, + []() {}); +} + +void +MediaFormatReader::UpdateBuffered() +{ + MOZ_ASSERT(OnTaskQueue()); + + if (mShutdown) { + return; + } + + if (!mInitDone || !mHasStartTime) { + mBuffered = TimeIntervals(); + return; + } + + if (HasVideo()) { + mVideo.mTimeRanges = mVideo.mTrackDemuxer->GetBuffered(); + bool hasLastEnd; + media::TimeUnit lastEnd = mVideo.mTimeRanges.GetEnd(&hasLastEnd); + if (hasLastEnd) { + if (mVideo.mLastTimeRangesEnd + && mVideo.mLastTimeRangesEnd.ref() < lastEnd) { + // New data was added after our previous end, we can clear the EOS flag. + mVideo.mDemuxEOS = false; + ScheduleUpdate(TrackInfo::kVideoTrack); + } + mVideo.mLastTimeRangesEnd = Some(lastEnd); + } + } + if (HasAudio()) { + mAudio.mTimeRanges = mAudio.mTrackDemuxer->GetBuffered(); + bool hasLastEnd; + media::TimeUnit lastEnd = mAudio.mTimeRanges.GetEnd(&hasLastEnd); + if (hasLastEnd) { + if (mAudio.mLastTimeRangesEnd + && mAudio.mLastTimeRangesEnd.ref() < lastEnd) { + // New data was added after our previous end, we can clear the EOS flag. + mAudio.mDemuxEOS = false; + ScheduleUpdate(TrackInfo::kAudioTrack); + } + mAudio.mLastTimeRangesEnd = Some(lastEnd); + } + } + + media::TimeIntervals intervals; + if (HasAudio() && HasVideo()) { + intervals = media::Intersection(mVideo.mTimeRanges, mAudio.mTimeRanges); + } else if (HasAudio()) { + intervals = mAudio.mTimeRanges; + } else if (HasVideo()) { + intervals = mVideo.mTimeRanges; + } + + if (!intervals.Length() || + intervals.GetStart() == media::TimeUnit::FromMicroseconds(0)) { + // IntervalSet already starts at 0 or is empty, nothing to shift. + mBuffered = intervals; + } else { + mBuffered = + intervals.Shift(media::TimeUnit() - mInfo.mStartTime); + } } bool diff --git a/dom/media/MediaFormatReader.h b/dom/media/MediaFormatReader.h index 4c916e9a2ab2..c9f0d7ee7e3c 100644 --- a/dom/media/MediaFormatReader.h +++ b/dom/media/MediaFormatReader.h @@ -25,6 +25,7 @@ class CDMProxy; class MediaFormatReader final : public MediaDecoderReader { typedef TrackInfo::TrackType TrackType; + typedef MozPromise NotifyDataArrivedPromise; public: MediaFormatReader(AbstractMediaDecoder* aDecoder, @@ -49,11 +50,10 @@ public: Seek(const SeekTarget& aTarget, int64_t aUnused) override; protected: - void NotifyDataArrivedInternal() override; + void NotifyDataArrived() override; + void UpdateBuffered() override; public: - media::TimeIntervals GetBuffered() override; - bool ForceZeroStartTime() const override; // For Media Resource Management @@ -92,10 +92,8 @@ private: bool IsWaitingOnCDMResource(); bool InitDemuxer(); - // Notify the demuxer that new data has been received. - // The next queued task calling GetBuffered() is guaranteed to have up to date - // buffered ranges. - void NotifyDemuxer(); + // Notify the track demuxers that new data has been received. + void NotifyTrackDemuxers(); void ReturnOutput(MediaData* aData, TrackType aTrack); // Enqueues a task to call Update(aTrack) on the decoder task queue. @@ -482,7 +480,8 @@ private: DecoderData& GetDecoderData(TrackType aTrack); // Demuxer objects. - RefPtr mDemuxer; + class DemuxerProxy; + UniquePtr mDemuxer; bool mDemuxerInitDone; void OnDemuxerInitDone(nsresult); void OnDemuxerInitFailed(const MediaResult& aError); From f97f51ce88ecf499b914eae634427d4f50d91007 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 30 Nov 2016 01:23:38 +1100 Subject: [PATCH 24/64] Bug 1319992: P2. Update MediaDecoderReader documentation. r=jwwang Remove all no longer relevant information. MozReview-Commit-ID: 89HB0Pk1XoI --HG-- extra : rebase_source : 8190aece8113a067080e082c2da63a750d9b4d68 --- dom/media/MediaDecoderReader.h | 35 ++++++++++------------------------ 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/dom/media/MediaDecoderReader.h b/dom/media/MediaDecoderReader.h index d15c39c051fb..a82d6c3092f0 100644 --- a/dom/media/MediaDecoderReader.h +++ b/dom/media/MediaDecoderReader.h @@ -54,7 +54,7 @@ private: // Encapsulates the decoding and reading of media data. Reading can either // synchronous and done on the calling "decode" thread, or asynchronous and // performed on a background thread, with the result being returned by -// callback. Never hold the decoder monitor when calling into this class. +// callback. // Unless otherwise specified, methods and fields of this class can only // be accessed on the decode task queue. class MediaDecoderReader { @@ -114,10 +114,6 @@ public: // // Normally this call preceedes a Seek() call, or shutdown. // - // The first samples of every stream produced after a ResetDecode() call - // *must* be marked as "discontinuities". If it's not, seeking work won't - // properly! - // // aParam is a set of TrackInfo::TrackType enums specifying which // queues need to be reset, defaulting to both audio and video tracks. virtual nsresult ResetDecode(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack, @@ -126,15 +122,11 @@ public: // Requests one audio sample from the reader. // // The decode should be performed asynchronously, and the promise should - // be resolved when it is complete. Don't hold the decoder - // monitor while calling this, as the implementation may try to wait - // on something that needs the monitor and deadlock. + // be resolved when it is complete. virtual RefPtr RequestAudioData(); // Requests one video sample from the reader. // - // Don't hold the decoder monitor while calling this, as the implementation - // may try to wait on something that needs the monitor and deadlock. // If aSkipToKeyframe is true, the decode should skip ahead to the // the next keyframe at or after aTimeThreshold microseconds. virtual RefPtr @@ -194,6 +186,8 @@ public: virtual size_t SizeOfVideoQueueInFrames(); virtual size_t SizeOfAudioQueueInFrames(); + // Called once new data has been cached by the MediaResource. + // mBuffered should be recalculated and updated accordingly. virtual void NotifyDataArrived() { MOZ_ASSERT(OnTaskQueue()); @@ -345,22 +339,13 @@ private: return false; } - // Populates aBuffered with the time ranges which are buffered. This may only - // be called on the decode task queue, and should only be used internally by - // UpdateBuffered - mBuffered (or mirrors of it) should be used for everything - // else. + // GetBuffered estimates the time ranges buffered by interpolating the cached + // byte ranges with the duration of the media. Reader subclasses should + // override this method if they can quickly calculate the buffered ranges more + // accurately. // - // This base implementation in MediaDecoderReader estimates the time ranges - // buffered by interpolating the cached byte ranges with the duration - // of the media. Reader subclasses should override this method if they - // can quickly calculate the buffered ranges more accurately. - // - // The primary advantage of this implementation in the reader base class - // is that it's a fast approximation, which does not perform any I/O. - // - // The OggReader relies on this base implementation not performing I/O, - // since in FirefoxOS we can't do I/O on the main thread, where this is - // called. + // The primary advantage of this implementation in the reader base class is + // that it's a fast approximation, which does not perform any I/O. media::TimeIntervals GetBuffered(); // Promises used only for the base-class (sync->async adapter) implementation From 70465b64702886f1a2a5edb9f238bb148a31a32c Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 30 Nov 2016 01:42:50 +1100 Subject: [PATCH 25/64] Bug 1319992: P3. Remove no longer used seeking argument. r=jwwang MozReview-Commit-ID: 9Oc0SHX0Rw2 --HG-- extra : rebase_source : 0cea32ef23a47b5ed3b2439f2efa268ec66a523c --- dom/media/MediaDecoderReader.h | 6 ++---- dom/media/MediaDecoderReaderWrapper.cpp | 7 +++---- dom/media/MediaDecoderReaderWrapper.h | 3 +-- dom/media/MediaDecoderStateMachine.cpp | 6 +++--- dom/media/MediaFormatReader.cpp | 2 +- dom/media/MediaFormatReader.h | 3 +-- dom/media/NextFrameSeekTask.cpp | 2 +- dom/media/NextFrameSeekTask.h | 2 +- dom/media/SeekTask.h | 2 +- dom/media/android/AndroidMediaReader.cpp | 2 +- dom/media/android/AndroidMediaReader.h | 2 +- dom/media/directshow/DirectShowReader.cpp | 2 +- dom/media/directshow/DirectShowReader.h | 3 +-- 13 files changed, 18 insertions(+), 24 deletions(-) diff --git a/dom/media/MediaDecoderReader.h b/dom/media/MediaDecoderReader.h index a82d6c3092f0..5b23edd70d1f 100644 --- a/dom/media/MediaDecoderReader.h +++ b/dom/media/MediaDecoderReader.h @@ -151,10 +151,8 @@ public: // ReadUpdatedMetadata will always be called once ReadMetadata has succeeded. virtual void ReadUpdatedMetadata(MediaInfo* aInfo) {} - // Moves the decode head to aTime microseconds. aEndTime denotes the end - // time of the media in usecs. This is only needed for OggReader, and should - // probably be removed somehow. - virtual RefPtr Seek(const SeekTarget& aTarget, int64_t aEndTime) = 0; + // Moves the decode head to aTime microseconds. + virtual RefPtr Seek(const SeekTarget& aTarget) = 0; virtual void SetCDMProxy(CDMProxy* aProxy) {} diff --git a/dom/media/MediaDecoderReaderWrapper.cpp b/dom/media/MediaDecoderReaderWrapper.cpp index c73ea018e6e1..a0ab6d35181d 100644 --- a/dom/media/MediaDecoderReaderWrapper.cpp +++ b/dom/media/MediaDecoderReaderWrapper.cpp @@ -121,16 +121,15 @@ MediaDecoderReaderWrapper::IsWaitingVideoData() const } RefPtr -MediaDecoderReaderWrapper::Seek(const SeekTarget& aTarget, - const media::TimeUnit& aEndTime) +MediaDecoderReaderWrapper::Seek(const SeekTarget& aTarget) { MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn()); SeekTarget adjustedTarget = aTarget; adjustedTarget.SetTime(adjustedTarget.GetTime() + StartTime()); - return InvokeAsync( + return InvokeAsync( mReader->OwnerThread(), mReader.get(), __func__, &MediaDecoderReader::Seek, - Move(adjustedTarget), aEndTime.ToMicroseconds()); + Move(adjustedTarget)); } void diff --git a/dom/media/MediaDecoderReaderWrapper.h b/dom/media/MediaDecoderReaderWrapper.h index 92741d06da73..e046b6516660 100644 --- a/dom/media/MediaDecoderReaderWrapper.h +++ b/dom/media/MediaDecoderReaderWrapper.h @@ -67,8 +67,7 @@ public: bool IsWaitingAudioData() const; bool IsWaitingVideoData() const; - RefPtr Seek(const SeekTarget& aTarget, - const media::TimeUnit& aEndTime); + RefPtr Seek(const SeekTarget& aTarget); RefPtr Shutdown(); void ReleaseResources(); diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 207d36af13a3..89a67b033698 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -1055,7 +1055,7 @@ private: void DoSeek() override { // Request the demuxer to perform seek. - mSeekRequest.Begin(Reader()->Seek(mSeekJob.mTarget, mMaster->Duration()) + mSeekRequest.Begin(Reader()->Seek(mSeekJob.mTarget) ->Then(OwnerThread(), __func__, [this] (media::TimeUnit aUnit) { OnSeekResolved(aUnit); @@ -1350,7 +1350,7 @@ private: { mSeekTask = new NextFrameSeekTask( mMaster->mDecoderID, OwnerThread(), Reader(), mSeekJob.mTarget, - Info(), mMaster->Duration(),mMaster->GetMediaTime(), + Info(), mMaster->Duration(), mMaster->GetMediaTime(), AudioQueue(), VideoQueue()); } @@ -1361,7 +1361,7 @@ private: void DoSeek() override { - mSeekTaskRequest.Begin(mSeekTask->Seek(mMaster->Duration()) + mSeekTaskRequest.Begin(mSeekTask->Seek() ->Then(OwnerThread(), __func__, [this] (const SeekTaskResolveValue& aValue) { OnSeekTaskResolved(aValue); diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index 8bb75acebe89..c6a3075b7387 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -2277,7 +2277,7 @@ MediaFormatReader::OnVideoSkipFailed(MediaTrackDemuxer::SkipFailureHolder aFailu } RefPtr -MediaFormatReader::Seek(const SeekTarget& aTarget, int64_t aUnused) +MediaFormatReader::Seek(const SeekTarget& aTarget) { MOZ_ASSERT(OnTaskQueue()); diff --git a/dom/media/MediaFormatReader.h b/dom/media/MediaFormatReader.h index c9f0d7ee7e3c..3ee6967309d7 100644 --- a/dom/media/MediaFormatReader.h +++ b/dom/media/MediaFormatReader.h @@ -46,8 +46,7 @@ public: void ReadUpdatedMetadata(MediaInfo* aInfo) override; - RefPtr - Seek(const SeekTarget& aTarget, int64_t aUnused) override; + RefPtr Seek(const SeekTarget& aTarget) override; protected: void NotifyDataArrived() override; diff --git a/dom/media/NextFrameSeekTask.cpp b/dom/media/NextFrameSeekTask.cpp index 5ecc1b058016..6a1ad3cea912 100644 --- a/dom/media/NextFrameSeekTask.cpp +++ b/dom/media/NextFrameSeekTask.cpp @@ -231,7 +231,7 @@ DiscardFrames(MediaQueue& aQueue, const Function& aCompare) } RefPtr -NextFrameSeekTask::Seek(const media::TimeUnit&) +NextFrameSeekTask::Seek() { AssertOwnerThread(); diff --git a/dom/media/NextFrameSeekTask.h b/dom/media/NextFrameSeekTask.h index d840b81f6715..3b22bf221351 100644 --- a/dom/media/NextFrameSeekTask.h +++ b/dom/media/NextFrameSeekTask.h @@ -36,7 +36,7 @@ public: void Discard() override; - RefPtr Seek(const media::TimeUnit& aDuration) override; + RefPtr Seek() override; int64_t CalculateNewCurrentTime() const override; diff --git a/dom/media/SeekTask.h b/dom/media/SeekTask.h index 089e9fea6899..f33cb956e977 100644 --- a/dom/media/SeekTask.h +++ b/dom/media/SeekTask.h @@ -56,7 +56,7 @@ public: virtual void Discard() = 0; - virtual RefPtr Seek(const media::TimeUnit& aDuration) = 0; + virtual RefPtr Seek() = 0; virtual int64_t CalculateNewCurrentTime() const = 0; diff --git a/dom/media/android/AndroidMediaReader.cpp b/dom/media/android/AndroidMediaReader.cpp index c98f741b6c98..cf21a6aab735 100644 --- a/dom/media/android/AndroidMediaReader.cpp +++ b/dom/media/android/AndroidMediaReader.cpp @@ -313,7 +313,7 @@ bool AndroidMediaReader::DecodeAudioData() } RefPtr -AndroidMediaReader::Seek(const SeekTarget& aTarget, int64_t aEndTime) +AndroidMediaReader::Seek(const SeekTarget& aTarget) { MOZ_ASSERT(OnTaskQueue()); diff --git a/dom/media/android/AndroidMediaReader.h b/dom/media/android/AndroidMediaReader.h index acf34bd675d8..d65b5089ce98 100644 --- a/dom/media/android/AndroidMediaReader.h +++ b/dom/media/android/AndroidMediaReader.h @@ -48,7 +48,7 @@ public: bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold) override; nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override; - RefPtr Seek(const SeekTarget& aTarget, int64_t aEndTime) override; + RefPtr Seek(const SeekTarget& aTarget) override; RefPtr Shutdown() override; diff --git a/dom/media/directshow/DirectShowReader.cpp b/dom/media/directshow/DirectShowReader.cpp index ba27548b60f8..04033739ea1c 100644 --- a/dom/media/directshow/DirectShowReader.cpp +++ b/dom/media/directshow/DirectShowReader.cpp @@ -320,7 +320,7 @@ DirectShowReader::DecodeVideoFrame(bool &aKeyframeSkip, } RefPtr -DirectShowReader::Seek(const SeekTarget& aTarget, int64_t aEndTime) +DirectShowReader::Seek(const SeekTarget& aTarget) { nsresult res = SeekInternal(aTarget.GetTime().ToMicroseconds()); if (NS_FAILED(res)) { diff --git a/dom/media/directshow/DirectShowReader.h b/dom/media/directshow/DirectShowReader.h index b165f0939190..4e314a819d84 100644 --- a/dom/media/directshow/DirectShowReader.h +++ b/dom/media/directshow/DirectShowReader.h @@ -57,8 +57,7 @@ public: nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override; - RefPtr - Seek(const SeekTarget& aTarget, int64_t aEndTime) override; + RefPtr Seek(const SeekTarget& aTarget) override; static const GUID CLSID_MPEG_LAYER_3_DECODER_FILTER; From 51407b155e88a298c45d4908a57a6ff36c132aa3 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 30 Nov 2016 01:50:08 +1100 Subject: [PATCH 26/64] Bug 1319992: P4. Use Mutex in place of Monitor. r=jwwang MozReview-Commit-ID: 79z6EtZQhYu --HG-- extra : rebase_source : 506bba4823f3d5deb64909e41340259b409a1282 --- dom/media/MediaFormatReader.cpp | 7 +++---- dom/media/MediaFormatReader.h | 10 +++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index c6a3075b7387..06bb348619aa 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -19,7 +19,6 @@ #include "mozilla/ClearOnShutdown.h" #include "mozilla/Preferences.h" #include "mozilla/Telemetry.h" -#include "mozilla/Mutex.h" #include "mozilla/SharedThreadPool.h" #include "mozilla/SyncRunnable.h" #include "nsContentUtils.h" @@ -415,7 +414,7 @@ MediaFormatReader::DecoderFactory::DoInitDecoder(TrackType aTrack) [this, &data, &ownerData] (TrackType aTrack) { data.mInitPromise.Complete(); data.mStage = Stage::None; - MonitorAutoLock mon(ownerData.mMonitor); + MutexAutoLock lock(ownerData.mMutex); ownerData.mDecoder = data.mDecoder.forget(); ownerData.mDescription = ownerData.mDecoder->GetDescriptionName(); mOwner->SetVideoDecodeThreshold(); @@ -2654,11 +2653,11 @@ MediaFormatReader::GetMozDebugReaderData(nsAString& aString) const char* videoName = audioName; if (HasAudio()) { - MonitorAutoLock mon(mAudio.mMonitor); + MutexAutoLock lock(mAudio.mMutex); audioName = mAudio.mDescription; } if (HasVideo()) { - MonitorAutoLock mon(mVideo.mMonitor); + MutexAutoLock mon(mVideo.mMutex); videoName = mVideo.mDescription; } diff --git a/dom/media/MediaFormatReader.h b/dom/media/MediaFormatReader.h index 3ee6967309d7..7d917966c1b7 100644 --- a/dom/media/MediaFormatReader.h +++ b/dom/media/MediaFormatReader.h @@ -10,7 +10,7 @@ #include "mozilla/Atomics.h" #include "mozilla/Maybe.h" #include "mozilla/TaskQueue.h" -#include "mozilla/Monitor.h" +#include "mozilla/Mutex.h" #include "MediaEventSource.h" #include "MediaDataDemuxer.h" @@ -209,7 +209,7 @@ private: uint32_t aNumOfMaxError) : mOwner(aOwner) , mType(aType) - , mMonitor("DecoderData") + , mMutex("DecoderData") , mDescription("shutdown") , mUpdateScheduled(false) , mDemuxEOS(false) @@ -243,14 +243,14 @@ private: // Callback that receives output and error notifications from the decoder. nsAutoPtr mCallback; - // Monitor protecting mDescription and mDecoder. - Monitor mMonitor; + // Mutex protecting mDescription and mDecoder. + Mutex mMutex; // The platform decoder. RefPtr mDecoder; const char* mDescription; void ShutdownDecoder() { - MonitorAutoLock mon(mMonitor); + MutexAutoLock lock(mMutex); if (mDecoder) { mDecoder->Shutdown(); } From d2f0d0608b1ace35b3e043d7035e30473d6c06ca Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 14 Dec 2016 17:35:36 +1100 Subject: [PATCH 27/64] Bug 1319992: P5. Don't attempt to estimate readyState when ended. r=jwwang Buffered range is now calculated asynchronously. It may not be up to date by the time the MDSM has entered ended mode. There's no point estimating readyState in ended mode anyway: we know what it is... MozReview-Commit-ID: ErGsAwBzeXI --HG-- extra : rebase_source : bd8cecca96e93114e970e09faf09a80f56bf4c98 --- dom/html/HTMLMediaElement.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 15f895475d6a..d9eebef3ea96 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -5474,7 +5474,7 @@ HTMLMediaElement::UpdateReadyStateInternal() // 6. Suspend playback. // Note: Playback will already be stalled, as the next frame is // unavailable. - } else if (mDecoder) { + } else if (mDecoder && !mDecoder->IsEnded()) { nextFrameStatus = mDecoder->NextFrameBufferedStatus(); } } From 6bb459b5dd38cfca79e092fb3c182970f983b48c Mon Sep 17 00:00:00 2001 From: John Lin Date: Fri, 16 Dec 2016 11:04:46 +0800 Subject: [PATCH 28/64] Bug 1317887 - don't run IPC temporary file stream test in non-e10s mode. r=jdm MozReview-Commit-ID: AvtMbbS7D82 --HG-- extra : rebase_source : 7b90fc7c71062459d9e370cf737e140b8a9ad901 --- dom/ipc/tests/mochitest.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/dom/ipc/tests/mochitest.ini b/dom/ipc/tests/mochitest.ini index cf2a20d5b813..acd6a595c114 100644 --- a/dom/ipc/tests/mochitest.ini +++ b/dom/ipc/tests/mochitest.ini @@ -17,6 +17,7 @@ skip-if = toolkit == 'cocoa' # disabled due to hangs, see changeset 6852e7c47edf [test_CrashService_crash.html] skip-if = !(crashreporter && !e10s && (toolkit == 'gtk2' || toolkit == 'gtk3' || toolkit == 'cocoa' || toolkit == 'windows')) [test_temporaryfile_stream.html] +skip-if = !e10s support-files = blob_verify.sjs !/dom/canvas/test/captureStream_common.js From d78d68e62a2cf3938aff494cc826f32faa7030be Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Fri, 16 Dec 2016 14:29:59 +1100 Subject: [PATCH 29/64] Bug 1323913: Make members const. r=gerald MozReview-Commit-ID: 9AZIGB2vgEp --HG-- extra : rebase_source : c20f644ce16a9119fa475112d21d6d3a4e873394 --- dom/media/MediaFormatReader.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index 06bb348619aa..de153ccab1c0 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -470,7 +470,8 @@ public: RefPtr Init(); - already_AddRefed GetTrackDemuxer(TrackType aTrack, uint32_t aTrackNumber) + already_AddRefed + GetTrackDemuxer(TrackType aTrack, uint32_t aTrackNumber) const { MOZ_RELEASE_ASSERT(mData && mData->mInitDone); @@ -484,7 +485,7 @@ public: } } - uint32_t GetNumberTracks(TrackType aTrack) + uint32_t GetNumberTracks(TrackType aTrack) const { MOZ_RELEASE_ASSERT(mData && mData->mInitDone); @@ -498,21 +499,21 @@ public: } } - bool IsSeekable() + bool IsSeekable() const { MOZ_RELEASE_ASSERT(mData && mData->mInitDone); return mData->mSeekable; } - bool IsSeekableOnlyInBufferedRanges() + bool IsSeekableOnlyInBufferedRanges() const { MOZ_RELEASE_ASSERT(mData && mData->mInitDone); return mData->mSeekableOnlyInBufferedRange; } - UniquePtr GetCrypto() + UniquePtr GetCrypto() const { MOZ_RELEASE_ASSERT(mData && mData->mInitDone); From 7f70113bbd2d7fc322f323dbbd390a9346d9d526 Mon Sep 17 00:00:00 2001 From: Steve Jarvis Date: Thu, 15 Dec 2016 07:47:07 -0700 Subject: [PATCH 30/64] Bug 1319762 - Remove download.xul and related unused files. r=florian Remove files and resources no longer shipped or referenced and update the appropriate packaging files. MozReview-Commit-ID: Apaa2JnOTMt --HG-- extra : rebase_source : e4f13f309fff39a5254d5cd7b53e98b51c6d21f8 --- .../base/content/downloadManagerOverlay.xul | 32 - browser/base/jar.mn | 2 - toolkit/components/downloads/moz.build | 8 - .../downloads/nsDownloadManagerUI.js | 107 -- .../downloads/nsDownloadManagerUI.manifest | 2 - .../chrome/mozapps/downloads/downloads.dtd | 52 - .../mozapps/downloads/downloads.properties | 31 - toolkit/locales/jar.mn | 1 - .../downloads/DownloadTaskbarProgress.jsm | 399 ----- .../content/DownloadProgressListener.js | 117 -- .../mozapps/downloads/content/download.xml | 327 ---- .../mozapps/downloads/content/downloads.css | 50 - .../mozapps/downloads/content/downloads.js | 1320 ----------------- .../mozapps/downloads/content/downloads.xul | 164 -- toolkit/mozapps/downloads/jar.mn | 5 - toolkit/mozapps/downloads/moz.build | 3 +- .../linux/mozapps/downloads/downloads.css | 112 -- toolkit/themes/linux/mozapps/jar.mn | 1 - .../osx/mozapps/downloads/downloads.css | 123 -- toolkit/themes/osx/mozapps/jar.mn | 1 - .../windows/mozapps/downloads/downloads.css | 139 -- toolkit/themes/windows/mozapps/jar.mn | 1 - 22 files changed, 1 insertion(+), 2996 deletions(-) delete mode 100644 browser/base/content/downloadManagerOverlay.xul delete mode 100644 toolkit/components/downloads/nsDownloadManagerUI.js delete mode 100644 toolkit/components/downloads/nsDownloadManagerUI.manifest delete mode 100644 toolkit/locales/en-US/chrome/mozapps/downloads/downloads.dtd delete mode 100644 toolkit/mozapps/downloads/DownloadTaskbarProgress.jsm delete mode 100644 toolkit/mozapps/downloads/content/DownloadProgressListener.js delete mode 100644 toolkit/mozapps/downloads/content/download.xml delete mode 100644 toolkit/mozapps/downloads/content/downloads.css delete mode 100644 toolkit/mozapps/downloads/content/downloads.js delete mode 100644 toolkit/mozapps/downloads/content/downloads.xul delete mode 100644 toolkit/themes/linux/mozapps/downloads/downloads.css delete mode 100644 toolkit/themes/osx/mozapps/downloads/downloads.css delete mode 100644 toolkit/themes/windows/mozapps/downloads/downloads.css diff --git a/browser/base/content/downloadManagerOverlay.xul b/browser/base/content/downloadManagerOverlay.xul deleted file mode 100644 index 9987820cb92e..000000000000 --- a/browser/base/content/downloadManagerOverlay.xul +++ /dev/null @@ -1,32 +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/. - - - - - - - -#include browserMountPoints.inc - - - - - - diff --git a/browser/base/jar.mn b/browser/base/jar.mn index 113b5248a589..9e7d61ca2b3b 100644 --- a/browser/base/jar.mn +++ b/browser/base/jar.mn @@ -4,7 +4,6 @@ browser.jar: % content browser %content/browser/ contentaccessible=yes #ifdef XP_MACOSX -% overlay chrome://mozapps/content/downloads/downloads.xul chrome://browser/content/downloadManagerOverlay.xul % overlay chrome://mozapps/content/update/updates.xul chrome://browser/content/softwareUpdateOverlay.xul #endif #ifdef XP_WIN @@ -174,7 +173,6 @@ browser.jar: * content/browser/hiddenWindow.xul (content/hiddenWindow.xul) #ifdef XP_MACOSX * content/browser/macBrowserOverlay.xul (content/macBrowserOverlay.xul) -* content/browser/downloadManagerOverlay.xul (content/downloadManagerOverlay.xul) * content/browser/softwareUpdateOverlay.xul (content/softwareUpdateOverlay.xul) #endif * content/browser/viewSourceOverlay.xul (content/viewSourceOverlay.xul) diff --git a/toolkit/components/downloads/moz.build b/toolkit/components/downloads/moz.build index 477db0bd6474..ce3239e325ad 100644 --- a/toolkit/components/downloads/moz.build +++ b/toolkit/components/downloads/moz.build @@ -49,14 +49,6 @@ if CONFIG['OS_ARCH'] == 'WINNT': 'nsDownloadScanner.cpp', ] -# XXX - Until Suite builds off XULRunner we can't guarantee our implementation -# of nsIDownloadManagerUI overrides toolkit's. -if not CONFIG['MOZ_SUITE']: - EXTRA_COMPONENTS += [ - 'nsDownloadManagerUI.js', - 'nsDownloadManagerUI.manifest', - ] - FINAL_LIBRARY = 'xul' LOCAL_INCLUDES += [ diff --git a/toolkit/components/downloads/nsDownloadManagerUI.js b/toolkit/components/downloads/nsDownloadManagerUI.js deleted file mode 100644 index 11e241403e76..000000000000 --- a/toolkit/components/downloads/nsDownloadManagerUI.js +++ /dev/null @@ -1,107 +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/. */ - -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); - -// Constants - -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cr = Components.results; -const DOWNLOAD_MANAGER_URL = "chrome://mozapps/content/downloads/downloads.xul"; -const PREF_FLASH_COUNT = "browser.download.manager.flashCount"; - -// nsDownloadManagerUI class - -function nsDownloadManagerUI() {} - -nsDownloadManagerUI.prototype = { - classID: Components.ID("7dfdf0d1-aff6-4a34-bad1-d0fe74601642"), - - // nsIDownloadManagerUI - - show: function show(aWindowContext, aDownload, aReason, aUsePrivateUI) - { - if (!aReason) - aReason = Ci.nsIDownloadManagerUI.REASON_USER_INTERACTED; - - // First we see if it is already visible - let window = this.recentWindow; - if (window) { - window.focus(); - - // If we are being asked to show again, with a user interaction reason, - // set the appropriate variable. - if (aReason == Ci.nsIDownloadManagerUI.REASON_USER_INTERACTED) - window.gUserInteracted = true; - return; - } - - let parent = null; - // We try to get a window to use as the parent here. If we don't have one, - // the download manager will close immediately after opening if the pref - // browser.download.manager.closeWhenDone is set to true. - try { - if (aWindowContext) - parent = aWindowContext.getInterface(Ci.nsIDOMWindow); - } catch (e) { /* it's OK to not have a parent window */ } - - // We pass the download manager and the nsIDownload we want selected (if any) - var params = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray); - params.appendElement(aDownload, false); - - // Pass in the reason as well - let reason = Cc["@mozilla.org/supports-PRInt16;1"]. - createInstance(Ci.nsISupportsPRInt16); - reason.data = aReason; - params.appendElement(reason, false); - - var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"]. - getService(Ci.nsIWindowWatcher); - ww.openWindow(parent, - DOWNLOAD_MANAGER_URL, - "Download:Manager", - "chrome,dialog=no,resizable", - params); - }, - - get visible() { - return (null != this.recentWindow); - }, - - getAttention: function getAttention() - { - if (!this.visible) - throw Cr.NS_ERROR_UNEXPECTED; - - var prefs = Cc["@mozilla.org/preferences-service;1"]. - getService(Ci.nsIPrefBranch); - // This preference may not be set, so defaulting to two. - let flashCount = 2; - try { - flashCount = prefs.getIntPref(PREF_FLASH_COUNT); - } catch (e) { } - - var win = this.recentWindow.QueryInterface(Ci.nsIDOMChromeWindow); - win.getAttentionWithCycleCount(flashCount); - }, - - // nsDownloadManagerUI - - get recentWindow() { - var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. - getService(Ci.nsIWindowMediator); - return wm.getMostRecentWindow("Download:Manager"); - }, - - // nsISupports - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIDownloadManagerUI]) -}; - -// Module - -var components = [nsDownloadManagerUI]; -this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components); - diff --git a/toolkit/components/downloads/nsDownloadManagerUI.manifest b/toolkit/components/downloads/nsDownloadManagerUI.manifest deleted file mode 100644 index 4073c23fb03b..000000000000 --- a/toolkit/components/downloads/nsDownloadManagerUI.manifest +++ /dev/null @@ -1,2 +0,0 @@ -component {7dfdf0d1-aff6-4a34-bad1-d0fe74601642} nsDownloadManagerUI.js -contract @mozilla.org/download-manager-ui;1 {7dfdf0d1-aff6-4a34-bad1-d0fe74601642} diff --git a/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.dtd b/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.dtd deleted file mode 100644 index 3c6373cfb81b..000000000000 --- a/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.dtd +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.properties b/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.properties index 3a50d17f3a7d..c712aab15179 100644 --- a/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.properties +++ b/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.properties @@ -17,8 +17,6 @@ failed=Failed finished=Finished canceled=Canceled -cannotPause=This download cannot be paused - downloadErrorAlertTitle=Download Error downloadErrorGeneric=The download cannot be saved because an unknown error occurred.\n\nPlease try again. @@ -92,51 +90,22 @@ timeLeftDouble2=%1$S, %2$S remaining timeFewSeconds=A few seconds remaining timeUnknown=Unknown time remaining -# LOCALIZATION NOTE (doneStatus): — is the "em dash" (long dash) -# #1 download size for FINISHED or download state; #2 host (e.g., eTLD + 1, IP) -# #2 can also be doneScheme or doneFileScheme for special URIs like file: -# examples: 1.1 MB — website2.com; Canceled — 222.net -doneStatus=#1 — #2 # LOCALIZATION NOTE (doneSize): #1 size number; #2 size unit doneSize=#1 #2 -doneSizeUnknown=Unknown size # LOCALIZATION NOTE (doneScheme): #1 URI scheme like data: jar: about: doneScheme2=%1$S resource # LOCALIZATION NOTE (doneFileScheme): Special case of doneScheme for file: # This is used as an eTLD replacement for local files, so make it lower case doneFileScheme=local file -stateFailed=Failed -stateCanceled=Canceled -# LOCALIZATION NOTE (stateBlocked): 'Parental Controls' should be capitalized -stateBlocked=Blocked by Parental Controls -stateDirty=Blocked: Download may contain a virus or spyware -# LOCALIZATION NOTE (stateBlockedPolicy): 'Security Zone Policy' should be capitalized - stateBlockedPolicy=This download has been blocked by your Security Zone Policy - # LOCALIZATION NOTE (yesterday): Displayed time for files finished yesterday yesterday=Yesterday # LOCALIZATION NOTE (monthDate): #1 month name; #2 date number; e.g., January 22 monthDate2=%1$S %2$S -fileDoesNotExistOpenTitle=Cannot Open %S -fileDoesNotExistShowTitle=Cannot Show %S -fileDoesNotExistError=%S does not exist. It may have been renamed, moved, or deleted since it was downloaded. - -chooseAppFilePickerTitle=Open With… - -# LOCALIZATION NOTE (downloadsTitleFiles, downloadsTitlePercent): Semi-colon list of -# plural forms. See: http://developer.mozilla.org/en/docs/Localization_and_Plurals -# #1 number of files; #2 overall download percent (only for downloadsTitlePercent) -# examples: 2% of 1 file - Downloads; 22% of 11 files - Downloads -downloadsTitleFiles=#1 file - Downloads;#1 files - Downloads -downloadsTitlePercent=#2% of #1 file - Downloads;#2% of #1 files - Downloads - fileExecutableSecurityWarning=“%S” is an executable file. Executable files may contain viruses or other malicious code that could harm your computer. Use caution when opening this file. Are you sure you want to launch “%S”? fileExecutableSecurityWarningTitle=Open Executable File? fileExecutableSecurityWarningDontAsk=Don’t ask me this again -displayNameDesktop=Desktop - # Desktop folder name for downloaded files downloadsFolder=Downloads diff --git a/toolkit/locales/jar.mn b/toolkit/locales/jar.mn index 32add622bc5b..fc602fa1b771 100644 --- a/toolkit/locales/jar.mn +++ b/toolkit/locales/jar.mn @@ -101,7 +101,6 @@ locale/@AB_CD@/mozapps/downloads/unknownContentType.properties (%chrome/mozapps/downloads/unknownContentType.properties) locale/@AB_CD@/mozapps/downloads/unknownContentType.dtd (%chrome/mozapps/downloads/unknownContentType.dtd) locale/@AB_CD@/mozapps/downloads/settingsChange.dtd (%chrome/mozapps/downloads/settingsChange.dtd) - locale/@AB_CD@/mozapps/downloads/downloads.dtd (%chrome/mozapps/downloads/downloads.dtd) locale/@AB_CD@/mozapps/downloads/downloads.properties (%chrome/mozapps/downloads/downloads.properties) locale/@AB_CD@/mozapps/extensions/extensions.dtd (%chrome/mozapps/extensions/extensions.dtd) #ifndef MOZ_FENNEC diff --git a/toolkit/mozapps/downloads/DownloadTaskbarProgress.jsm b/toolkit/mozapps/downloads/DownloadTaskbarProgress.jsm deleted file mode 100644 index 5635c78496f3..000000000000 --- a/toolkit/mozapps/downloads/DownloadTaskbarProgress.jsm +++ /dev/null @@ -1,399 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- - * vim: sw=2 ts=2 sts=2 et filetype=javascript - * 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/. */ - -this.EXPORTED_SYMBOLS = [ - "DownloadTaskbarProgress", -]; - -// Constants - -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; -const Cr = Components.results; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/AppConstants.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Services", - "resource://gre/modules/Services.jsm"); - -const kTaskbarIDWin = "@mozilla.org/windows-taskbar;1"; -const kTaskbarIDMac = "@mozilla.org/widget/macdocksupport;1"; - -// DownloadTaskbarProgress Object - -this.DownloadTaskbarProgress = -{ - init: function DTP_init() - { - if (DownloadTaskbarProgressUpdater) { - DownloadTaskbarProgressUpdater._init(); - } - }, - - /** - * Called when a browser window appears. This has an effect only when we - * don't already have an active window. - * - * @param aWindow - * The browser window that we'll potentially use to display the - * progress. - */ - onBrowserWindowLoad: function DTP_onBrowserWindowLoad(aWindow) - { - this.init(); - if (!DownloadTaskbarProgressUpdater) { - return; - } - if (!DownloadTaskbarProgressUpdater._activeTaskbarProgress) { - DownloadTaskbarProgressUpdater._setActiveWindow(aWindow, false); - } - }, - - /** - * Called when the download window appears. The download window will take - * over as the active window. - */ - onDownloadWindowLoad: function DTP_onDownloadWindowLoad(aWindow) - { - if (!DownloadTaskbarProgressUpdater) { - return; - } - DownloadTaskbarProgressUpdater._setActiveWindow(aWindow, true); - }, - - /** - * Getters for internal DownloadTaskbarProgressUpdater values - */ - - get activeTaskbarProgress() { - if (!DownloadTaskbarProgressUpdater) { - return null; - } - return DownloadTaskbarProgressUpdater._activeTaskbarProgress; - }, - - get activeWindowIsDownloadWindow() { - if (!DownloadTaskbarProgressUpdater) { - return null; - } - return DownloadTaskbarProgressUpdater._activeWindowIsDownloadWindow; - }, - - get taskbarState() { - if (!DownloadTaskbarProgressUpdater) { - return null; - } - return DownloadTaskbarProgressUpdater._taskbarState; - }, - -}; - -// DownloadTaskbarProgressUpdater Object - -var DownloadTaskbarProgressUpdater = -{ - // / Whether the taskbar is initialized. - _initialized: false, - - // / Reference to the taskbar. - _taskbar: null, - - // / Reference to the download manager. - _dm: null, - - /** - * Initialize and register ourselves as a download progress listener. - */ - _init: function DTPU_init() - { - if (this._initialized) { - return; // Already initialized - } - this._initialized = true; - - if (kTaskbarIDWin in Cc) { - this._taskbar = Cc[kTaskbarIDWin].getService(Ci.nsIWinTaskbar); - if (!this._taskbar.available) { - // The Windows version is probably too old - DownloadTaskbarProgressUpdater = null; - return; - } - } else if (kTaskbarIDMac in Cc) { - this._activeTaskbarProgress = Cc[kTaskbarIDMac]. - getService(Ci.nsITaskbarProgress); - } else { - DownloadTaskbarProgressUpdater = null; - return; - } - - this._taskbarState = Ci.nsITaskbarProgress.STATE_NO_PROGRESS; - - this._dm = Cc["@mozilla.org/download-manager;1"]. - getService(Ci.nsIDownloadManager); - this._dm.addPrivacyAwareListener(this); - - this._os = Cc["@mozilla.org/observer-service;1"]. - getService(Ci.nsIObserverService); - this._os.addObserver(this, "quit-application-granted", false); - - this._updateStatus(); - // onBrowserWindowLoad/onDownloadWindowLoad are going to set the active - // window, so don't do it here. - }, - - /** - * Unregisters ourselves as a download progress listener. - */ - _uninit: function DTPU_uninit() { - this._dm.removeListener(this); - this._os.removeObserver(this, "quit-application-granted"); - this._activeTaskbarProgress = null; - this._initialized = false; - }, - - /** - * This holds a reference to the taskbar progress for the window we're - * working with. This window would preferably be download window, but can be - * another window if it isn't open. - */ - _activeTaskbarProgress: null, - - // / Whether the active window is the download window - _activeWindowIsDownloadWindow: false, - - /** - * Sets the active window, and whether it's the download window. This takes - * care of clearing out the previous active window's taskbar item, updating - * the taskbar, and setting an onunload listener. - * - * @param aWindow - * The window to set as active. - * @param aIsDownloadWindow - * Whether this window is a download window. - */ - _setActiveWindow: function DTPU_setActiveWindow(aWindow, aIsDownloadWindow) - { - if (AppConstants.platform == "win") { - // Clear out the taskbar for the old active window. (If there was no active - // window, this is a no-op.) - this._clearTaskbar(); - - this._activeWindowIsDownloadWindow = aIsDownloadWindow; - if (aWindow) { - // Get the taskbar progress for this window - let docShell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIWebNavigation). - QueryInterface(Ci.nsIDocShellTreeItem).treeOwner. - QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIXULWindow).docShell; - let taskbarProgress = this._taskbar.getTaskbarProgress(docShell); - this._activeTaskbarProgress = taskbarProgress; - - this._updateTaskbar(); - // _onActiveWindowUnload is idempotent, so we don't need to check whether - // we've already set this before or not. - aWindow.addEventListener("unload", function() { - DownloadTaskbarProgressUpdater._onActiveWindowUnload(taskbarProgress); - }, false); - } - else { - this._activeTaskbarProgress = null; - } - } - }, - - // / Current state displayed on the active window's taskbar item - _taskbarState: null, - _totalSize: 0, - _totalTransferred: 0, - - _shouldSetState: function DTPU_shouldSetState() - { - if (AppConstants.platform == "win") { - // If the active window is not the download manager window, set the state - // only if it is normal or indeterminate. - return this._activeWindowIsDownloadWindow || - (this._taskbarState == Ci.nsITaskbarProgress.STATE_NORMAL || - this._taskbarState == Ci.nsITaskbarProgress.STATE_INDETERMINATE); - } - return true; - }, - - /** - * Update the active window's taskbar indicator with the current state. There - * are two cases here: - * 1. If the active window is the download window, then we always update - * the taskbar indicator. - * 2. If the active window isn't the download window, then we update only if - * the status is normal or indeterminate. i.e. one or more downloads are - * currently progressing or in scan mode. If we aren't, then we clear the - * indicator. - */ - _updateTaskbar: function DTPU_updateTaskbar() - { - if (!this._activeTaskbarProgress) { - return; - } - - if (this._shouldSetState()) { - this._activeTaskbarProgress.setProgressState(this._taskbarState, - this._totalTransferred, - this._totalSize); - } - // Clear any state otherwise - else { - this._clearTaskbar(); - } - }, - - /** - * Clear taskbar state. This is needed: - * - to transfer the indicator off a window before transferring it onto - * another one - * - whenever we don't want to show it for a non-download window. - */ - _clearTaskbar: function DTPU_clearTaskbar() - { - if (this._activeTaskbarProgress) { - this._activeTaskbarProgress.setProgressState( - Ci.nsITaskbarProgress.STATE_NO_PROGRESS - ); - } - }, - - /** - * Update this._taskbarState, this._totalSize and this._totalTransferred. - * This is called when the download manager is initialized or when the - * progress or state of a download changes. - * We compute the number of active and paused downloads, and the total size - * and total amount already transferred across whichever downloads we have - * the data for. - * - If there are no active downloads, then we don't want to show any - * progress. - * - If the number of active downloads is equal to the number of paused - * downloads, then we show a paused indicator if we know the size of at - * least one download, and no indicator if we don't. - * - If the number of active downloads is more than the number of paused - * downloads, then we show a "normal" indicator if we know the size of at - * least one download, and an indeterminate indicator if we don't. - */ - _updateStatus: function DTPU_updateStatus() - { - let numActive = this._dm.activeDownloadCount + this._dm.activePrivateDownloadCount; - let totalSize = 0, totalTransferred = 0; - - if (numActive == 0) { - this._taskbarState = Ci.nsITaskbarProgress.STATE_NO_PROGRESS; - } - else { - let numPaused = 0, numScanning = 0; - - // Enumerate all active downloads - [this._dm.activeDownloads, this._dm.activePrivateDownloads].forEach(function(downloads) { - while (downloads.hasMoreElements()) { - let download = downloads.getNext().QueryInterface(Ci.nsIDownload); - // Only set values if we actually know the download size - if (download.percentComplete != -1) { - totalSize += download.size; - totalTransferred += download.amountTransferred; - } - // We might need to display a paused state, so track this - if (download.state == this._dm.DOWNLOAD_PAUSED) { - numPaused++; - } else if (download.state == this._dm.DOWNLOAD_SCANNING) { - numScanning++; - } - } - }.bind(this)); - - // If all downloads are paused, show the progress as paused, unless we - // don't have any information about sizes, in which case we don't - // display anything - if (numActive == numPaused) { - if (totalSize == 0) { - this._taskbarState = Ci.nsITaskbarProgress.STATE_NO_PROGRESS; - totalTransferred = 0; - } - else { - this._taskbarState = Ci.nsITaskbarProgress.STATE_PAUSED; - } - } - // If at least one download is not paused, and we don't have any - // information about download sizes, display an indeterminate indicator - else if (totalSize == 0 || numActive == numScanning) { - this._taskbarState = Ci.nsITaskbarProgress.STATE_INDETERMINATE; - totalSize = 0; - totalTransferred = 0; - } - // Otherwise display a normal progress bar - else { - this._taskbarState = Ci.nsITaskbarProgress.STATE_NORMAL; - } - } - - this._totalSize = totalSize; - this._totalTransferred = totalTransferred; - }, - - /** - * Called when a window that at one point has been an active window is - * closed. If this window is currently the active window, we need to look for - * another window and make that our active window. - * - * This function is idempotent, so multiple calls for the same window are not - * a problem. - * - * @param aTaskbarProgress - * The taskbar progress for the window that is being unloaded. - */ - _onActiveWindowUnload: function DTPU_onActiveWindowUnload(aTaskbarProgress) - { - if (this._activeTaskbarProgress == aTaskbarProgress) { - let windowMediator = Cc["@mozilla.org/appshell/window-mediator;1"]. - getService(Ci.nsIWindowMediator); - let windows = windowMediator.getEnumerator(null); - let newActiveWindow = null; - if (windows.hasMoreElements()) { - newActiveWindow = windows.getNext().QueryInterface(Ci.nsIDOMWindow); - } - - // We aren't ever going to reach this point while the download manager is - // open, so it's safe to assume false for the second operand - this._setActiveWindow(newActiveWindow, false); - } - }, - - // nsIDownloadProgressListener - - /** - * Update status if a download's progress has changed. - */ - onProgressChange: function DTPU_onProgressChange() - { - this._updateStatus(); - this._updateTaskbar(); - }, - - /** - * Update status if a download's state has changed. - */ - onDownloadStateChange: function DTPU_onDownloadStateChange() - { - this._updateStatus(); - this._updateTaskbar(); - }, - - onSecurityChange: function() { }, - - onStateChange: function() { }, - - observe: function DTPU_observe(aSubject, aTopic, aData) { - if (aTopic == "quit-application-granted") { - this._uninit(); - } - } -}; diff --git a/toolkit/mozapps/downloads/content/DownloadProgressListener.js b/toolkit/mozapps/downloads/content/DownloadProgressListener.js deleted file mode 100644 index ab349baf291d..000000000000 --- a/toolkit/mozapps/downloads/content/DownloadProgressListener.js +++ /dev/null @@ -1,117 +0,0 @@ -// -*- 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/. */ - -/** - * DownloadProgressListener "class" is used to help update download items shown - * in the Download Manager UI such as displaying amount transferred, transfer - * rate, and time left for each download. - * - * This class implements the nsIDownloadProgressListener interface. - */ -function DownloadProgressListener() {} - -DownloadProgressListener.prototype = { - // nsISupports - - QueryInterface: XPCOMUtils.generateQI([Ci.nsIDownloadProgressListener]), - - // nsIDownloadProgressListener - - onDownloadStateChange: function dlPL_onDownloadStateChange(aState, aDownload) - { - // Update window title in-case we don't get all progress notifications - onUpdateProgress(); - - let dl; - let state = aDownload.state; - switch (state) { - case nsIDM.DOWNLOAD_QUEUED: - prependList(aDownload); - break; - - case nsIDM.DOWNLOAD_BLOCKED_POLICY: - prependList(aDownload); - // Should fall through, this is a final state but DOWNLOAD_QUEUED - // is skipped. See nsDownloadManager::AddDownload. - case nsIDM.DOWNLOAD_FAILED: - case nsIDM.DOWNLOAD_CANCELED: - case nsIDM.DOWNLOAD_BLOCKED_PARENTAL: - case nsIDM.DOWNLOAD_DIRTY: - case nsIDM.DOWNLOAD_FINISHED: - downloadCompleted(aDownload); - if (state == nsIDM.DOWNLOAD_FINISHED) - autoRemoveAndClose(aDownload); - break; - case nsIDM.DOWNLOAD_DOWNLOADING: { - dl = getDownload(aDownload.id); - - // At this point, we know if we are an indeterminate download or not - dl.setAttribute("progressmode", aDownload.percentComplete == -1 ? - "undetermined" : "normal"); - - // As well as knowing the referrer - let referrer = aDownload.referrer; - if (referrer) - dl.setAttribute("referrer", referrer.spec); - - break; - } - } - - // autoRemoveAndClose could have already closed our window... - try { - if (!dl) - dl = getDownload(aDownload.id); - - // Update to the new state - dl.setAttribute("state", state); - - // Update ui text values after switching states - updateTime(dl); - updateStatus(dl); - updateButtons(dl); - } catch (e) { } - }, - - onProgressChange: function dlPL_onProgressChange(aWebProgress, aRequest, - aCurSelfProgress, - aMaxSelfProgress, - aCurTotalProgress, - aMaxTotalProgress, aDownload) - { - var download = getDownload(aDownload.id); - - // Update this download's progressmeter - if (aDownload.percentComplete != -1) { - download.setAttribute("progress", aDownload.percentComplete); - - // Dispatch ValueChange for a11y - let event = document.createEvent("Events"); - event.initEvent("ValueChange", true, true); - document.getAnonymousElementByAttribute(download, "anonid", "progressmeter") - .dispatchEvent(event); - } - - // Update the progress so the status can be correctly updated - download.setAttribute("currBytes", aDownload.amountTransferred); - download.setAttribute("maxBytes", aDownload.size); - - // Update the rest of the UI (bytes transferred, bytes total, download rate, - // time remaining). - updateStatus(download, aDownload); - - // Update window title - onUpdateProgress(); - }, - - onStateChange: function(aWebProgress, aRequest, aState, aStatus, aDownload) - { - }, - - onSecurityChange: function(aWebProgress, aRequest, aState, aDownload) - { - } -}; diff --git a/toolkit/mozapps/downloads/content/download.xml b/toolkit/mozapps/downloads/content/download.xml deleted file mode 100644 index 1d4b87270ab8..000000000000 --- a/toolkit/mozapps/downloads/content/download.xml +++ /dev/null @@ -1,327 +0,0 @@ - - - - - - %downloadDTD; -]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/mozapps/downloads/content/downloads.css b/toolkit/mozapps/downloads/content/downloads.css deleted file mode 100644 index dcb648d6233c..000000000000 --- a/toolkit/mozapps/downloads/content/downloads.css +++ /dev/null @@ -1,50 +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/. */ - -richlistitem[type="download"] { - -moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-starting'); - -moz-box-orient: vertical; -} - -richlistitem[type="download"][state="0"] { - -moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-downloading'); -} - -richlistitem[type="download"][state="1"] { - -moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-done'); -} - -richlistitem[type="download"][state="2"] { - -moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-failed'); -} - -richlistitem[type="download"][state="3"] { - -moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-canceled'); -} - -richlistitem[type="download"][state="4"] { - -moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-paused'); -} - -richlistitem[type="download"][state="6"] { - -moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-blocked-parental'); -} - -richlistitem[type="download"][state="7"] { - -moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-scanning'); -} - -richlistitem[type="download"][state="8"] { - -moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-dirty'); -} - -richlistitem[type="download"][state="9"] { - -moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-blocked-policy'); -} - -/* Only focus buttons in the selected item*/ -richlistitem[type="download"]:not([selected="true"]) button { - -moz-user-focus: none; -} - diff --git a/toolkit/mozapps/downloads/content/downloads.js b/toolkit/mozapps/downloads/content/downloads.js deleted file mode 100644 index 0ea4836b0a61..000000000000 --- a/toolkit/mozapps/downloads/content/downloads.js +++ /dev/null @@ -1,1320 +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/. */ - -"use strict"; - -// Globals - -const PREF_BDM_CLOSEWHENDONE = "browser.download.manager.closeWhenDone"; -const PREF_BDM_ALERTONEXEOPEN = "browser.download.manager.alertOnEXEOpen"; -const PREF_BDM_SCANWHENDONE = "browser.download.manager.scanWhenDone"; - -const nsLocalFile = Components.Constructor("@mozilla.org/file/local;1", - "nsILocalFile", "initWithPath"); - -var Cc = Components.classes; -var Ci = Components.interfaces; -var Cu = Components.utils; -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/DownloadUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/AppConstants.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "PluralForm", - "resource://gre/modules/PluralForm.jsm"); - -const nsIDM = Ci.nsIDownloadManager; - -var gDownloadManager = Cc["@mozilla.org/download-manager;1"].getService(nsIDM); -var gDownloadManagerUI = Cc["@mozilla.org/download-manager-ui;1"]. - getService(Ci.nsIDownloadManagerUI); - -var gDownloadListener = null; -var gDownloadsView = null; -var gSearchBox = null; -var gSearchTerms = []; -var gBuilder = 0; - -// This variable is used when performing commands on download items and gives -// the command the ability to do something after all items have been operated -// on. The following convention is used to handle the value of the variable: -// whenever we aren't performing a command, the value is |undefined|; just -// before executing commands, the value will be set to |null|; and when -// commands want to create a callback, they set the value to be a callback -// function to be executed after all download items have been visited. -var gPerformAllCallback; - -// Control the performance of the incremental list building by setting how many -// milliseconds to wait before building more of the list and how many items to -// add between each delay. -const gListBuildDelay = 300; -const gListBuildChunk = 3; - -// Array of download richlistitem attributes to check when searching -const gSearchAttributes = [ - "target", - "status", - "dateTime", -]; - -// If the user has interacted with the window in a significant way, we should -// not auto-close the window. Tough UI decisions about what is "significant." -var gUserInteracted = false; - -// These strings will be converted to the corresponding ones from the string -// bundle on startup. -var gStr = { - paused: "paused", - cannotPause: "cannotPause", - doneStatus: "doneStatus", - doneSize: "doneSize", - doneSizeUnknown: "doneSizeUnknown", - stateFailed: "stateFailed", - stateCanceled: "stateCanceled", - stateBlockedParentalControls: "stateBlocked", - stateBlockedPolicy: "stateBlockedPolicy", - stateDirty: "stateDirty", - downloadsTitleFiles: "downloadsTitleFiles", - downloadsTitlePercent: "downloadsTitlePercent", - fileExecutableSecurityWarningTitle: "fileExecutableSecurityWarningTitle", - fileExecutableSecurityWarningDontAsk: "fileExecutableSecurityWarningDontAsk" -}; - -// The statement to query for downloads that are active or match the search -var gStmt = null; - -// Start/Stop Observers - -function downloadCompleted(aDownload) -{ - // The download is changing state, so update the clear list button - updateClearListButton(); - - // Wrap this in try...catch since this can be called while shutting down... - // it doesn't really matter if it fails then since well.. we're shutting down - // and there's no UI to update! - try { - let dl = getDownload(aDownload.id); - - // Update attributes now that we've finished - dl.setAttribute("startTime", Math.round(aDownload.startTime / 1000)); - dl.setAttribute("endTime", Date.now()); - dl.setAttribute("currBytes", aDownload.amountTransferred); - dl.setAttribute("maxBytes", aDownload.size); - - // Move the download below active if it should stay in the list - if (downloadMatchesSearch(dl)) { - // Iterate down until we find a non-active download - let next = dl.nextSibling; - while (next && next.inProgress) - next = next.nextSibling; - - // Move the item - gDownloadsView.insertBefore(dl, next); - } else { - removeFromView(dl); - } - - // getTypeFromFile fails if it can't find a type for this file. - try { - // Refresh the icon, so that executable icons are shown. - var mimeService = Cc["@mozilla.org/mime;1"]. - getService(Ci.nsIMIMEService); - var contentType = mimeService.getTypeFromFile(aDownload.targetFile); - - var listItem = getDownload(aDownload.id) - var oldImage = listItem.getAttribute("image"); - // Tacking on contentType bypasses cache - listItem.setAttribute("image", oldImage + "&contentType=" + contentType); - } catch (e) { } - - if (gDownloadManager.activeDownloadCount == 0) - document.title = document.documentElement.getAttribute("statictitle"); - - gDownloadManagerUI.getAttention(); - } - catch (e) { } -} - -function autoRemoveAndClose(aDownload) -{ - var pref = Cc["@mozilla.org/preferences-service;1"]. - getService(Ci.nsIPrefBranch); - - if (gDownloadManager.activeDownloadCount == 0) { - // For the moment, just use the simple heuristic that if this window was - // opened by the download process, rather than by the user, it should - // auto-close if the pref is set that way. If the user opened it themselves, - // it should not close until they explicitly close it. Additionally, the - // preference to control the feature may not be set, so defaulting to - // keeping the window open. - let autoClose = false; - try { - autoClose = pref.getBoolPref(PREF_BDM_CLOSEWHENDONE); - } catch (e) { } - var autoOpened = - !window.opener || window.opener.location.href == window.location.href; - if (autoClose && autoOpened && !gUserInteracted) { - gCloseDownloadManager(); - return true; - } - } - - return false; -} - -// This function can be overwritten by extensions that wish to place the -// Download Window in another part of the UI. -function gCloseDownloadManager() -{ - window.close(); -} - -// Download Event Handlers - -function cancelDownload(aDownload) -{ - gDownloadManager.cancelDownload(aDownload.getAttribute("dlid")); - - // XXXben - - // If we got here because we resumed the download, we weren't using a temp file - // because we used saveURL instead. (this is because the proper download mechanism - // employed by the helper app service isn't fully accessible yet... should be fixed... - // talk to bz...) - // the upshot is we have to delete the file if it exists. - var f = getLocalFileFromNativePathOrUrl(aDownload.getAttribute("file")); - - if (f.exists()) - f.remove(false); -} - -function pauseDownload(aDownload) -{ - var id = aDownload.getAttribute("dlid"); - gDownloadManager.pauseDownload(id); -} - -function resumeDownload(aDownload) -{ - gDownloadManager.resumeDownload(aDownload.getAttribute("dlid")); -} - -function removeDownload(aDownload) -{ - gDownloadManager.removeDownload(aDownload.getAttribute("dlid")); -} - -function retryDownload(aDownload) -{ - removeFromView(aDownload); - gDownloadManager.retryDownload(aDownload.getAttribute("dlid")); -} - -function showDownload(aDownload) -{ - var f = getLocalFileFromNativePathOrUrl(aDownload.getAttribute("file")); - - try { - // Show the directory containing the file and select the file - f.reveal(); - } catch (e) { - // If reveal fails for some reason (e.g., it's not implemented on unix or - // the file doesn't exist), try using the parent if we have it. - let parent = f.parent.QueryInterface(Ci.nsILocalFile); - if (!parent) - return; - - try { - // "Double click" the parent directory to show where the file should be - parent.launch(); - } catch (e) { - // If launch also fails (probably because it's not implemented), let the - // OS handler try to open the parent - openExternal(parent); - } - } -} - -function onDownloadDblClick(aEvent) -{ - // Only do the default action for double primary clicks - if (aEvent.button == 0 && aEvent.target.selected) - doDefaultForSelected(); -} - -function openDownload(aDownload) -{ - var f = getLocalFileFromNativePathOrUrl(aDownload.getAttribute("file")); - if (f.isExecutable()) { - var dontAsk = false; - var pref = Cc["@mozilla.org/preferences-service;1"]. - getService(Ci.nsIPrefBranch); - try { - dontAsk = !pref.getBoolPref(PREF_BDM_ALERTONEXEOPEN); - } catch (e) { } - - if (AppConstants.platform == "win") { - // On Vista and above, we rely on native security prompting for - // downloaded content unless it's disabled. - try { - var sysInfo = Cc["@mozilla.org/system-info;1"]. - getService(Ci.nsIPropertyBag2); - if (parseFloat(sysInfo.getProperty("version")) >= 6 && - pref.getBoolPref(PREF_BDM_SCANWHENDONE)) { - dontAsk = true; - } - } catch (ex) { } - } - - if (!dontAsk) { - var strings = document.getElementById("downloadStrings"); - var name = aDownload.getAttribute("target"); - var message = strings.getFormattedString("fileExecutableSecurityWarning", [name, name]); - - let title = gStr.fileExecutableSecurityWarningTitle; - let dontAsk = gStr.fileExecutableSecurityWarningDontAsk; - - var promptSvc = Cc["@mozilla.org/embedcomp/prompt-service;1"]. - getService(Ci.nsIPromptService); - var checkbox = { value: false }; - var open = promptSvc.confirmCheck(window, title, message, dontAsk, checkbox); - - if (!open) - return; - pref.setBoolPref(PREF_BDM_ALERTONEXEOPEN, !checkbox.value); - } - } - try { - try { - let download = gDownloadManager.getDownload(aDownload.getAttribute("dlid")); - let mimeInfo = download.MIMEInfo; - if (mimeInfo.preferredAction == mimeInfo.useHelperApp) { - mimeInfo.launchWithFile(f); - return; - } - } catch (ex) { - } - f.launch(); - } catch (ex) { - // if launch fails, try sending it through the system's external - // file: URL handler - openExternal(f); - } -} - -function openReferrer(aDownload) -{ - openURL(getReferrerOrSource(aDownload)); -} - -function copySourceLocation(aDownload) -{ - var uri = aDownload.getAttribute("uri"); - var clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"]. - getService(Ci.nsIClipboardHelper); - - // Check if we should initialize a callback - if (gPerformAllCallback === null) { - let uris = []; - gPerformAllCallback = aURI => aURI ? uris.push(aURI) : - clipboard.copyString(uris.join("\n")); - } - - // We have a callback to use, so use it to add a uri - if (typeof gPerformAllCallback == "function") - gPerformAllCallback(uri); - else { - // It's a plain copy source, so copy it - clipboard.copyString(uri); - } -} - -/** - * Remove the currently shown downloads from the download list. - */ -function clearDownloadList() { - // Clear the whole list if there's no search - if (gSearchTerms == "") { - gDownloadManager.cleanUp(); - return; - } - - // Remove each download starting from the end until we hit a download - // that is in progress - let item; - while ((item = gDownloadsView.lastChild) && !item.inProgress) - removeDownload(item); - - // Clear the input as if the user did it and move focus to the list - gSearchBox.value = ""; - gSearchBox.doCommand(); - gDownloadsView.focus(); -} - -// This is called by the progress listener. -var gLastComputedMean = -1; -var gLastActiveDownloads = 0; -function onUpdateProgress() -{ - let numActiveDownloads = gDownloadManager.activeDownloadCount; - - // Use the default title and reset "last" values if there's no downloads - if (numActiveDownloads == 0) { - document.title = document.documentElement.getAttribute("statictitle"); - gLastComputedMean = -1; - gLastActiveDownloads = 0; - - return; - } - - // Establish the mean transfer speed and amount downloaded. - var mean = 0; - var base = 0; - var dls = gDownloadManager.activeDownloads; - while (dls.hasMoreElements()) { - let dl = dls.getNext(); - if (dl.percentComplete < 100 && dl.size > 0) { - mean += dl.amountTransferred; - base += dl.size; - } - } - - // Calculate the percent transferred, unless we don't have a total file size - let title = gStr.downloadsTitlePercent; - if (base == 0) - title = gStr.downloadsTitleFiles; - else - mean = Math.floor((mean / base) * 100); - - // Update title of window - if (mean != gLastComputedMean || gLastActiveDownloads != numActiveDownloads) { - gLastComputedMean = mean; - gLastActiveDownloads = numActiveDownloads; - - // Get the correct plural form and insert number of downloads and percent - title = PluralForm.get(numActiveDownloads, title); - title = replaceInsert(title, 1, numActiveDownloads); - title = replaceInsert(title, 2, mean); - - document.title = title; - } -} - -// Startup, Shutdown - -function Startup() -{ - gDownloadsView = document.getElementById("downloadView"); - gSearchBox = document.getElementById("searchbox"); - - // convert strings to those in the string bundle - let sb = document.getElementById("downloadStrings"); - let getStr = string => sb.getString(string); - for (let [name, value] of Object.entries(gStr)) - gStr[name] = typeof value == "string" ? getStr(value) : value.map(getStr); - - initStatement(); - buildDownloadList(true); - - // The DownloadProgressListener (DownloadProgressListener.js) handles progress - // notifications. - gDownloadListener = new DownloadProgressListener(); - gDownloadManager.addListener(gDownloadListener); - - // If the UI was displayed because the user interacted, we need to make sure - // we update gUserInteracted accordingly. - if (window.arguments[1] == Ci.nsIDownloadManagerUI.REASON_USER_INTERACTED) - gUserInteracted = true; - - // downloads can finish before Startup() does, so check if the window should - // close and act accordingly - if (!autoRemoveAndClose()) - gDownloadsView.focus(); - - let obs = Cc["@mozilla.org/observer-service;1"]. - getService(Ci.nsIObserverService); - obs.addObserver(gDownloadObserver, "download-manager-remove-download", false); - obs.addObserver(gDownloadObserver, "browser-lastwindow-close-granted", false); - - // Clear the search box and move focus to the list on escape from the box - gSearchBox.addEventListener("keypress", function(e) { - if (e.keyCode == e.DOM_VK_ESCAPE) { - // Move focus to the list instead of closing the window - gDownloadsView.focus(); - e.preventDefault(); - } - }, false); - - let DownloadTaskbarProgress = - Cu.import("resource://gre/modules/DownloadTaskbarProgress.jsm", {}).DownloadTaskbarProgress; - DownloadTaskbarProgress.onDownloadWindowLoad(window); -} - -function Shutdown() -{ - gDownloadManager.removeListener(gDownloadListener); - - let obs = Cc["@mozilla.org/observer-service;1"]. - getService(Ci.nsIObserverService); - obs.removeObserver(gDownloadObserver, "download-manager-remove-download"); - obs.removeObserver(gDownloadObserver, "browser-lastwindow-close-granted"); - - clearTimeout(gBuilder); - gStmt.reset(); - gStmt.finalize(); -} - -var gDownloadObserver = { - observe: function gdo_observe(aSubject, aTopic, aData) { - switch (aTopic) { - case "download-manager-remove-download": - // A null subject here indicates "remove multiple", so we just rebuild. - if (!aSubject) { - // Rebuild the default view - buildDownloadList(true); - break; - } - - // Otherwise, remove a single download - let id = aSubject.QueryInterface(Ci.nsISupportsPRUint32); - let dl = getDownload(id.data); - removeFromView(dl); - break; - case "browser-lastwindow-close-granted": - if (AppConstants.platform != "macosx" && - gDownloadManager.activeDownloadCount == 0) { - setTimeout(gCloseDownloadManager, 0); - } - break; - } - } -}; - -// View Context Menus - -var gContextMenus = [ - // DOWNLOAD_DOWNLOADING - [ - "menuitem_pause" - , "menuitem_cancel" - , "menuseparator" - , "menuitem_show" - , "menuseparator" - , "menuitem_openReferrer" - , "menuitem_copyLocation" - , "menuseparator" - , "menuitem_selectAll" - ], - // DOWNLOAD_FINISHED - [ - "menuitem_open" - , "menuitem_show" - , "menuseparator" - , "menuitem_openReferrer" - , "menuitem_copyLocation" - , "menuseparator" - , "menuitem_selectAll" - , "menuseparator" - , "menuitem_removeFromList" - ], - // DOWNLOAD_FAILED - [ - "menuitem_retry" - , "menuseparator" - , "menuitem_openReferrer" - , "menuitem_copyLocation" - , "menuseparator" - , "menuitem_selectAll" - , "menuseparator" - , "menuitem_removeFromList" - ], - // DOWNLOAD_CANCELED - [ - "menuitem_retry" - , "menuseparator" - , "menuitem_openReferrer" - , "menuitem_copyLocation" - , "menuseparator" - , "menuitem_selectAll" - , "menuseparator" - , "menuitem_removeFromList" - ], - // DOWNLOAD_PAUSED - [ - "menuitem_resume" - , "menuitem_cancel" - , "menuseparator" - , "menuitem_show" - , "menuseparator" - , "menuitem_openReferrer" - , "menuitem_copyLocation" - , "menuseparator" - , "menuitem_selectAll" - ], - // DOWNLOAD_QUEUED - [ - "menuitem_cancel" - , "menuseparator" - , "menuitem_show" - , "menuseparator" - , "menuitem_openReferrer" - , "menuitem_copyLocation" - , "menuseparator" - , "menuitem_selectAll" - ], - // DOWNLOAD_BLOCKED_PARENTAL - [ - "menuitem_openReferrer" - , "menuitem_copyLocation" - , "menuseparator" - , "menuitem_selectAll" - , "menuseparator" - , "menuitem_removeFromList" - ], - // DOWNLOAD_SCANNING - [ - "menuitem_show" - , "menuseparator" - , "menuitem_openReferrer" - , "menuitem_copyLocation" - , "menuseparator" - , "menuitem_selectAll" - ], - // DOWNLOAD_DIRTY - [ - "menuitem_openReferrer" - , "menuitem_copyLocation" - , "menuseparator" - , "menuitem_selectAll" - , "menuseparator" - , "menuitem_removeFromList" - ], - // DOWNLOAD_BLOCKED_POLICY - [ - "menuitem_openReferrer" - , "menuitem_copyLocation" - , "menuseparator" - , "menuitem_selectAll" - , "menuseparator" - , "menuitem_removeFromList" - ] -]; - -function buildContextMenu(aEvent) -{ - if (aEvent.target.id != "downloadContextMenu") - return false; - - var popup = document.getElementById("downloadContextMenu"); - while (popup.hasChildNodes()) - popup.removeChild(popup.firstChild); - - if (gDownloadsView.selectedItem) { - let dl = gDownloadsView.selectedItem; - let idx = parseInt(dl.getAttribute("state")); - if (idx < 0) - idx = 0; - - var menus = gContextMenus[idx]; - for (let i = 0; i < menus.length; ++i) { - let menuitem = document.getElementById(menus[i]).cloneNode(true); - let cmd = menuitem.getAttribute("cmd"); - if (cmd) - menuitem.disabled = !gDownloadViewController.isCommandEnabled(cmd, dl); - - popup.appendChild(menuitem); - } - - return true; - } - - return false; -} -// Drag and Drop -var gDownloadDNDObserver = -{ - onDragStart: function(aEvent) - { - if (!gDownloadsView.selectedItem) - return; - var dl = gDownloadsView.selectedItem; - var f = getLocalFileFromNativePathOrUrl(dl.getAttribute("file")); - if (!f.exists()) - return; - - var dt = aEvent.dataTransfer; - dt.mozSetDataAt("application/x-moz-file", f, 0); - var url = Services.io.newFileURI(f).spec; - dt.setData("text/uri-list", url); - dt.setData("text/plain", url); - dt.effectAllowed = "copyMove"; - dt.addElement(dl); - }, - - onDragOver: function(aEvent) - { - var types = aEvent.dataTransfer.types; - if (types.includes("text/uri-list") || - types.includes("text/x-moz-url") || - types.includes("text/plain")) - aEvent.preventDefault(); - }, - - onDrop: function(aEvent) - { - var dt = aEvent.dataTransfer; - // If dragged item is from our source, do not try to - // redownload already downloaded file. - if (dt.mozGetDataAt("application/x-moz-file", 0)) - return; - - var url = dt.getData("URL"); - var name; - if (!url) { - url = dt.getData("text/x-moz-url") || dt.getData("text/plain"); - [url, name] = url.split("\n"); - } - if (url) { - let sourceDoc = dt.mozSourceNode ? dt.mozSourceNode.ownerDocument : document; - saveURL(url, name ? name : url, null, true, true, null, sourceDoc); - } - } -} - -function pasteHandler() { - let trans = Cc["@mozilla.org/widget/transferable;1"]. - createInstance(Ci.nsITransferable); - trans.init(null); - let flavors = ["text/x-moz-url", "text/unicode"]; - flavors.forEach(trans.addDataFlavor); - - Services.clipboard.getData(trans, Services.clipboard.kGlobalClipboard); - - // Getting the data or creating the nsIURI might fail - try { - let data = {}; - trans.getAnyTransferData({}, data, {}); - let [url, name] = data.value.QueryInterface(Ci.nsISupportsString).data.split("\n"); - - if (!url) - return; - - let uri = Services.io.newURI(url, null, null); - - saveURL(uri.spec, name || uri.spec, null, true, true, null, document); - } catch (ex) {} -} - -// Command Updating and Command Handlers - -var gDownloadViewController = { - isCommandEnabled: function(aCommand, aItem) - { - let dl = aItem; - let download = null; // used for getting an nsIDownload object - - switch (aCommand) { - case "cmd_cancel": - return dl.inProgress; - case "cmd_open": { - let file = getLocalFileFromNativePathOrUrl(dl.getAttribute("file")); - return dl.openable && file.exists(); - } - case "cmd_show": { - let file = getLocalFileFromNativePathOrUrl(dl.getAttribute("file")); - return file.exists(); - } - case "cmd_pause": - download = gDownloadManager.getDownload(dl.getAttribute("dlid")); - return dl.inProgress && !dl.paused && download.resumable; - case "cmd_pauseResume": - download = gDownloadManager.getDownload(dl.getAttribute("dlid")); - return (dl.inProgress || dl.paused) && download.resumable; - case "cmd_resume": - download = gDownloadManager.getDownload(dl.getAttribute("dlid")); - return dl.paused && download.resumable; - case "cmd_openReferrer": - return dl.hasAttribute("referrer"); - case "cmd_removeFromList": - case "cmd_retry": - return dl.removable; - case "cmd_copyLocation": - return true; - } - return false; - }, - - doCommand: function(aCommand, aItem) - { - if (this.isCommandEnabled(aCommand, aItem)) - this.commands[aCommand](aItem); - }, - - commands: { - cmd_cancel: function(aSelectedItem) { - cancelDownload(aSelectedItem); - }, - cmd_open: function(aSelectedItem) { - openDownload(aSelectedItem); - }, - cmd_openReferrer: function(aSelectedItem) { - openReferrer(aSelectedItem); - }, - cmd_pause: function(aSelectedItem) { - pauseDownload(aSelectedItem); - }, - cmd_pauseResume: function(aSelectedItem) { - if (aSelectedItem.paused) - this.cmd_resume(aSelectedItem); - else - this.cmd_pause(aSelectedItem); - }, - cmd_removeFromList: function(aSelectedItem) { - removeDownload(aSelectedItem); - }, - cmd_resume: function(aSelectedItem) { - resumeDownload(aSelectedItem); - }, - cmd_retry: function(aSelectedItem) { - retryDownload(aSelectedItem); - }, - cmd_show: function(aSelectedItem) { - showDownload(aSelectedItem); - }, - cmd_copyLocation: function(aSelectedItem) { - copySourceLocation(aSelectedItem); - }, - } -}; - -/** - * Helper function to do commands. - * - * @param aCmd - * The command to be performed. - * @param aItem - * The richlistitem that represents the download that will have the - * command performed on it. If this is null, the command is performed on - * all downloads. If the item passed in is not a richlistitem that - * represents a download, it will walk up the parent nodes until it finds - * a DOM node that is. - */ -function performCommand(aCmd, aItem) -{ - let elm = aItem; - if (!elm) { - // If we don't have a desired download item, do the command for all - // selected items. Initialize the callback to null so commands know to add - // a callback if they want. We will call the callback with empty arguments - // after performing the command on each selected download item. - gPerformAllCallback = null; - - // Convert the nodelist into an array to keep a copy of the download items - let items = []; - for (let i = gDownloadsView.selectedItems.length; --i >= 0; ) - items.unshift(gDownloadsView.selectedItems[i]); - - // Do the command for each download item - for (let item of items) - performCommand(aCmd, item); - - // Call the callback with no arguments and reset because we're done - if (typeof gPerformAllCallback == "function") - gPerformAllCallback(); - gPerformAllCallback = undefined; - - return; - } - while (elm.nodeName != "richlistitem" || - elm.getAttribute("type") != "download") { - elm = elm.parentNode; - } - - gDownloadViewController.doCommand(aCmd, elm); -} - -function setSearchboxFocus() -{ - gSearchBox.focus(); - gSearchBox.select(); -} - -function openExternal(aFile) -{ - var uri = Cc["@mozilla.org/network/io-service;1"]. - getService(Ci.nsIIOService).newFileURI(aFile); - - var protocolSvc = Cc["@mozilla.org/uriloader/external-protocol-service;1"]. - getService(Ci.nsIExternalProtocolService); - protocolSvc.loadUrl(uri); - - return; -} - -// Utility Functions - -/** - * Create a download richlistitem with the provided attributes. Some attributes - * are *required* while optional ones will only be set on the item if provided. - * - * @param aAttrs - * An object that must have the following properties: dlid, file, - * target, uri, state, progress, startTime, endTime, currBytes, - * maxBytes; optional properties: referrer - * @return An initialized download richlistitem - */ -function createDownloadItem(aAttrs) -{ - let dl = document.createElement("richlistitem"); - - // Copy the attributes from the argument into the item - for (let attr in aAttrs) - dl.setAttribute(attr, aAttrs[attr]); - - // Initialize other attributes - dl.setAttribute("type", "download"); - dl.setAttribute("id", "dl" + aAttrs.dlid); - dl.setAttribute("image", "moz-icon://" + aAttrs.file + "?size=32"); - dl.setAttribute("lastSeconds", Infinity); - - // Initialize more complex attributes - updateTime(dl); - updateStatus(dl); - - try { - let file = getLocalFileFromNativePathOrUrl(aAttrs.file); - dl.setAttribute("path", file.nativePath || file.path); - return dl; - } catch (e) { - // aFile might not be a file: url or a valid native path - // see bug #392386 for details - } - return null; -} - -/** - * Updates the disabled state of the buttons of a downlaod. - * - * @param aItem - * The richlistitem representing the download. - */ -function updateButtons(aItem) -{ - let buttons = aItem.buttons; - - for (let i = 0; i < buttons.length; ++i) { - let cmd = buttons[i].getAttribute("cmd"); - let enabled = gDownloadViewController.isCommandEnabled(cmd, aItem); - buttons[i].disabled = !enabled; - - if ("cmd_pause" == cmd && !enabled) { - // We need to add the tooltip indicating that the download cannot be - // paused now. - buttons[i].setAttribute("tooltiptext", gStr.cannotPause); - } - } -} - -/** - * Updates the status for a download item depending on its state - * - * @param aItem - * The richlistitem that has various download attributes. - * @param aDownload - * The nsDownload from the backend. This is an optional parameter, but - * is useful for certain states such as DOWNLOADING. - */ -function updateStatus(aItem, aDownload) { - let status = ""; - let statusTip = ""; - - let state = Number(aItem.getAttribute("state")); - switch (state) { - case nsIDM.DOWNLOAD_PAUSED: - { - let currBytes = Number(aItem.getAttribute("currBytes")); - let maxBytes = Number(aItem.getAttribute("maxBytes")); - - let transfer = DownloadUtils.getTransferTotal(currBytes, maxBytes); - status = replaceInsert(gStr.paused, 1, transfer); - - break; - } - case nsIDM.DOWNLOAD_DOWNLOADING: - { - let currBytes = Number(aItem.getAttribute("currBytes")); - let maxBytes = Number(aItem.getAttribute("maxBytes")); - // If we don't have an active download, assume 0 bytes/sec - let speed = aDownload ? aDownload.speed : 0; - let lastSec = Number(aItem.getAttribute("lastSeconds")); - - let newLast; - [status, newLast] = - DownloadUtils.getDownloadStatus(currBytes, maxBytes, speed, lastSec); - - // Update lastSeconds to be the new value - aItem.setAttribute("lastSeconds", newLast); - - break; - } - case nsIDM.DOWNLOAD_FINISHED: - case nsIDM.DOWNLOAD_FAILED: - case nsIDM.DOWNLOAD_CANCELED: - case nsIDM.DOWNLOAD_BLOCKED_PARENTAL: - case nsIDM.DOWNLOAD_BLOCKED_POLICY: - case nsIDM.DOWNLOAD_DIRTY: - { - let stateSize = {}; - stateSize[nsIDM.DOWNLOAD_FINISHED] = function() { - // Display the file size, but show "Unknown" for negative sizes - let fileSize = Number(aItem.getAttribute("maxBytes")); - let sizeText = gStr.doneSizeUnknown; - if (fileSize >= 0) { - let [size, unit] = DownloadUtils.convertByteUnits(fileSize); - sizeText = replaceInsert(gStr.doneSize, 1, size); - sizeText = replaceInsert(sizeText, 2, unit); - } - return sizeText; - }; - stateSize[nsIDM.DOWNLOAD_FAILED] = () => gStr.stateFailed; - stateSize[nsIDM.DOWNLOAD_CANCELED] = () => gStr.stateCanceled; - stateSize[nsIDM.DOWNLOAD_BLOCKED_PARENTAL] = () => gStr.stateBlockedParentalControls; - stateSize[nsIDM.DOWNLOAD_BLOCKED_POLICY] = () => gStr.stateBlockedPolicy; - stateSize[nsIDM.DOWNLOAD_DIRTY] = () => gStr.stateDirty; - - // Insert 1 is the download size or download state - status = replaceInsert(gStr.doneStatus, 1, stateSize[state]()); - - let [displayHost, fullHost] = - DownloadUtils.getURIHost(getReferrerOrSource(aItem)); - - // Insert 2 is the eTLD + 1 or other variations of the host - status = replaceInsert(status, 2, displayHost); - // Set the tooltip to be the full host - statusTip = fullHost; - - break; - } - } - - aItem.setAttribute("status", status); - aItem.setAttribute("statusTip", statusTip != "" ? statusTip : status); -} - -/** - * Updates the time that gets shown for completed download items - * - * @param aItem - * The richlistitem representing a download in the UI - */ -function updateTime(aItem) -{ - // Don't bother updating for things that aren't finished - if (aItem.inProgress) - return; - - let end = new Date(parseInt(aItem.getAttribute("endTime"))); - let [dateCompact, dateComplete] = DownloadUtils.getReadableDates(end); - aItem.setAttribute("dateTime", dateCompact); - aItem.setAttribute("dateTimeTip", dateComplete); -} - -/** - * Helper function to replace a placeholder string with a real string - * - * @param aText - * Source text containing placeholder (e.g., #1) - * @param aIndex - * Index number of placeholder to replace - * @param aValue - * New string to put in place of placeholder - * @return The string with placeholder replaced with the new string - */ -function replaceInsert(aText, aIndex, aValue) -{ - return aText.replace("#" + aIndex, aValue); -} - -/** - * Perform the default action for the currently selected download item - */ -function doDefaultForSelected() -{ - // Make sure we have something selected - let item = gDownloadsView.selectedItem; - if (!item) - return; - - // Get the default action (first item in the menu) - let state = Number(item.getAttribute("state")); - let menuitem = document.getElementById(gContextMenus[state][0]); - - // Try to do the action if the command is enabled - gDownloadViewController.doCommand(menuitem.getAttribute("cmd"), item); -} - -function removeFromView(aDownload) -{ - // Make sure we have an item to remove - if (!aDownload) return; - - let index = gDownloadsView.selectedIndex; - gDownloadsView.removeChild(aDownload); - gDownloadsView.selectedIndex = Math.min(index, gDownloadsView.itemCount - 1); - - // We might have removed the last item, so update the clear list button - updateClearListButton(); -} - -function getReferrerOrSource(aDownload) -{ - // Give the referrer if we have it set - if (aDownload.hasAttribute("referrer")) - return aDownload.getAttribute("referrer"); - - // Otherwise, provide the source - return aDownload.getAttribute("uri"); -} - -/** - * Initiate building the download list to have the active downloads followed by - * completed ones filtered by the search term if necessary. - * - * @param aForceBuild - * Force the list to be built even if the search terms don't change - */ -function buildDownloadList(aForceBuild) -{ - // Stringify the previous search - let prevSearch = gSearchTerms.join(" "); - - // Array of space-separated lower-case search terms - gSearchTerms = gSearchBox.value.replace(/^\s+|\s+$/g, ""). - toLowerCase().split(/\s+/); - - // Unless forced, don't rebuild the download list if the search didn't change - if (!aForceBuild && gSearchTerms.join(" ") == prevSearch) - return; - - // Clear out values before using them - clearTimeout(gBuilder); - gStmt.reset(); - - // Clear the list before adding items by replacing with a shallow copy - let empty = gDownloadsView.cloneNode(false); - gDownloadsView.parentNode.replaceChild(empty, gDownloadsView); - gDownloadsView = empty; - - try { - gStmt.bindByIndex(0, nsIDM.DOWNLOAD_NOTSTARTED); - gStmt.bindByIndex(1, nsIDM.DOWNLOAD_DOWNLOADING); - gStmt.bindByIndex(2, nsIDM.DOWNLOAD_PAUSED); - gStmt.bindByIndex(3, nsIDM.DOWNLOAD_QUEUED); - gStmt.bindByIndex(4, nsIDM.DOWNLOAD_SCANNING); - } catch (e) { - // Something must have gone wrong when binding, so clear and quit - gStmt.reset(); - return; - } - - // Take a quick break before we actually start building the list - gBuilder = setTimeout(function() { - // Start building the list - stepListBuilder(1); - - // We just tried to add a single item, so we probably need to enable - updateClearListButton(); - }, 0); -} - -/** - * Incrementally build the download list by adding at most the requested number - * of items if there are items to add. After doing that, it will schedule - * another chunk of items specified by gListBuildDelay and gListBuildChunk. - * - * @param aNumItems - * Number of items to add to the list before taking a break - */ -function stepListBuilder(aNumItems) { - try { - // If we're done adding all items, we can quit - if (!gStmt.executeStep()) { - // Send a notification that we finished, but wait for clear list to update - updateClearListButton(); - setTimeout(() => Cc["@mozilla.org/observer-service;1"]. - getService(Ci.nsIObserverService). - notifyObservers(window, "download-manager-ui-done", null), 0); - - return; - } - - // Try to get the attribute values from the statement - let attrs = { - dlid: gStmt.getInt64(0), - file: gStmt.getString(1), - target: gStmt.getString(2), - uri: gStmt.getString(3), - state: gStmt.getInt32(4), - startTime: Math.round(gStmt.getInt64(5) / 1000), - endTime: Math.round(gStmt.getInt64(6) / 1000), - currBytes: gStmt.getInt64(8), - maxBytes: gStmt.getInt64(9) - }; - - // Only add the referrer if it's not null - let referrer = gStmt.getString(7); - if (referrer) - attrs.referrer = referrer; - - // If the download is active, grab the real progress, otherwise default 100 - let isActive = gStmt.getInt32(10); - attrs.progress = isActive ? gDownloadManager.getDownload(attrs.dlid). - percentComplete : 100; - - // Make the item and add it to the end if it's active or matches the search - let item = createDownloadItem(attrs); - if (item && (isActive || downloadMatchesSearch(item))) { - // Add item to the end - gDownloadsView.appendChild(item); - - // Because of the joys of XBL, we can't update the buttons until the - // download object is in the document. - updateButtons(item); - } else { - // We didn't add an item, so bump up the number of items to process, but - // not a whole number so that we eventually do pause for a chunk break - aNumItems += .9; - } - } catch (e) { - // Something went wrong when stepping or getting values, so clear and quit - gStmt.reset(); - return; - } - - // Add another item to the list if we should; otherwise, let the UI update - // and continue later - if (aNumItems > 1) { - stepListBuilder(aNumItems - 1); - } else { - // Use a shorter delay for earlier downloads to display them faster - let delay = Math.min(gDownloadsView.itemCount * 10, gListBuildDelay); - gBuilder = setTimeout(stepListBuilder, delay, gListBuildChunk); - } -} - -/** - * Add a download to the front of the download list - * - * @param aDownload - * The nsIDownload to make into a richlistitem - */ -function prependList(aDownload) -{ - let attrs = { - dlid: aDownload.id, - file: aDownload.target.spec, - target: aDownload.displayName, - uri: aDownload.source.spec, - state: aDownload.state, - progress: aDownload.percentComplete, - startTime: Math.round(aDownload.startTime / 1000), - endTime: Date.now(), - currBytes: aDownload.amountTransferred, - maxBytes: aDownload.size - }; - - // Make the item and add it to the beginning - let item = createDownloadItem(attrs); - if (item) { - // Add item to the beginning - gDownloadsView.insertBefore(item, gDownloadsView.firstChild); - - // Because of the joys of XBL, we can't update the buttons until the - // download object is in the document. - updateButtons(item); - - // We might have added an item to an empty list, so update button - updateClearListButton(); - } -} - -/** - * Check if the download matches the current search term based on the texts - * shown to the user. All search terms are checked to see if each matches any - * of the displayed texts. - * - * @param aItem - * Download richlistitem to check if it matches the current search - * @return Boolean true if it matches the search; false otherwise - */ -function downloadMatchesSearch(aItem) -{ - // Search through the download attributes that are shown to the user and - // make it into one big string for easy combined searching - let combinedSearch = ""; - for (let attr of gSearchAttributes) - combinedSearch += aItem.getAttribute(attr).toLowerCase() + " "; - - // Make sure each of the terms are found - for (let term of gSearchTerms) - if (combinedSearch.indexOf(term) == -1) - return false; - - return true; -} - -// we should be using real URLs all the time, but until -// bug 239948 is fully fixed, this will do... -// -// note, this will thrown an exception if the native path -// is not valid (for example a native Windows path on a Mac) -// see bug #392386 for details -function getLocalFileFromNativePathOrUrl(aPathOrUrl) -{ - if (aPathOrUrl.substring(0, 7) == "file://") { - // if this is a URL, get the file from that - let ioSvc = Cc["@mozilla.org/network/io-service;1"]. - getService(Ci.nsIIOService); - - // XXX it's possible that using a null char-set here is bad - const fileUrl = ioSvc.newURI(aPathOrUrl, null, null). - QueryInterface(Ci.nsIFileURL); - return fileUrl.file.clone().QueryInterface(Ci.nsILocalFile); - } - // if it's a pathname, create the nsILocalFile directly - var f = new nsLocalFile(aPathOrUrl); - - return f; -} - -/** - * Update the disabled state of the clear list button based on whether or not - * there are items in the list that can potentially be removed. - */ -function updateClearListButton() -{ - let button = document.getElementById("clearListButton"); - // The button is enabled if we have items in the list and we can clean up - button.disabled = !(gDownloadsView.itemCount && gDownloadManager.canCleanUp); -} - -function getDownload(aID) -{ - return document.getElementById("dl" + aID); -} - -/** - * Initialize the statement which is used to retrieve the list of downloads. - */ -function initStatement() -{ - if (gStmt) - gStmt.finalize(); - - gStmt = gDownloadManager.DBConnection.createStatement( - "SELECT id, target, name, source, state, startTime, endTime, referrer, " + - "currBytes, maxBytes, state IN (?1, ?2, ?3, ?4, ?5) isActive " + - "FROM moz_downloads " + - "ORDER BY isActive DESC, endTime DESC, startTime DESC"); -} diff --git a/toolkit/mozapps/downloads/content/downloads.xul b/toolkit/mozapps/downloads/content/downloads.xul deleted file mode 100644 index 5ca9eec2d428..000000000000 --- a/toolkit/mozapps/downloads/content/downloads.xul +++ /dev/null @@ -1,164 +0,0 @@ - - -# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -# 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/. - -#ifdef XP_UNIX -#ifndef XP_MACOSX -#define XP_GNOME 1 -#endif -#endif - - - - - - -%downloadManagerDTD; - -%editMenuOverlayDTD; -]> - - - - + + + + + + + + + + + + + + diff --git a/editor/libeditor/crashtests/crashtests.list b/editor/libeditor/crashtests/crashtests.list index c00bf09bb052..947fa801f9bb 100644 --- a/editor/libeditor/crashtests/crashtests.list +++ b/editor/libeditor/crashtests/crashtests.list @@ -69,4 +69,5 @@ load 1158651.html load 1244894.xhtml load 1264921.html load 1272490.html +load 1317704.html load 1317718.html From 0070259e2a95d2eb568102f5a188ed7fd926bc80 Mon Sep 17 00:00:00 2001 From: Jared Wein Date: Thu, 15 Dec 2016 12:29:04 -0500 Subject: [PATCH 33/64] Bug 1323767 - Fix the indentation and inconsistent brace-style, and switch to using ES6 method definitions in videocontrols.xml. r=ralin MozReview-Commit-ID: 9GNVgX5gZpc --HG-- extra : rebase_source : 2f47a742d8486218041f5f717b209aa8f4d1d881 --- toolkit/content/widgets/videocontrols.xml | 4441 +++++++++++---------- 1 file changed, 2254 insertions(+), 2187 deletions(-) diff --git a/toolkit/content/widgets/videocontrols.xml b/toolkit/content/widgets/videocontrols.xml index ec5b62fd8f07..0c8a3f3eb04b 100644 --- a/toolkit/content/widgets/videocontrols.xml +++ b/toolkit/content/widgets/videocontrols.xml @@ -3,2206 +3,2273 @@ - 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/. --> - - %videocontrolsDTD; + +%videocontrolsDTD; ]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (this.type != "scrubber") - return ""; - - var currTime = this.thumb.timeLabel.getAttribute("value"); - var totalTime = this.durationValue; - - return this.scrubberNameFormat.replace(/#1/, currTime). - replace(/#2/, totalTime); - - - - - "&scrubberScale.nameFormat;" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
-
-
- -
- - -
-
-
- - - - - " + (show ? "SHOW" : "HIDE")); - this.startFade(this.statusOverlay, show, immediate); - }, - - /* - * Set the initial state of the controls. The binding is normally created along - * with video element, but could be attached at any point (eg, if the video is - * removed from the document and then reinserted). Thus, some one-time events may - * have already fired, and so we'll need to explicitly check the initial state. - */ - setupInitialState : function() { - this.randomID = Math.random(); - this.videocontrols.randomID = this.randomID; - - this.setPlayButtonState(this.video.paused); - - this.setFullscreenButtonState(); - - var duration = Math.round(this.video.duration * 1000); // in ms - var currentTime = Math.round(this.video.currentTime * 1000); // in ms - this.log("Initial playback position is at " + currentTime + " of " + duration); - // It would be nice to retain maxCurrentTimeSeen, but it would be difficult - // to determine if the media source changed while we were detached. - this.initPositionDurationBox(); - this.maxCurrentTimeSeen = currentTime; - this.showPosition(currentTime, duration); - - // If we have metadata, check if this is a - - , which meant that the XBL machinery - // undefined the property when the element was unbound. The code in - // this file actually depends on this, so now that randomID is an - // expando, we need to make sure to explicitly delete it. - delete this.randomID; - ]]> - - - - - - - if (!this.isTouchControls) - this.Utils.onMouseInOut(event); - - - if (!this.isTouchControls) - this.Utils.onMouseInOut(event); - - - if (!this.isTouchControls) - this.Utils.onMouseMove(event); - - -
- - - - - - - - - -