Title: [181397] trunk
- Revision
- 181397
- Author
- timothy_hor...@apple.com
- Date
- 2015-03-11 11:21:05 -0700 (Wed, 11 Mar 2015)
Log Message
<attachment>s should be created when dropping files onto contentEditable areas
https://bugs.webkit.org/show_bug.cgi?id=142494
<rdar://problem/19982553>
Reviewed by Anders Carlsson.
Covered by existing tests.
* editing/mac/EditorMac.mm:
(WebCore::Editor::WebContentReader::readFilenames):
Instead of inserting the dropped URLs as strings, make an <attachment>
for each.
* editing/pasteboard/drag-files-to-editable-element-expected.txt:
* editing/pasteboard/drag-files-to-editable-element.html:
Update the test to expect <attachment>s instead of filenames.
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (181396 => 181397)
--- trunk/LayoutTests/ChangeLog 2015-03-11 18:13:45 UTC (rev 181396)
+++ trunk/LayoutTests/ChangeLog 2015-03-11 18:21:05 UTC (rev 181397)
@@ -1,3 +1,15 @@
+2015-03-11 Tim Horton <timothy_hor...@apple.com>
+
+ <attachment>s should be created when dropping files onto contentEditable areas
+ https://bugs.webkit.org/show_bug.cgi?id=142494
+ <rdar://problem/19982553>
+
+ Reviewed by Anders Carlsson.
+
+ * editing/pasteboard/drag-files-to-editable-element-expected.txt:
+ * editing/pasteboard/drag-files-to-editable-element.html:
+ Update the test to expect <attachment>s instead of filenames.
+
2015-03-11 David Hyatt <hy...@apple.com>
Optimize offsetWidth and offsetHeight to avoid doing layouts.
Modified: trunk/LayoutTests/editing/pasteboard/drag-files-to-editable-element-expected.txt (181396 => 181397)
--- trunk/LayoutTests/editing/pasteboard/drag-files-to-editable-element-expected.txt 2015-03-11 18:13:45 UTC (rev 181396)
+++ trunk/LayoutTests/editing/pasteboard/drag-files-to-editable-element-expected.txt 2015-03-11 18:21:05 UTC (rev 181397)
@@ -1,9 +1,12 @@
-If we drag files onto an editable area, then the filenames should be inserted into the editable area.
+If we drag files onto an editable area, then attachments 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 attachment.nodeName is "ATTACHMENT"
+PASS attachment.nodeName is "ATTACHMENT"
+PASS attachment.nodeName is "ATTACHMENT"
+PASS fileNames is "foo bar baz "
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/editing/pasteboard/drag-files-to-editable-element.html (181396 => 181397)
--- trunk/LayoutTests/editing/pasteboard/drag-files-to-editable-element.html 2015-03-11 18:13:45 UTC (rev 181396)
+++ trunk/LayoutTests/editing/pasteboard/drag-files-to-editable-element.html 2015-03-11 18:21:05 UTC (rev 181397)
@@ -7,13 +7,19 @@
<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.');
+description('If we drag files onto an editable area, then attachments 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>');
+ var resultChildren = editable.children;
+ var fileNames = "";
+ for (var i = 0; i < resultChildren.length; i++) {
+ var attachment = resultChildren[i];
+ shouldBeEqualToString('attachment.nodeName', 'ATTACHMENT');
+ fileNames += attachment.file.name + " ";
+ }
+ shouldBeEqualToString('fileNames', 'foo bar baz ');
editable.innerHTML = '';
}
Modified: trunk/Source/WebCore/ChangeLog (181396 => 181397)
--- trunk/Source/WebCore/ChangeLog 2015-03-11 18:13:45 UTC (rev 181396)
+++ trunk/Source/WebCore/ChangeLog 2015-03-11 18:21:05 UTC (rev 181397)
@@ -1,3 +1,18 @@
+2015-03-11 Timothy Horton <timothy_hor...@apple.com>
+
+ <attachment>s should be created when dropping files onto contentEditable areas
+ https://bugs.webkit.org/show_bug.cgi?id=142494
+ <rdar://problem/19982553>
+
+ Reviewed by Anders Carlsson.
+
+ Covered by existing tests.
+
+ * editing/mac/EditorMac.mm:
+ (WebCore::Editor::WebContentReader::readFilenames):
+ Instead of inserting the dropped URLs as strings, make an <attachment>
+ for each.
+
2015-03-11 David Hyatt <hy...@apple.com>
Optimize offsetWidth and offsetHeight to avoid doing layouts.
Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (181396 => 181397)
--- trunk/Source/WebCore/editing/mac/EditorMac.mm 2015-03-11 18:13:45 UTC (rev 181396)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm 2015-03-11 18:21:05 UTC (rev 181397)
@@ -37,10 +37,12 @@
#import "DocumentLoader.h"
#import "Editor.h"
#import "EditorClient.h"
+#import "File.h"
#import "FontCascade.h"
#import "Frame.h"
#import "FrameLoaderClient.h"
#import "FrameView.h"
+#import "HTMLAttachmentElement.h"
#import "HTMLConverter.h"
#import "HTMLElement.h"
#import "HTMLNames.h"
@@ -529,11 +531,17 @@
for (size_t i = 0; i < size; i++) {
String text = paths[i];
+#if ENABLE(ATTACHMENT_ELEMENT)
+ RefPtr<HTMLAttachmentElement> attachment = HTMLAttachmentElement::create(attachmentTag, document);
+ attachment->setFile(File::create([[NSURL fileURLWithPath:text] path]).ptr());
+ fragment->appendChild(attachment.release());
+#else
text = frame.editor().client()->userVisibleString([NSURL fileURLWithPath:text]);
RefPtr<HTMLElement> paragraph = createDefaultParagraphElement(document);
paragraph->appendChild(document.createTextNode(text));
fragment->appendChild(paragraph.release());
+#endif
}
return true;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes