[Mac] PasteboardMac.mm build fails
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Feb 2012 06:14:48 +0000 (06:14 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Feb 2012 06:14:48 +0000 (06:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=78655

Reviewed by Enrica Casucci.

Source/WebCore:

This patch fixes the code to make a plain text for pasted file names.
The code should return a string of concatenated file names.

Test: editing/pasteboard/drag-files-to-editable-element.html

* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::plainText):

LayoutTests:

The added test drops multiple files onto an editable element,
and checks if the filenames are inserted into the editable element.

* editing/pasteboard/drag-files-to-editable-element-expected.txt: Added.
* editing/pasteboard/drag-files-to-editable-element.html: Added.
* platform/chromium/test_expectations.txt:
* platform/efl/Skipped:
* platform/gtk/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
* platform/wk2/Skipped:

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

LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/drag-files-to-editable-element-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/drag-files-to-editable-element.html [new file with mode: 0644]
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/efl/Skipped
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/qt/Skipped
LayoutTests/platform/win/Skipped
LayoutTests/platform/wk2/Skipped
Source/WebCore/ChangeLog
Source/WebCore/platform/mac/PasteboardMac.mm

index e5b3440..2b8542d 100644 (file)
@@ -1,3 +1,22 @@
+2012-02-15  Kentaro Hara  <haraken@chromium.org>
+
+        [Mac] PasteboardMac.mm build fails
+        https://bugs.webkit.org/show_bug.cgi?id=78655
+
+        Reviewed by Enrica Casucci.
+
+        The added test drops multiple files onto an editable element,
+        and checks if the filenames are inserted into the editable element.
+
+        * editing/pasteboard/drag-files-to-editable-element-expected.txt: Added.
+        * editing/pasteboard/drag-files-to-editable-element.html: Added.
+        * platform/chromium/test_expectations.txt:
+        * platform/efl/Skipped:
+        * platform/gtk/Skipped:
+        * platform/qt/Skipped:
+        * platform/win/Skipped:
+        * platform/wk2/Skipped:
+
 2012-02-15  Ilya Tikhonovsky  <loislo@chromium.org>
 
         [chromium] Unreviewed rebaseline after r107864.
diff --git a/LayoutTests/editing/pasteboard/drag-files-to-editable-element-expected.txt b/LayoutTests/editing/pasteboard/drag-files-to-editable-element-expected.txt
new file mode 100644 (file)
index 0000000..515d15a
--- /dev/null
@@ -0,0 +1,10 @@
+If we drag files onto an editable area, then the filenames should be inserted into the editable area.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS result is "<div>LayoutTests/editing/pasteboard/foo</div><div>LayoutTests/editing/pasteboard/bar</div><div>LayoutTests/editing/pasteboard/baz</div>"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/editing/pasteboard/drag-files-to-editable-element.html b/LayoutTests/editing/pasteboard/drag-files-to-editable-element.html
new file mode 100644 (file)
index 0000000..024b229
--- /dev/null
@@ -0,0 +1,38 @@
+<html>
+<head>
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<div id="editable" contentEditable=true style="width:200px; height:200px"></div>
+<script>
+description('If we drag files onto an editable area, then the filenames should be inserted into the editable area.');
+
+var editable = document.getElementById("editable");
+if (window.eventSender) {
+    dragFilesOntoEditable(['foo', 'bar', 'baz']);
+    var result = editable.innerHTML.replace(/file.*?LayoutTests/g, "LayoutTests");
+    shouldBeEqualToString('result', '<div>LayoutTests/editing/pasteboard/foo</div><div>LayoutTests/editing/pasteboard/bar</div><div>LayoutTests/editing/pasteboard/baz</div>');
+    editable.innerHTML = '';
+}
+
+function moveMouseToCenterOfElement(element)
+{
+    var centerX = element.offsetLeft + element.offsetWidth / 2;
+    var centerY = element.offsetTop + element.offsetHeight / 2;
+    eventSender.mouseMoveTo(centerX, centerY);
+}
+
+function dragFilesOntoEditable(files)
+{
+    eventSender.beginDragWithFiles(files);
+    moveMouseToCenterOfElement(editable);
+    eventSender.mouseUp();
+}
+
+var successfullyParsed = true;
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 6639c66..02c85b8 100644 (file)
@@ -825,6 +825,9 @@ BUGWK61611 LINUX WIN : editing/pasteboard/interchange-newline-2.html = TEXT
 BUGWK61624 WIN : editing/pasteboard/smart-paste-003.html = TEXT
 BUGWK61624 WIN : editing/pasteboard/smart-paste-004.html = TEXT
 
+// PasteBoard::plainText() does not support file names.
+BUGWK78655 : editing/pasteboard/drag-files-to-editable-element.html = FAIL
+
 // New test in r93068
 BUGWK66268 WIN LINUX : editing/deleting/regional-indicators.html = TEXT
 
index 9b155e9..c9ec479 100644 (file)
@@ -1249,6 +1249,9 @@ fast/dom/Window/slow-unload-handler-only-frame-is-stopped.html
 # The EFL port has no global history delegate
 http/tests/globalhistory
 
+# PasteBoard::plainText() does not support file names.
+editing/pasteboard/drag-files-to-editable-element.html
+
 # Fails because MutationObservers are not notified at end-of-task
 # https://bugs.webkit.org/show_bug.cgi?id=78290
 fast/mutation/end-of-task-delivery.html
index 2be00cf..135568b 100644 (file)
@@ -299,6 +299,9 @@ editing/pasteboard/data-transfer-items-drag-drop-string.html
 editing/pasteboard/clipboard-customData.html
 fast/events/drag-customData.html
 
+# PasteBoard::plainText() does not support file names.
+editing/pasteboard/drag-files-to-editable-element.html
+
 # Needs grammar checking.
 editing/spelling/markers.html
 
index 27cdc91..d9c847d 100644 (file)
@@ -411,6 +411,9 @@ editing/pasteboard/data-transfer-items.html
 editing/pasteboard/data-transfer-items-drag-drop-file.html
 editing/pasteboard/data-transfer-items-drag-drop-string.html
 
+# PasteBoard::plainText() does not support file names.
+editing/pasteboard/drag-files-to-editable-element.html
+
 # Missing drag & drop functionality in DRT
 editing/pasteboard/drop-inputtext-acquires-style.html
 fast/css/user-drag-none.html
index bdde24c..a0e9e2b 100644 (file)
@@ -155,6 +155,9 @@ http/tests/security/drag-drop-same-unique-origin.html
 # https://bugs.webkit.org/show_bug.cgi?id=61829
 fast/events/drag-image-filename.html
 
+# PasteBoard::plainText() does not support file names.
+editing/pasteboard/drag-files-to-editable-element.html
+
 # <rdar://problem/5643675> window.scrollTo scrolls a window with no scrollbars
 fast/events/attempt-scroll-with-no-scrollbars.html
 
index fab7474..ea849ad 100644 (file)
@@ -824,6 +824,9 @@ platform/mac/fast/text/rounding-hacks-expansion.html
 # http://webkit.org/b/58990
 editing/undo/undo-iframe-location-change.html
 
+# PasteBoard::plainText() does not support file names.
+editing/pasteboard/drag-files-to-editable-element.html
+
 # Times out
 # https://bugs.webkit.org/show_bug.cgi?id=63806
 http/tests/cache/history-only-cached-subresource-loads-max-age-https.html
index 52f426f..8266605 100644 (file)
@@ -1,3 +1,18 @@
+2012-02-15  Kentaro Hara  <haraken@chromium.org>
+
+        [Mac] PasteboardMac.mm build fails
+        https://bugs.webkit.org/show_bug.cgi?id=78655
+
+        Reviewed by Enrica Casucci.
+
+        This patch fixes the code to make a plain text for pasted file names.
+        The code should return a string of concatenated file names.
+
+        Test: editing/pasteboard/drag-files-to-editable-element.html
+
+        * platform/mac/PasteboardMac.mm:
+        (WebCore::Pasteboard::plainText):
+
 2012-02-15  Anders Carlsson  <andersca@apple.com>
 
         Another attempt at fixing the Snow Leopard build.
index dce160d..6e4bda8 100644 (file)
@@ -56,6 +56,7 @@
 #import <wtf/StdLibExtras.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/UnusedParam.h>
+#import <wtf/text/StringBuilder.h>
 #import <wtf/unicode/CharacterNames.h>
 
 #if USE(PLATFORM_STRATEGIES)
@@ -316,7 +317,7 @@ String Pasteboard::plainText(Frame* frame)
         return [(NSString *)platformStrategies()->pasteboardStrategy()->stringForType(NSStringPboardType, m_pasteboardName) precomposedStringWithCanonicalMapping];
     
     NSAttributedString *attributedString = nil;
-    NSString *string = nil;
+    NSString *string;
 
     if (types.contains(String(NSRTFDPboardType))) {
         RefPtr<SharedBuffer> data = platformStrategies()->pasteboardStrategy()->bufferForType(NSRTFDPboardType, m_pasteboardName);
@@ -335,11 +336,11 @@ String Pasteboard::plainText(Frame* frame)
     if (types.contains(String(NSFilenamesPboardType))) {
         Vector<String> pathnames;
         platformStrategies()->pasteboardStrategy()->getPathnamesForType(pathnames, NSFilenamesPboardType, m_pasteboardName);
+        StringBuilder builder;
         for (size_t i = 0; i < pathnames.size(); i++)
-            string = [string length] ? @"\n" + pathnames[i] : pathnames[i];
-        string = [string precomposedStringWithCanonicalMapping];
-        if (string != nil)
-            return string;
+            builder.append(i ? "\n" + pathnames[i] : pathnames[i]);
+        string = builder.toString();
+        return [string precomposedStringWithCanonicalMapping];
     }
     
     string = platformStrategies()->pasteboardStrategy()->stringForType(NSURLPboardType, m_pasteboardName);