From 7783684b2fd526d1b88f52b0909b8c78b1524cc7 Mon Sep 17 00:00:00 2001 From: Peter Moore Date: Thu, 6 Apr 2017 18:50:41 +0200 Subject: [PATCH 01/89] Bug 1349980 - update task generation to support -g in try syntax for running OS X tasks in generic-worker,r=dustin --- AUTHORS | 1 + .../taskgraph/transforms/job/mozharness.py | 22 +++- .../transforms/job/mozharness_test.py | 113 +++++++++++++----- .../taskgraph/transforms/job/toolchain.py | 2 +- taskcluster/taskgraph/transforms/task.py | 92 +++++++++++--- taskcluster/taskgraph/transforms/tests.py | 21 +++- taskcluster/taskgraph/try_option_syntax.py | 3 + 7 files changed, 196 insertions(+), 58 deletions(-) diff --git a/AUTHORS b/AUTHORS index 11aa3471caf0..31cafac21e0a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -797,6 +797,7 @@ Pete Collins Peter Annema Peter Bajusz Peter Lubczynski +Peter Moore Peter Naulls Peter Parente Peter Seliger diff --git a/taskcluster/taskgraph/transforms/job/mozharness.py b/taskcluster/taskgraph/transforms/job/mozharness.py index cac92f484233..0894faca6174 100644 --- a/taskcluster/taskgraph/transforms/job/mozharness.py +++ b/taskcluster/taskgraph/transforms/job/mozharness.py @@ -10,6 +10,8 @@ way, and certainly anything using mozharness should use this approach. from __future__ import absolute_import, print_function, unicode_literals +from textwrap import dedent + from taskgraph.util.schema import Schema from voluptuous import Required, Optional, Any @@ -168,7 +170,7 @@ def mozharness_on_docker_worker_setup(config, job, taskdesc): # We use the generic worker to run tasks on Windows @run_job_using("generic-worker", "mozharness", schema=mozharness_run_schema) -def mozharness_on_windows(config, job, taskdesc): +def mozharness_on_generic_worker(config, job, taskdesc): run = job['run'] # fail if invalid run options are included @@ -187,7 +189,7 @@ def mozharness_on_windows(config, job, taskdesc): worker = taskdesc['worker'] worker['artifacts'] = [{ - 'path': r'public\build', + 'path': r'public/build', 'type': 'directory', }] @@ -199,6 +201,11 @@ def mozharness_on_windows(config, job, taskdesc): 'MOZ_SCM_LEVEL': config.params['level'], }) + if not job['attributes']['build_platform'].startswith('win'): + raise Exception( + "Task generation for mozharness build jobs currently only supported on Windows" + ) + mh_command = [r'c:\mozilla-build\python\python.exe'] mh_command.append('\\'.join([r'.\build\src\testing', run['script'].replace('/', '\\')])) for cfg in run['config']: @@ -218,12 +225,15 @@ def mozharness_on_windows(config, job, taskdesc): hg_command.append('.\\build\\src') worker['command'] = [] - # sccache currently uses the full compiler commandline as input to the - # cache hash key, so create a symlink to the task dir and build from - # the symlink dir to get consistent paths. if taskdesc.get('needs-sccache'): worker['command'].extend([ - r'if exist z:\build rmdir z:\build', + # Make the comment part of the first command, as it will help users to + # understand what is going on, and why these steps are implemented. + dedent('''\ + :: sccache currently uses the full compiler commandline as input to the + :: cache hash key, so create a symlink to the task dir and build from + :: the symlink dir to get consistent paths. + if exist z:\\build rmdir z:\\build'''), r'mklink /d z:\build %cd%', # Grant delete permission on the link to everyone. r'icacls z:\build /grant *S-1-1-0:D /L', diff --git a/taskcluster/taskgraph/transforms/job/mozharness_test.py b/taskcluster/taskgraph/transforms/job/mozharness_test.py index b444e4575718..ad12dfac2ad0 100644 --- a/taskcluster/taskgraph/transforms/job/mozharness_test.py +++ b/taskcluster/taskgraph/transforms/job/mozharness_test.py @@ -169,56 +169,63 @@ def mozharness_test_on_docker(config, job, taskdesc): @run_job_using('generic-worker', 'mozharness-test', schema=mozharness_test_run_schema) -def mozharness_test_on_windows(config, job, taskdesc): +def mozharness_test_on_generic_worker(config, job, taskdesc): test = taskdesc['run']['test'] mozharness = test['mozharness'] worker = taskdesc['worker'] artifacts = [ { - 'path': 'public\\logs\\localconfig.json', + 'name': 'public/logs/localconfig.json', + 'path': 'logs/localconfig.json', 'type': 'file' }, { - 'path': 'public\\logs\\log_critical.log', + 'name': 'public/logs/log_critical.log', + 'path': 'logs/log_critical.log', 'type': 'file' }, { - 'path': 'public\\logs\\log_error.log', + 'name': 'public/logs/log_error.log', + 'path': 'logs/log_error.log', 'type': 'file' }, { - 'path': 'public\\logs\\log_fatal.log', + 'name': 'public/logs/log_fatal.log', + 'path': 'logs/log_fatal.log', 'type': 'file' }, { - 'path': 'public\\logs\\log_info.log', + 'name': 'public/logs/log_info.log', + 'path': 'logs/log_info.log', 'type': 'file' }, { - 'path': 'public\\logs\\log_raw.log', + 'name': 'public/logs/log_raw.log', + 'path': 'logs/log_raw.log', 'type': 'file' }, { - 'path': 'public\\logs\\log_warning.log', + 'name': 'public/logs/log_warning.log', + 'path': 'logs/log_warning.log', 'type': 'file' }, { - 'path': 'public\\test_info', + 'name': 'public/test_info', + 'path': 'build/blobber_upload_dir', 'type': 'directory' } ] build_platform = taskdesc['attributes']['build_platform'] - target = 'firefox-{}.en-US.{}'.format(get_firefox_version(), build_platform) + target = 'firefox-{}.en-US.{}'.format(get_firefox_version(), build_platform) \ + if build_platform.startswith('win') else 'target' + + installer_url = get_artifact_url('', mozharness['build-artifact-name']) - installer_url = get_artifact_url( - '', 'public/build/{}.zip'.format(target)) test_packages_url = get_artifact_url( '', 'public/build/{}.test_packages.json'.format(target)) - mozharness_url = get_artifact_url( - '', 'public/build/mozharness.zip') taskdesc['scopes'].extend( ['generic-worker:os-group:{}'.format(group) for group in test['os-groups']]) @@ -228,14 +235,48 @@ def mozharness_test_on_windows(config, job, taskdesc): worker['max-run-time'] = test['max-run-time'] worker['artifacts'] = artifacts - # assemble the command line - mh_command = [ - 'c:\\mozilla-build\\python\\python.exe', - '-u', - 'mozharness\\scripts\\' + normpath(mozharness['script']) - ] + # this list will get cleaned up / reduced / removed in bug 1354088 + if build_platform.startswith('macosx'): + worker['env'] = { + 'IDLEIZER_DISABLE_SHUTDOWN': 'true', + 'LANG': 'en_US.UTF-8', + 'LC_ALL': 'en_US.UTF-8', + 'MOZ_HIDE_RESULTS_TABLE': '1', + 'MOZ_NODE_PATH': '/usr/local/bin/node', + 'MOZ_NO_REMOTE': '1', + 'NO_EM_RESTART': '1', + 'NO_FAIL_ON_TEST_ERRORS': '1', + 'PATH': '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin', + 'SHELL': '/bin/bash', + 'XPCOM_DEBUG_BREAK': 'warn', + 'XPC_FLAGS': '0x0', + 'XPC_SERVICE_NAME': '0' + } + + if build_platform.startswith('macosx'): + mh_command = [ + 'python2.7', + '-u', + 'mozharness/scripts/' + mozharness['script'] + ] + elif build_platform.startswith('win'): + mh_command = [ + 'c:\\mozilla-build\\python\\python.exe', + '-u', + 'mozharness\\scripts\\' + normpath(mozharness['script']) + ] + else: + mh_command = [ + 'python', + '-u', + 'mozharness/scripts/' + mozharness['script'] + ] + for mh_config in mozharness['config']: - mh_command.extend(['--cfg', 'mozharness\\configs\\' + normpath(mh_config)]) + cfg_path = 'mozharness/configs/' + mh_config + if build_platform.startswith('win'): + cfg_path = normpath(cfg_path) + mh_command.extend(['--cfg', cfg_path]) mh_command.extend(mozharness.get('extra-options', [])) if mozharness.get('no-read-buildbot-config'): mh_command.append('--no-read-buildbot-config') @@ -259,16 +300,28 @@ def mozharness_test_on_windows(config, job, taskdesc): if isinstance(c, basestring) and c.startswith('--test-suite'): mh_command[i] += suffix - # bug 1311966 - symlink to artifacts until generic worker supports virtual artifact paths - artifact_link_commands = ['mklink /d %cd%\\public\\test_info %cd%\\build\\blobber_upload_dir'] - for link in [a['path'] for a in artifacts if a['path'].startswith('public\\logs\\')]: - artifact_link_commands.append('mklink %cd%\\{} %cd%\\{}'.format(link, link[7:])) + worker['mounts'] = [{ + 'directory': '.', + 'content': { + 'artifact': 'public/build/mozharness.zip', + 'task-id': { + 'task-reference': '' + } + }, + 'format': 'zip' + }] - worker['command'] = artifact_link_commands + [ - {'task-reference': 'c:\\mozilla-build\\wget\\wget.exe {}'.format(mozharness_url)}, - 'c:\\mozilla-build\\info-zip\\unzip.exe mozharness.zip', - {'task-reference': ' '.join(mh_command)} - ] + if build_platform.startswith('win'): + worker['command'] = [ + {'task-reference': ' '.join(mh_command)} + ] + else: + mh_command_task_ref = [] + for token in mh_command: + mh_command_task_ref.append({'task-reference': token}) + worker['command'] = [ + mh_command_task_ref + ] @run_job_using('native-engine', 'mozharness-test', schema=mozharness_test_run_schema) diff --git a/taskcluster/taskgraph/transforms/job/toolchain.py b/taskcluster/taskgraph/transforms/job/toolchain.py index 645f35c3ec61..456348283881 100644 --- a/taskcluster/taskgraph/transforms/job/toolchain.py +++ b/taskcluster/taskgraph/transforms/job/toolchain.py @@ -145,7 +145,7 @@ def windows_toolchain(config, job, taskdesc): svn_cache = 'level-{}-toolchain-clang-cl-build-svn'.format(config.params['level']) worker['mounts'] = [{ 'cache-name': svn_cache, - 'path': r'llvm-sources', + 'directory': r'llvm-sources', }] taskdesc['scopes'].extend([ 'generic-worker:cache:' + svn_cache, diff --git a/taskcluster/taskgraph/transforms/task.py b/taskcluster/taskgraph/transforms/task.py index f788ac17823a..e60192c14de9 100644 --- a/taskcluster/taskgraph/transforms/task.py +++ b/taskcluster/taskgraph/transforms/task.py @@ -12,6 +12,7 @@ from __future__ import absolute_import, print_function, unicode_literals import json import time +from copy import deepcopy from taskgraph.util.treeherder import split_symbol from taskgraph.transforms.base import TransformSequence @@ -212,10 +213,17 @@ task_description_schema = Schema({ Optional('retry-exit-status'): int, }, { + # see http://schemas.taskcluster.net/generic-worker/v1/payload.json + # and https://docs.taskcluster.net/reference/workers/generic-worker/payload Required('implementation'): 'generic-worker', # command is a list of commands to run, sequentially - Required('command'): [taskref_or_string], + # on Windows, each command is a string, on OS X and Linux, each command is + # a string array + Required('command'): Any( + [taskref_or_string], # Windows + [[taskref_or_string]] # Linux / OS X + ), # artifacts to extract from the task image after completion; note that artifacts # for the generic worker cannot have names @@ -223,17 +231,50 @@ task_description_schema = Schema({ # type of artifact -- simple file, or recursive directory 'type': Any('file', 'directory'), - # task image path from which to read artifact + # filesystem path from which to read artifact 'path': basestring, + + # if not specified, path is used for artifact name + Optional('name'): basestring }], - # directories and/or files to be mounted + # Directories and/or files to be mounted. + # The actual allowed combinations are stricter than the model below, + # but this provides a simple starting point. + # See https://docs.taskcluster.net/reference/workers/generic-worker/payload Optional('mounts'): [{ - # a unique name for the cache volume - 'cache-name': basestring, + # A unique name for the cache volume, implies writable cache directory + # (otherwise mount is a read-only file or directory). + Optional('cache-name'): basestring, + # Optional content for pre-loading cache, or mandatory content for + # read-only file or directory. Pre-loaded content can come from either + # a task artifact or from a URL. + Optional('content'): { - # task image path for the cache - 'path': basestring, + # *** Either (artifact and task-id) or url must be specified. *** + + # Artifact name that contains the content. + Optional('artifact'): basestring, + # Task ID that has the artifact that contains the content. + Optional('task-id'): taskref_or_string, + # URL that supplies the content in response to an unauthenticated + # GET request. + Optional('url'): basestring + }, + + # *** Either file or directory must be specified. *** + + # If mounting a cache or read-only directory, the filesystem location of + # the directory should be specified as a relative path to the task + # directory here. + Optional('directory'): basestring, + # If mounting a file, specify the relative path within the task + # directory to mount the file (the file will be read only). + Optional('file'): basestring, + # Required if and only if `content` is specified and mounting a + # directory (not a file). This should be the archive format of the + # content (either pre-loaded cache or read-only directory). + Optional('format'): Any('rar', 'tar.bz2', 'tar.gz', 'zip') }], # environment variables @@ -244,6 +285,9 @@ task_description_schema = Schema({ # os user groups for test task workers Optional('os-groups', default=[]): [basestring], + + # optional features + Required('chain-of-trust', default=False): bool, }, { Required('implementation'): 'buildbot-bridge', @@ -557,19 +601,26 @@ def build_generic_worker_payload(config, task, task_def): artifacts = [] for artifact in worker['artifacts']: - artifacts.append({ + a = { 'path': artifact['path'], 'type': artifact['type'], 'expires': task_def['expires'], # always expire with the task - }) + } + if 'name' in artifact: + a['name'] = artifact['name'] + artifacts.append(a) - mounts = [] - - for mount in worker.get('mounts', []): - mounts.append({ - 'cacheName': mount['cache-name'], - 'directory': mount['path'] - }) + # Need to copy over mounts, but rename keys to respect naming convention + # * 'cache-name' -> 'cacheName' + # * 'task-id' -> 'taskId' + # All other key names are already suitable, and don't need renaming. + mounts = deepcopy(worker.get('mounts', [])) + for mount in mounts: + if 'cache-name' in mount: + mount['cacheName'] = mount.pop('cache-name') + if 'content' in mount: + if 'task-id' in mount['content']: + mount['content']['taskId'] = mount['content'].pop('task-id') task_def['payload'] = { 'command': worker['command'], @@ -585,6 +636,15 @@ def build_generic_worker_payload(config, task, task_def): if 'retry-exit-status' in worker: raise Exception("retry-exit-status not supported in generic-worker") + # currently only support one feature (chain of trust) but this will likely grow + features = {} + + if worker.get('chain-of-trust'): + features['chainOfTrust'] = True + + if features: + task_def['payload']['features'] = features + @payload_builder('scriptworker-signing') def build_scriptworker_signing_payload(config, task, task_def): diff --git a/taskcluster/taskgraph/transforms/tests.py b/taskcluster/taskgraph/transforms/tests.py index aa0a0140181e..c7ac684ea62c 100644 --- a/taskcluster/taskgraph/transforms/tests.py +++ b/taskcluster/taskgraph/transforms/tests.py @@ -42,12 +42,13 @@ WORKER_TYPE = { 'xlarge': 'aws-provisioner-v1/gecko-t-linux-xlarge', 'legacy': 'aws-provisioner-v1/gecko-t-linux-medium', 'default': 'aws-provisioner-v1/gecko-t-linux-large', - # windows worker types keyed by test-platform + # windows / os x worker types keyed by test-platform 'windows7-32-vm': 'aws-provisioner-v1/gecko-t-win7-32', 'windows7-32': 'aws-provisioner-v1/gecko-t-win7-32-gpu', 'windows10-64-vm': 'aws-provisioner-v1/gecko-t-win10-64', 'windows10-64': 'aws-provisioner-v1/gecko-t-win10-64-gpu', - 'windows10-64-asan': 'aws-provisioner-v1/gecko-t-win10-64-gpu' + 'windows10-64-asan': 'aws-provisioner-v1/gecko-t-win10-64-gpu', + 'macosx64': 'scl3-puppet/os-x-10-10-gw' } logger = logging.getLogger(__name__) @@ -341,6 +342,11 @@ def set_target(config, tests): target = 'target.dmg' elif build_platform.startswith('android'): target = 'target.apk' + elif build_platform.startswith('win'): + target = 'firefox-{}.en-US.{}.zip'.format( + get_firefox_version(), + build_platform.split('/')[0] + ) else: target = 'target.tar.bz2' test['mozharness']['build-artifact-name'] = 'public/build/' + target @@ -386,11 +392,16 @@ def set_asan_docker_image(config, tests): @transforms.add def set_worker_implementation(config, tests): """Set the worker implementation based on the test platform.""" - use_tc_worker = config.config['args'].taskcluster_worker for test in tests: if test['test-platform'].startswith('macosx'): - test['worker-implementation'] = \ - 'native-engine' if use_tc_worker else 'buildbot-bridge' + # see if '-g' appears in try syntax + if config.config['args'].generic_worker: + test['worker-implementation'] = 'generic-worker' + # see if '-w' appears in try syntax + elif config.config['args'].taskcluster_worker: + test['worker-implementation'] = 'native-engine' + else: + test['worker-implementation'] = 'buildbot-bridge' elif test.get('suite', '') == 'talos': test['worker-implementation'] = 'buildbot-bridge' elif test['test-platform'].startswith('win'): diff --git a/taskcluster/taskgraph/try_option_syntax.py b/taskcluster/taskgraph/try_option_syntax.py index f6ca144441d0..71f4850fb34d 100644 --- a/taskcluster/taskgraph/try_option_syntax.py +++ b/taskcluster/taskgraph/try_option_syntax.py @@ -242,6 +242,9 @@ def parse_message(message): # this temporary option to be able to push jobs to tc-worker. parser.add_argument('-w', '--taskcluster-worker', dest='taskcluster_worker', action='store_true', default=False) + # Similarly, an extra flag for enabling os x jobs in generic-worker + parser.add_argument('-g', '--generic-worker', + dest='generic_worker', action='store_true', default=False) # In order to run test jobs multiple times parser.add_argument('--rebuild', dest='trigger_tests', type=int, default=1) From 1b3f1e93bacdd115d29d42bf87681396b5612317 Mon Sep 17 00:00:00 2001 From: Sotaro Ikeda Date: Thu, 6 Apr 2017 12:56:10 -0400 Subject: [PATCH 02/89] Bug 1353958 - Add Gpu process reset handling for QuantumRender. r=kats MozReview-Commit-ID: 6ZkB1ezyWlK --- dom/ipc/TabChild.cpp | 38 +++++++++++++++++++++++--------------- widget/PuppetWidget.cpp | 2 ++ 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index e8318157c6ef..07337043f098 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -3076,23 +3076,31 @@ TabChild::ReinitRendering() Unused << cb->SendGetCompositorOptions(mLayersId, &options); mCompositorOptions = Some(options); - bool success; - nsTArray ignored; - PLayerTransactionChild* shadowManager = - cb->SendPLayerTransactionConstructor(ignored, LayersId(), &mTextureFactoryIdentifier, &success); - if (!success) { - NS_WARNING("failed to re-allocate layer transaction"); - return; - } + if (gfxVars::UseWebRender()) { + RefPtr lm = mPuppetWidget->RecreateLayerManager(nullptr); + MOZ_ASSERT(lm->AsWebRenderLayerManager()); + lm->AsWebRenderLayerManager()->Initialize(cb, + wr::AsPipelineId(mLayersId), + &mTextureFactoryIdentifier); + } else { + bool success; + nsTArray ignored; + PLayerTransactionChild* shadowManager = + cb->SendPLayerTransactionConstructor(ignored, LayersId(), &mTextureFactoryIdentifier, &success); + if (!success) { + NS_WARNING("failed to re-allocate layer transaction"); + return; + } - if (!shadowManager) { - NS_WARNING("failed to re-construct LayersChild"); - return; - } + if (!shadowManager) { + NS_WARNING("failed to re-construct LayersChild"); + return; + } - RefPtr lm = mPuppetWidget->RecreateLayerManager(shadowManager); - ShadowLayerForwarder* lf = lm->AsShadowForwarder(); - lf->IdentifyTextureHost(mTextureFactoryIdentifier); + RefPtr lm = mPuppetWidget->RecreateLayerManager(shadowManager); + ShadowLayerForwarder* lf = lm->AsShadowForwarder(); + lf->IdentifyTextureHost(mTextureFactoryIdentifier); + } InitAPZState(); diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 8fac1eb39d86..239c27e5f769 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -614,6 +614,7 @@ PuppetWidget::GetLayerManager(PLayerTransactionChild* aShadowManager, // can do drawing in this process. mLayerManager = new BasicLayerManager(this); } else if (gfxVars::UseWebRender()) { + MOZ_ASSERT(!aShadowManager); mLayerManager = new WebRenderLayerManager(this); } else { mLayerManager = new ClientLayerManager(this); @@ -638,6 +639,7 @@ PuppetWidget::RecreateLayerManager(PLayerTransactionChild* aShadowManager) MOZ_ASSERT(mTabChild); if (gfxVars::UseWebRender()) { + MOZ_ASSERT(!aShadowManager); mLayerManager = new WebRenderLayerManager(this); } else { mLayerManager = new ClientLayerManager(this); From e329f0e096df073720e86fa3b60efee7c41e3afb Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 6 Apr 2017 01:46:00 -0400 Subject: [PATCH 03/89] Bug 1348403 - Rename SPDY to HTTP/2 in about:networking. r=jaws --HG-- extra : rebase_source : 4cca8e1c317b4a79ab7d74ccb86ca4e1be0427fe --- toolkit/content/aboutNetworking.xhtml | 2 +- toolkit/locales/en-US/chrome/global/aboutNetworking.dtd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/toolkit/content/aboutNetworking.xhtml b/toolkit/content/aboutNetworking.xhtml index d2c65914d90b..589bcd41ee2c 100644 --- a/toolkit/content/aboutNetworking.xhtml +++ b/toolkit/content/aboutNetworking.xhtml @@ -69,7 +69,7 @@ &aboutNetworking.hostname; &aboutNetworking.port; - &aboutNetworking.spdy; + &aboutNetworking.http2; &aboutNetworking.ssl; &aboutNetworking.active; &aboutNetworking.idle; diff --git a/toolkit/locales/en-US/chrome/global/aboutNetworking.dtd b/toolkit/locales/en-US/chrome/global/aboutNetworking.dtd index 4069e21c05d8..ca7f14c79209 100644 --- a/toolkit/locales/en-US/chrome/global/aboutNetworking.dtd +++ b/toolkit/locales/en-US/chrome/global/aboutNetworking.dtd @@ -14,7 +14,7 @@ - + From 736b841e354dda9d7889bbc396a8797388472279 Mon Sep 17 00:00:00 2001 From: Georg Fritzsche Date: Thu, 6 Apr 2017 22:10:01 +0700 Subject: [PATCH 04/89] Bug 1276201 - Migrate most recent updates from wiki page into in-tree histogram docs. r=chutten - Make mxr links into dxr links. - Fix link naming. - Add artifact build warning. --HG-- extra : rebase_source : 27743f1ac81799ec879d580d09d0a064dc718709 --- .../telemetry/docs/collection/histograms.rst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/toolkit/components/telemetry/docs/collection/histograms.rst b/toolkit/components/telemetry/docs/collection/histograms.rst index 7a943a572da7..11806f6257e9 100644 --- a/toolkit/components/telemetry/docs/collection/histograms.rst +++ b/toolkit/components/telemetry/docs/collection/histograms.rst @@ -2,7 +2,7 @@ Histograms ========== -If a user has opted into submitting performance data to Mozilla, the Telemetry system will collect various measures of Firefox performance, hardware, usage and customizations and submit it to Mozilla. The Telemetry data collected by a single client can be examined from the integrated ``about:telemetry`` browser page, while the aggregated reports across entire user populations are publicly available at `https://telemetry.mozilla.org `_. +If a user has opted into submitting performance data to Mozilla, the Telemetry system will collect various measures of Firefox performance, hardware, usage and customizations and submit it to Mozilla. The Telemetry data collected by a single client can be examined from the integrated ``about:telemetry`` browser page, while the aggregated reports across entire user populations are publicly available at `telemetry.mozilla.org `_. .. important:: @@ -193,7 +193,7 @@ Changing histogram declarations after the histogram has been released is tricky. Adding a JavaScript Probe ========================= -A Telemetry probe is the code that measures and stores values in a histogram. Probes in privileged JavaScript code can make use of the `nsITelemetry `_ interface to get references to histogram objects. A new value is recorded in the histogram by calling ``add`` on the histogram object: +A Telemetry probe is the code that measures and stores values in a histogram. Probes in privileged JavaScript code can make use of the `nsITelemetry `_ interface to get references to histogram objects. A new value is recorded in the histogram by calling ``add`` on the histogram object: .. code-block:: js @@ -205,7 +205,11 @@ A Telemetry probe is the code that measures and stores values in a histogram. Pr Note that ``nsITelemetry.getHistogramById()`` will throw an ``NS_ERROR_ILLEGAL_VALUE`` JavaScript exception if it is called with an invalid histogram ID. The ``add()`` function will not throw if it fails, instead it prints an error in the browser console. -For histograms measuring time, `TelemetryStopwatch `_ can be used to avoid working with Dates manually: +.. warning:: + + Adding a new Telemetry probe is not possible with Artifact builds. A full build is needed. + +For histograms measuring time, `TelemetryStopwatch `_ can be used to avoid working with Dates manually: .. code-block:: js @@ -218,7 +222,7 @@ For histograms measuring time, `TelemetryStopwatch `_ interface, but the helper functions declared in `Telemetry.h `_ are more convenient: +Probes in native code can also use the `nsITelemetry `_ interface, but the helper functions declared in `Telemetry.h `_ are more convenient: .. code-block:: cpp From 3d4f8c3b4a6affbfa67791ee724cd249e91018f2 Mon Sep 17 00:00:00 2001 From: Geoff Brown Date: Thu, 6 Apr 2017 11:19:12 -0600 Subject: [PATCH 05/89] Bug 1317121 - Skip TestTimeouts.test_search_timeout_found_settimeout on Android; r=ato --- .../harness/marionette_harness/tests/unit/test_timeouts.py | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_timeouts.py b/testing/marionette/harness/marionette_harness/tests/unit/test_timeouts.py index 354e6a7ebb13..7d09bd9b3d95 100644 --- a/testing/marionette/harness/marionette_harness/tests/unit/test_timeouts.py +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_timeouts.py @@ -40,6 +40,7 @@ class TestTimeouts(MarionetteTestCase): self.marionette.timeout.implicit = 0 self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID, "I'm not on the page") + @skip_if_mobile("Bug 1317121 - android emulator is too slow") def test_search_timeout_found_settimeout(self): test_html = self.marionette.absolute_url("test.html") self.marionette.navigate(test_html) From dd80050102004cdbd1753639638612160dfb1f91 Mon Sep 17 00:00:00 2001 From: Geoff Brown Date: Thu, 6 Apr 2017 11:19:13 -0600 Subject: [PATCH 06/89] Bug 1306848 - Skip TestTimeouts.test_search_timeout_found on Android; r=ato --- .../harness/marionette_harness/tests/unit/test_timeouts.py | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_timeouts.py b/testing/marionette/harness/marionette_harness/tests/unit/test_timeouts.py index 7d09bd9b3d95..9268e7175d30 100644 --- a/testing/marionette/harness/marionette_harness/tests/unit/test_timeouts.py +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_timeouts.py @@ -49,6 +49,7 @@ class TestTimeouts(MarionetteTestCase): self.marionette.timeout.implicit = 8 self.assertEqual(HTMLElement, type(self.marionette.find_element(By.ID, "newDiv"))) + @skip_if_mobile("Bug 1306848 - android emulator is too slow") def test_search_timeout_found(self): test_html = self.marionette.absolute_url("test.html") self.marionette.navigate(test_html) From 60fab48cebb0a024b4f7e4355195bb077afdd951 Mon Sep 17 00:00:00 2001 From: Ted Mielczarek Date: Thu, 6 Apr 2017 12:03:14 -0400 Subject: [PATCH 07/89] bug 1350093 - fix sccache configuration to handle changes in the format of TASKCLUSTER_WORKER_GROUP. r=froydnj The TASKCLUSTER_WORKER_GROUP environment variable used to contain the full AWS availability zone, but a recent docker-worker change changed it to be simply the AWS region, which broke sccache in taskcluster because we were using it as part of the S3 bucket name. MozReview-Commit-ID: 1KsfWpB4PoY --HG-- extra : rebase_source : bdc61f180bf079eb0ad2cdbbd25e3e3a0deb62e6 --- build/mozconfig.cache | 5 ++++- taskcluster/scripts/builder/build-linux.sh | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build/mozconfig.cache b/build/mozconfig.cache index e7912507ec29..86997dcdbacc 100644 --- a/build/mozconfig.cache +++ b/build/mozconfig.cache @@ -49,7 +49,10 @@ if test -z "$bucket" -a -z "$SCCACHE_DISABLE" -a -z "$no_sccache" -a -z "$MOZ_PG # prevent rerun if az is set, or wget is not available if test -z "$availability_zone" -a -x "$(command -v wget)"; then if test -n "${TASKCLUSTER_WORKER_GROUP}"; then - availability_zone="${TASKCLUSTER_WORKER_GROUP}" + # TASKCLUSTER_WORKER_GROUP is just the region now, so + # stick an extra character on to make the already-convoluted logic + # here simpler. + availability_zone="${TASKCLUSTER_WORKER_GROUP}x" else # timeout after 1 second, and don't retry (failure indicates instance is not in ec2 or network issue) # availability_zone is of the form where region is e.g. us-west-2, and az is us-west-2a diff --git a/taskcluster/scripts/builder/build-linux.sh b/taskcluster/scripts/builder/build-linux.sh index 03c69c4e597d..78b1dc751e7c 100755 --- a/taskcluster/scripts/builder/build-linux.sh +++ b/taskcluster/scripts/builder/build-linux.sh @@ -52,7 +52,7 @@ export LIBRARY_PATH=$LIBRARY_PATH:$WORKSPACE/src/obj-firefox:$WORKSPACE/src/gcc/ if [[ -n ${USE_SCCACHE} ]]; then # Point sccache at the Taskcluster proxy for AWS credentials. - export AWS_IAM_CREDENTIALS_URL="http://taskcluster/auth/v1/aws/s3/read-write/taskcluster-level-${MOZ_SCM_LEVEL}-sccache-${TASKCLUSTER_WORKER_GROUP%?}/?format=iam-role-compat" + export AWS_IAM_CREDENTIALS_URL="http://taskcluster/auth/v1/aws/s3/read-write/taskcluster-level-${MOZ_SCM_LEVEL}-sccache-${TASKCLUSTER_WORKER_GROUP}/?format=iam-role-compat" fi # test required parameters are supplied From 1f7a01483e42cde71027ef1667a997b2dd84cfe9 Mon Sep 17 00:00:00 2001 From: Aki Sasaki Date: Thu, 6 Apr 2017 10:59:07 -0700 Subject: [PATCH 08/89] bug 1339179 - adjust pine's taskcluster tasks. r=jlorenzo DONTBUILD --- taskcluster/taskgraph/target_tasks.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/taskcluster/taskgraph/target_tasks.py b/taskcluster/taskgraph/target_tasks.py index a86169c53928..7c1fd323328a 100644 --- a/taskcluster/taskgraph/target_tasks.py +++ b/taskcluster/taskgraph/target_tasks.py @@ -285,7 +285,12 @@ def target_tasks_pine(full_task_graph, parameters): # disable mobile jobs if str(platform).startswith('android'): return False - return True + # disable asan + if platform == 'linux64-asan': + return False + # disable non-pine and nightly tasks + if standard_filter(task, parameters): + return True return [l for l, t in full_task_graph.tasks.iteritems() if filter(t)] From f3a2ca7fb5cfb039c29b68cee28706361c2152cc Mon Sep 17 00:00:00 2001 From: "Byron Campen [:bwc]" Date: Thu, 6 Apr 2017 12:29:57 -0500 Subject: [PATCH 09/89] Bug 1339588 - Part 3: Don't break the nsTimer/nsTimerImpl cycle during Fire. r=froydnj, a=dveditz MozReview-Commit-ID: J6TNJqGsBv4 --HG-- extra : rebase_source : 363923520a2527911c9b82aaf28d3d3291e95a71 --- xpcom/threads/nsTimerImpl.cpp | 30 ++++++++++++++++++++++-------- xpcom/threads/nsTimerImpl.h | 1 + 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/xpcom/threads/nsTimerImpl.cpp b/xpcom/threads/nsTimerImpl.cpp index 21f86f7261a1..4dc61e424dcb 100644 --- a/xpcom/threads/nsTimerImpl.cpp +++ b/xpcom/threads/nsTimerImpl.cpp @@ -121,12 +121,16 @@ nsTimer::Release(void) NS_LOG_RELEASE(this, count, "nsTimer"); if (count == 1) { - // Last ref, held by nsTimerImpl. Make sure the cycle is broken. - // If there is a nsTimerEvent in a queue for this timer, the nsTimer will - // live until that event pops, otherwise the nsTimerImpl will go away and - // the nsTimer along with it. - mImpl->Cancel(); - mImpl = nullptr; + if (!mImpl->CancelCheckIfFiring()) { + // Last ref, in nsTimerImpl::mITimer. Make sure the cycle is broken. + // (when Cancel fails, nsTimerImpl::Fire is in progress, which has grabbed + // another ref to the nsITimer since we checked the value of mRefCnt + // above) + // If there is a nsTimerEvent in a queue for this timer, the nsTimer will + // live until that event pops, otherwise the nsTimerImpl will go away and + // the nsTimer along with it. + mImpl = nullptr; + } } else if (count == 0) { delete this; } @@ -307,8 +311,8 @@ nsTimerImpl::Init(nsIObserver* aObserver, uint32_t aDelay, uint32_t aType) return InitCommon(aDelay, aType); } -nsresult -nsTimerImpl::Cancel() +bool +nsTimerImpl::CancelCheckIfFiring() { Callback cb; @@ -321,6 +325,16 @@ nsTimerImpl::Cancel() cb.swap(mCallback); ++mGeneration; + if (mCallbackDuringFire.mType != Callback::Type::Unknown) { + return true; + } + return false; +} + +nsresult +nsTimerImpl::Cancel() +{ + (void)CancelCheckIfFiring(); return NS_OK; } diff --git a/xpcom/threads/nsTimerImpl.h b/xpcom/threads/nsTimerImpl.h index 857c05647c56..fc393c9407b2 100644 --- a/xpcom/threads/nsTimerImpl.h +++ b/xpcom/threads/nsTimerImpl.h @@ -50,6 +50,7 @@ public: static void Shutdown(); void SetDelayInternal(uint32_t aDelay, TimeStamp aBase = TimeStamp::Now()); + bool CancelCheckIfFiring(); void Fire(int32_t aGeneration); From 9178a1fa0665404db3eeabe8e0dd2b9c5dfad3fc Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Thu, 6 Apr 2017 20:17:34 +0200 Subject: [PATCH 10/89] Bug 1354166 - Add missing #include for gfxPlatform::IsHeadless(). r=bdahl MozReview-Commit-ID: DkpUu8j3Lou --- toolkit/xre/nsAppRunner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 5f875edfdcfe..1423170a5ab5 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -89,6 +89,7 @@ #include "nsIDocShell.h" #include "nsAppShellCID.h" #include "mozilla/scache/StartupCache.h" +#include "gfxPlatform.h" #include "gfxPrefs.h" #include "mozilla/Unused.h" From 14f1a284bb216faae1cd8dc5e4ac0cac50dc0d57 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Thu, 6 Apr 2017 20:17:34 +0200 Subject: [PATCH 11/89] Bug 1338108 - The result of adding any percentage factor to a size that is zero should also be zero. r=dholbert MozReview-Commit-ID: OzOCjvcz0A --- layout/base/nsLayoutUtils.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 131cf6f4f798..e74480c7f398 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -1450,13 +1450,14 @@ public: /** * This function increases an initial intrinsic size, 'aCurrent', according * to the given 'aPercent', such that the size-increase makes up exactly - * 'aPercent' percent of the returned value. If 'aPercent' is less than - * or equal to zero the original 'aCurrent' value is returned. If 'aPercent' - * is greater than or equal to 1.0 the value nscoord_MAX is returned. + * 'aPercent' percent of the returned value. If 'aPercent' or 'aCurrent' are + * less than or equal to zero the original 'aCurrent' value is returned. + * If 'aPercent' is greater than or equal to 1.0 the value nscoord_MAX is + * returned. */ static nscoord AddPercents(nscoord aCurrent, float aPercent) { - if (aPercent > 0.0f) { + if (aPercent > 0.0f && aCurrent > 0) { return MOZ_UNLIKELY(aPercent >= 1.0f) ? nscoord_MAX : NSToCoordRound(float(aCurrent) / (1.0f - aPercent)); } From 7c2f6c390ad10223a418628396ea01809db6f6ff Mon Sep 17 00:00:00 2001 From: Sebastian Hengst Date: Thu, 6 Apr 2017 21:12:29 +0200 Subject: [PATCH 12/89] Backed out changeset 4df8d4e384ef (bug 1338108) for unexpectedly passing 367185-1.xhtml. r=backout --- layout/base/nsLayoutUtils.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index e74480c7f398..131cf6f4f798 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -1450,14 +1450,13 @@ public: /** * This function increases an initial intrinsic size, 'aCurrent', according * to the given 'aPercent', such that the size-increase makes up exactly - * 'aPercent' percent of the returned value. If 'aPercent' or 'aCurrent' are - * less than or equal to zero the original 'aCurrent' value is returned. - * If 'aPercent' is greater than or equal to 1.0 the value nscoord_MAX is - * returned. + * 'aPercent' percent of the returned value. If 'aPercent' is less than + * or equal to zero the original 'aCurrent' value is returned. If 'aPercent' + * is greater than or equal to 1.0 the value nscoord_MAX is returned. */ static nscoord AddPercents(nscoord aCurrent, float aPercent) { - if (aPercent > 0.0f && aCurrent > 0) { + if (aPercent > 0.0f) { return MOZ_UNLIKELY(aPercent >= 1.0f) ? nscoord_MAX : NSToCoordRound(float(aCurrent) / (1.0f - aPercent)); } From 224324d56d3075f8cf8533672fc6505ad6df8e5f Mon Sep 17 00:00:00 2001 From: James Willcox Date: Wed, 1 Mar 2017 10:17:09 -0600 Subject: [PATCH 13/89] Bug 1344347 - Move Android out-of-process decoder service into GeckoView r=jolin MozReview-Commit-ID: QTnp95uhQV --HG-- rename : mobile/android/base/aidl/org/mozilla/gecko/media/FormatParam.aidl => mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/FormatParam.aidl rename : mobile/android/base/aidl/org/mozilla/gecko/media/ICodec.aidl => mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/ICodec.aidl rename : mobile/android/base/aidl/org/mozilla/gecko/media/ICodecCallbacks.aidl => mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/ICodecCallbacks.aidl rename : mobile/android/base/aidl/org/mozilla/gecko/media/IMediaDrmBridge.aidl => mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/IMediaDrmBridge.aidl rename : mobile/android/base/aidl/org/mozilla/gecko/media/IMediaDrmBridgeCallbacks.aidl => mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/IMediaDrmBridgeCallbacks.aidl rename : mobile/android/base/aidl/org/mozilla/gecko/media/IMediaManager.aidl => mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/IMediaManager.aidl rename : mobile/android/base/aidl/org/mozilla/gecko/media/Sample.aidl => mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/Sample.aidl rename : mobile/android/base/aidl/org/mozilla/gecko/media/SessionKeyInfo.aidl => mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/SessionKeyInfo.aidl rename : mobile/android/base/java/org/mozilla/gecko/media/AsyncCodec.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/AsyncCodec.java rename : mobile/android/base/java/org/mozilla/gecko/media/AsyncCodecFactory.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/AsyncCodecFactory.java rename : mobile/android/base/java/org/mozilla/gecko/media/Codec.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Codec.java rename : mobile/android/base/java/org/mozilla/gecko/media/CodecProxy.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java rename : mobile/android/base/java/org/mozilla/gecko/media/FormatParam.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/FormatParam.java rename : mobile/android/base/java/org/mozilla/gecko/media/GeckoMediaDrm.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrm.java rename : mobile/android/base/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java rename : mobile/android/base/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV23.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV23.java rename : mobile/android/base/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java rename : mobile/android/base/java/org/mozilla/gecko/media/MediaDrmProxy.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/MediaDrmProxy.java rename : mobile/android/base/java/org/mozilla/gecko/media/MediaManager.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/MediaManager.java rename : mobile/android/base/java/org/mozilla/gecko/media/RemoteMediaDrmBridge.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteMediaDrmBridge.java rename : mobile/android/base/java/org/mozilla/gecko/media/RemoteMediaDrmBridgeStub.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteMediaDrmBridgeStub.java rename : mobile/android/base/java/org/mozilla/gecko/media/SamplePool.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/SamplePool.java rename : mobile/android/base/java/org/mozilla/gecko/media/SessionKeyInfo.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/SessionKeyInfo.java rename : mobile/android/base/java/org/mozilla/gecko/mozglue/SharedMemory.java => mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/SharedMemory.java --- .../platforms/android/JavaCallbacksSupport.h | 2 +- .../WebrtcMediaCodecVP8VideoCodec.h | 2 +- mobile/android/base/Makefile.in | 9 +- .../org/mozilla/gecko/GeckoApplication.java | 8 + mobile/android/base/moz.build | 47 +- .../org/mozilla/gecko/media/FormatParam.aidl | 0 .../aidl/org/mozilla/gecko/media/ICodec.aidl | 0 .../mozilla/gecko/media/ICodecCallbacks.aidl | 0 .../mozilla/gecko/media/IMediaDrmBridge.aidl | 0 .../gecko/media/IMediaDrmBridgeCallbacks.aidl | 0 .../mozilla/gecko/media/IMediaManager.aidl | 0 .../aidl/org/mozilla/gecko/media/Sample.aidl | 0 .../mozilla/gecko/media/SessionKeyInfo.aidl | 0 .../org/mozilla/gecko/media/AsyncCodec.java | 0 .../gecko/media/AsyncCodecFactory.java | 0 .../java/org/mozilla/gecko/media/Codec.java | 0 .../org/mozilla/gecko/media/CodecProxy.java | 0 .../org/mozilla/gecko/media/FormatParam.java | 0 .../mozilla/gecko/media/GeckoMediaDrm.java | 0 .../gecko/media/GeckoMediaDrmBridgeV21.java | 0 .../gecko/media/GeckoMediaDrmBridgeV23.java | 0 .../gecko/media/JellyBeanAsyncCodec.java | 0 .../mozilla/gecko/media/MediaDrmProxy.java | 0 .../org/mozilla/gecko/media/MediaManager.java | 0 .../mozilla/gecko/media/RemoteManager.java | 15 +- .../gecko/media/RemoteMediaDrmBridge.java | 0 .../gecko/media/RemoteMediaDrmBridgeStub.java | 0 .../java/org/mozilla/gecko/media/Sample.java | 1 - .../org/mozilla/gecko/media/SamplePool.java | 0 .../mozilla/gecko/media/SessionKeyInfo.java | 0 .../mozilla/gecko/media}/SharedMemBuffer.java | 3 +- .../mozilla/gecko/mozglue/SharedMemory.java | 0 mozglue/android/SharedMemNatives.cpp | 4 +- widget/android/GeneratedJNINatives.h | 66 ++ widget/android/GeneratedJNIWrappers.cpp | 278 ++++++ widget/android/GeneratedJNIWrappers.h | 808 ++++++++++++++++++ widget/android/fennec/FennecJNINatives.h | 66 -- widget/android/fennec/FennecJNIWrappers.cpp | 278 ------ widget/android/fennec/FennecJNIWrappers.h | 808 ------------------ 39 files changed, 1207 insertions(+), 1188 deletions(-) rename mobile/android/{base => geckoview/src/main}/aidl/org/mozilla/gecko/media/FormatParam.aidl (100%) rename mobile/android/{base => geckoview/src/main}/aidl/org/mozilla/gecko/media/ICodec.aidl (100%) rename mobile/android/{base => geckoview/src/main}/aidl/org/mozilla/gecko/media/ICodecCallbacks.aidl (100%) rename mobile/android/{base => geckoview/src/main}/aidl/org/mozilla/gecko/media/IMediaDrmBridge.aidl (100%) rename mobile/android/{base => geckoview/src/main}/aidl/org/mozilla/gecko/media/IMediaDrmBridgeCallbacks.aidl (100%) rename mobile/android/{base => geckoview/src/main}/aidl/org/mozilla/gecko/media/IMediaManager.aidl (100%) rename mobile/android/{base => geckoview/src/main}/aidl/org/mozilla/gecko/media/Sample.aidl (100%) rename mobile/android/{base => geckoview/src/main}/aidl/org/mozilla/gecko/media/SessionKeyInfo.aidl (100%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/AsyncCodec.java (100%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/AsyncCodecFactory.java (100%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/Codec.java (100%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/CodecProxy.java (100%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/FormatParam.java (100%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/GeckoMediaDrm.java (100%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java (100%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV23.java (100%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java (100%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/MediaDrmProxy.java (100%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/MediaManager.java (100%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/RemoteManager.java (94%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/RemoteMediaDrmBridge.java (100%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/RemoteMediaDrmBridgeStub.java (100%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/Sample.java (99%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/SamplePool.java (100%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/media/SessionKeyInfo.java (100%) rename mobile/android/{base/java/org/mozilla/gecko/mozglue => geckoview/src/main/java/org/mozilla/gecko/media}/SharedMemBuffer.java (97%) rename mobile/android/{base => geckoview/src/main}/java/org/mozilla/gecko/mozglue/SharedMemory.java (100%) diff --git a/dom/media/platforms/android/JavaCallbacksSupport.h b/dom/media/platforms/android/JavaCallbacksSupport.h index 20783f30265f..c23e5f5921dc 100644 --- a/dom/media/platforms/android/JavaCallbacksSupport.h +++ b/dom/media/platforms/android/JavaCallbacksSupport.h @@ -5,7 +5,7 @@ #ifndef JavaCallbacksSupport_h_ #define JavaCallbacksSupport_h_ -#include "FennecJNINatives.h" +#include "GeneratedJNINatives.h" #include "MediaResult.h" #include "MediaCodec.h" diff --git a/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.h b/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.h index d2c0fffbb44c..d141721267d2 100644 --- a/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.h +++ b/media/webrtc/signaling/src/media-conduit/WebrtcMediaCodecVP8VideoCodec.h @@ -14,7 +14,7 @@ #include "MediaConduitInterface.h" #include "AudioConduit.h" #include "VideoConduit.h" -#include "FennecJNIWrappers.h" +#include "GeneratedJNIWrappers.h" #include "webrtc/modules/video_coding/include/video_codec_interface.h" diff --git a/mobile/android/base/Makefile.in b/mobile/android/base/Makefile.in index b5a13dc74e26..b3367d5dcef8 100644 --- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -571,13 +571,18 @@ aidl_src_path := $(srcdir)/aidl aidl_target_path := generated media_pkg := org/mozilla/gecko/media -$(aidl_target_path)/$(media_pkg)/%.java:$(aidl_src_path)/$(media_pkg)/%.aidl +$(aidl_target_path)/$(media_pkg)/%.java:$(aidl_geckoview_src_path)/$(media_pkg)/%.aidl @echo "Processing AIDL: $< => $@" - $(AIDL) -p$(ANDROID_SDK)/framework.aidl -I$(aidl_src_path) -o$(aidl_target_path) $< + $(AIDL) -p$(ANDROID_SDK)/framework.aidl -I$(aidl_geckoview_src_path) -o$(aidl_target_path) $< GECKOVIEW_AIDLS = \ org/mozilla/gecko/IGeckoEditableChild.aidl \ org/mozilla/gecko/IGeckoEditableParent.aidl \ + org/mozilla/gecko/media/ICodec.java \ + org/mozilla/gecko/media/ICodecCallbacks.java \ + org/mozilla/gecko/media/IMediaDrmBridge.java \ + org/mozilla/gecko/media/IMediaDrmBridgeCallbacks.java \ + org/mozilla/gecko/media/IMediaManager.java \ org/mozilla/gecko/process/IChildProcess.aidl \ org/mozilla/gecko/process/IProcessManager.aidl \ $(NULL) diff --git a/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java b/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java index 5732da1274c4..02d23edd515d 100644 --- a/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java +++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java @@ -23,6 +23,7 @@ import org.mozilla.gecko.home.HomePanelsManager; import org.mozilla.gecko.lwt.LightweightTheme; import org.mozilla.gecko.mdns.MulticastDNSManager; import org.mozilla.gecko.media.AudioFocusAgent; +import org.mozilla.gecko.media.RemoteManager; import org.mozilla.gecko.notifications.NotificationClient; import org.mozilla.gecko.notifications.NotificationHelper; import org.mozilla.gecko.preferences.DistroSharedPrefsImport; @@ -39,6 +40,7 @@ import java.lang.reflect.Method; public class GeckoApplication extends Application implements ContextGetter { private static final String LOG_TAG = "GeckoApplication"; + private static final String MEDIA_DECODING_PROCESS_CRASH = "MEDIA_DECODING_PROCESS_CRASH"; private boolean mInBackground; private boolean mPausedGecko; @@ -212,6 +214,12 @@ public class GeckoApplication extends Application GeckoAccessibility.setAccessibilityManagerListeners(this); AudioFocusAgent.getInstance().attachToContext(this); + + RemoteManager.setCrashReporter(new RemoteManager.ICrashReporter() { + public void reportDecodingProcessCrash() { + Telemetry.addToHistogram(MEDIA_DECODING_PROCESS_CRASH, 1); + } + }); } private class EventListener implements BundleEventListener diff --git a/mobile/android/base/moz.build b/mobile/android/base/moz.build index 082e4930da2a..e742990463f3 100644 --- a/mobile/android/base/moz.build +++ b/mobile/android/base/moz.build @@ -121,6 +121,7 @@ mgjar.sources += [geckoview_source_dir + 'java/org/mozilla/gecko/' + x for x in 'mozglue/NativeReference.java', 'mozglue/NativeZip.java', 'mozglue/SafeIntent.java', + 'mozglue/SharedMemory.java', ]] mgjar.generated_sources = [] # Keep it this way. mgjar.extra_jars += [ @@ -286,6 +287,24 @@ gvjar.sources += [geckoview_source_dir + 'java/org/mozilla/gecko/' + x 'gfx/VsyncSource.java', 'InputConnectionListener.java', 'InputMethods.java', + 'media/AsyncCodec.java', + 'media/AsyncCodecFactory.java', + 'media/Codec.java', + 'media/CodecProxy.java', + 'media/FormatParam.java', + 'media/GeckoMediaDrm.java', + 'media/GeckoMediaDrmBridgeV21.java', + 'media/GeckoMediaDrmBridgeV23.java', + 'media/JellyBeanAsyncCodec.java', + 'media/MediaDrmProxy.java', + 'media/MediaManager.java', + 'media/RemoteManager.java', + 'media/RemoteMediaDrmBridge.java', + 'media/RemoteMediaDrmBridgeStub.java', + 'media/Sample.java', + 'media/SamplePool.java', + 'media/SessionKeyInfo.java', + 'media/SharedMemBuffer.java', 'NativeQueue.java', 'NotificationListener.java', 'NSSBridge.java', @@ -594,25 +613,8 @@ gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [ 'lwt/LightweightTheme.java', 'lwt/LightweightThemeDrawable.java', 'mdns/MulticastDNSManager.java', - 'media/AsyncCodec.java', - 'media/AsyncCodecFactory.java', 'media/AudioFocusAgent.java', - 'media/Codec.java', - 'media/CodecProxy.java', - 'media/FormatParam.java', - 'media/GeckoMediaDrm.java', - 'media/GeckoMediaDrmBridgeV21.java', - 'media/GeckoMediaDrmBridgeV23.java', - 'media/JellyBeanAsyncCodec.java', 'media/MediaControlService.java', - 'media/MediaDrmProxy.java', - 'media/MediaManager.java', - 'media/RemoteManager.java', - 'media/RemoteMediaDrmBridge.java', - 'media/RemoteMediaDrmBridgeStub.java', - 'media/Sample.java', - 'media/SamplePool.java', - 'media/SessionKeyInfo.java', 'media/VideoPlayer.java', 'MediaCastingBar.java', 'MemoryMonitor.java', @@ -626,8 +628,6 @@ gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [ 'menu/MenuPanel.java', 'menu/MenuPopup.java', 'MotionEventInterceptor.java', - 'mozglue/SharedMemBuffer.java', - 'mozglue/SharedMemory.java', 'notifications/NotificationClient.java', 'notifications/NotificationHelper.java', 'notifications/NotificationReceiver.java', @@ -1188,17 +1188,14 @@ OBJDIR_PP_FILES.mobile.android.base += [ 'AndroidManifest.xml.in', ] -gbjar.sources += ['generated/org/mozilla/gecko/' + x for x in [ +gvjar.sources += ['generated/org/mozilla/gecko/' + x for x in [ + 'IGeckoEditableChild.java', + 'IGeckoEditableParent.java', 'media/ICodec.java', 'media/ICodecCallbacks.java', 'media/IMediaDrmBridge.java', 'media/IMediaDrmBridgeCallbacks.java', 'media/IMediaManager.java', -]] - -gvjar.sources += ['generated/org/mozilla/gecko/' + x for x in [ - 'IGeckoEditableChild.java', - 'IGeckoEditableParent.java', 'process/IChildProcess.java', 'process/IProcessManager.java', ]] diff --git a/mobile/android/base/aidl/org/mozilla/gecko/media/FormatParam.aidl b/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/FormatParam.aidl similarity index 100% rename from mobile/android/base/aidl/org/mozilla/gecko/media/FormatParam.aidl rename to mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/FormatParam.aidl diff --git a/mobile/android/base/aidl/org/mozilla/gecko/media/ICodec.aidl b/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/ICodec.aidl similarity index 100% rename from mobile/android/base/aidl/org/mozilla/gecko/media/ICodec.aidl rename to mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/ICodec.aidl diff --git a/mobile/android/base/aidl/org/mozilla/gecko/media/ICodecCallbacks.aidl b/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/ICodecCallbacks.aidl similarity index 100% rename from mobile/android/base/aidl/org/mozilla/gecko/media/ICodecCallbacks.aidl rename to mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/ICodecCallbacks.aidl diff --git a/mobile/android/base/aidl/org/mozilla/gecko/media/IMediaDrmBridge.aidl b/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/IMediaDrmBridge.aidl similarity index 100% rename from mobile/android/base/aidl/org/mozilla/gecko/media/IMediaDrmBridge.aidl rename to mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/IMediaDrmBridge.aidl diff --git a/mobile/android/base/aidl/org/mozilla/gecko/media/IMediaDrmBridgeCallbacks.aidl b/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/IMediaDrmBridgeCallbacks.aidl similarity index 100% rename from mobile/android/base/aidl/org/mozilla/gecko/media/IMediaDrmBridgeCallbacks.aidl rename to mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/IMediaDrmBridgeCallbacks.aidl diff --git a/mobile/android/base/aidl/org/mozilla/gecko/media/IMediaManager.aidl b/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/IMediaManager.aidl similarity index 100% rename from mobile/android/base/aidl/org/mozilla/gecko/media/IMediaManager.aidl rename to mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/IMediaManager.aidl diff --git a/mobile/android/base/aidl/org/mozilla/gecko/media/Sample.aidl b/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/Sample.aidl similarity index 100% rename from mobile/android/base/aidl/org/mozilla/gecko/media/Sample.aidl rename to mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/Sample.aidl diff --git a/mobile/android/base/aidl/org/mozilla/gecko/media/SessionKeyInfo.aidl b/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/SessionKeyInfo.aidl similarity index 100% rename from mobile/android/base/aidl/org/mozilla/gecko/media/SessionKeyInfo.aidl rename to mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/SessionKeyInfo.aidl diff --git a/mobile/android/base/java/org/mozilla/gecko/media/AsyncCodec.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/AsyncCodec.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/media/AsyncCodec.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/AsyncCodec.java diff --git a/mobile/android/base/java/org/mozilla/gecko/media/AsyncCodecFactory.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/AsyncCodecFactory.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/media/AsyncCodecFactory.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/AsyncCodecFactory.java diff --git a/mobile/android/base/java/org/mozilla/gecko/media/Codec.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Codec.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/media/Codec.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Codec.java diff --git a/mobile/android/base/java/org/mozilla/gecko/media/CodecProxy.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/media/CodecProxy.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java diff --git a/mobile/android/base/java/org/mozilla/gecko/media/FormatParam.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/FormatParam.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/media/FormatParam.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/FormatParam.java diff --git a/mobile/android/base/java/org/mozilla/gecko/media/GeckoMediaDrm.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrm.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/media/GeckoMediaDrm.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrm.java diff --git a/mobile/android/base/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java diff --git a/mobile/android/base/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV23.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV23.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV23.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV23.java diff --git a/mobile/android/base/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java diff --git a/mobile/android/base/java/org/mozilla/gecko/media/MediaDrmProxy.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/MediaDrmProxy.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/media/MediaDrmProxy.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/MediaDrmProxy.java diff --git a/mobile/android/base/java/org/mozilla/gecko/media/MediaManager.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/MediaManager.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/media/MediaManager.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/MediaManager.java diff --git a/mobile/android/base/java/org/mozilla/gecko/media/RemoteManager.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteManager.java similarity index 94% rename from mobile/android/base/java/org/mozilla/gecko/media/RemoteManager.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteManager.java index dda0a02cda41..6a586f41061e 100644 --- a/mobile/android/base/java/org/mozilla/gecko/media/RemoteManager.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteManager.java @@ -5,7 +5,6 @@ package org.mozilla.gecko.media; import org.mozilla.gecko.GeckoAppShell; -import org.mozilla.gecko.Telemetry; import android.content.ComponentName; import android.content.Context; @@ -25,6 +24,7 @@ public final class RemoteManager implements IBinder.DeathRecipient { private static final String LOGTAG = "GeckoRemoteManager"; private static final boolean DEBUG = false; private static RemoteManager sRemoteManager = null; + private static ICrashReporter setCrashReporter = null; public synchronized static RemoteManager getInstance() { if (sRemoteManager == null) { @@ -133,9 +133,18 @@ public final class RemoteManager implements IBinder.DeathRecipient { } } - private static final String MEDIA_DECODING_PROCESS_CRASH = "MEDIA_DECODING_PROCESS_CRASH"; private void reportDecodingProcessCrash() { - Telemetry.addToHistogram(MEDIA_DECODING_PROCESS_CRASH, 1); + if (setCrashReporter != null) { + setCrashReporter.reportDecodingProcessCrash(); + } + } + + public static void setCrashReporter(ICrashReporter reporter) { + setCrashReporter = reporter; + } + + public interface ICrashReporter { + void reportDecodingProcessCrash(); } public synchronized IMediaDrmBridge createRemoteMediaDrmBridge(String keySystem, diff --git a/mobile/android/base/java/org/mozilla/gecko/media/RemoteMediaDrmBridge.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteMediaDrmBridge.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/media/RemoteMediaDrmBridge.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteMediaDrmBridge.java diff --git a/mobile/android/base/java/org/mozilla/gecko/media/RemoteMediaDrmBridgeStub.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteMediaDrmBridgeStub.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/media/RemoteMediaDrmBridgeStub.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteMediaDrmBridgeStub.java diff --git a/mobile/android/base/java/org/mozilla/gecko/media/Sample.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Sample.java similarity index 99% rename from mobile/android/base/java/org/mozilla/gecko/media/Sample.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Sample.java index b7a98da8abdf..95bf6a2f403d 100644 --- a/mobile/android/base/java/org/mozilla/gecko/media/Sample.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Sample.java @@ -11,7 +11,6 @@ import android.os.Parcel; import android.os.Parcelable; import org.mozilla.gecko.annotation.WrapForJNI; -import org.mozilla.gecko.mozglue.SharedMemBuffer; import org.mozilla.gecko.mozglue.SharedMemory; import java.io.IOException; diff --git a/mobile/android/base/java/org/mozilla/gecko/media/SamplePool.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/SamplePool.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/media/SamplePool.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/SamplePool.java diff --git a/mobile/android/base/java/org/mozilla/gecko/media/SessionKeyInfo.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/SessionKeyInfo.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/media/SessionKeyInfo.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/SessionKeyInfo.java diff --git a/mobile/android/base/java/org/mozilla/gecko/mozglue/SharedMemBuffer.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/SharedMemBuffer.java similarity index 97% rename from mobile/android/base/java/org/mozilla/gecko/mozglue/SharedMemBuffer.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/SharedMemBuffer.java index d9455dc5df89..9442687ed4a7 100644 --- a/mobile/android/base/java/org/mozilla/gecko/mozglue/SharedMemBuffer.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/SharedMemBuffer.java @@ -1,10 +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/. */ -package org.mozilla.gecko.mozglue; +package org.mozilla.gecko.media; import android.os.Parcel; +import org.mozilla.gecko.mozglue.SharedMemory; import org.mozilla.gecko.media.Sample; import java.io.IOException; diff --git a/mobile/android/base/java/org/mozilla/gecko/mozglue/SharedMemory.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/SharedMemory.java similarity index 100% rename from mobile/android/base/java/org/mozilla/gecko/mozglue/SharedMemory.java rename to mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/SharedMemory.java diff --git a/mozglue/android/SharedMemNatives.cpp b/mozglue/android/SharedMemNatives.cpp index 04ceac6a57f2..6b8e8de197a1 100644 --- a/mozglue/android/SharedMemNatives.cpp +++ b/mozglue/android/SharedMemNatives.cpp @@ -13,7 +13,7 @@ extern "C" { JNIEXPORT void JNICALL -Java_org_mozilla_gecko_mozglue_SharedMemBuffer_nativeReadFromDirectBuffer(JNIEnv* jenv, jclass, jobject src, jlong dest, jint offset, jint size) +Java_org_mozilla_gecko_media_SharedMemBuffer_nativeReadFromDirectBuffer(JNIEnv* jenv, jclass, jobject src, jlong dest, jint offset, jint size) { uint8_t* from = static_cast(jenv->GetDirectBufferAddress(src)); if (from == nullptr) { @@ -32,7 +32,7 @@ Java_org_mozilla_gecko_mozglue_SharedMemBuffer_nativeReadFromDirectBuffer(JNIEnv JNIEXPORT void JNICALL -Java_org_mozilla_gecko_mozglue_SharedMemBuffer_nativeWriteToDirectBuffer(JNIEnv* jenv, jclass, jlong src, jobject dest, jint offset, jint size) +Java_org_mozilla_gecko_media_SharedMemBuffer_nativeWriteToDirectBuffer(JNIEnv* jenv, jclass, jlong src, jobject dest, jint offset, jint size) { uint8_t* from = reinterpret_cast(src); if (from == nullptr) { diff --git a/widget/android/GeneratedJNINatives.h b/widget/android/GeneratedJNINatives.h index d8d66d1d350d..097ba047a421 100644 --- a/widget/android/GeneratedJNINatives.h +++ b/widget/android/GeneratedJNINatives.h @@ -440,6 +440,72 @@ const JNINativeMethod VsyncSource::Natives::methods[] = { ::template Wrap<&Impl::NotifyVsync>) }; +template +class CodecProxy::NativeCallbacks::Natives : public mozilla::jni::NativeImpl +{ +public: + static const JNINativeMethod methods[4]; +}; + +template +const JNINativeMethod CodecProxy::NativeCallbacks::Natives::methods[] = { + + mozilla::jni::MakeNativeMethod( + mozilla::jni::NativeStub + ::template Wrap<&Impl::OnError>), + + mozilla::jni::MakeNativeMethod( + mozilla::jni::NativeStub + ::template Wrap<&Impl::OnInputExhausted>), + + mozilla::jni::MakeNativeMethod( + mozilla::jni::NativeStub + ::template Wrap<&Impl::OnOutput>), + + mozilla::jni::MakeNativeMethod( + mozilla::jni::NativeStub + ::template Wrap<&Impl::OnOutputFormatChanged>) +}; + +template +class MediaDrmProxy::NativeMediaDrmProxyCallbacks::Natives : public mozilla::jni::NativeImpl +{ +public: + static const JNINativeMethod methods[7]; +}; + +template +const JNINativeMethod MediaDrmProxy::NativeMediaDrmProxyCallbacks::Natives::methods[] = { + + mozilla::jni::MakeNativeMethod( + mozilla::jni::NativeStub + ::template Wrap<&Impl::OnRejectPromise>), + + mozilla::jni::MakeNativeMethod( + mozilla::jni::NativeStub + ::template Wrap<&Impl::OnSessionBatchedKeyChanged>), + + mozilla::jni::MakeNativeMethod( + mozilla::jni::NativeStub + ::template Wrap<&Impl::OnSessionClosed>), + + mozilla::jni::MakeNativeMethod( + mozilla::jni::NativeStub + ::template Wrap<&Impl::OnSessionCreated>), + + mozilla::jni::MakeNativeMethod( + mozilla::jni::NativeStub + ::template Wrap<&Impl::OnSessionError>), + + mozilla::jni::MakeNativeMethod( + mozilla::jni::NativeStub + ::template Wrap<&Impl::OnSessionMessage>), + + mozilla::jni::MakeNativeMethod( + mozilla::jni::NativeStub + ::template Wrap<&Impl::OnSessionUpdated>) +}; + template class GeckoProcessManager::Natives : public mozilla::jni::NativeImpl { diff --git a/widget/android/GeneratedJNIWrappers.cpp b/widget/android/GeneratedJNIWrappers.cpp index bf8a2eba3d25..00986135b49f 100644 --- a/widget/android/GeneratedJNIWrappers.cpp +++ b/widget/android/GeneratedJNIWrappers.cpp @@ -1744,6 +1744,284 @@ auto VsyncSource::INSTANCE() -> VsyncSource::LocalRef return mozilla::jni::Field::Get(VsyncSource::Context(), nullptr); } +const char CodecProxy::name[] = + "org/mozilla/gecko/media/CodecProxy"; + +constexpr char CodecProxy::Create_t::name[]; +constexpr char CodecProxy::Create_t::signature[]; + +auto CodecProxy::Create(bool a0, mozilla::jni::Object::Param a1, mozilla::jni::Object::Param a2, mozilla::jni::Object::Param a3, mozilla::jni::String::Param a4) -> CodecProxy::LocalRef +{ + return mozilla::jni::Method::Call(CodecProxy::Context(), nullptr, a0, a1, a2, a3, a4); +} + +constexpr char CodecProxy::Flush_t::name[]; +constexpr char CodecProxy::Flush_t::signature[]; + +auto CodecProxy::Flush() const -> bool +{ + return mozilla::jni::Method::Call(CodecProxy::mCtx, nullptr); +} + +constexpr char CodecProxy::Input_t::name[]; +constexpr char CodecProxy::Input_t::signature[]; + +auto CodecProxy::Input(mozilla::jni::ByteBuffer::Param a0, mozilla::jni::Object::Param a1, mozilla::jni::Object::Param a2) const -> bool +{ + return mozilla::jni::Method::Call(CodecProxy::mCtx, nullptr, a0, a1, a2); +} + +constexpr char CodecProxy::IsAdaptivePlaybackSupported_t::name[]; +constexpr char CodecProxy::IsAdaptivePlaybackSupported_t::signature[]; + +auto CodecProxy::IsAdaptivePlaybackSupported() const -> bool +{ + return mozilla::jni::Method::Call(CodecProxy::mCtx, nullptr); +} + +constexpr char CodecProxy::Release_t::name[]; +constexpr char CodecProxy::Release_t::signature[]; + +auto CodecProxy::Release() const -> bool +{ + return mozilla::jni::Method::Call(CodecProxy::mCtx, nullptr); +} + +constexpr char CodecProxy::ReleaseOutput_t::name[]; +constexpr char CodecProxy::ReleaseOutput_t::signature[]; + +auto CodecProxy::ReleaseOutput(mozilla::jni::Object::Param a0, bool a1) const -> bool +{ + return mozilla::jni::Method::Call(CodecProxy::mCtx, nullptr, a0, a1); +} + +constexpr char CodecProxy::SetRates_t::name[]; +constexpr char CodecProxy::SetRates_t::signature[]; + +auto CodecProxy::SetRates(int32_t a0) const -> bool +{ + return mozilla::jni::Method::Call(CodecProxy::mCtx, nullptr, a0); +} + +const char CodecProxy::NativeCallbacks::name[] = + "org/mozilla/gecko/media/CodecProxy$NativeCallbacks"; + +constexpr char CodecProxy::NativeCallbacks::New_t::name[]; +constexpr char CodecProxy::NativeCallbacks::New_t::signature[]; + +auto CodecProxy::NativeCallbacks::New() -> NativeCallbacks::LocalRef +{ + return mozilla::jni::Constructor::Call(NativeCallbacks::Context(), nullptr); +} + +constexpr char CodecProxy::NativeCallbacks::DisposeNative_t::name[]; +constexpr char CodecProxy::NativeCallbacks::DisposeNative_t::signature[]; + +auto CodecProxy::NativeCallbacks::DisposeNative() const -> void +{ + return mozilla::jni::Method::Call(NativeCallbacks::mCtx, nullptr); +} + +constexpr char CodecProxy::NativeCallbacks::OnError_t::name[]; +constexpr char CodecProxy::NativeCallbacks::OnError_t::signature[]; + +constexpr char CodecProxy::NativeCallbacks::OnInputExhausted_t::name[]; +constexpr char CodecProxy::NativeCallbacks::OnInputExhausted_t::signature[]; + +constexpr char CodecProxy::NativeCallbacks::OnOutput_t::name[]; +constexpr char CodecProxy::NativeCallbacks::OnOutput_t::signature[]; + +constexpr char CodecProxy::NativeCallbacks::OnOutputFormatChanged_t::name[]; +constexpr char CodecProxy::NativeCallbacks::OnOutputFormatChanged_t::signature[]; + +const char MediaDrmProxy::name[] = + "org/mozilla/gecko/media/MediaDrmProxy"; + +constexpr char MediaDrmProxy::CanDecode_t::name[]; +constexpr char MediaDrmProxy::CanDecode_t::signature[]; + +auto MediaDrmProxy::CanDecode(mozilla::jni::String::Param a0) -> bool +{ + return mozilla::jni::Method::Call(MediaDrmProxy::Context(), nullptr, a0); +} + +constexpr char MediaDrmProxy::IsCryptoSchemeSupported_t::name[]; +constexpr char MediaDrmProxy::IsCryptoSchemeSupported_t::signature[]; + +auto MediaDrmProxy::IsCryptoSchemeSupported(mozilla::jni::String::Param a0, mozilla::jni::String::Param a1) -> bool +{ + return mozilla::jni::Method::Call(MediaDrmProxy::Context(), nullptr, a0, a1); +} + +constexpr char MediaDrmProxy::CloseSession_t::name[]; +constexpr char MediaDrmProxy::CloseSession_t::signature[]; + +auto MediaDrmProxy::CloseSession(int32_t a0, mozilla::jni::String::Param a1) const -> void +{ + return mozilla::jni::Method::Call(MediaDrmProxy::mCtx, nullptr, a0, a1); +} + +constexpr char MediaDrmProxy::Create_t::name[]; +constexpr char MediaDrmProxy::Create_t::signature[]; + +auto MediaDrmProxy::Create(mozilla::jni::String::Param a0, mozilla::jni::Object::Param a1) -> MediaDrmProxy::LocalRef +{ + return mozilla::jni::Method::Call(MediaDrmProxy::Context(), nullptr, a0, a1); +} + +constexpr char MediaDrmProxy::CreateSession_t::name[]; +constexpr char MediaDrmProxy::CreateSession_t::signature[]; + +auto MediaDrmProxy::CreateSession(int32_t a0, int32_t a1, mozilla::jni::String::Param a2, mozilla::jni::ByteArray::Param a3) const -> void +{ + return mozilla::jni::Method::Call(MediaDrmProxy::mCtx, nullptr, a0, a1, a2, a3); +} + +constexpr char MediaDrmProxy::Destroy_t::name[]; +constexpr char MediaDrmProxy::Destroy_t::signature[]; + +auto MediaDrmProxy::Destroy() const -> void +{ + return mozilla::jni::Method::Call(MediaDrmProxy::mCtx, nullptr); +} + +constexpr char MediaDrmProxy::GetMediaCrypto_t::name[]; +constexpr char MediaDrmProxy::GetMediaCrypto_t::signature[]; + +auto MediaDrmProxy::GetMediaCrypto(mozilla::jni::String::Param a0) -> mozilla::jni::Object::LocalRef +{ + return mozilla::jni::Method::Call(MediaDrmProxy::Context(), nullptr, a0); +} + +constexpr char MediaDrmProxy::GetStubId_t::name[]; +constexpr char MediaDrmProxy::GetStubId_t::signature[]; + +auto MediaDrmProxy::GetStubId() const -> mozilla::jni::String::LocalRef +{ + return mozilla::jni::Method::Call(MediaDrmProxy::mCtx, nullptr); +} + +constexpr char MediaDrmProxy::IsSchemeSupported_t::name[]; +constexpr char MediaDrmProxy::IsSchemeSupported_t::signature[]; + +auto MediaDrmProxy::IsSchemeSupported(mozilla::jni::String::Param a0) -> bool +{ + return mozilla::jni::Method::Call(MediaDrmProxy::Context(), nullptr, a0); +} + +constexpr char MediaDrmProxy::UpdateSession_t::name[]; +constexpr char MediaDrmProxy::UpdateSession_t::signature[]; + +auto MediaDrmProxy::UpdateSession(int32_t a0, mozilla::jni::String::Param a1, mozilla::jni::ByteArray::Param a2) const -> void +{ + return mozilla::jni::Method::Call(MediaDrmProxy::mCtx, nullptr, a0, a1, a2); +} + +const char16_t MediaDrmProxy::AAC[] = u"audio/mp4a-latm"; + +const char16_t MediaDrmProxy::AVC[] = u"video/avc"; + +const char16_t MediaDrmProxy::OPUS[] = u"audio/opus"; + +const char16_t MediaDrmProxy::VORBIS[] = u"audio/vorbis"; + +const char16_t MediaDrmProxy::VP8[] = u"video/x-vnd.on2.vp8"; + +const char16_t MediaDrmProxy::VP9[] = u"video/x-vnd.on2.vp9"; + +const char MediaDrmProxy::NativeMediaDrmProxyCallbacks::name[] = + "org/mozilla/gecko/media/MediaDrmProxy$NativeMediaDrmProxyCallbacks"; + +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::New_t::name[]; +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::New_t::signature[]; + +auto MediaDrmProxy::NativeMediaDrmProxyCallbacks::New() -> NativeMediaDrmProxyCallbacks::LocalRef +{ + return mozilla::jni::Constructor::Call(NativeMediaDrmProxyCallbacks::Context(), nullptr); +} + +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnRejectPromise_t::name[]; +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnRejectPromise_t::signature[]; + +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionBatchedKeyChanged_t::name[]; +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionBatchedKeyChanged_t::signature[]; + +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionClosed_t::name[]; +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionClosed_t::signature[]; + +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionCreated_t::name[]; +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionCreated_t::signature[]; + +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionError_t::name[]; +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionError_t::signature[]; + +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionMessage_t::name[]; +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionMessage_t::signature[]; + +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionUpdated_t::name[]; +constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionUpdated_t::signature[]; + +const char Sample::name[] = + "org/mozilla/gecko/media/Sample"; + +constexpr char Sample::WriteToByteBuffer_t::name[]; +constexpr char Sample::WriteToByteBuffer_t::signature[]; + +auto Sample::WriteToByteBuffer(mozilla::jni::ByteBuffer::Param a0) const -> void +{ + return mozilla::jni::Method::Call(Sample::mCtx, nullptr, a0); +} + +constexpr char Sample::Info_t::name[]; +constexpr char Sample::Info_t::signature[]; + +auto Sample::Info() const -> mozilla::jni::Object::LocalRef +{ + return mozilla::jni::Field::Get(Sample::mCtx, nullptr); +} + +auto Sample::Info(mozilla::jni::Object::Param a0) const -> void +{ + return mozilla::jni::Field::Set(Sample::mCtx, nullptr, a0); +} + +const char SessionKeyInfo::name[] = + "org/mozilla/gecko/media/SessionKeyInfo"; + +constexpr char SessionKeyInfo::New_t::name[]; +constexpr char SessionKeyInfo::New_t::signature[]; + +auto SessionKeyInfo::New(mozilla::jni::ByteArray::Param a0, int32_t a1) -> SessionKeyInfo::LocalRef +{ + return mozilla::jni::Constructor::Call(SessionKeyInfo::Context(), nullptr, a0, a1); +} + +constexpr char SessionKeyInfo::KeyId_t::name[]; +constexpr char SessionKeyInfo::KeyId_t::signature[]; + +auto SessionKeyInfo::KeyId() const -> mozilla::jni::ByteArray::LocalRef +{ + return mozilla::jni::Field::Get(SessionKeyInfo::mCtx, nullptr); +} + +auto SessionKeyInfo::KeyId(mozilla::jni::ByteArray::Param a0) const -> void +{ + return mozilla::jni::Field::Set(SessionKeyInfo::mCtx, nullptr, a0); +} + +constexpr char SessionKeyInfo::Status_t::name[]; +constexpr char SessionKeyInfo::Status_t::signature[]; + +auto SessionKeyInfo::Status() const -> int32_t +{ + return mozilla::jni::Field::Get(SessionKeyInfo::mCtx, nullptr); +} + +auto SessionKeyInfo::Status(int32_t a0) const -> void +{ + return mozilla::jni::Field::Set(SessionKeyInfo::mCtx, nullptr, a0); +} + const char GeckoProcessManager::name[] = "org/mozilla/gecko/process/GeckoProcessManager"; diff --git a/widget/android/GeneratedJNIWrappers.h b/widget/android/GeneratedJNIWrappers.h index 5b97d1a95894..fe628134fd53 100644 --- a/widget/android/GeneratedJNIWrappers.h +++ b/widget/android/GeneratedJNIWrappers.h @@ -4966,6 +4966,814 @@ public: template class Natives; }; +class CodecProxy : public mozilla::jni::ObjectBase +{ +public: + static const char name[]; + + explicit CodecProxy(const Context& ctx) : ObjectBase(ctx) {} + + class NativeCallbacks; + + struct Create_t { + typedef CodecProxy Owner; + typedef CodecProxy::LocalRef ReturnType; + typedef CodecProxy::Param SetterType; + typedef mozilla::jni::Args< + bool, + mozilla::jni::Object::Param, + mozilla::jni::Object::Param, + mozilla::jni::Object::Param, + mozilla::jni::String::Param> Args; + static constexpr char name[] = "create"; + static constexpr char signature[] = + "(ZLandroid/media/MediaFormat;Landroid/view/Surface;Lorg/mozilla/gecko/media/CodecProxy$Callbacks;Ljava/lang/String;)Lorg/mozilla/gecko/media/CodecProxy;"; + static const bool isStatic = true; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + static auto Create(bool, mozilla::jni::Object::Param, mozilla::jni::Object::Param, mozilla::jni::Object::Param, mozilla::jni::String::Param) -> CodecProxy::LocalRef; + + struct Flush_t { + typedef CodecProxy Owner; + typedef bool ReturnType; + typedef bool SetterType; + typedef mozilla::jni::Args<> Args; + static constexpr char name[] = "flush"; + static constexpr char signature[] = + "()Z"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto Flush() const -> bool; + + struct Input_t { + typedef CodecProxy Owner; + typedef bool ReturnType; + typedef bool SetterType; + typedef mozilla::jni::Args< + mozilla::jni::ByteBuffer::Param, + mozilla::jni::Object::Param, + mozilla::jni::Object::Param> Args; + static constexpr char name[] = "input"; + static constexpr char signature[] = + "(Ljava/nio/ByteBuffer;Landroid/media/MediaCodec$BufferInfo;Landroid/media/MediaCodec$CryptoInfo;)Z"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto Input(mozilla::jni::ByteBuffer::Param, mozilla::jni::Object::Param, mozilla::jni::Object::Param) const -> bool; + + struct IsAdaptivePlaybackSupported_t { + typedef CodecProxy Owner; + typedef bool ReturnType; + typedef bool SetterType; + typedef mozilla::jni::Args<> Args; + static constexpr char name[] = "isAdaptivePlaybackSupported"; + static constexpr char signature[] = + "()Z"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto IsAdaptivePlaybackSupported() const -> bool; + + struct Release_t { + typedef CodecProxy Owner; + typedef bool ReturnType; + typedef bool SetterType; + typedef mozilla::jni::Args<> Args; + static constexpr char name[] = "release"; + static constexpr char signature[] = + "()Z"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto Release() const -> bool; + + struct ReleaseOutput_t { + typedef CodecProxy Owner; + typedef bool ReturnType; + typedef bool SetterType; + typedef mozilla::jni::Args< + mozilla::jni::Object::Param, + bool> Args; + static constexpr char name[] = "releaseOutput"; + static constexpr char signature[] = + "(Lorg/mozilla/gecko/media/Sample;Z)Z"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto ReleaseOutput(mozilla::jni::Object::Param, bool) const -> bool; + + struct SetRates_t { + typedef CodecProxy Owner; + typedef bool ReturnType; + typedef bool SetterType; + typedef mozilla::jni::Args< + int32_t> Args; + static constexpr char name[] = "setRates"; + static constexpr char signature[] = + "(I)Z"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto SetRates(int32_t) const -> bool; + + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + +}; + +class CodecProxy::NativeCallbacks : public mozilla::jni::ObjectBase +{ +public: + static const char name[]; + + explicit NativeCallbacks(const Context& ctx) : ObjectBase(ctx) {} + + struct New_t { + typedef NativeCallbacks Owner; + typedef NativeCallbacks::LocalRef ReturnType; + typedef NativeCallbacks::Param SetterType; + typedef mozilla::jni::Args<> Args; + static constexpr char name[] = ""; + static constexpr char signature[] = + "()V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + static auto New() -> NativeCallbacks::LocalRef; + + struct DisposeNative_t { + typedef NativeCallbacks Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args<> Args; + static constexpr char name[] = "disposeNative"; + static constexpr char signature[] = + "()V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto DisposeNative() const -> void; + + struct OnError_t { + typedef NativeCallbacks Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args< + bool> Args; + static constexpr char name[] = "onError"; + static constexpr char signature[] = + "(Z)V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + struct OnInputExhausted_t { + typedef NativeCallbacks Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args<> Args; + static constexpr char name[] = "onInputExhausted"; + static constexpr char signature[] = + "()V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + struct OnOutput_t { + typedef NativeCallbacks Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args< + mozilla::jni::Object::Param> Args; + static constexpr char name[] = "onOutput"; + static constexpr char signature[] = + "(Lorg/mozilla/gecko/media/Sample;)V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + struct OnOutputFormatChanged_t { + typedef NativeCallbacks Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args< + mozilla::jni::Object::Param> Args; + static constexpr char name[] = "onOutputFormatChanged"; + static constexpr char signature[] = + "(Landroid/media/MediaFormat;)V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + + template class Natives; +}; + +class MediaDrmProxy : public mozilla::jni::ObjectBase +{ +public: + static const char name[]; + + explicit MediaDrmProxy(const Context& ctx) : ObjectBase(ctx) {} + + class NativeMediaDrmProxyCallbacks; + + struct CanDecode_t { + typedef MediaDrmProxy Owner; + typedef bool ReturnType; + typedef bool SetterType; + typedef mozilla::jni::Args< + mozilla::jni::String::Param> Args; + static constexpr char name[] = "CanDecode"; + static constexpr char signature[] = + "(Ljava/lang/String;)Z"; + static const bool isStatic = true; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + static auto CanDecode(mozilla::jni::String::Param) -> bool; + + struct IsCryptoSchemeSupported_t { + typedef MediaDrmProxy Owner; + typedef bool ReturnType; + typedef bool SetterType; + typedef mozilla::jni::Args< + mozilla::jni::String::Param, + mozilla::jni::String::Param> Args; + static constexpr char name[] = "IsCryptoSchemeSupported"; + static constexpr char signature[] = + "(Ljava/lang/String;Ljava/lang/String;)Z"; + static const bool isStatic = true; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + static auto IsCryptoSchemeSupported(mozilla::jni::String::Param, mozilla::jni::String::Param) -> bool; + + struct CloseSession_t { + typedef MediaDrmProxy Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args< + int32_t, + mozilla::jni::String::Param> Args; + static constexpr char name[] = "closeSession"; + static constexpr char signature[] = + "(ILjava/lang/String;)V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto CloseSession(int32_t, mozilla::jni::String::Param) const -> void; + + struct Create_t { + typedef MediaDrmProxy Owner; + typedef MediaDrmProxy::LocalRef ReturnType; + typedef MediaDrmProxy::Param SetterType; + typedef mozilla::jni::Args< + mozilla::jni::String::Param, + mozilla::jni::Object::Param> Args; + static constexpr char name[] = "create"; + static constexpr char signature[] = + "(Ljava/lang/String;Lorg/mozilla/gecko/media/MediaDrmProxy$Callbacks;)Lorg/mozilla/gecko/media/MediaDrmProxy;"; + static const bool isStatic = true; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::GECKO; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + static auto Create(mozilla::jni::String::Param, mozilla::jni::Object::Param) -> MediaDrmProxy::LocalRef; + + struct CreateSession_t { + typedef MediaDrmProxy Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args< + int32_t, + int32_t, + mozilla::jni::String::Param, + mozilla::jni::ByteArray::Param> Args; + static constexpr char name[] = "createSession"; + static constexpr char signature[] = + "(IILjava/lang/String;[B)V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto CreateSession(int32_t, int32_t, mozilla::jni::String::Param, mozilla::jni::ByteArray::Param) const -> void; + + struct Destroy_t { + typedef MediaDrmProxy Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args<> Args; + static constexpr char name[] = "destroy"; + static constexpr char signature[] = + "()V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto Destroy() const -> void; + + struct GetMediaCrypto_t { + typedef MediaDrmProxy Owner; + typedef mozilla::jni::Object::LocalRef ReturnType; + typedef mozilla::jni::Object::Param SetterType; + typedef mozilla::jni::Args< + mozilla::jni::String::Param> Args; + static constexpr char name[] = "getMediaCrypto"; + static constexpr char signature[] = + "(Ljava/lang/String;)Landroid/media/MediaCrypto;"; + static const bool isStatic = true; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + static auto GetMediaCrypto(mozilla::jni::String::Param) -> mozilla::jni::Object::LocalRef; + + struct GetStubId_t { + typedef MediaDrmProxy Owner; + typedef mozilla::jni::String::LocalRef ReturnType; + typedef mozilla::jni::String::Param SetterType; + typedef mozilla::jni::Args<> Args; + static constexpr char name[] = "getStubId"; + static constexpr char signature[] = + "()Ljava/lang/String;"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::GECKO; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto GetStubId() const -> mozilla::jni::String::LocalRef; + + struct IsSchemeSupported_t { + typedef MediaDrmProxy Owner; + typedef bool ReturnType; + typedef bool SetterType; + typedef mozilla::jni::Args< + mozilla::jni::String::Param> Args; + static constexpr char name[] = "isSchemeSupported"; + static constexpr char signature[] = + "(Ljava/lang/String;)Z"; + static const bool isStatic = true; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + static auto IsSchemeSupported(mozilla::jni::String::Param) -> bool; + + struct UpdateSession_t { + typedef MediaDrmProxy Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args< + int32_t, + mozilla::jni::String::Param, + mozilla::jni::ByteArray::Param> Args; + static constexpr char name[] = "updateSession"; + static constexpr char signature[] = + "(ILjava/lang/String;[B)V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto UpdateSession(int32_t, mozilla::jni::String::Param, mozilla::jni::ByteArray::Param) const -> void; + + static const char16_t AAC[]; + + static const char16_t AVC[]; + + static const char16_t OPUS[]; + + static const char16_t VORBIS[]; + + static const char16_t VP8[]; + + static const char16_t VP9[]; + + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + +}; + +class MediaDrmProxy::NativeMediaDrmProxyCallbacks : public mozilla::jni::ObjectBase +{ +public: + static const char name[]; + + explicit NativeMediaDrmProxyCallbacks(const Context& ctx) : ObjectBase(ctx) {} + + struct New_t { + typedef NativeMediaDrmProxyCallbacks Owner; + typedef NativeMediaDrmProxyCallbacks::LocalRef ReturnType; + typedef NativeMediaDrmProxyCallbacks::Param SetterType; + typedef mozilla::jni::Args<> Args; + static constexpr char name[] = ""; + static constexpr char signature[] = + "()V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::GECKO; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + static auto New() -> NativeMediaDrmProxyCallbacks::LocalRef; + + struct OnRejectPromise_t { + typedef NativeMediaDrmProxyCallbacks Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args< + int32_t, + mozilla::jni::String::Param> Args; + static constexpr char name[] = "onRejectPromise"; + static constexpr char signature[] = + "(ILjava/lang/String;)V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::GECKO; + }; + + struct OnSessionBatchedKeyChanged_t { + typedef NativeMediaDrmProxyCallbacks Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args< + mozilla::jni::ByteArray::Param, + mozilla::jni::ObjectArray::Param> Args; + static constexpr char name[] = "onSessionBatchedKeyChanged"; + static constexpr char signature[] = + "([B[Lorg/mozilla/gecko/media/SessionKeyInfo;)V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::GECKO; + }; + + struct OnSessionClosed_t { + typedef NativeMediaDrmProxyCallbacks Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args< + int32_t, + mozilla::jni::ByteArray::Param> Args; + static constexpr char name[] = "onSessionClosed"; + static constexpr char signature[] = + "(I[B)V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::GECKO; + }; + + struct OnSessionCreated_t { + typedef NativeMediaDrmProxyCallbacks Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args< + int32_t, + int32_t, + mozilla::jni::ByteArray::Param, + mozilla::jni::ByteArray::Param> Args; + static constexpr char name[] = "onSessionCreated"; + static constexpr char signature[] = + "(II[B[B)V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::GECKO; + }; + + struct OnSessionError_t { + typedef NativeMediaDrmProxyCallbacks Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args< + mozilla::jni::ByteArray::Param, + mozilla::jni::String::Param> Args; + static constexpr char name[] = "onSessionError"; + static constexpr char signature[] = + "([BLjava/lang/String;)V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::GECKO; + }; + + struct OnSessionMessage_t { + typedef NativeMediaDrmProxyCallbacks Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args< + mozilla::jni::ByteArray::Param, + int32_t, + mozilla::jni::ByteArray::Param> Args; + static constexpr char name[] = "onSessionMessage"; + static constexpr char signature[] = + "([BI[B)V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::GECKO; + }; + + struct OnSessionUpdated_t { + typedef NativeMediaDrmProxyCallbacks Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args< + int32_t, + mozilla::jni::ByteArray::Param> Args; + static constexpr char name[] = "onSessionUpdated"; + static constexpr char signature[] = + "(I[B)V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::GECKO; + }; + + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + + template class Natives; +}; + +class Sample : public mozilla::jni::ObjectBase +{ +public: + static const char name[]; + + explicit Sample(const Context& ctx) : ObjectBase(ctx) {} + + struct WriteToByteBuffer_t { + typedef Sample Owner; + typedef void ReturnType; + typedef void SetterType; + typedef mozilla::jni::Args< + mozilla::jni::ByteBuffer::Param> Args; + static constexpr char name[] = "writeToByteBuffer"; + static constexpr char signature[] = + "(Ljava/nio/ByteBuffer;)V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto WriteToByteBuffer(mozilla::jni::ByteBuffer::Param) const -> void; + + struct Info_t { + typedef Sample Owner; + typedef mozilla::jni::Object::LocalRef ReturnType; + typedef mozilla::jni::Object::Param SetterType; + typedef mozilla::jni::Args<> Args; + static constexpr char name[] = "info"; + static constexpr char signature[] = + "Landroid/media/MediaCodec$BufferInfo;"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto Info() const -> mozilla::jni::Object::LocalRef; + + auto Info(mozilla::jni::Object::Param) const -> void; + + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + +}; + +class SessionKeyInfo : public mozilla::jni::ObjectBase +{ +public: + static const char name[]; + + explicit SessionKeyInfo(const Context& ctx) : ObjectBase(ctx) {} + + struct New_t { + typedef SessionKeyInfo Owner; + typedef SessionKeyInfo::LocalRef ReturnType; + typedef SessionKeyInfo::Param SetterType; + typedef mozilla::jni::Args< + mozilla::jni::ByteArray::Param, + int32_t> Args; + static constexpr char name[] = ""; + static constexpr char signature[] = + "([BI)V"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + static auto New(mozilla::jni::ByteArray::Param, int32_t) -> SessionKeyInfo::LocalRef; + + struct KeyId_t { + typedef SessionKeyInfo Owner; + typedef mozilla::jni::ByteArray::LocalRef ReturnType; + typedef mozilla::jni::ByteArray::Param SetterType; + typedef mozilla::jni::Args<> Args; + static constexpr char name[] = "keyId"; + static constexpr char signature[] = + "[B"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto KeyId() const -> mozilla::jni::ByteArray::LocalRef; + + auto KeyId(mozilla::jni::ByteArray::Param) const -> void; + + struct Status_t { + typedef SessionKeyInfo Owner; + typedef int32_t ReturnType; + typedef int32_t SetterType; + typedef mozilla::jni::Args<> Args; + static constexpr char name[] = "status"; + static constexpr char signature[] = + "I"; + static const bool isStatic = false; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + static const mozilla::jni::DispatchTarget dispatchTarget = + mozilla::jni::DispatchTarget::CURRENT; + }; + + auto Status() const -> int32_t; + + auto Status(int32_t) const -> void; + + static const mozilla::jni::CallingThread callingThread = + mozilla::jni::CallingThread::ANY; + +}; + class GeckoProcessManager : public mozilla::jni::ObjectBase { public: diff --git a/widget/android/fennec/FennecJNINatives.h b/widget/android/fennec/FennecJNINatives.h index 35a3c8184bfc..3099d6b81d41 100644 --- a/widget/android/fennec/FennecJNINatives.h +++ b/widget/android/fennec/FennecJNINatives.h @@ -150,72 +150,6 @@ const JNINativeMethod ZoomedView::Natives::methods[] = { ::template Wrap<&Impl::RequestZoomedViewData>) }; -template -class CodecProxy::NativeCallbacks::Natives : public mozilla::jni::NativeImpl -{ -public: - static const JNINativeMethod methods[4]; -}; - -template -const JNINativeMethod CodecProxy::NativeCallbacks::Natives::methods[] = { - - mozilla::jni::MakeNativeMethod( - mozilla::jni::NativeStub - ::template Wrap<&Impl::OnError>), - - mozilla::jni::MakeNativeMethod( - mozilla::jni::NativeStub - ::template Wrap<&Impl::OnInputExhausted>), - - mozilla::jni::MakeNativeMethod( - mozilla::jni::NativeStub - ::template Wrap<&Impl::OnOutput>), - - mozilla::jni::MakeNativeMethod( - mozilla::jni::NativeStub - ::template Wrap<&Impl::OnOutputFormatChanged>) -}; - -template -class MediaDrmProxy::NativeMediaDrmProxyCallbacks::Natives : public mozilla::jni::NativeImpl -{ -public: - static const JNINativeMethod methods[7]; -}; - -template -const JNINativeMethod MediaDrmProxy::NativeMediaDrmProxyCallbacks::Natives::methods[] = { - - mozilla::jni::MakeNativeMethod( - mozilla::jni::NativeStub - ::template Wrap<&Impl::OnRejectPromise>), - - mozilla::jni::MakeNativeMethod( - mozilla::jni::NativeStub - ::template Wrap<&Impl::OnSessionBatchedKeyChanged>), - - mozilla::jni::MakeNativeMethod( - mozilla::jni::NativeStub - ::template Wrap<&Impl::OnSessionClosed>), - - mozilla::jni::MakeNativeMethod( - mozilla::jni::NativeStub - ::template Wrap<&Impl::OnSessionCreated>), - - mozilla::jni::MakeNativeMethod( - mozilla::jni::NativeStub - ::template Wrap<&Impl::OnSessionError>), - - mozilla::jni::MakeNativeMethod( - mozilla::jni::NativeStub - ::template Wrap<&Impl::OnSessionMessage>), - - mozilla::jni::MakeNativeMethod( - mozilla::jni::NativeStub - ::template Wrap<&Impl::OnSessionUpdated>) -}; - } /* java */ } /* mozilla */ #endif // FennecJNINatives_h diff --git a/widget/android/fennec/FennecJNIWrappers.cpp b/widget/android/fennec/FennecJNIWrappers.cpp index 8644d8d46020..89cb61a62a21 100644 --- a/widget/android/fennec/FennecJNIWrappers.cpp +++ b/widget/android/fennec/FennecJNIWrappers.cpp @@ -178,284 +178,6 @@ auto AudioFocusAgent::NotifyStoppedPlaying() -> void return mozilla::jni::Method::Call(AudioFocusAgent::Context(), nullptr); } -const char CodecProxy::name[] = - "org/mozilla/gecko/media/CodecProxy"; - -constexpr char CodecProxy::Create_t::name[]; -constexpr char CodecProxy::Create_t::signature[]; - -auto CodecProxy::Create(bool a0, mozilla::jni::Object::Param a1, mozilla::jni::Object::Param a2, mozilla::jni::Object::Param a3, mozilla::jni::String::Param a4) -> CodecProxy::LocalRef -{ - return mozilla::jni::Method::Call(CodecProxy::Context(), nullptr, a0, a1, a2, a3, a4); -} - -constexpr char CodecProxy::Flush_t::name[]; -constexpr char CodecProxy::Flush_t::signature[]; - -auto CodecProxy::Flush() const -> bool -{ - return mozilla::jni::Method::Call(CodecProxy::mCtx, nullptr); -} - -constexpr char CodecProxy::Input_t::name[]; -constexpr char CodecProxy::Input_t::signature[]; - -auto CodecProxy::Input(mozilla::jni::ByteBuffer::Param a0, mozilla::jni::Object::Param a1, mozilla::jni::Object::Param a2) const -> bool -{ - return mozilla::jni::Method::Call(CodecProxy::mCtx, nullptr, a0, a1, a2); -} - -constexpr char CodecProxy::IsAdaptivePlaybackSupported_t::name[]; -constexpr char CodecProxy::IsAdaptivePlaybackSupported_t::signature[]; - -auto CodecProxy::IsAdaptivePlaybackSupported() const -> bool -{ - return mozilla::jni::Method::Call(CodecProxy::mCtx, nullptr); -} - -constexpr char CodecProxy::Release_t::name[]; -constexpr char CodecProxy::Release_t::signature[]; - -auto CodecProxy::Release() const -> bool -{ - return mozilla::jni::Method::Call(CodecProxy::mCtx, nullptr); -} - -constexpr char CodecProxy::ReleaseOutput_t::name[]; -constexpr char CodecProxy::ReleaseOutput_t::signature[]; - -auto CodecProxy::ReleaseOutput(mozilla::jni::Object::Param a0, bool a1) const -> bool -{ - return mozilla::jni::Method::Call(CodecProxy::mCtx, nullptr, a0, a1); -} - -constexpr char CodecProxy::SetRates_t::name[]; -constexpr char CodecProxy::SetRates_t::signature[]; - -auto CodecProxy::SetRates(int32_t a0) const -> bool -{ - return mozilla::jni::Method::Call(CodecProxy::mCtx, nullptr, a0); -} - -const char CodecProxy::NativeCallbacks::name[] = - "org/mozilla/gecko/media/CodecProxy$NativeCallbacks"; - -constexpr char CodecProxy::NativeCallbacks::New_t::name[]; -constexpr char CodecProxy::NativeCallbacks::New_t::signature[]; - -auto CodecProxy::NativeCallbacks::New() -> NativeCallbacks::LocalRef -{ - return mozilla::jni::Constructor::Call(NativeCallbacks::Context(), nullptr); -} - -constexpr char CodecProxy::NativeCallbacks::DisposeNative_t::name[]; -constexpr char CodecProxy::NativeCallbacks::DisposeNative_t::signature[]; - -auto CodecProxy::NativeCallbacks::DisposeNative() const -> void -{ - return mozilla::jni::Method::Call(NativeCallbacks::mCtx, nullptr); -} - -constexpr char CodecProxy::NativeCallbacks::OnError_t::name[]; -constexpr char CodecProxy::NativeCallbacks::OnError_t::signature[]; - -constexpr char CodecProxy::NativeCallbacks::OnInputExhausted_t::name[]; -constexpr char CodecProxy::NativeCallbacks::OnInputExhausted_t::signature[]; - -constexpr char CodecProxy::NativeCallbacks::OnOutput_t::name[]; -constexpr char CodecProxy::NativeCallbacks::OnOutput_t::signature[]; - -constexpr char CodecProxy::NativeCallbacks::OnOutputFormatChanged_t::name[]; -constexpr char CodecProxy::NativeCallbacks::OnOutputFormatChanged_t::signature[]; - -const char MediaDrmProxy::name[] = - "org/mozilla/gecko/media/MediaDrmProxy"; - -constexpr char MediaDrmProxy::CanDecode_t::name[]; -constexpr char MediaDrmProxy::CanDecode_t::signature[]; - -auto MediaDrmProxy::CanDecode(mozilla::jni::String::Param a0) -> bool -{ - return mozilla::jni::Method::Call(MediaDrmProxy::Context(), nullptr, a0); -} - -constexpr char MediaDrmProxy::IsCryptoSchemeSupported_t::name[]; -constexpr char MediaDrmProxy::IsCryptoSchemeSupported_t::signature[]; - -auto MediaDrmProxy::IsCryptoSchemeSupported(mozilla::jni::String::Param a0, mozilla::jni::String::Param a1) -> bool -{ - return mozilla::jni::Method::Call(MediaDrmProxy::Context(), nullptr, a0, a1); -} - -constexpr char MediaDrmProxy::CloseSession_t::name[]; -constexpr char MediaDrmProxy::CloseSession_t::signature[]; - -auto MediaDrmProxy::CloseSession(int32_t a0, mozilla::jni::String::Param a1) const -> void -{ - return mozilla::jni::Method::Call(MediaDrmProxy::mCtx, nullptr, a0, a1); -} - -constexpr char MediaDrmProxy::Create_t::name[]; -constexpr char MediaDrmProxy::Create_t::signature[]; - -auto MediaDrmProxy::Create(mozilla::jni::String::Param a0, mozilla::jni::Object::Param a1) -> MediaDrmProxy::LocalRef -{ - return mozilla::jni::Method::Call(MediaDrmProxy::Context(), nullptr, a0, a1); -} - -constexpr char MediaDrmProxy::CreateSession_t::name[]; -constexpr char MediaDrmProxy::CreateSession_t::signature[]; - -auto MediaDrmProxy::CreateSession(int32_t a0, int32_t a1, mozilla::jni::String::Param a2, mozilla::jni::ByteArray::Param a3) const -> void -{ - return mozilla::jni::Method::Call(MediaDrmProxy::mCtx, nullptr, a0, a1, a2, a3); -} - -constexpr char MediaDrmProxy::Destroy_t::name[]; -constexpr char MediaDrmProxy::Destroy_t::signature[]; - -auto MediaDrmProxy::Destroy() const -> void -{ - return mozilla::jni::Method::Call(MediaDrmProxy::mCtx, nullptr); -} - -constexpr char MediaDrmProxy::GetMediaCrypto_t::name[]; -constexpr char MediaDrmProxy::GetMediaCrypto_t::signature[]; - -auto MediaDrmProxy::GetMediaCrypto(mozilla::jni::String::Param a0) -> mozilla::jni::Object::LocalRef -{ - return mozilla::jni::Method::Call(MediaDrmProxy::Context(), nullptr, a0); -} - -constexpr char MediaDrmProxy::GetStubId_t::name[]; -constexpr char MediaDrmProxy::GetStubId_t::signature[]; - -auto MediaDrmProxy::GetStubId() const -> mozilla::jni::String::LocalRef -{ - return mozilla::jni::Method::Call(MediaDrmProxy::mCtx, nullptr); -} - -constexpr char MediaDrmProxy::IsSchemeSupported_t::name[]; -constexpr char MediaDrmProxy::IsSchemeSupported_t::signature[]; - -auto MediaDrmProxy::IsSchemeSupported(mozilla::jni::String::Param a0) -> bool -{ - return mozilla::jni::Method::Call(MediaDrmProxy::Context(), nullptr, a0); -} - -constexpr char MediaDrmProxy::UpdateSession_t::name[]; -constexpr char MediaDrmProxy::UpdateSession_t::signature[]; - -auto MediaDrmProxy::UpdateSession(int32_t a0, mozilla::jni::String::Param a1, mozilla::jni::ByteArray::Param a2) const -> void -{ - return mozilla::jni::Method::Call(MediaDrmProxy::mCtx, nullptr, a0, a1, a2); -} - -const char16_t MediaDrmProxy::AAC[] = u"audio/mp4a-latm"; - -const char16_t MediaDrmProxy::AVC[] = u"video/avc"; - -const char16_t MediaDrmProxy::OPUS[] = u"audio/opus"; - -const char16_t MediaDrmProxy::VORBIS[] = u"audio/vorbis"; - -const char16_t MediaDrmProxy::VP8[] = u"video/x-vnd.on2.vp8"; - -const char16_t MediaDrmProxy::VP9[] = u"video/x-vnd.on2.vp9"; - -const char MediaDrmProxy::NativeMediaDrmProxyCallbacks::name[] = - "org/mozilla/gecko/media/MediaDrmProxy$NativeMediaDrmProxyCallbacks"; - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::New_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::New_t::signature[]; - -auto MediaDrmProxy::NativeMediaDrmProxyCallbacks::New() -> NativeMediaDrmProxyCallbacks::LocalRef -{ - return mozilla::jni::Constructor::Call(NativeMediaDrmProxyCallbacks::Context(), nullptr); -} - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnRejectPromise_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnRejectPromise_t::signature[]; - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionBatchedKeyChanged_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionBatchedKeyChanged_t::signature[]; - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionClosed_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionClosed_t::signature[]; - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionCreated_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionCreated_t::signature[]; - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionError_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionError_t::signature[]; - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionMessage_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionMessage_t::signature[]; - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionUpdated_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionUpdated_t::signature[]; - -const char Sample::name[] = - "org/mozilla/gecko/media/Sample"; - -constexpr char Sample::WriteToByteBuffer_t::name[]; -constexpr char Sample::WriteToByteBuffer_t::signature[]; - -auto Sample::WriteToByteBuffer(mozilla::jni::ByteBuffer::Param a0) const -> void -{ - return mozilla::jni::Method::Call(Sample::mCtx, nullptr, a0); -} - -constexpr char Sample::Info_t::name[]; -constexpr char Sample::Info_t::signature[]; - -auto Sample::Info() const -> mozilla::jni::Object::LocalRef -{ - return mozilla::jni::Field::Get(Sample::mCtx, nullptr); -} - -auto Sample::Info(mozilla::jni::Object::Param a0) const -> void -{ - return mozilla::jni::Field::Set(Sample::mCtx, nullptr, a0); -} - -const char SessionKeyInfo::name[] = - "org/mozilla/gecko/media/SessionKeyInfo"; - -constexpr char SessionKeyInfo::New_t::name[]; -constexpr char SessionKeyInfo::New_t::signature[]; - -auto SessionKeyInfo::New(mozilla::jni::ByteArray::Param a0, int32_t a1) -> SessionKeyInfo::LocalRef -{ - return mozilla::jni::Constructor::Call(SessionKeyInfo::Context(), nullptr, a0, a1); -} - -constexpr char SessionKeyInfo::KeyId_t::name[]; -constexpr char SessionKeyInfo::KeyId_t::signature[]; - -auto SessionKeyInfo::KeyId() const -> mozilla::jni::ByteArray::LocalRef -{ - return mozilla::jni::Field::Get(SessionKeyInfo::mCtx, nullptr); -} - -auto SessionKeyInfo::KeyId(mozilla::jni::ByteArray::Param a0) const -> void -{ - return mozilla::jni::Field::Set(SessionKeyInfo::mCtx, nullptr, a0); -} - -constexpr char SessionKeyInfo::Status_t::name[]; -constexpr char SessionKeyInfo::Status_t::signature[]; - -auto SessionKeyInfo::Status() const -> int32_t -{ - return mozilla::jni::Field::Get(SessionKeyInfo::mCtx, nullptr); -} - -auto SessionKeyInfo::Status(int32_t a0) const -> void -{ - return mozilla::jni::Field::Set(SessionKeyInfo::mCtx, nullptr, a0); -} - const char Restrictions::name[] = "org/mozilla/gecko/restrictions/Restrictions"; diff --git a/widget/android/fennec/FennecJNIWrappers.h b/widget/android/fennec/FennecJNIWrappers.h index 044e9999e56a..139d01a9313c 100644 --- a/widget/android/fennec/FennecJNIWrappers.h +++ b/widget/android/fennec/FennecJNIWrappers.h @@ -654,814 +654,6 @@ public: }; -class CodecProxy : public mozilla::jni::ObjectBase -{ -public: - static const char name[]; - - explicit CodecProxy(const Context& ctx) : ObjectBase(ctx) {} - - class NativeCallbacks; - - struct Create_t { - typedef CodecProxy Owner; - typedef CodecProxy::LocalRef ReturnType; - typedef CodecProxy::Param SetterType; - typedef mozilla::jni::Args< - bool, - mozilla::jni::Object::Param, - mozilla::jni::Object::Param, - mozilla::jni::Object::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "create"; - static constexpr char signature[] = - "(ZLandroid/media/MediaFormat;Landroid/view/Surface;Lorg/mozilla/gecko/media/CodecProxy$Callbacks;Ljava/lang/String;)Lorg/mozilla/gecko/media/CodecProxy;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto Create(bool, mozilla::jni::Object::Param, mozilla::jni::Object::Param, mozilla::jni::Object::Param, mozilla::jni::String::Param) -> CodecProxy::LocalRef; - - struct Flush_t { - typedef CodecProxy Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "flush"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Flush() const -> bool; - - struct Input_t { - typedef CodecProxy Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteBuffer::Param, - mozilla::jni::Object::Param, - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "input"; - static constexpr char signature[] = - "(Ljava/nio/ByteBuffer;Landroid/media/MediaCodec$BufferInfo;Landroid/media/MediaCodec$CryptoInfo;)Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Input(mozilla::jni::ByteBuffer::Param, mozilla::jni::Object::Param, mozilla::jni::Object::Param) const -> bool; - - struct IsAdaptivePlaybackSupported_t { - typedef CodecProxy Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "isAdaptivePlaybackSupported"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto IsAdaptivePlaybackSupported() const -> bool; - - struct Release_t { - typedef CodecProxy Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "release"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Release() const -> bool; - - struct ReleaseOutput_t { - typedef CodecProxy Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param, - bool> Args; - static constexpr char name[] = "releaseOutput"; - static constexpr char signature[] = - "(Lorg/mozilla/gecko/media/Sample;Z)Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto ReleaseOutput(mozilla::jni::Object::Param, bool) const -> bool; - - struct SetRates_t { - typedef CodecProxy Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - int32_t> Args; - static constexpr char name[] = "setRates"; - static constexpr char signature[] = - "(I)Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto SetRates(int32_t) const -> bool; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class CodecProxy::NativeCallbacks : public mozilla::jni::ObjectBase -{ -public: - static const char name[]; - - explicit NativeCallbacks(const Context& ctx) : ObjectBase(ctx) {} - - struct New_t { - typedef NativeCallbacks Owner; - typedef NativeCallbacks::LocalRef ReturnType; - typedef NativeCallbacks::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = ""; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto New() -> NativeCallbacks::LocalRef; - - struct DisposeNative_t { - typedef NativeCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "disposeNative"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto DisposeNative() const -> void; - - struct OnError_t { - typedef NativeCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - bool> Args; - static constexpr char name[] = "onError"; - static constexpr char signature[] = - "(Z)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OnInputExhausted_t { - typedef NativeCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "onInputExhausted"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OnOutput_t { - typedef NativeCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "onOutput"; - static constexpr char signature[] = - "(Lorg/mozilla/gecko/media/Sample;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OnOutputFormatChanged_t { - typedef NativeCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "onOutputFormatChanged"; - static constexpr char signature[] = - "(Landroid/media/MediaFormat;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template class Natives; -}; - -class MediaDrmProxy : public mozilla::jni::ObjectBase -{ -public: - static const char name[]; - - explicit MediaDrmProxy(const Context& ctx) : ObjectBase(ctx) {} - - class NativeMediaDrmProxyCallbacks; - - struct CanDecode_t { - typedef MediaDrmProxy Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "CanDecode"; - static constexpr char signature[] = - "(Ljava/lang/String;)Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto CanDecode(mozilla::jni::String::Param) -> bool; - - struct IsCryptoSchemeSupported_t { - typedef MediaDrmProxy Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "IsCryptoSchemeSupported"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;)Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto IsCryptoSchemeSupported(mozilla::jni::String::Param, mozilla::jni::String::Param) -> bool; - - struct CloseSession_t { - typedef MediaDrmProxy Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "closeSession"; - static constexpr char signature[] = - "(ILjava/lang/String;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto CloseSession(int32_t, mozilla::jni::String::Param) const -> void; - - struct Create_t { - typedef MediaDrmProxy Owner; - typedef MediaDrmProxy::LocalRef ReturnType; - typedef MediaDrmProxy::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "create"; - static constexpr char signature[] = - "(Ljava/lang/String;Lorg/mozilla/gecko/media/MediaDrmProxy$Callbacks;)Lorg/mozilla/gecko/media/MediaDrmProxy;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto Create(mozilla::jni::String::Param, mozilla::jni::Object::Param) -> MediaDrmProxy::LocalRef; - - struct CreateSession_t { - typedef MediaDrmProxy Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - mozilla::jni::String::Param, - mozilla::jni::ByteArray::Param> Args; - static constexpr char name[] = "createSession"; - static constexpr char signature[] = - "(IILjava/lang/String;[B)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto CreateSession(int32_t, int32_t, mozilla::jni::String::Param, mozilla::jni::ByteArray::Param) const -> void; - - struct Destroy_t { - typedef MediaDrmProxy Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "destroy"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Destroy() const -> void; - - struct GetMediaCrypto_t { - typedef MediaDrmProxy Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getMediaCrypto"; - static constexpr char signature[] = - "(Ljava/lang/String;)Landroid/media/MediaCrypto;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetMediaCrypto(mozilla::jni::String::Param) -> mozilla::jni::Object::LocalRef; - - struct GetStubId_t { - typedef MediaDrmProxy Owner; - typedef mozilla::jni::String::LocalRef ReturnType; - typedef mozilla::jni::String::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getStubId"; - static constexpr char signature[] = - "()Ljava/lang/String;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto GetStubId() const -> mozilla::jni::String::LocalRef; - - struct IsSchemeSupported_t { - typedef MediaDrmProxy Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "isSchemeSupported"; - static constexpr char signature[] = - "(Ljava/lang/String;)Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto IsSchemeSupported(mozilla::jni::String::Param) -> bool; - - struct UpdateSession_t { - typedef MediaDrmProxy Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - mozilla::jni::String::Param, - mozilla::jni::ByteArray::Param> Args; - static constexpr char name[] = "updateSession"; - static constexpr char signature[] = - "(ILjava/lang/String;[B)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto UpdateSession(int32_t, mozilla::jni::String::Param, mozilla::jni::ByteArray::Param) const -> void; - - static const char16_t AAC[]; - - static const char16_t AVC[]; - - static const char16_t OPUS[]; - - static const char16_t VORBIS[]; - - static const char16_t VP8[]; - - static const char16_t VP9[]; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class MediaDrmProxy::NativeMediaDrmProxyCallbacks : public mozilla::jni::ObjectBase -{ -public: - static const char name[]; - - explicit NativeMediaDrmProxyCallbacks(const Context& ctx) : ObjectBase(ctx) {} - - struct New_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef NativeMediaDrmProxyCallbacks::LocalRef ReturnType; - typedef NativeMediaDrmProxyCallbacks::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = ""; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto New() -> NativeMediaDrmProxyCallbacks::LocalRef; - - struct OnRejectPromise_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "onRejectPromise"; - static constexpr char signature[] = - "(ILjava/lang/String;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnSessionBatchedKeyChanged_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteArray::Param, - mozilla::jni::ObjectArray::Param> Args; - static constexpr char name[] = "onSessionBatchedKeyChanged"; - static constexpr char signature[] = - "([B[Lorg/mozilla/gecko/media/SessionKeyInfo;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnSessionClosed_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - mozilla::jni::ByteArray::Param> Args; - static constexpr char name[] = "onSessionClosed"; - static constexpr char signature[] = - "(I[B)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnSessionCreated_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - mozilla::jni::ByteArray::Param, - mozilla::jni::ByteArray::Param> Args; - static constexpr char name[] = "onSessionCreated"; - static constexpr char signature[] = - "(II[B[B)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnSessionError_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteArray::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "onSessionError"; - static constexpr char signature[] = - "([BLjava/lang/String;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnSessionMessage_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteArray::Param, - int32_t, - mozilla::jni::ByteArray::Param> Args; - static constexpr char name[] = "onSessionMessage"; - static constexpr char signature[] = - "([BI[B)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnSessionUpdated_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - mozilla::jni::ByteArray::Param> Args; - static constexpr char name[] = "onSessionUpdated"; - static constexpr char signature[] = - "(I[B)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template class Natives; -}; - -class Sample : public mozilla::jni::ObjectBase -{ -public: - static const char name[]; - - explicit Sample(const Context& ctx) : ObjectBase(ctx) {} - - struct WriteToByteBuffer_t { - typedef Sample Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteBuffer::Param> Args; - static constexpr char name[] = "writeToByteBuffer"; - static constexpr char signature[] = - "(Ljava/nio/ByteBuffer;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto WriteToByteBuffer(mozilla::jni::ByteBuffer::Param) const -> void; - - struct Info_t { - typedef Sample Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "info"; - static constexpr char signature[] = - "Landroid/media/MediaCodec$BufferInfo;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Info() const -> mozilla::jni::Object::LocalRef; - - auto Info(mozilla::jni::Object::Param) const -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class SessionKeyInfo : public mozilla::jni::ObjectBase -{ -public: - static const char name[]; - - explicit SessionKeyInfo(const Context& ctx) : ObjectBase(ctx) {} - - struct New_t { - typedef SessionKeyInfo Owner; - typedef SessionKeyInfo::LocalRef ReturnType; - typedef SessionKeyInfo::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteArray::Param, - int32_t> Args; - static constexpr char name[] = ""; - static constexpr char signature[] = - "([BI)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto New(mozilla::jni::ByteArray::Param, int32_t) -> SessionKeyInfo::LocalRef; - - struct KeyId_t { - typedef SessionKeyInfo Owner; - typedef mozilla::jni::ByteArray::LocalRef ReturnType; - typedef mozilla::jni::ByteArray::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "keyId"; - static constexpr char signature[] = - "[B"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto KeyId() const -> mozilla::jni::ByteArray::LocalRef; - - auto KeyId(mozilla::jni::ByteArray::Param) const -> void; - - struct Status_t { - typedef SessionKeyInfo Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "status"; - static constexpr char signature[] = - "I"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Status() const -> int32_t; - - auto Status(int32_t) const -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - class Restrictions : public mozilla::jni::ObjectBase { public: From 44a355f273310e54df6c8336059e46085cb75834 Mon Sep 17 00:00:00 2001 From: vincentliu Date: Thu, 6 Apr 2017 15:40:35 -0400 Subject: [PATCH 14/89] Bug 1347617 - In SVG ConvolveMatrix code, bail out if kernelUnitLength is negative or zero. r=dholbert --- dom/svg/SVGFEConvolveMatrixElement.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dom/svg/SVGFEConvolveMatrixElement.cpp b/dom/svg/SVGFEConvolveMatrixElement.cpp index 2b0b0b62d03e..3d387ca6aaa9 100644 --- a/dom/svg/SVGFEConvolveMatrixElement.cpp +++ b/dom/svg/SVGFEConvolveMatrixElement.cpp @@ -232,6 +232,12 @@ SVGFEConvolveMatrixElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstan Size kernelUnitLength = GetKernelUnitLength(aInstance, &mNumberPairAttributes[KERNEL_UNIT_LENGTH]); + if (kernelUnitLength.width <= 0 || kernelUnitLength.height <= 0) { + // According to spec, A negative or zero value is an error. See link below for details. + // https://www.w3.org/TR/SVG/filters.html#feConvolveMatrixElementKernelUnitLengthAttribute + return failureDescription; + } + FilterPrimitiveDescription descr(PrimitiveType::ConvolveMatrix); AttributeMap& atts = descr.Attributes(); atts.Set(eConvolveMatrixKernelSize, IntSize(orderX, orderY)); From 6616a79634b910602a3d6dabbe6cf24e961660b3 Mon Sep 17 00:00:00 2001 From: Jeff Gilbert Date: Mon, 20 Mar 2017 17:49:13 -0700 Subject: [PATCH 15/89] Bug 1349064 - Sort std-headers. - r=froydnj MozReview-Commit-ID: IAgrtLrwqwD --- config/stl-headers | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/config/stl-headers b/config/stl-headers index 3d46e8c2d8de..e1ad9abd2be1 100644 --- a/config/stl-headers +++ b/config/stl-headers @@ -19,6 +19,14 @@ new # throwing exceptions algorithm atomic +cassert +climits +cmath +cstdarg +cstdio +cstdlib +cstring +cwchar deque functional ios @@ -35,16 +43,8 @@ set stack string thread +tuple type_traits utility vector -cassert -climits -cmath -cstdarg -cstdio -cstdlib -cstring -cwchar -tuple xutility From eaabf3f60f0b55413ff081f431874da554922923 Mon Sep 17 00:00:00 2001 From: Jeff Gilbert Date: Mon, 20 Mar 2017 17:57:34 -0700 Subject: [PATCH 16/89] Bug 1349064 - Add to config/std-headers. - r=froydnj MozReview-Commit-ID: 6PwjR2ENnfa --- config/stl-headers | 1 + 1 file changed, 1 insertion(+) diff --git a/config/stl-headers b/config/stl-headers index e1ad9abd2be1..b975803b0501 100644 --- a/config/stl-headers +++ b/config/stl-headers @@ -39,6 +39,7 @@ list map memory ostream +regex set stack string From 4fbb95ac439ffc588435dbf3f9ae1e5bd4f4476d Mon Sep 17 00:00:00 2001 From: Jeff Gilbert Date: Wed, 22 Mar 2017 16:43:11 -0700 Subject: [PATCH 17/89] Bug 1349064 - Replace MSVC wrappers with std::exception::_Set_raise_handler. - r=froydnj MozReview-Commit-ID: MG5c4bzDlI --- config/msvc-stl-wrapper.template.h | 6 --- memory/mozalloc/moz.build | 4 -- memory/mozalloc/msvc_raise_wrappers.cpp | 60 ++++--------------------- memory/mozalloc/msvc_raise_wrappers.h | 41 ----------------- memory/mozalloc/throw_msvc.h | 17 ------- 5 files changed, 9 insertions(+), 119 deletions(-) delete mode 100644 memory/mozalloc/msvc_raise_wrappers.h delete mode 100644 memory/mozalloc/throw_msvc.h diff --git a/config/msvc-stl-wrapper.template.h b/config/msvc-stl-wrapper.template.h index ed9d98b0dd1b..24f02023c5fb 100644 --- a/config/msvc-stl-wrapper.template.h +++ b/config/msvc-stl-wrapper.template.h @@ -19,12 +19,6 @@ # define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER} #endif -// Code built with !_HAS_EXCEPTIONS calls std::_Throw(), but the win2k -// CRT doesn't export std::_Throw(). So we define it. -#ifndef mozilla_Throw_h -# include "mozilla/throw_msvc.h" -#endif - #ifdef _DEBUG // From // http://msdn.microsoft.com/en-us/library/aa985982%28VS.80%29.aspx diff --git a/memory/mozalloc/moz.build b/memory/mozalloc/moz.build index 56d4b8d80f16..bf4db852b843 100644 --- a/memory/mozalloc/moz.build +++ b/memory/mozalloc/moz.build @@ -17,10 +17,6 @@ if CONFIG['WRAP_STL_INCLUDES']: elif CONFIG['_MSC_VER']: DEFINES['_HAS_EXCEPTIONS'] = 0 if CONFIG['MOZ_MSVC_STL_WRAP_RAISE']: - EXPORTS.mozilla += [ - 'msvc_raise_wrappers.h', - 'throw_msvc.h', - ] SOURCES += [ 'msvc_raise_wrappers.cpp', ] diff --git a/memory/mozalloc/msvc_raise_wrappers.cpp b/memory/mozalloc/msvc_raise_wrappers.cpp index 820663f63b38..f81efcecf56b 100644 --- a/memory/mozalloc/msvc_raise_wrappers.cpp +++ b/memory/mozalloc/msvc_raise_wrappers.cpp @@ -5,59 +5,17 @@ * 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 - +#include #include "mozalloc_abort.h" -__declspec(noreturn) static void abort_from_exception(const char* const which, - const char* const what); -static void -abort_from_exception(const char* const which, const char* const what) +static void __cdecl +RaiseHandler(const std::exception& e) { - fprintf(stderr, "fatal: STL threw %s: ", which); - mozalloc_abort(what); + mozalloc_abort(e.what()); } -namespace std { - -// NB: user code is not supposed to touch the std:: namespace. We're -// doing this after careful review because we want to define our own -// exception throwing semantics. Don't try this at home! - -MFBT_API __declspec(noreturn) void -moz_Xinvalid_argument(const char* what) -{ - abort_from_exception("invalid_argument", what); -} - -MFBT_API __declspec(noreturn) void -moz_Xlength_error(const char* what) -{ - abort_from_exception("length_error", what); -} - -MFBT_API __declspec(noreturn) void -moz_Xout_of_range(const char* what) -{ - abort_from_exception("out_of_range", what); -} - -MFBT_API __declspec(noreturn) void -moz_Xoverflow_error(const char* what) -{ - abort_from_exception("overflow_error", what); -} - -MFBT_API __declspec(noreturn) void -moz_Xruntime_error(const char* what) -{ - abort_from_exception("runtime_error", what); -} - -MFBT_API __declspec(noreturn) void -moz_Xbad_function_call() -{ - abort_from_exception("bad_function_call", "bad function call"); -} - -} // namespace std +static struct StaticScopeStruct final { + StaticScopeStruct() { + std::exception::_Set_raise_handler(RaiseHandler); + } +} StaticScopeInvoke; diff --git a/memory/mozalloc/msvc_raise_wrappers.h b/memory/mozalloc/msvc_raise_wrappers.h deleted file mode 100644 index 91b77f453b40..000000000000 --- a/memory/mozalloc/msvc_raise_wrappers.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: sw=4 ts=4 et : - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_msvc_raise_wrappers_h -#define mozilla_msvc_raise_wrappers_h - -#ifdef _XSTDDEF_ -# error "Unable to wrap _RAISE(); CRT _RAISE() already defined" -#endif -#ifdef _XUTILITY_ -# error "Unable to wrap _X[exception](); CRT versions already declared" -#endif -#ifdef _FUNCTIONAL_ -# error "Unable to wrap _Xbad_function_call(); CRT version already declared" -#endif - -#include "mozilla/mozalloc_abort.h" - -// xutility will declare the following functions in the std namespace. -// We #define them to be named differently so we can ensure the exception -// throwing semantics of these functions work exactly the way we want, by -// defining our own versions in msvc_raise_wrappers.cpp. -# define _Xinvalid_argument moz_Xinvalid_argument -# define _Xlength_error moz_Xlength_error -# define _Xout_of_range moz_Xout_of_range -# define _Xoverflow_error moz_Xoverflow_error -# define _Xruntime_error moz_Xruntime_error -// used by -# define _Xbad_function_call moz_Xbad_function_call - -# include -# include - -# undef _RAISE -# define _RAISE(x) mozalloc_abort((x).what()) - -#endif // ifndef mozilla_msvc_raise_wrappers_h diff --git a/memory/mozalloc/throw_msvc.h b/memory/mozalloc/throw_msvc.h deleted file mode 100644 index e6ebf46dc4c0..000000000000 --- a/memory/mozalloc/throw_msvc.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: sw=4 ts=4 et : - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_throw_msvc_h -#define mozilla_throw_msvc_h - -#if defined(MOZ_MSVC_STL_WRAP_RAISE) -# include "msvc_raise_wrappers.h" -#else -# error "Unknown STL wrapper tactic" -#endif - -#endif // mozilla_throw_msvc_h From ca719866b71b0595a2901ce88a659dc01adf62eb Mon Sep 17 00:00:00 2001 From: Jeff Gilbert Date: Thu, 23 Mar 2017 21:20:21 -0700 Subject: [PATCH 18/89] Bug 1349064 - Wrap std::regex_error for GCC. - r=glandium MozReview-Commit-ID: Ik2nIVmtYEJ --- memory/mozalloc/throw_gcc.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/memory/mozalloc/throw_gcc.h b/memory/mozalloc/throw_gcc.h index 4264df63d493..0c3c93868e84 100644 --- a/memory/mozalloc/throw_gcc.h +++ b/memory/mozalloc/throw_gcc.h @@ -32,6 +32,9 @@ # define MOZ_THROW_NORETURN MOZ_NORETURN #endif +// Handle `_GLIBCXX_THROW_OR_ABORT(regex_error(__ecode, __what));` et al. +#define _GLIBCXX_THROW_OR_ABORT(_EXC) mozalloc_abort( (_EXC).what() ) + namespace std { // NB: user code is not supposed to touch the std:: namespace. We're @@ -138,6 +141,15 @@ __throw_system_error(int err) mozalloc_abort(error); } +MOZ_THROW_NORETURN MOZ_EXPORT MOZ_ALWAYS_INLINE void +__throw_regex_error(int __ecode) +{ + char error[128]; + snprintf(error, sizeof(error)-1, + "fatal: STL threw regex_error(%d)", __ecode); + mozalloc_abort(error); +} + } // namespace std #undef MOZ_THROW_NORETURN From cce9ee69dcd402503260876b5a170ac203aee0a1 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Thu, 6 Apr 2017 16:17:54 -0400 Subject: [PATCH 19/89] Bug 1345355 - Allow pinch gestures with a zero span change but a nonzero focus change to scroll. r=botond It appears that some touchpad devices send us "touch" events (i.e. WM_TOUCH on Windows) but with all touch points having the same coordinates. This ends up getting detected as a zero-span pinch gesture in APZ, which short-circuits early and doesn't really get processed. Therefore even if the focus point changes we don't do any corresponding scroll. This patch shifts things around a little so that the short-circuit doesn't happen quite so early, and we still scroll when the focus point changes, even if the span is zero. MozReview-Commit-ID: 3CaQN1MsM8y --- gfx/layers/apz/src/AsyncPanZoomController.cpp | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 4ee6b6f43b39..ba5c8991d4c8 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -1368,14 +1368,6 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) { MOZ_ASSERT(mFrameMetrics.IsRootContent()); MOZ_ASSERT(mFrameMetrics.GetZoom().AreScalesSame()); - float prevSpan = aEvent.mPreviousSpan; - if (fabsf(prevSpan) <= EPSILON || fabsf(aEvent.mCurrentSpan) <= EPSILON) { - // We're still handling it; we've just decided to throw this event away. - return nsEventStatus_eConsumeNoDefault; - } - - float spanRatio = aEvent.mCurrentSpan / aEvent.mPreviousSpan; - { ReentrantMonitorAutoEnter lock(mMonitor); @@ -1384,12 +1376,29 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) { CSSPoint cssFocusPoint = focusPoint / mFrameMetrics.GetZoom(); ParentLayerPoint focusChange = mLastZoomFocus - focusPoint; + mLastZoomFocus = focusPoint; // If displacing by the change in focus point will take us off page bounds, // then reduce the displacement such that it doesn't. focusChange.x -= mX.DisplacementWillOverscrollAmount(focusChange.x); focusChange.y -= mY.DisplacementWillOverscrollAmount(focusChange.y); ScrollBy(focusChange / userZoom); + // If the span is zero or close to it, we don't want to process this zoom + // change because we're going to get wonky numbers for the spanRatio. So + // let's bail out here. Note that we do this after the focus-change-scroll + // above, so that if we have a pinch with zero span but changing focus, + // such as generated by some Synaptics touchpads on Windows, we still + // scroll properly. + float prevSpan = aEvent.mPreviousSpan; + if (fabsf(prevSpan) <= EPSILON || fabsf(aEvent.mCurrentSpan) <= EPSILON) { + // We might have done a nonzero ScrollBy above, so update metrics and + // repaint/recomposite + ScheduleCompositeAndMaybeRepaint(); + UpdateSharedCompositorFrameMetrics(); + return nsEventStatus_eConsumeNoDefault; + } + float spanRatio = aEvent.mCurrentSpan / aEvent.mPreviousSpan; + // When we zoom in with focus, we can zoom too much towards the boundaries // that we actually go over them. These are the needed displacements along // either axis such that we don't overscroll the boundaries when zooming. @@ -1448,8 +1457,6 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) { // We did a ScrollBy call above even if we didn't do a scale, so we // should composite for that. ScheduleComposite(); - - mLastZoomFocus = focusPoint; } return nsEventStatus_eConsumeNoDefault; From 73834c3e233bdf114e9c4be6c9515f0b79a84f50 Mon Sep 17 00:00:00 2001 From: James Willcox Date: Thu, 6 Apr 2017 10:00:46 -0500 Subject: [PATCH 20/89] Bug 1322029 - Disallow installing Fennec to external storage r=jchen MozReview-Commit-ID: Kv0iShdPgFT --- mobile/android/base/AndroidManifest.xml.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/android/base/AndroidManifest.xml.in b/mobile/android/base/AndroidManifest.xml.in index 3c9c8bca966a..572563d72220 100644 --- a/mobile/android/base/AndroidManifest.xml.in +++ b/mobile/android/base/AndroidManifest.xml.in @@ -2,7 +2,7 @@ Date: Thu, 6 Apr 2017 13:32:31 -0700 Subject: [PATCH 21/89] Bug 1353078: Fix broken null check. r=trivial MozReview-Commit-ID: 6YlqhNnk3Ju --- toolkit/components/extensions/ext-backgroundPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/components/extensions/ext-backgroundPage.js b/toolkit/components/extensions/ext-backgroundPage.js index 9e7bc4774e82..2f5c09aa3a8e 100644 --- a/toolkit/components/extensions/ext-backgroundPage.js +++ b/toolkit/components/extensions/ext-backgroundPage.js @@ -58,8 +58,8 @@ class BackgroundPage extends HiddenExtensionPage { // Wait until all event listeners registered by the script so far // to be handled. await Promise.all(context.listenerPromises); + context.listenerPromises = null; } - context.listenerPromises = null; this.extension.emit("startup"); } From e3ce8e00e3ec71616483dad68f470e62367e8631 Mon Sep 17 00:00:00 2001 From: Sebastian Hengst Date: Thu, 6 Apr 2017 22:48:36 +0200 Subject: [PATCH 22/89] Backed out changeset 1506a6e5ee37 (bug 1349064) --- memory/mozalloc/throw_gcc.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/memory/mozalloc/throw_gcc.h b/memory/mozalloc/throw_gcc.h index 0c3c93868e84..4264df63d493 100644 --- a/memory/mozalloc/throw_gcc.h +++ b/memory/mozalloc/throw_gcc.h @@ -32,9 +32,6 @@ # define MOZ_THROW_NORETURN MOZ_NORETURN #endif -// Handle `_GLIBCXX_THROW_OR_ABORT(regex_error(__ecode, __what));` et al. -#define _GLIBCXX_THROW_OR_ABORT(_EXC) mozalloc_abort( (_EXC).what() ) - namespace std { // NB: user code is not supposed to touch the std:: namespace. We're @@ -141,15 +138,6 @@ __throw_system_error(int err) mozalloc_abort(error); } -MOZ_THROW_NORETURN MOZ_EXPORT MOZ_ALWAYS_INLINE void -__throw_regex_error(int __ecode) -{ - char error[128]; - snprintf(error, sizeof(error)-1, - "fatal: STL threw regex_error(%d)", __ecode); - mozalloc_abort(error); -} - } // namespace std #undef MOZ_THROW_NORETURN From 110cacbc5816f50a93f88a72df8999843e23f13e Mon Sep 17 00:00:00 2001 From: Sebastian Hengst Date: Thu, 6 Apr 2017 22:48:41 +0200 Subject: [PATCH 23/89] Backed out changeset 8c35a43033bc (bug 1349064) --- config/msvc-stl-wrapper.template.h | 6 +++ memory/mozalloc/moz.build | 4 ++ memory/mozalloc/msvc_raise_wrappers.cpp | 60 +++++++++++++++++++++---- memory/mozalloc/msvc_raise_wrappers.h | 41 +++++++++++++++++ memory/mozalloc/throw_msvc.h | 17 +++++++ 5 files changed, 119 insertions(+), 9 deletions(-) create mode 100644 memory/mozalloc/msvc_raise_wrappers.h create mode 100644 memory/mozalloc/throw_msvc.h diff --git a/config/msvc-stl-wrapper.template.h b/config/msvc-stl-wrapper.template.h index 24f02023c5fb..ed9d98b0dd1b 100644 --- a/config/msvc-stl-wrapper.template.h +++ b/config/msvc-stl-wrapper.template.h @@ -19,6 +19,12 @@ # define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER} #endif +// Code built with !_HAS_EXCEPTIONS calls std::_Throw(), but the win2k +// CRT doesn't export std::_Throw(). So we define it. +#ifndef mozilla_Throw_h +# include "mozilla/throw_msvc.h" +#endif + #ifdef _DEBUG // From // http://msdn.microsoft.com/en-us/library/aa985982%28VS.80%29.aspx diff --git a/memory/mozalloc/moz.build b/memory/mozalloc/moz.build index bf4db852b843..56d4b8d80f16 100644 --- a/memory/mozalloc/moz.build +++ b/memory/mozalloc/moz.build @@ -17,6 +17,10 @@ if CONFIG['WRAP_STL_INCLUDES']: elif CONFIG['_MSC_VER']: DEFINES['_HAS_EXCEPTIONS'] = 0 if CONFIG['MOZ_MSVC_STL_WRAP_RAISE']: + EXPORTS.mozilla += [ + 'msvc_raise_wrappers.h', + 'throw_msvc.h', + ] SOURCES += [ 'msvc_raise_wrappers.cpp', ] diff --git a/memory/mozalloc/msvc_raise_wrappers.cpp b/memory/mozalloc/msvc_raise_wrappers.cpp index f81efcecf56b..820663f63b38 100644 --- a/memory/mozalloc/msvc_raise_wrappers.cpp +++ b/memory/mozalloc/msvc_raise_wrappers.cpp @@ -5,17 +5,59 @@ * 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 +#include + #include "mozalloc_abort.h" -static void __cdecl -RaiseHandler(const std::exception& e) +__declspec(noreturn) static void abort_from_exception(const char* const which, + const char* const what); +static void +abort_from_exception(const char* const which, const char* const what) { - mozalloc_abort(e.what()); + fprintf(stderr, "fatal: STL threw %s: ", which); + mozalloc_abort(what); } -static struct StaticScopeStruct final { - StaticScopeStruct() { - std::exception::_Set_raise_handler(RaiseHandler); - } -} StaticScopeInvoke; +namespace std { + +// NB: user code is not supposed to touch the std:: namespace. We're +// doing this after careful review because we want to define our own +// exception throwing semantics. Don't try this at home! + +MFBT_API __declspec(noreturn) void +moz_Xinvalid_argument(const char* what) +{ + abort_from_exception("invalid_argument", what); +} + +MFBT_API __declspec(noreturn) void +moz_Xlength_error(const char* what) +{ + abort_from_exception("length_error", what); +} + +MFBT_API __declspec(noreturn) void +moz_Xout_of_range(const char* what) +{ + abort_from_exception("out_of_range", what); +} + +MFBT_API __declspec(noreturn) void +moz_Xoverflow_error(const char* what) +{ + abort_from_exception("overflow_error", what); +} + +MFBT_API __declspec(noreturn) void +moz_Xruntime_error(const char* what) +{ + abort_from_exception("runtime_error", what); +} + +MFBT_API __declspec(noreturn) void +moz_Xbad_function_call() +{ + abort_from_exception("bad_function_call", "bad function call"); +} + +} // namespace std diff --git a/memory/mozalloc/msvc_raise_wrappers.h b/memory/mozalloc/msvc_raise_wrappers.h new file mode 100644 index 000000000000..91b77f453b40 --- /dev/null +++ b/memory/mozalloc/msvc_raise_wrappers.h @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: sw=4 ts=4 et : + */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_msvc_raise_wrappers_h +#define mozilla_msvc_raise_wrappers_h + +#ifdef _XSTDDEF_ +# error "Unable to wrap _RAISE(); CRT _RAISE() already defined" +#endif +#ifdef _XUTILITY_ +# error "Unable to wrap _X[exception](); CRT versions already declared" +#endif +#ifdef _FUNCTIONAL_ +# error "Unable to wrap _Xbad_function_call(); CRT version already declared" +#endif + +#include "mozilla/mozalloc_abort.h" + +// xutility will declare the following functions in the std namespace. +// We #define them to be named differently so we can ensure the exception +// throwing semantics of these functions work exactly the way we want, by +// defining our own versions in msvc_raise_wrappers.cpp. +# define _Xinvalid_argument moz_Xinvalid_argument +# define _Xlength_error moz_Xlength_error +# define _Xout_of_range moz_Xout_of_range +# define _Xoverflow_error moz_Xoverflow_error +# define _Xruntime_error moz_Xruntime_error +// used by +# define _Xbad_function_call moz_Xbad_function_call + +# include +# include + +# undef _RAISE +# define _RAISE(x) mozalloc_abort((x).what()) + +#endif // ifndef mozilla_msvc_raise_wrappers_h diff --git a/memory/mozalloc/throw_msvc.h b/memory/mozalloc/throw_msvc.h new file mode 100644 index 000000000000..e6ebf46dc4c0 --- /dev/null +++ b/memory/mozalloc/throw_msvc.h @@ -0,0 +1,17 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: sw=4 ts=4 et : + */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_throw_msvc_h +#define mozilla_throw_msvc_h + +#if defined(MOZ_MSVC_STL_WRAP_RAISE) +# include "msvc_raise_wrappers.h" +#else +# error "Unknown STL wrapper tactic" +#endif + +#endif // mozilla_throw_msvc_h From be8901b6ca0ee4810f236dbf5cf9aa2bdf4c73dc Mon Sep 17 00:00:00 2001 From: Sebastian Hengst Date: Thu, 6 Apr 2017 22:48:45 +0200 Subject: [PATCH 24/89] Backed out changeset 02e10c8eeb95 (bug 1349064) --- config/stl-headers | 1 - 1 file changed, 1 deletion(-) diff --git a/config/stl-headers b/config/stl-headers index b975803b0501..e1ad9abd2be1 100644 --- a/config/stl-headers +++ b/config/stl-headers @@ -39,7 +39,6 @@ list map memory ostream -regex set stack string From c8c533b78e78aa13e5fcd4ff357d553eda570452 Mon Sep 17 00:00:00 2001 From: Sebastian Hengst Date: Thu, 6 Apr 2017 22:49:32 +0200 Subject: [PATCH 25/89] Backed out changeset dc695c2ea24e (bug 1349064) for breaking Android build. r=backout --- config/stl-headers | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/config/stl-headers b/config/stl-headers index e1ad9abd2be1..3d46e8c2d8de 100644 --- a/config/stl-headers +++ b/config/stl-headers @@ -19,14 +19,6 @@ new # throwing exceptions algorithm atomic -cassert -climits -cmath -cstdarg -cstdio -cstdlib -cstring -cwchar deque functional ios @@ -43,8 +35,16 @@ set stack string thread -tuple type_traits utility vector +cassert +climits +cmath +cstdarg +cstdio +cstdlib +cstring +cwchar +tuple xutility From 33a8823b8b281512b90119fa1fbdf353d94ab12c Mon Sep 17 00:00:00 2001 From: Aaron Klotz Date: Tue, 14 Feb 2017 16:33:48 -0700 Subject: [PATCH 26/89] Bug 1354208: Add AccessibleHandler.dll to installer; r=mhowell MozReview-Commit-ID: 4EMkQMhS3B2 --HG-- extra : rebase_source : 15f9283e2fc4c41d708b6349c36c70600d0731d1 --- browser/installer/package-manifest.in | 1 + browser/installer/windows/nsis/defines.nsi.in | 18 ++++++++++++++++++ browser/installer/windows/nsis/installer.nsi | 10 ++++++++++ browser/installer/windows/nsis/shared.nsh | 1 + browser/installer/windows/nsis/uninstaller.nsi | 6 ++++++ 5 files changed, 36 insertions(+) diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index c58ac89ca670..5bc0c2e0e191 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -170,6 +170,7 @@ #ifdef ACCESSIBILITY #ifdef XP_WIN32 @BINPATH@/Accessible.tlb +@BINPATH@/AccessibleHandler.dll @BINPATH@/AccessibleMarshal.dll @BINPATH@/IA2Marshal.dll #endif diff --git a/browser/installer/windows/nsis/defines.nsi.in b/browser/installer/windows/nsis/defines.nsi.in index cf31c089f325..5f733b3df619 100644 --- a/browser/installer/windows/nsis/defines.nsi.in +++ b/browser/installer/windows/nsis/defines.nsi.in @@ -55,6 +55,24 @@ !define UpdateChannel "@MOZ_UPDATE_CHANNEL@" !endif +# AccessibleHandler.dll uses a different CLSID depending on release channel. +# These defines must match HANDLER_CLSID defined in +# accessible/ipc/win/handler/HandlerData.idl + +#ifndef MOZ_OFFICIAL_BRANDING +#ifdef DEBUG +!define AccessibleHandlerCLSID "{398FFD8D-5382-48F7-9E3B-19012762D39A}" +#else +!define AccessibleHandlerCLSID "{CE573FAF-7815-4FC2-A031-B092268ACE9E}" +#endif +#elifdef NIGHTLY_BUILD +!define AccessibleHandlerCLSID "{4629216B-8753-41BF-9527-5BFF51401671}" +#elifdef RELEASE_OR_BETA +!define AccessibleHandlerCLSID "{1BAA303D-B4B9-45E5-9CCB-E3FCA3E274B6}" +#else +!define AccessibleHandlerCLSID "{4A195748-DCA2-45FB-9295-0A139E76A9E7}" +#endif + # Due to official and beta using the same branding this is needed to # differentiante between the url used by the stub for downloading. !if "@MOZ_UPDATE_CHANNEL@" == "beta" diff --git a/browser/installer/windows/nsis/installer.nsi b/browser/installer/windows/nsis/installer.nsi index 307fe8af6251..3c05c31c6a90 100755 --- a/browser/installer/windows/nsis/installer.nsi +++ b/browser/installer/windows/nsis/installer.nsi @@ -307,6 +307,16 @@ Section "-Application" APP_IDX ClearErrors + ${RegisterDLL} "$INSTDIR\AccessibleHandler.dll" + ${If} ${Errors} + ${LogMsg} "** ERROR Registering: $INSTDIR\AccessibleHandler.dll **" + ${Else} + ${LogUninstall} "DLLReg: \AccessibleHandler.dll" + ${LogMsg} "Registered: $INSTDIR\AccessibleHandler.dll" + ${EndIf} + + ClearErrors + ; Default for creating Start Menu shortcut ; (1 = create, 0 = don't create) ${If} $AddStartMenuSC == "" diff --git a/browser/installer/windows/nsis/shared.nsh b/browser/installer/windows/nsis/shared.nsh index 6df7e08a5d5c..418190d7b16e 100755 --- a/browser/installer/windows/nsis/shared.nsh +++ b/browser/installer/windows/nsis/shared.nsh @@ -1160,6 +1160,7 @@ ; should be ${FileMainEXE} so if it is in use the CheckForFilesInUse macro ; returns after the first check. Push "end" + Push "AccessibleHandler.dll" Push "AccessibleMarshal.dll" Push "IA2Marshal.dll" Push "freebl3.dll" diff --git a/browser/installer/windows/nsis/uninstaller.nsi b/browser/installer/windows/nsis/uninstaller.nsi index 81ea8fef75cc..f3e10ba742d6 100755 --- a/browser/installer/windows/nsis/uninstaller.nsi +++ b/browser/installer/windows/nsis/uninstaller.nsi @@ -383,6 +383,12 @@ Section "Uninstall" ${UnregisterDLL} "$INSTDIR\AccessibleMarshal.dll" ${EndIf} + ; Only unregister the dll if the registration points to this installation + ReadRegStr $R1 HKCR "CLSID\${AccessibleHandlerCLSID}\InprocHandler32" "" + ${If} "$INSTDIR\AccessibleHandler.dll" == "$R1" + ${UnregisterDLL} "$INSTDIR\AccessibleHandler.dll" + ${EndIf} + ${un.RemovePrecompleteEntries} "false" ${If} ${FileExists} "$INSTDIR\defaults\pref\channel-prefs.js" From b60e1038c73d2e76406e112612f9306ed80b89d0 Mon Sep 17 00:00:00 2001 From: Michael Layzell Date: Thu, 30 Mar 2017 14:13:01 -0400 Subject: [PATCH 27/89] Bug 1320179 - Part 1: Move nsresult value calculation into a python script, r=froydnj This patch makes the error codes in nsError.h be generated by a python script. This gives us the opportunity to add rust code generation in parallel with the C++ code generation, which will happen in part 2. This patch also reworks the name calculation in ErrorNames.cpp to use generated code by the python script. MozReview-Commit-ID: 5wxbdZwxe7q --- xpcom/base/ErrorList.h | 1058 ------------------------------- xpcom/base/ErrorList.py | 1240 +++++++++++++++++++++++++++++++++++++ xpcom/base/ErrorNames.cpp | 40 +- xpcom/base/moz.build | 11 +- xpcom/base/nsError.h | 127 +--- 5 files changed, 1268 insertions(+), 1208 deletions(-) delete mode 100644 xpcom/base/ErrorList.h create mode 100644 xpcom/base/ErrorList.py diff --git a/xpcom/base/ErrorList.h b/xpcom/base/ErrorList.h deleted file mode 100644 index 15a662efd2a5..000000000000 --- a/xpcom/base/ErrorList.h +++ /dev/null @@ -1,1058 +0,0 @@ -// IWYU pragma: private, include "nsError.h" -/* Helper file for nsError.h, via preprocessor magic */ - /* Standard "it worked" return value */ - ERROR(NS_OK, 0), - - /* ======================================================================= */ - /* Core errors, not part of any modules */ - /* ======================================================================= */ - ERROR(NS_ERROR_BASE, 0xC1F30000), - /* Returned when an instance is not initialized */ - ERROR(NS_ERROR_NOT_INITIALIZED, NS_ERROR_BASE + 1), - /* Returned when an instance is already initialized */ - ERROR(NS_ERROR_ALREADY_INITIALIZED, NS_ERROR_BASE + 2), - /* Returned by a not implemented function */ - ERROR(NS_ERROR_NOT_IMPLEMENTED, 0x80004001), - /* Returned when a given interface is not supported. */ - ERROR(NS_NOINTERFACE, 0x80004002), - ERROR(NS_ERROR_NO_INTERFACE, NS_NOINTERFACE), - /* Returned when a function aborts */ - ERROR(NS_ERROR_ABORT, 0x80004004), - /* Returned when a function fails */ - ERROR(NS_ERROR_FAILURE, 0x80004005), - /* Returned when an unexpected error occurs */ - ERROR(NS_ERROR_UNEXPECTED, 0x8000ffff), - /* Returned when a memory allocation fails */ - ERROR(NS_ERROR_OUT_OF_MEMORY, 0x8007000e), - /* Returned when an illegal value is passed */ - ERROR(NS_ERROR_ILLEGAL_VALUE, 0x80070057), - ERROR(NS_ERROR_INVALID_ARG, NS_ERROR_ILLEGAL_VALUE), - ERROR(NS_ERROR_INVALID_POINTER, NS_ERROR_INVALID_ARG), - ERROR(NS_ERROR_NULL_POINTER, NS_ERROR_INVALID_ARG), - /* Returned when a class doesn't allow aggregation */ - ERROR(NS_ERROR_NO_AGGREGATION, 0x80040110), - /* Returned when an operation can't complete due to an unavailable resource */ - ERROR(NS_ERROR_NOT_AVAILABLE, 0x80040111), - /* Returned when a class is not registered */ - ERROR(NS_ERROR_FACTORY_NOT_REGISTERED, 0x80040154), - /* Returned when a class cannot be registered, but may be tried again later */ - ERROR(NS_ERROR_FACTORY_REGISTER_AGAIN, 0x80040155), - /* Returned when a dynamically loaded factory couldn't be found */ - ERROR(NS_ERROR_FACTORY_NOT_LOADED, 0x800401f8), - /* Returned when a factory doesn't support signatures */ - ERROR(NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT, NS_ERROR_BASE + 0x101), - /* Returned when a factory already is registered */ - ERROR(NS_ERROR_FACTORY_EXISTS, NS_ERROR_BASE + 0x100), - - - /* ======================================================================= */ - /* 1: NS_ERROR_MODULE_XPCOM */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_XPCOM - /* Result codes used by nsIVariant */ - ERROR(NS_ERROR_CANNOT_CONVERT_DATA, FAILURE(1)), - ERROR(NS_ERROR_OBJECT_IS_IMMUTABLE, FAILURE(2)), - ERROR(NS_ERROR_LOSS_OF_SIGNIFICANT_DATA, FAILURE(3)), - /* Result code used by nsIThreadManager */ - ERROR(NS_ERROR_NOT_SAME_THREAD, FAILURE(4)), - /* Various operations are not permitted during XPCOM shutdown and will fail - * with this exception. */ - ERROR(NS_ERROR_ILLEGAL_DURING_SHUTDOWN, FAILURE(30)), - ERROR(NS_ERROR_SERVICE_NOT_AVAILABLE, FAILURE(22)), - - ERROR(NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA, SUCCESS(1)), - /* Used by nsCycleCollectionParticipant */ - ERROR(NS_SUCCESS_INTERRUPTED_TRAVERSE, SUCCESS(2)), - /* DEPRECATED */ - ERROR(NS_ERROR_SERVICE_NOT_FOUND, SUCCESS(22)), - /* DEPRECATED */ - ERROR(NS_ERROR_SERVICE_IN_USE, SUCCESS(23)), -#undef MODULE - - - /* ======================================================================= */ - /* 2: NS_ERROR_MODULE_BASE */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_BASE - /* I/O Errors */ - - /* Stream closed */ - ERROR(NS_BASE_STREAM_CLOSED, FAILURE(2)), - /* Error from the operating system */ - ERROR(NS_BASE_STREAM_OSERROR, FAILURE(3)), - /* Illegal arguments */ - ERROR(NS_BASE_STREAM_ILLEGAL_ARGS, FAILURE(4)), - /* For unichar streams */ - ERROR(NS_BASE_STREAM_NO_CONVERTER, FAILURE(5)), - /* For unichar streams */ - ERROR(NS_BASE_STREAM_BAD_CONVERSION, FAILURE(6)), - ERROR(NS_BASE_STREAM_WOULD_BLOCK, FAILURE(7)), -#undef MODULE - - - /* ======================================================================= */ - /* 3: NS_ERROR_MODULE_GFX */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_GFX - /* no printer available (e.g. cannot find _any_ printer) */ - ERROR(NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE, FAILURE(1)), - /* _specified_ (by name) printer not found */ - ERROR(NS_ERROR_GFX_PRINTER_NAME_NOT_FOUND, FAILURE(2)), - /* print-to-file: could not open output file */ - ERROR(NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE, FAILURE(3)), - /* print: starting document */ - ERROR(NS_ERROR_GFX_PRINTER_STARTDOC, FAILURE(4)), - /* print: ending document */ - ERROR(NS_ERROR_GFX_PRINTER_ENDDOC, FAILURE(5)), - /* print: starting page */ - ERROR(NS_ERROR_GFX_PRINTER_STARTPAGE, FAILURE(6)), - /* The document is still being loaded */ - ERROR(NS_ERROR_GFX_PRINTER_DOC_IS_BUSY, FAILURE(7)), - - /* Font cmap is strangely structured - avoid this font! */ - ERROR(NS_ERROR_GFX_CMAP_MALFORMED, FAILURE(51)), -#undef MODULE - - - /* ======================================================================= */ - /* 4: NS_ERROR_MODULE_WIDGET */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_WIDGET - /* Used by: - * - nsIWidget::NotifyIME() - * - nsIWidget::OnWindowedPluginKeyEvent() - * Returned when the notification or the event is handled and it's consumed - * by somebody. */ - ERROR(NS_SUCCESS_EVENT_CONSUMED, SUCCESS(1)), - /* Used by: - * - nsIWidget::OnWindowedPluginKeyEvent() - * Returned when the event is handled correctly but the result will be - * notified asynchronously. */ - ERROR(NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY, SUCCESS(2)), -#undef MODULE - - - /* ======================================================================= */ - /* 6: NS_ERROR_MODULE_NETWORK */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_NETWORK - /* General async request error codes: - * - * These error codes are commonly passed through callback methods to indicate - * the status of some requested async request. - * - * For example, see nsIRequestObserver::onStopRequest. - */ - - /* The async request completed successfully. */ - ERROR(NS_BINDING_SUCCEEDED, NS_OK), - - /* The async request failed for some unknown reason. */ - ERROR(NS_BINDING_FAILED, FAILURE(1)), - /* The async request failed because it was aborted by some user action. */ - ERROR(NS_BINDING_ABORTED, FAILURE(2)), - /* The async request has been "redirected" to a different async request. - * (e.g., an HTTP redirect occurred). - * - * This error code is used with load groups to notify the load group observer - * when a request in the load group is redirected to another request. */ - ERROR(NS_BINDING_REDIRECTED, FAILURE(3)), - /* The async request has been "retargeted" to a different "handler." - * - * This error code is used with load groups to notify the load group observer - * when a request in the load group is removed from the load group and added - * to a different load group. */ - ERROR(NS_BINDING_RETARGETED, FAILURE(4)), - - /* Miscellaneous error codes: These errors are not typically passed via - * onStopRequest. */ - - /* The URI is malformed. */ - ERROR(NS_ERROR_MALFORMED_URI, FAILURE(10)), - /* The requested action could not be completed while the object is busy. - * Implementations of nsIChannel::asyncOpen will commonly return this error - * if the channel has already been opened (and has not yet been closed). */ - ERROR(NS_ERROR_IN_PROGRESS, FAILURE(15)), - /* Returned from nsIChannel::asyncOpen to indicate that OnDataAvailable will - * not be called because there is no content available. This is used by - * helper app style protocols (e.g., mailto). XXX perhaps this should be a - * success code. */ - ERROR(NS_ERROR_NO_CONTENT, FAILURE(17)), - /* The URI scheme corresponds to an unknown protocol handler. */ - ERROR(NS_ERROR_UNKNOWN_PROTOCOL, FAILURE(18)), - /* The content encoding of the source document was incorrect, for example - * returning a plain HTML document advertised as Content-Encoding: gzip */ - ERROR(NS_ERROR_INVALID_CONTENT_ENCODING, FAILURE(27)), - /* A transport level corruption was found in the source document. for example - * a document with a calculated checksum that does not match the Content-MD5 - * http header. */ - ERROR(NS_ERROR_CORRUPTED_CONTENT, FAILURE(29)), - /* A content signature verification failed for some reason. This can be either - * an actual verification error, or any other error that led to the fact that - * a content signature that was expected couldn't be verified. */ - ERROR(NS_ERROR_INVALID_SIGNATURE, FAILURE(58)), - /* While parsing for the first component of a header field using syntax as in - * Content-Disposition or Content-Type, the first component was found to be - * empty, such as in: Content-Disposition: ; filename=foo */ - ERROR(NS_ERROR_FIRST_HEADER_FIELD_COMPONENT_EMPTY, FAILURE(34)), - /* Returned from nsIChannel::asyncOpen when trying to open the channel again - * (reopening is not supported). */ - ERROR(NS_ERROR_ALREADY_OPENED, FAILURE(73)), - - /* Connectivity error codes: */ - - /* The connection is already established. XXX unused - consider removing. */ - ERROR(NS_ERROR_ALREADY_CONNECTED, FAILURE(11)), - /* The connection does not exist. XXX unused - consider removing. */ - ERROR(NS_ERROR_NOT_CONNECTED, FAILURE(12)), - /* The connection attempt failed, for example, because no server was - * listening at specified host:port. */ - ERROR(NS_ERROR_CONNECTION_REFUSED, FAILURE(13)), - /* The connection was lost due to a timeout error. */ - ERROR(NS_ERROR_NET_TIMEOUT, FAILURE(14)), - /* The requested action could not be completed while the networking library - * is in the offline state. */ - ERROR(NS_ERROR_OFFLINE, FAILURE(16)), - /* The requested action was prohibited because it would have caused the - * networking library to establish a connection to an unsafe or otherwise - * banned port. */ - ERROR(NS_ERROR_PORT_ACCESS_NOT_ALLOWED, FAILURE(19)), - /* The connection was established, but no data was ever received. */ - ERROR(NS_ERROR_NET_RESET, FAILURE(20)), - /* The connection was established, but the data transfer was interrupted. */ - ERROR(NS_ERROR_NET_INTERRUPT, FAILURE(71)), - /* The connection attempt to a proxy failed. */ - ERROR(NS_ERROR_PROXY_CONNECTION_REFUSED, FAILURE(72)), - /* A transfer was only partially done when it completed. */ - ERROR(NS_ERROR_NET_PARTIAL_TRANSFER, FAILURE(76)), - /* HTTP/2 detected invalid TLS configuration */ - ERROR(NS_ERROR_NET_INADEQUATE_SECURITY, FAILURE(82)), - - /* XXX really need to better rationalize these error codes. are consumers of - * necko really expected to know how to discern the meaning of these?? */ - /* This request is not resumable, but it was tried to resume it, or to - * request resume-specific data. */ - ERROR(NS_ERROR_NOT_RESUMABLE, FAILURE(25)), - /* The request failed as a result of a detected redirection loop. */ - ERROR(NS_ERROR_REDIRECT_LOOP, FAILURE(31)), - /* It was attempted to resume the request, but the entity has changed in the - * meantime. */ - ERROR(NS_ERROR_ENTITY_CHANGED, FAILURE(32)), - /* The request failed because the content type returned by the server was not - * a type expected by the channel (for nested channels such as the JAR - * channel). */ - ERROR(NS_ERROR_UNSAFE_CONTENT_TYPE, FAILURE(74)), - /* The request failed because the user tried to access to a remote XUL - * document from a website that is not in its white-list. */ - ERROR(NS_ERROR_REMOTE_XUL, FAILURE(75)), - /* The request resulted in an error page being displayed. */ - ERROR(NS_ERROR_LOAD_SHOWED_ERRORPAGE, FAILURE(77)), - /* The request occurred in docshell that lacks a treeowner, so it is - * probably in the process of being torn down. */ - ERROR(NS_ERROR_DOCSHELL_DYING, FAILURE(78)), - - - /* FTP specific error codes: */ - - ERROR(NS_ERROR_FTP_LOGIN, FAILURE(21)), - ERROR(NS_ERROR_FTP_CWD, FAILURE(22)), - ERROR(NS_ERROR_FTP_PASV, FAILURE(23)), - ERROR(NS_ERROR_FTP_PWD, FAILURE(24)), - ERROR(NS_ERROR_FTP_LIST, FAILURE(28)), - - /* DNS specific error codes: */ - - /* The lookup of a hostname failed. This generally refers to the hostname - * from the URL being loaded. */ - ERROR(NS_ERROR_UNKNOWN_HOST, FAILURE(30)), - /* A low or medium priority DNS lookup failed because the pending queue was - * already full. High priorty (the default) always makes room */ - ERROR(NS_ERROR_DNS_LOOKUP_QUEUE_FULL, FAILURE(33)), - /* The lookup of a proxy hostname failed. If a channel is configured to - * speak to a proxy server, then it will generate this error if the proxy - * hostname cannot be resolved. */ - ERROR(NS_ERROR_UNKNOWN_PROXY_HOST, FAILURE(42)), - - - /* Socket specific error codes: */ - - /* The specified socket type does not exist. */ - ERROR(NS_ERROR_UNKNOWN_SOCKET_TYPE, FAILURE(51)), - /* The specified socket type could not be created. */ - ERROR(NS_ERROR_SOCKET_CREATE_FAILED, FAILURE(52)), - /* The operating system doesn't support the given type of address. */ - ERROR(NS_ERROR_SOCKET_ADDRESS_NOT_SUPPORTED, FAILURE(53)), - /* The address to which we tried to bind the socket was busy. */ - ERROR(NS_ERROR_SOCKET_ADDRESS_IN_USE, FAILURE(54)), - - /* Cache specific error codes: */ - ERROR(NS_ERROR_CACHE_KEY_NOT_FOUND, FAILURE(61)), - ERROR(NS_ERROR_CACHE_DATA_IS_STREAM, FAILURE(62)), - ERROR(NS_ERROR_CACHE_DATA_IS_NOT_STREAM, FAILURE(63)), - ERROR(NS_ERROR_CACHE_WAIT_FOR_VALIDATION, FAILURE(64)), - ERROR(NS_ERROR_CACHE_ENTRY_DOOMED, FAILURE(65)), - ERROR(NS_ERROR_CACHE_READ_ACCESS_DENIED, FAILURE(66)), - ERROR(NS_ERROR_CACHE_WRITE_ACCESS_DENIED, FAILURE(67)), - ERROR(NS_ERROR_CACHE_IN_USE, FAILURE(68)), - /* Error passed through onStopRequest if the document could not be fetched - * from the cache. */ - ERROR(NS_ERROR_DOCUMENT_NOT_CACHED, FAILURE(70)), - - /* Effective TLD Service specific error codes: */ - - /* The requested number of domain levels exceeds those present in the host - * string. */ - ERROR(NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS, FAILURE(80)), - /* The host string is an IP address. */ - ERROR(NS_ERROR_HOST_IS_IP_ADDRESS, FAILURE(81)), - - - /* StreamLoader specific result codes: */ - - /* Result code returned by nsIStreamLoaderObserver to indicate that the - * observer is taking over responsibility for the data buffer, and the loader - * should NOT free it. */ - ERROR(NS_SUCCESS_ADOPTED_DATA, SUCCESS(90)), - - /* FTP */ - ERROR(NS_NET_STATUS_BEGIN_FTP_TRANSACTION, SUCCESS(27)), - ERROR(NS_NET_STATUS_END_FTP_TRANSACTION, SUCCESS(28)), - - /* This success code may be returned by nsIAuthModule::getNextToken to - * indicate that the authentication is finished and thus there's no need - * to call getNextToken again. */ - ERROR(NS_SUCCESS_AUTH_FINISHED, SUCCESS(40)), - - /* These are really not "results", they're statuses, used by nsITransport and - * friends. This is abuse of nsresult, but we'll put up with it for now. */ - /* nsITransport */ - ERROR(NS_NET_STATUS_READING, FAILURE(8)), - ERROR(NS_NET_STATUS_WRITING, FAILURE(9)), - - /* nsISocketTransport */ - ERROR(NS_NET_STATUS_RESOLVING_HOST, FAILURE(3)), - ERROR(NS_NET_STATUS_RESOLVED_HOST, FAILURE(11)), - ERROR(NS_NET_STATUS_CONNECTING_TO, FAILURE(7)), - ERROR(NS_NET_STATUS_CONNECTED_TO, FAILURE(4)), - ERROR(NS_NET_STATUS_TLS_HANDSHAKE_STARTING, FAILURE(12)), - ERROR(NS_NET_STATUS_TLS_HANDSHAKE_ENDED, FAILURE(13)), - ERROR(NS_NET_STATUS_SENDING_TO, FAILURE(5)), - ERROR(NS_NET_STATUS_WAITING_FOR, FAILURE(10)), - ERROR(NS_NET_STATUS_RECEIVING_FROM, FAILURE(6)), - - /* nsIInterceptedChannel */ - /* Generic error for non-specific failures during service worker interception */ - ERROR(NS_ERROR_INTERCEPTION_FAILED, FAILURE(100)), - - /* nsIHstsPrimingListener */ - /* Error code for HSTS priming timeout to distinguish from blocking */ - ERROR(NS_ERROR_HSTS_PRIMING_TIMEOUT, FAILURE(110)), -#undef MODULE - - - /* ======================================================================= */ - /* 7: NS_ERROR_MODULE_PLUGINS */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_PLUGINS - ERROR(NS_ERROR_PLUGINS_PLUGINSNOTCHANGED, FAILURE(1000)), - ERROR(NS_ERROR_PLUGIN_DISABLED, FAILURE(1001)), - ERROR(NS_ERROR_PLUGIN_BLOCKLISTED, FAILURE(1002)), - ERROR(NS_ERROR_PLUGIN_TIME_RANGE_NOT_SUPPORTED, FAILURE(1003)), - ERROR(NS_ERROR_PLUGIN_CLICKTOPLAY, FAILURE(1004)), - ERROR(NS_PLUGIN_INIT_PENDING, SUCCESS(1005)), -#undef MODULE - - - /* ======================================================================= */ - /* 8: NS_ERROR_MODULE_LAYOUT */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_LAYOUT - /* Return code for nsITableLayout */ - ERROR(NS_TABLELAYOUT_CELL_NOT_FOUND, SUCCESS(0)), - /* Return code for nsFrame::GetNextPrevLineFromeBlockFrame */ - ERROR(NS_POSITION_BEFORE_TABLE, SUCCESS(3)), - /** Return codes for nsPresState::GetProperty() */ - /* Returned if the property exists */ - ERROR(NS_STATE_PROPERTY_EXISTS, NS_OK), - /* Returned if the property does not exist */ - ERROR(NS_STATE_PROPERTY_NOT_THERE, SUCCESS(5)), -#undef MODULE - - - /* ======================================================================= */ - /* 9: NS_ERROR_MODULE_HTMLPARSER */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_HTMLPARSER - ERROR(NS_ERROR_HTMLPARSER_CONTINUE, NS_OK), - - ERROR(NS_ERROR_HTMLPARSER_EOF, FAILURE(1000)), - ERROR(NS_ERROR_HTMLPARSER_UNKNOWN, FAILURE(1001)), - ERROR(NS_ERROR_HTMLPARSER_CANTPROPAGATE, FAILURE(1002)), - ERROR(NS_ERROR_HTMLPARSER_CONTEXTMISMATCH, FAILURE(1003)), - ERROR(NS_ERROR_HTMLPARSER_BADFILENAME, FAILURE(1004)), - ERROR(NS_ERROR_HTMLPARSER_BADURL, FAILURE(1005)), - ERROR(NS_ERROR_HTMLPARSER_INVALIDPARSERCONTEXT, FAILURE(1006)), - ERROR(NS_ERROR_HTMLPARSER_INTERRUPTED, FAILURE(1007)), - ERROR(NS_ERROR_HTMLPARSER_BLOCK, FAILURE(1008)), - ERROR(NS_ERROR_HTMLPARSER_BADTOKENIZER, FAILURE(1009)), - ERROR(NS_ERROR_HTMLPARSER_BADATTRIBUTE, FAILURE(1010)), - ERROR(NS_ERROR_HTMLPARSER_UNRESOLVEDDTD, FAILURE(1011)), - ERROR(NS_ERROR_HTMLPARSER_MISPLACEDTABLECONTENT, FAILURE(1012)), - ERROR(NS_ERROR_HTMLPARSER_BADDTD, FAILURE(1013)), - ERROR(NS_ERROR_HTMLPARSER_BADCONTEXT, FAILURE(1014)), - ERROR(NS_ERROR_HTMLPARSER_STOPPARSING, FAILURE(1015)), - ERROR(NS_ERROR_HTMLPARSER_UNTERMINATEDSTRINGLITERAL, FAILURE(1016)), - ERROR(NS_ERROR_HTMLPARSER_HIERARCHYTOODEEP, FAILURE(1017)), - ERROR(NS_ERROR_HTMLPARSER_FAKE_ENDTAG, FAILURE(1018)), - ERROR(NS_ERROR_HTMLPARSER_INVALID_COMMENT, FAILURE(1019)), - - ERROR(NS_HTMLTOKENS_NOT_AN_ENTITY, SUCCESS(2000)), - ERROR(NS_HTMLPARSER_VALID_META_CHARSET, SUCCESS(3000)), -#undef MODULE - - - /* ======================================================================= */ - /* 10: NS_ERROR_MODULE_RDF */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_RDF - /* Returned from nsIRDFDataSource::Assert() and Unassert() if the assertion - * (or unassertion was accepted by the datasource */ - ERROR(NS_RDF_ASSERTION_ACCEPTED, NS_OK), - /* Returned from nsIRDFCursor::Advance() if the cursor has no more - * elements to enumerate */ - ERROR(NS_RDF_CURSOR_EMPTY, SUCCESS(1)), - /* Returned from nsIRDFDataSource::GetSource() and GetTarget() if the - * source/target has no value */ - ERROR(NS_RDF_NO_VALUE, SUCCESS(2)), - /* Returned from nsIRDFDataSource::Assert() and Unassert() if the assertion - * (or unassertion) was rejected by the datasource; i.e., the datasource was - * not willing to record the statement. */ - ERROR(NS_RDF_ASSERTION_REJECTED, SUCCESS(3)), - /* Return this from rdfITripleVisitor to stop cycling */ - ERROR(NS_RDF_STOP_VISIT, SUCCESS(4)), -#undef MODULE - - - /* ======================================================================= */ - /* 11: NS_ERROR_MODULE_UCONV */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_UCONV - ERROR(NS_ERROR_UCONV_NOCONV, FAILURE(1)), - ERROR(NS_ERROR_UDEC_ILLEGALINPUT, FAILURE(14)), - - ERROR(NS_SUCCESS_USING_FALLBACK_LOCALE, SUCCESS(2)), - ERROR(NS_OK_UDEC_EXACTLENGTH, SUCCESS(11)), - ERROR(NS_OK_UDEC_MOREINPUT, SUCCESS(12)), - ERROR(NS_OK_UDEC_MOREOUTPUT, SUCCESS(13)), - ERROR(NS_OK_UDEC_NOBOMFOUND, SUCCESS(14)), - ERROR(NS_OK_UENC_EXACTLENGTH, SUCCESS(33)), - ERROR(NS_OK_UENC_MOREOUTPUT, SUCCESS(34)), - ERROR(NS_ERROR_UENC_NOMAPPING, SUCCESS(35)), - ERROR(NS_OK_UENC_MOREINPUT, SUCCESS(36)), - - /* BEGIN DEPRECATED */ - ERROR(NS_EXACT_LENGTH, NS_OK_UDEC_EXACTLENGTH), - ERROR(NS_PARTIAL_MORE_INPUT, NS_OK_UDEC_MOREINPUT), - ERROR(NS_PARTIAL_MORE_OUTPUT, NS_OK_UDEC_MOREOUTPUT), - ERROR(NS_ERROR_ILLEGAL_INPUT, NS_ERROR_UDEC_ILLEGALINPUT), - /* END DEPRECATED */ -#undef MODULE - - - /* ======================================================================= */ - /* 13: NS_ERROR_MODULE_FILES */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_FILES - ERROR(NS_ERROR_FILE_UNRECOGNIZED_PATH, FAILURE(1)), - ERROR(NS_ERROR_FILE_UNRESOLVABLE_SYMLINK, FAILURE(2)), - ERROR(NS_ERROR_FILE_EXECUTION_FAILED, FAILURE(3)), - ERROR(NS_ERROR_FILE_UNKNOWN_TYPE, FAILURE(4)), - ERROR(NS_ERROR_FILE_DESTINATION_NOT_DIR, FAILURE(5)), - ERROR(NS_ERROR_FILE_TARGET_DOES_NOT_EXIST, FAILURE(6)), - ERROR(NS_ERROR_FILE_COPY_OR_MOVE_FAILED, FAILURE(7)), - ERROR(NS_ERROR_FILE_ALREADY_EXISTS, FAILURE(8)), - ERROR(NS_ERROR_FILE_INVALID_PATH, FAILURE(9)), - ERROR(NS_ERROR_FILE_DISK_FULL, FAILURE(10)), - ERROR(NS_ERROR_FILE_CORRUPTED, FAILURE(11)), - ERROR(NS_ERROR_FILE_NOT_DIRECTORY, FAILURE(12)), - ERROR(NS_ERROR_FILE_IS_DIRECTORY, FAILURE(13)), - ERROR(NS_ERROR_FILE_IS_LOCKED, FAILURE(14)), - ERROR(NS_ERROR_FILE_TOO_BIG, FAILURE(15)), - ERROR(NS_ERROR_FILE_NO_DEVICE_SPACE, FAILURE(16)), - ERROR(NS_ERROR_FILE_NAME_TOO_LONG, FAILURE(17)), - ERROR(NS_ERROR_FILE_NOT_FOUND, FAILURE(18)), - ERROR(NS_ERROR_FILE_READ_ONLY, FAILURE(19)), - ERROR(NS_ERROR_FILE_DIR_NOT_EMPTY, FAILURE(20)), - ERROR(NS_ERROR_FILE_ACCESS_DENIED, FAILURE(21)), - - ERROR(NS_SUCCESS_FILE_DIRECTORY_EMPTY, SUCCESS(1)), - /* Result codes used by nsIDirectoryServiceProvider2 */ - ERROR(NS_SUCCESS_AGGREGATE_RESULT, SUCCESS(2)), -#undef MODULE - - - /* ======================================================================= */ - /* 14: NS_ERROR_MODULE_DOM */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_DOM - /* XXX If you add a new DOM error code, also add an error string to - * dom/base/domerr.msg */ - - /* Standard DOM error codes: http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html */ - ERROR(NS_ERROR_DOM_INDEX_SIZE_ERR, FAILURE(1)), - ERROR(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR, FAILURE(3)), - ERROR(NS_ERROR_DOM_WRONG_DOCUMENT_ERR, FAILURE(4)), - ERROR(NS_ERROR_DOM_INVALID_CHARACTER_ERR, FAILURE(5)), - ERROR(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR, FAILURE(7)), - ERROR(NS_ERROR_DOM_NOT_FOUND_ERR, FAILURE(8)), - ERROR(NS_ERROR_DOM_NOT_SUPPORTED_ERR, FAILURE(9)), - ERROR(NS_ERROR_DOM_INUSE_ATTRIBUTE_ERR, FAILURE(10)), - ERROR(NS_ERROR_DOM_INVALID_STATE_ERR, FAILURE(11)), - ERROR(NS_ERROR_DOM_SYNTAX_ERR, FAILURE(12)), - ERROR(NS_ERROR_DOM_INVALID_MODIFICATION_ERR, FAILURE(13)), - ERROR(NS_ERROR_DOM_NAMESPACE_ERR, FAILURE(14)), - ERROR(NS_ERROR_DOM_INVALID_ACCESS_ERR, FAILURE(15)), - ERROR(NS_ERROR_DOM_TYPE_MISMATCH_ERR, FAILURE(17)), - ERROR(NS_ERROR_DOM_SECURITY_ERR, FAILURE(18)), - ERROR(NS_ERROR_DOM_NETWORK_ERR, FAILURE(19)), - ERROR(NS_ERROR_DOM_ABORT_ERR, FAILURE(20)), - ERROR(NS_ERROR_DOM_URL_MISMATCH_ERR, FAILURE(21)), - ERROR(NS_ERROR_DOM_QUOTA_EXCEEDED_ERR, FAILURE(22)), - ERROR(NS_ERROR_DOM_TIMEOUT_ERR, FAILURE(23)), - ERROR(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR, FAILURE(24)), - ERROR(NS_ERROR_DOM_DATA_CLONE_ERR, FAILURE(25)), - /* XXX Should be JavaScript native errors */ - ERROR(NS_ERROR_TYPE_ERR, FAILURE(26)), - ERROR(NS_ERROR_RANGE_ERR, FAILURE(27)), - /* StringEncoding API errors from http://wiki.whatwg.org/wiki/StringEncoding */ - ERROR(NS_ERROR_DOM_ENCODING_NOT_SUPPORTED_ERR, FAILURE(28)), - ERROR(NS_ERROR_DOM_INVALID_POINTER_ERR, FAILURE(29)), - /* WebCrypto API errors from http://www.w3.org/TR/WebCryptoAPI/ */ - ERROR(NS_ERROR_DOM_UNKNOWN_ERR, FAILURE(30)), - ERROR(NS_ERROR_DOM_DATA_ERR, FAILURE(31)), - ERROR(NS_ERROR_DOM_OPERATION_ERR, FAILURE(32)), - /* https://heycam.github.io/webidl/#notallowederror */ - ERROR(NS_ERROR_DOM_NOT_ALLOWED_ERR, FAILURE(33)), - /* DOM error codes defined by us */ - ERROR(NS_ERROR_DOM_SECMAN_ERR, FAILURE(1001)), - ERROR(NS_ERROR_DOM_WRONG_TYPE_ERR, FAILURE(1002)), - ERROR(NS_ERROR_DOM_NOT_OBJECT_ERR, FAILURE(1003)), - ERROR(NS_ERROR_DOM_NOT_XPC_OBJECT_ERR, FAILURE(1004)), - ERROR(NS_ERROR_DOM_NOT_NUMBER_ERR, FAILURE(1005)), - ERROR(NS_ERROR_DOM_NOT_BOOLEAN_ERR, FAILURE(1006)), - ERROR(NS_ERROR_DOM_NOT_FUNCTION_ERR, FAILURE(1007)), - ERROR(NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR, FAILURE(1008)), - ERROR(NS_ERROR_DOM_BAD_DOCUMENT_DOMAIN, FAILURE(1009)), - ERROR(NS_ERROR_DOM_PROP_ACCESS_DENIED, FAILURE(1010)), - ERROR(NS_ERROR_DOM_XPCONNECT_ACCESS_DENIED, FAILURE(1011)), - ERROR(NS_ERROR_DOM_BAD_URI, FAILURE(1012)), - ERROR(NS_ERROR_DOM_RETVAL_UNDEFINED, FAILURE(1013)), - ERROR(NS_ERROR_DOM_QUOTA_REACHED, FAILURE(1014)), - - /* A way to represent uncatchable exceptions */ - ERROR(NS_ERROR_UNCATCHABLE_EXCEPTION, FAILURE(1015)), - - ERROR(NS_ERROR_DOM_MALFORMED_URI, FAILURE(1016)), - ERROR(NS_ERROR_DOM_INVALID_HEADER_NAME, FAILURE(1017)), - - ERROR(NS_ERROR_DOM_INVALID_STATE_XHR_HAS_INVALID_CONTEXT, FAILURE(1018)), - ERROR(NS_ERROR_DOM_INVALID_STATE_XHR_MUST_BE_OPENED, FAILURE(1019)), - ERROR(NS_ERROR_DOM_INVALID_STATE_XHR_MUST_NOT_BE_SENDING, FAILURE(1020)), - ERROR(NS_ERROR_DOM_INVALID_STATE_XHR_MUST_NOT_BE_LOADING_OR_DONE, FAILURE(1021)), - ERROR(NS_ERROR_DOM_INVALID_STATE_XHR_HAS_WRONG_RESPONSETYPE_FOR_RESPONSEXML, FAILURE(1022)), - ERROR(NS_ERROR_DOM_INVALID_STATE_XHR_HAS_WRONG_RESPONSETYPE_FOR_RESPONSETEXT, FAILURE(1023)), - ERROR(NS_ERROR_DOM_INVALID_STATE_XHR_CHUNKED_RESPONSETYPES_UNSUPPORTED_FOR_SYNC, FAILURE(1024)), - ERROR(NS_ERROR_DOM_INVALID_ACCESS_XHR_TIMEOUT_AND_RESPONSETYPE_UNSUPPORTED_FOR_SYNC, FAILURE(1025)), - - /* May be used to indicate when e.g. setting a property value didn't - * actually change the value, like for obj.foo = "bar"; obj.foo = "bar"; - * the second assignment throws NS_SUCCESS_DOM_NO_OPERATION. - */ - ERROR(NS_SUCCESS_DOM_NO_OPERATION, SUCCESS(1)), - - /* - * A success code that indicates that evaluating a string of JS went - * just fine except it threw an exception. Only for legacy use by - * nsJSUtils. - */ - ERROR(NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW, SUCCESS(2)), - - /* - * A success code that indicates that evaluating a string of JS went - * just fine except it was killed by an uncatchable exception. - * Only for legacy use by nsJSUtils. - */ - ERROR(NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW_UNCATCHABLE, SUCCESS(3)), -#undef MODULE - - - /* ======================================================================= */ - /* 15: NS_ERROR_MODULE_IMGLIB */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_IMGLIB - ERROR(NS_IMAGELIB_SUCCESS_LOAD_FINISHED, SUCCESS(0)), - ERROR(NS_IMAGELIB_CHANGING_OWNER, SUCCESS(1)), - - ERROR(NS_IMAGELIB_ERROR_FAILURE, FAILURE(5)), - ERROR(NS_IMAGELIB_ERROR_NO_DECODER, FAILURE(6)), - ERROR(NS_IMAGELIB_ERROR_NOT_FINISHED, FAILURE(7)), - ERROR(NS_IMAGELIB_ERROR_NO_ENCODER, FAILURE(9)), -#undef MODULE - - - /* ======================================================================= */ - /* 17: NS_ERROR_MODULE_EDITOR */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_EDITOR - ERROR(NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND, SUCCESS(1)), - ERROR(NS_SUCCESS_EDITOR_FOUND_TARGET, SUCCESS(2)), -#undef MODULE - - - /* ======================================================================= */ - /* 18: NS_ERROR_MODULE_XPCONNECT */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_XPCONNECT - ERROR(NS_ERROR_XPC_NOT_ENOUGH_ARGS, FAILURE(1)), - ERROR(NS_ERROR_XPC_NEED_OUT_OBJECT, FAILURE(2)), - ERROR(NS_ERROR_XPC_CANT_SET_OUT_VAL, FAILURE(3)), - ERROR(NS_ERROR_XPC_NATIVE_RETURNED_FAILURE, FAILURE(4)), - ERROR(NS_ERROR_XPC_CANT_GET_INTERFACE_INFO, FAILURE(5)), - ERROR(NS_ERROR_XPC_CANT_GET_PARAM_IFACE_INFO, FAILURE(6)), - ERROR(NS_ERROR_XPC_CANT_GET_METHOD_INFO, FAILURE(7)), - ERROR(NS_ERROR_XPC_UNEXPECTED, FAILURE(8)), - ERROR(NS_ERROR_XPC_BAD_CONVERT_JS, FAILURE(9)), - ERROR(NS_ERROR_XPC_BAD_CONVERT_NATIVE, FAILURE(10)), - ERROR(NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF, FAILURE(11)), - ERROR(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, FAILURE(12)), - ERROR(NS_ERROR_XPC_CANT_CONVERT_WN_TO_FUN, FAILURE(13)), - ERROR(NS_ERROR_XPC_CANT_DEFINE_PROP_ON_WN, FAILURE(14)), - ERROR(NS_ERROR_XPC_CANT_WATCH_WN_STATIC, FAILURE(15)), - ERROR(NS_ERROR_XPC_CANT_EXPORT_WN_STATIC, FAILURE(16)), - ERROR(NS_ERROR_XPC_SCRIPTABLE_CALL_FAILED, FAILURE(17)), - ERROR(NS_ERROR_XPC_SCRIPTABLE_CTOR_FAILED, FAILURE(18)), - ERROR(NS_ERROR_XPC_CANT_CALL_WO_SCRIPTABLE, FAILURE(19)), - ERROR(NS_ERROR_XPC_CANT_CTOR_WO_SCRIPTABLE, FAILURE(20)), - ERROR(NS_ERROR_XPC_CI_RETURNED_FAILURE, FAILURE(21)), - ERROR(NS_ERROR_XPC_GS_RETURNED_FAILURE, FAILURE(22)), - ERROR(NS_ERROR_XPC_BAD_CID, FAILURE(23)), - ERROR(NS_ERROR_XPC_BAD_IID, FAILURE(24)), - ERROR(NS_ERROR_XPC_CANT_CREATE_WN, FAILURE(25)), - ERROR(NS_ERROR_XPC_JS_THREW_EXCEPTION, FAILURE(26)), - ERROR(NS_ERROR_XPC_JS_THREW_NATIVE_OBJECT, FAILURE(27)), - ERROR(NS_ERROR_XPC_JS_THREW_JS_OBJECT, FAILURE(28)), - ERROR(NS_ERROR_XPC_JS_THREW_NULL, FAILURE(29)), - ERROR(NS_ERROR_XPC_JS_THREW_STRING, FAILURE(30)), - ERROR(NS_ERROR_XPC_JS_THREW_NUMBER, FAILURE(31)), - ERROR(NS_ERROR_XPC_JAVASCRIPT_ERROR, FAILURE(32)), - ERROR(NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS, FAILURE(33)), - ERROR(NS_ERROR_XPC_CANT_CONVERT_PRIMITIVE_TO_ARRAY, FAILURE(34)), - ERROR(NS_ERROR_XPC_CANT_CONVERT_OBJECT_TO_ARRAY, FAILURE(35)), - ERROR(NS_ERROR_XPC_NOT_ENOUGH_ELEMENTS_IN_ARRAY, FAILURE(36)), - ERROR(NS_ERROR_XPC_CANT_GET_ARRAY_INFO, FAILURE(37)), - ERROR(NS_ERROR_XPC_NOT_ENOUGH_CHARS_IN_STRING, FAILURE(38)), - ERROR(NS_ERROR_XPC_SECURITY_MANAGER_VETO, FAILURE(39)), - ERROR(NS_ERROR_XPC_INTERFACE_NOT_SCRIPTABLE, FAILURE(40)), - ERROR(NS_ERROR_XPC_INTERFACE_NOT_FROM_NSISUPPORTS, FAILURE(41)), - ERROR(NS_ERROR_XPC_CANT_GET_JSOBJECT_OF_DOM_OBJECT, FAILURE(42)), - ERROR(NS_ERROR_XPC_CANT_SET_READ_ONLY_CONSTANT, FAILURE(43)), - ERROR(NS_ERROR_XPC_CANT_SET_READ_ONLY_ATTRIBUTE, FAILURE(44)), - ERROR(NS_ERROR_XPC_CANT_SET_READ_ONLY_METHOD, FAILURE(45)), - ERROR(NS_ERROR_XPC_CANT_ADD_PROP_TO_WRAPPED_NATIVE, FAILURE(46)), - ERROR(NS_ERROR_XPC_CALL_TO_SCRIPTABLE_FAILED, FAILURE(47)), - ERROR(NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED, FAILURE(48)), - ERROR(NS_ERROR_XPC_BAD_ID_STRING, FAILURE(49)), - ERROR(NS_ERROR_XPC_BAD_INITIALIZER_NAME, FAILURE(50)), - ERROR(NS_ERROR_XPC_HAS_BEEN_SHUTDOWN, FAILURE(51)), - ERROR(NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN, FAILURE(52)), - ERROR(NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL, FAILURE(53)), - ERROR(NS_ERROR_XPC_CANT_PASS_CPOW_TO_NATIVE, FAILURE(54)), - /* any new errors here should have an associated entry added in xpc.msg */ -#undef MODULE - - - /* ======================================================================= */ - /* 19: NS_ERROR_MODULE_PROFILE */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_PROFILE - ERROR(NS_ERROR_LAUNCHED_CHILD_PROCESS, FAILURE(200)), -#undef MODULE - - - /* ======================================================================= */ - /* 21: NS_ERROR_MODULE_SECURITY */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_SECURITY - /* Error code for CSP */ - ERROR(NS_ERROR_CSP_FORM_ACTION_VIOLATION, FAILURE(98)), - ERROR(NS_ERROR_CSP_FRAME_ANCESTOR_VIOLATION, FAILURE(99)), - - /* Error code for Sub-Resource Integrity */ - ERROR(NS_ERROR_SRI_CORRUPT, FAILURE(200)), - ERROR(NS_ERROR_SRI_DISABLED, FAILURE(201)), - ERROR(NS_ERROR_SRI_NOT_ELIGIBLE, FAILURE(202)), - ERROR(NS_ERROR_SRI_UNEXPECTED_HASH_TYPE, FAILURE(203)), - ERROR(NS_ERROR_SRI_IMPORT, FAILURE(204)), - - /* CMS specific nsresult error codes. Note: the numbers used here correspond - * to the values in nsICMSMessageErrors.idl. */ - ERROR(NS_ERROR_CMS_VERIFY_NOT_SIGNED, FAILURE(1024)), - ERROR(NS_ERROR_CMS_VERIFY_NO_CONTENT_INFO, FAILURE(1025)), - ERROR(NS_ERROR_CMS_VERIFY_BAD_DIGEST, FAILURE(1026)), - ERROR(NS_ERROR_CMS_VERIFY_NOCERT, FAILURE(1028)), - ERROR(NS_ERROR_CMS_VERIFY_UNTRUSTED, FAILURE(1029)), - ERROR(NS_ERROR_CMS_VERIFY_ERROR_UNVERIFIED, FAILURE(1031)), - ERROR(NS_ERROR_CMS_VERIFY_ERROR_PROCESSING, FAILURE(1032)), - ERROR(NS_ERROR_CMS_VERIFY_BAD_SIGNATURE, FAILURE(1033)), - ERROR(NS_ERROR_CMS_VERIFY_DIGEST_MISMATCH, FAILURE(1034)), - ERROR(NS_ERROR_CMS_VERIFY_UNKNOWN_ALGO, FAILURE(1035)), - ERROR(NS_ERROR_CMS_VERIFY_UNSUPPORTED_ALGO, FAILURE(1036)), - ERROR(NS_ERROR_CMS_VERIFY_MALFORMED_SIGNATURE, FAILURE(1037)), - ERROR(NS_ERROR_CMS_VERIFY_HEADER_MISMATCH, FAILURE(1038)), - ERROR(NS_ERROR_CMS_VERIFY_NOT_YET_ATTEMPTED, FAILURE(1039)), - ERROR(NS_ERROR_CMS_VERIFY_CERT_WITHOUT_ADDRESS, FAILURE(1040)), - ERROR(NS_ERROR_CMS_ENCRYPT_NO_BULK_ALG, FAILURE(1056)), - ERROR(NS_ERROR_CMS_ENCRYPT_INCOMPLETE, FAILURE(1057)), -#undef MODULE - - - /* ======================================================================= */ - /* 22: NS_ERROR_MODULE_DOM_XPATH */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_DOM_XPATH - /* DOM error codes from http://www.w3.org/TR/DOM-Level-3-XPath/ */ - ERROR(NS_ERROR_DOM_INVALID_EXPRESSION_ERR, FAILURE(51)), - ERROR(NS_ERROR_DOM_TYPE_ERR, FAILURE(52)), -#undef MODULE - - - /* ======================================================================= */ - /* 24: NS_ERROR_MODULE_URILOADER */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_URILOADER - ERROR(NS_ERROR_WONT_HANDLE_CONTENT, FAILURE(1)), - /* The load has been cancelled because it was found on a malware or phishing - * blacklist. */ - ERROR(NS_ERROR_MALWARE_URI, FAILURE(30)), - ERROR(NS_ERROR_PHISHING_URI, FAILURE(31)), - ERROR(NS_ERROR_TRACKING_URI, FAILURE(34)), - ERROR(NS_ERROR_UNWANTED_URI, FAILURE(35)), - ERROR(NS_ERROR_BLOCKED_URI, FAILURE(37)), - /* Used when "Save Link As..." doesn't see the headers quickly enough to - * choose a filename. See nsContextMenu.js. */ - ERROR(NS_ERROR_SAVE_LINK_AS_TIMEOUT, FAILURE(32)), - /* Used when the data from a channel has already been parsed and cached so it - * doesn't need to be reparsed from the original source. */ - ERROR(NS_ERROR_PARSED_DATA_CACHED, FAILURE(33)), - - /* This success code indicates that a refresh header was found and - * successfully setup. */ - ERROR(NS_REFRESHURI_HEADER_FOUND, SUCCESS(2)), -#undef MODULE - - - /* ======================================================================= */ - /* 25: NS_ERROR_MODULE_CONTENT */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_CONTENT - /* Error codes for image loading */ - ERROR(NS_ERROR_IMAGE_SRC_CHANGED, FAILURE(4)), - ERROR(NS_ERROR_IMAGE_BLOCKED, FAILURE(5)), - /* Error codes for content policy blocking */ - ERROR(NS_ERROR_CONTENT_BLOCKED, FAILURE(6)), - ERROR(NS_ERROR_CONTENT_BLOCKED_SHOW_ALT, FAILURE(7)), - /* Success variations of content policy blocking */ - ERROR(NS_PROPTABLE_PROP_NOT_THERE, FAILURE(10)), - /* Error code for XBL */ - ERROR(NS_ERROR_XBL_BLOCKED, FAILURE(15)), - /* Error code for when the content process crashed */ - ERROR(NS_ERROR_CONTENT_CRASHED, FAILURE(16)), - - /* XXX this is not really used */ - ERROR(NS_HTML_STYLE_PROPERTY_NOT_THERE, SUCCESS(2)), - ERROR(NS_CONTENT_BLOCKED, SUCCESS(8)), - ERROR(NS_CONTENT_BLOCKED_SHOW_ALT, SUCCESS(9)), - ERROR(NS_PROPTABLE_PROP_OVERWRITTEN, SUCCESS(11)), - /* Error codes for FindBroadcaster in XULDocument.cpp */ - ERROR(NS_FINDBROADCASTER_NOT_FOUND, SUCCESS(12)), - ERROR(NS_FINDBROADCASTER_FOUND, SUCCESS(13)), - ERROR(NS_FINDBROADCASTER_AWAIT_OVERLAYS, SUCCESS(14)), -#undef MODULE - - - /* ======================================================================= */ - /* 27: NS_ERROR_MODULE_XSLT */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_XSLT - ERROR(NS_ERROR_XPATH_INVALID_ARG, NS_ERROR_INVALID_ARG), - - ERROR(NS_ERROR_XSLT_PARSE_FAILURE, FAILURE(1)), - ERROR(NS_ERROR_XPATH_PARSE_FAILURE, FAILURE(2)), - ERROR(NS_ERROR_XSLT_ALREADY_SET, FAILURE(3)), - ERROR(NS_ERROR_XSLT_EXECUTION_FAILURE, FAILURE(4)), - ERROR(NS_ERROR_XPATH_UNKNOWN_FUNCTION, FAILURE(5)), - ERROR(NS_ERROR_XSLT_BAD_RECURSION, FAILURE(6)), - ERROR(NS_ERROR_XSLT_BAD_VALUE, FAILURE(7)), - ERROR(NS_ERROR_XSLT_NODESET_EXPECTED, FAILURE(8)), - ERROR(NS_ERROR_XSLT_ABORTED, FAILURE(9)), - ERROR(NS_ERROR_XSLT_NETWORK_ERROR, FAILURE(10)), - ERROR(NS_ERROR_XSLT_WRONG_MIME_TYPE, FAILURE(11)), - ERROR(NS_ERROR_XSLT_LOAD_RECURSION, FAILURE(12)), - ERROR(NS_ERROR_XPATH_BAD_ARGUMENT_COUNT, FAILURE(13)), - ERROR(NS_ERROR_XPATH_BAD_EXTENSION_FUNCTION, FAILURE(14)), - ERROR(NS_ERROR_XPATH_PAREN_EXPECTED, FAILURE(15)), - ERROR(NS_ERROR_XPATH_INVALID_AXIS, FAILURE(16)), - ERROR(NS_ERROR_XPATH_NO_NODE_TYPE_TEST, FAILURE(17)), - ERROR(NS_ERROR_XPATH_BRACKET_EXPECTED, FAILURE(18)), - ERROR(NS_ERROR_XPATH_INVALID_VAR_NAME, FAILURE(19)), - ERROR(NS_ERROR_XPATH_UNEXPECTED_END, FAILURE(20)), - ERROR(NS_ERROR_XPATH_OPERATOR_EXPECTED, FAILURE(21)), - ERROR(NS_ERROR_XPATH_UNCLOSED_LITERAL, FAILURE(22)), - ERROR(NS_ERROR_XPATH_BAD_COLON, FAILURE(23)), - ERROR(NS_ERROR_XPATH_BAD_BANG, FAILURE(24)), - ERROR(NS_ERROR_XPATH_ILLEGAL_CHAR, FAILURE(25)), - ERROR(NS_ERROR_XPATH_BINARY_EXPECTED, FAILURE(26)), - ERROR(NS_ERROR_XSLT_LOAD_BLOCKED_ERROR, FAILURE(27)), - ERROR(NS_ERROR_XPATH_INVALID_EXPRESSION_EVALUATED, FAILURE(28)), - ERROR(NS_ERROR_XPATH_UNBALANCED_CURLY_BRACE, FAILURE(29)), - ERROR(NS_ERROR_XSLT_BAD_NODE_NAME, FAILURE(30)), - ERROR(NS_ERROR_XSLT_VAR_ALREADY_SET, FAILURE(31)), - ERROR(NS_ERROR_XSLT_CALL_TO_KEY_NOT_ALLOWED, FAILURE(32)), - - ERROR(NS_XSLT_GET_NEW_HANDLER, SUCCESS(1)), -#undef MODULE - - - /* ======================================================================= */ - /* 28: NS_ERROR_MODULE_IPC */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_IPC - // Initial creation of a Transport object failed internally for unknown reasons. - ERROR(NS_ERROR_TRANSPORT_INIT, FAILURE(1)), - // Generic error related to duplicating handle failures. - ERROR(NS_ERROR_DUPLICATE_HANDLE, FAILURE(2)), - // Bridging: failure trying to open the connection to the parent - ERROR(NS_ERROR_BRIDGE_OPEN_PARENT, FAILURE(3)), - // Bridging: failure trying to open the connection to the child - ERROR(NS_ERROR_BRIDGE_OPEN_CHILD, FAILURE(4)), -#undef MODULE - - /* ======================================================================= */ - /* 29: NS_ERROR_MODULE_SVG */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_SVG - /* SVG DOM error codes from http://www.w3.org/TR/SVG11/svgdom.html */ - ERROR(NS_ERROR_DOM_SVG_WRONG_TYPE_ERR, FAILURE(0)), - /* Yes, the spec says "INVERTABLE", not "INVERTIBLE" */ - ERROR(NS_ERROR_DOM_SVG_MATRIX_NOT_INVERTABLE, FAILURE(2)), -#undef MODULE - - - /* ======================================================================= */ - /* 30: NS_ERROR_MODULE_STORAGE */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_STORAGE - /* To add additional errors to Storage, please append entries to the bottom - * of the list in the following format: - * NS_ERROR_STORAGE_YOUR_ERR, FAILURE(n) - * where n is the next unique positive integer. You must also add an entry - * to js/xpconnect/src/xpc.msg under the code block beginning with the - * comment 'storage related codes (from mozStorage.h)', in the following - * format: 'XPC_MSG_DEF(NS_ERROR_STORAGE_YOUR_ERR, "brief description of your - * error")' */ - ERROR(NS_ERROR_STORAGE_BUSY, FAILURE(1)), - ERROR(NS_ERROR_STORAGE_IOERR, FAILURE(2)), - ERROR(NS_ERROR_STORAGE_CONSTRAINT, FAILURE(3)), -#undef MODULE - - - /* ======================================================================= */ - /* 32: NS_ERROR_MODULE_DOM_FILE */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_DOM_FILE - ERROR(NS_ERROR_DOM_FILE_NOT_FOUND_ERR, FAILURE(0)), - ERROR(NS_ERROR_DOM_FILE_NOT_READABLE_ERR, FAILURE(1)), - ERROR(NS_ERROR_DOM_FILE_ABORT_ERR, FAILURE(2)), -#undef MODULE - - - /* ======================================================================= */ - /* 33: NS_ERROR_MODULE_DOM_INDEXEDDB */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_DOM_INDEXEDDB - /* IndexedDB error codes http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html */ - ERROR(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR, FAILURE(1)), - ERROR(NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR, FAILURE(3)), - ERROR(NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR, FAILURE(4)), - ERROR(NS_ERROR_DOM_INDEXEDDB_DATA_ERR, FAILURE(5)), - ERROR(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR, FAILURE(6)), - ERROR(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR, FAILURE(7)), - ERROR(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR, FAILURE(8)), - ERROR(NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR, FAILURE(9)), - ERROR(NS_ERROR_DOM_INDEXEDDB_TIMEOUT_ERR, FAILURE(10)), - ERROR(NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR, FAILURE(11)), - ERROR(NS_ERROR_DOM_INDEXEDDB_VERSION_ERR, FAILURE(12)), - ERROR(NS_ERROR_DOM_INDEXEDDB_RECOVERABLE_ERR, FAILURE(1001)), -#undef MODULE - - - /* ======================================================================= */ - /* 34: NS_ERROR_MODULE_DOM_FILEHANDLE */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_DOM_FILEHANDLE - ERROR(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR, FAILURE(1)), - ERROR(NS_ERROR_DOM_FILEHANDLE_NOT_ALLOWED_ERR, FAILURE(2)), - ERROR(NS_ERROR_DOM_FILEHANDLE_INACTIVE_ERR, FAILURE(3)), - ERROR(NS_ERROR_DOM_FILEHANDLE_ABORT_ERR, FAILURE(4)), - ERROR(NS_ERROR_DOM_FILEHANDLE_READ_ONLY_ERR, FAILURE(5)), - ERROR(NS_ERROR_DOM_FILEHANDLE_QUOTA_ERR, FAILURE(6)), -#undef MODULE - - /* ======================================================================= */ - /* 35: NS_ERROR_MODULE_SIGNED_JAR */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_SIGNED_JAR - ERROR(NS_ERROR_SIGNED_JAR_NOT_SIGNED, FAILURE(1)), - ERROR(NS_ERROR_SIGNED_JAR_MODIFIED_ENTRY, FAILURE(2)), - ERROR(NS_ERROR_SIGNED_JAR_UNSIGNED_ENTRY, FAILURE(3)), - ERROR(NS_ERROR_SIGNED_JAR_ENTRY_MISSING, FAILURE(4)), - ERROR(NS_ERROR_SIGNED_JAR_WRONG_SIGNATURE, FAILURE(5)), - ERROR(NS_ERROR_SIGNED_JAR_ENTRY_TOO_LARGE, FAILURE(6)), - ERROR(NS_ERROR_SIGNED_JAR_ENTRY_INVALID, FAILURE(7)), - ERROR(NS_ERROR_SIGNED_JAR_MANIFEST_INVALID, FAILURE(8)), -#undef MODULE - - /* ======================================================================= */ - /* 36: NS_ERROR_MODULE_DOM_FILESYSTEM */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_DOM_FILESYSTEM - ERROR(NS_ERROR_DOM_FILESYSTEM_INVALID_PATH_ERR, FAILURE(1)), - ERROR(NS_ERROR_DOM_FILESYSTEM_INVALID_MODIFICATION_ERR, FAILURE(2)), - ERROR(NS_ERROR_DOM_FILESYSTEM_NO_MODIFICATION_ALLOWED_ERR, FAILURE(3)), - ERROR(NS_ERROR_DOM_FILESYSTEM_PATH_EXISTS_ERR, FAILURE(4)), - ERROR(NS_ERROR_DOM_FILESYSTEM_TYPE_MISMATCH_ERR, FAILURE(5)), - ERROR(NS_ERROR_DOM_FILESYSTEM_UNKNOWN_ERR, FAILURE(6)), -#undef MODULE - - /* ======================================================================= */ - /* 38: NS_ERROR_MODULE_SIGNED_APP */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_SIGNED_APP - ERROR(NS_ERROR_SIGNED_APP_MANIFEST_INVALID, FAILURE(1)), -#undef MODULE - - /* ======================================================================= */ - /* 39: NS_ERROR_MODULE_DOM_ANIM */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_DOM_ANIM - ERROR(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR, FAILURE(1)), -#undef MODULE - - /* ======================================================================= */ - /* 40: NS_ERROR_MODULE_DOM_PUSH */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_DOM_PUSH - ERROR(NS_ERROR_DOM_PUSH_INVALID_REGISTRATION_ERR, FAILURE(1)), - ERROR(NS_ERROR_DOM_PUSH_DENIED_ERR, FAILURE(2)), - ERROR(NS_ERROR_DOM_PUSH_ABORT_ERR, FAILURE(3)), - ERROR(NS_ERROR_DOM_PUSH_SERVICE_UNREACHABLE, FAILURE(4)), - ERROR(NS_ERROR_DOM_PUSH_INVALID_KEY_ERR, FAILURE(5)), - ERROR(NS_ERROR_DOM_PUSH_MISMATCHED_KEY_ERR, FAILURE(6)), -#undef MODULE - - /* ======================================================================= */ - /* 41: NS_ERROR_MODULE_DOM_MEDIA */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_DOM_MEDIA - /* HTMLMediaElement API errors from https://html.spec.whatwg.org/multipage/embedded-content.html#media-elements */ - ERROR(NS_ERROR_DOM_MEDIA_ABORT_ERR, FAILURE(1)), - ERROR(NS_ERROR_DOM_MEDIA_NOT_ALLOWED_ERR, FAILURE(2)), - ERROR(NS_ERROR_DOM_MEDIA_NOT_SUPPORTED_ERR, FAILURE(3)), - - /* HTMLMediaElement internal decoding error */ - ERROR(NS_ERROR_DOM_MEDIA_DECODE_ERR, FAILURE(4)), - ERROR(NS_ERROR_DOM_MEDIA_FATAL_ERR, FAILURE(5)), - ERROR(NS_ERROR_DOM_MEDIA_METADATA_ERR, FAILURE(6)), - ERROR(NS_ERROR_DOM_MEDIA_OVERFLOW_ERR, FAILURE(7)), - ERROR(NS_ERROR_DOM_MEDIA_END_OF_STREAM, FAILURE(8)), - ERROR(NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA, FAILURE(9)), - ERROR(NS_ERROR_DOM_MEDIA_CANCELED, FAILURE(10)), - ERROR(NS_ERROR_DOM_MEDIA_MEDIASINK_ERR, FAILURE(11)), - ERROR(NS_ERROR_DOM_MEDIA_DEMUXER_ERR, FAILURE(12)), - ERROR(NS_ERROR_DOM_MEDIA_CDM_ERR, FAILURE(13)), - ERROR(NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER, FAILURE(14)), - ERROR(NS_ERROR_DOM_MEDIA_INITIALIZING_DECODER, FAILURE(15)), - - /* Internal platform-related errors */ - ERROR(NS_ERROR_DOM_MEDIA_CUBEB_INITIALIZATION_ERR, FAILURE(101)), -#undef MODULE - - /* ======================================================================= */ - /* 42: NS_ERROR_MODULE_URL_CLASSIFIER */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_URL_CLASSIFIER - ERROR(NS_ERROR_UC_UPDATE_UNKNOWN, FAILURE(1)), - ERROR(NS_ERROR_UC_UPDATE_DUPLICATE_PREFIX, FAILURE(2)), - ERROR(NS_ERROR_UC_UPDATE_INFINITE_LOOP, FAILURE(3)), - ERROR(NS_ERROR_UC_UPDATE_WRONG_REMOVAL_INDICES, FAILURE(4)), - ERROR(NS_ERROR_UC_UPDATE_CHECKSUM_MISMATCH, FAILURE(5)), - ERROR(NS_ERROR_UC_UPDATE_MISSING_CHECKSUM, FAILURE(6)), - ERROR(NS_ERROR_UC_UPDATE_SHUTDOWNING, FAILURE(7)), - ERROR(NS_ERROR_UC_UPDATE_TABLE_NOT_FOUND, FAILURE(8)), - ERROR(NS_ERROR_UC_UPDATE_BUILD_PREFIX_FAILURE, FAILURE(9)), - ERROR(NS_ERROR_UC_UPDATE_FAIL_TO_WRITE_DISK, FAILURE(10)), - ERROR(NS_ERROR_UC_UPDATE_PROTOCOL_PARSER_ERROR, FAILURE(11)), -#undef MODULE - - /* ======================================================================= */ - /* 43: NS_ERROR_MODULE_ERRORRESULT */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_ERRORRESULT - /* Represents a JS Value being thrown as an exception. */ - ERROR(NS_ERROR_INTERNAL_ERRORRESULT_JS_EXCEPTION, FAILURE(1)), - /* Used to indicate that we want to throw a DOMException. */ - ERROR(NS_ERROR_INTERNAL_ERRORRESULT_DOMEXCEPTION, FAILURE(2)), - /* Used to indicate that an exception is already pending on the JSContext. */ - ERROR(NS_ERROR_INTERNAL_ERRORRESULT_EXCEPTION_ON_JSCONTEXT, FAILURE(3)), - /* Used to indicate that we want to throw a TypeError. */ - ERROR(NS_ERROR_INTERNAL_ERRORRESULT_TYPEERROR, FAILURE(4)), - /* Used to indicate that we want to throw a RangeError. */ - ERROR(NS_ERROR_INTERNAL_ERRORRESULT_RANGEERROR, FAILURE(5)), -#undef MODULE - - /* ======================================================================= */ - /* 51: NS_ERROR_MODULE_GENERAL */ - /* ======================================================================= */ -#define MODULE NS_ERROR_MODULE_GENERAL - /* Error code used internally by the incremental downloader to cancel the - * network channel when the download is already complete. */ - ERROR(NS_ERROR_DOWNLOAD_COMPLETE, FAILURE(1)), - /* Error code used internally by the incremental downloader to cancel the - * network channel when the response to a range request is 200 instead of - * 206. */ - ERROR(NS_ERROR_DOWNLOAD_NOT_PARTIAL, FAILURE(2)), - ERROR(NS_ERROR_UNORM_MOREOUTPUT, FAILURE(33)), - - ERROR(NS_ERROR_DOCSHELL_REQUEST_REJECTED, FAILURE(1001)), - /* This is needed for displaying an error message when navigation is - * attempted on a document when printing The value arbitrary as long as it - * doesn't conflict with any of the other values in the errors in - * DisplayLoadError */ - ERROR(NS_ERROR_DOCUMENT_IS_PRINTMODE, FAILURE(2001)), - - ERROR(NS_SUCCESS_DONT_FIXUP, SUCCESS(1)), - /* This success code may be returned by nsIAppStartup::Run to indicate that - * the application should be restarted. This condition corresponds to the - * case in which nsIAppStartup::Quit was called with the eRestart flag. */ - ERROR(NS_SUCCESS_RESTART_APP, SUCCESS(1)), - ERROR(NS_SUCCESS_RESTART_APP_NOT_SAME_PROFILE, SUCCESS(3)), - ERROR(NS_SUCCESS_UNORM_NOTFOUND, SUCCESS(17)), - - - /* a11y */ - /* raised when current pivot's position is needed but it's not in the tree */ - ERROR(NS_ERROR_NOT_IN_TREE, FAILURE(38)), - - /* see nsTextEquivUtils */ - ERROR(NS_OK_NO_NAME_CLAUSE_HANDLED, SUCCESS(34)) -#undef MODULE diff --git a/xpcom/base/ErrorList.py b/xpcom/base/ErrorList.py new file mode 100644 index 000000000000..eb732b2befc0 --- /dev/null +++ b/xpcom/base/ErrorList.py @@ -0,0 +1,1240 @@ +#!/usr/bin/env python +from collections import OrderedDict + +class Mod: + """ + A nserror module. When used with a `with` statement, binds the itself to + Mod.active. + """ + active = None + + def __init__(self, num): + self.num = num + + def __enter__(self): + Mod.active = self + + def __exit__(self, _type, _value, _traceback): + Mod.active = None + +modules = OrderedDict() + +# To add error code to your module, you need to do the following: +# +# 1) Add a module offset code. Add yours to the bottom of the list +# right below this comment, adding 1. +# +# 2) In your module, define a header file which uses one of the +# NE_ERROR_GENERATExxxxxx macros. Some examples below: +# +# #define NS_ERROR_MYMODULE_MYERROR1 NS_ERROR_GENERATE(NS_ERROR_SEVERITY_ERROR,NS_ERROR_MODULE_MYMODULE,1) +# #define NS_ERROR_MYMODULE_MYERROR2 NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_MYMODULE,2) +# #define NS_ERROR_MYMODULE_MYERROR3 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_MYMODULE,3) + +# @name Standard Module Offset Code. Each Module should identify a unique number +# and then all errors associated with that module become offsets from the +# base associated with that module id. There are 16 bits of code bits for +# each module. + +modules["XPCOM"] = Mod(1) +modules["BASE"] = Mod(2) +modules["GFX"] = Mod(3) +modules["WIDGET"] = Mod(4) +modules["CALENDAR"] = Mod(5) +modules["NETWORK"] = Mod(6) +modules["PLUGINS"] = Mod(7) +modules["LAYOUT"] = Mod(8) +modules["HTMLPARSER"] = Mod(9) +modules["RDF"] = Mod(10) +modules["UCONV"] = Mod(11) +modules["REG"] = Mod(12) +modules["FILES"] = Mod(13) +modules["DOM"] = Mod(14) +modules["IMGLIB"] = Mod(15) +modules["MAILNEWS"] = Mod(16) +modules["EDITOR"] = Mod(17) +modules["XPCONNECT"] = Mod(18) +modules["PROFILE"] = Mod(19) +modules["LDAP"] = Mod(20) +modules["SECURITY"] = Mod(21) +modules["DOM_XPATH"] = Mod(22) +# Mod(23) used to be NS_ERROR_MODULE_DOM_RANGE (see bug 711047) +modules["URILOADER"] = Mod(24) +modules["CONTENT"] = Mod(25) +modules["PYXPCOM"] = Mod(26) +modules["XSLT"] = Mod(27) +modules["IPC"] = Mod(28) +modules["SVG"] = Mod(29) +modules["STORAGE"] = Mod(30) +modules["SCHEMA"] = Mod(31) +modules["DOM_FILE"] = Mod(32) +modules["DOM_INDEXEDDB"] = Mod(33) +modules["DOM_FILEHANDLE"] = Mod(34) +modules["SIGNED_JAR"] = Mod(35) +modules["DOM_FILESYSTEM"] = Mod(36) +modules["DOM_BLUETOOTH"] = Mod(37) +modules["SIGNED_APP"] = Mod(38) +modules["DOM_ANIM"] = Mod(39) +modules["DOM_PUSH"] = Mod(40) +modules["DOM_MEDIA"] = Mod(41) +modules["URL_CLASSIFIER"] = Mod(42) +# ErrorResult gets its own module to reduce the chance of someone accidentally +# defining an error code matching one of the ErrorResult ones. +modules["ERRORRESULT"] = Mod(43) + +# NS_ERROR_MODULE_GENERAL should be used by modules that do not +# care if return code values overlap. Callers of methods that +# return such codes should be aware that they are not +# globally unique. Implementors should be careful about blindly +# returning codes from other modules that might also use +# the generic base. +modules["GENERAL"] = Mod(51) + +MODULE_BASE_OFFSET = 0x45 + +NS_ERROR_SEVERITY_SUCCESS = 0 +NS_ERROR_SEVERITY_ERROR = 1 + +def SUCCESS_OR_FAILURE(sev, module, code): + return (sev << 31) | ((module + MODULE_BASE_OFFSET) << 16) | code + +def FAILURE(code): + return SUCCESS_OR_FAILURE(NS_ERROR_SEVERITY_ERROR, Mod.active.num, code) + +def SUCCESS(code): + return SUCCESS_OR_FAILURE(NS_ERROR_SEVERITY_SUCCESS, Mod.active.num, code) + +# Errors is an ordered dictionary, so that we can recover the order in which +# they were defined. This is important for determining which name is the +# canonical name for an error code. +errors = OrderedDict() + +# Standard "it worked" return value +errors["NS_OK"] = 0 + +# ======================================================================= +# Core errors, not part of any modules +# ======================================================================= +errors["NS_ERROR_BASE"] = 0xC1F30000 +# Returned when an instance is not initialized +errors["NS_ERROR_NOT_INITIALIZED"] = errors["NS_ERROR_BASE"] + 1 +# Returned when an instance is already initialized +errors["NS_ERROR_ALREADY_INITIALIZED"] = errors["NS_ERROR_BASE"] + 2 +# Returned by a not implemented function +errors["NS_ERROR_NOT_IMPLEMENTED"] = 0x80004001 +# Returned when a given interface is not supported. +errors["NS_NOINTERFACE"] = 0x80004002 +errors["NS_ERROR_NO_INTERFACE"] = errors["NS_NOINTERFACE"] +# Returned when a function aborts +errors["NS_ERROR_ABORT"] = 0x80004004 +# Returned when a function fails +errors["NS_ERROR_FAILURE"] = 0x80004005 +# Returned when an unexpected error occurs +errors["NS_ERROR_UNEXPECTED"] = 0x8000ffff +# Returned when a memory allocation fails +errors["NS_ERROR_OUT_OF_MEMORY"] = 0x8007000e +# Returned when an illegal value is passed +errors["NS_ERROR_ILLEGAL_VALUE"] = 0x80070057 +errors["NS_ERROR_INVALID_ARG"] = errors["NS_ERROR_ILLEGAL_VALUE"] +errors["NS_ERROR_INVALID_POINTER"] = errors["NS_ERROR_INVALID_ARG"] +errors["NS_ERROR_NULL_POINTER"] = errors["NS_ERROR_INVALID_ARG"] +# Returned when a class doesn't allow aggregation +errors["NS_ERROR_NO_AGGREGATION"] = 0x80040110 +# Returned when an operation can't complete due to an unavailable resource +errors["NS_ERROR_NOT_AVAILABLE"] = 0x80040111 +# Returned when a class is not registered +errors["NS_ERROR_FACTORY_NOT_REGISTERED"] = 0x80040154 +# Returned when a class cannot be registered, but may be tried again later +errors["NS_ERROR_FACTORY_REGISTER_AGAIN"] = 0x80040155 +# Returned when a dynamically loaded factory couldn't be found +errors["NS_ERROR_FACTORY_NOT_LOADED"] = 0x800401f8 +# Returned when a factory doesn't support signatures +errors["NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT"] = errors["NS_ERROR_BASE"] + 0x101 +# Returned when a factory already is registered +errors["NS_ERROR_FACTORY_EXISTS"] = errors["NS_ERROR_BASE"] + 0x100 + + +# ======================================================================= +# 1: NS_ERROR_MODULE_XPCOM +# ======================================================================= +with modules["XPCOM"]: + # Result codes used by nsIVariant + errors["NS_ERROR_CANNOT_CONVERT_DATA"] = FAILURE(1) + errors["NS_ERROR_OBJECT_IS_IMMUTABLE"] = FAILURE(2) + errors["NS_ERROR_LOSS_OF_SIGNIFICANT_DATA"] = FAILURE(3) + # Result code used by nsIThreadManager + errors["NS_ERROR_NOT_SAME_THREAD"] = FAILURE(4) + # Various operations are not permitted during XPCOM shutdown and will fail + # with this exception. + errors["NS_ERROR_ILLEGAL_DURING_SHUTDOWN"] = FAILURE(30) + errors["NS_ERROR_SERVICE_NOT_AVAILABLE"] = FAILURE(22) + + errors["NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA"] = SUCCESS(1) + # Used by nsCycleCollectionParticipant + errors["NS_SUCCESS_INTERRUPTED_TRAVERSE"] = SUCCESS(2) + # DEPRECATED + errors["NS_ERROR_SERVICE_NOT_FOUND"] = SUCCESS(22) + # DEPRECATED + errors["NS_ERROR_SERVICE_IN_USE"] = SUCCESS(23) + +# ======================================================================= +# 2: NS_ERROR_MODULE_BASE +# ======================================================================= +with modules["BASE"]: + # I/O Errors + + # Stream closed + errors["NS_BASE_STREAM_CLOSED"] = FAILURE(2) + # Error from the operating system + errors["NS_BASE_STREAM_OSERROR"] = FAILURE(3) + # Illegal arguments + errors["NS_BASE_STREAM_ILLEGAL_ARGS"] = FAILURE(4) + # For unichar streams + errors["NS_BASE_STREAM_NO_CONVERTER"] = FAILURE(5) + # For unichar streams + errors["NS_BASE_STREAM_BAD_CONVERSION"] = FAILURE(6) + errors["NS_BASE_STREAM_WOULD_BLOCK"] = FAILURE(7) + + + +# ======================================================================= +# 3: NS_ERROR_MODULE_GFX +# ======================================================================= +with modules["GFX"]: + # no printer available (e.g. cannot find _any_ printer) + errors["NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE"] = FAILURE(1) + # _specified_ (by name) printer not found + errors["NS_ERROR_GFX_PRINTER_NAME_NOT_FOUND"] = FAILURE(2) + # print-to-file: could not open output file + errors["NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE"] = FAILURE(3) + # print: starting document + errors["NS_ERROR_GFX_PRINTER_STARTDOC"] = FAILURE(4) + # print: ending document + errors["NS_ERROR_GFX_PRINTER_ENDDOC"] = FAILURE(5) + # print: starting page + errors["NS_ERROR_GFX_PRINTER_STARTPAGE"] = FAILURE(6) + # The document is still being loaded + errors["NS_ERROR_GFX_PRINTER_DOC_IS_BUSY"] = FAILURE(7) + + # Font cmap is strangely structured - avoid this font! + errors["NS_ERROR_GFX_CMAP_MALFORMED"] = FAILURE(51) + + + +# ======================================================================= +# 4: NS_ERROR_MODULE_WIDGET +# ======================================================================= +with modules["WIDGET"]: + # Used by: + # - nsIWidget::NotifyIME() + # - nsIWidget::OnWindowedPluginKeyEvent() + # Returned when the notification or the event is handled and it's consumed + # by somebody. + errors["NS_SUCCESS_EVENT_CONSUMED"] = SUCCESS(1) + # Used by: + # - nsIWidget::OnWindowedPluginKeyEvent() + # Returned when the event is handled correctly but the result will be + # notified asynchronously. + errors["NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY"] = SUCCESS(2) + + + +# ======================================================================= +# 6: NS_ERROR_MODULE_NETWORK +# ======================================================================= +with modules["NETWORK"]: + # General async request error codes: + # + # These error codes are commonly passed through callback methods to indicate + # the status of some requested async request. + # + # For example, see nsIRequestObserver::onStopRequest. + + # The async request completed successfully. + errors["NS_BINDING_SUCCEEDED"] = errors["NS_OK"] + + # The async request failed for some unknown reason. + errors["NS_BINDING_FAILED"] = FAILURE(1) + # The async request failed because it was aborted by some user action. + errors["NS_BINDING_ABORTED"] = FAILURE(2) + # The async request has been "redirected" to a different async request. + # (e.g., an HTTP redirect occurred). + # + # This error code is used with load groups to notify the load group observer + # when a request in the load group is redirected to another request. + errors["NS_BINDING_REDIRECTED"] = FAILURE(3) + # The async request has been "retargeted" to a different "handler." + # + # This error code is used with load groups to notify the load group observer + # when a request in the load group is removed from the load group and added + # to a different load group. + errors["NS_BINDING_RETARGETED"] = FAILURE(4) + + # Miscellaneous error codes: These errors are not typically passed via + # onStopRequest. + + # The URI is malformed. + errors["NS_ERROR_MALFORMED_URI"] = FAILURE(10) + # The requested action could not be completed while the object is busy. + # Implementations of nsIChannel::asyncOpen will commonly return this error + # if the channel has already been opened (and has not yet been closed). + errors["NS_ERROR_IN_PROGRESS"] = FAILURE(15) + # Returned from nsIChannel::asyncOpen to indicate that OnDataAvailable will + # not be called because there is no content available. This is used by + # helper app style protocols (e.g., mailto). XXX perhaps this should be a + # success code. + errors["NS_ERROR_NO_CONTENT"] = FAILURE(17) + # The URI scheme corresponds to an unknown protocol handler. + errors["NS_ERROR_UNKNOWN_PROTOCOL"] = FAILURE(18) + # The content encoding of the source document was incorrect, for example + # returning a plain HTML document advertised as Content-Encoding: gzip + errors["NS_ERROR_INVALID_CONTENT_ENCODING"] = FAILURE(27) + # A transport level corruption was found in the source document. for example + # a document with a calculated checksum that does not match the Content-MD5 + # http header. + errors["NS_ERROR_CORRUPTED_CONTENT"] = FAILURE(29) + # A content signature verification failed for some reason. This can be either + # an actual verification error, or any other error that led to the fact that + # a content signature that was expected couldn't be verified. + errors["NS_ERROR_INVALID_SIGNATURE"] = FAILURE(58) + # While parsing for the first component of a header field using syntax as in + # Content-Disposition or Content-Type, the first component was found to be + # empty, such as in: Content-Disposition: ; filename=foo + errors["NS_ERROR_FIRST_HEADER_FIELD_COMPONENT_EMPTY"] = FAILURE(34) + # Returned from nsIChannel::asyncOpen when trying to open the channel again + # (reopening is not supported). + errors["NS_ERROR_ALREADY_OPENED"] = FAILURE(73) + + # Connectivity error codes: + + # The connection is already established. XXX unused - consider removing. + errors["NS_ERROR_ALREADY_CONNECTED"] = FAILURE(11) + # The connection does not exist. XXX unused - consider removing. + errors["NS_ERROR_NOT_CONNECTED"] = FAILURE(12) + # The connection attempt failed, for example, because no server was + # listening at specified host:port. + errors["NS_ERROR_CONNECTION_REFUSED"] = FAILURE(13) + # The connection was lost due to a timeout error. + errors["NS_ERROR_NET_TIMEOUT"] = FAILURE(14) + # The requested action could not be completed while the networking library + # is in the offline state. + errors["NS_ERROR_OFFLINE"] = FAILURE(16) + # The requested action was prohibited because it would have caused the + # networking library to establish a connection to an unsafe or otherwise + # banned port. + errors["NS_ERROR_PORT_ACCESS_NOT_ALLOWED"] = FAILURE(19) + # The connection was established, but no data was ever received. + errors["NS_ERROR_NET_RESET"] = FAILURE(20) + # The connection was established, but the data transfer was interrupted. + errors["NS_ERROR_NET_INTERRUPT"] = FAILURE(71) + # The connection attempt to a proxy failed. + errors["NS_ERROR_PROXY_CONNECTION_REFUSED"] = FAILURE(72) + # A transfer was only partially done when it completed. + errors["NS_ERROR_NET_PARTIAL_TRANSFER"] = FAILURE(76) + # HTTP/2 detected invalid TLS configuration + errors["NS_ERROR_NET_INADEQUATE_SECURITY"] = FAILURE(82) + + # XXX really need to better rationalize these error codes. are consumers of + # necko really expected to know how to discern the meaning of these?? + # This request is not resumable, but it was tried to resume it, or to + # request resume-specific data. + errors["NS_ERROR_NOT_RESUMABLE"] = FAILURE(25) + # The request failed as a result of a detected redirection loop. + errors["NS_ERROR_REDIRECT_LOOP"] = FAILURE(31) + # It was attempted to resume the request, but the entity has changed in the + # meantime. + errors["NS_ERROR_ENTITY_CHANGED"] = FAILURE(32) + # The request failed because the content type returned by the server was not + # a type expected by the channel (for nested channels such as the JAR + # channel). + errors["NS_ERROR_UNSAFE_CONTENT_TYPE"] = FAILURE(74) + # The request failed because the user tried to access to a remote XUL + # document from a website that is not in its white-list. + errors["NS_ERROR_REMOTE_XUL"] = FAILURE(75) + # The request resulted in an error page being displayed. + errors["NS_ERROR_LOAD_SHOWED_ERRORPAGE"] = FAILURE(77) + # The request occurred in docshell that lacks a treeowner, so it is + # probably in the process of being torn down. + errors["NS_ERROR_DOCSHELL_DYING"] = FAILURE(78) + + + # FTP specific error codes: + + errors["NS_ERROR_FTP_LOGIN"] = FAILURE(21) + errors["NS_ERROR_FTP_CWD"] = FAILURE(22) + errors["NS_ERROR_FTP_PASV"] = FAILURE(23) + errors["NS_ERROR_FTP_PWD"] = FAILURE(24) + errors["NS_ERROR_FTP_LIST"] = FAILURE(28) + + # DNS specific error codes: + + # The lookup of a hostname failed. This generally refers to the hostname + # from the URL being loaded. + errors["NS_ERROR_UNKNOWN_HOST"] = FAILURE(30) + # A low or medium priority DNS lookup failed because the pending queue was + # already full. High priorty (the default) always makes room + errors["NS_ERROR_DNS_LOOKUP_QUEUE_FULL"] = FAILURE(33) + # The lookup of a proxy hostname failed. If a channel is configured to + # speak to a proxy server, then it will generate this error if the proxy + # hostname cannot be resolved. + errors["NS_ERROR_UNKNOWN_PROXY_HOST"] = FAILURE(42) + + + # Socket specific error codes: + + # The specified socket type does not exist. + errors["NS_ERROR_UNKNOWN_SOCKET_TYPE"] = FAILURE(51) + # The specified socket type could not be created. + errors["NS_ERROR_SOCKET_CREATE_FAILED"] = FAILURE(52) + # The operating system doesn't support the given type of address. + errors["NS_ERROR_SOCKET_ADDRESS_NOT_SUPPORTED"] = FAILURE(53) + # The address to which we tried to bind the socket was busy. + errors["NS_ERROR_SOCKET_ADDRESS_IN_USE"] = FAILURE(54) + + # Cache specific error codes: + errors["NS_ERROR_CACHE_KEY_NOT_FOUND"] = FAILURE(61) + errors["NS_ERROR_CACHE_DATA_IS_STREAM"] = FAILURE(62) + errors["NS_ERROR_CACHE_DATA_IS_NOT_STREAM"] = FAILURE(63) + errors["NS_ERROR_CACHE_WAIT_FOR_VALIDATION"] = FAILURE(64) + errors["NS_ERROR_CACHE_ENTRY_DOOMED"] = FAILURE(65) + errors["NS_ERROR_CACHE_READ_ACCESS_DENIED"] = FAILURE(66) + errors["NS_ERROR_CACHE_WRITE_ACCESS_DENIED"] = FAILURE(67) + errors["NS_ERROR_CACHE_IN_USE"] = FAILURE(68) + # Error passed through onStopRequest if the document could not be fetched + # from the cache. + errors["NS_ERROR_DOCUMENT_NOT_CACHED"] = FAILURE(70) + + # Effective TLD Service specific error codes: + + # The requested number of domain levels exceeds those present in the host + # string. + errors["NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS"] = FAILURE(80) + # The host string is an IP address. + errors["NS_ERROR_HOST_IS_IP_ADDRESS"] = FAILURE(81) + + + # StreamLoader specific result codes: + + # Result code returned by nsIStreamLoaderObserver to indicate that the + # observer is taking over responsibility for the data buffer, and the loader + # should NOT free it. + errors["NS_SUCCESS_ADOPTED_DATA"] = SUCCESS(90) + + # FTP + errors["NS_NET_STATUS_BEGIN_FTP_TRANSACTION"] = SUCCESS(27) + errors["NS_NET_STATUS_END_FTP_TRANSACTION"] = SUCCESS(28) + + # This success code may be returned by nsIAuthModule::getNextToken to + # indicate that the authentication is finished and thus there's no need + # to call getNextToken again. + errors["NS_SUCCESS_AUTH_FINISHED"] = SUCCESS(40) + + # These are really not "results", they're statuses, used by nsITransport and + # friends. This is abuse of nsresult, but we'll put up with it for now. + # nsITransport + errors["NS_NET_STATUS_READING"] = FAILURE(8) + errors["NS_NET_STATUS_WRITING"] = FAILURE(9) + + # nsISocketTransport + errors["NS_NET_STATUS_RESOLVING_HOST"] = FAILURE(3) + errors["NS_NET_STATUS_RESOLVED_HOST"] = FAILURE(11) + errors["NS_NET_STATUS_CONNECTING_TO"] = FAILURE(7) + errors["NS_NET_STATUS_CONNECTED_TO"] = FAILURE(4) + errors["NS_NET_STATUS_TLS_HANDSHAKE_STARTING"] = FAILURE(12) + errors["NS_NET_STATUS_TLS_HANDSHAKE_ENDED"] = FAILURE(13) + errors["NS_NET_STATUS_SENDING_TO"] = FAILURE(5) + errors["NS_NET_STATUS_WAITING_FOR"] = FAILURE(10) + errors["NS_NET_STATUS_RECEIVING_FROM"] = FAILURE(6) + + # nsIInterceptedChannel + # Generic error for non-specific failures during service worker interception + errors["NS_ERROR_INTERCEPTION_FAILED"] = FAILURE(100) + + # nsIHstsPrimingListener + # Error code for HSTS priming timeout to distinguish from blocking + errors["NS_ERROR_HSTS_PRIMING_TIMEOUT"] = FAILURE(110) + + + +# ======================================================================= +# 7: NS_ERROR_MODULE_PLUGINS +# ======================================================================= +with modules["PLUGINS"]: + errors["NS_ERROR_PLUGINS_PLUGINSNOTCHANGED"] = FAILURE(1000) + errors["NS_ERROR_PLUGIN_DISABLED"] = FAILURE(1001) + errors["NS_ERROR_PLUGIN_BLOCKLISTED"] = FAILURE(1002) + errors["NS_ERROR_PLUGIN_TIME_RANGE_NOT_SUPPORTED"] = FAILURE(1003) + errors["NS_ERROR_PLUGIN_CLICKTOPLAY"] = FAILURE(1004) + errors["NS_PLUGIN_INIT_PENDING"] = SUCCESS(1005) + + + +# ======================================================================= +# 8: NS_ERROR_MODULE_LAYOUT +# ======================================================================= +with modules["LAYOUT"]: + # Return code for nsITableLayout + errors["NS_TABLELAYOUT_CELL_NOT_FOUND"] = SUCCESS(0) + # Return code for nsFrame::GetNextPrevLineFromeBlockFrame + errors["NS_POSITION_BEFORE_TABLE"] = SUCCESS(3) + # Return codes for nsPresState::GetProperty() + # Returned if the property exists + errors["NS_STATE_PROPERTY_EXISTS"] = errors["NS_OK"] + # Returned if the property does not exist + errors["NS_STATE_PROPERTY_NOT_THERE"] = SUCCESS(5) + + + +# ======================================================================= +# 9: NS_ERROR_MODULE_HTMLPARSER +# ======================================================================= +with modules["HTMLPARSER"]: + errors["NS_ERROR_HTMLPARSER_CONTINUE"] = errors["NS_OK"] + + errors["NS_ERROR_HTMLPARSER_EOF"] = FAILURE(1000) + errors["NS_ERROR_HTMLPARSER_UNKNOWN"] = FAILURE(1001) + errors["NS_ERROR_HTMLPARSER_CANTPROPAGATE"] = FAILURE(1002) + errors["NS_ERROR_HTMLPARSER_CONTEXTMISMATCH"] = FAILURE(1003) + errors["NS_ERROR_HTMLPARSER_BADFILENAME"] = FAILURE(1004) + errors["NS_ERROR_HTMLPARSER_BADURL"] = FAILURE(1005) + errors["NS_ERROR_HTMLPARSER_INVALIDPARSERCONTEXT"] = FAILURE(1006) + errors["NS_ERROR_HTMLPARSER_INTERRUPTED"] = FAILURE(1007) + errors["NS_ERROR_HTMLPARSER_BLOCK"] = FAILURE(1008) + errors["NS_ERROR_HTMLPARSER_BADTOKENIZER"] = FAILURE(1009) + errors["NS_ERROR_HTMLPARSER_BADATTRIBUTE"] = FAILURE(1010) + errors["NS_ERROR_HTMLPARSER_UNRESOLVEDDTD"] = FAILURE(1011) + errors["NS_ERROR_HTMLPARSER_MISPLACEDTABLECONTENT"] = FAILURE(1012) + errors["NS_ERROR_HTMLPARSER_BADDTD"] = FAILURE(1013) + errors["NS_ERROR_HTMLPARSER_BADCONTEXT"] = FAILURE(1014) + errors["NS_ERROR_HTMLPARSER_STOPPARSING"] = FAILURE(1015) + errors["NS_ERROR_HTMLPARSER_UNTERMINATEDSTRINGLITERAL"] = FAILURE(1016) + errors["NS_ERROR_HTMLPARSER_HIERARCHYTOODEEP"] = FAILURE(1017) + errors["NS_ERROR_HTMLPARSER_FAKE_ENDTAG"] = FAILURE(1018) + errors["NS_ERROR_HTMLPARSER_INVALID_COMMENT"] = FAILURE(1019) + + errors["NS_HTMLTOKENS_NOT_AN_ENTITY"] = SUCCESS(2000) + errors["NS_HTMLPARSER_VALID_META_CHARSET"] = SUCCESS(3000) + + + +# ======================================================================= +# 10: NS_ERROR_MODULE_RDF +# ======================================================================= +with modules["RDF"]: + # Returned from nsIRDFDataSource::Assert() and Unassert() if the assertion + # (or unassertion was accepted by the datasource + errors["NS_RDF_ASSERTION_ACCEPTED"] = errors["NS_OK"] + # Returned from nsIRDFCursor::Advance() if the cursor has no more + # elements to enumerate + errors["NS_RDF_CURSOR_EMPTY"] = SUCCESS(1) + # Returned from nsIRDFDataSource::GetSource() and GetTarget() if the + # source/target has no value + errors["NS_RDF_NO_VALUE"] = SUCCESS(2) + # Returned from nsIRDFDataSource::Assert() and Unassert() if the assertion + # (or unassertion) was rejected by the datasource; i.e., the datasource was + # not willing to record the statement. + errors["NS_RDF_ASSERTION_REJECTED"] = SUCCESS(3) + # Return this from rdfITripleVisitor to stop cycling + errors["NS_RDF_STOP_VISIT"] = SUCCESS(4) + + + +# ======================================================================= +# 11: NS_ERROR_MODULE_UCONV +# ======================================================================= +with modules["UCONV"]: + errors["NS_ERROR_UCONV_NOCONV"] = FAILURE(1) + errors["NS_ERROR_UDEC_ILLEGALINPUT"] = FAILURE(14) + + errors["NS_SUCCESS_USING_FALLBACK_LOCALE"] = SUCCESS(2) + errors["NS_OK_UDEC_EXACTLENGTH"] = SUCCESS(11) + errors["NS_OK_UDEC_MOREINPUT"] = SUCCESS(12) + errors["NS_OK_UDEC_MOREOUTPUT"] = SUCCESS(13) + errors["NS_OK_UDEC_NOBOMFOUND"] = SUCCESS(14) + errors["NS_OK_UENC_EXACTLENGTH"] = SUCCESS(33) + errors["NS_OK_UENC_MOREOUTPUT"] = SUCCESS(34) + errors["NS_ERROR_UENC_NOMAPPING"] = SUCCESS(35) + errors["NS_OK_UENC_MOREINPUT"] = SUCCESS(36) + + # BEGIN DEPRECATED + errors["NS_EXACT_LENGTH"] = errors["NS_OK_UDEC_EXACTLENGTH"] + errors["NS_PARTIAL_MORE_INPUT"] = errors["NS_OK_UDEC_MOREINPUT"] + errors["NS_PARTIAL_MORE_OUTPUT"] = errors["NS_OK_UDEC_MOREOUTPUT"] + errors["NS_ERROR_ILLEGAL_INPUT"] = errors["NS_ERROR_UDEC_ILLEGALINPUT"] + # END DEPRECATED + + + +# ======================================================================= +# 13: NS_ERROR_MODULE_FILES +# ======================================================================= +with modules["FILES"]: + errors["NS_ERROR_FILE_UNRECOGNIZED_PATH"] = FAILURE(1) + errors["NS_ERROR_FILE_UNRESOLVABLE_SYMLINK"] = FAILURE(2) + errors["NS_ERROR_FILE_EXECUTION_FAILED"] = FAILURE(3) + errors["NS_ERROR_FILE_UNKNOWN_TYPE"] = FAILURE(4) + errors["NS_ERROR_FILE_DESTINATION_NOT_DIR"] = FAILURE(5) + errors["NS_ERROR_FILE_TARGET_DOES_NOT_EXIST"] = FAILURE(6) + errors["NS_ERROR_FILE_COPY_OR_MOVE_FAILED"] = FAILURE(7) + errors["NS_ERROR_FILE_ALREADY_EXISTS"] = FAILURE(8) + errors["NS_ERROR_FILE_INVALID_PATH"] = FAILURE(9) + errors["NS_ERROR_FILE_DISK_FULL"] = FAILURE(10) + errors["NS_ERROR_FILE_CORRUPTED"] = FAILURE(11) + errors["NS_ERROR_FILE_NOT_DIRECTORY"] = FAILURE(12) + errors["NS_ERROR_FILE_IS_DIRECTORY"] = FAILURE(13) + errors["NS_ERROR_FILE_IS_LOCKED"] = FAILURE(14) + errors["NS_ERROR_FILE_TOO_BIG"] = FAILURE(15) + errors["NS_ERROR_FILE_NO_DEVICE_SPACE"] = FAILURE(16) + errors["NS_ERROR_FILE_NAME_TOO_LONG"] = FAILURE(17) + errors["NS_ERROR_FILE_NOT_FOUND"] = FAILURE(18) + errors["NS_ERROR_FILE_READ_ONLY"] = FAILURE(19) + errors["NS_ERROR_FILE_DIR_NOT_EMPTY"] = FAILURE(20) + errors["NS_ERROR_FILE_ACCESS_DENIED"] = FAILURE(21) + + errors["NS_SUCCESS_FILE_DIRECTORY_EMPTY"] = SUCCESS(1) + # Result codes used by nsIDirectoryServiceProvider2 + errors["NS_SUCCESS_AGGREGATE_RESULT"] = SUCCESS(2) + + + +# ======================================================================= +# 14: NS_ERROR_MODULE_DOM +# ======================================================================= +with modules["DOM"]: + # XXX If you add a new DOM error code, also add an error string to + # dom/base/domerr.msg + + # Standard DOM error codes: http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html + errors["NS_ERROR_DOM_INDEX_SIZE_ERR"] = FAILURE(1) + errors["NS_ERROR_DOM_HIERARCHY_REQUEST_ERR"] = FAILURE(3) + errors["NS_ERROR_DOM_WRONG_DOCUMENT_ERR"] = FAILURE(4) + errors["NS_ERROR_DOM_INVALID_CHARACTER_ERR"] = FAILURE(5) + errors["NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR"] = FAILURE(7) + errors["NS_ERROR_DOM_NOT_FOUND_ERR"] = FAILURE(8) + errors["NS_ERROR_DOM_NOT_SUPPORTED_ERR"] = FAILURE(9) + errors["NS_ERROR_DOM_INUSE_ATTRIBUTE_ERR"] = FAILURE(10) + errors["NS_ERROR_DOM_INVALID_STATE_ERR"] = FAILURE(11) + errors["NS_ERROR_DOM_SYNTAX_ERR"] = FAILURE(12) + errors["NS_ERROR_DOM_INVALID_MODIFICATION_ERR"] = FAILURE(13) + errors["NS_ERROR_DOM_NAMESPACE_ERR"] = FAILURE(14) + errors["NS_ERROR_DOM_INVALID_ACCESS_ERR"] = FAILURE(15) + errors["NS_ERROR_DOM_TYPE_MISMATCH_ERR"] = FAILURE(17) + errors["NS_ERROR_DOM_SECURITY_ERR"] = FAILURE(18) + errors["NS_ERROR_DOM_NETWORK_ERR"] = FAILURE(19) + errors["NS_ERROR_DOM_ABORT_ERR"] = FAILURE(20) + errors["NS_ERROR_DOM_URL_MISMATCH_ERR"] = FAILURE(21) + errors["NS_ERROR_DOM_QUOTA_EXCEEDED_ERR"] = FAILURE(22) + errors["NS_ERROR_DOM_TIMEOUT_ERR"] = FAILURE(23) + errors["NS_ERROR_DOM_INVALID_NODE_TYPE_ERR"] = FAILURE(24) + errors["NS_ERROR_DOM_DATA_CLONE_ERR"] = FAILURE(25) + # XXX Should be JavaScript native errors + errors["NS_ERROR_TYPE_ERR"] = FAILURE(26) + errors["NS_ERROR_RANGE_ERR"] = FAILURE(27) + # StringEncoding API errors from http://wiki.whatwg.org/wiki/StringEncoding + errors["NS_ERROR_DOM_ENCODING_NOT_SUPPORTED_ERR"] = FAILURE(28) + errors["NS_ERROR_DOM_INVALID_POINTER_ERR"] = FAILURE(29) + # WebCrypto API errors from http://www.w3.org/TR/WebCryptoAPI/ + errors["NS_ERROR_DOM_UNKNOWN_ERR"] = FAILURE(30) + errors["NS_ERROR_DOM_DATA_ERR"] = FAILURE(31) + errors["NS_ERROR_DOM_OPERATION_ERR"] = FAILURE(32) + # https://heycam.github.io/webidl/#notallowederror + errors["NS_ERROR_DOM_NOT_ALLOWED_ERR"] = FAILURE(33) + # DOM error codes defined by us + errors["NS_ERROR_DOM_SECMAN_ERR"] = FAILURE(1001) + errors["NS_ERROR_DOM_WRONG_TYPE_ERR"] = FAILURE(1002) + errors["NS_ERROR_DOM_NOT_OBJECT_ERR"] = FAILURE(1003) + errors["NS_ERROR_DOM_NOT_XPC_OBJECT_ERR"] = FAILURE(1004) + errors["NS_ERROR_DOM_NOT_NUMBER_ERR"] = FAILURE(1005) + errors["NS_ERROR_DOM_NOT_BOOLEAN_ERR"] = FAILURE(1006) + errors["NS_ERROR_DOM_NOT_FUNCTION_ERR"] = FAILURE(1007) + errors["NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR"] = FAILURE(1008) + errors["NS_ERROR_DOM_BAD_DOCUMENT_DOMAIN"] = FAILURE(1009) + errors["NS_ERROR_DOM_PROP_ACCESS_DENIED"] = FAILURE(1010) + errors["NS_ERROR_DOM_XPCONNECT_ACCESS_DENIED"] = FAILURE(1011) + errors["NS_ERROR_DOM_BAD_URI"] = FAILURE(1012) + errors["NS_ERROR_DOM_RETVAL_UNDEFINED"] = FAILURE(1013) + errors["NS_ERROR_DOM_QUOTA_REACHED"] = FAILURE(1014) + + # A way to represent uncatchable exceptions + errors["NS_ERROR_UNCATCHABLE_EXCEPTION"] = FAILURE(1015) + + errors["NS_ERROR_DOM_MALFORMED_URI"] = FAILURE(1016) + errors["NS_ERROR_DOM_INVALID_HEADER_NAME"] = FAILURE(1017) + + errors["NS_ERROR_DOM_INVALID_STATE_XHR_HAS_INVALID_CONTEXT"] = FAILURE(1018) + errors["NS_ERROR_DOM_INVALID_STATE_XHR_MUST_BE_OPENED"] = FAILURE(1019) + errors["NS_ERROR_DOM_INVALID_STATE_XHR_MUST_NOT_BE_SENDING"] = FAILURE(1020) + errors["NS_ERROR_DOM_INVALID_STATE_XHR_MUST_NOT_BE_LOADING_OR_DONE"] = FAILURE(1021) + errors["NS_ERROR_DOM_INVALID_STATE_XHR_HAS_WRONG_RESPONSETYPE_FOR_RESPONSEXML"] = FAILURE(1022) + errors["NS_ERROR_DOM_INVALID_STATE_XHR_HAS_WRONG_RESPONSETYPE_FOR_RESPONSETEXT"] = FAILURE(1023) + errors["NS_ERROR_DOM_INVALID_STATE_XHR_CHUNKED_RESPONSETYPES_UNSUPPORTED_FOR_SYNC"] = FAILURE(1024) + errors["NS_ERROR_DOM_INVALID_ACCESS_XHR_TIMEOUT_AND_RESPONSETYPE_UNSUPPORTED_FOR_SYNC"] = FAILURE(1025) + + # May be used to indicate when e.g. setting a property value didn't + # actually change the value, like for obj.foo = "bar"; obj.foo = "bar"; + # the second assignment throws NS_SUCCESS_DOM_NO_OPERATION. + errors["NS_SUCCESS_DOM_NO_OPERATION"] = SUCCESS(1) + + # A success code that indicates that evaluating a string of JS went + # just fine except it threw an exception. Only for legacy use by + # nsJSUtils. + errors["NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW"] = SUCCESS(2) + + # A success code that indicates that evaluating a string of JS went + # just fine except it was killed by an uncatchable exception. + # Only for legacy use by nsJSUtils. + errors["NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW_UNCATCHABLE"] = SUCCESS(3) + + + +# ======================================================================= +# 15: NS_ERROR_MODULE_IMGLIB +# ======================================================================= +with modules["IMGLIB"]: + errors["NS_IMAGELIB_SUCCESS_LOAD_FINISHED"] = SUCCESS(0) + errors["NS_IMAGELIB_CHANGING_OWNER"] = SUCCESS(1) + + errors["NS_IMAGELIB_ERROR_FAILURE"] = FAILURE(5) + errors["NS_IMAGELIB_ERROR_NO_DECODER"] = FAILURE(6) + errors["NS_IMAGELIB_ERROR_NOT_FINISHED"] = FAILURE(7) + errors["NS_IMAGELIB_ERROR_NO_ENCODER"] = FAILURE(9) + + + +# ======================================================================= +# 17: NS_ERROR_MODULE_EDITOR +# ======================================================================= +with modules["EDITOR"]: + errors["NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND"] = SUCCESS(1) + errors["NS_SUCCESS_EDITOR_FOUND_TARGET"] = SUCCESS(2) + + + +# ======================================================================= +# 18: NS_ERROR_MODULE_XPCONNECT +# ======================================================================= +with modules["XPCONNECT"]: + errors["NS_ERROR_XPC_NOT_ENOUGH_ARGS"] = FAILURE(1) + errors["NS_ERROR_XPC_NEED_OUT_OBJECT"] = FAILURE(2) + errors["NS_ERROR_XPC_CANT_SET_OUT_VAL"] = FAILURE(3) + errors["NS_ERROR_XPC_NATIVE_RETURNED_FAILURE"] = FAILURE(4) + errors["NS_ERROR_XPC_CANT_GET_INTERFACE_INFO"] = FAILURE(5) + errors["NS_ERROR_XPC_CANT_GET_PARAM_IFACE_INFO"] = FAILURE(6) + errors["NS_ERROR_XPC_CANT_GET_METHOD_INFO"] = FAILURE(7) + errors["NS_ERROR_XPC_UNEXPECTED"] = FAILURE(8) + errors["NS_ERROR_XPC_BAD_CONVERT_JS"] = FAILURE(9) + errors["NS_ERROR_XPC_BAD_CONVERT_NATIVE"] = FAILURE(10) + errors["NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF"] = FAILURE(11) + errors["NS_ERROR_XPC_BAD_OP_ON_WN_PROTO"] = FAILURE(12) + errors["NS_ERROR_XPC_CANT_CONVERT_WN_TO_FUN"] = FAILURE(13) + errors["NS_ERROR_XPC_CANT_DEFINE_PROP_ON_WN"] = FAILURE(14) + errors["NS_ERROR_XPC_CANT_WATCH_WN_STATIC"] = FAILURE(15) + errors["NS_ERROR_XPC_CANT_EXPORT_WN_STATIC"] = FAILURE(16) + errors["NS_ERROR_XPC_SCRIPTABLE_CALL_FAILED"] = FAILURE(17) + errors["NS_ERROR_XPC_SCRIPTABLE_CTOR_FAILED"] = FAILURE(18) + errors["NS_ERROR_XPC_CANT_CALL_WO_SCRIPTABLE"] = FAILURE(19) + errors["NS_ERROR_XPC_CANT_CTOR_WO_SCRIPTABLE"] = FAILURE(20) + errors["NS_ERROR_XPC_CI_RETURNED_FAILURE"] = FAILURE(21) + errors["NS_ERROR_XPC_GS_RETURNED_FAILURE"] = FAILURE(22) + errors["NS_ERROR_XPC_BAD_CID"] = FAILURE(23) + errors["NS_ERROR_XPC_BAD_IID"] = FAILURE(24) + errors["NS_ERROR_XPC_CANT_CREATE_WN"] = FAILURE(25) + errors["NS_ERROR_XPC_JS_THREW_EXCEPTION"] = FAILURE(26) + errors["NS_ERROR_XPC_JS_THREW_NATIVE_OBJECT"] = FAILURE(27) + errors["NS_ERROR_XPC_JS_THREW_JS_OBJECT"] = FAILURE(28) + errors["NS_ERROR_XPC_JS_THREW_NULL"] = FAILURE(29) + errors["NS_ERROR_XPC_JS_THREW_STRING"] = FAILURE(30) + errors["NS_ERROR_XPC_JS_THREW_NUMBER"] = FAILURE(31) + errors["NS_ERROR_XPC_JAVASCRIPT_ERROR"] = FAILURE(32) + errors["NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS"] = FAILURE(33) + errors["NS_ERROR_XPC_CANT_CONVERT_PRIMITIVE_TO_ARRAY"] = FAILURE(34) + errors["NS_ERROR_XPC_CANT_CONVERT_OBJECT_TO_ARRAY"] = FAILURE(35) + errors["NS_ERROR_XPC_NOT_ENOUGH_ELEMENTS_IN_ARRAY"] = FAILURE(36) + errors["NS_ERROR_XPC_CANT_GET_ARRAY_INFO"] = FAILURE(37) + errors["NS_ERROR_XPC_NOT_ENOUGH_CHARS_IN_STRING"] = FAILURE(38) + errors["NS_ERROR_XPC_SECURITY_MANAGER_VETO"] = FAILURE(39) + errors["NS_ERROR_XPC_INTERFACE_NOT_SCRIPTABLE"] = FAILURE(40) + errors["NS_ERROR_XPC_INTERFACE_NOT_FROM_NSISUPPORTS"] = FAILURE(41) + errors["NS_ERROR_XPC_CANT_GET_JSOBJECT_OF_DOM_OBJECT"] = FAILURE(42) + errors["NS_ERROR_XPC_CANT_SET_READ_ONLY_CONSTANT"] = FAILURE(43) + errors["NS_ERROR_XPC_CANT_SET_READ_ONLY_ATTRIBUTE"] = FAILURE(44) + errors["NS_ERROR_XPC_CANT_SET_READ_ONLY_METHOD"] = FAILURE(45) + errors["NS_ERROR_XPC_CANT_ADD_PROP_TO_WRAPPED_NATIVE"] = FAILURE(46) + errors["NS_ERROR_XPC_CALL_TO_SCRIPTABLE_FAILED"] = FAILURE(47) + errors["NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED"] = FAILURE(48) + errors["NS_ERROR_XPC_BAD_ID_STRING"] = FAILURE(49) + errors["NS_ERROR_XPC_BAD_INITIALIZER_NAME"] = FAILURE(50) + errors["NS_ERROR_XPC_HAS_BEEN_SHUTDOWN"] = FAILURE(51) + errors["NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN"] = FAILURE(52) + errors["NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL"] = FAILURE(53) + errors["NS_ERROR_XPC_CANT_PASS_CPOW_TO_NATIVE"] = FAILURE(54) + # any new errors here should have an associated entry added in xpc.msg + + + +# ======================================================================= +# 19: NS_ERROR_MODULE_PROFILE +# ======================================================================= +with modules["PROFILE"]: + errors["NS_ERROR_LAUNCHED_CHILD_PROCESS"] = FAILURE(200) + + + +# ======================================================================= +# 21: NS_ERROR_MODULE_SECURITY +# ======================================================================= +with modules["SECURITY"]: + # Error code for CSP + errors["NS_ERROR_CSP_FORM_ACTION_VIOLATION"] = FAILURE(98) + errors["NS_ERROR_CSP_FRAME_ANCESTOR_VIOLATION"] = FAILURE(99) + + # Error code for Sub-Resource Integrity + errors["NS_ERROR_SRI_CORRUPT"] = FAILURE(200) + errors["NS_ERROR_SRI_DISABLED"] = FAILURE(201) + errors["NS_ERROR_SRI_NOT_ELIGIBLE"] = FAILURE(202) + errors["NS_ERROR_SRI_UNEXPECTED_HASH_TYPE"] = FAILURE(203) + errors["NS_ERROR_SRI_IMPORT"] = FAILURE(204) + + # CMS specific nsresult error codes. Note: the numbers used here correspond + # to the values in nsICMSMessageErrors.idl. + errors["NS_ERROR_CMS_VERIFY_NOT_SIGNED"] = FAILURE(1024) + errors["NS_ERROR_CMS_VERIFY_NO_CONTENT_INFO"] = FAILURE(1025) + errors["NS_ERROR_CMS_VERIFY_BAD_DIGEST"] = FAILURE(1026) + errors["NS_ERROR_CMS_VERIFY_NOCERT"] = FAILURE(1028) + errors["NS_ERROR_CMS_VERIFY_UNTRUSTED"] = FAILURE(1029) + errors["NS_ERROR_CMS_VERIFY_ERROR_UNVERIFIED"] = FAILURE(1031) + errors["NS_ERROR_CMS_VERIFY_ERROR_PROCESSING"] = FAILURE(1032) + errors["NS_ERROR_CMS_VERIFY_BAD_SIGNATURE"] = FAILURE(1033) + errors["NS_ERROR_CMS_VERIFY_DIGEST_MISMATCH"] = FAILURE(1034) + errors["NS_ERROR_CMS_VERIFY_UNKNOWN_ALGO"] = FAILURE(1035) + errors["NS_ERROR_CMS_VERIFY_UNSUPPORTED_ALGO"] = FAILURE(1036) + errors["NS_ERROR_CMS_VERIFY_MALFORMED_SIGNATURE"] = FAILURE(1037) + errors["NS_ERROR_CMS_VERIFY_HEADER_MISMATCH"] = FAILURE(1038) + errors["NS_ERROR_CMS_VERIFY_NOT_YET_ATTEMPTED"] = FAILURE(1039) + errors["NS_ERROR_CMS_VERIFY_CERT_WITHOUT_ADDRESS"] = FAILURE(1040) + errors["NS_ERROR_CMS_ENCRYPT_NO_BULK_ALG"] = FAILURE(1056) + errors["NS_ERROR_CMS_ENCRYPT_INCOMPLETE"] = FAILURE(1057) + + + +# ======================================================================= +# 22: NS_ERROR_MODULE_DOM_XPATH +# ======================================================================= +with modules["DOM_XPATH"]: + # DOM error codes from http://www.w3.org/TR/DOM-Level-3-XPath/ + errors["NS_ERROR_DOM_INVALID_EXPRESSION_ERR"] = FAILURE(51) + errors["NS_ERROR_DOM_TYPE_ERR"] = FAILURE(52) + + + +# ======================================================================= +# 24: NS_ERROR_MODULE_URILOADER +# ======================================================================= +with modules["URILOADER"]: + errors["NS_ERROR_WONT_HANDLE_CONTENT"] = FAILURE(1) + # The load has been cancelled because it was found on a malware or phishing + # blacklist. + errors["NS_ERROR_MALWARE_URI"] = FAILURE(30) + errors["NS_ERROR_PHISHING_URI"] = FAILURE(31) + errors["NS_ERROR_TRACKING_URI"] = FAILURE(34) + errors["NS_ERROR_UNWANTED_URI"] = FAILURE(35) + errors["NS_ERROR_BLOCKED_URI"] = FAILURE(37) + # Used when "Save Link As..." doesn't see the headers quickly enough to + # choose a filename. See nsContextMenu.js. + errors["NS_ERROR_SAVE_LINK_AS_TIMEOUT"] = FAILURE(32) + # Used when the data from a channel has already been parsed and cached so it + # doesn't need to be reparsed from the original source. + errors["NS_ERROR_PARSED_DATA_CACHED"] = FAILURE(33) + + # This success code indicates that a refresh header was found and + # successfully setup. + errors["NS_REFRESHURI_HEADER_FOUND"] = SUCCESS(2) + + + +# ======================================================================= +# 25: NS_ERROR_MODULE_CONTENT +# ======================================================================= +with modules["CONTENT"]: + # Error codes for image loading + errors["NS_ERROR_IMAGE_SRC_CHANGED"] = FAILURE(4) + errors["NS_ERROR_IMAGE_BLOCKED"] = FAILURE(5) + # Error codes for content policy blocking + errors["NS_ERROR_CONTENT_BLOCKED"] = FAILURE(6) + errors["NS_ERROR_CONTENT_BLOCKED_SHOW_ALT"] = FAILURE(7) + # Success variations of content policy blocking + errors["NS_PROPTABLE_PROP_NOT_THERE"] = FAILURE(10) + # Error code for XBL + errors["NS_ERROR_XBL_BLOCKED"] = FAILURE(15) + # Error code for when the content process crashed + errors["NS_ERROR_CONTENT_CRASHED"] = FAILURE(16) + + # XXX this is not really used + errors["NS_HTML_STYLE_PROPERTY_NOT_THERE"] = SUCCESS(2) + errors["NS_CONTENT_BLOCKED"] = SUCCESS(8) + errors["NS_CONTENT_BLOCKED_SHOW_ALT"] = SUCCESS(9) + errors["NS_PROPTABLE_PROP_OVERWRITTEN"] = SUCCESS(11) + # Error codes for FindBroadcaster in XULDocument.cpp + errors["NS_FINDBROADCASTER_NOT_FOUND"] = SUCCESS(12) + errors["NS_FINDBROADCASTER_FOUND"] = SUCCESS(13) + errors["NS_FINDBROADCASTER_AWAIT_OVERLAYS"] = SUCCESS(14) + + + +# ======================================================================= +# 27: NS_ERROR_MODULE_XSLT +# ======================================================================= +with modules["XSLT"]: + errors["NS_ERROR_XPATH_INVALID_ARG"] = errors["NS_ERROR_INVALID_ARG"] + + errors["NS_ERROR_XSLT_PARSE_FAILURE"] = FAILURE(1) + errors["NS_ERROR_XPATH_PARSE_FAILURE"] = FAILURE(2) + errors["NS_ERROR_XSLT_ALREADY_SET"] = FAILURE(3) + errors["NS_ERROR_XSLT_EXECUTION_FAILURE"] = FAILURE(4) + errors["NS_ERROR_XPATH_UNKNOWN_FUNCTION"] = FAILURE(5) + errors["NS_ERROR_XSLT_BAD_RECURSION"] = FAILURE(6) + errors["NS_ERROR_XSLT_BAD_VALUE"] = FAILURE(7) + errors["NS_ERROR_XSLT_NODESET_EXPECTED"] = FAILURE(8) + errors["NS_ERROR_XSLT_ABORTED"] = FAILURE(9) + errors["NS_ERROR_XSLT_NETWORK_ERROR"] = FAILURE(10) + errors["NS_ERROR_XSLT_WRONG_MIME_TYPE"] = FAILURE(11) + errors["NS_ERROR_XSLT_LOAD_RECURSION"] = FAILURE(12) + errors["NS_ERROR_XPATH_BAD_ARGUMENT_COUNT"] = FAILURE(13) + errors["NS_ERROR_XPATH_BAD_EXTENSION_FUNCTION"] = FAILURE(14) + errors["NS_ERROR_XPATH_PAREN_EXPECTED"] = FAILURE(15) + errors["NS_ERROR_XPATH_INVALID_AXIS"] = FAILURE(16) + errors["NS_ERROR_XPATH_NO_NODE_TYPE_TEST"] = FAILURE(17) + errors["NS_ERROR_XPATH_BRACKET_EXPECTED"] = FAILURE(18) + errors["NS_ERROR_XPATH_INVALID_VAR_NAME"] = FAILURE(19) + errors["NS_ERROR_XPATH_UNEXPECTED_END"] = FAILURE(20) + errors["NS_ERROR_XPATH_OPERATOR_EXPECTED"] = FAILURE(21) + errors["NS_ERROR_XPATH_UNCLOSED_LITERAL"] = FAILURE(22) + errors["NS_ERROR_XPATH_BAD_COLON"] = FAILURE(23) + errors["NS_ERROR_XPATH_BAD_BANG"] = FAILURE(24) + errors["NS_ERROR_XPATH_ILLEGAL_CHAR"] = FAILURE(25) + errors["NS_ERROR_XPATH_BINARY_EXPECTED"] = FAILURE(26) + errors["NS_ERROR_XSLT_LOAD_BLOCKED_ERROR"] = FAILURE(27) + errors["NS_ERROR_XPATH_INVALID_EXPRESSION_EVALUATED"] = FAILURE(28) + errors["NS_ERROR_XPATH_UNBALANCED_CURLY_BRACE"] = FAILURE(29) + errors["NS_ERROR_XSLT_BAD_NODE_NAME"] = FAILURE(30) + errors["NS_ERROR_XSLT_VAR_ALREADY_SET"] = FAILURE(31) + errors["NS_ERROR_XSLT_CALL_TO_KEY_NOT_ALLOWED"] = FAILURE(32) + + errors["NS_XSLT_GET_NEW_HANDLER"] = SUCCESS(1) + + + +# ======================================================================= +# 28: NS_ERROR_MODULE_IPC +# ======================================================================= +with modules["IPC"]: + # Initial creation of a Transport object failed internally for unknown reasons. + errors["NS_ERROR_TRANSPORT_INIT"] = FAILURE(1) + # Generic error related to duplicating handle failures. + errors["NS_ERROR_DUPLICATE_HANDLE"] = FAILURE(2) + # Bridging: failure trying to open the connection to the parent + errors["NS_ERROR_BRIDGE_OPEN_PARENT"] = FAILURE(3) + # Bridging: failure trying to open the connection to the child + errors["NS_ERROR_BRIDGE_OPEN_CHILD"] = FAILURE(4) + + +# ======================================================================= +# 29: NS_ERROR_MODULE_SVG +# ======================================================================= +with modules["SVG"]: + # SVG DOM error codes from http://www.w3.org/TR/SVG11/svgdom.html + errors["NS_ERROR_DOM_SVG_WRONG_TYPE_ERR"] = FAILURE(0) + # Yes, the spec says "INVERTABLE", not "INVERTIBLE" + errors["NS_ERROR_DOM_SVG_MATRIX_NOT_INVERTABLE"] = FAILURE(2) + + + +# ======================================================================= +# 30: NS_ERROR_MODULE_STORAGE +# ======================================================================= +with modules["STORAGE"]: + # To add additional errors to Storage, please append entries to the bottom + # of the list in the following format: + # NS_ERROR_STORAGE_YOUR_ERR, FAILURE(n) + # where n is the next unique positive integer. You must also add an entry + # to js/xpconnect/src/xpc.msg under the code block beginning with the + # comment 'storage related codes (from mozStorage.h)', in the following + # format: 'XPC_MSG_DEF(NS_ERROR_STORAGE_YOUR_ERR, "brief description of your + # error")' + errors["NS_ERROR_STORAGE_BUSY"] = FAILURE(1) + errors["NS_ERROR_STORAGE_IOERR"] = FAILURE(2) + errors["NS_ERROR_STORAGE_CONSTRAINT"] = FAILURE(3) + + + +# ======================================================================= +# 32: NS_ERROR_MODULE_DOM_FILE +# ======================================================================= +with modules["DOM_FILE"]: + errors["NS_ERROR_DOM_FILE_NOT_FOUND_ERR"] = FAILURE(0) + errors["NS_ERROR_DOM_FILE_NOT_READABLE_ERR"] = FAILURE(1) + errors["NS_ERROR_DOM_FILE_ABORT_ERR"] = FAILURE(2) + + + +# ======================================================================= +# 33: NS_ERROR_MODULE_DOM_INDEXEDDB +# ======================================================================= +with modules["DOM_INDEXEDDB"]: + # IndexedDB error codes http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html + errors["NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR"] = FAILURE(1) + errors["NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR"] = FAILURE(3) + errors["NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR"] = FAILURE(4) + errors["NS_ERROR_DOM_INDEXEDDB_DATA_ERR"] = FAILURE(5) + errors["NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR"] = FAILURE(6) + errors["NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR"] = FAILURE(7) + errors["NS_ERROR_DOM_INDEXEDDB_ABORT_ERR"] = FAILURE(8) + errors["NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR"] = FAILURE(9) + errors["NS_ERROR_DOM_INDEXEDDB_TIMEOUT_ERR"] = FAILURE(10) + errors["NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR"] = FAILURE(11) + errors["NS_ERROR_DOM_INDEXEDDB_VERSION_ERR"] = FAILURE(12) + errors["NS_ERROR_DOM_INDEXEDDB_RECOVERABLE_ERR"] = FAILURE(1001) + + + +# ======================================================================= +# 34: NS_ERROR_MODULE_DOM_FILEHANDLE +# ======================================================================= +with modules["DOM_FILEHANDLE"]: + errors["NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR"] = FAILURE(1) + errors["NS_ERROR_DOM_FILEHANDLE_NOT_ALLOWED_ERR"] = FAILURE(2) + errors["NS_ERROR_DOM_FILEHANDLE_INACTIVE_ERR"] = FAILURE(3) + errors["NS_ERROR_DOM_FILEHANDLE_ABORT_ERR"] = FAILURE(4) + errors["NS_ERROR_DOM_FILEHANDLE_READ_ONLY_ERR"] = FAILURE(5) + errors["NS_ERROR_DOM_FILEHANDLE_QUOTA_ERR"] = FAILURE(6) + + +# ======================================================================= +# 35: NS_ERROR_MODULE_SIGNED_JAR +# ======================================================================= +with modules["SIGNED_JAR"]: + errors["NS_ERROR_SIGNED_JAR_NOT_SIGNED"] = FAILURE(1) + errors["NS_ERROR_SIGNED_JAR_MODIFIED_ENTRY"] = FAILURE(2) + errors["NS_ERROR_SIGNED_JAR_UNSIGNED_ENTRY"] = FAILURE(3) + errors["NS_ERROR_SIGNED_JAR_ENTRY_MISSING"] = FAILURE(4) + errors["NS_ERROR_SIGNED_JAR_WRONG_SIGNATURE"] = FAILURE(5) + errors["NS_ERROR_SIGNED_JAR_ENTRY_TOO_LARGE"] = FAILURE(6) + errors["NS_ERROR_SIGNED_JAR_ENTRY_INVALID"] = FAILURE(7) + errors["NS_ERROR_SIGNED_JAR_MANIFEST_INVALID"] = FAILURE(8) + + +# ======================================================================= +# 36: NS_ERROR_MODULE_DOM_FILESYSTEM +# ======================================================================= +with modules["DOM_FILESYSTEM"]: + errors["NS_ERROR_DOM_FILESYSTEM_INVALID_PATH_ERR"] = FAILURE(1) + errors["NS_ERROR_DOM_FILESYSTEM_INVALID_MODIFICATION_ERR"] = FAILURE(2) + errors["NS_ERROR_DOM_FILESYSTEM_NO_MODIFICATION_ALLOWED_ERR"] = FAILURE(3) + errors["NS_ERROR_DOM_FILESYSTEM_PATH_EXISTS_ERR"] = FAILURE(4) + errors["NS_ERROR_DOM_FILESYSTEM_TYPE_MISMATCH_ERR"] = FAILURE(5) + errors["NS_ERROR_DOM_FILESYSTEM_UNKNOWN_ERR"] = FAILURE(6) + + +# ======================================================================= +# 38: NS_ERROR_MODULE_SIGNED_APP +# ======================================================================= +with modules["SIGNED_APP"]: + errors["NS_ERROR_SIGNED_APP_MANIFEST_INVALID"] = FAILURE(1) + + +# ======================================================================= +# 39: NS_ERROR_MODULE_DOM_ANIM +# ======================================================================= +with modules["DOM_ANIM"]: + errors["NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR"] = FAILURE(1) + + +# ======================================================================= +# 40: NS_ERROR_MODULE_DOM_PUSH +# ======================================================================= +with modules["DOM_PUSH"]: + errors["NS_ERROR_DOM_PUSH_INVALID_REGISTRATION_ERR"] = FAILURE(1) + errors["NS_ERROR_DOM_PUSH_DENIED_ERR"] = FAILURE(2) + errors["NS_ERROR_DOM_PUSH_ABORT_ERR"] = FAILURE(3) + errors["NS_ERROR_DOM_PUSH_SERVICE_UNREACHABLE"] = FAILURE(4) + errors["NS_ERROR_DOM_PUSH_INVALID_KEY_ERR"] = FAILURE(5) + errors["NS_ERROR_DOM_PUSH_MISMATCHED_KEY_ERR"] = FAILURE(6) + + +# ======================================================================= +# 41: NS_ERROR_MODULE_DOM_MEDIA +# ======================================================================= +with modules["DOM_MEDIA"]: + # HTMLMediaElement API errors from https://html.spec.whatwg.org/multipage/embedded-content.html#media-elements + errors["NS_ERROR_DOM_MEDIA_ABORT_ERR"] = FAILURE(1) + errors["NS_ERROR_DOM_MEDIA_NOT_ALLOWED_ERR"] = FAILURE(2) + errors["NS_ERROR_DOM_MEDIA_NOT_SUPPORTED_ERR"] = FAILURE(3) + + # HTMLMediaElement internal decoding error + errors["NS_ERROR_DOM_MEDIA_DECODE_ERR"] = FAILURE(4) + errors["NS_ERROR_DOM_MEDIA_FATAL_ERR"] = FAILURE(5) + errors["NS_ERROR_DOM_MEDIA_METADATA_ERR"] = FAILURE(6) + errors["NS_ERROR_DOM_MEDIA_OVERFLOW_ERR"] = FAILURE(7) + errors["NS_ERROR_DOM_MEDIA_END_OF_STREAM"] = FAILURE(8) + errors["NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA"] = FAILURE(9) + errors["NS_ERROR_DOM_MEDIA_CANCELED"] = FAILURE(10) + errors["NS_ERROR_DOM_MEDIA_MEDIASINK_ERR"] = FAILURE(11) + errors["NS_ERROR_DOM_MEDIA_DEMUXER_ERR"] = FAILURE(12) + errors["NS_ERROR_DOM_MEDIA_CDM_ERR"] = FAILURE(13) + errors["NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER"] = FAILURE(14) + errors["NS_ERROR_DOM_MEDIA_INITIALIZING_DECODER"] = FAILURE(15) + + # Internal platform-related errors + errors["NS_ERROR_DOM_MEDIA_CUBEB_INITIALIZATION_ERR"] = FAILURE(101) + + +# ======================================================================= +# 42: NS_ERROR_MODULE_URL_CLASSIFIER +# ======================================================================= +with modules["URL_CLASSIFIER"]: + errors["NS_ERROR_UC_UPDATE_UNKNOWN"] = FAILURE(1) + errors["NS_ERROR_UC_UPDATE_DUPLICATE_PREFIX"] = FAILURE(2) + errors["NS_ERROR_UC_UPDATE_INFINITE_LOOP"] = FAILURE(3) + errors["NS_ERROR_UC_UPDATE_WRONG_REMOVAL_INDICES"] = FAILURE(4) + errors["NS_ERROR_UC_UPDATE_CHECKSUM_MISMATCH"] = FAILURE(5) + errors["NS_ERROR_UC_UPDATE_MISSING_CHECKSUM"] = FAILURE(6) + errors["NS_ERROR_UC_UPDATE_SHUTDOWNING"] = FAILURE(7) + errors["NS_ERROR_UC_UPDATE_TABLE_NOT_FOUND"] = FAILURE(8) + errors["NS_ERROR_UC_UPDATE_BUILD_PREFIX_FAILURE"] = FAILURE(9) + errors["NS_ERROR_UC_UPDATE_FAIL_TO_WRITE_DISK"] = FAILURE(10) + errors["NS_ERROR_UC_UPDATE_PROTOCOL_PARSER_ERROR"] = FAILURE(11) + + +# ======================================================================= +# 43: NS_ERROR_MODULE_ERRORRESULT +# ======================================================================= +with modules["ERRORRESULT"]: + # Represents a JS Value being thrown as an exception. + errors["NS_ERROR_INTERNAL_ERRORRESULT_JS_EXCEPTION"] = FAILURE(1) + # Used to indicate that we want to throw a DOMException. + errors["NS_ERROR_INTERNAL_ERRORRESULT_DOMEXCEPTION"] = FAILURE(2) + # Used to indicate that an exception is already pending on the JSContext. + errors["NS_ERROR_INTERNAL_ERRORRESULT_EXCEPTION_ON_JSCONTEXT"] = FAILURE(3) + # Used to indicate that we want to throw a TypeError. + errors["NS_ERROR_INTERNAL_ERRORRESULT_TYPEERROR"] = FAILURE(4) + # Used to indicate that we want to throw a RangeError. + errors["NS_ERROR_INTERNAL_ERRORRESULT_RANGEERROR"] = FAILURE(5) + + +# ======================================================================= +# 51: NS_ERROR_MODULE_GENERAL +# ======================================================================= +with modules["GENERAL"]: + # Error code used internally by the incremental downloader to cancel the + # network channel when the download is already complete. + errors["NS_ERROR_DOWNLOAD_COMPLETE"] = FAILURE(1) + # Error code used internally by the incremental downloader to cancel the + # network channel when the response to a range request is 200 instead of + # 206. + errors["NS_ERROR_DOWNLOAD_NOT_PARTIAL"] = FAILURE(2) + errors["NS_ERROR_UNORM_MOREOUTPUT"] = FAILURE(33) + + errors["NS_ERROR_DOCSHELL_REQUEST_REJECTED"] = FAILURE(1001) + # This is needed for displaying an error message when navigation is + # attempted on a document when printing The value arbitrary as long as it + # doesn't conflict with any of the other values in the errors in + # DisplayLoadError + errors["NS_ERROR_DOCUMENT_IS_PRINTMODE"] = FAILURE(2001) + + errors["NS_SUCCESS_DONT_FIXUP"] = SUCCESS(1) + # This success code may be returned by nsIAppStartup::Run to indicate that + # the application should be restarted. This condition corresponds to the + # case in which nsIAppStartup::Quit was called with the eRestart flag. + errors["NS_SUCCESS_RESTART_APP"] = SUCCESS(1) + errors["NS_SUCCESS_RESTART_APP_NOT_SAME_PROFILE"] = SUCCESS(3) + errors["NS_SUCCESS_UNORM_NOTFOUND"] = SUCCESS(17) + + + # a11y + # raised when current pivot's position is needed but it's not in the tree + errors["NS_ERROR_NOT_IN_TREE"] = FAILURE(38) + + # see nsTextEquivUtils + errors["NS_OK_NO_NAME_CLAUSE_HANDLED"] = SUCCESS(34) + + +# ============================================================================ +# Write out the resulting module declarations to C++ and rust files +# ============================================================================ + +def error_list_h(output): + output.write(""" +/* THIS FILE IS GENERATED BY ErrorList.py - DO NOT EDIT */ + +#ifndef ErrorList_h__ +#define ErrorList_h__ + +""") + + output.write("#define NS_ERROR_MODULE_BASE_OFFSET {}\n".format(MODULE_BASE_OFFSET)) + + for mod, val in modules.iteritems(): + output.write("#define NS_ERROR_MODULE_{} {}\n".format(mod, val.num)) + + items = [] + for error, val in errors.iteritems(): + items.append(" {} = 0x{:X}".format(error, val)) + output.write(""" +enum class nsresult : uint32_t +{{ +{} +}}; + +""".format(",\n".join(items))) + + items = [] + for error, val in errors.iteritems(): + items.append(" {0} = nsresult::{0}".format(error)) + + output.write(""" +const nsresult +{} +; + +#endif // ErrorList_h__ +""".format(",\n".join(items))) + +def error_names_internal_h(output): + """Generate ErrorNamesInternal.h, which is a header file declaring one + function, const char* GetErrorNameInternal(nsresult). This method is not + intended to be used by consumer code, which should instead call + GetErrorName in ErrorNames.h.""" + + output.write(""" +/* THIS FILE IS GENERATED BY ErrorList.py - DO NOT EDIT */ + +#ifndef ErrorNamesInternal_h__ +#define ErrorNamesInternal_h__ + +#include "ErrorNames.h" + +namespace { + +const char* +GetErrorNameInternal(nsresult rv) +{ + switch (rv) { +""") + + # NOTE: Making sure we don't write out duplicate values is important as + # we're using a switch statement to implement this. + seen = set() + for error, val in errors.iteritems(): + if val not in seen: + output.write(' case nsresult::{0}: return "{0}";\n'.format(error)) + seen.add(val) + + output.write(""" + default: return nullptr; + } +} // GetErrorNameInternal + +} // namespace + +#endif // ErrorNamesInternal_h__ +""") diff --git a/xpcom/base/ErrorNames.cpp b/xpcom/base/ErrorNames.cpp index 165a1a0fc3a7..d58a3e0d8318 100644 --- a/xpcom/base/ErrorNames.cpp +++ b/xpcom/base/ErrorNames.cpp @@ -9,35 +9,17 @@ #include "nsString.h" #include "prerror.h" -namespace { - -struct ErrorEntry -{ - nsresult value; - const char * name; -}; - -#undef ERROR -#define ERROR(key, val) {key, #key} - -const ErrorEntry errors[] = { - #include "ErrorList.h" -}; - -#undef ERROR - -} // unnamed namespace +// Get the GetErrorNameInternal method +#include "ErrorNamesInternal.h" namespace mozilla { void GetErrorName(nsresult rv, nsACString& name) { - for (size_t i = 0; i < ArrayLength(errors); ++i) { - if (errors[i].value == rv) { - name.AssignASCII(errors[i].name); - return; - } + if (const char* errorName = GetErrorNameInternal(rv)) { + name.AssignASCII(errorName); + return; } bool isSecurityError = NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_SECURITY; @@ -82,3 +64,15 @@ GetErrorName(nsresult rv, nsACString& name) } } // namespace mozilla + +extern "C" { + +// This is an extern "C" binding for the GetErrorName method which is used by +// the nsresult rust bindings in xpcom/rust/nserror. +void +Gecko_GetErrorName(nsresult aRv, nsACString& aName) +{ + GetErrorName(aRv, aName); +} + +} diff --git a/xpcom/base/moz.build b/xpcom/base/moz.build index f48170793f2e..8155a409a05c 100644 --- a/xpcom/base/moz.build +++ b/xpcom/base/moz.build @@ -43,8 +43,9 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': XPIDL_MODULE = 'xpcom_base' EXPORTS += [ + '!ErrorList.h', + '!ErrorNamesInternal.h', 'CodeAddressService.h', - 'ErrorList.h', 'nsAgg.h', 'nsAlgorithm.h', 'nsAutoPtr.h', @@ -165,6 +166,14 @@ UNIFIED_SOURCES += [ 'nsWeakReference.cpp', ] +GENERATED_FILES += [ + "ErrorList.h", + "ErrorNamesInternal.h" +] + +GENERATED_FILES["ErrorList.h"].script = "ErrorList.py:error_list_h" +GENERATED_FILES["ErrorNamesInternal.h"].script = "ErrorList.py:error_names_internal_h" + if CONFIG['OS_ARCH'] == 'Linux': SOURCES += [ 'LinuxUtils.cpp', diff --git a/xpcom/base/nsError.h b/xpcom/base/nsError.h index 2db39ed0853e..5b8f1c06f543 100644 --- a/xpcom/base/nsError.h +++ b/xpcom/base/nsError.h @@ -16,135 +16,10 @@ #include -/* - * To add error code to your module, you need to do the following: - * - * 1) Add a module offset code. Add yours to the bottom of the list - * right below this comment, adding 1. - * - * 2) In your module, define a header file which uses one of the - * NE_ERROR_GENERATExxxxxx macros. Some examples below: - * - * #define NS_ERROR_MYMODULE_MYERROR1 NS_ERROR_GENERATE(NS_ERROR_SEVERITY_ERROR,NS_ERROR_MODULE_MYMODULE,1) - * #define NS_ERROR_MYMODULE_MYERROR2 NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_MYMODULE,2) - * #define NS_ERROR_MYMODULE_MYERROR3 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_MYMODULE,3) - * - */ - - -/** - * @name Standard Module Offset Code. Each Module should identify a unique number - * and then all errors associated with that module become offsets from the - * base associated with that module id. There are 16 bits of code bits for - * each module. - */ - -#define NS_ERROR_MODULE_XPCOM 1 -#define NS_ERROR_MODULE_BASE 2 -#define NS_ERROR_MODULE_GFX 3 -#define NS_ERROR_MODULE_WIDGET 4 -#define NS_ERROR_MODULE_CALENDAR 5 -#define NS_ERROR_MODULE_NETWORK 6 -#define NS_ERROR_MODULE_PLUGINS 7 -#define NS_ERROR_MODULE_LAYOUT 8 -#define NS_ERROR_MODULE_HTMLPARSER 9 -#define NS_ERROR_MODULE_RDF 10 -#define NS_ERROR_MODULE_UCONV 11 -#define NS_ERROR_MODULE_REG 12 -#define NS_ERROR_MODULE_FILES 13 -#define NS_ERROR_MODULE_DOM 14 -#define NS_ERROR_MODULE_IMGLIB 15 -#define NS_ERROR_MODULE_MAILNEWS 16 -#define NS_ERROR_MODULE_EDITOR 17 -#define NS_ERROR_MODULE_XPCONNECT 18 -#define NS_ERROR_MODULE_PROFILE 19 -#define NS_ERROR_MODULE_LDAP 20 -#define NS_ERROR_MODULE_SECURITY 21 -#define NS_ERROR_MODULE_DOM_XPATH 22 -/* 23 used to be NS_ERROR_MODULE_DOM_RANGE (see bug 711047) */ -#define NS_ERROR_MODULE_URILOADER 24 -#define NS_ERROR_MODULE_CONTENT 25 -#define NS_ERROR_MODULE_PYXPCOM 26 -#define NS_ERROR_MODULE_XSLT 27 -#define NS_ERROR_MODULE_IPC 28 -#define NS_ERROR_MODULE_SVG 29 -#define NS_ERROR_MODULE_STORAGE 30 -#define NS_ERROR_MODULE_SCHEMA 31 -#define NS_ERROR_MODULE_DOM_FILE 32 -#define NS_ERROR_MODULE_DOM_INDEXEDDB 33 -#define NS_ERROR_MODULE_DOM_FILEHANDLE 34 -#define NS_ERROR_MODULE_SIGNED_JAR 35 -#define NS_ERROR_MODULE_DOM_FILESYSTEM 36 -#define NS_ERROR_MODULE_DOM_BLUETOOTH 37 -#define NS_ERROR_MODULE_SIGNED_APP 38 -#define NS_ERROR_MODULE_DOM_ANIM 39 -#define NS_ERROR_MODULE_DOM_PUSH 40 -#define NS_ERROR_MODULE_DOM_MEDIA 41 -#define NS_ERROR_MODULE_URL_CLASSIFIER 42 -/* ErrorResult gets its own module to reduce the chance of someone accidentally - defining an error code matching one of the ErrorResult ones. */ -#define NS_ERROR_MODULE_ERRORRESULT 43 - -/* NS_ERROR_MODULE_GENERAL should be used by modules that do not - * care if return code values overlap. Callers of methods that - * return such codes should be aware that they are not - * globally unique. Implementors should be careful about blindly - * returning codes from other modules that might also use - * the generic base. - */ -#define NS_ERROR_MODULE_GENERAL 51 - -/** - * @name Severity Code. This flag identifies the level of warning - */ - #define NS_ERROR_SEVERITY_SUCCESS 0 #define NS_ERROR_SEVERITY_ERROR 1 -/** - * @name Mozilla Code. This flag separates consumers of mozilla code - * from the native platform - */ - -#define NS_ERROR_MODULE_BASE_OFFSET 0x45 - -/* Helpers for defining our enum, to be undef'd later */ -#define SUCCESS_OR_FAILURE(sev, module, code) \ - ((uint32_t)(sev) << 31) | \ - ((uint32_t)(module + NS_ERROR_MODULE_BASE_OFFSET) << 16) | \ - (uint32_t)(code) -#define SUCCESS(code) \ - SUCCESS_OR_FAILURE(NS_ERROR_SEVERITY_SUCCESS, MODULE, code) -#define FAILURE(code) \ - SUCCESS_OR_FAILURE(NS_ERROR_SEVERITY_ERROR, MODULE, code) - -/** - * @name Standard return values - */ - -/*@{*/ - -enum class nsresult : uint32_t -{ - #undef ERROR - #define ERROR(key, val) key = val - #include "ErrorList.h" - #undef ERROR -}; - -/* - * enum classes don't place their initializers in the global scope, so we need - * constants for compatibility with old code. - */ -const nsresult - #define ERROR(key, val) key = nsresult::key - #include "ErrorList.h" - #undef ERROR -; - -#undef SUCCESS_OR_FAILURE -#undef SUCCESS -#undef FAILURE +#include "ErrorList.h" /** * @name Standard Error Handling Macros From df411f4313f18f76979a9e737f89a0f41fac7bfe Mon Sep 17 00:00:00 2001 From: Michael Layzell Date: Fri, 31 Mar 2017 14:20:09 -0400 Subject: [PATCH 28/89] Bug 1320179 - Part 2: Add the nserror rust crate and generate NS_ERROR codes, r=froydnj MozReview-Commit-ID: FFU6WfEqev --- config/rules.mk | 1 + .../mozbuild/backend/recursivemake.py | 1 + toolkit/library/gtest/rust/Cargo.lock | 8 +++ toolkit/library/rust/Cargo.lock | 8 +++ toolkit/library/rust/shared/Cargo.toml | 1 + toolkit/library/rust/shared/lib.rs | 1 + xpcom/base/ErrorList.py | 17 +++++ xpcom/base/moz.build | 4 +- xpcom/rust/nserror/Cargo.toml | 9 +++ xpcom/rust/nserror/src/lib.rs | 62 +++++++++++++++++++ 10 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 xpcom/rust/nserror/Cargo.toml create mode 100644 xpcom/rust/nserror/src/lib.rs diff --git a/config/rules.mk b/config/rules.mk index cc406cb9ffa2..3b029ae49996 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -929,6 +929,7 @@ CARGO_BUILD = env $(rustflags_override) \ CLANG_PATH=$(MOZ_CLANG_PATH) \ PKG_CONFIG_ALLOW_CROSS=1 \ RUST_BACKTRACE=1 \ + MOZ_OBJDIR=$(topobjdir) \ $(CARGO) build $(cargo_build_flags) ifdef RUST_LIBRARY_FILE diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py index b605fd7e745b..0029b27e0231 100644 --- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -524,6 +524,7 @@ class RecursiveMakeBackend(CommonBackend): '.h', '.inc', '.py', + '.rs', ) tier = 'export' if any(f.endswith(export_suffixes) for f in obj.outputs) else 'misc' self._no_skip[tier].add(backend_file.relobjdir) diff --git a/toolkit/library/gtest/rust/Cargo.lock b/toolkit/library/gtest/rust/Cargo.lock index 131615d8086f..32f23a52358d 100644 --- a/toolkit/library/gtest/rust/Cargo.lock +++ b/toolkit/library/gtest/rust/Cargo.lock @@ -307,6 +307,7 @@ version = "0.1.0" dependencies = [ "geckoservo 0.0.1", "mp4parse_capi 0.7.1", + "nserror 0.1.0", "nsstring 0.1.0", "rust_url_capi 0.0.1", "webrender_bindings 0.1.0", @@ -439,6 +440,13 @@ name = "nom" version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "nserror" +version = "0.1.0" +dependencies = [ + "nsstring 0.1.0", +] + [[package]] name = "nsstring" version = "0.1.0" diff --git a/toolkit/library/rust/Cargo.lock b/toolkit/library/rust/Cargo.lock index ffdcfeb62018..e8c89cb8ec3e 100644 --- a/toolkit/library/rust/Cargo.lock +++ b/toolkit/library/rust/Cargo.lock @@ -305,6 +305,7 @@ version = "0.1.0" dependencies = [ "geckoservo 0.0.1", "mp4parse_capi 0.7.1", + "nserror 0.1.0", "nsstring 0.1.0", "rust_url_capi 0.0.1", "webrender_bindings 0.1.0", @@ -433,6 +434,13 @@ name = "nom" version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "nserror" +version = "0.1.0" +dependencies = [ + "nsstring 0.1.0", +] + [[package]] name = "nsstring" version = "0.1.0" diff --git a/toolkit/library/rust/shared/Cargo.toml b/toolkit/library/rust/shared/Cargo.toml index 5d294e3e595c..88b5957c69fa 100644 --- a/toolkit/library/rust/shared/Cargo.toml +++ b/toolkit/library/rust/shared/Cargo.toml @@ -9,6 +9,7 @@ description = "Shared Rust code for libxul" geckoservo = { path = "../../../../servo/ports/geckolib", optional = true } mp4parse_capi = { path = "../../../../media/libstagefright/binding/mp4parse_capi" } nsstring = { path = "../../../../xpcom/rust/nsstring" } +nserror = { path = "../../../../xpcom/rust/nserror" } rust_url_capi = { path = "../../../../netwerk/base/rust-url-capi" } webrender_bindings = { path = "../../../../gfx/webrender_bindings", optional = true } diff --git a/toolkit/library/rust/shared/lib.rs b/toolkit/library/rust/shared/lib.rs index 936fd1875511..3ab5c588bcb0 100644 --- a/toolkit/library/rust/shared/lib.rs +++ b/toolkit/library/rust/shared/lib.rs @@ -7,6 +7,7 @@ extern crate geckoservo; extern crate mp4parse_capi; extern crate nsstring; +extern crate nserror; extern crate rust_url_capi; #[cfg(feature = "quantum_render")] extern crate webrender_bindings; diff --git a/xpcom/base/ErrorList.py b/xpcom/base/ErrorList.py index eb732b2befc0..5bd8d8f9991c 100644 --- a/xpcom/base/ErrorList.py +++ b/xpcom/base/ErrorList.py @@ -1238,3 +1238,20 @@ GetErrorNameInternal(nsresult rv) #endif // ErrorNamesInternal_h__ """) + + +def error_list_rs(output): + output.write(""" +/* THIS FILE IS GENERATED BY ErrorList.py - DO NOT EDIT */ + +use super::nsresult; + +""") + + output.write("pub const NS_ERROR_MODULE_BASE_OFFSET: u32 = {};\n".format(MODULE_BASE_OFFSET)) + + for mod, val in modules.iteritems(): + output.write("pub const NS_ERROR_MODULE_{}: u16 = {};\n".format(mod, val.num)) + + for error, val in errors.iteritems(): + output.write("pub const {}: nsresult = 0x{:X};\n".format(error, val)) diff --git a/xpcom/base/moz.build b/xpcom/base/moz.build index 8155a409a05c..69156f40d869 100644 --- a/xpcom/base/moz.build +++ b/xpcom/base/moz.build @@ -167,12 +167,14 @@ UNIFIED_SOURCES += [ ] GENERATED_FILES += [ + "error_list.rs", "ErrorList.h", - "ErrorNamesInternal.h" + "ErrorNamesInternal.h", ] GENERATED_FILES["ErrorList.h"].script = "ErrorList.py:error_list_h" GENERATED_FILES["ErrorNamesInternal.h"].script = "ErrorList.py:error_names_internal_h" +GENERATED_FILES["error_list.rs"].script = "ErrorList.py:error_list_rs" if CONFIG['OS_ARCH'] == 'Linux': SOURCES += [ diff --git a/xpcom/rust/nserror/Cargo.toml b/xpcom/rust/nserror/Cargo.toml new file mode 100644 index 000000000000..f503a5e5052b --- /dev/null +++ b/xpcom/rust/nserror/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "nserror" +version = "0.1.0" +authors = ["Michael Layzell "] +license = "MPL-2.0" +description = "Rust bindings to xpcom nsresult and NS_ERROR_ values" + +[dependencies] +nsstring = { path = "../nsstring" } diff --git a/xpcom/rust/nserror/src/lib.rs b/xpcom/rust/nserror/src/lib.rs new file mode 100644 index 000000000000..ce4d809acac3 --- /dev/null +++ b/xpcom/rust/nserror/src/lib.rs @@ -0,0 +1,62 @@ +extern crate nsstring; + +use nsstring::{nsCString, nsACString}; + +/// The type of errors in gecko. This type is currently a type alias, rather +/// than a newtype, in order to conform to the C ABI. In future versions of rust +/// which support RFC #1758 or similar we may be able to use +/// `#[repr(transparent)]` to get a better API for using nsresult. +/// +/// The most unfortunate thing about this current implementation is that `u32` +/// and `nsresult` unify. +#[allow(non_camel_case_types)] +pub type nsresult = u32; + +/// An extension trait which is intended to add methods to `nsresult` types. +/// Unfortunately, due to ABI issues, this trait is implemented on all u32 +/// types. These methods are meaningless on non-nsresult values. +pub trait NsresultExt { + fn failed(self) -> bool; + fn succeeded(self) -> bool; + fn to_result(self) -> Result; + + /// Get a printable name for the nsresult error code. This function returns + /// a nsCString<'static>, which implements `Display`. + fn error_name(self) -> nsCString<'static>; +} + +impl NsresultExt for nsresult { + fn failed(self) -> bool { + (self >> 31) != 0 + } + + fn succeeded(self) -> bool { + !self.failed() + } + + fn to_result(self) -> Result { + if self.failed() { + Err(self) + } else { + Ok(self) + } + } + + fn error_name(self) -> nsCString<'static> { + let mut cstr = nsCString::new(); + unsafe { + Gecko_GetErrorName(self, &mut *cstr); + } + cstr + } +} + +extern "C" { + fn Gecko_GetErrorName(rv: nsresult, cstr: *mut nsACString); +} + +mod error_list { + include!(concat!(env!("MOZ_OBJDIR"), "/xpcom/base/error_list.rs")); +} + +pub use error_list::*; From c21cba13858ae1ead0977d27c96a52c19f0f2260 Mon Sep 17 00:00:00 2001 From: Michael Layzell Date: Wed, 5 Apr 2017 16:40:58 -0400 Subject: [PATCH 29/89] Bug 1320179 - Part 3: Define LOGLEVEL_0 unconditionally in protobuf on windows, r=fitzgen This brings the workaround for the GOOGLE_LOG(ERROR) problem when ERROR is defined as `0` by wingdi.h in line with our workaround in the chromium sandbox code. (http://searchfox.org/mozilla-central/rev/381a7b8f8a78b481336cfa384cb0a5536e217e4a/security/sandbox/chromium/base/logging.h#334-346) The other patches on this bug triggered a build problem where in some situations ERROR would be undefined when the LogLevel enum is being defined, while ERROR was defined at a callsite. By unconditionally defining ERROR on windows and including the LOGLEVEL_0 enum variant, we can avoid this issue and fix the associated build bustage. MozReview-Commit-ID: 3XFHf1FqHBr --- .../components/protobuf/src/google/protobuf/stubs/common.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/toolkit/components/protobuf/src/google/protobuf/stubs/common.h b/toolkit/components/protobuf/src/google/protobuf/stubs/common.h index fa6fe3ce973b..43cb1d2ad756 100644 --- a/toolkit/components/protobuf/src/google/protobuf/stubs/common.h +++ b/toolkit/components/protobuf/src/google/protobuf/stubs/common.h @@ -588,7 +588,7 @@ enum LogLevel { LOGLEVEL_DFATAL = LOGLEVEL_FATAL #endif -#ifdef ERROR +#ifdef _WIN32 // ERROR is defined as 0 on some windows builds, so `GOOGLE_LOG(ERROR, ...)` // expands into `GOOGLE_LOG(0, ...)` which then expands into // `someGoogleLogging(LOGLEVEL_0, ...)`. This is not ideal, because the @@ -596,6 +596,10 @@ enum LogLevel { // `someGoogleLogging(LOGLEVEL_ERROR, ...)` instead. The workaround to get // everything building is to simply define LOGLEVEL_0 as LOGLEVEL_ERROR and // move on with our lives. + // + // We also define ERROR the same way that the Windows SDK does for + // consistency. +#define ERROR 0 , LOGLEVEL_0 = LOGLEVEL_ERROR #endif }; From c33097aeaa5c8c2475001969b0489221df67a4c2 Mon Sep 17 00:00:00 2001 From: Michael Layzell Date: Thu, 6 Apr 2017 17:32:58 -0400 Subject: [PATCH 30/89] Bug 1320179 - Part 4: MOZ_OBJDIR->MOZ_TOPOBJDIR and update m-c-changes.patch for protobuf changes, r=fitzgen MozReview-Commit-ID: EPhkF350sGY --- config/rules.mk | 2 +- toolkit/components/protobuf/m-c-changes.patch | 6 +++++- xpcom/rust/nserror/src/lib.rs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/config/rules.mk b/config/rules.mk index 3b029ae49996..ef202f75e56c 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -929,7 +929,7 @@ CARGO_BUILD = env $(rustflags_override) \ CLANG_PATH=$(MOZ_CLANG_PATH) \ PKG_CONFIG_ALLOW_CROSS=1 \ RUST_BACKTRACE=1 \ - MOZ_OBJDIR=$(topobjdir) \ + MOZ_TOPOBJDIR=$(topobjdir) \ $(CARGO) build $(cargo_build_flags) ifdef RUST_LIBRARY_FILE diff --git a/toolkit/components/protobuf/m-c-changes.patch b/toolkit/components/protobuf/m-c-changes.patch index bb91d940098a..680041c85fa9 100644 --- a/toolkit/components/protobuf/m-c-changes.patch +++ b/toolkit/components/protobuf/m-c-changes.patch @@ -200,7 +200,7 @@ LOGLEVEL_DFATAL = LOGLEVEL_FATAL #endif + -+#ifdef ERROR ++#ifdef _WIN32 + // ERROR is defined as 0 on some windows builds, so `GOOGLE_LOG(ERROR, ...)` + // expands into `GOOGLE_LOG(0, ...)` which then expands into + // `someGoogleLogging(LOGLEVEL_0, ...)`. This is not ideal, because the @@ -208,6 +208,10 @@ + // `someGoogleLogging(LOGLEVEL_ERROR, ...)` instead. The workaround to get + // everything building is to simply define LOGLEVEL_0 as LOGLEVEL_ERROR and + // move on with our lives. ++ // ++ // We also define ERROR the same way that the Windows SDK does for ++ // consistency. ++#define ERROR 0 + , LOGLEVEL_0 = LOGLEVEL_ERROR +#endif }; diff --git a/xpcom/rust/nserror/src/lib.rs b/xpcom/rust/nserror/src/lib.rs index ce4d809acac3..c8322faae167 100644 --- a/xpcom/rust/nserror/src/lib.rs +++ b/xpcom/rust/nserror/src/lib.rs @@ -56,7 +56,7 @@ extern "C" { } mod error_list { - include!(concat!(env!("MOZ_OBJDIR"), "/xpcom/base/error_list.rs")); + include!(concat!(env!("MOZ_TOPOBJDIR"), "/xpcom/base/error_list.rs")); } pub use error_list::*; From eb2583d29f591fedf7c2fac266bf7e91f848a9e1 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Thu, 6 Apr 2017 17:41:01 -0400 Subject: [PATCH 31/89] Bug 1345355 - Add a gtest for a pinch with zero span but changing focus. r=botond MozReview-Commit-ID: 8AstF1QmBzw --- gfx/layers/apz/test/gtest/TestPinching.cpp | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/gfx/layers/apz/test/gtest/TestPinching.cpp b/gfx/layers/apz/test/gtest/TestPinching.cpp index 289c8bbc77aa..54fb7a75790a 100644 --- a/gfx/layers/apz/test/gtest/TestPinching.cpp +++ b/gfx/layers/apz/test/gtest/TestPinching.cpp @@ -237,3 +237,58 @@ TEST_F(APZCPinchGestureDetectorTester, Pinch_APZZoom_Disabled) { apzc->AssertStateIsReset(); } + +TEST_F(APZCPinchGestureDetectorTester, Pinch_NoSpan) { + SCOPED_GFX_PREF(APZAllowZooming, bool, false); + SCOPED_GFX_PREF(TouchActionEnabled, bool, false); + + FrameMetrics originalMetrics = GetPinchableFrameMetrics(); + apzc->SetFrameMetrics(originalMetrics); + + // When APZAllowZooming is false, the ZoomConstraintsClient produces + // ZoomConstraints with mAllowZoom set to false. + MakeApzcUnzoomable(); + + // With APZAllowZooming false, we expect the NotifyPinchGesture function to + // get called as the pinch progresses, but the metrics shouldn't change. + EXPECT_CALL(*mcc, NotifyPinchGesture(PinchGestureInput::PINCHGESTURE_START, apzc->GetGuid(), LayoutDeviceCoord(0), _)).Times(1); + EXPECT_CALL(*mcc, NotifyPinchGesture(PinchGestureInput::PINCHGESTURE_SCALE, apzc->GetGuid(), _, _)).Times(AtLeast(1)); + EXPECT_CALL(*mcc, NotifyPinchGesture(PinchGestureInput::PINCHGESTURE_END, apzc->GetGuid(), LayoutDeviceCoord(0), _)).Times(1); + + int inputId = 0; + ScreenIntPoint focus(250, 300); + + // Do a pinch holding a zero span and moving the focus by y=100 + + MultiTouchInput mtiStart = MultiTouchInput(MultiTouchInput::MULTITOUCH_START, 0, TimeStamp(), 0); + mtiStart.mTouches.AppendElement(CreateSingleTouchData(inputId, focus)); + mtiStart.mTouches.AppendElement(CreateSingleTouchData(inputId + 1, focus)); + apzc->ReceiveInputEvent(mtiStart, nullptr); + + focus.y -= 35 + 1; // this is to get over the PINCH_START_THRESHOLD in GestureEventListener.cpp + MultiTouchInput mtiMove1 = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, 0, TimeStamp(), 0); + mtiMove1.mTouches.AppendElement(CreateSingleTouchData(inputId, focus)); + mtiMove1.mTouches.AppendElement(CreateSingleTouchData(inputId + 1, focus)); + apzc->ReceiveInputEvent(mtiMove1, nullptr); + + focus.y -= 100; // do a two-finger scroll of 100 screen pixels + MultiTouchInput mtiMove2 = MultiTouchInput(MultiTouchInput::MULTITOUCH_MOVE, 0, TimeStamp(), 0); + mtiMove2.mTouches.AppendElement(CreateSingleTouchData(inputId, focus)); + mtiMove2.mTouches.AppendElement(CreateSingleTouchData(inputId + 1, focus)); + apzc->ReceiveInputEvent(mtiMove2, nullptr); + + MultiTouchInput mtiEnd = MultiTouchInput(MultiTouchInput::MULTITOUCH_END, 0, TimeStamp(), 0); + mtiEnd.mTouches.AppendElement(CreateSingleTouchData(inputId, focus)); + mtiEnd.mTouches.AppendElement(CreateSingleTouchData(inputId + 1, focus)); + apzc->ReceiveInputEvent(mtiEnd, nullptr); + + // Done, check the metrics to make sure we scrolled by 100 screen pixels, + // which is 50 CSS pixels for the pinchable frame metrics. + + FrameMetrics fm = apzc->GetFrameMetrics(); + EXPECT_EQ(originalMetrics.GetZoom(), fm.GetZoom()); + EXPECT_EQ(originalMetrics.GetScrollOffset().x, fm.GetScrollOffset().x); + EXPECT_EQ(originalMetrics.GetScrollOffset().y + 50, fm.GetScrollOffset().y); + + apzc->AssertStateIsReset(); +} From a168dcdbf337f5a76a197b8aa63285820cbc8222 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Thu, 6 Apr 2017 17:41:02 -0400 Subject: [PATCH 32/89] Bug 1348980 - implement UnscaledFont API for Moz2D and thebes. r=jfkthame --- gfx/2d/2D.h | 43 +++++++++++++++++-- gfx/2d/Factory.cpp | 27 +++++++----- gfx/2d/NativeFontResourceDWrite.cpp | 2 +- gfx/2d/NativeFontResourceGDI.cpp | 2 +- gfx/2d/NativeFontResourceMac.cpp | 2 +- gfx/2d/ScaledFontBase.cpp | 13 +++++- gfx/2d/ScaledFontBase.h | 4 +- gfx/2d/ScaledFontCairo.cpp | 8 ++-- gfx/2d/ScaledFontCairo.h | 4 +- gfx/2d/ScaledFontDWrite.cpp | 9 ++-- gfx/2d/ScaledFontDWrite.h | 14 ++++-- gfx/2d/ScaledFontFontconfig.cpp | 5 ++- gfx/2d/ScaledFontFontconfig.h | 5 ++- gfx/2d/ScaledFontMac.cpp | 6 ++- gfx/2d/ScaledFontMac.h | 2 +- gfx/2d/ScaledFontWin.cpp | 8 ++-- gfx/2d/ScaledFontWin.h | 4 +- gfx/2d/Types.h | 3 +- gfx/2d/UnscaledFontDWrite.h | 41 ++++++++++++++++++ gfx/2d/UnscaledFontFreeType.h | 64 ++++++++++++++++++++++++++++ gfx/2d/UnscaledFontGDI.h | 35 +++++++++++++++ gfx/2d/UnscaledFontMac.h | 47 ++++++++++++++++++++ gfx/2d/moz.build | 10 +++++ gfx/thebes/gfxAndroidPlatform.h | 1 - gfx/thebes/gfxDWriteFontList.cpp | 22 +++++++++- gfx/thebes/gfxDWriteFontList.h | 5 +++ gfx/thebes/gfxDWriteFonts.cpp | 27 +++++------- gfx/thebes/gfxDWriteFonts.h | 5 ++- gfx/thebes/gfxFT2FontBase.cpp | 5 ++- gfx/thebes/gfxFT2FontBase.h | 4 +- gfx/thebes/gfxFT2FontList.cpp | 16 ++++++- gfx/thebes/gfxFT2FontList.h | 3 ++ gfx/thebes/gfxFT2Fonts.cpp | 5 ++- gfx/thebes/gfxFT2Fonts.h | 3 +- gfx/thebes/gfxFcPlatformFontList.cpp | 58 +++++++++++++++++++++++-- gfx/thebes/gfxFcPlatformFontList.h | 23 +++++++++- gfx/thebes/gfxFont.cpp | 6 ++- gfx/thebes/gfxFont.h | 12 +++++- gfx/thebes/gfxFontEntry.h | 1 + gfx/thebes/gfxFontconfigUtils.h | 5 ++- gfx/thebes/gfxGDIFont.cpp | 12 +++++- gfx/thebes/gfxGDIFontList.cpp | 16 +++++++ gfx/thebes/gfxGDIFontList.h | 7 ++- gfx/thebes/gfxMacFont.cpp | 20 ++++++--- gfx/thebes/gfxMacFont.h | 5 ++- gfx/thebes/gfxMacPlatformFontList.h | 4 ++ gfx/thebes/gfxMacPlatformFontList.mm | 15 ++++++- gfx/thebes/gfxPlatform.cpp | 5 ++- gfx/thebes/gfxPlatformGtk.cpp | 1 + gfx/thebes/gfxWindowsPlatform.cpp | 7 ++- layout/generic/nsTextFrame.cpp | 1 + 51 files changed, 558 insertions(+), 94 deletions(-) create mode 100644 gfx/2d/UnscaledFontDWrite.h create mode 100644 gfx/2d/UnscaledFontFreeType.h create mode 100644 gfx/2d/UnscaledFontGDI.h create mode 100644 gfx/2d/UnscaledFontMac.h diff --git a/gfx/2d/2D.h b/gfx/2d/2D.h index 3b3d0d652987..703bac83fa11 100644 --- a/gfx/2d/2D.h +++ b/gfx/2d/2D.h @@ -25,6 +25,7 @@ // outparams using the &-operator. But it will have to do as there's no easy // solution. #include "mozilla/RefPtr.h" +#include "mozilla/WeakPtr.h" #include "mozilla/DebugOnly.h" @@ -696,6 +697,27 @@ struct GlyphMetrics Float mHeight; }; +class UnscaledFont + : public external::AtomicRefCounted + , public SupportsWeakPtr +{ +public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(UnscaledFont) + MOZ_DECLARE_WEAKREFERENCE_TYPENAME(UnscaledFont) + + virtual ~UnscaledFont(); + + virtual FontType GetType() const = 0; + + static uint32_t DeletionCounter() { return sDeletionCounter; } + +protected: + UnscaledFont() {} + +private: + static uint32_t sDeletionCounter; +}; + /** This class is an abstraction of a backend/platform specific font object * at a particular size. It is passed into text drawing calls to describe * the font used for the drawing call. @@ -718,6 +740,7 @@ public: typedef void (*FontDescriptorOutput)(const uint8_t* aData, uint32_t aLength, Float aFontSize, void* aBaton); virtual FontType GetType() const = 0; + virtual Float GetSize() const = 0; virtual AntialiasMode GetDefaultAAMode(); /** This allows getting a path that describes the outline of a set of glyphs. @@ -753,10 +776,15 @@ public: return mUserData.Get(key); } + const RefPtr& GetUnscaledFont() const { return mUnscaledFont; } + protected: - ScaledFont() {} + explicit ScaledFont(const RefPtr& aUnscaledFont) + : mUnscaledFont(aUnscaledFont) + {} UserData mUserData; + RefPtr mUnscaledFont; }; /** @@ -1426,11 +1454,14 @@ public: CreateDrawTargetForData(BackendType aBackend, unsigned char* aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat, bool aUninitialized = false); static already_AddRefed - CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSize); + CreateScaledFontForNativeFont(const NativeFont &aNativeFont, + const RefPtr& aUnscaledFont, + Float aSize); #ifdef MOZ_WIDGET_GTK static already_AddRefed - CreateScaledFontForFontconfigFont(cairo_scaled_font_t* aScaledFont, FcPattern* aPattern, Float aSize); + CreateScaledFontForFontconfigFont(cairo_scaled_font_t* aScaledFont, FcPattern* aPattern, + const RefPtr& aUnscaledFont, Float aSize); #endif /** @@ -1462,7 +1493,10 @@ public: * cairo_scaled_font_t* parameters must correspond to the same font. */ static already_AddRefed - CreateScaledFontWithCairo(const NativeFont &aNativeFont, Float aSize, cairo_scaled_font_t* aScaledFont); + CreateScaledFontWithCairo(const NativeFont &aNativeFont, + const RefPtr& aUnscaledFont, + Float aSize, + cairo_scaled_font_t* aScaledFont); /** * This creates a simple data source surface for a certain size. It allocates @@ -1588,6 +1622,7 @@ public: static already_AddRefed CreateScaledFontForDWriteFont(IDWriteFontFace* aFontFace, const gfxFontStyle* aStyle, + const RefPtr& aUnscaledFont, Float aSize, bool aUseEmbeddedBitmap, bool aForceGDIMode); diff --git a/gfx/2d/Factory.cpp b/gfx/2d/Factory.cpp index acf68eeaef70..f64aa7647f98 100644 --- a/gfx/2d/Factory.cpp +++ b/gfx/2d/Factory.cpp @@ -469,31 +469,33 @@ Factory::GetMaxSurfaceSize(BackendType aType) } already_AddRefed -Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSize) +Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont, + const RefPtr& aUnscaledFont, + Float aSize) { switch (aNativeFont.mType) { #ifdef WIN32 case NativeFontType::DWRITE_FONT_FACE: { - return MakeAndAddRef(static_cast(aNativeFont.mFont), aSize); + return MakeAndAddRef(static_cast(aNativeFont.mFont), aUnscaledFont, aSize); } #if defined(USE_CAIRO) || defined(USE_SKIA) case NativeFontType::GDI_FONT_FACE: { - return MakeAndAddRef(static_cast(aNativeFont.mFont), aSize); + return MakeAndAddRef(static_cast(aNativeFont.mFont), aUnscaledFont, aSize); } #endif #endif #ifdef XP_DARWIN case NativeFontType::MAC_FONT_FACE: { - return MakeAndAddRef(static_cast(aNativeFont.mFont), aSize); + return MakeAndAddRef(static_cast(aNativeFont.mFont), aUnscaledFont, aSize); } #endif #if defined(USE_CAIRO) || defined(USE_SKIA_FREETYPE) case NativeFontType::CAIRO_FONT_FACE: { - return MakeAndAddRef(static_cast(aNativeFont.mFont), aSize); + return MakeAndAddRef(static_cast(aNativeFont.mFont), aUnscaledFont, aSize); } #endif default: @@ -564,14 +566,17 @@ Factory::CreateScaledFontFromFontDescriptor(FontType aType, const uint8_t* aData } already_AddRefed -Factory::CreateScaledFontWithCairo(const NativeFont& aNativeFont, Float aSize, cairo_scaled_font_t* aScaledFont) +Factory::CreateScaledFontWithCairo(const NativeFont& aNativeFont, + const RefPtr& aUnscaledFont, + Float aSize, + cairo_scaled_font_t* aScaledFont) { #ifdef USE_CAIRO // In theory, we could pull the NativeFont out of the cairo_scaled_font_t*, // but that would require a lot of code that would be otherwise repeated in // various backends. // Therefore, we just reuse CreateScaledFontForNativeFont's implementation. - RefPtr font = CreateScaledFontForNativeFont(aNativeFont, aSize); + RefPtr font = CreateScaledFontForNativeFont(aNativeFont, aUnscaledFont, aSize); static_cast(font.get())->SetCairoScaledFont(aScaledFont); return font.forget(); #else @@ -581,9 +586,10 @@ Factory::CreateScaledFontWithCairo(const NativeFont& aNativeFont, Float aSize, c #ifdef MOZ_WIDGET_GTK already_AddRefed -Factory::CreateScaledFontForFontconfigFont(cairo_scaled_font_t* aScaledFont, FcPattern* aPattern, Float aSize) +Factory::CreateScaledFontForFontconfigFont(cairo_scaled_font_t* aScaledFont, FcPattern* aPattern, + const RefPtr& aUnscaledFont, Float aSize) { - return MakeAndAddRef(aScaledFont, aPattern, aSize); + return MakeAndAddRef(aScaledFont, aPattern, aUnscaledFont, aSize); } #endif @@ -745,11 +751,12 @@ Factory::D2DCleanup() already_AddRefed Factory::CreateScaledFontForDWriteFont(IDWriteFontFace* aFontFace, const gfxFontStyle* aStyle, + const RefPtr& aUnscaledFont, float aSize, bool aUseEmbeddedBitmap, bool aForceGDIMode) { - return MakeAndAddRef(aFontFace, aSize, + return MakeAndAddRef(aFontFace, aUnscaledFont, aSize, aUseEmbeddedBitmap, aForceGDIMode, aStyle); } diff --git a/gfx/2d/NativeFontResourceDWrite.cpp b/gfx/2d/NativeFontResourceDWrite.cpp index e4d12ad872d1..afa14f8c3a77 100644 --- a/gfx/2d/NativeFontResourceDWrite.cpp +++ b/gfx/2d/NativeFontResourceDWrite.cpp @@ -275,7 +275,7 @@ NativeFontResourceDWrite::CreateScaledFont(uint32_t aIndex, Float aGlyphSize, return nullptr; } - RefPtr scaledFont = new ScaledFontDWrite(fontFace, aGlyphSize); + RefPtr scaledFont = new ScaledFontDWrite(fontFace, nullptr, aGlyphSize); if (mNeedsCairo && !scaledFont->PopulateCairoScaledFont()) { gfxWarning() << "Unable to create cairo scaled font DWrite font."; return nullptr; diff --git a/gfx/2d/NativeFontResourceGDI.cpp b/gfx/2d/NativeFontResourceGDI.cpp index f51e75179fda..4de37943d6c9 100644 --- a/gfx/2d/NativeFontResourceGDI.cpp +++ b/gfx/2d/NativeFontResourceGDI.cpp @@ -50,7 +50,7 @@ NativeFontResourceGDI::CreateScaledFont(uint32_t aIndex, Float aGlyphSize, // Constructor for ScaledFontWin dereferences and copies the LOGFONT, so we // are safe to pass this reference. - RefPtr scaledFont = new ScaledFontWin(logFont, aGlyphSize); + RefPtr scaledFont = new ScaledFontWin(logFont, nullptr, aGlyphSize); if (mNeedsCairo && !scaledFont->PopulateCairoScaledFont()) { gfxWarning() << "Unable to create cairo scaled font GDI font."; return nullptr; diff --git a/gfx/2d/NativeFontResourceMac.cpp b/gfx/2d/NativeFontResourceMac.cpp index f38a1b639aed..53782b06d6c5 100644 --- a/gfx/2d/NativeFontResourceMac.cpp +++ b/gfx/2d/NativeFontResourceMac.cpp @@ -209,7 +209,7 @@ already_AddRefed NativeFontResourceMac::CreateScaledFont(uint32_t aIndex, Float aGlyphSize, const uint8_t* aInstanceData, uint32_t aInstanceDataLength) { - RefPtr scaledFont = new ScaledFontMac(mFontRef, aGlyphSize); + RefPtr scaledFont = new ScaledFontMac(mFontRef, nullptr, aGlyphSize); if (!scaledFont->PopulateCairoScaledFont()) { gfxWarning() << "Unable to create cairo scaled Mac font."; diff --git a/gfx/2d/ScaledFontBase.cpp b/gfx/2d/ScaledFontBase.cpp index 4fc7504d3d91..a2f777ff32f7 100644 --- a/gfx/2d/ScaledFontBase.cpp +++ b/gfx/2d/ScaledFontBase.cpp @@ -26,6 +26,13 @@ using namespace std; namespace mozilla { namespace gfx { +uint32_t UnscaledFont::sDeletionCounter = 0; + +UnscaledFont::~UnscaledFont() +{ + sDeletionCounter++; +} + AntialiasMode ScaledFont::GetDefaultAAMode() { @@ -46,8 +53,10 @@ ScaledFontBase::~ScaledFontBase() #endif } -ScaledFontBase::ScaledFontBase(Float aSize) - : mSize(aSize) +ScaledFontBase::ScaledFontBase(const RefPtr& aUnscaledFont, + Float aSize) + : ScaledFont(aUnscaledFont) + , mSize(aSize) { #ifdef USE_SKIA mTypeface = nullptr; diff --git a/gfx/2d/ScaledFontBase.h b/gfx/2d/ScaledFontBase.h index e4bb4f2f8c01..c777ac170c4e 100644 --- a/gfx/2d/ScaledFontBase.h +++ b/gfx/2d/ScaledFontBase.h @@ -28,7 +28,7 @@ class ScaledFontBase : public ScaledFont { public: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontBase) - explicit ScaledFontBase(Float aSize); + ScaledFontBase(const RefPtr& aUnscaledFont, Float aSize); virtual ~ScaledFontBase(); virtual already_AddRefed GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget); @@ -37,7 +37,7 @@ public: virtual void GetGlyphDesignMetrics(const uint16_t* aGlyphIndices, uint32_t aNumGlyphs, GlyphMetrics* aGlyphMetrics); - float GetSize() { return mSize; } + virtual Float GetSize() const { return mSize; } #ifdef USE_SKIA virtual SkTypeface* GetSkTypeface() { return mTypeface; } diff --git a/gfx/2d/ScaledFontCairo.cpp b/gfx/2d/ScaledFontCairo.cpp index b8b52145e1b5..006ffa9bfdf9 100644 --- a/gfx/2d/ScaledFontCairo.cpp +++ b/gfx/2d/ScaledFontCairo.cpp @@ -17,9 +17,11 @@ namespace gfx { // an SkFontHost implementation that allows Skia to render using this. // This is mainly because FT_Face is not good for sharing between libraries, which // is a requirement when we consider runtime switchable backends and so on -ScaledFontCairo::ScaledFontCairo(cairo_scaled_font_t* aScaledFont, Float aSize) - : ScaledFontBase(aSize) -{ +ScaledFontCairo::ScaledFontCairo(cairo_scaled_font_t* aScaledFont, + const RefPtr& aUnscaledFont, + Float aSize) + : ScaledFontBase(aUnscaledFont, aSize) +{ SetCairoScaledFont(aScaledFont); } diff --git a/gfx/2d/ScaledFontCairo.h b/gfx/2d/ScaledFontCairo.h index 7862fa1a0345..22d7b0b4b86b 100644 --- a/gfx/2d/ScaledFontCairo.h +++ b/gfx/2d/ScaledFontCairo.h @@ -18,7 +18,9 @@ class ScaledFontCairo : public ScaledFontBase public: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontCairo) - ScaledFontCairo(cairo_scaled_font_t* aScaledFont, Float aSize); + ScaledFontCairo(cairo_scaled_font_t* aScaledFont, + const RefPtr& aUnscaledFont, + Float aSize); #if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE) virtual SkTypeface* GetSkTypeface(); diff --git a/gfx/2d/ScaledFontDWrite.cpp b/gfx/2d/ScaledFontDWrite.cpp index e1ac69f5803a..70f991cd8c88 100644 --- a/gfx/2d/ScaledFontDWrite.cpp +++ b/gfx/2d/ScaledFontDWrite.cpp @@ -102,10 +102,13 @@ DWriteFontStretchFromStretch(int16_t aStretch) } } -ScaledFontDWrite::ScaledFontDWrite(IDWriteFontFace *aFontFace, Float aSize, - bool aUseEmbeddedBitmap, bool aForceGDIMode, +ScaledFontDWrite::ScaledFontDWrite(IDWriteFontFace *aFontFace, + const RefPtr& aUnscaledFont, + Float aSize, + bool aUseEmbeddedBitmap, + bool aForceGDIMode, const gfxFontStyle* aStyle) - : ScaledFontBase(aSize) + : ScaledFontBase(aUnscaledFont, aSize) , mFontFace(aFontFace) , mUseEmbeddedBitmap(aUseEmbeddedBitmap) , mForceGDIMode(aForceGDIMode) diff --git a/gfx/2d/ScaledFontDWrite.h b/gfx/2d/ScaledFontDWrite.h index 18db30a6be3d..c3c97e2c72e7 100644 --- a/gfx/2d/ScaledFontDWrite.h +++ b/gfx/2d/ScaledFontDWrite.h @@ -19,15 +19,21 @@ class ScaledFontDWrite final : public ScaledFontBase { public: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontDwrite) - ScaledFontDWrite(IDWriteFontFace *aFont, Float aSize) - : ScaledFontBase(aSize) + ScaledFontDWrite(IDWriteFontFace *aFont, + const RefPtr& aUnscaledFont, + Float aSize) + : ScaledFontBase(aUnscaledFont, aSize) , mFontFace(aFont) , mUseEmbeddedBitmap(false) , mForceGDIMode(false) {} - ScaledFontDWrite(IDWriteFontFace *aFontFace, Float aSize, bool aUseEmbeddedBitmap, - bool aForceGDIMode, const gfxFontStyle* aStyle); + ScaledFontDWrite(IDWriteFontFace *aFontFace, + const RefPtr& aUnscaledFont, + Float aSize, + bool aUseEmbeddedBitmap, + bool aForceGDIMode, + const gfxFontStyle* aStyle); virtual FontType GetType() const { return FontType::DWRITE; } diff --git a/gfx/2d/ScaledFontFontconfig.cpp b/gfx/2d/ScaledFontFontconfig.cpp index 62011e8016b8..25fd44fc4d8b 100644 --- a/gfx/2d/ScaledFontFontconfig.cpp +++ b/gfx/2d/ScaledFontFontconfig.cpp @@ -23,8 +23,9 @@ namespace gfx { // is a requirement when we consider runtime switchable backends and so on ScaledFontFontconfig::ScaledFontFontconfig(cairo_scaled_font_t* aScaledFont, FcPattern* aPattern, + const RefPtr& aUnscaledFont, Float aSize) - : ScaledFontBase(aSize), + : ScaledFontBase(aUnscaledFont, aSize), mPattern(aPattern) { SetCairoScaledFont(aScaledFont); @@ -331,7 +332,7 @@ ScaledFontFontconfig::CreateFromInstanceData(const InstanceData& aInstanceData, } RefPtr scaledFont = - new ScaledFontFontconfig(cairoScaledFont, pattern, aSize); + new ScaledFontFontconfig(cairoScaledFont, pattern, nullptr, aSize); FcPatternDestroy(pattern); diff --git a/gfx/2d/ScaledFontFontconfig.h b/gfx/2d/ScaledFontFontconfig.h index b24928d9db05..a446dd2e018e 100644 --- a/gfx/2d/ScaledFontFontconfig.h +++ b/gfx/2d/ScaledFontFontconfig.h @@ -19,7 +19,8 @@ class ScaledFontFontconfig : public ScaledFontBase { public: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontFontconfig, override) - ScaledFontFontconfig(cairo_scaled_font_t* aScaledFont, FcPattern* aPattern, Float aSize); + ScaledFontFontconfig(cairo_scaled_font_t* aScaledFont, FcPattern* aPattern, + const RefPtr& aUnscaledFont, Float aSize); ~ScaledFontFontconfig(); FontType GetType() const override { return FontType::FONTCONFIG; } @@ -28,6 +29,8 @@ public: SkTypeface* GetSkTypeface() override; #endif + bool CanSerialize() override { return true; } + bool GetFontFileData(FontFileDataOutput aDataCallback, void* aBaton) override; bool GetFontInstanceData(FontInstanceDataOutput aCb, void* aBaton) override; diff --git a/gfx/2d/ScaledFontMac.cpp b/gfx/2d/ScaledFontMac.cpp index 6201cfff836b..f5ef2f0da56e 100644 --- a/gfx/2d/ScaledFontMac.cpp +++ b/gfx/2d/ScaledFontMac.cpp @@ -67,8 +67,10 @@ CreateCTFontFromCGFontWithVariations(CGFontRef aCGFont, CGFloat aSize) return ctFont; } -ScaledFontMac::ScaledFontMac(CGFontRef aFont, Float aSize) - : ScaledFontBase(aSize) +ScaledFontMac::ScaledFontMac(CGFontRef aFont, + const RefPtr& aUnscaledFont, + Float aSize) + : ScaledFontBase(aUnscaledFont, aSize) { if (!sSymbolLookupDone) { CTFontDrawGlyphsPtr = diff --git a/gfx/2d/ScaledFontMac.h b/gfx/2d/ScaledFontMac.h index 0eaf6065fddc..69ff35c6be7e 100644 --- a/gfx/2d/ScaledFontMac.h +++ b/gfx/2d/ScaledFontMac.h @@ -41,7 +41,7 @@ class ScaledFontMac : public ScaledFontBase { public: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontMac) - ScaledFontMac(CGFontRef aFont, Float aSize); + ScaledFontMac(CGFontRef aFont, const RefPtr& aUnscaledFont, Float aSize); virtual ~ScaledFontMac(); virtual FontType GetType() const { return FontType::MAC; } diff --git a/gfx/2d/ScaledFontWin.cpp b/gfx/2d/ScaledFontWin.cpp index a07a2e4016f7..58275ed3dc51 100644 --- a/gfx/2d/ScaledFontWin.cpp +++ b/gfx/2d/ScaledFontWin.cpp @@ -22,8 +22,10 @@ namespace mozilla { namespace gfx { -ScaledFontWin::ScaledFontWin(const LOGFONT* aFont, Float aSize) - : ScaledFontBase(aSize) +ScaledFontWin::ScaledFontWin(const LOGFONT* aFont, + const RefPtr& aUnscaledFont, + Float aSize) + : ScaledFontBase(aUnscaledFont, aSize) , mLogFont(*aFont) { } @@ -80,7 +82,7 @@ ScaledFontWin::CreateFromFontDescriptor(const uint8_t* aData, uint32_t aDataLeng nativeFont.mFont = (void*)aData; RefPtr font = - Factory::CreateScaledFontForNativeFont(nativeFont, aSize); + Factory::CreateScaledFontForNativeFont(nativeFont, nullptr, aSize); #ifdef USE_CAIRO_SCALED_FONT static_cast(font.get())->PopulateCairoScaledFont(); diff --git a/gfx/2d/ScaledFontWin.h b/gfx/2d/ScaledFontWin.h index fe5816707d00..3b935ded8e79 100644 --- a/gfx/2d/ScaledFontWin.h +++ b/gfx/2d/ScaledFontWin.h @@ -16,7 +16,9 @@ class ScaledFontWin : public ScaledFontBase { public: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontWin) - ScaledFontWin(const LOGFONT* aFont, Float aSize); + ScaledFontWin(const LOGFONT* aFont, + const RefPtr& aUnscaledFont, + Float aSize); virtual FontType GetType() const { return FontType::GDI; } diff --git a/gfx/2d/Types.h b/gfx/2d/Types.h index 915b038f0668..47da6c491e02 100644 --- a/gfx/2d/Types.h +++ b/gfx/2d/Types.h @@ -150,7 +150,8 @@ enum class FontType : int8_t { SKIA, CAIRO, COREGRAPHICS, - FONTCONFIG + FONTCONFIG, + FREETYPE }; enum class NativeSurfaceType : int8_t { diff --git a/gfx/2d/UnscaledFontDWrite.h b/gfx/2d/UnscaledFontDWrite.h new file mode 100644 index 000000000000..121a7aead48d --- /dev/null +++ b/gfx/2d/UnscaledFontDWrite.h @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 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/. */ + +#ifndef MOZILLA_GFX_UNSCALEDFONTDWRITE_H_ +#define MOZILLA_GFX_UNSCALEDFONTDWRITE_H_ + +#include + +#include "2D.h" + +namespace mozilla { +namespace gfx { + +class UnscaledFontDWrite final : public UnscaledFont +{ +public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(UnscaledFontDWrite, override) + explicit UnscaledFontDWrite(const RefPtr& aFontFace, + DWRITE_FONT_SIMULATIONS aSimulations = + DWRITE_FONT_SIMULATIONS_NONE) + : mFontFace(aFontFace), + mSimulations(aSimulations) + {} + + FontType GetType() const override { return FontType::DWRITE; } + + const RefPtr GetFontFace() const { return mFontFace; } + DWRITE_FONT_SIMULATIONS GetSimulations() const { return mSimulations; } + +private: + RefPtr mFontFace; + DWRITE_FONT_SIMULATIONS mSimulations; +}; + +} // namespace gfx +} // namespace mozilla + +#endif /* MOZILLA_GFX_UNSCALEDFONTDWRITE_H_ */ + diff --git a/gfx/2d/UnscaledFontFreeType.h b/gfx/2d/UnscaledFontFreeType.h new file mode 100644 index 000000000000..2e57feb1e749 --- /dev/null +++ b/gfx/2d/UnscaledFontFreeType.h @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 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/. */ + +#ifndef MOZILLA_GFX_UNSCALEDFONTFREETYPE_H_ +#define MOZILLA_GFX_UNSCALEDFONTFREETYPE_H_ + +#include + +#include "2D.h" + +namespace mozilla { +namespace gfx { + +class UnscaledFontFreeType : public UnscaledFont +{ +public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(UnscaledFontFreeType, override) + explicit UnscaledFontFreeType(FT_Face aFace) + : mFace(aFace) + , mIndex(0) + {} + explicit UnscaledFontFreeType(const char* aFile, + uint32_t aIndex = 0) + : mFace(nullptr) + , mFile(aFile) + , mIndex(aIndex) + {} + + FontType GetType() const override { return FontType::FREETYPE; } + + FT_Face GetFace() const { return mFace; } + const char* GetFile() const { return mFile.c_str(); } + uint32_t GetIndex() const { return mIndex; } + +private: + FT_Face mFace; + std::string mFile; + uint32_t mIndex; +}; + +#ifdef MOZ_WIDGET_GTK +class UnscaledFontFontconfig : public UnscaledFontFreeType +{ +public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(UnscaledFontFontconfig, override) + explicit UnscaledFontFontconfig(FT_Face aFace) + : UnscaledFontFreeType(aFace) + {} + explicit UnscaledFontFontconfig(const char* aFile, + uint32_t aIndex = 0) + : UnscaledFontFreeType(aFile, aIndex) + {} + + FontType GetType() const override { return FontType::FONTCONFIG; } +}; +#endif + +} // namespace gfx +} // namespace mozilla + +#endif /* MOZILLA_GFX_UNSCALEDFONTFREETYPE_H_ */ + diff --git a/gfx/2d/UnscaledFontGDI.h b/gfx/2d/UnscaledFontGDI.h new file mode 100644 index 000000000000..eaaa92e927bf --- /dev/null +++ b/gfx/2d/UnscaledFontGDI.h @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 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/. */ + +#ifndef MOZILLA_GFX_UNSCALEDFONTGDI_H_ +#define MOZILLA_GFX_UNSCALEDFONTGDI_H_ + +#include "2D.h" +#include + +namespace mozilla { +namespace gfx { + +class UnscaledFontGDI final : public UnscaledFont +{ +public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(UnscaledFontGDI, override) + explicit UnscaledFontGDI(const LOGFONT& aLogFont) + : mLogFont(aLogFont) + {} + + FontType GetType() const override { return FontType::GDI; } + + const LOGFONT& GetLogFont() const { return mLogFont; } + +private: + LOGFONT mLogFont; +}; + +} // namespace gfx +} // namespace mozilla + +#endif /* MOZILLA_GFX_UNSCALEDFONTGDI_H_ */ + diff --git a/gfx/2d/UnscaledFontMac.h b/gfx/2d/UnscaledFontMac.h new file mode 100644 index 000000000000..27da8185a8ec --- /dev/null +++ b/gfx/2d/UnscaledFontMac.h @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 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/. */ + +#ifndef MOZILLA_GFX_UNSCALEDFONTMAC_H_ +#define MOZILLA_GFX_UNSCALEDFONTMAC_H_ + +#ifdef MOZ_WIDGET_COCOA +#include +#else +#include +#include +#endif + +#include "2D.h" + +namespace mozilla { +namespace gfx { + +class UnscaledFontMac final : public UnscaledFont +{ +public: + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(UnscaledFontMac, override) + explicit UnscaledFontMac(CGFontRef aFont) + : mFont(aFont) + { + CFRetain(mFont); + } + ~UnscaledFontMac() + { + CFRelease(mFont); + } + + FontType GetType() const override { return FontType::MAC; } + + CGFontRef GetFont() const { return mFont; } + +private: + CGFontRef mFont; +}; + +} // namespace gfx +} // namespace mozilla + +#endif /* MOZILLA_GFX_UNSCALEDFONTMAC_H_ */ + diff --git a/gfx/2d/moz.build b/gfx/2d/moz.build index f98ce72dc88a..ec6928ff6af2 100644 --- a/gfx/2d/moz.build +++ b/gfx/2d/moz.build @@ -65,12 +65,17 @@ EXPORTS.mozilla.gfx += ['ssse3-scaler.h'] if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'): EXPORTS.mozilla.gfx += [ 'MacIOSurface.h', + 'UnscaledFontMac.h', ] UNIFIED_SOURCES += [ 'NativeFontResourceMac.cpp', 'ScaledFontMac.cpp', ] elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': + EXPORTS.mozilla.gfx += [ + 'UnscaledFontDWrite.h', + 'UnscaledFontGDI.h', + ] SOURCES += [ 'DrawTargetD2D1.cpp', 'ExtendInputEffectD2D1.cpp', @@ -91,6 +96,11 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'windows': 'JobScheduler_posix.cpp', ] +if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3'): + EXPORTS.mozilla.gfx += [ + 'UnscaledFontFreeType.h', + ] + if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'): SOURCES += [ 'NativeFontResourceFontconfig.cpp', diff --git a/gfx/thebes/gfxAndroidPlatform.h b/gfx/thebes/gfxAndroidPlatform.h index a26e2ece3b60..f7976bb0de7a 100644 --- a/gfx/thebes/gfxAndroidPlatform.h +++ b/gfx/thebes/gfxAndroidPlatform.h @@ -6,7 +6,6 @@ #ifndef GFX_PLATFORM_ANDROID_H #define GFX_PLATFORM_ANDROID_H -#include "gfxFT2Fonts.h" #include "gfxPlatform.h" #include "gfxUserFontSet.h" #include "nsCOMPtr.h" diff --git a/gfx/thebes/gfxDWriteFontList.cpp b/gfx/thebes/gfxDWriteFontList.cpp index 243182c140f7..5b625933224e 100644 --- a/gfx/thebes/gfxDWriteFontList.cpp +++ b/gfx/thebes/gfxDWriteFontList.cpp @@ -27,6 +27,7 @@ #include "harfbuzz/hb.h" using namespace mozilla; +using namespace mozilla::gfx; using mozilla::intl::OSPreferences; #define LOG_FONTLIST(args) MOZ_LOG(gfxPlatform::GetLog(eGfxLog_fontlist), \ @@ -579,7 +580,26 @@ gfxFont * gfxDWriteFontEntry::CreateFontInstance(const gfxFontStyle* aFontStyle, bool aNeedsBold) { - return new gfxDWriteFont(this, aFontStyle, aNeedsBold); + WeakPtr& unscaledFontPtr = + aNeedsBold ? mUnscaledFontBold : mUnscaledFont; + RefPtr unscaledFont = + static_cast(unscaledFontPtr.get()); + if (!unscaledFont) { + DWRITE_FONT_SIMULATIONS sims = DWRITE_FONT_SIMULATIONS_NONE; + if (aNeedsBold) { + sims |= DWRITE_FONT_SIMULATIONS_BOLD; + } + RefPtr fontFace; + nsresult rv = CreateFontFace(getter_AddRefs(fontFace), sims); + if (NS_FAILED(rv)) { + return nullptr; + } + + unscaledFont = new UnscaledFontDWrite(fontFace, sims); + unscaledFontPtr = unscaledFont; + } + + return new gfxDWriteFont(unscaledFont, this, aFontStyle, aNeedsBold); } nsresult diff --git a/gfx/thebes/gfxDWriteFontList.h b/gfx/thebes/gfxDWriteFontList.h index 553d67f493a6..c817bacaac33 100644 --- a/gfx/thebes/gfxDWriteFontList.h +++ b/gfx/thebes/gfxDWriteFontList.h @@ -17,6 +17,8 @@ #include "gfxPlatform.h" #include +#include "mozilla/gfx/UnscaledFontDWrite.h" + /** * gfxDWriteFontFamily is a class that describes one of the fonts on the @@ -201,6 +203,9 @@ protected: int8_t mIsCJK; bool mForceGDIClassic; + + mozilla::WeakPtr mUnscaledFont; + mozilla::WeakPtr mUnscaledFontBold; }; // custom text renderer used to determine the fallback font for a given char diff --git a/gfx/thebes/gfxDWriteFonts.cpp b/gfx/thebes/gfxDWriteFonts.cpp index ea8e879fb4fa..4a7f6723e3fe 100644 --- a/gfx/thebes/gfxDWriteFonts.cpp +++ b/gfx/thebes/gfxDWriteFonts.cpp @@ -71,11 +71,12 @@ UsingClearType() //////////////////////////////////////////////////////////////////////////////// // gfxDWriteFont -gfxDWriteFont::gfxDWriteFont(gfxFontEntry *aFontEntry, +gfxDWriteFont::gfxDWriteFont(const RefPtr& aUnscaledFont, + gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, bool aNeedsBold, AntialiasOption anAAOption) - : gfxFont(aFontEntry, aFontStyle, anAAOption) + : gfxFont(aUnscaledFont, aFontEntry, aFontStyle, anAAOption) , mCairoFontFace(nullptr) , mMetrics(nullptr) , mSpaceGlyph(0) @@ -84,27 +85,15 @@ gfxDWriteFont::gfxDWriteFont(gfxFontEntry *aFontEntry, , mUseSubpixelPositions(false) , mAllowManualShowGlyphs(true) { - gfxDWriteFontEntry *fe = - static_cast(aFontEntry); - nsresult rv; - DWRITE_FONT_SIMULATIONS sims = DWRITE_FONT_SIMULATIONS_NONE; if ((GetStyle()->style != NS_FONT_STYLE_NORMAL) && - fe->IsUpright() && + aFontEntry->IsUpright() && GetStyle()->allowSyntheticStyle) { // For this we always use the font_matrix for uniformity. Not the // DWrite simulation. mNeedsOblique = true; } - if (aNeedsBold) { - sims |= DWRITE_FONT_SIMULATIONS_BOLD; - } - rv = fe->CreateFontFace(getter_AddRefs(mFontFace), sims); - - if (NS_FAILED(rv)) { - mIsValid = false; - return; - } + mFontFace = aUnscaledFont->GetFontFace(); ComputeMetrics(anAAOption); } @@ -131,7 +120,8 @@ UniquePtr gfxDWriteFont::CopyWithAntialiasOption(AntialiasOption anAAOption) { auto entry = static_cast(mFontEntry.get()); - return MakeUnique(entry, &mStyle, mNeedsBold, anAAOption); + RefPtr unscaledFont = static_cast(mUnscaledFont.get()); + return MakeUnique(unscaledFont, entry, &mStyle, mNeedsBold, anAAOption); } const gfxFont::Metrics& @@ -694,6 +684,7 @@ gfxDWriteFont::GetScaledFont(mozilla::gfx::DrawTarget *aTarget) if (wantCairo) { mAzureScaledFont = Factory::CreateScaledFontWithCairo(nativeFont, + GetUnscaledFont(), GetAdjustedSize(), GetCairoScaledFont()); } else if (aTarget->GetBackendType() == BackendType::SKIA) { @@ -704,11 +695,13 @@ gfxDWriteFont::GetScaledFont(mozilla::gfx::DrawTarget *aTarget) const gfxFontStyle* fontStyle = GetStyle(); mAzureScaledFont = Factory::CreateScaledFontForDWriteFont(mFontFace, fontStyle, + GetUnscaledFont(), GetAdjustedSize(), useEmbeddedBitmap, GetForceGDIClassic()); } else { mAzureScaledFont = Factory::CreateScaledFontForNativeFont(nativeFont, + GetUnscaledFont(), GetAdjustedSize()); } diff --git a/gfx/thebes/gfxDWriteFonts.h b/gfx/thebes/gfxDWriteFonts.h index cc39f6c20d96..16378f3cb364 100644 --- a/gfx/thebes/gfxDWriteFonts.h +++ b/gfx/thebes/gfxDWriteFonts.h @@ -17,13 +17,16 @@ #include "nsDataHashtable.h" #include "nsHashKeys.h" +#include "mozilla/gfx/UnscaledFontDWrite.h" + /** * \brief Class representing a font face for a font entry. */ class gfxDWriteFont : public gfxFont { public: - gfxDWriteFont(gfxFontEntry *aFontEntry, + gfxDWriteFont(const RefPtr& aUnscaledFont, + gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, bool aNeedsBold = false, AntialiasOption = kAntialiasDefault); diff --git a/gfx/thebes/gfxFT2FontBase.cpp b/gfx/thebes/gfxFT2FontBase.cpp index 241f28f6388c..0b411b960aea 100644 --- a/gfx/thebes/gfxFT2FontBase.cpp +++ b/gfx/thebes/gfxFT2FontBase.cpp @@ -12,10 +12,11 @@ using namespace mozilla::gfx; -gfxFT2FontBase::gfxFT2FontBase(cairo_scaled_font_t *aScaledFont, +gfxFT2FontBase::gfxFT2FontBase(const RefPtr& aUnscaledFont, + cairo_scaled_font_t *aScaledFont, gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle) - : gfxFont(aFontEntry, aFontStyle, kAntialiasDefault, aScaledFont), + : gfxFont(aUnscaledFont, aFontEntry, aFontStyle, kAntialiasDefault, aScaledFont), mSpaceGlyph(0), mHasMetrics(false) { diff --git a/gfx/thebes/gfxFT2FontBase.h b/gfx/thebes/gfxFT2FontBase.h index 498c74ff97ac..c4f89221eb2f 100644 --- a/gfx/thebes/gfxFT2FontBase.h +++ b/gfx/thebes/gfxFT2FontBase.h @@ -10,10 +10,12 @@ #include "gfxContext.h" #include "gfxFont.h" #include "mozilla/gfx/2D.h" +#include "mozilla/gfx/UnscaledFontFreeType.h" class gfxFT2FontBase : public gfxFont { public: - gfxFT2FontBase(cairo_scaled_font_t *aScaledFont, + gfxFT2FontBase(const RefPtr& aUnscaledFont, + cairo_scaled_font_t *aScaledFont, gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle); virtual ~gfxFT2FontBase(); diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index 49d6cb6bc230..44a8498ca074 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -50,6 +50,7 @@ #include using namespace mozilla; +using namespace mozilla::gfx; static LazyLogModule sFontInfoLog("fontInfoLog"); @@ -237,7 +238,20 @@ FT2FontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold if (!scaledFont) { return nullptr; } - gfxFont *font = new gfxFT2Font(scaledFont, this, aFontStyle, aNeedsBold); + + RefPtr unscaledFont = + static_cast(mUnscaledFont.get()); + if (!unscaledFont) { + unscaledFont = + mFilename.IsEmpty() ? + new UnscaledFontFreeType(mFTFace) : + new UnscaledFontFreeType(mFilename.BeginReading(), + mFTFontIndex); + mUnscaledFont = unscaledFont; + } + + gfxFont *font = new gfxFT2Font(unscaledFont, scaledFont, this, + aFontStyle, aNeedsBold); cairo_scaled_font_destroy(scaledFont); return font; } diff --git a/gfx/thebes/gfxFT2FontList.h b/gfx/thebes/gfxFT2FontList.h index 63187ba26597..0722f2e498ee 100644 --- a/gfx/thebes/gfxFT2FontList.h +++ b/gfx/thebes/gfxFT2FontList.h @@ -8,6 +8,7 @@ #include "mozilla/MemoryReporting.h" #include "gfxPlatformFontList.h" +#include "mozilla/gfx/UnscaledFontFreeType.h" namespace mozilla { namespace dom { @@ -94,6 +95,8 @@ public: nsCString mFilename; uint8_t mFTFontIndex; + + mozilla::WeakPtr mUnscaledFont; }; class FT2FontFamily : public gfxFontFamily diff --git a/gfx/thebes/gfxFT2Fonts.cpp b/gfx/thebes/gfxFT2Fonts.cpp index 1902541911eb..1c9eef0f1713 100644 --- a/gfx/thebes/gfxFT2Fonts.cpp +++ b/gfx/thebes/gfxFT2Fonts.cpp @@ -156,11 +156,12 @@ gfxFT2Font::AddRange(const char16_t *aText, uint32_t aOffset, } } -gfxFT2Font::gfxFT2Font(cairo_scaled_font_t *aCairoFont, +gfxFT2Font::gfxFT2Font(const RefPtr& aUnscaledFont, + cairo_scaled_font_t *aCairoFont, FT2FontEntry *aFontEntry, const gfxFontStyle *aFontStyle, bool aNeedsBold) - : gfxFT2FontBase(aCairoFont, aFontEntry, aFontStyle) + : gfxFT2FontBase(aUnscaledFont, aCairoFont, aFontEntry, aFontStyle) , mCharGlyphCache(32) { NS_ASSERTION(mFontEntry, "Unable to find font entry for font. Something is whack."); diff --git a/gfx/thebes/gfxFT2Fonts.h b/gfx/thebes/gfxFT2Fonts.h index 8e4691c065ab..7211d09518be 100644 --- a/gfx/thebes/gfxFT2Fonts.h +++ b/gfx/thebes/gfxFT2Fonts.h @@ -19,7 +19,8 @@ class FT2FontEntry; class gfxFT2Font : public gfxFT2FontBase { public: // new functions - gfxFT2Font(cairo_scaled_font_t *aCairoFont, + gfxFT2Font(const RefPtr& aUnscaledFont, + cairo_scaled_font_t *aCairoFont, FT2FontEntry *aFontEntry, const gfxFontStyle *aFontStyle, bool aNeedsBold); diff --git a/gfx/thebes/gfxFcPlatformFontList.cpp b/gfx/thebes/gfxFcPlatformFontList.cpp index f5f07e06e7f9..d10834b1c7c6 100644 --- a/gfx/thebes/gfxFcPlatformFontList.cpp +++ b/gfx/thebes/gfxFcPlatformFontList.cpp @@ -39,6 +39,7 @@ #endif using namespace mozilla; +using namespace mozilla::gfx; using namespace mozilla::unicode; #ifndef FC_POSTSCRIPT_NAME @@ -796,6 +797,33 @@ PreparePattern(FcPattern* aPattern, bool aIsPrinterFont) FcDefaultSubstitute(aPattern); } +void +gfxFontconfigFontEntry::UnscaledFontCache::MoveToFront(size_t aIndex) { + if (aIndex > 0) { + WeakPtr front = + Move(mUnscaledFonts[aIndex]); + for (size_t i = aIndex; i > 0; i--) { + mUnscaledFonts[i] = Move(mUnscaledFonts[i-1]); + } + mUnscaledFonts[0] = Move(front); + } +} + +already_AddRefed +gfxFontconfigFontEntry::UnscaledFontCache::Lookup(const char* aFile, uint32_t aIndex) { + for (size_t i = 0; i < kNumEntries; i++) { + UnscaledFontFontconfig* entry = + static_cast(mUnscaledFonts[i].get()); + if (entry && + !strcmp(entry->GetFile(), aFile) && + entry->GetIndex() == aIndex) { + MoveToFront(i); + return do_AddRef(entry); + } + } + return nullptr; +} + static inline gfxFloat SizeForStyle(gfxFontconfigFontEntry* aEntry, const gfxFontStyle& aStyle) { @@ -848,8 +876,31 @@ gfxFontconfigFontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle, cairo_scaled_font_t* scaledFont = CreateScaledFont(renderPattern, size, aFontStyle, aNeedsBold); + + const FcChar8* file = ToFcChar8Ptr(""); + int index = 0; + if (!mFontData) { + if (FcPatternGetString(renderPattern, FC_FILE, 0, + const_cast(&file)) != FcResultMatch || + FcPatternGetInteger(renderPattern, FC_INDEX, 0, &index) != FcResultMatch) { + NS_WARNING("No file in Fontconfig pattern for font instance"); + return nullptr; + } + } + + RefPtr unscaledFont = + mUnscaledFontCache.Lookup(ToCharPtr(file), index); + if (!unscaledFont) { + unscaledFont = + mFontData ? + new UnscaledFontFontconfig(mFTFace) : + new UnscaledFontFontconfig(ToCharPtr(file), index); + mUnscaledFontCache.Add(unscaledFont); + } + gfxFont* newFont = - new gfxFontconfigFont(scaledFont, renderPattern, size, + new gfxFontconfigFont(unscaledFont, scaledFont, + renderPattern, size, this, aFontStyle, aNeedsBold); cairo_scaled_font_destroy(scaledFont); @@ -1067,13 +1118,14 @@ gfxFontconfigFontFamily::FindAllFontsForStyle(const gfxFontStyle& aFontStyle, } } -gfxFontconfigFont::gfxFontconfigFont(cairo_scaled_font_t *aScaledFont, +gfxFontconfigFont::gfxFontconfigFont(const RefPtr& aUnscaledFont, + cairo_scaled_font_t *aScaledFont, FcPattern *aPattern, gfxFloat aAdjustedSize, gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, bool aNeedsBold) : - gfxFontconfigFontBase(aScaledFont, aPattern, aFontEntry, aFontStyle) + gfxFontconfigFontBase(aUnscaledFont, aScaledFont, aPattern, aFontEntry, aFontStyle) { mAdjustedSize = aAdjustedSize; } diff --git a/gfx/thebes/gfxFcPlatformFontList.h b/gfx/thebes/gfxFcPlatformFontList.h index 1bc35021e50e..a9e66378c148 100644 --- a/gfx/thebes/gfxFcPlatformFontList.h +++ b/gfx/thebes/gfxFcPlatformFontList.h @@ -168,6 +168,26 @@ protected: // data font const uint8_t* mFontData; + + class UnscaledFontCache + { + public: + already_AddRefed + Lookup(const char* aFile, uint32_t aIndex); + + void Add(const RefPtr& aUnscaledFont) { + mUnscaledFonts[kNumEntries-1] = aUnscaledFont; + MoveToFront(kNumEntries-1); + } + + private: + void MoveToFront(size_t aIndex); + + static const size_t kNumEntries = 3; + mozilla::WeakPtr mUnscaledFonts[kNumEntries]; + }; + + UnscaledFontCache mUnscaledFontCache; }; class gfxFontconfigFontFamily : public gfxFontFamily { @@ -205,7 +225,8 @@ protected: class gfxFontconfigFont : public gfxFontconfigFontBase { public: - gfxFontconfigFont(cairo_scaled_font_t *aScaledFont, + gfxFontconfigFont(const RefPtr &aUnscaledFont, + cairo_scaled_font_t *aScaledFont, FcPattern *aPattern, gfxFloat aAdjustedSize, gfxFontEntry *aFontEntry, diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index 50ad740a439d..fc3417a882c3 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -835,7 +835,8 @@ gfxFont::RunMetrics::CombineWith(const RunMetrics& aOther, bool aOtherIsOnLeft) mAdvanceWidth += aOther.mAdvanceWidth; } -gfxFont::gfxFont(gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, +gfxFont::gfxFont(const RefPtr& aUnscaledFont, + gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, AntialiasOption anAAOption, cairo_scaled_font_t *aScaledFont) : mScaledFont(aScaledFont), mFontEntry(aFontEntry), mIsValid(true), @@ -844,7 +845,8 @@ gfxFont::gfxFont(gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, mStyle(*aFontStyle), mAdjustedSize(0.0), mFUnitsConvFactor(-1.0f), // negative to indicate "not yet initialized" - mAntialiasOption(anAAOption) + mAntialiasOption(anAAOption), + mUnscaledFont(aUnscaledFont) { #ifdef DEBUG_TEXT_RUN_STORAGE_METRICS ++gFontCount; diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h index bb55c54b708f..12384fad63df 100644 --- a/gfx/thebes/gfxFont.h +++ b/gfx/thebes/gfxFont.h @@ -1385,7 +1385,8 @@ protected: } } - gfxFont(gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, + gfxFont(const RefPtr& aUnscaledFont, + gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, AntialiasOption anAAOption = kAntialiasDefault, cairo_scaled_font_t *aScaledFont = nullptr); @@ -1801,8 +1802,14 @@ public: virtual FontType GetType() const = 0; + const RefPtr& GetUnscaledFont() const { + return mUnscaledFont; + } + virtual already_AddRefed GetScaledFont(DrawTarget* aTarget) - { return gfxPlatform::GetPlatform()->GetScaledFontForFont(aTarget, this); } + { + return gfxPlatform::GetPlatform()->GetScaledFontForFont(aTarget, this); + } bool KerningDisabled() { return mKerningSet && !mKerningEnabled; @@ -2120,6 +2127,7 @@ protected: // ranges supported by font RefPtr mUnicodeRangeMap; + RefPtr mUnscaledFont; RefPtr mAzureScaledFont; // For vertical metrics, created on demand. diff --git a/gfx/thebes/gfxFontEntry.h b/gfx/thebes/gfxFontEntry.h index 7f0e7215bef2..0999a6323247 100644 --- a/gfx/thebes/gfxFontEntry.h +++ b/gfx/thebes/gfxFontEntry.h @@ -20,6 +20,7 @@ #include "harfbuzz/hb.h" #include "mozilla/gfx/2D.h" #include "mozilla/UniquePtr.h" +#include "mozilla/WeakPtr.h" typedef struct gr_face gr_face; diff --git a/gfx/thebes/gfxFontconfigUtils.h b/gfx/thebes/gfxFontconfigUtils.h index 3f502c124345..d1cd66b2fbb1 100644 --- a/gfx/thebes/gfxFontconfigUtils.h +++ b/gfx/thebes/gfxFontconfigUtils.h @@ -38,11 +38,12 @@ public: class gfxFontconfigFontBase : public gfxFT2FontBase { public: - gfxFontconfigFontBase(cairo_scaled_font_t *aScaledFont, + gfxFontconfigFontBase(const RefPtr& aUnscaledFont, + cairo_scaled_font_t *aScaledFont, FcPattern *aPattern, gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle) - : gfxFT2FontBase(aScaledFont, aFontEntry, aFontStyle) + : gfxFT2FontBase(aUnscaledFont, aScaledFont, aFontEntry, aFontStyle) , mPattern(aPattern) { } virtual FontType GetType() const override { return FONT_TYPE_FONTCONFIG; } diff --git a/gfx/thebes/gfxGDIFont.cpp b/gfx/thebes/gfxGDIFont.cpp index 10551baa122b..14c5d9a7f91b 100644 --- a/gfx/thebes/gfxGDIFont.cpp +++ b/gfx/thebes/gfxGDIFont.cpp @@ -44,7 +44,7 @@ gfxGDIFont::gfxGDIFont(GDIFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, bool aNeedsBold, AntialiasOption anAAOption) - : gfxFont(aFontEntry, aFontStyle, anAAOption), + : gfxFont(nullptr, aFontEntry, aFontStyle, anAAOption), mFont(nullptr), mFontFace(nullptr), mMetrics(nullptr), @@ -53,6 +53,10 @@ gfxGDIFont::gfxGDIFont(GDIFontEntry *aFontEntry, mScriptCache(nullptr) { Initialize(); + + if (mFont) { + mUnscaledFont = aFontEntry->LookupUnscaledFont(mFont); + } } gfxGDIFont::~gfxGDIFont() @@ -224,6 +228,12 @@ gfxGDIFont::Initialize() mMetrics = new gfxFont::Metrics; ::memset(mMetrics, 0, sizeof(*mMetrics)); + if (!mFont) { + NS_WARNING("Failed creating GDI font"); + mIsValid = false; + return; + } + AutoDC dc; SetGraphicsMode(dc.GetDC(), GM_ADVANCED); AutoSelectFont selectFont(dc.GetDC(), mFont); diff --git a/gfx/thebes/gfxGDIFontList.cpp b/gfx/thebes/gfxGDIFontList.cpp index 074bdc0efe5a..78c87005b8c5 100644 --- a/gfx/thebes/gfxGDIFontList.cpp +++ b/gfx/thebes/gfxGDIFontList.cpp @@ -33,6 +33,7 @@ #include using namespace mozilla; +using namespace mozilla::gfx; #define ROUND(x) floor((x) + 0.5) @@ -246,6 +247,21 @@ GDIFontEntry::CopyFontTable(uint32_t aTableTag, nsTArray& aBuffer) return NS_ERROR_FAILURE; } +already_AddRefed +GDIFontEntry::LookupUnscaledFont(HFONT aFont) +{ + RefPtr unscaledFont = + static_cast(mUnscaledFont.get()); + if (!unscaledFont) { + LOGFONT lf; + GetObject(aFont, sizeof(LOGFONT), &lf); + unscaledFont = new UnscaledFontGDI(lf); + mUnscaledFont = unscaledFont; + } + + return unscaledFont.forget(); +} + void GDIFontEntry::FillLogFont(LOGFONTW *aLogFont, uint16_t aWeight, gfxFloat aSize) diff --git a/gfx/thebes/gfxGDIFontList.h b/gfx/thebes/gfxGDIFontList.h index fcc71ac5dd04..fff107a28d74 100644 --- a/gfx/thebes/gfxGDIFontList.h +++ b/gfx/thebes/gfxGDIFontList.h @@ -10,6 +10,7 @@ #include "gfxWindowsPlatform.h" #include "gfxPlatformFontList.h" #include "nsGkAtoms.h" +#include "mozilla/gfx/UnscaledFontGDI.h" #include @@ -262,7 +263,7 @@ public: gfxSparseBitSet mUnicodeRanges; protected: - friend class gfxWindowsFont; + friend class gfxGDIFont; GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType, uint8_t aStyle, uint16_t aWeight, int16_t aStretch, @@ -275,7 +276,11 @@ protected: virtual nsresult CopyFontTable(uint32_t aTableTag, nsTArray& aBuffer) override; + already_AddRefed LookupUnscaledFont(HFONT aFont); + LOGFONTW mLogFont; + + mozilla::WeakPtr mUnscaledFont; }; // a single font family, referencing one or more faces diff --git a/gfx/thebes/gfxMacFont.cpp b/gfx/thebes/gfxMacFont.cpp index 2409f5288a7b..aa6a6676fedd 100644 --- a/gfx/thebes/gfxMacFont.cpp +++ b/gfx/thebes/gfxMacFont.cpp @@ -159,9 +159,11 @@ CreateVariationDictionaryOrNull(CGFontRef aCGFont, return dict.forget(); } -gfxMacFont::gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, +gfxMacFont::gfxMacFont(const RefPtr& aUnscaledFont, + MacOSFontEntry *aFontEntry, + const gfxFontStyle *aFontStyle, bool aNeedsBold) - : gfxFont(aFontEntry, aFontStyle), + : gfxFont(aUnscaledFont, aFontEntry, aFontStyle), mCGFont(nullptr), mCTFont(nullptr), mFontFace(nullptr), @@ -170,7 +172,7 @@ gfxMacFont::gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyl mApplySyntheticBold = aNeedsBold; if (mVariationFont && aFontStyle->variationSettings.Length() > 0) { - CGFontRef baseFont = aFontEntry->GetFontRef(); + CGFontRef baseFont = aUnscaledFont->GetFont(); if (!baseFont) { mIsValid = false; return; @@ -185,7 +187,7 @@ gfxMacFont::gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyl mCGFont = baseFont; } } else { - mCGFont = aFontEntry->GetFontRef(); + mCGFont = aUnscaledFont->GetFont(); if (!mCGFont) { mIsValid = false; return; @@ -636,18 +638,22 @@ gfxMacFont::GetScaledFont(DrawTarget *aTarget) NativeFont nativeFont; nativeFont.mType = NativeFontType::MAC_FONT_FACE; nativeFont.mFont = GetCGFontRef(); - mAzureScaledFont = mozilla::gfx::Factory::CreateScaledFontWithCairo(nativeFont, GetAdjustedSize(), mScaledFont); + mAzureScaledFont = + Factory::CreateScaledFontWithCairo(nativeFont, + GetUnscaledFont(), + GetAdjustedSize(), + mScaledFont); } RefPtr scaledFont(mAzureScaledFont); return scaledFont.forget(); } -already_AddRefed +already_AddRefed gfxMacFont::GetGlyphRenderingOptions(const TextRunDrawParams* aRunParams) { if (aRunParams) { - return mozilla::gfx::Factory::CreateCGGlyphRenderingOptions(aRunParams->fontSmoothingBGColor); + return Factory::CreateCGGlyphRenderingOptions(aRunParams->fontSmoothingBGColor); } return nullptr; } diff --git a/gfx/thebes/gfxMacFont.h b/gfx/thebes/gfxMacFont.h index dcc659063b48..2744addb9a63 100644 --- a/gfx/thebes/gfxMacFont.h +++ b/gfx/thebes/gfxMacFont.h @@ -11,12 +11,15 @@ #include "cairo.h" #include +#include "mozilla/gfx/UnscaledFontMac.h" + class MacOSFontEntry; class gfxMacFont : public gfxFont { public: - gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, + gfxMacFont(const RefPtr& aUnscaledFont, + MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, bool aNeedsBold); virtual ~gfxMacFont(); diff --git a/gfx/thebes/gfxMacPlatformFontList.h b/gfx/thebes/gfxMacPlatformFontList.h index 4e826ec15a10..2eb0d4f7e578 100644 --- a/gfx/thebes/gfxMacPlatformFontList.h +++ b/gfx/thebes/gfxMacPlatformFontList.h @@ -20,6 +20,8 @@ #include "nsTArray.h" #include "mozilla/LookAndFeel.h" +#include "mozilla/gfx/UnscaledFontMac.h" + class gfxMacPlatformFontList; // a single member of a font family (i.e. a single face, such as Times Italic) @@ -76,6 +78,8 @@ protected: bool mHasVariations; bool mHasVariationsInitialized; nsTHashtable mAvailableTables; + + mozilla::WeakPtr mUnscaledFont; }; class gfxMacPlatformFontList : public gfxPlatformFontList { diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index c831a633b071..044da068c077 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -75,7 +75,7 @@ #include using namespace mozilla; - +using namespace mozilla::gfx; using mozilla::dom::FontFamilyListEntry; // indexes into the NSArray objects that the Cocoa font manager returns @@ -244,7 +244,18 @@ MacOSFontEntry::ReadCMAP(FontInfoData *aFontInfoData) gfxFont* MacOSFontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold) { - return new gfxMacFont(this, aFontStyle, aNeedsBold); + RefPtr unscaledFont = + static_cast(mUnscaledFont.get()); + if (!unscaledFont) { + CGFontRef baseFont = GetFontRef(); + if (!baseFont) { + return nullptr; + } + unscaledFont = new UnscaledFontMac(baseFont); + mUnscaledFont = unscaledFont; + } + + return new gfxMacFont(unscaledFont, this, aFontStyle, aNeedsBold); } bool diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 5460e57a4480..82167c1b264e 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -1223,6 +1223,7 @@ gfxPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont) nativeFont.mType = NativeFontType::CAIRO_FONT_FACE; nativeFont.mFont = aFont->GetCairoScaledFont(); return Factory::CreateScaledFontForNativeFont(nativeFont, + aFont->GetUnscaledFont(), aFont->GetAdjustedSize()); } @@ -2423,7 +2424,9 @@ gfxPlatform::GetScaledFontForFontWithCairoSkia(DrawTarget* aTarget, gfxFont* aFo if (aTarget->GetBackendType() == BackendType::CAIRO || aTarget->GetBackendType() == BackendType::SKIA) { nativeFont.mType = NativeFontType::CAIRO_FONT_FACE; nativeFont.mFont = aFont->GetCairoScaledFont(); - return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize()); + return Factory::CreateScaledFontForNativeFont(nativeFont, + aFont->GetUnscaledFont(), + aFont->GetAdjustedSize()); } return nullptr; diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index 96dbbef4cb5d..c0d98e3a0382 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -603,6 +603,7 @@ gfxPlatformGtk::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont) return Factory::CreateScaledFontForFontconfigFont( fcFont->GetCairoScaledFont(), fcFont->GetPattern(), + fcFont->GetUnscaledFont(), fcFont->GetAdjustedSize()); } MOZ_FALLTHROUGH; diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index 1410fb040298..3dbace4dd8d5 100755 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -592,11 +592,13 @@ gfxWindowsPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont) if (aTarget->GetBackendType() == BackendType::CAIRO) { return Factory::CreateScaledFontWithCairo(nativeFont, + font->GetUnscaledFont(), font->GetAdjustedSize(), font->GetCairoScaledFont()); } return Factory::CreateScaledFontForNativeFont(nativeFont, + font->GetUnscaledFont(), font->GetAdjustedSize()); } @@ -611,11 +613,14 @@ gfxWindowsPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont) if (aTarget->GetBackendType() == BackendType::CAIRO) { return Factory::CreateScaledFontWithCairo(nativeFont, + aFont->GetUnscaledFont(), aFont->GetAdjustedSize(), aFont->GetCairoScaledFont()); } - return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize()); + return Factory::CreateScaledFontForNativeFont(nativeFont, + aFont->GetUnscaledFont(), + aFont->GetAdjustedSize()); } static const char kFontAparajita[] = "Aparajita"; diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index d22d6e36ee43..84ec06150d4e 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -5025,6 +5025,7 @@ nsDisplayText::nsDisplayText(nsDisplayListBuilder* aBuilder, nsTextFrame* aFrame std::vector glyphs; Color color; if (!capture->ContainsOnlyColoredGlyphs(mFont, color, glyphs) + || !mFont || !mFont->CanSerialize() || XRE_IsParentProcess()) { mFont = nullptr; From 22fb7629b8cadde2f9ff9bb34c2c487cef575df5 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Thu, 6 Apr 2017 17:41:24 -0400 Subject: [PATCH 33/89] Bug 1348980 - use UnscaledFont to track WebRender font keys. r=jrmuizel --- gfx/layers/ipc/PWebRenderBridge.ipdl | 1 + gfx/layers/wr/WebRenderBridgeChild.cpp | 107 ++++++++++++++++++++++++ gfx/layers/wr/WebRenderBridgeChild.h | 33 ++++++++ gfx/layers/wr/WebRenderBridgeParent.cpp | 11 ++- gfx/layers/wr/WebRenderBridgeParent.h | 7 +- gfx/layers/wr/WebRenderLayerManager.cpp | 1 + gfx/layers/wr/WebRenderTextLayer.cpp | 3 +- gfx/layers/wr/WebRenderTextLayer.h | 2 - gfx/thebes/gfxUtils.cpp | 67 --------------- gfx/thebes/gfxUtils.h | 34 +------- gfx/webrender_bindings/WebRenderAPI.cpp | 2 +- gfx/webrender_bindings/src/bindings.rs | 7 ++ gfx/webrender_bindings/webrender_ffi.h | 4 + layout/generic/nsBulletFrame.cpp | 5 +- 14 files changed, 172 insertions(+), 112 deletions(-) diff --git a/gfx/layers/ipc/PWebRenderBridge.ipdl b/gfx/layers/ipc/PWebRenderBridge.ipdl index e767e05e42c4..0e6aba2efe27 100644 --- a/gfx/layers/ipc/PWebRenderBridge.ipdl +++ b/gfx/layers/ipc/PWebRenderBridge.ipdl @@ -46,6 +46,7 @@ parent: SurfaceFormat aFormat, ByteBuffer aBytes); sync DeleteImage(ImageKey aImageKey); async AddRawFont(FontKey aFontKey, ByteBuffer aBytes, uint32_t aFontIndex); + async DeleteFont(FontKey aFontKey); async DPBegin(IntSize aSize); async DPEnd(IntSize aSize, WebRenderParentCommand[] commands, OpDestroy[] toDestroy, uint64_t fwdTransactionId, uint64_t transactionId, ByteBuffer aDL, WrBuiltDisplayListDescriptor aDLDesc, ByteBuffer aAux, WrAuxiliaryListsDescriptor aAuxDesc); diff --git a/gfx/layers/wr/WebRenderBridgeChild.cpp b/gfx/layers/wr/WebRenderBridgeChild.cpp index c5f731ca49a4..1e739164a66e 100644 --- a/gfx/layers/wr/WebRenderBridgeChild.cpp +++ b/gfx/layers/wr/WebRenderBridgeChild.cpp @@ -24,6 +24,7 @@ WebRenderBridgeChild::WebRenderBridgeChild(const wr::PipelineId& aPipelineId) , mPipelineId(aPipelineId) , mIPCOpen(false) , mDestroyed(false) + , mFontKeysDeleted(0) { } @@ -151,6 +152,112 @@ WebRenderBridgeChild::DeallocExternalImageId(uint64_t aImageId) SendRemoveExternalImageId(aImageId); } +struct FontFileData +{ + wr::ByteBuffer mFontBuffer; + uint32_t mFontIndex; + float mGlyphSize; +}; + +static void +WriteFontFileData(const uint8_t* aData, uint32_t aLength, uint32_t aIndex, + float aGlyphSize, uint32_t aVariationCount, + const ScaledFont::VariationSetting* aVariations, void* aBaton) +{ + FontFileData* data = static_cast(aBaton); + + if (!data->mFontBuffer.Allocate(aLength)) { + return; + } + memcpy(data->mFontBuffer.mData, aData, aLength); + + data->mFontIndex = aIndex; + data->mGlyphSize = aGlyphSize; +} + +void +WebRenderBridgeChild::PushGlyphs(wr::DisplayListBuilder& aBuilder, const nsTArray& aGlyphs, + gfx::ScaledFont* aFont, const gfx::Point& aOffset, const gfx::Rect& aBounds, + const gfx::Rect& aClip) +{ + MOZ_ASSERT(aFont); + MOZ_ASSERT(!aGlyphs.IsEmpty()); + + WrFontKey key = GetFontKeyForScaledFont(aFont); + MOZ_ASSERT(key.mNamespace && key.mHandle); + + WrClipRegion clipRegion = aBuilder.BuildClipRegion(wr::ToWrRect(aClip)); + + for (size_t i = 0; i < aGlyphs.Length(); i++) { + GlyphArray glyph_array = aGlyphs[i]; + nsTArray& glyphs = glyph_array.glyphs(); + + nsTArray wr_glyph_instances; + wr_glyph_instances.SetLength(glyphs.Length()); + + for (size_t j = 0; j < glyphs.Length(); j++) { + wr_glyph_instances[j].index = glyphs[j].mIndex; + wr_glyph_instances[j].x = glyphs[j].mPosition.x - aOffset.x; + wr_glyph_instances[j].y = glyphs[j].mPosition.y - aOffset.y; + } + aBuilder.PushText(wr::ToWrRect(aBounds), + clipRegion, + glyph_array.color().value(), + key, + Range(wr_glyph_instances.Elements(), wr_glyph_instances.Length()), + aFont->GetSize()); + + } +} + +wr::FontKey +WebRenderBridgeChild::GetFontKeyForScaledFont(gfx::ScaledFont* aScaledFont) +{ + MOZ_ASSERT(!mDestroyed); + MOZ_ASSERT(aScaledFont); + MOZ_ASSERT((aScaledFont->GetType() == gfx::FontType::DWRITE) || + (aScaledFont->GetType() == gfx::FontType::MAC) || + (aScaledFont->GetType() == gfx::FontType::FONTCONFIG)); + + RefPtr unscaled = aScaledFont->GetUnscaledFont(); + MOZ_ASSERT(unscaled); + + wr::FontKey key = {0, 0}; + if (mFontKeys.Get(unscaled, &key)) { + return key; + } + + FontFileData data; + if (!aScaledFont->GetFontFileData(WriteFontFileData, &data) || + !data.mFontBuffer.mData) { + return key; + } + + key.mNamespace = GetNamespace(); + key.mHandle = GetNextResourceId(); + + SendAddRawFont(key, data.mFontBuffer, data.mFontIndex); + + mFontKeys.Put(unscaled, key); + + return key; +} + +void +WebRenderBridgeChild::RemoveExpiredFontKeys() +{ + uint32_t counter = UnscaledFont::DeletionCounter(); + if (mFontKeysDeleted != counter) { + mFontKeysDeleted = counter; + for (auto iter = mFontKeys.Iter(); !iter.Done(); iter.Next()) { + if (!iter.Key()) { + SendDeleteFont(iter.Data()); + iter.Remove(); + } + } + } +} + CompositorBridgeChild* WebRenderBridgeChild::GetCompositorBridgeChild() { diff --git a/gfx/layers/wr/WebRenderBridgeChild.h b/gfx/layers/wr/WebRenderBridgeChild.h index d39ce3e0db65..7a673b233a13 100644 --- a/gfx/layers/wr/WebRenderBridgeChild.h +++ b/gfx/layers/wr/WebRenderBridgeChild.h @@ -26,6 +26,28 @@ class CompositableClient; class CompositorBridgeChild; class TextureForwarder; +class UnscaledFontHashKey : public PLDHashEntryHdr +{ +public: + typedef gfx::UnscaledFont* KeyType; + typedef const gfx::UnscaledFont* KeyTypePointer; + + explicit UnscaledFontHashKey(KeyTypePointer aKey) : mKey(const_cast(aKey)) {} + + KeyType GetKey() const { return mKey; } + bool KeyEquals(KeyTypePointer aKey) const { return aKey == mKey; } + + static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; } + static PLDHashNumber HashKey(KeyTypePointer aKey) + { + return NS_PTR_TO_UINT32(aKey) >> 2; + } + enum { ALLOW_MEMMOVE = true }; + +private: + WeakPtr mKey; +}; + class WebRenderBridgeChild final : public PWebRenderBridgeChild , public CompositableForwarder { @@ -67,6 +89,14 @@ public: mIdNamespace = aIdNamespace; } + void PushGlyphs(wr::DisplayListBuilder& aBuilder, const nsTArray& aGlyphs, + gfx::ScaledFont* aFont, const gfx::Point& aOffset, const gfx::Rect& aBounds, + const gfx::Rect& aClip); + + wr::FontKey GetFontKeyForScaledFont(gfx::ScaledFont* aScaledFont); + + void RemoveExpiredFontKeys(); + private: friend class CompositorBridgeChild; @@ -123,6 +153,9 @@ private: bool mIPCOpen; bool mDestroyed; + + uint32_t mFontKeysDeleted; + nsDataHashtable mFontKeys; }; } // namespace layers diff --git a/gfx/layers/wr/WebRenderBridgeParent.cpp b/gfx/layers/wr/WebRenderBridgeParent.cpp index ab8c87321030..8c31960a5ac6 100644 --- a/gfx/layers/wr/WebRenderBridgeParent.cpp +++ b/gfx/layers/wr/WebRenderBridgeParent.cpp @@ -226,7 +226,16 @@ WebRenderBridgeParent::RecvAddRawFont(const wr::FontKey& aFontKey, return IPC_OK(); } - +mozilla::ipc::IPCResult +WebRenderBridgeParent::RecvDeleteFont(const wr::FontKey& aFontKey) +{ + if (mDestroyed) { + return IPC_OK(); + } + MOZ_ASSERT(mApi); + mApi->DeleteFont(aFontKey); + return IPC_OK(); +} mozilla::ipc::IPCResult WebRenderBridgeParent::RecvUpdateImage(const wr::ImageKey& aImageKey, diff --git a/gfx/layers/wr/WebRenderBridgeParent.h b/gfx/layers/wr/WebRenderBridgeParent.h index b63b393f9e07..06c7a2369b24 100644 --- a/gfx/layers/wr/WebRenderBridgeParent.h +++ b/gfx/layers/wr/WebRenderBridgeParent.h @@ -73,14 +73,15 @@ public: const uint32_t& aStride, const gfx::SurfaceFormat& aFormat, const ByteBuffer& aBuffer) override; - mozilla::ipc::IPCResult RecvAddRawFont(const wr::FontKey& aFontKey, - const ByteBuffer& aBuffer, - const uint32_t& aFontIndex) override; mozilla::ipc::IPCResult RecvUpdateImage(const wr::ImageKey& aImageKey, const gfx::IntSize& aSize, const gfx::SurfaceFormat& aFormat, const ByteBuffer& aBuffer) override; mozilla::ipc::IPCResult RecvDeleteImage(const wr::ImageKey& a1) override; + mozilla::ipc::IPCResult RecvAddRawFont(const wr::FontKey& aFontKey, + const ByteBuffer& aBuffer, + const uint32_t& aFontIndex) override; + mozilla::ipc::IPCResult RecvDeleteFont(const wr::FontKey& aFontKey) override; mozilla::ipc::IPCResult RecvDPBegin(const gfx::IntSize& aSize) override; mozilla::ipc::IPCResult RecvDPEnd(const gfx::IntSize& aSize, InfallibleTArray&& aCommands, diff --git a/gfx/layers/wr/WebRenderLayerManager.cpp b/gfx/layers/wr/WebRenderLayerManager.cpp index f723f3cad9a8..f8c81da1a2ec 100644 --- a/gfx/layers/wr/WebRenderLayerManager.cpp +++ b/gfx/layers/wr/WebRenderLayerManager.cpp @@ -288,6 +288,7 @@ WebRenderLayerManager::EndTransaction(DrawPaintedLayerCallback aCallback, EndTransactionFlags aFlags) { DiscardImages(); + WrBridge()->RemoveExpiredFontKeys(); mPaintedLayerCallback = aCallback; mPaintedLayerCallbackData = aCallbackData; diff --git a/gfx/layers/wr/WebRenderTextLayer.cpp b/gfx/layers/wr/WebRenderTextLayer.cpp index 83f6f1afea31..afc5608229be 100644 --- a/gfx/layers/wr/WebRenderTextLayer.cpp +++ b/gfx/layers/wr/WebRenderTextLayer.cpp @@ -39,8 +39,7 @@ WebRenderTextLayer::RenderLayer(wr::DisplayListBuilder& aBuilder) Stringify(clip).c_str()); } - mGlyphHelper.BuildWebRenderCommands(WrBridge(), aBuilder, mGlyphs, mFont, - GetOffsetToParent(), rect, clip); + WrBridge()->PushGlyphs(aBuilder, mGlyphs, mFont, GetOffsetToParent(), rect, clip); } } // namespace layers diff --git a/gfx/layers/wr/WebRenderTextLayer.h b/gfx/layers/wr/WebRenderTextLayer.h index 889ed49c49a2..4f80aaccebfc 100644 --- a/gfx/layers/wr/WebRenderTextLayer.h +++ b/gfx/layers/wr/WebRenderTextLayer.h @@ -33,8 +33,6 @@ public: Layer* GetLayer() override { return this; } void RenderLayer(wr::DisplayListBuilder& aBuilder) override; -protected: - gfx::WebRenderGlyphHelper mGlyphHelper; }; } // namespace layers diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index a426becec4d9..fff0872c6cf7 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -21,14 +21,10 @@ #include "mozilla/gfx/Logging.h" #include "mozilla/gfx/PathHelpers.h" #include "mozilla/gfx/Swizzle.h" -#include "mozilla/layers/WebRenderMessages.h" #include "mozilla/Maybe.h" #include "mozilla/RefPtr.h" #include "mozilla/UniquePtrExtensions.h" #include "mozilla/Vector.h" -#include "mozilla/webrender/WebRenderTypes.h" -#include "mozilla/webrender/WebRenderAPI.h" -#include "mozilla/layers/WebRenderBridgeChild.h" #include "nsComponentManagerUtils.h" #include "nsIClipboardHelper.h" #include "nsIFile.h" @@ -1443,68 +1439,5 @@ Color ToDeviceColor(nscolor aColor) return ToDeviceColor(Color::FromABGR(aColor)); } -static void -WriteFontFileData(const uint8_t* aData, uint32_t aLength, uint32_t aIndex, - float aGlyphSize, uint32_t aVariationCount, - const ScaledFont::VariationSetting* aVariations, void* aBaton) -{ - WebRenderGlyphHelper* helper = static_cast(aBaton); - - uint8_t* fontData = (uint8_t*)malloc(aLength * sizeof(uint8_t)); - memcpy(fontData, aData, aLength * sizeof(uint8_t)); - - helper->mFontData = fontData; - helper->mFontDataLength = aLength; - helper->mIndex = aIndex; - helper->mGlyphSize = aGlyphSize; -} - -void -WebRenderGlyphHelper::BuildWebRenderCommands(WebRenderBridgeChild* aBridge, - wr::DisplayListBuilder& aBuilder, - const nsTArray& aGlyphs, - ScaledFont* aFont, - const Point& aOffset, - const Rect& aBounds, - const Rect& aClip) -{ - MOZ_ASSERT(aFont); - MOZ_ASSERT(!aGlyphs.IsEmpty()); - MOZ_ASSERT((aFont->GetType() == gfx::FontType::DWRITE) || - (aFont->GetType() == gfx::FontType::MAC)); - - aFont->GetFontFileData(&WriteFontFileData, this); - wr::ByteBuffer fontBuffer(mFontDataLength, mFontData); - - WrFontKey key; - key.mNamespace = aBridge->GetNamespace(); - key.mHandle = aBridge->GetNextResourceId(); - - aBridge->SendAddRawFont(key, fontBuffer, mIndex); - - WrClipRegion clipRegion = aBuilder.BuildClipRegion(wr::ToWrRect(aClip)); - - for (size_t i = 0; i < aGlyphs.Length(); i++) { - GlyphArray glyph_array = aGlyphs[i]; - nsTArray& glyphs = glyph_array.glyphs(); - - nsTArray wr_glyph_instances; - wr_glyph_instances.SetLength(glyphs.Length()); - - for (size_t j = 0; j < glyphs.Length(); j++) { - wr_glyph_instances[j].index = glyphs[j].mIndex; - wr_glyph_instances[j].x = glyphs[j].mPosition.x - aOffset.x; - wr_glyph_instances[j].y = glyphs[j].mPosition.y - aOffset.y; - } - aBuilder.PushText(wr::ToWrRect(aBounds), - clipRegion, - glyph_array.color().value(), - key, - Range(wr_glyph_instances.Elements(), wr_glyph_instances.Length()), - mGlyphSize); - - } -} - } // namespace gfx } // namespace mozilla diff --git a/gfx/thebes/gfxUtils.h b/gfx/thebes/gfxUtils.h index 313571b966b6..2100a3aa3f35 100644 --- a/gfx/thebes/gfxUtils.h +++ b/gfx/thebes/gfxUtils.h @@ -17,7 +17,7 @@ #include "nsRegionFwd.h" #include "mozilla/gfx/Rect.h" #include "mozilla/CheckedInt.h" -#include "mozilla/webrender/webrender_ffi.h" +#include "mozilla/webrender/WebRenderTypes.h" class gfxASurface; class gfxDrawable; @@ -313,38 +313,6 @@ SafeBytesForBitmap(uint32_t aWidth, uint32_t aHeight, unsigned aBytesPerPixel) return width * height * aBytesPerPixel; } -class WebRenderGlyphHelper final { -public: - WebRenderGlyphHelper() - : mFontData(nullptr) - , mFontDataLength(0) - , mIndex(0) - , mGlyphSize(0.0) - { - } - - ~WebRenderGlyphHelper() - { - if (mFontData) { - free(mFontData); - } - } - - void BuildWebRenderCommands(layers::WebRenderBridgeChild* aChild, - wr::DisplayListBuilder& aBuilder, - const nsTArray& aGlyphs, - ScaledFont* aFont, - const Point& aOffset, - const Rect& aBounds, - const Rect& aClip); - -public: - uint8_t* mFontData; - uint32_t mFontDataLength; - uint32_t mIndex; - float mGlyphSize; -}; - } // namespace gfx } // namespace mozilla diff --git a/gfx/webrender_bindings/WebRenderAPI.cpp b/gfx/webrender_bindings/WebRenderAPI.cpp index 429c3fff8277..2057e3f58438 100644 --- a/gfx/webrender_bindings/WebRenderAPI.cpp +++ b/gfx/webrender_bindings/WebRenderAPI.cpp @@ -445,7 +445,7 @@ WebRenderAPI::AddRawFont(wr::FontKey key, Range aBytes) void WebRenderAPI::DeleteFont(wr::FontKey aKey) { - printf("XXX - WebRender does not seem to implement deleting a font! Leaking it...\n"); + wr_api_delete_font(mWrApi, aKey); } class EnableProfiler : public RendererEvent diff --git a/gfx/webrender_bindings/src/bindings.rs b/gfx/webrender_bindings/src/bindings.rs index d7b0b9ff82da..c96d56873172 100644 --- a/gfx/webrender_bindings/src/bindings.rs +++ b/gfx/webrender_bindings/src/bindings.rs @@ -941,6 +941,13 @@ pub extern "C" fn wr_api_add_raw_font(api: &mut RenderApi, api.add_raw_font(key, font_vector); } +#[no_mangle] +pub extern "C" fn wr_api_delete_font(api: &mut RenderApi, key: FontKey) +{ + assert!( unsafe { is_in_compositor_thread() }); + api.delete_font(key); +} + #[no_mangle] pub unsafe extern "C" fn wr_api_get_namespace(api: &mut RenderApi) -> IdNamespace { api.id_namespace diff --git a/gfx/webrender_bindings/webrender_ffi.h b/gfx/webrender_bindings/webrender_ffi.h index 3060738c6589..b1a0e52d87ab 100644 --- a/gfx/webrender_bindings/webrender_ffi.h +++ b/gfx/webrender_bindings/webrender_ffi.h @@ -601,6 +601,10 @@ WR_INLINE void wr_api_add_raw_font(WrAPI* api, WrFontKey key, uint8_t* font_buffer, size_t buffer_size) WR_FUNC; +WR_INLINE void +wr_api_delete_font(WrAPI* api, WrFontKey key) +WR_FUNC; + WR_INLINE WrIdNamespace wr_api_get_namespace(WrAPI* api) WR_FUNC; diff --git a/layout/generic/nsBulletFrame.cpp b/layout/generic/nsBulletFrame.cpp index 80d5afb53548..7ba8b022a143 100644 --- a/layout/generic/nsBulletFrame.cpp +++ b/layout/generic/nsBulletFrame.cpp @@ -309,7 +309,6 @@ private: nsPoint mPoint; RefPtr mFont; nsTArray mGlyphs; - WebRenderGlyphHelper mGlyphHelper; // Store the type of list-style-type. int32_t mListStyleType; @@ -506,8 +505,8 @@ BulletRenderer::CreateWebRenderCommandsForText(nsDisplayItem* aItem, NSRectToRect(aItem->GetBounds(builder, &dummy), appUnitsPerDevPixel); Rect destRectTransformed = aLayer->RelativeToParent(destRect); - mGlyphHelper.BuildWebRenderCommands(layer->WrBridge(), aBuilder, mGlyphs, mFont, aLayer->GetOffsetToParent(), - destRectTransformed, destRectTransformed); + layer->WrBridge()->PushGlyphs(aBuilder, mGlyphs, mFont, aLayer->GetOffsetToParent(), + destRectTransformed, destRectTransformed); } class nsDisplayBullet final : public nsDisplayItem { From 06dfd98d7d53d64b5b02458099b9cc0dfef022ed Mon Sep 17 00:00:00 2001 From: Doug Thayer Date: Thu, 6 Apr 2017 15:09:16 -0700 Subject: [PATCH 34/89] Bug 893505 - Simplify the application update UI. r=Gijs, r=enndeakin, r=rstrong, data-r=bsmedberg There are quite a few changes in here. At a high level, all we're trying to do is to replace the old update popup with a less intrusive and more modern doorhanger (set of doorhangers) for various update success and failure conditions. --- browser/app/profile/firefox.js | 17 +- browser/base/content/browser-addons.js | 5 +- .../browser-fullScreenAndPointerLock.js | 10 +- browser/base/content/browser-fxaccounts.js | 4 +- browser/base/content/browser.css | 2 +- browser/base/content/browser.js | 344 +++++++++-------- .../base/content/test/appUpdate/.eslintrc.js | 7 + .../base/content/test/appUpdate/browser.ini | 22 ++ .../appUpdate/browser_updatesBasicPrompt.js | 28 ++ .../browser_updatesBasicPromptNoStaging.js | 22 ++ ...eteAndPartialPatchesWithBadCompleteSize.js | 13 + ...leteAndPartialPatchesWithBadPartialSize.js | 13 + ...esCompleteAndPartialPatchesWithBadSizes.js | 33 ++ ...rowser_updatesCompletePatchApplyFailure.js | 25 ++ ...updatesCompletePatchWithBadCompleteSize.js | 34 ++ .../browser_updatesDownloadFailures.js | 37 ++ .../appUpdate/browser_updatesMalformedXml.js | 29 ++ ...browser_updatesPartialPatchApplyFailure.js | 26 ++ ...lPatchApplyFailureWithCompleteAvailable.js | 22 ++ ...plyFailureWithCompleteValidationFailure.js | 33 ++ ...r_updatesPartialPatchWithBadPartialSize.js | 33 ++ .../content/test/appUpdate/downloadPage.html | 13 + browser/base/content/test/appUpdate/head.js | 361 ++++++++++++++++++ .../content/test/appUpdate/testConstants.js | 4 + browser/base/content/test/general/browser.ini | 1 - .../general/browser_menuButtonBadgeManager.js | 46 --- browser/base/moz.build | 10 + .../official/pref/firefox-branding.js | 4 +- .../customizableui/content/panelUI.inc.xul | 75 +++- .../customizableui/content/panelUI.js | 361 +++++++++++++++++- .../customizableui/test/browser.ini | 1 + .../test/browser_panelUINotifications.js | 305 +++++++++++++++ .../components/downloads/content/indicator.js | 6 +- .../locales/en-US/chrome/browser/browser.dtd | 28 ++ .../en-US/chrome/browser/browser.properties | 9 - .../shared/customizableui/panelUI.inc.css | 100 +++-- .../themes/shared/notification-icons.inc.css | 8 + browser/themes/shared/notification-icons.svg | 8 + browser/themes/shared/update-badge.svg | 4 +- testing/talos/talos/config.py | 1 - toolkit/components/telemetry/Histograms.json | 36 ++ toolkit/mozapps/update/nsUpdateService.js | 105 ++++- .../mozapps/update/tests/chrome/chrome.ini | 1 + .../update/tests/chrome/testConstants.js | 4 + .../mozapps/update/tests/chrome/update.sjs | 27 +- toolkit/mozapps/update/tests/chrome/utils.js | 16 +- toolkit/mozapps/update/tests/data/shared.js | 37 +- .../update/tests/data/sharedUpdateXML.js | 6 +- .../update/tests/data/xpcshellUtilsAUS.js | 2 + .../updater/updater-xpcshell/Makefile.in | 29 +- 50 files changed, 1997 insertions(+), 370 deletions(-) create mode 100644 browser/base/content/test/appUpdate/.eslintrc.js create mode 100644 browser/base/content/test/appUpdate/browser.ini create mode 100644 browser/base/content/test/appUpdate/browser_updatesBasicPrompt.js create mode 100644 browser/base/content/test/appUpdate/browser_updatesBasicPromptNoStaging.js create mode 100644 browser/base/content/test/appUpdate/browser_updatesCompleteAndPartialPatchesWithBadCompleteSize.js create mode 100644 browser/base/content/test/appUpdate/browser_updatesCompleteAndPartialPatchesWithBadPartialSize.js create mode 100644 browser/base/content/test/appUpdate/browser_updatesCompleteAndPartialPatchesWithBadSizes.js create mode 100644 browser/base/content/test/appUpdate/browser_updatesCompletePatchApplyFailure.js create mode 100644 browser/base/content/test/appUpdate/browser_updatesCompletePatchWithBadCompleteSize.js create mode 100644 browser/base/content/test/appUpdate/browser_updatesDownloadFailures.js create mode 100644 browser/base/content/test/appUpdate/browser_updatesMalformedXml.js create mode 100644 browser/base/content/test/appUpdate/browser_updatesPartialPatchApplyFailure.js create mode 100644 browser/base/content/test/appUpdate/browser_updatesPartialPatchApplyFailureWithCompleteAvailable.js create mode 100644 browser/base/content/test/appUpdate/browser_updatesPartialPatchApplyFailureWithCompleteValidationFailure.js create mode 100644 browser/base/content/test/appUpdate/browser_updatesPartialPatchWithBadPartialSize.js create mode 100644 browser/base/content/test/appUpdate/downloadPage.html create mode 100644 browser/base/content/test/appUpdate/head.js create mode 100644 browser/base/content/test/appUpdate/testConstants.js delete mode 100644 browser/base/content/test/general/browser_menuButtonBadgeManager.js create mode 100644 browser/components/customizableui/test/browser_panelUINotifications.js create mode 100644 toolkit/mozapps/update/tests/chrome/testConstants.js diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 9a75ce3ed95a..7ca5d3e888b3 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -115,6 +115,17 @@ pref("app.update.backgroundMaxErrors", 10); // Whether or not app updates are enabled pref("app.update.enabled", true); +// Whether or not to use the doorhanger application update UI. +pref("app.update.doorhanger", true); + +// How many times we should let downloads fail before prompting the user to +// download a fresh installer. +pref("app.update.download.promptMaxAttempts", 2); + +// How many times we should let an elevation prompt fail before prompting the user to +// download a fresh installer. +pref("app.update.elevation.promptMaxAttempts", 2); + // If set to true, the Update Service will automatically download updates when // app updates are enabled per the app.update.enabled preference and if the user // can apply updates. @@ -123,12 +134,6 @@ pref("app.update.auto", true); // If set to true, the Update Service will present no UI for any event. pref("app.update.silent", false); -// If set to true, the hamburger button will show badges for update events. -#ifndef RELEASE_OR_BETA -pref("app.update.badge", true); -#else -pref("app.update.badge", false); -#endif // app.update.badgeWaitTime is in branding section // If set to true, the Update Service will apply updates in the background diff --git a/browser/base/content/browser-addons.js b/browser/base/content/browser-addons.js index 02dccc4cbdc1..fd58d6a43a20 100644 --- a/browser/base/content/browser-addons.js +++ b/browser/base/content/browser-addons.js @@ -504,10 +504,9 @@ const gExtensionsNotifications = { let sideloaded = ExtensionsUI.sideloaded; let updates = ExtensionsUI.updates; if (sideloaded.size + updates.size == 0) { - gMenuButtonBadgeManager.removeBadge(gMenuButtonBadgeManager.BADGEID_ADDONS); + PanelUI.removeNotification("addon-alert"); } else { - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_ADDONS, - "addon-alert"); + PanelUI.showBadgeOnlyNotification("addon-alert"); } let container = document.getElementById("PanelUI-footer-addons"); diff --git a/browser/base/content/browser-fullScreenAndPointerLock.js b/browser/base/content/browser-fullScreenAndPointerLock.js index a84c36618902..ea62dc4c0c86 100644 --- a/browser/base/content/browser-fullScreenAndPointerLock.js +++ b/browser/base/content/browser-fullScreenAndPointerLock.js @@ -537,7 +537,8 @@ var FullScreen = { // e.g. we wouldn't want the autoscroll icon firing this event, so when the user // toggles chrome when moving mouse to the top, it doesn't go away again. if (aEvent.type == "popupshown" && !FullScreen._isChromeCollapsed && - aEvent.target.localName != "tooltip" && aEvent.target.localName != "window") + aEvent.target.localName != "tooltip" && aEvent.target.localName != "window" && + aEvent.target.getAttribute("nopreventnavboxhide") != "true") FullScreen._isPopupOpen = true; else if (aEvent.type == "popuphidden" && aEvent.target.localName != "tooltip" && aEvent.target.localName != "window") { @@ -547,6 +548,10 @@ var FullScreen = { } }, + get navToolboxHidden() { + return this._isChromeCollapsed; + }, + // Autohide helpers for the context menu item getAutohide(aItem) { aItem.setAttribute("checked", gPrefService.getBoolPref("browser.fullscreen.autohide")); @@ -579,6 +584,7 @@ var FullScreen = { } this._isChromeCollapsed = false; + Services.obs.notifyObservers(null, "fullscreen-nav-toolbox", "shown"); }, hideNavToolbox(aAnimate = false) { @@ -602,6 +608,8 @@ var FullScreen = { gNavToolbox.style.marginTop = -gNavToolbox.getBoundingClientRect().height + "px"; this._isChromeCollapsed = true; + Services.obs.notifyObservers(null, "fullscreen-nav-toolbox", "hidden"); + MousePosTracker.removeListener(this); }, diff --git a/browser/base/content/browser-fxaccounts.js b/browser/base/content/browser-fxaccounts.js index f3e48aa51ae2..19284e0b7e22 100644 --- a/browser/base/content/browser-fxaccounts.js +++ b/browser/base/content/browser-fxaccounts.js @@ -217,9 +217,9 @@ var gFxAccounts = { } } if (showErrorBadge) { - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_FXA, "fxa-needs-authentication"); + PanelUI.showBadgeOnlyNotification("fxa-needs-authentication"); } else { - gMenuButtonBadgeManager.removeBadge(gMenuButtonBadgeManager.BADGEID_FXA); + PanelUI.removeNotification("fxa-needs-authentication"); } } diff --git a/browser/base/content/browser.css b/browser/base/content/browser.css index 089f5d1f7745..dfac617830d1 100644 --- a/browser/base/content/browser.css +++ b/browser/base/content/browser.css @@ -1183,7 +1183,7 @@ toolbarpaletteitem[place="palette"][hidden] { max-width: 10em; } -#main-window[customizing=true] #PanelUI-update-status { +#main-window[customizing=true] .PanelUI-notification-menu-item { display: none; } diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index ffe519f5a15c..3f9c10548ea3 100755 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1515,8 +1515,6 @@ var gBrowserInit = { gBrowserThumbnails.init(); - gMenuButtonBadgeManager.init(); - gMenuButtonUpdateBadge.init(); gExtensionsNotifications.init(); @@ -1693,8 +1691,6 @@ var gBrowserInit = { gMenuButtonUpdateBadge.uninit(); - gMenuButtonBadgeManager.uninit(); - SidebarUI.uninit(); // Now either cancel delayedStartup, or clean up the services initialized from @@ -2749,185 +2745,217 @@ function PageProxyClickHandler(aEvent) { middleMousePaste(aEvent); } -var gMenuButtonBadgeManager = { - BADGEID_APPUPDATE: "update", - BADGEID_DOWNLOAD: "download", - BADGEID_FXA: "fxa", - BADGEID_ADDONS: "addons", - - fxaBadge: null, - downloadBadge: null, - appUpdateBadge: null, - addonsBadge: null, - - init() { - PanelUI.panel.addEventListener("popupshowing", this, true); - }, - - uninit() { - PanelUI.panel.removeEventListener("popupshowing", this, true); - }, - - handleEvent(e) { - if (e.type === "popupshowing") { - this.clearBadges(); - } - }, - - _showBadge() { - let badgeToShow = this.downloadBadge || this.appUpdateBadge || this.fxaBadge || this.addonsBadge; - - if (badgeToShow) { - PanelUI.menuButton.setAttribute("badge-status", badgeToShow); - } else { - PanelUI.menuButton.removeAttribute("badge-status"); - } - }, - - _changeBadge(badgeId, badgeStatus = null) { - if (badgeId == this.BADGEID_APPUPDATE) { - this.appUpdateBadge = badgeStatus; - } else if (badgeId == this.BADGEID_DOWNLOAD) { - this.downloadBadge = badgeStatus; - } else if (badgeId == this.BADGEID_FXA) { - this.fxaBadge = badgeStatus; - } else if (badgeId == this.BADGEID_ADDONS) { - this.addonsBadge = badgeStatus; - } else { - Cu.reportError("The badge ID '" + badgeId + "' is unknown!"); - } - this._showBadge(); - }, - - addBadge(badgeId, badgeStatus) { - if (!badgeStatus) { - Cu.reportError("badgeStatus must be defined"); - return; - } - this._changeBadge(badgeId, badgeStatus); - }, - - removeBadge(badgeId) { - this._changeBadge(badgeId); - }, - - clearBadges() { - this.appUpdateBadge = null; - this.downloadBadge = null; - this.fxaBadge = null; - this._showBadge(); - } -}; - // Setup the hamburger button badges for updates, if enabled. var gMenuButtonUpdateBadge = { - enabled: false, - badgeWaitTime: 0, - timer: null, - cancelObserverRegistered: false, + kTopics: [ + "update-staged", + "update-downloaded", + "update-available", + "update-error", + ], + + timeouts: [], + + get enabled() { + return Services.prefs.getBoolPref("app.update.doorhanger", false); + }, + + get badgeWaitTime() { + return Services.prefs.getIntPref("app.update.badgeWaitTime", 4 * 24 * 3600); // 4 days + }, init() { - this.enabled = Services.prefs.getBoolPref("app.update.badge", false); if (this.enabled) { - this.badgeWaitTime = Services.prefs.getIntPref("app.update.badgeWaitTime", - 345600); // 4 days - Services.obs.addObserver(this, "update-staged", false); - Services.obs.addObserver(this, "update-downloaded", false); + this.kTopics.forEach(t => { + Services.obs.addObserver(this, t, false); + }); } }, uninit() { - if (this.timer) - this.timer.cancel(); if (this.enabled) { - Services.obs.removeObserver(this, "update-staged"); - Services.obs.removeObserver(this, "update-downloaded"); - this.enabled = false; + this.kTopics.forEach(t => { + Services.obs.removeObserver(this, t); + }); } - if (this.cancelObserverRegistered) { - Services.obs.removeObserver(this, "update-canceled"); - this.cancelObserverRegistered = false; + + this.reset(); + }, + + reset() { + PanelUI.removeNotification(/^update-/); + this.clearCallbacks(); + }, + + clearCallbacks() { + this.timeouts.forEach(t => clearTimeout(t)); + this.timeouts = []; + }, + + addTimeout(time, callback) { + this.timeouts.push(setTimeout(() => { + this.clearCallbacks(); + callback(); + }, time)); + }, + + replaceReleaseNotes(update, whatsNewId) { + let whatsNewLink = document.getElementById(whatsNewId); + if (update && update.detailsURL) { + whatsNewLink.href = update.detailsURL; + } else { + whatsNewLink.href = Services.urlFormatter.formatURLPref("app.update.url.details"); } }, - onMenuPanelCommand(event) { - if (event.originalTarget.getAttribute("update-status") === "succeeded") { - // restart the app - let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"] - .createInstance(Ci.nsISupportsPRBool); - Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart"); + requestRestart() { + let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"] + .createInstance(Ci.nsISupportsPRBool); + Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart"); - if (!cancelQuit.data) { - Services.startup.quit(Services.startup.eAttemptQuit | Services.startup.eRestart); + if (!cancelQuit.data) { + Services.startup.quit(Services.startup.eAttemptQuit | Services.startup.eRestart); + } + }, + + openManualUpdateUrl() { + let manualUpdateUrl = Services.urlFormatter.formatURLPref("app.update.url.manual"); + openUILinkIn(manualUpdateUrl, "tab"); + }, + + showUpdateNotification(type, dismissed, mainAction) { + let action = { + callback(fromDoorhanger) { + if (fromDoorhanger) { + Services.telemetry.getHistogramById("UPDATE_NOTIFICATION_MAIN_ACTION_DOORHANGER").add(type); + } else { + Services.telemetry.getHistogramById("UPDATE_NOTIFICATION_MAIN_ACTION_MENU").add(type); + } + mainAction(); } - } else { - // open the page for manual update - let url = Services.urlFormatter.formatURLPref("app.update.url.manual"); - openUILinkIn(url, "tab"); + }; + + let secondaryAction = { + callback() { + Services.telemetry.getHistogramById("UPDATE_NOTIFICATION_DISMISSED").add(type); + }, + dismiss: true + }; + + PanelUI.showNotification("update-" + type, action, [secondaryAction], { dismissed }); + Services.telemetry.getHistogramById("UPDATE_NOTIFICATION_SHOWN").add(type); + }, + + showRestartNotification(dismissed) { + this.showUpdateNotification("restart", dismissed, () => gMenuButtonUpdateBadge.requestRestart()); + }, + + showUpdateAvailableNotification(update, dismissed) { + this.replaceReleaseNotes(update, "update-available-whats-new"); + this.showUpdateNotification("available", dismissed, () => { + let updateService = Cc["@mozilla.org/updates/update-service;1"] + .getService(Ci.nsIApplicationUpdateService); + updateService.downloadUpdate(update, true); + }); + }, + + showManualUpdateNotification(update, dismissed) { + this.replaceReleaseNotes(update, "update-manual-whats-new"); + + this.showUpdateNotification("manual", dismissed, () => gMenuButtonUpdateBadge.openManualUpdateUrl()); + }, + + handleUpdateError(update, status) { + switch (status) { + case "download-attempt-failed": + this.clearCallbacks(); + this.showUpdateAvailableNotification(update, false); + break; + case "download-attempts-exceeded": + this.clearCallbacks(); + this.showManualUpdateNotification(update, false); + break; + case "elevation-attempt-failed": + this.clearCallbacks(); + this.showRestartNotification(update, false); + break; + case "elevation-attempts-exceeded": + this.clearCallbacks(); + this.showManualUpdateNotification(update, false); + break; + case "check-attempts-exceeded": + case "unknown": + // Background update has failed, let's show the UI responsible for + // prompting the user to update manually. + this.clearCallbacks(); + this.showManualUpdateNotification(update, false); + break; + } + }, + + handleUpdateStagedOrDownloaded(update, status) { + switch (status) { + case "applied": + case "pending": + case "applied-service": + case "pending-service": + case "success": + this.clearCallbacks(); + + let badgeWaitTimeMs = this.badgeWaitTime * 1000; + let doorhangerWaitTimeMs = update.promptWaitTime * 1000; + + if (badgeWaitTimeMs < doorhangerWaitTimeMs) { + this.addTimeout(badgeWaitTimeMs, () => { + this.showRestartNotification(true); + + // doorhangerWaitTimeMs is relative to when we initially received + // the event. Since we've already waited badgeWaitTimeMs, subtract + // that from doorhangerWaitTimeMs. + let remainingTime = doorhangerWaitTimeMs - badgeWaitTimeMs; + this.addTimeout(remainingTime, () => { + this.showRestartNotification(false); + }); + }); + } else { + this.addTimeout(doorhangerWaitTimeMs, () => { + this.showRestartNotification(false); + }); + } + break; + } + }, + + handleUpdateAvailable(update, status) { + switch (status) { + case "show-prompt": + // If an update is available and had the showPrompt flag set, then + // show an update available doorhanger. + this.clearCallbacks(); + this.showUpdateAvailableNotification(update, false); + break; } }, observe(subject, topic, status) { - if (topic == "update-canceled") { - this.reset(); - return; - } - if (status == "failed") { - // Background update has failed, let's show the UI responsible for - // prompting the user to update manually. - this.uninit(); - this.displayBadge(false); + if (!this.enabled) { return; } - // Give the user badgeWaitTime seconds to react before prompting. - this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); - this.timer.initWithCallback(this, this.badgeWaitTime * 1000, - this.timer.TYPE_ONE_SHOT); - // The timer callback will call uninit() when it completes. - }, + let update = subject && subject.QueryInterface(Ci.nsIUpdate); - notify() { - // If the update is successfully applied, or if the updater has fallen back - // to non-staged updates, add a badge to the hamburger menu to indicate an - // update will be applied once the browser restarts. - this.uninit(); - this.displayBadge(true); - }, - - displayBadge(succeeded) { - let status = succeeded ? "succeeded" : "failed"; - let badgeStatus = "update-" + status; - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_APPUPDATE, badgeStatus); - - let stringId; - let updateButtonText; - if (succeeded) { - let brandBundle = document.getElementById("bundle_brand"); - let brandShortName = brandBundle.getString("brandShortName"); - stringId = "appmenu.restartNeeded.description"; - updateButtonText = gNavigatorBundle.getFormattedString(stringId, - [brandShortName]); - Services.obs.addObserver(this, "update-canceled", false); - this.cancelObserverRegistered = true; - } else { - stringId = "appmenu.updateFailed.description"; - updateButtonText = gNavigatorBundle.getString(stringId); + switch (topic) { + case "update-available": + this.handleUpdateAvailable(update, status); + break; + case "update-staged": + case "update-downloaded": + this.handleUpdateStagedOrDownloaded(update, status); + break; + case "update-error": + this.handleUpdateError(update, status); + break; } - - let updateButton = document.getElementById("PanelUI-update-status"); - updateButton.setAttribute("label", updateButtonText); - updateButton.setAttribute("update-status", status); - updateButton.hidden = false; - }, - - reset() { - gMenuButtonBadgeManager.removeBadge( - gMenuButtonBadgeManager.BADGEID_APPUPDATE); - let updateButton = document.getElementById("PanelUI-update-status"); - updateButton.hidden = true; - this.uninit(); - this.init(); } }; diff --git a/browser/base/content/test/appUpdate/.eslintrc.js b/browser/base/content/test/appUpdate/.eslintrc.js new file mode 100644 index 000000000000..7c80211924ef --- /dev/null +++ b/browser/base/content/test/appUpdate/.eslintrc.js @@ -0,0 +1,7 @@ +"use strict"; + +module.exports = { + "extends": [ + "../../../../../testing/mochitest/browser.eslintrc.js" + ] +}; diff --git a/browser/base/content/test/appUpdate/browser.ini b/browser/base/content/test/appUpdate/browser.ini new file mode 100644 index 000000000000..a4f340c28c75 --- /dev/null +++ b/browser/base/content/test/appUpdate/browser.ini @@ -0,0 +1,22 @@ +[DEFAULT] +tags = appupdate +support-files = + head.js + downloadPage.html + testConstants.js + +[browser_updatesBasicPrompt.js] +skip-if = asan +reason = Bug 1168003 +[browser_updatesBasicPromptNoStaging.js] +[browser_updatesCompleteAndPartialPatchesWithBadCompleteSize.js] +[browser_updatesCompleteAndPartialPatchesWithBadPartialSize.js] +[browser_updatesCompleteAndPartialPatchesWithBadSizes.js] +[browser_updatesCompletePatchApplyFailure.js] +[browser_updatesCompletePatchWithBadCompleteSize.js] +[browser_updatesDownloadFailures.js] +[browser_updatesMalformedXml.js] +[browser_updatesPartialPatchApplyFailure.js] +[browser_updatesPartialPatchApplyFailureWithCompleteAvailable.js] +[browser_updatesPartialPatchApplyFailureWithCompleteValidationFailure.js] +[browser_updatesPartialPatchWithBadPartialSize.js] diff --git a/browser/base/content/test/appUpdate/browser_updatesBasicPrompt.js b/browser/base/content/test/appUpdate/browser_updatesBasicPrompt.js new file mode 100644 index 000000000000..a895386f554e --- /dev/null +++ b/browser/base/content/test/appUpdate/browser_updatesBasicPrompt.js @@ -0,0 +1,28 @@ +add_task(function* testBasicPrompt() { + SpecialPowers.pushPrefEnv({set: [[PREF_APP_UPDATE_STAGING_ENABLED, true]]}); + let updateParams = "showPrompt=1&promptWaitTime=0"; + gUseTestUpdater = true; + + // Open a new window to make sure that it doesn't get in the way + // of the notification management. + let extraWindow = yield BrowserTestUtils.openNewBrowserWindow(); + + yield runUpdateTest(updateParams, 1, [ + { + notificationId: "update-available", + button: "button", + beforeClick() { + checkWhatsNewLink("update-available-whats-new"); + } + }, + { + notificationId: "update-restart", + button: "secondarybutton", + *cleanup() { + PanelUI.removeNotification(/.*/); + } + }, + ]); + + yield BrowserTestUtils.closeWindow(extraWindow); +}); diff --git a/browser/base/content/test/appUpdate/browser_updatesBasicPromptNoStaging.js b/browser/base/content/test/appUpdate/browser_updatesBasicPromptNoStaging.js new file mode 100644 index 000000000000..f364fc347ab7 --- /dev/null +++ b/browser/base/content/test/appUpdate/browser_updatesBasicPromptNoStaging.js @@ -0,0 +1,22 @@ +add_task(function* testBasicPromptNoStaging() { + SpecialPowers.pushPrefEnv({set: [[PREF_APP_UPDATE_STAGING_ENABLED, false]]}); + + let updateParams = "showPrompt=1&promptWaitTime=0"; + + yield runUpdateTest(updateParams, 1, [ + { + notificationId: "update-available", + button: "button", + beforeClick() { + checkWhatsNewLink("update-available-whats-new"); + } + }, + { + notificationId: "update-restart", + button: "secondarybutton", + cleanup() { + PanelUI.removeNotification(/.*/); + } + }, + ]); +}); diff --git a/browser/base/content/test/appUpdate/browser_updatesCompleteAndPartialPatchesWithBadCompleteSize.js b/browser/base/content/test/appUpdate/browser_updatesCompleteAndPartialPatchesWithBadCompleteSize.js new file mode 100644 index 000000000000..22ace19af56c --- /dev/null +++ b/browser/base/content/test/appUpdate/browser_updatesCompleteAndPartialPatchesWithBadCompleteSize.js @@ -0,0 +1,13 @@ +add_task(function* testCompleteAndPartialPatchesWithBadCompleteSize() { + let updateParams = "invalidCompleteSize=1&promptWaitTime=0"; + + yield runUpdateTest(updateParams, 1, [ + { + notificationId: "update-restart", + button: "secondarybutton", + cleanup() { + PanelUI.removeNotification(/.*/); + } + }, + ]); +}); diff --git a/browser/base/content/test/appUpdate/browser_updatesCompleteAndPartialPatchesWithBadPartialSize.js b/browser/base/content/test/appUpdate/browser_updatesCompleteAndPartialPatchesWithBadPartialSize.js new file mode 100644 index 000000000000..0ce011075898 --- /dev/null +++ b/browser/base/content/test/appUpdate/browser_updatesCompleteAndPartialPatchesWithBadPartialSize.js @@ -0,0 +1,13 @@ +add_task(function* testCompleteAndPartialPatchesWithBadPartialSize() { + let updateParams = "invalidPartialSize=1&promptWaitTime=0"; + + yield runUpdateTest(updateParams, 1, [ + { + notificationId: "update-restart", + button: "secondarybutton", + cleanup() { + PanelUI.removeNotification(/.*/); + } + }, + ]); +}); diff --git a/browser/base/content/test/appUpdate/browser_updatesCompleteAndPartialPatchesWithBadSizes.js b/browser/base/content/test/appUpdate/browser_updatesCompleteAndPartialPatchesWithBadSizes.js new file mode 100644 index 000000000000..c160aab2351f --- /dev/null +++ b/browser/base/content/test/appUpdate/browser_updatesCompleteAndPartialPatchesWithBadSizes.js @@ -0,0 +1,33 @@ +add_task(function* testCompleteAndPartialPatchesWithBadSizes() { + SpecialPowers.pushPrefEnv({set: [[PREF_APP_UPDATE_DOWNLOADPROMPTMAXATTEMPTS, 2]]}); + let updateParams = "invalidPartialSize=1&invalidCompleteSize=1"; + + yield runUpdateTest(updateParams, 1, [ + { + // if we fail maxBackgroundErrors download attempts, then we want to + // first show the user an update available prompt. + notificationId: "update-available", + button: "button" + }, + { + notificationId: "update-available", + button: "button" + }, + { + // if we have only an invalid patch, then something's wrong and we don't + // have an automatic way to fix it, so show the manual update + // doorhanger. + notificationId: "update-manual", + button: "button", + beforeClick() { + checkWhatsNewLink("update-manual-whats-new"); + }, + *cleanup() { + yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); + is(gBrowser.selectedBrowser.currentURI.spec, + URL_MANUAL_UPDATE, "Landed on manual update page.") + gBrowser.removeTab(gBrowser.selectedTab); + } + }, + ]); +}); diff --git a/browser/base/content/test/appUpdate/browser_updatesCompletePatchApplyFailure.js b/browser/base/content/test/appUpdate/browser_updatesCompletePatchApplyFailure.js new file mode 100644 index 000000000000..70b3dfbf8478 --- /dev/null +++ b/browser/base/content/test/appUpdate/browser_updatesCompletePatchApplyFailure.js @@ -0,0 +1,25 @@ +add_task(function* testCompletePatchApplyFailure() { + let patches = getLocalPatchString("complete", null, null, null, null, null, + STATE_PENDING); + let updates = getLocalUpdateString(patches, null, null, null, + Services.appinfo.version, null); + + yield runUpdateProcessingTest(updates, [ + { + // if we have only an invalid patch, then something's wrong and we don't + // have an automatic way to fix it, so show the manual update + // doorhanger. + notificationId: "update-manual", + button: "button", + beforeClick() { + checkWhatsNewLink("update-manual-whats-new"); + }, + *cleanup() { + yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); + is(gBrowser.selectedBrowser.currentURI.spec, + URL_MANUAL_UPDATE, "Landed on manual update page.") + gBrowser.removeTab(gBrowser.selectedTab); + } + }, + ]); +}); diff --git a/browser/base/content/test/appUpdate/browser_updatesCompletePatchWithBadCompleteSize.js b/browser/base/content/test/appUpdate/browser_updatesCompletePatchWithBadCompleteSize.js new file mode 100644 index 000000000000..36946010049e --- /dev/null +++ b/browser/base/content/test/appUpdate/browser_updatesCompletePatchWithBadCompleteSize.js @@ -0,0 +1,34 @@ +add_task(function* testCompletePatchWithBadCompleteSize() { + SpecialPowers.pushPrefEnv({set: [[PREF_APP_UPDATE_DOWNLOADPROMPTMAXATTEMPTS, 2]]}); + + let updateParams = "completePatchOnly=1&invalidCompleteSize=1"; + + yield runUpdateTest(updateParams, 1, [ + { + // if we fail maxBackgroundErrors download attempts, then we want to + // first show the user an update available prompt. + notificationId: "update-available", + button: "button" + }, + { + notificationId: "update-available", + button: "button" + }, + { + // if we have only an invalid patch, then something's wrong and we don't + // have an automatic way to fix it, so show the manual update + // doorhanger. + notificationId: "update-manual", + button: "button", + beforeClick() { + checkWhatsNewLink("update-manual-whats-new"); + }, + *cleanup() { + yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); + is(gBrowser.selectedBrowser.currentURI.spec, + URL_MANUAL_UPDATE, "Landed on manual update page.") + gBrowser.removeTab(gBrowser.selectedTab); + } + }, + ]); +}); diff --git a/browser/base/content/test/appUpdate/browser_updatesDownloadFailures.js b/browser/base/content/test/appUpdate/browser_updatesDownloadFailures.js new file mode 100644 index 000000000000..fb7bfd3aa64f --- /dev/null +++ b/browser/base/content/test/appUpdate/browser_updatesDownloadFailures.js @@ -0,0 +1,37 @@ +add_task(function* testDownloadFailures() { + const maxBackgroundErrors = 5; + SpecialPowers.pushPrefEnv({set: [ + [PREF_APP_UPDATE_BACKGROUNDMAXERRORS, maxBackgroundErrors], + [PREF_APP_UPDATE_DOWNLOADPROMPTMAXATTEMPTS, 2] + ]}); + let updateParams = "badURL=1"; + + // Open a new window to make sure that our pref management isn't duplicated. + let extraWindow = yield BrowserTestUtils.openNewBrowserWindow(); + + yield runUpdateTest(updateParams, 1, [ + { + // if we fail maxBackgroundErrors download attempts, then we want to + // first show the user an update available prompt. + notificationId: "update-available", + button: "button" + }, + { + notificationId: "update-available", + button: "button" + }, + { + notificationId: "update-manual", + button: "button", + *cleanup() { + yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); + is(gBrowser.selectedBrowser.currentURI.spec, + URL_MANUAL_UPDATE, "Landed on manual update page."); + gBrowser.removeTab(gBrowser.selectedTab); + gMenuButtonUpdateBadge.reset(); + } + }, + ]); + + yield BrowserTestUtils.closeWindow(extraWindow); +}); diff --git a/browser/base/content/test/appUpdate/browser_updatesMalformedXml.js b/browser/base/content/test/appUpdate/browser_updatesMalformedXml.js new file mode 100644 index 000000000000..43210d6561a6 --- /dev/null +++ b/browser/base/content/test/appUpdate/browser_updatesMalformedXml.js @@ -0,0 +1,29 @@ +add_task(function* testMalformedXml() { + const updateDetailsUrl = "http://example.com/details"; + const maxBackgroundErrors = 10; + SpecialPowers.pushPrefEnv({set: [ + [PREF_APP_UPDATE_BACKGROUNDMAXERRORS, maxBackgroundErrors], + [PREF_APP_UPDATE_URL_DETAILS, updateDetailsUrl] + ]}); + + let updateParams = "xmlMalformed=1"; + + yield runUpdateTest(updateParams, maxBackgroundErrors, [ + { + // if we fail 10 check attempts, then we want to just show the user a manual update + // workflow. + notificationId: "update-manual", + button: "button", + beforeClick() { + checkWhatsNewLink("update-manual-whats-new", updateDetailsUrl); + }, + *cleanup() { + yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); + is(gBrowser.selectedBrowser.currentURI.spec, + URL_MANUAL_UPDATE, "Landed on manual update page.") + gBrowser.removeTab(gBrowser.selectedTab); + gMenuButtonUpdateBadge.reset(); + } + }, + ]); +}); diff --git a/browser/base/content/test/appUpdate/browser_updatesPartialPatchApplyFailure.js b/browser/base/content/test/appUpdate/browser_updatesPartialPatchApplyFailure.js new file mode 100644 index 000000000000..4be63a92f055 --- /dev/null +++ b/browser/base/content/test/appUpdate/browser_updatesPartialPatchApplyFailure.js @@ -0,0 +1,26 @@ +add_task(function* testPartialPatchApplyFailure() { + let patches = getLocalPatchString("partial", null, null, null, null, null, + STATE_PENDING); + let updates = getLocalUpdateString(patches, null, null, null, + Services.appinfo.version, null, + null, null, null, null, "false"); + + yield runUpdateProcessingTest(updates, [ + { + // if we have only an invalid patch, then something's wrong and we don't + // have an automatic way to fix it, so show the manual update + // doorhanger. + notificationId: "update-manual", + button: "button", + beforeClick() { + checkWhatsNewLink("update-manual-whats-new"); + }, + *cleanup() { + yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); + is(gBrowser.selectedBrowser.currentURI.spec, + URL_MANUAL_UPDATE, "Landed on manual update page.") + gBrowser.removeTab(gBrowser.selectedTab); + } + }, + ]); +}); diff --git a/browser/base/content/test/appUpdate/browser_updatesPartialPatchApplyFailureWithCompleteAvailable.js b/browser/base/content/test/appUpdate/browser_updatesPartialPatchApplyFailureWithCompleteAvailable.js new file mode 100644 index 000000000000..6d598e126859 --- /dev/null +++ b/browser/base/content/test/appUpdate/browser_updatesPartialPatchApplyFailureWithCompleteAvailable.js @@ -0,0 +1,22 @@ +add_task(function* testPartialPatchApplyFailureWithCompleteAvailable() { + let patches = getLocalPatchString("partial", null, null, null, null, null, + STATE_PENDING) + + getLocalPatchString("complete", null, null, null, + null, "false"); + + let promptWaitTime = "0"; + let updates = getLocalUpdateString(patches, null, null, null, + Services.appinfo.version, null, + null, null, null, null, "false", + null, null, null, null, promptWaitTime); + + yield runUpdateProcessingTest(updates, [ + { + notificationId: "update-restart", + button: "secondarybutton", + cleanup() { + PanelUI.removeNotification(/.*/); + } + }, + ]); +}); diff --git a/browser/base/content/test/appUpdate/browser_updatesPartialPatchApplyFailureWithCompleteValidationFailure.js b/browser/base/content/test/appUpdate/browser_updatesPartialPatchApplyFailureWithCompleteValidationFailure.js new file mode 100644 index 000000000000..621a5ab142f2 --- /dev/null +++ b/browser/base/content/test/appUpdate/browser_updatesPartialPatchApplyFailureWithCompleteValidationFailure.js @@ -0,0 +1,33 @@ +add_task(function* testPartialPatchApplyFailureWithCompleteValidationFailure() { + // because of the way we're simulating failure, we have to just pretend we've already + // retried. + SpecialPowers.pushPrefEnv({set: [[PREF_APP_UPDATE_DOWNLOADPROMPTMAXATTEMPTS, 0]]}); + let patches = getLocalPatchString("partial", null, null, null, null, null, + STATE_PENDING) + + getLocalPatchString("complete", null, "MD5", + null, "1234", + "false"); + + let updates = getLocalUpdateString(patches, null, null, null, + Services.appinfo.version, null, + null, null, null, null, "false"); + + yield runUpdateProcessingTest(updates, [ + { + // if we have only an invalid patch, then something's wrong and we don't + // have an automatic way to fix it, so show the manual update + // doorhanger. + notificationId: "update-manual", + button: "button", + beforeClick() { + checkWhatsNewLink("update-manual-whats-new"); + }, + *cleanup() { + yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); + is(gBrowser.selectedBrowser.currentURI.spec, + URL_MANUAL_UPDATE, "Landed on manual update page.") + gBrowser.removeTab(gBrowser.selectedTab); + } + }, + ]); +}); diff --git a/browser/base/content/test/appUpdate/browser_updatesPartialPatchWithBadPartialSize.js b/browser/base/content/test/appUpdate/browser_updatesPartialPatchWithBadPartialSize.js new file mode 100644 index 000000000000..741a5288bc5f --- /dev/null +++ b/browser/base/content/test/appUpdate/browser_updatesPartialPatchWithBadPartialSize.js @@ -0,0 +1,33 @@ +add_task(function* testPartialPatchWithBadPartialSize() { + SpecialPowers.pushPrefEnv({set: [[PREF_APP_UPDATE_DOWNLOADPROMPTMAXATTEMPTS, 2]]}); + let updateParams = "partialPatchOnly=1&invalidPartialSize=1"; + + yield runUpdateTest(updateParams, 1, [ + { + // if we fail maxBackgroundErrors download attempts, then we want to + // first show the user an update available prompt. + notificationId: "update-available", + button: "button" + }, + { + notificationId: "update-available", + button: "button" + }, + { + // if we have only an invalid patch, then something's wrong and we don't + // have an automatic way to fix it, so show the manual update + // doorhanger. + notificationId: "update-manual", + button: "button", + beforeClick() { + checkWhatsNewLink("update-manual-whats-new"); + }, + *cleanup() { + yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); + is(gBrowser.selectedBrowser.currentURI.spec, + URL_MANUAL_UPDATE, "Landed on manual update page.") + gBrowser.removeTab(gBrowser.selectedTab); + } + }, + ]); +}); diff --git a/browser/base/content/test/appUpdate/downloadPage.html b/browser/base/content/test/appUpdate/downloadPage.html new file mode 100644 index 000000000000..4810e2e0d6ef --- /dev/null +++ b/browser/base/content/test/appUpdate/downloadPage.html @@ -0,0 +1,13 @@ + + + + Download page + + + + + + Download + + + diff --git a/browser/base/content/test/appUpdate/head.js b/browser/base/content/test/appUpdate/head.js new file mode 100644 index 000000000000..81d33418d7ec --- /dev/null +++ b/browser/base/content/test/appUpdate/head.js @@ -0,0 +1,361 @@ +Cu.import("resource://gre/modules/FileUtils.jsm"); +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); + +const IS_MACOSX = ("nsILocalFileMac" in Ci); +const IS_WIN = ("@mozilla.org/windows-registry-key;1" in Cc); + +const BIN_SUFFIX = (IS_WIN ? ".exe" : ""); +const FILE_UPDATER_BIN = "updater" + (IS_MACOSX ? ".app" : BIN_SUFFIX); +const FILE_UPDATER_BIN_BAK = FILE_UPDATER_BIN + ".bak"; + +let gRembemberedPrefs = []; + +const DATA_URI_SPEC = "chrome://mochitests/content/browser/browser/base/content/test/appUpdate/"; + +var DEBUG_AUS_TEST = true; +var gUseTestUpdater = false; + +const LOG_FUNCTION = info; + +/* import-globals-from testConstants.js */ +Services.scriptloader.loadSubScript(DATA_URI_SPEC + "testConstants.js", this); +/* import-globals-from sharedUpdateXML.js */ +Services.scriptloader.loadSubScript(DATA_URI_SPEC + "shared.js", this); + +var gURLData = URL_HOST + "/" + REL_PATH_DATA; +const URL_MANUAL_UPDATE = gURLData + "downloadPage.html"; + +const NOTIFICATIONS = [ + "update-available", + "update-manual", + "update-restart" +]; + +/** + * Delay for a very short period. Useful for moving the code after this + * to the back of the event loop. + * + * @return A promise which will resolve after a very short period. + */ +function delay() { + return new Promise(resolve => executeSoon(resolve)); +} + +/** + * Gets the update version info for the update url parameters to send to + * update.sjs. + * + * @param aAppVersion (optional) + * The application version for the update snippet. If not specified the + * current application version will be used. + * @return The url parameters for the application and platform version to send + * to update.sjs. + */ +function getVersionParams(aAppVersion) { + let appInfo = Services.appinfo; + return "&appVersion=" + (aAppVersion ? aAppVersion : appInfo.version); +} + +/** + * Clean up updates list and the updates directory. + */ +function cleanUpUpdates() { + gUpdateManager.activeUpdate = null; + gUpdateManager.saveUpdates(); + + removeUpdateDirsAndFiles(); +} + +/** + * Runs a typical update test. Will set various common prefs for using the + * updater doorhanger, runs the provided list of steps, and makes sure + * everything is cleaned up afterwards. + * + * @param updateParams + * URL-encoded params which will be sent to update.sjs. + * @param checkAttempts + * How many times to check for updates. Useful for testing the UI + * for check failures. + * @param steps + * A list of test steps to perform, specifying expected doorhangers + * and additional validation/cleanup callbacks. + * @return A promise which will resolve once all of the steps have been run + * and cleanup has been performed. + */ +function runUpdateTest(updateParams, checkAttempts, steps) { + return Task.spawn(function*() { + registerCleanupFunction(() => { + gMenuButtonUpdateBadge.uninit(); + gMenuButtonUpdateBadge.init(); + cleanUpUpdates(); + }); + yield SpecialPowers.pushPrefEnv({ + set: [ + [PREF_APP_UPDATE_DOWNLOADPROMPTATTEMPTS, 0], + [PREF_APP_UPDATE_ENABLED, true], + [PREF_APP_UPDATE_IDLETIME, 0], + [PREF_APP_UPDATE_URL_MANUAL, URL_MANUAL_UPDATE], + [PREF_APP_UPDATE_LOG, DEBUG_AUS_TEST], + ]}); + + yield setupTestUpdater(); + + let url = URL_HTTP_UPDATE_SJS + + "?" + updateParams + + getVersionParams(); + + setUpdateURL(url); + + executeSoon(() => { + Task.spawn(function*() { + gAUS.checkForBackgroundUpdates(); + for (var i = 0; i < checkAttempts - 1; i++) { + yield waitForEvent("update-error", "check-attempt-failed"); + gAUS.checkForBackgroundUpdates(); + } + }); + }); + + for (let step of steps) { + yield processStep(step); + } + + yield finishTestRestoreUpdaterBackup(); + }); +} + +/** + * Runs a test which processes an update. Similar to runUpdateTest. + * + * @param updates + * A list of updates to process. + * @param steps + * A list of test steps to perform, specifying expected doorhangers + * and additional validation/cleanup callbacks. + * @return A promise which will resolve once all of the steps have been run + * and cleanup has been performed. + */ +function runUpdateProcessingTest(updates, steps) { + return Task.spawn(function*() { + registerCleanupFunction(() => { + gMenuButtonUpdateBadge.reset(); + cleanUpUpdates(); + }); + + SpecialPowers.pushPrefEnv({ + set: [ + [PREF_APP_UPDATE_DOWNLOADPROMPTATTEMPTS, 0], + [PREF_APP_UPDATE_ENABLED, true], + [PREF_APP_UPDATE_IDLETIME, 0], + [PREF_APP_UPDATE_URL_MANUAL, URL_MANUAL_UPDATE], + [PREF_APP_UPDATE_LOG, DEBUG_AUS_TEST], + ]}); + + yield setupTestUpdater(); + + writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true); + + writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false); + writeStatusFile(STATE_FAILED_CRC_ERROR); + reloadUpdateManagerData(); + + testPostUpdateProcessing(); + + for (let step of steps) { + yield processStep(step); + } + + yield finishTestRestoreUpdaterBackup(); + }); +} + +function processStep({notificationId, button, beforeClick, cleanup}) { + return Task.spawn(function*() { + + yield BrowserTestUtils.waitForEvent(PanelUI.notificationPanel, "popupshown"); + const shownNotification = PanelUI.activeNotification.id; + + is(shownNotification, notificationId, "The right notification showed up."); + if (shownNotification != notificationId) { + if (cleanup) { + yield cleanup(); + } + return; + } + + let notification = document.getElementById(`PanelUI-${notificationId}-notification`); + is(notification.hidden, false, `${notificationId} notification is showing`); + if (beforeClick) { + yield Task.spawn(beforeClick); + } + + let buttonEl = document.getAnonymousElementByAttribute(notification, "anonid", button); + + buttonEl.click(); + + if (cleanup) { + yield cleanup(); + } + }); +} + +/** + * Waits for the specified topic and (optionally) status. + * @param topic + * String representing the topic to wait for. + * @param status + * Optional String representing the status on said topic to wait for. + * @return A promise which will resolve the first time an event occurs on the + * specified topic, and (optionally) with the specified status. + */ +function waitForEvent(topic, status = null) { + return new Promise(resolve => Services.obs.addObserver({ + observe(subject, innerTopic, innerStatus) { + if (!status || status == innerStatus) { + Services.obs.removeObserver(this, topic); + resolve(innerStatus); + } + } + }, topic, false)) +} + +/** + * Ensures that the "What's new" link with the provided ID is displayed and + * matches the url parameter provided. If no URL is provided, it will instead + * ensure that the link matches the default link URL. + * + * @param id + * The ID of the "What's new" link element. + * @param url (optional) + * The URL to check against. If none is provided, a default will be used. + */ +function checkWhatsNewLink(id, url) { + let whatsNewLink = document.getElementById(id); + is(whatsNewLink.href, + url || URL_HTTP_UPDATE_SJS + "?uiURL=DETAILS", + "What's new link points to the test_details URL"); + is(whatsNewLink.hidden, false, "What's new link is not hidden."); +} + +/** + * For tests that use the test updater restores the backed up real updater if + * it exists and tries again on failure since Windows debug builds at times + * leave the file in use. After success moveRealUpdater is called to continue + * the setup of the test updater. For tests that don't use the test updater + * runTest will be called. + */ +function setupTestUpdater() { + return Task.spawn(function*() { + if (gUseTestUpdater) { + try { + restoreUpdaterBackup(); + } catch (e) { + logTestInfo("Attempt to restore the backed up updater failed... " + + "will try again, Exception: " + e); + yield delay(); + yield setupTestUpdater(); + return; + } + yield moveRealUpdater(); + } + }); +} + +/** + * Backs up the real updater and tries again on failure since Windows debug + * builds at times leave the file in use. After success it will call + * copyTestUpdater to continue the setup of the test updater. + */ +function moveRealUpdater() { + return Task.spawn(function*() { + try { + // Move away the real updater + let baseAppDir = getAppBaseDir(); + let updater = baseAppDir.clone(); + updater.append(FILE_UPDATER_BIN); + updater.moveTo(baseAppDir, FILE_UPDATER_BIN_BAK); + } catch (e) { + logTestInfo("Attempt to move the real updater out of the way failed... " + + "will try again, Exception: " + e); + yield delay(); + yield moveRealUpdater(); + return; + } + + yield copyTestUpdater(); + }); +} + +/** + * Copies the test updater so it can be used by tests and tries again on failure + * since Windows debug builds at times leave the file in use. After success it + * will call runTest to continue the test. + */ +function copyTestUpdater() { + return Task.spawn(function*() { + try { + // Copy the test updater + let baseAppDir = getAppBaseDir(); + let testUpdaterDir = Services.dirsvc.get("CurWorkD", Ci.nsILocalFile); + let relPath = REL_PATH_DATA; + let pathParts = relPath.split("/"); + for (let i = 0; i < pathParts.length; ++i) { + testUpdaterDir.append(pathParts[i]); + } + + let testUpdater = testUpdaterDir.clone(); + testUpdater.append(FILE_UPDATER_BIN); + testUpdater.copyToFollowingLinks(baseAppDir, FILE_UPDATER_BIN); + } catch (e) { + logTestInfo("Attempt to copy the test updater failed... " + + "will try again, Exception: " + e); + yield delay(); + yield copyTestUpdater(); + } + }); +} + +/** + * Restores the updater that was backed up. This is called in setupTestUpdater + * before the backup of the real updater is done in case the previous test + * failed to restore the updater, in finishTestDefaultWaitForWindowClosed when + * the test has finished, and in test_9999_cleanup.xul after all tests have + * finished. + */ +function restoreUpdaterBackup() { + let baseAppDir = getAppBaseDir(); + let updater = baseAppDir.clone(); + let updaterBackup = baseAppDir.clone(); + updater.append(FILE_UPDATER_BIN); + updaterBackup.append(FILE_UPDATER_BIN_BAK); + if (updaterBackup.exists()) { + if (updater.exists()) { + updater.remove(true); + } + updaterBackup.moveTo(baseAppDir, FILE_UPDATER_BIN); + } +} + +/** + * When a test finishes this will repeatedly attempt to restore the real updater + * for tests that use the test updater and then call + * finishTestDefaultWaitForWindowClosed after the restore is successful. + */ +function finishTestRestoreUpdaterBackup() { + return Task.spawn(function*() { + if (gUseTestUpdater) { + try { + // Windows debug builds keep the updater file in use for a short period of + // time after the updater process exits. + restoreUpdaterBackup(); + } catch (e) { + logTestInfo("Attempt to restore the backed up updater failed... " + + "will try again, Exception: " + e); + + yield delay(); + yield finishTestRestoreUpdaterBackup(); + return; + } + } + }); +} diff --git a/browser/base/content/test/appUpdate/testConstants.js b/browser/base/content/test/appUpdate/testConstants.js new file mode 100644 index 000000000000..62a9e479513b --- /dev/null +++ b/browser/base/content/test/appUpdate/testConstants.js @@ -0,0 +1,4 @@ +const REL_PATH_DATA = "browser/browser/base/content/test/appUpdate/"; +const URL_HOST = "http://example.com"; +const URL_PATH_UPDATE_XML = "/" + REL_PATH_DATA + "update.sjs"; +const URL_HTTP_UPDATE_SJS = URL_HOST + URL_PATH_UPDATE_XML; diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini index dd8286c59549..aee8cdaaa05e 100644 --- a/browser/base/content/test/general/browser.ini +++ b/browser/base/content/test/general/browser.ini @@ -638,7 +638,6 @@ tags = psm [browser_domFullscreen_fullscreenMode.js] tags = fullscreen # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD. -[browser_menuButtonBadgeManager.js] # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD. [browser_newTabDrop.js] # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD. diff --git a/browser/base/content/test/general/browser_menuButtonBadgeManager.js b/browser/base/content/test/general/browser_menuButtonBadgeManager.js deleted file mode 100644 index 9afe39ab75da..000000000000 --- a/browser/base/content/test/general/browser_menuButtonBadgeManager.js +++ /dev/null @@ -1,46 +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/. */ - -var menuButton = document.getElementById("PanelUI-menu-button"); - -add_task(function* testButtonActivities() { - is(menuButton.hasAttribute("badge-status"), false, "Should not have a badge status"); - is(menuButton.hasAttribute("badge"), false, "Should not have the badge attribute set"); - - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_FXA, "fxa-needs-authentication"); - is(menuButton.getAttribute("badge-status"), "fxa-needs-authentication", "Should have fxa-needs-authentication badge status"); - - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_APPUPDATE, "update-succeeded"); - is(menuButton.getAttribute("badge-status"), "update-succeeded", "Should have update-succeeded badge status (update > fxa)"); - - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_APPUPDATE, "update-failed"); - is(menuButton.getAttribute("badge-status"), "update-failed", "Should have update-failed badge status"); - - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_DOWNLOAD, "download-severe"); - is(menuButton.getAttribute("badge-status"), "download-severe", "Should have download-severe badge status"); - - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_DOWNLOAD, "download-warning"); - is(menuButton.getAttribute("badge-status"), "download-warning", "Should have download-warning badge status"); - - gMenuButtonBadgeManager.addBadge("unknownbadge", "attr"); - is(menuButton.getAttribute("badge-status"), "download-warning", "Should not have changed badge status"); - - gMenuButtonBadgeManager.removeBadge(gMenuButtonBadgeManager.BADGEID_DOWNLOAD); - is(menuButton.getAttribute("badge-status"), "update-failed", "Should have update-failed badge status"); - - gMenuButtonBadgeManager.removeBadge(gMenuButtonBadgeManager.BADGEID_APPUPDATE); - is(menuButton.getAttribute("badge-status"), "fxa-needs-authentication", "Should have fxa-needs-authentication badge status"); - - gMenuButtonBadgeManager.removeBadge(gMenuButtonBadgeManager.BADGEID_FXA); - is(menuButton.hasAttribute("badge-status"), false, "Should not have a badge status"); - - yield PanelUI.show(); - is(menuButton.hasAttribute("badge-status"), false, "Should not have a badge status (Hamburger menu opened)"); - PanelUI.hide(); - - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_FXA, "fxa-needs-authentication"); - gMenuButtonBadgeManager.addBadge(gMenuButtonBadgeManager.BADGEID_APPUPDATE, "update-succeeded"); - gMenuButtonBadgeManager.clearBadges(); - is(menuButton.hasAttribute("badge-status"), false, "Should not have a badge status (clearBadges called)"); -}); diff --git a/browser/base/moz.build b/browser/base/moz.build index 4b5f75b746fa..3c32c228e13d 100644 --- a/browser/base/moz.build +++ b/browser/base/moz.build @@ -51,4 +51,14 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'cocoa'): if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk2', 'gtk3'): DEFINES['MENUBAR_CAN_AUTOHIDE'] = 1 +if CONFIG['MOZ_UPDATER']: + BROWSER_CHROME_MANIFESTS += ['content/test/appUpdate/browser.ini'] + +TEST_HARNESS_FILES.testing.mochitest.browser.browser.base.content.test.appUpdate += [ + '/toolkit/mozapps/update/tests/chrome/update.sjs', + '/toolkit/mozapps/update/tests/data/shared.js', + '/toolkit/mozapps/update/tests/data/sharedUpdateXML.js', + '/toolkit/mozapps/update/tests/data/simple.mar', +] + JAR_MANIFESTS += ['jar.mn'] diff --git a/browser/branding/official/pref/firefox-branding.js b/browser/branding/official/pref/firefox-branding.js index 52aaa4f508d0..82ef1c891a87 100644 --- a/browser/branding/official/pref/firefox-branding.js +++ b/browser/branding/official/pref/firefox-branding.js @@ -26,8 +26,8 @@ pref("app.update.url.details", "https://www.mozilla.org/%LOCALE%/firefox/notes") pref("app.update.checkInstallTime.days", 63); // Give the user x seconds to reboot before showing a badge on the hamburger -// button. default=immediately -pref("app.update.badgeWaitTime", 0); +// button. default=4 days +pref("app.update.badgeWaitTime", 345600); // Number of usages of the web console or scratchpad. // If this is less than 5, then pasting code into the web console or scratchpad is disabled diff --git a/browser/components/customizableui/content/panelUI.inc.xul b/browser/components/customizableui/content/panelUI.inc.xul index 04ba6abfa837..d0ae3d72cf7c 100644 --- a/browser/components/customizableui/content/panelUI.inc.xul +++ b/browser/components/customizableui/content/panelUI.inc.xul @@ -17,9 +17,17 @@