Title: [293028] trunk
Revision
293028
Author
[email protected]
Date
2022-04-19 11:23:50 -0700 (Tue, 19 Apr 2022)

Log Message

user-select: none shouldn't affect editability
https://bugs.webkit.org/show_bug.cgi?id=118009

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-ui/user-select-none-in-editable-expected.txt: Added.
* web-platform-tests/css/css-ui/user-select-none-in-editable.html: Added.
* web-platform-tests/css/css-ui/user-select-none-on-input-expected.txt: Added.
* web-platform-tests/css/css-ui/user-select-none-on-input.html: Added.

Source/WebCore:

Tests: editing/selection/user-select-js-property.html
       imported/w3c/web-platform-tests/css/css-ui/user-select-none-in-editable.html
       imported/w3c/web-platform-tests/css/css-ui/user-select-none-on-input.html

Change `effectiveUserSelect` to take in account `-webkit-user-modify`.

* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::effectiveUserSelect const):
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::effectiveUserSelect const): Deleted.

LayoutTests:

- Removed tests that were testing old behavior
- Added new tests for new behavior (imported from the Blink codebase)

* editing/selection/4866671.html: Removed.
* editing/selection/5779984-1-expected.txt: Removed.
* editing/selection/5779984-1.html: Removed.
* editing/selection/user-select-js-property-expected.txt: Added.
* editing/selection/user-select-js-property.html: Added.
* platform/gtk/editing/selection/4866671-expected.png: Removed.
* platform/gtk/editing/selection/4866671-expected.txt: Removed.
* platform/ios/TestExpectations:
* platform/ios/editing/selection/4866671-expected.txt: Removed.
* platform/mac/editing/selection/4866671-expected.png: Removed.
* platform/mac/editing/selection/4866671-expected.txt: Removed.
* platform/win/editing/selection/4866671-expected.txt: Removed.
* platform/wincairo/editing/selection/4866671-expected.txt: Removed.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (293027 => 293028)


--- trunk/LayoutTests/ChangeLog	2022-04-19 18:15:28 UTC (rev 293027)
+++ trunk/LayoutTests/ChangeLog	2022-04-19 18:23:50 UTC (rev 293028)
@@ -1,5 +1,29 @@
 2022-04-19  Tim Nguyen  <[email protected]>
 
+        user-select: none shouldn't affect editability
+        https://bugs.webkit.org/show_bug.cgi?id=118009
+
+        Reviewed by Antti Koivisto.
+
+        - Removed tests that were testing old behavior
+        - Added new tests for new behavior (imported from the Blink codebase)
+
+        * editing/selection/4866671.html: Removed.
+        * editing/selection/5779984-1-expected.txt: Removed.
+        * editing/selection/5779984-1.html: Removed.
+        * editing/selection/user-select-js-property-expected.txt: Added.
+        * editing/selection/user-select-js-property.html: Added.
+        * platform/gtk/editing/selection/4866671-expected.png: Removed.
+        * platform/gtk/editing/selection/4866671-expected.txt: Removed.
+        * platform/ios/TestExpectations:
+        * platform/ios/editing/selection/4866671-expected.txt: Removed.
+        * platform/mac/editing/selection/4866671-expected.png: Removed.
+        * platform/mac/editing/selection/4866671-expected.txt: Removed.
+        * platform/win/editing/selection/4866671-expected.txt: Removed.
+        * platform/wincairo/editing/selection/4866671-expected.txt: Removed.
+
+2022-04-19  Tim Nguyen  <[email protected]>
+
         [iOS] Also skip resize-orthogonal-containing-block.html
         https://bugs.webkit.org/show_bug.cgi?id=239459
 

Deleted: trunk/LayoutTests/editing/selection/4866671.html (293027 => 293028)


--- trunk/LayoutTests/editing/selection/4866671.html	2022-04-19 18:15:28 UTC (rev 293027)
+++ trunk/LayoutTests/editing/selection/4866671.html	2022-04-19 18:23:50 UTC (rev 293028)
@@ -1,11 +0,0 @@
-<p>This tests caret movement through -webkit-user-select:none content.  The caret should move over <b>yyy</b>.</p>
-<div id="div" contenteditable="true">x<span style="font-weight:bold; -webkit-user-select:none;">yyy</span>x</div>
-
-<script>
-var div = document.getElementById("div");
-var sel = window.getSelection();
-
-sel.setPosition(div, 0);
-sel.modify("move", "forward", "character");
-sel.modify("move", "forward", "character");
-</script>

Deleted: trunk/LayoutTests/editing/selection/5779984-1-expected.txt (293027 => 293028)


--- trunk/LayoutTests/editing/selection/5779984-1-expected.txt	2022-04-19 18:15:28 UTC (rev 293027)
+++ trunk/LayoutTests/editing/selection/5779984-1-expected.txt	2022-04-19 18:23:50 UTC (rev 293028)
@@ -1,3 +0,0 @@
-This tests setting the WebkitUserSelect property on a CSSStyleDeclaration.
-This text should not be selectable.
-This test passed if you see no failure messages.

Deleted: trunk/LayoutTests/editing/selection/5779984-1.html (293027 => 293028)


--- trunk/LayoutTests/editing/selection/5779984-1.html	2022-04-19 18:15:28 UTC (rev 293027)
+++ trunk/LayoutTests/editing/selection/5779984-1.html	2022-04-19 18:23:50 UTC (rev 293028)
@@ -1,18 +0,0 @@
-<div id="description">This tests setting the WebkitUserSelect property on a CSSStyleDeclaration.</div>
-<div contenteditable="true" id="test">This text should not be selectable.</div>
-
-<script>
-if (window.testRunner)
-    window.testRunner.dumpAsText();
-div = document.getElementById("test");
-text = div.firstChild;
-if (div.style.WebkitUserSelect == undefined)
-    document.write("FAILURE: CSSStyleDeclaration::WebkitUserSelect was undefined.<br>");
-div.style.WebkitUserSelect = "none";
-s = window.getSelection();
-s.setBaseAndExtent(text, 1, text, 2);
-if (s.type != "None")
-    document.write("FAILURE: Setting -webkit-user-select to none did not have the expected effect. Setting the selection did not fail.<br>");
-    
-document.write("This test passed if you see no failure messages.")
-</script>

Added: trunk/LayoutTests/editing/selection/user-select-js-property-expected.txt (0 => 293028)


--- trunk/LayoutTests/editing/selection/user-select-js-property-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/user-select-js-property-expected.txt	2022-04-19 18:23:50 UTC (rev 293028)
@@ -0,0 +1,10 @@
+Test setting CSSStyleDeclaration.webkitUserStyle and userStyle
+
+editable
+uneditable
+
+PASS user-select-js-property
+PASS 'webkitUserSelect' in style
+PASS webkitUserSelect of '#bar { -webkit-user-select: none; }' should be 'none'
+PASS webkitUserSelect of '-webkit-user-select:none' should be 'none'
+

Added: trunk/LayoutTests/editing/selection/user-select-js-property.html (0 => 293028)


--- trunk/LayoutTests/editing/selection/user-select-js-property.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/user-select-js-property.html	2022-04-19 18:23:50 UTC (rev 293028)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<script src=""
+<script src=""
+<style>
+    /* FIXME: Add testcases for unprefixed version (webkit.org/b/208677) */
+    #bar {
+        -webkit-user-select: none;
+    }
+</style>
+<div id="container">
+<p id="description">Test setting CSSStyleDeclaration.webkitUserStyle and userStyle</p>
+<div id="sample1" contenteditable="true">editable</div>
+<div id="sample2" contenteditable="false">uneditable</div>
+<div class="none" style="-webkit-user-select:none"></div>
+</div>
+<div id="log"></div>
+<script>
+var selection = window.getSelection();
+function setSelection(node)
+{
+    var range = document.createRange();
+    range.selectNodeContents(node);
+    selection.empty();
+    selection.addRange(range);
+}
+
+test(function(){
+    // user-select:none in editable element
+    sample1.style.webkitUserSelect = "none";
+    setSelection(sample1);
+    assert_equals(selection.type, "Range");
+
+    // user-select:none in uneditable element
+    sample2.style.webkitUserSelect = "none";
+    setSelection(sample2);
+    assert_equals(selection.type, "None");
+});
+
+var style = document.createElement("baz").style;
+test(function () {
+    assert_true("webkitUserSelect" in style);
+}, "'webkitUserSelect' in style");
+
+for (let cssRule of document.styleSheets[0].cssRules) {
+    testUserSelect(cssRule.style, cssRule.cssText);
+}
+
+for (let element of document.querySelectorAll(".none")) {
+    testUserSelect(getComputedStyle(element), element.getAttribute("style"));
+}
+
+function testUserSelect(style, title) {
+    test(function () {
+        assert_equals(style.webkitUserSelect, "none");
+    }, "webkitUserSelect of '" + title + "' should be 'none'");
+}
+</script>
\ No newline at end of file

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (293027 => 293028)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-04-19 18:15:28 UTC (rev 293027)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-04-19 18:23:50 UTC (rev 293028)
@@ -1,3 +1,15 @@
+2022-04-19  Tim Nguyen  <[email protected]>
+
+        user-select: none shouldn't affect editability
+        https://bugs.webkit.org/show_bug.cgi?id=118009
+
+        Reviewed by Antti Koivisto.
+
+        * web-platform-tests/css/css-ui/user-select-none-in-editable-expected.txt: Added.
+        * web-platform-tests/css/css-ui/user-select-none-in-editable.html: Added.
+        * web-platform-tests/css/css-ui/user-select-none-on-input-expected.txt: Added.
+        * web-platform-tests/css/css-ui/user-select-none-on-input.html: Added.
+
 2022-04-19  Joseph Griego  <[email protected]>
 
         Fix runtime expose scope check for shadow realms

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-ui/user-select-none-in-editable-expected.txt (0 => 293028)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-ui/user-select-none-in-editable-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-ui/user-select-none-in-editable-expected.txt	2022-04-19 18:23:50 UTC (rev 293028)
@@ -0,0 +1,8 @@
+Manual step:
+Move caret after "c"
+Hit right arrow key twice
+Caret should be after "Y"
+abcXYZdef
+
+PASS Test user-select: none in editable contexts
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-ui/user-select-none-in-editable.html (0 => 293028)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-ui/user-select-none-in-editable.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-ui/user-select-none-in-editable.html	2022-04-19 18:23:50 UTC (rev 293028)
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Test user-select: none in editable contexts</title>
+<meta charset="utf-8">
+<link rel="author" title="Tim Nguyen" href=""
+<link rel="help" href=""
+<style>
+.user-select-none {
+    -webkit-user-select: none;
+    user-select: none;
+}
+</style>
+</head>
+<body>
+<div id="container">
+Manual step:
+<ol>
+<li>Move caret after "c"</li>
+<li>Hit right arrow key twice</li>
+<li>Caret should be after "Y"</li>
+</ol>
+<div id="outer" contenteditable="true">
+abc<span id="inner" class="user-select-none">XYZ</span>def
+</div>
+</div>
+<script src=""
+<script src=""
+<script>
+setup({ single_test: true });
+const selection = window.getSelection();
+selection.collapse(document.getElementById("outer"), 1);
+selection.modify("move", "forward", "character");
+selection.modify("move", "forward", "character");
+assert_equals(selection.focusNode, document.getElementById("inner").firstChild);
+assert_equals(selection.focusOffset, 2);
+done();
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-ui/user-select-none-on-input-expected.txt (0 => 293028)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-ui/user-select-none-on-input-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-ui/user-select-none-on-input-expected.txt	2022-04-19 18:23:50 UTC (rev 293028)
@@ -0,0 +1,5 @@
+
+
+PASS Test <input> with user-select: none
+PASS Test <textarea> with user-select: none
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-ui/user-select-none-on-input.html (0 => 293028)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-ui/user-select-none-on-input.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-ui/user-select-none-on-input.html	2022-04-19 18:23:50 UTC (rev 293028)
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Test user-select: none on input/textarea does not affect editability</title>
+    <meta charset="utf-8">
+    <link rel="author" title="Tim Nguyen" href=""
+    <link rel="help" href=""
+    <style>
+    input, textarea {
+        -webkit-user-select: none;
+        user-select: none;
+    }
+    </style>
+</head>
+<body>
+    <input>
+    <textarea></textarea>
+    <script src=""
+    <script src=""
+    <script src=""
+    <script src=""
+    <script>
+    async function testElement(element) {
+        const expectedText = "xyz";
+        element.focus();
+        await test_driver.send_keys(element, expectedText);
+        assert_equals(element.value, expectedText, "Text should be entered");
+        element.select();
+        assert_equals(element.value.substring(element.selectionStart, element.selectionEnd), expectedText, "Text should be programatically selectable");
+        await test_driver.send_keys(element, "\uE003");
+        assert_equals(element.value, "", "Text should be cleared");
+    }
+    promise_test(() => {
+        return testElement(document.querySelector("input"))
+    }, "Test <input> with user-select: none");
+    promise_test(() => {
+        return testElement(document.querySelector("textarea"))
+    }, "Test <textarea> with user-select: none");
+    </script>
+</body>
+</html>

Deleted: trunk/LayoutTests/platform/gtk/editing/selection/4866671-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/gtk/editing/selection/4866671-expected.txt (293027 => 293028)


--- trunk/LayoutTests/platform/gtk/editing/selection/4866671-expected.txt	2022-04-19 18:15:28 UTC (rev 293027)
+++ trunk/LayoutTests/platform/gtk/editing/selection/4866671-expected.txt	2022-04-19 18:23:50 UTC (rev 293028)
@@ -1,23 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderBlock {P} at (0,0) size 784x18
-        RenderText {#text} at (0,0) size 612x17
-          text run at (0,0) width 432: "This tests caret movement through -webkit-user-select:none content. "
-          text run at (431,0) width 181: "The caret should move over "
-        RenderInline {B} at (0,0) size 25x17
-          RenderText {#text} at (611,0) size 25x17
-            text run at (611,0) width 25: "yyy"
-        RenderText {#text} at (635,0) size 5x17
-          text run at (635,0) width 5: "."
-      RenderBlock {DIV} at (0,34) size 784x18
-        RenderText {#text} at (0,0) size 8x17
-          text run at (0,0) width 8: "x"
-        RenderInline {SPAN} at (0,0) size 24x17
-          RenderText {#text} at (8,0) size 24x17
-            text run at (8,0) width 24: "yyy"
-        RenderText {#text} at (32,0) size 8x17
-          text run at (32,0) width 8: "x"
-caret: position 0 of child 2 {#text} of child 2 {DIV} of body

Modified: trunk/LayoutTests/platform/ios/TestExpectations (293027 => 293028)


--- trunk/LayoutTests/platform/ios/TestExpectations	2022-04-19 18:15:28 UTC (rev 293027)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2022-04-19 18:23:50 UTC (rev 293028)
@@ -1040,6 +1040,7 @@
 imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/email-set-value.html [ Skip ]
 imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/maxlength-number.html [ Skip ]
 imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/radio-double-activate-pseudo.html [ Skip ]
+imported/w3c/web-platform-tests/css/css-ui/user-select-none-on-input.html [ Skip ]
 
 # Tests that use EventSender's mouseMoveTo, mouseUp and mouseDown
 css3/viewport-percentage-lengths/vh-resize.html [ Skip ]

Deleted: trunk/LayoutTests/platform/ios/editing/selection/4866671-expected.txt (293027 => 293028)


--- trunk/LayoutTests/platform/ios/editing/selection/4866671-expected.txt	2022-04-19 18:15:28 UTC (rev 293027)
+++ trunk/LayoutTests/platform/ios/editing/selection/4866671-expected.txt	2022-04-19 18:23:50 UTC (rev 293028)
@@ -1,23 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderBlock {P} at (0,0) size 784x20
-        RenderText {#text} at (0,0) size 625x19
-          text run at (0,0) width 443: "This tests caret movement through -webkit-user-select:none content. "
-          text run at (442,0) width 183: "The caret should move over "
-        RenderInline {B} at (0,0) size 25x19
-          RenderText {#text} at (624,0) size 25x19
-            text run at (624,0) width 25: "yyy"
-        RenderText {#text} at (648,0) size 5x19
-          text run at (648,0) width 5: "."
-      RenderBlock {DIV} at (0,36) size 784x20
-        RenderText {#text} at (0,0) size 8x19
-          text run at (0,0) width 8: "x"
-        RenderInline {SPAN} at (0,0) size 24x19
-          RenderText {#text} at (8,0) size 24x19
-            text run at (8,0) width 24: "yyy"
-        RenderText {#text} at (32,0) size 8x19
-          text run at (32,0) width 8: "x"
-caret: position 0 of child 2 {#text} of child 2 {DIV} of body

Deleted: trunk/LayoutTests/platform/mac/editing/selection/4866671-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/mac/editing/selection/4866671-expected.txt (293027 => 293028)


--- trunk/LayoutTests/platform/mac/editing/selection/4866671-expected.txt	2022-04-19 18:15:28 UTC (rev 293027)
+++ trunk/LayoutTests/platform/mac/editing/selection/4866671-expected.txt	2022-04-19 18:23:50 UTC (rev 293028)
@@ -1,23 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderBlock {P} at (0,0) size 784x18
-        RenderText {#text} at (0,0) size 625x18
-          text run at (0,0) width 443: "This tests caret movement through -webkit-user-select:none content. "
-          text run at (442,0) width 183: "The caret should move over "
-        RenderInline {B} at (0,0) size 25x18
-          RenderText {#text} at (624,0) size 25x18
-            text run at (624,0) width 25: "yyy"
-        RenderText {#text} at (648,0) size 5x18
-          text run at (648,0) width 5: "."
-      RenderBlock {DIV} at (0,34) size 784x18
-        RenderText {#text} at (0,0) size 8x18
-          text run at (0,0) width 8: "x"
-        RenderInline {SPAN} at (0,0) size 24x18
-          RenderText {#text} at (8,0) size 24x18
-            text run at (8,0) width 24: "yyy"
-        RenderText {#text} at (32,0) size 8x18
-          text run at (32,0) width 8: "x"
-caret: position 0 of child 2 {#text} of child 2 {DIV} of body

Deleted: trunk/LayoutTests/platform/win/editing/selection/4866671-expected.txt (293027 => 293028)


--- trunk/LayoutTests/platform/win/editing/selection/4866671-expected.txt	2022-04-19 18:15:28 UTC (rev 293027)
+++ trunk/LayoutTests/platform/win/editing/selection/4866671-expected.txt	2022-04-19 18:23:50 UTC (rev 293028)
@@ -1,23 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderBlock {P} at (0,0) size 784x18
-        RenderText {#text} at (0,0) size 612x18
-          text run at (0,0) width 432: "This tests caret movement through -webkit-user-select:none content. "
-          text run at (432,0) width 180: "The caret should move over "
-        RenderInline {B} at (0,0) size 24x18
-          RenderText {#text} at (612,0) size 24x18
-            text run at (612,0) width 24: "yyy"
-        RenderText {#text} at (636,0) size 4x18
-          text run at (636,0) width 4: "."
-      RenderBlock {DIV} at (0,34) size 784x18
-        RenderText {#text} at (0,0) size 8x18
-          text run at (0,0) width 8: "x"
-        RenderInline {SPAN} at (0,0) size 24x18
-          RenderText {#text} at (8,0) size 24x18
-            text run at (8,0) width 24: "yyy"
-        RenderText {#text} at (32,0) size 8x18
-          text run at (32,0) width 8: "x"
-caret: position 0 of child 2 {#text} of child 2 {DIV} of body

Deleted: trunk/LayoutTests/platform/wincairo/editing/selection/4866671-expected.txt (293027 => 293028)


--- trunk/LayoutTests/platform/wincairo/editing/selection/4866671-expected.txt	2022-04-19 18:15:28 UTC (rev 293027)
+++ trunk/LayoutTests/platform/wincairo/editing/selection/4866671-expected.txt	2022-04-19 18:23:50 UTC (rev 293028)
@@ -1,23 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderBlock {P} at (0,0) size 784x20
-        RenderText {#text} at (0,0) size 587x19
-          text run at (0,0) width 415: "This tests caret movement through -webkit-user-select:none content. "
-          text run at (415,0) width 172: "The caret should move over "
-        RenderInline {B} at (0,0) size 24x19
-          RenderText {#text} at (587,0) size 24x19
-            text run at (587,0) width 24: "yyy"
-        RenderText {#text} at (611,0) size 4x19
-          text run at (611,0) width 4: "."
-      RenderBlock {DIV} at (0,36) size 784x20
-        RenderText {#text} at (0,0) size 7x19
-          text run at (0,0) width 7: "x"
-        RenderInline {SPAN} at (0,0) size 24x19
-          RenderText {#text} at (7,0) size 24x19
-            text run at (7,0) width 24: "yyy"
-        RenderText {#text} at (31,0) size 7x19
-          text run at (31,0) width 7: "x"
-caret: position 0 of child 2 {#text} of child 2 {DIV} of body

Modified: trunk/Source/WebCore/ChangeLog (293027 => 293028)


--- trunk/Source/WebCore/ChangeLog	2022-04-19 18:15:28 UTC (rev 293027)
+++ trunk/Source/WebCore/ChangeLog	2022-04-19 18:23:50 UTC (rev 293028)
@@ -1,3 +1,21 @@
+2022-04-19  Tim Nguyen  <[email protected]>
+
+        user-select: none shouldn't affect editability
+        https://bugs.webkit.org/show_bug.cgi?id=118009
+
+        Reviewed by Antti Koivisto.
+
+        Tests: editing/selection/user-select-js-property.html
+               imported/w3c/web-platform-tests/css/css-ui/user-select-none-in-editable.html
+               imported/w3c/web-platform-tests/css/css-ui/user-select-none-on-input.html
+
+        Change `effectiveUserSelect` to take in account `-webkit-user-modify`.
+
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::effectiveUserSelect const):
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::effectiveUserSelect const): Deleted.
+
 2022-04-19  Antti Koivisto  <[email protected]>
 
         [LFC][Integration] Use WeakPtr for InlineContent in iterator

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (293027 => 293028)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2022-04-19 18:15:28 UTC (rev 293027)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2022-04-19 18:23:50 UTC (rev 293028)
@@ -2912,5 +2912,16 @@
     return containment;
 }
 
+UserSelect RenderStyle::effectiveUserSelect() const
+{
+    if (effectiveInert())
+        return UserSelect::None;
 
+    auto value = userSelect();
+    if (userModify() != UserModify::ReadOnly && userDrag() != UserDrag::Element)
+        return value == UserSelect::None ? UserSelect::Text : value;
+
+    return value;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (293027 => 293028)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2022-04-19 18:15:28 UTC (rev 293027)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2022-04-19 18:23:50 UTC (rev 293028)
@@ -627,7 +627,7 @@
     UserModify effectiveUserModify() const { return effectiveInert() ? UserModify::ReadOnly : userModify(); }
     UserModify userModify() const { return static_cast<UserModify>(m_rareInheritedData->userModify); }
     UserDrag userDrag() const { return static_cast<UserDrag>(m_rareNonInheritedData->userDrag); }
-    UserSelect effectiveUserSelect() const { return effectiveInert() ? UserSelect::None : userSelect(); }
+    WEBCORE_EXPORT UserSelect effectiveUserSelect() const;
     UserSelect userSelect() const { return static_cast<UserSelect>(m_rareInheritedData->userSelect); }
     TextOverflow textOverflow() const { return static_cast<TextOverflow>(m_rareNonInheritedData->textOverflow); }
     WordBreak wordBreak() const { return static_cast<WordBreak>(m_rareInheritedData->wordBreak); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to