Bug 885242 - Part 2 - Simplify markup in browser.xul, do some cleanup elsewhere. r=mbrubeck

--HG--
extra : rebase_source : c5292e82d00371bdd4a5a8be8b3b7d80bb8cf472
This commit is contained in:
Jonathan Wilde 2013-07-17 23:05:40 -07:00
parent a2211f601f
commit 885087c357
3 changed files with 66 additions and 55 deletions

View File

@ -9,17 +9,20 @@ const kProgressMarginStart = 30;
const kProgressMarginEnd = 70;
const WebProgress = {
get _identityBox() { return document.getElementById("identity-box"); },
_progressActive: false,
init: function init() {
messageManager.addMessageListener("Content:StateChange", this);
messageManager.addMessageListener("Content:LocationChange", this);
messageManager.addMessageListener("Content:SecurityChange", this);
Elements.progress.addEventListener("transitionend", this._progressTransEnd, true);
Elements.tabList.addEventListener("TabSelect", this._onTabSelect, true);
Elements.progress.addEventListener("transitionend", this, true);
Elements.tabList.addEventListener("TabSelect", this, true);
let urlBar = document.getElementById("urlbar-edit");
urlBar.addEventListener("input", this._onUrlBarInput, false);
urlBar.addEventListener("input", this, false);
return this;
},
@ -62,6 +65,20 @@ const WebProgress = {
}
},
handleEvent: function handleEvent(aEvent) {
switch (aEvent.type) {
case "transitionend":
this._progressTransEnd(aEvent);
break;
case "TabSelect":
this._onTabSelect(aEvent);
break;
case "input":
this._onUrlBarInput(aEvent);
break;
}
},
_securityChange: function _securityChange(aJson, aTab) {
let state = aJson.state;
let nsIWebProgressListener = Ci.nsIWebProgressListener;
@ -75,8 +92,7 @@ const WebProgress = {
}
if (aTab == Browser.selectedTab) {
let identityBox = document.getElementById("identity-box-inner");
identityBox.className = aTab._identityState;
this._identityBox.className = aTab._identityState;
}
},
@ -203,24 +219,22 @@ const WebProgress = {
Elements.progress.setAttribute("fade", true);
},
_progressTransEnd: function _progressTransEnd(data) {
_progressTransEnd: function _progressTransEnd(aEvent) {
if (!Elements.progress.hasAttribute("fade"))
return;
// Close out fade finished, reset
if (data.propertyName == "opacity") {
if (aEvent.propertyName == "opacity") {
Elements.progress.style.width = "0px";
Elements.progressContainer.setAttribute("collapsed", true);
}
},
_onTabSelect: function(aEvent) {
let identityBox = document.getElementById("identity-box-inner");
let tab = Browser.getTabFromChrome(aEvent.originalTarget);
identityBox.className = tab._identityState || "";
this._identityBox.className = tab._identityState || "";
},
_onUrlBarInput: function(aEvent) {
let identityBox = document.getElementById("identity-box-inner");
Browser.selectedTab._identityState = identityBox.className = "";
Browser.selectedTab._identityState = this._identityBox.className = "";
},
};

View File

@ -247,7 +247,7 @@
<html:div id="overlay-plus" class="overlay-button"
observes="cmd_back"></html:div>
<!-- Navbar -->
<!-- Navigation bar -->
<appbar id="navbar" mousethrough="never" observes="bcast_windowState">
<hbox id="progress-container" layer="true">
<hbox id="progress-control" />
@ -259,40 +259,41 @@
<hbox id="urlbar-autocomplete" observes="bcast_windowState"/>
</scrollbox>
<!-- Main Toolbar -->
<toolbar id="toolbar" observes="bcast_windowState" flex="1">
<!-- Main toolbar -->
<toolbar id="toolbar" flex="1">
<observes element="bcast_windowState" attribute="*"/>
<observes element="bcast_urlbarState" attribute="*"/>
<toolbarbutton id="back-button" class="appbar-primary" command="cmd_back"/>
<toolbarbutton id="forward-button" class="appbar-primary" command="cmd_forward"/>
<toolbarbutton id="back-button" class="appbar-primary"
command="cmd_back"/>
<toolbarbutton id="forward-button" class="appbar-primary"
command="cmd_forward"/>
<hbox id="urlbar-container" flex="1" observes="bcast_urlbarState">
<hbox id="urlbar" flex="1">
<box id="identity-box" role="button">
<hbox id="identity-box-inner" align="center" mousethrough="always">
<image id="identity-icon"/>
</hbox>
</box>
<hbox id="urlbar" flex="1" observes="bcast_urlbarState">
<box id="identity-box" align="center" role="button">
<image id="identity-icon"/>
</box>
<textbox id="urlbar-edit"
type="url"
class="uri-element"
autocompletesearch="history"
autocompletepopup="urlbar-autocomplete"
completeselectedindex="true"
placeholder="&urlbar.emptytext;"
flex="1"/>
</hbox>
<textbox id="urlbar-edit" type="url" flex="1"
autocompletesearch="history"
autocompletepopup="urlbar-autocomplete"
completeselectedindex="true"
placeholder="&urlbar.emptytext;"/>
<toolbarbutton id="reload-button" oncommand="CommandUpdater.doCommand(event.shiftKey ? 'cmd_forceReload' : 'cmd_reload');"/>
<toolbarbutton id="reload-button" oncommand="
CommandUpdater.doCommand(event.shiftKey ? 'cmd_forceReload'
: 'cmd_reload');"/>
<toolbarbutton id="stop-button" command="cmd_stop"/>
</hbox>
<toolbarbutton id="download-button" class="appbar-secondary" oncommand="Appbar.onDownloadButton()"/>
<toolbarbutton id="star-button" class="appbar-primary" type="checkbox" oncommand="Appbar.onStarButton()"/>
<toolbarbutton id="pin-button" class="appbar-primary" type="checkbox" oncommand="Appbar.onPinButton()"/>
<toolbarbutton id="menu-button" class="appbar-primary" oncommand="Appbar.onMenuButton(event)"/>
<toolbarbutton id="download-button" class="appbar-secondary"
oncommand="Appbar.onDownloadButton()"/>
<toolbarbutton id="star-button" class="appbar-primary" type="checkbox"
oncommand="Appbar.onStarButton()"/>
<toolbarbutton id="pin-button" class="appbar-primary" type="checkbox"
oncommand="Appbar.onPinButton()"/>
<toolbarbutton id="menu-button" class="appbar-primary"
oncommand="Appbar.onMenuButton(event)"/>
</toolbar>
</vbox>
</appbar>
@ -337,12 +338,14 @@
</vbox>
<!-- Find bar -->
<appbar id="findbar" class="window-width findbar-box" orient="horizontal" pack="start">
<textbox id="findbar-textbox" class="search-bar findbar-item" oncommand="FindHelperUI.search(this.value)" oninput="FindHelperUI.updateCommands(this.value);" type="search"/>
<button class="findbar-item previous-button" command="cmd_findPrevious"/>
<button class="findbar-item next-button" command="cmd_findNext"/>
<appbar id="findbar" class="window-width" pack="start">
<textbox id="findbar-textbox" type="search"
oncommand="FindHelperUI.search(this.value)"
oninput="FindHelperUI.updateCommands(this.value); "/>
<button class="previous-button" command="cmd_findPrevious"/>
<button class="next-button" command="cmd_findNext"/>
<spacer flex="1"/>
<button id="findbar-close" class="findbar-item close-button" command="cmd_findClose"/>
<button id="findbar-close" class="close-button" command="cmd_findClose"/>
</appbar>
<!-- Context button bar -->

View File

@ -327,12 +327,6 @@ documenttab[selected] .documenttab-selection {
overflow: hidden;
}
/* helperapp (save-as) popup */
#helperapp-target {
font-size: @font_small@ !important;
}
/* overlay buttons */
.overlay-button {
@ -514,7 +508,7 @@ documenttab[selected] .documenttab-selection {
}
/* URL bar */
#urlbar-container {
#urlbar {
border: @metro_border_thick@ solid @urlbar_border_color@;
margin: 0 @toolbar_horizontal_spacing@;
padding: 0;
@ -522,7 +516,7 @@ documenttab[selected] .documenttab-selection {
overflow: hidden;
}
#urlbar-container[mode="edit"] {
#urlbar[mode="edit"] {
border-color: @metro_orange@;
}
@ -533,11 +527,11 @@ documenttab[selected] .documenttab-selection {
list-style-image: url("chrome://browser/skin/images/identity-icons-generic.png");
}
#identity-box-inner.verifiedDomain > #identity-icon {
#identity-box.verifiedDomain > #identity-icon {
list-style-image: url("chrome://browser/skin/images/identity-icons-https.png");
}
#identity-box-inner.verifiedIdentity > #identity-icon {
#identity-box.verifiedIdentity > #identity-icon {
list-style-image: url("chrome://browser/skin/images/identity-icons-https-ev.png");
}
@ -571,9 +565,9 @@ documenttab[selected] .documenttab-selection {
list-style-image: url(chrome://browser/skin/images/appbar-stop.png);
}
#toolbar[mode="loading"] > #urlbar-container > #reload-button,
#toolbar:-moz-any([mode="edit"], [mode="view"]) > #urlbar-container > #stop-button,
#toolbar[viewstate="snapped"] > #urlbar-container ~ toolbarbutton {
#urlbar[mode="loading"] > #reload-button,
#urlbar:-moz-any([mode="edit"], [mode="view"]) > #stop-button,
#toolbar[viewstate="snapped"] > #urlbar ~ toolbarbutton {
visibility: collapse;
}