mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Merge last PGO-safe changeset from inbound to central
This commit is contained in:
commit
50ebfbbd4a
@ -137,8 +137,9 @@ __defineGetter__("gPrefService", function() {
|
||||
});
|
||||
|
||||
__defineGetter__("AddonManager", function() {
|
||||
Cu.import("resource://gre/modules/AddonManager.jsm");
|
||||
return this.AddonManager;
|
||||
let tmp = {};
|
||||
Cu.import("resource://gre/modules/AddonManager.jsm", tmp);
|
||||
return this.AddonManager = tmp.AddonManager;
|
||||
});
|
||||
__defineSetter__("AddonManager", function (val) {
|
||||
delete this.AddonManager;
|
||||
@ -1503,7 +1504,9 @@ function prepareForStartup() {
|
||||
}
|
||||
|
||||
function delayedStartup(isLoadingBlank, mustLoadSidebar) {
|
||||
Cu.import("resource:///modules/TelemetryTimestamps.jsm");
|
||||
let tmp = {};
|
||||
Cu.import("resource:///modules/TelemetryTimestamps.jsm", tmp);
|
||||
let TelemetryTimestamps = tmp.TelemetryTimestamps;
|
||||
TelemetryTimestamps.add("delayedStartupStarted");
|
||||
gDelayedStartupTimeoutId = null;
|
||||
|
||||
@ -1779,7 +1782,7 @@ function delayedStartup(isLoadingBlank, mustLoadSidebar) {
|
||||
return;
|
||||
let duration = new Date() - appMenuOpening;
|
||||
appMenuOpening = null;
|
||||
Services.telemetry.getHistogramById("FX_APP_MENU_OPEN_MS").add(duration);
|
||||
Services.telemetry.getHistogramById("FX_APP_MENU_OPEN_MS").add(duration);
|
||||
}, false);
|
||||
}
|
||||
|
||||
|
@ -341,6 +341,9 @@ function onLoadPageInfo()
|
||||
gStrings.notSet = gBundle.getString("notset");
|
||||
gStrings.mediaImg = gBundle.getString("mediaImg");
|
||||
gStrings.mediaBGImg = gBundle.getString("mediaBGImg");
|
||||
gStrings.mediaBorderImg = gBundle.getString("mediaBorderImg");
|
||||
gStrings.mediaListImg = gBundle.getString("mediaListImg");
|
||||
gStrings.mediaCursor = gBundle.getString("mediaCursor");
|
||||
gStrings.mediaObject = gBundle.getString("mediaObject");
|
||||
gStrings.mediaEmbed = gBundle.getString("mediaEmbed");
|
||||
gStrings.mediaLink = gBundle.getString("mediaLink");
|
||||
@ -663,13 +666,35 @@ function addImage(url, type, alt, elem, isBg)
|
||||
|
||||
function grabAll(elem)
|
||||
{
|
||||
// check for background images, any node may have multiple
|
||||
// check for images defined in CSS (e.g. background, borders), any node may have multiple
|
||||
var computedStyle = elem.ownerDocument.defaultView.getComputedStyle(elem, "");
|
||||
|
||||
if (computedStyle) {
|
||||
Array.forEach(computedStyle.getPropertyCSSValue("background-image"), function (url) {
|
||||
if (url.primitiveType == CSSPrimitiveValue.CSS_URI)
|
||||
addImage(url.getStringValue(), gStrings.mediaBGImg, gStrings.notSet, elem, true);
|
||||
});
|
||||
var addImgFunc = function (label, val) {
|
||||
if (val.primitiveType == CSSPrimitiveValue.CSS_URI) {
|
||||
addImage(val.getStringValue(), label, gStrings.notSet, elem, true);
|
||||
}
|
||||
else if (val.primitiveType == CSSPrimitiveValue.CSS_STRING) {
|
||||
// This is for -moz-image-rect.
|
||||
// TODO: Reimplement once bug 714757 is fixed
|
||||
var strVal = val.getStringValue();
|
||||
if (strVal.search(/^.*url\(\"?/) > -1) {
|
||||
url = strVal.replace(/^.*url\(\"?/,"").replace(/\"?\).*$/,"");
|
||||
addImage(url, label, gStrings.notSet, elem, true);
|
||||
}
|
||||
}
|
||||
else if (val.cssValueType == CSSValue.CSS_VALUE_LIST) {
|
||||
// recursively resolve multiple nested CSS value lists
|
||||
for (var i = 0; i < val.length; i++)
|
||||
addImgFunc(label, val.item(i));
|
||||
}
|
||||
};
|
||||
|
||||
addImgFunc(gStrings.mediaBGImg, computedStyle.getPropertyCSSValue("background-image"));
|
||||
addImgFunc(gStrings.mediaBorderImg, computedStyle.getPropertyCSSValue("-moz-border-image-source"));
|
||||
// TODO: support unprefixed "border-image" once bug 713643 is fixed.
|
||||
addImgFunc(gStrings.mediaListImg, computedStyle.getPropertyCSSValue("list-style-image"));
|
||||
addImgFunc(gStrings.mediaCursor, computedStyle.getPropertyCSSValue("cursor"));
|
||||
}
|
||||
|
||||
// one swi^H^H^Hif-else to rule them all
|
||||
|
@ -123,6 +123,7 @@ _BROWSER_FILES = \
|
||||
browser_bug441778.js \
|
||||
browser_popupNotification.js \
|
||||
browser_bug455852.js \
|
||||
browser_bug460146.js \
|
||||
browser_bug462673.js \
|
||||
browser_bug477014.js \
|
||||
browser_bug479408.js \
|
||||
|
51
browser/base/content/test/browser_bug460146.js
Normal file
51
browser/base/content/test/browser_bug460146.js
Normal file
@ -0,0 +1,51 @@
|
||||
/* Check proper image url retrieval from all kinds of elements/styles */
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
var doc = gBrowser.contentDocument;
|
||||
var pageInfo = BrowserPageInfo(doc, "mediaTab");
|
||||
|
||||
pageInfo.addEventListener("load", function () {
|
||||
pageInfo.removeEventListener("load", arguments.callee, true);
|
||||
pageInfo.onFinished.push(function () {
|
||||
executeSoon(function () {
|
||||
var imageTree = pageInfo.document.getElementById("imagetree");
|
||||
var imageRowsNum = imageTree.view.rowCount;
|
||||
|
||||
ok(imageTree, "Image tree is null (media tab is broken)");
|
||||
|
||||
ok(imageRowsNum == 7, "Number of images listed: " +
|
||||
imageRowsNum + ", should be 7");
|
||||
|
||||
pageInfo.close();
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
});
|
||||
});
|
||||
}, true);
|
||||
}, true);
|
||||
|
||||
content.location =
|
||||
"data:text/html," +
|
||||
"<html>" +
|
||||
" <head>" +
|
||||
" <title>Test for media tab</title>" +
|
||||
" <link rel='shortcut icon' href='file:///dummy_icon.ico'>" + // Icon
|
||||
" </head>" +
|
||||
" <body style='background-image:url(about:logo?a);'>" + // Background
|
||||
" <img src='file:///dummy_image.gif'>" + // Image
|
||||
" <ul>" +
|
||||
" <li style='list-style:url(about:logo?b);'>List Item 1</li>" + // Bullet
|
||||
" </ul> " +
|
||||
" <div style='-moz-border-image: url(about:logo?c) 20 20 20 20;'>test</div>" + // Border
|
||||
" <a href='' style='cursor: url(about:logo?d),default;'>test link</a>" + // Cursor
|
||||
" <object type='image/svg+xml' width=20 height=20 data='file:///dummy_object.svg'></object>" + // Object
|
||||
" </body>" +
|
||||
"</html>";
|
||||
}
|
@ -89,7 +89,7 @@ var gCookiesWindow = {
|
||||
this.filter();
|
||||
}
|
||||
|
||||
document.getElementById("removeAllCookies").disabled = this._view._rowCount == 0;
|
||||
this._updateRemoveAllButton();
|
||||
|
||||
this._saveState();
|
||||
},
|
||||
@ -119,7 +119,7 @@ var gCookiesWindow = {
|
||||
this._view._rowCount = 0;
|
||||
this._tree.treeBoxObject.rowCountChanged(0, -oldRowCount);
|
||||
this._view.selection.clearSelection();
|
||||
document.getElementById("removeAllCookies").disabled = true;
|
||||
this._updateRemoveAllButton();
|
||||
}
|
||||
else if (aData == "reload") {
|
||||
// first, clear any existing entries
|
||||
@ -210,10 +210,7 @@ var gCookiesWindow = {
|
||||
this._view._rowCount += rowCountImpact;
|
||||
this._tree.treeBoxObject.rowCountChanged(oldRowCount - 1, rowCountImpact);
|
||||
|
||||
if (this._view._rowCount > 0 && !this._view._filtered)
|
||||
document.getElementById("removeAllCookies").disabled = false;
|
||||
else
|
||||
document.getElementById("removeAllCookies").disabled = true;
|
||||
this._updateRemoveAllButton();
|
||||
},
|
||||
|
||||
_view: {
|
||||
@ -593,10 +590,21 @@ var gCookiesWindow = {
|
||||
removeCookie.parentNode.selectedPanel =
|
||||
selectedCookieCount == 1 ? removeCookie : removeCookies;
|
||||
|
||||
document.getElementById("removeAllCookies").disabled = this._view._filtered;
|
||||
removeCookie.disabled = removeCookies.disabled = !(seln.count > 0);
|
||||
},
|
||||
|
||||
performDeletion: function gCookiesWindow_performDeletion(deleteItems) {
|
||||
var psvc = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
var blockFutureCookies = false;
|
||||
if (psvc.prefHasUserValue("network.cookie.blockFutureCookies"))
|
||||
blockFutureCookies = psvc.getBoolPref("network.cookie.blockFutureCookies");
|
||||
for (var i = 0; i < deleteItems.length; ++i) {
|
||||
var item = deleteItems[i];
|
||||
this._cm.remove(item.host, item.name, item.path, blockFutureCookies);
|
||||
}
|
||||
},
|
||||
|
||||
deleteCookie: function () {
|
||||
# // Selection Notes
|
||||
# // - Selection always moves to *NEXT* adjacent item unless item
|
||||
@ -713,15 +721,7 @@ var gCookiesWindow = {
|
||||
}
|
||||
}
|
||||
|
||||
var psvc = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
var blockFutureCookies = false;
|
||||
if (psvc.prefHasUserValue("network.cookie.blockFutureCookies"))
|
||||
blockFutureCookies = psvc.getBoolPref("network.cookie.blockFutureCookies");
|
||||
for (i = 0; i < deleteItems.length; ++i) {
|
||||
var item = deleteItems[i];
|
||||
this._cm.remove(item.host, item.name, item.path, blockFutureCookies);
|
||||
}
|
||||
this.performDeletion(deleteItems);
|
||||
|
||||
if (nextSelected < 0)
|
||||
seln.clearSelection();
|
||||
@ -732,8 +732,22 @@ var gCookiesWindow = {
|
||||
},
|
||||
|
||||
deleteAllCookies: function () {
|
||||
this._cm.removeAll();
|
||||
this._tree.focus();
|
||||
if (this._view._filtered) {
|
||||
var rowCount = this._view.rowCount;
|
||||
var deleteItems = [];
|
||||
for (var index = 0; index < rowCount; index++) {
|
||||
deleteItems.push(this._view._getItemAtIndex(index));
|
||||
}
|
||||
this._view._removeItemAtIndex(0, rowCount);
|
||||
this._view._rowCount = 0;
|
||||
this._tree.treeBoxObject.rowCountChanged(0, -rowCount);
|
||||
this.performDeletion(deleteItems);
|
||||
}
|
||||
else {
|
||||
this._cm.removeAll();
|
||||
}
|
||||
this._updateRemoveAllButton();
|
||||
this.focusFilterBox();
|
||||
},
|
||||
|
||||
onCookieKeyPress: function (aEvent) {
|
||||
@ -833,6 +847,7 @@ var gCookiesWindow = {
|
||||
this._lastSelectedRanges = [];
|
||||
|
||||
document.getElementById("cookiesIntro").value = this._bundle.getString("cookiesAll");
|
||||
this._updateRemoveAllButton();
|
||||
},
|
||||
|
||||
_cookieMatchesFilter: function (aCookie) {
|
||||
@ -878,6 +893,10 @@ var gCookiesWindow = {
|
||||
}
|
||||
},
|
||||
|
||||
_updateRemoveAllButton: function gCookiesWindow__updateRemoveAllButton() {
|
||||
document.getElementById("removeAllCookies").disabled = this._view._rowCount == 0;
|
||||
},
|
||||
|
||||
filter: function () {
|
||||
var filter = document.getElementById("filter").value;
|
||||
if (filter == "") {
|
||||
@ -908,6 +927,7 @@ var gCookiesWindow = {
|
||||
view.selection.select(0);
|
||||
|
||||
document.getElementById("cookiesIntro").value = gCookiesWindow._bundle.getString("cookiesFiltered");
|
||||
this._updateRemoveAllButton();
|
||||
},
|
||||
|
||||
setFilter: function (aFilterString) {
|
||||
|
@ -46,6 +46,7 @@ include $(topsrcdir)/config/rules.mk
|
||||
_BROWSER_FILES = \
|
||||
browser_bug410900.js \
|
||||
browser_bug567487.js \
|
||||
browser_bug705422.js \
|
||||
privacypane_tests.js \
|
||||
browser_privacypane_1.js \
|
||||
browser_privacypane_2.js \
|
||||
|
140
browser/components/preferences/tests/browser_bug705422.js
Normal file
140
browser/components/preferences/tests/browser_bug705422.js
Normal file
@ -0,0 +1,140 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
const searchTerm = "example";
|
||||
const dummyTerm = "elpmaxe";
|
||||
|
||||
var cm = Components.classes["@mozilla.org/cookiemanager;1"]
|
||||
.getService(Components.interfaces.nsICookieManager);
|
||||
|
||||
// delete all cookies (might be left over from other tests)
|
||||
cm.removeAll();
|
||||
|
||||
// data for cookies
|
||||
var vals = [[searchTerm+".com", dummyTerm, dummyTerm], // match
|
||||
[searchTerm+".org", dummyTerm, dummyTerm], // match
|
||||
[dummyTerm+".com", searchTerm, dummyTerm], // match
|
||||
[dummyTerm+".edu", searchTerm+dummyTerm, dummyTerm],// match
|
||||
[dummyTerm+".net", dummyTerm, searchTerm], // match
|
||||
[dummyTerm+".org", dummyTerm, searchTerm+dummyTerm],// match
|
||||
[dummyTerm+".int", dummyTerm, dummyTerm]]; // no match
|
||||
|
||||
// matches must correspond to above data
|
||||
const matches = 6;
|
||||
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var cookieSvc = Components.classes["@mozilla.org/cookieService;1"]
|
||||
.getService(Components.interfaces.nsICookieService);
|
||||
var v;
|
||||
// inject cookies
|
||||
for (v in vals) {
|
||||
let [host, name, value] = vals[v];
|
||||
var cookieUri = ios.newURI("http://"+host, null, null);
|
||||
cookieSvc.setCookieString(cookieUri, null, name+"="+value+";", null);
|
||||
}
|
||||
|
||||
// open cookie manager
|
||||
var cmd = window.openDialog("chrome://browser/content/preferences/cookies.xul",
|
||||
"Browser:Cookies", "", {});
|
||||
|
||||
// when it has loaded, run actual tests
|
||||
cmd.addEventListener("load", function() {executeSoon(function() {runTest(cmd, searchTerm, vals.length, matches);});}, false);
|
||||
}
|
||||
|
||||
function isDisabled(win, expectation) {
|
||||
var disabled = win.document.getElementById("removeAllCookies").disabled;
|
||||
is(disabled, expectation, "Remove all cookies button has correct state: "+(expectation?"disabled":"enabled"));
|
||||
}
|
||||
|
||||
function runTest(win, searchTerm, cookies, matches) {
|
||||
var cm = Components.classes["@mozilla.org/cookiemanager;1"]
|
||||
.getService(Components.interfaces.nsICookieManager);
|
||||
|
||||
|
||||
// number of cookies should match injected cookies
|
||||
var cnt = 0,
|
||||
enumerator = cm.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
cnt++;
|
||||
enumerator.getNext();
|
||||
}
|
||||
is(cnt, cookies, "Number of cookies match injected cookies");
|
||||
|
||||
// "delete all cookies" should be enabled
|
||||
isDisabled(win, false);
|
||||
|
||||
// filter cookies and count matches
|
||||
win.gCookiesWindow.setFilter(searchTerm);
|
||||
is(win.gCookiesWindow._view.rowCount, matches, "Correct number of cookies shown after filter is applied");
|
||||
|
||||
// "delete all cookies" should be enabled
|
||||
isDisabled(win, false);
|
||||
|
||||
|
||||
// select first cookie and delete
|
||||
var tree = win.document.getElementById("cookiesList");
|
||||
var deleteButton = win.document.getElementById("removeCookie");
|
||||
var x = {}, y = {}, width = {}, height = {};
|
||||
tree.treeBoxObject.getCoordsForCellItem(0, tree.columns[0], "cell", x, y, width, height);
|
||||
EventUtils.synthesizeMouse(tree.body, x.value + width.value / 2, y.value + height.value / 2, {}, win);
|
||||
EventUtils.synthesizeMouseAtCenter(deleteButton, {}, win);
|
||||
|
||||
// count cookies should be matches-1
|
||||
is(win.gCookiesWindow._view.rowCount, matches-1, "Deleted selected cookie");
|
||||
|
||||
// select two adjacent cells and delete
|
||||
EventUtils.synthesizeMouse(tree.body, x.value + width.value / 2, y.value + height.value / 2, {}, win);
|
||||
deleteButton = win.document.getElementById("removeCookies");
|
||||
var eventObj = {};
|
||||
if (navigator.platform.indexOf("Mac") >= 0)
|
||||
eventObj.metaKey = true;
|
||||
else
|
||||
eventObj.ctrlKey = true;
|
||||
tree.treeBoxObject.getCoordsForCellItem(1, tree.columns[0], "cell", x, y, width, height);
|
||||
EventUtils.synthesizeMouse(tree.body, x.value + width.value / 2, y.value + height.value / 2, eventObj, win);
|
||||
EventUtils.synthesizeMouseAtCenter(deleteButton, {}, win);
|
||||
|
||||
// count cookies should be matches-3
|
||||
is(win.gCookiesWindow._view.rowCount, matches-3, "Deleted selected two adjacent cookies");
|
||||
|
||||
// "delete all cookies" should be enabled
|
||||
isDisabled(win, false);
|
||||
|
||||
// delete all cookies and count
|
||||
var deleteAllButton = win.document.getElementById("removeAllCookies");
|
||||
EventUtils.synthesizeMouseAtCenter(deleteAllButton, {}, win);
|
||||
is(win.gCookiesWindow._view.rowCount, 0, "Deleted all matching cookies");
|
||||
|
||||
// "delete all cookies" should be disabled
|
||||
isDisabled(win, true);
|
||||
|
||||
// clear filter and count should be cookies-matches
|
||||
win.gCookiesWindow.setFilter("");
|
||||
is(win.gCookiesWindow._view.rowCount, cookies-matches, "Unmatched cookies remain");
|
||||
|
||||
// "delete all cookies" should be enabled
|
||||
isDisabled(win, false);
|
||||
|
||||
// delete all cookies and count should be 0
|
||||
EventUtils.synthesizeMouseAtCenter(deleteAllButton, {}, win);
|
||||
is(win.gCookiesWindow._view.rowCount, 0, "Deleted all cookies");
|
||||
|
||||
// check that datastore is also at 0
|
||||
var cnt = 0,
|
||||
enumerator = cm.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
cnt++;
|
||||
enumerator.getNext();
|
||||
}
|
||||
is(cnt, 0, "Zero cookies remain");
|
||||
|
||||
// "delete all cookies" should be disabled
|
||||
isDisabled(win, true);
|
||||
|
||||
// clean up
|
||||
win.close();
|
||||
finish();
|
||||
}
|
@ -51,6 +51,9 @@ mediaImg=Image
|
||||
mediaVideo=Video
|
||||
mediaAudio=Audio
|
||||
mediaBGImg=Background
|
||||
mediaBorderImg=Border
|
||||
mediaListImg=Bullet
|
||||
mediaCursor=Cursor
|
||||
mediaObject=Object
|
||||
mediaEmbed=Embed
|
||||
mediaLink=Icon
|
||||
|
@ -11,7 +11,9 @@ function getSimpleMeasurementsFromTelemetryPing() {
|
||||
|
||||
function test() {
|
||||
// Test the module logic
|
||||
Cu.import("resource:///modules/TelemetryTimestamps.jsm");
|
||||
let tmp = {};
|
||||
Cu.import("resource:///modules/TelemetryTimestamps.jsm", tmp);
|
||||
let TelemetryTimestamps = tmp.TelemetryTimestamps;
|
||||
let now = Date.now();
|
||||
TelemetryTimestamps.add("foo");
|
||||
ok(TelemetryTimestamps.get().foo, "foo was added");
|
||||
|
@ -313,7 +313,7 @@ if test -n "$gonkdir" ; then
|
||||
STLPORT_CPPFLAGS="-I$gonkdir/ndk/sources/cxx-stl/stlport/stlport/"
|
||||
STLPORT_LIBS="-lstlport"
|
||||
|
||||
CPPFLAGS="-DANDROID -I$gonkdir/bionic/libc/include/ -I$gonkdir/bionic/libc/kernel/common -I$gonkdir/bionic/libc/arch-arm/include -I$gonkdir/bionic/libc/kernel/arch-arm -I$gonkdir/bionic/libm/include -I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/hardware/libhardware/include -I$gonkdir/hardware/libhardware_legacy/include -I$gonkdir/system/core/include -I$gonkdir/bionic -I$gonkdir/frameworks/base/include $STLPORT_CPPFLAGS $CPPFLAGS"
|
||||
CPPFLAGS="-DANDROID -I$gonkdir/bionic/libc/include/ -I$gonkdir/bionic/libc/kernel/common -I$gonkdir/bionic/libc/arch-arm/include -I$gonkdir/bionic/libc/kernel/arch-arm -I$gonkdir/bionic/libm/include -I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/hardware/libhardware/include -I$gonkdir/hardware/libhardware_legacy/include -I$gonkdir/system/core/include -I$gonkdir/bionic -I$gonkdir/frameworks/base/include $STLPORT_CPPFLAGS $CPPFLAGS -I$gonkdir/frameworks/base/services/sensorservice"
|
||||
CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
|
||||
CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions $CXXFLAGS"
|
||||
LIBS="$LIBS $STLPORT_LIBS"
|
||||
|
@ -4,8 +4,6 @@ conformance/glsl/misc/glsl-long-variable-names.html
|
||||
conformance/glsl/misc/shader-with-256-character-identifier.frag.html
|
||||
conformance/glsl/misc/shader-with-long-line.html
|
||||
conformance/more/conformance/quickCheckAPI-S_V.html
|
||||
conformance/more/functions/uniformfBadArgs.html
|
||||
conformance/more/functions/uniformiBadArgs.html
|
||||
conformance/glsl/misc/attrib-location-length-limits.html
|
||||
conformance/glsl/misc/uniform-location-length-limits.html
|
||||
conformance/programs/program-test.html
|
||||
conformance/programs/program-test.html
|
||||
|
@ -355,17 +355,18 @@ function start() {
|
||||
// we currently disable this test on version of Mac OSX older than 10.6,
|
||||
// due to various weird failures, including one making getRenderbufferParameter tests
|
||||
// on DEPTH_STENCIL fail
|
||||
var kDarwinVersion = 0;
|
||||
if (kIsMac) {
|
||||
// code borrowed from browser/modules/test/browser_taskbar_preview.js
|
||||
var is106orHigher = false;
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var version = Components.classes["@mozilla.org/system-info;1"]
|
||||
.getService(Components.interfaces.nsIPropertyBag2)
|
||||
.getProperty("version");
|
||||
kDarwinVersion = parseFloat(Components.classes["@mozilla.org/system-info;1"]
|
||||
.getService(Components.interfaces.nsIPropertyBag2)
|
||||
.getProperty("version"));
|
||||
// the next line is correct: Mac OS 10.6 corresponds to Darwin version 10 !
|
||||
// Mac OS 10.5 would be Darwin version 9. the |version| string we've got here
|
||||
// is the Darwin version.
|
||||
is106orHigher = (parseFloat(version) >= 10.0);
|
||||
is106orHigher = (kDarwinVersion >= 10.0);
|
||||
if (!is106orHigher) {
|
||||
dump("WebGL mochitest disabled on Mac OSX versions older than 10.6\n");
|
||||
SimpleTest.finish();
|
||||
@ -411,6 +412,16 @@ function start() {
|
||||
if (kIsWindows && !kIsWindowsVistaOrHigher)
|
||||
testsExpectedToFail.push('conformance/textures/texture-mips.html');
|
||||
|
||||
if (kIsMac && kDarwinVersion < 11.0) { // Darwin 11 == Mac OS 10.7
|
||||
testsExpectedToFail.push('conformance/more/functions/uniformfBadArgs.html');
|
||||
testsExpectedToFail.push('conformance/more/functions/uniformiBadArgs.html');
|
||||
}
|
||||
|
||||
if (kIsMac && kDarwinVersion >= 11.0) {
|
||||
testsExpectedToFail.push('conformance/textures/texture-mips.html');
|
||||
testsExpectedToFail.push('conformance/textures/texture-npot.html');
|
||||
}
|
||||
|
||||
var testsToIgnore = [];
|
||||
|
||||
var testsSuccessful = [];
|
||||
|
@ -5,5 +5,6 @@ load 422009-1.xhtml
|
||||
load 457776-1.html
|
||||
load 496308-1.html
|
||||
load 682637-1.html
|
||||
load eventctor-nulldictionary.html
|
||||
load recursive-onload.html
|
||||
load recursive-DOMNodeInserted.html
|
||||
|
4
content/events/crashtests/eventctor-nulldictionary.html
Normal file
4
content/events/crashtests/eventctor-nulldictionary.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<script>
|
||||
new MouseEvent("click", null);
|
||||
</script>
|
@ -27,9 +27,9 @@ var gFragmentParams = [
|
||||
{ fragment: "#t=5", start: 5, end: null },
|
||||
{ fragment: "#t=5.5", start: 5.5, end: null },
|
||||
{ fragment: "#t=5,", start: null, end: null },
|
||||
{ fragment: "#t=,5", start: 0, end: 5 },
|
||||
{ fragment: "#t=2.5,5.5", start: 2.5, end: 5.5, todo: "See Bug 682141" },
|
||||
{ fragment: "#t=1,2.5", start: 1, end: 2.5, todo: "See Bug 682141" },
|
||||
{ fragment: "#t=,5", start: 0, end: 5, todo: "See bugs 682141 and 720248" },
|
||||
{ fragment: "#t=2.5,5.5", start: 2.5, end: 5.5, todo: "See bugs 682141 and 720248" },
|
||||
{ fragment: "#t=1,2.5", start: 1, end: 2.5, todo: "See bugs 682141 and 720248" },
|
||||
{ fragment: "#t=,15", start: 0, end: null }
|
||||
];
|
||||
|
||||
|
@ -46,8 +46,8 @@
|
||||
// some property of another element, e.g. <animate>, <set>.
|
||||
|
||||
#define NS_ISMILANIMATIONELEMENT_IID \
|
||||
{ 0xaf92584b, 0x75b0, 0x4584, \
|
||||
{ 0x87, 0xd2, 0xa8, 0x3, 0x34, 0xf0, 0x5, 0xaf } }
|
||||
{ 0x29792cd9, 0x0f96, 0x4ba6, \
|
||||
{ 0xad, 0xea, 0x03, 0x0e, 0x0b, 0xfe, 0x1e, 0xb7 } }
|
||||
|
||||
class nsISMILAttr;
|
||||
class nsSMILAnimationFunction;
|
||||
@ -83,6 +83,11 @@ public:
|
||||
*/
|
||||
virtual mozilla::dom::Element& AsElement() = 0;
|
||||
|
||||
/*
|
||||
* Returns true if the element passes conditional processing
|
||||
*/
|
||||
virtual bool PassesConditionalProcessingTests() = 0;
|
||||
|
||||
/*
|
||||
* Returns the source attribute as an nsAttrValue. The global namespace will
|
||||
* be used.
|
||||
|
@ -687,10 +687,12 @@ nsSMILAnimationController::SampleAnimation(AnimationElementPtrKey* aKey,
|
||||
NS_ENSURE_TRUE(aData, PL_DHASH_NEXT);
|
||||
|
||||
nsISMILAnimationElement* animElem = aKey->GetKey();
|
||||
SampleAnimationParams* params = static_cast<SampleAnimationParams*>(aData);
|
||||
if (animElem->PassesConditionalProcessingTests()) {
|
||||
SampleAnimationParams* params = static_cast<SampleAnimationParams*>(aData);
|
||||
|
||||
SampleTimedElement(animElem, params->mActiveContainers);
|
||||
AddAnimationToCompositorTable(animElem, params->mCompositorTable);
|
||||
SampleTimedElement(animElem, params->mActiveContainers);
|
||||
AddAnimationToCompositorTable(animElem, params->mCompositorTable);
|
||||
}
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
@ -119,6 +119,14 @@ nsSVGAnimationElement::AsElement()
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool
|
||||
nsSVGAnimationElement::PassesConditionalProcessingTests()
|
||||
{
|
||||
nsCOMPtr<DOMSVGTests> tests(do_QueryInterface(
|
||||
static_cast<nsSVGElement*>(this)));
|
||||
return tests->PassesConditionalProcessingTests();
|
||||
}
|
||||
|
||||
const nsAttrValue*
|
||||
nsSVGAnimationElement::GetAnimAttr(nsIAtom* aName) const
|
||||
{
|
||||
|
@ -89,6 +89,7 @@ public:
|
||||
// nsISMILAnimationElement interface
|
||||
virtual const Element& AsElement() const;
|
||||
virtual Element& AsElement();
|
||||
virtual bool PassesConditionalProcessingTests();
|
||||
virtual const nsAttrValue* GetAnimAttr(nsIAtom* aName) const;
|
||||
virtual bool GetAnimAttr(nsIAtom* aAttName, nsAString& aResult) const;
|
||||
virtual bool HasAnimAttr(nsIAtom* aAttName) const;
|
||||
|
@ -2146,12 +2146,10 @@ CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj,
|
||||
|
||||
jsval fieldValue;
|
||||
NPVariant npv;
|
||||
NPBool hasProperty;
|
||||
|
||||
if (getPropertyResult) {
|
||||
// Plugin has already handed us the value we want here.
|
||||
npv = *getPropertyResult;
|
||||
hasProperty = true;
|
||||
}
|
||||
else {
|
||||
VOID_TO_NPVARIANT(npv);
|
||||
|
@ -394,7 +394,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
|
||||
}
|
||||
|
||||
const char *name = NULL;
|
||||
NPError nperr = npGetValue(NULL, NPPVpluginNameString, &name);
|
||||
npGetValue(NULL, NPPVpluginNameString, &name);
|
||||
if (name) {
|
||||
info.fName = PL_strdup(name);
|
||||
}
|
||||
@ -403,7 +403,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
|
||||
}
|
||||
|
||||
const char *description = NULL;
|
||||
nperr = npGetValue(NULL, NPPVpluginDescriptionString, &description);
|
||||
npGetValue(NULL, NPPVpluginDescriptionString, &description);
|
||||
if (description) {
|
||||
info.fDescription = PL_strdup(description);
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ WifiGeoPositionProvider.prototype = {
|
||||
|
||||
// This is a background load
|
||||
xhr.mozBackgroundRequest = true;
|
||||
xhr.open("GET", providerUrl, false);
|
||||
xhr.open("GET", providerUrl, true);
|
||||
xhr.channel.loadFlags = Ci.nsIChannel.LOAD_ANONYMOUS;
|
||||
xhr.addEventListener("error", function(req) {
|
||||
LOG("onerror: " + req);
|
||||
|
@ -102,7 +102,7 @@ using mozilla::MutexAutoLock;
|
||||
using mozilla::TimeDuration;
|
||||
using mozilla::TimeStamp;
|
||||
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForCode;
|
||||
using mozilla::xpconnect::memory::ReportJSRuntimeStats;
|
||||
using mozilla::xpconnect::memory::ReportJSRuntimeExplicitTreeStats;
|
||||
|
||||
USING_WORKERS_NAMESPACE
|
||||
|
||||
@ -243,7 +243,7 @@ public:
|
||||
|
||||
// Always report, even if we're disabled, so that we at least get an entry
|
||||
// in about::memory.
|
||||
ReportJSRuntimeStats(rtStats, mPathPrefix, aCallback, aClosure);
|
||||
ReportJSRuntimeExplicitTreeStats(rtStats, mPathPrefix, aCallback, aClosure);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -679,6 +679,42 @@ public class GeckoAppShell
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Keep these values consistent with |SensorType| in Hal.h
|
||||
*/
|
||||
private static final int SENSOR_ORIENTATION = 1;
|
||||
private static final int SENSOR_ACCELERATION = 2;
|
||||
private static final int SENSOR_PROXIMITY = 3;
|
||||
|
||||
private static Sensor gProximitySensor = null;
|
||||
|
||||
public static void enableSensor(int aSensortype) {
|
||||
SensorManager sm = (SensorManager)
|
||||
GeckoApp.surfaceView.getContext().
|
||||
getSystemService(Context.SENSOR_SERVICE);
|
||||
|
||||
switch(aSensortype) {
|
||||
case SENSOR_PROXIMITY:
|
||||
if(gProximitySensor == null)
|
||||
gProximitySensor = sm.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||
sm.registerListener(GeckoApp.surfaceView, gProximitySensor,
|
||||
SensorManager.SENSOR_DELAY_GAME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void disableSensor(int aSensortype) {
|
||||
SensorManager sm = (SensorManager)
|
||||
GeckoApp.surfaceView.getContext().
|
||||
getSystemService(Context.SENSOR_SERVICE);
|
||||
|
||||
switch(aSensortype) {
|
||||
case SENSOR_PROXIMITY:
|
||||
sm.unregisterListener(GeckoApp.surfaceView, gProximitySensor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void moveTaskToBack() {
|
||||
GeckoApp.mAppContext.moveTaskToBack(true);
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ public class GeckoEvent {
|
||||
public static final int VIEWPORT = 20;
|
||||
public static final int VISITED = 21;
|
||||
public static final int NETWORK_CHANGED = 22;
|
||||
public static final int PROXIMITY_EVENT = 23;
|
||||
|
||||
public static final int IME_COMPOSITION_END = 0;
|
||||
public static final int IME_COMPOSITION_BEGIN = 1;
|
||||
@ -111,6 +112,7 @@ public class GeckoEvent {
|
||||
public Rect mRect;
|
||||
public double mX, mY, mZ;
|
||||
public double mAlpha, mBeta, mGamma;
|
||||
public double mDistance;
|
||||
|
||||
public int mMetaState, mFlags;
|
||||
public int mKeyCode, mUnicodeChar;
|
||||
@ -223,19 +225,30 @@ public class GeckoEvent {
|
||||
}
|
||||
|
||||
public GeckoEvent(SensorEvent s) {
|
||||
|
||||
if (s.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
|
||||
int sensor_type = s.sensor.getType();
|
||||
|
||||
switch(sensor_type) {
|
||||
case Sensor.TYPE_ACCELEROMETER:
|
||||
mType = ACCELERATION_EVENT;
|
||||
mX = s.values[0];
|
||||
mY = s.values[1];
|
||||
mZ = s.values[2];
|
||||
}
|
||||
else {
|
||||
break;
|
||||
|
||||
case Sensor.TYPE_ORIENTATION:
|
||||
mType = ORIENTATION_EVENT;
|
||||
mAlpha = -s.values[0];
|
||||
mBeta = -s.values[1];
|
||||
mGamma = -s.values[2];
|
||||
Log.i("GeckoEvent", "SensorEvent type = " + s.sensor.getType() + " " + s.sensor.getName() + " " + mAlpha + " " + mBeta + " " + mGamma );
|
||||
break;
|
||||
|
||||
case Sensor.TYPE_PROXIMITY:
|
||||
mType = PROXIMITY_EVENT;
|
||||
mDistance = s.values[0];
|
||||
Log.i("GeckoEvent", "SensorEvent type = " + s.sensor.getType() +
|
||||
" " + s.sensor.getName() + " " + mDistance);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,9 +142,9 @@ PatternIsCompatible(const Pattern& aPattern)
|
||||
const RadialGradientPattern& pattern = static_cast<const RadialGradientPattern&>(aPattern);
|
||||
return pattern.mStops->GetBackendType() == BACKEND_CAIRO;
|
||||
}
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Never returns NULL. As such, you must always pass in Cairo-compatible
|
||||
|
@ -118,9 +118,9 @@ GfxFormatToCairoFormat(SurfaceFormat format)
|
||||
return CAIRO_FORMAT_RGB24;
|
||||
case FORMAT_A8:
|
||||
return CAIRO_FORMAT_A8;
|
||||
default:
|
||||
return CAIRO_FORMAT_ARGB32;
|
||||
}
|
||||
|
||||
return CAIRO_FORMAT_ARGB32;
|
||||
}
|
||||
|
||||
static inline cairo_content_t
|
||||
@ -134,9 +134,9 @@ GfxFormatToCairoContent(SurfaceFormat format)
|
||||
return CAIRO_CONTENT_COLOR;
|
||||
case FORMAT_A8:
|
||||
return CAIRO_CONTENT_ALPHA;
|
||||
default:
|
||||
return CAIRO_CONTENT_COLOR_ALPHA;
|
||||
}
|
||||
|
||||
return CAIRO_CONTENT_COLOR_ALPHA;
|
||||
}
|
||||
|
||||
static inline cairo_line_join_t
|
||||
|
@ -37,28 +37,13 @@
|
||||
|
||||
#include "SourceSurfaceCairo.h"
|
||||
#include "DrawTargetCairo.h"
|
||||
#include "HelpersCairo.h"
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
static cairo_format_t
|
||||
GfxFormatToCairoFormat(SurfaceFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case FORMAT_B8G8R8A8:
|
||||
return CAIRO_FORMAT_ARGB32;
|
||||
case FORMAT_B8G8R8X8:
|
||||
return CAIRO_FORMAT_RGB24;
|
||||
case FORMAT_A8:
|
||||
return CAIRO_FORMAT_A8;
|
||||
}
|
||||
|
||||
return CAIRO_FORMAT_ARGB32;
|
||||
}
|
||||
|
||||
static SurfaceFormat
|
||||
CairoFormatToSurfaceFormat(cairo_format_t format)
|
||||
{
|
||||
@ -70,25 +55,9 @@ CairoFormatToSurfaceFormat(cairo_format_t format)
|
||||
return FORMAT_B8G8R8X8;
|
||||
case CAIRO_FORMAT_A8:
|
||||
return FORMAT_A8;
|
||||
default:
|
||||
return FORMAT_B8G8R8A8;
|
||||
}
|
||||
|
||||
return FORMAT_B8G8R8A8;
|
||||
}
|
||||
|
||||
static cairo_content_t
|
||||
GfxFormatToCairoContent(SurfaceFormat format)
|
||||
{
|
||||
switch(format)
|
||||
{
|
||||
case FORMAT_B8G8R8A8:
|
||||
return CAIRO_CONTENT_COLOR_ALPHA;
|
||||
case FORMAT_B8G8R8X8:
|
||||
return CAIRO_CONTENT_COLOR;
|
||||
case FORMAT_A8:
|
||||
return CAIRO_CONTENT_ALPHA;
|
||||
}
|
||||
|
||||
return CAIRO_CONTENT_COLOR_ALPHA;
|
||||
}
|
||||
|
||||
SourceSurfaceCairo::SourceSurfaceCairo(cairo_surface_t* aSurface,
|
||||
|
@ -263,6 +263,9 @@ gfxPattern::GetPattern(mozilla::gfx::DrawTarget *aTarget)
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* Reassure the compiler we are handling all the enum values. */
|
||||
break;
|
||||
}
|
||||
|
||||
new (mColorPattern.addr()) ColorPattern(Color(0, 0, 0, 0));
|
||||
@ -322,9 +325,9 @@ gfxPattern::IsOpaque()
|
||||
return true;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mSourceSurface->GetFormat() == FORMAT_B8G8R8X8) {
|
||||
|
61
hal/Hal.cpp
61
hal/Hal.cpp
@ -200,7 +200,7 @@ class ObserversManager
|
||||
public:
|
||||
void AddObserver(Observer<InfoType>* aObserver) {
|
||||
if (!mObservers) {
|
||||
mObservers = new ObserverList<InfoType>();
|
||||
mObservers = new mozilla::ObserverList<InfoType>();
|
||||
}
|
||||
|
||||
mObservers->AddObserver(aObserver);
|
||||
@ -250,7 +250,7 @@ protected:
|
||||
virtual void GetCurrentInformationInternal(InfoType*) = 0;
|
||||
|
||||
private:
|
||||
ObserverList<InfoType>* mObservers;
|
||||
mozilla::ObserverList<InfoType>* mObservers;
|
||||
InfoType mInfo;
|
||||
bool mHasValidCache;
|
||||
};
|
||||
@ -344,6 +344,63 @@ void SetScreenBrightness(double brightness)
|
||||
PROXY_IF_SANDBOXED(SetScreenBrightness(clamped(brightness, 0.0, 1.0)));
|
||||
}
|
||||
|
||||
void
|
||||
EnableSensorNotifications(SensorType aSensor) {
|
||||
AssertMainThread();
|
||||
PROXY_IF_SANDBOXED(EnableSensorNotifications(aSensor));
|
||||
}
|
||||
|
||||
void
|
||||
DisableSensorNotifications(SensorType aSensor) {
|
||||
AssertMainThread();
|
||||
PROXY_IF_SANDBOXED(DisableSensorNotifications(aSensor));
|
||||
}
|
||||
|
||||
typedef mozilla::ObserverList<SensorData> SensorObserverList;
|
||||
static SensorObserverList *gSensorObservers = NULL;
|
||||
|
||||
static SensorObserverList &
|
||||
GetSensorObservers(SensorType sensor_type) {
|
||||
MOZ_ASSERT(sensor_type < NUM_SENSOR_TYPE);
|
||||
|
||||
if(gSensorObservers == NULL)
|
||||
gSensorObservers = new SensorObserverList[NUM_SENSOR_TYPE];
|
||||
return gSensorObservers[sensor_type];
|
||||
}
|
||||
|
||||
void
|
||||
RegisterSensorObserver(SensorType aSensor, ISensorObserver *aObserver) {
|
||||
SensorObserverList &observers = GetSensorObservers(aSensor);
|
||||
|
||||
AssertMainThread();
|
||||
|
||||
observers.AddObserver(aObserver);
|
||||
if(observers.Length() == 1) {
|
||||
EnableSensorNotifications(aSensor);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UnregisterSensorObserver(SensorType aSensor, ISensorObserver *aObserver) {
|
||||
SensorObserverList &observers = GetSensorObservers(aSensor);
|
||||
|
||||
AssertMainThread();
|
||||
|
||||
observers.RemoveObserver(aObserver);
|
||||
if(observers.Length() == 0) {
|
||||
DisableSensorNotifications(aSensor);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NotifySensorChange(const SensorData &aSensorData) {
|
||||
SensorObserverList &observers = GetSensorObservers(aSensorData.sensor());
|
||||
|
||||
AssertMainThread();
|
||||
|
||||
observers.Broadcast(aSensorData);
|
||||
}
|
||||
|
||||
void
|
||||
RegisterNetworkObserver(NetworkObserver* aObserver)
|
||||
{
|
||||
|
41
hal/Hal.h
41
hal/Hal.h
@ -47,6 +47,7 @@
|
||||
#include "prlog.h"
|
||||
#include "mozilla/dom/battery/Types.h"
|
||||
#include "mozilla/dom/network/Types.h"
|
||||
#include "mozilla/hal_sandbox/PHal.h"
|
||||
|
||||
/*
|
||||
* Hal.h contains the public Hal API.
|
||||
@ -169,6 +170,46 @@ double GetScreenBrightness();
|
||||
*/
|
||||
void SetScreenBrightness(double brightness);
|
||||
|
||||
|
||||
/**
|
||||
* Register an observer for the sensor of given type.
|
||||
*
|
||||
* The observer will receive data whenever the data generated by the
|
||||
* sensor is avaiable.
|
||||
*/
|
||||
void RegisterSensorObserver(hal::SensorType aSensor,
|
||||
hal::ISensorObserver *aObserver);
|
||||
|
||||
/**
|
||||
* Unregister an observer for the sensor of given type.
|
||||
*/
|
||||
void UnregisterSensorObserver(hal::SensorType aSensor,
|
||||
hal::ISensorObserver *aObserver);
|
||||
|
||||
/**
|
||||
* Post a value generated by a sensor.
|
||||
*
|
||||
* This API is internal to hal; clients shouldn't call it directly.
|
||||
*/
|
||||
void NotifySensorChange(const hal::SensorData &aSensorData);
|
||||
|
||||
/**
|
||||
* Enable sensor notifications from the backend
|
||||
*
|
||||
* This method is only visible from implementation of sensor manager.
|
||||
* Rest of the system should not try this.
|
||||
*/
|
||||
void EnableSensorNotifications(hal::SensorType aSensor);
|
||||
|
||||
/**
|
||||
* Disable sensor notifications from the backend
|
||||
*
|
||||
* This method is only visible from implementation of sensor manager.
|
||||
* Rest of the system should not try this.
|
||||
*/
|
||||
void DisableSensorNotifications(hal::SensorType aSensor);
|
||||
|
||||
|
||||
/**
|
||||
* Inform the network backend there is a new network observer.
|
||||
* @param aNetworkObserver The observer that should be added.
|
||||
|
83
hal/HalSensor.h
Normal file
83
hal/HalSensor.h
Normal file
@ -0,0 +1,83 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: sw=2 ts=8 et ft=cpp : */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sinker Li <thinker@codemud.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __HAL_SENSOR_H_
|
||||
#define __HAL_SENSOR_H_
|
||||
|
||||
#include "mozilla/Observer.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace hal {
|
||||
|
||||
/**
|
||||
* Enumeration of sensor types. They are used to specify type while
|
||||
* register or unregister an observer for a sensor of given type.
|
||||
*/
|
||||
enum SensorType {
|
||||
SENSOR_UNKNOWN = -1,
|
||||
SENSOR_ORIENTATION,
|
||||
SENSOR_ACCELERATION,
|
||||
SENSOR_PROXIMITY,
|
||||
NUM_SENSOR_TYPE
|
||||
};
|
||||
|
||||
class SensorData;
|
||||
|
||||
typedef Observer<SensorData> ISensorObserver;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include "IPC/IPCMessageUtils.h"
|
||||
|
||||
namespace IPC {
|
||||
/**
|
||||
* Serializer for SensorType
|
||||
*/
|
||||
template <>
|
||||
struct ParamTraits<mozilla::hal::SensorType>:
|
||||
public EnumSerializer<mozilla::hal::SensorType,
|
||||
mozilla::hal::SENSOR_UNKNOWN,
|
||||
mozilla::hal::NUM_SENSOR_TYPE> {
|
||||
};
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
#endif /* __HAL_SENSOR_H_ */
|
@ -61,6 +61,7 @@ EXPORTS_mozilla = \
|
||||
Hal.h \
|
||||
HalImpl.h \
|
||||
HalSandbox.h \
|
||||
HalSensor.h \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
@ -70,18 +71,36 @@ CPPSRCS = \
|
||||
$(NULL)
|
||||
|
||||
ifeq (android,$(MOZ_WIDGET_TOOLKIT))
|
||||
CPPSRCS += AndroidHal.cpp
|
||||
CPPSRCS += \
|
||||
AndroidHal.cpp \
|
||||
AndroidSensor.cpp \
|
||||
$(NULL)
|
||||
else ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
|
||||
CPPSRCS += GonkHal.cpp Power.cpp
|
||||
CPPSRCS += \
|
||||
GonkHal.cpp \
|
||||
Power.cpp \
|
||||
GonkSensor.cpp \
|
||||
$(NULL)
|
||||
else ifeq (Linux,$(OS_TARGET))
|
||||
CPPSRCS += LinuxHal.cpp Power.cpp
|
||||
CPPSRCS += \
|
||||
LinuxHal.cpp \
|
||||
FallbackSensor.cpp \
|
||||
Power.cpp \
|
||||
$(NULL)
|
||||
ifdef MOZ_ENABLE_DBUS
|
||||
CPPSRCS += UPowerClient.cpp
|
||||
endif
|
||||
else ifeq (WINNT,$(OS_TARGET))
|
||||
CPPSRCS += WindowsHal.cpp WindowsBattery.cpp
|
||||
CPPSRCS += \
|
||||
WindowsHal.cpp \
|
||||
WindowsBattery.cpp \
|
||||
FallbackSensor.cpp \
|
||||
$(NULL)
|
||||
else
|
||||
CPPSRCS += FallbackHal.cpp
|
||||
CPPSRCS += \
|
||||
FallbackHal.cpp \
|
||||
FallbackSensor.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
@ -89,4 +108,4 @@ include $(topsrcdir)/ipc/chromium/chromium-config.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
CFLAGS += $(MOZ_DBUS_GLIB_CFLAGS)
|
||||
CXXFLAGS += $(MOZ_DBUS_GLIB_CFLAGS)
|
||||
CXXFLAGS += $(MOZ_DBUS_GLIB_CFLAGS) -DHAVE_PTHREADS
|
||||
|
75
hal/android/AndroidSensor.cpp
Normal file
75
hal/android/AndroidSensor.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sinker Li <thinker@codemud.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "Hal.h"
|
||||
#include "AndroidBridge.h"
|
||||
|
||||
using namespace mozilla::hal;
|
||||
|
||||
namespace mozilla {
|
||||
namespace hal_impl {
|
||||
|
||||
/**
|
||||
* Translate ID of sensor type from Sensor service to Android.
|
||||
*
|
||||
* Must be consistent with the definition of sensor types in
|
||||
* embedding/android/GeckoAppShell.java
|
||||
*/
|
||||
static int
|
||||
MapSensorType(SensorType aSensorType) {
|
||||
return (SENSOR_UNKNOWN <= aSensorType && aSensorType < NUM_SENSOR_TYPE) ?
|
||||
aSensorType + 1 : -1;
|
||||
}
|
||||
|
||||
void
|
||||
EnableSensorNotifications(SensorType aSensor) {
|
||||
int androidSensor = MapSensorType(aSensor);
|
||||
|
||||
MOZ_ASSERT(androidSensor != -1);
|
||||
AndroidBridge::Bridge()->EnableSensor(androidSensor);
|
||||
}
|
||||
|
||||
void
|
||||
DisableSensorNotifications(SensorType aSensor) {
|
||||
int androidSensor = MapSensorType(aSensor);
|
||||
|
||||
MOZ_ASSERT(androidSensor != -1);
|
||||
AndroidBridge::Bridge()->DisableSensor(androidSensor);
|
||||
}
|
||||
|
||||
} // hal_impl
|
||||
} // mozilla
|
56
hal/fallback/FallbackSensor.cpp
Normal file
56
hal/fallback/FallbackSensor.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: sw=4 ts=8 et ft=cpp : */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sinker Li <thinker@codemud.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "mozilla/Hal.h"
|
||||
|
||||
using namespace mozilla::hal;
|
||||
|
||||
namespace mozilla {
|
||||
namespace hal_impl {
|
||||
|
||||
void
|
||||
EnableSensorNotifications(SensorType aSensor) {
|
||||
}
|
||||
|
||||
void
|
||||
DisableSensorNotifications(SensorType aSensor) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
167
hal/gonk/GonkSensor.cpp
Normal file
167
hal/gonk/GonkSensor.cpp
Normal file
@ -0,0 +1,167 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Hal.h"
|
||||
#include "HalSensor.h"
|
||||
#include "hardware/sensors.h"
|
||||
#include "mozilla/Util.h"
|
||||
#include "SensorDevice.h"
|
||||
|
||||
using namespace mozilla::hal;
|
||||
using namespace android;
|
||||
|
||||
static SensorType
|
||||
HardwareSensorToHalSensor(int type)
|
||||
{
|
||||
switch(type) {
|
||||
case SENSOR_TYPE_ORIENTATION:
|
||||
return SENSOR_ORIENTATION;
|
||||
case SENSOR_TYPE_ACCELEROMETER:
|
||||
return SENSOR_ACCELERATION;
|
||||
case SENSOR_TYPE_PROXIMITY:
|
||||
return SENSOR_PROXIMITY;
|
||||
default:
|
||||
return SENSOR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
HalSensorToHardwareSensor(SensorType type)
|
||||
{
|
||||
switch(type) {
|
||||
case SENSOR_ORIENTATION:
|
||||
return SENSOR_TYPE_ORIENTATION;
|
||||
case SENSOR_ACCELERATION:
|
||||
return SENSOR_TYPE_ACCELEROMETER;
|
||||
case SENSOR_PROXIMITY:
|
||||
return SENSOR_TYPE_PROXIMITY;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
SensorseventToSensorData(const sensors_event_t& data, SensorData* aSensorData)
|
||||
{
|
||||
aSensorData->sensor() = HardwareSensorToHalSensor(data.type);
|
||||
|
||||
if (aSensorData->sensor() == SENSOR_UNKNOWN)
|
||||
return false;
|
||||
|
||||
aSensorData->timestamp() = data.timestamp;
|
||||
aSensorData->values()[0] = data.data[0];
|
||||
aSensorData->values()[1] = data.data[1];
|
||||
aSensorData->values()[2] = data.data[2];
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
onSensorChanged(const sensors_event_t& data, SensorData* aSensorData)
|
||||
{
|
||||
mozilla::DebugOnly<bool> convertedData = SensorseventToSensorData(data, aSensorData);
|
||||
MOZ_ASSERT(convertedData);
|
||||
NotifySensorChange(*aSensorData);
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace hal_impl {
|
||||
|
||||
static pthread_t sThread;
|
||||
static bool sInitialized = false;
|
||||
static bool sContinue = false;
|
||||
static int sActivatedSensors = 0;
|
||||
static SensorData sSensordata[NUM_SENSOR_TYPE];
|
||||
|
||||
static void*
|
||||
UpdateSensorData(void* /*unused*/)
|
||||
{
|
||||
SensorDevice &device = SensorDevice::getInstance();
|
||||
const size_t numEventMax = 16;
|
||||
sensors_event_t buffer[numEventMax];
|
||||
int count = 0;
|
||||
|
||||
while (sContinue) {
|
||||
count = device.poll(buffer, numEventMax);
|
||||
if (count < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i=0; i<count; i++) {
|
||||
onSensorChanged(buffer[i], &sSensordata[HardwareSensorToHalSensor(buffer[i].type)]);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
InitialResources()
|
||||
{
|
||||
pthread_create(&sThread, NULL, &UpdateSensorData, NULL);
|
||||
sInitialized = true;
|
||||
sContinue = true;
|
||||
}
|
||||
|
||||
static void
|
||||
ReleaseResources()
|
||||
{
|
||||
sContinue = false;
|
||||
pthread_join(sThread, NULL);
|
||||
sInitialized = false;
|
||||
}
|
||||
|
||||
static void
|
||||
SensorSwitch(SensorType aSensor, bool activate)
|
||||
{
|
||||
int type = HalSensorToHardwareSensor(aSensor);
|
||||
const sensor_t* sensors = NULL;
|
||||
SensorDevice& device = SensorDevice::getInstance();
|
||||
size_t size = device.getSensorList(&sensors);
|
||||
|
||||
for (size_t i=0; i<size; i++) {
|
||||
if (sensors[i].type == type) {
|
||||
device.activate((void*)pthread_self(), sensors[i].handle, activate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EnableSensorNotifications(SensorType aSensor)
|
||||
{
|
||||
if (!sInitialized) {
|
||||
InitialResources();
|
||||
}
|
||||
|
||||
SensorSwitch(aSensor, true);
|
||||
sActivatedSensors++;
|
||||
}
|
||||
|
||||
void
|
||||
DisableSensorNotifications(SensorType aSensor)
|
||||
{
|
||||
if (!sInitialized) {
|
||||
NS_WARNING("Disable sensors without initializing first");
|
||||
return;
|
||||
}
|
||||
|
||||
SensorSwitch(aSensor, false);
|
||||
sActivatedSensors--;
|
||||
|
||||
if (!sActivatedSensors) {
|
||||
ReleaseResources();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GetCurrentSensorDataInformation(SensorType aSensor, SensorData* aSensorData) {
|
||||
*aSensorData = sSensordata[aSensor];
|
||||
}
|
||||
|
||||
} // hal_impl
|
||||
} // mozilla
|
@ -39,6 +39,11 @@
|
||||
|
||||
include protocol PContent;
|
||||
include protocol PBrowser;
|
||||
include "nspr/prtime.h";
|
||||
include "mozilla/HalSensor.h";
|
||||
|
||||
using PRTime;
|
||||
using mozilla::hal::SensorType;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -48,6 +53,12 @@ namespace hal {
|
||||
bool charging;
|
||||
double remainingTime;
|
||||
};
|
||||
|
||||
struct SensorData {
|
||||
SensorType sensor;
|
||||
PRTime timestamp;
|
||||
float[] values;
|
||||
};
|
||||
}
|
||||
|
||||
namespace hal {
|
||||
@ -89,6 +100,13 @@ parent:
|
||||
Reboot();
|
||||
PowerOff();
|
||||
|
||||
child:
|
||||
NotifySensorChange(SensorData aSensorData);
|
||||
|
||||
parent:
|
||||
EnableSensorNotifications(SensorType aSensor);
|
||||
DisableSensorNotifications(SensorType aSensor);
|
||||
|
||||
__delete__();
|
||||
};
|
||||
|
||||
|
@ -164,9 +164,20 @@ PowerOff()
|
||||
Hal()->SendPowerOff();
|
||||
}
|
||||
|
||||
void
|
||||
EnableSensorNotifications(SensorType aSensor) {
|
||||
Hal()->SendEnableSensorNotifications(aSensor);
|
||||
}
|
||||
|
||||
void
|
||||
DisableSensorNotifications(SensorType aSensor) {
|
||||
Hal()->SendDisableSensorNotifications(aSensor);
|
||||
}
|
||||
|
||||
class HalParent : public PHalParent
|
||||
, public BatteryObserver
|
||||
, public NetworkObserver
|
||||
, public ISensorObserver
|
||||
{
|
||||
public:
|
||||
NS_OVERRIDE virtual bool
|
||||
@ -293,6 +304,22 @@ public:
|
||||
hal::PowerOff();
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvEnableSensorNotifications(const SensorType &aSensor) {
|
||||
hal::RegisterSensorObserver(aSensor, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvDisableSensorNotifications(const SensorType &aSensor) {
|
||||
hal::UnregisterSensorObserver(aSensor, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Notify(const SensorData& aSensorData) {
|
||||
unused << SendNotifySensorChange(aSensorData);
|
||||
}
|
||||
};
|
||||
|
||||
class HalChild : public PHalChild {
|
||||
@ -303,6 +330,9 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvNotifySensorChange(const hal::SensorData &aSensorData);
|
||||
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvNotifyNetworkChange(const NetworkInformation& aNetworkInfo) {
|
||||
hal::NotifyNetworkChange(aNetworkInfo);
|
||||
@ -310,6 +340,13 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
bool
|
||||
HalChild::RecvNotifySensorChange(const hal::SensorData &aSensorData) {
|
||||
hal::NotifySensorChange(aSensorData);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PHalChild* CreateHalChild() {
|
||||
return new HalChild();
|
||||
}
|
||||
|
@ -98,17 +98,33 @@ namespace IPC {
|
||||
|
||||
/**
|
||||
* Generic enum serializer.
|
||||
* E is the enum type.
|
||||
* lowBound is the lowest allowed value of the enum.
|
||||
* highBound is the value higher than highest allowed value of the enum.
|
||||
* In other words, it's the lowest unallowed value.
|
||||
*
|
||||
* This is a generic serializer for any enum type used in IPDL.
|
||||
* Programmers can define ParamTraits<E> for enum type E by deriving
|
||||
* EnumSerializer<E, smallestLegal, highGuard>.
|
||||
*
|
||||
* The serializer would check value againts a range specified by
|
||||
* smallestLegal and highGuard. Only values from smallestLegal to
|
||||
* highGuard are valid, include smallestLegal but highGuard.
|
||||
*
|
||||
* For example, following is definition of serializer for enum type FOO.
|
||||
* \code
|
||||
* enum FOO { FOO_FIRST, FOO_SECOND, FOO_LAST, NUM_FOO };
|
||||
*
|
||||
* template <>
|
||||
* struct ParamTraits<FOO>:
|
||||
* public EnumSerializer<FOO, FOO_FIRST, NUM_FOO> {};
|
||||
* \endcode
|
||||
* FOO_FIRST, FOO_SECOND, and FOO_LAST are valid value.
|
||||
*
|
||||
* \sa https://developer.mozilla.org/en/IPDL/Type_Serialization
|
||||
*/
|
||||
template <typename E, E lowBound, E highBound>
|
||||
template <typename E, E smallestLegal, E highBound>
|
||||
struct EnumSerializer {
|
||||
typedef E paramType;
|
||||
|
||||
static bool IsLegalValue(const paramType &aValue) {
|
||||
return lowBound <= aValue && aValue < highBound;
|
||||
return smallestLegal <= aValue && aValue < highBound;
|
||||
}
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aValue) {
|
||||
|
@ -102,6 +102,7 @@ struct CompartmentStats
|
||||
|
||||
size_t objectSlots;
|
||||
size_t objectElements;
|
||||
size_t objectMisc;
|
||||
size_t stringChars;
|
||||
size_t shapesExtraTreeTables;
|
||||
size_t shapesExtraDictTables;
|
||||
|
@ -126,10 +126,12 @@ CellCallback(JSContext *cx, void *vdata, void *thing, JSGCTraceKind traceKind,
|
||||
} else {
|
||||
cStats->gcHeapObjectsNonFunction += thingSize;
|
||||
}
|
||||
size_t slotsSize, elementsSize;
|
||||
obj->sizeOfExcludingThis(rtStats->mallocSizeOf, &slotsSize, &elementsSize);
|
||||
size_t slotsSize, elementsSize, miscSize;
|
||||
obj->sizeOfExcludingThis(rtStats->mallocSizeOf, &slotsSize,
|
||||
&elementsSize, &miscSize);
|
||||
cStats->objectSlots += slotsSize;
|
||||
cStats->objectElements += elementsSize;
|
||||
cStats->objectMisc += miscSize;
|
||||
break;
|
||||
}
|
||||
case JSTRACE_STRING:
|
||||
@ -262,7 +264,8 @@ CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats)
|
||||
rtStats->totalObjects += cStats.gcHeapObjectsNonFunction +
|
||||
cStats.gcHeapObjectsFunction +
|
||||
cStats.objectSlots +
|
||||
cStats.objectElements;
|
||||
cStats.objectElements +
|
||||
cStats.objectMisc;
|
||||
rtStats->totalShapes += cStats.gcHeapShapesTree +
|
||||
cStats.gcHeapShapesDict +
|
||||
cStats.gcHeapShapesBase +
|
||||
|
9
js/src/jit-test/tests/basic/bug720675.js
Normal file
9
js/src/jit-test/tests/basic/bug720675.js
Normal file
@ -0,0 +1,9 @@
|
||||
// |jit-test| allow-oom;
|
||||
|
||||
gcparam("maxBytes", gcparam("gcBytes") + 4*1024);
|
||||
arr = [1e0, 5e1, 9e19, 0.1e20, 1.3e20, 1e20, 9e20, 9.99e20,
|
||||
0.1e21, 1e21, 1e21+65537, 1e21+65536, 1e21-65536, 1];
|
||||
for (var i = 0; i < 4000; i++) {
|
||||
arr.push(1e19 + i*1e19);
|
||||
}
|
||||
for (var i in arr) {}
|
@ -192,9 +192,16 @@ IdToString(JSContext *cx, jsid id)
|
||||
{
|
||||
if (JSID_IS_STRING(id))
|
||||
return JSID_TO_ATOM(id);
|
||||
if (JS_LIKELY(JSID_IS_INT(id)))
|
||||
return js_IntToString(cx, JSID_TO_INT(id))->ensureFlat(cx);
|
||||
return ToStringSlow(cx, IdToValue(id))->ensureFlat(cx);
|
||||
|
||||
JSString *str;
|
||||
if (JS_LIKELY(JSID_IS_INT(id)))
|
||||
str = js_IntToString(cx, JSID_TO_INT(id));
|
||||
else
|
||||
str = ToStringSlow(cx, IdToValue(id));
|
||||
|
||||
if (!str)
|
||||
return NULL;
|
||||
return str->ensureFlat(cx);
|
||||
}
|
||||
|
||||
inline
|
||||
|
@ -978,7 +978,7 @@ JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure)
|
||||
JS_PUBLIC_API(size_t)
|
||||
JS_GetObjectTotalSize(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return obj->computedSizeOfIncludingThis();
|
||||
return obj->computedSizeOfThisSlotsElements();
|
||||
}
|
||||
|
||||
static size_t
|
||||
|
@ -388,6 +388,13 @@ js::TraceWeakMaps(WeakMapTracer *trc)
|
||||
WatchpointMap::traceAll(trc);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
js::GCThingIsMarkedGray(void *thing)
|
||||
{
|
||||
JS_ASSERT(thing);
|
||||
return reinterpret_cast<gc::Cell *>(thing)->isMarked(gc::GRAY);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS_SetAccumulateTelemetryCallback(JSRuntime *rt, JSAccumulateTelemetryDataCallback callback)
|
||||
{
|
||||
|
@ -292,6 +292,10 @@ struct WeakMapTracer {
|
||||
extern JS_FRIEND_API(void)
|
||||
TraceWeakMaps(WeakMapTracer *trc);
|
||||
|
||||
extern JS_FRIEND_API(bool)
|
||||
GCThingIsMarkedGray(void *thing);
|
||||
|
||||
|
||||
/*
|
||||
* Shadow declarations of JS internal structures, for access by inline access
|
||||
* functions below. Do not use these structures in any other way. When adding
|
||||
|
@ -1469,6 +1469,14 @@ fun_finalize(JSContext *cx, JSObject *obj)
|
||||
obj->toFunction()->finalizeUpvars();
|
||||
}
|
||||
|
||||
size_t
|
||||
JSFunction::sizeOfMisc(JSMallocSizeOfFun mallocSizeOf) const
|
||||
{
|
||||
return (isFlatClosure() && hasFlatClosureUpvars()) ?
|
||||
mallocSizeOf(getFlatClosureUpvars()) :
|
||||
0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reserve two slots in all function objects for XPConnect. Note that this
|
||||
* does not bloat every instance, only those on which reserved slots are set,
|
||||
|
@ -290,6 +290,12 @@ struct JSFunction : public JSObject
|
||||
inline JSAtom *methodAtom() const;
|
||||
inline void setMethodAtom(JSAtom *atom);
|
||||
|
||||
/*
|
||||
* Measures things hanging off this JSFunction that are counted by the
|
||||
* |miscSize| argument in JSObject::sizeOfExcludingThis().
|
||||
*/
|
||||
size_t sizeOfMisc(JSMallocSizeOfFun mallocSizeOf) const;
|
||||
|
||||
private:
|
||||
/*
|
||||
* These member functions are inherited from JSObject, but should never be applied to
|
||||
|
@ -856,14 +856,6 @@ IsAboutToBeFinalized(JSContext *cx, const Value &v)
|
||||
return IsAboutToBeFinalized(cx, (Cell *)v.toGCThing());
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
js_GCThingIsMarked(void *thing, uintN color = BLACK)
|
||||
{
|
||||
JS_ASSERT(thing);
|
||||
AssertValidColor(thing, color);
|
||||
return reinterpret_cast<Cell *>(thing)->isMarked(color);
|
||||
}
|
||||
|
||||
/* Lifetime for type sets attached to scripts containing observed types. */
|
||||
static const int64_t JIT_SCRIPT_RELEASE_TYPES_INTERVAL = 60 * 1000 * 1000;
|
||||
|
||||
|
@ -1363,9 +1363,6 @@ IsAboutToBeFinalized(JSContext *cx, const js::gc::Cell *thing);
|
||||
extern bool
|
||||
IsAboutToBeFinalized(JSContext *cx, const js::Value &value);
|
||||
|
||||
extern JS_FRIEND_API(bool)
|
||||
js_GCThingIsMarked(void *thing, uintN color);
|
||||
|
||||
extern void
|
||||
js_TraceStackFrame(JSTracer *trc, js::StackFrame *fp);
|
||||
|
||||
|
@ -4119,7 +4119,7 @@ JSObject::growSlots(JSContext *cx, uint32_t oldCount, uint32_t newCount)
|
||||
*/
|
||||
JS_ASSERT(newCount < NELEMENTS_LIMIT);
|
||||
|
||||
size_t oldSize = Probes::objectResizeActive() ? computedSizeOfIncludingThis() : 0;
|
||||
size_t oldSize = Probes::objectResizeActive() ? computedSizeOfThisSlotsElements() : 0;
|
||||
size_t newSize = oldSize + (newCount - oldCount) * sizeof(Value);
|
||||
|
||||
/*
|
||||
@ -4188,7 +4188,7 @@ JSObject::shrinkSlots(JSContext *cx, uint32_t oldCount, uint32_t newCount)
|
||||
if (isCall())
|
||||
return;
|
||||
|
||||
size_t oldSize = Probes::objectResizeActive() ? computedSizeOfIncludingThis() : 0;
|
||||
size_t oldSize = Probes::objectResizeActive() ? computedSizeOfThisSlotsElements() : 0;
|
||||
size_t newSize = oldSize - (oldCount - newCount) * sizeof(Value);
|
||||
|
||||
if (newCount == 0) {
|
||||
@ -4234,7 +4234,7 @@ JSObject::growElements(JSContext *cx, uintN newcap)
|
||||
uint32_t oldcap = getDenseArrayCapacity();
|
||||
JS_ASSERT(oldcap <= newcap);
|
||||
|
||||
size_t oldSize = Probes::objectResizeActive() ? computedSizeOfIncludingThis() : 0;
|
||||
size_t oldSize = Probes::objectResizeActive() ? computedSizeOfThisSlotsElements() : 0;
|
||||
|
||||
uint32_t nextsize = (oldcap <= CAPACITY_DOUBLING_MAX)
|
||||
? oldcap * 2
|
||||
@ -4277,7 +4277,7 @@ JSObject::growElements(JSContext *cx, uintN newcap)
|
||||
Debug_SetValueRangeToCrashOnTouch(elements + initlen, actualCapacity - initlen);
|
||||
|
||||
if (Probes::objectResizeActive())
|
||||
Probes::resizeObject(cx, this, oldSize, computedSizeOfIncludingThis());
|
||||
Probes::resizeObject(cx, this, oldSize, computedSizeOfThisSlotsElements());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -4290,7 +4290,7 @@ JSObject::shrinkElements(JSContext *cx, uintN newcap)
|
||||
uint32_t oldcap = getDenseArrayCapacity();
|
||||
JS_ASSERT(newcap <= oldcap);
|
||||
|
||||
size_t oldSize = Probes::objectResizeActive() ? computedSizeOfIncludingThis() : 0;
|
||||
size_t oldSize = Probes::objectResizeActive() ? computedSizeOfThisSlotsElements() : 0;
|
||||
|
||||
/* Don't shrink elements below the minimum capacity. */
|
||||
if (oldcap <= SLOT_CAPACITY_MIN || !hasDynamicElements())
|
||||
@ -4309,7 +4309,7 @@ JSObject::shrinkElements(JSContext *cx, uintN newcap)
|
||||
elements = newheader->elements();
|
||||
|
||||
if (Probes::objectResizeActive())
|
||||
Probes::resizeObject(cx, this, oldSize, computedSizeOfIncludingThis());
|
||||
Probes::resizeObject(cx, this, oldSize, computedSizeOfThisSlotsElements());
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -363,6 +363,7 @@ extern Class NormalArgumentsObjectClass;
|
||||
extern Class ObjectClass;
|
||||
extern Class ProxyClass;
|
||||
extern Class RegExpClass;
|
||||
extern Class RegExpStaticsClass;
|
||||
extern Class SlowArrayClass;
|
||||
extern Class StopIterationClass;
|
||||
extern Class StringClass;
|
||||
@ -672,11 +673,11 @@ struct JSObject : js::gc::Cell
|
||||
inline bool hasPropertyTable() const;
|
||||
|
||||
inline size_t sizeOfThis() const;
|
||||
inline size_t computedSizeOfIncludingThis() const;
|
||||
inline size_t computedSizeOfThisSlotsElements() const;
|
||||
|
||||
/* mallocSizeOf can be NULL, in which case we compute the sizes analytically */
|
||||
inline void sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf,
|
||||
size_t *slotsSize, size_t *elementsSize) const;
|
||||
size_t *slotsSize, size_t *elementsSize,
|
||||
size_t *miscSize) const;
|
||||
|
||||
inline size_t numFixedSlots() const;
|
||||
|
||||
@ -1416,6 +1417,7 @@ struct JSObject : js::gc::Cell
|
||||
inline bool isPrimitive() const;
|
||||
inline bool isProxy() const;
|
||||
inline bool isRegExp() const;
|
||||
inline bool isRegExpStatics() const;
|
||||
inline bool isScope() const;
|
||||
inline bool isScript() const;
|
||||
inline bool isSlowArray() const;
|
||||
@ -1448,6 +1450,7 @@ struct JSObject : js::gc::Cell
|
||||
inline bool isCrossCompartmentWrapper() const;
|
||||
|
||||
inline js::ArgumentsObject &asArguments();
|
||||
inline const js::ArgumentsObject &asArguments() const;
|
||||
inline js::BlockObject &asBlock();
|
||||
inline js::BooleanObject &asBoolean();
|
||||
inline js::CallObject &asCall();
|
||||
|
@ -66,6 +66,7 @@
|
||||
#include "gc/Barrier.h"
|
||||
#include "js/TemplateLib.h"
|
||||
#include "vm/GlobalObject.h"
|
||||
#include "vm/RegExpStatics.h"
|
||||
|
||||
#include "jsatominlines.h"
|
||||
#include "jsfuninlines.h"
|
||||
@ -76,6 +77,7 @@
|
||||
|
||||
#include "gc/Barrier-inl.h"
|
||||
#include "vm/String-inl.h"
|
||||
#include "vm/RegExpStatics-inl.h"
|
||||
|
||||
inline bool
|
||||
JSObject::hasPrivate() const
|
||||
@ -936,6 +938,7 @@ inline bool JSObject::isNumber() const { return hasClass(&js::NumberClass); }
|
||||
inline bool JSObject::isObject() const { return hasClass(&js::ObjectClass); }
|
||||
inline bool JSObject::isPrimitive() const { return isNumber() || isString() || isBoolean(); }
|
||||
inline bool JSObject::isRegExp() const { return hasClass(&js::RegExpClass); }
|
||||
inline bool JSObject::isRegExpStatics() const { return hasClass(&js::RegExpStaticsClass); }
|
||||
inline bool JSObject::isScope() const { return isCall() || isDeclEnv() || isNestedScope(); }
|
||||
inline bool JSObject::isStaticBlock() const { return isBlock() && !getProto(); }
|
||||
inline bool JSObject::isStopIteration() const { return hasClass(&js::StopIterationClass); }
|
||||
@ -1208,31 +1211,43 @@ JSObject::sizeOfThis() const
|
||||
}
|
||||
|
||||
inline size_t
|
||||
JSObject::computedSizeOfIncludingThis() const
|
||||
JSObject::computedSizeOfThisSlotsElements() const
|
||||
{
|
||||
size_t slotsSize, elementsSize;
|
||||
sizeOfExcludingThis(NULL, &slotsSize, &elementsSize);
|
||||
return sizeOfThis() + slotsSize + elementsSize;
|
||||
size_t n = sizeOfThis();
|
||||
|
||||
if (hasDynamicSlots())
|
||||
n += numDynamicSlots() * sizeof(js::Value);
|
||||
|
||||
if (hasDynamicElements())
|
||||
n += (js::ObjectElements::VALUES_PER_HEADER + getElementsHeader()->capacity) *
|
||||
sizeof(js::Value);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
inline void
|
||||
JSObject::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf,
|
||||
size_t *slotsSize, size_t *elementsSize) const
|
||||
size_t *slotsSize, size_t *elementsSize,
|
||||
size_t *miscSize) const
|
||||
{
|
||||
*slotsSize = 0;
|
||||
if (hasDynamicSlots()) {
|
||||
size_t computedSize = numDynamicSlots() * sizeof(js::Value);
|
||||
*slotsSize = mallocSizeOf ? mallocSizeOf(slots) : computedSize;
|
||||
} else {
|
||||
*slotsSize = 0;
|
||||
*slotsSize += mallocSizeOf(slots);
|
||||
}
|
||||
|
||||
*elementsSize = 0;
|
||||
if (hasDynamicElements()) {
|
||||
size_t computedSize =
|
||||
(js::ObjectElements::VALUES_PER_HEADER +
|
||||
getElementsHeader()->capacity) * sizeof(js::Value);
|
||||
*elementsSize =
|
||||
mallocSizeOf ? mallocSizeOf(getElementsHeader()) : computedSize;
|
||||
} else {
|
||||
*elementsSize = 0;
|
||||
*elementsSize += mallocSizeOf(getElementsHeader());
|
||||
}
|
||||
|
||||
/* Other things may be measured in the future if DMD indicates it is worthwhile. */
|
||||
*miscSize = 0;
|
||||
if (isFunction()) {
|
||||
*miscSize += toFunction()->sizeOfMisc(mallocSizeOf);
|
||||
} else if (isArguments()) {
|
||||
*miscSize += asArguments().sizeOfMisc(mallocSizeOf);
|
||||
} else if (isRegExpStatics()) {
|
||||
*miscSize += js::SizeOfRegExpStaticsData(this, mallocSizeOf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,6 +121,12 @@ ArgumentsObject::setStackFrame(StackFrame *frame)
|
||||
setFixedSlot(STACK_FRAME_SLOT, PrivateValue(frame));
|
||||
}
|
||||
|
||||
inline size_t
|
||||
ArgumentsObject::sizeOfMisc(JSMallocSizeOfFun mallocSizeOf) const
|
||||
{
|
||||
return mallocSizeOf(data());
|
||||
}
|
||||
|
||||
inline const js::Value &
|
||||
NormalArgumentsObject::callee() const
|
||||
{
|
||||
|
@ -213,6 +213,12 @@ class ArgumentsObject : public JSObject
|
||||
/* The stack frame for this ArgumentsObject, if the frame is still active. */
|
||||
inline js::StackFrame *maybeStackFrame() const;
|
||||
inline void setStackFrame(js::StackFrame *frame);
|
||||
|
||||
/*
|
||||
* Measures things hanging off this ArgumentsObject that are counted by the
|
||||
* |miscSize| argument in JSObject::sizeOfExcludingThis().
|
||||
*/
|
||||
inline size_t sizeOfMisc(JSMallocSizeOfFun mallocSizeOf) const;
|
||||
};
|
||||
|
||||
class NormalArgumentsObject : public ArgumentsObject
|
||||
@ -246,21 +252,28 @@ js::NormalArgumentsObject &
|
||||
JSObject::asNormalArguments()
|
||||
{
|
||||
JS_ASSERT(isNormalArguments());
|
||||
return *reinterpret_cast<js::NormalArgumentsObject *>(this);
|
||||
return *static_cast<js::NormalArgumentsObject *>(this);
|
||||
}
|
||||
|
||||
js::StrictArgumentsObject &
|
||||
JSObject::asStrictArguments()
|
||||
{
|
||||
JS_ASSERT(isStrictArguments());
|
||||
return *reinterpret_cast<js::StrictArgumentsObject *>(this);
|
||||
return *static_cast<js::StrictArgumentsObject *>(this);
|
||||
}
|
||||
|
||||
js::ArgumentsObject &
|
||||
JSObject::asArguments()
|
||||
{
|
||||
JS_ASSERT(isArguments());
|
||||
return *reinterpret_cast<js::ArgumentsObject *>(this);
|
||||
return *static_cast<js::ArgumentsObject *>(this);
|
||||
}
|
||||
|
||||
const js::ArgumentsObject &
|
||||
JSObject::asArguments() const
|
||||
{
|
||||
JS_ASSERT(isArguments());
|
||||
return *static_cast<const js::ArgumentsObject *>(this);
|
||||
}
|
||||
|
||||
#endif /* ArgumentsObject_h___ */
|
||||
|
@ -54,6 +54,12 @@ js::GlobalObject::getRegExpStatics() const
|
||||
return static_cast<RegExpStatics *>(resObj.getPrivate());
|
||||
}
|
||||
|
||||
inline size_t
|
||||
SizeOfRegExpStaticsData(const JSObject *obj, JSMallocSizeOfFun mallocSizeOf)
|
||||
{
|
||||
return mallocSizeOf(obj->getPrivate());
|
||||
}
|
||||
|
||||
inline
|
||||
RegExpStatics::RegExpStatics()
|
||||
: bufferLink(NULL),
|
||||
|
@ -69,7 +69,7 @@ resc_trace(JSTracer *trc, JSObject *obj)
|
||||
res->mark(trc);
|
||||
}
|
||||
|
||||
static Class regexp_statics_class = {
|
||||
Class js::RegExpStaticsClass = {
|
||||
"RegExpStatics",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub, /* addProperty */
|
||||
@ -92,7 +92,7 @@ static Class regexp_statics_class = {
|
||||
JSObject *
|
||||
RegExpStatics::create(JSContext *cx, GlobalObject *parent)
|
||||
{
|
||||
JSObject *obj = NewObjectWithGivenProto(cx, ®exp_statics_class, NULL, parent);
|
||||
JSObject *obj = NewObjectWithGivenProto(cx, &RegExpStaticsClass, NULL, parent);
|
||||
if (!obj)
|
||||
return NULL;
|
||||
RegExpStatics *res = cx->new_<RegExpStatics>();
|
||||
|
@ -261,6 +261,8 @@ class PreserveRegExpStatics
|
||||
inline ~PreserveRegExpStatics();
|
||||
};
|
||||
|
||||
size_t SizeOfRegExpStaticsData(const JSObject *obj, JSMallocSizeOfFun mallocSizeOf);
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
#endif
|
||||
|
@ -1491,7 +1491,7 @@ ReportCompartmentStats(const JS::CompartmentStats &cStats,
|
||||
callback, closure);
|
||||
|
||||
ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, cStats,
|
||||
"object-slots"),
|
||||
"objects/slots"),
|
||||
nsIMemoryReporter::KIND_HEAP, cStats.objectSlots,
|
||||
"Memory allocated for the compartment's non-fixed object slot arrays, "
|
||||
"which are used to represent object properties. Some objects also "
|
||||
@ -1501,12 +1501,19 @@ ReportCompartmentStats(const JS::CompartmentStats &cStats,
|
||||
callback, closure);
|
||||
|
||||
ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, cStats,
|
||||
"object-elements"),
|
||||
"objects/elements"),
|
||||
nsIMemoryReporter::KIND_HEAP, cStats.objectElements,
|
||||
"Memory allocated for the compartment's object element arrays, "
|
||||
"which are used to represent indexed object properties.",
|
||||
callback, closure);
|
||||
|
||||
ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, cStats,
|
||||
"objects/misc"),
|
||||
nsIMemoryReporter::KIND_HEAP, cStats.objectMisc,
|
||||
"Memory allocated for various small, miscellaneous "
|
||||
"structures that hang off certain kinds of objects.",
|
||||
callback, closure);
|
||||
|
||||
ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, cStats,
|
||||
"string-chars"),
|
||||
nsIMemoryReporter::KIND_HEAP, cStats.stringChars,
|
||||
@ -1554,13 +1561,13 @@ ReportCompartmentStats(const JS::CompartmentStats &cStats,
|
||||
|
||||
#ifdef JS_METHODJIT
|
||||
ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, cStats,
|
||||
"mjit-code"),
|
||||
"mjit/code"),
|
||||
nsIMemoryReporter::KIND_NONHEAP, cStats.mjitCode,
|
||||
"Memory used by the method JIT to hold the compartment's generated code.",
|
||||
callback, closure);
|
||||
|
||||
ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, cStats,
|
||||
"mjit-data"),
|
||||
"mjit/data"),
|
||||
nsIMemoryReporter::KIND_HEAP, cStats.mjitData,
|
||||
"Memory used by the method JIT for the compartment's compilation data: "
|
||||
"JITScripts, native maps, and inline cache structs.",
|
||||
@ -1602,9 +1609,9 @@ ReportCompartmentStats(const JS::CompartmentStats &cStats,
|
||||
}
|
||||
|
||||
void
|
||||
ReportJSRuntimeStats(const JS::RuntimeStats &rtStats, const nsACString &pathPrefix,
|
||||
nsIMemoryMultiReporterCallback *callback,
|
||||
nsISupports *closure)
|
||||
ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats, const nsACString &pathPrefix,
|
||||
nsIMemoryMultiReporterCallback *callback,
|
||||
nsISupports *closure)
|
||||
{
|
||||
PRInt64 gcTotal = 0;
|
||||
for (size_t index = 0;
|
||||
@ -1719,106 +1726,110 @@ public:
|
||||
if (!JS::CollectRuntimeStats(xpcrt->GetJSRuntime(), &rtStats))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
size_t xpconnect;
|
||||
{
|
||||
xpconnect =
|
||||
xpcrt->SizeOfIncludingThis(JsMallocSizeOf) +
|
||||
XPCWrappedNativeScope::SizeOfAllScopesIncludingThis(JsMallocSizeOf);
|
||||
}
|
||||
size_t xpconnect =
|
||||
xpcrt->SizeOfIncludingThis(JsMallocSizeOf) +
|
||||
XPCWrappedNativeScope::SizeOfAllScopesIncludingThis(JsMallocSizeOf);
|
||||
|
||||
NS_NAMED_LITERAL_CSTRING(pathPrefix, "explicit/js/");
|
||||
|
||||
// This is the second step (see above).
|
||||
ReportJSRuntimeStats(rtStats, pathPrefix, callback, closure);
|
||||
// This is the second step (see above). First we report stuff in the
|
||||
// "explicit" tree, then we report other stuff.
|
||||
|
||||
ReportJSRuntimeExplicitTreeStats(rtStats, pathPrefix, callback, closure);
|
||||
|
||||
ReportMemoryBytes(pathPrefix + NS_LITERAL_CSTRING("xpconnect"),
|
||||
nsIMemoryReporter::KIND_HEAP, xpconnect,
|
||||
"Memory used by XPConnect.",
|
||||
callback, closure);
|
||||
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-gc-heap-chunk-dirty-unused"),
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-chunk-dirty-unused"),
|
||||
nsIMemoryReporter::KIND_OTHER,
|
||||
rtStats.gcHeapChunkDirtyUnused,
|
||||
"The same as 'explicit/js/gc-heap-chunk-dirty-unused'. Shown here for "
|
||||
"easy comparison with other 'js-gc' reporters.",
|
||||
callback, closure);
|
||||
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-gc-heap-chunk-clean-unused"),
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-chunk-clean-unused"),
|
||||
nsIMemoryReporter::KIND_OTHER,
|
||||
rtStats.gcHeapChunkCleanUnused,
|
||||
"The same as 'explicit/js/gc-heap-chunk-clean-unused'. Shown here for "
|
||||
"easy comparison with other 'js-gc' reporters.",
|
||||
callback, closure);
|
||||
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-gc-heap-decommitted"),
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-decommitted"),
|
||||
nsIMemoryReporter::KIND_OTHER,
|
||||
rtStats.gcHeapChunkCleanDecommitted + rtStats.gcHeapChunkDirtyDecommitted,
|
||||
"The same as 'explicit/js/gc-heap-decommitted'. Shown here for "
|
||||
"easy comparison with other 'js-gc' reporters.",
|
||||
callback, closure);
|
||||
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-gc-heap-arena-unused"),
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-arena-unused"),
|
||||
nsIMemoryReporter::KIND_OTHER,
|
||||
rtStats.gcHeapArenaUnused,
|
||||
"Memory on the garbage-collected JavaScript heap, within arenas, that "
|
||||
"could be holding useful data but currently isn't. This is the sum of "
|
||||
"all compartments' 'gc-heap/arena-unused' numbers.",
|
||||
"Memory on the main JSRuntime's garbage-collected JavaScript heap, "
|
||||
"within arenas, that could be holding useful data but currently isn't. "
|
||||
"This is the sum of all compartments' 'gc-heap/arena-unused' numbers.",
|
||||
callback, closure);
|
||||
|
||||
ReportMemoryPercentage(NS_LITERAL_CSTRING("js-gc-heap-unused-fraction"),
|
||||
ReportMemoryPercentage(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-unused-fraction"),
|
||||
nsIMemoryReporter::KIND_OTHER,
|
||||
rtStats.gcHeapUnusedPercentage,
|
||||
"Fraction of the garbage-collected JavaScript heap that is unused. "
|
||||
"Computed as ('js-gc-heap-chunk-clean-unused' + "
|
||||
"'js-gc-heap-chunk-dirty-unused' + 'js-gc-heap-decommitted' + "
|
||||
"Fraction of the main JSRuntime's garbage-collected JavaScript "
|
||||
"heap that is unused. Computed as ('js-gc-heap-chunk-clean-unused' "
|
||||
"+ 'js-gc-heap-chunk-dirty-unused' + 'js-gc-heap-decommitted' + "
|
||||
"'js-gc-heap-arena-unused') / 'js-gc-heap'.",
|
||||
callback, closure);
|
||||
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-total-objects"),
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-main-runtime-objects"),
|
||||
nsIMemoryReporter::KIND_OTHER, rtStats.totalObjects,
|
||||
"Memory used for all object-related data. This is the sum of all "
|
||||
"compartments' 'gc-heap/objects-non-function', "
|
||||
"Memory used for all object-related data in the main JSRuntime. "
|
||||
"This is the sum of all compartments' 'gc-heap/objects-non-function', "
|
||||
"'gc-heap/objects-function' and 'object-slots' numbers.",
|
||||
callback, closure);
|
||||
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-total-shapes"),
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-main-runtime-shapes"),
|
||||
nsIMemoryReporter::KIND_OTHER, rtStats.totalShapes,
|
||||
"Memory used for all shape-related data. This is the sum of all "
|
||||
"compartments' 'gc-heap/shapes/tree', 'gc-heap/shapes/dict', "
|
||||
"'gc-heap/shapes/base', "
|
||||
"Memory used for all shape-related data in the main JSRuntime. "
|
||||
"This is the sum of all compartments' 'gc-heap/shapes/tree', "
|
||||
"'gc-heap/shapes/dict', 'gc-heap/shapes/base', "
|
||||
"'shapes-extra/tree-tables', 'shapes-extra/dict-tables', "
|
||||
"'shapes-extra/tree-shape-kids' and 'shapes-extra/empty-shape-arrays'.",
|
||||
callback, closure);
|
||||
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-total-scripts"),
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-main-runtime-scripts"),
|
||||
nsIMemoryReporter::KIND_OTHER, rtStats.totalScripts,
|
||||
"Memory used for all script-related data. This is the sum of all "
|
||||
"compartments' 'gc-heap/scripts' and 'script-data' numbers.",
|
||||
"Memory used for all script-related data in the main JSRuntime. "
|
||||
"This is the sum of all compartments' 'gc-heap/scripts' and "
|
||||
"'script-data' numbers.",
|
||||
callback, closure);
|
||||
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-total-strings"),
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-main-runtime-strings"),
|
||||
nsIMemoryReporter::KIND_OTHER, rtStats.totalStrings,
|
||||
"Memory used for all string-related data. This is the sum of all "
|
||||
"compartments' 'gc-heap/strings' and 'string-chars' numbers.",
|
||||
"Memory used for all string-related data in the main JSRuntime. "
|
||||
"This is the sum of all compartments' 'gc-heap/strings' and "
|
||||
"'string-chars' numbers.",
|
||||
callback, closure);
|
||||
#ifdef JS_METHODJIT
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-total-mjit"),
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-main-runtime-mjit"),
|
||||
nsIMemoryReporter::KIND_OTHER, rtStats.totalMjit,
|
||||
"Memory used by the method JIT. This is the sum of all compartments' "
|
||||
"'mjit-code', and 'mjit-data' numbers.",
|
||||
"Memory used by the method JIT in the main JSRuntime. "
|
||||
"This is the sum of all compartments' 'mjit/code', and 'mjit/data' "
|
||||
"numbers.",
|
||||
callback, closure);
|
||||
#endif
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-total-type-inference"),
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-main-runtime-type-inference"),
|
||||
nsIMemoryReporter::KIND_OTHER, rtStats.totalTypeInference,
|
||||
"Non-transient memory used by type inference. This is the sum of all "
|
||||
"compartments' 'gc-heap/type-objects', 'type-inference/script-main', "
|
||||
"'type-inference/object-main' and 'type-inference/tables' numbers.",
|
||||
"Non-transient memory used by type inference in the main JSRuntime. "
|
||||
"This is the sum of all compartments' 'gc-heap/type-objects', "
|
||||
"'type-inference/script-main', 'type-inference/object-main' and "
|
||||
"'type-inference/tables' numbers.",
|
||||
callback, closure);
|
||||
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-total-analysis-temporary"),
|
||||
ReportMemoryBytes(NS_LITERAL_CSTRING("js-main-runtime-analysis-temporary"),
|
||||
nsIMemoryReporter::KIND_OTHER, rtStats.totalAnalysisTemp,
|
||||
"Memory used transiently during type inference and compilation. "
|
||||
"This is the sum of all compartments' 'analysis-temporary' numbers.",
|
||||
"Memory used transiently during type inference and compilation in the "
|
||||
"main JSRuntime. This is the sum of all compartments' "
|
||||
"'analysis-temporary' numbers.",
|
||||
callback, closure);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -381,8 +381,8 @@ def write_cpp(iface, fd):
|
||||
" if (!aCx || !aVal) {\n"
|
||||
" return NS_OK;\n"
|
||||
" }\n"
|
||||
" NS_ENSURE_STATE(JSVAL_IS_OBJECT(*aVal));\n\n"
|
||||
" JSObject* obj = JSVAL_TO_OBJECT(*aVal);\n"
|
||||
" NS_ENSURE_STATE(aVal->isObject());\n\n"
|
||||
" JSObject* obj = &aVal->toObject();\n"
|
||||
" nsCxPusher pusher;\n"
|
||||
" NS_ENSURE_STATE(pusher.Push(aCx, false));\n"
|
||||
" JSAutoRequest ar(aCx);\n"
|
||||
|
@ -161,19 +161,15 @@ xpc_FastGetCachedWrapper(nsWrapperCache *cache, JSObject *scope)
|
||||
|
||||
// The JS GC marks objects gray that are held alive directly or
|
||||
// indirectly by an XPConnect root. The cycle collector explores only
|
||||
// this subset of the JS heap. JSStaticAtoms cause this to crash,
|
||||
// because they are statically allocated in the data segment and thus
|
||||
// are not really GCThings.
|
||||
// this subset of the JS heap.
|
||||
inline JSBool
|
||||
xpc_IsGrayGCThing(void *thing)
|
||||
{
|
||||
return js_GCThingIsMarked(thing, js::gc::GRAY);
|
||||
return js::GCThingIsMarkedGray(thing);
|
||||
}
|
||||
|
||||
// The cycle collector only cares about JS objects and XML objects that
|
||||
// are held alive directly or indirectly by an XPConnect root. This
|
||||
// version is preferred to xpc_IsGrayGCThing when it isn't known if thing
|
||||
// is a JSString or not. Implemented in nsXPConnect.cpp.
|
||||
// The cycle collector only cares about some kinds of GCthings that are
|
||||
// reachable from an XPConnect root. Implemented in nsXPConnect.cpp.
|
||||
extern JSBool
|
||||
xpc_GCThingIsGrayCCThing(void *thing);
|
||||
|
||||
@ -228,10 +224,12 @@ namespace mozilla {
|
||||
namespace xpconnect {
|
||||
namespace memory {
|
||||
|
||||
// This reports all the stats in |rtStats| that belong in the "explicit" tree,
|
||||
// (which isn't all of them).
|
||||
void
|
||||
ReportJSRuntimeStats(const JS::RuntimeStats &rtStats, const nsACString &pathPrefix,
|
||||
nsIMemoryMultiReporterCallback *callback,
|
||||
nsISupports *closure);
|
||||
ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats, const nsACString &pathPrefix,
|
||||
nsIMemoryMultiReporterCallback *callback,
|
||||
nsISupports *closure);
|
||||
|
||||
} // namespace memory
|
||||
} // namespace xpconnect
|
||||
|
12
layout/reftests/svg/smil/anim-conditions-01.svg
Normal file
12
layout/reftests/svg/smil/anim-conditions-01.svg
Normal file
@ -0,0 +1,12 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
class="reftest-wait"
|
||||
onload="setTimeAndSnapshot(1, true)">
|
||||
<title>Test animation is disabled if conditional processing fails</title>
|
||||
<script xlink:href="smil-util.js" type="text/javascript"/>
|
||||
<rect width="100%" height="100%" fill="red"/>
|
||||
<rect width="100%" height="100%" fill="lime">
|
||||
<set systemLanguage="foo" attributeName="width"
|
||||
to="0%" dur="5s" begin="0s"/>
|
||||
</rect>
|
||||
</svg>
|
After Width: | Height: | Size: 498 B |
12
layout/reftests/svg/smil/anim-conditions-02.svg
Normal file
12
layout/reftests/svg/smil/anim-conditions-02.svg
Normal file
@ -0,0 +1,12 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
class="reftest-wait"
|
||||
onload="setTimeAndSnapshot(1, true)">
|
||||
<title>Test animation is enabled if conditional processing succeeds</title>
|
||||
<script xlink:href="smil-util.js" type="text/javascript"/>
|
||||
<rect width="100%" height="100%" fill="red"/>
|
||||
<rect width="0%" height="100%" fill="lime">
|
||||
<set requiredFeatures="http://www.w3.org/TR/SVG11/feature#Gradient" attributeName="width"
|
||||
to="100%" dur="5s" begin="0s"/>
|
||||
</rect>
|
||||
</svg>
|
After Width: | Height: | Size: 542 B |
@ -85,6 +85,10 @@ fails == anim-fillcolor-1.svg anim-standard-ref.svg # bug 436296
|
||||
== anim-height-interp-5.svg anim-height-interp-5-ref.svg
|
||||
== anim-height-interp-6.svg anim-height-interp-6-ref.svg
|
||||
|
||||
# check conditional processing
|
||||
== anim-conditions-01.svg lime.svg
|
||||
== anim-conditions-02.svg lime.svg
|
||||
|
||||
# animate some <length> attributes:
|
||||
== anim-filter-primitive-size-01.svg lime.svg
|
||||
== anim-filter-size-01.svg lime.svg
|
||||
|
@ -707,8 +707,11 @@ nsUserFontSet::ReplaceFontEntry(gfxProxyFontEntry *aProxy,
|
||||
break;
|
||||
}
|
||||
}
|
||||
static_cast<gfxMixedFontFamily*>(aProxy->Family())->
|
||||
ReplaceFontEntry(aProxy, aFontEntry);
|
||||
gfxMixedFontFamily *family =
|
||||
static_cast<gfxMixedFontFamily*>(aProxy->Family());
|
||||
if (family) {
|
||||
family->ReplaceFontEntry(aProxy, aFontEntry);
|
||||
}
|
||||
}
|
||||
|
||||
nsCSSFontFaceRule*
|
||||
|
@ -632,6 +632,40 @@ public class GeckoAppShell
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Keep these values consistent with |SensorType| in Hal.h
|
||||
*/
|
||||
private static final int SENSOR_ORIENTATION = 1;
|
||||
private static final int SENSOR_ACCELERATION = 2;
|
||||
private static final int SENSOR_PROXIMITY = 3;
|
||||
|
||||
private static Sensor gProximitySensor = null;
|
||||
|
||||
public static void enableSensor(int aSensortype) {
|
||||
SensorManager sm = (SensorManager)
|
||||
GeckoApp.mAppContext.getSystemService(Context.SENSOR_SERVICE);
|
||||
|
||||
switch(aSensortype) {
|
||||
case SENSOR_PROXIMITY:
|
||||
if(gProximitySensor == null)
|
||||
gProximitySensor = sm.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||
sm.registerListener(GeckoApp.mAppContext, gProximitySensor,
|
||||
SensorManager.SENSOR_DELAY_GAME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void disableSensor(int aSensortype) {
|
||||
SensorManager sm = (SensorManager)
|
||||
GeckoApp.mAppContext.getSystemService(Context.SENSOR_SERVICE);
|
||||
|
||||
switch(aSensortype) {
|
||||
case SENSOR_PROXIMITY:
|
||||
sm.unregisterListener(GeckoApp.mAppContext, gProximitySensor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void moveTaskToBack() {
|
||||
GeckoApp.mAppContext.moveTaskToBack(true);
|
||||
}
|
||||
|
@ -86,6 +86,7 @@ public class GeckoEvent {
|
||||
public static final int VIEWPORT = 20;
|
||||
public static final int VISITED = 21;
|
||||
public static final int NETWORK_CHANGED = 22;
|
||||
public static final int PROXIMITY_EVENT = 23;
|
||||
|
||||
public static final int IME_COMPOSITION_END = 0;
|
||||
public static final int IME_COMPOSITION_BEGIN = 1;
|
||||
@ -118,6 +119,7 @@ public class GeckoEvent {
|
||||
public Rect mRect;
|
||||
public double mX, mY, mZ;
|
||||
public double mAlpha, mBeta, mGamma;
|
||||
public double mDistance;
|
||||
|
||||
public int mMetaState, mFlags;
|
||||
public int mKeyCode, mUnicodeChar;
|
||||
@ -231,19 +233,30 @@ public class GeckoEvent {
|
||||
}
|
||||
|
||||
public GeckoEvent(SensorEvent s) {
|
||||
|
||||
if (s.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
|
||||
int sensor_type = s.sensor.getType();
|
||||
|
||||
switch(sensor_type) {
|
||||
case Sensor.TYPE_ACCELEROMETER:
|
||||
mType = ACCELERATION_EVENT;
|
||||
mX = s.values[0];
|
||||
mY = s.values[1];
|
||||
mZ = s.values[2];
|
||||
}
|
||||
else {
|
||||
break;
|
||||
|
||||
case Sensor.TYPE_ORIENTATION:
|
||||
mType = ORIENTATION_EVENT;
|
||||
mAlpha = -s.values[0];
|
||||
mBeta = -s.values[1];
|
||||
mGamma = -s.values[2];
|
||||
Log.i(LOGTAG, "SensorEvent type = " + s.sensor.getType() + " " + s.sensor.getName() + " " + mAlpha + " " + mBeta + " " + mGamma );
|
||||
break;
|
||||
|
||||
case Sensor.TYPE_PROXIMITY:
|
||||
mType = PROXIMITY_EVENT;
|
||||
mDistance = s.values[0];
|
||||
Log.i("GeckoEvent", "SensorEvent type = " + s.sensor.getType() +
|
||||
" " + s.sensor.getName() + " " + mDistance);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ Tester.prototype = {
|
||||
this._cs.registerListener(this);
|
||||
this._globalProperties = Object.keys(window);
|
||||
this._globalPropertyWhitelist = ["navigator", "constructor", "Application",
|
||||
"__SS_tabsToRestore", "webConsoleCommandController",
|
||||
"__SS_tabsToRestore", "__SSi", "webConsoleCommandController",
|
||||
|
||||
// Temporarily added to whitelist for Fennec tests:
|
||||
"AddonUpdateChecker",
|
||||
|
22
toolkit/components/startup/mozprofilerprobe.mof
Normal file
22
toolkit/components/startup/mozprofilerprobe.mof
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma namespace("\\\\.\\root\\wmi")
|
||||
#pragma autorecover
|
||||
|
||||
[dynamic: ToInstance, Description("Mozilla Generic Provider"),
|
||||
Guid("{509962E0-406B-46F4-99BA-5A009F8D2225}")]
|
||||
class MozillaProvider : EventTrace
|
||||
{
|
||||
};
|
||||
|
||||
[dynamic: ToInstance, Description("Mozilla Event: Places Init is complete."): Amended,
|
||||
Guid("{A3DA04E0-57D7-482A-A1C1-61DA5F95BACB}"),
|
||||
EventType(1)]
|
||||
class MozillaEventPlacesInit : MozillaProvider
|
||||
{
|
||||
};
|
||||
|
||||
[dynamic: ToInstance, Description("Mozilla Event: Session Store Window Restored."): Amended,
|
||||
Guid("{917B96B1-ECAD-4DAB-A760-8D49027748AE}"),
|
||||
EventType(1)]
|
||||
class MozillaEventSessionStoreWindowRestored : MozillaProvider
|
||||
{
|
||||
};
|
@ -27,6 +27,7 @@
|
||||
* Daniel Brooks <db48x@db48x.net>
|
||||
* Taras Glek <tglek@mozilla.com>
|
||||
* Landry Breuil <landry@openbsd.org>
|
||||
* David Rajchenbach-Teller <dteller@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
@ -98,6 +99,38 @@
|
||||
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
|
||||
#if defined(XP_WIN)
|
||||
#include "mozilla/perfprobe.h"
|
||||
/**
|
||||
* Events sent to the system for profiling purposes
|
||||
*/
|
||||
//Keep them syncronized with the .mof file
|
||||
|
||||
//Process-wide GUID, used by the OS to differentiate sources
|
||||
// {509962E0-406B-46F4-99BA-5A009F8D2225}
|
||||
//Keep it synchronized with the .mof file
|
||||
#define NS_APPLICATION_TRACING_CID \
|
||||
{ 0x509962E0, 0x406B, 0x46F4, \
|
||||
{ 0x99, 0xBA, 0x5A, 0x00, 0x9F, 0x8D, 0x22, 0x25} }
|
||||
|
||||
//Event-specific GUIDs, used by the OS to differentiate events
|
||||
// {A3DA04E0-57D7-482A-A1C1-61DA5F95BACB}
|
||||
#define NS_PLACES_INIT_COMPLETE_EVENT_CID \
|
||||
{ 0xA3DA04E0, 0x57D7, 0x482A, \
|
||||
{ 0xA1, 0xC1, 0x61, 0xDA, 0x5F, 0x95, 0xBA, 0xCB} }
|
||||
// {917B96B1-ECAD-4DAB-A760-8D49027748AE}
|
||||
#define NS_SESSION_STORE_WINDOW_RESTORED_EVENT_CID \
|
||||
{ 0x917B96B1, 0xECAD, 0x4DAB, \
|
||||
{ 0xA7, 0x60, 0x8D, 0x49, 0x02, 0x77, 0x48, 0xAE} }
|
||||
|
||||
static NS_DEFINE_CID(kApplicationTracingCID,
|
||||
NS_APPLICATION_TRACING_CID);
|
||||
static NS_DEFINE_CID(kPlacesInitCompleteCID,
|
||||
NS_PLACES_INIT_COMPLETE_EVENT_CID);
|
||||
static NS_DEFINE_CID(kSessionStoreWindowRestoredCID,
|
||||
NS_SESSION_STORE_WINDOW_RESTORED_EVENT_CID);
|
||||
#endif //defined(XP_WIN)
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
PRUint32 gRestartMode = 0;
|
||||
@ -159,6 +192,39 @@ nsAppStartup::Init()
|
||||
os->AddObserver(this, "xul-window-registered", true);
|
||||
os->AddObserver(this, "xul-window-destroyed", true);
|
||||
|
||||
#if defined(XP_WIN)
|
||||
os->AddObserver(this, "places-init-complete", true);
|
||||
// This last event is only interesting to us for xperf-based measures
|
||||
|
||||
// Initialize interaction with profiler
|
||||
mProbesManager =
|
||||
new ProbeManager(
|
||||
kApplicationTracingCID,
|
||||
NS_LITERAL_CSTRING("Application startup probe"));
|
||||
// Note: The operation is meant mostly for in-house profiling.
|
||||
// Therefore, we do not warn if probes manager cannot be initialized
|
||||
|
||||
if (mProbesManager) {
|
||||
mPlacesInitCompleteProbe =
|
||||
mProbesManager->
|
||||
GetProbe(kPlacesInitCompleteCID,
|
||||
NS_LITERAL_CSTRING("places-init-complete"));
|
||||
NS_WARN_IF_FALSE(mPlacesInitCompleteProbe,
|
||||
"Cannot initialize probe 'places-init-complete'");
|
||||
|
||||
mSessionWindowRestoredProbe =
|
||||
mProbesManager->
|
||||
GetProbe(kSessionStoreWindowRestoredCID,
|
||||
NS_LITERAL_CSTRING("sessionstore-windows-restored"));
|
||||
NS_WARN_IF_FALSE(mSessionWindowRestoredProbe,
|
||||
"Cannot initialize probe 'sessionstore-windows-restored'");
|
||||
|
||||
rv = mProbesManager->StartSession();
|
||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
|
||||
"Cannot initialize system probe manager");
|
||||
}
|
||||
#endif //defined(XP_WIN)
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -560,6 +626,15 @@ nsAppStartup::Observe(nsISupports *aSubject,
|
||||
ExitLastWindowClosingSurvivalArea();
|
||||
} else if (!strcmp(aTopic, "sessionstore-windows-restored")) {
|
||||
StartupTimeline::Record(StartupTimeline::SESSION_RESTORED);
|
||||
#if defined(XP_WIN)
|
||||
if (mSessionWindowRestoredProbe) {
|
||||
mSessionWindowRestoredProbe->Trigger();
|
||||
}
|
||||
} else if (!strcmp(aTopic, "places-init-complete")) {
|
||||
if (mPlacesInitCompleteProbe) {
|
||||
mPlacesInitCompleteProbe->Trigger();
|
||||
}
|
||||
#endif //defined(XP_WIN)
|
||||
} else {
|
||||
NS_ERROR("Unexpected observer topic.");
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Benjamin Smedberg <bsmedberg@covad.net>
|
||||
* David Rajchenbach-Teller <dteller@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
@ -48,6 +49,13 @@
|
||||
#include "nsINativeAppSupport.h"
|
||||
#include "nsIAppShell.h"
|
||||
|
||||
#if defined(XP_WIN)
|
||||
//XPerf-backed probes
|
||||
#include "mozilla/perfprobe.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#endif //defined(XP_WIN)
|
||||
|
||||
|
||||
struct PLEvent;
|
||||
|
||||
// {7DD4D320-C84B-4624-8D45-7BB9B2356977}
|
||||
@ -85,6 +93,15 @@ private:
|
||||
bool mAttemptingQuit; // Quit(eAttemptQuit) still trying
|
||||
bool mRestart; // Quit(eRestart)
|
||||
bool mInterrupted; // Was startup interrupted by an interactive prompt?
|
||||
|
||||
#if defined(XP_WIN)
|
||||
//Interaction with OS-provided profiling probes
|
||||
typedef mozilla::probes::ProbeManager ProbeManager;
|
||||
typedef mozilla::probes::Probe Probe;
|
||||
nsRefPtr<ProbeManager> mProbesManager;
|
||||
nsRefPtr<Probe> mPlacesInitCompleteProbe;
|
||||
nsRefPtr<Probe> mSessionWindowRestoredProbe;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // nsAppStartup_h__
|
||||
|
@ -110,7 +110,15 @@
|
||||
|
||||
<tr>
|
||||
<th class="column">
|
||||
#ifdef XP_WIN
|
||||
&aboutSupport.appBasicsProfileDirWinMac;
|
||||
#else
|
||||
#ifdef XP_MACOSX
|
||||
&aboutSupport.appBasicsProfileDirWinMac;
|
||||
#else
|
||||
&aboutSupport.appBasicsProfileDir;
|
||||
#endif
|
||||
#endif
|
||||
</th>
|
||||
|
||||
<td>
|
||||
|
@ -429,6 +429,7 @@ OS_LIBS += \
|
||||
-lcutils \
|
||||
-lcamera_client \
|
||||
-lbinder \
|
||||
-lsensorservice \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
|
@ -16,7 +16,13 @@
|
||||
<!ENTITY aboutSupport.appBasicsTitle "Application Basics">
|
||||
<!ENTITY aboutSupport.appBasicsName "Name">
|
||||
<!ENTITY aboutSupport.appBasicsVersion "Version">
|
||||
|
||||
<!ENTITY aboutSupport.appBasicsProfileDir "Profile Directory">
|
||||
<!-- LOCALIZATION NOTE (aboutSupport.appBasicsProfileDirWinMac):
|
||||
This is the Windows- and Mac-specific variant of aboutSupport.appBasicsProfileDir.
|
||||
Windows/Mac use the term "Folder" instead of "Directory" -->
|
||||
<!ENTITY aboutSupport.appBasicsProfileDirWinMac "Profile Folder">
|
||||
|
||||
<!ENTITY aboutSupport.appBasicsEnabledPlugins "Enabled Plugins">
|
||||
<!ENTITY aboutSupport.appBasicsBuildConfig "Build Configuration">
|
||||
<!ENTITY aboutSupport.appBasicsUserAgent "User Agent">
|
||||
@ -24,7 +30,6 @@
|
||||
<!ENTITY aboutSupport.appBasicsMemoryUse "Memory Use">
|
||||
|
||||
<!ENTITY aboutSupport.showDir.label "Open Directory">
|
||||
|
||||
<!-- LOCALIZATION NOTE (aboutSupport.showMac.label): This is the Mac-specific
|
||||
variant of aboutSupport.showDir.label. This allows us to use the preferred
|
||||
"Finder" terminology on Mac. -->
|
||||
|
@ -4,6 +4,11 @@
|
||||
|
||||
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
let tmp = {};
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm", tmp);
|
||||
let AddonManager = tmp.AddonManager;
|
||||
let AddonManagerPrivate = tmp.AddonManagerPrivate;
|
||||
|
||||
var pathParts = gTestPath.split("/");
|
||||
// Drop the test filename
|
||||
pathParts.splice(pathParts.length - 1, pathParts.length);
|
||||
|
@ -1,6 +1,8 @@
|
||||
const TEST_ROOT = "http://example.com/browser/toolkit/mozapps/plugins/tests/";
|
||||
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||
let tmp = {};
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm", tmp);
|
||||
let AddonManager = tmp.AddonManager;
|
||||
|
||||
var gPFS;
|
||||
|
||||
|
@ -107,6 +107,12 @@ AndroidBridge::Init(JNIEnv *jEnv,
|
||||
|
||||
jEnableDeviceMotion = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableDeviceMotion", "(Z)V");
|
||||
jEnableLocation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableLocation", "(Z)V");
|
||||
jEnableSensor =
|
||||
(jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass,
|
||||
"enableSensor", "(I)V");
|
||||
jDisableSensor =
|
||||
(jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass,
|
||||
"disableSensor", "(I)V");
|
||||
jReturnIMEQueryResult = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "returnIMEQueryResult", "(Ljava/lang/String;II)V");
|
||||
jScheduleRestart = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "scheduleRestart", "()V");
|
||||
jNotifyXreExit = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "onXreExit", "()V");
|
||||
@ -315,6 +321,20 @@ AndroidBridge::EnableLocation(bool aEnable)
|
||||
env->CallStaticVoidMethod(mGeckoAppShellClass, jEnableLocation, aEnable);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::EnableSensor(int aSensorType) {
|
||||
ALOG_BRIDGE("AndroidBridge::EnableSensor");
|
||||
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jEnableSensor,
|
||||
aSensorType);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::DisableSensor(int aSensorType) {
|
||||
ALOG_BRIDGE("AndroidBridge::DisableSensor");
|
||||
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jDisableSensor,
|
||||
aSensorType);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::ReturnIMEQueryResult(const PRUnichar *aResult, PRUint32 aLen,
|
||||
int aSelStart, int aSelLen)
|
||||
|
@ -162,6 +162,10 @@ public:
|
||||
|
||||
void EnableLocation(bool aEnable);
|
||||
|
||||
void EnableSensor(int aSensorType);
|
||||
|
||||
void DisableSensor(int aSensorType);
|
||||
|
||||
void ReturnIMEQueryResult(const PRUnichar *aResult, PRUint32 aLen, int aSelStart, int aSelLen);
|
||||
|
||||
void NotifyXreExit();
|
||||
@ -419,6 +423,8 @@ protected:
|
||||
jmethodID jAcknowledgeEventSync;
|
||||
jmethodID jEnableDeviceMotion;
|
||||
jmethodID jEnableLocation;
|
||||
jmethodID jEnableSensor;
|
||||
jmethodID jDisableSensor;
|
||||
jmethodID jReturnIMEQueryResult;
|
||||
jmethodID jNotifyAppShellReady;
|
||||
jmethodID jNotifyXreExit;
|
||||
|
@ -55,6 +55,7 @@ jfieldID AndroidGeckoEvent::jGammaField = 0;
|
||||
jfieldID AndroidGeckoEvent::jXField = 0;
|
||||
jfieldID AndroidGeckoEvent::jYField = 0;
|
||||
jfieldID AndroidGeckoEvent::jZField = 0;
|
||||
jfieldID AndroidGeckoEvent::jDistanceField = 0;
|
||||
jfieldID AndroidGeckoEvent::jRectField = 0;
|
||||
jfieldID AndroidGeckoEvent::jNativeWindowField = 0;
|
||||
|
||||
@ -168,6 +169,7 @@ AndroidGeckoEvent::InitGeckoEventClass(JNIEnv *jEnv)
|
||||
jXField = getField("mX", "D");
|
||||
jYField = getField("mY", "D");
|
||||
jZField = getField("mZ", "D");
|
||||
jDistanceField = getField("mDistance", "D");
|
||||
jRectField = getField("mRect", "Landroid/graphics/Rect;");
|
||||
|
||||
jCharactersField = getField("mCharacters", "Ljava/lang/String;");
|
||||
@ -540,6 +542,11 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
|
||||
break;
|
||||
}
|
||||
|
||||
case PROXIMITY_EVENT: {
|
||||
mDistance = jenv->GetDoubleField(jobj, jDistanceField);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -443,6 +443,7 @@ public:
|
||||
double X() { return mX; }
|
||||
double Y() { return mY; }
|
||||
double Z() { return mZ; }
|
||||
double Distance() { return mDistance; }
|
||||
const nsIntRect& Rect() { return mRect; }
|
||||
nsAString& Characters() { return mCharacters; }
|
||||
nsAString& CharactersExtra() { return mCharactersExtra; }
|
||||
@ -479,6 +480,7 @@ protected:
|
||||
int mRangeForeColor, mRangeBackColor;
|
||||
double mAlpha, mBeta, mGamma;
|
||||
double mX, mY, mZ;
|
||||
double mDistance;
|
||||
int mPointerIndex;
|
||||
nsString mCharacters, mCharactersExtra;
|
||||
nsRefPtr<nsGeoPosition> mGeoPosition;
|
||||
@ -517,6 +519,7 @@ protected:
|
||||
static jfieldID jXField;
|
||||
static jfieldID jYField;
|
||||
static jfieldID jZField;
|
||||
static jfieldID jDistanceField;
|
||||
static jfieldID jRectField;
|
||||
static jfieldID jNativeWindowField;
|
||||
|
||||
@ -563,6 +566,7 @@ public:
|
||||
VIEWPORT = 20,
|
||||
VISITED = 21,
|
||||
NETWORK_CHANGED = 22,
|
||||
PROXIMITY_EVENT = 23,
|
||||
dummy_java_enum_list_end
|
||||
};
|
||||
|
||||
|
@ -36,6 +36,10 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// Make sure the order of included headers
|
||||
#include "base/basictypes.h"
|
||||
#include "nspr/prtypes.h"
|
||||
|
||||
#include "mozilla/Hal.h"
|
||||
#include "nsAppShell.h"
|
||||
#include "nsWindow.h"
|
||||
@ -48,6 +52,7 @@
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Hal.h"
|
||||
#include "prenv.h"
|
||||
|
||||
#include "AndroidBridge.h"
|
||||
@ -355,6 +360,15 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
|
||||
break;
|
||||
}
|
||||
|
||||
case AndroidGeckoEvent::PROXIMITY_EVENT: {
|
||||
InfallibleTArray<float> values;
|
||||
values.AppendElement(curEvent->Distance());
|
||||
|
||||
hal::SensorData sdata(hal::SENSOR_PROXIMITY, PR_Now(), values);
|
||||
hal::NotifySensorChange(sdata);
|
||||
break;
|
||||
}
|
||||
|
||||
case AndroidGeckoEvent::ACTIVITY_STOPPING: {
|
||||
nsCOMPtr<nsIObserverService> obsServ =
|
||||
mozilla::services::GetObserverService();
|
||||
|
@ -1104,24 +1104,6 @@ nsIMM32Handler::HandleComposition(nsWindow* aWindow,
|
||||
}
|
||||
}
|
||||
|
||||
if (!IS_COMMITTING_LPARAM(lParam) && !IS_COMPOSING_LPARAM(lParam)) {
|
||||
PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
|
||||
("IMM32: HandleComposition, Handle 0 length TextEvent\n"));
|
||||
|
||||
// XXX This block should be wrong. If composition string is not change,
|
||||
// we should do nothing.
|
||||
|
||||
if (!mIsComposing) {
|
||||
HandleStartComposition(aWindow, aIMEContext);
|
||||
}
|
||||
|
||||
mCompositionString.Truncate();
|
||||
DispatchTextEvent(aWindow, aIMEContext, false);
|
||||
|
||||
return ShouldDrawCompositionStringOurselves();
|
||||
}
|
||||
|
||||
|
||||
bool startCompositionMessageHasBeenSent = mIsComposing;
|
||||
|
||||
//
|
||||
@ -1161,6 +1143,32 @@ nsIMM32Handler::HandleComposition(nsWindow* aWindow,
|
||||
|
||||
GetCompositionString(aIMEContext, GCS_COMPSTR);
|
||||
|
||||
if (!IS_COMPOSING_LPARAM(lParam)) {
|
||||
PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
|
||||
("IMM32: HandleComposition, lParam doesn't indicate composing, "
|
||||
"mCompositionString=\"%s\", mLastDispatchedCompositionString=\"%s\"",
|
||||
NS_ConvertUTF16toUTF8(mCompositionString).get(),
|
||||
NS_ConvertUTF16toUTF8(mLastDispatchedCompositionString).get()));
|
||||
|
||||
// If composition string isn't changed, we can trust the lParam.
|
||||
// So, we need to do nothing.
|
||||
if (mLastDispatchedCompositionString == mCompositionString) {
|
||||
return ShouldDrawCompositionStringOurselves();
|
||||
}
|
||||
|
||||
// IME may send WM_IME_COMPOSITION without composing lParam values
|
||||
// when composition string becomes empty (e.g., using Backspace key).
|
||||
// If composition string is empty, we should dispatch a text event with
|
||||
// empty string.
|
||||
if (mCompositionString.IsEmpty()) {
|
||||
DispatchTextEvent(aWindow, aIMEContext, false);
|
||||
return ShouldDrawCompositionStringOurselves();
|
||||
}
|
||||
|
||||
// Otherwise, we cannot trust the lParam value. We might need to
|
||||
// dispatch text event with the latest composition string information.
|
||||
}
|
||||
|
||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=296339
|
||||
if (mCompositionString.IsEmpty() && !startCompositionMessageHasBeenSent) {
|
||||
// In this case, maybe, the sender is MSPinYin. That sends *only*
|
||||
|
@ -69,6 +69,10 @@ CPPSRCS = \
|
||||
FileLocation.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
CPPSRCS += perfprobe.cpp
|
||||
endif
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DEPTH)/chrome/src/$(LIB_PREFIX)chrome_s.$(LIB_SUFFIX) \
|
||||
../ds/$(LIB_PREFIX)xpcomds_s.$(LIB_SUFFIX) \
|
||||
@ -125,6 +129,10 @@ EXPORTS_mozilla = \
|
||||
FileLocation.h \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
EXPORTS_mozilla += perfprobe.h
|
||||
endif
|
||||
|
||||
|
||||
GARBAGE += $(XPCOM_GLUE_SRC_LCPPSRCS) $(XPCOM_GLUENS_SRC_LCPPSRCS) $(wildcard *.$(OBJ_SUFFIX))
|
||||
|
||||
|
261
xpcom/build/perfprobe.cpp
Normal file
261
xpcom/build/perfprobe.cpp
Normal file
@ -0,0 +1,261 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation <http://www.mozilla.org/>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* David Rajchenbach-Teller <dteller@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*****************************
|
||||
Windows implementation of probes, using xperf
|
||||
*****************************/
|
||||
#include <windows.h>
|
||||
#include <wmistr.h>
|
||||
#include <evntrace.h>
|
||||
|
||||
#include "perfprobe.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace probes {
|
||||
|
||||
#if defined(MOZ_LOGGING)
|
||||
static PRLogModuleInfo *gProbeLog = PR_NewLogModule("SysProbe");
|
||||
#define LOG(x) PR_LOG(gProbeLog, PR_LOG_DEBUG, x)
|
||||
#else
|
||||
#define LOG(x)
|
||||
#endif
|
||||
|
||||
//Utility function
|
||||
GUID CID_to_GUID(const nsCID &aCID)
|
||||
{
|
||||
GUID result;
|
||||
result.Data1 = aCID.m0;
|
||||
result.Data2 = aCID.m1;
|
||||
result.Data3 = aCID.m2;
|
||||
for (int i = 0; i < 8; ++i)
|
||||
result.Data4[i] = aCID.m3[i];
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Implementation of Probe
|
||||
|
||||
Probe::Probe(const nsCID &aGUID,
|
||||
const nsACString &aName,
|
||||
ProbeManager *aManager)
|
||||
: mGUID(CID_to_GUID(aGUID))
|
||||
, mName(aName)
|
||||
, mManager(aManager)
|
||||
{
|
||||
}
|
||||
|
||||
nsresult Probe::Trigger()
|
||||
{
|
||||
if (!(mManager->mIsActive)) {
|
||||
//Do not trigger if there is no session
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
_EVENT_TRACE_HEADER event;
|
||||
ZeroMemory(&event, sizeof(event));
|
||||
event.Size = sizeof(event);
|
||||
event.Flags = WNODE_FLAG_TRACED_GUID ;
|
||||
event.Guid = (const GUID)mGUID;
|
||||
event.Class.Type = 1;
|
||||
event.Class.Version = 0;
|
||||
event.Class.Level = TRACE_LEVEL_INFORMATION;
|
||||
|
||||
ULONG result = TraceEvent(mManager->mSessionHandle, &event);
|
||||
|
||||
LOG(("Probes: Triggered %s, %s, %ld",
|
||||
mName.Data(),
|
||||
result==ERROR_SUCCESS ? "success":"failure",
|
||||
result));
|
||||
|
||||
nsresult rv;
|
||||
switch(result)
|
||||
{
|
||||
case ERROR_SUCCESS: rv = NS_OK; break;
|
||||
case ERROR_INVALID_FLAG_NUMBER:
|
||||
case ERROR_MORE_DATA:
|
||||
case ERROR_INVALID_PARAMETER: rv = NS_ERROR_INVALID_ARG; break;
|
||||
case ERROR_INVALID_HANDLE: rv = NS_ERROR_FAILURE; break;
|
||||
case ERROR_NOT_ENOUGH_MEMORY:
|
||||
case ERROR_OUTOFMEMORY: rv = NS_ERROR_OUT_OF_MEMORY; break;
|
||||
default: rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// Implementation of ProbeManager
|
||||
|
||||
ProbeManager::~ProbeManager()
|
||||
{
|
||||
//If the manager goes out of scope, stop the session.
|
||||
if (mIsActive && mRegistrationHandle) {
|
||||
StopSession();
|
||||
}
|
||||
}
|
||||
|
||||
ProbeManager::ProbeManager(const nsCID &aApplicationUID,
|
||||
const nsACString &aApplicationName)
|
||||
: mSessionHandle(NULL)
|
||||
, mRegistrationHandle(NULL)
|
||||
, mApplicationUID(aApplicationUID)
|
||||
, mApplicationName(aApplicationName)
|
||||
{
|
||||
#if defined(MOZ_LOGGING)
|
||||
char cidStr[NSID_LENGTH];
|
||||
aApplicationUID.ToProvidedString(cidStr);
|
||||
LOG(("ProbeManager::Init for application %s, %s",
|
||||
aApplicationName.Data(), cidStr));
|
||||
#endif
|
||||
}
|
||||
|
||||
//Note: The Windows API is just a little bit scary there.
|
||||
//The only way to obtain the session handle is to
|
||||
//- ignore the session handle obtained from RegisterTraceGuids
|
||||
//- pass a callback
|
||||
//- in that callback, request the session handle through
|
||||
// GetTraceLoggerHandle and some opaque value received by the callback
|
||||
|
||||
ULONG WINAPI ControlCallback(
|
||||
__in WMIDPREQUESTCODE RequestCode,
|
||||
__in PVOID Context,
|
||||
__in ULONG *Reserved,
|
||||
__in PVOID Buffer
|
||||
)
|
||||
{
|
||||
ProbeManager* context = (ProbeManager*)Context;
|
||||
switch(RequestCode)
|
||||
{
|
||||
case WMI_ENABLE_EVENTS:
|
||||
{
|
||||
context->mIsActive = true;
|
||||
TRACEHANDLE sessionHandle = GetTraceLoggerHandle(Buffer);
|
||||
//Note: We only accept one handle
|
||||
if ((HANDLE)sessionHandle == INVALID_HANDLE_VALUE) {
|
||||
ULONG result = GetLastError();
|
||||
LOG(("Probes: ControlCallback failed, %ul", result));
|
||||
return result;
|
||||
} else if (context->mIsActive && context->mSessionHandle
|
||||
&& context->mSessionHandle != sessionHandle) {
|
||||
LOG(("Probes: Can only handle one context at a time, "
|
||||
"ignoring activation"));
|
||||
return ERROR_SUCCESS;
|
||||
} else {
|
||||
context->mSessionHandle = sessionHandle;
|
||||
LOG(("Probes: ControlCallback activated"));
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
case WMI_DISABLE_EVENTS:
|
||||
context->mIsActive = false;
|
||||
context->mSessionHandle = NULL;
|
||||
LOG(("Probes: ControlCallback deactivated"));
|
||||
return ERROR_SUCCESS;
|
||||
|
||||
default:
|
||||
LOG(("Probes: ControlCallback does not know what to do with %d",
|
||||
RequestCode));
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<Probe> ProbeManager::GetProbe(const nsCID &eventUID,
|
||||
const nsACString &eventName)
|
||||
{
|
||||
nsRefPtr<Probe> result(new Probe(eventUID, eventName, this));
|
||||
mAllProbes.AppendElement(result);
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
nsresult ProbeManager::StartSession()
|
||||
{
|
||||
return StartSession(mAllProbes);
|
||||
}
|
||||
|
||||
nsresult ProbeManager::StartSession(nsTArray<nsRefPtr<Probe>> &aProbes)
|
||||
{
|
||||
const size_t probesCount = aProbes.Length();
|
||||
_TRACE_GUID_REGISTRATION* probes = new _TRACE_GUID_REGISTRATION[probesCount];
|
||||
for (unsigned int i = 0; i < probesCount; ++i) {
|
||||
const Probe *probe = aProbes[i];
|
||||
const Probe *probeX = static_cast<const Probe*>(probe);
|
||||
probes[i].Guid = (LPCGUID)&(probeX->mGUID);
|
||||
}
|
||||
ULONG result =
|
||||
RegisterTraceGuids(&ControlCallback
|
||||
/*RequestAddress: Sets mSessions appropriately.*/,
|
||||
this
|
||||
/*RequestContext: Passed to ControlCallback*/,
|
||||
(LPGUID)&mApplicationUID
|
||||
/*ControlGuid: Tracing GUID
|
||||
the cast comes from MSDN examples*/,
|
||||
probesCount
|
||||
/*GuidCount: Number of probes*/,
|
||||
probes
|
||||
/*TraceGuidReg: Probes registration*/,
|
||||
NULL
|
||||
/*MofImagePath: Must be NULL, says MSDN*/,
|
||||
NULL
|
||||
/*MofResourceName:Must be NULL, says MSDN*/,
|
||||
&mRegistrationHandle
|
||||
/*RegistrationHandle: Handler.
|
||||
used only for unregistration*/
|
||||
);
|
||||
delete[] probes;
|
||||
NS_ENSURE_TRUE(result == ERROR_SUCCESS, NS_ERROR_UNEXPECTED);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult ProbeManager::StopSession()
|
||||
{
|
||||
LOG(("Probes: Stopping measures"));
|
||||
if (mSessionHandle != NULL) {
|
||||
ULONG result = UnregisterTraceGuids(mSessionHandle);
|
||||
mSessionHandle = NULL;
|
||||
if (result != ERROR_SUCCESS) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
236
xpcom/build/perfprobe.h
Normal file
236
xpcom/build/perfprobe.h
Normal file
@ -0,0 +1,236 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation <http://www.mozilla.org/>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* David Rajchenbach-Teller <dteller@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* A mechanism for interacting with operating system-provided
|
||||
* debugging/profiling tools such as Microsoft EWT/Windows Performance Toolkit.
|
||||
*/
|
||||
|
||||
#ifndef mozilla_perfprobe_h
|
||||
#define mozilla_perfprobe_h
|
||||
|
||||
#if !defined(XP_WIN)
|
||||
#error "For the moment, perfprobe.h is defined only for Windows platforms"
|
||||
#endif
|
||||
|
||||
#include "nsError.h"
|
||||
#include "nsStringGlue.h"
|
||||
#include "prlog.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include <windows.h>
|
||||
#undef GetStartupInfo //Prevent Windows from polluting global namespace
|
||||
#include <wmistr.h>
|
||||
#include <evntrace.h>
|
||||
|
||||
namespace mozilla {
|
||||
namespace probes {
|
||||
|
||||
class ProbeManager;
|
||||
|
||||
/**
|
||||
* A data structure supporting a trigger operation that can be used to
|
||||
* send information to the operating system.
|
||||
*/
|
||||
|
||||
class Probe
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_REFCOUNTING(Probe)
|
||||
|
||||
/**
|
||||
* Trigger the event.
|
||||
*
|
||||
* Note: Can be called from any thread.
|
||||
*/
|
||||
nsresult Trigger();
|
||||
~Probe() {};
|
||||
|
||||
protected:
|
||||
Probe(const nsCID &aGUID,
|
||||
const nsACString &aName,
|
||||
ProbeManager *aManager);
|
||||
friend ProbeManager;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* The system GUID associated to this probe. See the documentation
|
||||
* of |ProbeManager::Make| for more details.
|
||||
*/
|
||||
const GUID mGUID;
|
||||
|
||||
/**
|
||||
* The name of this probe. See the documentation
|
||||
* of |ProbeManager::Make| for more details.
|
||||
*/
|
||||
const nsCString mName;
|
||||
|
||||
/**
|
||||
* The ProbeManager managing this probe.
|
||||
*
|
||||
* Note: This is a weak reference to avoid a useless cycle.
|
||||
*/
|
||||
class ProbeManager *mManager;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A manager for a group of probes.
|
||||
*
|
||||
* You can have several managers in one application, provided that they all
|
||||
* have distinct IDs and names. However, having more than 2 is considered a bad
|
||||
* practice.
|
||||
*/
|
||||
class ProbeManager
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_REFCOUNTING(ProbeManager)
|
||||
|
||||
/**
|
||||
* Create a new probe manager.
|
||||
*
|
||||
* This constructor should be called from the main thread.
|
||||
*
|
||||
* @param uid The unique ID of the probe. Under Windows, this unique
|
||||
* ID must have been previously registered using an external tool.
|
||||
* See MyCategory on http://msdn.microsoft.com/en-us/library/aa364100.aspx
|
||||
* @param name A name for the probe. Currently used only for logging purposes.
|
||||
* In the future, may be attached to the data sent to the operating system.
|
||||
*
|
||||
* Note: If two ProbeManagers are constructed with the same uid and/or name,
|
||||
* behavior is unspecified.
|
||||
*/
|
||||
ProbeManager(const nsCID &applicationUID,
|
||||
const nsACString &applicationName);
|
||||
|
||||
/**
|
||||
* Acquire a probe.
|
||||
*
|
||||
* Note: Only probes acquired before the call to SetReady are taken into
|
||||
* account
|
||||
* Note: Can be called only from the main thread.
|
||||
*
|
||||
* @param eventUID The unique ID of the probe. Under Windows, this unique
|
||||
* ID must have been previously registered using an external tool.
|
||||
* See MyCategory on http://msdn.microsoft.com/en-us/library/aa364100.aspx
|
||||
* @param eventMame A name for the probe. Currently used only for logging
|
||||
* purposes. In the
|
||||
* future, may be attached to the data sent to the operating system.
|
||||
* @return Either |null| in case of error or a valid |Probe*|.
|
||||
*
|
||||
* Note: If this method is called twice with the same uid and/or name,
|
||||
* behavior is undefined.
|
||||
*/
|
||||
already_AddRefed<Probe> GetProbe(const nsCID &eventUID,
|
||||
const nsACString &eventName);
|
||||
|
||||
/**
|
||||
* Start/stop the measuring session.
|
||||
*
|
||||
* This method should be called from the main thread.
|
||||
*
|
||||
* Note that starting an already started probe manager has no effect,
|
||||
* nor does stopping an already stopped probe manager.
|
||||
*/
|
||||
nsresult StartSession();
|
||||
nsresult StopSession();
|
||||
|
||||
/**
|
||||
* @return true If measures are currently on, i.e. if triggering probes is any
|
||||
* is useful. You do not have to check this before triggering a probe, unless
|
||||
* this can avoid complex computations.
|
||||
*/
|
||||
bool IsActive();
|
||||
|
||||
~ProbeManager();
|
||||
|
||||
protected:
|
||||
nsresult StartSession(nsTArray<nsRefPtr<Probe> > &probes);
|
||||
nsresult Init(const nsCID &applicationUID, const nsACString &applicationName);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* `true` if a session is in activity, `false` otherwise.
|
||||
*/
|
||||
bool mIsActive;
|
||||
|
||||
/**
|
||||
* The UID of this manager.
|
||||
* See documentation above for registration steps that you
|
||||
* may have to take.
|
||||
*/
|
||||
nsCID mApplicationUID;
|
||||
|
||||
/**
|
||||
* The name of the application.
|
||||
*/
|
||||
nsCString mApplicationName;
|
||||
|
||||
/**
|
||||
* All the probes that have been created for this manager.
|
||||
*/
|
||||
nsTArray<nsRefPtr<Probe> > mAllProbes;
|
||||
|
||||
/**
|
||||
* Handle used for triggering events
|
||||
*/
|
||||
TRACEHANDLE mSessionHandle;
|
||||
|
||||
/**
|
||||
* Handle used for registration/unregistration
|
||||
*/
|
||||
TRACEHANDLE mRegistrationHandle;
|
||||
|
||||
/**
|
||||
* `true` if initialization has been performed, `false` until then.
|
||||
*/
|
||||
bool mInitialized;
|
||||
|
||||
friend Probe;//Needs to access |mSessionHandle|
|
||||
friend ULONG WINAPI ControlCallback(
|
||||
__in WMIDPREQUESTCODE RequestCode,
|
||||
__in PVOID Context,
|
||||
__in ULONG *Reserved,
|
||||
__in PVOID Buffer
|
||||
);//Sets |mSessionHandle|
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
#endif //mozilla_perfprobe_h
|
@ -585,15 +585,38 @@ class nsTSubstring_CharT
|
||||
// XXXbz or can I just include nscore.h and use NS_BUILD_REFCNT_LOGGING?
|
||||
#if defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING)
|
||||
#define XPCOM_STRING_CONSTRUCTOR_OUT_OF_LINE
|
||||
nsTSubstring_CharT( char_type *data, size_type length, PRUint32 flags );
|
||||
nsTSubstring_CharT( char_type *data, size_type length, PRUint32 flags );
|
||||
#else
|
||||
#undef XPCOM_STRING_CONSTRUCTOR_OUT_OF_LINE
|
||||
nsTSubstring_CharT( char_type *data, size_type length, PRUint32 flags )
|
||||
: mData(data),
|
||||
mLength(length),
|
||||
mFlags(flags) {}
|
||||
nsTSubstring_CharT( char_type *data, size_type length, PRUint32 flags )
|
||||
: mData(data),
|
||||
mLength(length),
|
||||
mFlags(flags) {}
|
||||
#endif /* DEBUG || FORCE_BUILD_REFCNT_LOGGING */
|
||||
|
||||
size_t SizeOfExcludingThisMustBeUnshared(nsMallocSizeOfFun mallocSizeOf)
|
||||
{
|
||||
NS_ASSERTION(!(mFlags & F_SHARED), "string is shared");
|
||||
return mallocSizeOf(mData);
|
||||
}
|
||||
|
||||
size_t SizeOfIncludingThisMustBeUnshared(nsMallocSizeOfFun mallocSizeOf)
|
||||
{
|
||||
return mallocSizeOf(this) + SizeOfExcludingThisMustBeUnshared(mallocSizeOf);
|
||||
}
|
||||
|
||||
size_t SizeOfExcludingThisIfUnshared(nsMallocSizeOfFun mallocSizeOf)
|
||||
{
|
||||
if (mFlags & F_SHARED)
|
||||
return 0;
|
||||
return mallocSizeOf(mData);
|
||||
}
|
||||
|
||||
size_t SizeOfIncludingThisIfUnshared(nsMallocSizeOfFun mallocSizeOf)
|
||||
{
|
||||
return mallocSizeOf(this) + SizeOfExcludingThisIfUnshared(mallocSizeOf);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
friend class nsTObsoleteAStringThunk_CharT;
|
||||
|
Loading…
Reference in New Issue
Block a user