<!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>[182146] 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/182146">182146</a></dd>
<dt>Author</dt> <dd>hyatt@apple.com</dd>
<dt>Date</dt> <dd>2015-03-30 11:02:37 -0700 (Mon, 30 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[New Block-Inside-Inline Model] Create anonymous inline blocks to hold blocks-inside-inlines.
https://bugs.webkit.org/show_bug.cgi?id=143145

Reviewed by Dean Jackson.

Source/WebCore:

Added fast/block/inside-inlines/ tests.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::renderName):
Add support for labeling anonymous inline-blocks when dumped by the render tree.

* rendering/RenderInline.cpp:
(WebCore::RenderInline::addChildIgnoringContinuation):
When the pref is set to use the new block-inside-inline model, create an anonymous inline block to
hold block children of RenderInlines instead of splitting flows or creating continuations.

* rendering/RenderObject.h:
(WebCore::RenderObject::isAnonymousInlineBlock):
Add the definition of isAnonymousInlineBlock (note the exclusion of Ruby, since Ruby creates anonymous
inline-blocks also).

LayoutTests:

* fast/block/inside-inlines: Added.
* fast/block/inside-inlines/empty-block-expected.html: Added.
* fast/block/inside-inlines/empty-block.html: Added.
* fast/block/inside-inlines/new-model: Added.
* fast/block/inside-inlines/new-model/empty-block-expected.html: Added.
* fast/block/inside-inlines/new-model/empty-block.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="#trunkSourceWebCorerenderingRenderBlockcpp">trunk/Source/WebCore/rendering/RenderBlock.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderInlinecpp">trunk/Source/WebCore/rendering/RenderInline.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjecth">trunk/Source/WebCore/rendering/RenderObject.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/fast/block/inside-inlines/</li>
<li><a href="#trunkLayoutTestsfastblockinsideinlinesemptyblockexpectedhtml">trunk/LayoutTests/fast/block/inside-inlines/empty-block-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastblockinsideinlinesemptyblockhtml">trunk/LayoutTests/fast/block/inside-inlines/empty-block.html</a></li>
<li>trunk/LayoutTests/fast/block/inside-inlines/new-model/</li>
<li><a href="#trunkLayoutTestsfastblockinsideinlinesnewmodelemptyblockexpectedhtml">trunk/LayoutTests/fast/block/inside-inlines/new-model/empty-block-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastblockinsideinlinesnewmodelemptyblockhtml">trunk/LayoutTests/fast/block/inside-inlines/new-model/empty-block.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (182145 => 182146)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-03-30 17:35:39 UTC (rev 182145)
+++ trunk/LayoutTests/ChangeLog        2015-03-30 18:02:37 UTC (rev 182146)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2015-03-27  David Hyatt  &lt;hyatt@apple.com&gt;
+
+        [New Block-Inside-Inline Model] Create anonymous inline blocks to hold blocks-inside-inlines.
+        https://bugs.webkit.org/show_bug.cgi?id=143145
+
+        Reviewed by Dean Jackson.
+
+        * fast/block/inside-inlines: Added.
+        * fast/block/inside-inlines/empty-block-expected.html: Added.
+        * fast/block/inside-inlines/empty-block.html: Added.
+        * fast/block/inside-inlines/new-model: Added.
+        * fast/block/inside-inlines/new-model/empty-block-expected.html: Added.
+        * fast/block/inside-inlines/new-model/empty-block.html: Added.
+
</ins><span class="cx"> 2015-03-30  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WK2][NetworkCache] Add support for &quot;Cache-Control: max-stale&quot; request header
</span></span></pre></div>
<a id="trunkLayoutTestsfastblockinsideinlinesemptyblockexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/block/inside-inlines/empty-block-expected.html (0 => 182146)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/block/inside-inlines/empty-block-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/block/inside-inlines/empty-block-expected.html        2015-03-30 18:02:37 UTC (rev 182146)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+&lt;!doctype html&gt;
+
+The two lines below should look identical.
+
+&lt;div&gt;
+
+&lt;a style=&quot;line-height:2; background-color:green; padding:0 100px&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;br&gt;
+&amp;nbsp;&amp;nbsp;&lt;/a&gt;
+&lt;/div&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfastblockinsideinlinesemptyblockhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/block/inside-inlines/empty-block.html (0 => 182146)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/block/inside-inlines/empty-block.html                                (rev 0)
+++ trunk/LayoutTests/fast/block/inside-inlines/empty-block.html        2015-03-30 18:02:37 UTC (rev 182146)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+&lt;!doctype html&gt;
+
+The two lines below should look identical.
+
+&lt;div&gt;
+
+&lt;a style=&quot;line-height:2; background-color:green; padding:0 100px&quot;&gt;&amp;nbsp;&amp;nbsp;
+&lt;div&gt;&lt;/div&gt;
+&amp;nbsp;&amp;nbsp;&lt;/a&gt;
+&lt;/div&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfastblockinsideinlinesnewmodelemptyblockexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/block/inside-inlines/new-model/empty-block-expected.html (0 => 182146)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/block/inside-inlines/new-model/empty-block-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/block/inside-inlines/new-model/empty-block-expected.html        2015-03-30 18:02:37 UTC (rev 182146)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+&lt;!doctype html&gt;
+
+The two lines below should look identical.
+
+&lt;div&gt;
+
+&lt;a style=&quot;line-height:2; background-color:green; padding:0 100px&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;br&gt;
+&amp;nbsp;&amp;nbsp;&lt;/a&gt;
+&lt;/div&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfastblockinsideinlinesnewmodelemptyblockhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/block/inside-inlines/new-model/empty-block.html (0 => 182146)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/block/inside-inlines/new-model/empty-block.html                                (rev 0)
+++ trunk/LayoutTests/fast/block/inside-inlines/new-model/empty-block.html        2015-03-30 18:02:37 UTC (rev 182146)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;head&gt;
+&lt;script&gt;
+window.internals.settings.setNewBlockInsideInlineModelEnabled(true)
+&lt;/script&gt;
+&lt;/head&gt;
+
+The two lines below should look identical.
+
+&lt;div&gt;
+
+&lt;a style=&quot;line-height:2; background-color:green; padding:0 100px&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;br&gt;
+&lt;div&gt;&lt;/div&gt;&amp;nbsp;&amp;nbsp;&lt;/a&gt;
+&lt;/div&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (182145 => 182146)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-03-30 17:35:39 UTC (rev 182145)
+++ trunk/Source/WebCore/ChangeLog        2015-03-30 18:02:37 UTC (rev 182146)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2015-03-27  David Hyatt  &lt;hyatt@apple.com&gt;
+
+        [New Block-Inside-Inline Model] Create anonymous inline blocks to hold blocks-inside-inlines.
+        https://bugs.webkit.org/show_bug.cgi?id=143145
+
+        Reviewed by Dean Jackson.
+
+        Added fast/block/inside-inlines/ tests.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::renderName):
+        Add support for labeling anonymous inline-blocks when dumped by the render tree.
+
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::addChildIgnoringContinuation):
+        When the pref is set to use the new block-inside-inline model, create an anonymous inline block to
+        hold block children of RenderInlines instead of splitting flows or creating continuations.
+
+        * rendering/RenderObject.h:
+        (WebCore::RenderObject::isAnonymousInlineBlock):
+        Add the definition of isAnonymousInlineBlock (note the exclusion of Ruby, since Ruby creates anonymous
+        inline-blocks also).
+
</ins><span class="cx"> 2015-03-30  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WK2][NetworkCache] Add support for &quot;Cache-Control: max-stale&quot; request header
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (182145 => 182146)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlock.cpp        2015-03-30 17:35:39 UTC (rev 182145)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp        2015-03-30 18:02:37 UTC (rev 182146)
</span><span class="lines">@@ -3656,6 +3656,8 @@
</span><span class="cx">         return &quot;RenderBlock (positioned)&quot;;
</span><span class="cx">     if (isAnonymousBlock())
</span><span class="cx">         return &quot;RenderBlock (anonymous)&quot;;
</span><ins>+    if (isAnonymousInlineBlock())
+        return &quot;RenderBlock (anonymous inline-block)&quot;;
</ins><span class="cx">     // FIXME: Temporary hack while the new generated content system is being implemented.
</span><span class="cx">     if (isPseudoElement())
</span><span class="cx">         return &quot;RenderBlock (generated)&quot;;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderInlinecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (182145 => 182146)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderInline.cpp        2015-03-30 17:35:39 UTC (rev 182145)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp        2015-03-30 18:02:37 UTC (rev 182146)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> #include &quot;RenderNamedFlowThread.h&quot;
</span><span class="cx"> #include &quot;RenderTheme.h&quot;
</span><span class="cx"> #include &quot;RenderView.h&quot;
</span><ins>+#include &quot;Settings.h&quot;
</ins><span class="cx"> #include &quot;StyleInheritedData.h&quot;
</span><span class="cx"> #include &quot;TransformState.h&quot;
</span><span class="cx"> #include &quot;VisiblePosition.h&quot;
</span><span class="lines">@@ -306,8 +307,11 @@
</span><span class="cx">     // Make sure we don't append things after :after-generated content if we have it.
</span><span class="cx">     if (!beforeChild &amp;&amp; isAfterContent(lastChild()))
</span><span class="cx">         beforeChild = lastChild();
</span><del>-
-    if (!newChild-&gt;isInline() &amp;&amp; !newChild-&gt;isFloatingOrOutOfFlowPositioned()) {
</del><ins>+    
+    bool useNewBlockInsideInlineModel = document().settings()-&gt;newBlockInsideInlineModelEnabled();
+    
+    // This code is for the old block-inside-inline model that uses continuations.
+    if (!useNewBlockInsideInlineModel &amp;&amp; !newChild-&gt;isInline() &amp;&amp; !newChild-&gt;isFloatingOrOutOfFlowPositioned()) {
</ins><span class="cx">         // We are placing a block inside an inline. We have to perform a split of this
</span><span class="cx">         // inline into continuations.  This involves creating an anonymous block box to hold
</span><span class="cx">         // |newChild|.  We then make that block box a continuation of this inline.  We take all of
</span><span class="lines">@@ -327,7 +331,66 @@
</span><span class="cx">         splitFlow(beforeChild, newBox, newChild, oldContinuation);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><ins>+    
+    if (!useNewBlockInsideInlineModel) {
+        RenderBoxModelObject::addChild(newChild, beforeChild);
+        newChild-&gt;setNeedsLayoutAndPrefWidthsRecalc();
+        return;
+    }
</ins><span class="cx"> 
</span><ins>+    // This code is for the new block-inside-inline model that uses anonymous inline blocks.
+    // If the requested beforeChild is not one of our children, then this is most likely because
+    // there is an anonymous inline-block box within this object that contains the beforeChild.
+    // Insert the child into the anonymous inline-block box instead of here.
+    // A second possibility is that the beforeChild is an anonymous block inside the anonymous inline block.
+    // This can happen if inlines are inserted in between two of the anonymous inline block's block-level
+    // children after it has been created.
+    if (beforeChild &amp;&amp; beforeChild-&gt;parent() != this) {
+        ASSERT(beforeChild-&gt;parent());
+        ASSERT(beforeChild-&gt;parent()-&gt;isAnonymousInlineBlock() || beforeChild-&gt;parent()-&gt;isAnonymousBlock());
+        if (beforeChild-&gt;parent()-&gt;isAnonymousInlineBlock()) {
+            if (!newChild-&gt;isInline() || (newChild-&gt;isInline() &amp;&amp; beforeChild-&gt;parent()-&gt;firstChild() != beforeChild))
+                beforeChild-&gt;parent()-&gt;addChild(newChild, beforeChild);
+            else
+                addChild(newChild, beforeChild-&gt;parent());
+        } else if (beforeChild-&gt;parent()-&gt;isAnonymousBlock()) {
+            ASSERT(!beforeChild-&gt;parent()-&gt;parent() || beforeChild-&gt;parent()-&gt;parent()-&gt;isAnonymousInlineBlock());
+            ASSERT(beforeChild-&gt;isInline());
+            if (newChild-&gt;isInline() || (!newChild-&gt;isInline() &amp;&amp; beforeChild-&gt;parent()-&gt;firstChild() != beforeChild))
+                beforeChild-&gt;parent()-&gt;addChild(newChild, beforeChild);
+            else
+                addChild(newChild, beforeChild-&gt;parent());
+        }
+        return;
+    }
+
+    if (!newChild-&gt;isInline()) {
+        // We are placing a block inside an inline. We have to place the block inside an anonymous inline-block.
+        // This inline-block can house a sequence of contiguous block-level children, and they will all sit on the
+        // same &quot;line&quot; together. We try to reuse an existing inline-block if possible.
+        if (beforeChild) {
+            if (beforeChild-&gt;previousSibling() &amp;&amp; beforeChild-&gt;previousSibling()-&gt;isAnonymousInlineBlock()) {
+                downcast&lt;RenderBlockFlow&gt;(beforeChild-&gt;previousSibling())-&gt;addChild(newChild);
+                return;
+            }
+        } else {
+            if (lastChild() &amp;&amp; lastChild()-&gt;isAnonymousInlineBlock()) {
+                downcast&lt;RenderBlockFlow&gt;(lastChild())-&gt;addChild(newChild);
+                return;
+            }
+        }

+        if (!newChild-&gt;isFloatingOrOutOfFlowPositioned()) {
+            // There was no suitable existing anonymous inline-block. Create a new one.
+            RenderBlockFlow* anonymousInlineBlock = new RenderBlockFlow(document(), RenderStyle::createAnonymousStyleWithDisplay(&amp;style(), INLINE_BLOCK));
+            anonymousInlineBlock-&gt;initializeStyle();
+    
+            RenderBoxModelObject::addChild(anonymousInlineBlock, beforeChild);
+            anonymousInlineBlock-&gt;addChild(newChild);
+            return;
+        }
+    }
+
</ins><span class="cx">     RenderBoxModelObject::addChild(newChild, beforeChild);
</span><span class="cx"> 
</span><span class="cx">     newChild-&gt;setNeedsLayoutAndPrefWidthsRecalc();
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.h (182145 => 182146)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.h        2015-03-30 17:35:39 UTC (rev 182145)
+++ trunk/Source/WebCore/rendering/RenderObject.h        2015-03-30 18:02:37 UTC (rev 182146)
</span><span class="lines">@@ -489,6 +489,11 @@
</span><span class="cx"> #endif
</span><span class="cx">             ;
</span><span class="cx">     }
</span><ins>+    bool isAnonymousInlineBlock() const
+    {
+        return isAnonymous() &amp;&amp; style().display() == INLINE_BLOCK &amp;&amp; style().styleType() == NOPSEUDO &amp;&amp; isRenderBlockFlow() &amp;&amp; !isRubyRun() &amp;&amp; !isRubyBase();
+    }
+
</ins><span class="cx">     bool isElementContinuation() const { return node() &amp;&amp; node()-&gt;renderer() != this; }
</span><span class="cx">     bool isInlineElementContinuation() const { return isElementContinuation() &amp;&amp; isInline(); }
</span><span class="cx">     bool isBlockElementContinuation() const { return isElementContinuation() &amp;&amp; !isInline(); }
</span></span></pre>
</div>
</div>

</body>
</html>