From a1dc5c3de8b3ec6fabe018dfd78748b91ab144bb Mon Sep 17 00:00:00 2001 From: Mark Finkle Date: Fri, 29 May 2009 01:58:30 -0400 Subject: [PATCH] Bug 494551: Use images for buttons in main chrome UI (widget part), r=gavin --- mobile/chrome/content/CanvasBrowser.js | 2 +- mobile/chrome/content/WidgetStack.js | 13 ++++++++++ mobile/chrome/content/browser-ui.js | 32 +++++++++++++++++------ mobile/chrome/content/browser.js | 2 +- mobile/chrome/content/browser.xul | 35 +++++++++++++------------- mobile/chrome/content/tabs.xml | 8 +++--- 6 files changed, 60 insertions(+), 32 deletions(-) diff --git a/mobile/chrome/content/CanvasBrowser.js b/mobile/chrome/content/CanvasBrowser.js index 3fb1f612930c..c454ea9e0cfe 100644 --- a/mobile/chrome/content/CanvasBrowser.js +++ b/mobile/chrome/content/CanvasBrowser.js @@ -518,7 +518,7 @@ CanvasBrowser.prototype = { if (needToPanToTop) { ws.beginUpdateBatch(); this._needToPanToTop = false; - ws.panTo(0, -60); + ws.panTo(0, -BrowserUI.toolbarH); } // Adjust the zoomLevel to fit the page contents in our window // width diff --git a/mobile/chrome/content/WidgetStack.js b/mobile/chrome/content/WidgetStack.js index d94a2836edb3..ba2309103b61 100644 --- a/mobile/chrome/content/WidgetStack.js +++ b/mobile/chrome/content/WidgetStack.js @@ -473,6 +473,19 @@ WidgetStack.prototype = { state.widget.setAttribute("top", y); }, + // moveUnfrozenTo: move an unfrozen, pannable widget with id wid to x, y in + // the stack. should only be used on unfrozen widgets when a dynamic change + // in position needs to be made. we basically remove, adjust and re-add + // the widget + moveUnfrozenTo: function (wid, x, y) { + delete this._widgetState[wid]; + let widget = document.getElementById(wid); + if (x) widget.setAttribute("left", x); + if (y) widget.setAttribute("top", y); + this._addNewWidget(widget); + this._updateWidgets(); + }, + // we're relying on viewportBounds and viewingRect having the same origin get viewportVisibleRect () { let rect = this._viewportBounds.intersect(this._viewingRect); diff --git a/mobile/chrome/content/browser-ui.js b/mobile/chrome/content/browser-ui.js index 1f744024ab61..5a238319b812 100644 --- a/mobile/chrome/content/browser-ui.js +++ b/mobile/chrome/content/browser-ui.js @@ -189,15 +189,31 @@ var BrowserUI = { document.getElementById("panel-items").selectedPanel = document.getElementById(id); }, + get toolbarH() { + if (!this._toolbarH) { + let toolbar = document.getElementById("toolbar-main"); + this._toolbarH = toolbar.boxObject.height; + } + return this._toolbarH; + }, + + _initControls : false, sizeControls : function(windowW, windowH) { let toolbar = document.getElementById("toolbar-main"); - if (!this._toolbarH) - this._toolbarH = toolbar.boxObject.height; + let tabs = document.getElementById("tabs-container"); + let controls = document.getElementById("browser-controls"); + if (!this._initControls) { + this._initControls = true; + ws.moveUnfrozenTo("toolbar-main", null, -this.toolbarH) + ws.moveUnfrozenTo("tabs-container", -tabs.boxObject.width, this.toolbarH) + ws.moveUnfrozenTo("browser-controls", null, this.toolbarH) + } toolbar.width = windowW; let popup = document.getElementById("popup_autocomplete"); - popup.height = windowH - this._toolbarH; + popup.top = this.toolbarH; + popup.height = windowH - this.toolbarH; popup.width = windowW; // notification box @@ -207,9 +223,9 @@ var BrowserUI = { document.getElementById("findbar-container").width = windowW; // sidebars - let sideBarHeight = windowH - this._toolbarH; - document.getElementById("browser-controls").height = sideBarHeight; - document.getElementById("tabs-container").height = sideBarHeight; + let sideBarHeight = windowH - this.toolbarH; + controls.height = sideBarHeight; + tabs.height = sideBarHeight; // bookmark editor let bmkeditor = document.getElementById("bookmark-container"); @@ -267,7 +283,7 @@ var BrowserUI = { break; case TOOLBARSTATE_LOADING: - ws.panTo(0, -60); + ws.panTo(0, -this.toolbarH); this.showToolbar(); icons.setAttribute("mode", "loading"); this._favicon.src = ""; @@ -411,7 +427,7 @@ var BrowserUI = { newTab : function newTab() { Browser.addTab("about:blank", true); - ws.panTo(0, -60); + ws.panTo(0, -this.toolbarH); this.showToolbar(URLBAR_EDIT); }, diff --git a/mobile/chrome/content/browser.js b/mobile/chrome/content/browser.js index 70ccda81d3aa..a9a49f9f02a7 100644 --- a/mobile/chrome/content/browser.js +++ b/mobile/chrome/content/browser.js @@ -358,7 +358,7 @@ var Browser = { this._canvasBrowser.setCurrentBrowser(this.selectedBrowser, firstTab); document.getElementById("tabs").selectedItem = tab.content; - ws.panTo(0, -60, true); + ws.panTo(0, -BrowserUI.toolbarH); if (!firstTab) { let webProgress = this.selectedBrowser.webProgress; diff --git a/mobile/chrome/content/browser.xul b/mobile/chrome/content/browser.xul index cdc01ed815df..a9850776ddac 100644 --- a/mobile/chrome/content/browser.xul +++ b/mobile/chrome/content/browser.xul @@ -220,12 +220,12 @@ - - + @@ -237,19 +237,18 @@ - - - + + + - + - + - + @@ -299,10 +298,10 @@ -