Backed out changeset 9c966265dc48 (bug 1383367)

MozReview-Commit-ID: HW5syKq18xj
This commit is contained in:
Sebastian Hengst 2017-07-30 12:54:07 +02:00
Родитель 3625be87df
Коммит 64305ef2cd
1 изменённых файлов: 0 добавлений и 101 удалений

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

@ -16,48 +16,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
Cu.importGlobalProperties(["URL"]);
let reflowObservers = new WeakMap();
function ReflowObserver(doc) {
this._doc = doc;
doc.docShell.addWeakReflowObserver(this);
reflowObservers.set(this._doc, this);
this.callbacks = [];
}
ReflowObserver.prototype = {
QueryInterface: XPCOMUtils.generateQI(["nsIReflowObserver", "nsISupportsWeakReference"]),
_onReflow() {
reflowObservers.delete(this._doc);
this._doc.docShell.removeWeakReflowObserver(this);
for (let callback of this.callbacks) {
try {
callback();
} catch (e) {
Cu.reportError(e);
}
}
},
reflow() {
this._onReflow();
},
reflowInterruptible() {
this._onReflow();
},
};
const FLUSH_TYPES = {
"style": Ci.nsIDOMWindowUtils.FLUSH_STYLE,
"layout": Ci.nsIDOMWindowUtils.FLUSH_LAYOUT,
"display": Ci.nsIDOMWindowUtils.FLUSH_DISPLAY,
};
this.BrowserUtils = {
/**
@ -668,63 +626,4 @@ this.BrowserUtils = {
}
return [url, postData];
},
/**
* Calls the given function when the given document has just reflowed,
* and returns a promise which resolves to its return value after it
* has been called.
*
* The function *must not trigger any reflows*, or make any changes
* which would require a layout flush.
*
* @param {Document} doc
* @param {function} callback
* @returns {Promise}
*/
promiseReflowed(doc, callback) {
let observer = reflowObservers.get(doc);
if (!observer) {
observer = new ReflowObserver(doc);
reflowObservers.set(doc, observer);
}
return new Promise((resolve, reject) => {
observer.callbacks.push(() => {
try {
resolve(callback());
} catch (e) {
reject(e);
}
});
});
},
/**
* Calls the given function as soon as a layout flush of the given
* type is not necessary, and returns a promise which resolves to the
* callback's return value after it executes.
*
* The function *must not trigger any reflows*, or make any changes
* which would require a layout flush.
*
* @param {Document} doc
* @param {string} flushType
* The flush type required. Must be one of:
*
* - "style"
* - "layout"
* - "display"
* @param {function} callback
* @returns {Promise}
*/
async promiseLayoutFlushed(doc, flushType, callback) {
let utils = doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
if (!utils.needsFlush(FLUSH_TYPES[flushType])) {
return callback();
}
return this.promiseReflowed(doc, callback);
},
};