From ff4b3aa2cbf644174d174f49b3d3cc1819e6833a Mon Sep 17 00:00:00 2001 From: "BlakeR1234%aol.com" Date: Thu, 3 Aug 2000 03:42:22 +0000 Subject: [PATCH] Fix bug 41345, implement checkmarks for the current visited page in the Go menu (as IE 5.x and NN 4.x do). r=jag, a=radha --- xpfe/browser/resources/content/navigator.js | 19 ++- xpfe/browser/resources/content/navigator.xul | 2 +- .../resources/content/sessionHistoryUI.js | 111 +++++++++--------- 3 files changed, 71 insertions(+), 61 deletions(-) diff --git a/xpfe/browser/resources/content/navigator.js b/xpfe/browser/resources/content/navigator.js index 0522a7aab1da..0ce81b34120c 100644 --- a/xpfe/browser/resources/content/navigator.js +++ b/xpfe/browser/resources/content/navigator.js @@ -18,7 +18,8 @@ * Rights Reserved. * * Contributor(s): - * Blake Ross + * Blake Ross + * Peter Annema */ var pref = null; @@ -63,6 +64,8 @@ catch (ex) var backButton = null; var forwardButton = null; + var webNavigation = null; + var useRealProgressFlag = false; var totalRequests = 0; var finishedRequests = 0; @@ -424,6 +427,14 @@ function Startup() contentArea.addEventListener("load",postURLToNativeWidget, true); } + // Get the content area docshell + var docShell = { value : null }; + var result = appCore.getContentDocShell(docShell); + if (docShell.value) { + //Get the session history component from docshell + webNavigation = docShell.value.QueryInterface(Components.interfaces.nsIWebNavigation); + } + dump("*** Pulling out the charset\n"); if ( window.arguments && window.arguments[1] ) { if (window.arguments[1].indexOf('charset=') != -1) { @@ -603,15 +614,13 @@ function BrowserForward() function BrowserBackMenu(event) { - //FillHistoryMenu(event.target, "back"); - appCore.backButtonPopup(event.target); + FillHistoryMenu(event.target, "back"); } function BrowserForwardMenu(event) { - //FillHistoryMen(event.target, "forward"); - appCore.forwardButtonPopup(event.target); + FillHistoryMenu(event.target, "forward"); } diff --git a/xpfe/browser/resources/content/navigator.xul b/xpfe/browser/resources/content/navigator.xul index c695516a4d7a..c9de9b76d08b 100644 --- a/xpfe/browser/resources/content/navigator.xul +++ b/xpfe/browser/resources/content/navigator.xul @@ -278,7 +278,7 @@ Contributor(s): ______________________________________. --> + oncreate="createUBHistoryMenu(event.target);" oncommand="executeUrlBarHistoryCommand(event.target);"> diff --git a/xpfe/browser/resources/content/sessionHistoryUI.js b/xpfe/browser/resources/content/sessionHistoryUI.js index e85d70c2cb5c..8e4ec46d70f7 100644 --- a/xpfe/browser/resources/content/sessionHistoryUI.js +++ b/xpfe/browser/resources/content/sessionHistoryUI.js @@ -18,8 +18,9 @@ * Rights Reserved. * * Contributor(s): - * Jason Eager - * (Some other netscape person who forgot to put the NPL header!) + * Jason Eager + * Blake Ross + * Peter Annema * */ const MAX_HISTORY_MENU_ITEMS = 15; @@ -29,55 +30,44 @@ var localstore = rdf.GetDataSource("rdf:localstore"); function FillHistoryMenu( aParent, aMenu ) { - var shistory; - // Get the content area docshell - var docShell = null; - var result = appCore.getContentDocShell(docShell); - if (docShell) + if (webNavigation) { - //Get the session history component from docshell - docShell = docShell.QueryInterface(Components.interfaces.nsIWebNavigation); - if (docShell) + var shistory = webNavigation.sessionHistory; + if (shistory) { - shistory = docShell.sessionHistory; - if (shistory) + //Remove old entries if any + deleteHistoryItems( aParent ); + var count = shistory.count; + var index = shistory.index; + switch (aMenu) { - //Remove old entries if any - deleteHistoryItems( aParent ); - var count = shistory.count; - var index = shistory.index; - switch (aMenu) - { - case "back": - var end = (index > MAX_HISTORY_MENU_ITEMS) ? index - MAX_HISTORY_MENU_ITEMS : 0; - for ( var j = index - 1; j >= end; j--) - { - var entry = shistory.getEntryAtIndex(j, false); - if (entry) - createMenuItem( aParent, j, entry.getTitle() ); - } - break; - case "forward": - var end = ((count-index) > MAX_HISTORY_MENU_ITEMS) ? index + MAX_HISTORY_MENU_ITEMS : count; - for ( var j = index + 1; j < end; j++) - { - var entry = shistory.getEntryAtIndex(j, false); - if (entry) - createMenuItem( aParent, j, entry.getTitle() ); - } - break; - case "go": - var end = count > MAX_HISTORY_MENU_ITEMS - ? count - MAX_HISTORY_MENU_ITEMS - : 0; - for( var j = count - 1; j >= end; j-- ) - { - var entry = shistory.getEntryAtIndex(j, false); - if (entry) - createMenuItem( aParent, j, entry.getTitle() ); - } - break; - } + case "back": + var end = (index > MAX_HISTORY_MENU_ITEMS) ? index - MAX_HISTORY_MENU_ITEMS : 0; + for ( var j = index - 1; j >= end; j--) + { + var entry = shistory.getEntryAtIndex(j, false); + if (entry) + createMenuItem( aParent, j, entry.title ); + } + break; + case "forward": + var end = ((count-index) > MAX_HISTORY_MENU_ITEMS) ? index + MAX_HISTORY_MENU_ITEMS : count; + for ( var j = index + 1; j < end; j++) + { + var entry = shistory.getEntryAtIndex(j, false); + if (entry) + createMenuItem( aParent, j, entry.title ); + } + break; + case "go": + var end = count > MAX_HISTORY_MENU_ITEMS ? count - MAX_HISTORY_MENU_ITEMS : 0; + for( var j = count - 1; j >= end; j-- ) + { + var entry = shistory.getEntryAtIndex(j, false); + if (entry) + createCheckboxMenuItem( aParent, j, entry.title, j==index ); + } + break; } } } @@ -94,7 +84,7 @@ function executeUrlBarHistoryCommand( aTarget) } } -function createUBHistoryMenu( aEvent ) +function createUBHistoryMenu( aParent ) { var ubHistory = appCore.urlbarHistory; // dump("In createUbHistoryMenu\n"); @@ -105,7 +95,7 @@ function createUBHistoryMenu( aEvent ) //dump("localstore found\n"); var i= MAX_HISTORY_MENU_ITEMS; // Delete any old menu items - deleteHistoryItems(aEvent); + deleteHistoryItems(aParent); while (entries.hasMoreElements() && (i-- > 0)) { var entry = entries.getNext(); @@ -113,7 +103,7 @@ function createUBHistoryMenu( aEvent ) entry = entry.QueryInterface(Components.interfaces.nsIRDFLiteral); var url = entry.Value; //dump("CREATEUBHISTORYMENU menuitem = " + url + "\n"); - createMenuItem(aEvent.target, i, url); + createMenuItem(aParent, i, url); } } @@ -158,19 +148,30 @@ function createMenuItem( aParent, aIndex, aValue) aParent.appendChild( menuitem ); } -function deleteHistoryItems( aEvent ) +function createCheckboxMenuItem( aParent, aIndex, aValue, aChecked) { - var children = aEvent.target.childNodes; + var menuitem = document.createElement( "menuitem" ); + menuitem.setAttribute( "type", "checkbox" ); + menuitem.setAttribute( "value", aValue ); + menuitem.setAttribute( "index", aIndex ); + if (aChecked==true) + menuitem.setAttribute( "checked", "true" ); + aParent.appendChild( menuitem ); + } + +function deleteHistoryItems( aParent ) + { + var children = aParent.childNodes; for (var i = 0; i < children.length; i++ ) { var index = children[i].getAttribute( "index" ); if (index) - aEvent.target.removeChild( children[i] ); + aParent.removeChild( children[i] ); } } function updateGoMenu(event) { - appCore.updateGoMenu(event.target); + FillHistoryMenu(event.target, "go"); }