Merge mozilla-central to b2g-inbound

This commit is contained in:
Carsten "Tomcat" Book 2013-11-08 15:29:28 +01:00
Родитель a65953798c efcabbb9bf
Коммит 021c6d3068
1434 изменённых файлов: 49834 добавлений и 36065 удалений

Просмотреть файл

@ -1732,7 +1732,8 @@ DocAccessible::ProcessContentInserted(Accessible* aContainer,
// accessibles into accessible tree. We need to invalidate children even
// there's no inserted accessibles in the end because accessible children
// are created while parent recaches child accessibles.
aContainer->UpdateChildren();
aContainer->InvalidateChildren();
CacheChildrenInSubtree(aContainer);
}
UpdateTree(aContainer, aInsertedContent->ElementAt(idx), true);

Просмотреть файл

@ -2,6 +2,7 @@
[test_ariadialog.html]
[test_bug852150.xhtml]
[test_bug895082.html]
[test_canvas.html]
[test_colorpicker.xul]
[test_contextmenu.xul]

Просмотреть файл

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<title>Replace body test</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../role.js"></script>
<script type="application/javascript"
src="../events.js"></script>
<script type="application/javascript">
function doTest()
{
var y = document.getElementById("y");
var oldBody = document.body;
var newBody = document.createElement("body")
document.documentElement.insertBefore(newBody, oldBody);
setTimeout(function() {
document.documentElement.removeChild(oldBody);
newBody.appendChild(y);
ok(true, "we didn't assert");
SimpleTest.finish();
}, 0);
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=895082"
title="Bug 895082 - replacing body element asserts">
Bug 895082</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div><div id="y"></div></div>
</body>
</html>

Просмотреть файл

@ -113,7 +113,7 @@ AB_CD = $(MOZ_UI_LOCALE)
AB := $(firstword $(subst -, ,$(AB_CD)))
clean clobber::
clean clobber repackage::
rm -rf $(DIST)/$(APP_NAME).app
ifdef LIBXUL_SDK
@ -128,16 +128,19 @@ libs-preqs = \
$(NULL)
.PHONY: repackage
libs:: $(libs-preqs)
tools repackage:: $(libs-preqs)
rsync -a --exclude "*.in" $(srcdir)/macbuild/Contents $(DIST)/$(APP_NAME).app --exclude English.lproj
rsync -a --exclude "*.in" $(srcdir)/macbuild/Contents/Resources/English.lproj/ $(DIST)/$(APP_NAME).app/Contents/Resources/$(AB).lproj
sed -e "s/%MOZ_APP_VERSION%/$(MOZ_APP_VERSION)/" -e "s/%MOZ_APP_NAME%/$(MOZ_APP_NAME)/" -e "s/%APP_VERSION%/$(APP_VERSION)/" -e "s/%APP_NAME%/$(APP_NAME)/" -e "s/%APP_BINARY%/$(APP_BINARY)/" $(srcdir)/macbuild/Contents/Info.plist.in > $(DIST)/$(APP_NAME).app/Contents/Info.plist
sed -e "s/%APP_VERSION%/$(APP_VERSION)/" -e "s/%APP_NAME%/$(APP_NAME)/" $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | iconv -f UTF-8 -t UTF-16 > $(DIST)/$(APP_NAME).app/Contents/Resources/$(AB).lproj/InfoPlist.strings
rm -rf $(DIST)/$(APP_NAME).app/Contents/$(APPFILES)
ln -s $(abspath $(DIST)/bin) $(DIST)/$(APP_NAME).app/Contents/$(APPFILES)
rsync -a $(DIST)/bin/ $(DIST)/$(APP_NAME).app/Contents/$(APPFILES)
$(RM) $(DIST)/$(APP_NAME).app/Contents/$(APPFILES)/mangle $(DIST)/$(APP_NAME).app/Contents/$(APPFILES)/shlibsign
ifdef LIBXUL_SDK
cp $(LIBXUL_DIST)/bin/xulrunner$(BIN_SUFFIX) $(DIST)/$(APP_NAME).app/Contents/MacOS/$(APP_BINARY)
rsync -a --exclude nsinstall --copy-unsafe-links $(LIBXUL_DIST)/XUL.framework $(DIST)/$(APP_NAME).app/Contents/Frameworks
else
$(RM) $(DIST)/$(APP_NAME).app/Contents/MacOS/$(PROGRAM)
rsync -aL $(PROGRAM) $(DIST)/$(APP_NAME).app/Contents/MacOS
endif
cp -RL $(srcdir)/b2g.icns $(DIST)/$(APP_NAME).app/Contents/Resources/$(MOZ_APP_NAME).icns
printf "APPLMOZB" > $(DIST)/$(APP_NAME).app/Contents/PkgInfo

Просмотреть файл

Просмотреть файл

@ -10,6 +10,7 @@ chrome.jar:
content/arrow.svg (content/arrow.svg)
* content/dbg-browser-actors.js (content/dbg-browser-actors.js)
content/forms.js (content/forms.js)
* content/settings.js (content/settings.js)
* content/shell.html (content/shell.html)
* content/shell.js (content/shell.js)

Просмотреть файл

@ -162,7 +162,7 @@ AB_CD = $(MOZ_UI_LOCALE)
AB := $(firstword $(subst -, ,$(AB_CD)))
clean clobber::
clean clobber repackage::
$(RM) -r $(dist_dest)
ifdef LIBXUL_SDK
@ -173,19 +173,17 @@ endif
MAC_BUNDLE_VERSION = $(shell $(PYTHON) $(srcdir)/macversion.py --version=$(MOZ_APP_VERSION) --buildid=$(DEPTH)/config/buildid)
libs:: $(PROGRAM)
.PHONY: repackage
tools repackage:: $(PROGRAM)
$(MKDIR) -p $(dist_dest)/Contents/MacOS
$(MKDIR) -p $(dist_dest)/Contents/Resources/$(AB).lproj
rsync -a --exclude "*.in" $(srcdir)/macbuild/Contents $(dist_dest) --exclude English.lproj
rsync -a --exclude "*.in" $(srcdir)/macbuild/Contents/Resources/English.lproj/ $(dist_dest)/Contents/Resources/$(AB).lproj
sed -e "s/%APP_VERSION%/$(MOZ_APP_VERSION)/" -e "s/%MAC_APP_NAME%/$(MAC_APP_NAME)/" -e "s/%MOZ_MACBUNDLE_ID%/$(MOZ_MACBUNDLE_ID)/" -e "s/%MAC_BUNDLE_VERSION%/$(MAC_BUNDLE_VERSION)/" $(srcdir)/macbuild/Contents/Info.plist.in > $(dist_dest)/Contents/Info.plist
sed -e "s/%MAC_APP_NAME%/$(MAC_APP_NAME)/" $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | iconv -f UTF-8 -t UTF-16 > $(dist_dest)/Contents/Resources/$(AB).lproj/InfoPlist.strings
rm -rf $(dist_dest)/Contents/$(APPFILES)
ln -s $(abspath $(DIST)/bin) $(dist_dest)/Contents/$(APPFILES)
ifdef LIBXUL_SDK
rsync -a $(DIST)/bin/ $(dist_dest)/Contents/$(APPFILES)
$(RM) $(dist_dest)/Contents/MacOS/$(PROGRAM)
rsync -aL $(PROGRAM) $(dist_dest)/Contents/MacOS
endif
cp -RL $(DIST)/branding/firefox.icns $(dist_dest)/Contents/Resources/firefox.icns
cp -RL $(DIST)/branding/document.icns $(dist_dest)/Contents/Resources/document.icns
printf APPLMOZB > $(dist_dest)/Contents/PkgInfo

Просмотреть файл

@ -1,8 +1,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
let {Ci,Cu,CC,Cc} = require("chrome");
let {Ci,Cu,CC} = require("chrome");
const promise = require("sdk/core/promise");
const {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm");
@ -18,11 +19,11 @@ function AppValidator(project) {
AppValidator.prototype.error = function (message) {
this.errors.push(message);
}
};
AppValidator.prototype.warning = function (message) {
this.warnings.push(message);
}
};
AppValidator.prototype._getPackagedManifestFile = function () {
let manifestFile = FileUtils.File(this.project.location);
@ -85,7 +86,7 @@ AppValidator.prototype._fetchManifest = function (manifestURL) {
}
return deferred.promise;
}
};
AppValidator.prototype._getManifest = function () {
let manifestURL;
@ -106,29 +107,28 @@ AppValidator.prototype._getManifest = function () {
return promise.resolve(null);
}
return this._fetchManifest(manifestURL);
}
};
AppValidator.prototype.validateManifest = function (manifest) {
if (!manifest.name) {
this.error(strings.GetStringFromName("validator.missNameManifestProperty"));
return;
}
if (!manifest.icons || Object.keys(manifest.icons).length == 0) {
if (!manifest.icons || Object.keys(manifest.icons).length === 0) {
this.warning(strings.GetStringFromName("validator.missIconsManifestProperty"));
} else if (!manifest.icons["128"]) {
this.warning(strings.GetStringFromName("validator.missIconMarketplace"));
}
}
};
AppValidator.prototype._getOriginURL = function (manifest) {
AppValidator.prototype._getOriginURL = function () {
if (this.project.type == "packaged") {
let manifestURL = Services.io.newURI(this.manifestURL, null, null);
return Services.io.newURI(".", null, manifestURL).spec;
} else if (this.project.type == "hosted") {
return Services.io.newURI(this.project.location, null, null).prePath;
}
}
};
AppValidator.prototype.validateLaunchPath = function (manifest) {
let deferred = promise.defer();
@ -181,7 +181,7 @@ AppValidator.prototype.validateLaunchPath = function (manifest) {
}
return deferred.promise;
}
};
AppValidator.prototype.validateType = function (manifest) {
let appType = manifest.type || "web";
@ -196,7 +196,7 @@ AppValidator.prototype.validateType = function (manifest) {
if (appType === "certified") {
this.warning(strings.GetStringFromName("validator.noCertifiedSupport"));
}
}
};
AppValidator.prototype.validate = function () {
this.errors = [];
@ -210,7 +210,6 @@ AppValidator.prototype.validate = function () {
return this.validateLaunchPath(manifest);
}
}).bind(this));
}
};
exports.AppValidator = AppValidator;

Просмотреть файл

@ -173,6 +173,10 @@ let UI = {
project.errorsCount = 0;
}
if (project.warningsCount && project.errorsCount) {
project.validationStatus = "error warning";
}
});
},

Просмотреть файл

@ -64,7 +64,9 @@
<div class="project-title">
<h1 template='{"type":"textContent","path":"manifest.name"}'></h1>
<div class="project-status" template='{"type":"attribute","path":"validationStatus","name":"status"}'>
<p class="project-validation" template='{"type":"textContent","path":"validationStatus"}'></p>
<p class="project-validation valid">&projects.valid;</p>
<p class="project-validation warning">&projects.warning;</p>
<p class="project-validation error">&projects.error;</p>
<p class="project-type" template='{"type":"textContent","path":"type"}'></p>
</div>
</div>

Просмотреть файл

@ -141,8 +141,34 @@
next();
});
},
// Test multiple failures (missing name [error] and icon [warning])
function () {
let validator = createHosted("no-name-or-icon");
validator.validate().then(() => {
checkNoNameOrIcon(validator);
});
},
function () {
let validator = createPackaged("no-name-or-icon");
validator.validate().then(() => {
checkNoNameOrIcon(validator);
});
}
];
function checkNoNameOrIcon(validator) {
is(validator.errors.length, 1, "app with no name has an error");
is(validator.errors[0],
strings.GetStringFromName("validator.missNameManifestProperty"),
"with expected message");
is(validator.warnings.length, 1, "app with no icon has a warning");
is(validator.warnings[0],
strings.GetStringFromName("validator.missIconsManifestProperty"),
"with expected message");
next();
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,3 @@
{
"launch_path": "/home.html"
}

Просмотреть файл

@ -37,8 +37,8 @@ function getAllBreakpoints(dbg) {
let sources = dbg._view.Sources;
let { trimUrlLength: trim } = dbg.panelWin.SourceUtils;
for (let source in sources) {
for (let { attachment: breakpoint } in source) {
for (let source of sources) {
for (let { attachment: breakpoint } of source) {
breakpoints.push({
url: source.value,
label: source.label + ":" + breakpoint.line,

Просмотреть файл

@ -231,8 +231,8 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
* The corresponding breakpoints if found, an empty array otherwise.
*/
getOtherBreakpoints: function(aLocation = {}, aStore = []) {
for (let source in this) {
for (let breakpointItem in source) {
for (let source of this) {
for (let breakpointItem of source) {
let { url, line } = breakpointItem.attachment;
if (url != aLocation.url || line != aLocation.line) {
aStore.push(breakpointItem);
@ -1340,7 +1340,7 @@ WatchExpressionsView.prototype = Heritage.extend(WidgetMethods, {
*/
switchExpression: function(aVar, aExpression) {
let expressionItem =
[i for (i in this) if (i.attachment.currentExpression == aVar.name)][0];
[i for (i of this) if (i.attachment.currentExpression == aVar.name)][0];
// Remove the watch expression if it's going to be empty or a duplicate.
if (!aExpression || this.getAllStrings().indexOf(aExpression) != -1) {
@ -1366,7 +1366,7 @@ WatchExpressionsView.prototype = Heritage.extend(WidgetMethods, {
*/
deleteExpression: function(aVar) {
let expressionItem =
[i for (i in this) if (i.attachment.currentExpression == aVar.name)][0];
[i for (i of this) if (i.attachment.currentExpression == aVar.name)][0];
// Remove the watch expression.
this.remove(expressionItem);
@ -1998,7 +1998,7 @@ GlobalSearchView.prototype = Heritage.extend(WidgetMethods, {
_createGlobalResultsUI: function(aGlobalResults) {
let i = 0;
for (let sourceResults in aGlobalResults) {
for (let sourceResults of aGlobalResults) {
if (i++ == 0) {
this._createSourceResultsUI(sourceResults);
} else {
@ -2123,7 +2123,7 @@ GlobalSearchView.prototype = Heritage.extend(WidgetMethods, {
/**
* An object containing all source results, grouped by source location.
* Iterable via "for (let [location, sourceResults] in globalResults) { }".
* Iterable via "for (let [location, sourceResults] of globalResults) { }".
*/
function GlobalResults() {
this._store = [];
@ -2150,7 +2150,7 @@ GlobalResults.prototype = {
/**
* An object containing all the matched lines for a specific source.
* Iterable via "for (let [lineNumber, lineResults] in sourceResults) { }".
* Iterable via "for (let [lineNumber, lineResults] of sourceResults) { }".
*
* @param string aUrl
* The target source url.
@ -2291,7 +2291,7 @@ SourceResults.prototype = {
/**
* An object containing all the matches for a specific line.
* Iterable via "for (let chunk in lineResults) { }".
* Iterable via "for (let chunk of lineResults) { }".
*
* @param number aLine
* The target line in the source.
@ -2436,12 +2436,10 @@ LineResults.prototype = {
/**
* A generator-iterator over the global, source or line results.
*/
GlobalResults.prototype.__iterator__ =
SourceResults.prototype.__iterator__ =
LineResults.prototype.__iterator__ = function() {
for (let item of this._store) {
yield item;
}
GlobalResults.prototype["@@iterator"] =
SourceResults.prototype["@@iterator"] =
LineResults.prototype["@@iterator"] = function*() {
yield* this._store;
};
/**

Просмотреть файл

@ -615,7 +615,7 @@ StackFramesView.prototype = Heritage.extend(WidgetMethods, {
// Update the context menu to show the currently selected stackframe item
// as a checked entry.
for (let otherItem in this) {
for (let otherItem of this) {
if (otherItem != stackframeItem) {
otherItem.attachment.popup.menuitem.removeAttribute("checked");
} else {

Просмотреть файл

@ -188,12 +188,14 @@ let DebuggerView = {
_initializeEditor: function(aCallback) {
dumpn("Initializing the DebuggerView editor");
// This needs to be more localizable: see bug 929234.
let extraKeys = {};
extraKeys[(Services.appinfo.OS == "Darwin" ? "Cmd-" : "Ctrl-") + "F"] = (cm) => {
let searchKey = document.getElementById("tokenSearchKey").getAttribute("key");
extraKeys[Editor.accel(searchKey)] = (cm) => {
DebuggerView.Filtering._doTokenSearch();
};
extraKeys[Editor.keyFor("jumpToLine")] = false;
this.editor = new Editor({
mode: Editor.modes.text,
readOnly: true,

Просмотреть файл

@ -107,8 +107,8 @@ function test() {
}
function initialChecks() {
for (let source in gSources) {
for (let breakpoint in source) {
for (let source of gSources) {
for (let breakpoint of source) {
ok(gBreakpoints._getAdded(breakpoint.attachment),
"All breakpoint items should have corresponding promises (1).");
ok(!gBreakpoints._getRemoving(breakpoint.attachment),
@ -223,8 +223,8 @@ function test() {
is(!!selectedBreakpoint.attachment.disabled, false,
"The targetted breakpoint should not have been disabled (" + aIndex + ").");
for (let source in gSources) {
for (let otherBreakpoint in source) {
for (let source of gSources) {
for (let otherBreakpoint of source) {
if (otherBreakpoint != selectedBreakpoint) {
ok(!gBreakpoints._getAdded(otherBreakpoint.attachment),
"There should be no breakpoint client for a disabled breakpoint (9).");
@ -235,8 +235,8 @@ function test() {
}
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED, 4).then(() => {
for (let source in gSources) {
for (let someBreakpoint in source) {
for (let source of gSources) {
for (let someBreakpoint of source) {
ok(gBreakpoints._getAdded(someBreakpoint.attachment),
"There should be a breakpoint client for all enabled breakpoints (11).");
is(someBreakpoint.attachment.disabled, false,
@ -245,8 +245,8 @@ function test() {
}
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED, 5).then(() => {
for (let source in gSources) {
for (let someBreakpoint in source) {
for (let source of gSources) {
for (let someBreakpoint of source) {
ok(!gBreakpoints._getAdded(someBreakpoint.attachment),
"There should be no breakpoint client for a disabled breakpoint (13).");
is(someBreakpoint.attachment.disabled, true,
@ -255,8 +255,8 @@ function test() {
}
waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED, 5).then(() => {
for (let source in gSources) {
for (let someBreakpoint in source) {
for (let source of gSources) {
for (let someBreakpoint of source) {
ok(gBreakpoints._getAdded(someBreakpoint.attachment),
"There should be a breakpoint client for all enabled breakpoints (15).");
is(someBreakpoint.attachment.disabled, false,
@ -293,8 +293,8 @@ function test() {
ok(!gSources._selectedBreakpointItem,
"There should be no breakpoint available after removing all breakpoints.");
for (let source in gSources) {
for (let otherBreakpoint in source) {
for (let source of gSources) {
for (let otherBreakpoint of source) {
ok(false, "It's a trap!");
}
}

Просмотреть файл

@ -1008,7 +1008,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
// Apply CSS transforms to each waterfall in this container totalTime
// accurately translate and resize as needed.
for (let { target, attachment } in this) {
for (let { target, attachment } of this) {
let timingsNode = $(".requests-menu-timings", target);
let startCapNode = $(".requests-menu-timings-cap.start", target);
let endCapNode = $(".requests-menu-timings-cap.end", target);
@ -1144,7 +1144,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
* Reapplies the current waterfall background on all request items.
*/
_flushWaterfallBackgrounds: function() {
for (let { target } in this) {
for (let { target } of this) {
let waterfallNode = $(".requests-menu-waterfall", target);
waterfallNode.style.backgroundImage = this._cachedWaterfallBackground;
}

Просмотреть файл

@ -28,9 +28,9 @@ function runTests()
let found = false;
outer: for (let scope in sidebar.variablesView) {
for (let [, obj] in scope) {
for (let [, prop] in obj) {
outer: for (let scope of sidebar.variablesView) {
for (let [, obj] of scope) {
for (let [, prop] of obj) {
if (prop.name == "a" && prop.value == "foobarBug636725") {
found = true;
break outer;

Просмотреть файл

@ -55,7 +55,7 @@ const STR = Services.strings.createBundle(DBG_STRINGS_URI);
/**
* A tree view for inspecting scopes, objects and properties.
* Iterable via "for (let [id, scope] in instance) { }".
* Iterable via "for (let [id, scope] of instance) { }".
* Requires the devtools common.css and debugger.css skin stylesheets.
*
* To allow replacing variable or property values in this view, provide an
@ -1126,7 +1126,7 @@ VariablesView.getterOrSetterDeleteCallback = function(aItem) {
/**
* A Scope is an object holding Variable instances.
* Iterable via "for (let [name, variable] in instance) { }".
* Iterable via "for (let [name, variable] of instance) { }".
*
* @param VariablesView aView
* The view to contain this scope.
@ -2077,7 +2077,7 @@ DevToolsUtils.defineLazyPrototypeGetter(Scope.prototype, "_batchItems", Array);
/**
* A Variable is a Scope holding Property instances.
* Iterable via "for (let [name, property] in instance) { }".
* Iterable via "for (let [name, property] of instance) { }".
*
* @param Scope aScope
* The scope to contain this variable.
@ -2867,7 +2867,7 @@ Variable.prototype = Heritage.extend(Scope.prototype, {
/**
* A Property is a Variable holding additional child Property instances.
* Iterable via "for (let [name, property] in instance) { }".
* Iterable via "for (let [name, property] of instance) { }".
*
* @param Variable aVar
* The variable to contain this property.
@ -2928,13 +2928,11 @@ Property.prototype = Heritage.extend(Variable.prototype, {
/**
* A generator-iterator over the VariablesView, Scopes, Variables and Properties.
*/
VariablesView.prototype.__iterator__ =
Scope.prototype.__iterator__ =
Variable.prototype.__iterator__ =
Property.prototype.__iterator__ = function() {
for (let item of this._store) {
yield item;
}
VariablesView.prototype["@@iterator"] =
Scope.prototype["@@iterator"] =
Variable.prototype["@@iterator"] =
Property.prototype["@@iterator"] = function*() {
yield* this._store;
};
/**

Просмотреть файл

@ -405,7 +405,7 @@ ViewHelpers.Prefs.prototype = {
/**
* A generic Item is used to describe children present in a Widget.
* The label, value and description properties are necessarily strings.
* Iterable via "for (let childItem in parentItem) { }".
* Iterable via "for (let childItem of parentItem) { }".
*
* @param object aOwnerView
* The owner view creating this item.
@ -513,7 +513,7 @@ Item.prototype = {
if (aItem.finalize) {
aItem.finalize(aItem);
}
for (let childItem in aItem) {
for (let childItem of aItem) {
aItem.remove(childItem);
}
@ -557,7 +557,7 @@ Item.prototype = {
/**
* Some generic Widget methods handling Item instances.
* Iterable via "for (let childItem in wrappedView) { }".
* Iterable via "for (let childItem of wrappedView) { }".
*
* Usage:
* function MyView() {
@ -1529,7 +1529,7 @@ this.WidgetMethods = {
if (aItem.finalize) {
aItem.finalize(aItem);
}
for (let childItem in aItem) {
for (let childItem of aItem) {
aItem.remove(childItem);
}
@ -1654,9 +1654,7 @@ this.WidgetMethods = {
/**
* A generator-iterator over all the items in this container.
*/
Item.prototype.__iterator__ =
WidgetMethods.__iterator__ = function() {
for (let [, item] of this._itemsByElement) {
yield item;
}
Item.prototype["@@iterator"] =
WidgetMethods["@@iterator"] = function*() {
yield* this._itemsByElement.values();
};

Просмотреть файл

@ -99,10 +99,6 @@ Editor.modes = {
fs: { name: "x-shader/x-fragment" }
};
function ctrl(k) {
return (Services.appinfo.OS == "Darwin" ? "Cmd-" : "Ctrl-") + k;
}
/**
* A very thin wrapper around CodeMirror. Provides a number
* of helper methods to make our use of CodeMirror easier and
@ -142,17 +138,26 @@ function Editor(config) {
theme: "mozilla"
};
// Overwrite default config with user-provided, if needed.
Object.keys(config).forEach((k) => this.config[k] = config[k]);
// Additional shortcuts.
this.config.extraKeys[ctrl("J")] = (cm) => this.jumpToLine();
this.config.extraKeys[ctrl("/")] = "toggleComment";
this.config.extraKeys[Editor.keyFor("jumpToLine")] = (cm) => this.jumpToLine();
this.config.extraKeys[Editor.keyFor("toggleComment")] = "toggleComment";
// Disable ctrl-[ and ctrl-] because toolbox uses those
// shortcuts.
this.config.extraKeys[ctrl("[")] = false;
this.config.extraKeys[ctrl("]")] = false;
// Disable ctrl-[ and ctrl-] because toolbox uses those shortcuts.
this.config.extraKeys[Editor.keyFor("indentLess")] = false;
this.config.extraKeys[Editor.keyFor("indentMore")] = false;
// Overwrite default config with user-provided, if needed.
Object.keys(config).forEach((k) => {
if (k != "extraKeys")
return this.config[k] = config[k];
if (!config.extraKeys)
return;
Object.keys(config.extraKeys).forEach((key) => {
this.config.extraKeys[key] = config.extraKeys[key];
});
});
// Overwrite default tab behavior. If something is selected,
// indent those lines. If nothing is selected and we're
@ -666,6 +671,27 @@ CM_MAPPING.forEach(function (name) {
};
});
// Static methods on the Editor object itself.
/**
* Returns a string representation of a shortcut 'key' with
* a OS specific modifier. Cmd- for Macs, Ctrl- for other
* platforms. Useful with extraKeys configuration option.
*/
Editor.accel = function (key) {
return (Services.appinfo.OS == "Darwin" ? "Cmd-" : "Ctrl-") + key;
};
/**
* Returns a string representation of a shortcut for a
* specified command 'cmd'. Cmd- for macs, Ctrl- for other
* platforms. Useful when overwriting or disabling default
* shortcuts.
*/
Editor.keyFor = function (cmd) {
return Editor.accel(L10N.GetStringFromName(cmd + ".commandkey"));
};
// Since Gecko already provide complete and up to date list of CSS property
// names, values and color names, we compute them so that they can replace
// the ones used in CodeMirror while initiating an editor object. This is done

Просмотреть файл

@ -27,10 +27,6 @@ const SAVE_ERROR = "error-save";
// @see StyleEditor.updateStylesheet
const UPDATE_STYLESHEET_THROTTLE_DELAY = 500;
function ctrl(k) {
return (Services.appinfo.OS == "Darwin" ? "Cmd-" : "Ctrl-") + k;
}
/**
* StyleSheetEditor controls the editor linked to a particular StyleSheet
* object.
@ -392,11 +388,11 @@ StyleSheetEditor.prototype = {
_getKeyBindings: function() {
let bindings = {};
bindings[ctrl(_("saveStyleSheet.commandkey"))] = () => {
bindings[Editor.accel(_("saveStyleSheet.commandkey"))] = () => {
this.saveToFile(this.savedFile);
};
bindings["Shift-" + ctrl(_("saveStyleSheet.commandkey"))] = () => {
bindings["Shift-" + Editor.accel(_("saveStyleSheet.commandkey"))] = () => {
this.saveToFile();
};

Просмотреть файл

@ -447,7 +447,7 @@ function findVariableViewProperties(aView, aRules, aOptions)
function finder(aRules, aVar, aPromises)
{
for (let [id, prop] in aVar) {
for (let [id, prop] of aVar) {
for (let rule of aRules) {
let matcher = matchVariablesViewProperty(prop, rule, aOptions);
aPromises.push(matcher.then(onMatch.bind(null, prop, rule)));

Просмотреть файл

@ -78,6 +78,9 @@
<!ENTITY projects.manifestEditorTooltip "Edit your app's manifest in the panel below. The Update button will save your changes and update the app.">
<!ENTITY projects.manifestViewer "Manifest Viewer">
<!ENTITY projects.manifestViewerTooltip "Examine your app's manifest in the panel below.">
<!ENTITY projects.valid "Valid">
<!ENTITY projects.error "Error">
<!ENTITY projects.warning "Warning">
<!ENTITY help.title "App Manager">
<!ENTITY help.close "Close">

Просмотреть файл

@ -47,4 +47,30 @@ annotation.currentLine=Current line
# a tooltip displayed in any of the editor gutters when the user hovers the
# current debugger location. The debugger can pause the JavaScript execution at
# user-defined lines.
annotation.debugLocation.title=Current step: %S
annotation.debugLocation.title=Current step: %S
# LOCALIZATION NOTE (jumpToLine.commandkey): This the key to use in
# conjunction with accel (Command on Mac or Ctrl on other platforms) to jump to
# a specific line in the editor.
jumpToLine.commandkey=J
# LOCALIZATION NOTE (toggleComment.commandkey): This the key to use in
# conjunction with accel (Command on Mac or Ctrl on other platforms) to either
# comment or uncomment selected lines in the editor.
toggleComment.commandkey=/
# LOCALIZATION NOTE (toolboxPrevTool.commandkey): This the key to use in
# conjunction with accel (Command on Mac or Ctrl on other platforms) to reduce
# indentation level in CodeMirror. However, its default value also used by
# the Toolbox to switch between tools so we disable it.
#
# DO NOT translate this key without proper synchronization with toolbox.dtd.
indentLess.commandkey=[
# LOCALIZATION NOTE (toolboxPrevTool.commandkey): This the key to use in
# conjunction with accel (Command on Mac or Ctrl on other platforms) to increase
# indentation level in CodeMirror. However, its default value also used by
# the Toolbox to switch between tools
#
# DO NOT translate this key without proper synchronization with toolbox.dtd.
indentMore.commandkey=]

Просмотреть файл

@ -9,6 +9,9 @@ let Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "gUUIDGenerator",
"@mozilla.org/uuid-generator;1", "nsIUUIDGenerator");
let WebProgressListener = {
_lastLocation: null,
_firstPaint: false,
@ -260,7 +263,7 @@ let WebNavigation = {
// start might already be in use)
let id = aIdMap[aEntry.ID] || 0;
if (!id) {
for (id = Date.now(); id in aIdMap.used; id++);
id = gUUIDGenerator.generateUUID();
aIdMap[aEntry.ID] = id;
aIdMap.used[id] = true;
}

Просмотреть файл

@ -124,15 +124,15 @@ strong {
box-shadow: inset 0 0 1px 1px rgba(255,255,255,0.2), inset 0 -1px 0 0 rgba(0,0,0,0.2);
}
.project-item-status[status="warning"] {
background-color: #F2B33F;
}
.project-item-status[status="valid"] {
background-color: #70BF53;
}
.project-item-status[status="error"] {
.project-item-status[status~="warning"] {
background-color: #F2B33F;
}
.project-item-status[status~="error"] {
background-color: #ED4C62;
}
@ -315,20 +315,27 @@ strong {
.project-validation {
color: #FFF;
display: none;
margin-left: 10px;
}
[status="valid"] > .project-validation {
.project-validation.valid {
background-color: #70BF53;
}
[status="warning"] > .project-validation {
.project-validation.warning {
background-color: #F2B33F;
}
[status="error"] > .project-validation {
.project-validation.error {
background-color: #ED4C62;
}
[status="valid"] > .project-validation.valid,
[status~="warning"] > .project-validation.warning,
[status~="error"] > .project-validation.error {
display: inline;
}
/********* PROJECT BUTTONS ***********/
@ -399,27 +406,31 @@ strong {
display: none;
}
[status="warning"] > .project-item-warnings,
[status="error"] > .project-item-errors,
[status="warning"] > .project-warnings,
[status="error"] > .project-errors {
[status~="warning"] .project-item-warnings,
[status~="error"] .project-item-errors {
display: inline-block;
}
[status~="warning"] > .project-warnings,
[status~="error"] > .project-errors {
display: block;
}
.project-warnings {
.project-warnings,
.project-errors {
margin: 20px 20px 0;
padding: 10px 10px;
border-left: 3px solid #ECB51E;
background-color: rgba(236, 181, 20, 0.1);
font-family: monospace;
}
.project-warnings {
border-left: 3px solid #ECB51E;
background-color: rgba(236, 181, 20, 0.1);
}
.project-errors {
margin: 20px;
padding: 10px 10px;
border-left: 3px solid #ED4C62;
background-color: rgba(237,76,98,0.1);
font-family: monospace;
}
.project-item-warnings {

Просмотреть файл

@ -1373,7 +1373,7 @@ PP_TARGETS += DIST_CHROME_FILES
endif
ifneq ($(XPI_PKGNAME),)
libs realchrome::
tools realchrome::
ifdef STRIP_XPI
ifndef MOZ_DEBUG
@echo "Stripping $(XPI_PKGNAME) package directory..."
@ -1412,7 +1412,7 @@ ifndef XPI_NAME
$(error XPI_NAME must be set for INSTALL_EXTENSION_ID)
endif
libs::
tools::
$(RM) -r "$(DIST)/bin$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)"
$(NSINSTALL) -D "$(DIST)/bin$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)"
$(call copy_dir,$(FINAL_TARGET),$(DIST)/bin$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID))

Просмотреть файл

@ -116,20 +116,22 @@ bool WebGLContext::IsExtensionSupported(WebGLExtensionID ext) const
return WebGLExtensionInstancedArrays::IsSupported(this);
case EXT_sRGB:
return WebGLExtensionSRGB::IsSupported(this);
case WEBGL_draw_buffers:
return WebGLExtensionDrawBuffers::IsSupported(this);
default:
// For warnings-as-errors.
break;
}
// Uncomment this switch for any new extensions
#if 0
if (Preferences::GetBool("webgl.enable-draft-extensions", false) || IsWebGL2()) {
switch (ext) {
case WEBGL_draw_buffers:
return WebGLExtensionDrawBuffers::IsSupported(this);
default:
// For warnings-as-errors.
break;
}
}
#endif
return false;
}

Просмотреть файл

@ -60,7 +60,6 @@
#include "nsIPrincipal.h"
#include "nsTextFragment.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptGlobalObjectOwner.h"
#include "nsIParserService.h"
@ -712,10 +711,7 @@ IsScriptEnabled(nsIDocument *aDoc, nsIDocShell *aContainer)
// Getting context is tricky if the document hasn't had its
// GlobalObject set yet
if (!globalObject) {
nsCOMPtr<nsIScriptGlobalObjectOwner> owner = do_GetInterface(aContainer);
NS_ENSURE_TRUE(owner, true);
globalObject = owner->GetScriptGlobalObject();
globalObject = aContainer->GetScriptGlobalObject();
NS_ENSURE_TRUE(globalObject, true);
}

Просмотреть файл

@ -34,6 +34,7 @@ GetUserMediaLog()
#include "nsITabSource.h"
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidJNIWrapper.h"
#include "AndroidBridge.h"
#endif
@ -250,16 +251,12 @@ MediaEngineWebRTC::EnumerateAudioDevices(nsTArray<nsRefPtr<MediaEngineAudioSourc
// get the JVM
JavaVM *jvm = mozilla::AndroidBridge::Bridge()->GetVM();
JNIEnv *env = GetJNIForThread();
JNIEnv *env;
jvm->AttachCurrentThread(&env, nullptr);
if (webrtc::VoiceEngine::SetAndroidObjects(jvm, (void*)context) != 0) {
if (webrtc::VoiceEngine::SetAndroidObjects(jvm, env, (void*)context) != 0) {
LOG(("VoiceEngine:SetAndroidObjects Failed"));
return;
}
env->DeleteGlobalRef(context);
#endif
if (!mVoiceEngine) {

Просмотреть файл

@ -45,7 +45,6 @@
#include "webrtc/video_engine/include/vie_codec.h"
#include "webrtc/video_engine/include/vie_render.h"
#include "webrtc/video_engine/include/vie_capture.h"
#include "webrtc/video_engine/include/vie_file.h"
#ifdef MOZ_B2G_CAMERA
#include "CameraPreviewMediaStream.h"
#include "DOMCameraManager.h"
@ -118,7 +117,14 @@ public:
#else
// ViEExternalRenderer.
virtual int FrameSizeChange(unsigned int, unsigned int, unsigned int);
virtual int DeliverFrame(unsigned char*, int, uint32_t, int64_t);
virtual int DeliverFrame(unsigned char*,int, uint32_t , int64_t,
void *handle);
/**
* Does DeliverFrame() support a null buffer and non-null handle
* (video texture)?
* XXX Investigate! Especially for Android/B2G
*/
virtual bool IsTextureSupported() { return false; }
MediaEngineWebRTCVideoSource(webrtc::VideoEngine* aVideoEnginePtr, int aIndex)
: mVideoEngine(aVideoEnginePtr)

Просмотреть файл

@ -40,7 +40,8 @@ MediaEngineWebRTCVideoSource::FrameSizeChange(
// ViEExternalRenderer Callback. Process every incoming frame here.
int
MediaEngineWebRTCVideoSource::DeliverFrame(
unsigned char* buffer, int size, uint32_t time_stamp, int64_t render_time)
unsigned char* buffer, int size, uint32_t time_stamp, int64_t render_time,
void *handle)
{
// mInSnapshotMode can only be set before the camera is turned on and
// the renderer is started, so this amounts to a 1-shot
@ -399,126 +400,7 @@ MediaEngineWebRTCVideoSource::Stop(SourceMediaStream *aSource, TrackID aID)
nsresult
MediaEngineWebRTCVideoSource::Snapshot(uint32_t aDuration, nsIDOMFile** aFile)
{
/**
* To get a Snapshot we do the following:
* - Set a condition variable (mInSnapshotMode) to true
* - Attach the external renderer and start the camera
* - Wait for the condition variable to change to false
*
* Starting the camera has the effect of invoking DeliverFrame() when
* the first frame arrives from the camera. We only need one frame for
* GetCaptureDeviceSnapshot to work, so we immediately set the condition
* variable to false and notify this method.
*
* This causes the current thread to continue (PR_CondWaitVar will return),
* at which point we can grab a snapshot, convert it to a file and
* return from this function after cleaning up the temporary stream object
* and caling Stop() on the media source.
*/
#ifdef MOZ_B2G_CAMERA
ReentrantMonitorAutoEnter sync(mCallbackMonitor);
#endif
*aFile = nullptr;
if (!mInitDone || mState != kAllocated) {
return NS_ERROR_FAILURE;
}
#ifdef MOZ_B2G_CAMERA
mLastCapture = nullptr;
NS_DispatchToMainThread(WrapRunnable(this,
&MediaEngineWebRTCVideoSource::StartImpl,
mCapability));
mCallbackMonitor.Wait();
if (mState != kStarted) {
return NS_ERROR_FAILURE;
}
NS_DispatchToMainThread(WrapRunnable(this,
&MediaEngineWebRTCVideoSource::SnapshotImpl));
mCallbackMonitor.Wait();
if (mLastCapture == nullptr)
return NS_ERROR_FAILURE;
mState = kStopped;
NS_DispatchToMainThread(WrapRunnable(this,
&MediaEngineWebRTCVideoSource::StopImpl));
// The camera return nsDOMMemoryFile indeed, and the inheritance tree is:
// nsIDOMBlob <- nsIDOMFile <- nsDOMFileBase <- nsDOMFile <- nsDOMMemoryFile
*aFile = mLastCapture.get();
return NS_OK;
#else
{
MonitorAutoLock lock(mMonitor);
mInSnapshotMode = true;
}
// Start the rendering (equivalent to calling Start(), but without a track).
int error = 0;
if (!mInitDone || mState != kAllocated) {
return NS_ERROR_FAILURE;
}
error = mViERender->AddRenderer(mCaptureIndex, webrtc::kVideoI420, (webrtc::ExternalRenderer*)this);
if (error == -1) {
return NS_ERROR_FAILURE;
}
error = mViERender->StartRender(mCaptureIndex);
if (error == -1) {
return NS_ERROR_FAILURE;
}
if (mViECapture->StartCapture(mCaptureIndex, mCapability) < 0) {
return NS_ERROR_FAILURE;
}
// Wait for the condition variable, will be set in DeliverFrame.
// We use a while loop, because even if Wait() returns, it's not
// guaranteed that the condition variable changed.
// FIX: we need need a way to cancel this and to bail if it appears to not be working
// Perhaps a maximum time, though some cameras can take seconds to start. 10 seconds?
{
MonitorAutoLock lock(mMonitor);
while (mInSnapshotMode) {
lock.Wait();
}
}
// If we get here, DeliverFrame received at least one frame.
webrtc::ViEFile* vieFile = webrtc::ViEFile::GetInterface(mVideoEngine);
if (!vieFile) {
return NS_ERROR_FAILURE;
}
// Create a temporary file on the main thread and put the snapshot in it.
// See Run() in MediaEngineWebRTCVideo.h (sets mSnapshotPath).
NS_DispatchToMainThread(this, NS_DISPATCH_SYNC);
if (!mSnapshotPath) {
return NS_ERROR_FAILURE;
}
NS_ConvertUTF16toUTF8 path(*mSnapshotPath);
if (vieFile->GetCaptureDeviceSnapshot(mCaptureIndex, path.get()) < 0) {
delete mSnapshotPath;
mSnapshotPath = nullptr;
return NS_ERROR_FAILURE;
}
// Stop the camera.
mViERender->StopRender(mCaptureIndex);
mViERender->RemoveRenderer(mCaptureIndex);
nsCOMPtr<nsIFile> file;
nsresult rv = NS_NewLocalFile(*mSnapshotPath, false, getter_AddRefs(file));
delete mSnapshotPath;
mSnapshotPath = nullptr;
NS_ENSURE_SUCCESS(rv, rv);
NS_ADDREF(*aFile = new nsDOMFileFile(file));
#endif
return NS_OK;
return NS_ERROR_NOT_IMPLEMENTED;
}
/**

Просмотреть файл

@ -40,7 +40,6 @@
#include "nsJSUtils.h"
#include "nsCRT.h"
#include "nsIAuthPrompt.h"
#include "nsIScriptGlobalObjectOwner.h"
#include "nsContentCreatorFunctions.h"
#include "nsContentPolicyUtils.h"
#include "nsIDOMUserDataHandler.h"

Просмотреть файл

@ -898,7 +898,6 @@ NS_INTERFACE_MAP_BEGIN(nsDocShell)
NS_INTERFACE_MAP_ENTRY(nsIScrollable)
NS_INTERFACE_MAP_ENTRY(nsITextScroll)
NS_INTERFACE_MAP_ENTRY(nsIDocCharset)
NS_INTERFACE_MAP_ENTRY(nsIScriptGlobalObjectOwner)
NS_INTERFACE_MAP_ENTRY(nsIRefreshURI)
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
@ -3921,6 +3920,13 @@ nsDocShell::GetCurrentSHEntry(nsISHEntry** aEntry, bool* aOSHE)
return NS_OK;
}
nsIScriptGlobalObject*
nsDocShell::GetScriptGlobalObject()
{
NS_ENSURE_SUCCESS(EnsureScriptEnvironment(), nullptr);
return mScriptGlobal;
}
NS_IMETHODIMP
nsDocShell::SetDeviceSizeIsPageSize(bool aValue)
{
@ -5844,17 +5850,6 @@ nsDocShell::ScrollByPages(int32_t numPages)
return NS_OK;
}
//*****************************************************************************
// nsDocShell::nsIScriptGlobalObjectOwner
//*****************************************************************************
nsIScriptGlobalObject*
nsDocShell::GetScriptGlobalObject()
{
NS_ENSURE_SUCCESS(EnsureScriptEnvironment(), nullptr);
return mScriptGlobal;
}
//*****************************************************************************
// nsDocShell::nsIRefreshURI
//*****************************************************************************

Просмотреть файл

@ -33,7 +33,6 @@
#include "nsIDocCharset.h"
#include "nsIInterfaceRequestor.h"
#include "nsIRefreshURI.h"
#include "nsIScriptGlobalObjectOwner.h"
#include "nsIWebNavigation.h"
#include "nsIWebPageDescriptor.h"
#include "nsIWebProgressListener.h"
@ -130,7 +129,6 @@ class nsDocShell : public nsDocLoader,
public nsITextScroll,
public nsIDocCharset,
public nsIContentViewerContainer,
public nsIScriptGlobalObjectOwner,
public nsIRefreshURI,
public nsIWebProgressListener,
public nsIWebPageDescriptor,
@ -205,9 +203,6 @@ public:
nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(uint32_t aLoadType);
uint32_t ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType);
// nsIScriptGlobalObjectOwner methods
virtual nsIScriptGlobalObject* GetScriptGlobalObject();
// Don't use NS_DECL_NSILOADCONTEXT because some of nsILoadContext's methods
// are shared with nsIDocShell (appID, etc.) and can't be declared twice.
NS_IMETHOD GetAssociatedWindow(nsIDOMWindow**);

Просмотреть файл

@ -34,6 +34,7 @@ interface nsIRequest;
interface nsISHEntry;
interface nsILayoutHistoryState;
interface nsISecureBrowserUI;
interface nsIScriptGlobalObject;
interface nsIDOMStorage;
interface nsIPrincipal;
interface nsIWebBrowserPrint;
@ -43,7 +44,7 @@ interface nsIReflowObserver;
typedef unsigned long nsLoadFlags;
[scriptable, builtinclass, uuid(77aca3ee-7417-4cd2-994e-9bd95ca1d98a)]
[scriptable, builtinclass, uuid(55ca6545-7ce4-49ad-8117-8286ca9c61bb)]
interface nsIDocShell : nsIDocShellTreeItem
{
/**
@ -908,6 +909,11 @@ interface nsIDocShell : nsIDocShellTreeItem
[noscript, notxpcom] bool IsInvisible();
[noscript, notxpcom] void SetInvisible(in bool aIsInvisibleDochsell);
/**
* Get the script global for the document in this docshell.
*/
[noscript,notxpcom,nostdcall] nsIScriptGlobalObject GetScriptGlobalObject();
/**
* If deviceSizeIsPageSize is set to true, device-width/height media queries
* will be calculated from the page size, not the device size.

Просмотреть файл

@ -34,7 +34,6 @@ EXPORTS += [
'nsIScriptContext.h',
'nsIScriptExternalNameSet.h',
'nsIScriptGlobalObject.h',
'nsIScriptGlobalObjectOwner.h',
'nsIScriptNameSpaceManager.h',
'nsIScriptObjectPrincipal.h',
'nsIScriptTimeoutHandler.h',

Просмотреть файл

@ -1,36 +0,0 @@
/* -*- 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/. */
#ifndef nsIScriptGlobalObjectOwner_h__
#define nsIScriptGlobalObjectOwner_h__
#include "nsISupports.h"
class nsIScriptGlobalObject;
#define NS_ISCRIPTGLOBALOBJECTOWNER_IID \
{0xfd25ca8e, 0x6b63, 0x435f, \
{ 0xb8, 0xc6, 0xb8, 0x07, 0x68, 0xa4, 0x0a, 0xdc }}
/**
* Implemented by any object capable of supplying a nsIScriptGlobalObject.
* The implentor may create the script global object on demand.
*/
class nsIScriptGlobalObjectOwner : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTGLOBALOBJECTOWNER_IID)
/**
* Returns the script global object
*/
virtual nsIScriptGlobalObject* GetScriptGlobalObject() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptGlobalObjectOwner,
NS_ISCRIPTGLOBALOBJECTOWNER_IID)
#endif /* nsIScriptGlobalObjectOwner_h__ */

Просмотреть файл

@ -24,14 +24,9 @@ docShell.setFullscreenAllowed(infos.fullscreenAllowed);
if (!('BrowserElementIsPreloaded' in this)) {
try {
if (Services.prefs.getBoolPref("dom.mozInputMethod.enabled")) {
Services.scriptloader.loadSubScript("chrome://global/content/forms.js", global);
}
} catch (e) {
}
// Those are produc-specific files that's sometimes unavailable.
try {
Services.scriptloader.loadSubScript("chrome://browser/content/forms.js");
Services.scriptloader.loadSubScript("chrome://browser/content/ErrorPage.js");
} catch (e) {
}

Просмотреть файл

@ -9,7 +9,7 @@ this.EXPORTED_SYMBOLS = ['Keyboard'];
const Cu = Components.utils;
const Cc = Components.classes;
const Ci = Components.interfaces;
const kFormsFrameScript = 'chrome://global/content/forms.js';
const kFormsFrameScript = 'chrome://browser/content/forms.js';
Cu.import('resource://gre/modules/Services.jsm');
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
@ -64,31 +64,27 @@ this.Keyboard = {
ppmm.broadcastAsyncMessage('Keyboard:FocusChange', { 'type': 'blur' });
}
} else {
this.initFormsFrameScript(mm);
}
},
mm.addMessageListener('Forms:Input', this);
mm.addMessageListener('Forms:SelectionChange', this);
mm.addMessageListener('Forms:GetText:Result:OK', this);
mm.addMessageListener('Forms:GetText:Result:Error', this);
mm.addMessageListener('Forms:SetSelectionRange:Result:OK', this);
mm.addMessageListener('Forms:ReplaceSurroundingText:Result:OK', this);
mm.addMessageListener('Forms:SendKey:Result:OK', this);
mm.addMessageListener('Forms:SequenceError', this);
mm.addMessageListener('Forms:GetContext:Result:OK', this);
mm.addMessageListener('Forms:SetComposition:Result:OK', this);
mm.addMessageListener('Forms:EndComposition:Result:OK', this);
initFormsFrameScript: function(mm) {
mm.addMessageListener('Forms:Input', this);
mm.addMessageListener('Forms:SelectionChange', this);
mm.addMessageListener('Forms:GetText:Result:OK', this);
mm.addMessageListener('Forms:GetText:Result:Error', this);
mm.addMessageListener('Forms:SetSelectionRange:Result:OK', this);
mm.addMessageListener('Forms:ReplaceSurroundingText:Result:OK', this);
mm.addMessageListener('Forms:SendKey:Result:OK', this);
mm.addMessageListener('Forms:SequenceError', this);
mm.addMessageListener('Forms:GetContext:Result:OK', this);
mm.addMessageListener('Forms:SetComposition:Result:OK', this);
mm.addMessageListener('Forms:EndComposition:Result:OK', this);
// When not running apps OOP, we need to load forms.js here since this
// won't happen from dom/ipc/preload.js
try {
if (Services.prefs.getBoolPref("dom.ipc.tabs.disabled") === true) {
mm.loadFrameScript(kFormsFrameScript, true);
// When not running apps OOP, we need to load forms.js here since this
// won't happen from dom/ipc/preload.js
try {
if (Services.prefs.getBoolPref("dom.ipc.tabs.disabled") === true) {
mm.loadFrameScript(kFormsFrameScript, true);
}
} catch (e) {
dump('Error loading ' + kFormsFrameScript + ' as frame script: ' + e + '\n');
}
} catch (e) {
dump('Error loading ' + kFormsFrameScript + ' as frame script: ' + e + '\n');
}
},

Просмотреть файл

@ -1,6 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
toolkit.jar:
content/global/forms.js (forms.js)

Просмотреть файл

@ -87,15 +87,9 @@ const BrowserElementIsPreloaded = true;
} catch(e) {
}
try {
if (Services.prefs.getBoolPref("dom.mozInputMethod.enabled")) {
Services.scriptloader.loadSubScript("chrome://global/content/forms.js", global);
}
} catch (e) {
}
// Those are produc-specific files that's sometimes unavailable.
try {
Services.scriptloader.loadSubScript("chrome://browser/content/forms.js", global);
Services.scriptloader.loadSubScript("chrome://browser/content/ErrorPage.js", global);
} catch (e) {
}

Просмотреть файл

@ -37,7 +37,7 @@
// weak imports, and test for their presence before using them.
#if !defined(__QUICKDRAWAPI__)
typedef struct Cursor;
struct Cursor;
extern "C" void SetCursor(const Cursor * crsr) __attribute__((weak_import));
#endif /* __QUICKDRAWAPI__ */

Просмотреть файл

@ -21,7 +21,6 @@
#include "nsIURI.h"
#include "nsIScriptContext.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptGlobalObjectOwner.h"
#include "nsIPrincipal.h"
#include "nsIScriptSecurityManager.h"
#include "nsIInterfaceRequestor.h"
@ -119,22 +118,19 @@ static
nsIScriptGlobalObject* GetGlobalObject(nsIChannel* aChannel)
{
// Get the global object owner from the channel
nsCOMPtr<nsIScriptGlobalObjectOwner> globalOwner;
NS_QueryNotificationCallbacks(aChannel, globalOwner);
if (!globalOwner) {
NS_WARNING("Unable to get an nsIScriptGlobalObjectOwner from the "
"channel!");
}
if (!globalOwner) {
nsCOMPtr<nsIDocShell> docShell;
NS_QueryNotificationCallbacks(aChannel, docShell);
if (!docShell) {
NS_WARNING("Unable to get a docShell from the channel!");
return nullptr;
}
// So far so good: get the script context from its owner.
nsIScriptGlobalObject* global = globalOwner->GetScriptGlobalObject();
// So far so good: get the script global from its docshell
nsIScriptGlobalObject* global = docShell->GetScriptGlobalObject();
NS_ASSERTION(global,
"Unable to get an nsIScriptGlobalObject from the "
"ScriptGlobalObjectOwner!");
"docShell!");
return global;
}

Просмотреть файл

@ -10,7 +10,7 @@
#include "Tools.h"
#include <vector>
#include <algorithm>
#include "QuartzSupport.h"
#include "MacIOSurface.h"
using namespace std;

Просмотреть файл

@ -37,6 +37,12 @@ CGRectToRect(CGRect rect)
rect.size.height);
}
static inline Point
CGPointToPoint(CGPoint point)
{
return Point(point.x, point.y);
}
static inline void
SetStrokeOptions(CGContextRef cg, const StrokeOptions &aStrokeOptions)
{

Просмотреть файл

@ -724,14 +724,19 @@ DrawTargetCairo::CopySurface(SourceSurface *aSurface,
AutoPrepareForDrawing prep(this, mContext);
AutoClearDeviceOffset clear(aSurface);
if (!aSurface || aSurface->GetType() != SURFACE_CAIRO) {
if (!aSurface) {
gfxWarning() << "Unsupported surface type specified";
return;
}
cairo_surface_t* surf = static_cast<SourceSurfaceCairo*>(aSurface)->GetSurface();
cairo_surface_t* surf = GetCairoSurfaceForSourceSurface(aSurface);
if (!surf) {
gfxWarning() << "Unsupported surface type specified";
return;
}
CopySurfaceInternal(surf, aSource, aDest);
cairo_surface_destroy(surf);
}
void

Просмотреть файл

@ -763,26 +763,7 @@ DrawTargetD2D::CopySurface(SourceSurface *aSurface,
mRT->Clear(D2D1::ColorF(0, 0.0f));
mRT->PopAxisAlignedClip();
RefPtr<ID2D1Bitmap> bitmap;
switch (aSurface->GetType()) {
case SURFACE_D2D1_BITMAP:
{
SourceSurfaceD2D *srcSurf = static_cast<SourceSurfaceD2D*>(aSurface);
bitmap = srcSurf->GetBitmap();
}
break;
case SURFACE_D2D1_DRAWTARGET:
{
SourceSurfaceD2DTarget *srcSurf = static_cast<SourceSurfaceD2DTarget*>(aSurface);
bitmap = srcSurf->GetBitmap(mRT);
AddDependencyOnSource(srcSurf);
}
break;
default:
return;
}
RefPtr<ID2D1Bitmap> bitmap = GetBitmapForSurface(aSurface, srcRect);
if (!bitmap) {
return;
}

419
gfx/2d/MacIOSurface.cpp Normal file
Просмотреть файл

@ -0,0 +1,419 @@
#include "MacIOSurface.h"
#include <QuartzCore/QuartzCore.h>
#include <dlfcn.h>
#include "mozilla/RefPtr.h"
#include "mozilla/Assertions.h"
using namespace mozilla;
// IOSurface signatures
#define IOSURFACE_FRAMEWORK_PATH \
"/System/Library/Frameworks/IOSurface.framework/IOSurface"
#define OPENGL_FRAMEWORK_PATH \
"/System/Library/Frameworks/OpenGL.framework/OpenGL"
#define COREGRAPHICS_FRAMEWORK_PATH \
"/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/CoreGraphics"
#define GET_CONST(const_name) \
((CFStringRef*) dlsym(sIOSurfaceFramework, const_name))
#define GET_IOSYM(dest,sym_name) \
(typeof(dest)) dlsym(sIOSurfaceFramework, sym_name)
#define GET_CGLSYM(dest,sym_name) \
(typeof(dest)) dlsym(sOpenGLFramework, sym_name)
#define GET_CGSYM(dest,sym_name) \
(typeof(dest)) dlsym(sCoreGraphicsFramework, sym_name)
MacIOSurfaceLib::LibraryUnloader MacIOSurfaceLib::sLibraryUnloader;
bool MacIOSurfaceLib::isLoaded = false;
void* MacIOSurfaceLib::sIOSurfaceFramework;
void* MacIOSurfaceLib::sOpenGLFramework;
void* MacIOSurfaceLib::sCoreGraphicsFramework;
IOSurfaceCreateFunc MacIOSurfaceLib::sCreate;
IOSurfaceGetIDFunc MacIOSurfaceLib::sGetID;
IOSurfaceLookupFunc MacIOSurfaceLib::sLookup;
IOSurfaceGetBaseAddressFunc MacIOSurfaceLib::sGetBaseAddress;
IOSurfaceGetWidthFunc MacIOSurfaceLib::sWidth;
IOSurfaceGetHeightFunc MacIOSurfaceLib::sHeight;
IOSurfaceGetBytesPerRowFunc MacIOSurfaceLib::sBytesPerRow;
IOSurfaceLockFunc MacIOSurfaceLib::sLock;
IOSurfaceUnlockFunc MacIOSurfaceLib::sUnlock;
CGLTexImageIOSurface2DFunc MacIOSurfaceLib::sTexImage;
IOSurfaceContextCreateFunc MacIOSurfaceLib::sIOSurfaceContextCreate;
IOSurfaceContextCreateImageFunc MacIOSurfaceLib::sIOSurfaceContextCreateImage;
IOSurfaceContextGetSurfaceFunc MacIOSurfaceLib::sIOSurfaceContextGetSurface;
unsigned int (*MacIOSurfaceLib::sCGContextGetTypePtr) (CGContextRef) = nullptr;
CFStringRef MacIOSurfaceLib::kPropWidth;
CFStringRef MacIOSurfaceLib::kPropHeight;
CFStringRef MacIOSurfaceLib::kPropBytesPerElem;
CFStringRef MacIOSurfaceLib::kPropBytesPerRow;
CFStringRef MacIOSurfaceLib::kPropIsGlobal;
bool MacIOSurfaceLib::isInit() {
// Guard against trying to reload the library
// if it is not available.
if (!isLoaded)
LoadLibrary();
MOZ_ASSERT(sIOSurfaceFramework);
return sIOSurfaceFramework;
}
IOSurfacePtr MacIOSurfaceLib::IOSurfaceCreate(CFDictionaryRef properties) {
return sCreate(properties);
}
IOSurfacePtr MacIOSurfaceLib::IOSurfaceLookup(IOSurfaceID aIOSurfaceID) {
return sLookup(aIOSurfaceID);
}
IOSurfaceID MacIOSurfaceLib::IOSurfaceGetID(IOSurfacePtr aIOSurfacePtr) {
return sGetID(aIOSurfacePtr);
}
void* MacIOSurfaceLib::IOSurfaceGetBaseAddress(IOSurfacePtr aIOSurfacePtr) {
return sGetBaseAddress(aIOSurfacePtr);
}
size_t MacIOSurfaceLib::IOSurfaceGetWidth(IOSurfacePtr aIOSurfacePtr) {
return sWidth(aIOSurfacePtr);
}
size_t MacIOSurfaceLib::IOSurfaceGetHeight(IOSurfacePtr aIOSurfacePtr) {
return sHeight(aIOSurfacePtr);
}
size_t MacIOSurfaceLib::IOSurfaceGetBytesPerRow(IOSurfacePtr aIOSurfacePtr) {
return sBytesPerRow(aIOSurfacePtr);
}
IOReturn MacIOSurfaceLib::IOSurfaceLock(IOSurfacePtr aIOSurfacePtr,
uint32_t options, uint32_t *seed) {
return sLock(aIOSurfacePtr, options, seed);
}
IOReturn MacIOSurfaceLib::IOSurfaceUnlock(IOSurfacePtr aIOSurfacePtr,
uint32_t options, uint32_t *seed) {
return sUnlock(aIOSurfacePtr, options, seed);
}
CGLError MacIOSurfaceLib::CGLTexImageIOSurface2D(CGLContextObj ctxt,
GLenum target, GLenum internalFormat,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
IOSurfacePtr ioSurface, GLuint plane) {
return sTexImage(ctxt, target, internalFormat, width, height,
format, type, ioSurface, plane);
}
CGContextRef MacIOSurfaceLib::IOSurfaceContextCreate(IOSurfacePtr aIOSurfacePtr,
unsigned aWidth, unsigned aHeight,
unsigned aBitsPerComponent, unsigned aBytes,
CGColorSpaceRef aColorSpace, CGBitmapInfo bitmapInfo) {
if (!sIOSurfaceContextCreate)
return nullptr;
return sIOSurfaceContextCreate(aIOSurfacePtr, aWidth, aHeight, aBitsPerComponent, aBytes, aColorSpace, bitmapInfo);
}
CGImageRef MacIOSurfaceLib::IOSurfaceContextCreateImage(CGContextRef aContext) {
if (!sIOSurfaceContextCreateImage)
return nullptr;
return sIOSurfaceContextCreateImage(aContext);
}
IOSurfacePtr MacIOSurfaceLib::IOSurfaceContextGetSurface(CGContextRef aContext) {
if (!sIOSurfaceContextGetSurface)
return nullptr;
return sIOSurfaceContextGetSurface(aContext);
}
CFStringRef MacIOSurfaceLib::GetIOConst(const char* symbole) {
CFStringRef *address = (CFStringRef*)dlsym(sIOSurfaceFramework, symbole);
if (!address)
return nullptr;
return *address;
}
void MacIOSurfaceLib::LoadLibrary() {
if (isLoaded) {
return;
}
isLoaded = true;
sIOSurfaceFramework = dlopen(IOSURFACE_FRAMEWORK_PATH,
RTLD_LAZY | RTLD_LOCAL);
sOpenGLFramework = dlopen(OPENGL_FRAMEWORK_PATH,
RTLD_LAZY | RTLD_LOCAL);
sCoreGraphicsFramework = dlopen(COREGRAPHICS_FRAMEWORK_PATH,
RTLD_LAZY | RTLD_LOCAL);
if (!sIOSurfaceFramework || !sOpenGLFramework || !sCoreGraphicsFramework) {
if (sIOSurfaceFramework)
dlclose(sIOSurfaceFramework);
if (sOpenGLFramework)
dlclose(sOpenGLFramework);
if (sCoreGraphicsFramework)
dlclose(sCoreGraphicsFramework);
sIOSurfaceFramework = nullptr;
sOpenGLFramework = nullptr;
sCoreGraphicsFramework = nullptr;
return;
}
kPropWidth = GetIOConst("kIOSurfaceWidth");
kPropHeight = GetIOConst("kIOSurfaceHeight");
kPropBytesPerElem = GetIOConst("kIOSurfaceBytesPerElement");
kPropBytesPerRow = GetIOConst("kIOSurfaceBytesPerRow");
kPropIsGlobal = GetIOConst("kIOSurfaceIsGlobal");
sCreate = GET_IOSYM(sCreate, "IOSurfaceCreate");
sGetID = GET_IOSYM(sGetID, "IOSurfaceGetID");
sWidth = GET_IOSYM(sWidth, "IOSurfaceGetWidth");
sHeight = GET_IOSYM(sHeight, "IOSurfaceGetHeight");
sBytesPerRow = GET_IOSYM(sBytesPerRow, "IOSurfaceGetBytesPerRow");
sLookup = GET_IOSYM(sLookup, "IOSurfaceLookup");
sLock = GET_IOSYM(sLock, "IOSurfaceLock");
sUnlock = GET_IOSYM(sUnlock, "IOSurfaceUnlock");
sGetBaseAddress = GET_IOSYM(sGetBaseAddress, "IOSurfaceGetBaseAddress");
sTexImage = GET_CGLSYM(sTexImage, "CGLTexImageIOSurface2D");
sCGContextGetTypePtr = (unsigned int (*)(CGContext*))dlsym(RTLD_DEFAULT, "CGContextGetType");
// Optional symbols
sIOSurfaceContextCreate = GET_CGSYM(sIOSurfaceContextCreate, "CGIOSurfaceContextCreate");
sIOSurfaceContextCreateImage = GET_CGSYM(sIOSurfaceContextCreateImage, "CGIOSurfaceContextCreateImage");
sIOSurfaceContextGetSurface = GET_CGSYM(sIOSurfaceContextGetSurface, "CGIOSurfaceContextGetSurface");
if (!sCreate || !sGetID || !sLookup || !sTexImage || !sGetBaseAddress ||
!kPropWidth || !kPropHeight || !kPropBytesPerElem || !kPropIsGlobal ||
!sLock || !sUnlock || !sWidth || !sHeight || !kPropBytesPerRow ||
!sBytesPerRow) {
CloseLibrary();
}
}
void MacIOSurfaceLib::CloseLibrary() {
if (sIOSurfaceFramework) {
dlclose(sIOSurfaceFramework);
}
if (sOpenGLFramework) {
dlclose(sOpenGLFramework);
}
sIOSurfaceFramework = nullptr;
sOpenGLFramework = nullptr;
}
MacIOSurface::~MacIOSurface() {
CFRelease(mIOSurfacePtr);
}
TemporaryRef<MacIOSurface> MacIOSurface::CreateIOSurface(int aWidth, int aHeight,
double aContentsScaleFactor,
bool aHasAlpha) {
if (!MacIOSurfaceLib::isInit() || aContentsScaleFactor <= 0)
return nullptr;
CFMutableDictionaryRef props = ::CFDictionaryCreateMutable(
kCFAllocatorDefault, 4,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
if (!props)
return nullptr;
int32_t bytesPerElem = 4;
size_t intScaleFactor = ceil(aContentsScaleFactor);
aWidth *= intScaleFactor;
aHeight *= intScaleFactor;
CFNumberRef cfWidth = ::CFNumberCreate(nullptr, kCFNumberSInt32Type, &aWidth);
CFNumberRef cfHeight = ::CFNumberCreate(nullptr, kCFNumberSInt32Type, &aHeight);
CFNumberRef cfBytesPerElem = ::CFNumberCreate(nullptr, kCFNumberSInt32Type, &bytesPerElem);
::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropWidth,
cfWidth);
::CFRelease(cfWidth);
::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropHeight,
cfHeight);
::CFRelease(cfHeight);
::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropBytesPerElem,
cfBytesPerElem);
::CFRelease(cfBytesPerElem);
::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropIsGlobal,
kCFBooleanTrue);
IOSurfacePtr surfaceRef = MacIOSurfaceLib::IOSurfaceCreate(props);
::CFRelease(props);
if (!surfaceRef)
return nullptr;
RefPtr<MacIOSurface> ioSurface = new MacIOSurface(surfaceRef, aContentsScaleFactor, aHasAlpha);
if (!ioSurface) {
::CFRelease(surfaceRef);
return nullptr;
}
return ioSurface.forget();
}
TemporaryRef<MacIOSurface> MacIOSurface::LookupSurface(IOSurfaceID aIOSurfaceID,
double aContentsScaleFactor,
bool aHasAlpha) {
if (!MacIOSurfaceLib::isInit() || aContentsScaleFactor <= 0)
return nullptr;
IOSurfacePtr surfaceRef = MacIOSurfaceLib::IOSurfaceLookup(aIOSurfaceID);
if (!surfaceRef)
return nullptr;
RefPtr<MacIOSurface> ioSurface = new MacIOSurface(surfaceRef, aContentsScaleFactor, aHasAlpha);
if (!ioSurface) {
::CFRelease(surfaceRef);
return nullptr;
}
return ioSurface.forget();
}
IOSurfaceID MacIOSurface::GetIOSurfaceID() {
return MacIOSurfaceLib::IOSurfaceGetID(mIOSurfacePtr);
}
void* MacIOSurface::GetBaseAddress() {
return MacIOSurfaceLib::IOSurfaceGetBaseAddress(mIOSurfacePtr);
}
size_t MacIOSurface::GetWidth() {
size_t intScaleFactor = ceil(mContentsScaleFactor);
return GetDevicePixelWidth() / intScaleFactor;
}
size_t MacIOSurface::GetHeight() {
size_t intScaleFactor = ceil(mContentsScaleFactor);
return GetDevicePixelHeight() / intScaleFactor;
}
size_t MacIOSurface::GetDevicePixelWidth() {
return MacIOSurfaceLib::IOSurfaceGetWidth(mIOSurfacePtr);
}
size_t MacIOSurface::GetDevicePixelHeight() {
return MacIOSurfaceLib::IOSurfaceGetHeight(mIOSurfacePtr);
}
size_t MacIOSurface::GetBytesPerRow() {
return MacIOSurfaceLib::IOSurfaceGetBytesPerRow(mIOSurfacePtr);
}
#define READ_ONLY 0x1
void MacIOSurface::Lock() {
MacIOSurfaceLib::IOSurfaceLock(mIOSurfacePtr, READ_ONLY, nullptr);
}
void MacIOSurface::Unlock() {
MacIOSurfaceLib::IOSurfaceUnlock(mIOSurfacePtr, READ_ONLY, nullptr);
}
#include "SourceSurfaceRawData.h"
using mozilla::gfx::SourceSurface;
using mozilla::gfx::SourceSurfaceRawData;
using mozilla::gfx::IntSize;
using mozilla::gfx::SurfaceFormat;
TemporaryRef<SourceSurface>
MacIOSurface::GetAsSurface() {
Lock();
size_t bytesPerRow = GetBytesPerRow();
size_t ioWidth = GetDevicePixelWidth();
size_t ioHeight = GetDevicePixelHeight();
unsigned char* ioData = (unsigned char*)GetBaseAddress();
unsigned char* dataCpy = (unsigned char*)malloc(bytesPerRow*ioHeight);
for (size_t i = 0; i < ioHeight; i++) {
memcpy(dataCpy + i * bytesPerRow,
ioData + i * bytesPerRow, ioWidth * 4);
}
Unlock();
SurfaceFormat format = HasAlpha() ? mozilla::gfx::FORMAT_B8G8R8A8 :
mozilla::gfx::FORMAT_B8G8R8X8;
RefPtr<SourceSurfaceRawData> surf = new SourceSurfaceRawData();
surf->InitWrappingData(dataCpy, IntSize(ioWidth, ioHeight), bytesPerRow, format, true);
return surf.forget();
}
CGLError
MacIOSurface::CGLTexImageIOSurface2D(CGLContextObj ctx)
{
return MacIOSurfaceLib::CGLTexImageIOSurface2D(ctx,
GL_TEXTURE_RECTANGLE_ARB,
HasAlpha() ? GL_RGBA : GL_RGB,
GetDevicePixelWidth(),
GetDevicePixelHeight(),
GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV,
mIOSurfacePtr, 0);
}
static
CGColorSpaceRef CreateSystemColorSpace() {
CGColorSpaceRef cspace = ::CGDisplayCopyColorSpace(::CGMainDisplayID());
if (!cspace) {
cspace = ::CGColorSpaceCreateDeviceRGB();
}
return cspace;
}
CGContextRef MacIOSurface::CreateIOSurfaceContext() {
CGColorSpaceRef cspace = CreateSystemColorSpace();
CGContextRef ref = MacIOSurfaceLib::IOSurfaceContextCreate(mIOSurfacePtr,
GetDevicePixelWidth(),
GetDevicePixelHeight(),
8, 32, cspace, 0x2002);
::CGColorSpaceRelease(cspace);
return ref;
}
CGImageRef MacIOSurface::CreateImageFromIOSurfaceContext(CGContextRef aContext) {
if (!MacIOSurfaceLib::isInit())
return nullptr;
return MacIOSurfaceLib::IOSurfaceContextCreateImage(aContext);
}
TemporaryRef<MacIOSurface> MacIOSurface::IOSurfaceContextGetSurface(CGContextRef aContext,
double aContentsScaleFactor,
bool aHasAlpha) {
if (!MacIOSurfaceLib::isInit() || aContentsScaleFactor <= 0)
return nullptr;
IOSurfacePtr surfaceRef = MacIOSurfaceLib::IOSurfaceContextGetSurface(aContext);
if (!surfaceRef)
return nullptr;
// Retain the IOSurface because MacIOSurface will release it
CFRetain(surfaceRef);
RefPtr<MacIOSurface> ioSurface = new MacIOSurface(surfaceRef, aContentsScaleFactor, aHasAlpha);
if (!ioSurface) {
::CFRelease(surfaceRef);
return nullptr;
}
return ioSurface.forget();
}
CGContextType GetContextType(CGContextRef ref)
{
if (!MacIOSurfaceLib::isInit() || !MacIOSurfaceLib::sCGContextGetTypePtr)
return CG_CONTEXT_TYPE_UNKNOWN;
unsigned int type = MacIOSurfaceLib::sCGContextGetTypePtr(ref);
if (type == CG_CONTEXT_TYPE_BITMAP) {
return CG_CONTEXT_TYPE_BITMAP;
} else if (type == CG_CONTEXT_TYPE_IOSURFACE) {
return CG_CONTEXT_TYPE_IOSURFACE;
} else {
return CG_CONTEXT_TYPE_UNKNOWN;
}
}

Просмотреть файл

@ -7,6 +7,37 @@
#ifndef MacIOSurface_h__
#define MacIOSurface_h__
#ifdef XP_MACOSX
#include <QuartzCore/QuartzCore.h>
#include <dlfcn.h>
#include "mozilla/RefPtr.h"
typedef CFTypeRef IOSurfacePtr;
typedef IOSurfacePtr (*IOSurfaceCreateFunc) (CFDictionaryRef properties);
typedef IOSurfacePtr (*IOSurfaceLookupFunc) (uint32_t io_surface_id);
typedef IOSurfaceID (*IOSurfaceGetIDFunc) (CFTypeRef io_surface);
typedef IOReturn (*IOSurfaceLockFunc) (CFTypeRef io_surface,
uint32_t options,
uint32_t *seed);
typedef IOReturn (*IOSurfaceUnlockFunc) (CFTypeRef io_surface,
uint32_t options,
uint32_t *seed);
typedef void* (*IOSurfaceGetBaseAddressFunc) (CFTypeRef io_surface);
typedef size_t (*IOSurfaceGetWidthFunc) (IOSurfacePtr io_surface);
typedef size_t (*IOSurfaceGetHeightFunc) (IOSurfacePtr io_surface);
typedef size_t (*IOSurfaceGetBytesPerRowFunc) (IOSurfacePtr io_surface);
typedef CGLError (*CGLTexImageIOSurface2DFunc) (CGLContextObj ctxt,
GLenum target, GLenum internalFormat,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
IOSurfacePtr ioSurface, GLuint plane);
typedef CGContextRef (*IOSurfaceContextCreateFunc)(CFTypeRef io_surface,
unsigned width, unsigned height,
unsigned bitsPerComponent, unsigned bytes,
CGColorSpaceRef colorSpace, CGBitmapInfo bitmapInfo);
typedef CGImageRef (*IOSurfaceContextCreateImageFunc)(CGContextRef ref);
typedef IOSurfacePtr (*IOSurfaceContextGetSurfaceFunc)(CGContextRef ref);
#import <OpenGL/OpenGL.h>
#include "2D.h"
@ -20,6 +51,15 @@ typedef struct CGContext* CGContextRef;
typedef struct CGImage* CGImageRef;
typedef uint32_t IOSurfaceID;
enum CGContextType {
CG_CONTEXT_TYPE_UNKNOWN = 0,
// These are found by inspection, it's possible they could be changed
CG_CONTEXT_TYPE_BITMAP = 4,
CG_CONTEXT_TYPE_IOSURFACE = 8
};
CGContextType GetContextType(CGContextRef ref);
class MacIOSurface : public mozilla::RefCounted<MacIOSurface> {
public:
typedef mozilla::gfx::SourceSurface SourceSurface;
@ -52,7 +92,7 @@ public:
bool HasAlpha() { return mHasAlpha; }
// We would like to forward declare NSOpenGLContext, but it is an @interface
// and this file is also used from c++, so we use a void *.
CGLError CGLTexImageIOSurface2D(void *ctxt);
CGLError CGLTexImageIOSurface2D(CGLContextObj ctxt);
mozilla::TemporaryRef<SourceSurface> GetAsSurface();
CGContextRef CreateIOSurfaceContext();
@ -69,5 +109,67 @@ private:
bool mHasAlpha;
};
class MacIOSurfaceLib: public MacIOSurface {
public:
static void *sIOSurfaceFramework;
static void *sOpenGLFramework;
static void *sCoreGraphicsFramework;
static bool isLoaded;
static IOSurfaceCreateFunc sCreate;
static IOSurfaceGetIDFunc sGetID;
static IOSurfaceLookupFunc sLookup;
static IOSurfaceGetBaseAddressFunc sGetBaseAddress;
static IOSurfaceLockFunc sLock;
static IOSurfaceUnlockFunc sUnlock;
static IOSurfaceGetWidthFunc sWidth;
static IOSurfaceGetHeightFunc sHeight;
static IOSurfaceGetBytesPerRowFunc sBytesPerRow;
static CGLTexImageIOSurface2DFunc sTexImage;
static IOSurfaceContextCreateFunc sIOSurfaceContextCreate;
static IOSurfaceContextCreateImageFunc sIOSurfaceContextCreateImage;
static IOSurfaceContextGetSurfaceFunc sIOSurfaceContextGetSurface;
static CFStringRef kPropWidth;
static CFStringRef kPropHeight;
static CFStringRef kPropBytesPerElem;
static CFStringRef kPropBytesPerRow;
static CFStringRef kPropIsGlobal;
static bool isInit();
static CFStringRef GetIOConst(const char* symbole);
static IOSurfacePtr IOSurfaceCreate(CFDictionaryRef properties);
static IOSurfacePtr IOSurfaceLookup(IOSurfaceID aIOSurfaceID);
static IOSurfaceID IOSurfaceGetID(IOSurfacePtr aIOSurfacePtr);
static void *IOSurfaceGetBaseAddress(IOSurfacePtr aIOSurfacePtr);
static size_t IOSurfaceGetWidth(IOSurfacePtr aIOSurfacePtr);
static size_t IOSurfaceGetHeight(IOSurfacePtr aIOSurfacePtr);
static size_t IOSurfaceGetBytesPerRow(IOSurfacePtr aIOSurfacePtr);
static IOReturn IOSurfaceLock(IOSurfacePtr aIOSurfacePtr,
uint32_t options, uint32_t *seed);
static IOReturn IOSurfaceUnlock(IOSurfacePtr aIOSurfacePtr,
uint32_t options, uint32_t *seed);
static CGLError CGLTexImageIOSurface2D(CGLContextObj ctxt,
GLenum target, GLenum internalFormat,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
IOSurfacePtr ioSurface, GLuint plane);
static CGContextRef IOSurfaceContextCreate(IOSurfacePtr aIOSurfacePtr,
unsigned aWidth, unsigned aHeight,
unsigned aBitsPerCompoent, unsigned aBytes,
CGColorSpaceRef aColorSpace, CGBitmapInfo bitmapInfo);
static CGImageRef IOSurfaceContextCreateImage(CGContextRef ref);
static IOSurfacePtr IOSurfaceContextGetSurface(CGContextRef ref);
static unsigned int (*sCGContextGetTypePtr) (CGContextRef);
static void LoadLibrary();
static void CloseLibrary();
// Static deconstructor
static class LibraryUnloader {
public:
~LibraryUnloader() {
CloseLibrary();
}
} sLibraryUnloader;
};
#endif
#endif

Просмотреть файл

@ -165,6 +165,54 @@ PathCG::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule) c
return builder;
}
static void
StreamPathToSinkApplierFunc(void *vinfo, const CGPathElement *element)
{
PathSink *sink = reinterpret_cast<PathSink*>(vinfo);
switch (element->type) {
case kCGPathElementMoveToPoint:
{
CGPoint pt = element->points[0];
sink->MoveTo(CGPointToPoint(pt));
break;
}
case kCGPathElementAddLineToPoint:
{
CGPoint pt = element->points[0];
sink->LineTo(CGPointToPoint(pt));
break;
}
case kCGPathElementAddQuadCurveToPoint:
{
CGPoint cpt = element->points[0];
CGPoint pt = element->points[1];
sink->QuadraticBezierTo(CGPointToPoint(cpt),
CGPointToPoint(pt));
break;
}
case kCGPathElementAddCurveToPoint:
{
CGPoint cpt1 = element->points[0];
CGPoint cpt2 = element->points[1];
CGPoint pt = element->points[2];
sink->BezierTo(CGPointToPoint(cpt1),
CGPointToPoint(cpt2),
CGPointToPoint(pt));
break;
}
case kCGPathElementCloseSubpath:
{
sink->Close();
break;
}
}
}
void
PathCG::StreamToSink(PathSink *aSink) const
{
CGPathApply(mPath, aSink, StreamPathToSinkApplierFunc);
}
bool
PathCG::ContainsPoint(const Point &aPoint, const Matrix &aTransform) const

Просмотреть файл

@ -85,7 +85,7 @@ public:
virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
const Matrix &aTransform = Matrix()) const;
virtual void StreamToSink(PathSink *aSink) const { MOZ_ASSERT(false); }
virtual void StreamToSink(PathSink *aSink) const;
virtual FillRule GetFillRule() const { return mFillRule; }

Просмотреть файл

@ -93,15 +93,6 @@ private:
double mContentsScaleFactor;
};
enum CGContextType {
CG_CONTEXT_TYPE_UNKNOWN = 0,
// These are found by inspection, it's possible they could be changed
CG_CONTEXT_TYPE_BITMAP = 4,
CG_CONTEXT_TYPE_IOSURFACE = 8
};
CGContextType GetContextType(CGContextRef ref);
#endif // XP_MACOSX
#endif // nsCoreAnimationSupport_h__

Просмотреть файл

@ -6,6 +6,7 @@
#include "QuartzSupport.h"
#include "nsDebug.h"
#include "MacIOSurface.h"
#import <QuartzCore/QuartzCore.h>
#import <AppKit/NSOpenGL.h>
@ -27,436 +28,6 @@
using mozilla::RefPtr;
using mozilla::TemporaryRef;
// IOSurface signatures
typedef CFTypeRef IOSurfacePtr;
typedef IOSurfacePtr (*IOSurfaceCreateFunc) (CFDictionaryRef properties);
typedef IOSurfacePtr (*IOSurfaceLookupFunc) (uint32_t io_surface_id);
typedef IOSurfaceID (*IOSurfaceGetIDFunc) (CFTypeRef io_surface);
typedef IOReturn (*IOSurfaceLockFunc) (CFTypeRef io_surface,
uint32_t options,
uint32_t *seed);
typedef IOReturn (*IOSurfaceUnlockFunc) (CFTypeRef io_surface,
uint32_t options,
uint32_t *seed);
typedef void* (*IOSurfaceGetBaseAddressFunc) (CFTypeRef io_surface);
typedef size_t (*IOSurfaceGetWidthFunc) (IOSurfacePtr io_surface);
typedef size_t (*IOSurfaceGetHeightFunc) (IOSurfacePtr io_surface);
typedef size_t (*IOSurfaceGetBytesPerRowFunc) (IOSurfacePtr io_surface);
typedef CGLError (*CGLTexImageIOSurface2DFunc) (CGLContextObj ctxt,
GLenum target, GLenum internalFormat,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
IOSurfacePtr ioSurface, GLuint plane);
typedef CGContextRef (*IOSurfaceContextCreateFunc)(CFTypeRef io_surface,
unsigned width, unsigned height,
unsigned bitsPerComponent, unsigned bytes,
CGColorSpaceRef colorSpace, CGBitmapInfo bitmapInfo);
typedef CGImageRef (*IOSurfaceContextCreateImageFunc)(CGContextRef ref);
typedef IOSurfacePtr (*IOSurfaceContextGetSurfaceFunc)(CGContextRef ref);
#define GET_CONST(const_name) \
((CFStringRef*) dlsym(sIOSurfaceFramework, const_name))
#define GET_IOSYM(dest,sym_name) \
(typeof(dest)) dlsym(sIOSurfaceFramework, sym_name)
#define GET_CGLSYM(dest,sym_name) \
(typeof(dest)) dlsym(sOpenGLFramework, sym_name)
#define GET_CGSYM(dest,sym_name) \
(typeof(dest)) dlsym(sCoreGraphicsFramework, sym_name)
class MacIOSurfaceLib: public MacIOSurface {
public:
static void *sIOSurfaceFramework;
static void *sOpenGLFramework;
static void *sCoreGraphicsFramework;
static bool isLoaded;
static IOSurfaceCreateFunc sCreate;
static IOSurfaceGetIDFunc sGetID;
static IOSurfaceLookupFunc sLookup;
static IOSurfaceGetBaseAddressFunc sGetBaseAddress;
static IOSurfaceLockFunc sLock;
static IOSurfaceUnlockFunc sUnlock;
static IOSurfaceGetWidthFunc sWidth;
static IOSurfaceGetHeightFunc sHeight;
static IOSurfaceGetBytesPerRowFunc sBytesPerRow;
static CGLTexImageIOSurface2DFunc sTexImage;
static IOSurfaceContextCreateFunc sIOSurfaceContextCreate;
static IOSurfaceContextCreateImageFunc sIOSurfaceContextCreateImage;
static IOSurfaceContextGetSurfaceFunc sIOSurfaceContextGetSurface;
static CFStringRef kPropWidth;
static CFStringRef kPropHeight;
static CFStringRef kPropBytesPerElem;
static CFStringRef kPropBytesPerRow;
static CFStringRef kPropIsGlobal;
static bool isInit();
static CFStringRef GetIOConst(const char* symbole);
static IOSurfacePtr IOSurfaceCreate(CFDictionaryRef properties);
static IOSurfacePtr IOSurfaceLookup(IOSurfaceID aIOSurfaceID);
static IOSurfaceID IOSurfaceGetID(IOSurfacePtr aIOSurfacePtr);
static void *IOSurfaceGetBaseAddress(IOSurfacePtr aIOSurfacePtr);
static size_t IOSurfaceGetWidth(IOSurfacePtr aIOSurfacePtr);
static size_t IOSurfaceGetHeight(IOSurfacePtr aIOSurfacePtr);
static size_t IOSurfaceGetBytesPerRow(IOSurfacePtr aIOSurfacePtr);
static IOReturn IOSurfaceLock(IOSurfacePtr aIOSurfacePtr,
uint32_t options, uint32_t *seed);
static IOReturn IOSurfaceUnlock(IOSurfacePtr aIOSurfacePtr,
uint32_t options, uint32_t *seed);
static CGLError CGLTexImageIOSurface2D(CGLContextObj ctxt,
GLenum target, GLenum internalFormat,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
IOSurfacePtr ioSurface, GLuint plane);
static CGContextRef IOSurfaceContextCreate(IOSurfacePtr aIOSurfacePtr,
unsigned aWidth, unsigned aHeight,
unsigned aBitsPerCompoent, unsigned aBytes,
CGColorSpaceRef aColorSpace, CGBitmapInfo bitmapInfo);
static CGImageRef IOSurfaceContextCreateImage(CGContextRef ref);
static IOSurfacePtr IOSurfaceContextGetSurface(CGContextRef ref);
static unsigned int (*sCGContextGetTypePtr) (CGContextRef);
static void LoadLibrary();
static void CloseLibrary();
// Static deconstructor
static class LibraryUnloader {
public:
~LibraryUnloader() {
CloseLibrary();
}
} sLibraryUnloader;
};
MacIOSurfaceLib::LibraryUnloader MacIOSurfaceLib::sLibraryUnloader;
bool MacIOSurfaceLib::isLoaded = false;
void* MacIOSurfaceLib::sIOSurfaceFramework;
void* MacIOSurfaceLib::sOpenGLFramework;
void* MacIOSurfaceLib::sCoreGraphicsFramework;
IOSurfaceCreateFunc MacIOSurfaceLib::sCreate;
IOSurfaceGetIDFunc MacIOSurfaceLib::sGetID;
IOSurfaceLookupFunc MacIOSurfaceLib::sLookup;
IOSurfaceGetBaseAddressFunc MacIOSurfaceLib::sGetBaseAddress;
IOSurfaceGetWidthFunc MacIOSurfaceLib::sWidth;
IOSurfaceGetHeightFunc MacIOSurfaceLib::sHeight;
IOSurfaceGetBytesPerRowFunc MacIOSurfaceLib::sBytesPerRow;
IOSurfaceLockFunc MacIOSurfaceLib::sLock;
IOSurfaceUnlockFunc MacIOSurfaceLib::sUnlock;
CGLTexImageIOSurface2DFunc MacIOSurfaceLib::sTexImage;
IOSurfaceContextCreateFunc MacIOSurfaceLib::sIOSurfaceContextCreate;
IOSurfaceContextCreateImageFunc MacIOSurfaceLib::sIOSurfaceContextCreateImage;
IOSurfaceContextGetSurfaceFunc MacIOSurfaceLib::sIOSurfaceContextGetSurface;
unsigned int (*MacIOSurfaceLib::sCGContextGetTypePtr) (CGContextRef) = nullptr;
CFStringRef MacIOSurfaceLib::kPropWidth;
CFStringRef MacIOSurfaceLib::kPropHeight;
CFStringRef MacIOSurfaceLib::kPropBytesPerElem;
CFStringRef MacIOSurfaceLib::kPropBytesPerRow;
CFStringRef MacIOSurfaceLib::kPropIsGlobal;
bool MacIOSurfaceLib::isInit() {
// Guard against trying to reload the library
// if it is not available.
if (!isLoaded)
LoadLibrary();
if (!sIOSurfaceFramework) {
NS_ERROR("MacIOSurfaceLib failed to initialize");
}
return sIOSurfaceFramework;
}
IOSurfacePtr MacIOSurfaceLib::IOSurfaceCreate(CFDictionaryRef properties) {
return sCreate(properties);
}
IOSurfacePtr MacIOSurfaceLib::IOSurfaceLookup(IOSurfaceID aIOSurfaceID) {
return sLookup(aIOSurfaceID);
}
IOSurfaceID MacIOSurfaceLib::IOSurfaceGetID(IOSurfacePtr aIOSurfacePtr) {
return sGetID(aIOSurfacePtr);
}
void* MacIOSurfaceLib::IOSurfaceGetBaseAddress(IOSurfacePtr aIOSurfacePtr) {
return sGetBaseAddress(aIOSurfacePtr);
}
size_t MacIOSurfaceLib::IOSurfaceGetWidth(IOSurfacePtr aIOSurfacePtr) {
return sWidth(aIOSurfacePtr);
}
size_t MacIOSurfaceLib::IOSurfaceGetHeight(IOSurfacePtr aIOSurfacePtr) {
return sHeight(aIOSurfacePtr);
}
size_t MacIOSurfaceLib::IOSurfaceGetBytesPerRow(IOSurfacePtr aIOSurfacePtr) {
return sBytesPerRow(aIOSurfacePtr);
}
IOReturn MacIOSurfaceLib::IOSurfaceLock(IOSurfacePtr aIOSurfacePtr,
uint32_t options, uint32_t *seed) {
return sLock(aIOSurfacePtr, options, seed);
}
IOReturn MacIOSurfaceLib::IOSurfaceUnlock(IOSurfacePtr aIOSurfacePtr,
uint32_t options, uint32_t *seed) {
return sUnlock(aIOSurfacePtr, options, seed);
}
CGLError MacIOSurfaceLib::CGLTexImageIOSurface2D(CGLContextObj ctxt,
GLenum target, GLenum internalFormat,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
IOSurfacePtr ioSurface, GLuint plane) {
return sTexImage(ctxt, target, internalFormat, width, height,
format, type, ioSurface, plane);
}
CGContextRef MacIOSurfaceLib::IOSurfaceContextCreate(IOSurfacePtr aIOSurfacePtr,
unsigned aWidth, unsigned aHeight,
unsigned aBitsPerComponent, unsigned aBytes,
CGColorSpaceRef aColorSpace, CGBitmapInfo bitmapInfo) {
if (!sIOSurfaceContextCreate)
return nullptr;
return sIOSurfaceContextCreate(aIOSurfacePtr, aWidth, aHeight, aBitsPerComponent, aBytes, aColorSpace, bitmapInfo);
}
CGImageRef MacIOSurfaceLib::IOSurfaceContextCreateImage(CGContextRef aContext) {
if (!sIOSurfaceContextCreateImage)
return nullptr;
return sIOSurfaceContextCreateImage(aContext);
}
IOSurfacePtr MacIOSurfaceLib::IOSurfaceContextGetSurface(CGContextRef aContext) {
if (!sIOSurfaceContextGetSurface)
return nullptr;
return sIOSurfaceContextGetSurface(aContext);
}
CFStringRef MacIOSurfaceLib::GetIOConst(const char* symbole) {
CFStringRef *address = (CFStringRef*)dlsym(sIOSurfaceFramework, symbole);
if (!address)
return nullptr;
return *address;
}
void MacIOSurfaceLib::LoadLibrary() {
if (isLoaded) {
return;
}
isLoaded = true;
sIOSurfaceFramework = dlopen(IOSURFACE_FRAMEWORK_PATH,
RTLD_LAZY | RTLD_LOCAL);
sOpenGLFramework = dlopen(OPENGL_FRAMEWORK_PATH,
RTLD_LAZY | RTLD_LOCAL);
sCoreGraphicsFramework = dlopen(COREGRAPHICS_FRAMEWORK_PATH,
RTLD_LAZY | RTLD_LOCAL);
if (!sIOSurfaceFramework || !sOpenGLFramework || !sCoreGraphicsFramework) {
if (sIOSurfaceFramework)
dlclose(sIOSurfaceFramework);
if (sOpenGLFramework)
dlclose(sOpenGLFramework);
if (sCoreGraphicsFramework)
dlclose(sCoreGraphicsFramework);
sIOSurfaceFramework = nullptr;
sOpenGLFramework = nullptr;
sCoreGraphicsFramework = nullptr;
return;
}
kPropWidth = GetIOConst("kIOSurfaceWidth");
kPropHeight = GetIOConst("kIOSurfaceHeight");
kPropBytesPerElem = GetIOConst("kIOSurfaceBytesPerElement");
kPropBytesPerRow = GetIOConst("kIOSurfaceBytesPerRow");
kPropIsGlobal = GetIOConst("kIOSurfaceIsGlobal");
sCreate = GET_IOSYM(sCreate, "IOSurfaceCreate");
sGetID = GET_IOSYM(sGetID, "IOSurfaceGetID");
sWidth = GET_IOSYM(sWidth, "IOSurfaceGetWidth");
sHeight = GET_IOSYM(sHeight, "IOSurfaceGetHeight");
sBytesPerRow = GET_IOSYM(sBytesPerRow, "IOSurfaceGetBytesPerRow");
sLookup = GET_IOSYM(sLookup, "IOSurfaceLookup");
sLock = GET_IOSYM(sLock, "IOSurfaceLock");
sUnlock = GET_IOSYM(sUnlock, "IOSurfaceUnlock");
sGetBaseAddress = GET_IOSYM(sGetBaseAddress, "IOSurfaceGetBaseAddress");
sTexImage = GET_CGLSYM(sTexImage, "CGLTexImageIOSurface2D");
sCGContextGetTypePtr = (unsigned int (*)(CGContext*))dlsym(RTLD_DEFAULT, "CGContextGetType");
// Optional symbols
sIOSurfaceContextCreate = GET_CGSYM(sIOSurfaceContextCreate, "CGIOSurfaceContextCreate");
sIOSurfaceContextCreateImage = GET_CGSYM(sIOSurfaceContextCreateImage, "CGIOSurfaceContextCreateImage");
sIOSurfaceContextGetSurface = GET_CGSYM(sIOSurfaceContextGetSurface, "CGIOSurfaceContextGetSurface");
if (!sCreate || !sGetID || !sLookup || !sTexImage || !sGetBaseAddress ||
!kPropWidth || !kPropHeight || !kPropBytesPerElem || !kPropIsGlobal ||
!sLock || !sUnlock || !sWidth || !sHeight || !kPropBytesPerRow ||
!sBytesPerRow) {
CloseLibrary();
}
}
void MacIOSurfaceLib::CloseLibrary() {
if (sIOSurfaceFramework) {
dlclose(sIOSurfaceFramework);
}
if (sOpenGLFramework) {
dlclose(sOpenGLFramework);
}
sIOSurfaceFramework = nullptr;
sOpenGLFramework = nullptr;
}
MacIOSurface::~MacIOSurface() {
CFRelease(mIOSurfacePtr);
}
TemporaryRef<MacIOSurface> MacIOSurface::CreateIOSurface(int aWidth, int aHeight,
double aContentsScaleFactor,
bool aHasAlpha) {
if (!MacIOSurfaceLib::isInit() || aContentsScaleFactor <= 0)
return nullptr;
CFMutableDictionaryRef props = ::CFDictionaryCreateMutable(
kCFAllocatorDefault, 4,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
if (!props)
return nullptr;
int32_t bytesPerElem = 4;
size_t intScaleFactor = ceil(aContentsScaleFactor);
aWidth *= intScaleFactor;
aHeight *= intScaleFactor;
CFNumberRef cfWidth = ::CFNumberCreate(nullptr, kCFNumberSInt32Type, &aWidth);
CFNumberRef cfHeight = ::CFNumberCreate(nullptr, kCFNumberSInt32Type, &aHeight);
CFNumberRef cfBytesPerElem = ::CFNumberCreate(nullptr, kCFNumberSInt32Type, &bytesPerElem);
::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropWidth,
cfWidth);
::CFRelease(cfWidth);
::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropHeight,
cfHeight);
::CFRelease(cfHeight);
::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropBytesPerElem,
cfBytesPerElem);
::CFRelease(cfBytesPerElem);
::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropIsGlobal,
kCFBooleanTrue);
IOSurfacePtr surfaceRef = MacIOSurfaceLib::IOSurfaceCreate(props);
::CFRelease(props);
if (!surfaceRef)
return nullptr;
RefPtr<MacIOSurface> ioSurface = new MacIOSurface(surfaceRef, aContentsScaleFactor, aHasAlpha);
if (!ioSurface) {
::CFRelease(surfaceRef);
return nullptr;
}
return ioSurface.forget();
}
TemporaryRef<MacIOSurface> MacIOSurface::LookupSurface(IOSurfaceID aIOSurfaceID,
double aContentsScaleFactor,
bool aHasAlpha) {
if (!MacIOSurfaceLib::isInit() || aContentsScaleFactor <= 0)
return nullptr;
IOSurfacePtr surfaceRef = MacIOSurfaceLib::IOSurfaceLookup(aIOSurfaceID);
if (!surfaceRef)
return nullptr;
RefPtr<MacIOSurface> ioSurface = new MacIOSurface(surfaceRef, aContentsScaleFactor, aHasAlpha);
if (!ioSurface) {
::CFRelease(surfaceRef);
return nullptr;
}
return ioSurface.forget();
}
IOSurfaceID MacIOSurface::GetIOSurfaceID() {
return MacIOSurfaceLib::IOSurfaceGetID(mIOSurfacePtr);
}
void* MacIOSurface::GetBaseAddress() {
return MacIOSurfaceLib::IOSurfaceGetBaseAddress(mIOSurfacePtr);
}
size_t MacIOSurface::GetWidth() {
size_t intScaleFactor = ceil(mContentsScaleFactor);
return GetDevicePixelWidth() / intScaleFactor;
}
size_t MacIOSurface::GetHeight() {
size_t intScaleFactor = ceil(mContentsScaleFactor);
return GetDevicePixelHeight() / intScaleFactor;
}
size_t MacIOSurface::GetDevicePixelWidth() {
return MacIOSurfaceLib::IOSurfaceGetWidth(mIOSurfacePtr);
}
size_t MacIOSurface::GetDevicePixelHeight() {
return MacIOSurfaceLib::IOSurfaceGetHeight(mIOSurfacePtr);
}
size_t MacIOSurface::GetBytesPerRow() {
return MacIOSurfaceLib::IOSurfaceGetBytesPerRow(mIOSurfacePtr);
}
#define READ_ONLY 0x1
void MacIOSurface::Lock() {
MacIOSurfaceLib::IOSurfaceLock(mIOSurfacePtr, READ_ONLY, nullptr);
}
void MacIOSurface::Unlock() {
MacIOSurfaceLib::IOSurfaceUnlock(mIOSurfacePtr, READ_ONLY, nullptr);
}
#include "SourceSurfaceRawData.h"
using mozilla::gfx::SourceSurface;
using mozilla::gfx::SourceSurfaceRawData;
using mozilla::gfx::IntSize;
using mozilla::gfx::SurfaceFormat;
TemporaryRef<SourceSurface>
MacIOSurface::GetAsSurface() {
Lock();
size_t bytesPerRow = GetBytesPerRow();
size_t ioWidth = GetDevicePixelWidth();
size_t ioHeight = GetDevicePixelHeight();
unsigned char* ioData = (unsigned char*)GetBaseAddress();
unsigned char* dataCpy = (unsigned char*)malloc(bytesPerRow*ioHeight);
for (size_t i = 0; i < ioHeight; i++) {
memcpy(dataCpy + i * bytesPerRow,
ioData + i * bytesPerRow, ioWidth * 4);
}
Unlock();
SurfaceFormat format = HasAlpha() ? mozilla::gfx::FORMAT_B8G8R8A8 :
mozilla::gfx::FORMAT_B8G8R8X8;
RefPtr<SourceSurfaceRawData> surf = new SourceSurfaceRawData();
surf->InitWrappingData(dataCpy, IntSize(ioWidth, ioHeight), bytesPerRow, format, true);
return surf.forget();
}
CGLError
MacIOSurface::CGLTexImageIOSurface2D(void *c)
{
NSOpenGLContext *ctxt = static_cast<NSOpenGLContext*>(c);
return MacIOSurfaceLib::CGLTexImageIOSurface2D((CGLContextObj)[ctxt CGLContextObj],
GL_TEXTURE_RECTANGLE_ARB,
HasAlpha() ? LOCAL_GL_RGBA : LOCAL_GL_RGB,
GetDevicePixelWidth(),
GetDevicePixelHeight(),
LOCAL_GL_BGRA,
LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV,
mIOSurfacePtr, 0);
}
CGColorSpaceRef CreateSystemColorSpace() {
CGColorSpaceRef cspace = ::CGDisplayCopyColorSpace(::CGMainDisplayID());
if (!cspace) {
@ -465,16 +36,6 @@ CGColorSpaceRef CreateSystemColorSpace() {
return cspace;
}
CGContextRef MacIOSurface::CreateIOSurfaceContext() {
CGColorSpaceRef cspace = CreateSystemColorSpace();
CGContextRef ref = MacIOSurfaceLib::IOSurfaceContextCreate(mIOSurfacePtr,
GetDevicePixelWidth(),
GetDevicePixelHeight(),
8, 32, cspace, 0x2002);
::CGColorSpaceRelease(cspace);
return ref;
}
nsCARenderer::~nsCARenderer() {
Destroy();
}
@ -1067,49 +628,3 @@ void nsCARenderer::SaveToDisk(MacIOSurface *surf) {
}
#endif
CGImageRef MacIOSurface::CreateImageFromIOSurfaceContext(CGContextRef aContext) {
if (!MacIOSurfaceLib::isInit())
return nullptr;
return MacIOSurfaceLib::IOSurfaceContextCreateImage(aContext);
}
TemporaryRef<MacIOSurface> MacIOSurface::IOSurfaceContextGetSurface(CGContextRef aContext,
double aContentsScaleFactor,
bool aHasAlpha) {
if (!MacIOSurfaceLib::isInit() || aContentsScaleFactor <= 0)
return nullptr;
IOSurfacePtr surfaceRef = MacIOSurfaceLib::IOSurfaceContextGetSurface(aContext);
if (!surfaceRef)
return nullptr;
// Retain the IOSurface because MacIOSurface will release it
CFRetain(surfaceRef);
RefPtr<MacIOSurface> ioSurface = new MacIOSurface(surfaceRef, aContentsScaleFactor, aHasAlpha);
if (!ioSurface) {
::CFRelease(surfaceRef);
return nullptr;
}
return ioSurface.forget();
}
CGContextType GetContextType(CGContextRef ref)
{
if (!MacIOSurfaceLib::isInit() || !MacIOSurfaceLib::sCGContextGetTypePtr)
return CG_CONTEXT_TYPE_UNKNOWN;
unsigned int type = MacIOSurfaceLib::sCGContextGetTypePtr(ref);
if (type == CG_CONTEXT_TYPE_BITMAP) {
return CG_CONTEXT_TYPE_BITMAP;
} else if (type == CG_CONTEXT_TYPE_IOSURFACE) {
return CG_CONTEXT_TYPE_IOSURFACE;
} else {
return CG_CONTEXT_TYPE_UNKNOWN;
}
}

Просмотреть файл

@ -6,7 +6,7 @@
#include "SourceSurfaceCG.h"
#include "DrawTargetCG.h"
#include "QuartzSupport.h"
#include "MacIOSurface.h"
#include "Tools.h"
namespace mozilla {

Просмотреть файл

@ -102,6 +102,7 @@ SOURCES += [
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
SOURCES += [
'MacIOSurface.cpp',
'QuartzSupport.mm',
]

Просмотреть файл

@ -2429,6 +2429,7 @@ public:
NativeGLContext,
NativeImageSurface,
NativeThebesSurface,
NativeCGLContext,
NativeDataTypeMax
};

Просмотреть файл

@ -133,7 +133,8 @@ public:
switch (aType) {
case NativeGLContext:
return mContext;
case NativeCGLContext:
return [mContext CGLContextObj];
default:
return nullptr;
}

Просмотреть файл

@ -76,10 +76,10 @@ SharedSurface_IOSurface::SharedSurface_IOSurface(MacIOSurface* surface,
LOCAL_GL_TEXTURE_WRAP_T,
LOCAL_GL_CLAMP_TO_EDGE);
void *nativeCtx = mGL->GetNativeData(GLContext::NativeGLContext);
MOZ_ASSERT(nativeCtx);
CGLContextObj ctx = static_cast<CGLContextObj>(mGL->GetNativeData(GLContext::NativeCGLContext));
MOZ_ASSERT(ctx);
surface->CGLTexImageIOSurface2D(nativeCtx);
surface->CGLTexImageIOSurface2D(ctx);
}
SharedSurface_IOSurface::~SharedSurface_IOSurface()

Просмотреть файл

@ -103,9 +103,8 @@ MakeIOSurfaceTexture(void* aCGIOSurfaceContext, mozilla::gl::GLContext* aGL)
aGL->fTexParameteri(LOCAL_GL_TEXTURE_RECTANGLE_ARB, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
RefPtr<MacIOSurface> ioSurface = MacIOSurface::IOSurfaceContextGetSurface((CGContextRef)aCGIOSurfaceContext);
void *nativeCtx = aGL->GetNativeData(GLContext::NativeGLContext);
ioSurface->CGLTexImageIOSurface2D(nativeCtx);
ioSurface->CGLTexImageIOSurface2D(static_cast<CGLContextObj>(aGL->GetNativeData(GLContext::NativeCGLContext)));
aGL->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, 0);

Просмотреть файл

@ -482,8 +482,7 @@ MacIOSurfaceTextureSourceOGL::BindTexture(GLenum aTextureUnit)
gl()->fActiveTexture(aTextureUnit);
gl()->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, tex);
void *nativeGL = gl()->GetNativeData(gl::GLContext::NativeGLContext);
mSurface->CGLTexImageIOSurface2D(nativeGL);
mSurface->CGLTexImageIOSurface2D(static_cast<CGLContextObj>(gl()->GetNativeData(GLContext::NativeCGLContext)));
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
}

Просмотреть файл

@ -0,0 +1,215 @@
/* -*- 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 "mozilla/gfx/2D.h"
#include "nsTArray.h"
#include "pldhash.h"
#include "nsExpirationTracker.h"
#include "nsClassHashtable.h"
#include "mozilla/Telemetry.h"
#include "gfxGradientCache.h"
#include <time.h>
namespace mozilla {
namespace gfx {
using namespace mozilla;
struct GradientCacheKey : public PLDHashEntryHdr {
typedef const GradientCacheKey& KeyType;
typedef const GradientCacheKey* KeyTypePointer;
enum { ALLOW_MEMMOVE = true };
const nsTArray<GradientStop> mStops;
ExtendMode mExtend;
BackendType mBackendType;
GradientCacheKey(const nsTArray<GradientStop>& aStops, ExtendMode aExtend, BackendType aBackendType)
: mStops(aStops), mExtend(aExtend), mBackendType(aBackendType)
{ }
GradientCacheKey(const GradientCacheKey* aOther)
: mStops(aOther->mStops), mExtend(aOther->mExtend), mBackendType(aOther->mBackendType)
{ }
union FloatUint32
{
float f;
uint32_t u;
};
static PLDHashNumber
HashKey(const KeyTypePointer aKey)
{
PLDHashNumber hash = 0;
FloatUint32 convert;
hash = AddToHash(hash, aKey->mBackendType);
hash = AddToHash(hash, aKey->mExtend);
for (uint32_t i = 0; i < aKey->mStops.Length(); i++) {
hash = AddToHash(hash, aKey->mStops[i].color.ToABGR());
// Use the float bits as hash, except for the cases of 0.0 and -0.0 which both map to 0
convert.f = aKey->mStops[i].offset;
hash = AddToHash(hash, convert.f ? convert.u : 0);
}
return hash;
}
bool KeyEquals(KeyTypePointer aKey) const
{
bool sameStops = true;
if (aKey->mStops.Length() != mStops.Length()) {
sameStops = false;
} else {
for (uint32_t i = 0; i < mStops.Length(); i++) {
if (mStops[i].color.ToABGR() != aKey->mStops[i].color.ToABGR() ||
mStops[i].offset != aKey->mStops[i].offset) {
sameStops = false;
break;
}
}
}
return sameStops &&
(aKey->mBackendType == mBackendType) &&
(aKey->mExtend == mExtend);
}
static KeyTypePointer KeyToPointer(KeyType aKey)
{
return &aKey;
}
};
/**
* This class is what is cached. It need to be allocated in an object separated
* to the cache entry to be able to be tracked by the nsExpirationTracker.
* */
struct GradientCacheData {
GradientCacheData(GradientStops* aStops, const GradientCacheKey& aKey)
: mStops(aStops),
mKey(aKey)
{}
GradientCacheData(const GradientCacheData& aOther)
: mStops(aOther.mStops),
mKey(aOther.mKey)
{ }
nsExpirationState *GetExpirationState() {
return &mExpirationState;
}
nsExpirationState mExpirationState;
const RefPtr<GradientStops> mStops;
GradientCacheKey mKey;
};
/**
* This class implements a cache with no maximum size, that retains the
* gfxPatterns used to draw the gradients.
*
* The key is the nsStyleGradient that defines the gradient, and the size of the
* gradient.
*
* The value is the gfxPattern, and whether or not we perform an optimization
* based on the actual gradient property.
*
* An entry stays in the cache as long as it is used often. As long as a cache
* entry is in the cache, all the references it has are guaranteed to be valid:
* the nsStyleRect for the key, the gfxPattern for the value.
*/
class GradientCache MOZ_FINAL : public nsExpirationTracker<GradientCacheData,4>
{
public:
GradientCache()
: nsExpirationTracker<GradientCacheData, 4>(MAX_GENERATION_MS)
{
srand(time(nullptr));
mTimerPeriod = rand() % MAX_GENERATION_MS + 1;
Telemetry::Accumulate(Telemetry::GRADIENT_RETENTION_TIME, mTimerPeriod);
}
virtual void NotifyExpired(GradientCacheData* aObject)
{
// This will free the gfxPattern.
RemoveObject(aObject);
mHashEntries.Remove(aObject->mKey);
}
GradientCacheData* Lookup(const nsTArray<GradientStop>& aStops, ExtendMode aExtend, BackendType aBackendType)
{
GradientCacheData* gradient =
mHashEntries.Get(GradientCacheKey(aStops, aExtend, aBackendType));
if (gradient) {
MarkUsed(gradient);
}
return gradient;
}
// Returns true if we successfully register the gradient in the cache, false
// otherwise.
bool RegisterEntry(GradientCacheData* aValue)
{
nsresult rv = AddObject(aValue);
if (NS_FAILED(rv)) {
// We are OOM, and we cannot track this object. We don't want stall
// entries in the hash table (since the expiration tracker is responsible
// for removing the cache entries), so we avoid putting that entry in the
// table, which is a good things considering we are short on memory
// anyway, we probably don't want to retain things.
return false;
}
mHashEntries.Put(aValue->mKey, aValue);
return true;
}
protected:
uint32_t mTimerPeriod;
static const uint32_t MAX_GENERATION_MS = 10000;
/**
* FIXME use nsTHashtable to avoid duplicating the GradientCacheKey.
* https://bugzilla.mozilla.org/show_bug.cgi?id=761393#c47
*/
nsClassHashtable<GradientCacheKey, GradientCacheData> mHashEntries;
};
static GradientCache* gGradientCache = nullptr;
GradientStops *
gfxGradientCache::GetGradientStops(DrawTarget *aDT, nsTArray<GradientStop>& aStops, ExtendMode aExtend)
{
if (!gGradientCache) {
gGradientCache = new GradientCache();
}
GradientCacheData* cached = gGradientCache->Lookup(aStops, aExtend, aDT->GetType());
return cached ? cached->mStops : nullptr;
}
GradientStops *
gfxGradientCache::GetOrCreateGradientStops(DrawTarget *aDT, nsTArray<GradientStop>& aStops, ExtendMode aExtend)
{
RefPtr<GradientStops> gs = GetGradientStops(aDT, aStops, aExtend);
if (!gs) {
gs = aDT->CreateGradientStops(aStops.Elements(), aStops.Length(), aExtend);
if (!gs) {
return nullptr;
}
GradientCacheData *cached = new GradientCacheData(gs, GradientCacheKey(aStops, aExtend, aDT->GetType()));
if (!gGradientCache->RegisterEntry(cached)) {
delete cached;
}
}
return gs;
}
void
gfxGradientCache::Shutdown()
{
delete gGradientCache;
gGradientCache = nullptr;
}
}
}

Просмотреть файл

@ -0,0 +1,32 @@
/* -*- 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/. */
#ifndef GFX_GRADIENT_CACHE_H
#define GFX_GRADIENT_CACHE_H
#include "nsTArray.h"
#include "gfxPattern.h"
#include "mozilla/gfx/2D.h"
namespace mozilla {
namespace gfx {
class gfxGradientCache {
public:
static gfx::GradientStops *GetGradientStops(gfx::DrawTarget *aDT,
nsTArray<gfx::GradientStop>& aStops,
gfx::ExtendMode aExtend);
static gfx::GradientStops *GetOrCreateGradientStops(gfx::DrawTarget *aDT,
nsTArray<gfx::GradientStop>& aStops,
gfx::ExtendMode aExtend);
static void Shutdown();
};
}
}
#endif

Просмотреть файл

@ -8,6 +8,7 @@
#include "gfxASurface.h"
#include "gfxPlatform.h"
#include "gfx2DGlue.h"
#include "gfxGradientCache.h"
#include "cairo.h"
@ -102,6 +103,29 @@ gfxPattern::SetColorStops(mozilla::RefPtr<mozilla::gfx::GradientStops> aStops)
mStops = aStops;
}
void
gfxPattern::CacheColorStops(mozilla::gfx::DrawTarget *aDT)
{
if (mPattern) {
mStops = nullptr;
nsTArray<GradientStop> stops;
int count = 0;
cairo_pattern_get_color_stop_count(mPattern, &count);
stops.SetLength(count);
for (int n = 0; n < count; ++n) {
double offset, r, g, b, a;
cairo_pattern_get_color_stop_rgba(mPattern, n, &offset, &r, &g, &b, &a);
stops[n].color = mozilla::gfx::Color(r, g, b, a);
stops[n].offset = offset;
}
mStops = gfxGradientCache::GetOrCreateGradientStops(aDT,
stops,
(cairo_pattern_get_extend(mPattern) == CAIRO_EXTEND_REPEAT)
? mozilla::gfx::EXTEND_REPEAT
: mozilla::gfx::EXTEND_CLAMP);
}
}
void
gfxPattern::SetMatrix(const gfxMatrix& matrix)
{

Просмотреть файл

@ -14,6 +14,7 @@
#include "GraphicsFilter.h"
#include "nsISupportsImpl.h"
#include "nsAutoPtr.h"
#include "nsTArray.h"
class gfxContext;
class gfxASurface;
@ -40,6 +41,11 @@ public:
void AddColorStop(gfxFloat offset, const gfxRGBA& c);
void SetColorStops(mozilla::RefPtr<mozilla::gfx::GradientStops> aStops);
// This should only be called on a cairo pattern that we want to use with
// Azure. We will read back the color stops from cairo and try to look
// them up in the cache.
void CacheColorStops(mozilla::gfx::DrawTarget *aDT);
void SetMatrix(const gfxMatrix& matrix);
gfxMatrix GetMatrix() const;
gfxMatrix GetInverseMatrix() const;

Просмотреть файл

@ -48,6 +48,7 @@
#include "harfbuzz/hb.h"
#include "gfxGraphiteShaper.h"
#include "gfx2DGlue.h"
#include "gfxGradientCache.h"
#include "nsUnicodeRange.h"
#include "nsServiceManagerUtils.h"
@ -503,6 +504,7 @@ gfxPlatform::Shutdown()
// started up. That's OK, they can handle it.
gfxFontCache::Shutdown();
gfxFontGroup::Shutdown();
gfxGradientCache::Shutdown();
gfxGraphiteShaper::Shutdown();
#if defined(XP_MACOSX) || defined(XP_WIN) // temporary, until this is implemented on others
gfxPlatformFontList::Shutdown();

Просмотреть файл

@ -24,6 +24,7 @@ EXPORTS += [
'gfxFontFeatures.h',
'gfxFontTest.h',
'gfxFontUtils.h',
'gfxGradientCache.h',
'gfxImageSurface.h',
'gfxLineSegment.h',
'gfxMatrix.h',
@ -245,6 +246,7 @@ SOURCES += [
'gfxFontMissingGlyphs.cpp',
'gfxFontTest.cpp',
'gfxFontUtils.cpp',
'gfxGradientCache.cpp',
'gfxGraphiteShaper.cpp',
'gfxHarfBuzzShaper.cpp',
'gfxImageSurface.cpp',

Просмотреть файл

@ -100,6 +100,8 @@ PrintBacktrace()
fprintf(stderr, "#%d %s\n", OOM_traceIdx, OOM_traceSymbols[OOM_traceIdx]);
}
// This must be free(), not js_free(), because backtrace_symbols()
// allocates with malloc().
free(OOM_traceSymbols);
}

Просмотреть файл

@ -85,6 +85,8 @@ using JS::CallReceiver;
using JS::CompileOptions;
using JS::IsAcceptableThis;
using JS::NativeImpl;
using JS::OwningCompileOptions;
using JS::ReadOnlyCompileOptions;
using JS::Rooted;
using JS::RootedFunction;

Просмотреть файл

@ -109,7 +109,7 @@ TraceLogging::~TraceLogging()
{
if (entries) {
flush();
free(entries);
js_free(entries);
entries = nullptr;
}
@ -122,7 +122,7 @@ TraceLogging::~TraceLogging()
void
TraceLogging::grow()
{
Entry* nentries = (Entry*) realloc(entries, numEntries*2*sizeof(Entry));
Entry* nentries = (Entry*) js_realloc(entries, numEntries*2*sizeof(Entry));
// Allocating a bigger array failed.
// Keep using the current storage, but remove all entries by flushing them.
@ -142,7 +142,7 @@ TraceLogging::log(Type type, const char* text /* = nullptr */, unsigned int numb
// Create array containing the entries if not existing.
if (!entries) {
entries = (Entry*) malloc(numEntries*sizeof(Entry));
entries = (Entry*) js_malloc(numEntries*sizeof(Entry));
if (!entries)
return;
}
@ -173,7 +173,7 @@ TraceLogging::log(Type type, const char* text /* = nullptr */, unsigned int numb
}
void
TraceLogging::log(Type type, const JS::CompileOptions &options)
TraceLogging::log(Type type, const JS::ReadOnlyCompileOptions &options)
{
this->log(type, options.filename, options.lineno);
}
@ -248,7 +248,7 @@ TraceLogging::flush()
}
if (entries[i].text() != nullptr) {
free(entries[i].text());
js_free(entries[i].text());
entries[i].text_ = nullptr;
}
}

Просмотреть файл

@ -16,7 +16,7 @@
#include "js/TypeDecls.h"
namespace JS {
class CompileOptions;
class ReadOnlyCompileOptions;
}
namespace js {
@ -103,7 +103,7 @@ class TraceLogging
~TraceLogging();
void log(Type type, const char* text = nullptr, unsigned int number = 0);
void log(Type type, const JS::CompileOptions &options);
void log(Type type, const JS::ReadOnlyCompileOptions &options);
void log(Type type, JSScript* script);
void log(const char* log);
void flush();
@ -130,7 +130,7 @@ class AutoTraceLog {
public:
AutoTraceLog(TraceLogging* logger, TraceLogging::Type start, TraceLogging::Type stop,
const JS::CompileOptions &options)
const JS::ReadOnlyCompileOptions &options)
: logger(logger),
stop(stop)
{

Просмотреть файл

@ -70,7 +70,7 @@ namespace JSC {
~AssemblerBuffer()
{
if (m_buffer != m_inlineBuffer)
free(m_buffer);
js_free(m_buffer);
}
void ensureSpace(int space)
@ -222,7 +222,7 @@ namespace JSC {
}
if (m_buffer == m_inlineBuffer) {
newBuffer = static_cast<char*>(malloc(newCapacity));
newBuffer = static_cast<char*>(js_malloc(newCapacity));
if (!newBuffer) {
m_size = 0;
m_oom = true;
@ -230,7 +230,7 @@ namespace JSC {
}
memcpy(newBuffer, m_buffer, m_size);
} else {
newBuffer = static_cast<char*>(realloc(m_buffer, newCapacity));
newBuffer = static_cast<char*>(js_realloc(m_buffer, newCapacity));
if (!newBuffer) {
m_size = 0;
m_oom = true;

Просмотреть файл

@ -106,14 +106,14 @@ public:
, m_lastConstDelta(0)
, m_flushCount(0)
{
m_pool = static_cast<uint32_t*>(malloc(maxPoolSize));
m_mask = static_cast<char*>(malloc(maxPoolSize / sizeof(uint32_t)));
m_pool = static_cast<uint32_t*>(js_malloc(maxPoolSize));
m_mask = static_cast<char*>(js_malloc(maxPoolSize / sizeof(uint32_t)));
}
~AssemblerBufferWithConstantPool()
{
free(m_mask);
free(m_pool);
js_free(m_mask);
js_free(m_pool);
}
void ensureSpace(int space)

Просмотреть файл

@ -519,10 +519,15 @@ bool js_StartPerf()
flags = "--call-graph";
}
// Split |flags| on spaces. (Don't bother to free it -- we're going to
char *flags2 = (char *)js_malloc(strlen(flags) + 1);
if (!flags2)
return false;
strcpy(flags2, flags);
// Split |flags2| on spaces. (Don't bother to free it -- we're going to
// exec anyway.)
char *toksave;
char *tok = strtok_r(strdup(flags), " ", &toksave);
char *tok = strtok_r(flags2, " ", &toksave);
while (tok) {
args.append(tok);
tok = strtok_r(nullptr, " ", &toksave);

Просмотреть файл

@ -1373,7 +1373,7 @@ PP_TARGETS += DIST_CHROME_FILES
endif
ifneq ($(XPI_PKGNAME),)
libs realchrome::
tools realchrome::
ifdef STRIP_XPI
ifndef MOZ_DEBUG
@echo "Stripping $(XPI_PKGNAME) package directory..."
@ -1412,7 +1412,7 @@ ifndef XPI_NAME
$(error XPI_NAME must be set for INSTALL_EXTENSION_ID)
endif
libs::
tools::
$(RM) -r "$(DIST)/bin$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)"
$(NSINSTALL) -D "$(DIST)/bin$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)"
$(call copy_dir,$(FINAL_TARGET),$(DIST)/bin$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID))

Просмотреть файл

@ -2916,7 +2916,7 @@ if test "$_USE_SYSTEM_NSPR" || (test "$NSPR_CFLAGS" -o "$NSPR_LIBS"); then
fi
case "$target" in
*linux*)
*linux*|*darwin*)
if test -z "$_HAS_NSPR"; then JS_POSIX_NSPR_DEFAULT=1; fi
;;
esac

Просмотреть файл

@ -137,7 +137,7 @@ MaybeCheckEvalFreeVariables(ExclusiveContext *cxArg, HandleScript evalCaller, Ha
}
static inline bool
CanLazilyParse(ExclusiveContext *cx, const CompileOptions &options)
CanLazilyParse(ExclusiveContext *cx, const ReadOnlyCompileOptions &options)
{
return options.canLazilyParse &&
options.compileAndGo &&
@ -146,7 +146,7 @@ CanLazilyParse(ExclusiveContext *cx, const CompileOptions &options)
}
void
frontend::MaybeCallSourceHandler(JSContext *cx, const CompileOptions &options,
frontend::MaybeCallSourceHandler(JSContext *cx, const ReadOnlyCompileOptions &options,
const jschar *chars, size_t length)
{
JSSourceHandler listener = cx->runtime()->debugHooks.sourceHandler;
@ -154,7 +154,7 @@ frontend::MaybeCallSourceHandler(JSContext *cx, const CompileOptions &options,
if (listener) {
void *listenerTSData;
listener(options.filename, options.lineno, chars, length,
listener(options.filename(), options.lineno, chars, length,
&listenerTSData, listenerData);
}
}
@ -162,7 +162,7 @@ frontend::MaybeCallSourceHandler(JSContext *cx, const CompileOptions &options,
JSScript *
frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject scopeChain,
HandleScript evalCaller,
const CompileOptions &options,
const ReadOnlyCompileOptions &options,
const jschar *chars, size_t length,
JSString *source_ /* = nullptr */,
unsigned staticLevel /* = 0 */,
@ -195,7 +195,7 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco
ScriptSource *ss = cx->new_<ScriptSource>(options.originPrincipals());
if (!ss)
return nullptr;
if (options.filename && !ss->setFilename(cx, options.filename))
if (options.filename() && !ss->setFilename(cx, options.filename()))
return nullptr;
RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, ss));
@ -379,8 +379,8 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco
* Source map URLs passed as a compile option (usually via a HTTP source map
* header) override any source map urls passed as comment pragmas.
*/
if (options.sourceMapURL) {
if (!ss->setSourceMapURL(cx, options.sourceMapURL))
if (options.sourceMapURL()) {
if (!ss->setSourceMapURL(cx, options.sourceMapURL()))
return nullptr;
}
@ -472,7 +472,7 @@ frontend::CompileLazyFunction(JSContext *cx, LazyScript *lazy, const jschar *cha
// Compile a JS function body, which might appear as the value of an event
// handler attribute in an HTML <INPUT> tag, or in a Function() constructor.
static bool
CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, CompileOptions options,
CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, const ReadOnlyCompileOptions &options,
const AutoNameVector &formals, const jschar *chars, size_t length,
GeneratorKind generatorKind)
{
@ -494,7 +494,7 @@ CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, CompileOptions opt
ScriptSource *ss = cx->new_<ScriptSource>(options.originPrincipals());
if (!ss)
return false;
if (options.filename && !ss->setFilename(cx, options.filename))
if (options.filename() && !ss->setFilename(cx, options.filename()))
return false;
RootedScriptSource sourceObject(cx, ScriptSourceObject::create(cx, ss));
if (!sourceObject)
@ -611,7 +611,8 @@ CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, CompileOptions opt
}
bool
frontend::CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, CompileOptions options,
frontend::CompileFunctionBody(JSContext *cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions &options,
const AutoNameVector &formals, const jschar *chars, size_t length)
{
return CompileFunctionBody(cx, fun, options, formals, chars, length, NotGenerator);
@ -619,7 +620,7 @@ frontend::CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, CompileO
bool
frontend::CompileStarGeneratorBody(JSContext *cx, MutableHandleFunction fun,
CompileOptions options, const AutoNameVector &formals,
const ReadOnlyCompileOptions &options, const AutoNameVector &formals,
const jschar *chars, size_t length)
{
return CompileFunctionBody(cx, fun, options, formals, chars, length, StarGenerator);

Просмотреть файл

@ -23,7 +23,7 @@ namespace frontend {
JSScript *
CompileScript(ExclusiveContext *cx, LifoAlloc *alloc,
HandleObject scopeChain, HandleScript evalCaller,
const CompileOptions &options, const jschar *chars, size_t length,
const ReadOnlyCompileOptions &options, const jschar *chars, size_t length,
JSString *source_ = nullptr, unsigned staticLevel = 0,
SourceCompressionTask *extraSct = nullptr);
@ -31,10 +31,12 @@ bool
CompileLazyFunction(JSContext *cx, LazyScript *lazy, const jschar *chars, size_t length);
bool
CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, CompileOptions options,
CompileFunctionBody(JSContext *cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions &options,
const AutoNameVector &formals, const jschar *chars, size_t length);
bool
CompileStarGeneratorBody(JSContext *cx, MutableHandleFunction fun, CompileOptions options,
CompileStarGeneratorBody(JSContext *cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions &options,
const AutoNameVector &formals, const jschar *chars, size_t length);
/*
@ -42,7 +44,7 @@ CompileStarGeneratorBody(JSContext *cx, MutableHandleFunction fun, CompileOption
* occur on a worker thread.
*/
void
MaybeCallSourceHandler(JSContext *cx, const CompileOptions &options,
MaybeCallSourceHandler(JSContext *cx, const ReadOnlyCompileOptions &options,
const jschar *chars, size_t length);
/*

Просмотреть файл

@ -4810,7 +4810,7 @@ EmitFunc(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
// Inherit most things (principals, version, etc) from the parent.
Rooted<JSScript*> parent(cx, bce->script);
CompileOptions options(bce->parser->options());
CompileOptions options(cx, bce->parser->options());
options.setPrincipals(parent->principals())
.setOriginPrincipals(parent->originPrincipals())
.setCompileAndGo(parent->compileAndGo)

Просмотреть файл

@ -249,7 +249,7 @@ condIf(const ParseNode *pn, ParseNodeKind kind)
static bool
Fold(ExclusiveContext *cx, ParseNode **pnp,
FullParseHandler &handler, const CompileOptions &options,
FullParseHandler &handler, const ReadOnlyCompileOptions &options,
bool inGenexpLambda, SyntacticContext sc)
{
ParseNode *pn = *pnp;

Просмотреть файл

@ -384,7 +384,7 @@ Parser<SyntaxParseHandler>::abortIfSyntaxParser()
template <typename ParseHandler>
Parser<ParseHandler>::Parser(ExclusiveContext *cx, LifoAlloc *alloc,
const CompileOptions &options,
const ReadOnlyCompileOptions &options,
const jschar *chars, size_t length, bool foldConstants,
Parser<SyntaxParseHandler> *syntaxParser,
LazyScript *lazyOuterFunction)

Просмотреть файл

@ -367,7 +367,7 @@ class Parser : private AutoGCRooter, public StrictModeGetter
bool reportWithOffset(ParseReportKind kind, bool strict, uint32_t offset, unsigned errorNumber,
...);
Parser(ExclusiveContext *cx, LifoAlloc *alloc, const CompileOptions &options,
Parser(ExclusiveContext *cx, LifoAlloc *alloc, const ReadOnlyCompileOptions &options,
const jschar *chars, size_t length, bool foldConstants,
Parser<SyntaxParseHandler> *syntaxParser,
LazyScript *lazyOuterFunction);
@ -471,7 +471,7 @@ class Parser : private AutoGCRooter, public StrictModeGetter
virtual bool strictMode() { return pc->sc->strict; }
const CompileOptions &options() const {
const ReadOnlyCompileOptions &options() const {
return tokenStream.options();
}

Просмотреть файл

@ -260,7 +260,7 @@ TokenStream::SourceCoords::lineNumAndColumnIndex(uint32_t offset, uint32_t *line
#endif
// Initialize members that aren't initialized in |init|.
TokenStream::TokenStream(ExclusiveContext *cx, const CompileOptions &options,
TokenStream::TokenStream(ExclusiveContext *cx, const ReadOnlyCompileOptions &options,
const jschar *base, size_t length, StrictModeGetter *smg)
: srcCoords(cx, options.lineno),
options_(options),
@ -272,7 +272,7 @@ TokenStream::TokenStream(ExclusiveContext *cx, const CompileOptions &options,
linebase(base - options.column),
prevLinebase(nullptr),
userbuf(cx, base - options.column, length + options.column), // See comment below
filename(options.filename),
filename(options.filename()),
sourceURL_(nullptr),
sourceMapURL_(nullptr),
tokenbuf(cx),

Просмотреть файл

@ -408,7 +408,7 @@ class MOZ_STACK_CLASS TokenStream
public:
typedef Vector<jschar, 32> CharBuffer;
TokenStream(ExclusiveContext *cx, const CompileOptions &options,
TokenStream(ExclusiveContext *cx, const ReadOnlyCompileOptions &options,
const jschar *base, size_t length, StrictModeGetter *smg);
~TokenStream();
@ -734,7 +734,7 @@ class MOZ_STACK_CLASS TokenStream
return cx;
}
const CompileOptions &options() const {
const ReadOnlyCompileOptions &options() const {
return options_;
}
@ -878,7 +878,7 @@ class MOZ_STACK_CLASS TokenStream
void updateFlagsForEOL();
// Options used for parsing/tokenizing.
const CompileOptions &options_;
const ReadOnlyCompileOptions &options_;
Token tokens[ntokens]; // circular token buffer
unsigned cursor; // index of last parsed token

Просмотреть файл

@ -1323,7 +1323,7 @@ class MOZ_STACK_CLASS ModuleCompiler
JS_ASSERT(errorOffset_ == UINT32_MAX);
JS_ASSERT(str);
errorOffset_ = offset;
errorString_ = strdup(str);
errorString_ = js_strdup(cx_, str);
return false;
}

Просмотреть файл

@ -731,9 +731,11 @@ GetCPUID(uint32_t *cpuId)
class MachineId
{
uint32_t cpuId_;
mozilla::Vector<char> buildId_;
js::Vector<char> buildId_;
public:
MachineId(ExclusiveContext *cx) : buildId_(cx) {}
bool extractCurrentState(ExclusiveContext *cx) {
if (!cx->asmJSCacheOps().buildId)
return false;
@ -913,7 +915,7 @@ js::StoreAsmJSModuleInCache(AsmJSParser &parser,
const AsmJSStaticLinkData &linkData,
ExclusiveContext *cx)
{
MachineId machineId;
MachineId machineId(cx);
if (!machineId.extractCurrentState(cx))
return;
@ -968,7 +970,7 @@ js::LookupAsmJSModuleInCache(ExclusiveContext *cx,
{
int64_t usecBefore = PRMJ_Now();
MachineId machineId;
MachineId machineId(cx);
if (!machineId.extractCurrentState(cx))
return true;
@ -982,7 +984,7 @@ js::LookupAsmJSModuleInCache(ExclusiveContext *cx,
const uint8_t *cursor = entry.memory;
MachineId cachedMachineId;
MachineId cachedMachineId(cx);
cursor = cachedMachineId.deserialize(cx, cursor);
if (!cursor)
return false;

Просмотреть файл

@ -818,7 +818,7 @@ MPhi::reserveLength(size_t length)
{
// Initializes a new MPhi to have an Operand vector of at least the given
// capacity. This permits use of addInput() instead of addInputSlow(), the
// latter of which may call realloc().
// latter of which may call realloc_().
JS_ASSERT(numOperands() == 0);
#if DEBUG
capacity_ = length;
@ -968,7 +968,7 @@ MPhi::addInputSlow(MDefinition *ins, bool *ptypeChange)
uint32_t index = inputs_.length();
bool performingRealloc = !inputs_.canAppendWithoutRealloc(1);
// Remove all MUses from all use lists, in case realloc() moves.
// Remove all MUses from all use lists, in case realloc_() moves.
if (performingRealloc) {
for (uint32_t i = 0; i < index; i++) {
MUse *use = &inputs_[i];

Просмотреть файл

@ -4316,7 +4316,7 @@ class MPhi MOZ_FINAL : public MDefinition, public InlineForwardListNode<MPhi>
// Use only if capacity has been reserved by reserveLength
void addInput(MDefinition *ins);
// Appends a new input to the input vector. May call realloc().
// Appends a new input to the input vector. May call realloc_().
// Prefer reserveLength() and addInput() instead, where possible.
bool addInputSlow(MDefinition *ins, bool *ptypeChange = nullptr);

Просмотреть файл

@ -4267,39 +4267,116 @@ AutoFile::open(JSContext *cx, const char *filename)
return true;
}
JSObject * const JS::ReadOnlyCompileOptions::nullObjectPtr = nullptr;
JS::CompileOptions::CompileOptions(JSContext *cx, JSVersion version)
: principals_(nullptr),
originPrincipals_(nullptr),
version(version != JSVERSION_UNKNOWN ? version : cx->findVersion()),
versionSet(false),
utf8(false),
filename(nullptr),
sourceMapURL(nullptr),
lineno(1),
column(0),
element(NullPtr()),
compileAndGo(cx->options().compileAndGo()),
forEval(false),
noScriptRval(cx->options().noScriptRval()),
selfHostingMode(false),
canLazilyParse(true),
strictOption(cx->options().strictMode()),
extraWarningsOption(cx->options().extraWarnings()),
werrorOption(cx->options().werror()),
asmJSOption(cx->options().asmJS()),
sourcePolicy(SAVE_SOURCE)
void
JS::ReadOnlyCompileOptions::copyPODOptions(const ReadOnlyCompileOptions &rhs)
{
version = rhs.version;
versionSet = rhs.versionSet;
utf8 = rhs.utf8;
lineno = rhs.lineno;
column = rhs.column;
compileAndGo = rhs.compileAndGo;
forEval = rhs.forEval;
noScriptRval = rhs.noScriptRval;
selfHostingMode = rhs.selfHostingMode;
canLazilyParse = rhs.canLazilyParse;
strictOption = rhs.strictOption;
extraWarningsOption = rhs.extraWarningsOption;
werrorOption = rhs.werrorOption;
asmJSOption = rhs.asmJSOption;
sourcePolicy = rhs.sourcePolicy;
}
JSPrincipals *
CompileOptions::originPrincipals() const
JS::ReadOnlyCompileOptions::originPrincipals() const
{
return NormalizeOriginPrincipals(principals_, originPrincipals_);
}
JS::OwningCompileOptions::OwningCompileOptions(JSContext *cx)
: ReadOnlyCompileOptions(),
runtime(GetRuntime(cx)),
elementRoot(cx)
{
}
JS::OwningCompileOptions::~OwningCompileOptions()
{
if (principals_)
JS_DropPrincipals(runtime, principals_);
if (originPrincipals_)
JS_DropPrincipals(runtime, originPrincipals_);
// OwningCompileOptions always owns these, so these casts are okay.
js_free(const_cast<char *>(filename_));
js_free(const_cast<jschar *>(sourceMapURL_));
}
bool
JS::OwningCompileOptions::copy(JSContext *cx, const ReadOnlyCompileOptions &rhs)
{
copyPODOptions(rhs);
setPrincipals(rhs.principals());
setOriginPrincipals(rhs.originPrincipals());
setElement(rhs.element());
return (setFileAndLine(cx, rhs.filename(), rhs.lineno) &&
setSourceMapURL(cx, rhs.sourceMapURL()));
}
bool
JS::OwningCompileOptions::setFileAndLine(JSContext *cx, const char *f, unsigned l)
{
char *copy = nullptr;
if (f) {
copy = JS_strdup(cx, f);
if (!copy)
return false;
}
// OwningCompileOptions always owns filename_, so this cast is okay.
js_free(const_cast<char *>(filename_));
filename_ = copy;
lineno = l;
return true;
}
bool
JS::OwningCompileOptions::setSourceMapURL(JSContext *cx, const jschar *s)
{
jschar *copy = nullptr;
if (s) {
copy = js_strdup(cx, s);
if (!copy)
return false;
}
// OwningCompileOptions always owns sourceMapURL_, so this cast is okay.
js_free(const_cast<jschar *>(sourceMapURL_));
sourceMapURL_ = copy;
return true;
}
JS::CompileOptions::CompileOptions(JSContext *cx, JSVersion version)
: ReadOnlyCompileOptions(), elementRoot(cx)
{
this->version = (version != JSVERSION_UNKNOWN) ? version : cx->findVersion();
compileAndGo = cx->options().compileAndGo();
noScriptRval = cx->options().noScriptRval();
strictOption = cx->options().strictMode();
extraWarningsOption = cx->options().extraWarnings();
werrorOption = cx->options().werror();
asmJSOption = cx->options().asmJS();
}
JSScript *
JS::Compile(JSContext *cx, HandleObject obj, CompileOptions options,
JS::Compile(JSContext *cx, HandleObject obj, const ReadOnlyCompileOptions &options,
const jschar *chars, size_t length)
{
JS_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
@ -4313,7 +4390,7 @@ JS::Compile(JSContext *cx, HandleObject obj, CompileOptions options,
}
JSScript *
JS::Compile(JSContext *cx, HandleObject obj, CompileOptions options,
JS::Compile(JSContext *cx, HandleObject obj, const ReadOnlyCompileOptions &options,
const char *bytes, size_t length)
{
jschar *chars;
@ -4330,7 +4407,7 @@ JS::Compile(JSContext *cx, HandleObject obj, CompileOptions options,
}
JSScript *
JS::Compile(JSContext *cx, HandleObject obj, CompileOptions options, FILE *fp)
JS::Compile(JSContext *cx, HandleObject obj, const ReadOnlyCompileOptions &options, FILE *fp)
{
FileContents buffer(cx);
if (!ReadCompleteFile(cx, fp, buffer))
@ -4341,18 +4418,19 @@ JS::Compile(JSContext *cx, HandleObject obj, CompileOptions options, FILE *fp)
}
JSScript *
JS::Compile(JSContext *cx, HandleObject obj, CompileOptions options, const char *filename)
JS::Compile(JSContext *cx, HandleObject obj, const ReadOnlyCompileOptions &optionsArg, const char *filename)
{
AutoFile file;
if (!file.open(cx, filename))
return nullptr;
CompileOptions options(cx, optionsArg);
options.setFileAndLine(filename, 1);
JSScript *script = Compile(cx, obj, options, file.fp());
return script;
}
JS_PUBLIC_API(bool)
JS::CanCompileOffThread(JSContext *cx, const CompileOptions &options)
JS::CanCompileOffThread(JSContext *cx, const ReadOnlyCompileOptions &options)
{
#ifdef JS_WORKER_THREADS
if (!cx->runtime()->useHelperThreads() || !cx->runtime()->helperThreadCount())
@ -4375,7 +4453,7 @@ JS::CanCompileOffThread(JSContext *cx, const CompileOptions &options)
}
JS_PUBLIC_API(bool)
JS::CompileOffThread(JSContext *cx, Handle<JSObject*> obj, CompileOptions options,
JS::CompileOffThread(JSContext *cx, Handle<JSObject*> obj, const ReadOnlyCompileOptions &options,
const jschar *chars, size_t length,
OffThreadCompileCallback callback, void *callbackData)
{
@ -4503,7 +4581,7 @@ JS_GetGlobalFromScript(JSScript *script)
}
JS_PUBLIC_API(JSFunction *)
JS::CompileFunction(JSContext *cx, HandleObject obj, CompileOptions options,
JS::CompileFunction(JSContext *cx, HandleObject obj, const ReadOnlyCompileOptions &options,
const char *name, unsigned nargs, const char *const *argnames,
const jschar *chars, size_t length)
{
@ -4547,7 +4625,7 @@ JS::CompileFunction(JSContext *cx, HandleObject obj, CompileOptions options,
}
JS_PUBLIC_API(JSFunction *)
JS::CompileFunction(JSContext *cx, HandleObject obj, CompileOptions options,
JS::CompileFunction(JSContext *cx, HandleObject obj, const ReadOnlyCompileOptions &options,
const char *name, unsigned nargs, const char *const *argnames,
const char *bytes, size_t length)
{
@ -4688,9 +4766,10 @@ JS_ExecuteScriptVersion(JSContext *cx, JSObject *objArg, JSScript *script, jsval
static const unsigned LARGE_SCRIPT_LENGTH = 500*1024;
extern JS_PUBLIC_API(bool)
JS::Evaluate(JSContext *cx, HandleObject obj, CompileOptions options,
JS::Evaluate(JSContext *cx, HandleObject obj, const ReadOnlyCompileOptions &optionsArg,
const jschar *chars, size_t length, jsval *rval)
{
CompileOptions options(cx, optionsArg);
JS_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
@ -4729,7 +4808,7 @@ JS::Evaluate(JSContext *cx, HandleObject obj, CompileOptions options,
}
extern JS_PUBLIC_API(bool)
JS::Evaluate(JSContext *cx, HandleObject obj, CompileOptions options,
JS::Evaluate(JSContext *cx, HandleObject obj, const ReadOnlyCompileOptions &options,
const char *bytes, size_t length, jsval *rval)
{
jschar *chars;
@ -4746,7 +4825,7 @@ JS::Evaluate(JSContext *cx, HandleObject obj, CompileOptions options,
}
extern JS_PUBLIC_API(bool)
JS::Evaluate(JSContext *cx, HandleObject obj, CompileOptions options,
JS::Evaluate(JSContext *cx, HandleObject obj, const ReadOnlyCompileOptions &optionsArg,
const char *filename, jsval *rval)
{
FileContents buffer(cx);
@ -4756,6 +4835,7 @@ JS::Evaluate(JSContext *cx, HandleObject obj, CompileOptions options,
return false;
}
CompileOptions options(cx, optionsArg);
options.setFileAndLine(filename, 1);
return Evaluate(cx, obj, options, buffer.begin(), buffer.length(), rval);
}

Просмотреть файл

@ -3321,23 +3321,102 @@ JS_CompileUCFunction(JSContext *cx, JSObject *obj, const char *name,
namespace JS {
/* Options for JavaScript compilation. */
class JS_PUBLIC_API(CompileOptions)
/*
* In the most common use case, a CompileOptions instance is allocated on the
* stack, and holds non-owning references to non-POD option values: strings;
* principals; objects; and so on. The code declaring the instance guarantees
* that such option values will outlive the CompileOptions itself: objects are
* otherwise rooted; principals have had their reference counts bumped; strings
* will not be freed until the CompileOptions goes out of scope. In this
* situation, CompileOptions only refers to things others own, so it can be
* lightweight.
*
* In some cases, however, we need to hold compilation options with a
* non-stack-like lifetime. For example, JS::CompileOffThread needs to save
* compilation options where a worker thread can find them, and then return
* immediately. The worker thread will come along at some later point, and use
* the options.
*
* The compiler itself just needs to be able to access a collection of options;
* it doesn't care who owns them, or what's keeping them alive. It does its own
* addrefs/copies/tracing/etc.
*
* So, we have a class hierarchy that reflects these three use cases:
*
* - ReadOnlyCompileOptions is the common base class. It can be used by code
* that simply needs to access options set elsewhere, like the compiler.
*
* - The usual CompileOptions class must be stack-allocated, and holds
* non-owning references to the filename, element, and so on. It's derived
* from ReadOnlyCompileOptions, so the compiler can use it.
*
* - OwningCompileOptions roots / copies / reference counts of all its values,
* and unroots / frees / releases them when it is destructed. It too is
* derived from ReadOnlyCompileOptions, so the compiler accepts it.
*/
/*
* The common base class for the CompileOptions hierarchy.
*
* Use this in code that only needs to access compilation options created
* elsewhere, like the compiler. Don't instantiate this class (the constructor
* is protected anyway); instead, create instances only of the derived classes:
* CompileOptions and OwningCompileOptions.
*/
class JS_PUBLIC_API(ReadOnlyCompileOptions)
{
protected:
JSPrincipals *principals_;
JSPrincipals *originPrincipals_;
const char *filename_;
const jschar *sourceMapURL_;
// This constructor leaves 'version' set to JSVERSION_UNKNOWN. The structure
// is unusable until that's set to something more specific; the derived
// classes' constructors take care of that, in ways appropriate to their
// purpose.
ReadOnlyCompileOptions()
: principals_(nullptr),
originPrincipals_(nullptr),
filename_(nullptr),
sourceMapURL_(nullptr),
version(JSVERSION_UNKNOWN),
versionSet(false),
utf8(false),
lineno(1),
column(0),
compileAndGo(false),
forEval(false),
noScriptRval(false),
selfHostingMode(false),
canLazilyParse(true),
strictOption(false),
extraWarningsOption(false),
werrorOption(false),
asmJSOption(false),
sourcePolicy(SAVE_SOURCE)
{ }
// Set all POD options (those not requiring reference counts, copies,
// rooting, or other hand-holding) to their values in |rhs|.
void copyPODOptions(const ReadOnlyCompileOptions &rhs);
public:
// Read-only accessors for non-POD options. The proper way to set these
// depends on the derived type.
JSPrincipals *principals() const { return principals_; }
JSPrincipals *originPrincipals() const;
const char *filename() const { return filename_; }
const jschar *sourceMapURL() const { return sourceMapURL_; }
virtual JSObject *element() const = 0;
// POD options.
JSVersion version;
bool versionSet;
bool utf8;
const char *filename;
const jschar *sourceMapURL;
unsigned lineno;
unsigned column;
Handle<JSObject*> element;
bool compileAndGo;
bool forEval;
bool noScriptRval;
@ -3353,17 +3432,120 @@ class JS_PUBLIC_API(CompileOptions)
SAVE_SOURCE
} sourcePolicy;
explicit CompileOptions(JSContext *cx, JSVersion version = JSVERSION_UNKNOWN);
CompileOptions &setPrincipals(JSPrincipals *p) { principals_ = p; return *this; }
CompileOptions &setOriginPrincipals(JSPrincipals *p) { originPrincipals_ = p; return *this; }
CompileOptions &setVersion(JSVersion v) { version = v; versionSet = true; return *this; }
CompileOptions &setUTF8(bool u) { utf8 = u; return *this; }
CompileOptions &setFileAndLine(const char *f, unsigned l) {
filename = f; lineno = l; return *this;
private:
static JSObject * const nullObjectPtr;
void operator=(const ReadOnlyCompileOptions &) MOZ_DELETE;
};
/*
* Compilation options, with dynamic lifetime. An instance of this type
* makes a copy of / holds / roots all dynamically allocated resources
* (principals; elements; strings) that it refers to. Its destructor frees
* / drops / unroots them. This is heavier than CompileOptions, below, but
* unlike CompileOptions, it can outlive any given stack frame.
*
* Note that this *roots* any JS values it refers to - they're live
* unconditionally. Thus, instances of this type can't be owned, directly
* or indirectly, by a JavaScript object: if any value that this roots ever
* comes to refer to the object that owns this, then the whole cycle, and
* anything else it entrains, will never be freed.
*/
class JS_PUBLIC_API(OwningCompileOptions) : public ReadOnlyCompileOptions
{
JSRuntime *runtime;
PersistentRootedObject elementRoot;
public:
// A minimal constructor, for use with OwningCompileOptions::copy. This
// leaves |this.version| set to JSVERSION_UNKNOWN; the instance
// shouldn't be used until we've set that to something real (as |copy|
// will).
explicit OwningCompileOptions(JSContext *cx);
~OwningCompileOptions();
JSObject *element() const MOZ_OVERRIDE { return elementRoot; }
// Set this to a copy of |rhs|. Return false on OOM.
bool copy(JSContext *cx, const ReadOnlyCompileOptions &rhs);
/* These setters make copies of their string arguments, and are fallible. */
bool setFileAndLine(JSContext *cx, const char *f, unsigned l);
bool setSourceMapURL(JSContext *cx, const jschar *s);
/* These setters are infallible, and can be chained. */
OwningCompileOptions &setElement(JSObject *e) { elementRoot = e; return *this; }
OwningCompileOptions &setPrincipals(JSPrincipals *p) {
if (p) JS_HoldPrincipals(p);
if (principals_) JS_DropPrincipals(runtime, principals_);
principals_ = p;
return *this;
}
CompileOptions &setSourceMapURL(const jschar *s) { sourceMapURL = s; return *this; }
OwningCompileOptions &setOriginPrincipals(JSPrincipals *p) {
if (p) JS_HoldPrincipals(p);
if (originPrincipals_) JS_DropPrincipals(runtime, originPrincipals_);
originPrincipals_ = p;
return *this;
}
OwningCompileOptions &setVersion(JSVersion v) {
version = v;
versionSet = true;
return *this;
}
OwningCompileOptions &setUTF8(bool u) { utf8 = u; return *this; }
OwningCompileOptions &setColumn(unsigned c) { column = c; return *this; }
OwningCompileOptions &setCompileAndGo(bool cng) { compileAndGo = cng; return *this; }
OwningCompileOptions &setForEval(bool eval) { forEval = eval; return *this; }
OwningCompileOptions &setNoScriptRval(bool nsr) { noScriptRval = nsr; return *this; }
OwningCompileOptions &setSelfHostingMode(bool shm) { selfHostingMode = shm; return *this; }
OwningCompileOptions &setCanLazilyParse(bool clp) { canLazilyParse = clp; return *this; }
OwningCompileOptions &setSourcePolicy(SourcePolicy sp) { sourcePolicy = sp; return *this; }
};
/*
* Compilation options stored on the stack. An instance of this type
* simply holds references to dynamically allocated resources (element;
* filename; source map URL) that are owned by something else. If you
* create an instance of this type, it's up to you to guarantee that
* everything you store in it will outlive it.
*/
class MOZ_STACK_CLASS JS_PUBLIC_API(CompileOptions) : public ReadOnlyCompileOptions
{
RootedObject elementRoot;
public:
explicit CompileOptions(JSContext *cx, JSVersion version = JSVERSION_UNKNOWN);
CompileOptions(js::ContextFriendFields *cx, const ReadOnlyCompileOptions &rhs)
: ReadOnlyCompileOptions(), elementRoot(cx)
{
copyPODOptions(rhs);
principals_ = rhs.principals();
originPrincipals_ = rhs.originPrincipals();
filename_ = rhs.filename();
sourceMapURL_ = rhs.sourceMapURL();
elementRoot = rhs.element();
}
JSObject *element() const MOZ_OVERRIDE { return elementRoot; }
CompileOptions &setFileAndLine(const char *f, unsigned l) {
filename_ = f; lineno = l; return *this;
}
CompileOptions &setSourceMapURL(const jschar *s) { sourceMapURL_ = s; return *this; }
CompileOptions &setElement(JSObject *e) { elementRoot = e; return *this; }
CompileOptions &setPrincipals(JSPrincipals *p) { principals_ = p; return *this; }
CompileOptions &setOriginPrincipals(JSPrincipals *p) {
originPrincipals_ = p;
return *this;
}
CompileOptions &setVersion(JSVersion v) {
version = v;
versionSet = true;
return *this;
}
CompileOptions &setUTF8(bool u) { utf8 = u; return *this; }
CompileOptions &setColumn(unsigned c) { column = c; return *this; }
CompileOptions &setElement(Handle<JSObject*> e) { element.repoint(e); return *this; }
CompileOptions &setCompileAndGo(bool cng) { compileAndGo = cng; return *this; }
CompileOptions &setForEval(bool eval) { forEval = eval; return *this; }
CompileOptions &setNoScriptRval(bool nsr) { noScriptRval = nsr; return *this; }
@ -3373,21 +3555,21 @@ class JS_PUBLIC_API(CompileOptions)
};
extern JS_PUBLIC_API(JSScript *)
Compile(JSContext *cx, JS::Handle<JSObject*> obj, CompileOptions options,
Compile(JSContext *cx, JS::Handle<JSObject*> obj, const ReadOnlyCompileOptions &options,
const char *bytes, size_t length);
extern JS_PUBLIC_API(JSScript *)
Compile(JSContext *cx, JS::Handle<JSObject*> obj, CompileOptions options,
Compile(JSContext *cx, JS::Handle<JSObject*> obj, const ReadOnlyCompileOptions &options,
const jschar *chars, size_t length);
extern JS_PUBLIC_API(JSScript *)
Compile(JSContext *cx, JS::Handle<JSObject*> obj, CompileOptions options, FILE *file);
Compile(JSContext *cx, JS::Handle<JSObject*> obj, const ReadOnlyCompileOptions &options, FILE *file);
extern JS_PUBLIC_API(JSScript *)
Compile(JSContext *cx, JS::Handle<JSObject*> obj, CompileOptions options, const char *filename);
Compile(JSContext *cx, JS::Handle<JSObject*> obj, const ReadOnlyCompileOptions &options, const char *filename);
extern JS_PUBLIC_API(bool)
CanCompileOffThread(JSContext *cx, const CompileOptions &options);
CanCompileOffThread(JSContext *cx, const ReadOnlyCompileOptions &options);
/*
* Off thread compilation control flow.
@ -3406,7 +3588,7 @@ CanCompileOffThread(JSContext *cx, const CompileOptions &options);
*/
extern JS_PUBLIC_API(bool)
CompileOffThread(JSContext *cx, Handle<JSObject*> obj, CompileOptions options,
CompileOffThread(JSContext *cx, Handle<JSObject*> obj, const ReadOnlyCompileOptions &options,
const jschar *chars, size_t length,
OffThreadCompileCallback callback, void *callbackData);
@ -3414,12 +3596,12 @@ extern JS_PUBLIC_API(JSScript *)
FinishOffThreadScript(JSContext *maybecx, JSRuntime *rt, void *token);
extern JS_PUBLIC_API(JSFunction *)
CompileFunction(JSContext *cx, JS::Handle<JSObject*> obj, CompileOptions options,
CompileFunction(JSContext *cx, JS::Handle<JSObject*> obj, const ReadOnlyCompileOptions &options,
const char *name, unsigned nargs, const char *const *argnames,
const char *bytes, size_t length);
extern JS_PUBLIC_API(JSFunction *)
CompileFunction(JSContext *cx, JS::Handle<JSObject*> obj, CompileOptions options,
CompileFunction(JSContext *cx, JS::Handle<JSObject*> obj, const ReadOnlyCompileOptions &options,
const char *name, unsigned nargs, const char *const *argnames,
const jschar *chars, size_t length);
@ -3545,15 +3727,15 @@ JS_EvaluateUCScriptForPrincipalsVersionOrigin(JSContext *cx, JSObject *obj,
namespace JS {
extern JS_PUBLIC_API(bool)
Evaluate(JSContext *cx, JS::Handle<JSObject*> obj, CompileOptions options,
Evaluate(JSContext *cx, JS::Handle<JSObject*> obj, const ReadOnlyCompileOptions &options,
const jschar *chars, size_t length, jsval *rval);
extern JS_PUBLIC_API(bool)
Evaluate(JSContext *cx, JS::Handle<JSObject*> obj, CompileOptions options,
Evaluate(JSContext *cx, JS::Handle<JSObject*> obj, const ReadOnlyCompileOptions &options,
const char *bytes, size_t length, jsval *rval);
extern JS_PUBLIC_API(bool)
Evaluate(JSContext *cx, JS::Handle<JSObject*> obj, CompileOptions options,
Evaluate(JSContext *cx, JS::Handle<JSObject*> obj, const ReadOnlyCompileOptions &options,
const char *filename, jsval *rval);
} /* namespace JS */
@ -4416,7 +4598,7 @@ typedef void
// engine, it is critical that the buildId shall change for each new build of
// the JS engine.
typedef bool
(* BuildIdOp)(mozilla::Vector<char> *buildId);
(* BuildIdOp)(js::Vector<char> *buildId);
struct AsmJSCacheOps
{

Просмотреть файл

@ -370,7 +370,7 @@ cvt_ws(SprintfState *ss, const jschar *ws, int width, int prec, int flags)
int result;
/*
* Supply nullptr as the JSContext; errors are not reported,
* and malloc() is used to allocate the buffer buffer.
* and js_malloc() is used to allocate the buffer.
*/
if (ws) {
size_t wslen = js_strlen(ws);
@ -445,7 +445,7 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv,
if( number > NAS_DEFAULT_NUM ){
nas = (struct NumArgState*)malloc( number * sizeof( struct NumArgState ) );
nas = (struct NumArgState*)js_malloc( number * sizeof( struct NumArgState ) );
if( !nas ){
*rv = -1;
return nullptr;
@ -1040,7 +1040,7 @@ JS_PUBLIC_API(uint32_t) JS_vsxprintf(JSStuffFunc func, void *arg,
}
/*
** Stuff routine that automatically grows the malloc'd output buffer
** Stuff routine that automatically grows the js_malloc'd output buffer
** before it overflows.
*/
static int GrowStuff(SprintfState *ss, const char *sp, uint32_t len)
@ -1073,7 +1073,7 @@ static int GrowStuff(SprintfState *ss, const char *sp, uint32_t len)
}
/*
** sprintf into a malloc'd buffer
** sprintf into a js_malloc'd buffer
*/
JS_PUBLIC_API(char *) JS_smprintf(const char *fmt, ...)
{

Просмотреть файл

@ -35,6 +35,8 @@ class Rooted;
class JS_PUBLIC_API(AutoGCRooter);
class JS_PUBLIC_API(CompileOptions);
class JS_PUBLIC_API(ReadOnlyCompileOptions);
class JS_PUBLIC_API(OwningCompileOptions);
class JS_PUBLIC_API(CompartmentOptions);
struct Zone;

Просмотреть файл

@ -1670,7 +1670,7 @@ JSScript::initCompartment(ExclusiveContext *cx)
JSScript *
JSScript::Create(ExclusiveContext *cx, HandleObject enclosingScope, bool savedCallerFun,
const CompileOptions &options, unsigned staticLevel,
const ReadOnlyCompileOptions &options, unsigned staticLevel,
HandleScriptSource sourceObject, uint32_t bufStart, uint32_t bufEnd)
{
JS_ASSERT(bufStart <= bufEnd);

Просмотреть файл

@ -639,7 +639,7 @@ class JSScript : public js::gc::BarrieredCell<JSScript>
public:
static JSScript *Create(js::ExclusiveContext *cx,
js::HandleObject enclosingScope, bool savedCallerFun,
const JS::CompileOptions &options, unsigned staticLevel,
const JS::ReadOnlyCompileOptions &options, unsigned staticLevel,
js::HandleScriptSource sourceObject, uint32_t sourceStart,
uint32_t sourceEnd);

Просмотреть файл

@ -174,31 +174,29 @@ static const JSClass workerGlobalClass = {
JS_ConvertStub, nullptr
};
ParseTask::ParseTask(ExclusiveContext *cx, const CompileOptions &options,
ParseTask::ParseTask(ExclusiveContext *cx, JSContext *initCx,
const jschar *chars, size_t length, JSObject *scopeChain,
JS::OffThreadCompileCallback callback, void *callbackData)
: cx(cx), options(options), chars(chars), length(length),
: cx(cx), options(initCx), chars(chars), length(length),
alloc(JSRuntime::TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE), scopeChain(scopeChain),
callback(callback), callbackData(callbackData), script(nullptr), errors(cx)
{
JSRuntime *rt = scopeChain->runtimeFromMainThread();
if (options.principals())
JS_HoldPrincipals(options.principals());
if (options.originPrincipals())
JS_HoldPrincipals(options.originPrincipals());
if (!AddObjectRoot(rt, &this->scopeChain, "ParseTask::scopeChain"))
MOZ_CRASH();
}
bool
ParseTask::init(JSContext *cx, const ReadOnlyCompileOptions &options)
{
return this->options.copy(cx, options);
}
ParseTask::~ParseTask()
{
JSRuntime *rt = scopeChain->runtimeFromMainThread();
if (options.principals())
JS_DropPrincipals(rt, options.principals());
if (options.originPrincipals())
JS_DropPrincipals(rt, options.originPrincipals());
JS_RemoveObjectRootRT(rt, &scopeChain);
// ParseTask takes over ownership of its input exclusive context.
@ -209,7 +207,7 @@ ParseTask::~ParseTask()
}
bool
js::StartOffThreadParseScript(JSContext *cx, const CompileOptions &options,
js::StartOffThreadParseScript(JSContext *cx, const ReadOnlyCompileOptions &options,
const jschar *chars, size_t length, HandleObject scopeChain,
JS::OffThreadCompileCallback callback, void *callbackData)
{
@ -267,9 +265,9 @@ js::StartOffThreadParseScript(JSContext *cx, const CompileOptions &options,
workercx->enterCompartment(global->compartment());
ScopedJSDeletePtr<ParseTask> task(
cx->new_<ParseTask>(workercx.get(), options, chars, length,
cx->new_<ParseTask>(workercx.get(), cx, chars, length,
scopeChain, callback, callbackData));
if (!task)
if (!task || !task->init(cx, options))
return false;
workercx.forget();
@ -1055,7 +1053,7 @@ js::CancelOffThreadIonCompile(JSCompartment *compartment, JSScript *script)
}
bool
js::StartOffThreadParseScript(JSContext *cx, const CompileOptions &options,
js::StartOffThreadParseScript(JSContext *cx, const ReadOnlyCompileOptions &options,
const jschar *chars, size_t length, HandleObject scopeChain,
JS::OffThreadCompileCallback callback, void *callbackData)
{

Просмотреть файл

@ -245,7 +245,7 @@ CancelOffThreadIonCompile(JSCompartment *compartment, JSScript *script);
* alive until the compilation finishes.
*/
bool
StartOffThreadParseScript(JSContext *cx, const CompileOptions &options,
StartOffThreadParseScript(JSContext *cx, const ReadOnlyCompileOptions &options,
const jschar *chars, size_t length, HandleObject scopeChain,
JS::OffThreadCompileCallback callback, void *callbackData);
@ -391,7 +391,7 @@ struct AsmJSParallelTask
struct ParseTask
{
ExclusiveContext *cx;
CompileOptions options;
OwningCompileOptions options;
const jschar *chars;
size_t length;
LifoAlloc alloc;
@ -414,9 +414,10 @@ struct ParseTask
// when finishing the script.
Vector<frontend::CompileError *> errors;
ParseTask(ExclusiveContext *cx, const CompileOptions &options,
ParseTask(ExclusiveContext *cx, JSContext *initCx,
const jschar *chars, size_t length, JSObject *scopeChain,
JS::OffThreadCompileCallback callback, void *callbackData);
bool init(JSContext *cx, const ReadOnlyCompileOptions &options);
~ParseTask();
};

Просмотреть файл

@ -291,7 +291,7 @@ GetLine(FILE *file, const char * prompt)
}
if (len + 1 == size) {
size = size * 2;
char *tmp = (char *) realloc(buffer, size);
char *tmp = (char *) js_realloc(buffer, size);
if (!tmp) {
free(buffer);
return nullptr;
@ -336,7 +336,7 @@ NewContextData()
return nullptr;
JSShellContextData *data = (JSShellContextData *)
calloc(sizeof(JSShellContextData), 1);
js_calloc(sizeof(JSShellContextData), 1);
if (!data)
return nullptr;
data->startTime = PRMJ_Now();
@ -458,10 +458,9 @@ EvalAndPrint(JSContext *cx, Handle<JSObject*> global, const char *bytes, size_t
{
// Eval.
JS::CompileOptions options(cx);
options.utf8 = true;
options.compileAndGo = true;
options.filename = "typein";
options.lineno = lineno;
options.setUTF8(true)
.setCompileAndGo(true)
.setFileAndLine("typein", lineno);
RootedScript script(cx);
script = JS::Compile(cx, global, options, bytes, length);
if (!script)
@ -5169,12 +5168,12 @@ ShellCloseAsmJSCacheEntryForWrite(HandleObject global, size_t serializedSize, ui
}
static bool
ShellBuildId(mozilla::Vector<char> *buildId)
ShellBuildId(js::Vector<char> *buildId)
{
// The browser embeds the date into the buildid and the buildid is embedded
// in the binary, so every 'make' necessarily builds a new firefox binary.
// Fortunately, the actual firefox executable is tiny -- all the code is in
// libxul.so and other shared modules -- so this isn't a big deal. No so
// libxul.so and other shared modules -- so this isn't a big deal. Not so
// for the statically-linked JS shell. To avoid recompmiling js.cpp and
// re-linking 'js' on every 'make', we use a constant buildid and rely on
// the shell user to manually clear the cache (deleting the dir passed to

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше