Bug 1360162 - Don't call UpdateOverlayTextVisibility twice by input.value setter when input element has focus. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Wed, 21 Jun 2017 13:10:58 +0900
changeset 598723 9bacb74dc2b1eecc0e6857cecd3ddb1428768bb4
parent 598698 f8bb96fb5c4f9960c5f754f877eceb677df18ddc
child 634558 1cf67e2cfcd1af630f14cbc5421babe4b85449b6
push id65297
push userm_kato@ga2.so-net.ne.jp
push dateThu, 22 Jun 2017 05:05:23 +0000
reviewersmasayuki
bugs1360162
milestone56.0a1
Bug 1360162 - Don't call UpdateOverlayTextVisibility twice by input.value setter when input element has focus. r?masayuki When editor has focus, input.value setter will call UpdateOverlayTextVisibility via nsTextInputListener::EditAction -> nsTextControlFrame::SetValueChanged at first. But SetValue will call UpdateOverlayTextVisibility again via ValueWasChanged. So it is unnecessary to call UpdateOverlayTextVisibility on nsTextEditorState::SetValue when we have the editor. MozReview-Commit-ID: Hw3Bh64Euo6
dom/html/nsTextEditorState.cpp
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -2690,16 +2690,21 @@ nsTextEditorState::SetValue(const nsAStr
               domSel->RemoveAllRanges();
             }
 
             plaintextEditor->SetText(newValue);
           }
 
           mTextListener->SetValueChanged(true);
           mTextListener->SettingValue(false);
+
+          if (!notifyValueChanged) {
+            // Listener doesn't update frame, but it is required for placeholder
+            ValueWasChanged(true);
+          }
         }
 
         if (!weakFrame.IsAlive()) {
           // If the frame was destroyed because of a flush somewhere inside
           // InsertText, mBoundFrame here will be false.  But it's also possible
           // for the frame to go away because of another reason (such as deleting
           // the existing selection -- see bug 574558), in which case we don't
           // need to reset the value here.
@@ -2752,22 +2757,22 @@ nsTextEditorState::SetValue(const nsAStr
       // our SelectionProperties dirty to make accessibility tests happy.
       // Probably because they depend on the SetSelectionRange() call we make on
       // our frame in RestoreSelectionState, but I have no idea why they do.
       if (IsSelectionCached()) {
         SelectionProperties& props = GetSelectionProperties();
         props.SetIsDirty();
       }
     }
+
+    // If we've reached the point where the root node has been created, we
+    // can assume that it's safe to notify.
+    ValueWasChanged(!!mRootNode);
   }
 
-  // If we've reached the point where the root node has been created, we
-  // can assume that it's safe to notify.
-  ValueWasChanged(!!mRootNode);
-
   mTextCtrlElement->OnValueChanged(/* aNotify = */ !!mRootNode,
                                    /* aWasInteractiveUserChange = */ false);
 
   return true;
 }
 
 bool
 nsTextEditorState::HasNonEmptyValue()