Bug 570893 - Only re-enable the form controls when reload, not re-disable it, r=bz
authorTimothy Guan-tin Chien <timdream@gmail.com>
Fri, 30 Dec 2016 14:26:35 +0800
changeset 327840 17caae57fcd04392f755de11f39b0323141d2af4
parent 327795 1d58dd2e8476114149fd398568e38befbb7c1fd0
child 327841 141fe3b986cd80d7781545b24413462735c76545
push id85304
push userphilringnalda@gmail.com
push dateWed, 04 Jan 2017 02:47:06 +0000
treeherdermozilla-inbound@6176579defcb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs570893
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
 {