WebCore:
authoradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Aug 2007 18:51:05 +0000 (18:51 +0000)
committeradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Aug 2007 18:51:05 +0000 (18:51 +0000)
        Reviewed by Justin.

        Fix for <rdar://problem/5450600> REGRESSION: can't paste in textfield if its in a body that has user-select:none set (affects widgets)

        Test: editing/pasteboard/paste-plaintext-user-select-none.html

        * editing/ReplaceSelectionCommand.cpp: (WebCore::ReplacementFragment::insertFragmentForTestRendering):
          Copy the user-select style from the current selection node and apply it so it is considered during the test rendering.
          This is important since we recently changed user-select to be inherited.  When we consider valid VisiblePositions for the test rendering,
          we need to have the correct user-select value that will actually be used for the real insertion.

LayoutTests:

        Reviewed by Justin.

        Test for <rdar://problem/5450600> REGRESSION: can't paste in textfield if its in a body that has user-select:none set (affects widgets)

        * editing/pasteboard/paste-plaintext-user-select-none-expected.txt: Added.
        * editing/pasteboard/paste-plaintext-user-select-none.html: Added.
        * fast/forms/textarea-paste-newline.html: Updated to escape '\n' in failure description.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@25332 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/paste-plaintext-user-select-none-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/paste-plaintext-user-select-none.html [new file with mode: 0644]
LayoutTests/fast/forms/textarea-paste-newline.html
WebCore/ChangeLog
WebCore/editing/ReplaceSelectionCommand.cpp

index 516b95c..79ddbbc 100644 (file)
@@ -1,3 +1,13 @@
+2007-08-30  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Justin.
+
+        Test for <rdar://problem/5450600> REGRESSION: can't paste in textfield if its in a body that has user-select:none set (affects widgets)
+
+        * editing/pasteboard/paste-plaintext-user-select-none-expected.txt: Added.
+        * editing/pasteboard/paste-plaintext-user-select-none.html: Added.
+        * fast/forms/textarea-paste-newline.html: Updated to escape '\n' in failure description.
+
 2007-08-30  Oliver Hunt <oliver@apple.com>
 
         Reviewed by Adam.
diff --git a/LayoutTests/editing/pasteboard/paste-plaintext-user-select-none-expected.txt b/LayoutTests/editing/pasteboard/paste-plaintext-user-select-none-expected.txt
new file mode 100644 (file)
index 0000000..74ca744
--- /dev/null
@@ -0,0 +1,12 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertText:Test Passed replacingDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 11 of #text > DIV > BODY > HTML > #document to 11 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+This tests that you can paste into a plain-text editable area even if the body has user-select:none set on it. 
+Test Passed
diff --git a/LayoutTests/editing/pasteboard/paste-plaintext-user-select-none.html b/LayoutTests/editing/pasteboard/paste-plaintext-user-select-none.html
new file mode 100644 (file)
index 0000000..a1bf7d1
--- /dev/null
@@ -0,0 +1,35 @@
+<html> 
+<head>
+    <style>
+        body {
+            -webkit-user-select: none;
+        }
+
+        .editing { 
+            border: 2px solid red; 
+            padding: 12px; 
+            font-size: 24px;
+            -webkit-user-select: text;
+            -webkit-user-modify: read-write-plaintext-only;
+        }
+    </style>
+    <script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+    <script>
+        function editingTest() {
+            if (window.layoutTestController)
+                layoutTestController.dumpAsText();
+            
+            document.getElementById('tf').focus();
+            copyCommand();
+
+            document.getElementById('root').focus();
+            pasteCommand();
+        }
+    </script>
+</head> 
+    <body onload="runEditingTest();">
+        This tests that you can paste into a plain-text editable area even if the body has user-select:none set on it.
+        <input id="tf" value="Test Passed">
+        <div id="root" class="editing"></div>
+    </body>
+</html>
index de7e9e8..c5f066b 100644 (file)
@@ -19,7 +19,7 @@ function test()
     else if (result1 == "")
         document.write("<p>The test failed; doesn't work in release builds of Safari because paste is not allowed.</p>");
     else
-        document.write("<p>The test failed, result 1 was '" + result1.replace("\n", "\\n") + "' and result 2 was '" + result2.replace("\n", "\\n") + "'. This test demonstrates a bug (5299425): the final '\n' in a textarea is reported by .value even if it is collapsed.</p>");
+        document.write("<p>The test failed, result 1 was '" + result1.replace("\n", "\\n") + "' and result 2 was '" + result2.replace("\n", "\\n") + "'. This test demonstrates a bug (5299425): the final '\\n' in a textarea is reported by .value even if it is collapsed.</p>");
 }
 </script>
 <body onload="test()">
index d9fd207..aa6659f 100644 (file)
@@ -1,3 +1,16 @@
+2007-08-30  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Justin.
+
+        Fix for <rdar://problem/5450600> REGRESSION: can't paste in textfield if its in a body that has user-select:none set (affects widgets)
+
+        Test: editing/pasteboard/paste-plaintext-user-select-none.html
+
+        * editing/ReplaceSelectionCommand.cpp: (WebCore::ReplacementFragment::insertFragmentForTestRendering):
+          Copy the user-select style from the current selection node and apply it so it is considered during the test rendering.
+          This is important since we recently changed user-select to be inherited.  When we consider valid VisiblePositions for the test rendering,
+          we need to have the correct user-select value that will actually be used for the real insertion.
+
 2007-08-31  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Oliver.
@@ -11,7 +24,7 @@
         * plugins/win/PluginStreamWin.cpp:
         (WebCore::PluginStreamWin::didReceiveData):
 
-2007-08-31  Darin Adler  <darin@apple.com>
+a2007-08-31  Darin Adler  <darin@apple.com>
 
         Reviewed by Anders.
 
index aec25d9..671a91b 100644 (file)
@@ -189,7 +189,8 @@ PassRefPtr<Node> ReplacementFragment::insertFragmentForTestRendering(Node* conte
     
     ExceptionCode ec = 0;
 
-    // Copy the whitespace style from the context onto this element.
+    // Copy the whitespace and user-select style from the context onto this element.
+    // FIXME: We should examine other style properties to see if they would be appropriate to consider during the test rendering.
     Node* n = context;
     while (n && !n->isElementNode())
         n = n->parentNode();
@@ -198,6 +199,8 @@ PassRefPtr<Node> ReplacementFragment::insertFragmentForTestRendering(Node* conte
         CSSStyleDeclaration* style = holder->style();
         style->setProperty(CSS_PROP_WHITE_SPACE, contextStyle->getPropertyValue(CSS_PROP_WHITE_SPACE), false, ec);
         ASSERT(ec == 0);
+        style->setProperty(CSS_PROP__WEBKIT_USER_SELECT, contextStyle->getPropertyValue(CSS_PROP__WEBKIT_USER_SELECT), false, ec);
+        ASSERT(ec == 0);
     }
     
     holder->appendChild(m_fragment, ec);