<!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" />
<title>[164521] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/164521">164521</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2014-02-21 19:14:13 -0800 (Fri, 21 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>After copy and paste, cursor may appear to be above the bottom of content
https://bugs.webkit.org/show_bug.cgi?id=129167

Reviewed by Ryosuke Niwa.

Source/WebCore:

Adding a clear:both to the end of content.

I can't handle the case of the cursor appearing above the bottom of
absolutely positioned divs (of the case of floats inside absolutely
positioned divs) because you can't know where the bottom of a div
will end up being rendered (it is affected by things like browser
window width and text size settings). Therefore, the only case I
can handle is the case where there is a floating div in the same
level as the document itself.

Test: editing/pasteboard/copy-paste-inserts-clearing-div.html

* editing/EditingStyle.cpp:
(WebCore::EditingStyle::isFloating):
* editing/EditingStyle.h:
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::StyledMarkupAccumulator):
(WebCore::StyledMarkupAccumulator::appendElement):
(WebCore::createMarkupInternal):

LayoutTests:

Makes sure that the clearing div is inserted.

* editing/pasteboard/copy-paste-inserts-clearing-div-expected.txt: Added.
* editing/pasteboard/copy-paste-inserts-clearing-div.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreeditingEditingStylecpp">trunk/Source/WebCore/editing/EditingStyle.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingEditingStyleh">trunk/Source/WebCore/editing/EditingStyle.h</a></li>
<li><a href="#trunkSourceWebCoreeditingmarkupcpp">trunk/Source/WebCore/editing/markup.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestseditingpasteboardcopypasteinsertsclearingdivexpectedtxt">trunk/LayoutTests/editing/pasteboard/copy-paste-inserts-clearing-div-expected.txt</a></li>
<li><a href="#trunkLayoutTestseditingpasteboardcopypasteinsertsclearingdivhtml">trunk/LayoutTests/editing/pasteboard/copy-paste-inserts-clearing-div.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (164520 => 164521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-02-22 02:58:13 UTC (rev 164520)
+++ trunk/LayoutTests/ChangeLog        2014-02-22 03:14:13 UTC (rev 164521)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-02-21  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        After copy and paste, cursor may appear to be above the bottom of content
+        https://bugs.webkit.org/show_bug.cgi?id=129167
+
+        Reviewed by Ryosuke Niwa.
+
+        Makes sure that the clearing div is inserted.
+
+        * editing/pasteboard/copy-paste-inserts-clearing-div-expected.txt: Added.
+        * editing/pasteboard/copy-paste-inserts-clearing-div.html: Added.
+
</ins><span class="cx"> 2014-02-21  Brian Burg  &lt;bburg@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Move unported Web Inspector tests to LayoutTests/inspector-obsolete
</span></span></pre></div>
<a id="trunkLayoutTestseditingpasteboardcopypasteinsertsclearingdivexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/editing/pasteboard/copy-paste-inserts-clearing-div-expected.txt (0 => 164521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/copy-paste-inserts-clearing-div-expected.txt                                (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/copy-paste-inserts-clearing-div-expected.txt        2014-02-22 03:14:13 UTC (rev 164521)
</span><span class="lines">@@ -0,0 +1,100 @@
</span><ins>+This tests to see if floating elements cause a clearing element to be inserted upon copy/paste
+
+first test - before:
+| &lt;html&gt;
+|   &lt;head&gt;
+|     &quot;
+&quot;
+|     &lt;meta&gt;
+|       content=&quot;text/html; charset=utf-8&quot;
+|       http-equiv=&quot;Content-type&quot;
+|     &quot;
+&quot;
+|     &lt;script&gt;
+|       src=&quot;../../resources/dump-as-markup.js&quot;
+|       type=&quot;text/javascript&quot;
+|     &quot;
+&quot;
+|   &quot;
+&quot;
+|   &lt;body&gt;
+|     &quot;
+Before
+&quot;
+|     &lt;div&gt;
+|       style=&quot;position: absolute; top: 0px; right: 0px; width: 100px; height: 100px; background: yellow;&quot;
+|     &quot;
+&quot;
+|     &lt;div&gt;
+|       style=&quot;float: right; width: 200px; height: 200px; background: blue;&quot;
+|     &quot;
+After
+
+&quot;
+|     &lt;script&gt;
+|       &quot;
+
+Markup.description('This tests to see if floating elements cause a clearing element to be inserted upon copy/paste');
+
+document.designMode = 'on';
+
+if (window.internals)
+    window.internals.settings.setShouldConvertPositionStyleOnCopy(true);
+
+var s = window.getSelection();
+
+Markup.dump('test1', 'first test - before');
+document.execCommand(&quot;SelectAll&quot;);
+document.execCommand(&quot;Cut&quot;);
+document.execCommand(&quot;Paste&quot;);
+Markup.dump('test1', 'first test - after');
+
+&quot;
+
+first test - after:
+| &lt;html&gt;
+|   &lt;head&gt;
+|     &quot;
+&quot;
+|     &lt;meta&gt;
+|       content=&quot;text/html; charset=utf-8&quot;
+|       http-equiv=&quot;Content-type&quot;
+|     &quot;
+&quot;
+|     &lt;script&gt;
+|       src=&quot;../../resources/dump-as-markup.js&quot;
+|       type=&quot;text/javascript&quot;
+|     &quot;
+&quot;
+|   &quot;
+&quot;
+|   &lt;body&gt;
+|     &lt;div&gt;
+|       style=&quot;position: relative;&quot;
+|       &quot;BeforeĀ &quot;
+|       &lt;div&gt;
+|         style=&quot;position: absolute; top: 0px; right: 0px; width: 100px; height: 100px; background-color: yellow;&quot;
+|       &lt;div&gt;
+|         style=&quot;float: right; width: 200px; height: 200px; background-color: blue;&quot;
+|       &quot;After&lt;#selection-caret&gt;&quot;
+|       &lt;div&gt;
+|         style=&quot;clear: both;&quot;
+|     &lt;script&gt;
+|       &quot;
+
+Markup.description('This tests to see if floating elements cause a clearing element to be inserted upon copy/paste');
+
+document.designMode = 'on';
+
+if (window.internals)
+    window.internals.settings.setShouldConvertPositionStyleOnCopy(true);
+
+var s = window.getSelection();
+
+Markup.dump('test1', 'first test - before');
+document.execCommand(&quot;SelectAll&quot;);
+document.execCommand(&quot;Cut&quot;);
+document.execCommand(&quot;Paste&quot;);
+Markup.dump('test1', 'first test - after');
+
+&quot;
</ins></span></pre></div>
<a id="trunkLayoutTestseditingpasteboardcopypasteinsertsclearingdivhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/editing/pasteboard/copy-paste-inserts-clearing-div.html (0 => 164521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/editing/pasteboard/copy-paste-inserts-clearing-div.html                                (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/copy-paste-inserts-clearing-div.html        2014-02-22 03:14:13 UTC (rev 164521)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;meta http-equiv=&quot;Content-type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
+&lt;script type=&quot;text/javascript&quot; src=&quot;../../resources/dump-as-markup.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+Before
+&lt;div style=&quot;position: absolute; top: 0px; right: 0px; width: 100px; height: 100px; background: yellow;&quot;&gt;&lt;/div&gt;
+&lt;div style=&quot;float: right; width: 200px; height: 200px; background: blue;&quot;&gt;&lt;/div&gt;
+After
+
+&lt;script&gt;
+
+Markup.description('This tests to see if floating elements cause a clearing element to be inserted upon copy/paste');
+
+document.designMode = 'on';
+
+if (window.internals)
+    window.internals.settings.setShouldConvertPositionStyleOnCopy(true);
+
+var s = window.getSelection();
+
+Markup.dump('test1', 'first test - before');
+document.execCommand(&quot;SelectAll&quot;);
+document.execCommand(&quot;Cut&quot;);
+document.execCommand(&quot;Paste&quot;);
+Markup.dump('test1', 'first test - after');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (164520 => 164521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-22 02:58:13 UTC (rev 164520)
+++ trunk/Source/WebCore/ChangeLog        2014-02-22 03:14:13 UTC (rev 164521)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2014-02-21  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        After copy and paste, cursor may appear to be above the bottom of content
+        https://bugs.webkit.org/show_bug.cgi?id=129167
+
+        Reviewed by Ryosuke Niwa.
+
+        Adding a clear:both to the end of content.
+
+        I can't handle the case of the cursor appearing above the bottom of
+        absolutely positioned divs (of the case of floats inside absolutely
+        positioned divs) because you can't know where the bottom of a div
+        will end up being rendered (it is affected by things like browser
+        window width and text size settings). Therefore, the only case I
+        can handle is the case where there is a floating div in the same
+        level as the document itself.
+
+        Test: editing/pasteboard/copy-paste-inserts-clearing-div.html
+
+        * editing/EditingStyle.cpp:
+        (WebCore::EditingStyle::isFloating):
+        * editing/EditingStyle.h:
+        * editing/markup.cpp:
+        (WebCore::StyledMarkupAccumulator::StyledMarkupAccumulator):
+        (WebCore::StyledMarkupAccumulator::appendElement):
+        (WebCore::createMarkupInternal):
+
</ins><span class="cx"> 2014-02-21  Dean Jackson  &lt;dino@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS Media] Wireless target UI
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditingStylecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (164520 => 164521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/EditingStyle.cpp        2014-02-22 02:58:13 UTC (rev 164520)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp        2014-02-22 03:14:13 UTC (rev 164521)
</span><span class="lines">@@ -1242,6 +1242,13 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool EditingStyle::isFloating()
+{
+    RefPtr&lt;CSSValue&gt; v = m_mutableStyle-&gt;getPropertyCSSValue(CSSPropertyFloat);
+    RefPtr&lt;CSSPrimitiveValue&gt; noneValue = cssValuePool().createIdentifierValue(CSSValueNone);
+    return v &amp;&amp; !v-&gt;equals(*noneValue);
+}
+
</ins><span class="cx"> int EditingStyle::legacyFontSize(Document* document) const
</span><span class="cx"> {
</span><span class="cx">     RefPtr&lt;CSSValue&gt; cssValue = m_mutableStyle-&gt;getPropertyCSSValue(CSSPropertyFontSize);
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditingStyleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/EditingStyle.h (164520 => 164521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/EditingStyle.h        2014-02-22 02:58:13 UTC (rev 164520)
+++ trunk/Source/WebCore/editing/EditingStyle.h        2014-02-22 03:14:13 UTC (rev 164521)
</span><span class="lines">@@ -136,6 +136,7 @@
</span><span class="cx">     void removePropertiesInElementDefaultStyle(Element*);
</span><span class="cx">     void forceInline();
</span><span class="cx">     bool convertPositionStyle();
</span><ins>+    bool isFloating();
</ins><span class="cx">     int legacyFontSize(Document*) const;
</span><span class="cx"> 
</span><span class="cx">     float fontSizeDelta() const { return m_fontSizeDelta; }
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingmarkupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/markup.cpp (164520 => 164521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/markup.cpp        2014-02-22 02:58:13 UTC (rev 164520)
+++ trunk/Source/WebCore/editing/markup.cpp        2014-02-22 03:14:13 UTC (rev 164521)
</span><span class="lines">@@ -125,6 +125,7 @@
</span><span class="cx">     String takeResults();
</span><span class="cx">     
</span><span class="cx">     bool needRelativeStyleWrapper() const { return m_needRelativeStyleWrapper; }
</span><ins>+    bool needClearingDiv() const { return m_needClearingDiv; }
</ins><span class="cx"> 
</span><span class="cx">     using MarkupAccumulator::appendString;
</span><span class="cx"> 
</span><span class="lines">@@ -162,6 +163,7 @@
</span><span class="cx">     RefPtr&lt;EditingStyle&gt; m_wrappingStyle;
</span><span class="cx">     bool m_needRelativeStyleWrapper;
</span><span class="cx">     bool m_needsPositionStyleConversion;
</span><ins>+    bool m_needClearingDiv;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> inline StyledMarkupAccumulator::StyledMarkupAccumulator(Vector&lt;Node*&gt;* nodes, EAbsoluteURLs shouldResolveURLs, EAnnotateForInterchange shouldAnnotate, const Range* range, bool needsPositionStyleConversion, Node* highestNodeToBeSerialized)
</span><span class="lines">@@ -170,6 +172,7 @@
</span><span class="cx">     , m_highestNodeToBeSerialized(highestNodeToBeSerialized)
</span><span class="cx">     , m_needRelativeStyleWrapper(false)
</span><span class="cx">     , m_needsPositionStyleConversion(needsPositionStyleConversion)
</span><ins>+    , m_needClearingDiv(false)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -327,8 +330,10 @@
</span><span class="cx">             if (addDisplayInline)
</span><span class="cx">                 newInlineStyle-&gt;forceInline();
</span><span class="cx">             
</span><del>-            if (m_needsPositionStyleConversion)
</del><ins>+            if (m_needsPositionStyleConversion) {
</ins><span class="cx">                 m_needRelativeStyleWrapper |= newInlineStyle-&gt;convertPositionStyle();
</span><ins>+                m_needClearingDiv |= newInlineStyle-&gt;isFloating();
+            }
</ins><span class="cx"> 
</span><span class="cx">             // If the node is not fully selected by the range, then we don't want to keep styles that affect its relationship to the nodes around it
</span><span class="cx">             // only the ones that affect it and the nodes within it.
</span><span class="lines">@@ -629,6 +634,8 @@
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     if (accumulator.needRelativeStyleWrapper() &amp;&amp; needsPositionStyleConversion) {
</span><ins>+        if (accumulator.needClearingDiv())
+            accumulator.appendString(&quot;&lt;div style=\&quot;clear: both;\&quot;&gt;&lt;/div&gt;&quot;);
</ins><span class="cx">         RefPtr&lt;EditingStyle&gt; positionRelativeStyle = styleFromMatchedRulesAndInlineDecl(body);
</span><span class="cx">         positionRelativeStyle-&gt;style()-&gt;setProperty(CSSPropertyPosition, CSSValueRelative);
</span><span class="cx">         accumulator.wrapWithStyleNode(positionRelativeStyle-&gt;style(), document, true);
</span></span></pre>
</div>
</div>

</body>
</html>