Bug 1320200 - Propagate scroll-behavior on a text input to the anonymous scrollable <div> inside it. r=tnikkel draft
authorBotond Ballo <botond@mozilla.com>
Fri, 25 Nov 2016 19:39:17 -0500
changeset 444068 0db4979a2717d54da258dbd83c6be31fdb6c1537
parent 443220 34fce7c12173bdd6dda54c2ebf6d344252f1ac48
child 538230 3db6905e2b706d2ed5905d75828ca253424a2bc7
push id37190
push userbballo@mozilla.com
push dateSat, 26 Nov 2016 00:40:42 +0000
reviewerstnikkel
bugs1320200
milestone53.0a1
Bug 1320200 - Propagate scroll-behavior on a text input to the anonymous scrollable <div> inside it. r=tnikkel MozReview-Commit-ID: Cur3x41wAfU
dom/html/nsTextEditorState.cpp
layout/reftests/scrolling/reftest.list
layout/reftests/scrolling/scroll-behavior-textarea.html
layout/style/res/forms.css
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -1802,16 +1802,17 @@ nsTextEditorState::InitializeRootNode()
     // crash when the number of lines exceeds the height of the textarea and
     // setting -moz-hidden-unscrollable overflow (NS_STYLE_OVERFLOW_CLIP)
     // doesn't paint the caret for some reason.
     const nsStyleDisplay* disp = mBoundFrame->StyleDisplay();
     if (disp->mOverflowX != NS_STYLE_OVERFLOW_VISIBLE &&
         disp->mOverflowX != NS_STYLE_OVERFLOW_CLIP) {
       classValue.AppendLiteral(" inherit-overflow");
     }
+    classValue.AppendLiteral(" inherit-scroll-behavior");
   }
   nsresult rv = mRootNode->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
                                    classValue, false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return mBoundFrame->UpdateValueDisplay(false);
 }
 
--- a/layout/reftests/scrolling/reftest.list
+++ b/layout/reftests/scrolling/reftest.list
@@ -15,16 +15,17 @@ skip-if(Android) pref(layout.css.scroll-
 skip-if(Android) pref(layout.css.scroll-behavior.enabled,true) pref(layout.css.scroll-behavior.property-enabled,true) == scroll-behavior-3.html scroll-behavior-3.html?ref # see bug 1041833
 skip-if(Android) pref(layout.css.scroll-behavior.enabled,true) pref(layout.css.scroll-behavior.property-enabled,true) == scroll-behavior-4.html scroll-behavior-4.html?ref # see bug 1041833
 skip-if(Android) pref(layout.css.scroll-behavior.enabled,true) pref(layout.css.scroll-behavior.property-enabled,true) == scroll-behavior-5.html scroll-behavior-5.html?ref # see bug 1041833
 skip-if(Android) pref(layout.css.scroll-behavior.enabled,true) pref(layout.css.scroll-behavior.property-enabled,true) == scroll-behavior-6.html scroll-behavior-6.html?ref # see bug 1041833
 skip-if(Android) pref(layout.css.scroll-behavior.enabled,true) pref(layout.css.scroll-behavior.property-enabled,true) == scroll-behavior-7.html scroll-behavior-7.html?ref # see bug 1041833
 skip-if(Android) pref(layout.css.scroll-behavior.enabled,true) pref(layout.css.scroll-behavior.property-enabled,true) == scroll-behavior-8.html scroll-behavior-8.html?ref # see bug 1041833
 skip-if(Android) pref(layout.css.scroll-behavior.enabled,true) pref(layout.css.scroll-behavior.property-enabled,true) == scroll-behavior-9.html scroll-behavior-9.html?ref # see bug 1041833
 skip-if(Android) pref(layout.css.scroll-behavior.enabled,true) pref(layout.css.scroll-behavior.property-enabled,true) == scroll-behavior-10.html scroll-behavior-10.html?ref # see bug 1041833
+skip-if(Android) pref(layout.css.scroll-behavior.enabled,true) pref(layout.css.scroll-behavior.property-enabled,true) == scroll-behavior-textarea.html scroll-behavior-textarea.html?ref # see bug 1320200
 HTTP == simple-1.html simple-1.html?ref
 HTTP == subpixel-1.html#d subpixel-1-ref.html#d
 fuzzy-if(Android,4,120) HTTP == text-1.html text-1.html?ref
 fuzzy-if(Android,4,120) HTTP == text-2.html?up text-2.html?ref
 fuzzy-if(d2d,1,4) HTTP == transformed-1.html transformed-1.html?ref
 HTTP == transformed-1.html?up transformed-1.html?ref
 fuzzy-if(Android,5,20000) == uncovering-1.html uncovering-1-ref.html
 fuzzy-if(Android,5,20000) == uncovering-2.html uncovering-2-ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/scrolling/scroll-behavior-textarea.html
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML>
+<html class="reftest-wait">
+<head>
+    <meta charset="utf-8">
+    <title>Testcase for bug 1320200, smooth scrolling in textarea</title>
+    <style type="text/css">
+
+        html,body {
+            color: black;
+            background-color: white;
+            font-size: 16px;
+            padding: 0;
+            margin: 0;
+        }
+
+        #text {
+            width: 50px;
+            height: 50px;
+            overflow: scroll;
+            will-change: scroll-position;
+            scroll-behavior: smooth;
+        }
+
+    </style>
+</head>
+<body>
+  <textarea id="text">
+  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis odio est, cursus non adipiscing at, fringilla quis eros. Sed volutpat nibh sit amet ante molestie a vehicula nulla gravida. Mauris elementum cursus urna id vestibulum. Etiam volutpat odio tincidunt libero ullamcorper elementum. Suspendisse potenti. Ut ut arcu lorem. Integer mi sapien, porta a pharetra et, varius laoreet eros. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed ut mi at elit consequat aliquam id eu lectus. Etiam tincidunt diam et ante ullamcorper a convallis erat lobortis. Sed blandit ultrices dui et bibendum. Sed condimentum velit eget nibh rutrum cursus. Quisque pretium iaculis gravida.
+  </textarea>
+<script>
+  function doTest() {
+    if (document.location.search != '?ref') {
+      var e = document.getElementById("text");
+      e.scrollTop = e.scrollHeight;
+
+      // Interrupt any smooth scrolling
+      e.scrollLeft = e.scrollLeft;
+      e.scrollTop = e.scrollTop;
+    }
+    document.documentElement.removeAttribute("class");
+  }
+  window.addEventListener("MozReftestInvalidate", doTest, false);
+</script>
+</body>
+</html>
--- a/layout/style/res/forms.css
+++ b/layout/style/res/forms.css
@@ -184,16 +184,20 @@ input::placeholder {
 
 input > .anonymous-div.wrap {
   white-space: pre-wrap;
 }
 textarea > .anonymous-div.inherit-overflow,
 input > .anonymous-div.inherit-overflow {
   overflow: inherit;
 }
+textarea > .anonymous-div.inherit-scroll-behavior,
+input > .anonymous-div.inherit-scroll-behavior {
+  scroll-behavior: inherit;
+}
 
 input::placeholder,
 textarea::placeholder {
   /*
    * Changing display to inline can leads to broken behaviour and will assert.
    */
   display: inline-block !important;