Bug 93972: Don't save form control values in session history if they have an autocomplete attribute set to off, or if their containing form has an autocomplete attribute set to off. This is accomplished by returning an empty 'state key' which indicates that the state should not be stored in session history's hash table. r/sr=jst@netscape.com,vidur@netscape.com

This commit is contained in:
pollmann%netscape.com 2001-08-16 07:18:24 +00:00
Родитель db2a4e9803
Коммит 0e7a2eacd9
2 изменённых файлов: 38 добавлений и 0 удалений

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

@ -67,6 +67,7 @@
#include "nsIDOMHTMLFormElement.h"
#include "nsIForm.h"
#include "nsIContentList.h"
#include "nsReadableUtils.h"
#define NEW_CONTEXT_PARENTAGE_INVARIANT
@ -2298,6 +2299,14 @@ static inline void KeyAppendAtom(nsIAtom* aAtom, nsCString& aKey)
KeyAppendString(nsDependentString(atomString), aKey);
}
static inline PRBool IsAutocompleteOff(nsIDOMElement* aElement)
{
nsAutoString autocomplete;
aElement->GetAttribute(NS_LITERAL_STRING("autocomplete"), autocomplete);
ToLowerCase(autocomplete);
return autocomplete.Equals(NS_LITERAL_STRING("off"));
}
NS_IMETHODIMP
FrameManager::GenerateStateKey(nsIContent* aContent,
nsIStatefulFrame::SpecialStateID aID,
@ -2322,6 +2331,11 @@ FrameManager::GenerateStateKey(nsIContent* aContent,
return NS_OK;
}
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(aContent));
if (element && IsAutocompleteOff(element)) {
return NS_OK;
}
// If we have a dom element, add tag/type/name to hash key
// This is paranoia, but guarantees that we won't restore
// state to the wrong type of control.
@ -2355,6 +2369,11 @@ FrameManager::GenerateStateKey(nsIContent* aContent,
control->GetForm(getter_AddRefs(formElement));
if (formElement) {
if (IsAutocompleteOff(formElement)) {
aKey.Truncate();
return NS_OK;
}
nsAutoString formName;
formElement->GetName(formName);
KeyAppendString(formName, aKey);

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

@ -67,6 +67,7 @@
#include "nsIDOMHTMLFormElement.h"
#include "nsIForm.h"
#include "nsIContentList.h"
#include "nsReadableUtils.h"
#define NEW_CONTEXT_PARENTAGE_INVARIANT
@ -2298,6 +2299,14 @@ static inline void KeyAppendAtom(nsIAtom* aAtom, nsCString& aKey)
KeyAppendString(nsDependentString(atomString), aKey);
}
static inline PRBool IsAutocompleteOff(nsIDOMElement* aElement)
{
nsAutoString autocomplete;
aElement->GetAttribute(NS_LITERAL_STRING("autocomplete"), autocomplete);
ToLowerCase(autocomplete);
return autocomplete.Equals(NS_LITERAL_STRING("off"));
}
NS_IMETHODIMP
FrameManager::GenerateStateKey(nsIContent* aContent,
nsIStatefulFrame::SpecialStateID aID,
@ -2322,6 +2331,11 @@ FrameManager::GenerateStateKey(nsIContent* aContent,
return NS_OK;
}
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(aContent));
if (element && IsAutocompleteOff(element)) {
return NS_OK;
}
// If we have a dom element, add tag/type/name to hash key
// This is paranoia, but guarantees that we won't restore
// state to the wrong type of control.
@ -2355,6 +2369,11 @@ FrameManager::GenerateStateKey(nsIContent* aContent,
control->GetForm(getter_AddRefs(formElement));
if (formElement) {
if (IsAutocompleteOff(formElement)) {
aKey.Truncate();
return NS_OK;
}
nsAutoString formName;
formElement->GetName(formName);
KeyAppendString(formName, aKey);