зеркало из https://github.com/mozilla/gecko-dev.git
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
This commit is contained in:
Родитель
2261960f15
Коммит
a5fca72c45
|
@ -18,7 +18,8 @@
|
||||||
* Rights Reserved.
|
* Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Blake Ross <BlakeR1234@aol.com>
|
* Blake Ross <BlakeR1234@aol.com>
|
||||||
|
* Peter Annema <disttsc@bart.nl>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var pref = null;
|
var pref = null;
|
||||||
|
@ -63,6 +64,8 @@ catch (ex)
|
||||||
var backButton = null;
|
var backButton = null;
|
||||||
var forwardButton = null;
|
var forwardButton = null;
|
||||||
|
|
||||||
|
var webNavigation = null;
|
||||||
|
|
||||||
var useRealProgressFlag = false;
|
var useRealProgressFlag = false;
|
||||||
var totalRequests = 0;
|
var totalRequests = 0;
|
||||||
var finishedRequests = 0;
|
var finishedRequests = 0;
|
||||||
|
@ -424,6 +427,14 @@ function Startup()
|
||||||
contentArea.addEventListener("load",postURLToNativeWidget, true);
|
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");
|
dump("*** Pulling out the charset\n");
|
||||||
if ( window.arguments && window.arguments[1] ) {
|
if ( window.arguments && window.arguments[1] ) {
|
||||||
if (window.arguments[1].indexOf('charset=') != -1) {
|
if (window.arguments[1].indexOf('charset=') != -1) {
|
||||||
|
@ -603,15 +614,13 @@ function BrowserForward()
|
||||||
|
|
||||||
function BrowserBackMenu(event)
|
function BrowserBackMenu(event)
|
||||||
{
|
{
|
||||||
//FillHistoryMenu(event.target, "back");
|
FillHistoryMenu(event.target, "back");
|
||||||
appCore.backButtonPopup(event.target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function BrowserForwardMenu(event)
|
function BrowserForwardMenu(event)
|
||||||
{
|
{
|
||||||
//FillHistoryMen(event.target, "forward");
|
FillHistoryMenu(event.target, "forward");
|
||||||
appCore.forwardButtonPopup(event.target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -278,7 +278,7 @@ Contributor(s): ______________________________________. -->
|
||||||
</box>
|
</box>
|
||||||
<menubutton class="menubutton-icon" id="ubhist">
|
<menubutton class="menubutton-icon" id="ubhist">
|
||||||
<menupopup id="ubhist-popup" popupalign="topright" popupanchor="bottomright"
|
<menupopup id="ubhist-popup" popupalign="topright" popupanchor="bottomright"
|
||||||
oncreate="createUBHistoryMenu(event);" oncommand="executeUrlBarHistoryCommand(event.target);">
|
oncreate="createUBHistoryMenu(event.target);" oncommand="executeUrlBarHistoryCommand(event.target);">
|
||||||
<menuitem value=" "/>
|
<menuitem value=" "/>
|
||||||
</menupopup>
|
</menupopup>
|
||||||
</menubutton>
|
</menubutton>
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
* Rights Reserved.
|
* Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Jason Eager <jce2@po.cwru.edu>
|
* Jason Eager <jce2@po.cwru.edu>
|
||||||
* (Some other netscape person who forgot to put the NPL header!)
|
* Blake Ross <BlakeR1234@aol.com>
|
||||||
|
* Peter Annema <disttsc@bart.nl>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const MAX_HISTORY_MENU_ITEMS = 15;
|
const MAX_HISTORY_MENU_ITEMS = 15;
|
||||||
|
@ -29,55 +30,44 @@ var localstore = rdf.GetDataSource("rdf:localstore");
|
||||||
|
|
||||||
function FillHistoryMenu( aParent, aMenu )
|
function FillHistoryMenu( aParent, aMenu )
|
||||||
{
|
{
|
||||||
var shistory;
|
if (webNavigation)
|
||||||
// Get the content area docshell
|
|
||||||
var docShell = null;
|
|
||||||
var result = appCore.getContentDocShell(docShell);
|
|
||||||
if (docShell)
|
|
||||||
{
|
{
|
||||||
//Get the session history component from docshell
|
var shistory = webNavigation.sessionHistory;
|
||||||
docShell = docShell.QueryInterface(Components.interfaces.nsIWebNavigation);
|
if (shistory)
|
||||||
if (docShell)
|
|
||||||
{
|
{
|
||||||
shistory = docShell.sessionHistory;
|
//Remove old entries if any
|
||||||
if (shistory)
|
deleteHistoryItems( aParent );
|
||||||
|
var count = shistory.count;
|
||||||
|
var index = shistory.index;
|
||||||
|
switch (aMenu)
|
||||||
{
|
{
|
||||||
//Remove old entries if any
|
case "back":
|
||||||
deleteHistoryItems( aParent );
|
var end = (index > MAX_HISTORY_MENU_ITEMS) ? index - MAX_HISTORY_MENU_ITEMS : 0;
|
||||||
var count = shistory.count;
|
for ( var j = index - 1; j >= end; j--)
|
||||||
var index = shistory.index;
|
{
|
||||||
switch (aMenu)
|
var entry = shistory.getEntryAtIndex(j, false);
|
||||||
{
|
if (entry)
|
||||||
case "back":
|
createMenuItem( aParent, j, entry.title );
|
||||||
var end = (index > MAX_HISTORY_MENU_ITEMS) ? index - MAX_HISTORY_MENU_ITEMS : 0;
|
}
|
||||||
for ( var j = index - 1; j >= end; j--)
|
break;
|
||||||
{
|
case "forward":
|
||||||
var entry = shistory.getEntryAtIndex(j, false);
|
var end = ((count-index) > MAX_HISTORY_MENU_ITEMS) ? index + MAX_HISTORY_MENU_ITEMS : count;
|
||||||
if (entry)
|
for ( var j = index + 1; j < end; j++)
|
||||||
createMenuItem( aParent, j, entry.getTitle() );
|
{
|
||||||
}
|
var entry = shistory.getEntryAtIndex(j, false);
|
||||||
break;
|
if (entry)
|
||||||
case "forward":
|
createMenuItem( aParent, j, entry.title );
|
||||||
var end = ((count-index) > MAX_HISTORY_MENU_ITEMS) ? index + MAX_HISTORY_MENU_ITEMS : count;
|
}
|
||||||
for ( var j = index + 1; j < end; j++)
|
break;
|
||||||
{
|
case "go":
|
||||||
var entry = shistory.getEntryAtIndex(j, false);
|
var end = count > MAX_HISTORY_MENU_ITEMS ? count - MAX_HISTORY_MENU_ITEMS : 0;
|
||||||
if (entry)
|
for( var j = count - 1; j >= end; j-- )
|
||||||
createMenuItem( aParent, j, entry.getTitle() );
|
{
|
||||||
}
|
var entry = shistory.getEntryAtIndex(j, false);
|
||||||
break;
|
if (entry)
|
||||||
case "go":
|
createCheckboxMenuItem( aParent, j, entry.title, j==index );
|
||||||
var end = count > MAX_HISTORY_MENU_ITEMS
|
}
|
||||||
? count - MAX_HISTORY_MENU_ITEMS
|
break;
|
||||||
: 0;
|
|
||||||
for( var j = count - 1; j >= end; j-- )
|
|
||||||
{
|
|
||||||
var entry = shistory.getEntryAtIndex(j, false);
|
|
||||||
if (entry)
|
|
||||||
createMenuItem( aParent, j, entry.getTitle() );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +84,7 @@ function executeUrlBarHistoryCommand( aTarget)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createUBHistoryMenu( aEvent )
|
function createUBHistoryMenu( aParent )
|
||||||
{
|
{
|
||||||
var ubHistory = appCore.urlbarHistory;
|
var ubHistory = appCore.urlbarHistory;
|
||||||
// dump("In createUbHistoryMenu\n");
|
// dump("In createUbHistoryMenu\n");
|
||||||
|
@ -105,7 +95,7 @@ function createUBHistoryMenu( aEvent )
|
||||||
//dump("localstore found\n");
|
//dump("localstore found\n");
|
||||||
var i= MAX_HISTORY_MENU_ITEMS;
|
var i= MAX_HISTORY_MENU_ITEMS;
|
||||||
// Delete any old menu items
|
// Delete any old menu items
|
||||||
deleteHistoryItems(aEvent);
|
deleteHistoryItems(aParent);
|
||||||
|
|
||||||
while (entries.hasMoreElements() && (i-- > 0)) {
|
while (entries.hasMoreElements() && (i-- > 0)) {
|
||||||
var entry = entries.getNext();
|
var entry = entries.getNext();
|
||||||
|
@ -113,7 +103,7 @@ function createUBHistoryMenu( aEvent )
|
||||||
entry = entry.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
entry = entry.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
||||||
var url = entry.Value;
|
var url = entry.Value;
|
||||||
//dump("CREATEUBHISTORYMENU menuitem = " + url + "\n");
|
//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 );
|
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++ )
|
for (var i = 0; i < children.length; i++ )
|
||||||
{
|
{
|
||||||
var index = children[i].getAttribute( "index" );
|
var index = children[i].getAttribute( "index" );
|
||||||
if (index)
|
if (index)
|
||||||
aEvent.target.removeChild( children[i] );
|
aParent.removeChild( children[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateGoMenu(event)
|
function updateGoMenu(event)
|
||||||
{
|
{
|
||||||
appCore.updateGoMenu(event.target);
|
FillHistoryMenu(event.target, "go");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче