Merge mozilla-central to mozilla-inbound

This commit is contained in:
Carsten "Tomcat" Book 2014-02-25 15:18:06 +01:00
commit 60446c5e55
83 changed files with 1511 additions and 289 deletions

View File

@ -22,6 +22,4 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more.
CLOBBER to test mozfile changes which previously broke mozbuild's ability to clobber (bug 949600).
Safe to ignore - last clobber was 'Skia update from Bug 910754 needs a CLOBBER build' at Feb 18 15:19:59 2014 PST
Update CLOBBER for bug 939672 moves file location and requires clobber build.

View File

@ -872,6 +872,10 @@ pref("identity.fxaccounts.auth.uri", "https://api-accounts.dev.lcip.org/v1");
pref("apz.asyncscroll.throttle", 40);
pref("apz.pan_repaint_interval", 40);
// Maximum fling velocity in px/ms. Slower devices may need to reduce this
// to avoid checkerboarding. Note, float value must be set as a string.
pref("apz.max_velocity_pixels_per_ms", "6.0");
// This preference allows FirefoxOS apps (and content, I think) to force
// the use of software (instead of hardware accelerated) 2D canvases by
// creating a context like this:

View File

@ -222,11 +222,20 @@ ContentPermissionPrompt.prototype = {
permission: perm.type,
access: (perm.access && perm.access !== "unused") ?
perm.type + "-" + perm.access : perm.type,
options: [],
deny: true,
action: Ci.nsIPermissionManager.UNKNOWN_ACTION
};
// Append available options, if any.
let options = perm.options.QueryInterface(Ci.nsIArray);
for (let i = 0; i < options.length; i++) {
let option = options.queryElementAt(i, Ci.nsISupportsString).data;
tmp.options.push(option);
}
typesInfo.push(tmp);
}
if (typesInfo.length == 0) {
request.cancel();
return;
@ -309,13 +318,13 @@ ContentPermissionPrompt.prototype = {
delegatePrompt: function(request, requestId, typesInfo, callback) {
this.sendToBrowserWindow("permission-prompt", request, requestId, typesInfo,
function(type, remember) {
function(type, remember, choices) {
if (type == "permission-allow") {
rememberPermission(typesInfo, request.principal, !remember);
if (callback) {
callback();
}
request.allow();
request.allow(choices);
return;
}
@ -354,7 +363,7 @@ ContentPermissionPrompt.prototype = {
return;
evt.target.removeEventListener(evt.type, contentEvent);
callback(detail.type, detail.remember);
callback(detail.type, detail.remember, detail.choices);
})
}
@ -367,7 +376,7 @@ ContentPermissionPrompt.prototype = {
let permissions = {};
for (let i in typesInfo) {
debug("prompt " + typesInfo[i].permission);
permissions[typesInfo[i].permission] = [];
permissions[typesInfo[i].permission] = typesInfo[i].options;
}
let details = {

View File

@ -2,14 +2,55 @@
<body>
<script>
// invoke audio-capture permission prompt
navigator.mozGetUserMedia({audio: true}, function () {}, function () {});
var actions = [
{
permissions: ["video-capture"],
action: function() {
// invoke video-capture permission prompt
navigator.mozGetUserMedia({video: true}, function () {}, function () {});
}
},
{
permissions: ["audio-capture", "video-capture"],
action: function() {
// invoke audio-capture + video-capture permission prompt
navigator.mozGetUserMedia({audio: true, video: true}, function () {}, function () {});
}
},
{
permissions: ["audio-capture"],
action: function() {
// invoke audio-capture permission prompt
navigator.mozGetUserMedia({audio: true}, function () {}, function () {});
}
},
{
permissions: ["geolocation"],
action: function() {
// invoke geolocation permission prompt
navigator.geolocation.getCurrentPosition(function (pos) {});
}
},
{
permissions: ["desktop-notification"],
action: function() {
// invoke desktop-notification prompt
Notification.requestPermission(function (perm) {});
}
},
];
// invoke geolocation permission prompt
navigator.geolocation.getCurrentPosition(function (pos) {});
// invoke desktop-notification prompt
Notification.requestPermission(function (perm) {});
// The requested permissions are specified in query string.
var permissions = JSON.parse(decodeURIComponent(window.location.search.substring(1)));
for (var i = 0; i < actions.length; i++) {
if(permissions.length === actions[i].permissions.length &&
permissions.every(function(permission) {
return actions[i].permissions.indexOf(permission) >= 0;
})) {
actions[i].action();
break;
}
}
</script>
</body>

View File

@ -16,7 +16,6 @@ const { Services } = Cu.import("resource://gre/modules/Services.jsm");
let browser = Services.wm.getMostRecentWindow("navigator:browser");
let shell;
let test_counts = 0;
function loadShell() {
if (!browser) {
@ -31,50 +30,21 @@ function getContentWindow() {
return shell.contentBrowser.contentWindow;
}
function addChromeEventListener(type, listener) {
if (loadShell()) {
let content = getContentWindow();
content.addEventListener("mozChromeEvent", function chromeListener(evt) {
if (!evt.detail || evt.detail.type !== type) {
let eventHandler = function(evt) {
if (!evt.detail || evt.detail.type !== "permission-prompt") {
return;
}
let remove = listener(evt);
if (remove) {
content.removeEventListener("mozChromeEvent", chromeListener);
}
sendAsyncMessage("permission-request", evt.detail.permissions);
};
content.addEventListener("mozChromeEvent", eventHandler);
// need to remove ChromeEvent listener after test finished.
addMessageListener("teardown", function() {
content.removeEventListener("mozChromeEvent", eventHandler);
});
}
function checkPromptEvent(prompt_evt) {
let detail = prompt_evt.detail;
if (detail.permissions) {
if ("audio-capture" in detail.permissions) {
sendAsyncMessage("permission.granted", "audio-capture");
test_counts--;
}
if ("desktop-notification" in detail.permissions) {
sendAsyncMessage("permission.granted", "desktop-notification");
test_counts--;
}
if ("geolocation" in detail.permissions) {
sendAsyncMessage("permission.granted", "geolocation");
test_counts--;
}
}
if (!test_counts) {
debug("remove prompt event listener.");
return true;
}
return false;
}
if (loadShell()) {
addMessageListener("test.counts", function (counts) {
test_counts = counts;
});
addChromeEventListener("permission-prompt", checkPromptEvent);
}

View File

@ -11,57 +11,82 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=951997
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=951997">Permission prompt web content test</a>
<script type="application/javascript">
<script type="application/javascript;version=1.8">
"use strict";
const APP_URL = "SandboxPromptTest.html";
var iframe;
var gUrl = SimpleTest.getTestFileURL("permission_handler_chrome.js");
var gScript = SpecialPowers.loadChromeScript(gUrl);
var gResult = [
{
type: "audio-capture",
prompt: false
"video-capture": ["back"],
},
{
type: "geolocation",
prompt: false
"audio-capture": [""],
"video-capture": ["back"],
},
{
type: "desktop-notification",
prompt: false
"audio-capture": [""],
},
{
"geolocation": [],
},
{
"desktop-notification": [],
}
];
// Create a sanbox iframe.
function loadBrowser() {
var iframe = document.createElement("iframe");
SpecialPowers.wrap(iframe).mozbrowser = true;
iframe.src = APP_URL;
document.body.appendChild(iframe);
}
// send test counts to chrome script.
gScript.sendAsyncMessage("test.counts", gResult.length);
gScript.addMessageListener("permission.granted", function (aName) {
gResult.forEach(function(aType, aIndex) {
if (aType.type == aName) {
aType.prompt = true;
}
});
if(gResult.every(function(aType) { return aType.prompt; })) {
ok(true, "Get all permission prompts");
function runNext() {
if (gResult.length > 0) {
// Put the requested permission in query string
let requestedPermission = JSON.stringify(Object.keys(gResult[0]));
info('request permissions for ' + requestedPermission);
iframe.src = APP_URL + '?' + encodeURIComponent(requestedPermission);
} else {
info('test finished, teardown');
gScript.sendAsyncMessage("teardown", "");
gScript.destroy();
SimpleTest.finish();
}});
}
}
// Create a sanbox iframe.
function loadBrowser() {
iframe = document.createElement("iframe");
SpecialPowers.wrap(iframe).mozbrowser = true;
iframe.src = 'about:blank';
document.body.appendChild(iframe);
iframe.addEventListener("load", function onLoad() {
iframe.removeEventListener("load", onLoad);
runNext();
});
}
gScript.addMessageListener("permission-request", function (permissions) {
let expectedValue = gResult.shift();
let permissionTypes = Object.keys(permissions);
is(permissionTypes.length, Object.keys(expectedValue).length, "expected number of permissions");
for (let type of permissionTypes) {
ok(expectedValue.hasOwnProperty(type), "expected permission type");
for (let i in permissions[type]) {
is(permissions[type][i], expectedValue[type][i], "expected permission option");
}
}
runNext();
});
// Add permissions to this app. We use ALLOW_ACTION here. The ContentPermissionPrompt
// should prompt for permission, not allow it without prompt.
SpecialPowers.pushPrefEnv({"set": [["media.navigator.permission.disabled", false]]},
function() {
SpecialPowers.addPermission('video-capture',
SpecialPowers.Ci.nsIPermissionManager.ALLOW_ACTION, document);
SpecialPowers.addPermission('audio-capture',
SpecialPowers.Ci.nsIPermissionManager.ALLOW_ACTION, document);
SpecialPowers.addPermission('geolocation',

View File

@ -12,7 +12,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e0f39c7179c8b297326c0e2313950610be1f5c52"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="49312fb89b90eca48a8011b94a1a1a751daf32d2"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d11f524d00cacf5ba0dfbf25e4aa2158b1c3a036"/>
@ -96,6 +96,6 @@
<project name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="d2685281e2e54ca14d1df304867aa82c37b27162"/>
<project name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="627f9b20fc518937b93747a7ff1ed4f5ed46e06f"/>
<project name="platform/prebuilts/tools" path="prebuilts/tools" revision="c16df012d9649be75d6590f93aeacbdc24b29d53"/>
<project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="11663426672fcc46e2a0f29239afa736b90635ba"/>
<project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="431afac2ebfdd9c1c8402b413ff5914ed448e961"/>
<project name="android-sdk" path="sdk" remote="b2g" revision="5701d3cb45c2e848cc57003cda2e1141288ecae4"/>
</manifest>

View File

@ -11,7 +11,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e0f39c7179c8b297326c0e2313950610be1f5c52"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="49312fb89b90eca48a8011b94a1a1a751daf32d2"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="3d5c964015967ca8c86abe6dbbebee3cb82b1609"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="a314508e397c8f1814228d36259ea8708034444e"/>
@ -106,7 +106,7 @@
<project name="platform/ndk" path="ndk" revision="7666b97bbaf1d645cdd6b4430a367b7a2bb53369"/>
<project name="platform/prebuilts/misc" path="prebuilts/misc" revision="f6ab40b3257abc07741188fd173ac392575cc8d2"/>
<project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="e52099755d0bd3a579130eefe8e58066cc6c0cb6"/>
<project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="11663426672fcc46e2a0f29239afa736b90635ba"/>
<project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="431afac2ebfdd9c1c8402b413ff5914ed448e961"/>
<project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="842e33e43a55ea44833b9e23e4d180fa17c843af"/>
<project name="platform/prebuilts/tools" path="prebuilts/tools" revision="5db24726f0f42124304195a6bdea129039eeeaeb"/>
<project name="platform/system/bluetooth" path="system/bluetooth" revision="930ae098543881f47eac054677726ee4b998b2f8"/>

View File

@ -12,7 +12,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e0f39c7179c8b297326c0e2313950610be1f5c52"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="49312fb89b90eca48a8011b94a1a1a751daf32d2"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d11f524d00cacf5ba0dfbf25e4aa2158b1c3a036"/>
@ -96,6 +96,6 @@
<project name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="d2685281e2e54ca14d1df304867aa82c37b27162"/>
<project name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="627f9b20fc518937b93747a7ff1ed4f5ed46e06f"/>
<project name="platform/prebuilts/tools" path="prebuilts/tools" revision="c16df012d9649be75d6590f93aeacbdc24b29d53"/>
<project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="11663426672fcc46e2a0f29239afa736b90635ba"/>
<project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="431afac2ebfdd9c1c8402b413ff5914ed448e961"/>
<project name="android-sdk" path="sdk" remote="b2g" revision="5701d3cb45c2e848cc57003cda2e1141288ecae4"/>
</manifest>

View File

@ -1,4 +1,4 @@
{
"revision": "7e08d1fefea803f39389bb009e146aaa692d126a",
"revision": "e86b294efd18bfe96a58ba67f1b56fa48d70e753",
"repo_path": "/integration/gaia-central"
}

View File

@ -11,7 +11,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e0f39c7179c8b297326c0e2313950610be1f5c52"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="49312fb89b90eca48a8011b94a1a1a751daf32d2"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>

View File

@ -10,7 +10,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e0f39c7179c8b297326c0e2313950610be1f5c52"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="49312fb89b90eca48a8011b94a1a1a751daf32d2"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>

View File

@ -12,7 +12,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e0f39c7179c8b297326c0e2313950610be1f5c52"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="49312fb89b90eca48a8011b94a1a1a751daf32d2"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>

View File

@ -11,7 +11,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e0f39c7179c8b297326c0e2313950610be1f5c52"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="49312fb89b90eca48a8011b94a1a1a751daf32d2"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>

View File

@ -11,7 +11,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e0f39c7179c8b297326c0e2313950610be1f5c52"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="49312fb89b90eca48a8011b94a1a1a751daf32d2"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="3d5c964015967ca8c86abe6dbbebee3cb82b1609"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="a314508e397c8f1814228d36259ea8708034444e"/>
@ -106,7 +106,7 @@
<project name="platform/ndk" path="ndk" revision="7666b97bbaf1d645cdd6b4430a367b7a2bb53369"/>
<project name="platform/prebuilts/misc" path="prebuilts/misc" revision="f6ab40b3257abc07741188fd173ac392575cc8d2"/>
<project name="platform/prebuilts/ndk" path="prebuilts/ndk" revision="e52099755d0bd3a579130eefe8e58066cc6c0cb6"/>
<project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="11663426672fcc46e2a0f29239afa736b90635ba"/>
<project name="platform_prebuilts_qemu-kernel" path="prebuilts/qemu-kernel" remote="b2g" revision="431afac2ebfdd9c1c8402b413ff5914ed448e961"/>
<project name="platform/prebuilts/sdk" path="prebuilts/sdk" revision="842e33e43a55ea44833b9e23e4d180fa17c843af"/>
<project name="platform/prebuilts/tools" path="prebuilts/tools" revision="5db24726f0f42124304195a6bdea129039eeeaeb"/>
<project name="platform/system/bluetooth" path="system/bluetooth" revision="930ae098543881f47eac054677726ee4b998b2f8"/>

View File

@ -11,7 +11,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e0f39c7179c8b297326c0e2313950610be1f5c52"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="49312fb89b90eca48a8011b94a1a1a751daf32d2"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="15e8982284c4560f9c74c2b9fe8bb361ebfe0cb6"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="84f2f2fce22605e17d511ff1767e54770067b5b5"/>

View File

@ -11323,7 +11323,7 @@ public:
}
if (doc->mIsApprovedForFullscreen || doc->mAllowRelocking) {
Allow();
Allow(JS::UndefinedHandleValue);
return NS_OK;
}
@ -11368,8 +11368,10 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsPointerLockPermissionRequest,
NS_IMETHODIMP
nsPointerLockPermissionRequest::GetTypes(nsIArray** aTypes)
{
nsTArray<nsString> emptyOptions;
return CreatePermissionArray(NS_LITERAL_CSTRING("pointerLock"),
NS_LITERAL_CSTRING("unused"),
emptyOptions,
aTypes);
}
@ -11414,8 +11416,10 @@ nsPointerLockPermissionRequest::Cancel()
}
NS_IMETHODIMP
nsPointerLockPermissionRequest::Allow()
nsPointerLockPermissionRequest::Allow(JS::HandleValue aChoices)
{
MOZ_ASSERT(aChoices.isUndefined());
nsCOMPtr<Element> e = do_QueryReferent(mElement);
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);
nsDocument* d = static_cast<nsDocument*>(doc.get());

View File

@ -15,6 +15,9 @@
#include <stagefright/OMXClient.h>
#include <stagefright/OMXCodec.h>
#include <OMX.h>
#if MOZ_WIDGET_GONK && ANDROID_VERSION >= 18
#include <ui/Fence.h>
#endif
#include "mozilla/Preferences.h"
#include "mozilla/Types.h"
@ -213,7 +216,7 @@ VideoGraphicBuffer::Unlock()
// The message is delivered to OmxDecoder on ALooper thread.
// MediaBuffer::release() could take a very long time.
// PostReleaseVideoBuffer() prevents long time locking.
omxDecoder->PostReleaseVideoBuffer(mMediaBuffer);
omxDecoder->PostReleaseVideoBuffer(mMediaBuffer, mReleaseFenceHandle);
} else {
NS_WARNING("OmxDecoder is not present");
if (mMediaBuffer) {
@ -794,7 +797,7 @@ bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aTimeUs,
{
Mutex::Autolock autoLock(mSeekLock);
mIsVideoSeeking = false;
ReleaseAllPendingVideoBuffersLocked();
PostReleaseVideoBuffer(nullptr, FenceHandle());
}
aDoSeek = false;
@ -841,6 +844,9 @@ bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aTimeUs,
aFrame->mKeyFrame = keyFrame;
aFrame->Y.mWidth = mVideoWidth;
aFrame->Y.mHeight = mVideoHeight;
// Release to hold video buffer in OmxDecoder more.
// MediaBuffer's ref count is changed from 2 to 1.
ReleaseVideoBuffer();
} else if (mVideoBuffer->range_length() > 0) {
char *data = static_cast<char *>(mVideoBuffer->data()) + mVideoBuffer->range_offset();
size_t length = mVideoBuffer->range_length();
@ -1022,11 +1028,13 @@ void OmxDecoder::onMessageReceived(const sp<AMessage> &msg)
}
}
void OmxDecoder::PostReleaseVideoBuffer(MediaBuffer *aBuffer)
void OmxDecoder::PostReleaseVideoBuffer(MediaBuffer *aBuffer, const FenceHandle& aReleaseFenceHandle)
{
{
Mutex::Autolock autoLock(mPendingVideoBuffersLock);
mPendingVideoBuffers.push(aBuffer);
if (aBuffer) {
mPendingVideoBuffers.push(BufferItem(aBuffer, aReleaseFenceHandle));
}
}
sp<AMessage> notify =
@ -1037,14 +1045,13 @@ void OmxDecoder::PostReleaseVideoBuffer(MediaBuffer *aBuffer)
void OmxDecoder::ReleaseAllPendingVideoBuffersLocked()
{
Vector<MediaBuffer *> releasingVideoBuffers;
Vector<BufferItem> releasingVideoBuffers;
{
Mutex::Autolock autoLock(mPendingVideoBuffersLock);
int size = mPendingVideoBuffers.size();
for (int i = 0; i < size; i++) {
MediaBuffer *buffer = mPendingVideoBuffers[i];
releasingVideoBuffers.push(buffer);
releasingVideoBuffers.push(mPendingVideoBuffers[i]);
}
mPendingVideoBuffers.clear();
}
@ -1052,7 +1059,28 @@ void OmxDecoder::ReleaseAllPendingVideoBuffersLocked()
int size = releasingVideoBuffers.size();
for (int i = 0; i < size; i++) {
MediaBuffer *buffer;
buffer = releasingVideoBuffers[i];
buffer = releasingVideoBuffers[i].mMediaBuffer;
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
android::sp<Fence> fence;
int fenceFd = -1;
fence = releasingVideoBuffers[i].mReleaseFenceHandle.mFence;
if (fence.get() && fence->isValid()) {
fenceFd = fence->dup();
}
MOZ_ASSERT(buffer->refcount() == 1);
// This code expect MediaBuffer's ref count is 1.
// Return gralloc buffer to ANativeWindow
ANativeWindow* window = static_cast<ANativeWindow*>(mNativeWindowClient.get());
window->cancelBuffer(window,
buffer->graphicBuffer().get(),
fenceFd);
// Mark MediaBuffer as rendered.
// When gralloc buffer is directly returned to ANativeWindow,
// this mark is necesary.
sp<MetaData> metaData = buffer->meta_data();
metaData->setInt32(kKeyRendered, 1);
#endif
// Return MediaBuffer to OMXCodec.
buffer->release();
}
releasingVideoBuffers.clear();

View File

@ -10,6 +10,7 @@
#include "GonkNativeWindow.h"
#include "GonkNativeWindowClient.h"
#include "GrallocImages.h"
#include "mozilla/layers/FenceUtils.h"
#include "MP3FrameParser.h"
#include "MPAPI.h"
#include "MediaResource.h"
@ -83,6 +84,7 @@ class OmxDecoder : public OMXCodecProxy::EventListener {
typedef mozilla::MP3FrameParser MP3FrameParser;
typedef mozilla::MediaResource MediaResource;
typedef mozilla::AbstractMediaDecoder AbstractMediaDecoder;
typedef mozilla::layers::FenceHandle FenceHandle;
enum {
kPreferSoftwareCodecs = 1,
@ -122,11 +124,26 @@ class OmxDecoder : public OMXCodecProxy::EventListener {
MediaBuffer *mVideoBuffer;
MediaBuffer *mAudioBuffer;
struct BufferItem {
BufferItem()
: mMediaBuffer(nullptr)
{
}
BufferItem(MediaBuffer* aMediaBuffer, const FenceHandle& aReleaseFenceHandle)
: mMediaBuffer(aMediaBuffer)
, mReleaseFenceHandle(aReleaseFenceHandle) {
}
MediaBuffer* mMediaBuffer;
// a fence will signal when the current buffer is no longer being read.
FenceHandle mReleaseFenceHandle;
};
// Hold video's MediaBuffers that are released during video seeking.
// The holded MediaBuffers are released soon after seek completion.
// OMXCodec does not accept MediaBuffer during seeking. If MediaBuffer is
// returned to OMXCodec during seeking, OMXCodec calls assert.
Vector<MediaBuffer *> mPendingVideoBuffers;
Vector<BufferItem> mPendingVideoBuffers;
// The lock protects mPendingVideoBuffers.
Mutex mPendingVideoBuffersLock;
@ -235,7 +252,7 @@ public:
void Pause();
// Post kNotifyPostReleaseVideoBuffer message to OmxDecoder via ALooper.
void PostReleaseVideoBuffer(MediaBuffer *aBuffer);
void PostReleaseVideoBuffer(MediaBuffer *aBuffer, const FenceHandle& aReleaseFenceHandle);
// Receive a message from AHandlerReflector.
// Called on ALooper thread.
void onMessageReceived(const sp<AMessage> &msg);

View File

@ -51,6 +51,7 @@
#include "ImageContainer.h"
#include "nsGlobalWindow.h"
#include "prprf.h"
#include "mozilla/Hal.h"
#endif
#include "NullTransport.h"
@ -83,6 +84,7 @@ class MediaEngineWebRTCVideoSource : public MediaEngineVideoSource
, public nsRunnable
#ifdef MOZ_B2G_CAMERA
, public CameraControlListener
, public mozilla::hal::ScreenConfigurationObserver
#else
, public webrtc::ExternalRenderer
#endif
@ -92,7 +94,8 @@ public:
MediaEngineWebRTCVideoSource(int aIndex)
: mCameraControl(nullptr)
, mCallbackMonitor("WebRTCCamera.CallbackMonitor")
, mSensorAngle(0)
, mRotation(0)
, mBackCamera(false)
, mCaptureIndex(aIndex)
, mMonitor("WebRTCCamera.Monitor")
, mWidth(0)
@ -172,7 +175,8 @@ public:
void StartImpl(webrtc::CaptureCapability aCapability);
void StopImpl();
void SnapshotImpl();
void RotateImage(layers::Image* aImage);
void RotateImage(layers::Image* aImage, uint32_t aWidth, uint32_t aHeight);
void Notify(const mozilla::hal::ScreenConfiguration& aConfiguration);
#endif
// This runnable is for creating a temporary file on the main thread.
@ -207,7 +211,9 @@ private:
nsRefPtr<ICameraControl> mCameraControl;
mozilla::ReentrantMonitor mCallbackMonitor; // Monitor for camera callback handling
nsRefPtr<nsIDOMFile> mLastCapture;
int mSensorAngle;
int mRotation;
int mCameraAngle; // See dom/base/ScreenOrientation.h
bool mBackCamera;
#else
webrtc::VideoEngine* mVideoEngine; // Weak reference, don't free.
webrtc::ViEBase* mViEBase;

View File

@ -12,6 +12,9 @@
#ifdef MOZ_B2G_CAMERA
#include "GrallocImages.h"
#include "libyuv.h"
#include "mozilla/Hal.h"
#include "ScreenOrientation.h"
using namespace mozilla::dom;
#endif
namespace mozilla {
@ -137,7 +140,7 @@ MediaEngineWebRTCVideoSource::NotifyPull(MediaStreamGraph* aGraph,
nsRefPtr<layers::Image> image = mImage;
TrackTicks target = TimeToTicksRoundUp(USECS_PER_S, aDesiredTime);
TrackTicks delta = target - aLastEndTime;
LOGFRAME(("NotifyPull, desired = %ld, target = %ld, delta = %ld %s", (int64_t) aDesiredTime,
LOGFRAME(("NotifyPull, desired = %ld, target = %ld, delta = %ld %s", (int64_t) aDesiredTime,
(int64_t) target, (int64_t) delta, image ? "" : "<null>"));
// Bug 846188 We may want to limit incoming frames to the requested frame rate
@ -512,6 +515,7 @@ MediaEngineWebRTCVideoSource::AllocImpl() {
// in DeallocImpl() will do that for us.
mCameraControl->AddListener(this);
}
mCallbackMonitor.Notify();
}
@ -522,6 +526,54 @@ MediaEngineWebRTCVideoSource::DeallocImpl() {
mCameraControl = nullptr;
}
// The same algorithm from bug 840244
static int
GetRotateAmount(ScreenOrientation aScreen, int aCameraMountAngle, bool aBackCamera) {
int screenAngle = 0;
switch (aScreen) {
case eScreenOrientation_PortraitPrimary:
screenAngle = 0;
break;
case eScreenOrientation_PortraitSecondary:
screenAngle = 180;
break;
case eScreenOrientation_LandscapePrimary:
screenAngle = 90;
break;
case eScreenOrientation_LandscapeSecondary:
screenAngle = 270;
break;
default:
MOZ_ASSERT(false);
break;
}
int result;
if (aBackCamera) {
//back camera
result = (aCameraMountAngle - screenAngle + 360) % 360;
} else {
//front camera
result = (aCameraMountAngle + screenAngle) % 360;
}
return result;
}
// undefine to remove on-the-fly rotation support
// #define DYNAMIC_GUM_ROTATION
void
MediaEngineWebRTCVideoSource::Notify(const hal::ScreenConfiguration& aConfiguration) {
#ifdef DYNAMIC_GUM_ROTATION
MonitorAutoLock enter(mMonitor);
mRotation = GetRotateAmount(aConfiguration.orientation(), mCameraAngle, mBackCamera);
LOG(("*** New orientation: %d (Camera %d Back %d MountAngle: %d)",
mRotation, mCaptureIndex, mBackCamera, mCameraAngle));
#endif
}
void
MediaEngineWebRTCVideoSource::StartImpl(webrtc::CaptureCapability aCapability) {
MOZ_ASSERT(NS_IsMainThread());
@ -532,14 +584,15 @@ MediaEngineWebRTCVideoSource::StartImpl(webrtc::CaptureCapability aCapability) {
config.mPreviewSize.height = aCapability.height;
mCameraControl->Start(&config);
mCameraControl->Set(CAMERA_PARAM_PICTURESIZE, config.mPreviewSize);
mCameraControl->Get(CAMERA_PARAM_SENSORANGLE, mSensorAngle);
MOZ_ASSERT(mSensorAngle >= 0 && mSensorAngle < 360);
hal::RegisterScreenConfigurationObserver(this);
}
void
MediaEngineWebRTCVideoSource::StopImpl() {
MOZ_ASSERT(NS_IsMainThread());
hal::UnregisterScreenConfigurationObserver(this);
mCameraControl->Stop();
}
@ -563,6 +616,21 @@ MediaEngineWebRTCVideoSource::OnHardwareStateChange(HardwareState aState)
mCallbackMonitor.Notify();
}
} else {
mCameraControl->Get(CAMERA_PARAM_SENSORANGLE, mCameraAngle);
MOZ_ASSERT(mCameraAngle == 0 || mCameraAngle == 90 || mCameraAngle == 180 ||
mCameraAngle == 270);
hal::ScreenConfiguration aConfig;
hal::GetCurrentScreenConfiguration(&aConfig);
nsCString deviceName;
ICameraControl::GetCameraName(mCaptureIndex, deviceName);
if (deviceName.EqualsASCII("back")) {
mBackCamera = true;
}
mRotation = GetRotateAmount(aConfig.orientation(), mCameraAngle, mBackCamera);
LOG(("*** Initial orientation: %d (Camera %d Back %d MountAngle: %d)",
mRotation, mCaptureIndex, mBackCamera, mCameraAngle));
mState = kStarted;
mCallbackMonitor.Notify();
}
@ -587,13 +655,13 @@ MediaEngineWebRTCVideoSource::OnTakePictureComplete(uint8_t* aData, uint32_t aLe
}
void
MediaEngineWebRTCVideoSource::RotateImage(layers::Image* aImage) {
MediaEngineWebRTCVideoSource::RotateImage(layers::Image* aImage, uint32_t aWidth, uint32_t aHeight) {
layers::GrallocImage *nativeImage = static_cast<layers::GrallocImage*>(aImage);
layers::SurfaceDescriptor handle = nativeImage->GetSurfaceDescriptor();
layers::SurfaceDescriptorGralloc grallocHandle = handle.get_SurfaceDescriptorGralloc();
android::sp<android::GraphicBuffer> graphicBuffer = layers::GrallocBufferActor::GetFrom(grallocHandle);
void *pMem = nullptr;
uint32_t size = mWidth * mHeight * 3 / 2;
uint32_t size = aWidth * aHeight * 3 / 2;
graphicBuffer->lock(android::GraphicBuffer::USAGE_SW_READ_MASK, &pMem);
@ -602,12 +670,15 @@ MediaEngineWebRTCVideoSource::RotateImage(layers::Image* aImage) {
nsRefPtr<layers::Image> image = mImageContainer->CreateImage(ImageFormat::PLANAR_YCBCR);
layers::PlanarYCbCrImage* videoImage = static_cast<layers::PlanarYCbCrImage*>(image.get());
uint32_t dstWidth = mWidth;
uint32_t dstHeight = mHeight;
uint32_t dstWidth;
uint32_t dstHeight;
if (mSensorAngle == 90 || mSensorAngle == 270) {
dstWidth = mHeight;
dstHeight = mWidth;
if (mRotation == 90 || mRotation == 270) {
dstWidth = aHeight;
dstHeight = aWidth;
} else {
dstWidth = aWidth;
dstHeight = aHeight;
}
uint32_t half_width = dstWidth / 2;
@ -617,9 +688,9 @@ MediaEngineWebRTCVideoSource::RotateImage(layers::Image* aImage) {
dstPtr + (dstWidth * dstHeight), half_width,
dstPtr + (dstWidth * dstHeight * 5 / 4), half_width,
0, 0,
mWidth, mHeight,
mWidth, mHeight,
static_cast<libyuv::RotationMode>(mSensorAngle),
aWidth, aHeight,
aWidth, aHeight,
static_cast<libyuv::RotationMode>(mRotation),
libyuv::FOURCC_NV21);
graphicBuffer->unlock();
@ -651,17 +722,19 @@ MediaEngineWebRTCVideoSource::OnNewPreviewFrame(layers::Image* aImage, uint32_t
if (mState == kStopped) {
return false;
}
// Bug XXX we'd prefer to avoid converting if mRotation == 0, but that causes problems in UpdateImage()
RotateImage(aImage, aWidth, aHeight);
if (mRotation != 0 && mRotation != 180) {
uint32_t temp = aWidth;
aWidth = aHeight;
aHeight = temp;
}
if (mWidth != static_cast<int>(aWidth) || mHeight != static_cast<int>(aHeight)) {
mWidth = aWidth;
mHeight = aHeight;
LOG(("Video FrameSizeChange: %ux%u", mWidth, mHeight));
}
if (mSensorAngle == 0) {
mImage = aImage;
} else {
RotateImage(aImage);
}
return true; // return true because we're accepting the frame
}
#endif

View File

@ -19,6 +19,9 @@
#include "nsArrayUtils.h"
#include "nsIMutableArray.h"
#include "nsContentPermissionHelper.h"
#include "nsCxPusher.h"
#include "nsJSUtils.h"
#include "nsISupportsPrimitives.h"
using mozilla::unused; // <snicker>
using namespace mozilla::dom;
@ -94,10 +97,12 @@ ContentPermissionRequestParent::IsBeingDestroyed()
NS_IMPL_ISUPPORTS1(ContentPermissionType, nsIContentPermissionType)
ContentPermissionType::ContentPermissionType(const nsACString& aType,
const nsACString& aAccess)
const nsACString& aAccess,
const nsTArray<nsString>& aOptions)
{
mType = aType;
mAccess = aAccess;
mOptions = aOptions;
}
ContentPermissionType::~ContentPermissionType()
@ -118,6 +123,35 @@ ContentPermissionType::GetAccess(nsACString& aAccess)
return NS_OK;
}
NS_IMETHODIMP
ContentPermissionType::GetOptions(nsIArray** aOptions)
{
NS_ENSURE_ARG_POINTER(aOptions);
*aOptions = nullptr;
nsresult rv;
nsCOMPtr<nsIMutableArray> options =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
// copy options into JS array
for (uint32_t i = 0; i < mOptions.Length(); ++i) {
nsCOMPtr<nsISupportsString> isupportsString =
do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = isupportsString->SetData(mOptions[i]);
NS_ENSURE_SUCCESS(rv, rv);
rv = options->AppendElement(isupportsString, false);
NS_ENSURE_SUCCESS(rv, rv);
}
NS_ADDREF(*aOptions = options);
return NS_OK;
}
uint32_t
ConvertPermissionRequestToArray(nsTArray<PermissionRequest>& aSrcArray,
nsIMutableArray* aDesArray)
@ -125,7 +159,9 @@ ConvertPermissionRequestToArray(nsTArray<PermissionRequest>& aSrcArray,
uint32_t len = aSrcArray.Length();
for (uint32_t i = 0; i < len; i++) {
nsRefPtr<ContentPermissionType> cpt =
new ContentPermissionType(aSrcArray[i].type(), aSrcArray[i].access());
new ContentPermissionType(aSrcArray[i].type(),
aSrcArray[i].access(),
aSrcArray[i].options());
aDesArray->AppendElement(cpt, false);
}
return len;
@ -134,11 +170,13 @@ ConvertPermissionRequestToArray(nsTArray<PermissionRequest>& aSrcArray,
nsresult
CreatePermissionArray(const nsACString& aType,
const nsACString& aAccess,
const nsTArray<nsString>& aOptions,
nsIArray** aTypesArray)
{
nsCOMPtr<nsIMutableArray> types = do_CreateInstance(NS_ARRAY_CONTRACTID);
nsRefPtr<ContentPermissionType> permType = new ContentPermissionType(aType,
aAccess);
aAccess,
aOptions);
types->AppendElement(permType, false);
types.forget(aTypesArray);
@ -248,13 +286,15 @@ nsContentPermissionRequestProxy::Cancel()
return NS_ERROR_FAILURE;
}
unused << ContentPermissionRequestParent::Send__delete__(mParent, false);
nsTArray<PermissionChoice> emptyChoices;
unused << ContentPermissionRequestParent::Send__delete__(mParent, false, emptyChoices);
mParent = nullptr;
return NS_OK;
}
NS_IMETHODIMP
nsContentPermissionRequestProxy::Allow()
nsContentPermissionRequestProxy::Allow(JS::HandleValue aChoices)
{
if (mParent == nullptr) {
return NS_ERROR_FAILURE;
@ -282,7 +322,37 @@ nsContentPermissionRequestProxy::Allow()
}
#endif
unused << ContentPermissionRequestParent::Send__delete__(mParent, true);
nsTArray<PermissionChoice> choices;
if (aChoices.isNullOrUndefined()) {
// No choice is specified.
} else if (aChoices.isObject()) {
// Iterate through all permission types.
for (uint32_t i = 0; i < mPermissionRequests.Length(); ++i) {
nsCString type = mPermissionRequests[i].type();
mozilla::AutoSafeJSContext cx;
JS::Rooted<JSObject*> obj(cx, &aChoices.toObject());
JSAutoCompartment ac(cx, obj);
JS::Rooted<JS::Value> val(cx);
if (!JS_GetProperty(cx, obj, type.BeginReading(), &val) ||
!val.isString()) {
// no setting for the permission type, skip it
} else {
nsDependentJSString choice;
if (!choice.init(cx, val)) {
return NS_ERROR_FAILURE;
}
choices.AppendElement(PermissionChoice(type, choice));
}
}
} else {
MOZ_ASSERT(false, "SelectedChoices should be undefined or an JS object");
return NS_ERROR_FAILURE;
}
unused << ContentPermissionRequestParent::Send__delete__(mParent, true, choices);
mParent = nullptr;
return NS_OK;
}

View File

@ -35,12 +35,15 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSICONTENTPERMISSIONTYPE
ContentPermissionType(const nsACString& aType, const nsACString& aAccess);
ContentPermissionType(const nsACString& aType,
const nsACString& aAccess,
const nsTArray<nsString>& aOptions);
virtual ~ContentPermissionType();
protected:
nsCString mType;
nsCString mAccess;
nsTArray<nsString> mOptions;
};
uint32_t ConvertPermissionRequestToArray(nsTArray<PermissionRequest>& aSrcArray,
@ -48,6 +51,7 @@ uint32_t ConvertPermissionRequestToArray(nsTArray<PermissionRequest>& aSrcArray,
nsresult CreatePermissionArray(const nsACString& aType,
const nsACString& aAccess,
const nsTArray<nsString>& aOptions,
nsIArray** aTypesArray);
PContentPermissionRequestParent*

View File

@ -16,8 +16,6 @@ BEGIN_BLUETOOTH_NAMESPACE
class BluetoothHidManager : public BluetoothProfileManagerBase
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
BT_DECL_PROFILE_MGR_BASE
virtual void GetName(nsACString& aName)
{

View File

@ -72,6 +72,8 @@ public:
#define BT_DECL_PROFILE_MGR_BASE \
public: \
NS_DECL_ISUPPORTS \
NS_DECL_NSIOBSERVER \
virtual void OnGetServiceChannel(const nsAString& aDeviceAddress, \
const nsAString& aServiceUuid, \
int aChannel) MOZ_OVERRIDE; \

View File

@ -547,7 +547,7 @@ BluetoothService::SetEnabled(bool aEnabled)
* aEnabled: expected status of bluetooth
*/
if (mEnabled == aEnabled) {
BT_WARNING("Bluetooth has already been enabled/disabled before"
BT_WARNING("Bluetooth has already been enabled/disabled before "
"or the toggling is failed.");
}

View File

@ -15,8 +15,6 @@ BEGIN_BLUETOOTH_NAMESPACE
class BluetoothA2dpManager : public BluetoothProfileManagerBase
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
BT_DECL_PROFILE_MGR_BASE
virtual void GetName(nsACString& aName)
{

View File

@ -1464,7 +1464,7 @@ BluetoothOppManager::OnSocketDisconnect(BluetoothSocket* aSocket)
// Do nothing when a listening server socket is closed.
return;
}
BT_LOGR("[%s]", (mIsServer) ? "client" : "server");
BT_LOGR("[%s]", (mIsServer) ? "server" : "client");
/**
* It is valid for a bluetooth device which is transfering file via OPP

View File

@ -29,8 +29,6 @@ class BluetoothOppManager : public BluetoothSocketObserver
, public BluetoothProfileManagerBase
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
BT_DECL_PROFILE_MGR_BASE
virtual void GetName(nsACString& aName)
{

View File

@ -0,0 +1,183 @@
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "base/basictypes.h"
#include "BluetoothHfpManager.h"
#include "BluetoothProfileController.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPtr.h"
#include "nsIObserverService.h"
#include "nsThreadUtils.h"
using namespace mozilla;
USING_BLUETOOTH_NAMESPACE
namespace {
StaticRefPtr<BluetoothHfpManager> sBluetoothHfpManager;
bool sInShutdown = false;
} // anonymous namespace
/**
* nsIObserver function
*/
NS_IMETHODIMP
BluetoothHfpManager::Observe(nsISupports* aSubject,
const char* aTopic,
const char16_t* aData)
{
if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
HandleShutdown();
} else {
MOZ_ASSERT(false, "BluetoothHfpManager got unexpected topic!");
return NS_ERROR_UNEXPECTED;
}
return NS_OK;
}
/**
* BluetoothProfileManagerBase functions
*/
void
BluetoothHfpManager::Connect(const nsAString& aDeviceAddress,
BluetoothProfileController* aController)
{
MOZ_ASSERT(aController);
aController->OnConnect(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
}
void
BluetoothHfpManager::Disconnect(BluetoothProfileController* aController)
{
MOZ_ASSERT(aController);
aController->OnDisconnect(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
}
bool
BluetoothHfpManager::IsConnected()
{
return false;
}
void
BluetoothHfpManager::OnConnect(const nsAString& aErrorStr)
{
MOZ_ASSERT(false);
}
void
BluetoothHfpManager::OnDisconnect(const nsAString& aErrorStr)
{
MOZ_ASSERT(false);
}
void
BluetoothHfpManager::GetAddress(nsAString& aDeviceAddress)
{
aDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
}
void
BluetoothHfpManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
const nsAString& aServiceUuid,
int aChannel)
{
MOZ_ASSERT(false);
}
void
BluetoothHfpManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
{
MOZ_ASSERT(false);
}
/**
* BluetoothHfpManagerBase function
*/
bool
BluetoothHfpManager::IsScoConnected()
{
return false;
}
/**
* Non-inherited functions
*/
// static
BluetoothHfpManager*
BluetoothHfpManager::Get()
{
MOZ_ASSERT(NS_IsMainThread());
// If sBluetoothHfpManager already exists, exit early
if (sBluetoothHfpManager) {
return sBluetoothHfpManager;
}
// If we're in shutdown, don't create a new instance
NS_ENSURE_FALSE(sInShutdown, nullptr);
// Create a new instance and return
BluetoothHfpManager* manager = new BluetoothHfpManager();
NS_ENSURE_TRUE(manager->Init(), nullptr);
sBluetoothHfpManager = manager;
return sBluetoothHfpManager;
}
bool
BluetoothHfpManager::Init()
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
NS_ENSURE_TRUE(obs, false);
if (NS_FAILED(obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false))) {
BT_WARNING("Failed to add observers!");
return false;
}
return true;
}
void
BluetoothHfpManager::HandleShutdown()
{
MOZ_ASSERT(NS_IsMainThread());
sInShutdown = true;
sBluetoothHfpManager = nullptr;
}
bool
BluetoothHfpManager::ConnectSco()
{
MOZ_ASSERT(NS_IsMainThread());
/**
* TODO:
* Implement ConnectSco() for applications that want to create SCO link
* without a HFP connection (e.g., VoIP).
*/
return false;
}
bool
BluetoothHfpManager::DisconnectSco()
{
MOZ_ASSERT(NS_IsMainThread());
/**
* TODO:
* Implement DisconnectSco() for applications that want to destroy SCO link
* without a HFP connection (e.g., VoIP).
*/
return false;
}
NS_IMPL_ISUPPORTS1(BluetoothHfpManager, nsIObserver)

View File

@ -0,0 +1,45 @@
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_bluetooth_bluetoothhfpmanager_h__
#define mozilla_dom_bluetooth_bluetoothhfpmanager_h__
#include "BluetoothHfpManagerBase.h"
/**
* Fallback BluetoothHfpManager is built for non-phone devices (e.g., tablets).
* These devices has no radio interface and the build flag MOZ_B2G_RIL is
* disabled. To prevent build breaks of accessing radio interface, we implement
* fallback BluetoothHfpManager with empty functions to keep original
* BluetoothHfpManager away from numerous #ifdef/#endif statements.
*/
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothHfpManager : public BluetoothHfpManagerBase
{
public:
BT_DECL_HFP_MGR_BASE
virtual void GetName(nsACString& aName)
{
aName.AssignLiteral("Fallback HFP/HSP");
}
static BluetoothHfpManager* Get();
virtual ~BluetoothHfpManager() { }
bool ConnectSco();
bool DisconnectSco();
private:
BluetoothHfpManager() { }
bool Init();
void HandleShutdown();
};
END_BLUETOOTH_NAMESPACE
#endif

View File

@ -75,8 +75,6 @@ class BluetoothHfpManager : public BluetoothHfpManagerBase
, public BatteryObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
BT_DECL_HFP_MGR_BASE
virtual void GetName(nsACString& aName)
{

View File

@ -16,8 +16,6 @@ BEGIN_BLUETOOTH_NAMESPACE
class BluetoothA2dpManager : public BluetoothProfileManagerBase
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
BT_DECL_PROFILE_MGR_BASE
virtual void GetName(nsACString& aName)
{

View File

@ -79,8 +79,6 @@ class BluetoothHfpManager : public BluetoothSocketObserver
, public BatteryObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
BT_DECL_HFP_MGR_BASE
virtual void GetName(nsACString& aName)
{

View File

@ -29,8 +29,6 @@ class BluetoothOppManager : public BluetoothSocketObserver
, public BluetoothProfileManagerBase
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
BT_DECL_PROFILE_MGR_BASE
virtual void GetName(nsACString& aName)
{

View File

@ -30,40 +30,52 @@ if CONFIG['MOZ_B2G_BT']:
if CONFIG['MOZ_B2G_BT_BLUEZ']:
SOURCES += [
'bluez/BluetoothA2dpManager.cpp',
'bluez/BluetoothDBusService.cpp',
'bluez/BluetoothHfpManager.cpp',
'bluez/BluetoothOppManager.cpp',
'bluez/BluetoothSocket.cpp',
'bluez/BluetoothUnixSocketConnector.cpp',
'bluez/BluetoothUtils.cpp',
'bluez/linux/BluetoothDBusService.cpp',
]
LOCAL_INCLUDES += [
'bluez',
'bluez/linux',
]
DEFINES['MOZ_B2G_BT_BLUEZ'] = True
elif CONFIG['MOZ_B2G_BT_BLUEDROID']:
SOURCES += [
'bluedroid/BluetoothA2dpManager.cpp',
'bluedroid/BluetoothHfpManager.cpp',
'bluedroid/BluetoothOppManager.cpp',
'bluedroid/BluetoothServiceBluedroid.cpp',
'bluedroid/BluetoothSocket.cpp',
'bluedroid/BluetoothUtils.cpp',
'bluedroid/gonk/BluetoothServiceBluedroid.cpp',
]
LOCAL_INCLUDES += [
'bluedroid',
'bluedroid/gonk',
]
if CONFIG['MOZ_B2G_RIL']:
SOURCES += [
'bluedroid/hfp/BluetoothHfpManager.cpp',
]
LOCAL_INCLUDES += [
'bluedroid/hfp',
]
else:
SOURCES += [
'bluedroid/hfp-fallback/BluetoothHfpManager.cpp',
]
LOCAL_INCLUDES += [
'bluedroid/hfp-fallback',
]
DEFINES['MOZ_B2G_BT_BLUEDROID'] = True
elif CONFIG['MOZ_ENABLE_DBUS']:
SOURCES += [
'bluez/BluetoothDBusService.cpp',
'bluez/BluetoothHfpManager.cpp',
'bluez/linux/BluetoothDBusService.cpp',
]
LOCAL_INCLUDES += [
'bluez',
'bluez/linux',
]
DEFINES['MOZ_BLUETOOTH_DBUS'] = True
DEFINES['HAVE_PTHREADS'] = True

View File

@ -596,9 +596,12 @@ nsGonkCameraControl::SetThumbnailSizeImpl(const Size& aSize)
}
if (smallestDeltaIndex == UINT32_MAX) {
DOM_CAMERA_LOGW("Unable to find a thumbnail size close to %ux%u\n",
DOM_CAMERA_LOGW("Unable to find a thumbnail size close to %ux%u, disabling thumbnail\n",
aSize.width, aSize.height);
return NS_ERROR_INVALID_ARG;
// If we are unable to find a thumbnail size with a suitable aspect ratio,
// just disable the thumbnail altogether.
Size size = { 0, 0 };
return SetAndPush(CAMERA_PARAM_THUMBNAILSIZE, size);
}
Size size = supportedSizes[smallestDeltaIndex];

View File

@ -1574,10 +1574,12 @@ public:
~DeviceStorageCursorRequest() {}
bool Recv__delete__(const bool& allow)
bool Recv__delete__(const bool& allow,
const InfallibleTArray<PermissionChoice>& choices)
{
MOZ_ASSERT(choices.IsEmpty(), "DeviceStorageCursor doesn't support permission choice");
if (allow) {
Allow();
Allow(JS::UndefinedHandleValue);
}
else {
Cancel();
@ -1813,7 +1815,11 @@ nsDOMDeviceStorageCursor::GetTypes(nsIArray** aTypes)
DeviceStorageTypeChecker::GetPermissionForType(mFile->mStorageType, type);
NS_ENSURE_SUCCESS(rv, rv);
return CreatePermissionArray(type, NS_LITERAL_CSTRING("read"), aTypes);
nsTArray<nsString> emptyOptions;
return CreatePermissionArray(type,
NS_LITERAL_CSTRING("read"),
emptyOptions,
aTypes);
}
NS_IMETHODIMP
@ -1846,8 +1852,10 @@ nsDOMDeviceStorageCursor::Cancel()
}
NS_IMETHODIMP
nsDOMDeviceStorageCursor::Allow()
nsDOMDeviceStorageCursor::Allow(JS::HandleValue aChoices)
{
MOZ_ASSERT(aChoices.isUndefined());
if (!mFile->IsSafePath()) {
nsCOMPtr<nsIRunnable> r
= new PostErrorEvent(this, POST_ERROR_EVENT_PERMISSION_DENIED);
@ -1897,10 +1905,13 @@ nsDOMDeviceStorageCursor::Continue(ErrorResult& aRv)
}
bool
nsDOMDeviceStorageCursor::Recv__delete__(const bool& allow)
nsDOMDeviceStorageCursor::Recv__delete__(const bool& allow,
const InfallibleTArray<PermissionChoice>& choices)
{
MOZ_ASSERT(choices.IsEmpty(), "DeviceStorageCursor doesn't support permission choice");
if (allow) {
Allow();
Allow(JS::UndefinedHandleValue);
}
else {
Cancel();
@ -2422,7 +2433,7 @@ public:
MOZ_ASSERT(NS_IsMainThread());
if (mozilla::Preferences::GetBool("device.storage.prompt.testing", false)) {
Allow();
Allow(JS::UndefinedHandleValue);
return NS_OK;
}
@ -2453,7 +2464,8 @@ public:
return rv;
}
nsTArray<PermissionRequest> permArray;
permArray.AppendElement(PermissionRequest(type, access));
nsTArray<nsString> emptyOptions;
permArray.AppendElement(PermissionRequest(type, access, emptyOptions));
child->SendPContentPermissionRequestConstructor(
this, permArray, IPC::Principal(mPrincipal));
@ -2485,7 +2497,8 @@ public:
return rv;
}
return CreatePermissionArray(type, access, aTypes);
nsTArray<nsString> emptyOptions;
return CreatePermissionArray(type, access, emptyOptions, aTypes);
}
NS_IMETHOD GetPrincipal(nsIPrincipal * *aRequestingPrincipal)
@ -2514,9 +2527,10 @@ public:
return NS_DispatchToMainThread(event);
}
NS_IMETHOD Allow()
NS_IMETHOD Allow(JS::HandleValue aChoices)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aChoices.isUndefined());
if (!mRequest) {
return NS_ERROR_FAILURE;
@ -2772,10 +2786,13 @@ public:
return NS_OK;
}
bool Recv__delete__(const bool& allow)
bool Recv__delete__(const bool& allow,
const InfallibleTArray<PermissionChoice>& choices)
{
MOZ_ASSERT(choices.IsEmpty(), "DeviceStorage doesn't support permission choice");
if (allow) {
Allow();
Allow(JS::UndefinedHandleValue);
}
else {
Cancel();
@ -3641,7 +3658,7 @@ nsDOMDeviceStorage::EnumerateInternal(const nsAString& aPath,
= new DeviceStorageCursorRequest(cursor);
if (mozilla::Preferences::GetBool("device.storage.prompt.testing", false)) {
r->Allow();
r->Allow(JS::UndefinedHandleValue);
return cursor.forget();
}
@ -3663,7 +3680,10 @@ nsDOMDeviceStorage::EnumerateInternal(const nsAString& aPath,
return nullptr;
}
nsTArray<PermissionRequest> permArray;
permArray.AppendElement(PermissionRequest(type, NS_LITERAL_CSTRING("read")));
nsTArray<nsString> emptyOptions;
permArray.AppendElement(PermissionRequest(type,
NS_LITERAL_CSTRING("read"),
emptyOptions));
child->SendPContentPermissionRequestConstructor(r,
permArray,
IPC::Principal(mPrincipal));

View File

@ -204,7 +204,8 @@ public:
bool mOkToCallContinue;
PRTime mSince;
virtual bool Recv__delete__(const bool& allow) MOZ_OVERRIDE;
virtual bool Recv__delete__(const bool& allow,
const InfallibleTArray<PermissionChoice>& choices) MOZ_OVERRIDE;
virtual void IPDLRelease() MOZ_OVERRIDE;
void GetStorageType(nsAString & aType);

View File

@ -12,7 +12,7 @@ interface nsIArray;
/**
* Interface provides the request type and its access.
*/
[scriptable, uuid(384b6cc4-a66b-4bea-98e0-eb10562a9ba4)]
[scriptable, uuid(ef4db3b8-ca9c-4b1d-8f81-fd88ec32af13)]
interface nsIContentPermissionType : nsISupports {
/**
* The type of the permission request, such as
@ -25,6 +25,11 @@ interface nsIContentPermissionType : nsISupports {
* "read".
*/
readonly attribute ACString access;
/**
* The array of available options.
*/
readonly attribute nsIArray options; // ["choice1", "choice2"]
};
/**
@ -59,7 +64,7 @@ interface nsIContentPermissionRequest : nsISupports {
*/
void cancel();
void allow();
void allow([optional] in jsval choices); // {"type1": "choice1", "type2": "choiceA"}
};
/**

View File

@ -8,6 +8,12 @@ namespace dom {
struct PermissionRequest {
nsCString type;
nsCString access;
nsString[] options;
};
struct PermissionChoice {
nsCString type;
nsString choice;
};
} // namespace dom

View File

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PBrowser;
include PContentPermission;
namespace mozilla {
namespace dom {
@ -15,7 +16,7 @@ parent:
prompt();
child:
__delete__(bool allow);
__delete__(bool allow, PermissionChoice[] choices);
};

View File

@ -10,7 +10,9 @@
#include "nsIContentPermissionPrompt.h"
#include "nsIDocument.h"
#include "nsIDOMNavigatorUserMedia.h"
#include "nsIStringEnumerator.h"
#include "nsISupportsArray.h"
#include "nsJSUtils.h"
#include "nsPIDOMWindow.h"
#include "nsTArray.h"
#include "GetUserMediaRequest.h"
@ -45,11 +47,54 @@ ConvertArrayToPermissionRequest(nsIArray* aSrcArray,
nsAutoCString access;
cpt->GetType(type);
cpt->GetAccess(access);
aDesArray.AppendElement(PermissionRequest(type, access));
nsCOMPtr<nsIArray> optionArray;
cpt->GetOptions(getter_AddRefs(optionArray));
uint32_t optionsLength = 0;
optionArray->GetLength(&optionsLength);
nsTArray<nsString> options;
for (uint32_t j = 0; j < optionsLength; ++j) {
nsCOMPtr<nsISupportsString> isupportsString = do_QueryElementAt(optionArray, j);
if (isupportsString) {
nsString option;
isupportsString->GetData(option);
options.AppendElement(option);
}
}
aDesArray.AppendElement(PermissionRequest(type, access, options));
}
return len;
}
static void
CreateDeviceNameList(nsTArray<nsCOMPtr<nsIMediaDevice> > &aDevices,
nsTArray<nsString> &aDeviceNameList)
{
for (uint32_t i = 0; i < aDevices.Length(); ++i) {
nsString name;
nsresult rv = aDevices[i]->GetName(name);
NS_ENSURE_SUCCESS_VOID(rv);
aDeviceNameList.AppendElement(name);
}
}
static already_AddRefed<nsIMediaDevice>
FindDeviceByName(nsTArray<nsCOMPtr<nsIMediaDevice> > &aDevices,
const nsAString &aDeviceName)
{
for (uint32_t i = 0; i < aDevices.Length(); ++i) {
nsCOMPtr<nsIMediaDevice> device = aDevices[i];
nsString deviceName;
device->GetName(deviceName);
if (deviceName.Equals(aDeviceName)) {
return device.forget();
}
}
return nullptr;
}
// Helper function for notifying permission granted
static nsresult
NotifyPermissionAllow(const nsAString &aCallID, nsTArray<nsCOMPtr<nsIMediaDevice> > &aDevices)
@ -108,16 +153,20 @@ public:
virtual ~MediaPermissionRequest() {}
// It will be called when prompt dismissed.
virtual bool Recv__delete__(const bool &allow) MOZ_OVERRIDE;
virtual bool Recv__delete__(const bool &allow,
const InfallibleTArray<PermissionChoice>& choices) MOZ_OVERRIDE;
virtual void IPDLRelease() MOZ_OVERRIDE { Release(); }
already_AddRefed<nsPIDOMWindow> GetOwner();
private:
nsresult DoAllow(const nsString &audioDevice, const nsString &videoDevice);
bool mAudio; // Request for audio permission
bool mVideo; // Request for video permission
nsRefPtr<dom::GetUserMediaRequest> mRequest;
nsTArray<nsCOMPtr<nsIMediaDevice> > mDevices; // candiate device list
nsTArray<nsCOMPtr<nsIMediaDevice> > mAudioDevices; // candidate audio devices
nsTArray<nsCOMPtr<nsIMediaDevice> > mVideoDevices; // candidate video devices
};
// MediaPermissionRequest
@ -138,10 +187,10 @@ MediaPermissionRequest::MediaPermissionRequest(nsRefPtr<dom::GetUserMediaRequest
nsAutoString deviceType;
device->GetType(deviceType);
if (mAudio && deviceType.EqualsLiteral("audio")) {
mDevices.AppendElement(device);
mAudioDevices.AppendElement(device);
}
if (mVideo && deviceType.EqualsLiteral("video")) {
mDevices.AppendElement(device);
mVideoDevices.AppendElement(device);
}
}
}
@ -151,16 +200,23 @@ NS_IMETHODIMP
MediaPermissionRequest::GetTypes(nsIArray** aTypes)
{
nsCOMPtr<nsIMutableArray> types = do_CreateInstance(NS_ARRAY_CONTRACTID);
//XXX append device list
if (mAudio) {
nsTArray<nsString> audioDeviceNames;
CreateDeviceNameList(mAudioDevices, audioDeviceNames);
nsCOMPtr<ContentPermissionType> AudioType =
new ContentPermissionType(NS_LITERAL_CSTRING(AUDIO_PERMISSION_NAME),
NS_LITERAL_CSTRING("unused"));
NS_LITERAL_CSTRING("unused"),
audioDeviceNames);
types->AppendElement(AudioType, false);
}
if (mVideo) {
nsTArray<nsString> videoDeviceNames;
CreateDeviceNameList(mVideoDevices, videoDeviceNames);
nsCOMPtr<ContentPermissionType> VideoType =
new ContentPermissionType(NS_LITERAL_CSTRING(VIDEO_PERMISSION_NAME),
NS_LITERAL_CSTRING("unused"));
NS_LITERAL_CSTRING("unused"),
videoDeviceNames);
types->AppendElement(VideoType, false);
}
NS_IF_ADDREF(*aTypes = types);
@ -212,12 +268,74 @@ MediaPermissionRequest::Cancel()
}
NS_IMETHODIMP
MediaPermissionRequest::Allow()
MediaPermissionRequest::Allow(JS::HandleValue aChoices)
{
// check if JS object
if (!aChoices.isObject()) {
MOZ_ASSERT(false, "Not a correct format of PermissionChoice");
return NS_ERROR_INVALID_ARG;
}
// iterate through audio-capture and video-capture
AutoSafeJSContext cx;
JS::Rooted<JSObject*> obj(cx, &aChoices.toObject());
JSAutoCompartment ac(cx, obj);
JS::Rooted<JS::Value> v(cx);
// get selected audio device name
nsString audioDevice;
if (mAudio) {
if (!JS_GetProperty(cx, obj, AUDIO_PERMISSION_NAME, &v) || !v.isString()) {
return NS_ERROR_FAILURE;
}
nsDependentJSString deviceName;
if (!deviceName.init(cx, v)) {
MOZ_ASSERT(false, "Couldn't initialize string from aChoices");
return NS_ERROR_FAILURE;
}
audioDevice = deviceName;
}
// get selected video device name
nsString videoDevice;
if (mVideo) {
if (!JS_GetProperty(cx, obj, VIDEO_PERMISSION_NAME, &v) || !v.isString()) {
return NS_ERROR_FAILURE;
}
nsDependentJSString deviceName;
if (!deviceName.init(cx, v)) {
MOZ_ASSERT(false, "Couldn't initialize string from aChoices");
return NS_ERROR_FAILURE;
}
videoDevice = deviceName;
}
return DoAllow(audioDevice, videoDevice);
}
nsresult
MediaPermissionRequest::DoAllow(const nsString &audioDevice,
const nsString &videoDevice)
{
nsTArray<nsCOMPtr<nsIMediaDevice> > selectedDevices;
if (mAudio) {
nsCOMPtr<nsIMediaDevice> device =
FindDeviceByName(mAudioDevices, audioDevice);
if (device) {
selectedDevices.AppendElement(device);
}
}
if (mVideo) {
nsCOMPtr<nsIMediaDevice> device =
FindDeviceByName(mVideoDevices, videoDevice);
if (device) {
selectedDevices.AppendElement(device);
}
}
nsString callID;
mRequest->GetCallID(callID);
NotifyPermissionAllow(callID, mDevices);
return NS_OK;
return NotifyPermissionAllow(callID, selectedDevices);
}
already_AddRefed<nsPIDOMWindow>
@ -230,10 +348,21 @@ MediaPermissionRequest::GetOwner()
//PCOMContentPermissionRequestChild
bool
MediaPermissionRequest::Recv__delete__(const bool& allow)
MediaPermissionRequest::Recv__delete__(const bool& allow,
const InfallibleTArray<PermissionChoice>& choices)
{
if (allow) {
(void) Allow();
// get selected device name for audio and video
nsString audioDevice, videoDevice;
for (uint32_t i = 0; i < choices.Length(); ++i) {
const nsString &choice = choices[i].choice();
if (choices[i].type().EqualsLiteral(AUDIO_PERMISSION_NAME)) {
audioDevice = choice;
} else if (choices[i].type().EqualsLiteral(VIDEO_PERMISSION_NAME)) {
videoDevice = choice;
}
}
(void) DoAllow(audioDevice, videoDevice);
} else {
(void) Cancel();
}

View File

@ -74,10 +74,20 @@ this.PermissionPromptHelper = {
}
if (permValue == Ci.nsIPermissionManager.PROMPT_ACTION) {
// create the options from permission request.
let options = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
if (msg.options) {
for (let option of options) {
options.appendElement(option);
}
}
// create an array with a nsIContentPermissionType element
let type = {
type: msg.type,
access: msg.access ? msg.access : "unused",
options: options,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionType])
};
let typeArray = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
@ -122,9 +132,10 @@ this.PermissionPromptHelper = {
{ result: Ci.nsIPermissionManager.DENY_ACTION,
requestID: msg.requestID });
},
allow: function() {
allow: function(aChoice) {
mm.sendAsyncMessage("PermissionPromptHelper:AskPermission:OK",
{ result: Ci.nsIPermissionManager.ALLOW_ACTION,
choice: aChoice,
requestID: msg.requestID });
}
});

View File

@ -23,7 +23,7 @@ this.PHONE_NUMBER_META_DATA = {
"500": '["FK","00",,,,,"\\d{5}","[2-7]\\d{4}",]',
"261": '["MG","00","0",,,"$NP$FG","\\d{7,9}","[23]\\d{8}",[["([23]\\d)(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",,,]]]',
"92": '["PK","00","0",,,"($NP$FG)","\\d{6,12}","1\\d{8}|[2-8]\\d{5,11}|9(?:[013-9]\\d{4,9}|2\\d(?:111\\d{6}|\\d{3,7}))",[["(\\d{2})(111)(\\d{3})(\\d{3})","$1 $2 $3 $4","(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)1",,],["(\\d{3})(111)(\\d{3})(\\d{3})","$1 $2 $3 $4","2[349]|45|54|60|72|8[2-5]|9[2-9]",,],["(\\d{2})(\\d{7,8})","$1 $2","(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]",,],["(\\d{3})(\\d{6,7})","$1 $2","2[349]|45|54|60|72|8[2-5]|9[2-9]",,],["(3\\d{2})(\\d{7})","$1 $2","3","$NP$FG",],["([15]\\d{3})(\\d{5,6})","$1 $2","58[12]|1",,],["(586\\d{2})(\\d{5})","$1 $2","586",,],["([89]00)(\\d{3})(\\d{2})","$1 $2 $3","[89]00","$NP$FG",]]]',
"234": '["NG","009","0",,,"$NP$FG","\\d{5,14}","[1-69]\\d{5,8}|[78]\\d{5,13}",[["([129])(\\d{3})(\\d{3,4})","$1 $2 $3","[129]",,],["([3-8]\\d)(\\d{3})(\\d{2,3})","$1 $2 $3","[3-6]|7(?:[1-79]|0[1-9])|8[2-9]",,],["([78]\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3","70|8[01]",,],["([78]00)(\\d{4})(\\d{4,5})","$1 $2 $3","[78]00",,],["([78]00)(\\d{5})(\\d{5,6})","$1 $2 $3","[78]00",,],["(78)(\\d{2})(\\d{3})","$1 $2 $3","78",,]]]',
"234": '["NG","009","0",,,"$NP$FG","\\d{5,14}","[1-6]\\d{5,8}|9\\d{5,9}|[78]\\d{5,13}",[["([129])(\\d{3})(\\d{3,4})","$1 $2 $3","[129]",,],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3","[3-6]|7(?:[1-79]|0[1-9])|8[2-9]",,],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3","70|8[01]|90[39]",,],["([78]00)(\\d{4})(\\d{4,5})","$1 $2 $3","[78]00",,],["([78]00)(\\d{5})(\\d{5,6})","$1 $2 $3","[78]00",,],["(78)(\\d{2})(\\d{3})","$1 $2 $3","78",,]]]',
"350": '["GI","00",,,,,"\\d{8}","[2568]\\d{7}",[["(\\d{3})(\\d{5})","$1 $2","2",,]]]',
"45": '["DK","00",,,,,"\\d{8}","[2-9]\\d{7}",[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",,,]]]',
"963": '["SY","00","0",,,"$NP$FG","\\d{6,9}","[1-59]\\d{7,8}",[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3","[1-5]",,],["(9\\d{2})(\\d{3})(\\d{3})","$1 $2 $3","9",,]]]',
@ -51,7 +51,7 @@ this.PHONE_NUMBER_META_DATA = {
"507": '["PA","00",,,,,"\\d{7,8}","[1-9]\\d{6,7}",[["(\\d{3})(\\d{4})","$1-$2","[1-57-9]",,],["(\\d{4})(\\d{4})","$1-$2","6",,]]]',
"692": '["MH","011","1",,,,"\\d{7}","[2-6]\\d{6}",[["(\\d{3})(\\d{4})","$1-$2",,,]]]',
"250": '["RW","00","0",,,,"\\d{8,9}","[027-9]\\d{7,8}",[["(2\\d{2})(\\d{3})(\\d{3})","$1 $2 $3","2","$FG",],["([7-9]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3","[7-9]","$NP$FG",],["(0\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4","0",,]]]',
"81": '["JP","010","0",,,"$NP$FG","\\d{7,16}","[1-9]\\d{8,9}|0(?:[36]\\d{7,14}|7\\d{5,7}|8\\d{7})",[["(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3","(?:12|57|99)0",,],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3","800",,],["(\\d{3})(\\d{4})","$1-$2","077",,],["(\\d{3})(\\d{2})(\\d{3,4})","$1-$2-$3","077",,],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3","088",,],["(\\d{3})(\\d{3})(\\d{3,4})","$1-$2-$3","0(?:37|66)",,],["(\\d{3})(\\d{4})(\\d{4,5})","$1-$2-$3","0(?:37|66)",,],["(\\d{3})(\\d{5})(\\d{5,6})","$1-$2-$3","0(?:37|66)",,],["(\\d{3})(\\d{6})(\\d{6,7})","$1-$2-$3","0(?:37|66)",,],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3","[2579]0|80[1-9]",,],["(\\d{4})(\\d)(\\d{4})","$1-$2-$3","1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|5(?:76|97)|499|746|8(?:3[89]|63|47|51)|9(?:49|80|9[16])",,],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3","1(?:2[3-6]|3[3-9]|4[2-6]|5[2-8]|[68][2-7]|7[2-689]|9[1-578])|2(?:2[03-689]|3[3-58]|4[0-468]|5[04-8]|6[013-8]|7[06-9]|8[02-57-9]|9[13])|4(?:2[28]|3[689]|6[035-7]|7[05689]|80|9[3-5])|5(?:3[1-36-9]|4[4578]|5[013-8]|6[1-9]|7[2-8]|8[14-7]|9[4-9])|7(?:2[15]|3[5-9]|4[02-9]|6[135-8]|7[0-4689]|9[014-9])|8(?:2[49]|3[3-8]|4[5-8]|5[2-9]|6[35-9]|7[579]|8[03-579]|9[2-8])|9(?:[23]0|4[02-46-9]|5[024-79]|6[4-9]|7[2-47-9]|8[02-7]|9[3-7])",,],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3","1|2(?:2[37]|5[5-9]|64|78|8[39]|91)|4(?:2[2689]|64|7[347])|5(?:[2-589]|39)|60|8(?:[46-9]|3[279]|2[124589])|9(?:[235-8]|93)",,],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3","2(?:9[14-79]|74|[34]7|[56]9)|82|993",,],["(\\d)(\\d{4})(\\d{4})","$1-$2-$3","3|4(?:2[09]|7[01])|6[1-9]",,],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3","[2479][1-9]",,]]]',
"81": '["JP","010","0",,,"$NP$FG","\\d{8,17}","[1-9]\\d{8,9}|00(?:[36]\\d{7,14}|7\\d{5,7}|8\\d{7})",[["(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3","(?:12|57|99)0",,],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3","800",,],["(\\d{4})(\\d{4})","$1-$2","0077","$FG","NA"],["(\\d{4})(\\d{2})(\\d{3,4})","$1-$2-$3","0077","$FG","NA"],["(\\d{4})(\\d{2})(\\d{4})","$1-$2-$3","0088","$FG","NA"],["(\\d{4})(\\d{3})(\\d{3,4})","$1-$2-$3","00(?:37|66)","$FG","NA"],["(\\d{4})(\\d{4})(\\d{4,5})","$1-$2-$3","00(?:37|66)","$FG","NA"],["(\\d{4})(\\d{5})(\\d{5,6})","$1-$2-$3","00(?:37|66)","$FG","NA"],["(\\d{4})(\\d{6})(\\d{6,7})","$1-$2-$3","00(?:37|66)","$FG","NA"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3","[2579]0|80[1-9]",,],["(\\d{4})(\\d)(\\d{4})","$1-$2-$3","1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|5(?:76|97)|499|746|8(?:3[89]|63|47|51)|9(?:49|80|9[16])",,],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3","1(?:2[3-6]|3[3-9]|4[2-6]|5[2-8]|[68][2-7]|7[2-689]|9[1-578])|2(?:2[03-689]|3[3-58]|4[0-468]|5[04-8]|6[013-8]|7[06-9]|8[02-57-9]|9[13])|4(?:2[28]|3[689]|6[035-7]|7[05689]|80|9[3-5])|5(?:3[1-36-9]|4[4578]|5[013-8]|6[1-9]|7[2-8]|8[14-7]|9[4-9])|7(?:2[15]|3[5-9]|4[02-9]|6[135-8]|7[0-4689]|9[014-9])|8(?:2[49]|3[3-8]|4[5-8]|5[2-9]|6[35-9]|7[579]|8[03-579]|9[2-8])|9(?:[23]0|4[02-46-9]|5[024-79]|6[4-9]|7[2-47-9]|8[02-7]|9[3-7])",,],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3","1|2(?:2[37]|5[5-9]|64|78|8[39]|91)|4(?:2[2689]|64|7[347])|5(?:[2-589]|39)|60|8(?:[46-9]|3[279]|2[124589])|9(?:[235-8]|93)",,],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3","2(?:9[14-79]|74|[34]7|[56]9)|82|993",,],["(\\d)(\\d{4})(\\d{4})","$1-$2-$3","3|4(?:2[09]|7[01])|6[1-9]",,],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3","[2479][1-9]",,]]]',
"237": '["CM","00",,,,,"\\d{8}","[2357-9]\\d{7}",[["([2357-9]\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4","[23579]|88",,],["(800)(\\d{2})(\\d{3})","$1 $2 $3","80",,]]]',
"351": '["PT","00",,,,,"\\d{9}","[2-46-9]\\d{8}",[["(2\\d)(\\d{3})(\\d{4})","$1 $2 $3","2[12]",,],["([2-46-9]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3","2[3-9]|[346-9]",,]]]',
"246": '["IO","00",,,,,"\\d{7}","3\\d{6}",[["(\\d{3})(\\d{4})","$1 $2",,,]]]',
@ -66,14 +66,14 @@ this.PHONE_NUMBER_META_DATA = {
"421": '["SK","00","0",,,"$NP$FG","\\d{9}","[2-689]\\d{8}",[["(2)(\\d{3})(\\d{3})(\\d{2})","$1/$2 $3 $4","2",,],["([3-5]\\d)(\\d{3})(\\d{2})(\\d{2})","$1/$2 $3 $4","[3-5]",,],["([689]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3","[689]",,]]]',
"672": '["NF","00",,,,,"\\d{5,6}","[13]\\d{5}",[["(\\d{2})(\\d{4})","$1 $2","1",,],["(\\d)(\\d{5})","$1 $2","3",,]]]',
"870": '["001",,,,,,"\\d{9}","[35-7]\\d{8}",[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",,,]]]',
"883": '["001",,,,,,"\\d{9}(?:\\d{3})?","51\\d{7}(?:\\d{3})?",[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",,,],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",,,]]]',
"883": '["001",,,,,,"\\d{9}(?:\\d{3})?","51\\d{7}(?:\\d{3})?",[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3","510",,],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4","510",,],["(\\d{4})(\\d{4})(\\d{4})","$1 $2 $3","51[13]",,]]]',
"264": '["NA","00","0",,,"$NP$FG","\\d{8,9}","[68]\\d{7,8}",[["(8\\d)(\\d{3})(\\d{4})","$1 $2 $3","8[1235]",,],["(6\\d)(\\d{2,3})(\\d{4})","$1 $2 $3","6",,],["(88)(\\d{3})(\\d{3})","$1 $2 $3","88",,],["(870)(\\d{3})(\\d{3})","$1 $2 $3","870",,]]]',
"878": '["001",,,,,,"\\d{12}","1\\d{11}",[["(\\d{2})(\\d{5})(\\d{5})","$1 $2 $3",,,]]]',
"239": '["ST","00",,,,,"\\d{7}","[29]\\d{6}",[["(\\d{3})(\\d{4})","$1 $2",,,]]]',
"357": '["CY","00",,,,,"\\d{8}","[257-9]\\d{7}",[["(\\d{2})(\\d{6})","$1 $2",,,]]]',
"240": '["GQ","00",,,,,"\\d{9}","[23589]\\d{8}",[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3","[235]",,],["(\\d{3})(\\d{6})","$1 $2","[89]",,]]]',
"506": '["CR","00",,"(19(?:0[01468]|19|20|66|77))",,,"\\d{8,10}","[24-9]\\d{7,9}",[["(\\d{4})(\\d{4})","$1 $2","[24-7]|8[3-9]",,],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3","[89]0",,]]]',
"86": '["CN","(1[1279]\\d{3})?00","0","(1[1279]\\d{3})|0",,,"\\d{4,12}","1(?:00\\d{2}|\\d{6,11})|[2-7]\\d{6,11}|8[0-357-9]\\d{6,9}|9(?:5\\d{3,4}|\\d{9})",[["(80\\d{2})(\\d{4})","$1 $2","80[2678]","$NP$FG",],["([48]00)(\\d{3})(\\d{4})","$1 $2 $3","[48]00",,],["(\\d{5,6})","$1","100|95",,"NA"],["(\\d{2})(\\d{5,6})","$1 $2","(?:10|2\\d)[19]","$NP$FG",],["(\\d{3})(\\d{5,6})","$1 $2","[3-9]","$NP$FG",],["(\\d{3,4})(\\d{4})","$1 $2","[2-9]",,"NA"],["(21)(\\d{4})(\\d{4,6})","$1 $2 $3","21","$NP$FG",],["([12]\\d)(\\d{4})(\\d{4})","$1 $2 $3","10[1-9]|2[02-9]","$NP$FG",],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3","3(?:11|7[179])|4(?:[15]1|3[12])|5(?:1|2[37]|3[12]|51|7[13-79]|9[15])|7(?:31|5[457]|6[09]|91)|8(?:71|98)","$NP$FG",],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3","3(?:1[02-9]|35|49|5|7[02-68]|9[1-68])|4(?:1[02-9]|2[179]|[35][2-9]|6[4789]|7\\d|8[23])|5(?:3[03-9]|4[36]|5[02-9]|6[1-46]|7[028]|80|9[2-46-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[04-9]|4[3-6]|6[2368])|8(?:1[236-8]|2[5-7]|3|5[1-9]|7[02-9]|8[3678]|9[1-7])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])","$NP$FG",],["(1[3-58]\\d)(\\d{4})(\\d{4})","$1 $2 $3","1[3-58]",,],["(10800)(\\d{3})(\\d{4})","$1 $2 $3","108",,]]]',
"86": '["CN","(1[1279]\\d{3})?00","0","(1[1279]\\d{3})|0",,,"\\d{4,12}","[1-7]\\d{6,11}|8[0-357-9]\\d{6,9}|9\\d{9}",[["(80\\d{2})(\\d{4})","$1 $2","80[2678]","$NP$FG",],["([48]00)(\\d{3})(\\d{4})","$1 $2 $3","[48]00",,],["(\\d{5,6})","$1","100|95",,"NA"],["(\\d{2})(\\d{5,6})","$1 $2","(?:10|2\\d)[19]","$NP$FG",],["(\\d{3})(\\d{5,6})","$1 $2","[3-9]","$NP$FG",],["(\\d{3,4})(\\d{4})","$1 $2","[2-9]",,"NA"],["(21)(\\d{4})(\\d{4,6})","$1 $2 $3","21","$NP$FG",],["([12]\\d)(\\d{4})(\\d{4})","$1 $2 $3","10[1-9]|2[02-9]","$NP$FG",],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3","3(?:11|7[179])|4(?:[15]1|3[12])|5(?:1|2[37]|3[12]|51|7[13-79]|9[15])|7(?:31|5[457]|6[09]|91)|8(?:71|98)","$NP$FG",],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3","3(?:1[02-9]|35|49|5|7[02-68]|9[1-68])|4(?:1[02-9]|2[179]|[35][2-9]|6[4789]|7\\d|8[23])|5(?:3[03-9]|4[36]|5[02-9]|6[1-46]|7[028]|80|9[2-46-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[04-9]|4[3-6]|6[2368])|8(?:1[236-8]|2[5-7]|3|5[1-9]|7[02-9]|8[3678]|9[1-7])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])","$NP$FG",],["(1[3-58]\\d)(\\d{4})(\\d{4})","$1 $2 $3","1[3-58]",,],["(10800)(\\d{3})(\\d{4})","$1 $2 $3","108",,]]]',
"257": '["BI","00",,,,,"\\d{8}","[27]\\d{7}",[["([27]\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",,,]]]',
"683": '["NU","00",,,,,"\\d{4}","[1-5]\\d{3}",]',
"43": '["AT","00","0",,,"$NP$FG","\\d{3,13}","[1-9]\\d{3,12}",[["(1)(\\d{3,12})","$1 $2","1",,],["(5\\d)(\\d{3,5})","$1 $2","5[079]",,],["(5\\d)(\\d{3})(\\d{3,4})","$1 $2 $3","5[079]",,],["(5\\d)(\\d{4})(\\d{4,7})","$1 $2 $3","5[079]",,],["(\\d{3})(\\d{3,10})","$1 $2","316|46|51|732|6(?:44|5[0-3579]|[6-9])|7(?:1|[28]0)|[89]",,],["(\\d{4})(\\d{3,9})","$1 $2","2|3(?:1[1-578]|[3-8])|4[2378]|5[2-6]|6(?:[12]|4[1-35-9]|5[468])|7(?:2[1-8]|35|4[1-8]|[5-79])",,]]]',
@ -84,7 +84,7 @@ this.PHONE_NUMBER_META_DATA = {
"236": '["CF","00",,,,,"\\d{8}","[278]\\d{7}",[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",,,]]]',
"590": ['["GP","00","0",,,"$NP$FG","\\d{9}","[56]\\d{8}",[["([56]90)(\\d{2})(\\d{4})","$1 $2-$3",,,]]]','["BL","00","0",,,,"\\d{9}","[56]\\d{8}",]','["MF","00","0",,,,"\\d{9}","[56]\\d{8}",]'],
"53": '["CU","119","0",,,"($NP$FG)","\\d{4,8}","[2-57]\\d{5,7}",[["(\\d)(\\d{6,7})","$1 $2","7",,],["(\\d{2})(\\d{4,6})","$1 $2","[2-4]",,],["(\\d)(\\d{7})","$1 $2","5","$NP$FG",]]]',
"64": '["NZ","0(?:0|161)","0",,,"$NP$FG","\\d{7,11}","6[235-9]\\d{6}|[2-57-9]\\d{7,10}",[["([34679])(\\d{3})(\\d{4})","$1-$2 $3","[3467]|9[1-9]",,],["(24099)(\\d{3})","$1 $2","240",,],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3","21",,],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3","2(?:1[1-9]|[69]|7[0-35-9])|86",,],["(2\\d)(\\d{3,4})(\\d{4})","$1 $2 $3","2[028]",,],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3","2(?:10|74)|5|[89]0",,]]]',
"64": '["NZ","0(?:0|161)","0",,,"$NP$FG","\\d{7,11}","6[235-9]\\d{6}|[2-57-9]\\d{7,10}",[["([34679])(\\d{3})(\\d{4})","$1-$2 $3","[3467]|9[1-9]",,],["(24099)(\\d{3})","$1 $2","240",,],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3","21",,],["(\\d{2})(\\d{3})(\\d{3,5})","$1 $2 $3","2(?:1[1-9]|[69]|7[0-35-9])|86",,],["(2\\d)(\\d{3,4})(\\d{4})","$1 $2 $3","2[028]",,],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3","2(?:10|74)|5|[89]0",,]]]',
"965": '["KW","00",,,,,"\\d{7,8}","[12569]\\d{6,7}",[["(\\d{4})(\\d{3,4})","$1 $2","[1269]",,],["(5[015]\\d)(\\d{5})","$1 $2","5",,]]]',
"224": '["GN","00",,,,,"\\d{8,9}","[367]\\d{7,8}",[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4","3",,],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4","[67]",,]]]',
"973": '["BH","00",,,,,"\\d{8}","[136-9]\\d{7}",[["(\\d{4})(\\d{4})","$1 $2",,,]]]',
@ -95,7 +95,7 @@ this.PHONE_NUMBER_META_DATA = {
"968": '["OM","00",,,,,"\\d{7,9}","(?:2[2-6]|5|9[1-9])\\d{6}|800\\d{5,6}",[["(2\\d)(\\d{6})","$1 $2","2",,],["(9\\d{3})(\\d{4})","$1 $2","9",,],["([58]00)(\\d{4,6})","$1 $2","[58]",,]]]',
"599": ['["CW","00",,,,,"\\d{7,8}","[169]\\d{6,7}",[["(\\d{3})(\\d{4})","$1 $2","[13-7]",,],["(9)(\\d{3})(\\d{4})","$1 $2 $3","9",,]]]','["BQ","00",,,,,"\\d{7}","[347]\\d{6}",]'],
"800": '["001",,,,,,"\\d{8}","\\d{8}",[["(\\d{4})(\\d{4})","$1 $2",,,]]]',
"386": '["SI","00","0",,,"$NP$FG","\\d{5,8}","[1-7]\\d{6,7}|[89]\\d{4,7}",[["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4","[12]|3[4-8]|4[24-8]|5[2-8]|7[3-8]","($NP$FG)",],["([3-7]\\d)(\\d{3})(\\d{3})","$1 $2 $3","[37][01]|4[019]|51|6",,],["([89][09])(\\d{3,6})","$1 $2","[89][09]",,],["([58]\\d{2})(\\d{5})","$1 $2","59|8[1-3]",,]]]',
"386": '["SI","00","0",,,"$NP$FG","\\d{5,8}","[1-7]\\d{6,7}|[89]\\d{4,7}",[["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4","[12]|3[4-8]|4[24-8]|5[2-8]|7[3-8]","($NP$FG)",],["([3-7]\\d)(\\d{3})(\\d{3})","$1 $2 $3","[37][01]|4[0139]|51|6",,],["([89][09])(\\d{3,6})","$1 $2","[89][09]",,],["([58]\\d{2})(\\d{5})","$1 $2","59|8[1-3]",,]]]',
"679": '["FJ","0(?:0|52)",,,,,"\\d{7}(?:\\d{4})?","[36-9]\\d{6}|0\\d{10}",[["(\\d{3})(\\d{4})","$1 $2","[36-9]",,],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3","0",,]]]',
"238": '["CV","0",,,,,"\\d{7}","[259]\\d{6}",[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",,,]]]',
"691": '["FM","00",,,,,"\\d{7}","[39]\\d{6}",[["(\\d{3})(\\d{4})","$1 $2",,,]]]',
@ -148,7 +148,7 @@ this.PHONE_NUMBER_META_DATA = {
"971": '["AE","00","0",,,"$NP$FG","\\d{5,12}","[2-79]\\d{7,8}|800\\d{2,9}",[["([2-4679])(\\d{3})(\\d{4})","$1 $2 $3","[2-4679][2-8]",,],["(5[0256])(\\d{3})(\\d{4})","$1 $2 $3","5",,],["([479]00)(\\d)(\\d{5})","$1 $2 $3","[479]0","$FG",],["([68]00)(\\d{2,9})","$1 $2","60|8","$FG",]]]',
"30": '["GR","00",,,,,"\\d{10}","[26-9]\\d{9}",[["([27]\\d)(\\d{4})(\\d{4})","$1 $2 $3","21|7",,],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3","2[2-9]1|[689]",,],["(2\\d{3})(\\d{6})","$1 $2","2[2-9][02-9]",,]]]',
"228": '["TG","00",,,,,"\\d{8}","[29]\\d{7}",[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",,,]]]',
"48": '["PL","00",,,,,"\\d{6,9}","[1-58]\\d{6,8}|9\\d{8}|[67]\\d{5,8}",[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4","[124]|3[2-4]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145]",,],["(\\d{2})(\\d{4,6})","$1 $2","[124]|3[2-4]|5[24-689]|6[1-3578]|7[14-7]|8[1-7]",,],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3","39|5[013]|6[0469]|7[02389]|8[08]",,],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3","64",,],["(\\d{3})(\\d{3})","$1 $2","64",,]]]',
"48": '["PL","00",,,,,"\\d{6,9}","[1-58]\\d{6,8}|9\\d{8}|[67]\\d{5,8}",[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4","[124]|3[2-4]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145]",,],["(\\d{2})(\\d{4,6})","$1 $2","[124]|3[2-4]|5[24-689]|6[1-3578]|7[14-7]|8[1-7]",,],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3","39|5[0137]|6[0469]|7[02389]|8[08]",,],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3","64",,],["(\\d{3})(\\d{3})","$1 $2","64",,]]]',
"886": '["TW","0(?:0[25679]|19)","0",,,"$NP$FG","\\d{8,9}","[2-9]\\d{7,8}",[["([2-8])(\\d{3,4})(\\d{4})","$1 $2 $3","[2-7]|8[1-9]",,],["([89]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3","80|9",,]]]',
"212": ['["MA","00","0",,,"$NP$FG","\\d{9}","[5689]\\d{8}",[["([56]\\d{2})(\\d{6})","$1-$2","5(?:2[015-7]|3[0-4])|6",,],["([58]\\d{3})(\\d{5})","$1-$2","5(?:2[2-489]|3[5-9])|892",,],["(5\\d{4})(\\d{4})","$1-$2","5(?:29|38)",,],["(8[09])(\\d{7})","$1-$2","8(?:0|9[013-9])",,]]]','["EH","00","0",,,"$NP$FG","\\d{9}","[5689]\\d{8}",]'],
"372": '["EE","00",,,,,"\\d{4,10}","1\\d{3,4}|[3-9]\\d{6,7}|800\\d{6,7}",[["([3-79]\\d{2})(\\d{4})","$1 $2","[369]|4[3-8]|5(?:[0-2]|5[0-478]|6[45])|7[1-9]",,],["(70)(\\d{2})(\\d{4})","$1 $2 $3","70",,],["(8000)(\\d{3})(\\d{3})","$1 $2 $3","800",,],["([458]\\d{3})(\\d{3,4})","$1 $2","40|5|8(?:00|[1-5])",,]]]',
@ -156,14 +156,14 @@ this.PHONE_NUMBER_META_DATA = {
"502": '["GT","00",,,,,"\\d{8}(?:\\d{3})?","[2-7]\\d{7}|1[89]\\d{9}",[["(\\d{4})(\\d{4})","$1 $2","[2-7]",,],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3","1",,]]]',
"82": '["KR","00(?:[124-68]|[37]\\d{2})","0","0(8[1-46-8]|85\\d{2})?",,"$NP$FG","\\d{4,10}","[1-7]\\d{3,9}|8\\d{8}",[["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3","1(?:0|1[19]|[69]9|5[458])|[57]0",,],["(\\d{2})(\\d{3,4})(\\d{4})","$1-$2-$3","1(?:[169][2-8]|[78]|5[1-4])|[68]0|[3-6][1-9][1-9]",,],["(\\d{3})(\\d)(\\d{4})","$1-$2-$3","131",,],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3","131",,],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3","13[2-9]",,],["(\\d{2})(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3-$4","30",,],["(\\d)(\\d{3,4})(\\d{4})","$1-$2-$3","2[1-9]",,],["(\\d)(\\d{3,4})","$1-$2","21[0-46-9]",,],["(\\d{2})(\\d{3,4})","$1-$2","[3-6][1-9]1",,],["(\\d{4})(\\d{4})","$1-$2","1(?:5[46-9]|6[04678])","$FG",]]]',
"253": '["DJ","00",,,,,"\\d{8}","[27]\\d{7}",[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",,,]]]',
"91": '["IN","00","0",,,"$NP$FG","\\d{6,13}","1\\d{7,12}|[2-9]\\d{9,10}",[["(\\d{2})(\\d{2})(\\d{6})","$1 $2 $3","7(?:2[0579]|3[057-9]|4[0-389]|6[0-35-9]|[57]|8[0-79])|8(?:0[015689]|1[0-57-9]|2[2356-9]|3[0-57-9]|[45]|6[02457-9]|7[1-69]|8[0124-9]|9[02-9])|9",,],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3","11|2[02]|33|4[04]|79|80[2-46]",,],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3","1(?:2[0-249]|3[0-25]|4[145]|[569][14]|7[1257]|8[1346]|[68][1-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[126-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:[136][25]|22|4[28]|5[12]|[78]1|9[15])|6(?:12|[2345]1|57|6[13]|7[14]|80)",,],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3","7(?:12|2[14]|3[134]|4[47]|5[15]|[67]1|88)",,],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3","8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)",,],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3","1(?:[2-579]|[68][1-9])|[2-8]",,],["(1600)(\\d{2})(\\d{4})","$1 $2 $3","160","$FG",],["(1800)(\\d{4,5})","$1 $2","180","$FG",],["(18[06]0)(\\d{2,4})(\\d{4})","$1 $2 $3","18[06]","$FG",],["(\\d{4})(\\d{3})(\\d{4})(\\d{2})","$1 $2 $3 $4","18[06]","$FG",]]]',
"91": '["IN","00","0",,,"$NP$FG","\\d{6,13}","1\\d{7,12}|[2-9]\\d{9,10}",[["(\\d{2})(\\d{2})(\\d{6})","$1 $2 $3","7(?:2[0579]|3[057-9]|4[0-389]|6[0-35-9]|[57]|8[0-79])|8(?:0[015689]|1[0-57-9]|2[2356-9]|3[0-57-9]|[45]|6[02457-9]|7[1-69]|8[0124-9]|9[02-9])|9",,],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3","11|2[02]|33|4[04]|79|80[2-46]",,],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3","1(?:2[0-249]|3[0-25]|4[145]|[569][14]|7[1257]|8[1346]|[68][1-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[126-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:[136][25]|22|4[28]|5[12]|[78]1|9[15])|6(?:12|[2345]1|57|6[13]|7[14]|80)",,],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3","7(?:12|2[14]|3[134]|4[47]|5[15]|[67]1|88)",,],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3","8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)",,],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3","1(?:[23579]|[468][1-9])|[2-8]",,],["(1600)(\\d{2})(\\d{4})","$1 $2 $3","160","$FG",],["(1800)(\\d{4,5})","$1 $2","180","$FG",],["(18[06]0)(\\d{2,4})(\\d{4})","$1 $2 $3","18[06]","$FG",],["(140)(\\d{3})(\\d{4})","$1 $2 $3","140","$FG",],["(\\d{4})(\\d{3})(\\d{4})(\\d{2})","$1 $2 $3 $4","18[06]","$FG",]]]',
"389": '["MK","00","0",,,"$NP$FG","\\d{8}","[2-578]\\d{7}",[["(2)(\\d{3})(\\d{4})","$1 $2 $3","2",,],["([347]\\d)(\\d{3})(\\d{3})","$1 $2 $3","[347]",,],["([58]\\d{2})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4","[58]",,]]]',
"1": ['["US","011","1",,,,"\\d{7}(?:\\d{3})?","[2-9]\\d{9}",[["(\\d{3})(\\d{4})","$1-$2",,,"NA"],["(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",,,"$1-$2-$3"]]]','["AI","011","1",,,,"\\d{7}(?:\\d{3})?","[2589]\\d{9}",]','["AS","011","1",,,,"\\d{7}(?:\\d{3})?","[5689]\\d{9}",]','["BB","011","1",,,,"\\d{7}(?:\\d{3})?","[2589]\\d{9}",]','["BM","011","1",,,,"\\d{7}(?:\\d{3})?","[4589]\\d{9}",]','["BS","011","1",,,,"\\d{7}(?:\\d{3})?","[2589]\\d{9}",]','["CA","011","1",,,,"\\d{7}(?:\\d{3})?","[2-9]\\d{9}|3\\d{6}",]','["DM","011","1",,,,"\\d{7}(?:\\d{3})?","[57-9]\\d{9}",]','["DO","011","1",,,,"\\d{7}(?:\\d{3})?","[589]\\d{9}",]','["GD","011","1",,,,"\\d{7}(?:\\d{3})?","[4589]\\d{9}",]','["GU","011","1",,,,"\\d{7}(?:\\d{3})?","[5689]\\d{9}",]','["JM","011","1",,,,"\\d{7}(?:\\d{3})?","[589]\\d{9}",]','["KN","011","1",,,,"\\d{7}(?:\\d{3})?","[589]\\d{9}",]','["KY","011","1",,,,"\\d{7}(?:\\d{3})?","[3589]\\d{9}",]','["LC","011","1",,,,"\\d{7}(?:\\d{3})?","[5789]\\d{9}",]','["MP","011","1",,,,"\\d{7}(?:\\d{3})?","[5689]\\d{9}",]','["MS","011","1",,,,"\\d{7}(?:\\d{3})?","[5689]\\d{9}",]','["PR","011","1",,,,"\\d{7}(?:\\d{3})?","[5789]\\d{9}",]','["SX","011","1",,,,"\\d{7}(?:\\d{3})?","[5789]\\d{9}",]','["TC","011","1",,,,"\\d{7}(?:\\d{3})?","[5689]\\d{9}",]','["TT","011","1",,,,"\\d{7}(?:\\d{3})?","[589]\\d{9}",]','["AG","011","1",,,,"\\d{7}(?:\\d{3})?","[2589]\\d{9}",]','["VC","011","1",,,,"\\d{7}(?:\\d{3})?","[5789]\\d{9}",]','["VG","011","1",,,,"\\d{7}(?:\\d{3})?","[2589]\\d{9}",]','["VI","011","1",,,,"\\d{7}(?:\\d{3})?","[3589]\\d{9}",]'],
"60": '["MY","00","0",,,,"\\d{6,10}","[13-9]\\d{7,9}",[["([4-79])(\\d{3})(\\d{4})","$1-$2 $3","[4-79]","$NP$FG",],["(3)(\\d{4})(\\d{4})","$1-$2 $3","3","$NP$FG",],["([18]\\d)(\\d{3})(\\d{3,4})","$1-$2 $3","1[02-46-9][1-9]|8","$NP$FG",],["(1)([36-8]00)(\\d{2})(\\d{4})","$1-$2-$3-$4","1[36-8]0",,],["(11)(\\d{4})(\\d{4})","$1-$2 $3","11","$NP$FG",],["(15[49])(\\d{3})(\\d{4})","$1-$2 $3","15","$NP$FG",]]]',
"355": '["AL","00","0",,,"$NP$FG","\\d{5,9}","[2-57]\\d{7}|6\\d{8}|8\\d{5,7}|9\\d{5}",[["(4)(\\d{3})(\\d{4})","$1 $2 $3","4[0-6]",,],["(6[6-9])(\\d{3})(\\d{4})","$1 $2 $3","6",,],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3","[2358][2-5]|4[7-9]",,],["(\\d{3})(\\d{3,5})","$1 $2","[235][16-9]|8[016-9]|[79]",,]]]',
"254": '["KE","000","0",,,"$NP$FG","\\d{5,10}","20\\d{6,7}|[4-9]\\d{6,9}",[["(\\d{2})(\\d{4,7})","$1 $2","[24-6]",,],["(\\d{3})(\\d{6,7})","$1 $2","7",,],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3","[89]",,]]]',
"223": '["ML","00",,,,,"\\d{8}","[246-9]\\d{7}",[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4","[246-9]",,],["(\\d{4})","$1","67|74",,"NA"]]]',
"686": '["KI","00",,"0",,,"\\d{5,8}","[2-689]\\d{4}|7\\d{7}",]',
"686": '["KI","00",,"0",,,"\\d{5,8}","[2-58]\\d{4}|7\\d{7}",]',
"994": '["AZ","00","0",,,"($NP$FG)","\\d{7,9}","[1-9]\\d{8}",[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4","(?:1[28]|2(?:[45]2|[0-36])|365)",,],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4","[4-8]","$NP$FG",],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4","9","$NP$FG",]]]',
"979": '["001",,,,,,"\\d{9}","\\d{9}",[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",,,]]]',
"66": '["TH","00","0",,,"$NP$FG","\\d{4}|\\d{8,10}","[2-9]\\d{7,8}|1\\d{3}(?:\\d{6})?",[["(2)(\\d{3})(\\d{4})","$1 $2 $3","2",,],["([3-9]\\d)(\\d{3})(\\d{3,4})","$1 $2 $3","[3-9]",,],["(1[89]00)(\\d{3})(\\d{3})","$1 $2 $3","1","$FG",]]]',
@ -174,7 +174,7 @@ this.PHONE_NUMBER_META_DATA = {
"57": '["CO","00(?:4(?:[14]4|56)|[579])","0","0([3579]|4(?:44|56))?",,,"\\d{7,11}","(?:[13]\\d{0,3}|[24-8])\\d{7}",[["(\\d)(\\d{7})","$1 $2","1(?:8[2-9]|9[0-3]|[2-7])|[24-8]","($FG)",],["(\\d{3})(\\d{7})","$1 $2","3",,],["(1)(\\d{3})(\\d{7})","$1-$2-$3","1(?:80|9[04])","$NP$FG","$1 $2 $3"]]]',
"597": '["SR","00",,,,,"\\d{6,7}","[2-8]\\d{5,6}",[["(\\d{3})(\\d{3})","$1-$2","[2-4]|5[2-58]",,],["(\\d{2})(\\d{2})(\\d{2})","$1-$2-$3","56",,],["(\\d{3})(\\d{4})","$1-$2","[6-8]",,]]]',
"676": '["TO","00",,,,,"\\d{5,7}","[02-8]\\d{4,6}",[["(\\d{2})(\\d{3})","$1-$2","[1-6]|7[0-4]|8[05]",,],["(\\d{3})(\\d{4})","$1 $2","7[5-9]|8[7-9]",,],["(\\d{4})(\\d{3})","$1 $2","0",,]]]',
"505": '["NI","00",,,,,"\\d{8}","[1258]\\d{7}",[["(\\d{4})(\\d{4})","$1 $2",,,]]]',
"505": '["NI","00",,,,,"\\d{8}","[12578]\\d{7}",[["(\\d{4})(\\d{4})","$1 $2",,,]]]',
"850": '["KP","00|99","0",,,"$NP$FG","\\d{6,8}|\\d{10}","1\\d{9}|[28]\\d{7}",[["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3","1",,],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3","2",,],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3","8",,]]]',
"7": ['["RU","810","8",,,"$NP ($FG)","\\d{10}","[3489]\\d{9}",[["(\\d{3})(\\d{2})(\\d{2})","$1-$2-$3","[1-79]","$FG","NA"],["([3489]\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4","[34689]",,],["(7\\d{2})(\\d{3})(\\d{4})","$1 $2 $3","7",,]]]','["KZ","810","8",,,,"\\d{10}","(?:33\\d|7\\d{2}|80[09])\\d{7}",]'],
"268": '["SZ","00",,,,,"\\d{8}","[027]\\d{7}",[["(\\d{4})(\\d{4})","$1 $2","[027]",,]]]',
@ -195,9 +195,9 @@ this.PHONE_NUMBER_META_DATA = {
"232": '["SL","00","0",,,"($NP$FG)","\\d{6,8}","[2-578]\\d{7}",[["(\\d{2})(\\d{6})","$1 $2",,,]]]',
"594": '["GF","00","0",,,"$NP$FG","\\d{9}","[56]\\d{8}",[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",,,]]]',
"976": '["MN","001","0",,,"$NP$FG","\\d{6,10}","[12]\\d{7,9}|[57-9]\\d{7}",[["([12]\\d)(\\d{2})(\\d{4})","$1 $2 $3","[12]1",,],["([12]2\\d)(\\d{5,6})","$1 $2","[12]2[1-3]",,],["([12]\\d{3})(\\d{5})","$1 $2","[12](?:27|[3-5])",,],["(\\d{4})(\\d{4})","$1 $2","[57-9]","$FG",],["([12]\\d{4})(\\d{4,5})","$1 $2","[12](?:27|[3-5])",,]]]',
"20": '["EG","00","0",,,"$NP$FG","\\d{5,10}","1\\d{4,9}|[2456]\\d{8}|3\\d{7}|[89]\\d{8,9}",[["(\\d)(\\d{7,8})","$1 $2","[23]",,],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3","1[012]|[89]00",,],["(\\d{2})(\\d{6,7})","$1 $2","1(?:3|5[23])|[4-6]|[89][2-9]",,]]]',
"20": '["EG","00","0",,,"$NP$FG","\\d{5,10}","1\\d{4,9}|[2456]\\d{8}|3\\d{7}|[89]\\d{8,9}",[["(\\d)(\\d{7,8})","$1 $2","[23]",,],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3","1[012]|[89]00",,],["(\\d{2})(\\d{6,7})","$1 $2","1[35]|[4-6]|[89][2-9]",,]]]',
"689": '["PF","00",,,,,"\\d{6}(?:\\d{2})?","[2-79]\\d{5}|8\\d{5,7}",[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4","89",,],["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",,,]]]',
"56": '["CL","(?:0|1(?:1[0-69]|2[0-57]|5[13-58]|69|7[0167]|8[018]))0","0","0|(1(?:1[0-69]|2[0-57]|5[13-58]|69|7[0167]|8[018]))",,"$NP$FG","\\d{6,11}","(?:[2-9]|600|123)\\d{7,8}",[["(2)(\\d{3,4})(\\d{4})","$1 $2 $3","2","($FG)",],["(\\d{2})(\\d{2,3})(\\d{4})","$1 $2 $3","[357]|4[1-35]|6[13-57]","($FG)",],["(9)([5-9]\\d{3})(\\d{4})","$1 $2 $3","9",,],["(44)(\\d{3})(\\d{4})","$1 $2 $3","44",,],["([68]00)(\\d{3})(\\d{3,4})","$1 $2 $3","60|8","$FG",],["(600)(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4","60","$FG",],["(1230)(\\d{3})(\\d{4})","$1 $2 $3","1","$FG",],["(\\d{4,5})","$1","[1-9]","$FG","NA"]]]',
"56": '["CL","(?:0|1(?:1[0-69]|2[0-57]|5[13-58]|69|7[0167]|8[018]))0","0","0|(1(?:1[0-69]|2[0-57]|5[13-58]|69|7[0167]|8[018]))",,"$NP$FG","\\d{6,11}","(?:[2-9]|600|123)\\d{7,8}",[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3","2","($FG)",],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3","[357]|4[1-35]|6[13-57]","($FG)",],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3","65","($FG)",],["(9)([5-9]\\d{3})(\\d{4})","$1 $2 $3","9",,],["(44)(\\d{3})(\\d{4})","$1 $2 $3","44",,],["([68]00)(\\d{3})(\\d{3,4})","$1 $2 $3","60|8","$FG",],["(600)(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4","60","$FG",],["(1230)(\\d{3})(\\d{4})","$1 $2 $3","1","$FG",],["(\\d{4,5})","$1","[1-9]","$FG","NA"]]]',
"596": '["MQ","00","0",,,"$NP$FG","\\d{9}","[56]\\d{8}",[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",,,]]]',
"508": '["PM","00","0",,,"$NP$FG","\\d{6}","[45]\\d{5}",[["([45]\\d)(\\d{2})(\\d{2})","$1 $2 $3",,,]]]',
"269": '["KM","00",,,,,"\\d{7}","[379]\\d{6}",[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",,,]]]',
@ -215,7 +215,7 @@ this.PHONE_NUMBER_META_DATA = {
"378": '["SM","00",,"(?:0549)?([89]\\d{5})","0549$1",,"\\d{6,10}","[05-7]\\d{7,9}",[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4","[5-7]",,],["(0549)(\\d{6})","$1 $2","0",,"($1) $2"],["(\\d{6})","0549 $1","[89]",,"(0549) $1"]]]',
"235": '["TD","00|16",,,,,"\\d{8}","[2679]\\d{7}",[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",,,]]]',
"960": '["MV","0(?:0|19)",,,,,"\\d{7,10}","[3467]\\d{6}|9(?:00\\d{7}|\\d{6})",[["(\\d{3})(\\d{4})","$1-$2","[3467]|9(?:[1-9]|0[1-9])",,],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3","900",,]]]',
"221": '["SN","00",,,,,"\\d{9}","[37]\\d{8}",[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",,,]]]',
"221": '["SN","00",,,,,"\\d{9}","[378]\\d{8}",[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4","[37]",,],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4","8",,]]]',
"595": '["PY","00","0",,,,"\\d{5,9}","5[0-5]\\d{4,7}|[2-46-9]\\d{5,8}",[["(\\d{2})(\\d{5,7})","$1 $2","(?:[26]1|3[289]|4[124678]|7[123]|8[1236])","($FG)",],["(\\d{3})(\\d{3,6})","$1 $2","[2-9]0","$NP$FG",],["(\\d{3})(\\d{6})","$1 $2","9[1-9]","$NP$FG",],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3","8700",,],["(\\d{3})(\\d{4,6})","$1 $2","[2-8][1-9]","($FG)",]]]',
"977": '["NP","00","0",,,"$NP$FG","\\d{6,10}","[1-8]\\d{7}|9(?:[1-69]\\d{6}|7[2-6]\\d{5,7}|8\\d{8})",[["(1)(\\d{7})","$1-$2","1[2-6]",,],["(\\d{2})(\\d{6})","$1-$2","1[01]|[2-8]|9(?:[1-69]|7[15-9])",,],["(9\\d{2})(\\d{7})","$1-$2","9(?:7[45]|8)",,]]]',
"36": '["HU","00","06",,,"($FG)","\\d{6,9}","[1-9]\\d{7,8}",[["(1)(\\d{3})(\\d{4})","$1 $2 $3","1",,],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3","[2-9]",,]]]',

View File

@ -86,7 +86,8 @@ class nsGeolocationRequest
~nsGeolocationRequest();
virtual bool Recv__delete__(const bool& allow) MOZ_OVERRIDE;
virtual bool Recv__delete__(const bool& allow,
const InfallibleTArray<PermissionChoice>& choices) MOZ_OVERRIDE;
virtual void IPDLRelease() MOZ_OVERRIDE { Release(); }
bool IsWatch() { return mIsWatchPositionRequest; }
@ -195,7 +196,7 @@ public:
NS_IMETHOD Run() {
if (mAllow) {
mRequest->Allow();
mRequest->Allow(JS::UndefinedHandleValue);
} else {
mRequest->Cancel();
}
@ -381,8 +382,10 @@ nsGeolocationRequest::GetPrincipal(nsIPrincipal * *aRequestingPrincipal)
NS_IMETHODIMP
nsGeolocationRequest::GetTypes(nsIArray** aTypes)
{
nsTArray<nsString> emptyOptions;
return CreatePermissionArray(NS_LITERAL_CSTRING("geolocation"),
NS_LITERAL_CSTRING("unused"),
emptyOptions,
aTypes);
}
@ -413,8 +416,10 @@ nsGeolocationRequest::Cancel()
}
NS_IMETHODIMP
nsGeolocationRequest::Allow()
nsGeolocationRequest::Allow(JS::HandleValue aChoices)
{
MOZ_ASSERT(aChoices.isUndefined());
// Kick off the geo device, if it isn't already running
nsRefPtr<nsGeolocationService> gs = nsGeolocationService::GetGeolocationService();
nsresult rv = gs->StartDevice(GetPrincipal());
@ -600,10 +605,13 @@ nsGeolocationRequest::Shutdown()
}
}
bool nsGeolocationRequest::Recv__delete__(const bool& allow)
bool nsGeolocationRequest::Recv__delete__(const bool& allow,
const InfallibleTArray<PermissionChoice>& choices)
{
MOZ_ASSERT(choices.IsEmpty(), "Geolocation doesn't support permission choice");
if (allow) {
(void) Allow();
(void) Allow(JS::UndefinedHandleValue);
} else {
(void) Cancel();
}
@ -1361,7 +1369,7 @@ Geolocation::WatchPositionReady(nsGeolocationRequest* aRequest)
return NS_ERROR_FAILURE;
}
aRequest->Allow();
aRequest->Allow(JS::UndefinedHandleValue);
return NS_OK;
}
@ -1472,8 +1480,10 @@ Geolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request)
}
nsTArray<PermissionRequest> permArray;
nsTArray<nsString> emptyOptions;
permArray.AppendElement(PermissionRequest(NS_LITERAL_CSTRING("geolocation"),
NS_LITERAL_CSTRING("unused")));
NS_LITERAL_CSTRING("unused"),
emptyOptions));
// Retain a reference so the object isn't deleted without IPDL's knowledge.
// Corresponding release occurs in DeallocPContentPermissionRequest.

View File

@ -49,10 +49,12 @@ public:
{
}
virtual bool Recv__delete__(const bool& aAllow) MOZ_OVERRIDE
virtual bool Recv__delete__(const bool& aAllow,
const InfallibleTArray<PermissionChoice>& choices) MOZ_OVERRIDE
{
MOZ_ASSERT(choices.IsEmpty(), "DesktopNotification doesn't support permission choice");
if (aAllow) {
(void) Allow();
(void) Allow(JS::UndefinedHandleValue);
} else {
(void) Cancel();
}
@ -179,9 +181,11 @@ DesktopNotification::Init()
nsRefPtr<DesktopNotificationRequest> copy = request;
nsTArray<PermissionRequest> permArray;
nsTArray<nsString> emptyOptions;
permArray.AppendElement(PermissionRequest(
NS_LITERAL_CSTRING("desktop-notification"),
NS_LITERAL_CSTRING("unused")));
NS_LITERAL_CSTRING("unused"),
emptyOptions));
child->SendPContentPermissionRequestConstructor(copy.forget().get(),
permArray,
IPC::Principal(mPrincipal));
@ -347,8 +351,9 @@ DesktopNotificationRequest::Cancel()
}
NS_IMETHODIMP
DesktopNotificationRequest::Allow()
DesktopNotificationRequest::Allow(JS::HandleValue aChoices)
{
MOZ_ASSERT(aChoices.isUndefined());
nsresult rv = mDesktopNotification->SetAllow(true);
mDesktopNotification = nullptr;
return rv;
@ -357,8 +362,10 @@ DesktopNotificationRequest::Allow()
NS_IMETHODIMP
DesktopNotificationRequest::GetTypes(nsIArray** aTypes)
{
nsTArray<nsString> emptyOptions;
return CreatePermissionArray(NS_LITERAL_CSTRING("desktop-notification"),
NS_LITERAL_CSTRING("unused"),
emptyOptions,
aTypes);
}

View File

@ -163,7 +163,8 @@ public:
virtual ~NotificationPermissionRequest() {}
bool Recv__delete__(const bool& aAllow);
bool Recv__delete__(const bool& aAllow,
const InfallibleTArray<PermissionChoice>& choices);
void IPDLRelease() { Release(); }
protected:
@ -269,9 +270,11 @@ NotificationPermissionRequest::Run()
AddRef();
nsTArray<PermissionRequest> permArray;
nsTArray<nsString> emptyOptions;
permArray.AppendElement(PermissionRequest(
NS_LITERAL_CSTRING("desktop-notification"),
NS_LITERAL_CSTRING("unused")));
NS_LITERAL_CSTRING("unused"),
emptyOptions));
child->SendPContentPermissionRequestConstructor(this, permArray,
IPC::Principal(mPrincipal));
@ -318,8 +321,10 @@ NotificationPermissionRequest::Cancel()
}
NS_IMETHODIMP
NotificationPermissionRequest::Allow()
NotificationPermissionRequest::Allow(JS::HandleValue aChoices)
{
MOZ_ASSERT(aChoices.isUndefined());
mPermission = NotificationPermission::Granted;
return DispatchCallback();
}
@ -347,16 +352,21 @@ NotificationPermissionRequest::CallCallback()
NS_IMETHODIMP
NotificationPermissionRequest::GetTypes(nsIArray** aTypes)
{
nsTArray<nsString> emptyOptions;
return CreatePermissionArray(NS_LITERAL_CSTRING("desktop-notification"),
NS_LITERAL_CSTRING("unused"),
emptyOptions,
aTypes);
}
bool
NotificationPermissionRequest::Recv__delete__(const bool& aAllow)
NotificationPermissionRequest::Recv__delete__(const bool& aAllow,
const InfallibleTArray<PermissionChoice>& choices)
{
MOZ_ASSERT(choices.IsEmpty(), "Notification doesn't support permission choice");
if (aAllow) {
(void) Allow();
(void) Allow(JS::UndefinedHandleValue);
} else {
(void) Cancel();
}

View File

@ -8,11 +8,12 @@
#ifdef MOZ_WIDGET_GONK
#include "mozilla/layers/AtomicRefCountedWithFinalize.h"
#include "mozilla/layers/LayersSurfaces.h"
#include "mozilla/gfx/Point.h"
#include "ImageLayers.h"
#include "ImageContainer.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/layers/AtomicRefCountedWithFinalize.h"
#include "mozilla/layers/FenceUtils.h"
#include "mozilla/layers/LayersSurfaces.h"
#include <ui/GraphicBuffer.h>
@ -46,6 +47,16 @@ public:
return mSurfaceDescriptor;
}
void SetReleaseFenceHandle(const FenceHandle& aReleaseFenceHandle)
{
mReleaseFenceHandle = aReleaseFenceHandle;
}
const FenceHandle& GetReleaseFenceHandle() const
{
return mReleaseFenceHandle;
}
protected:
virtual void Unlock() {}
@ -65,6 +76,7 @@ private:
protected:
SurfaceDescriptor mSurfaceDescriptor;
FenceHandle mReleaseFenceHandle;
};
/**

View File

@ -38,6 +38,7 @@ class GraphicBuffer;
namespace mozilla {
namespace layers {
class TextureHost;
typedef uint32_t TextureFlags;
@ -88,18 +89,20 @@ enum LayerRenderStateFlags {
struct LayerRenderState {
LayerRenderState()
#ifdef MOZ_WIDGET_GONK
: mSurface(nullptr), mFlags(0), mHasOwnOffset(false)
: mSurface(nullptr), mFlags(0), mHasOwnOffset(false), mTexture(nullptr)
#endif
{}
#ifdef MOZ_WIDGET_GONK
LayerRenderState(android::GraphicBuffer* aSurface,
const nsIntSize& aSize,
uint32_t aFlags)
uint32_t aFlags,
TextureHost* aTexture)
: mSurface(aSurface)
, mSize(aSize)
, mFlags(aFlags)
, mHasOwnOffset(false)
, mTexture(aTexture)
{}
bool YFlipped() const
@ -123,6 +126,7 @@ struct LayerRenderState {
android::sp<android::GraphicBuffer> mSurface;
// size of mSurface
nsIntSize mSize;
TextureHost* mTexture;
#endif
// see LayerRenderStateFlags
uint32_t mFlags;

View File

@ -378,6 +378,20 @@ ClientLayerManager::ForwardTransaction(bool aScheduleComposite)
->SetDescriptorFromReply(ots.textureId(), ots.image());
break;
}
case EditReply::TReturnReleaseFence: {
const ReturnReleaseFence& rep = reply.get_ReturnReleaseFence();
FenceHandle fence = rep.fence();
PTextureChild* child = rep.textureChild();
if (!fence.IsValid() || !child) {
break;
}
RefPtr<TextureClient> texture = TextureClient::AsTextureClient(child);
if (texture) {
texture->SetReleaseFenceHandle(fence);
}
break;
}
default:
NS_RUNTIMEABORT("not reached");

View File

@ -20,7 +20,6 @@
#include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder
#include "mozilla/layers/SharedPlanarYCbCrImage.h"
#include "mozilla/layers/YCbCrImageDataSerializer.h"
#include "mozilla/layers/PTextureChild.h"
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING, etc
#include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc
#include "ImageContainer.h" // for PlanarYCbCrImage, etc
@ -159,6 +158,13 @@ TextureClient::DestroyIPDLActor(PTextureChild* actor)
return true;
}
// static
TextureClient*
TextureClient::AsTextureClient(PTextureChild* actor)
{
return actor? static_cast<TextureChild*>(actor)->mTextureClient : nullptr;
}
bool
TextureClient::InitIPDLActor(CompositableForwarder* aForwarder)
{

View File

@ -17,10 +17,12 @@
#include "mozilla/gfx/2D.h" // for DrawTarget
#include "mozilla/gfx/Point.h" // for IntSize
#include "mozilla/gfx/Types.h" // for SurfaceFormat
#include "mozilla/layers/FenceUtils.h" // for FenceHandle
#include "mozilla/ipc/Shmem.h" // for Shmem
#include "mozilla/layers/AtomicRefCountedWithFinalize.h"
#include "mozilla/layers/CompositorTypes.h" // for TextureFlags, etc
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
#include "mozilla/layers/PTextureChild.h" // for PTextureChild
#include "mozilla/mozalloc.h" // for operator delete
#include "nsAutoPtr.h" // for nsRefPtr
#include "nsCOMPtr.h" // for already_AddRefed
@ -230,6 +232,11 @@ public:
static PTextureChild* CreateIPDLActor();
static bool DestroyIPDLActor(PTextureChild* actor);
/**
* Get the TextureClient corresponding to the actor passed in parameter.
*/
static TextureClient* AsTextureClient(PTextureChild* actor);
virtual bool IsAllocated() const = 0;
virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor) = 0;
@ -287,6 +294,13 @@ public:
*/
void ForceRemove();
virtual void SetReleaseFenceHandle(FenceHandle aReleaseFenceHandle) {}
const FenceHandle& GetReleaseFenceHandle() const
{
return mReleaseFenceHandle;
}
private:
/**
* Called once, just before the destructor.
@ -325,6 +339,7 @@ protected:
TextureFlags mFlags;
bool mShared;
bool mValid;
FenceHandle mReleaseFenceHandle;
friend class TextureChild;
};

View File

@ -36,6 +36,9 @@ CompositableHost::CompositableHost(const TextureInfo& aTextureInfo)
CompositableHost::~CompositableHost()
{
MOZ_COUNT_DTOR(CompositableHost);
if (mBackendData) {
mBackendData->ClearData();
}
}
void
@ -62,6 +65,8 @@ CompositableHost::UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
void
CompositableHost::RemoveTextureHost(TextureHost* aTexture)
{
// Clear strong refrence to CompositableBackendSpecificData
aTexture->SetCompositableBackendSpecificData(nullptr);
}
void

View File

@ -19,6 +19,7 @@
#include "mozilla/layers/CompositorTypes.h" // for TextureInfo, etc
#include "mozilla/layers/LayersTypes.h" // for LayerRenderState, etc
#include "mozilla/layers/PCompositableParent.h"
#include "mozilla/layers/TextureHost.h" // for TextureHost
#include "mozilla/mozalloc.h" // for operator delete
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsRegion.h" // for nsIntRegion
@ -46,7 +47,6 @@ struct TiledLayerProperties
class Layer;
class DeprecatedTextureHost;
class TextureHost;
class SurfaceDescriptor;
class Compositor;
class ISurfaceAllocator;
@ -70,7 +70,45 @@ public:
MOZ_COUNT_DTOR(CompositableBackendSpecificData);
}
virtual void SetCompositor(Compositor* aCompositor) {}
virtual void ClearData() {}
virtual void ClearData()
{
mCurrentReleaseFenceTexture = nullptr;
ClearPendingReleaseFenceTextureList();
}
/**
* Store a texture currently used for Composition.
* This function is called when the texutre might receive ReleaseFence
* as a result of Composition.
*/
void SetCurrentReleaseFenceTexture(TextureHost* aTexture)
{
if (mCurrentReleaseFenceTexture) {
mPendingReleaseFenceTextures.push_back(mCurrentReleaseFenceTexture);
}
mCurrentReleaseFenceTexture = aTexture;
}
virtual std::vector< RefPtr<TextureHost> >& GetPendingReleaseFenceTextureList()
{
return mPendingReleaseFenceTextures;
}
virtual void ClearPendingReleaseFenceTextureList()
{
return mPendingReleaseFenceTextures.clear();
}
protected:
/**
* Store a TextureHost currently used for Composition
* and it might receive ReleaseFence for the texutre.
*/
RefPtr<TextureHost> mCurrentReleaseFenceTexture;
/**
* Store TextureHosts that might have ReleaseFence to be delivered
* to TextureClient by CompositableHost.
*/
std::vector< RefPtr<TextureHost> > mPendingReleaseFenceTextures;
};
/**

View File

@ -97,6 +97,12 @@ TextureHost::AsTextureHost(PTextureParent* actor)
return actor? static_cast<TextureParent*>(actor)->mTextureHost : nullptr;
}
PTextureParent*
TextureHost::GetIPDLActor()
{
return mActor;
}
// implemented in TextureOGL.cpp
TemporaryRef<DeprecatedTextureHost> CreateDeprecatedTextureHostOGL(SurfaceDescriptorType aDescriptorType,
uint32_t aDeprecatedTextureHostFlags,
@ -250,7 +256,8 @@ TextureHost::SetCompositableBackendSpecificData(CompositableBackendSpecificData*
TextureHost::TextureHost(TextureFlags aFlags)
: mFlags(aFlags)
: mActor(nullptr)
, mFlags(aFlags)
{}
TextureHost::~TextureHost()
@ -731,6 +738,7 @@ TextureParent::Init(const SurfaceDescriptor& aSharedData,
mTextureHost = TextureHost::Create(aSharedData,
mAllocator,
aFlags);
mTextureHost->mActor = this;
return !!mTextureHost;
}
@ -768,6 +776,8 @@ TextureParent::ActorDestroy(ActorDestroyReason why)
if (mTextureHost->GetFlags() & TEXTURE_DEALLOCATE_CLIENT) {
mTextureHost->ForgetSharedData();
}
mTextureHost->mActor = nullptr;
mTextureHost = nullptr;
}

View File

@ -43,6 +43,7 @@ class CompositableHost;
class CompositableBackendSpecificData;
class SurfaceDescriptor;
class ISurfaceAllocator;
class TextureHostOGL;
class TextureSourceOGL;
class TextureSourceD3D9;
class TextureSourceD3D11;
@ -273,7 +274,6 @@ class TextureHost
void Finalize();
friend class AtomicRefCountedWithFinalize<TextureHost>;
public:
TextureHost(TextureFlags aFlags);
@ -395,6 +395,14 @@ public:
*/
static TextureHost* AsTextureHost(PTextureParent* actor);
/**
* Return a pointer to the IPDLActor.
*
* This is to be used with IPDL messages only. Do not store the returned
* pointer.
*/
PTextureParent* GetIPDLActor();
/**
* Specific to B2G's Composer2D
* XXX - more doc here
@ -418,9 +426,17 @@ public:
virtual const char *Name() { return "TextureHost"; }
virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
/**
* Cast to a TextureHost for each backend.
*/
virtual TextureHostOGL* AsHostOGL() { return nullptr; }
protected:
PTextureParent* mActor;
TextureFlags mFlags;
RefPtr<CompositableBackendSpecificData> mCompositableBackendData;
friend class TextureParent;
};
/**

View File

@ -47,12 +47,19 @@ static float gFlingStoppedThreshold = 0.01f;
*/
static uint32_t gMaxVelocityQueueSize = 5;
/**
* Maximum velocity in pixels per millisecond. Velocity will be capped at this
* value if a faster fling occurs. Negative values indicate unlimited velocity.
*/
static float gMaxVelocity = -1.0f;
static void ReadAxisPrefs()
{
Preferences::AddFloatVarCache(&gMaxEventAcceleration, "apz.max_event_acceleration", gMaxEventAcceleration);
Preferences::AddFloatVarCache(&gFlingFriction, "apz.fling_friction", gFlingFriction);
Preferences::AddFloatVarCache(&gFlingStoppedThreshold, "apz.fling_stopped_threshold", gFlingStoppedThreshold);
Preferences::AddUintVarCache(&gMaxVelocityQueueSize, "apz.max_velocity_queue_size", gMaxVelocityQueueSize);
Preferences::AddFloatVarCache(&gMaxVelocity, "apz.max_velocity_pixels_per_ms", gMaxVelocity);
}
class ReadAxisPref MOZ_FINAL : public nsRunnable {
@ -90,6 +97,9 @@ Axis::Axis(AsyncPanZoomController* aAsyncPanZoomController)
void Axis::UpdateWithTouchAtDevicePoint(int32_t aPos, const TimeDuration& aTimeDelta) {
float newVelocity = mAxisLocked ? 0 : (mPos - aPos) / aTimeDelta.ToMilliseconds();
if (gMaxVelocity > 0.0f) {
newVelocity = std::min(newVelocity, gMaxVelocity);
}
mVelocity = newVelocity;
mPos = aPos;

View File

@ -8,6 +8,7 @@
#include "CompositableTransactionParent.h"
#include "CompositableHost.h" // for CompositableParent, etc
#include "CompositorParent.h" // for CompositorParent
#include "GLContext.h" // for GLContext
#include "Layers.h" // for Layer
#include "RenderTrace.h" // for RenderTraceInvalidateEnd, etc
#include "TiledLayerBuffer.h" // for TiledLayerComposer
@ -19,6 +20,7 @@
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
#include "mozilla/layers/LayersTypes.h" // for MOZ_LAYERS_LOG
#include "mozilla/layers/TextureHost.h" // for TextureHost
#include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL
#include "mozilla/layers/ThebesLayerComposite.h"
#include "mozilla/mozalloc.h" // for operator delete
#include "nsDebug.h" // for NS_WARNING, NS_ASSERTION
@ -159,6 +161,8 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
RenderTraceInvalidateEnd(layer, "FF00FF");
}
// return texure data to client if necessary
ReturnTextureDataIfNecessary(compositable, replyv, op.compositableParent());
break;
}
case CompositableOperation::TOpPaintTextureRegion: {
@ -190,6 +194,8 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
OpContentBufferSwap(compositableParent, nullptr, frontUpdatedRegion));
RenderTraceInvalidateEnd(thebes, "FF00FF");
// return texure data to client if necessary
ReturnTextureDataIfNecessary(compositable, replyv, op.compositableParent());
break;
}
case CompositableOperation::TOpPaintTextureIncremental: {
@ -239,6 +245,8 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
MOZ_ASSERT(tex.get());
compositable->RemoveTextureHost(tex);
// return texure data to client if necessary
ReturnTextureDataIfNecessary(compositable, replyv, op.compositableParent());
break;
}
case CompositableOperation::TOpUseTexture: {
@ -257,6 +265,8 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
compositable->GetLayer()->SetInvalidRectToVisibleRegion();
}
}
// return texure data to client if necessary
ReturnTextureDataIfNecessary(compositable, replyv, op.compositableParent());
break;
}
case CompositableOperation::TOpUseComponentAlphaTextures: {
@ -271,6 +281,8 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
if (IsAsync()) {
ScheduleComposition(op);
}
// return texure data to client if necessary
ReturnTextureDataIfNecessary(compositable, replyv, op.compositableParent());
break;
}
case CompositableOperation::TOpUpdateTexture: {
@ -281,7 +293,6 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
texture->Updated(op.region().type() == MaybeRegion::TnsIntRegion
? &op.region().get_nsIntRegion()
: nullptr); // no region means invalidate the entire surface
break;
}
@ -293,6 +304,54 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
return true;
}
#if MOZ_WIDGET_GONK && ANDROID_VERSION >= 18
void
CompositableParentManager::ReturnTextureDataIfNecessary(CompositableHost* aCompositable,
EditReplyVector& replyv,
PCompositableParent* aParent)
{
if (!aCompositable || !aCompositable->GetCompositableBackendSpecificData()) {
return;
}
const std::vector< RefPtr<TextureHost> > textureList =
aCompositable->GetCompositableBackendSpecificData()->GetPendingReleaseFenceTextureList();
// Return pending Texture data
for (size_t i = 0; i < textureList.size(); i++) {
TextureHostOGL* hostOGL = textureList[i]->AsHostOGL();
PTextureParent* actor = textureList[i]->GetIPDLActor();
if (!hostOGL || !actor) {
continue;
}
android::sp<android::Fence> fence = hostOGL->GetAndResetReleaseFence();
if (fence.get() && fence->isValid()) {
FenceHandle handle = FenceHandle(fence);
replyv.push_back(ReturnReleaseFence(aParent, nullptr, actor, nullptr, handle));
// Hold fence handle to prevent fence's file descriptor is closed before IPC happens.
mPrevFenceHandles.push_back(handle);
}
}
aCompositable->GetCompositableBackendSpecificData()->ClearPendingReleaseFenceTextureList();
}
#else
void
CompositableParentManager::ReturnTextureDataIfNecessary(CompositableHost* aCompositable,
EditReplyVector& replyv,
PCompositableParent* aParent)
{
if (!aCompositable || !aCompositable->GetCompositableBackendSpecificData()) {
return;
}
aCompositable->GetCompositableBackendSpecificData()->ClearPendingReleaseFenceTextureList();
}
#endif
void
CompositableParentManager::ClearPrevFenceHandles()
{
mPrevFenceHandles.clear();
}
} // namespace
} // namespace

View File

@ -16,6 +16,8 @@
namespace mozilla {
namespace layers {
class CompositableHost;
typedef std::vector<mozilla::layers::EditReply> EditReplyVector;
// Since PCompositble has two potential manager protocols, we can't just call
@ -37,6 +39,14 @@ protected:
* thread (ImageBridge for instance).
*/
virtual bool IsAsync() const { return false; }
void ReturnTextureDataIfNecessary(CompositableHost* aCompositable,
EditReplyVector& replyv,
PCompositableParent* aParent);
void ClearPrevFenceHandles();
protected:
std::vector<FenceHandle> mPrevFenceHandles;
};
} // namespace

View File

@ -0,0 +1,43 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 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 IPC_FencerUtils_h
#define IPC_FencerUtils_h
#include "ipc/IPCMessageUtils.h"
/**
* FenceHandle is used for delivering Fence object via ipc.
*/
#if MOZ_WIDGET_GONK && ANDROID_VERSION >= 18
# include "mozilla/layers/FenceUtilsGonk.h"
#else
namespace mozilla {
namespace layers {
struct FenceHandle {
bool operator==(const FenceHandle&) const { return false; }
bool IsValid() const { return false; }
};
} // namespace layers
} // namespace mozilla
#endif // MOZ_WIDGET_GONK && ANDROID_VERSION >= 18
namespace IPC {
#if MOZ_WIDGET_GONK && ANDROID_VERSION >= 18
#else
template <>
struct ParamTraits<mozilla::layers::FenceHandle> {
typedef mozilla::layers::FenceHandle paramType;
static void Write(Message*, const paramType&) {}
static bool Read(const Message*, void**, paramType*) { return false; }
};
#endif // MOZ_WIDGET_GONK && ANDROID_VERSION >= 18
} // namespace IPC
#endif // IPC_FencerUtils_h

View File

@ -0,0 +1,96 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 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/. */
#include "GLContext.h"
#include "mozilla/unused.h"
#include "nsXULAppAPI.h"
#include "FenceUtilsGonk.h"
using namespace android;
using namespace base;
using namespace mozilla::layers;
namespace IPC {
void
ParamTraits<FenceHandle>::Write(Message* aMsg,
const paramType& aParam)
{
Flattenable *flattenable = aParam.mFence.get();
size_t nbytes = flattenable->getFlattenedSize();
size_t nfds = flattenable->getFdCount();
char data[nbytes];
int fds[nfds];
flattenable->flatten(data, nbytes, fds, nfds);
aMsg->WriteSize(nbytes);
aMsg->WriteSize(nfds);
aMsg->WriteBytes(data, nbytes);
for (size_t n = 0; n < nfds; ++n) {
// These buffers can't die in transit because they're created
// synchonously and the parent-side buffer can only be dropped if
// there's a crash.
aMsg->WriteFileDescriptor(FileDescriptor(fds[n], false));
}
}
bool
ParamTraits<FenceHandle>::Read(const Message* aMsg,
void** aIter, paramType* aResult)
{
size_t nbytes;
size_t nfds;
const char* data;
if (!aMsg->ReadSize(aIter, &nbytes) ||
!aMsg->ReadSize(aIter, &nfds) ||
!aMsg->ReadBytes(aIter, &data, nbytes)) {
return false;
}
int fds[nfds];
for (size_t n = 0; n < nfds; ++n) {
FileDescriptor fd;
if (!aMsg->ReadFileDescriptor(aIter, &fd)) {
return false;
}
// If the GraphicBuffer was shared cross-process, SCM_RIGHTS does
// the right thing and dup's the fd. If it's shared cross-thread,
// SCM_RIGHTS doesn't dup the fd. That's surprising, but we just
// deal with it here. NB: only the "default" (master) process can
// alloc gralloc buffers.
bool sameProcess = (XRE_GetProcessType() == GeckoProcessType_Default);
int dupFd = sameProcess ? dup(fd.fd) : fd.fd;
fds[n] = dupFd;
}
sp<Fence> buffer(new Fence());
Flattenable *flattenable = buffer.get();
if (NO_ERROR == flattenable->unflatten(data, nbytes, fds, nfds)) {
aResult->mFence = buffer;
return true;
}
return false;
}
} // namespace IPC
namespace mozilla {
namespace layers {
FenceHandle::FenceHandle(const sp<Fence>& aFence)
: mFence(aFence)
{
}
} // namespace layers
} // namespace mozilla

View File

@ -0,0 +1,53 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 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_layers_FenceUtilsGonk_h
#define mozilla_layers_FenceUtilsGonk_h
#include <unistd.h>
#include <ui/Fence.h>
#include "ipc/IPCMessageUtils.h"
namespace mozilla {
namespace layers {
struct FenceHandle {
typedef android::Fence Fence;
FenceHandle()
{ }
FenceHandle(const android::sp<Fence>& aFence);
bool operator==(const FenceHandle& aOther) const {
return mFence.get() == aOther.mFence.get();
}
bool IsValid() const
{
return mFence.get() && mFence->isValid();
}
android::sp<Fence> mFence;
};
} // namespace layers
} // namespace mozilla
namespace IPC {
template <>
struct ParamTraits<mozilla::layers::FenceHandle> {
typedef mozilla::layers::FenceHandle paramType;
static void Write(Message* aMsg, const paramType& aParam);
static bool Read(const Message* aMsg, void** aIter, paramType* aResult);
};
} // namespace IPC
#endif // mozilla_layers_FenceUtilsGonk_h

View File

@ -516,6 +516,20 @@ ImageBridgeChild::EndTransaction()
->SetDescriptorFromReply(ots.textureId(), ots.image());
break;
}
case EditReply::TReturnReleaseFence: {
const ReturnReleaseFence& rep = reply.get_ReturnReleaseFence();
FenceHandle fence = rep.fence();
PTextureChild* child = rep.textureChild();
if (!fence.IsValid() || !child) {
break;
}
RefPtr<TextureClient> texture = TextureClient::AsTextureClient(child);
if (texture) {
texture->SetReleaseFenceHandle(fence);
}
break;
}
default:
NS_RUNTIMEABORT("not reached");
}

View File

@ -75,6 +75,9 @@ ImageBridgeParent::RecvUpdate(const EditArray& aEdits, EditReplyArray* aReply)
return true;
}
// Clear fence handles used in previsou transaction.
ClearPrevFenceHandles();
EditReplyVector replyv;
for (EditArray::index_type i = 0; i < aEdits.Length(); ++i) {
ReceiveCompositableUpdate(aEdits[i], replyv);

View File

@ -204,6 +204,9 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
return true;
}
// Clear fence handles used in previsou transaction.
ClearPrevFenceHandles();
EditReplyVector replyv;
{

View File

@ -39,6 +39,7 @@ using mozilla::layers::ScaleMode from "mozilla/layers/LayersTypes.h";
using mozilla::layers::EventRegions from "mozilla/layers/LayersTypes.h";
using mozilla::layers::DiagnosticTypes from "mozilla/layers/CompositorTypes.h";
using struct mozilla::layers::FrameMetrics from "FrameMetrics.h";
using struct mozilla::layers::FenceHandle from "mozilla/layers/FenceUtils.h";
namespace mozilla {
namespace layers {
@ -396,11 +397,19 @@ struct OpTextureSwap {
SurfaceDescriptor image;
};
struct ReturnReleaseFence {
PCompositable compositable;
PTexture texture;
FenceHandle fence;
};
// Unit of a "changeset reply". This is a weird abstraction, probably
// only to be used for buffer swapping.
union EditReply {
OpContentBufferSwap;
OpTextureSwap;
ReturnReleaseFence;
};
} // namespace

View File

@ -129,6 +129,7 @@ EXPORTS.mozilla.layers += [
'ipc/CompositableTransactionParent.h',
'ipc/CompositorChild.h',
'ipc/CompositorParent.h',
'ipc/FenceUtils.h',
'ipc/GeckoContentController.h',
'ipc/GestureEventListener.h',
'ipc/ImageBridgeChild.h',
@ -202,6 +203,14 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
'ipc/ShadowLayerUtilsGralloc.cpp',
]
if CONFIG['ANDROID_VERSION'] in ('18'):
EXPORTS.mozilla.layers += [
'ipc/FenceUtilsGonk.h',
]
SOURCES += [
'ipc/FenceUtilsGonk.cpp',
]
UNIFIED_SOURCES += [
'basic/BasicCanvasLayer.cpp',
'basic/BasicColorLayer.cpp',

View File

@ -196,6 +196,16 @@ GrallocTextureClientOGL::UpdateSurface(gfxASurface* aSurface)
return true;
}
void
GrallocTextureClientOGL::SetReleaseFenceHandle(FenceHandle aReleaseFenceHandle)
{
if (mBufferLocked) {
mBufferLocked->SetReleaseFenceHandle(aReleaseFenceHandle);
} else {
mReleaseFenceHandle = aReleaseFenceHandle;
}
}
bool
GrallocTextureClientOGL::Lock(OpenMode aMode)
{
@ -207,6 +217,15 @@ GrallocTextureClientOGL::Lock(OpenMode aMode)
if (mMappedBuffer) {
return true;
}
#if MOZ_WIDGET_GONK && ANDROID_VERSION >= 18
if (mReleaseFenceHandle.IsValid()) {
android::sp<Fence> fence = mReleaseFenceHandle.mFence;
fence->waitForever("GrallocTextureClientOGL::Lock");
mReleaseFenceHandle = FenceHandle();
}
#endif
uint32_t usage = 0;
if (aMode & OPEN_READ) {
usage |= GRALLOC_USAGE_SW_READ_OFTEN;

View File

@ -9,6 +9,7 @@
#include "mozilla/layers/TextureClient.h"
#include "ISurfaceAllocator.h" // For IsSurfaceDescriptorValid
#include "mozilla/layers/FenceUtils.h" // for FenceHandle
#include "mozilla/layers/ShadowLayerUtilsGralloc.h"
#include <ui/GraphicBuffer.h>
@ -59,6 +60,13 @@ public:
virtual TextureClientData* DropTextureData() MOZ_OVERRIDE;
virtual void SetReleaseFenceHandle(FenceHandle aReleaseFenceHandle) MOZ_OVERRIDE;
const FenceHandle& GetReleaseFenceHandle() const
{
return mReleaseFenceHandle;
}
void InitWith(GrallocBufferActor* aActor, gfx::IntSize aSize);
void SetTextureFlags(TextureFlags aFlags) { AddFlags(aFlags); }

View File

@ -332,7 +332,8 @@ GrallocTextureHostOGL::GetRenderState()
}
return LayerRenderState(mTextureSource->mGraphicBuffer.get(),
gfx::ThebesIntSize(mSize),
flags);
flags,
this);
}
return LayerRenderState();
@ -379,6 +380,11 @@ GrallocTextureHostOGL::SetCompositableBackendSpecificData(CompositableBackendSpe
if (mTextureSource) {
mTextureSource->SetCompositableBackendSpecificData(aBackendData);
}
// Register this object to CompositableBackendSpecificData
// as current TextureHost.
if (aBackendData) {
aBackendData->SetCurrentReleaseFenceTexture(this);
}
}
} // namepsace layers

View File

@ -71,6 +71,9 @@ protected:
};
class GrallocTextureHostOGL : public TextureHost
#if MOZ_WIDGET_GONK && ANDROID_VERSION >= 18
, public TextureHostOGL
#endif
{
friend class GrallocBufferActor;
public:
@ -104,6 +107,13 @@ public:
return mTextureSource;
}
#if MOZ_WIDGET_GONK && ANDROID_VERSION >= 18
virtual TextureHostOGL* AsHostOGL() MOZ_OVERRIDE
{
return this;
}
#endif
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE;
virtual void SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) MOZ_OVERRIDE;

View File

@ -176,6 +176,7 @@ void CompositableDataGonkOGL::SetCompositor(Compositor* aCompositor)
void CompositableDataGonkOGL::ClearData()
{
CompositableBackendSpecificData::ClearData();
DeleteTextureIfPresent();
}
@ -200,6 +201,41 @@ CompositableDataGonkOGL::DeleteTextureIfPresent()
}
}
#if MOZ_WIDGET_GONK && ANDROID_VERSION >= 18
bool
TextureHostOGL::SetReleaseFence(const android::sp<android::Fence>& aReleaseFence)
{
if (!aReleaseFence.get() || !aReleaseFence->isValid()) {
return false;
}
if (!mReleaseFence.get()) {
mReleaseFence = aReleaseFence;
} else {
android::sp<android::Fence> mergedFence = android::Fence::merge(
android::String8::format("TextureHostOGL"),
mReleaseFence, aReleaseFence);
if (!mergedFence.get()) {
// synchronization is broken, the best we can do is hope fences
// signal in order so the new fence will act like a union.
// This error handling is same as android::ConsumerBase does.
mReleaseFence = aReleaseFence;
return false;
}
mReleaseFence = mergedFence;
}
return true;
}
android::sp<android::Fence>
TextureHostOGL::GetAndResetReleaseFence()
{
android::sp<android::Fence> fence = mReleaseFence;
mReleaseFence = android::Fence::NO_FENCE;
return fence;
}
#endif
bool
TextureImageTextureSourceOGL::Update(gfx::DataSourceSurface* aSurface,
nsIntRegion* aDestRegion,
@ -1155,7 +1191,8 @@ GrallocDeprecatedTextureHostOGL::GetRenderState()
return LayerRenderState(mGraphicBuffer.get(),
bufferSize,
flags);
flags,
nullptr);
}
return LayerRenderState();

View File

@ -32,6 +32,9 @@
#include "OGLShaderProgram.h" // for ShaderProgramType, etc
#ifdef MOZ_WIDGET_GONK
#include <ui/GraphicBuffer.h>
#if ANDROID_VERSION >= 18
#include <ui/Fence.h>
#endif
#endif
class gfxImageSurface;
@ -117,6 +120,29 @@ public:
virtual TextureImageDeprecatedTextureHostOGL* AsTextureImageDeprecatedTextureHost() { return nullptr; }
};
/**
* TextureHostOGL provides the necessary API for platform specific composition.
*/
class TextureHostOGL
{
public:
#if MOZ_WIDGET_GONK && ANDROID_VERSION >= 18
/**
* Store a fence that will signal when the current buffer is no longer being read.
* Similar to android's GLConsumer::setReleaseFence()
*/
virtual bool SetReleaseFence(const android::sp<android::Fence>& aReleaseFence);
/**
* Return a releaseFence's Fence and clear a reference to the Fence.
*/
virtual android::sp<android::Fence> GetAndResetReleaseFence();
protected:
android::sp<android::Fence> mReleaseFence;
#endif
};
/**
* A TextureSource backed by a TextureImage.
*

View File

@ -19,11 +19,13 @@
#include "libdisplay/GonkDisplay.h"
#include "Framebuffer.h"
#include "GLContext.h" // for GLContext
#include "HwcUtils.h"
#include "HwcComposer2D.h"
#include "mozilla/layers/LayerManagerComposite.h"
#include "mozilla/layers/PLayerTransaction.h"
#include "mozilla/layers/ShadowLayerUtilsGralloc.h"
#include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL
#include "mozilla/StaticPtr.h"
#include "cutils/properties.h"
#include "gfx2DGlue.h"
@ -67,7 +69,10 @@ HwcComposer2D::HwcComposer2D()
, mHwc(nullptr)
, mColorFill(false)
, mRBSwapSupport(false)
, mPrevRetireFence(-1)
#if ANDROID_VERSION >= 18
, mPrevRetireFence(Fence::NO_FENCE)
, mPrevDisplayFence(Fence::NO_FENCE)
#endif
, mPrepared(false)
{
}
@ -649,36 +654,29 @@ HwcComposer2D::Commit()
int err = mHwc->set(mHwc, HWC_NUM_DISPLAY_TYPES, displays);
// To avoid tearing, workaround for missing releaseFenceFd
// waits in Gecko layers, see Bug 925444.
if (!mPrevReleaseFds.IsEmpty()) {
// Wait for previous retire Fence to signal.
// Denotes contents on display have been replaced.
// For buffer-sync, framework should not over-write
// prev buffers until we close prev releaseFenceFds
sp<Fence> fence = new Fence(mPrevRetireFence);
if (fence->wait(1000) == -ETIME) {
LOGE("Wait timed-out for retireFenceFd %d", mPrevRetireFence);
}
for (int i = 0; i < mPrevReleaseFds.Length(); i++) {
close(mPrevReleaseFds[i]);
}
close(mPrevRetireFence);
mPrevReleaseFds.Clear();
}
mPrevDisplayFence = mPrevRetireFence;
mPrevRetireFence = Fence::NO_FENCE;
for (uint32_t j=0; j < (mList->numHwLayers - 1); j++) {
if (mList->hwLayers[j].releaseFenceFd >= 0) {
mPrevReleaseFds.AppendElement(mList->hwLayers[j].releaseFenceFd);
}
}
int fd = mList->hwLayers[j].releaseFenceFd;
mList->hwLayers[j].releaseFenceFd = -1;
sp<Fence> fence = new Fence(fd);
LayerRenderState state = mHwcLayerMap[j]->GetLayer()->GetRenderState();
if (!state.mTexture) {
continue;
}
TextureHostOGL* texture = state.mTexture->AsHostOGL();
if (!texture) {
continue;
}
texture->SetReleaseFence(fence);
}
}
if (mList->retireFenceFd >= 0) {
if (!mPrevReleaseFds.IsEmpty()) {
mPrevRetireFence = mList->retireFenceFd;
} else { // GPU Composition
close(mList->retireFenceFd);
}
mPrevRetireFence = new Fence(mList->retireFenceFd);
}
mPrepared = false;

View File

@ -23,6 +23,9 @@
#include <list>
#include <hardware/hwcomposer.h>
#if ANDROID_VERSION >= 18
#include <ui/Fence.h>
#endif
namespace mozilla {
@ -83,8 +86,10 @@ private:
//Holds all the dynamically allocated RectVectors needed
//to render the current frame
std::list<RectVector> mVisibleRegions;
nsTArray<int> mPrevReleaseFds;
int mPrevRetireFence;
#if ANDROID_VERSION >= 18
android::sp<android::Fence> mPrevRetireFence;
android::sp<android::Fence> mPrevDisplayFence;
#endif
nsTArray<layers::LayerComposite*> mHwcLayerMap;
bool mPrepared;
};

View File

@ -105,8 +105,7 @@ status_t GonkNativeWindow::setDefaultBufferFormat(uint32_t defaultFormat) {
}
already_AddRefed<GraphicBufferLocked>
GonkNativeWindow::getCurrentBuffer()
{
GonkNativeWindow::getCurrentBuffer() {
Mutex::Autolock _l(mMutex);
GonkBufferQueue::BufferItem item;
@ -123,17 +122,20 @@ GonkNativeWindow::getCurrentBuffer()
}
bool
GonkNativeWindow::returnBuffer(uint32_t aIndex, uint32_t aGeneration) {
BI_LOGD("GonkNativeWindow::returnBuffer: slot=%d (generation=%d)", aIndex, aGeneration);
GonkNativeWindow::returnBuffer(uint32_t index, uint32_t generation, const sp<Fence>& fence) {
BI_LOGD("GonkNativeWindow::returnBuffer: slot=%d (generation=%d)", index, generation);
Mutex::Autolock lock(mMutex);
if (aGeneration != mBufferQueue->getGeneration()) {
if (generation != mBufferQueue->getGeneration()) {
BI_LOGD("returnBuffer: buffer is from generation %d (current is %d)",
aGeneration, mBufferQueue->getGeneration());
generation, mBufferQueue->getGeneration());
return false;
}
status_t err = releaseBufferLocked(aIndex);
status_t err;
err = addReleaseFenceLocked(index, fence);
err = releaseBufferLocked(index);
if (err != NO_ERROR) {
return false;
}
@ -141,8 +143,7 @@ GonkNativeWindow::returnBuffer(uint32_t aIndex, uint32_t aGeneration) {
}
mozilla::layers::SurfaceDescriptor *
GonkNativeWindow::getSurfaceDescriptorFromBuffer(ANativeWindowBuffer* buffer)
{
GonkNativeWindow::getSurfaceDescriptorFromBuffer(ANativeWindowBuffer* buffer) {
Mutex::Autolock lock(mMutex);
return mBufferQueue->getSurfaceDescriptorFromBuffer(buffer);
}
@ -161,4 +162,22 @@ void GonkNativeWindow::onFrameAvailable() {
}
}
void CameraGraphicBuffer::Unlock() {
if (mLocked) {
android::sp<android::Fence> fence;
fence = mReleaseFenceHandle.IsValid() ? mReleaseFenceHandle.mFence : Fence::NO_FENCE;
// The window might have been destroyed. The buffer is no longer
// valid at that point.
sp<GonkNativeWindow> window = mNativeWindow.promote();
if (window.get() && window->returnBuffer(mIndex, mGeneration, fence)) {
mLocked = false;
} else {
// If the window doesn't exist any more, release the buffer
// directly.
ImageBridgeChild *ibc = ImageBridgeChild::GetSingleton();
ibc->DeallocSurfaceDescriptorGralloc(mSurfaceDescriptor);
}
}
}
} // namespace android

View File

@ -116,7 +116,7 @@ class GonkNativeWindow: public GonkConsumerBase
// Return the buffer to the queue and mark it as FREE. After that
// the buffer is useable again for the decoder.
bool returnBuffer(uint32_t index, uint32_t generation);
bool returnBuffer(uint32_t index, uint32_t generation, const sp<Fence>& fence);
SurfaceDescriptor* getSurfaceDescriptorFromBuffer(ANativeWindowBuffer* buffer);
@ -157,22 +157,7 @@ public:
protected:
// Unlock either returns the buffer to the native window or
// destroys the buffer if the window is already released.
virtual void Unlock() MOZ_OVERRIDE
{
if (mLocked) {
// The window might have been destroyed. The buffer is no longer
// valid at that point.
sp<GonkNativeWindow> window = mNativeWindow.promote();
if (window.get() && window->returnBuffer(mIndex, mGeneration)) {
mLocked = false;
} else {
// If the window doesn't exist any more, release the buffer
// directly.
ImageBridgeChild *ibc = ImageBridgeChild::GetSingleton();
ibc->DeallocSurfaceDescriptorGralloc(mSurfaceDescriptor);
}
}
}
virtual void Unlock() MOZ_OVERRIDE;
protected:
wp<GonkNativeWindow> mNativeWindow;