#413: M1374117 M1360162

This commit is contained in:
Cameron Kaiser 2017-07-02 19:37:42 -07:00
parent 320e8fda0a
commit ee8f682ebc

View File

@ -2120,6 +2120,11 @@ nsTextEditorState::SetValue(const nsAString& aValue, uint32_t aFlags)
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
@ -2163,11 +2168,11 @@ nsTextEditorState::SetValue(const nsAString& aValue, uint32_t aFlags)
if (mBoundFrame) {
mBoundFrame->UpdateValueDisplay(true);
}
}
// 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(!!mRootNode);
@ -2245,8 +2250,15 @@ nsTextEditorState::UpdatePlaceholderVisibility(bool aNotify)
mPlaceholderVisibility = value.IsEmpty();
if (mPlaceholderVisibility &&
!Preferences::GetBool("dom.placeholder.show_on_focus", true)) {
static bool sPrefCached = false;
static bool sPrefShowOnFocus = true;
if (!sPrefCached) {
sPrefCached = true;
Preferences::AddBoolVarCache(&sPrefShowOnFocus,
"dom.placeholder.show_on_focus", true);
}
if (mPlaceholderVisibility && !sPrefShowOnFocus) {
nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement);
mPlaceholderVisibility = !nsContentUtils::IsFocusedContent(content);
}