Bug 1600536 - user-select: auto on input / textarea should behave as text. r=mats
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 09 Dec 2019 18:16:57 +0000
changeset 506134 964b6feba6a475508002c1c7a9f0484fe9a3035d
parent 506133 fcbd865d22bc4301fd560663249e23e922191a89
child 506135 922cb699c35184ba8825d404480a1fa873bbb11b
push id36896
push usernbeleuzu@mozilla.com
push dateMon, 09 Dec 2019 21:50:19 +0000
treeherdermozilla-central@86afe431ec55 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1600536
milestone73.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 1600536 - user-select: auto on input / textarea should behave as text. r=mats This is covered by existing tests, via the removal of the rule in forms.css Differential Revision: https://phabricator.services.mozilla.com/D56355
layout/generic/nsFrame.cpp
layout/style/res/forms.css
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -4459,19 +4459,20 @@ static StyleUserSelect UsedUserSelect(co
   //
   // Also, we check for auto first to allow explicitly overriding the value for
   // the editing host.
   auto style = aFrame->StyleUIReset()->mUserSelect;
   if (style != StyleUserSelect::Auto) {
     return style;
   }
 
-  if (IsEditingHost(aFrame)) {
+  if (aFrame->IsTextInputFrame() || IsEditingHost(aFrame)) {
     // We don't implement 'contain' itself, but we make 'text' behave as
-    // 'contain' for contenteditable elements anyway so this is ok.
+    // 'contain' for contenteditable and <input> / <textarea> elements anyway so
+    // this is ok.
     return StyleUserSelect::Text;
   }
 
   auto* parent = nsLayoutUtils::GetParentOrPlaceholderFor(aFrame);
   return parent ? UsedUserSelect(parent) : StyleUserSelect::Text;
 }
 
 bool nsIFrame::IsSelectable(StyleUserSelect* aSelectStyle) const {
--- a/layout/style/res/forms.css
+++ b/layout/style/res/forms.css
@@ -94,17 +94,16 @@ input {
      internal padding magic) */
   padding: 1px;
   border: 2px inset ThreeDLightShadow;
   background-color: -moz-Field;
   color: -moz-FieldText;
   font: -moz-field;
   text-rendering: optimizeLegibility;
   cursor: text;
-  user-select: text;
   overflow-clip-box: padding-box content-box;
 }
 
 input > .anonymous-div,
 input::placeholder {
   word-wrap: normal;
   /* Make the line-height equal to the available height */
   line-height: -moz-block-height;
@@ -120,17 +119,16 @@ textarea {
   padding-inline-end: 1px;
   background-color: -moz-Field;
   color: -moz-FieldText;
   font: medium -moz-fixed;
   text-rendering: optimizeLegibility;
   vertical-align: text-bottom;
   cursor: text;
   resize: both;
-  user-select: text;
   white-space: pre-wrap;
   word-wrap: break-word;
   overflow-clip-box: content-box;
 }
 
 /* A few properties that we don't want to inherit by default: */
 input, textarea, select, button {
   text-align: initial;