From 44609e49cca04bd158ceecf5f0967ae3bed4a50e Mon Sep 17 00:00:00 2001 From: "gavin%gavinsharp.com" Date: Wed, 1 Feb 2006 15:22:15 +0000 Subject: [PATCH] Bug 324354: Ctrl-Z (undo) reveals visited URLs AFTER clearing history, patch by Martijn Wargers , r=mconnor --- browser/base/content/browser.js | 12 ++++++++++++ browser/base/content/sanitize.js | 13 +++++++++++++ browser/base/content/search.xml | 6 +++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 3947b93e3cb0..755af0a019e5 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -242,6 +242,18 @@ const gSessionHistoryObserver = { backCommand.setAttribute("disabled", "true"); var fwdCommand = document.getElementById("Browser:Forward"); fwdCommand.setAttribute("disabled", "true"); + + //Clear undo history of all URL Bars + var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(); + var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator); + var windows = windowManagerInterface.getEnumerator("navigator:browser"); + while (windows.hasMoreElements()) { + var urlBar = windows.getNext().gURLBar; + if (urlBar) { + urlBar.editor.enableUndo(false); + urlBar.editor.enableUndo(true); + } + } } }; diff --git a/browser/base/content/sanitize.js b/browser/base/content/sanitize.js index 99af9a3e68fb..31026c11423e 100644 --- a/browser/base/content/sanitize.js +++ b/browser/base/content/sanitize.js @@ -151,6 +151,19 @@ Sanitizer.prototype = { formdata: { clear: function () { + //Clear undo history of all searchBars + var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(); + var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator); + var windows = windowManagerInterface.getEnumerator("navigator:browser"); + while (windows.hasMoreElements()) { + var searchBar = windows.getNext().document.getElementById("searchbar"); + if (searchBar) { + searchBar.mTextbox.value = ""; + searchBar.mTextbox.editor.enableUndo(false); + searchBar.mTextbox.editor.enableUndo(true); + } + } + var formHistory = Components.classes["@mozilla.org/satchel/form-history;1"] .getService(Components.interfaces.nsIFormHistory); formHistory.removeAllEntries(); diff --git a/browser/base/content/search.xml b/browser/base/content/search.xml index 2c9cecf28430..fa67c8ae8364 100644 --- a/browser/base/content/search.xml +++ b/browser/base/content/search.xml @@ -389,9 +389,13 @@ doCommand: function (aCommand) { + // Clear the searchbar and its undo history + this.mOuter.value = ""; + this.mOuter.editor.enableUndo(false); + this.mOuter.editor.enableUndo(true); + this.mOuter.formHistSvc.removeEntriesForName( this.mOuter.getAttribute("autocompletesearchparam")); - this.mOuter.value = ""; } }) ]]>