mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-22 02:09:28 +00:00
Bug 851130 - Part 3 - Fixup new StartUI tab object and dependent views. r=sfoster
This commit is contained in:
parent
c71dc2606f
commit
a9188be7a3
@ -26,8 +26,8 @@ function BookmarksView(aSet, aLimit, aRoot, aFilterUnpinned) {
|
||||
this._pinHelper = new ItemPinHelper("metro.bookmarks.unpinned");
|
||||
this._bookmarkService.addObserver(this._changes, false);
|
||||
Services.obs.addObserver(this, "metro_viewstate_changed", false);
|
||||
window.addEventListener('MozAppbarDismissing', this, false);
|
||||
window.addEventListener('BookmarksNeedsRefresh', this, false);
|
||||
StartUI.chromeWin.addEventListener('MozAppbarDismissing', this, false);
|
||||
StartUI.chromeWin.addEventListener('BookmarksNeedsRefresh', this, false);
|
||||
|
||||
this.root = aRoot;
|
||||
}
|
||||
@ -60,7 +60,7 @@ BookmarksView.prototype = Util.extend(Object.create(View.prototype), {
|
||||
|
||||
handleItemClick: function bv_handleItemClick(aItem) {
|
||||
let url = aItem.getAttribute("value");
|
||||
BrowserUI.goToURI(url);
|
||||
StartUI.goToURI(url);
|
||||
},
|
||||
|
||||
_getItemForBookmarkId: function bv__getItemForBookmark(aBookmarkId) {
|
||||
@ -309,7 +309,9 @@ let BookmarksStartView = {
|
||||
},
|
||||
|
||||
uninit: function uninit() {
|
||||
this._view.destruct();
|
||||
if (this._view) {
|
||||
this._view.destruct();
|
||||
}
|
||||
},
|
||||
|
||||
show: function show() {
|
||||
|
@ -17,8 +17,8 @@ function HistoryView(aSet, aLimit, aFilterUnpinned) {
|
||||
this._pinHelper = new ItemPinHelper("metro.history.unpinned");
|
||||
this._historyService.addObserver(this, false);
|
||||
Services.obs.addObserver(this, "metro_viewstate_changed", false);
|
||||
window.addEventListener('MozAppbarDismissing', this, false);
|
||||
window.addEventListener('HistoryNeedsRefresh', this, false);
|
||||
StartUI.chromeWin.addEventListener('MozAppbarDismissing', this, false);
|
||||
StartUI.chromeWin.addEventListener('HistoryNeedsRefresh', this, false);
|
||||
}
|
||||
|
||||
HistoryView.prototype = Util.extend(Object.create(View.prototype), {
|
||||
@ -27,7 +27,7 @@ HistoryView.prototype = Util.extend(Object.create(View.prototype), {
|
||||
|
||||
handleItemClick: function tabview_handleItemClick(aItem) {
|
||||
let url = aItem.getAttribute("value");
|
||||
BrowserUI.goToURI(url);
|
||||
StartUI.goToURI(url);
|
||||
},
|
||||
|
||||
populateGrid: function populateGrid(aRefresh) {
|
||||
@ -298,6 +298,8 @@ let HistoryStartView = {
|
||||
},
|
||||
|
||||
uninit: function uninit() {
|
||||
this._view.destruct();
|
||||
if (this._view) {
|
||||
this._view.destruct();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -45,7 +45,7 @@ RemoteTabsView.prototype = Util.extend(Object.create(View.prototype), {
|
||||
|
||||
handleItemClick: function tabview_handleItemClick(aItem) {
|
||||
let url = aItem.getAttribute("value");
|
||||
BrowserUI.goToURI(url);
|
||||
StartUI.goToURI(url);
|
||||
},
|
||||
|
||||
observe: function(subject, topic, data) {
|
||||
@ -122,7 +122,9 @@ let RemoteTabsStartView = {
|
||||
},
|
||||
|
||||
uninit: function uninit() {
|
||||
this._view.destruct();
|
||||
if (this._view) {
|
||||
this._view.destruct();
|
||||
}
|
||||
},
|
||||
|
||||
show: function show() {
|
||||
|
@ -4,98 +4,62 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var StartUI = {
|
||||
get isVisible() { return this.isStartPageVisible; },
|
||||
get isStartPageVisible() { return true; /*return Elements.windowState.hasAttribute("startpage");*/ },
|
||||
get startUI() { return document.getElementById("start-container"); },
|
||||
|
||||
get maxResultsPerSection() {
|
||||
return Services.prefs.getIntPref("browser.display.startUI.maxresults");
|
||||
},
|
||||
|
||||
sections: [
|
||||
"TopSitesStartView",
|
||||
"BookmarksStartView",
|
||||
"HistoryStartView",
|
||||
"RemoteTabsStartView"
|
||||
],
|
||||
|
||||
init: function init() {
|
||||
Elements.startUI.addEventListener("contextmenu", this, false);
|
||||
Elements.startUI.addEventListener("click", this, false);
|
||||
Elements.startUI.addEventListener("MozMousePixelScroll", this, false);
|
||||
this.startUI.addEventListener("contextmenu", this, false);
|
||||
this.startUI.addEventListener("click", this, false);
|
||||
this.startUI.addEventListener("MozMousePixelScroll", this, false);
|
||||
|
||||
this.sections.forEach(function (sectionName) {
|
||||
let section = window[sectionName];
|
||||
if (section.init)
|
||||
section.init();
|
||||
});
|
||||
TopSitesStartView.init();
|
||||
BookmarksStartView.init();
|
||||
HistoryStartView.init();
|
||||
RemoteTabsStartView.init();
|
||||
|
||||
TopSitesStartView.show();
|
||||
BookmarksStartView.show();
|
||||
HistoryStartView.show();
|
||||
RemoteTabsStartView.show();
|
||||
},
|
||||
|
||||
uninit: function() {
|
||||
this.sections.forEach(function (sectionName) {
|
||||
let section = window[sectionName];
|
||||
if (section.uninit)
|
||||
section.uninit();
|
||||
});
|
||||
if (TopSitesStartView)
|
||||
TopSitesStartView.uninit();
|
||||
if (BookmarksStartView)
|
||||
BookmarksStartView.uninit();
|
||||
if (HistoryStartView)
|
||||
HistoryStartView.uninit();
|
||||
if (RemoteTabsStartView)
|
||||
RemoteTabsStartView.uninit();
|
||||
},
|
||||
|
||||
/** Show the Firefox start page / "new tab" page */
|
||||
show: function show() {
|
||||
if (this.isStartPageVisible)
|
||||
return false;
|
||||
|
||||
ContextUI.displayNavbar();
|
||||
|
||||
Elements.contentShowing.setAttribute("disabled", "true");
|
||||
Elements.windowState.setAttribute("startpage", "true");
|
||||
|
||||
this.sections.forEach(function (sectionName) {
|
||||
let section = window[sectionName];
|
||||
if (section.show)
|
||||
section.show();
|
||||
});
|
||||
return true;
|
||||
get chromeWin() {
|
||||
// XXX Not e10s friendly, we use this in a few places.
|
||||
return Services.wm.getMostRecentWindow('navigator:browser');
|
||||
},
|
||||
|
||||
/** Hide the Firefox start page */
|
||||
hide: function hide(aURI) {
|
||||
aURI = aURI || Browser.selectedBrowser.currentURI.spec;
|
||||
if (!this.isStartPageVisible || this.isStartURI(aURI))
|
||||
return false;
|
||||
|
||||
Elements.contentShowing.removeAttribute("disabled");
|
||||
Elements.windowState.removeAttribute("startpage");
|
||||
return true;
|
||||
},
|
||||
|
||||
/** Is the current tab supposed to show the Firefox start page? */
|
||||
isStartURI: function isStartURI(aURI) {
|
||||
aURI = aURI || Browser.selectedBrowser.currentURI.spec;
|
||||
return aURI == kStartOverlayURI || aURI == "about:home";
|
||||
},
|
||||
|
||||
/** Call this to show or hide the start page when switching tabs or pages */
|
||||
update: function update(aURI) {
|
||||
aURI = aURI || Browser.selectedBrowser.currentURI.spec;
|
||||
if (this.isStartURI(aURI)) {
|
||||
this.show();
|
||||
} else if (aURI != "about:blank") { // about:blank is loaded briefly for new tabs; ignore it
|
||||
this.hide(aURI);
|
||||
}
|
||||
goToURI: function (aURI) {
|
||||
this.chromeWin.BrowserUI.goToURI(aURI);
|
||||
},
|
||||
|
||||
onClick: function onClick(aEvent) {
|
||||
// If someone clicks / taps in empty grid space, take away
|
||||
// focus from the nav bar edit so the soft keyboard will hide.
|
||||
if (BrowserUI.blurNavBar()) {
|
||||
if (this.chromeWin.BrowserUI.blurNavBar()) {
|
||||
// Advanced notice to CAO, so we can shuffle the nav bar in advance
|
||||
// of the keyboard transition.
|
||||
ContentAreaObserver.navBarWillBlur();
|
||||
this.chromeWin.ContentAreaObserver.navBarWillBlur();
|
||||
}
|
||||
if (aEvent.button == 0) {
|
||||
this.chromeWin.ContextUI.dismissTabs();
|
||||
}
|
||||
|
||||
if (aEvent.button == 0)
|
||||
ContextUI.dismissTabs();
|
||||
},
|
||||
|
||||
onNarrowTitleClick: function onNarrowTitleClick(sectionId) {
|
||||
@ -104,12 +68,20 @@ var StartUI = {
|
||||
if (section.hasAttribute("expanded"))
|
||||
return;
|
||||
|
||||
for (let expandedSection of Elements.startUI.querySelectorAll(".meta-section[expanded]"))
|
||||
for (let expandedSection of this.startUI.querySelectorAll(".meta-section[expanded]"))
|
||||
expandedSection.removeAttribute("expanded")
|
||||
|
||||
section.setAttribute("expanded", "true");
|
||||
},
|
||||
|
||||
getScrollBoxObject: function () {
|
||||
let startBox = document.getElementById("start-scrollbox");
|
||||
if (!startBox._cachedSBO) {
|
||||
startBox._cachedSBO = startBox.boxObject.QueryInterface(Ci.nsIScrollBoxObject);
|
||||
}
|
||||
return startBox._cachedSBO;
|
||||
},
|
||||
|
||||
handleEvent: function handleEvent(aEvent) {
|
||||
switch (aEvent.type) {
|
||||
case "contextmenu":
|
||||
@ -117,18 +89,17 @@ var StartUI = {
|
||||
event.initEvent("MozEdgeUICompleted", true, false);
|
||||
window.dispatchEvent(event);
|
||||
break;
|
||||
|
||||
case "click":
|
||||
this.onClick(aEvent);
|
||||
break;
|
||||
|
||||
case "MozMousePixelScroll":
|
||||
let startBox = document.getElementById("start-scrollbox");
|
||||
let [, scrollInterface] = ScrollUtils.getScrollboxFromElement(startBox);
|
||||
|
||||
if (Elements.windowState.getAttribute("viewstate") == "snapped") {
|
||||
scrollInterface.scrollBy(0, aEvent.detail);
|
||||
let scroller = this.getScrollBoxObject();
|
||||
if (this.startUI.getAttribute("viewstate") == "snapped") {
|
||||
scroller.scrollBy(0, aEvent.detail);
|
||||
} else {
|
||||
scrollInterface.scrollBy(aEvent.detail, 0);
|
||||
scroller.scrollBy(aEvent.detail, 0);
|
||||
}
|
||||
|
||||
aEvent.preventDefault();
|
||||
|
@ -16,7 +16,7 @@ function TopSitesView(aGrid, aMaxSites) {
|
||||
this._topSitesMax = aMaxSites;
|
||||
|
||||
// clean up state when the appbar closes
|
||||
window.addEventListener('MozAppbarDismissing', this, false);
|
||||
StartUI.chromeWin.addEventListener('MozAppbarDismissing', this, false);
|
||||
let history = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
history.addObserver(this, false);
|
||||
@ -290,7 +290,9 @@ let TopSitesStartView = {
|
||||
},
|
||||
|
||||
uninit: function uninit() {
|
||||
this._view.destruct();
|
||||
if (this._view) {
|
||||
this._view.destruct();
|
||||
}
|
||||
},
|
||||
|
||||
show: function show() {
|
||||
|
@ -188,11 +188,6 @@ documenttab[selected] .documenttab-selection {
|
||||
/* Start UI ----------------------------------------------------------------- */
|
||||
|
||||
#start-container {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#start-container[startpage],
|
||||
#start-container[filtering] {
|
||||
display: -moz-box;
|
||||
}
|
||||
|
||||
@ -200,12 +195,6 @@ documenttab[selected] .documenttab-selection {
|
||||
overflow-x: scroll;
|
||||
}
|
||||
|
||||
/* if autocomplete is set, hide both start pages,
|
||||
* else hide the autocomplete screen */
|
||||
#start-container[filtering] > .start-page,
|
||||
#start-container:not([filtering]) > #start-autocomplete {
|
||||
visibility: collapse;
|
||||
}
|
||||
/* startUI sections, grids */
|
||||
#start-scrollbox > .meta-section {
|
||||
/* allot space for at least a single column */
|
||||
@ -213,13 +202,16 @@ documenttab[selected] .documenttab-selection {
|
||||
/* leave margin for horizontal scollbar */
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
#start-scrollbox[input="precise"] > .meta-section {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
#start-topsites {
|
||||
/* allot space for 3 tile columns for the topsites grid */
|
||||
min-width: calc(3 * @grid_double_column_width@);
|
||||
}
|
||||
|
||||
#start-scrollbox {
|
||||
-moz-box-orient: horizontal;
|
||||
/* Move scrollbar above toolbar,
|
||||
|
Loading…
x
Reference in New Issue
Block a user