Bug 1273958 Fix suppression of search box for disco pane r=kmag,rhelmer

Hiding the header was causing some problems so instead restructure the
XUL to put the discovery pane in the top-level deck alongside a vbox
with the header and a deck with all the other panes that have the header.

MozReview-Commit-ID: 2PnW1F9aYgt

--HG--
extra : rebase_source : 758e8560c88801e65ae7e0d1152bd5b75e013b70
This commit is contained in:
Andrew Swan 2016-05-20 16:42:48 -07:00
Родитель 426f8dbfee
Коммит cac4af48b7
10 изменённых файлов: 597 добавлений и 560 удалений

Просмотреть файл

@ -631,7 +631,8 @@ var gViewController = {
initialize: function() {
this.viewPort = document.getElementById("view-port");
this.headerEl = document.getElementById("header");
this.headeredViews = document.getElementById("headered-views");
this.headeredViewsDeck = document.getElementById("headered-views-content");
this.viewObjects["search"] = gSearchView;
this.viewObjects["discover"] = gDiscoverView;
@ -752,6 +753,24 @@ var gViewController = {
notifyInitialized();
},
get displayedView() {
if (this.viewPort.selectedPanel == this.headeredViews) {
return this.headeredViewsDeck.selectedPanel;
} else {
return this.viewPort.selectedPanel;
}
},
set displayedView(view) {
let node = view.node;
if (node.parentNode == this.headeredViewsDeck) {
this.headeredViewsDeck.selectedPanel = node;
this.viewPort.selectedPanel = this.headeredViews;
} else {
this.viewPort.selectedPanel = node;
}
},
loadViewInternal: function(aViewId, aPreviousView, aState) {
var view = this.parseViewId(aViewId);
@ -763,13 +782,11 @@ var gViewController = {
throw Components.Exception("Root node doesn't exist for '" + view.type + "' view");
if (this.currentViewObj && aViewId != aPreviousView) {
this.headerEl.hidden = Boolean(viewObj.hideHeader);
try {
let canHide = this.currentViewObj.hide();
if (canHide === false)
return;
this.viewPort.selectedPanel.removeAttribute("loading");
this.displayedView.removeAttribute("loading");
} catch (e) {
// this shouldn't be fatal
Cu.reportError(e);
@ -781,8 +798,8 @@ var gViewController = {
this.currentViewId = aViewId;
this.currentViewObj = viewObj;
this.viewPort.selectedPanel = this.currentViewObj.node;
this.viewPort.selectedPanel.setAttribute("loading", "true");
this.displayedView = this.currentViewObj;
this.currentViewObj.node.setAttribute("loading", "true");
this.currentViewObj.node.focus();
if (aViewId == aPreviousView)
@ -798,7 +815,7 @@ var gViewController = {
},
notifyViewChanged: function() {
this.viewPort.selectedPanel.removeAttribute("loading");
this.displayedView.removeAttribute("loading");
if (this.viewChangeCallback) {
this.viewChangeCallback();
@ -3323,7 +3340,7 @@ var gDetailView = {
// relies on us finishing before the ViewChanged event bubbles up to its
// listeners, and promises resolve asynchronously.
let whenViewLoaded = callback => {
if (gViewController.viewPort.selectedPanel.hasAttribute("loading")) {
if (gViewController.displayedView.hasAttribute("loading")) {
gDetailView.node.addEventListener("ViewChanged", function viewChangedEventListener() {
gDetailView.node.removeEventListener("ViewChanged", viewChangedEventListener);
callback();

Просмотреть файл

@ -161,6 +161,40 @@
</richlistbox>
</vbox>
<vbox class="main-content" flex="1">
<!-- view port -->
<deck id="view-port" flex="1" selectedIndex="0">
<!-- discover view -->
<deck id="discover-view" flex="1" class="view-pane" selectedIndex="0" tabindex="0">
<vbox id="discover-loading" align="center" pack="stretch" flex="1" class="alert-container">
<spacer class="alert-spacer-before"/>
<hbox class="alert loading" align="center">
<image/>
<label value="&loading.label;"/>
</hbox>
<spacer class="alert-spacer-after"/>
</vbox>
<vbox id="discover-error" align="center" pack="stretch" flex="1" class="alert-container">
<spacer class="alert-spacer-before"/>
<hbox>
<spacer class="discover-spacer-before"/>
<hbox class="alert" align="center">
<image class="discover-logo"/>
<vbox flex="1" align="stretch">
<label class="discover-title">&discover.title;</label>
<description class="discover-description">&discover.description2;</description>
<description class="discover-footer">&discover.footer;</description>
</vbox>
</hbox>
<spacer class="discover-spacer-after"/>
</hbox>
<spacer class="alert-spacer-after"/>
</vbox>
<browser id="discover-browser" type="content" flex="1"
disablehistory="true" homepage="about:blank"/>
</deck>
<!-- container for views with the search/tools header -->
<vbox id="headered-views" flex="1">
<!-- main header -->
<hbox id="header" align="center">
<button id="show-all-extensions" hidden="true"
@ -228,39 +262,8 @@
searchbuttonlabel="&search.buttonlabel;"
placeholder="&search.placeholder;"/>
</hbox>
<!-- view port -->
<deck id="view-port" flex="1" selectedIndex="0">
<!-- discover view -->
<deck id="discover-view" flex="1" class="view-pane" selectedIndex="0" tabindex="0">
<vbox id="discover-loading" align="center" pack="stretch" flex="1" class="alert-container">
<spacer class="alert-spacer-before"/>
<hbox class="alert loading" align="center">
<image/>
<label value="&loading.label;"/>
</hbox>
<spacer class="alert-spacer-after"/>
</vbox>
<vbox id="discover-error" align="center" pack="stretch" flex="1" class="alert-container">
<spacer class="alert-spacer-before"/>
<hbox>
<spacer class="discover-spacer-before"/>
<hbox class="alert" align="center">
<image class="discover-logo"/>
<vbox flex="1" align="stretch">
<label class="discover-title">&discover.title;</label>
<description class="discover-description">&discover.description2;</description>
<description class="discover-footer">&discover.footer;</description>
</vbox>
</hbox>
<spacer class="discover-spacer-after"/>
</hbox>
<spacer class="alert-spacer-after"/>
</vbox>
<browser id="discover-browser" type="content" flex="1"
disablehistory="true" homepage="about:blank"/>
</deck>
<deck id="headered-views-content" flex="1" selectedIndex="0">
<!-- search view -->
<vbox id="search-view" flex="1" class="view-pane" tabindex="0">
<hbox class="view-header global-warning-container" align="center">
@ -709,5 +712,7 @@
</scrollbox>
</deck>
</vbox>
</deck>
</vbox>
</hbox>
</page>

Просмотреть файл

@ -127,7 +127,7 @@ function is_in_list(aManager, view, canGoBack, canGoForward) {
var doc = aManager.document;
is(doc.getElementById("categories").selectedItem.value, view, "Should be on the right category");
is(doc.getElementById("view-port").selectedPanel.id, "list-view", "Should be on the right view");
is(get_current_view(aManager).id, "list-view", "Should be on the right view");
check_state(aManager, canGoBack, canGoForward);
}
@ -136,7 +136,7 @@ function is_in_search(aManager, query, canGoBack, canGoForward) {
var doc = aManager.document;
is(doc.getElementById("categories").selectedItem.value, "addons://search/", "Should be on the right category");
is(doc.getElementById("view-port").selectedPanel.id, "search-view", "Should be on the right view");
is(get_current_view(aManager).id, "search-view", "Should be on the right view");
is(doc.getElementById("header-search").value, query, "Should have used the right query");
check_state(aManager, canGoBack, canGoForward);
@ -146,7 +146,7 @@ function is_in_detail(aManager, view, canGoBack, canGoForward) {
var doc = aManager.document;
is(doc.getElementById("categories").selectedItem.value, view, "Should be on the right category");
is(doc.getElementById("view-port").selectedPanel.id, "detail-view", "Should be on the right view");
is(get_current_view(aManager).id, "detail-view", "Should be on the right view");
check_state(aManager, canGoBack, canGoForward);
}

Просмотреть файл

@ -30,14 +30,14 @@ function is_in_list(aManager, view) {
var doc = aManager.document;
is(doc.getElementById("categories").selectedItem.value, view, "Should be on the right category");
is(doc.getElementById("view-port").selectedPanel.id, "list-view", "Should be on the right view");
is(get_current_view(aManager).id, "list-view", "Should be on the right view");
}
function is_in_detail(aManager, view) {
var doc = aManager.document;
is(doc.getElementById("categories").selectedItem.value, view, "Should be on the right category");
is(doc.getElementById("view-port").selectedPanel.id, "detail-view", "Should be on the right view");
is(get_current_view(aManager).id, "detail-view", "Should be on the right view");
}
// Check that double-click does something.

Просмотреть файл

@ -11,6 +11,8 @@ const SEARCH_URL = TESTROOT + "browser_searching.xml";
const SEARCH_EXPECTED_TOTAL = 100;
const SEARCH_QUERY = "search";
const SEARCHABLE_PAGE = "addons://list/extension";
var gManagerWindow;
@ -20,7 +22,7 @@ function test() {
waitForExplicitFinish();
open_manager("addons://list/extension", function(aWindow) {
open_manager(SEARCHABLE_PAGE, function(aWindow) {
gManagerWindow = aWindow;
run_next_test();
});
@ -76,7 +78,7 @@ add_test(function() {
info("Searching locally");
search(false, function() {
check_allresultslink(false);
restart_manager(gManagerWindow, null, function(aManager) {
restart_manager(gManagerWindow, SEARCHABLE_PAGE, function(aManager) {
gManagerWindow = aManager;
run_next_test();
});
@ -84,11 +86,12 @@ add_test(function() {
});
add_test(function() {
debugger;
info("Searching remotely - more results than cap");
Services.prefs.setIntPref(PREF_GETADDONS_MAXRESULTS, 3);
search(true, function() {
check_allresultslink(true);
restart_manager(gManagerWindow, null, function(aManager) {
restart_manager(gManagerWindow, SEARCHABLE_PAGE, function(aManager) {
gManagerWindow = aManager;
run_next_test();
});
@ -100,7 +103,7 @@ add_test(function() {
Services.prefs.setIntPref(PREF_GETADDONS_MAXRESULTS, 200);
search(true, function() {
check_allresultslink(false);
restart_manager(gManagerWindow, null, function(aManager) {
restart_manager(gManagerWindow, SEARCHABLE_PAGE, function(aManager) {
gManagerWindow = aManager;
run_next_test();
});

Просмотреть файл

@ -28,7 +28,7 @@ function getExperimentAddons() {
function getInstallItem() {
let doc = gManagerWindow.document;
let view = doc.getElementById("view-port").selectedPanel;
let view = get_current_view(gManagerWindow);
let list = doc.getElementById("addon-list");
let node = list.firstChild;

Просмотреть файл

@ -71,7 +71,7 @@ function getInstallItem() {
}
function openDetailsView(aId) {
let view = gManagerWindow.document.getElementById("view-port").selectedPanel
let view = get_current_view(gManagerWindow);
Assert.equal(view.id, "list-view", "Should be in the list view to use this function");
let item = get_addon_element(gManagerWindow, aId);

Просмотреть файл

@ -617,7 +617,7 @@ add_test(function() {
// Tests that compatible-by-default addons are shown if strict compatibility checking is disabled
add_test(function() {
restart_manager(gManagerWindow, null, function(aWindow) {
restart_manager(gManagerWindow, "addons://list/extension", function(aWindow) {
gManagerWindow = aWindow;
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
@ -649,6 +649,8 @@ add_test(function() {
// Installed add-on is considered local on new search
gAddonInstalled = true;
// Switch over to extensions list so we can do a new search
gCategoryUtilities.openType("extension", function() {
search(QUERY, false, function() {
check_filtered_results(QUERY, "relevancescore", false);
@ -658,6 +660,7 @@ add_test(function() {
run_next_test();
});
});
});
});
function bug_815120_test_search(aLocalOnly) {

Просмотреть файл

@ -452,7 +452,7 @@ add_test(function() {
EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
wait_for_view_load(gManagerWindow, function() {
is(gDocument.getElementById("view-port").selectedPanel.id, "detail-view", "Should be in the detail view");
is(get_current_view(gManagerWindow).id, "detail-view", "Should be in the detail view");
var button = gDocument.getElementById("detail-uninstall-btn");
isnot(button, null, "Should have a remove button");
@ -516,7 +516,7 @@ add_test(function() {
EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
wait_for_view_load(gManagerWindow, function() {
is(gDocument.getElementById("view-port").selectedPanel.id, "detail-view", "Should be in the detail view");
is(get_current_view(gManagerWindow).id, "detail-view", "Should be in the detail view");
var button = gDocument.getElementById("detail-uninstall-btn");
isnot(button, null, "Should have a remove button");
@ -583,7 +583,7 @@ add_test(function() {
EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
wait_for_view_load(gManagerWindow, function() {
is(gDocument.getElementById("view-port").selectedPanel.id, "detail-view", "Should be in the detail view");
is(get_current_view(gManagerWindow).id, "detail-view", "Should be in the detail view");
var button = gDocument.getElementById("detail-uninstall-btn");
isnot(button, null, "Should have a remove button");
@ -1068,7 +1068,7 @@ add_test(function() {
is(aAddon, null, "Add-on should no longer be installed");
is(aAddon2, null, "Second add-on should no longer be installed");
open_manager(null, function(aWindow) {
open_manager("addons://list/extension", function(aWindow) {
gManagerWindow = aWindow;
gDocument = gManagerWindow.document;
gCategoryUtilities = new CategoryUtilities(gManagerWindow);

Просмотреть файл

@ -284,10 +284,19 @@ function get_addon_file_url(aFilename) {
}
}
function get_current_view(aManager) {
let view = aManager.document.getElementById("view-port").selectedPanel;
if (view.id == "headered-views") {
view = aManager.document.getElementById("headered-views-content").selectedPanel;
}
is(view, aManager.gViewController.displayedView, "view controller is tracking the displayed view correctly");
return view;
}
function get_test_items_in_list(aManager) {
var tests = "@tests.mozilla.org";
let view = aManager.document.getElementById("view-port").selectedPanel;
let view = get_current_view(aManager);
let listid = view.id == "search-view" ? "search-list" : "addon-list";
let item = aManager.document.getElementById(listid).firstChild;
let items = [];
@ -308,7 +317,7 @@ function get_test_items_in_list(aManager) {
function check_all_in_list(aManager, aIds, aIgnoreExtras) {
var doc = aManager.document;
var view = doc.getElementById("view-port").selectedPanel;
var view = get_current_view(aManager);
var listid = view.id == "search-view" ? "search-list" : "addon-list";
var list = doc.getElementById(listid);
@ -336,7 +345,7 @@ function check_all_in_list(aManager, aIds, aIgnoreExtras) {
function get_addon_element(aManager, aId) {
var doc = aManager.document;
var view = doc.getElementById("view-port").selectedPanel;
var view = get_current_view(aManager);
var listid = "addon-list";
if (view.id == "search-view")
listid = "search-list";