Title: [102392] trunk
- Revision
- 102392
- Author
- rn...@webkit.org
- Date
- 2011-12-08 16:15:26 -0800 (Thu, 08 Dec 2011)
Log Message
Line breaks are lost when pasted into textarea text starting with a blank line set while textarea is hidden
https://bugs.webkit.org/show_bug.cgi?id=74126
Reviewed by Tony Chang.
The bug was caused by the code that generated text out of pre-rendered text was generating div's inside the fragment
pasted into textarea even though serialization algorithm in textarea doesn't handle block elements.
Fixed the bug by special-casing this in createFragmentFromText. In the long run, we should really get rid of this
whole pre-rendering trick.
* editing/markup.cpp:
(WebCore::createFragmentFromText):
Modified Paths
Added Paths
Diff
Added: trunk/LayoutTests/editing/input/paste-linebreak-into-initially-hidden-textarea-expected.txt (0 => 102392)
--- trunk/LayoutTests/editing/input/paste-linebreak-into-initially-hidden-textarea-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/input/paste-linebreak-into-initially-hidden-textarea-expected.txt 2011-12-09 00:15:26 UTC (rev 102392)
@@ -0,0 +1,4 @@
+This tests pasting into a textarea that starts with a line break that didn't initially have a renderer (display: none). WebKit should still be able to paste text with line breaks.
+
+
+PASS
Added: trunk/LayoutTests/editing/input/paste-linebreak-into-initially-hidden-textarea.html (0 => 102392)
--- trunk/LayoutTests/editing/input/paste-linebreak-into-initially-hidden-textarea.html (rev 0)
+++ trunk/LayoutTests/editing/input/paste-linebreak-into-initially-hidden-textarea.html 2011-12-09 00:15:26 UTC (rev 102392)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests pasting into a textarea that starts with a line break that didn't initially have a renderer (display: none).
+WebKit should still be able to paste text with line breaks.</p>
+<textarea id="test" style="display: none" cols="50" rows="10"></textarea>
+<div id="log"></div>
+<script type="text/_javascript_">
+
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+var textarea = document.querySelector('textarea');
+textarea.value = "\nwebkit";
+textarea.style.display = "";
+
+textarea.focus();
+textarea.selectionStart = textarea.selectionEnd = 0;
+document.execCommand('insertHTML', false, 'hello\nworld\n');
+
+var expected = 'hello\nworld\nwebkit';
+if (textarea.value == expected)
+ document.getElementById('log').innerText = 'PASS';
+else
+ document.getElementById('log').innerText = 'FAILED: expected "' + expected + '" but got "' + textarea.value + '"';
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (102391 => 102392)
--- trunk/Source/WebCore/ChangeLog 2011-12-09 00:07:10 UTC (rev 102391)
+++ trunk/Source/WebCore/ChangeLog 2011-12-09 00:15:26 UTC (rev 102392)
@@ -1,3 +1,19 @@
+2011-12-08 Ryosuke Niwa <rn...@webkit.org>
+
+ Line breaks are lost when pasted into textarea text starting with a blank line set while textarea is hidden
+ https://bugs.webkit.org/show_bug.cgi?id=74126
+
+ Reviewed by Tony Chang.
+
+ The bug was caused by the code that generated text out of pre-rendered text was generating div's inside the fragment
+ pasted into textarea even though serialization algorithm in textarea doesn't handle block elements.
+
+ Fixed the bug by special-casing this in createFragmentFromText. In the long run, we should really get rid of this
+ whole pre-rendering trick.
+
+ * editing/markup.cpp:
+ (WebCore::createFragmentFromText):
+
2011-12-08 Florin Malita <fmal...@google.com>
Moving SVG elements on the page doesn't always erase element at the old position
Modified: trunk/Source/WebCore/editing/markup.cpp (102391 => 102392)
--- trunk/Source/WebCore/editing/markup.cpp 2011-12-09 00:07:10 UTC (rev 102391)
+++ trunk/Source/WebCore/editing/markup.cpp 2011-12-09 00:15:26 UTC (rev 102392)
@@ -49,6 +49,7 @@
#include "HTMLBodyElement.h"
#include "HTMLElement.h"
#include "HTMLNames.h"
+#include "HTMLTextFormControlElement.h"
#include "KURL.h"
#include "MarkupAccumulator.h"
#include "Range.h"
@@ -880,7 +881,8 @@
&& !block->hasTagName(bodyTag)
&& !block->hasTagName(htmlTag)
&& block != editableRootForPosition(context->startPosition());
-
+ bool useLineBreak = enclosingTextFormControl(context->startPosition());
+
Vector<String> list;
string.split('\n', true, list); // true gets us empty strings in the list
size_t numLines = list.size();
@@ -891,7 +893,10 @@
if (s.isEmpty() && i + 1 == numLines) {
// For last line, use the "magic BR" rather than a P.
element = createBreakElement(document);
- element->setAttribute(classAttr, AppleInterchangeNewline);
+ element->setAttribute(classAttr, AppleInterchangeNewline);
+ } else if (useLineBreak) {
+ element = createBreakElement(document);
+ fillContainerFromString(fragment.get(), s);
} else {
if (useClonesOfEnclosingBlock)
element = block->cloneElementWithoutChildren();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes