Ignore <input> and <textarea>'s user-select styling

Background:
The CSS spec says that user-select does "selective inheritance",
see https://drafts.csswg.org/css-ui-4/#propdef-user-select.

<input> and <textarea> are two elements that are affected
by this. These elements should not inherit user-select from
parent elements.

Fixed problem:
<input|textarea readonly|disabled> could inherit
"user-select: none".

This regressed because
https://chromium-review.googlesource.com/570246
removed input|textarea's default user-select styling.

Solution:
Make all text controls always selectable. This is done in
LayoutTextControl::AdjustInnerEditorStyle.

Interoperability note:
<input readonly style="user-select: none"
value="Chrome 61 cannot select this.">. This CL fixes
this by ensuring that all text fields (i.e also readonly fields)
are always selectable (no matter user-select styling).

In other words, <input> and <input readonly> now behave in
the same way (both always allow selections) which aligns
us with Firefox and Edge.

BUG=761433, 764316
TBR=hugoh@opera.com

(cherry picked from commit ba7c210328c00a6693ddc5da6504f8520bb3bdc2)

Change-Id: I89fc94a2a04caf3a87b12a9071081dafd48a8727
Reviewed-on: https://chromium-review.googlesource.com/663217
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Hugo Holgersson <hugoh@opera.com>
Cr-Original-Commit-Position: refs/heads/master@{#503793}
Reviewed-on: https://chromium-review.googlesource.com/685655
Reviewed-by: Hugo Holgersson <hugoh@opera.com>
Cr-Commit-Position: refs/branch-heads/3202@{#453}
Cr-Branched-From: fa6a5d87adff761bc16afc5498c3f5944c1daa68-refs/heads/master@{#499098}
diff --git a/third_party/WebKit/Source/core/input/EventHandlerTest.cpp b/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
index 73eb50f..cfc9199 100644
--- a/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
+++ b/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
@@ -429,6 +429,28 @@
                                                                          hit));
 }
 
+TEST_F(EventHandlerTest, ReadOnlyInputDoesNotInheritUserSelect) {
+  SetHtmlInnerHTML(
+      "<div style='user-select: none'>"
+      "<input readonly value='blabla'>"
+      "</div>");
+  Element* const field =
+      ToElement(GetDocument().body()->firstChild()->firstChild());
+  ShadowRoot* const shadow_root = field->UserAgentShadowRoot();
+
+  Element* const text = shadow_root->getElementById("inner-editor");
+  LayoutPoint location = text->GetLayoutObject()->VisualRect().Center();
+  HitTestResult hit =
+      GetDocument().GetFrame()->GetEventHandler().HitTestResultAtPoint(
+          location);
+  EXPECT_TRUE(text->CanStartSelection());
+
+  // TODO(crbug.com/764661): Show I-beam because field is selectable.
+  // EXPECT_TRUE(
+  //   GetDocument().GetFrame()->GetEventHandler().ShouldShowIBeamForNode(field,
+  //                                                                      hit));
+}
+
 TEST_F(EventHandlerTest, ImagesCannotStartSelection) {
   SetHtmlInnerHTML("<img>");
   Element* const img = ToElement(GetDocument().body()->firstChild());
diff --git a/third_party/WebKit/Source/core/layout/LayoutTextControl.cpp b/third_party/WebKit/Source/core/layout/LayoutTextControl.cpp
index 706c45f..b623ea8 100644
--- a/third_party/WebKit/Source/core/layout/LayoutTextControl.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutTextControl.cpp
@@ -79,6 +79,7 @@
   // element.
   text_block_style.SetDirection(Style()->Direction());
   text_block_style.SetUnicodeBidi(Style()->GetUnicodeBidi());
+  text_block_style.SetUserSelect(EUserSelect::kText);
 
   UpdateUserModifyProperty(*GetTextControlElement(), text_block_style);
 }