зеркало из https://github.com/mozilla/pjs.git
Bug 567186 - When possible, set viewport size before page finishes loading [r=mfinkle]
This commit is contained in:
Родитель
3fb463ad29
Коммит
74732d7e57
|
@ -158,6 +158,22 @@ var BrowserUI = {
|
|||
}
|
||||
},
|
||||
|
||||
_metaAdded : function(aEvent) {
|
||||
let meta = aEvent.originalTarget;
|
||||
if (!meta)
|
||||
return;
|
||||
|
||||
if (meta.name == "viewport" || meta.name == "HandheldFriendly") {
|
||||
// Must have an owner document and not be in a frame
|
||||
var ownerDoc = meta.ownerDocument;
|
||||
if (!ownerDoc || ownerDoc.defaultView.frameElement)
|
||||
return;
|
||||
|
||||
let tab = Browser.getTabForDocument(ownerDoc);
|
||||
tab.updateViewportMetadata();
|
||||
}
|
||||
},
|
||||
|
||||
_linkAdded : function(aEvent) {
|
||||
let link = aEvent.originalTarget;
|
||||
if (!link || !link.href)
|
||||
|
@ -420,6 +436,7 @@ var BrowserUI = {
|
|||
// XXX these really want to listen to only the current browser
|
||||
browsers.addEventListener("DOMTitleChanged", this, true);
|
||||
browsers.addEventListener("DOMLinkAdded", this, true);
|
||||
browsers.addEventListener("DOMMetaAdded", this, true);
|
||||
browsers.addEventListener("DOMWillOpenModalDialog", this, true);
|
||||
|
||||
// listening mousedown for automatically dismiss some popups (e.g. larry)
|
||||
|
@ -728,6 +745,9 @@ var BrowserUI = {
|
|||
case "DOMLinkAdded":
|
||||
this._linkAdded(aEvent);
|
||||
break;
|
||||
case "DOMMetaAdded":
|
||||
this._metaAdded(aEvent);
|
||||
break;
|
||||
case "DOMWindowClose":
|
||||
this._domWindowClose(aEvent);
|
||||
break;
|
||||
|
|
|
@ -3081,10 +3081,10 @@ Tab.prototype = {
|
|||
/** Update browser size when the metadata or the window size changes. */
|
||||
updateViewportSize: function updateViewportSize() {
|
||||
let browser = this._browser;
|
||||
let metaData = this._browserViewportState.metaData
|
||||
if (!browser || !metaData)
|
||||
if (!browser)
|
||||
return;
|
||||
|
||||
let metaData = this._browserViewportState.metaData || {};
|
||||
if (!metaData.autoSize) {
|
||||
let screenW = window.innerWidth;
|
||||
let screenH = window.innerHeight;
|
||||
|
@ -3144,12 +3144,17 @@ Tab.prototype = {
|
|||
Browser.scrollBrowserToContent();
|
||||
}
|
||||
}
|
||||
|
||||
this._browserViewportState.metaData = null;
|
||||
this.updateViewportSize();
|
||||
},
|
||||
|
||||
endLoading: function endLoading() {
|
||||
if (!this._loading) throw "Not Loading!";
|
||||
|
||||
this.updateViewportMetadata();
|
||||
if (!this._browserViewportState.metaData)
|
||||
this.updateViewportMetadata();
|
||||
|
||||
this.setIcon(this._browser.mIconURL);
|
||||
this._loading = false;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче