<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[19949] trunk</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/19949">19949</a></dd>
<dt>Author</dt> <dd>justing</dd>
<dt>Date</dt> <dd>2007-03-02 15:02:49 -0800 (Fri, 02 Mar 2007)</dd>
</dl>
<h3>Log Message</h3>
<pre>LayoutTests:
Reviewed by harrison
<rdar://problem/4545040>
innerHTML does not HTML-escape text nodes inside PRE elements
<rdar://problem/5027857>
Pasting into Mail from Safari's view-source window renders the HTML
* editing/pasteboard/5027857-expected.checksum: Added.
* editing/pasteboard/5027857-expected.png: Added.
* editing/pasteboard/5027857-expected.txt: Added.
* editing/pasteboard/5027857.html: Added.
WebCore:
Reviewed by harrison
<rdar://problem/4545040>
innerHTML does not HTML-escape text nodes inside PRE elements
<rdar://problem/5027857>
Pasting into Mail from Safari's view-source window renders the HTML
* editing/HTMLInterchange.cpp:
(WebCore::convertHTMLTextToInterchangeFormat): Send this function
the node that the text comes from as a parameter. It shouldn't convert
'\n's to spaces/nbsps if the text is coming from text where newlines are
preserved.
* editing/HTMLInterchange.h:
* editing/markup.cpp:
(WebCore::startMarkup): Escape text inside the children of PREs.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoreeditingHTMLInterchangecpp">trunk/WebCore/editing/HTMLInterchange.cpp</a></li>
<li><a href="#trunkWebCoreeditingHTMLInterchangeh">trunk/WebCore/editing/HTMLInterchange.h</a></li>
<li><a href="#trunkWebCoreeditingmarkupcpp">trunk/WebCore/editing/markup.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestseditingpasteboard5027857expectedchecksum">trunk/LayoutTests/editing/pasteboard/5027857-expected.checksum</a></li>
<li><a href="#trunkLayoutTestseditingpasteboard5027857expectedpng">trunk/LayoutTests/editing/pasteboard/5027857-expected.png</a></li>
<li><a href="#trunkLayoutTestseditingpasteboard5027857expectedtxt">trunk/LayoutTests/editing/pasteboard/5027857-expected.txt</a></li>
<li><a href="#trunkLayoutTestseditingpasteboard5027857html">trunk/LayoutTests/editing/pasteboard/5027857.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (19948 => 19949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2007-03-02 21:10:59 UTC (rev 19948)
+++ trunk/LayoutTests/ChangeLog        2007-03-02 23:02:49 UTC (rev 19949)
</span><span class="lines">@@ -1,5 +1,19 @@
</span><span class="cx"> 2007-03-02 Justin Garcia <justin.garcia@apple.com>
</span><span class="cx">
</span><ins>+ Reviewed by harrison
+
+ <rdar://problem/4545040>
+ innerHTML does not HTML-escape text nodes inside PRE elements
+ <rdar://problem/5027857>
+ Pasting into Mail from Safari's view-source window renders the HTML
+
+ * editing/pasteboard/5027857-expected.checksum: Added.
+ * editing/pasteboard/5027857-expected.png: Added.
+ * editing/pasteboard/5027857-expected.txt: Added.
+ * editing/pasteboard/5027857.html: Added.
+
+2007-03-02 Justin Garcia <justin.garcia@apple.com>
+
</ins><span class="cx"> Reviewed by john
</span><span class="cx">
</span><span class="cx"> <rdar://problem/5032095>
</span></span></pre></div>
<a id="trunkLayoutTestseditingpasteboard5027857expectedchecksum"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/editing/pasteboard/5027857-expected.checksum (0 => 19949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/5027857-expected.checksum         (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/5027857-expected.checksum        2007-03-02 23:02:49 UTC (rev 19949)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+3c451b6cf5c9adde3cf099393c67fd01
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestseditingpasteboard5027857expectedpng"></a>
<div class="binary"><h4>Added: trunk/LayoutTests/editing/pasteboard/5027857-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/LayoutTests/editing/pasteboard/5027857-expected.png
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:mime-type
</span><span class="cx"> + application/octet-stream
</span><a id="trunkLayoutTestseditingpasteboard5027857expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/editing/pasteboard/5027857-expected.txt (0 => 19949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/5027857-expected.txt         (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/5027857-expected.txt        2007-03-02 23:02:49 UTC (rev 19949)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x579
+ RenderBlock {P} at (0,0) size 784x36
+ RenderText {#text} at (0,0) size 765x36
+ text run at (0,0) width 414: "This tests a bug when copying HTML markup inside <pre> tags. "
+ text run at (414,0) width 351: "When pasted, this content would appear as the rendered"
+ text run at (0,18) width 134: "form of that markup. "
+ text run at (134,18) width 333: "You should see markup in the editable region below."
+ RenderBlock {PRE} at (0,52) size 784x15
+ RenderBlock {PRE} at (0,0) size 784x15
+ RenderText {#text} at (0,0) size 328x15
+ text run at (0,0) width 328: "<input type='button'>foo<br>bar<b>baz</b>"
+ RenderBlock (anonymous) at (0,28) size 784x0
+caret: position 41 of child 0 {#text} of child 0 {PRE} of child 2 {PRE} of child 0 {BODY} of child 0 {HTML} of document
</ins></span></pre></div>
<a id="trunkLayoutTestseditingpasteboard5027857html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/editing/pasteboard/5027857.html (0 => 19949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/5027857.html         (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/5027857.html        2007-03-02 23:02:49 UTC (rev 19949)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+<p>This tests a bug when copying HTML markup inside &lt;pre&gt; tags. When pasted, this content would appear as the rendered form of that markup. You should see markup in the editable region below.</p>
+<pre id="pre" contenteditable="true">&lt;input type='button'&gt;foo&lt;br&gt;bar&lt;b&gt;baz&lt;/b&gt;</pre>
+
+<script>
+var pre = document.getElementById("pre");
+pre.focus();
+document.execCommand("SelectAll");
+document.execCommand("Cut");
+document.execCommand("Paste");
+</script>
</ins></span></pre></div>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (19948 => 19949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2007-03-02 21:10:59 UTC (rev 19948)
+++ trunk/WebCore/ChangeLog        2007-03-02 23:02:49 UTC (rev 19949)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2007-03-02 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by harrison
+
+ <rdar://problem/4545040>
+ innerHTML does not HTML-escape text nodes inside PRE elements
+ <rdar://problem/5027857>
+ Pasting into Mail from Safari's view-source window renders the HTML
+
+ * editing/HTMLInterchange.cpp:
+ (WebCore::convertHTMLTextToInterchangeFormat): Send this function
+ the node that the text comes from as a parameter. It shouldn't convert
+ '\n's to spaces/nbsps if the text is coming from text where newlines are
+ preserved.
+ * editing/HTMLInterchange.h:
+ * editing/markup.cpp:
+ (WebCore::startMarkup): Escape text inside the children of PREs.
+
</ins><span class="cx"> 2007-03-02 Sam Weinig <sam@webkit.org>
</span><span class="cx">
</span><span class="cx"> Reviewed by Anders.
</span></span></pre></div>
<a id="trunkWebCoreeditingHTMLInterchangecpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/editing/HTMLInterchange.cpp (19948 => 19949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/editing/HTMLInterchange.cpp        2007-03-02 21:10:59 UTC (rev 19948)
+++ trunk/WebCore/editing/HTMLInterchange.cpp        2007-03-02 23:02:49 UTC (rev 19949)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx">
</span><span class="cx"> #include "CharacterNames.h"
</span><span class="cx"> #include "Document.h"
</span><ins>+#include "Text.h"
</ins><span class="cx"> #include "TextIterator.h"
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -49,12 +50,12 @@
</span><span class="cx">
</span><span class="cx"> } // end anonymous namespace
</span><span class="cx">
</span><del>-// FIXME: Can't really do this work without taking whitespace mode into account.
-// This means that eventually this function needs to be eliminated or at least have
-// its parameters changed because it can't do its work on the string without knowing
-// what parts are in what whitespace mode.
-DeprecatedString convertHTMLTextToInterchangeFormat(const DeprecatedString &in)
</del><ins>+DeprecatedString convertHTMLTextToInterchangeFormat(const DeprecatedString& in, const Text* node)
</ins><span class="cx"> {
</span><ins>+ // Assume all the text comes from node.
+ if (node->renderer() && node->renderer()->style()->preserveNewline())
+ return in;
+
</ins><span class="cx"> DeprecatedString s;
</span><span class="cx">
</span><span class="cx"> unsigned int i = 0;
</span></span></pre></div>
<a id="trunkWebCoreeditingHTMLInterchangeh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/editing/HTMLInterchange.h (19948 => 19949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/editing/HTMLInterchange.h        2007-03-02 21:10:59 UTC (rev 19948)
+++ trunk/WebCore/editing/HTMLInterchange.h        2007-03-02 23:02:49 UTC (rev 19949)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> class DeprecatedString;
</span><ins>+class Text;
</ins><span class="cx">
</span><span class="cx"> #define AppleInterchangeNewline "Apple-interchange-newline"
</span><span class="cx"> #define AppleConvertedSpace "Apple-converted-space"
</span><span class="lines">@@ -38,7 +39,7 @@
</span><span class="cx">
</span><span class="cx"> enum EAnnotateForInterchange { DoNotAnnotateForInterchange, AnnotateForInterchange };
</span><span class="cx">
</span><del>-DeprecatedString convertHTMLTextToInterchangeFormat(const DeprecatedString&);
</del><ins>+DeprecatedString convertHTMLTextToInterchangeFormat(const DeprecatedString&, const Text*);
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkWebCoreeditingmarkupcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/editing/markup.cpp (19948 => 19949)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/editing/markup.cpp        2007-03-02 21:10:59 UTC (rev 19948)
+++ trunk/WebCore/editing/markup.cpp        2007-03-02 23:02:49 UTC (rev 19949)
</span><span class="lines">@@ -160,7 +160,6 @@
</span><span class="cx"> case Node::TEXT_NODE: {
</span><span class="cx"> if (Node* parent = node->parentNode()) {
</span><span class="cx"> if (parent->hasTagName(listingTag)
</span><del>- || parent->hasTagName(preTag)
</del><span class="cx"> || parent->hasTagName(scriptTag)
</span><span class="cx"> || parent->hasTagName(styleTag)
</span><span class="cx"> || parent->hasTagName(textareaTag)
</span><span class="lines">@@ -168,7 +167,6 @@
</span><span class="cx"> return stringValueForRange(node, range).deprecatedString();
</span><span class="cx"> }
</span><span class="cx"> bool useRenderedText = annotate && !enclosingNodeWithTag(const_cast<Node*>(node), selectTag);
</span><del>-
</del><span class="cx"> DeprecatedString markup = useRenderedText ? escapeTextForMarkup(renderedText(node, range), false) : escapeTextForMarkup(stringValueForRange(node, range).deprecatedString(), false);
</span><span class="cx"> if (defaultStyle) {
</span><span class="cx"> Node *element = node->parentNode();
</span><span class="lines">@@ -188,7 +186,7 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>- return annotate ? convertHTMLTextToInterchangeFormat(markup) : markup;
</del><ins>+ return annotate ? convertHTMLTextToInterchangeFormat(markup, static_cast<const Text*>(node)) : markup;
</ins><span class="cx"> }
</span><span class="cx"> case Node::COMMENT_NODE:
</span><span class="cx"> return static_cast<const Comment*>(node)->toString().deprecatedString();
</span></span></pre>
</div>
</div>
</body>
</html>