Bug 639733 - Include the tag name in the frame state key. r=bzbarsky

This commit is contained in:
Mats Palmgren 2011-04-06 13:32:31 +02:00
parent cba5eb782d
commit ce7e2319e4
2 changed files with 20 additions and 8 deletions

View File

@ -2138,10 +2138,16 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
if (!generatedUniqueKey) {
// Either we didn't have a form control or we aren't in an HTML document so
// we can't figure out form info. First append a character that is not "d"
// or "f" to disambiguate from the case when we were a form control in an
// HTML document.
// we can't figure out form info. Append the tag name if it's an element
// to avoid restoring state for one type of element on another type.
if (aContent->IsElement()) {
KeyAppendString(nsDependentAtomString(aContent->Tag()), aKey);
}
else {
// Append a character that is not "d" or "f" to disambiguate from
// the case when we were a form control in an HTML document.
KeyAppendString(NS_LITERAL_CSTRING("o"), aKey);
}
// Now start at aContent and append the indices of it and all its ancestors
// in their containers. That should at least pin down its position in the

View File

@ -527,11 +527,12 @@ nsIsIndexFrame::SaveState(SpecialStateID aStateID, nsPresState** aState)
{
NS_ENSURE_ARG_POINTER(aState);
*aState = nsnull;
// Get the value string
nsAutoString stateString;
GetInputValue(stateString);
nsresult res = NS_OK;
if (! stateString.IsEmpty()) {
// Construct a pres state and store value in it.
@ -549,7 +550,7 @@ nsIsIndexFrame::SaveState(SpecialStateID aStateID, nsPresState** aState)
(*aState)->SetStateProperty(state);
}
return res;
return NS_OK;
}
NS_IMETHODIMP
@ -561,6 +562,11 @@ nsIsIndexFrame::RestoreState(nsPresState* aState)
nsCOMPtr<nsISupportsString> stateString
(do_QueryInterface(aState->GetStateProperty()));
if (!stateString) {
NS_ERROR("Not a <isindex> state!");
return NS_ERROR_FAILURE;
}
nsAutoString data;
stateString->GetData(data);
SetInputValue(data);