Title: [290098] trunk
Revision
290098
Author
akeer...@apple.com
Date
2022-02-17 17:03:50 -0800 (Thu, 17 Feb 2022)

Log Message

'-webkit-user-select: all' is not respected in editable views
https://bugs.webkit.org/show_bug.cgi?id=190977
rdar://34945944

Reviewed by Wenson Hsieh.

Source/WebCore:

Original patch by Tim Horton.

Currently, if the web view's editable bit is set to true, all nodes are
made editable via a short circuit. However, the content of nodes with
'-webkit-user-select: all' should not be editable. To fix, remove the
short circuit and allow '-webkit-user-select' to take precedence.

'-webkit-user-modify: read-only' and 'contenteditable=false' elements
remain editable in editable web views.

Tests: editing/editability/contenteditable-false-in-editable-view.html
       editing/editability/user-modify-read-only-in-editable-view.html
       editing/editability/user-select-all-in-editable-view.html

* dom/Node.cpp:
(WebCore::computeEditabilityFromComputedStyle):
(WebCore::Node::computeEditability const):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::editabilityFromContentEditableAttr):
(WebCore::HTMLElement::matchesReadWritePseudoClass const):
* html/HTMLElement.h:
* page/Page.h:

Source/WebKit:

Add methods for testing the GTK port.

* UIProcess/API/C/gtk/WKView.cpp:
(WKViewSetEditable):
* UIProcess/API/C/gtk/WKViewPrivate.h:
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseSetEditable):
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:

Tools:

Add a UIScriptController method to make web views editable.

Remove TestRunner::setWebViewEditable as it is unused.

* DumpRenderTree/TestRunner.cpp:
(TestRunner::staticFunctions):
(setWebViewEditableCallback): Deleted.
* DumpRenderTree/TestRunner.h:
* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::setWebViewEditable): Deleted.
* DumpRenderTree/mac/UIScriptControllerMac.h:
* DumpRenderTree/mac/UIScriptControllerMac.mm:
(WTR::UIScriptControllerMac::setWebViewEditable):
* DumpRenderTree/win/TestRunnerWin.cpp:
(TestRunner::~TestRunner):
(TestRunner::setWebViewEditable): Deleted.
* DumpRenderTree/win/UIScriptControllerWin.cpp:
(WTR::UIScriptControllerWin::setWebViewEditable):
* DumpRenderTree/win/UIScriptControllerWin.h:
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::setWebViewEditable):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::cocoaResetStateToConsistentValues):
* WebKitTestRunner/cocoa/UIScriptControllerCocoa.h:
* WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm:
(WTR::UIScriptControllerCocoa::setWebViewEditable):
* WebKitTestRunner/gtk/TestControllerGtk.cpp:
(WTR::TestController::platformResetStateToConsistentValues):
* WebKitTestRunner/gtk/UIScriptControllerGtk.cpp:
(WTR::UIScriptControllerGtk::setWebViewEditable):
* WebKitTestRunner/gtk/UIScriptControllerGtk.h:

LayoutTests:

Add tests to verify the behavior of `-[WKWebView _setEditable:]` with
'-webkit-user-select: all', '-webkit-user-modify: none', and
'contenteditable=false'. Elements with '-webkit-user-select: all' should
not be editable.

* editing/editability/contenteditable-false-in-editable-view-expected.txt: Added.
* editing/editability/contenteditable-false-in-editable-view.html: Added.
* editing/editability/user-modify-read-only-in-editable-view-expected.txt: Added.
* editing/editability/user-modify-read-only-in-editable-view.html: Added.
* editing/editability/user-select-all-in-editable-view-expected.txt: Added.
* editing/editability/user-select-all-in-editable-view.html: Added.
* editing/input/ios/rtl-keyboard-input-on-focus-in-editable-page.html:

Replace the test option with the new UIHelper method.

* resources/ui-helper.js:
(window.UIHelper.setWebViewEditable):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (290097 => 290098)


--- trunk/LayoutTests/ChangeLog	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/LayoutTests/ChangeLog	2022-02-18 01:03:50 UTC (rev 290098)
@@ -1,3 +1,29 @@
+2022-02-17  Aditya Keerthi  <akeer...@apple.com>
+
+        '-webkit-user-select: all' is not respected in editable views
+        https://bugs.webkit.org/show_bug.cgi?id=190977
+        rdar://34945944
+
+        Reviewed by Wenson Hsieh.
+
+        Add tests to verify the behavior of `-[WKWebView _setEditable:]` with
+        '-webkit-user-select: all', '-webkit-user-modify: none', and
+        'contenteditable=false'. Elements with '-webkit-user-select: all' should
+        not be editable.
+
+        * editing/editability/contenteditable-false-in-editable-view-expected.txt: Added.
+        * editing/editability/contenteditable-false-in-editable-view.html: Added.
+        * editing/editability/user-modify-read-only-in-editable-view-expected.txt: Added.
+        * editing/editability/user-modify-read-only-in-editable-view.html: Added.
+        * editing/editability/user-select-all-in-editable-view-expected.txt: Added.
+        * editing/editability/user-select-all-in-editable-view.html: Added.
+        * editing/input/ios/rtl-keyboard-input-on-focus-in-editable-page.html:
+
+        Replace the test option with the new UIHelper method.
+
+        * resources/ui-helper.js:
+        (window.UIHelper.setWebViewEditable):
+
 2022-02-17  Matt Woodrow  <mattwood...@apple.com>
 
         Account for subgrid MBP when sizing

Added: trunk/LayoutTests/editing/editability/contenteditable-false-in-editable-view-expected.txt (0 => 290098)


--- trunk/LayoutTests/editing/editability/contenteditable-false-in-editable-view-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/editability/contenteditable-false-in-editable-view-expected.txt	2022-02-18 01:03:50 UTC (rev 290098)
@@ -0,0 +1,7 @@
+This tests that the cursor can be moved inside a non-editable element if the web view is editable. The cursor should end up inside "some text in between". To test manually, ensure this page is opened in an editable web view.
+| "before "
+| <span>
+|   contenteditable="false"
+|   id="inner"
+|   "some <#selection-caret>text in between"
+| " after"

Added: trunk/LayoutTests/editing/editability/contenteditable-false-in-editable-view.html (0 => 290098)


--- trunk/LayoutTests/editing/editability/contenteditable-false-in-editable-view.html	                        (rev 0)
+++ trunk/LayoutTests/editing/editability/contenteditable-false-in-editable-view.html	2022-02-18 01:03:50 UTC (rev 290098)
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests that the cursor can be moved inside a non-editable element if the web view is editable. The cursor should end up inside "some text in between". To test manually, ensure this page is opened in an editable web view.</p>
+
+<div id="container">before <span id="inner" contenteditable="false">some text in between</span> after</div>
+
+<script src=""
+<script src=""
+<script>
+
+Markup.waitUntilDone();
+
+addEventListener("load", async () => {
+    Markup.description(document.getElementById('description').textContent);
+
+    if (window.testRunner && testRunner.runUIScript)
+        await UIHelper.setWebViewEditable(true);
+
+    var selection = window.getSelection();
+    selection.setPosition(container, 0);
+
+    for (var i = 0; i < 12; i++)
+        selection.modify("move", "forward", "character");
+
+    Markup.dump('container');
+    Markup.notifyDone();
+});
+
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/editing/editability/user-modify-read-only-in-editable-view-expected.txt (0 => 290098)


--- trunk/LayoutTests/editing/editability/user-modify-read-only-in-editable-view-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/editability/user-modify-read-only-in-editable-view-expected.txt	2022-02-18 01:03:50 UTC (rev 290098)
@@ -0,0 +1,7 @@
+This tests that the cursor can be moved inside a "-webkit-user-modify: read-only" element if the web view is editable. The cursor should end up inside "some text in between". To test manually, ensure this page is opened in an editable web view.
+| "before "
+| <span>
+|   id="inner"
+|   style="-webkit-user-modify: read-only"
+|   "some <#selection-caret>text in between"
+| " after"

Added: trunk/LayoutTests/editing/editability/user-modify-read-only-in-editable-view.html (0 => 290098)


--- trunk/LayoutTests/editing/editability/user-modify-read-only-in-editable-view.html	                        (rev 0)
+++ trunk/LayoutTests/editing/editability/user-modify-read-only-in-editable-view.html	2022-02-18 01:03:50 UTC (rev 290098)
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests that the cursor can be moved inside a "-webkit-user-modify: read-only" element if the web view is editable. The cursor should end up inside "some text in between". To test manually, ensure this page is opened in an editable web view.</p>
+
+<div id="container" contenteditable>before <span id="inner" style="-webkit-user-modify: read-only">some text in between</span> after</div>
+
+<script src=""
+<script src=""
+<script>
+
+Markup.waitUntilDone();
+
+addEventListener("load", async () => {
+    Markup.description(document.getElementById('description').textContent);
+
+    if (window.testRunner && testRunner.runUIScript)
+        await UIHelper.setWebViewEditable(true);
+
+    var selection = window.getSelection();
+    selection.setPosition(container, 0);
+
+    for (var i = 0; i < 12; i++)
+        selection.modify("move", "forward", "character");
+
+    Markup.dump('container');
+    Markup.notifyDone();
+});
+
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/editing/editability/user-select-all-in-editable-view-expected.txt (0 => 290098)


--- trunk/LayoutTests/editing/editability/user-select-all-in-editable-view-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/editability/user-select-all-in-editable-view-expected.txt	2022-02-18 01:03:50 UTC (rev 290098)
@@ -0,0 +1,7 @@
+This tests that moving the cursor inside a 'user-select: all' element expands the selection to the entire element. The cursor should not end up inside the 'user-select: all' element, but rather in the middle of "after". To test manually, ensure this page is opened in an editable web view.
+| "before "
+| <span>
+|   id="inner"
+|   style="-webkit-user-select: all;"
+|   "a long select-all"
+| " aft<#selection-caret>er"

Added: trunk/LayoutTests/editing/editability/user-select-all-in-editable-view.html (0 => 290098)


--- trunk/LayoutTests/editing/editability/user-select-all-in-editable-view.html	                        (rev 0)
+++ trunk/LayoutTests/editing/editability/user-select-all-in-editable-view.html	2022-02-18 01:03:50 UTC (rev 290098)
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests that moving the cursor inside a 'user-select: all' element expands the selection to the entire element. The cursor should not end up inside the 'user-select: all' element, but rather in the middle of "after". To test manually, ensure this page is opened in an editable web view.</p>
+
+<div id="container">before <span id="inner" style="-webkit-user-select: all;">a long select-all</span> after</div>
+
+<script src=""
+<script src=""
+<script>
+
+Markup.waitUntilDone();
+
+addEventListener("load", async () => {
+    Markup.description(document.getElementById('description').textContent);
+
+    if (window.testRunner && testRunner.runUIScript)
+        await UIHelper.setWebViewEditable(true);
+
+    var selection = window.getSelection();
+    selection.setPosition(container, 0);
+
+    for (var i = 0; i < 12; i++)
+        selection.modify("move", "forward", "character");
+
+    Markup.dump('container');
+    Markup.notifyDone();
+});
+
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/editing/input/ios/rtl-keyboard-input-on-focus-in-editable-page.html (290097 => 290098)


--- trunk/LayoutTests/editing/input/ios/rtl-keyboard-input-on-focus-in-editable-page.html	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/LayoutTests/editing/input/ios/rtl-keyboard-input-on-focus-in-editable-page.html	2022-02-18 01:03:50 UTC (rev 290098)
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true editable=true ] -->
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
 <html>
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <head>
@@ -40,6 +40,7 @@
             });
         });
 
+        await UIHelper.setWebViewEditable(true);
         await UIHelper.setKeyboardInputModeIdentifier("he_IL");
         await UIHelper.activateAndWaitForInputSessionAt(100, 250);
         await UIHelper.ensurePresentationUpdate();

Modified: trunk/LayoutTests/resources/ui-helper.js (290097 => 290098)


--- trunk/LayoutTests/resources/ui-helper.js	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/LayoutTests/resources/ui-helper.js	2022-02-18 01:03:50 UTC (rev 290098)
@@ -1344,6 +1344,11 @@
         return new Promise(resolve => testRunner.runUIScript(`uiController.setHardwareKeyboardAttached(${attached ? "true" : "false"})`, resolve));
     }
 
+    static setWebViewEditable(editable)
+    {
+        return new Promise(resolve => testRunner.runUIScript(`uiController.setWebViewEditable(${editable ? "true" : "false"})`, resolve));
+    }
+
     static rectForMenuAction(action)
     {
         return new Promise(resolve => {

Modified: trunk/Source/WebCore/ChangeLog (290097 => 290098)


--- trunk/Source/WebCore/ChangeLog	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Source/WebCore/ChangeLog	2022-02-18 01:03:50 UTC (rev 290098)
@@ -1,3 +1,34 @@
+2022-02-17  Aditya Keerthi  <akeer...@apple.com>
+
+        '-webkit-user-select: all' is not respected in editable views
+        https://bugs.webkit.org/show_bug.cgi?id=190977
+        rdar://34945944
+
+        Reviewed by Wenson Hsieh.
+
+        Original patch by Tim Horton.
+
+        Currently, if the web view's editable bit is set to true, all nodes are
+        made editable via a short circuit. However, the content of nodes with
+        '-webkit-user-select: all' should not be editable. To fix, remove the
+        short circuit and allow '-webkit-user-select' to take precedence.
+
+        '-webkit-user-modify: read-only' and 'contenteditable=false' elements
+        remain editable in editable web views.
+
+        Tests: editing/editability/contenteditable-false-in-editable-view.html
+               editing/editability/user-modify-read-only-in-editable-view.html
+               editing/editability/user-select-all-in-editable-view.html
+
+        * dom/Node.cpp:
+        (WebCore::computeEditabilityFromComputedStyle):
+        (WebCore::Node::computeEditability const):
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::editabilityFromContentEditableAttr):
+        (WebCore::HTMLElement::matchesReadWritePseudoClass const):
+        * html/HTMLElement.h:
+        * page/Page.h:
+
 2022-02-17  Matt Woodrow  <mattwood...@apple.com>
 
         Account for subgrid MBP when sizing

Modified: trunk/Source/WebCore/dom/Node.cpp (290097 => 290098)


--- trunk/Source/WebCore/dom/Node.cpp	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Source/WebCore/dom/Node.cpp	2022-02-18 01:03:50 UTC (rev 290098)
@@ -750,7 +750,7 @@
         document().page()->inspectorController().inspect(this);
 }
 
-static Node::Editability computeEditabilityFromComputedStyle(const Node& startNode, Node::UserSelectAllTreatment treatment)
+static Node::Editability computeEditabilityFromComputedStyle(const Node& startNode, Node::UserSelectAllTreatment treatment, PageIsEditable pageIsEditable)
 {
     // Ideally we'd call ASSERT(!needsStyleRecalc()) here, but
     // ContainerNode::setFocus() calls invalidateStyleForSubtree(), so the assertion
@@ -766,6 +766,10 @@
         // therefore non editable.
         if (treatment == Node::UserSelectAllIsAlwaysNonEditable && style->userSelectIncludingInert() == UserSelect::All)
             return Node::Editability::ReadOnly;
+
+        if (pageIsEditable == PageIsEditable::Yes)
+            return Node::Editability::CanEditRichly;
+
         switch (style->userModify()) {
         case UserModify::ReadOnly:
             return Node::Editability::ReadOnly;
@@ -777,6 +781,10 @@
         ASSERT_NOT_REACHED();
         return Node::Editability::ReadOnly;
     }
+
+    if (pageIsEditable == PageIsEditable::Yes)
+        return Node::Editability::CanEditRichly;
+
     return Node::Editability::ReadOnly;
 }
 
@@ -785,18 +793,19 @@
     if (!document().hasLivingRenderTree() || isPseudoElement())
         return Editability::ReadOnly;
 
+    Ref document = this->document();
+    auto pageIsEditable = document->page() && document->page()->isEditable() ? PageIsEditable::Yes : PageIsEditable::No;
+
     if (isInShadowTree())
-        return HTMLElement::editabilityFromContentEditableAttr(*this);
+        return HTMLElement::editabilityFromContentEditableAttr(*this, pageIsEditable);
 
-    if (document().frame() && document().frame()->page() && document().frame()->page()->isEditable())
-        return Editability::CanEditRichly;
+    if (shouldUpdateStyle == ShouldUpdateStyle::Update && document->needsStyleRecalc()) {
+        if (!document->usesStyleBasedEditability())
+            return HTMLElement::editabilityFromContentEditableAttr(*this, pageIsEditable);
+        document->updateStyleIfNeeded();
+    }
 
-    if (shouldUpdateStyle == ShouldUpdateStyle::Update && document().needsStyleRecalc()) {
-        if (!document().usesStyleBasedEditability())
-            return HTMLElement::editabilityFromContentEditableAttr(*this);
-        document().updateStyleIfNeeded();
-    }
-    return computeEditabilityFromComputedStyle(*this, treatment);
+    return computeEditabilityFromComputedStyle(*this, treatment, pageIsEditable);
 }
 
 RenderBox* Node::renderBox() const

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (290097 => 290098)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2022-02-18 01:03:50 UTC (rev 290098)
@@ -299,8 +299,11 @@
     return eventNameForEventHandlerAttribute(attributeName, map);
 }
 
-Node::Editability HTMLElement::editabilityFromContentEditableAttr(const Node& node)
+Node::Editability HTMLElement::editabilityFromContentEditableAttr(const Node& node, PageIsEditable pageIsEditable)
 {
+    if (pageIsEditable == PageIsEditable::Yes)
+        return Editability::CanEditRichly;
+
     if (auto* startElement = is<Element>(node) ? &downcast<Element>(node) : node.parentElement()) {
         for (auto& element : lineageOfType<HTMLElement>(*startElement)) {
             switch (contentEditableType(element)) {
@@ -320,9 +323,8 @@
     if (containingShadowRoot && containingShadowRoot->mode() == ShadowRootMode::UserAgent)
         return Editability::ReadOnly;
 
-    auto& document = node.document();
-    if (is<HTMLDocument>(document))
-        return downcast<HTMLDocument>(document).inDesignMode() ? Editability::CanEditRichly : Editability::ReadOnly;
+    if (node.document().inDesignMode())
+        return Editability::CanEditRichly;
 
     return Editability::ReadOnly;
 }
@@ -329,7 +331,7 @@
 
 bool HTMLElement::matchesReadWritePseudoClass() const
 {
-    return editabilityFromContentEditableAttr(*this) != Editability::ReadOnly;
+    return editabilityFromContentEditableAttr(*this, PageIsEditable::No) != Editability::ReadOnly;
 }
 
 void HTMLElement::parseAttribute(const QualifiedName& name, const AtomString& value)

Modified: trunk/Source/WebCore/html/HTMLElement.h (290097 => 290098)


--- trunk/Source/WebCore/html/HTMLElement.h	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Source/WebCore/html/HTMLElement.h	2022-02-18 01:03:50 UTC (rev 290098)
@@ -39,6 +39,7 @@
 struct SimpleRange;
 struct TextRecognitionResult;
 
+enum class PageIsEditable : bool;
 enum class EnterKeyHint : uint8_t;
 
 #if PLATFORM(IOS_FAMILY)
@@ -61,7 +62,7 @@
     WEBCORE_EXPORT String contentEditable() const;
     WEBCORE_EXPORT ExceptionOr<void> setContentEditable(const String&);
 
-    static Editability editabilityFromContentEditableAttr(const Node&);
+    static Editability editabilityFromContentEditableAttr(const Node&, PageIsEditable);
 
     virtual bool draggable() const;
     WEBCORE_EXPORT void setDraggable(bool);

Modified: trunk/Source/WebCore/page/Page.h (290097 => 290098)


--- trunk/Source/WebCore/page/Page.h	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Source/WebCore/page/Page.h	2022-02-18 01:03:50 UTC (rev 290098)
@@ -194,6 +194,8 @@
 enum class EventThrottlingBehavior : bool { Responsive, Unresponsive };
 enum class MainFrameMainResource : bool { No, Yes };
 
+enum class PageIsEditable : bool { No, Yes };
+
 enum class CompositingPolicy : bool {
     Normal,
     Conservative, // Used in low memory situations.

Modified: trunk/Source/WebKit/ChangeLog (290097 => 290098)


--- trunk/Source/WebKit/ChangeLog	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Source/WebKit/ChangeLog	2022-02-18 01:03:50 UTC (rev 290098)
@@ -1,3 +1,20 @@
+2022-02-17  Aditya Keerthi  <akeer...@apple.com>
+
+        '-webkit-user-select: all' is not respected in editable views
+        https://bugs.webkit.org/show_bug.cgi?id=190977
+        rdar://34945944
+
+        Reviewed by Wenson Hsieh.
+
+        Add methods for testing the GTK port.
+
+        * UIProcess/API/C/gtk/WKView.cpp:
+        (WKViewSetEditable):
+        * UIProcess/API/C/gtk/WKViewPrivate.h:
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseSetEditable):
+        * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
+
 2022-02-17  Devin Rousso  <drou...@apple.com>
 
         [MacCatalyst] improve support for resizing

Modified: trunk/Source/WebKit/UIProcess/API/C/gtk/WKView.cpp (290097 => 290098)


--- trunk/Source/WebKit/UIProcess/API/C/gtk/WKView.cpp	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Source/WebKit/UIProcess/API/C/gtk/WKView.cpp	2022-02-18 01:03:50 UTC (rev 290098)
@@ -49,6 +49,11 @@
     webkitWebViewBaseSetFocus(toImpl(viewRef), focused);
 }
 
+void WKViewSetEditable(WKViewRef viewRef, bool editable)
+{
+    webkitWebViewBaseSetEditable(toImpl(viewRef), editable);
+}
+
 void WKViewSetEnableBackForwardNavigationGesture(WKViewRef viewRef, bool enabled)
 {
     webkitWebViewBaseSetEnableBackForwardNavigationGesture(toImpl(viewRef), enabled);

Modified: trunk/Source/WebKit/UIProcess/API/C/gtk/WKViewPrivate.h (290097 => 290098)


--- trunk/Source/WebKit/UIProcess/API/C/gtk/WKViewPrivate.h	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Source/WebKit/UIProcess/API/C/gtk/WKViewPrivate.h	2022-02-18 01:03:50 UTC (rev 290098)
@@ -34,6 +34,8 @@
 
 WK_EXPORT void WKViewSetFocus(WKViewRef viewRef, bool focused);
 
+WK_EXPORT void WKViewSetEditable(WKViewRef viewRef, bool editable);
+
 WK_EXPORT void WKViewSetEnableBackForwardNavigationGesture(WKViewRef viewRef, bool enabled);
 
 WK_EXPORT bool WKViewBeginBackSwipeForTesting(WKViewRef viewRef);

Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (290097 => 290098)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp	2022-02-18 01:03:50 UTC (rev 290098)
@@ -2439,6 +2439,12 @@
     webkitWebViewBaseScheduleUpdateActivityState(webViewBase, flagsToUpdate);
 }
 
+void webkitWebViewBaseSetEditable(WebKitWebViewBase* webViewBase, bool editable)
+{
+    WebKitWebViewBasePrivate* priv = webViewBase->priv;
+    priv->pageProxy->setEditable(editable);
+}
+
 IntSize webkitWebViewBaseGetViewSize(WebKitWebViewBase* webViewBase)
 {
     WebKitWebViewBasePrivate* priv = webViewBase->priv;

Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h (290097 => 290098)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h	2022-02-18 01:03:50 UTC (rev 290098)
@@ -64,6 +64,7 @@
 void webkitWebViewBaseSetContentsSize(WebKitWebViewBase*, const WebCore::IntSize&);
 
 void webkitWebViewBaseSetFocus(WebKitWebViewBase*, bool focused);
+void webkitWebViewBaseSetEditable(WebKitWebViewBase*, bool editable);
 WebCore::IntSize webkitWebViewBaseGetViewSize(WebKitWebViewBase*);
 bool webkitWebViewBaseIsInWindowActive(WebKitWebViewBase*);
 bool webkitWebViewBaseIsFocused(WebKitWebViewBase*);

Modified: trunk/Tools/ChangeLog (290097 => 290098)


--- trunk/Tools/ChangeLog	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/ChangeLog	2022-02-18 01:03:50 UTC (rev 290098)
@@ -1,3 +1,44 @@
+2022-02-17  Aditya Keerthi  <akeer...@apple.com>
+
+        '-webkit-user-select: all' is not respected in editable views
+        https://bugs.webkit.org/show_bug.cgi?id=190977
+        rdar://34945944
+
+        Reviewed by Wenson Hsieh.
+
+        Add a UIScriptController method to make web views editable.
+
+        Remove TestRunner::setWebViewEditable as it is unused.
+
+        * DumpRenderTree/TestRunner.cpp:
+        (TestRunner::staticFunctions):
+        (setWebViewEditableCallback): Deleted.
+        * DumpRenderTree/TestRunner.h:
+        * DumpRenderTree/mac/TestRunnerMac.mm:
+        (TestRunner::setWebViewEditable): Deleted.
+        * DumpRenderTree/mac/UIScriptControllerMac.h:
+        * DumpRenderTree/mac/UIScriptControllerMac.mm:
+        (WTR::UIScriptControllerMac::setWebViewEditable):
+        * DumpRenderTree/win/TestRunnerWin.cpp:
+        (TestRunner::~TestRunner):
+        (TestRunner::setWebViewEditable): Deleted.
+        * DumpRenderTree/win/UIScriptControllerWin.cpp:
+        (WTR::UIScriptControllerWin::setWebViewEditable):
+        * DumpRenderTree/win/UIScriptControllerWin.h:
+        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+        * TestRunnerShared/UIScriptContext/UIScriptController.h:
+        (WTR::UIScriptController::setWebViewEditable):
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::cocoaResetStateToConsistentValues):
+        * WebKitTestRunner/cocoa/UIScriptControllerCocoa.h:
+        * WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm:
+        (WTR::UIScriptControllerCocoa::setWebViewEditable):
+        * WebKitTestRunner/gtk/TestControllerGtk.cpp:
+        (WTR::TestController::platformResetStateToConsistentValues):
+        * WebKitTestRunner/gtk/UIScriptControllerGtk.cpp:
+        (WTR::UIScriptControllerGtk::setWebViewEditable):
+        * WebKitTestRunner/gtk/UIScriptControllerGtk.h:
+
 2022-02-17  Sihui Liu  <sihui_...@apple.com>
 
         Ensure NetworkStorageManager::moveData performs move operation based on data types

Modified: trunk/Tools/DumpRenderTree/TestRunner.cpp (290097 => 290098)


--- trunk/Tools/DumpRenderTree/TestRunner.cpp	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/DumpRenderTree/TestRunner.cpp	2022-02-18 01:03:50 UTC (rev 290098)
@@ -1464,18 +1464,6 @@
     return JSValueMakeUndefined(context);
 }
 
-static JSValueRef setWebViewEditableCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
-{
-    // Has Mac implementation
-    if (argumentCount < 1)
-        return JSValueMakeUndefined(context);
-
-    TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
-    controller->setWebViewEditable(JSValueToBoolean(context, arguments[0]));
-
-    return JSValueMakeUndefined(context);
-}
-
 static JSValueRef abortModalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -2080,7 +2068,6 @@
         { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setValueForUser", setValueForUserCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
-        { "setWebViewEditable", setWebViewEditableCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setWillSendRequestClearHeader", setWillSendRequestClearHeaderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setWillSendRequestReturnsNull", setWillSendRequestReturnsNullCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setWillSendRequestReturnsNullOnRedirect", setWillSendRequestReturnsNullOnRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },

Modified: trunk/Tools/DumpRenderTree/TestRunner.h (290097 => 290098)


--- trunk/Tools/DumpRenderTree/TestRunner.h	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/DumpRenderTree/TestRunner.h	2022-02-18 01:03:50 UTC (rev 290098)
@@ -334,8 +334,6 @@
 
     void setPOSIXLocale(JSStringRef);
 
-    void setWebViewEditable(bool);
-
     void abortModal();
 
     static void setSerializeHTTPLoads(bool);

Modified: trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm (290097 => 290098)


--- trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm	2022-02-18 01:03:50 UTC (rev 290098)
@@ -958,12 +958,6 @@
     [view goToBackForwardItem:[[view backForwardList] currentItem]];
 }
 
-void TestRunner::setWebViewEditable(bool editable)
-{
-    WebView *view = [mainFrame webView];
-    [view setEditable:editable];
-}
-
 static NSString *SynchronousLoaderRunLoopMode = @"DumpRenderTreeSynchronousLoaderRunLoopMode";
 
 @interface SynchronousLoader : NSObject <NSURLConnectionDelegate>

Modified: trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.h (290097 => 290098)


--- trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.h	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.h	2022-02-18 01:03:50 UTC (rev 290098)
@@ -47,6 +47,7 @@
     void removeViewFromWindow(JSValueRef) override;
     void addViewToWindow(JSValueRef) override;
     void toggleCapsLock(JSValueRef) override;
+    void setWebViewEditable(bool) override;
     void simulateAccessibilitySettingsChangeNotification(JSValueRef) override;
     NSUndoManager *platformUndoManager() const override;
     void copyText(JSStringRef) override;

Modified: trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm (290097 => 290098)


--- trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm	2022-02-18 01:03:50 UTC (rev 290098)
@@ -158,6 +158,11 @@
     doAsyncTask(callback);
 }
 
+void UIScriptControllerMac::setWebViewEditable(bool editable)
+{
+    [mainFrame webView].editable = editable;
+}
+
 NSUndoManager *UIScriptControllerMac::platformUndoManager() const
 {
     return nil;

Modified: trunk/Tools/DumpRenderTree/win/TestRunnerWin.cpp (290097 => 290098)


--- trunk/Tools/DumpRenderTree/win/TestRunnerWin.cpp	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/DumpRenderTree/win/TestRunnerWin.cpp	2022-02-18 01:03:50 UTC (rev 290098)
@@ -66,6 +66,8 @@
     COMPtr<IWebViewEditing> viewEditing;
     if (FAILED(webView->QueryInterface(&viewEditing)))
         return;
+    viewEditing->setEditable(FALSE);
+
     COMPtr<IWebEditingDelegate> delegate;
     if (FAILED(viewEditing->editingDelegate(&delegate)))
         return;
@@ -1100,19 +1102,6 @@
     webView->goToBackForwardItem(item.get(), &success);
 }
 
-void TestRunner::setWebViewEditable(bool editable)
-{
-    COMPtr<IWebView> webView;
-    if (FAILED(frame->webView(&webView)))
-        return;
-
-    COMPtr<IWebViewEditing> viewEditing;
-    if (FAILED(webView->QueryInterface(&viewEditing)))
-        return;
-
-    viewEditing->setEditable(editable);
-}
-
 void TestRunner::authenticateSession(JSStringRef, JSStringRef, JSStringRef)
 {
     fprintf(testResult, "ERROR: TestRunner::authenticateSession() not implemented\n");

Modified: trunk/Tools/DumpRenderTree/win/UIScriptControllerWin.cpp (290097 => 290098)


--- trunk/Tools/DumpRenderTree/win/UIScriptControllerWin.cpp	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/DumpRenderTree/win/UIScriptControllerWin.cpp	2022-02-18 01:03:50 UTC (rev 290098)
@@ -70,4 +70,17 @@
     return 1;
 }
 
+void UIScriptControllerWin::setWebViewEditable(bool editable)
+{
+    COMPtr<IWebView> webView;
+    if (FAILED(frame->webView(&webView)))
+        return;
+
+    COMPtr<IWebViewEditing> viewEditing;
+    if (FAILED(webView->QueryInterface(&viewEditing)))
+        return;
+
+    viewEditing->setEditable(editable);
 }
+
+}

Modified: trunk/Tools/DumpRenderTree/win/UIScriptControllerWin.h (290097 => 290098)


--- trunk/Tools/DumpRenderTree/win/UIScriptControllerWin.h	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/DumpRenderTree/win/UIScriptControllerWin.h	2022-02-18 01:03:50 UTC (rev 290098)
@@ -39,6 +39,7 @@
     void doAsyncTask(JSValueRef) override;
     void zoomToScale(double, JSValueRef) override;
     double zoomScale() const override;
+    void setWebViewEditable(bool) override;
 };
 
 }

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (290097 => 290098)


--- trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2022-02-18 01:03:50 UTC (rev 290098)
@@ -365,6 +365,8 @@
 
     undefined setHardwareKeyboardAttached(boolean attached);
 
+    undefined setWebViewEditable(boolean editable);
+
     object attachmentInfo(DOMString attachmentIdentifier);
     undefined insertAttachmentForFilePath(DOMString filePath, DOMString contentType, object callback);
 

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (290097 => 290098)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2022-02-18 01:03:50 UTC (rev 290098)
@@ -197,6 +197,8 @@
         return nullptr;
     }
 
+    virtual void setWebViewEditable(bool) { }
+
     virtual void rawKeyDown(JSStringRef) { notImplemented(); }
     virtual void rawKeyUp(JSStringRef) { notImplemented(); }
 

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (290097 => 290098)


--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2022-02-18 01:03:50 UTC (rev 290098)
@@ -311,6 +311,7 @@
         TestRunnerWKWebView *platformView = webView->platformView();
         platformView._viewScale = 1;
         platformView._minimumEffectiveDeviceWidth = 0;
+        platformView._editable = NO;
         [platformView _setContinuousSpellCheckingEnabledForTesting:options.shouldShowSpellCheckingDots()];
         [platformView resetInteractionCallbacks];
         [platformView _resetNavigationGestureStateForTesting];

Modified: trunk/Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.h (290097 => 290098)


--- trunk/Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.h	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.h	2022-02-18 01:03:50 UTC (rev 290098)
@@ -41,6 +41,7 @@
 private:
     void setViewScale(double) override;
     void setMinimumEffectiveWidth(double) override;
+    void setWebViewEditable(bool) override;
     void becomeFirstResponder() override;
     void resignFirstResponder() override;
     void removeViewFromWindow(JSValueRef) override;

Modified: trunk/Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm (290097 => 290098)


--- trunk/Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm	2022-02-18 01:03:50 UTC (rev 290098)
@@ -63,6 +63,11 @@
     webView()._minimumEffectiveDeviceWidth = effectiveWidth;
 }
 
+void UIScriptControllerCocoa::setWebViewEditable(bool editable)
+{
+    webView()._editable = editable;
+}
+
 void UIScriptControllerCocoa::becomeFirstResponder()
 {
     [webView() becomeFirstResponder];

Modified: trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp (290097 => 290098)


--- trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp	2022-02-18 01:03:50 UTC (rev 290098)
@@ -29,6 +29,7 @@
 
 #include "PlatformWebView.h"
 #include <WebKit/WKTextCheckerGLib.h>
+#include <WebKit/WKViewPrivate.h>
 #include <gtk/gtk.h>
 #include <wtf/Platform.h>
 #include <wtf/RunLoop.h>
@@ -147,8 +148,10 @@
 
 bool TestController::platformResetStateToConsistentValues(const TestOptions&)
 {
-    if (m_mainWebView)
+    if (m_mainWebView) {
         m_mainWebView->dismissAllPopupMenus();
+        WKViewSetEditable(m_mainWebView->platformView(), false);
+    }
 
     WKTextCheckerContinuousSpellCheckingEnabledStateChanged(true);
     return true;

Modified: trunk/Tools/WebKitTestRunner/gtk/UIScriptControllerGtk.cpp (290097 => 290098)


--- trunk/Tools/WebKitTestRunner/gtk/UIScriptControllerGtk.cpp	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/WebKitTestRunner/gtk/UIScriptControllerGtk.cpp	2022-02-18 01:03:50 UTC (rev 290098)
@@ -203,4 +203,10 @@
     return JSValueToObject(m_context->jsContext(), contentDictionary ? JSValueMakeFromJSONString(m_context->jsContext(), createJSString(jsonObject->toJSONString().utf8().data()).get()) : JSValueMakeUndefined(m_context->jsContext()), nullptr);
 }
 
+void UIScriptControllerGtk::setWebViewEditable(bool editable)
+{
+    auto* webView = TestController::singleton().mainWebView()->platformView();
+    WKViewSetEditable(webView, editable);
+}
+
 } // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/gtk/UIScriptControllerGtk.h (290097 => 290098)


--- trunk/Tools/WebKitTestRunner/gtk/UIScriptControllerGtk.h	2022-02-18 01:00:48 UTC (rev 290097)
+++ trunk/Tools/WebKitTestRunner/gtk/UIScriptControllerGtk.h	2022-02-18 01:03:50 UTC (rev 290098)
@@ -52,6 +52,7 @@
     void simulateAccessibilitySettingsChangeNotification(JSValueRef) override;
     void removeViewFromWindow(JSValueRef) override;
     void addViewToWindow(JSValueRef) override;
+    void setWebViewEditable(bool) override;
 
 private:
     void overridePreference(JSStringRef, JSStringRef) override;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to