mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 18:04:46 +00:00
Bug 997805 - Correctly restore the placeholder text after the editor object is re-attached to a text control as a result of a reframe; r=bzbarsky
Recomputing the placeholder visibility does not require the placeholder div itself to be present, as the only information required for that is the current value of the text control which is present either way. This patch fixes nsTextEditorState::ValueWasChanged and nsTextEditorState::UpdatePlaceholderVisibility to that effect. But the real fix is in nsTextEditorState::UpdatePlaceholderText, where after setting the placeholder text on the anonymous div, we redo the placeholder visibility computation. Since this function can be called from HTMLTextAreaElement::CreatePlaceholderNode during frame construction, the GetValue function may return the wrong value since the editor has not properly been set up yet, resulting in this bug. And this function call is useless anyway, because changing the placeholder text does not really affect the result of the visibility computation, so there is no need to do this work in the first place.
This commit is contained in:
parent
5820a8c792
commit
298702866a
@ -1940,11 +1940,6 @@ nsTextEditorState::InitializeKeyboardEventListeners()
|
||||
void
|
||||
nsTextEditorState::ValueWasChanged(bool aNotify)
|
||||
{
|
||||
// placeholder management
|
||||
if (!mPlaceholderDiv) {
|
||||
return;
|
||||
}
|
||||
|
||||
UpdatePlaceholderVisibility(aNotify);
|
||||
}
|
||||
|
||||
@ -1965,15 +1960,11 @@ nsTextEditorState::UpdatePlaceholderText(bool aNotify)
|
||||
nsContentUtils::RemoveNewlines(placeholderValue);
|
||||
NS_ASSERTION(mPlaceholderDiv->GetFirstChild(), "placeholder div has no child");
|
||||
mPlaceholderDiv->GetFirstChild()->SetText(placeholderValue, aNotify);
|
||||
ValueWasChanged(aNotify);
|
||||
}
|
||||
|
||||
void
|
||||
nsTextEditorState::UpdatePlaceholderVisibility(bool aNotify)
|
||||
{
|
||||
NS_ASSERTION(mPlaceholderDiv, "This function should not be called if "
|
||||
"mPlaceholderDiv isn't set");
|
||||
|
||||
nsAutoString value;
|
||||
GetValue(value, true);
|
||||
|
||||
|
2
editor/reftests/997805-ref.html
Normal file
2
editor/reftests/997805-ref.html
Normal file
@ -0,0 +1,2 @@
|
||||
<!DOCTYPE html>
|
||||
<textarea placeholder="placeholder"></textarea>
|
16
editor/reftests/997805.html
Normal file
16
editor/reftests/997805.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="reftest-wait">
|
||||
<textarea placeholder="placeholder"></textarea>
|
||||
<script>
|
||||
onload = function() {
|
||||
var t = document.querySelector("textarea");
|
||||
t.style.display = "none";
|
||||
t.value = "test";
|
||||
setTimeout(function() {
|
||||
t.style.display = "";
|
||||
t.value = "";
|
||||
document.documentElement.className = "";
|
||||
}, 0);
|
||||
};
|
||||
</script>
|
||||
</html>
|
@ -126,3 +126,4 @@ needs-focus == spellcheck-contenteditable-focused-reframe.html spellcheck-conten
|
||||
== spellcheck-contenteditable-property-dynamic-override.html spellcheck-contenteditable-disabled-ref.html
|
||||
== spellcheck-contenteditable-property-dynamic-override-inherit.html spellcheck-contenteditable-disabled-ref.html
|
||||
needs-focus == 969773.html 969773-ref.html
|
||||
== 997805.html 997805-ref.html
|
||||
|
Loading…
Reference in New Issue
Block a user