Bug 1088158 - Update the visibility state of placeholders for textareas correctly when they get their anonymous content; r=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 28 Oct 2014 09:44:26 -0400
changeset 237001 178efc7a2007b169fb6875b8bcce88ad06e9defd
parent 237000 bc42f690b6268ef3942cff66c008b0d24bb4116e
child 237002 1c53d6dbd26395144b943d41a916b9dadcf9fa1d
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1088158
milestone36.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 1088158 - Update the visibility state of placeholders for textareas correctly when they get their anonymous content; r=roc
editor/reftests/1088158-ref.html
editor/reftests/1088158.html
editor/reftests/reftest.list
layout/forms/nsTextControlFrame.cpp
new file mode 100644
--- /dev/null
+++ b/editor/reftests/1088158-ref.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<textarea placeholder="placeholder"></textarea>
new file mode 100644
--- /dev/null
+++ b/editor/reftests/1088158.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<script>
+  onload = function() {
+    var t = document.createElement('textarea');
+    t.placeholder = "placeholder";
+    document.body.appendChild(t.cloneNode(true));
+  }
+</script>
--- a/editor/reftests/reftest.list
+++ b/editor/reftests/reftest.list
@@ -122,8 +122,9 @@ needs-focus == spellcheck-contenteditabl
 == spellcheck-contenteditable-property-dynamic.html spellcheck-contenteditable-disabled-ref.html
 == spellcheck-contenteditable-property-dynamic-inherit.html spellcheck-contenteditable-disabled-ref.html
 == spellcheck-contenteditable-attr-dynamic-override.html spellcheck-contenteditable-disabled-ref.html
 == spellcheck-contenteditable-attr-dynamic-override-inherit.html spellcheck-contenteditable-disabled-ref.html
 == 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
+== 1088158.html 1088158-ref.html
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -346,16 +346,23 @@ nsTextControlFrame::CreateAnonymousConte
       PresContext()->StyleSet()->ResolvePseudoElementStyle(
           mContent->AsElement(), pseudoType, StyleContext(),
           placeholderNode->AsElement());
 
     if (!aElements.AppendElement(ContentInfo(placeholderNode,
                                  placeholderStyleContext))) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
+
+    if (!IsSingleLineTextControl()) {
+      // For textareas, UpdateValueDisplay doesn't initialize the visibility
+      // status of the placeholder because it returns early, so we have to
+      // do that manually here.
+      txtCtrl->UpdatePlaceholderVisibility(true);
+    }
   }
 
   rv = UpdateValueDisplay(false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // textareas are eagerly initialized
   bool initEagerly = !IsSingleLineTextControl();
   if (!initEagerly) {