This commit is contained in:
Ryan VanderMeulen 2016-08-19 09:52:53 -04:00
Родитель 775bb69951 dc0f8c6c81
Коммит 01c4e8cc1b
843 изменённых файлов: 40908 добавлений и 36167 удалений

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

@ -525,8 +525,7 @@ Accessible::ChildAtPoint(int32_t aX, int32_t aY,
nsIWidget* rootWidget = rootFrame->GetView()->GetNearestWidget(nullptr);
NS_ENSURE_TRUE(rootWidget, nullptr);
LayoutDeviceIntRect rootRect;
rootWidget->GetScreenBounds(rootRect);
LayoutDeviceIntRect rootRect = rootWidget->GetScreenBounds();
WidgetMouseEvent dummyEvent(true, eMouseMove, rootWidget,
WidgetMouseEvent::eSynthesized);

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

@ -173,6 +173,40 @@ OuterDocAccessible::IsAcceptableChild(nsIContent* aEl) const
return false;
}
#if defined(XP_WIN)
// On Windows e10s, since we don't cache in the chrome process, these next two
// functions must be implemented so that we properly cross the chrome-to-content
// boundary when traversing.
uint32_t
OuterDocAccessible::ChildCount() const
{
uint32_t result = mChildren.Length();
if (!result && RemoteChildDoc()) {
result = 1;
}
return result;
}
Accessible*
OuterDocAccessible::GetChildAt(uint32_t aIndex) const
{
Accessible* result = AccessibleWrap::GetChildAt(aIndex);
if (result || aIndex) {
return result;
}
// If we are asking for child 0 and GetChildAt doesn't return anything, try
// to get the remote child doc and return that instead.
ProxyAccessible* remoteChild = RemoteChildDoc();
if (!remoteChild) {
return nullptr;
}
return WrapperFor(remoteChild);
}
#endif // defined(XP_WIN)
ProxyAccessible*
OuterDocAccessible::RemoteChildDoc() const
{

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

@ -40,6 +40,11 @@ public:
virtual bool RemoveChild(Accessible* aAccessible) override;
virtual bool IsAcceptableChild(nsIContent* aEl) const override;
#if defined(XP_WIN)
virtual uint32_t ChildCount() const override;
virtual Accessible* GetChildAt(uint32_t aIndex) const override;
#endif // defined(XP_WIN)
protected:
virtual ~OuterDocAccessible() override;
};
@ -53,4 +58,4 @@ Accessible::AsOuterDoc()
} // namespace a11y
} // namespace mozilla
#endif
#endif

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

@ -9,6 +9,7 @@ support-files =
doc_content_text.html
!/accessible/tests/mochitest/*.js
!/accessible/tests/mochitest/moz.png
skip-if = os == 'win'
[test_alive.html]
[test_content_integration.html]

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

@ -7,6 +7,8 @@
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="../common.js"></script>
@ -73,34 +75,45 @@
////////////////////////////////////////////////////////////////////////////
// 'invalid' state
// XXX: maxlength doesn't make the element invalid until bug 613016 and
// bug 613019 are fixed. Commenting out related lines and adding a todo to
// make sure it will be uncommented as soon as possible.
var todoInput = document.createElement("input");
todoInput.maxLength = '2';
todoInput.value = 'foo';
todo(!todoInput.validity.valid,
"input should be invalid because of maxlength");
// invalid/valid state
//var invalid = ["maxlength","pattern","email","url"];
//document.getElementById("maxlength").value = "i am too long";
var invalid = ["pattern","email","url"];
for (i in invalid) {
testStates(invalid[i], STATE_INVALID);
testStates(invalid[i] + "2", 0, 0, STATE_INVALID);
}
// invalid/valid state
//var invalid = ["maxlength","pattern","email","url"];
//document.getElementById("maxlength").value = "i am too long";
var invalid = ["pattern","email","url"];
for (i in invalid) {
testStates(invalid[i], STATE_INVALID);
testStates(invalid[i] + "2", 0, 0, STATE_INVALID);
////////////////////////////////////////////////////////////////////////////
// not 'invalid' state
// (per spec, min/maxlength are always valid until interactively edited)
var validInput = document.createElement("input");
validInput.maxLength = '0';
validInput.value = 'a';
ok(validInput.validity.valid,
"input should be valid despite maxlength (no interactive edits)");
var validInput2 = document.createElement("input");
validInput2.minLength = '1';
validInput2.value = '';
ok(validInput2.validity.valid,
"input should be valid despite minlength (no interactive edits)");
var valid = ["minlength","maxlength"];
for (i in valid) {
testStates(valid[i], 0, 0, STATE_INVALID);
testStates(valid[i] + "2", 0, 0, STATE_INVALID);
}
////////////////////////////////////////////////////////////////////////////
// 'invalid' state
// (per spec, min/maxlength validity is affected by interactive edits)
var mininp = document.getElementById("minlength");
mininp.focus();
synthesizeKey("VK_BACK_SPACE", {});
ok(!mininp.validity.valid,
"input should be invalid after interactive edits");
testStates(mininp, STATE_INVALID);
// inputs currently cannot be made longer than maxlength interactively,
// so we're not testing that case.
////////////////////////////////////////////////////////////////////////////
// autocomplete states
testStates("autocomplete-default", 0, EXT_STATE_SUPPORTS_AUTOCOMPLETION);
@ -214,18 +227,10 @@
<input id="file" type="file" required disabled>
<!-- invalid/valid -->
<input id="maxlength" maxlength="1">
<input id="maxlength2" maxlength="100" value="foo">
<input id="pattern" pattern="bar" value="foo">
<input id="pattern2" pattern="bar" value="bar">
<input id="email" type="email" value="foo">
<input id="email2" type="email" value="foo@bar.com">
<input id="url" type="url" value="foo">
<input id="url2" type="url" value="http://mozilla.org/">
<!-- invalid/valid -->
<input id="maxlength" maxlength="1">
<input id="maxlength" maxlength="1" value="f">
<input id="maxlength2" maxlength="100" value="foo">
<input id="minlength" minlength="2" value="fo">
<input id="minlength2" minlength="1" value="foo">
<input id="pattern" pattern="bar" value="foo">
<input id="pattern2" pattern="bar" value="bar">
<input id="email" type="email" value="foo">

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

@ -104,13 +104,11 @@ pref("app.update.log", false);
// the failure.
pref("app.update.backgroundMaxErrors", 10);
// The aus update xml certificate checks for application update are disabled on
// Windows, Mac OS X, and Linux since the mar signature check are implemented on
// these platforms and is sufficient to prevent us from applying a mar that is
// not valid. Bug 1182352 will remove the update xml certificate checks and the
// following two preferences.
// When |app.update.cert.requireBuiltIn| is true or not specified the
// final certificate and all certificates the connection is redirected to before
// the final certificate for the url specified in the |app.update.url|
// preference must be built-in.
pref("app.update.cert.requireBuiltIn", false);
pref("app.update.cert.checkAttributes", false);
// Whether or not app updates are enabled
pref("app.update.enabled", true);

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

@ -2275,6 +2275,7 @@ function BrowserViewSourceOfDocument(aArgsOrDocument) {
relatedToCurrent: true,
inBackground: false,
forceNotRemote,
relatedBrowser: args.browser
});
args.viewSourceBrowser = tabBrowser.getBrowserForTab(tab);
top.gViewSourceUtils.viewSourceInBrowser(args);
@ -3237,7 +3238,8 @@ var PrintPreviewListener = {
this._tabBeforePrintPreview = gBrowser.selectedTab;
this._printPreviewTab = gBrowser.loadOneTab("about:blank",
{ inBackground: false,
forceNotRemote });
forceNotRemote,
relatedBrowser: browser });
gBrowser.selectedTab = this._printPreviewTab;
}
return gBrowser.getBrowserForTab(this._printPreviewTab);

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

@ -1483,6 +1483,7 @@
var aForceNotRemote;
var aNoReferrer;
var aUserContextId;
var aRelatedBrowser;
if (arguments.length == 2 &&
typeof arguments[1] == "object" &&
!(arguments[1] instanceof Ci.nsIURI)) {
@ -1500,6 +1501,7 @@
aForceNotRemote = params.forceNotRemote;
aNoReferrer = params.noReferrer;
aUserContextId = params.userContextId;
aRelatedBrowser = params.relatedBrowser;
}
var bgLoad = (aLoadInBackground != null) ? aLoadInBackground :
@ -1518,7 +1520,8 @@
allowMixedContent: aAllowMixedContent,
forceNotRemote: aForceNotRemote,
noReferrer: aNoReferrer,
userContextId: aUserContextId });
userContextId: aUserContextId,
relatedBrowser: aRelatedBrowser });
if (!bgLoad)
this.selectedTab = tab;
@ -1811,6 +1814,10 @@
b.setAttribute("autoscrollpopup", this._autoScrollPopup.id);
if (aParams.relatedBrowser) {
b.relatedBrowser = aParams.relatedBrowser;
}
// Create the browserStack container
var stack = document.createElementNS(NS_XUL, "stack");
stack.className = "browserStack";
@ -1889,7 +1896,8 @@
browser = this._createBrowser({permanentKey: aTab.permanentKey,
remote: remote,
uriIsAboutBlank: uriIsAboutBlank,
userContextId: aParams.userContextId});
userContextId: aParams.userContextId,
relatedBrowser: aParams.relatedBrowser});
}
let notificationbox = this.getNotificationBox(browser);
@ -1963,6 +1971,7 @@
var aNoReferrer;
var aUserContextId;
var aEventDetail;
var aRelatedBrowser;
if (arguments.length == 2 &&
typeof arguments[1] == "object" &&
!(arguments[1] instanceof Ci.nsIURI)) {
@ -1981,6 +1990,7 @@
aNoReferrer = params.noReferrer;
aUserContextId = params.userContextId;
aEventDetail = params.eventDetail;
aRelatedBrowser = params.relatedBrowser;
}
// if we're adding tabs, we're past interrupt mode, ditch the owner
@ -2047,7 +2057,8 @@
// of tab.linkedBrowser.
let browserParams = {
forceNotRemote: aForceNotRemote,
userContextId: aUserContextId
userContextId: aUserContextId,
relatedBrowser: aRelatedBrowser
};
let { usingPreloadedContent } = this._linkBrowserToTab(t, aURI, browserParams);
let b = t.linkedBrowser;

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

@ -9,6 +9,10 @@ Cu.import("resource://gre/modules/Promise.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://testing-common/AddonManagerTesting.jsm");
Cu.import("resource://testing-common/AddonTestUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
"resource://gre/modules/AddonManager.jsm");
const PREF_EXPERIMENTS_ENABLED = "experiments.enabled";
const PREF_LOGGING_LEVEL = "experiments.logging.level";
@ -127,16 +131,16 @@ function dateToSeconds(date) {
var gGlobalScope = this;
function loadAddonManager() {
let ns = {};
Cu.import("resource://gre/modules/Services.jsm", ns);
let head = "../../../../toolkit/mozapps/extensions/test/xpcshell/head_addons.js";
let file = do_get_file(head);
let uri = ns.Services.io.newFileURI(file);
ns.Services.scriptloader.loadSubScript(uri.spec, gGlobalScope);
AddonTestUtils.init(gGlobalScope);
AddonTestUtils.overrideCertDB();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
startupManager();
return AddonTestUtils.promiseStartupManager();
}
const {
promiseRestartManager,
} = AddonTestUtils;
// Starts the addon manager without creating app info. We can't directly use
// |loadAddonManager| defined above in test_conditions.js as it would make the test fail.
function startAddonManagerOnly() {
@ -162,13 +166,8 @@ function getExperimentAddons(previous=false) {
function createAppInfo(ID="xpcshell@tests.mozilla.org", name="XPCShell",
version="1.0", platformVersion="1.0") {
let tmp = {};
Cu.import("resource://testing-common/AppInfo.jsm", tmp);
tmp.updateAppInfo({
ID, name, version, platformVersion,
crashReporter: true,
});
gAppInfo = tmp.getAppInfo();
AddonTestUtils.createAppInfo(ID, name, version, platformVersion);
gAppInfo = AddonTestUtils.appInfo;
}
/**

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

@ -28,7 +28,7 @@ function uninstallExperimentAddons() {
return Task.spawn(function* () {
let addons = yield getExperimentAddons();
for (let a of addons) {
yield AddonTestUtils.uninstallAddonByID(a.id);
yield AddonManagerTesting.uninstallAddonByID(a.id);
}
});
}
@ -412,7 +412,7 @@ add_task(function* test_addonAlreadyInstalled() {
// Install conflicting addon.
yield AddonTestUtils.installXPIFromURL(gDataRoot + EXPERIMENT1_XPI_NAME, EXPERIMENT1_XPI_SHA1);
yield AddonManagerTesting.installXPIFromURL(gDataRoot + EXPERIMENT1_XPI_NAME, EXPERIMENT1_XPI_SHA1);
addons = yield getExperimentAddons();
Assert.equal(addons.length, 1, "1 add-on is installed.");
list = yield experiments.getExperiments();
@ -1407,7 +1407,7 @@ add_task(function* test_unexpectedUninstall() {
// Uninstall the addon through the addon manager instead of stopping it through
// the experiments API.
yield AddonTestUtils.uninstallAddonByID(EXPERIMENT1_ID);
yield AddonManagerTesting.uninstallAddonByID(EXPERIMENT1_ID);
yield experiments._mainTask;
yield experiments.notify();
@ -1433,7 +1433,7 @@ add_task(function* testUnknownExperimentsUninstalled() {
// Simulate us not listening.
experiments._unregisterWithAddonManager();
yield AddonTestUtils.installXPIFromURL(gDataRoot + EXPERIMENT1_XPI_NAME, EXPERIMENT1_XPI_SHA1);
yield AddonManagerTesting.installXPIFromURL(gDataRoot + EXPERIMENT1_XPI_NAME, EXPERIMENT1_XPI_SHA1);
experiments._registerWithAddonManager();
addons = yield getExperimentAddons();
@ -1472,7 +1472,7 @@ add_task(function* testForeignExperimentInstall() {
let failed = false;
try {
yield AddonTestUtils.installXPIFromURL(gDataRoot + EXPERIMENT1_XPI_NAME, EXPERIMENT1_XPI_SHA1);
yield AddonManagerTesting.installXPIFromURL(gDataRoot + EXPERIMENT1_XPI_NAME, EXPERIMENT1_XPI_SHA1);
} catch (ex) {
failed = true;
}
@ -1622,7 +1622,7 @@ add_task(function* test_foreignUninstallAndRestart() {
Assert.equal(addons.length, 1, "A single experiment add-on is installed.");
Assert.ok(addons[0].isActive, "That experiment is active.");
yield AddonTestUtils.uninstallAddonByID(EXPERIMENT1_ID);
yield AddonManagerTesting.uninstallAddonByID(EXPERIMENT1_ID);
yield experiments._mainTask;
addons = yield getExperimentAddons();

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

@ -25,18 +25,6 @@ var gManifestHandlerURI = null;
const TLOG = bsp.TELEMETRY_LOG;
var gGlobalScope = this;
function loadAddonManager() {
let ns = {};
Cu.import("resource://gre/modules/Services.jsm", ns);
let head = "../../../../toolkit/mozapps/extensions/test/xpcshell/head_addons.js";
let file = do_get_file(head);
let uri = ns.Services.io.newFileURI(file);
ns.Services.scriptloader.loadSubScript(uri.spec, gGlobalScope);
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
startupManager();
}
function checkEvent(event, id, data)
{
do_print("Checking message " + id);

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

@ -1,3 +1,3 @@
This is the pdf.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 1.5.365
Current extension version is: 1.5.385

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

@ -64,7 +64,7 @@ var PdfjsChromeUtils = {
*/
init: function () {
this._browsers = new Set();
this._browsers = new WeakSet();
if (!this._ppmm) {
// global parent process message manager (PPMM)
this._ppmm = Cc['@mozilla.org/parentprocessmessagemanager;1'].

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

@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdf = {}));
// Use strict in our context only - users might not want it
'use strict';
var pdfjsVersion = '1.5.365';
var pdfjsBuild = '19105f0';
var pdfjsVersion = '1.5.385';
var pdfjsBuild = 'a9c37c2';
var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ?

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

@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfWorker = {}));
// Use strict in our context only - users might not want it
'use strict';
var pdfjsVersion = '1.5.365';
var pdfjsBuild = '19105f0';
var pdfjsVersion = '1.5.385';
var pdfjsBuild = 'a9c37c2';
var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ?
@ -16762,8 +16762,8 @@ var RefSetCache = (function RefSetCacheClosure() {
return RefSetCache;
})();
function isName(v) {
return v instanceof Name;
function isName(v, name) {
return v instanceof Name && (name === undefined || v.name === name);
}
function isCmd(v, cmd) {
@ -16771,14 +16771,8 @@ function isCmd(v, cmd) {
}
function isDict(v, type) {
if (!(v instanceof Dict)) {
return false;
}
if (!type) {
return true;
}
var dictType = v.get('Type');
return isName(dictType) && dictType.name === type;
return v instanceof Dict &&
(type === undefined || isName(v.get('Type'), type));
}
function isRef(v) {
@ -23148,7 +23142,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
function CipherTransformFactory(dict, fileId, password) {
var filter = dict.get('Filter');
if (!isName(filter) || filter.name !== 'Standard') {
if (!isName(filter, 'Standard')) {
error('unknown encryption method');
}
this.dict = dict;
@ -24105,10 +24099,11 @@ function isEOF(v) {
var MAX_LENGTH_TO_CACHE = 1000;
var Parser = (function ParserClosure() {
function Parser(lexer, allowStreams, xref) {
function Parser(lexer, allowStreams, xref, recoveryMode) {
this.lexer = lexer;
this.allowStreams = allowStreams;
this.xref = xref;
this.recoveryMode = recoveryMode || false;
this.imageCache = Object.create(null);
this.refill();
}
@ -24154,7 +24149,10 @@ var Parser = (function ParserClosure() {
array.push(this.getObj(cipherTransform));
}
if (isEOF(this.buf1)) {
error('End of file inside array');
if (!this.recoveryMode) {
error('End of file inside array');
}
return array;
}
this.shift();
return array;
@ -24175,7 +24173,10 @@ var Parser = (function ParserClosure() {
dict.set(key, this.getObj(cipherTransform));
}
if (isEOF(this.buf1)) {
error('End of file inside dictionary');
if (!this.recoveryMode) {
error('End of file inside dictionary');
}
return dict;
}
// Stream objects are not allowed inside content streams or
@ -33540,8 +33541,7 @@ var Catalog = (function CatalogClosure() {
var type = stream.dict.get('Type');
var subtype = stream.dict.get('Subtype');
if (isName(type) && isName(subtype) &&
type.name === 'Metadata' && subtype.name === 'XML') {
if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
// XXX: This should examine the charset the XML document defines,
// however since there are currently no real means to decode
// arbitrary charsets, let's just hope that the author of the PDF
@ -33750,7 +33750,7 @@ var Catalog = (function CatalogClosure() {
assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
var type = labelDict.get('Type');
assert(!type || (isName(type) && type.name === 'PageLabel'),
assert(!type || isName(type, 'PageLabel'),
'Invalid type in PageLabel dictionary.');
var s = labelDict.get('S');
@ -33828,7 +33828,7 @@ var Catalog = (function CatalogClosure() {
var javaScript = [];
function appendIfJavaScriptDict(jsDict) {
var type = jsDict.get('S');
if (!isName(type) || type.name !== 'JavaScript') {
if (!isName(type, 'JavaScript')) {
return;
}
var js = jsDict.get('JS');
@ -33856,11 +33856,11 @@ var Catalog = (function CatalogClosure() {
var openactionDict = this.catDict.get('OpenAction');
if (isDict(openactionDict, 'Action')) {
var actionType = openactionDict.get('S');
if (isName(actionType) && actionType.name === 'Named') {
if (isName(actionType, 'Named')) {
// The named Print action is not a part of the PDF 1.7 specification,
// but is supported by many PDF readers/writers (including Adobe's).
var action = openactionDict.get('N');
if (isName(action) && action.name === 'Print') {
if (isName(action, 'Print')) {
javaScript.push('print({});');
}
} else {
@ -34416,13 +34416,15 @@ var XRef = (function XRefClosure() {
var dict;
for (i = 0, ii = trailers.length; i < ii; ++i) {
stream.pos = trailers[i];
var parser = new Parser(new Lexer(stream), true, this);
var parser = new Parser(new Lexer(stream), /* allowStreams = */ true,
/* xref = */ this, /* recoveryMode = */ true);
var obj = parser.getObj();
if (!isCmd(obj, 'trailer')) {
continue;
}
// read the trailer dictionary
if (!isDict(dict = parser.getObj())) {
dict = parser.getObj();
if (!isDict(dict)) {
continue;
}
// taking the first one with 'ID'
@ -36131,7 +36133,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var groupSubtype = group.get('S');
var colorSpace;
if (isName(groupSubtype) && groupSubtype.name === 'Transparency') {
if (isName(groupSubtype, 'Transparency')) {
groupOptions.isolated = (group.get('I') || false);
groupOptions.knockout = (group.get('K') || false);
colorSpace = (group.has('CS') ?
@ -36426,7 +36428,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
gStateObj.push([key, value]);
break;
case 'SMask':
if (isName(value) && value.name === 'None') {
if (isName(value, 'None')) {
gStateObj.push([key, false]);
break;
}
@ -36734,8 +36736,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
assert(isStream(xobj), 'XObject should be a stream');
var type = xobj.dict.get('Subtype');
assert(isName(type),
'XObject should have a Name subtype');
assert(isName(type), 'XObject should have a Name subtype');
if (type.name === 'Form') {
stateManager.save();
@ -37446,8 +37447,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
assert(isStream(xobj), 'XObject should be a stream');
var type = xobj.dict.get('Subtype');
assert(isName(type),
'XObject should have a Name subtype');
assert(isName(type), 'XObject should have a Name subtype');
if ('Form' !== type.name) {
xobjsCache.key = name;
@ -39216,7 +39216,7 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
case 'Widget':
var fieldType = Util.getInheritableProperty(dict, 'FT');
if (isName(fieldType) && fieldType.name === 'Tx') {
if (isName(fieldType, 'Tx')) {
return new TextWidgetAnnotation(parameters);
}
return new WidgetAnnotation(parameters);
@ -39461,10 +39461,9 @@ var Annotation = (function AnnotationClosure() {
}
if (borderStyle.has('BS')) {
var dict = borderStyle.get('BS');
var dictType;
var dictType = dict.get('Type');
if (!dict.has('Type') || (isName(dictType = dict.get('Type')) &&
dictType.name === 'Border')) {
if (!dictType || isName(dictType, 'Border')) {
this.borderStyle.setWidth(dict.get('W'));
this.borderStyle.setStyle(dict.get('S'));
this.borderStyle.setDashArray(dict.getArray('D'));

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

@ -4641,7 +4641,7 @@ var PDFLinkService = (function PDFLinkServiceClosure() {
* @returns {number}
*/
get pagesCount() {
return this.pdfDocument.numPages;
return this.pdfDocument ? this.pdfDocument.numPages : 0;
},
/**
@ -4672,7 +4672,9 @@ var PDFLinkService = (function PDFLinkServiceClosure() {
(destRef + 1);
if (pageNumber) {
if (pageNumber > self.pagesCount) {
pageNumber = self.pagesCount;
console.error('PDFLinkService_navigateTo: ' +
'Trying to navigate to a non-existent page.');
return;
}
self.pdfViewer.scrollPageIntoView(pageNumber, dest);
@ -4849,11 +4851,15 @@ var PDFLinkService = (function PDFLinkServiceClosure() {
break;
case 'NextPage':
this.page++;
if (this.page < this.pagesCount) {
this.page++;
}
break;
case 'PrevPage':
this.page--;
if (this.page > 1) {
this.page--;
}
break;
case 'LastPage':
@ -6371,7 +6377,7 @@ var PDFViewer = (function pdfViewer() {
* @private
*/
_setCurrentPageNumber:
function pdfViewer_setCurrentPageNumber(val, resetCurrentPageView) {
function PDFViewer_setCurrentPageNumber(val, resetCurrentPageView) {
if (this._currentPageNumber === val) {
if (resetCurrentPageView) {
this._resetCurrentPageView();
@ -6380,6 +6386,8 @@ var PDFViewer = (function pdfViewer() {
}
if (!(0 < val && val <= this.pagesCount)) {
console.error('PDFViewer_setCurrentPageNumber: "' + val +
'" is out of bounds.');
return;
}
@ -6449,8 +6457,14 @@ var PDFViewer = (function pdfViewer() {
* @param {number} rotation - The rotation of the pages (0, 90, 180, 270).
*/
set pagesRotation(rotation) {
if (!(typeof rotation === 'number' && rotation % 90 === 0)) {
throw new Error('Invalid pages rotation angle.');
}
this._pagesRotation = rotation;
if (!this.pdfDocument) {
return;
}
for (var i = 0, l = this._pages.length; i < l; i++) {
var pageView = this._pages[i];
pageView.update(pageView.scale, rotation);
@ -6505,7 +6519,6 @@ var PDFViewer = (function pdfViewer() {
// rendering.
self._buffer.push(this);
};
// when page is painted, using the image as thumbnail base
pageView.onAfterDraw = function pdfViewLoadOnAfterDraw() {
if (!isOnePageRenderedResolved) {
isOnePageRenderedResolved = true;
@ -6651,7 +6664,7 @@ var PDFViewer = (function pdfViewer() {
}
},
_setScale: function pdfViewer_setScale(value, noScroll) {
_setScale: function PDFViewer_setScale(value, noScroll) {
var scale = parseFloat(value);
if (scale > 0) {
@ -6691,8 +6704,8 @@ var PDFViewer = (function pdfViewer() {
scale = Math.min(MAX_AUTO_SCALE, horizontalScale);
break;
default:
console.error('pdfViewSetScale: \'' + value +
'\' is an unknown zoom value.');
console.error('PDFViewer_setScale: "' + value +
'" is an unknown zoom value.');
return;
}
this._setScaleUpdatePages(scale, value, noScroll, true);
@ -7365,15 +7378,15 @@ var PDFViewerApplication = {
},
get pagesCount() {
return this.pdfDocument.numPages;
return this.pdfDocument ? this.pdfDocument.numPages : 0;
},
set page(val) {
this.pdfLinkService.page = val;
this.pdfViewer.currentPageNumber = val;
},
get page() { // TODO remove
return this.pdfLinkService.page;
get page() {
return this.pdfViewer.currentPageNumber;
},
get supportsPrinting() {
@ -8299,30 +8312,25 @@ function webViewerInitialized() {
}
}, true);
appConfig.sidebar.toggleButton.addEventListener('click',
function() {
PDFViewerApplication.pdfSidebar.toggle();
});
appConfig.sidebar.toggleButton.addEventListener('click', function() {
PDFViewerApplication.pdfSidebar.toggle();
});
appConfig.toolbar.previous.addEventListener('click',
function() {
PDFViewerApplication.page--;
});
appConfig.toolbar.previous.addEventListener('click', function() {
PDFViewerApplication.page--;
});
appConfig.toolbar.next.addEventListener('click',
function() {
PDFViewerApplication.page++;
});
appConfig.toolbar.next.addEventListener('click', function() {
PDFViewerApplication.page++;
});
appConfig.toolbar.zoomIn.addEventListener('click',
function() {
PDFViewerApplication.zoomIn();
});
appConfig.toolbar.zoomIn.addEventListener('click', function() {
PDFViewerApplication.zoomIn();
});
appConfig.toolbar.zoomOut.addEventListener('click',
function() {
PDFViewerApplication.zoomOut();
});
appConfig.toolbar.zoomOut.addEventListener('click', function() {
PDFViewerApplication.zoomOut();
});
appConfig.toolbar.pageNumber.addEventListener('click', function() {
this.select();
@ -8894,7 +8902,9 @@ window.addEventListener('keydown', function keydown(evt) {
/* falls through */
case 75: // 'k'
case 80: // 'p'
PDFViewerApplication.page--;
if (PDFViewerApplication.page > 1) {
PDFViewerApplication.page--;
}
handled = true;
break;
case 27: // esc key
@ -8924,7 +8934,9 @@ window.addEventListener('keydown', function keydown(evt) {
/* falls through */
case 74: // 'j'
case 78: // 'n'
PDFViewerApplication.page++;
if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
PDFViewerApplication.page++;
}
handled = true;
break;
@ -8936,8 +8948,8 @@ window.addEventListener('keydown', function keydown(evt) {
}
break;
case 35: // end
if (isViewerInPresentationMode || (PDFViewerApplication.pdfDocument &&
PDFViewerApplication.page < PDFViewerApplication.pagesCount)) {
if (isViewerInPresentationMode ||
PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
PDFViewerApplication.page = PDFViewerApplication.pagesCount;
handled = true;
ensureViewerFocused = true;
@ -8962,7 +8974,9 @@ window.addEventListener('keydown', function keydown(evt) {
pdfViewer.currentScaleValue !== 'page-fit') {
break;
}
PDFViewerApplication.page--;
if (PDFViewerApplication.page > 1) {
PDFViewerApplication.page--;
}
handled = true;
break;

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

@ -18,6 +18,12 @@ else
DEFINES += -DMOZ_MULET
endif
# When packaging an artifact build not all xpt files expected by the
# packager will be present.
ifdef MOZ_ARTIFACT_BUILDS
MOZ_PKG_FATAL_WARNINGS =
endif
DEFINES += -DMOZ_APP_NAME=$(MOZ_APP_NAME) -DPREF_DIR=$(PREF_DIR)
ifdef MOZ_DEBUG
@ -43,6 +49,10 @@ ifdef NSS_DISABLE_DBM
DEFINES += -DNSS_DISABLE_DBM=1
endif
ifdef MOZ_ARTIFACT_BUILDS
DEFINES += -DMOZ_ARTIFACT_BUILDS=1
endif
DEFINES += -DJAREXT=
ifdef MOZ_ANGLE_RENDERER

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

@ -143,6 +143,12 @@
#endif
; [Components]
#ifdef MOZ_ARTIFACT_BUILDS
@RESPATH@/components/prebuilt-interfaces.manifest
@RESPATH@/components/interfaces.xpt
@RESPATH@/browser/components/prebuilt-interfaces.manifest
@RESPATH@/browser/components/interfaces.xpt
#endif
@RESPATH@/browser/components/components.manifest
@RESPATH@/components/alerts.xpt
#ifdef ACCESSIBILITY

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

@ -32,3 +32,10 @@ TEST_DIRS += [
DIST_SUBDIR = 'browser'
export('DIST_SUBDIR')
if CONFIG['MOZ_ARTIFACT_BUILDS']:
# Ensure a pre-built interfaces.xpt installed to the objdir by the artifact
# code is included by the top-level chrome.manifest.
EXTRA_COMPONENTS += [
'../build/prebuilt-interfaces.manifest',
]

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

@ -16,7 +16,7 @@
-moz-appearance: none;
background: var(--panel-arrowcontent-background);
color: var(--panel-arrowcontent-color);
border: var(--panel-arrowcontent-border);
border: 1px solid var(--panel-arrowcontent-border-color);
margin-top: -6px;
padding-top: 1px;
}

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

@ -144,7 +144,7 @@
.panel-subviews {
padding: 4px;
background-clip: padding-box;
border-left: 1px solid var(--panel-separator-color);
border-left: 1px solid var(--panel-arrowcontent-border-color);
box-shadow: 0 3px 5px hsla(210,4%,10%,.1),
0 0 7px hsla(210,4%,10%,.1);
margin-inline-start: var(--panel-ui-exit-subview-gutter-width);

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

@ -31,7 +31,7 @@
/* emulating chrome://browser/content/places/menu.xml#places-popup-arrow but without the arrow */
box-shadow: 0 0 4px rgba(0,0,0,0.2);
background: var(--panel-arrowcontent-background);
border: var(--panel-arrowcontent-border);
border: 1px solid var(--panel-arrowcontent-border-color);
border-radius: 3.5px;
margin-top: -4px;
}

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

@ -183,7 +183,7 @@
}
}
@media (-moz-windows-compositor) {
@media (-moz-windows-glass) {
#placesToolbox {
border-top: none;
}

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

@ -2,26 +2,6 @@ dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
AC_DEFUN([MOZ_CONFIG_FFI], [
MOZ_ARG_ENABLE_BOOL(system-ffi,
[ --enable-system-ffi Use system libffi (located with pkgconfig)],
MOZ_SYSTEM_FFI=1 )
if test -n "$MOZ_SYSTEM_FFI"; then
# Vanilla libffi 3.0.9 needs a few patches from upcoming version 3.0.10
# for non-GCC compilers.
if test -z "$GNU_CC"; then
PKG_CHECK_MODULES(MOZ_FFI, libffi > 3.0.9)
else
PKG_CHECK_MODULES(MOZ_FFI, libffi >= 3.0.9)
fi
fi
AC_SUBST(MOZ_SYSTEM_FFI)
])
AC_DEFUN([MOZ_SUBCONFIGURE_FFI], [
if test "$MOZ_BUILD_APP" != js -o -n "$JS_STANDALONE"; then

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

@ -101,3 +101,10 @@ if CONFIG['MOZ_VALGRIND']:
'valgrind/i386-redhat-linux-gnu.sup',
'valgrind/x86_64-redhat-linux-gnu.sup',
]
if CONFIG['MOZ_ARTIFACT_BUILDS']:
# Ensure a pre-built interfaces.xpt installed to the objdir by the artifact
# code is included by the top-level chrome.manifest.
EXTRA_COMPONENTS += [
'prebuilt-interfaces.manifest',
]

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

@ -0,0 +1,38 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
js_option('--with-system-ffi',
help='Use system libffi (located with pkgconfig)')
use_system_ffi = depends_if('--with-system-ffi')(lambda _: True)
system_ffi = pkg_check_modules('MOZ_FFI', 'libffi > 3.0.9',
when=use_system_ffi)
set_config('MOZ_SYSTEM_FFI', system_ffi)
add_old_configure_assignment('MOZ_SYSTEM_FFI', system_ffi)
@depends(building_js, '--help')
def ctypes_default(building_js, _):
return not building_js
js_option('--enable-ctypes', help='Enable js-ctypes',
default=ctypes_default)
build_ctypes = depends_if('--enable-ctypes')(lambda _: True)
set_config('BUILD_CTYPES', build_ctypes)
set_define('BUILD_CTYPES', build_ctypes)
add_old_configure_assignment('BUILD_CTYPES', build_ctypes)
@depends(build_ctypes, building_js)
def js_has_ctypes(ctypes, js):
if ctypes and js:
return True
set_config('JS_HAS_CTYPES', js_has_ctypes)
set_define('JS_HAS_CTYPES', js_has_ctypes)
add_old_configure_assignment('JS_HAS_CTYPES', js_has_ctypes)

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

@ -169,7 +169,6 @@ def old_configure_options(*options):
'--enable-cookies',
'--enable-cpp-rtti',
'--enable-crashreporter',
'--enable-ctypes',
'--enable-dbus',
'--enable-debug-js-modules',
'--enable-directshow',
@ -209,7 +208,6 @@ def old_configure_options(*options):
'--enable-oom-breakpoint',
'--enable-optimize',
'--enable-parental-controls',
'--enable-permissions',
'--enable-pie',
'--enable-png-arm-neon-support',
'--enable-posix-nspr-emulation',
@ -234,7 +232,6 @@ def old_configure_options(*options):
'--enable-synth-pico',
'--enable-system-cairo',
'--enable-system-extension-dirs',
'--enable-system-ffi',
'--enable-system-pixman',
'--enable-system-sqlite',
'--enable-tasktracer',

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

@ -18,20 +18,20 @@ def pkg_config_version(pkg_config):
# - `package_desc` package name and version requirement string, list of
# strings describing packages to locate, or depends function that will
# resolve to such a string or list of strings.
# - `condition` a depends function that will determine whether to perform
# - `when` a depends function that will determine whether to perform
# any checks (default is to always perform checks).
# - `allow_missing` If set, failure to fulfill the package description
# will not result in an error or logged message, and any error message
# will be returned to the caller.
# Returns `True` when the package description is fulfilled.
@template
def pkg_check_modules(var, package_desc, condition=always,
def pkg_check_modules(var, package_desc, when=always,
allow_missing=False):
if isinstance(package_desc, (tuple, list)):
package_desc = ' '.join(package_desc)
package_desc = dependable(package_desc)
@depends_when(pkg_config, pkg_config_version, when=condition)
@depends_when(pkg_config, pkg_config_version, when=when)
def check_pkg_config(pkg_config, version):
min_version = '0.9.0'
if pkg_config is None:
@ -42,7 +42,7 @@ def pkg_check_modules(var, package_desc, condition=always,
die("*** Your version of pkg-config is too old. You need version %s or newer.",
min_version)
@depends_when(pkg_config, package_desc, when=condition)
@depends_when(pkg_config, package_desc, when=when)
@imports('subprocess')
@imports('sys')
@imports(_from='mozbuild.configure.util', _import='LineIO')

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

@ -0,0 +1 @@
interfaces interfaces.xpt

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

@ -126,6 +126,12 @@ nsNullPrincipalURI::SetHostPort(const nsACString &aHost)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNullPrincipalURI::SetHostAndPort(const nsACString &aHost)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNullPrincipalURI::GetOriginCharset(nsACString &_charset)
{

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

@ -310,7 +310,7 @@ EXTRA_CONFIG_DEPS := \
$(CONFIGURES): %: %.in $(EXTRA_CONFIG_DEPS)
@echo Generating $@
sed '1,/^divert/d' $< > $@
cp -f $< $@
chmod +x $@
CONFIG_STATUS_DEPS := \

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

@ -72,7 +72,9 @@ depends_files := $(foreach root,$(xpidl_modules),$(idl_deps_dir)/$(root).pp)
GARBAGE += $(xpt_files) $(depends_files)
ifdef COMPILE_ENVIRONMENT
xpidl:: $(xpt_files) $(chrome_manifests) $(interfaces_manifests)
endif
$(xpt_files): $(process_py) $(call mkdir_deps,$(idl_deps_dir) $(dist_include_dir))

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

@ -1,20 +1,21 @@
dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
dnl
dnl Welcome to the new world of configure. We're working on moving to a
dnl python based configure. In the meanwhile, remains of the old autoconf
dnl based configure is in old-configure.in.
dnl If you need to add something, please come talk to the build system
dnl peers for now.
dnl
dnl Because adding a configure file in the tree is going to conflict with
dnl existing configure files in people's (and automation) work trees, and
dnl because some automation jobs are still running autoconf and configure
dnl "manually", this file is actually an m4 file that is processed by
dnl autoconf, but doesn't call any autoconf macros. The `divert` line
dnl below ensures the script that follows is output by autoconf.
divert(0)dnl
#!/bin/sh
# 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/.
#
# Welcome to the new world of configure. We're working on moving to a
# python based configure. In the meanwhile, remains of the old autoconf
# based configure is in old-configure.in.
# If you need to add something, please come talk to the build system
# peers for now.
#
# Because adding a configure file in the tree is going to conflict with
# existing configure files in people's (and automation) work trees, and
# because some automation jobs are still running autoconf and configure
# "manually", this file is actually an m4 file that is processed by
# autoconf, but doesn't call any autoconf macros. The `divert` line
# below ensures the script that follows is output by autoconf.
: "divert(0)dnl"
#!/bin/sh
SRCDIR=$(dirname $0)

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -30,8 +30,8 @@
** the version number) and changes its name to "sqlite3.h" as
** part of the build process.
*/
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
#ifndef SQLITE3_H
#define SQLITE3_H
#include <stdarg.h> /* Needed for the definition of va_list */
/*
@ -54,8 +54,17 @@ extern "C" {
#ifndef SQLITE_CDECL
# define SQLITE_CDECL
#endif
#ifndef SQLITE_APICALL
# define SQLITE_APICALL
#endif
#ifndef SQLITE_STDCALL
# define SQLITE_STDCALL
# define SQLITE_STDCALL SQLITE_APICALL
#endif
#ifndef SQLITE_CALLBACK
# define SQLITE_CALLBACK
#endif
#ifndef SQLITE_SYSAPI
# define SQLITE_SYSAPI
#endif
/*
@ -111,9 +120,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
#define SQLITE_VERSION "3.13.0"
#define SQLITE_VERSION_NUMBER 3013000
#define SQLITE_SOURCE_ID "2016-05-18 10:57:30 fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2"
#define SQLITE_VERSION "3.14.1"
#define SQLITE_VERSION_NUMBER 3014001
#define SQLITE_SOURCE_ID "2016-08-11 18:53:32 a12d8059770df4bca59e321c266410344242bf7b"
/*
** CAPI3REF: Run-Time Library Version Numbers
@ -506,6 +515,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_exec(
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
/*
** CAPI3REF: Flags For File Open Operations
@ -1035,6 +1045,16 @@ struct sqlite3_io_methods {
*/
typedef struct sqlite3_mutex sqlite3_mutex;
/*
** CAPI3REF: Loadable Extension Thunk
**
** A pointer to the opaque sqlite3_api_routines structure is passed as
** the third parameter to entry points of [loadable extensions]. This
** structure must be typedefed in order to work around compiler warnings
** on some platforms.
*/
typedef struct sqlite3_api_routines sqlite3_api_routines;
/*
** CAPI3REF: OS Interface Object
**
@ -1939,7 +1959,7 @@ struct sqlite3_mem_methods {
** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
** There should be two additional arguments.
** When the first argument to this interface is 1, then only the C-API is
** enabled and the SQL function remains disabled. If the first argment to
** enabled and the SQL function remains disabled. If the first argument to
** this interface is 0, then both the C-API and the SQL function are disabled.
** If the first argument is -1, then no changes are made to state of either the
** C-API or the SQL function.
@ -2232,7 +2252,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
** A busy handler must not close the database connection
** or [prepared statement] that invoked the busy handler.
*/
SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);
/*
** CAPI3REF: Set A Busy Timeout
@ -2754,6 +2774,9 @@ SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
** CAPI3REF: Tracing And Profiling Functions
** METHOD: sqlite3
**
** These routines are deprecated. Use the [sqlite3_trace_v2()] interface
** instead of the routines described here.
**
** These routines register callback functions that can be used for
** tracing and profiling the execution of SQL statements.
**
@ -2779,10 +2802,104 @@ SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
** sqlite3_profile() function is considered experimental and is
** subject to change in future versions of SQLite.
*/
SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_trace(sqlite3*,
void(*xTrace)(void*,const char*), void*);
SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
/*
** CAPI3REF: SQL Trace Event Codes
** KEYWORDS: SQLITE_TRACE
**
** These constants identify classes of events that can be monitored
** using the [sqlite3_trace_v2()] tracing logic. The third argument
** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of
** the following constants. ^The first argument to the trace callback
** is one of the following constants.
**
** New tracing constants may be added in future releases.
**
** ^A trace callback has four arguments: xCallback(T,C,P,X).
** ^The T argument is one of the integer type codes above.
** ^The C argument is a copy of the context pointer passed in as the
** fourth argument to [sqlite3_trace_v2()].
** The P and X arguments are pointers whose meanings depend on T.
**
** <dl>
** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>
** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement
** first begins running and possibly at other times during the
** execution of the prepared statement, such as at the start of each
** trigger subprogram. ^The P argument is a pointer to the
** [prepared statement]. ^The X argument is a pointer to a string which
** is the unexpanded SQL text of the prepared statement or an SQL comment
** that indicates the invocation of a trigger. ^The callback can compute
** the same text that would have been returned by the legacy [sqlite3_trace()]
** interface by using the X argument when X begins with "--" and invoking
** [sqlite3_expanded_sql(P)] otherwise.
**
** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>
** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same
** information as is provided by the [sqlite3_profile()] callback.
** ^The P argument is a pointer to the [prepared statement] and the
** X argument points to a 64-bit integer which is the estimated of
** the number of nanosecond that the prepared statement took to run.
** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.
**
** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>
** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared
** statement generates a single row of result.
** ^The P argument is a pointer to the [prepared statement] and the
** X argument is unused.
**
** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>
** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database
** connection closes.
** ^The P argument is a pointer to the [database connection] object
** and the X argument is unused.
** </dl>
*/
#define SQLITE_TRACE_STMT 0x01
#define SQLITE_TRACE_PROFILE 0x02
#define SQLITE_TRACE_ROW 0x04
#define SQLITE_TRACE_CLOSE 0x08
/*
** CAPI3REF: SQL Trace Hook
** METHOD: sqlite3
**
** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback
** function X against [database connection] D, using property mask M
** and context pointer P. ^If the X callback is
** NULL or if the M mask is zero, then tracing is disabled. The
** M argument should be the bitwise OR-ed combination of
** zero or more [SQLITE_TRACE] constants.
**
** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides
** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().
**
** ^The X callback is invoked whenever any of the events identified by
** mask M occur. ^The integer return value from the callback is currently
** ignored, though this may change in future releases. Callback
** implementations should return zero to ensure future compatibility.
**
** ^A trace callback is invoked with four arguments: callback(T,C,P,X).
** ^The T argument is one of the [SQLITE_TRACE]
** constants to indicate why the callback was invoked.
** ^The C argument is a copy of the context pointer.
** The P and X arguments are pointers whose meanings depend on T.
**
** The sqlite3_trace_v2() interface is intended to replace the legacy
** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which
** are deprecated.
*/
SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2(
sqlite3*,
unsigned uMask,
int(*xCallback)(unsigned,void*,void*,void*),
void *pCtx
);
/*
** CAPI3REF: Query Progress Callbacks
** METHOD: sqlite3
@ -3401,11 +3518,35 @@ SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
** CAPI3REF: Retrieving Statement SQL
** METHOD: sqlite3_stmt
**
** ^This interface can be used to retrieve a saved copy of the original
** SQL text used to create a [prepared statement] if that statement was
** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
** SQL text used to create [prepared statement] P if P was
** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
** string containing the SQL text of prepared statement P with
** [bound parameters] expanded.
**
** ^(For example, if a prepared statement is created using the SQL
** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
** and parameter :xyz is unbound, then sqlite3_sql() will return
** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
** will return "SELECT 2345,NULL".)^
**
** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory
** is available to hold the result, or if the result would exceed the
** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].
**
** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
** option causes sqlite3_expanded_sql() to always return NULL.
**
** ^The string returned by sqlite3_sql(P) is managed by SQLite and is
** automatically freed when the prepared statement is finalized.
** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
** is obtained from [sqlite3_malloc()] and must be free by the application
** by passing it to [sqlite3_free()].
*/
SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt);
/*
** CAPI3REF: Determine If An SQL Statement Writes The Database
@ -4563,12 +4704,13 @@ SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
** SQLite will invoke the destructor function X with parameter P exactly
** once, when the metadata is discarded.
** SQLite is free to discard the metadata at any time, including: <ul>
** <li> when the corresponding function parameter changes, or
** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
** SQL statement, or
** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
** <li> during the original sqlite3_set_auxdata() call when a memory
** allocation error occurs. </ul>)^
** <li> ^(when the corresponding function parameter changes)^, or
** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
** SQL statement)^, or
** <li> ^(when sqlite3_set_auxdata() is invoked again on the same
** parameter)^, or
** <li> ^(during the original sqlite3_set_auxdata() call when a memory
** allocation error occurs.)^ </ul>
**
** Note the last bullet in particular. The destructor X in
** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
@ -5395,7 +5537,7 @@ SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
** column exists. ^The sqlite3_table_column_metadata() interface returns
** SQLITE_ERROR and if the specified column does not exist.
** ^If the column-name parameter to sqlite3_table_column_metadata() is a
** NULL pointer, then this routine simply checks for the existance of the
** NULL pointer, then this routine simply checks for the existence of the
** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
** does not.
**
@ -5529,8 +5671,8 @@ SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
**
** ^This interface enables or disables both the C-API
** [sqlite3_load_extension()] and the SQL function [load_extension()].
** Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
** to enable or disable only the C-API.
** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
** to enable or disable only the C-API.)^
**
** <b>Security warning:</b> It is recommended that extension loading
** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
@ -5550,7 +5692,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int ono
**
** ^(Even though the function prototype shows that xEntryPoint() takes
** no arguments and returns void, SQLite invokes xEntryPoint() with three
** arguments and expects and integer result as if the signature of the
** arguments and expects an integer result as if the signature of the
** entry point where as follows:
**
** <blockquote><pre>
@ -5576,7 +5718,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int ono
** See also: [sqlite3_reset_auto_extension()]
** and [sqlite3_cancel_auto_extension()]
*/
SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void(*xEntryPoint)(void));
/*
** CAPI3REF: Cancel Automatic Extension Loading
@ -5588,7 +5730,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
** unregistered and it returns 0 if X was not on the list of initialization
** routines.
*/
SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void(*xEntryPoint)(void));
/*
** CAPI3REF: Reset Automatic Extension Loading
@ -6764,6 +6906,18 @@ SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int
** memory used by all pager caches associated with the database connection.)^
** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
**
** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
** pager cache is shared between two or more connections the bytes of heap
** memory used by that pager cache is divided evenly between the attached
** connections.)^ In other words, if none of the pager caches associated
** with the database connection are shared, this request returns the same
** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are
** shared, the value returned by this call will be smaller than that returned
** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.
**
** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
** <dd>This parameter returns the approximate number of bytes of heap
** memory used to store the schema for all databases associated
@ -6821,7 +6975,8 @@ SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int
#define SQLITE_DBSTATUS_CACHE_MISS 8
#define SQLITE_DBSTATUS_CACHE_WRITE 9
#define SQLITE_DBSTATUS_DEFERRED_FKS 10
#define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */
#define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
#define SQLITE_DBSTATUS_MAX 11 /* Largest defined DBSTATUS */
/*
@ -7977,7 +8132,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_db_cacheflush(sqlite3*);
** ^The second parameter to the preupdate callback is a pointer to
** the [database connection] that registered the preupdate hook.
** ^The third parameter to the preupdate callback is one of the constants
** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to indentify the
** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to identify the
** kind of update operation that is about to occur.
** ^(The fourth parameter to the preupdate callback is the name of the
** database within the database connection that is being modified. This
@ -8204,7 +8359,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_snapshot_cmp(
#ifdef __cplusplus
} /* End of the 'extern "C"' block */
#endif
#endif /* _SQLITE3_H_ */
#endif /* SQLITE3_H */
/******** Begin file sqlite3rtree.h *********/
/*
@ -9924,7 +10079,7 @@ struct Fts5ExtensionApi {
** behaviour. The structure methods are expected to function as follows:
**
** xCreate:
** This function is used to allocate and inititalize a tokenizer instance.
** This function is used to allocate and initialize a tokenizer instance.
** A tokenizer instance is required to actually tokenize text.
**
** The first argument passed to this function is a copy of the (void*)
@ -10184,5 +10339,4 @@ struct fts5_api {
#endif /* _FTS5_H */
/******** End of fts5.h *********/

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

@ -545,8 +545,12 @@ HTMLBreadcrumbs.prototype = {
handleFocus: function (event) {
event.stopPropagation();
this.outer.setAttribute("aria-activedescendant",
this.nodeHierarchy[this.currentIndex].button.id);
let node = this.nodeHierarchy[this.currentIndex];
if (node) {
this.outer.setAttribute("aria-activedescendant", node.button.id);
} else {
this.outer.removeAttribute("aria-activedescendant");
}
this.outer.focus();
},
@ -665,6 +669,9 @@ HTMLBreadcrumbs.prototype = {
if (this.hadFocus) {
this.nodeHierarchy[index].button.focus();
}
} else {
// Unset active active descendant when all buttons are unselected.
this.outer.removeAttribute("aria-activedescendant");
}
this.currentIndex = index;
},

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

@ -68,6 +68,7 @@ add_task(function* () {
}
yield testPseudoElements(inspector, container);
yield testComments(inspector, container);
});
function* testPseudoElements(inspector, container) {
@ -91,3 +92,41 @@ function* testPseudoElements(inspector, container) {
is(container.childNodes[3].textContent, "::after",
"::before shows up in breadcrumb");
}
function* testComments(inspector, container) {
info("Checking for comment elements");
let breadcrumbs = inspector.breadcrumbs;
let checkedButtonIndex = 2;
let button = container.childNodes[checkedButtonIndex];
let onBreadcrumbsUpdated = inspector.once("breadcrumbs-updated");
button.click();
yield onBreadcrumbsUpdated;
is(breadcrumbs.currentIndex, checkedButtonIndex, "New button is selected");
ok(breadcrumbs.outer.hasAttribute("aria-activedescendant"),
"Active descendant must be set");
let comment = [...inspector.markup._containers].find(([node]) =>
node.nodeType === Ci.nsIDOMNode.COMMENT_NODE)[0];
let onInspectorUpdated = inspector.once("inspector-updated");
inspector.selection.setNodeFront(comment);
yield onInspectorUpdated;
is(breadcrumbs.currentIndex, -1,
"When comment is selected no breadcrumb should be checked");
ok(!breadcrumbs.outer.hasAttribute("aria-activedescendant"),
"Active descendant must not be set");
onInspectorUpdated = inspector.once("inspector-updated");
onBreadcrumbsUpdated = inspector.once("breadcrumbs-updated");
button.click();
yield Promise.all([onInspectorUpdated, onBreadcrumbsUpdated]);
is(breadcrumbs.currentIndex, checkedButtonIndex,
"Same button is selected again");
ok(breadcrumbs.outer.hasAttribute("aria-activedescendant"),
"Active descendant must be set again");
}

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

@ -64,6 +64,7 @@
<link />
</article>
<div id='pseudo-container'></div>
<!-- This is a comment node -->
<svg id="vector" viewBox="0 0 10 10">
<clipPath id="clip">
<rect id="rectangle" x="0" y="0" width="10" height="5"></rect>

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

@ -5939,8 +5939,7 @@ nsDocShell::GetPositionAndSize(int32_t* aX, int32_t* aY, int32_t* aWidth,
{
if (mParentWidget) {
// ensure size is up-to-date if window has changed resolution
LayoutDeviceIntRect r;
mParentWidget->GetClientBounds(r);
LayoutDeviceIntRect r = mParentWidget->GetClientBounds();
SetPositionAndSize(mBounds.x, mBounds.y, r.width, r.height, 0);
}

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

@ -1071,6 +1071,9 @@ Animation::UpdateFinishedState(SeekFlag aSeekFlag,
currentTime.Value().ToMilliseconds() <= 0.0) {
if (aSeekFlag == SeekFlag::DidSeek) {
mHoldTime = currentTime;
} else if (!mPreviousCurrentTime.IsNull()) {
mHoldTime.SetValue(std::min(mPreviousCurrentTime.Value(),
TimeDuration(0)));
} else {
mHoldTime.SetValue(0);
}

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

@ -221,9 +221,11 @@ void
KeyframeEffectReadOnly::GetComputedTimingAsDict(
ComputedTimingProperties& aRetVal) const
{
double playbackRate = mAnimation ? mAnimation->PlaybackRate() : 1;
const Nullable<TimeDuration> currentTime = GetLocalTime();
GetComputedTimingDictionary(GetComputedTimingAt(currentTime,
SpecifiedTiming()),
SpecifiedTiming(),
playbackRate),
currentTime,
SpecifiedTiming(),
aRetVal);
@ -232,7 +234,8 @@ KeyframeEffectReadOnly::GetComputedTimingAsDict(
ComputedTiming
KeyframeEffectReadOnly::GetComputedTimingAt(
const Nullable<TimeDuration>& aLocalTime,
const TimingParams& aTiming)
const TimingParams& aTiming,
double aPlaybackRate)
{
const StickyTimeDuration zeroDuration;
@ -271,9 +274,15 @@ KeyframeEffectReadOnly::GetComputedTimingAt(
// Calculate the time within the active interval.
// https://w3c.github.io/web-animations/#active-time
StickyTimeDuration activeTime;
if (localTime >=
std::min(StickyTimeDuration(aTiming.mDelay + result.mActiveDuration),
result.mEndTime)) {
StickyTimeDuration beforeActiveBoundary =
std::min(StickyTimeDuration(aTiming.mDelay), result.mEndTime);
StickyTimeDuration activeAfterBoundary =
std::min(StickyTimeDuration(aTiming.mDelay + result.mActiveDuration),
result.mEndTime);
if (localTime > activeAfterBoundary ||
(aPlaybackRate >= 0 && localTime == activeAfterBoundary)) {
result.mPhase = ComputedTiming::AnimationPhase::After;
if (!result.FillsForwards()) {
// The animation isn't active or filling at this time.
@ -282,8 +291,8 @@ KeyframeEffectReadOnly::GetComputedTimingAt(
activeTime = std::max(std::min(result.mActiveDuration,
result.mActiveDuration + aTiming.mEndDelay),
zeroDuration);
} else if (localTime <
std::min(StickyTimeDuration(aTiming.mDelay), result.mEndTime)) {
} else if (localTime < beforeActiveBoundary ||
(aPlaybackRate < 0 && localTime == beforeActiveBoundary)) {
result.mPhase = ComputedTiming::AnimationPhase::Before;
if (!result.FillsBackwards()) {
// The animation isn't active or filling at this time.
@ -391,6 +400,15 @@ KeyframeEffectReadOnly::GetComputedTimingAt(
return result;
}
ComputedTiming
KeyframeEffectReadOnly::GetComputedTiming(const TimingParams* aTiming) const
{
double playbackRate = mAnimation ? mAnimation->PlaybackRate() : 1;
return GetComputedTimingAt(GetLocalTime(),
aTiming ? *aTiming : SpecifiedTiming(),
playbackRate);
}
// https://w3c.github.io/web-animations/#in-play
bool
KeyframeEffectReadOnly::IsInPlay() const

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

@ -264,16 +264,13 @@ public:
// (because it is not currently active and is not filling at this time).
static ComputedTiming
GetComputedTimingAt(const Nullable<TimeDuration>& aLocalTime,
const TimingParams& aTiming);
const TimingParams& aTiming,
double aPlaybackRate);
// Shortcut for that gets the computed timing using the current local time as
// calculated from the timeline time.
ComputedTiming
GetComputedTiming(const TimingParams* aTiming = nullptr) const
{
return GetComputedTimingAt(GetLocalTime(),
aTiming ? *aTiming : SpecifiedTiming());
}
GetComputedTiming(const TimingParams* aTiming = nullptr) const;
void
GetComputedTimingAsDict(ComputedTimingProperties& aRetVal) const override;

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

@ -701,7 +701,7 @@ nsresult
FileReader::IncreaseBusyCounter()
{
if (mWorkerPrivate && mBusyCount++ == 0 &&
!HoldWorker(mWorkerPrivate)) {
!HoldWorker(mWorkerPrivate, Closing)) {
return NS_ERROR_FAILURE;
}

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

@ -2270,7 +2270,7 @@ WebSocketImpl::RegisterWorkerHolder()
MOZ_ASSERT(!mWorkerHolder);
mWorkerHolder = new WebSocketWorkerHolder(this);
if (NS_WARN_IF(!mWorkerHolder->HoldWorker(mWorkerPrivate))) {
if (NS_WARN_IF(!mWorkerHolder->HoldWorker(mWorkerPrivate, Canceling))) {
mWorkerHolder = nullptr;
return false;
}

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

@ -2041,9 +2041,7 @@ nsDOMWindowUtils::SendQueryContentEvent(uint32_t aType,
nsIFrame* popupFrame =
nsLayoutUtils::GetPopupFrameForEventCoordinates(presContext->GetRootPresContext(), &dummyEvent);
LayoutDeviceIntRect widgetBounds;
nsresult rv = widget->GetClientBounds(widgetBounds);
NS_ENSURE_SUCCESS(rv, rv);
LayoutDeviceIntRect widgetBounds = widget->GetClientBounds();
widgetBounds.MoveTo(0, 0);
// There is no popup frame at the point and the point isn't in our widget,

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

@ -31,6 +31,7 @@
#include "nsIDocShellTreeOwner.h"
#include "nsIDocShellLoadInfo.h"
#include "nsIBaseWindow.h"
#include "nsIBrowser.h"
#include "nsContentUtils.h"
#include "nsIXPConnect.h"
#include "nsUnicharUtils.h"
@ -2485,6 +2486,34 @@ nsFrameLoader::SetClampScrollPosition(bool aClamp)
return NS_OK;
}
static
ContentParent*
GetContentParent(Element* aBrowser)
{
nsCOMPtr<nsIBrowser> browser = do_QueryInterface(aBrowser);
if (!browser) {
return nullptr;
}
nsCOMPtr<nsIDOMElement> related;
browser->GetRelatedBrowser(getter_AddRefs(related));
nsCOMPtr<nsIFrameLoaderOwner> otherOwner = do_QueryInterface(related);
if (!otherOwner) {
return nullptr;
}
nsCOMPtr<nsIFrameLoader> otherLoader = otherOwner->GetFrameLoader();
TabParent* tabParent = TabParent::GetFrom(otherLoader);
if (tabParent &&
tabParent->Manager() &&
tabParent->Manager()->IsContentParent()) {
return tabParent->Manager()->AsContentParent();
}
return nullptr;
}
bool
nsFrameLoader::TryRemoteBrowser()
{
@ -2543,6 +2572,9 @@ nsFrameLoader::TryRemoteBrowser()
nsCaseInsensitiveStringComparator())) {
return false;
}
// Try to get the related content parent from our browser element.
openerContentParent = GetContentParent(mOwnerContent);
}
uint32_t chromeFlags = 0;

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

@ -607,6 +607,7 @@ GK_ATOM(middle, "middle")
GK_ATOM(min, "min")
GK_ATOM(minheight, "minheight")
GK_ATOM(minimum_scale, "minimum-scale")
GK_ATOM(minlength, "minlength")
GK_ATOM(minpos, "minpos")
GK_ATOM(minusSign, "minus-sign")
GK_ATOM(minwidth, "minwidth")

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

@ -13827,11 +13827,7 @@ nsGlobalWindow::NotifyDefaultButtonLoaded(Element& aDefaultButton,
aError.Throw(NS_ERROR_FAILURE);
return;
}
LayoutDeviceIntRect widgetRect;
aError = widget->GetScreenBounds(widgetRect);
if (aError.Failed()) {
return;
}
LayoutDeviceIntRect widgetRect = widget->GetScreenBounds();
// Convert the buttonRect coordinates from screen to the widget.
buttonRect -= widgetRect.TopLeft();

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

@ -1278,16 +1278,37 @@ struct CycleCollectorStats
constexpr CycleCollectorStats() :
mMaxGCDuration(0), mRanSyncForgetSkippable(false), mSuspected(0),
mMaxSkippableDuration(0), mMaxSliceTime(0), mMaxSliceTimeSinceClear(0),
mTotalSliceTime(0), mAnyLockedOut(false), mExtraForgetSkippableCalls(0) {}
mTotalSliceTime(0), mAnyLockedOut(false), mExtraForgetSkippableCalls(0),
mFile(nullptr) {}
void Init()
{
Clear();
mMaxSliceTimeSinceClear = 0;
char* env = getenv("MOZ_CCTIMER");
if (!env) {
return;
}
if (strcmp(env, "none") == 0) {
mFile = nullptr;
} else if (strcmp(env, "stdout") == 0) {
mFile = stdout;
} else if (strcmp(env, "stderr") == 0) {
mFile = stderr;
} else {
mFile = fopen(env, "a");
if (!mFile) {
MOZ_CRASH("Failed to open MOZ_CCTIMER log file.");
}
}
}
void Clear()
{
if (mFile && mFile != stdout && mFile != stderr) {
fclose(mFile);
}
mBeginSliceTime = TimeStamp();
mEndSliceTime = TimeStamp();
mBeginTime = TimeStamp();
@ -1356,6 +1377,9 @@ struct CycleCollectorStats
bool mAnyLockedOut;
int32_t mExtraForgetSkippableCalls;
// A file to dump CC activity to; set by MOZ_CCTIMER environment variable.
FILE* mFile;
};
CycleCollectorStats gCCStats;
@ -1593,7 +1617,7 @@ nsJSContext::EndCycleCollectionCallback(CycleCollectorResults &aResults)
uint32_t minForgetSkippableTime = (sMinForgetSkippableTime == UINT32_MAX)
? 0 : sMinForgetSkippableTime;
if (sPostGCEventsToConsole) {
if (sPostGCEventsToConsole || gCCStats.mFile) {
nsCString mergeMsg;
if (aResults.mMergedZones) {
mergeMsg.AssignLiteral(" merged");
@ -1623,10 +1647,15 @@ nsJSContext::EndCycleCollectionCallback(CycleCollectorResults &aResults)
PR_USEC_PER_MSEC,
sTotalForgetSkippableTime / PR_USEC_PER_MSEC,
gCCStats.mMaxSkippableDuration, sRemovedPurples));
nsCOMPtr<nsIConsoleService> cs =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
if (cs) {
cs->LogStringMessage(msg.get());
if (sPostGCEventsToConsole) {
nsCOMPtr<nsIConsoleService> cs =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
if (cs) {
cs->LogStringMessage(msg.get());
}
}
if (gCCStats.mFile) {
fprintf(gCCStats.mFile, "%s\n", NS_ConvertUTF16toUTF8(msg).get());
}
}

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

@ -357,7 +357,8 @@ nsPluginArray::EnsurePlugins()
if (pluginTag->IsClicktoplay()) {
nsCString name;
pluginTag->GetName(name);
if (NS_LITERAL_CSTRING("Shockwave Flash").Equals(name)) {
if (name.EqualsLiteral("Shockwave Flash") &&
Preferences::GetBool("plugins.navigator_hide_disabled_flash", false)) {
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
nsCString permString;
nsresult rv = pluginHost->GetPermissionStringForTag(pluginTag, 0, permString);

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

@ -1926,7 +1926,10 @@ nsScriptLoader::FillCompileOptionsForRequest(const AutoJSAPI &jsapi,
// aRequest ended up getting script data from, as the script filename.
nsContentUtils::GetWrapperSafeScriptFilename(mDocument, aRequest->mURI, aRequest->mURL);
aOptions->setIntroductionType("scriptElement");
bool isScriptElement = !aRequest->IsModuleRequest() ||
aRequest->AsModuleRequest()->IsTopLevel();
aOptions->setIntroductionType(isScriptElement ? "scriptElement"
: "importedModule");
aOptions->setFileAndLine(aRequest->mURL.get(), aRequest->mLineNo);
aOptions->setVersion(JSVersion(aRequest->mJSVersion));
aOptions->setIsRunOnce(true);

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

@ -203,6 +203,7 @@ nsIAtom** const kAttributesHTML[] = {
&nsGkAtoms::media,
&nsGkAtoms::method,
&nsGkAtoms::min,
&nsGkAtoms::minlength,
&nsGkAtoms::multiple,
&nsGkAtoms::muted,
&nsGkAtoms::name,

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

@ -18,6 +18,8 @@ support-files =
module_large1.js
module_large2.js
module_large3.js
module_extractIntroType.js
iframe_extractIntroType.html
[test_moduleScriptsRun.html]
[test_moduleParsedAsModule.html]
@ -42,3 +44,5 @@ support-files =
[test_multiModuleLargeImports.html]
[test_asyncInlineModules.html]
[test_scriptInsertedModule.html]
[test_topLevelIntroType.html]
[test_importIntroType.html]

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

@ -0,0 +1,14 @@
<!DOCTYPE html>
<meta charset=utf-8>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
// Hook up the debugger statement to extract the calling script's
// introductionType and set it in a property on the parent global.
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);
var dbg = new Debugger;
dbg.addDebuggee(parent);
dbg.onDebuggerStatement = function (frame) {
parent.introType = frame.script.source.introductionType;
}
</script>

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

@ -0,0 +1,5 @@
// Extract the introductionType for this module in conjunction with
// iframe_extractIntroType.html.
extractIntroType = function() {
debugger;
}

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

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Test introduction type of an imported module</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
var introType;
var extractIntroType;
info('start');
SimpleTest.waitForExplicitFinish();
function testIntroductionType() {
extractIntroType();
ok(introType == "importedModule", 'Check introduction type');
SimpleTest.finish();
}
</script>
<iframe src="iframe_extractIntroType.html"></iframe>
<script type="module">
import "./module_extractIntroType.js";
</script>
<body onload='testIntroductionType()'></body>

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

@ -0,0 +1,21 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Test introduction type of a top-level module</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
var introType;
var extractIntroType;
info('start');
SimpleTest.waitForExplicitFinish();
function testIntroductionType() {
extractIntroType();
ok(introType == "scriptElement", 'Check introduction type');
SimpleTest.finish();
}
</script>
<iframe src="iframe_extractIntroType.html"></iframe>
<script type="module" src="module_extractIntroType.js">
</script>
<body onload='testIntroductionType()'></body>

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

@ -395,7 +395,7 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal,
}
} else {
bc->mWorkerHolder = new BroadcastChannelWorkerHolder(bc);
if (NS_WARN_IF(!bc->mWorkerHolder->HoldWorker(workerPrivate))) {
if (NS_WARN_IF(!bc->mWorkerHolder->HoldWorker(workerPrivate, Closing))) {
bc->mWorkerHolder = nullptr;
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;

2
dom/cache/CacheWorkerHolder.cpp поставляемый
Просмотреть файл

@ -24,7 +24,7 @@ CacheWorkerHolder::Create(WorkerPrivate* aWorkerPrivate)
MOZ_ASSERT(aWorkerPrivate);
RefPtr<CacheWorkerHolder> workerHolder = new CacheWorkerHolder();
if (NS_WARN_IF(!workerHolder->HoldWorker(aWorkerPrivate))) {
if (NS_WARN_IF(!workerHolder->HoldWorker(aWorkerPrivate, Terminating))) {
return nullptr;
}

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

@ -1156,7 +1156,8 @@ CanvasRenderingContext2D::Reset()
gCanvasAzureMemoryUsed -= mWidth * mHeight * 4;
}
ReturnTarget();
bool forceReset = true;
ReturnTarget(forceReset);
mTarget = nullptr;
mBufferProvider = nullptr;
@ -1645,25 +1646,28 @@ CanvasRenderingContext2D::EnsureTarget(const gfx::Rect* aCoveredRect,
Redraw();
}
// Restore clips and transform.
mTarget->SetTransform(Matrix());
if (mBufferProvider != oldBufferProvider || !mBufferProvider ||
!mBufferProvider->PreservesDrawingState()) {
// Restore clips and transform.
mTarget->SetTransform(Matrix());
if (mTarget->GetBackendType() == gfx::BackendType::CAIRO) {
// Cairo doesn't play well with huge clips. When given a very big clip it
// will try to allocate big mask surface without taking the target
// size into account which can cause OOM. See bug 1034593.
// This limits the clip extents to the size of the canvas.
// A fix in Cairo would probably be preferable, but requires somewhat
// invasive changes.
mTarget->PushClipRect(canvasRect);
}
if (mTarget->GetBackendType() == gfx::BackendType::CAIRO) {
// Cairo doesn't play well with huge clips. When given a very big clip it
// will try to allocate big mask surface without taking the target
// size into account which can cause OOM. See bug 1034593.
// This limits the clip extents to the size of the canvas.
// A fix in Cairo would probably be preferable, but requires somewhat
// invasive changes.
mTarget->PushClipRect(canvasRect);
}
for (const auto& style : mStyleStack) {
for (const auto& clipOrTransform : style.clipsAndTransforms) {
if (clipOrTransform.IsClip()) {
mTarget->PushClip(clipOrTransform.clip);
} else {
mTarget->SetTransform(clipOrTransform.transform);
for (const auto& style : mStyleStack) {
for (const auto& clipOrTransform : style.clipsAndTransforms) {
if (clipOrTransform.IsClip()) {
mTarget->PushClip(clipOrTransform.clip);
} else {
mTarget->SetTransform(clipOrTransform.transform);
}
}
}
}
@ -1772,22 +1776,24 @@ CanvasRenderingContext2D::ClearTarget(bool aRetainBuffer)
}
void
CanvasRenderingContext2D::ReturnTarget()
CanvasRenderingContext2D::ReturnTarget(bool aForceReset)
{
if (mTarget && mBufferProvider && mTarget != sErrorTarget) {
CurrentState().transform = mTarget->GetTransform();
for (const auto& style : mStyleStack) {
for (const auto& clipOrTransform : style.clipsAndTransforms) {
if (clipOrTransform.IsClip()) {
mTarget->PopClip();
if (aForceReset || !mBufferProvider->PreservesDrawingState()) {
for (const auto& style : mStyleStack) {
for (const auto& clipOrTransform : style.clipsAndTransforms) {
if (clipOrTransform.IsClip()) {
mTarget->PopClip();
}
}
}
}
if (mTarget->GetBackendType() == gfx::BackendType::CAIRO) {
// With the cairo backend we pushed an extra clip rect which we have to
// balance out here. See the comment in EnsureDrawTarget.
mTarget->PopClip();
if (mTarget->GetBackendType() == gfx::BackendType::CAIRO) {
// With the cairo backend we pushed an extra clip rect which we have to
// balance out here. See the comment in EnsureDrawTarget.
mTarget->PopClip();
}
}
mBufferProvider->ReturnDrawTarget(mTarget.forget());

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

@ -665,7 +665,7 @@ protected:
* Returns the target to the buffer provider. i.e. this will queue a frame for
* rendering.
*/
void ReturnTarget();
void ReturnTarget(bool aForceReset = false);
/**
* Check if the target is valid after calling EnsureTarget.

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

@ -40,6 +40,7 @@ const SEC_ASN1Template SGN_DigestInfoTemplate[] = {
namespace mozilla {
namespace dom {
using mozilla::dom::workers::Canceling;
using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
using mozilla::dom::workers::Status;
using mozilla::dom::workers::WorkerHolder;
@ -161,7 +162,7 @@ public:
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate);
RefPtr<InternalWorkerHolder> ref = new InternalWorkerHolder();
if (NS_WARN_IF(!ref->HoldWorker(workerPrivate))) {
if (NS_WARN_IF(!ref->HoldWorker(workerPrivate, Canceling))) {
return nullptr;
}
return ref.forget();

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

@ -96,7 +96,7 @@ DataTransfer::DataTransfer(nsISupports* aParent, EventMessage aEventMessage,
, mDragImageX(0)
, mDragImageY(0)
{
mItems = new DataTransferItemList(this, aIsExternal, false /* aIsCrossDomainSubFrameDrop */);
mItems = new DataTransferItemList(this, aIsExternal);
// For these events, we want to be able to add data to the data transfer, so
// clear the readonly state. Otherwise, the data is already present. For
// external usage, cache the data from the native clipboard or drag.
@ -335,11 +335,19 @@ DataTransfer::GetTypes(ErrorResult& aRv) const
}
}
// If we have any files, add the "Files" string to the list
if (mItems->Files()->Length() > 0 &&
NS_WARN_IF(!types->Add(NS_LITERAL_STRING("Files")))) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
for (uint32_t i = 0; i < mItems->Length(); ++i) {
ErrorResult rv;
bool found = false;
DataTransferItem* item = mItems->IndexedGetter(i, found, rv);
if (!found || rv.Failed() || item->Kind() != DataTransferItem::KIND_FILE) {
rv.SuppressException();
continue;
}
if (NS_WARN_IF(!types->Add(NS_LITERAL_STRING("Files")))) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
break;
}
return types.forget();
@ -608,14 +616,6 @@ DataTransfer::GetDataAtInternal(const nsAString& aFormat, uint32_t aIndex,
nsAutoString format;
GetRealFormat(aFormat, format);
// Check if the caller is allowed to access the drag data. Callers with
// chrome privileges can always read the data. During the
// drop event, allow retrieving the data except in the case where the
// source of the drag is in a child frame of the caller. In that case,
// we only allow access to data of the same principal. During other events,
// only allow access to the data with the same principal.
bool checkFormatItemPrincipal = mIsCrossDomainSubFrameDrop ||
(mEventMessage != eDrop && mEventMessage != ePaste);
MOZ_ASSERT(aSubjectPrincipal);
RefPtr<DataTransferItem> item = mItems->MozItemByTypeAt(format, aIndex);
@ -630,34 +630,11 @@ DataTransfer::GetDataAtInternal(const nsAString& aFormat, uint32_t aIndex,
return NS_OK;
}
if (item->Principal() && checkFormatItemPrincipal &&
!aSubjectPrincipal->Subsumes(item->Principal())) {
return NS_ERROR_DOM_SECURITY_ERR;
}
nsCOMPtr<nsIVariant> data = item->Data();
if (!data) {
return NS_OK;
}
nsCOMPtr<nsISupports> isupportsData;
nsresult rv = data->GetAsISupports(getter_AddRefs(isupportsData));
if (NS_SUCCEEDED(rv) && isupportsData) {
// Make sure the code that is calling us is same-origin with the data.
nsCOMPtr<EventTarget> pt = do_QueryInterface(isupportsData);
if (pt) {
nsresult rv = NS_OK;
nsIScriptContext* c = pt->GetContextForEventHandlers(&rv);
NS_ENSURE_TRUE(c && NS_SUCCEEDED(rv), NS_ERROR_DOM_SECURITY_ERR);
nsIGlobalObject* go = c->GetGlobalObject();
NS_ENSURE_TRUE(go, NS_ERROR_DOM_SECURITY_ERR);
nsCOMPtr<nsIScriptObjectPrincipal> sp = do_QueryInterface(go);
MOZ_ASSERT(sp, "This cannot fail on the main thread.");
nsIPrincipal* dataPrincipal = sp->GetPrincipal();
NS_ENSURE_TRUE(dataPrincipal, NS_ERROR_DOM_SECURITY_ERR);
NS_ENSURE_TRUE(aSubjectPrincipal->Subsumes(dataPrincipal), NS_ERROR_DOM_SECURITY_ERR);
}
// DataTransferItem::Data() handles the principal checks
ErrorResult result;
nsCOMPtr<nsIVariant> data = item->Data(aSubjectPrincipal, result);
if (NS_WARN_IF(!data || result.Failed())) {
return result.StealNSResult();
}
data.forget(aData);
@ -1020,7 +997,8 @@ DataTransfer::GetTransferable(uint32_t aIndex, nsILoadContext* aLoadContext)
do {
for (uint32_t f = 0; f < count; f++) {
RefPtr<DataTransferItem> formatitem = item[f];
if (!formatitem->Data()) { // skip empty items
nsCOMPtr<nsIVariant> variant = formatitem->DataNoSecurityCheck();
if (!variant) { // skip empty items
continue;
}
@ -1040,7 +1018,7 @@ DataTransfer::GetTransferable(uint32_t aIndex, nsILoadContext* aLoadContext)
nsCOMPtr<nsISupports> convertedData;
if (handlingCustomFormats) {
if (!ConvertFromVariant(formatitem->Data(), getter_AddRefs(convertedData),
if (!ConvertFromVariant(variant, getter_AddRefs(convertedData),
&lengthInBytes)) {
continue;
}
@ -1125,7 +1103,7 @@ DataTransfer::GetTransferable(uint32_t aIndex, nsILoadContext* aLoadContext)
} else {
// This is the second pass of the loop and a known type is encountered.
// Add it as is.
if (!ConvertFromVariant(formatitem->Data(), getter_AddRefs(convertedData),
if (!ConvertFromVariant(variant, getter_AddRefs(convertedData),
&lengthInBytes)) {
continue;
}
@ -1477,16 +1455,17 @@ void
DataTransfer::FillInExternalCustomTypes(uint32_t aIndex,
nsIPrincipal* aPrincipal)
{
RefPtr<DataTransferItem> item = new DataTransferItem(mItems,
RefPtr<DataTransferItem> item = new DataTransferItem(this,
NS_LITERAL_STRING(kCustomTypesMime));
item->SetKind(DataTransferItem::KIND_STRING);
item->SetIndex(aIndex);
if (!item->Data()) {
nsCOMPtr<nsIVariant> variant = item->DataNoSecurityCheck();
if (!variant) {
return;
}
FillInExternalCustomTypes(item->Data(), aIndex, aPrincipal);
FillInExternalCustomTypes(variant, aIndex, aPrincipal);
}
void

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

@ -195,15 +195,28 @@ public:
nsresult GetDataAtNoSecurityCheck(const nsAString& aFormat, uint32_t aIndex,
nsIVariant** aData);
DataTransferItemList* Items() const {
return mItems;
}
// a readonly dataTransfer cannot have new data added or existing data
// removed. Only the dropEffect and effectAllowed may be modified.
DataTransferItemList* Items() const { return mItems; }
bool IsReadOnly() const {
return mReadOnly;
}
void SetReadOnly() {
mReadOnly = true;
}
bool IsReadOnly() const { return mReadOnly; }
void SetReadOnly() { mReadOnly = true; }
int32_t ClipboardType() const { return mClipboardType; }
EventMessage GetEventMessage() const { return mEventMessage; }
int32_t ClipboardType() const {
return mClipboardType;
}
EventMessage GetEventMessage() const {
return mEventMessage;
}
bool IsCrossDomainSubFrameDrop() const {
return mIsCrossDomainSubFrameDrop;
}
// converts the data into an array of nsITransferable objects to be used for
// drag and drop or clipboard operations.

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

@ -10,12 +10,13 @@
#include "mozilla/EventForwards.h"
#include "mozilla/dom/DataTransferItemBinding.h"
#include "mozilla/dom/Directory.h"
#include "mozilla/dom/DirectoryEntry.h"
#include "mozilla/dom/DOMFileSystem.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/FileEntry.h"
#include "mozilla/dom/FileSystem.h"
#include "mozilla/dom/FileSystemDirectoryEntry.h"
#include "mozilla/dom/FileSystemFileEntry.h"
#include "nsIClipboard.h"
#include "nsISupportsPrimitives.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsNetUtil.h"
#include "nsQueryObject.h"
#include "nsContentUtils.h"
@ -40,7 +41,7 @@ namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DataTransferItem, mData,
mPrincipal, mParent, mCachedFile)
mPrincipal, mDataTransfer, mCachedFile)
NS_IMPL_CYCLE_COLLECTING_ADDREF(DataTransferItem)
NS_IMPL_CYCLE_COLLECTING_RELEASE(DataTransferItem)
@ -56,11 +57,11 @@ DataTransferItem::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
}
already_AddRefed<DataTransferItem>
DataTransferItem::Clone(DataTransferItemList* aParent) const
DataTransferItem::Clone(DataTransfer* aDataTransfer) const
{
MOZ_ASSERT(aParent);
MOZ_ASSERT(aDataTransfer);
RefPtr<DataTransferItem> it = new DataTransferItem(aParent, mType);
RefPtr<DataTransferItem> it = new DataTransferItem(aDataTransfer, mType);
// Copy over all of the fields
it->mKind = mKind;
@ -153,16 +154,16 @@ DataTransferItem::FillInExternalData()
trans->Init(nullptr);
trans->AddDataFlavor(format);
if (mParent->GetEventMessage() == ePaste) {
if (mDataTransfer->GetEventMessage() == ePaste) {
MOZ_ASSERT(mIndex == 0, "index in clipboard must be 0");
nsCOMPtr<nsIClipboard> clipboard =
do_GetService("@mozilla.org/widget/clipboard;1");
if (!clipboard || mParent->ClipboardType() < 0) {
if (!clipboard || mDataTransfer->ClipboardType() < 0) {
return;
}
nsresult rv = clipboard->GetData(trans, mParent->ClipboardType());
nsresult rv = clipboard->GetData(trans, mDataTransfer->ClipboardType());
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
@ -238,8 +239,8 @@ DataTransferItem::GetAsFile(ErrorResult& aRv)
return nullptr;
}
nsIVariant* data = Data();
if (NS_WARN_IF(!data)) {
nsCOMPtr<nsIVariant> data = Data(nsContentUtils::SubjectPrincipal(), aRv);
if (NS_WARN_IF(!data || aRv.Failed())) {
return nullptr;
}
@ -259,9 +260,9 @@ DataTransferItem::GetAsFile(ErrorResult& aRv)
mCachedFile = blob->ToFile();
} else if (nsCOMPtr<BlobImpl> blobImpl = do_QueryInterface(supports)) {
MOZ_ASSERT(blobImpl->IsFile());
mCachedFile = File::Create(GetParentObject(), blobImpl);
mCachedFile = File::Create(mDataTransfer, blobImpl);
} else if (nsCOMPtr<nsIFile> ifile = do_QueryInterface(supports)) {
mCachedFile = File::CreateFromFile(GetParentObject(), ifile);
mCachedFile = File::CreateFromFile(mDataTransfer, ifile);
} else {
MOZ_ASSERT(false, "One of the above code paths should be taken");
}
@ -271,7 +272,7 @@ DataTransferItem::GetAsFile(ErrorResult& aRv)
return file.forget();
}
already_AddRefed<Entry>
already_AddRefed<FileSystemEntry>
DataTransferItem::GetAsEntry(ErrorResult& aRv)
{
RefPtr<File> file = GetAsFile(aRv);
@ -280,25 +281,14 @@ DataTransferItem::GetAsEntry(ErrorResult& aRv)
}
nsCOMPtr<nsIGlobalObject> global;
RefPtr<DataTransfer> dataTransfer;
RefPtr<DataTransferItemList> list = GetParentObject();
if (!list) {
return nullptr;
}
dataTransfer = list->GetParentObject();
if (!dataTransfer) {
return nullptr;
}
// This is annoying, but DataTransfer may have various things as parent.
nsCOMPtr<EventTarget> target =
do_QueryInterface(dataTransfer->GetParentObject());
do_QueryInterface(mDataTransfer->GetParentObject());
if (target) {
global = target->GetOwnerGlobal();
} else {
nsCOMPtr<nsIDOMEvent> event =
do_QueryInterface(dataTransfer->GetParentObject());
do_QueryInterface(mDataTransfer->GetParentObject());
if (event) {
global = event->InternalDOMEvent()->GetParentObject();
}
@ -308,8 +298,8 @@ DataTransferItem::GetAsEntry(ErrorResult& aRv)
return nullptr;
}
RefPtr<DOMFileSystem> fs = DOMFileSystem::Create(global);
RefPtr<Entry> entry;
RefPtr<FileSystem> fs = FileSystem::Create(global);
RefPtr<FileSystemEntry> entry;
BlobImpl* impl = file->Impl();
MOZ_ASSERT(impl);
@ -329,12 +319,12 @@ DataTransferItem::GetAsEntry(ErrorResult& aRv)
}
RefPtr<Directory> directory = Directory::Create(global, directoryFile);
entry = new DirectoryEntry(global, directory, fs);
entry = new FileSystemDirectoryEntry(global, directory, fs);
} else {
entry = new FileEntry(global, file, fs);
entry = new FileSystemFileEntry(global, file, fs);
}
Sequence<RefPtr<Entry>> entries;
Sequence<RefPtr<FileSystemEntry>> entries;
if (!entries.AppendElement(entry, fallible)) {
return nullptr;
}
@ -377,7 +367,7 @@ DataTransferItem::CreateFileFromInputStream(nsIInputStream* aStream)
return nullptr;
}
return File::CreateMemoryFile(GetParentObject(), data, available, fileName,
return File::CreateMemoryFile(mDataTransfer, data, available, fileName,
mType, PR_Now());
}
@ -390,17 +380,18 @@ DataTransferItem::GetAsString(FunctionStringCallback* aCallback,
}
// Theoretically this should be done inside of the runnable, as it might be an
// expensive operation on some systems. However, it doesn't really matter as
// in order to get a DataTransferItem, we need to call
// DataTransferItemList::IndexedGetter which already calls the Data method,
// meaning that this operation is basically free.
nsIVariant* data = Data();
if (NS_WARN_IF(!data)) {
// expensive operation on some systems, however we wouldn't get access to the
// NS_ERROR_DOM_SECURITY_ERROR messages which may be raised by this method.
nsCOMPtr<nsIVariant> data = Data(nsContentUtils::SubjectPrincipal(), aRv);
if (NS_WARN_IF(!data || aRv.Failed())) {
return;
}
nsAutoString stringData;
data->GetAsAString(stringData);
nsresult rv = data->GetAsAString(stringData);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
// Dispatch the callback to the main thread
class GASRunnable final : public Runnable
@ -424,12 +415,92 @@ DataTransferItem::GetAsString(FunctionStringCallback* aCallback,
};
RefPtr<GASRunnable> runnable = new GASRunnable(aCallback, stringData);
nsresult rv = NS_DispatchToMainThread(runnable);
rv = NS_DispatchToMainThread(runnable);
if (NS_FAILED(rv)) {
NS_WARNING("NS_DispatchToMainThread Failed in "
"DataTransferItem::GetAsString!");
}
}
already_AddRefed<nsIVariant>
DataTransferItem::DataNoSecurityCheck()
{
if (!mData) {
FillInExternalData();
}
nsCOMPtr<nsIVariant> data = mData;
return data.forget();
}
already_AddRefed<nsIVariant>
DataTransferItem::Data(nsIPrincipal* aPrincipal, ErrorResult& aRv)
{
MOZ_ASSERT(aPrincipal);
nsCOMPtr<nsIVariant> variant = DataNoSecurityCheck();
// If the inbound principal is system, we can skip the below checks, as
// they will trivially succeed.
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
return variant.forget();
}
MOZ_ASSERT(!ChromeOnly(), "Non-chrome code shouldn't see a ChromeOnly DataTransferItem");
if (ChromeOnly()) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr;
}
bool checkItemPrincipal = mDataTransfer->IsCrossDomainSubFrameDrop() ||
(mDataTransfer->GetEventMessage() != eDrop &&
mDataTransfer->GetEventMessage() != ePaste);
// Check if the caller is allowed to access the drag data. Callers with
// chrome privileges can always read the data. During the
// drop event, allow retrieving the data except in the case where the
// source of the drag is in a child frame of the caller. In that case,
// we only allow access to data of the same principal. During other events,
// only allow access to the data with the same principal.
if (Principal() && checkItemPrincipal &&
!aPrincipal->Subsumes(Principal())) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr;
}
if (!variant) {
return nullptr;
}
nsCOMPtr<nsISupports> data;
nsresult rv = variant->GetAsISupports(getter_AddRefs(data));
if (NS_SUCCEEDED(rv) && data) {
nsCOMPtr<EventTarget> pt = do_QueryInterface(data);
if (pt) {
nsIScriptContext* c = pt->GetContextForEventHandlers(&rv);
if (NS_WARN_IF(NS_FAILED(rv) || !c)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr;
}
nsIGlobalObject* go = c->GetGlobalObject();
if (NS_WARN_IF(!go)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr;
}
nsCOMPtr<nsIScriptObjectPrincipal> sp = do_QueryInterface(go);
MOZ_ASSERT(sp, "This cannot fail on the main thread.");
nsIPrincipal* dataPrincipal = sp->GetPrincipal();
if (NS_WARN_IF(!dataPrincipal || !aPrincipal->Equals(dataPrincipal))) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr;
}
}
}
return variant.forget();
}
} // namespace dom
} // namespace mozilla

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

@ -14,7 +14,7 @@
namespace mozilla {
namespace dom {
class Entry;
class FileSystemEntry;
class FunctionStringCallback;
class DataTransferItem final : public nsISupports
@ -35,11 +35,17 @@ public:
KIND_OTHER,
};
DataTransferItem(DataTransferItemList* aParent, const nsAString& aType)
: mIndex(0), mChromeOnly(false), mKind(KIND_OTHER), mType(aType), mParent(aParent)
{}
DataTransferItem(DataTransfer* aDataTransfer, const nsAString& aType)
: mIndex(0)
, mChromeOnly(false)
, mKind(KIND_OTHER)
, mType(aType)
, mDataTransfer(aDataTransfer)
{
MOZ_ASSERT(mDataTransfer, "Must be associated with a DataTransfer");
}
already_AddRefed<DataTransferItem> Clone(DataTransferItemList* aParent) const;
already_AddRefed<DataTransferItem> Clone(DataTransfer* aDataTransfer) const;
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
void GetAsString(FunctionStringCallback* aCallback, ErrorResult& aRv);
@ -75,11 +81,11 @@ public:
already_AddRefed<File> GetAsFile(ErrorResult& aRv);
already_AddRefed<Entry> GetAsEntry(ErrorResult& aRv);
already_AddRefed<FileSystemEntry> GetAsEntry(ErrorResult& aRv);
DataTransferItemList* GetParentObject() const
DataTransfer* GetParentObject() const
{
return mParent;
return mDataTransfer;
}
nsIPrincipal* Principal() const
@ -91,13 +97,8 @@ public:
mPrincipal = aPrincipal;
}
nsIVariant* Data()
{
if (!mData) {
FillInExternalData();
}
return mData;
}
already_AddRefed<nsIVariant> DataNoSecurityCheck();
already_AddRefed<nsIVariant> Data(nsIPrincipal* aPrincipal, ErrorResult& aRv);
void SetData(nsIVariant* aData);
uint32_t Index() const
@ -131,7 +132,7 @@ private:
nsString mType;
nsCOMPtr<nsIVariant> mData;
nsCOMPtr<nsIPrincipal> mPrincipal;
RefPtr<DataTransferItemList> mParent;
RefPtr<DataTransfer> mDataTransfer;
// File cache for nsIFile application/x-moz-file entries.
RefPtr<File> mCachedFile;

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

@ -22,7 +22,7 @@
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DataTransferItemList, mParent, mItems,
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DataTransferItemList, mDataTransfer, mItems,
mIndexedItems, mFiles)
NS_IMPL_CYCLE_COLLECTING_ADDREF(DataTransferItemList)
NS_IMPL_CYCLE_COLLECTING_RELEASE(DataTransferItemList)
@ -40,10 +40,10 @@ DataTransferItemList::WrapObject(JSContext* aCx,
}
already_AddRefed<DataTransferItemList>
DataTransferItemList::Clone(DataTransfer* aParent) const
DataTransferItemList::Clone(DataTransfer* aDataTransfer) const
{
RefPtr<DataTransferItemList> list =
new DataTransferItemList(aParent, mIsExternal, mIsCrossDomainSubFrameDrop);
new DataTransferItemList(aDataTransfer, mIsExternal);
// We need to clone the mItems and mIndexedItems lists while keeping the same
// correspondences between the mIndexedItems and mItems lists (namely, if an
@ -63,7 +63,7 @@ DataTransferItemList::Clone(DataTransfer* aParent) const
nsTArray<RefPtr<DataTransferItem>>& newItems = list->mIndexedItems[i];
newItems.SetLength(items.Length());
for (uint32_t j = 0; j < items.Length(); j++) {
newItems[j] = items[j]->Clone(list);
newItems[j] = items[j]->Clone(aDataTransfer);
}
}
@ -83,7 +83,7 @@ DataTransferItemList::Clone(DataTransfer* aParent) const
void
DataTransferItemList::Remove(uint32_t aIndex, ErrorResult& aRv)
{
if (IsReadOnly()) {
if (mDataTransfer->IsReadOnly()) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
@ -104,63 +104,9 @@ DataTransferItemList::IndexedGetter(uint32_t aIndex, bool& aFound, ErrorResult&
return nullptr;
}
RefPtr<DataTransferItem> item = mItems[aIndex];
// Check if the caller is allowed to access the drag data. Callers with
// chrome privileges can always read the data. During the
// drop event, allow retrieving the data except in the case where the
// source of the drag is in a child frame of the caller. In that case,
// we only allow access to data of the same principal. During other events,
// only allow access to the data with the same principal.
nsIPrincipal* principal = nullptr;
if (mIsCrossDomainSubFrameDrop) {
principal = nsContentUtils::SubjectPrincipal();
}
if (item->Principal() && principal &&
!principal->Subsumes(item->Principal())) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
aFound = false;
return nullptr;
}
nsCOMPtr<nsIVariant> variantData = item->Data();
nsCOMPtr<nsISupports> data;
if (variantData &&
NS_SUCCEEDED(variantData->GetAsISupports(getter_AddRefs(data))) &&
data) {
// Make sure the code that is calling us is same-origin with the data.
nsCOMPtr<EventTarget> pt = do_QueryInterface(data);
if (pt) {
nsresult rv = NS_OK;
nsIScriptContext* c = pt->GetContextForEventHandlers(&rv);
if (NS_WARN_IF(NS_FAILED(rv) || !c)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr;
}
nsIGlobalObject* go = c->GetGlobalObject();
if (NS_WARN_IF(!go)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr;
}
nsCOMPtr<nsIScriptObjectPrincipal> sp = do_QueryInterface(go);
MOZ_ASSERT(sp, "This cannot fail on the main thread.");
nsIPrincipal* dataPrincipal = sp->GetPrincipal();
if (!principal) {
principal = nsContentUtils::SubjectPrincipal();
}
if (NS_WARN_IF(!dataPrincipal || !principal->Equals(dataPrincipal))) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return nullptr;
}
}
}
MOZ_ASSERT(mItems[aIndex]);
aFound = true;
return item;
return mItems[aIndex];
}
uint32_t
@ -178,7 +124,7 @@ DataTransferItemList::MozItemCount() const
void
DataTransferItemList::Clear(ErrorResult& aRv)
{
if (NS_WARN_IF(IsReadOnly())) {
if (NS_WARN_IF(mDataTransfer->IsReadOnly())) {
return;
}
@ -198,14 +144,14 @@ DataTransferItemList::Add(const nsAString& aData,
const nsAString& aType,
ErrorResult& aRv)
{
if (NS_WARN_IF(IsReadOnly())) {
if (NS_WARN_IF(mDataTransfer->IsReadOnly())) {
return nullptr;
}
nsCOMPtr<nsIVariant> data(new storage::TextVariant(aData));
nsAutoString format;
mParent->GetRealFormat(aType, format);
mDataTransfer->GetRealFormat(aType, format);
// We add the textual data to index 0. We set aInsertOnly to true, as we don't
// want to update an existing entry if it is already present, as per the spec.
@ -226,7 +172,7 @@ DataTransferItemList::Add(const nsAString& aData,
DataTransferItem*
DataTransferItemList::Add(File& aData, ErrorResult& aRv)
{
if (IsReadOnly()) {
if (mDataTransfer->IsReadOnly()) {
return nullptr;
}
@ -258,7 +204,7 @@ FileList*
DataTransferItemList::Files()
{
if (!mFiles) {
mFiles = new FileList(static_cast<nsIDOMDataTransfer*>(mParent));
mFiles = new FileList(static_cast<nsIDOMDataTransfer*>(mDataTransfer));
RegenerateFiles();
}
@ -270,7 +216,7 @@ DataTransferItemList::MozRemoveByTypeAt(const nsAString& aType,
uint32_t aIndex,
ErrorResult& aRv)
{
if (NS_WARN_IF(IsReadOnly() ||
if (NS_WARN_IF(mDataTransfer->IsReadOnly() ||
aIndex >= mIndexedItems.Length())) {
return;
}
@ -414,7 +360,7 @@ DataTransferItemList::AppendNewItem(uint32_t aIndex,
MOZ_ASSERT(mIndexedItems.Length() == aIndex);
mIndexedItems.AppendElement();
}
RefPtr<DataTransferItem> item = new DataTransferItem(this, aType);
RefPtr<DataTransferItem> item = new DataTransferItem(mDataTransfer, aType);
item->SetIndex(aIndex);
item->SetPrincipal(aPrincipal);
item->SetData(aData);
@ -444,27 +390,6 @@ DataTransferItemList::MozItemsAt(uint32_t aIndex) // -- INDEXED
return &mIndexedItems[aIndex];
}
bool
DataTransferItemList::IsReadOnly() const
{
MOZ_ASSERT(mParent);
return mParent->IsReadOnly();
}
int32_t
DataTransferItemList::ClipboardType() const
{
MOZ_ASSERT(mParent);
return mParent->ClipboardType();
}
EventMessage
DataTransferItemList::GetEventMessage() const
{
MOZ_ASSERT(mParent);
return mParent->GetEventMessage();
}
void
DataTransferItemList::PopIndexZero()
{
@ -501,7 +426,7 @@ DataTransferItemList::ClearDataHelper(DataTransferItem* aItem,
ErrorResult& aRv)
{
MOZ_ASSERT(aItem);
if (NS_WARN_IF(IsReadOnly())) {
if (NS_WARN_IF(mDataTransfer->IsReadOnly())) {
return;
}

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

@ -22,12 +22,11 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DataTransferItemList);
DataTransferItemList(DataTransfer* aParent, bool aIsExternal,
bool aIsCrossDomainSubFrameDrop)
: mParent(aParent)
, mIsCrossDomainSubFrameDrop(aIsCrossDomainSubFrameDrop)
DataTransferItemList(DataTransfer* aDataTransfer, bool aIsExternal)
: mDataTransfer(aDataTransfer)
, mIsExternal(aIsExternal)
{
MOZ_ASSERT(aDataTransfer);
// We always allocate an index 0 in our DataTransferItemList. This is done
// in order to maintain the invariants according to the spec. Mainly, within
// the spec's list, there is intended to be a single copy of each mime type,
@ -41,7 +40,7 @@ public:
mIndexedItems.SetLength(1);
}
already_AddRefed<DataTransferItemList> Clone(DataTransfer* aParent) const;
already_AddRefed<DataTransferItemList> Clone(DataTransfer* aDataTransfer) const;
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
@ -60,17 +59,12 @@ public:
DataTransferItem* IndexedGetter(uint32_t aIndex, bool& aFound,
ErrorResult& aRv) const;
void Clear(ErrorResult& aRv);
DataTransfer* GetParentObject() const
{
return mParent;
return mDataTransfer;
}
// Accessors for data from ParentObject
bool IsReadOnly() const;
int32_t ClipboardType() const;
EventMessage GetEventMessage() const;
void Clear(ErrorResult& aRv);
already_AddRefed<DataTransferItem>
SetDataWithPrincipal(const nsAString& aType, nsIVariant* aData,
@ -103,8 +97,7 @@ private:
~DataTransferItemList() {}
RefPtr<DataTransfer> mParent;
bool mIsCrossDomainSubFrameDrop;
RefPtr<DataTransfer> mDataTransfer;
bool mIsExternal;
RefPtr<FileList> mFiles;
nsTArray<RefPtr<DataTransferItem>> mItems;

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

@ -28,6 +28,7 @@
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIScreen.h"
#include "nsIScrollableFrame.h"
#include "nsJSEnvironment.h"
#include "nsLayoutUtils.h"
@ -597,6 +598,8 @@ Event::InitEvent(const nsAString& aEventTypeArg,
mEvent->mFlags.mDefaultPrevented = false;
mEvent->mFlags.mDefaultPreventedByContent = false;
mEvent->mFlags.mDefaultPreventedByChrome = false;
mEvent->mFlags.mPropagationStopped = false;
mEvent->mFlags.mImmediatePropagationStopped = false;
// Clearing the old targets, so that the event is targeted correctly when
// re-dispatching it.
@ -925,17 +928,46 @@ Event::GetScreenCoords(nsPresContext* aPresContext,
return CSSIntPoint(aPoint.x, aPoint.y);
}
nsPoint pt =
LayoutDevicePixel::ToAppUnits(aPoint, aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom());
int32_t appPerDevFullZoom =
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
LayoutDevicePoint devPt = aPoint;
if (nsIPresShell* ps = aPresContext->GetPresShell()) {
// convert to appUnits in order to use RemoveResolution, then back to
// device pixels
nsPoint pt =
LayoutDevicePixel::ToAppUnits(aPoint, appPerDevFullZoom);
pt = pt.RemoveResolution(nsLayoutUtils::GetCurrentAPZResolutionScale(ps));
devPt = LayoutDevicePixel::FromAppUnits(pt, appPerDevFullZoom);
}
pt += LayoutDevicePixel::ToAppUnits(guiEvent->mWidget->WidgetToScreenOffset(),
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom());
devPt += guiEvent->mWidget->WidgetToScreenOffset();
return CSSPixel::FromAppUnitsRounded(pt);
nsCOMPtr<nsIScreen> screen = guiEvent->mWidget->GetWidgetScreen();
if (screen) {
// subtract device-pixel origin of current screen
int32_t x, y, w, h;
screen->GetRect(&x, &y, &w, &h);
devPt.x -= x;
devPt.y -= y;
// then convert position *within the current screen* to unscaled CSS px
double cssToDevScale;
screen->GetDefaultCSSScaleFactor(&cssToDevScale);
CSSIntPoint cssPt(NSToIntRound(devPt.x / cssToDevScale),
NSToIntRound(devPt.y / cssToDevScale));
// finally, add the desktop-pixel origin of the screen, to get a global
// CSS pixel value that is compatible with window.screenX/Y positions
screen->GetRectDisplayPix(&x, &y, &w, &h);
cssPt.x += x;
cssPt.y += y;
return cssPt;
}
// this shouldn't happen, but just in case...
NS_WARNING("failed to find screen, using default CSS px conversion");
return CSSPixel::FromAppUnitsRounded(
LayoutDevicePixel::ToAppUnits(aPoint, appPerDevFullZoom));
}
// static

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

@ -4157,8 +4157,7 @@ GetWindowClientRectCenter(nsIWidget* aWidget)
{
NS_ENSURE_TRUE(aWidget, LayoutDeviceIntPoint(0, 0));
LayoutDeviceIntRect rect;
aWidget->GetClientBounds(rect);
LayoutDeviceIntRect rect = aWidget->GetClientBounds();
LayoutDeviceIntPoint point(rect.x + rect.width / 2,
rect.y + rect.height / 2);
int32_t round = aWidget->RoundsWidgetCoordinatesTo();

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

@ -413,12 +413,6 @@ WheelTransaction::OverrideSystemScrollSpeed(WidgetWheelEvent* aEvent)
return DeltaValues(aEvent);
}
// We shouldn't override the scrolling speed on non root scroll frame.
if (sTargetFrame !=
sTargetFrame->PresContext()->PresShell()->GetRootScrollFrame()) {
return DeltaValues(aEvent);
}
return DeltaValues(aEvent->OverriddenDeltaX(),
aEvent->OverriddenDeltaY());
}

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

@ -88,6 +88,8 @@ UNIFIED_SOURCES += [
'CustomEvent.cpp',
'DataContainerEvent.cpp',
'DataTransfer.cpp',
'DataTransferItem.cpp',
'DataTransferItemList.cpp',
'DeviceMotionEvent.cpp',
'DOMEventTargetHelper.cpp',
'DragEvent.cpp',
@ -126,8 +128,6 @@ UNIFIED_SOURCES += [
# nsEventStateManager.cpp should be built separately because of Mac OS X headers.
SOURCES += [
'DataTransferItem.cpp',
'DataTransferItemList.cpp',
'EventStateManager.cpp',
]

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

@ -16,9 +16,16 @@
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
SpecialPowers.pushPrefEnv({"set": [
["mousewheel.system_scroll_override_on_root_content.enabled", false]
]}, runTest);
var subWin = window.open("window_wheel_default_action.html", "_blank",
"width=500,height=500,scrollbars=yes");
var subWin = null;
function runTest() {
subWin = window.open("window_wheel_default_action.html", "_blank",
"width=500,height=500,scrollbars=yes");
}
function finish()
{

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

@ -918,7 +918,7 @@ FetchBody<Derived>::RegisterWorkerHolder()
MOZ_ASSERT(!mWorkerHolder);
mWorkerHolder = new FetchBodyWorkerHolder<Derived>(this);
if (!mWorkerHolder->HoldWorker(mWorkerPrivate)) {
if (!mWorkerHolder->HoldWorker(mWorkerPrivate, Closing)) {
NS_WARNING("Failed to add workerHolder");
mWorkerHolder = nullptr;
return false;

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

@ -9,7 +9,8 @@
#include "mozilla/dom/DOMError.h"
#include "mozilla/dom/File.h"
#include "mozilla/dom/FileBinding.h"
#include "mozilla/dom/FileEntry.h"
#include "mozilla/dom/FileSystemDirectoryReaderBinding.h"
#include "mozilla/dom/FileSystemFileEntry.h"
#include "mozilla/dom/Promise.h"
#include "nsIGlobalObject.h"
#include "nsPIDOMWindow.h"
@ -17,8 +18,8 @@
namespace mozilla {
namespace dom {
EntryCallbackRunnable::EntryCallbackRunnable(EntryCallback* aCallback,
Entry* aEntry)
EntryCallbackRunnable::EntryCallbackRunnable(FileSystemEntryCallback* aCallback,
FileSystemEntry* aEntry)
: mCallback(aCallback)
, mEntry(aEntry)
{
@ -58,7 +59,7 @@ ErrorCallbackRunnable::Run()
return NS_OK;
}
EmptyEntriesCallbackRunnable::EmptyEntriesCallbackRunnable(EntriesCallback* aCallback)
EmptyEntriesCallbackRunnable::EmptyEntriesCallbackRunnable(FileSystemEntriesCallback* aCallback)
: mCallback(aCallback)
{
MOZ_ASSERT(aCallback);
@ -67,16 +68,16 @@ EmptyEntriesCallbackRunnable::EmptyEntriesCallbackRunnable(EntriesCallback* aCal
NS_IMETHODIMP
EmptyEntriesCallbackRunnable::Run()
{
Sequence<OwningNonNull<Entry>> sequence;
Sequence<OwningNonNull<FileSystemEntry>> sequence;
mCallback->HandleEvent(sequence);
return NS_OK;
}
GetEntryHelper::GetEntryHelper(nsIGlobalObject* aGlobalObject,
DOMFileSystem* aFileSystem,
EntryCallback* aSuccessCallback,
FileSystem* aFileSystem,
FileSystemEntryCallback* aSuccessCallback,
ErrorCallback* aErrorCallback,
DirectoryEntry::GetInternalType aType)
FileSystemDirectoryEntry::GetInternalType aType)
: mGlobal(aGlobalObject)
, mFileSystem(aFileSystem)
, mSuccessCallback(aSuccessCallback)
@ -100,19 +101,20 @@ GetEntryHelper::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue)
JS::Rooted<JSObject*> obj(aCx, &aValue.toObject());
if (mType == DirectoryEntry::eGetFile) {
if (mType == FileSystemDirectoryEntry::eGetFile) {
RefPtr<File> file;
if (NS_FAILED(UNWRAP_OBJECT(File, obj, file))) {
Error(NS_ERROR_DOM_TYPE_MISMATCH_ERR);
return;
}
RefPtr<FileEntry> entry = new FileEntry(mGlobal, file, mFileSystem);
RefPtr<FileSystemFileEntry> entry =
new FileSystemFileEntry(mGlobal, file, mFileSystem);
mSuccessCallback->HandleEvent(*entry);
return;
}
MOZ_ASSERT(mType == DirectoryEntry::eGetDirectory);
MOZ_ASSERT(mType == FileSystemDirectoryEntry::eGetDirectory);
RefPtr<Directory> directory;
if (NS_FAILED(UNWRAP_OBJECT(Directory, obj, directory))) {
@ -120,8 +122,8 @@ GetEntryHelper::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue)
return;
}
RefPtr<DirectoryEntry> entry =
new DirectoryEntry(mGlobal, directory, mFileSystem);
RefPtr<FileSystemDirectoryEntry> entry =
new FileSystemDirectoryEntry(mGlobal, directory, mFileSystem);
mSuccessCallback->HandleEvent(*entry);
}

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

@ -7,7 +7,7 @@
#ifndef mozilla_dom_ErrorCallbackRunnable_h
#define mozilla_dom_ErrorCallbackRunnable_h
#include "DirectoryEntry.h"
#include "FileSystemDirectoryEntry.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/PromiseNativeHandler.h"
@ -16,18 +16,20 @@ class nsIGlobalObject;
namespace mozilla {
namespace dom {
class FileSystemEntriesCallback;
class EntryCallbackRunnable final : public Runnable
{
public:
EntryCallbackRunnable(EntryCallback* aCallback,
Entry* aEntry);
EntryCallbackRunnable(FileSystemEntryCallback* aCallback,
FileSystemEntry* aEntry);
NS_IMETHOD
Run() override;
private:
RefPtr<EntryCallback> mCallback;
RefPtr<Entry> mEntry;
RefPtr<FileSystemEntryCallback> mCallback;
RefPtr<FileSystemEntry> mEntry;
};
class ErrorCallbackRunnable final : public Runnable
@ -49,13 +51,13 @@ private:
class EmptyEntriesCallbackRunnable final : public Runnable
{
public:
explicit EmptyEntriesCallbackRunnable(EntriesCallback* aCallback);
explicit EmptyEntriesCallbackRunnable(FileSystemEntriesCallback* aCallback);
NS_IMETHOD
Run() override;
private:
RefPtr<EntriesCallback> mCallback;
RefPtr<FileSystemEntriesCallback> mCallback;
};
class GetEntryHelper final : public PromiseNativeHandler
@ -64,10 +66,10 @@ public:
NS_DECL_ISUPPORTS
GetEntryHelper(nsIGlobalObject* aGlobalObject,
DOMFileSystem* aFileSystem,
EntryCallback* aSuccessCallback,
FileSystem* aFileSystem,
FileSystemEntryCallback* aSuccessCallback,
ErrorCallback* aErrorCallback,
DirectoryEntry::GetInternalType aType);
FileSystemDirectoryEntry::GetInternalType aType);
virtual void
ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override;
@ -82,10 +84,10 @@ private:
Error(nsresult aError);
nsCOMPtr<nsIGlobalObject> mGlobal;
RefPtr<DOMFileSystem> mFileSystem;
RefPtr<EntryCallback> mSuccessCallback;
RefPtr<FileSystem> mFileSystem;
RefPtr<FileSystemEntryCallback> mSuccessCallback;
RefPtr<ErrorCallback> mErrorCallback;
DirectoryEntry::GetInternalType mType;
FileSystemDirectoryEntry::GetInternalType mType;
};
class ErrorCallbackHelper

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

@ -1,66 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "Entry.h"
#include "DirectoryEntry.h"
#include "FileEntry.h"
#include "mozilla/dom/UnionTypes.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Entry, mParent, mFileSystem)
NS_IMPL_CYCLE_COLLECTING_ADDREF(Entry)
NS_IMPL_CYCLE_COLLECTING_RELEASE(Entry)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Entry)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
/* static */ already_AddRefed<Entry>
Entry::Create(nsIGlobalObject* aGlobalObject,
const OwningFileOrDirectory& aFileOrDirectory,
DOMFileSystem* aFileSystem)
{
MOZ_ASSERT(aGlobalObject);
MOZ_ASSERT(aFileSystem);
RefPtr<Entry> entry;
if (aFileOrDirectory.IsFile()) {
entry = new FileEntry(aGlobalObject,
aFileOrDirectory.GetAsFile(),
aFileSystem);
} else {
MOZ_ASSERT(aFileOrDirectory.IsDirectory());
entry = new DirectoryEntry(aGlobalObject,
aFileOrDirectory.GetAsDirectory(),
aFileSystem);
}
return entry.forget();
}
Entry::Entry(nsIGlobalObject* aGlobal, DOMFileSystem* aFileSystem)
: mParent(aGlobal)
, mFileSystem(aFileSystem)
{
MOZ_ASSERT(aGlobal);
MOZ_ASSERT(aFileSystem);
}
Entry::~Entry()
{}
JSObject*
Entry::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return EntryBinding::Wrap(aCx, this, aGivenProto);
}
} // dom namespace
} // mozilla namespace

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

@ -4,26 +4,26 @@
* 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 "DOMFileSystem.h"
#include "RootDirectoryEntry.h"
#include "mozilla/dom/DOMFileSystemBinding.h"
#include "FileSystem.h"
#include "FileSystemRootDirectoryEntry.h"
#include "mozilla/dom/FileSystemBinding.h"
#include "nsContentUtils.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMFileSystem, mParent, mRoot)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(FileSystem, mParent, mRoot)
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMFileSystem)
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMFileSystem)
NS_IMPL_CYCLE_COLLECTING_ADDREF(FileSystem)
NS_IMPL_CYCLE_COLLECTING_RELEASE(FileSystem)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMFileSystem)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FileSystem)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
/* static */ already_AddRefed<DOMFileSystem>
DOMFileSystem::Create(nsIGlobalObject* aGlobalObject)
/* static */ already_AddRefed<FileSystem>
FileSystem::Create(nsIGlobalObject* aGlobalObject)
{
MOZ_ASSERT(aGlobalObject);
@ -42,34 +42,33 @@ DOMFileSystem::Create(nsIGlobalObject* aGlobalObject)
// UUID in this format '{' + UUID + '}'. We remove them with these +1 and -2.
nsAutoCString name(Substring(chars + 1, chars + NSID_LENGTH - 2));
RefPtr<DOMFileSystem> fs =
new DOMFileSystem(aGlobalObject, NS_ConvertUTF8toUTF16(name));
RefPtr<FileSystem> fs =
new FileSystem(aGlobalObject, NS_ConvertUTF8toUTF16(name));
return fs.forget();
}
DOMFileSystem::DOMFileSystem(nsIGlobalObject* aGlobal,
const nsAString& aName)
FileSystem::FileSystem(nsIGlobalObject* aGlobal, const nsAString& aName)
: mParent(aGlobal)
, mName(aName)
{
MOZ_ASSERT(aGlobal);
}
DOMFileSystem::~DOMFileSystem()
FileSystem::~FileSystem()
{}
JSObject*
DOMFileSystem::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
FileSystem::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return DOMFileSystemBinding::Wrap(aCx, this, aGivenProto);
return FileSystemBinding::Wrap(aCx, this, aGivenProto);
}
void
DOMFileSystem::CreateRoot(const Sequence<RefPtr<Entry>>& aEntries)
FileSystem::CreateRoot(const Sequence<RefPtr<FileSystemEntry>>& aEntries)
{
MOZ_ASSERT(!mRoot);
mRoot = new RootDirectoryEntry(mParent, aEntries, this);
mRoot = new FileSystemRootDirectoryEntry(mParent, aEntries, this);
}
} // dom namespace

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

@ -4,8 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_DOMFileSystem_h
#define mozilla_dom_DOMFileSystem_h
#ifndef mozilla_dom_FileSystem_h
#define mozilla_dom_FileSystem_h
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
@ -18,19 +18,19 @@ class nsIGlobalObject;
namespace mozilla {
namespace dom {
class DirectoryEntry;
class Entry;
class FileSystemDirectoryEntry;
class FileSystemEntry;
class OwningFileOrDirectory;
class DOMFileSystem final
class FileSystem final
: public nsISupports
, public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMFileSystem)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(FileSystem)
static already_AddRefed<DOMFileSystem>
static already_AddRefed<FileSystem>
Create(nsIGlobalObject* aGlobalObject);
nsIGlobalObject*
@ -48,26 +48,26 @@ public:
aName = mName;
}
DirectoryEntry*
FileSystemDirectoryEntry*
Root() const
{
return mRoot;
}
void
CreateRoot(const Sequence<RefPtr<Entry>>& aEntries);
CreateRoot(const Sequence<RefPtr<FileSystemEntry>>& aEntries);
private:
explicit DOMFileSystem(nsIGlobalObject* aGlobalObject,
const nsAString& aName);
~DOMFileSystem();
explicit FileSystem(nsIGlobalObject* aGlobalObject,
const nsAString& aName);
~FileSystem();
nsCOMPtr<nsIGlobalObject> mParent;
RefPtr<DirectoryEntry> mRoot;
RefPtr<FileSystemDirectoryEntry> mRoot;
nsString mName;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_DOMFileSystem_h
#endif // mozilla_dom_FileSystem_h

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

@ -4,70 +4,74 @@
* 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 "DirectoryEntry.h"
#include "FileSystemDirectoryEntry.h"
#include "CallbackRunnables.h"
#include "DirectoryReader.h"
#include "FileSystemDirectoryReader.h"
#include "mozilla/dom/Directory.h"
#include "mozilla/dom/FileSystemDirectoryEntryBinding.h"
#include "mozilla/dom/FileSystemUtils.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_INHERITED(DirectoryEntry, Entry, mDirectory)
NS_IMPL_CYCLE_COLLECTION_INHERITED(FileSystemDirectoryEntry, FileSystemEntry,
mDirectory)
NS_IMPL_ADDREF_INHERITED(DirectoryEntry, Entry)
NS_IMPL_RELEASE_INHERITED(DirectoryEntry, Entry)
NS_IMPL_ADDREF_INHERITED(FileSystemDirectoryEntry, FileSystemEntry)
NS_IMPL_RELEASE_INHERITED(FileSystemDirectoryEntry, FileSystemEntry)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DirectoryEntry)
NS_INTERFACE_MAP_END_INHERITING(Entry)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FileSystemDirectoryEntry)
NS_INTERFACE_MAP_END_INHERITING(FileSystemEntry)
DirectoryEntry::DirectoryEntry(nsIGlobalObject* aGlobal,
Directory* aDirectory,
DOMFileSystem* aFileSystem)
: Entry(aGlobal, aFileSystem)
FileSystemDirectoryEntry::FileSystemDirectoryEntry(nsIGlobalObject* aGlobal,
Directory* aDirectory,
FileSystem* aFileSystem)
: FileSystemEntry(aGlobal, aFileSystem)
, mDirectory(aDirectory)
{
MOZ_ASSERT(aGlobal);
}
DirectoryEntry::~DirectoryEntry()
FileSystemDirectoryEntry::~FileSystemDirectoryEntry()
{}
JSObject*
DirectoryEntry::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
FileSystemDirectoryEntry::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto)
{
return DirectoryEntryBinding::Wrap(aCx, this, aGivenProto);
return FileSystemDirectoryEntryBinding::Wrap(aCx, this, aGivenProto);
}
void
DirectoryEntry::GetName(nsAString& aName, ErrorResult& aRv) const
FileSystemDirectoryEntry::GetName(nsAString& aName, ErrorResult& aRv) const
{
MOZ_ASSERT(mDirectory);
mDirectory->GetName(aName, aRv);
}
void
DirectoryEntry::GetFullPath(nsAString& aPath, ErrorResult& aRv) const
FileSystemDirectoryEntry::GetFullPath(nsAString& aPath, ErrorResult& aRv) const
{
MOZ_ASSERT(mDirectory);
mDirectory->GetPath(aPath, aRv);
}
already_AddRefed<DirectoryReader>
DirectoryEntry::CreateReader() const
already_AddRefed<FileSystemDirectoryReader>
FileSystemDirectoryEntry::CreateReader() const
{
MOZ_ASSERT(mDirectory);
RefPtr<DirectoryReader> reader =
new DirectoryReader(GetParentObject(), Filesystem(), mDirectory);
RefPtr<FileSystemDirectoryReader> reader =
new FileSystemDirectoryReader(GetParentObject(), Filesystem(), mDirectory);
return reader.forget();
}
void
DirectoryEntry::GetInternal(const nsAString& aPath, const FileSystemFlags& aFlag,
const Optional<OwningNonNull<EntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
GetInternalType aType) const
FileSystemDirectoryEntry::GetInternal(const nsAString& aPath,
const FileSystemFlags& aFlag,
const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
GetInternalType aType) const
{
MOZ_ASSERT(mDirectory);
@ -107,8 +111,8 @@ DirectoryEntry::GetInternal(const nsAString& aPath, const FileSystemFlags& aFlag
}
void
DirectoryEntry::RemoveRecursively(VoidCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback) const
FileSystemDirectoryEntry::RemoveRecursively(VoidCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback) const
{
ErrorCallbackHelper::Call(GetParentObject(), aErrorCallback,
NS_ERROR_DOM_SECURITY_ERR);

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

@ -4,25 +4,28 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_DirectoryEntry_h
#define mozilla_dom_DirectoryEntry_h
#ifndef mozilla_dom_FileSystemDirectoryEntry_h
#define mozilla_dom_FileSystemDirectoryEntry_h
#include "mozilla/dom/Entry.h"
#include "mozilla/dom/DOMFileSystemBinding.h"
#include "mozilla/dom/FileSystemBinding.h"
#include "mozilla/dom/FileSystemEntry.h"
namespace mozilla {
namespace dom {
class Directory;
class FileSystemDirectoryReader;
class DirectoryEntry : public Entry
class FileSystemDirectoryEntry : public FileSystemEntry
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DirectoryEntry, Entry)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileSystemDirectoryEntry,
FileSystemEntry)
DirectoryEntry(nsIGlobalObject* aGlobalObject, Directory* aDirectory,
DOMFileSystem* aFileSystem);
FileSystemDirectoryEntry(nsIGlobalObject* aGlobalObject,
Directory* aDirectory,
FileSystem* aFileSystem);
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
@ -39,12 +42,12 @@ public:
virtual void
GetFullPath(nsAString& aFullPath, ErrorResult& aRv) const override;
virtual already_AddRefed<DirectoryReader>
virtual already_AddRefed<FileSystemDirectoryReader>
CreateReader() const;
void
GetFile(const nsAString& aPath, const FileSystemFlags& aFlag,
const Optional<OwningNonNull<EntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback) const
{
GetInternal(aPath, aFlag, aSuccessCallback, aErrorCallback, eGetFile);
@ -52,7 +55,7 @@ public:
void
GetDirectory(const nsAString& aPath, const FileSystemFlags& aFlag,
const Optional<OwningNonNull<EntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback) const
{
GetInternal(aPath, aFlag, aSuccessCallback, aErrorCallback, eGetDirectory);
@ -66,12 +69,12 @@ public:
virtual void
GetInternal(const nsAString& aPath, const FileSystemFlags& aFlag,
const Optional<OwningNonNull<EntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
GetInternalType aType) const;
protected:
virtual ~DirectoryEntry();
virtual ~FileSystemDirectoryEntry();
private:
RefPtr<Directory> mDirectory;
@ -80,4 +83,4 @@ private:
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_DirectoryEntry_h
#endif // mozilla_dom_FileSystemDirectoryEntry_h

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

@ -4,9 +4,9 @@
* 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 "DirectoryReader.h"
#include "FileSystemDirectoryReader.h"
#include "CallbackRunnables.h"
#include "FileEntry.h"
#include "FileSystemFileEntry.h"
#include "mozilla/dom/FileBinding.h"
#include "mozilla/dom/Directory.h"
#include "mozilla/dom/DirectoryBinding.h"
@ -25,8 +25,8 @@ public:
NS_DECL_ISUPPORTS
PromiseHandler(nsIGlobalObject* aGlobalObject,
DOMFileSystem* aFileSystem,
EntriesCallback* aSuccessCallback,
FileSystem* aFileSystem,
FileSystemEntriesCallback* aSuccessCallback,
ErrorCallback* aErrorCallback)
: mGlobal(aGlobalObject)
, mFileSystem(aFileSystem)
@ -52,7 +52,7 @@ public:
return;
}
Sequence<OwningNonNull<Entry>> sequence;
Sequence<OwningNonNull<FileSystemEntry>> sequence;
if (NS_WARN_IF(!sequence.SetLength(length, fallible))) {
return;
}
@ -71,7 +71,8 @@ public:
RefPtr<File> file;
if (NS_SUCCEEDED(UNWRAP_OBJECT(File, valueObj, file))) {
RefPtr<FileEntry> entry = new FileEntry(mGlobal, file, mFileSystem);
RefPtr<FileSystemFileEntry> entry =
new FileSystemFileEntry(mGlobal, file, mFileSystem);
sequence[i] = entry;
continue;
}
@ -82,8 +83,8 @@ public:
return;
}
RefPtr<DirectoryEntry> entry =
new DirectoryEntry(mGlobal, directory, mFileSystem);
RefPtr<FileSystemDirectoryEntry> entry =
new FileSystemDirectoryEntry(mGlobal, directory, mFileSystem);
sequence[i] = entry;
}
@ -106,8 +107,8 @@ private:
~PromiseHandler() {}
nsCOMPtr<nsIGlobalObject> mGlobal;
RefPtr<DOMFileSystem> mFileSystem;
RefPtr<EntriesCallback> mSuccessCallback;
RefPtr<FileSystem> mFileSystem;
RefPtr<FileSystemEntriesCallback> mSuccessCallback;
RefPtr<ErrorCallback> mErrorCallback;
};
@ -115,20 +116,20 @@ NS_IMPL_ISUPPORTS0(PromiseHandler);
} // anonymous namespace
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DirectoryReader, mParent, mDirectory,
mFileSystem)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(FileSystemDirectoryReader, mParent,
mDirectory, mFileSystem)
NS_IMPL_CYCLE_COLLECTING_ADDREF(DirectoryReader)
NS_IMPL_CYCLE_COLLECTING_RELEASE(DirectoryReader)
NS_IMPL_CYCLE_COLLECTING_ADDREF(FileSystemDirectoryReader)
NS_IMPL_CYCLE_COLLECTING_RELEASE(FileSystemDirectoryReader)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DirectoryReader)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FileSystemDirectoryReader)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
DirectoryReader::DirectoryReader(nsIGlobalObject* aGlobal,
DOMFileSystem* aFileSystem,
Directory* aDirectory)
FileSystemDirectoryReader::FileSystemDirectoryReader(nsIGlobalObject* aGlobal,
FileSystem* aFileSystem,
Directory* aDirectory)
: mParent(aGlobal)
, mFileSystem(aFileSystem)
, mDirectory(aDirectory)
@ -138,19 +139,20 @@ DirectoryReader::DirectoryReader(nsIGlobalObject* aGlobal,
MOZ_ASSERT(aFileSystem);
}
DirectoryReader::~DirectoryReader()
FileSystemDirectoryReader::~FileSystemDirectoryReader()
{}
JSObject*
DirectoryReader::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
FileSystemDirectoryReader::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto)
{
return DirectoryReaderBinding::Wrap(aCx, this, aGivenProto);
return FileSystemDirectoryReaderBinding::Wrap(aCx, this, aGivenProto);
}
void
DirectoryReader::ReadEntries(EntriesCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
ErrorResult& aRv)
FileSystemDirectoryReader::ReadEntries(FileSystemEntriesCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
ErrorResult& aRv)
{
MOZ_ASSERT(mDirectory);

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

@ -4,8 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_DirectoryReader_h
#define mozilla_dom_DirectoryReader_h
#ifndef mozilla_dom_FileSystemDirectoryReader_h
#define mozilla_dom_FileSystemDirectoryReader_h
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
@ -19,19 +19,20 @@ namespace mozilla {
namespace dom {
class Directory;
class DOMFileSystem;
class FileSystem;
class FileSystemEntriesCallback;
class DirectoryReader
class FileSystemDirectoryReader
: public nsISupports
, public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DirectoryReader)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(FileSystemDirectoryReader)
explicit DirectoryReader(nsIGlobalObject* aGlobalObject,
DOMFileSystem* aFileSystem,
Directory* aDirectory);
explicit FileSystemDirectoryReader(nsIGlobalObject* aGlobalObject,
FileSystem* aFileSystem,
Directory* aDirectory);
nsIGlobalObject*
GetParentObject() const
@ -43,16 +44,16 @@ public:
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
virtual void
ReadEntries(EntriesCallback& aSuccessCallback,
ReadEntries(FileSystemEntriesCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
ErrorResult& aRv);
protected:
virtual ~DirectoryReader();
virtual ~FileSystemDirectoryReader();
private:
nsCOMPtr<nsIGlobalObject> mParent;
RefPtr<DOMFileSystem> mFileSystem;
RefPtr<FileSystem> mFileSystem;
RefPtr<Directory> mDirectory;
bool mAlreadyRead;
@ -61,4 +62,4 @@ private:
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_DirectoryReader_h
#endif // mozilla_dom_FileSystemDirectoryReader_h

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

@ -0,0 +1,68 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "FileSystemEntry.h"
#include "FileSystemDirectoryEntry.h"
#include "FileSystemFileEntry.h"
#include "mozilla/dom/FileSystemEntryBinding.h"
#include "mozilla/dom/UnionTypes.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(FileSystemEntry, mParent, mFileSystem)
NS_IMPL_CYCLE_COLLECTING_ADDREF(FileSystemEntry)
NS_IMPL_CYCLE_COLLECTING_RELEASE(FileSystemEntry)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FileSystemEntry)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
/* static */ already_AddRefed<FileSystemEntry>
FileSystemEntry::Create(nsIGlobalObject* aGlobalObject,
const OwningFileOrDirectory& aFileOrDirectory,
FileSystem* aFileSystem)
{
MOZ_ASSERT(aGlobalObject);
MOZ_ASSERT(aFileSystem);
RefPtr<FileSystemEntry> entry;
if (aFileOrDirectory.IsFile()) {
entry = new FileSystemFileEntry(aGlobalObject,
aFileOrDirectory.GetAsFile(),
aFileSystem);
} else {
MOZ_ASSERT(aFileOrDirectory.IsDirectory());
entry = new FileSystemDirectoryEntry(aGlobalObject,
aFileOrDirectory.GetAsDirectory(),
aFileSystem);
}
return entry.forget();
}
FileSystemEntry::FileSystemEntry(nsIGlobalObject* aGlobal,
FileSystem* aFileSystem)
: mParent(aGlobal)
, mFileSystem(aFileSystem)
{
MOZ_ASSERT(aGlobal);
MOZ_ASSERT(aFileSystem);
}
FileSystemEntry::~FileSystemEntry()
{}
JSObject*
FileSystemEntry::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return FileSystemEntryBinding::Wrap(aCx, this, aGivenProto);
}
} // dom namespace
} // mozilla namespace

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

@ -4,8 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_Entry_h
#define mozilla_dom_Entry_h
#ifndef mozilla_dom_FileSystemEntry_h
#define mozilla_dom_FileSystemEntry_h
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
@ -17,21 +17,21 @@
namespace mozilla {
namespace dom {
class DOMFileSystem;
class FileSystem;
class OwningFileOrDirectory;
class Entry
class FileSystemEntry
: public nsISupports
, public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Entry)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(FileSystemEntry)
static already_AddRefed<Entry>
static already_AddRefed<FileSystemEntry>
Create(nsIGlobalObject* aGlobalObject,
const OwningFileOrDirectory& aFileOrDirectory,
DOMFileSystem* aFileSystem);
FileSystem* aFileSystem);
nsIGlobalObject*
GetParentObject() const
@ -60,23 +60,23 @@ public:
virtual void
GetFullPath(nsAString& aFullPath, ErrorResult& aRv) const = 0;
DOMFileSystem*
FileSystem*
Filesystem() const
{
return mFileSystem;
}
protected:
Entry(nsIGlobalObject* aGlobalObject,
DOMFileSystem* aFileSystem);
virtual ~Entry();
FileSystemEntry(nsIGlobalObject* aGlobalObject,
FileSystem* aFileSystem);
virtual ~FileSystemEntry();
private:
nsCOMPtr<nsIGlobalObject> mParent;
RefPtr<DOMFileSystem> mFileSystem;
RefPtr<FileSystem> mFileSystem;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_Entry_h
#endif // mozilla_dom_FileSystemEntry_h

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

@ -4,9 +4,10 @@
* 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 "FileEntry.h"
#include "FileSystemFileEntry.h"
#include "CallbackRunnables.h"
#include "mozilla/dom/File.h"
#include "mozilla/dom/FileSystemFileEntryBinding.h"
namespace mozilla {
namespace dom {
@ -38,41 +39,42 @@ private:
} // anonymous namespace
NS_IMPL_CYCLE_COLLECTION_INHERITED(FileEntry, Entry, mFile)
NS_IMPL_CYCLE_COLLECTION_INHERITED(FileSystemFileEntry, FileSystemEntry, mFile)
NS_IMPL_ADDREF_INHERITED(FileEntry, Entry)
NS_IMPL_RELEASE_INHERITED(FileEntry, Entry)
NS_IMPL_ADDREF_INHERITED(FileSystemFileEntry, FileSystemEntry)
NS_IMPL_RELEASE_INHERITED(FileSystemFileEntry, FileSystemEntry)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FileEntry)
NS_INTERFACE_MAP_END_INHERITING(Entry)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FileSystemFileEntry)
NS_INTERFACE_MAP_END_INHERITING(FileSystemEntry)
FileEntry::FileEntry(nsIGlobalObject* aGlobal,
File* aFile,
DOMFileSystem* aFileSystem)
: Entry(aGlobal, aFileSystem)
FileSystemFileEntry::FileSystemFileEntry(nsIGlobalObject* aGlobal,
File* aFile,
FileSystem* aFileSystem)
: FileSystemEntry(aGlobal, aFileSystem)
, mFile(aFile)
{
MOZ_ASSERT(aGlobal);
MOZ_ASSERT(mFile);
}
FileEntry::~FileEntry()
FileSystemFileEntry::~FileSystemFileEntry()
{}
JSObject*
FileEntry::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
FileSystemFileEntry::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto)
{
return FileEntryBinding::Wrap(aCx, this, aGivenProto);
return FileSystemFileEntryBinding::Wrap(aCx, this, aGivenProto);
}
void
FileEntry::GetName(nsAString& aName, ErrorResult& aRv) const
FileSystemFileEntry::GetName(nsAString& aName, ErrorResult& aRv) const
{
mFile->GetName(aName);
}
void
FileEntry::GetFullPath(nsAString& aPath, ErrorResult& aRv) const
FileSystemFileEntry::GetFullPath(nsAString& aPath, ErrorResult& aRv) const
{
mFile->GetPath(aPath);
if (aPath.IsEmpty()) {
@ -88,16 +90,16 @@ FileEntry::GetFullPath(nsAString& aPath, ErrorResult& aRv) const
}
void
FileEntry::CreateWriter(VoidCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback) const
FileSystemFileEntry::CreateWriter(VoidCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback) const
{
ErrorCallbackHelper::Call(GetParentObject(), aErrorCallback,
NS_ERROR_DOM_SECURITY_ERR);
}
void
FileEntry::GetFile(BlobCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback) const
FileSystemFileEntry::GetFile(BlobCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback) const
{
RefPtr<BlobCallbackRunnable> runnable =
new BlobCallbackRunnable(&aSuccessCallback, mFile);

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

@ -4,24 +4,25 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_FileEntry_h
#define mozilla_dom_FileEntry_h
#ifndef mozilla_dom_FileSystemFileEntry_h
#define mozilla_dom_FileSystemFileEntry_h
#include "mozilla/dom/Entry.h"
#include "mozilla/dom/FileSystemEntry.h"
namespace mozilla {
namespace dom {
class File;
class BlobCallback;
class FileEntry final : public Entry
class FileSystemFileEntry final : public FileSystemEntry
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileEntry, Entry)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileSystemFileEntry, FileSystemEntry)
FileEntry(nsIGlobalObject* aGlobalObject, File* aFile,
DOMFileSystem* aFileSystem);
FileSystemFileEntry(nsIGlobalObject* aGlobalObject, File* aFile,
FileSystem* aFileSystem);
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
@ -47,7 +48,7 @@ public:
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback) const;
private:
~FileEntry();
~FileSystemFileEntry();
RefPtr<File> mFile;
};
@ -55,4 +56,4 @@ private:
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_FileEntry_h
#endif // mozilla_dom_FileSystemFileEntry_h

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

@ -4,58 +4,61 @@
* 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 "RootDirectoryEntry.h"
#include "RootDirectoryReader.h"
#include "FileSystemRootDirectoryEntry.h"
#include "FileSystemRootDirectoryReader.h"
#include "mozilla/dom/FileSystemUtils.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_INHERITED(RootDirectoryEntry, DirectoryEntry, mEntries)
NS_IMPL_CYCLE_COLLECTION_INHERITED(FileSystemRootDirectoryEntry,
FileSystemDirectoryEntry, mEntries)
NS_IMPL_ADDREF_INHERITED(RootDirectoryEntry, DirectoryEntry)
NS_IMPL_RELEASE_INHERITED(RootDirectoryEntry, DirectoryEntry)
NS_IMPL_ADDREF_INHERITED(FileSystemRootDirectoryEntry, FileSystemDirectoryEntry)
NS_IMPL_RELEASE_INHERITED(FileSystemRootDirectoryEntry, FileSystemDirectoryEntry)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(RootDirectoryEntry)
NS_INTERFACE_MAP_END_INHERITING(DirectoryEntry)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FileSystemRootDirectoryEntry)
NS_INTERFACE_MAP_END_INHERITING(FileSystemDirectoryEntry)
RootDirectoryEntry::RootDirectoryEntry(nsIGlobalObject* aGlobal,
const Sequence<RefPtr<Entry>>& aEntries,
DOMFileSystem* aFileSystem)
: DirectoryEntry(aGlobal, nullptr, aFileSystem)
FileSystemRootDirectoryEntry::FileSystemRootDirectoryEntry(nsIGlobalObject* aGlobal,
const Sequence<RefPtr<FileSystemEntry>>& aEntries,
FileSystem* aFileSystem)
: FileSystemDirectoryEntry(aGlobal, nullptr, aFileSystem)
, mEntries(aEntries)
{
MOZ_ASSERT(aGlobal);
}
RootDirectoryEntry::~RootDirectoryEntry()
FileSystemRootDirectoryEntry::~FileSystemRootDirectoryEntry()
{}
void
RootDirectoryEntry::GetName(nsAString& aName, ErrorResult& aRv) const
FileSystemRootDirectoryEntry::GetName(nsAString& aName, ErrorResult& aRv) const
{
aName.Truncate();
}
void
RootDirectoryEntry::GetFullPath(nsAString& aPath, ErrorResult& aRv) const
FileSystemRootDirectoryEntry::GetFullPath(nsAString& aPath, ErrorResult& aRv) const
{
aPath.AssignLiteral(FILESYSTEM_DOM_PATH_SEPARATOR_LITERAL);
}
already_AddRefed<DirectoryReader>
RootDirectoryEntry::CreateReader() const
already_AddRefed<FileSystemDirectoryReader>
FileSystemRootDirectoryEntry::CreateReader() const
{
RefPtr<DirectoryReader> reader =
new RootDirectoryReader(GetParentObject(), Filesystem(), mEntries);
RefPtr<FileSystemDirectoryReader> reader =
new FileSystemRootDirectoryReader(GetParentObject(), Filesystem(),
mEntries);
return reader.forget();
}
void
RootDirectoryEntry::GetInternal(const nsAString& aPath, const FileSystemFlags& aFlag,
const Optional<OwningNonNull<EntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
GetInternalType aType) const
FileSystemRootDirectoryEntry::GetInternal(const nsAString& aPath,
const FileSystemFlags& aFlag,
const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
GetInternalType aType) const
{
if (!aSuccessCallback.WasPassed() && !aErrorCallback.WasPassed()) {
return;
@ -76,7 +79,7 @@ RootDirectoryEntry::GetInternal(const nsAString& aPath, const FileSystemFlags& a
MOZ_ASSERT(!parts.IsEmpty());
RefPtr<Entry> entry;
RefPtr<FileSystemEntry> entry;
for (uint32_t i = 0; i < mEntries.Length(); ++i) {
ErrorResult rv;
nsAutoString name;
@ -135,7 +138,7 @@ RootDirectoryEntry::GetInternal(const nsAString& aPath, const FileSystemFlags& a
}
}
auto* directoryEntry = static_cast<DirectoryEntry*>(entry.get());
auto* directoryEntry = static_cast<FileSystemDirectoryEntry*>(entry.get());
directoryEntry->GetInternal(path, aFlag, aSuccessCallback, aErrorCallback,
aType);
}

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

@ -4,23 +4,23 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_RootDirectoryEntry_h
#define mozilla_dom_RootDirectoryEntry_h
#ifndef mozilla_dom_FileSystemRootDirectoryEntry_h
#define mozilla_dom_FileSystemRootDirectoryEntry_h
#include "mozilla/dom/DirectoryEntry.h"
#include "mozilla/dom/FileSystemDirectoryEntry.h"
namespace mozilla {
namespace dom {
class RootDirectoryEntry final : public DirectoryEntry
class FileSystemRootDirectoryEntry final : public FileSystemDirectoryEntry
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(RootDirectoryEntry, DirectoryEntry)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileSystemRootDirectoryEntry, FileSystemDirectoryEntry)
RootDirectoryEntry(nsIGlobalObject* aGlobalObject,
const Sequence<RefPtr<Entry>>& aEntries,
DOMFileSystem* aFileSystem);
FileSystemRootDirectoryEntry(nsIGlobalObject* aGlobalObject,
const Sequence<RefPtr<FileSystemEntry>>& aEntries,
FileSystem* aFileSystem);
virtual void
GetName(nsAString& aName, ErrorResult& aRv) const override;
@ -28,15 +28,15 @@ public:
virtual void
GetFullPath(nsAString& aFullPath, ErrorResult& aRv) const override;
virtual already_AddRefed<DirectoryReader>
virtual already_AddRefed<FileSystemDirectoryReader>
CreateReader() const override;
private:
~RootDirectoryEntry();
~FileSystemRootDirectoryEntry();
virtual void
GetInternal(const nsAString& aPath, const FileSystemFlags& aFlag,
const Optional<OwningNonNull<EntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<FileSystemEntryCallback>>& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
GetInternalType aType) const override;
@ -44,10 +44,10 @@ private:
Error(const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
nsresult aError) const;
Sequence<RefPtr<Entry>> mEntries;
Sequence<RefPtr<FileSystemEntry>> mEntries;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_RootDirectoryEntry_h
#endif // mozilla_dom_FileSystemRootDirectoryEntry_h

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

@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "RootDirectoryReader.h"
#include "FileSystemRootDirectoryReader.h"
#include "CallbackRunnables.h"
#include "nsIGlobalObject.h"
@ -16,8 +16,8 @@ namespace {
class EntriesCallbackRunnable final : public Runnable
{
public:
EntriesCallbackRunnable(EntriesCallback* aCallback,
const Sequence<RefPtr<Entry>>& aEntries)
EntriesCallbackRunnable(FileSystemEntriesCallback* aCallback,
const Sequence<RefPtr<FileSystemEntry>>& aEntries)
: mCallback(aCallback)
, mEntries(aEntries)
{
@ -27,7 +27,7 @@ public:
NS_IMETHOD
Run() override
{
Sequence<OwningNonNull<Entry>> entries;
Sequence<OwningNonNull<FileSystemEntry>> entries;
for (uint32_t i = 0; i < mEntries.Length(); ++i) {
if (!entries.AppendElement(mEntries[i].forget(), fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
@ -39,24 +39,27 @@ public:
}
private:
RefPtr<EntriesCallback> mCallback;
Sequence<RefPtr<Entry>> mEntries;
RefPtr<FileSystemEntriesCallback> mCallback;
Sequence<RefPtr<FileSystemEntry>> mEntries;
};
} // anonymous namespace
NS_IMPL_CYCLE_COLLECTION_INHERITED(RootDirectoryReader, DirectoryReader, mEntries)
NS_IMPL_CYCLE_COLLECTION_INHERITED(FileSystemRootDirectoryReader,
FileSystemDirectoryReader, mEntries)
NS_IMPL_ADDREF_INHERITED(RootDirectoryReader, DirectoryReader)
NS_IMPL_RELEASE_INHERITED(RootDirectoryReader, DirectoryReader)
NS_IMPL_ADDREF_INHERITED(FileSystemRootDirectoryReader,
FileSystemDirectoryReader)
NS_IMPL_RELEASE_INHERITED(FileSystemRootDirectoryReader,
FileSystemDirectoryReader)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(RootDirectoryReader)
NS_INTERFACE_MAP_END_INHERITING(DirectoryReader)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FileSystemRootDirectoryReader)
NS_INTERFACE_MAP_END_INHERITING(FileSystemDirectoryReader)
RootDirectoryReader::RootDirectoryReader(nsIGlobalObject* aGlobal,
DOMFileSystem* aFileSystem,
const Sequence<RefPtr<Entry>>& aEntries)
: DirectoryReader(aGlobal, aFileSystem, nullptr)
FileSystemRootDirectoryReader::FileSystemRootDirectoryReader(nsIGlobalObject* aGlobal,
FileSystem* aFileSystem,
const Sequence<RefPtr<FileSystemEntry>>& aEntries)
: FileSystemDirectoryReader(aGlobal, aFileSystem, nullptr)
, mEntries(aEntries)
, mAlreadyRead(false)
{
@ -64,13 +67,13 @@ RootDirectoryReader::RootDirectoryReader(nsIGlobalObject* aGlobal,
MOZ_ASSERT(aFileSystem);
}
RootDirectoryReader::~RootDirectoryReader()
FileSystemRootDirectoryReader::~FileSystemRootDirectoryReader()
{}
void
RootDirectoryReader::ReadEntries(EntriesCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
ErrorResult& aRv)
FileSystemRootDirectoryReader::ReadEntries(FileSystemEntriesCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
ErrorResult& aRv)
{
if (mAlreadyRead) {
RefPtr<EmptyEntriesCallbackRunnable> runnable =

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

@ -0,0 +1,41 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_FileSystemRootDirectoryReader_h
#define mozilla_dom_FileSystemRootDirectoryReader_h
#include "FileSystemDirectoryReader.h"
namespace mozilla {
namespace dom {
class FileSystemRootDirectoryReader final : public FileSystemDirectoryReader
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileSystemRootDirectoryReader,
FileSystemDirectoryReader)
explicit FileSystemRootDirectoryReader(nsIGlobalObject* aGlobalObject,
FileSystem* aFileSystem,
const Sequence<RefPtr<FileSystemEntry>>& aEntries);
virtual void
ReadEntries(FileSystemEntriesCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
ErrorResult& aRv) override;
private:
~FileSystemRootDirectoryReader();
Sequence<RefPtr<FileSystemEntry>> mEntries;
bool mAlreadyRead;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_FileSystemRootDirectoryReader_h

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

@ -1,40 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_RootDirectoryReader_h
#define mozilla_dom_RootDirectoryReader_h
#include "DirectoryReader.h"
namespace mozilla {
namespace dom {
class RootDirectoryReader final : public DirectoryReader
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(RootDirectoryReader, DirectoryReader)
explicit RootDirectoryReader(nsIGlobalObject* aGlobalObject,
DOMFileSystem* aFileSystem,
const Sequence<RefPtr<Entry>>& aEntries);
virtual void
ReadEntries(EntriesCallback& aSuccessCallback,
const Optional<OwningNonNull<ErrorCallback>>& aErrorCallback,
ErrorResult& aRv) override;
private:
~RootDirectoryReader();
Sequence<RefPtr<Entry>> mEntries;
bool mAlreadyRead;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_RootDirectoryReader_h

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

@ -7,22 +7,22 @@
TEST_DIRS += ['tests']
EXPORTS.mozilla.dom += [
'DirectoryEntry.h',
'DirectoryReader.h',
'DOMFileSystem.h',
'Entry.h',
'FileEntry.h',
'FileSystem.h',
'FileSystemDirectoryEntry.h',
'FileSystemDirectoryReader.h',
'FileSystemEntry.h',
'FileSystemFileEntry.h',
]
UNIFIED_SOURCES += [
'CallbackRunnables.cpp',
'DirectoryEntry.cpp',
'DirectoryReader.cpp',
'DOMFileSystem.cpp',
'Entry.cpp',
'FileEntry.cpp',
'RootDirectoryEntry.cpp',
'RootDirectoryReader.cpp',
'FileSystem.cpp',
'FileSystemDirectoryEntry.cpp',
'FileSystemDirectoryReader.cpp',
'FileSystemEntry.cpp',
'FileSystemFileEntry.cpp',
'FileSystemRootDirectoryEntry.cpp',
'FileSystemRootDirectoryReader.cpp',
]
FINAL_LIBRARY = 'xul'

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

@ -79,8 +79,8 @@
#include "nsIRadioGroupContainer.h"
// input type=file
#include "mozilla/dom/Entry.h"
#include "mozilla/dom/DOMFileSystem.h"
#include "mozilla/dom/FileSystemEntry.h"
#include "mozilla/dom/FileSystem.h"
#include "mozilla/dom/File.h"
#include "mozilla/dom/FileList.h"
#include "nsIFile.h"
@ -1467,8 +1467,10 @@ HTMLInputElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
if (aName == nsGkAtoms::readonly || aName == nsGkAtoms::disabled) {
UpdateBarredFromConstraintValidation();
}
} else if (MaxLengthApplies() && aName == nsGkAtoms::maxlength) {
} else if (MinOrMaxLengthApplies() && aName == nsGkAtoms::maxlength) {
UpdateTooLongValidityState();
} else if (MinOrMaxLengthApplies() && aName == nsGkAtoms::minlength) {
UpdateTooShortValidityState();
} else if (aName == nsGkAtoms::pattern && !mParserCreating) {
UpdatePatternMismatchValidityState();
} else if (aName == nsGkAtoms::multiple) {
@ -1589,6 +1591,7 @@ NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(HTMLInputElement, InputMode, inputmode,
kInputDefaultInputmode->tag)
NS_IMPL_BOOL_ATTR(HTMLInputElement, Multiple, multiple)
NS_IMPL_NON_NEGATIVE_INT_ATTR(HTMLInputElement, MaxLength, maxlength)
NS_IMPL_NON_NEGATIVE_INT_ATTR(HTMLInputElement, MinLength, minlength)
NS_IMPL_STRING_ATTR(HTMLInputElement, Name, name)
NS_IMPL_BOOL_ATTR(HTMLInputElement, ReadOnly, readonly)
NS_IMPL_BOOL_ATTR(HTMLInputElement, Required, required)
@ -4089,8 +4092,7 @@ HTMLInputElement::MaybeInitPickers(EventChainPostVisitor& aVisitor)
nsCOMPtr<nsIContent> target =
do_QueryInterface(aVisitor.mEvent->mOriginalTarget);
if (target &&
target->GetParent() == this &&
target->IsRootOfNativeAnonymousSubtree() &&
target->FindFirstNonChromeOnlyAccessContent() == this &&
((Preferences::GetBool("dom.input.dirpicker", false) && Allowdirs()) ||
(Preferences::GetBool("dom.webkitBlink.dirPicker.enabled", false) &&
HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory)))) {
@ -5333,6 +5335,9 @@ HTMLInputElement::ParseAttribute(int32_t aNamespaceID,
if (aAttribute == nsGkAtoms::maxlength) {
return aResult.ParseNonNegativeIntValue(aValue);
}
if (aAttribute == nsGkAtoms::minlength) {
return aResult.ParseNonNegativeIntValue(aValue);
}
if (aAttribute == nsGkAtoms::size) {
return aResult.ParsePositiveIntValue(aValue);
}
@ -7005,7 +7010,7 @@ HTMLInputElement::IsTooLong()
{
if (!mValueChanged ||
!mLastValueChangeWasInteractive ||
!MaxLengthApplies() ||
!MinOrMaxLengthApplies() ||
!HasAttr(kNameSpaceID_None, nsGkAtoms::maxlength)) {
return false;
}
@ -7023,6 +7028,29 @@ HTMLInputElement::IsTooLong()
return textLength > maxLength;
}
bool
HTMLInputElement::IsTooShort()
{
if (!mValueChanged ||
!mLastValueChangeWasInteractive ||
!MinOrMaxLengthApplies() ||
!HasAttr(kNameSpaceID_None, nsGkAtoms::minlength)) {
return false;
}
int32_t minLength = MinLength();
// Minlength of -1 means parsing error.
if (minLength == -1) {
return false;
}
int32_t textLength = -1;
GetTextLength(&textLength);
return textLength && textLength < minLength;
}
bool
HTMLInputElement::IsValueMissing() const
{
@ -7284,6 +7312,12 @@ HTMLInputElement::UpdateTooLongValidityState()
SetValidityState(VALIDITY_STATE_TOO_LONG, IsTooLong());
}
void
HTMLInputElement::UpdateTooShortValidityState()
{
SetValidityState(VALIDITY_STATE_TOO_SHORT, IsTooShort());
}
void
HTMLInputElement::UpdateValueMissingValidityStateForRadio(bool aIgnoreSelf)
{
@ -7384,6 +7418,7 @@ HTMLInputElement::UpdateAllValidityStates(bool aNotify)
{
bool validBefore = IsValid();
UpdateTooLongValidityState();
UpdateTooShortValidityState();
UpdateValueMissingValidityState();
UpdateTypeMismatchValidityState();
UpdatePatternMismatchValidityState();
@ -7442,6 +7477,26 @@ HTMLInputElement::GetValidationMessage(nsAString& aValidationMessage,
aValidationMessage = message;
break;
}
case VALIDITY_STATE_TOO_SHORT:
{
nsXPIDLString message;
int32_t minLength = MinLength();
int32_t textLength = -1;
nsAutoString strMinLength;
nsAutoString strTextLength;
GetTextLength(&textLength);
strMinLength.AppendInt(minLength);
strTextLength.AppendInt(textLength);
const char16_t* params[] = { strMinLength.get(), strTextLength.get() };
rv = nsContentUtils::FormatLocalizedString(nsContentUtils::eDOM_PROPERTIES,
"FormValidationTextTooShort",
params, message);
aValidationMessage = message;
break;
}
case VALIDITY_STATE_VALUE_MISSING:
{
nsXPIDLString message;
@ -8204,14 +8259,15 @@ HTMLInputElement::UpdateEntries(const nsTArray<OwningFileOrDirectory>& aFilesOrD
nsCOMPtr<nsIGlobalObject> global = OwnerDoc()->GetScopeObject();
MOZ_ASSERT(global);
RefPtr<DOMFileSystem> fs = DOMFileSystem::Create(global);
RefPtr<FileSystem> fs = FileSystem::Create(global);
if (NS_WARN_IF(!fs)) {
return;
}
Sequence<RefPtr<Entry>> entries;
Sequence<RefPtr<FileSystemEntry>> entries;
for (uint32_t i = 0; i < aFilesOrDirectories.Length(); ++i) {
RefPtr<Entry> entry = Entry::Create(global, aFilesOrDirectories[i], fs);
RefPtr<FileSystemEntry> entry =
FileSystemEntry::Create(global, aFilesOrDirectories[i], fs);
MOZ_ASSERT(entry);
if (!entries.AppendElement(entry, fallible)) {
@ -8227,7 +8283,7 @@ HTMLInputElement::UpdateEntries(const nsTArray<OwningFileOrDirectory>& aFilesOrD
}
void
HTMLInputElement::GetWebkitEntries(nsTArray<RefPtr<Entry>>& aSequence)
HTMLInputElement::GetWebkitEntries(nsTArray<RefPtr<FileSystemEntry>>& aSequence)
{
Telemetry::Accumulate(Telemetry::BLINK_FILESYSTEM_USED, true);
aSequence.AppendElements(mEntries);

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

@ -40,9 +40,9 @@ namespace dom {
class AfterSetFilesOrDirectoriesRunnable;
class Date;
class DispatchChangeEventCallback;
class Entry;
class File;
class FileList;
class FileSystemEntry;
class GetFilesHelper;
/**
@ -306,6 +306,7 @@ public:
// nsIConstraintValidation
bool IsTooLong();
bool IsTooShort();
bool IsValueMissing() const;
bool HasTypeMismatch() const;
bool HasPatternMismatch() const;
@ -314,6 +315,7 @@ public:
bool HasStepMismatch(bool aUseZeroIfValueNaN = false) const;
bool HasBadInput() const;
void UpdateTooLongValidityState();
void UpdateTooShortValidityState();
void UpdateValueMissingValidityState();
void UpdateTypeMismatchValidityState();
void UpdatePatternMismatchValidityState();
@ -534,7 +536,8 @@ public:
void SetMaxLength(int32_t aValue, ErrorResult& aRv)
{
if (aValue < 0) {
int32_t minLength = MinLength();
if (aValue < 0 || (minLength >= 0 && aValue < minLength)) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return;
}
@ -542,6 +545,22 @@ public:
SetHTMLIntAttr(nsGkAtoms::maxlength, aValue, aRv);
}
int32_t MinLength() const
{
return GetIntAttr(nsGkAtoms::minlength, -1);
}
void SetMinLength(int32_t aValue, ErrorResult& aRv)
{
int32_t maxLength = MaxLength();
if (aValue < 0 || (maxLength >= 0 && aValue > maxLength)) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return;
}
SetHTMLIntAttr(nsGkAtoms::minlength, aValue, aRv);
}
// XPCOM GetMin() is OK
void SetMin(const nsAString& aValue, ErrorResult& aRv)
{
@ -728,7 +747,7 @@ public:
SetHTMLBoolAttr(nsGkAtoms::webkitdirectory, aValue, aRv);
}
void GetWebkitEntries(nsTArray<RefPtr<Entry>>& aSequence);
void GetWebkitEntries(nsTArray<RefPtr<FileSystemEntry>>& aSequence);
bool IsFilesAndDirectoriesSupported() const;
@ -1049,9 +1068,9 @@ protected:
bool DoesAutocompleteApply() const;
/**
* Returns if the maxlength attribute applies for the current type.
* Returns if the minlength or maxlength attributes apply for the current type.
*/
bool MaxLengthApplies() const { return IsSingleLineTextControl(false, mType); }
bool MinOrMaxLengthApplies() const { return IsSingleLineTextControl(false, mType); }
void FreeData();
nsTextEditorState *GetEditorState() const;
@ -1401,7 +1420,7 @@ protected:
nsString mFirstFilePath;
RefPtr<FileList> mFileList;
Sequence<RefPtr<Entry>> mEntries;
Sequence<RefPtr<FileSystemEntry>> mEntries;
nsString mStaticDocFileList;

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

@ -193,6 +193,7 @@ NS_IMPL_BOOL_ATTR(HTMLTextAreaElement, Autofocus, autofocus)
NS_IMPL_UINT_ATTR_NON_ZERO_DEFAULT_VALUE(HTMLTextAreaElement, Cols, cols, DEFAULT_COLS)
NS_IMPL_BOOL_ATTR(HTMLTextAreaElement, Disabled, disabled)
NS_IMPL_NON_NEGATIVE_INT_ATTR(HTMLTextAreaElement, MaxLength, maxlength)
NS_IMPL_NON_NEGATIVE_INT_ATTR(HTMLTextAreaElement, MinLength, minlength)
NS_IMPL_STRING_ATTR(HTMLTextAreaElement, Name, name)
NS_IMPL_BOOL_ATTR(HTMLTextAreaElement, ReadOnly, readonly)
NS_IMPL_BOOL_ATTR(HTMLTextAreaElement, Required, required)
@ -398,7 +399,8 @@ HTMLTextAreaElement::ParseAttribute(int32_t aNamespaceID,
nsAttrValue& aResult)
{
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::maxlength) {
if (aAttribute == nsGkAtoms::maxlength ||
aAttribute == nsGkAtoms::minlength) {
return aResult.ParseNonNegativeIntValue(aValue);
} else if (aAttribute == nsGkAtoms::cols ||
aAttribute == nsGkAtoms::rows) {
@ -1317,6 +1319,8 @@ HTMLTextAreaElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
}
} else if (aName == nsGkAtoms::maxlength) {
UpdateTooLongValidityState();
} else if (aName == nsGkAtoms::minlength) {
UpdateTooShortValidityState();
}
UpdateState(aNotify);
@ -1390,6 +1394,29 @@ HTMLTextAreaElement::IsTooLong()
return textLength > maxLength;
}
bool
HTMLTextAreaElement::IsTooShort()
{
if (!mValueChanged ||
!mLastValueChangeWasInteractive ||
!HasAttr(kNameSpaceID_None, nsGkAtoms::minlength)) {
return false;
}
int32_t minLength = -1;
GetMinLength(&minLength);
// Minlength of -1 means parsing error.
if (minLength == -1) {
return false;
}
int32_t textLength = -1;
GetTextLength(&textLength);
return textLength && textLength < minLength;
}
bool
HTMLTextAreaElement::IsValueMissing() const
{
@ -1406,6 +1433,12 @@ HTMLTextAreaElement::UpdateTooLongValidityState()
SetValidityState(VALIDITY_STATE_TOO_LONG, IsTooLong());
}
void
HTMLTextAreaElement::UpdateTooShortValidityState()
{
SetValidityState(VALIDITY_STATE_TOO_SHORT, IsTooShort());
}
void
HTMLTextAreaElement::UpdateValueMissingValidityState()
{
@ -1449,6 +1482,27 @@ HTMLTextAreaElement::GetValidationMessage(nsAString& aValidationMessage,
aValidationMessage = message;
}
break;
case VALIDITY_STATE_TOO_SHORT:
{
nsXPIDLString message;
int32_t minLength = -1;
int32_t textLength = -1;
nsAutoString strMinLength;
nsAutoString strTextLength;
GetMinLength(&minLength);
GetTextLength(&textLength);
strMinLength.AppendInt(minLength);
strTextLength.AppendInt(textLength);
const char16_t* params[] = { strMinLength.get(), strTextLength.get() };
rv = nsContentUtils::FormatLocalizedString(nsContentUtils::eDOM_PROPERTIES,
"FormValidationTextTooShort",
params, message);
aValidationMessage = message;
}
break;
case VALIDITY_STATE_VALUE_MISSING:
{
nsXPIDLString message;
@ -1557,6 +1611,7 @@ HTMLTextAreaElement::OnValueChanged(bool aNotify, bool aWasInteractiveUserChange
// Update the validity state
bool validBefore = IsValid();
UpdateTooLongValidityState();
UpdateTooShortValidityState();
UpdateValueMissingValidityState();
if (validBefore != IsValid()) {

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

@ -10,6 +10,7 @@
#include "mozilla/Attributes.h"
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsITextControlElement.h"
#include "nsIControllers.h"
#include "nsIDOMNSEditableElement.h"
#include "nsCOMPtr.h"
#include "nsGenericHTMLElement.h"
@ -155,8 +156,10 @@ public:
// nsIConstraintValidation
bool IsTooLong();
bool IsTooShort();
bool IsValueMissing() const;
void UpdateTooLongValidityState();
void UpdateTooShortValidityState();
void UpdateValueMissingValidityState();
void UpdateBarredFromConstraintValidation();
nsresult GetValidationMessage(nsAString& aValidationMessage,
@ -199,12 +202,26 @@ public:
}
void SetMaxLength(int32_t aMaxLength, ErrorResult& aError)
{
if (aMaxLength < 0) {
int32_t minLength = MinLength();
if (aMaxLength < 0 || (minLength >= 0 && aMaxLength < minLength)) {
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
} else {
SetHTMLIntAttr(nsGkAtoms::maxlength, aMaxLength, aError);
}
}
int32_t MinLength()
{
return GetIntAttr(nsGkAtoms::minlength, -1);
}
void SetMinLength(int32_t aMinLength, ErrorResult& aError)
{
int32_t maxLength = MaxLength();
if (aMinLength < 0 || (maxLength >= 0 && aMinLength > maxLength)) {
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
} else {
SetHTMLIntAttr(nsGkAtoms::minlength, aMinLength, aError);
}
}
// XPCOM GetName is fine
void SetName(const nsAString& aName, ErrorResult& aError)
{

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

@ -55,6 +55,13 @@ ValidityState::GetTooLong(bool* aTooLong)
return NS_OK;
}
NS_IMETHODIMP
ValidityState::GetTooShort(bool* aTooShort)
{
*aTooShort = TooShort();
return NS_OK;
}
NS_IMETHODIMP
ValidityState::GetRangeUnderflow(bool* aRangeUnderflow)
{

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

@ -50,6 +50,10 @@ public:
{
return GetValidityState(nsIConstraintValidation::VALIDITY_STATE_TOO_LONG);
}
bool TooShort() const
{
return GetValidityState(nsIConstraintValidation::VALIDITY_STATE_TOO_SHORT);
}
bool RangeUnderflow() const
{
return GetValidityState(nsIConstraintValidation::VALIDITY_STATE_RANGE_UNDERFLOW);

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

@ -947,7 +947,8 @@ nsHTMLDocument::SetDomain(const nsAString& aDomain, ErrorResult& rv)
return;
}
rv2 = newURI->SetHostPort(NS_ConvertUTF16toUTF8(aDomain));
// We use SetHostAndPort because we want to reset the port number if needed.
rv2 = newURI->SetHostAndPort(NS_ConvertUTF16toUTF8(aDomain));
if (NS_FAILED(rv2)) {
rv.Throw(rv2);
return;

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