diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index 32cb28d72fe..26a7708071f 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -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 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); diff --git a/layout/html/base/src/nsFrameManager.cpp b/layout/html/base/src/nsFrameManager.cpp index 32cb28d72fe..26a7708071f 100644 --- a/layout/html/base/src/nsFrameManager.cpp +++ b/layout/html/base/src/nsFrameManager.cpp @@ -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 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);