mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
b=448080, p=enn & mfinkle, r=gavin. switching between tabs fails to update parts UI
This commit is contained in:
parent
a11306c0d2
commit
099969f660
@ -49,6 +49,8 @@ const PANELMODE_SIDEBAR = 6;
|
||||
const PANELMODE_TABLIST = 7;
|
||||
const PANELMODE_FULL = 8;
|
||||
|
||||
const kDefaultFavIconURL = "chrome://browser/skin/images/default-favicon.png";
|
||||
|
||||
var BrowserUI = {
|
||||
_panel : null,
|
||||
_caption : null,
|
||||
@ -58,11 +60,18 @@ var BrowserUI = {
|
||||
_favicon : null,
|
||||
_faviconAdded : false,
|
||||
|
||||
_titleChanged : function(aEvent) {
|
||||
if (aEvent.target != getBrowser().contentDocument)
|
||||
_titleChanged : function(aDocument) {
|
||||
var browser = Browser.currentBrowser;
|
||||
if (browser && aDocument != browser.contentDocument)
|
||||
return;
|
||||
|
||||
this._caption.value = aEvent.target.title;
|
||||
this._caption.value = aDocument.title;
|
||||
|
||||
var docElem = document.documentElement;
|
||||
var title = "";
|
||||
if (aDocument.title)
|
||||
title = aDocument.title + docElem.getAttribute("titleseparator");
|
||||
document.title = title + docElem.getAttribute("titlemodifier");
|
||||
},
|
||||
|
||||
_linkAdded : function(aEvent) {
|
||||
@ -78,16 +87,27 @@ var BrowserUI = {
|
||||
}
|
||||
},
|
||||
|
||||
_tabSelect : function(aEvent) {
|
||||
var browser = Browser.currentBrowser;
|
||||
this.setURI();
|
||||
this._titleChanged(browser.contentDocument);
|
||||
this._favicon.setAttribute("src", browser.mIconURL || kDefaultFavIconURL);
|
||||
this.show(PANELMODE_NONE);
|
||||
},
|
||||
|
||||
_setIcon : function(aURI) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var faviconURI = ios.newURI(aURI, null, null);
|
||||
if (faviconURI.schemeIs("javascript"))
|
||||
return;
|
||||
|
||||
var fis = Cc["@mozilla.org/browser/favicon-service;1"].getService(Ci.nsIFaviconService);
|
||||
if (fis.isFailedFavicon(faviconURI))
|
||||
faviconURI = ios.newURI("chrome://browser/skin/images/default-favicon.png", null, null);
|
||||
fis.setAndLoadFaviconForPage(getBrowser().currentURI, faviconURI, true);
|
||||
if (faviconURI.schemeIs("javascript") ||
|
||||
fis.isFailedFavicon(faviconURI))
|
||||
faviconURI = ios.newURI(kDefaultFavIconURL, null, null);
|
||||
|
||||
var browser = getBrowser();
|
||||
browser.mIconURL = faviconURI.spec;
|
||||
|
||||
fis.setAndLoadFaviconForPage(browser.currentURI, faviconURI, true);
|
||||
this._favicon.setAttribute("src", faviconURI.spec);
|
||||
this._faviconAdded = true;
|
||||
},
|
||||
@ -239,11 +259,13 @@ var BrowserUI = {
|
||||
this._favicon.addEventListener("error", this, false);
|
||||
this._autocompleteNavbuttons = document.getElementById("autocomplete_navbuttons");
|
||||
|
||||
getBrowser().addEventListener("DOMTitleChanged", this, true);
|
||||
getBrowser().addEventListener("DOMLinkAdded", this, true);
|
||||
Browser.content.addEventListener("DOMTitleChanged", this, true);
|
||||
Browser.content.addEventListener("DOMLinkAdded", this, true);
|
||||
Browser.content.addEventListener("overpan", this, false);
|
||||
Browser.content.addEventListener("pan", this, true);
|
||||
|
||||
document.getElementById("tab-list").addEventListener("TabSelect", this, true);
|
||||
|
||||
Browser.content.addEventListener("mousedown", this, true);
|
||||
Browser.content.addEventListener("mouseup", this, true);
|
||||
Browser.content.addEventListener("mousemove", this, true);
|
||||
@ -251,7 +273,7 @@ var BrowserUI = {
|
||||
window.addEventListener("resize", this, false);
|
||||
},
|
||||
|
||||
update : function(aState) {
|
||||
update : function(aState, aBrowser) {
|
||||
if (aState == TOOLBARSTATE_INDETERMINATE) {
|
||||
this._faviconAdded = false;
|
||||
aState = TOOLBARSTATE_LOADED;
|
||||
@ -261,6 +283,7 @@ var BrowserUI = {
|
||||
var toolbar = document.getElementById("toolbar-main");
|
||||
if (aState == TOOLBARSTATE_LOADING) {
|
||||
this.show(PANELMODE_URLVIEW);
|
||||
Browser.content.setLoading(aBrowser);
|
||||
|
||||
toolbar.top = 0;
|
||||
toolbar.setAttribute("mode", "loading");
|
||||
@ -269,12 +292,13 @@ var BrowserUI = {
|
||||
this._faviconAdded = false;
|
||||
}
|
||||
else if (aState == TOOLBARSTATE_LOADED) {
|
||||
var browser = document.getElementById("browser");
|
||||
browser.top = toolbar.boxObject.height;
|
||||
var container = document.getElementById("browser");
|
||||
container.top = toolbar.boxObject.height;
|
||||
|
||||
toolbar.setAttribute("mode", "view");
|
||||
this._throbber.setAttribute("src", "");
|
||||
if (this._faviconAdded == false) {
|
||||
var faviconURI = getBrowser().currentURI.prePath + "/favicon.ico";
|
||||
var faviconURI = aBrowser.currentURI.prePath + "/favicon.ico";
|
||||
this._setIcon(faviconURI);
|
||||
}
|
||||
}
|
||||
@ -553,18 +577,20 @@ var BrowserUI = {
|
||||
|
||||
selectTab : function(aTab) {
|
||||
Browser.content.selectTab(aTab);
|
||||
this.show(PANELMODE_NONE);
|
||||
},
|
||||
|
||||
handleEvent: function (aEvent) {
|
||||
switch (aEvent.type) {
|
||||
// Browser events
|
||||
case "DOMTitleChanged":
|
||||
this._titleChanged(aEvent);
|
||||
this._titleChanged(aEvent.target);
|
||||
break;
|
||||
case "DOMLinkAdded":
|
||||
this._linkAdded(aEvent);
|
||||
break;
|
||||
case "TabSelect":
|
||||
this._tabSelect(aEvent);
|
||||
break;
|
||||
// URL textbox events
|
||||
case "click":
|
||||
this.show(PANELMODE_URLEDIT);
|
||||
|
@ -65,18 +65,6 @@ function getBrowser() {
|
||||
var Browser = {
|
||||
_content : null,
|
||||
|
||||
_titleChanged : function(aEvent) {
|
||||
var browser = this.content.browser;
|
||||
if (!browser || aEvent.target != browser.contentDocument)
|
||||
return;
|
||||
|
||||
var docElem = document.documentElement;
|
||||
var title = "";
|
||||
if (aEvent.target.title)
|
||||
title = aEvent.target.title + docElem.getAttribute("titleseparator");
|
||||
document.title = title + docElem.getAttribute("titlemodifier");
|
||||
},
|
||||
|
||||
startup : function() {
|
||||
window.controllers.appendController(this);
|
||||
window.controllers.appendController(BrowserUI);
|
||||
@ -106,11 +94,11 @@ var Browser = {
|
||||
os.addObserver(gXPInstallObserver, "xpinstall-install-blocked", false);
|
||||
os.addObserver(gXPInstallObserver, "xpinstall-download-started", false);
|
||||
|
||||
BrowserUI.init();
|
||||
|
||||
this._content.addEventListener("DOMUpdatePageReport", gPopupBlockerObserver.onUpdatePageReport, false);
|
||||
this._content.tabList = document.getElementById("tab-list");
|
||||
this._content.newTab(true);
|
||||
this._content.addEventListener("DOMTitleChanged", this, true);
|
||||
this._content.addEventListener("DOMUpdatePageReport", gPopupBlockerObserver.onUpdatePageReport, false);
|
||||
BrowserUI.init();
|
||||
|
||||
SpatialNavigation.init(this.content);
|
||||
|
||||
@ -212,14 +200,6 @@ var Browser = {
|
||||
return this._content.browser;
|
||||
},
|
||||
|
||||
handleEvent: function (aEvent) {
|
||||
switch (aEvent.type) {
|
||||
case "DOMTitleChanged":
|
||||
this._titleChanged(aEvent);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
supportsCommand : function(cmd) {
|
||||
var isSupported = false;
|
||||
switch (cmd) {
|
||||
@ -330,11 +310,11 @@ ProgressController.prototype = {
|
||||
if (aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
|
||||
if (aRequest && aWebProgress.DOMWindow == this._browser.contentWindow) {
|
||||
if (aStateFlags & Ci.nsIWebProgressListener.STATE_START) {
|
||||
BrowserUI.update(TOOLBARSTATE_LOADING);
|
||||
BrowserUI.update(TOOLBARSTATE_LOADING, this._browser);
|
||||
this._tabbrowser.updateCanvasState();
|
||||
}
|
||||
else if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) {
|
||||
BrowserUI.update(TOOLBARSTATE_LOADED);
|
||||
BrowserUI.update(TOOLBARSTATE_LOADED, this._browser);
|
||||
this._tabbrowser.updateCanvasState();
|
||||
}
|
||||
}
|
||||
|
@ -51,25 +51,26 @@
|
||||
this._panEventTrackerIndex = 0;
|
||||
]]></constructor>
|
||||
|
||||
<field name="dragData">
|
||||
({
|
||||
dragging: false,
|
||||
dragX: 0,
|
||||
dragY: 0,
|
||||
sX: 0,
|
||||
sY: 0,
|
||||
pageX: 0,
|
||||
pageY: 0,
|
||||
oldPageX: 0,
|
||||
oldPageY: 0,
|
||||
velocityX: 0,
|
||||
velocityY: 0,
|
||||
originalX: 0,
|
||||
originalY: 0,
|
||||
destinationX: 0,
|
||||
destinationY: 0
|
||||
})
|
||||
</field>
|
||||
<property name="dragData" readonly="true">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
if (!this.currentTab.dragData) {
|
||||
this.currentTab.dragData = {
|
||||
dragging: false,
|
||||
dragX: 0,
|
||||
dragY: 0,
|
||||
sX: 0,
|
||||
sY: 0,
|
||||
pageX: 0,
|
||||
pageY: 0,
|
||||
oldPageX: 0,
|
||||
oldPageY: 0
|
||||
}
|
||||
}
|
||||
return this.currentTab.dragData;
|
||||
]]>
|
||||
</getter>
|
||||
</property>
|
||||
|
||||
<field name="_stack">
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "cstack");
|
||||
@ -174,6 +175,15 @@
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="setLoading">
|
||||
<parameter name="browser"/>
|
||||
<body><![CDATA[
|
||||
var tab = this.getTabForDisplay(browser.parentNode);
|
||||
if (tab)
|
||||
tab.dragData = null;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="updateBrowser">
|
||||
<parameter name="browser"/>
|
||||
<parameter name="done"/>
|
||||
@ -224,6 +234,10 @@
|
||||
|
||||
browser.setAttribute("type", "content-primary");
|
||||
this.displayList.selectedPanel = display;
|
||||
|
||||
var event = document.createEvent("Events");
|
||||
event.initEvent("TabSelect", true, false);
|
||||
tab.dispatchEvent(event);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
@ -231,7 +245,16 @@
|
||||
<parameter name="makeFront"/>
|
||||
<body><![CDATA[
|
||||
var browser = this.createBrowser(makeFront, null, null);
|
||||
return browser ? this.getTabForDisplay(browser.parentNode) : null;
|
||||
if (!browser)
|
||||
return null;
|
||||
|
||||
var tab = this.getTabForDisplay(browser.parentNode);
|
||||
|
||||
var evt = document.createEvent("Events");
|
||||
evt.initEvent("TabOpen", true, false);
|
||||
tab.dispatchEvent(evt);
|
||||
|
||||
return tab;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
@ -245,6 +268,10 @@
|
||||
if (display)
|
||||
display.removeChild(display);
|
||||
tab.parentNode.removeChild(tab);
|
||||
|
||||
var evt = document.createEvent("Events");
|
||||
evt.initEvent("TabClose", true, false);
|
||||
tab.dispatchEvent(evt);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
@ -794,7 +821,7 @@
|
||||
self.dragData.velocityY * dt * (Math.sqrt(Math.abs(self.dragData.destinationY - self.dragData.dragY)) /
|
||||
Math.sqrt(Math.abs(self.dragData.destinationY - self.dragData.originalY)));
|
||||
let nextX = self.dragData.dragX - dx;
|
||||
let nextY = self.dragData.dragY - dy;
|
||||
let nextY = self.dragData.dragY - dy;
|
||||
|
||||
if((self.dragData.originalX > nextX &&
|
||||
nextX > self.dragData.destinationX) ||
|
||||
@ -805,17 +832,17 @@
|
||||
self.dragData.dragX = self.dragData.destinationX;
|
||||
if((self.dragData.originalY > nextY &&
|
||||
nextY > self.dragData.destinationY) ||
|
||||
(self.dragData.originalY < nextY &&
|
||||
(self.dragData.originalY < nextY &&
|
||||
nextY < self.dragData.destinationY))
|
||||
self.dragData.dragY = nextY;
|
||||
else
|
||||
self.dragData.dragY = self.dragData.destinationY;
|
||||
|
||||
|
||||
self._updateCanvasPosition();
|
||||
|
||||
|
||||
let actualDx = startX - self.dragData.dragX;
|
||||
let actualDy = startY - self.dragData.dragY
|
||||
if ((actualDx / (self.dragData.destinationX - self.dragData.originalX) < 0 && actualDy / (self.dragData.destinationY - self.dragData.originalY) < 0) || ( Math.abs(actualDx) < 4 && Math.abs(actualDy) < 4)) {
|
||||
if ((actualDx / (self.dragData.destinationX - self.dragData.originalX) < 0 && actualDy / (self.dragData.destinationY - self.dragData.originalY) < 0) || ( Math.abs(actualDx) < 4 && Math.abs(actualDy) < 4)) {
|
||||
self._endKinetic();
|
||||
}
|
||||
]]></body>
|
||||
@ -1008,14 +1035,14 @@
|
||||
let now = Date.now();
|
||||
if (this.deckbrowser.dragData.dragging) {
|
||||
this.deckbrowser._panEventTrackerIndex = (this.deckbrowser._panEventTrackerIndex + 1) % this.deckbrowser.PAN_EVENTS_TO_TRACK;
|
||||
|
||||
|
||||
var pt = new Object();
|
||||
pt.x = aEvent.screenX;
|
||||
pt.y = aEvent.screenY;
|
||||
pt.t = now;
|
||||
|
||||
this.deckbrowser._panEventTracker[this.deckbrowser._panEventTrackerIndex] = pt;
|
||||
|
||||
|
||||
}
|
||||
this.deckbrowser._moveCanvas(dx, dy);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user