<!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>[173281] 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/173281">173281</a></dd>
<dt>Author</dt> <dd>hyatt@apple.com</dd>
<dt>Date</dt> <dd>2014-09-04 14:20:12 -0700 (Thu, 04 Sep 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Initial letters should clear one another.
https://bugs.webkit.org/show_bug.cgi?id=136514

Reviewed by Simon Fraser.

Source/WebCore:

Added fast/css-generated-content/initial-letter-clearance.html.

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::computeLogicalLocationForFloat):
Compute the required clearance and add it both to the block's logical height
and to the logical top offset of the float.

(WebCore::RenderBlockFlow::lowestInitialLetterLogicalBottom):
* rendering/RenderBlockFlow.h:
A new method for determining the lowest floating initial letter.

LayoutTests:

* fast/css-generated-content/initial-letter-clearance.html: Added.
* platform/mac/fast/css-generated-content/initial-letter-clearance-expected.png: Added.
* platform/mac/fast/css-generated-content/initial-letter-clearance-expected.txt: 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="#trunkSourceWebCorerenderingRenderBlockFlowcpp">trunk/Source/WebCore/rendering/RenderBlockFlow.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockFlowh">trunk/Source/WebCore/rendering/RenderBlockFlow.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcssgeneratedcontentinitialletterclearancehtml">trunk/LayoutTests/fast/css-generated-content/initial-letter-clearance.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastcssgeneratedcontentinitialletterclearanceexpectedpng">trunk/LayoutTests/platform/mac/fast/css-generated-content/initial-letter-clearance-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastcssgeneratedcontentinitialletterclearanceexpectedtxt">trunk/LayoutTests/platform/mac/fast/css-generated-content/initial-letter-clearance-expected.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (173280 => 173281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-09-04 21:16:53 UTC (rev 173280)
+++ trunk/LayoutTests/ChangeLog        2014-09-04 21:20:12 UTC (rev 173281)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2014-09-03  David Hyatt  &lt;hyatt@apple.com&gt;
+
+        Initial letters should clear one another.
+        https://bugs.webkit.org/show_bug.cgi?id=136514
+
+        Reviewed by Simon Fraser.
+
+        * fast/css-generated-content/initial-letter-clearance.html: Added.
+        * platform/mac/fast/css-generated-content/initial-letter-clearance-expected.png: Added.
+        * platform/mac/fast/css-generated-content/initial-letter-clearance-expected.txt: Added.
+
</ins><span class="cx"> 2014-09-04  Beth Dakin  &lt;bdakin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r172832): Poor 2-finger scrolling performance at theverge.com articles 
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssgeneratedcontentinitialletterclearancehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css-generated-content/initial-letter-clearance.html (0 => 173281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css-generated-content/initial-letter-clearance.html                                (rev 0)
+++ trunk/LayoutTests/fast/css-generated-content/initial-letter-clearance.html        2014-09-04 21:20:12 UTC (rev 173281)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+div { width:400px; margin:1em }
+div::first-letter { font-family: Zapfino; -webkit-initial-letter: 2 4; margin-right:2px; margin-left:2; }
+
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;div&gt;
+Just an example of first-letter. Short paragraph!
+&lt;/div&gt;
+&lt;div&gt;
+Just an example of first-letter. This letter should span 3 lines of text, and
+so it should align itself cleanly with the cap-height of the J lining up with
+the cap-height of the first line, and the baseline of the J lining up with the
+baseline of the third line. The descender of the J is still avoided by following lines. This paragraph cleared the short paragraph.
+&lt;/div&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastcssgeneratedcontentinitialletterclearanceexpectedpng"></a>
<div class="binary"><h4>Added: trunk/LayoutTests/platform/mac/fast/css-generated-content/initial-letter-clearance-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/platform/mac/fast/css-generated-content/initial-letter-clearance-expected.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestsplatformmacfastcssgeneratedcontentinitialletterclearanceexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/fast/css-generated-content/initial-letter-clearance-expected.txt (0 => 173281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/fast/css-generated-content/initial-letter-clearance-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/css-generated-content/initial-letter-clearance-expected.txt        2014-09-04 21:20:12 UTC (rev 173281)
</span><span class="lines">@@ -0,0 +1,22 @@
</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,16) size 784x568
+      RenderBlock {DIV} at (16,0) size 400x54
+        RenderBlock (floating) at (2,3) size 48x81
+          RenderText {#text} at (0,-46) size 48x200
+            text run at (0,-46) width 48: &quot;J&quot;
+        RenderText {#text} at (52,36) size 289x18
+          text run at (52,36) width 289: &quot;ust an example of first-letter. Short paragraph!&quot;
+      RenderBlock {DIV} at (16,70) size 400x158
+        RenderBlock (floating) at (2,17) size 48x81
+          RenderText {#text} at (0,-46) size 48x200
+            text run at (0,-46) width 48: &quot;J&quot;
+        RenderText {#text} at (52,50) size 395x108
+          text run at (52,50) width 337: &quot;ust an example of first-letter. This letter should span 3&quot;
+          text run at (52,68) width 330: &quot;lines of text, and so it should align itself cleanly with&quot;
+          text run at (52,86) width 341: &quot;the cap-height of the J lining up with the cap-height of&quot;
+          text run at (0,104) width 348: &quot;the first line, and the baseline of the J lining up with the&quot;
+          text run at (0,122) width 395: &quot;baseline of the third line. The descender of the J is still avoided&quot;
+          text run at (0,140) width 395: &quot;by following lines. This paragraph cleared the short paragraph.&quot;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (173280 => 173281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-09-04 21:16:53 UTC (rev 173280)
+++ trunk/Source/WebCore/ChangeLog        2014-09-04 21:20:12 UTC (rev 173281)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2014-09-03  David Hyatt  &lt;hyatt@apple.com&gt;
+
+        Initial letters should clear one another.
+        https://bugs.webkit.org/show_bug.cgi?id=136514
+
+        Reviewed by Simon Fraser.
+
+        Added fast/css-generated-content/initial-letter-clearance.html.
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::computeLogicalLocationForFloat):
+        Compute the required clearance and add it both to the block's logical height
+        and to the logical top offset of the float.
+
+        (WebCore::RenderBlockFlow::lowestInitialLetterLogicalBottom):
+        * rendering/RenderBlockFlow.h:
+        A new method for determining the lowest floating initial letter.
+
</ins><span class="cx"> 2014-09-04  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Use WTFString::find(char) in more places
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (173280 => 173281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2014-09-04 21:16:53 UTC (rev 173280)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2014-09-04 21:20:12 UTC (rev 173281)
</span><span class="lines">@@ -2301,7 +2301,16 @@
</span><span class="cx">     LayoutUnit floatLogicalLeft;
</span><span class="cx"> 
</span><span class="cx">     bool insideFlowThread = flowThreadContainingBlock();
</span><del>-
</del><ins>+    bool isInitialLetter = childBox.style().styleType() == FIRST_LETTER &amp;&amp; childBox.style().initialLetterDrop() &gt; 0;
+    
+    if (isInitialLetter) {
+        int letterClearance = lowestInitialLetterLogicalBottom() - logicalTopOffset;
+        if (letterClearance &gt; 0) {
+            logicalTopOffset += letterClearance;
+            setLogicalHeight(logicalHeight() + letterClearance);
+        }
+    }
+    
</ins><span class="cx">     if (childBox.style().floating() == LeftFloat) {
</span><span class="cx">         LayoutUnit heightRemainingLeft = 1;
</span><span class="cx">         LayoutUnit heightRemainingRight = 1;
</span><span class="lines">@@ -2337,7 +2346,7 @@
</span><span class="cx">         floatLogicalLeft -= logicalWidthForFloat(floatingObject);
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    if (childBox.style().styleType() == FIRST_LETTER &amp;&amp; childBox.style().initialLetterDrop() &gt; 0) {
</del><ins>+    if (isInitialLetter) {
</ins><span class="cx">         const RenderStyle&amp; style = firstLineStyle();
</span><span class="cx">         const FontMetrics&amp; fontMetrics = style.fontMetrics();
</span><span class="cx">         if (fontMetrics.hasCapHeight()) {
</span><span class="lines">@@ -2559,6 +2568,21 @@
</span><span class="cx">     return lowestFloatBottom;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+LayoutUnit RenderBlockFlow::lowestInitialLetterLogicalBottom() const
+{
+    if (!m_floatingObjects)
+        return 0;
+    LayoutUnit lowestFloatBottom = 0;
+    const FloatingObjectSet&amp; floatingObjectSet = m_floatingObjects-&gt;set();
+    auto end = floatingObjectSet.end();
+    for (auto it = floatingObjectSet.begin(); it != end; ++it) {
+        FloatingObject* floatingObject = it-&gt;get();
+        if (floatingObject-&gt;isPlaced() &amp;&amp; floatingObject-&gt;renderer().style().styleType() == FIRST_LETTER &amp;&amp; floatingObject-&gt;renderer().style().initialLetterDrop() &gt; 0)
+            lowestFloatBottom = std::max(lowestFloatBottom, logicalBottomForFloat(floatingObject));
+    }
+    return lowestFloatBottom;
+}
+
</ins><span class="cx"> LayoutUnit RenderBlockFlow::addOverhangingFloats(RenderBlockFlow&amp; child, bool makeChildPaintOtherFloats)
</span><span class="cx"> {
</span><span class="cx">     // Prevent floats from being added to the canvas by the root element, e.g., &lt;html&gt;.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (173280 => 173281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.h        2014-09-04 21:16:53 UTC (rev 173280)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h        2014-09-04 21:20:12 UTC (rev 173281)
</span><span class="lines">@@ -492,6 +492,8 @@
</span><span class="cx">     LayoutUnit logicalRightOffsetForPositioningFloat(LayoutUnit logicalTop, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemaining) const;
</span><span class="cx">     LayoutUnit logicalLeftOffsetForPositioningFloat(LayoutUnit logicalTop, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemaining) const;
</span><span class="cx"> 
</span><ins>+    LayoutUnit lowestInitialLetterLogicalBottom() const;
+    
</ins><span class="cx">     LayoutUnit lowestFloatLogicalBottom(FloatingObject::Type = FloatingObject::FloatLeftRight) const; 
</span><span class="cx">     LayoutUnit nextFloatLogicalBottomBelow(LayoutUnit) const;
</span><span class="cx">     LayoutUnit nextFloatLogicalBottomBelowForBlock(LayoutUnit) const;
</span></span></pre>
</div>
</div>

</body>
</html>