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
--- 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()