зеркало из https://github.com/mozilla/gecko-dev.git
Bug 923166 - Use nsIDOMWindowUtils.containerElement inside of LayoutHelpers.getFrameElement. r=paul
This commit is contained in:
Родитель
8b0258f3e6
Коммит
8f661228e9
|
@ -368,37 +368,17 @@ LayoutHelpers.prototype = {
|
|||
* like win.frameElement, but goes through mozbrowsers and mozapps iframes.
|
||||
*
|
||||
* @param DOMWindow win The window to get the frame for
|
||||
* @return DOMElement The element(only <iframe> for now) in which the window
|
||||
* is embedded. A null return from this function does not imply that it is a
|
||||
* top level window. Use isTopLevelWindow(win) if needed.
|
||||
* @return DOMElement The element in which the window is embedded.
|
||||
*/
|
||||
getFrameElement: function LH_getFrameElement(win) {
|
||||
if (this.isTopLevelWindow(win)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the docShell for that window
|
||||
let docShell = win.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShell);
|
||||
let winUtils = win.
|
||||
QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
if (docShell.isBrowserOrApp) {
|
||||
// Get the docShell's same-type parent ignoring mozBrowser and mozApp
|
||||
// boundaries
|
||||
let parentDocShell = docShell.getSameTypeParentIgnoreBrowserAndAppBoundaries();
|
||||
// Once we have a parent, get all its iframes and loop through them
|
||||
// to find `win`. If we do, it means win is a nested iframe
|
||||
let parentDoc = parentDocShell.contentViewer.DOMDocument;
|
||||
let allIframes = parentDoc.querySelectorAll("iframe");
|
||||
for (let f of allIframes) {
|
||||
if (f.contentWindow === win) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
} else {
|
||||
return win.frameElement;
|
||||
}
|
||||
return winUtils.containerElement;
|
||||
},
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче