mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-11 13:48:23 +02:00
Bug 1456391 - Part 4: Use new mapFrameTree version for GeckoView. r=snorp
The copy-pasted description of mapFrameTree in GeckoView already claims to only run the callback for *non*-dynamic child frames. With this patch we make GeckoView actually do that and unify the behaviour with Desktop. MozReview-Commit-ID: 6967vUcgB2r --HG-- extra : rebase_source : 024dcda6d39e01ba8c9c2948a767200200383b37
This commit is contained in:
parent
3dfb944b8d
commit
110831186a
1 changed files with 2 additions and 32 deletions
|
|
@ -11,6 +11,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
SessionHistory: "resource://gre/modules/sessionstore/SessionHistory.jsm",
|
||||
FormData: "resource://gre/modules/FormData.jsm",
|
||||
ScrollPosition: "resource://gre/modules/ScrollPosition.jsm",
|
||||
Utils: "resource://gre/modules/sessionstore/Utils.jsm",
|
||||
});
|
||||
|
||||
class GeckoViewContent extends GeckoViewContentModule {
|
||||
|
|
@ -63,40 +64,9 @@ class GeckoViewContent extends GeckoViewContentModule {
|
|||
this);
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that will recursively call |cb| to collected data for all
|
||||
* non-dynamic frames in the current frame/docShell tree.
|
||||
*/
|
||||
mapFrameTree(frame, cb) {
|
||||
// Collect data for the current frame.
|
||||
let callbacks = Array.isArray(cb) ? cb : [cb];
|
||||
let objs = callbacks.map((callback) => callback(frame) || {});
|
||||
let children = callbacks.map(() => []);
|
||||
|
||||
// Recurse into child frames.
|
||||
for (let i = 0; i < frame.frames.length; i++) {
|
||||
let subframe = frame.frames[i];
|
||||
let results = this.mapFrameTree(subframe, callbacks);
|
||||
results.forEach((result, j) => {
|
||||
if (result && Object.keys(result).length) {
|
||||
children[j][i] = result;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
objs.forEach((obj, i) => {
|
||||
if (children[i].length) {
|
||||
obj.children = children[i];
|
||||
}
|
||||
});
|
||||
|
||||
let res = objs.map((obj) => Object.keys(obj).length ? obj : null);
|
||||
return Array.isArray(cb) ? res : res[0];
|
||||
}
|
||||
|
||||
collectSessionState() {
|
||||
let history = SessionHistory.collect(docShell);
|
||||
let [formdata, scrolldata] = this.mapFrameTree(content, [FormData.collect, ScrollPosition.collect]);
|
||||
let [formdata, scrolldata] = Utils.mapFrameTree(content, FormData.collect, ScrollPosition.collect);
|
||||
|
||||
// Save the current document resolution.
|
||||
let zoom = { value: 1 };
|
||||
|
|
|
|||
Loading…
Reference in a new issue