Bug 570893 - Only re-enable the form controls when reload, not re-disable it, r=bz
With this patch, the disabled state is still kept in the nsPresState,
but we will only honor that if the state saved asks as to re-enable the
control.
The behavior is changed so that controls disabled by JavaScript will be
kept enabled as the JavaScript world gets reloaded.
MozReview-Commit-ID: 6PchHfx6KYX
--- a/dom/html/HTMLButtonElement.cpp
+++ b/dom/html/HTMLButtonElement.cpp
@@ -471,18 +471,18 @@ HTMLButtonElement::SaveState()
}
return NS_OK;
}
bool
HTMLButtonElement::RestoreState(nsPresState* aState)
{
- if (aState && aState->IsDisabledSet()) {
- SetDisabled(aState->GetDisabled());
+ if (aState && aState->IsDisabledSet() && !aState->GetDisabled()) {
+ SetDisabled(false);
}
return false;
}
EventStates
HTMLButtonElement::IntrinsicState() const
{
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -6994,18 +6994,18 @@ HTMLInputElement::RestoreState(nsPresSta
// may potentially be big, but most likely we've failed to allocate
// before the type change.)
SetValueInternal(inputState->GetValue(),
nsTextEditorState::eSetValue_Notify);
break;
}
}
- if (aState->IsDisabledSet()) {
- SetDisabled(aState->GetDisabled());
+ if (aState->IsDisabledSet() && !aState->GetDisabled()) {
+ SetDisabled(false);
}
return restoredCheckedState;
}
bool
HTMLInputElement::AllowDrop()
{
--- a/dom/html/HTMLSelectElement.cpp
+++ b/dom/html/HTMLSelectElement.cpp
@@ -1580,18 +1580,18 @@ HTMLSelectElement::RestoreState(nsPresSt
if (state) {
RestoreStateTo(state);
// Don't flush, if the frame doesn't exist yet it doesn't care if
// we're reset or not.
DispatchContentReset();
}
- if (aState->IsDisabledSet()) {
- SetDisabled(aState->GetDisabled());
+ if (aState->IsDisabledSet() && !aState->GetDisabled()) {
+ SetDisabled(false);
}
return false;
}
void
HTMLSelectElement::RestoreStateTo(SelectState* aNewSelected)
{
--- a/dom/html/HTMLTextAreaElement.cpp
+++ b/dom/html/HTMLTextAreaElement.cpp
@@ -1185,18 +1185,18 @@ HTMLTextAreaElement::RestoreState(nsPres
if (state) {
nsAutoString data;
state->GetData(data);
nsresult rv = SetValue(data);
NS_ENSURE_SUCCESS(rv, false);
}
- if (aState->IsDisabledSet()) {
- SetDisabled(aState->GetDisabled());
+ if (aState->IsDisabledSet() && !aState->GetDisabled()) {
+ SetDisabled(false);
}
return false;
}
EventStates
HTMLTextAreaElement::IntrinsicState() const
{