Bug 570893 - Only re-enable the form controls when reload, not re-disable it, r=bz draft
authorTimothy Guan-tin Chien <timdream@gmail.com>
Fri, 30 Dec 2016 14:26:35 +0800
changeset 455199 8da18d0af18115caa17617bac87011d3b74ea9cd
parent 454351 143bb4b9249e528e658f6ccc449991794b8675f8
child 540911 17eb5c55fa2dd68bb6b7bc4ce125d94f1cd0fb2d
push id40153
push userbmo:timdream@gmail.com
push dateTue, 03 Jan 2017 02:46:38 +0000
reviewersbz
bugs570893
milestone53.0a1
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
dom/html/HTMLButtonElement.cpp
dom/html/HTMLInputElement.cpp
dom/html/HTMLSelectElement.cpp
dom/html/HTMLTextAreaElement.cpp
--- 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
 {