<!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
        
        &lt;rdar://problem/4545040&gt;
        innerHTML does not HTML-escape text nodes inside PRE elements
        &lt;rdar://problem/5027857&gt;
        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

        &lt;rdar://problem/4545040&gt;
        innerHTML does not HTML-escape text nodes inside PRE elements
        &lt;rdar://problem/5027857&gt;
        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  &lt;justin.garcia@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Reviewed by harrison
+        
+        &lt;rdar://problem/4545040&gt;
+        innerHTML does not HTML-escape text nodes inside PRE elements
+        &lt;rdar://problem/5027857&gt;
+        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  &lt;justin.garcia@apple.com&gt;
+
</ins><span class="cx">         Reviewed by john
</span><span class="cx">         
</span><span class="cx">         &lt;rdar://problem/5032095&gt;
</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: &quot;This tests a bug when copying HTML markup inside &lt;pre&gt; tags. &quot;
+          text run at (414,0) width 351: &quot;When pasted, this content would appear as the rendered&quot;
+          text run at (0,18) width 134: &quot;form of that markup. &quot;
+          text run at (134,18) width 333: &quot;You should see markup in the editable region below.&quot;
+      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: &quot;&lt;input type='button'&gt;foo&lt;br&gt;bar&lt;b&gt;baz&lt;/b&gt;&quot;
+        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>+&lt;p&gt;This tests a bug when copying HTML markup inside &amp;lt;pre&amp;gt; tags.  When pasted, this content would appear as the rendered form of that markup.  You should see markup in the editable region below.&lt;/p&gt;
+&lt;pre id=&quot;pre&quot; contenteditable=&quot;true&quot;&gt;&amp;lt;input type='button'&amp;gt;foo&amp;lt;br&amp;gt;bar&amp;lt;b&amp;gt;baz&amp;lt;/b&amp;gt;&lt;/pre&gt;
+
+&lt;script&gt;
+var pre = document.getElementById(&quot;pre&quot;);
+pre.focus();
+document.execCommand(&quot;SelectAll&quot;);
+document.execCommand(&quot;Cut&quot;);
+document.execCommand(&quot;Paste&quot;);
+&lt;/script&gt;
</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  &lt;justin.garcia@apple.com&gt;
+
+        Reviewed by harrison
+
+        &lt;rdar://problem/4545040&gt;
+        innerHTML does not HTML-escape text nodes inside PRE elements
+        &lt;rdar://problem/5027857&gt;
+        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  &lt;sam@webkit.org&gt;
</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 &quot;CharacterNames.h&quot;
</span><span class="cx"> #include &quot;Document.h&quot;
</span><ins>+#include &quot;Text.h&quot;
</ins><span class="cx"> #include &quot;TextIterator.h&quot;
</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 &amp;in)
</del><ins>+DeprecatedString convertHTMLTextToInterchangeFormat(const DeprecatedString&amp; in, const Text* node)
</ins><span class="cx"> {
</span><ins>+    // Assume all the text comes from node.
+    if (node-&gt;renderer() &amp;&amp; node-&gt;renderer()-&gt;style()-&gt;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   &quot;Apple-interchange-newline&quot;
</span><span class="cx"> #define AppleConvertedSpace       &quot;Apple-converted-space&quot;
</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&amp;);
</del><ins>+DeprecatedString convertHTMLTextToInterchangeFormat(const DeprecatedString&amp;, 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-&gt;parentNode()) {
</span><span class="cx">                 if (parent-&gt;hasTagName(listingTag)
</span><del>-                        || parent-&gt;hasTagName(preTag)
</del><span class="cx">                         || parent-&gt;hasTagName(scriptTag)
</span><span class="cx">                         || parent-&gt;hasTagName(styleTag)
</span><span class="cx">                         || parent-&gt;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 &amp;&amp; !enclosingNodeWithTag(const_cast&lt;Node*&gt;(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-&gt;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&lt;const Text*&gt;(node)) : markup;
</ins><span class="cx">         }
</span><span class="cx">         case Node::COMMENT_NODE:
</span><span class="cx">             return static_cast&lt;const Comment*&gt;(node)-&gt;toString().deprecatedString();
</span></span></pre>
</div>
</div>

</body>
</html>