Skip to content

Commit

Permalink
Remove draggable elements default presentational CSS of -webkit-user-…
Browse files Browse the repository at this point in the history
…select: none

https://bugs.webkit.org/show_bug.cgi?id=234716

Reviewed by Tim Nguyen.

This behaves similar to both Firefox and Chromium. Draggable elements do not make them
un-selectable. When selected, dragging still takes priority also like other browsers.

* LayoutTests/fast/html/find-selects-draggable-element-expected.txt: Added.
* LayoutTests/fast/html/find-selects-draggable-element.html: Added.
* Source/WebCore/html/HTMLElement.cpp:
  (WebCore::HTMLElement::collectPresentationalHintsForAttribute):

Canonical link: https://commits.webkit.org/264448@main
  • Loading branch information
TingPing committed May 24, 2023
1 parent d67decd commit 1605f4d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
@@ -1 +1,4 @@
Test changing style with draggable text. The test passes if WebKit doesn't crash or hit an assertiona
Test changing style with draggable text. The test passes if WebKit doesn't crash or hit an assertion

a
a
@@ -0,0 +1,2 @@
PASS window.getSelection().toString() == 'Something' is true
Something
12 changes: 12 additions & 0 deletions LayoutTests/fast/html/find-selects-draggable-element.html
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script>
function findText() {
window.find("Something");
shouldBeTrue("window.getSelection().toString() == 'Something'");
}
</script>
<body onload="findText()">
<p draggable="true">Something</p>
</body>
@@ -1,3 +1,2 @@
PASS if no crash.


6 changes: 2 additions & 4 deletions Source/WebCore/html/HTMLElement.cpp
Expand Up @@ -270,11 +270,9 @@ void HTMLElement::collectPresentationalHintsForAttribute(const QualifiedName& na
addPropertyToPresentationalHintStyle(style, CSSPropertyDisplay, CSSValueNone);
break;
case AttributeNames::draggableAttr:
if (equalLettersIgnoringASCIICase(value, "true"_s)) {
if (equalLettersIgnoringASCIICase(value, "true"_s))
addPropertyToPresentationalHintStyle(style, CSSPropertyWebkitUserDrag, CSSValueElement);
if (!isDraggableIgnoringAttributes())
addPropertyToPresentationalHintStyle(style, CSSPropertyWebkitUserSelect, CSSValueNone);
} else if (equalLettersIgnoringASCIICase(value, "false"_s))
else if (equalLettersIgnoringASCIICase(value, "false"_s))
addPropertyToPresentationalHintStyle(style, CSSPropertyWebkitUserDrag, CSSValueNone);
break;
case AttributeNames::dirAttr:
Expand Down

0 comments on commit 1605f4d

Please sign in to comment.