<!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>[213455] 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/213455">213455</a></dd>
<dt>Author</dt> <dd>hyatt@apple.com</dd>
<dt>Date</dt> <dd>2017-03-06 10:00:35 -0800 (Mon, 06 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Enable fieldsets to be flexboxes, grids and multicolumn.
https://bugs.webkit.org/show_bug.cgi?id=169082

Source/WebCore:

Reviewed by Simon Fraser .

Added new tests in fast/forms/fieldset.

This patch eliminates RenderFieldset and moves the functionality into RenderBlock so that
derived classes can also be fieldsets.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
Remove RenderFieldset from the project.

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::titleUIElement):
Call in to RenderBlock now instead of RenderFieldset.

* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::createElementRenderer):
* html/HTMLFieldSetElement.h:
The fieldset DOM element now uses RenderElement::createFor to make renderers so that multiple display types
can be supported. A special flag has been added that indicates only to make flexbox and block-related
renderers (not table display types).

* rendering/OrderIterator.cpp:
(WebCore::OrderIterator::shouldSkipChild):
(WebCore::OrderIteratorPopulator::collectChild):
* rendering/OrderIterator.h:
Streamline child collection for flexboxes and grids to indicate whether the child should be skipped as a return
value from collectChild. Add a shouldSkipChild method that skips both out of flow positioned objects and
excluded children like the legends of fieldsets.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlockRareData::RenderBlockRareData):
When the legend is taller than the fieldset's borderBefore(), intrinsic border is added to the CSS border width.
This intrinsic border being factored in ensures that the padding and content boxes of fieldsets are correct
across any layout system, since the legend is now just treated as part of the border.

(WebCore::RenderBlock::computePreferredLogicalWidths):
(WebCore::RenderBlock::computeBlockPreferredLogicalWidths):
Call the new computePreferredWidthsForExcludedChildren to ensure that excluded children contribute to
preferred width in their own way and not as part of a specific layout system.

(WebCore::RenderBlock::renderName):
Hacked to still return RenderFieldSet for RenderBlockFlow-backed fieldsets for layout test compatibility.

(WebCore::RenderBlock::layoutExcludedChildren):
Renamed from layoutSpecialExcludedChild to more accurately reflect the fact that multiple excluded children
can be included here (e.g., both a multicolumn flow thread and a legend). The RenderBlock base class handles
the layout of legends by both placing them and setting the correct intrinsic border before amount on the
block.

(WebCore::RenderBlock::findFieldsetLegend):
Moved from RenderFieldset.

(WebCore::RenderBlock::adjustBorderBoxRectForPainting):
(WebCore::RenderBlock::paintRectToClipOutFromBorder):
These methods are used when painting to shrink the border box as needed to account for the legend and to
provide the portion of the border that needs to be clipped out. These methods have been enhanced to
properly support all writing modes.

(WebCore::RenderBlock::intrinsicBorderForFieldset):
(WebCore::RenderBlock::setIntrinsicBorderForFieldset):
(WebCore::RenderBlock::borderTop):
(WebCore::RenderBlock::borderLeft):
(WebCore::RenderBlock::borderBottom):
(WebCore::RenderBlock::borderRight):
(WebCore::RenderBlock::borderBefore):
These methods are overridden for border to ensure that the intrinsic border added by a tall legend is
properly factored in.

(WebCore::RenderBlock::computePreferredWidthsForExcludedChildren):
* rendering/RenderBlock.h:
This method computes the preferred widths for legend children in order to ensure that the legend properly
grows the width of the fieldset when it is the widest item.

(WebCore::RenderBlock::adjustBorderBoxLogicalHeightForBoxSizing):
(WebCore::RenderBlock::adjustContentBoxLogicalHeightForBoxSizing):
Preserve the behavior of fieldsets in that the available content size includes the space lost accounting
for the legend. I don't think this makes much sense, but it matches the behavior of other browsers
(and our old behavior).

(WebCore::RenderBlock::paintExcludedChildrenInBorder):
Method for painting the excluded children that might be present in our border. We only do this if the
paint phase is a box decoration painting phase and if the legend isn't self-painting.

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::willCreateColumns):
Allow fieldsets to create columns now.

(WebCore::RenderBlockFlow::layoutBlockChildren):
(WebCore::RenderBlockFlow::layoutExcludedChildren):
Renamed this method and change it to call the base class to ensure that legends in multicolumn fieldsets
get handled properly.

(WebCore::RenderBlockFlow::addChild):
Patched to make sure legends don't get put into the multicolumn flow thread, as they need to
remain outside of it.

(WebCore::RenderBlockFlow::layoutSpecialExcludedChild): Deleted.
Renamed to layoutExcludedChildren.

* rendering/RenderBlockFlow.h:
* rendering/RenderBox.cpp:
(WebCore::RenderBox::paintBoxDecorations):
(WebCore::RenderBox::paintMask):
Patched to call the new adjustBorderBoxRectForPainting and paintRectToClipOutFromBorder methods in
order to properly shrink the border box rect for painting and to clip out the portion of the border
covered by the legend.

(WebCore::RenderBox::avoidsFloats):
Add fieldsets as avoiding floats. RenderFieldset used to subclass this method to return true, but with
its removal, we need to put this in the base class along with legends.

* rendering/RenderBox.h:
(WebCore::RenderBox::isGridItem):
(WebCore::RenderBox::isFlexItem):
Patched to exclude legends so that they don't try to size like they are really in the grid or flexbox.

(WebCore::RenderBox::adjustBorderBoxRectForPainting):
This method is overridden by RenderBLock to handle adjusting fieldset border rects for painting.

* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintBorder):
* rendering/RenderBoxModelObject.h:
(WebCore::RenderBoxModelObject::paintRectToClipOutFromBorder):
Patched to properly paint fieldsets using the new helpers.

* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::FlexBoxIterator::next):
(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
(WebCore::RenderDeprecatedFlexibleBox::layoutHorizontalBox):
Make sure deprecated flexible boxes lay out their legends properly by calling layoutExcludedChildren.

* rendering/RenderElement.cpp:
(WebCore::RenderElement::createFor):
* rendering/RenderElement.h:
Patched to take a flag that limits what renderers can be created so that fieldsets don't make table
display types.

* rendering/RenderFieldset.cpp: Removed.
* rendering/RenderFieldset.h: Removed.
Remove RenderFieldset files from the tree.

* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::computeIntrinsicLogicalWidths):
(WebCore::RenderFlexibleBox::firstLineBaseline):
(WebCore::RenderFlexibleBox::layoutBlock):
(WebCore::RenderFlexibleBox::layoutFlexItems):
(WebCore::RenderFlexibleBox::prepareOrderIteratorAndMargins):
Make sure flexible boxes lay out their legends properly by calling layoutExcludedChildren.
Patch methods to use the OrderIterator's new shouldSkipChild method to ensure legends aren't
part of the flexible box layout.

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::layoutBlock):
(WebCore::RenderGrid::computeIntrinsicLogicalWidths):
(WebCore::RenderGrid::placeItemsOnGrid):
(WebCore::RenderGrid::populateExplicitGridAndOrderIterator):
(WebCore::RenderGrid::layoutGridItems):
Make sure grids lay out their legends properly by calling layoutExcludedChildren.
Patch methods to use the OrderIterator's new shouldSkipChild method to ensure legends aren't
part of the grid's layout.

* rendering/RenderMultiColumnFlowThread.cpp:
(WebCore::RenderMultiColumnFlowThread::populate):
Pull legends back up into the block and don't let them be part of the flow thread.

* rendering/RenderMultiColumnSet.cpp:
(WebCore::RenderMultiColumnSet::requiresBalancing):
Fix an assert to allow legends to exist as siblings of multicolumn sets.

* rendering/RenderObject.cpp:
(WebCore::RenderObject::isFieldset):
Changed to examine the HTML element rather than RenderFieldset.

* rendering/RenderObject.h:
(WebCore::RenderObject::isExcludedFromNormalLayout):
(WebCore::RenderObject::setIsExcludedFromNormalLayout):
(WebCore::RenderObject::RenderObjectBitfields::RenderObjectBitfields):
RenderObjects now have a new bit that is set for excluded objects like legends, flow threads,
placeholders, and ruby text. This bit lets code easily detect that an object is excluded from
the layout system and can be skipped.

(WebCore::RenderObject::isExcludedAndPlacedInBorder):
Helper method for asking if an object is painting inside the border. Used to know we
need to factor it into preferred width calculations outside of any one layout system
and also to know that we need to paint it when we paint the fieldset's border instead of
later (after we might have scrolled or clipped the child painting area).

* rendering/RenderRubyRun.cpp:
(WebCore::RenderRubyRun::layoutExcludedChildren):
(WebCore::RenderRubyRun::layoutSpecialExcludedChild): Deleted.
* rendering/RenderRubyRun.h:
Rename layoutSpecialExcludedChild to layoutExcludedChildren.

* rendering/RenderTable.cpp:
(WebCore::RenderTable::adjustBorderBoxRectForPainting):
(WebCore::RenderTable::paintBoxDecorations):
(WebCore::RenderTable::paintMask):
(WebCore::RenderTable::subtractCaptionRect): Deleted.
* rendering/RenderTable.h:
Patched tables to share the same border box rect adjustment used by fieldsets when subtracting
out captions. This is prep work to allow tables to be fieldsets, but for now I didn't go all the
way.

* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::paintBoxDecorations):
(WebCore::RenderTableCell::paintMask):
Make sure table cells adjust their border box rects for painting. Again this is prep work for
cells potentially being fieldsets, but not supported yet.

* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::layoutExcludedChildren):
(WebCore::RenderTextControl::layoutSpecialExcludedChild): Deleted.
* rendering/RenderTextControl.h:
* rendering/RenderTextControlMultiLine.cpp:
(WebCore::RenderTextControlMultiLine::layoutExcludedChildren):
(WebCore::RenderTextControlMultiLine::layoutSpecialExcludedChild): Deleted.
* rendering/RenderTextControlMultiLine.h:
Renamed the methods for doing the excluded child layout.

* rendering/RenderTreeAsText.cpp:
(WebCore::RenderTreeAsText::writeRenderObject):
Make sure to dump the original fieldset border and not the border with the extra legend stuff in it.

LayoutTests:

Reviewed by Simon Fraser.

* fast/forms/fieldset/abs-pos-child-sizing-expected.html: Added.
* fast/forms/fieldset/abs-pos-child-sizing.html: Added.
* fast/forms/fieldset/fieldset-deprecated-flexbox-expected.html: Added.
* fast/forms/fieldset/fieldset-deprecated-flexbox.html: Added.
* fast/forms/fieldset/fieldset-flexbox-expected.html: Added.
* fast/forms/fieldset/fieldset-flexbox.html: Added.
* fast/forms/fieldset/fieldset-grid-expected.html: Added.
* fast/forms/fieldset/fieldset-grid.html: Added.
* fast/forms/fieldset/fieldset-multicolumn-expected.html: Added.
* fast/forms/fieldset/fieldset-multicolumn.html: Added.
* fast/forms/fieldset/fieldset-overflow-auto-expected.html: Added.
* fast/forms/fieldset/fieldset-overflow-auto.html: Added.
* fast/forms/fieldset/fieldset-overflow-hidden-expected.html: Added.
* fast/forms/fieldset/fieldset-overflow-hidden.html: Added.
* fast/forms/fieldset/fieldset-positioned-children-expected.html: Added.
* fast/forms/fieldset/fieldset-positioned-children.html: Added.
* fast/forms/fieldset/fieldset-positioned-legend-expected.html: Added.
* fast/forms/fieldset/fieldset-positioned-legend.html: Added.
* fast/forms/fieldset/fieldset-self-painting-legend-expected.html: Added.
* fast/forms/fieldset/fieldset-self-painting-legend.html: Added.
* fast/forms/fieldset/fieldset-writing-modes-expected.html: Added.
* fast/forms/fieldset/fieldset-writing-modes.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAccessibilityRenderObjectcpp">trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityatkWebKitAccessibleWrapperAtkcpp">trunk/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFieldSetElementcpp">trunk/Source/WebCore/html/HTMLFieldSetElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFieldSetElementh">trunk/Source/WebCore/html/HTMLFieldSetElement.h</a></li>
<li><a href="#trunkSourceWebCorerenderingOrderIteratorcpp">trunk/Source/WebCore/rendering/OrderIterator.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingOrderIteratorh">trunk/Source/WebCore/rendering/OrderIterator.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockcpp">trunk/Source/WebCore/rendering/RenderBlock.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockh">trunk/Source/WebCore/rendering/RenderBlock.h</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>
<li><a href="#trunkSourceWebCorerenderingRenderBoxcpp">trunk/Source/WebCore/rendering/RenderBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxh">trunk/Source/WebCore/rendering/RenderBox.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxModelObjectcpp">trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxModelObjecth">trunk/Source/WebCore/rendering/RenderBoxModelObject.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderDeprecatedFlexibleBoxcpp">trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderElementcpp">trunk/Source/WebCore/rendering/RenderElement.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderElementh">trunk/Source/WebCore/rendering/RenderElement.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderFlexibleBoxcpp">trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderGridcpp">trunk/Source/WebCore/rendering/RenderGrid.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderMultiColumnFlowThreadcpp">trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderMultiColumnSetcpp">trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjectcpp">trunk/Source/WebCore/rendering/RenderObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjecth">trunk/Source/WebCore/rendering/RenderObject.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderRubyRuncpp">trunk/Source/WebCore/rendering/RenderRubyRun.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderRubyRunh">trunk/Source/WebCore/rendering/RenderRubyRun.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTablecpp">trunk/Source/WebCore/rendering/RenderTable.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTableh">trunk/Source/WebCore/rendering/RenderTable.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTableCellcpp">trunk/Source/WebCore/rendering/RenderTableCell.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTextControlcpp">trunk/Source/WebCore/rendering/RenderTextControl.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTextControlh">trunk/Source/WebCore/rendering/RenderTextControl.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTextControlMultiLinecpp">trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTextControlMultiLineh">trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTreeAsTextcpp">trunk/Source/WebCore/rendering/RenderTreeAsText.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderingAllInOnecpp">trunk/Source/WebCore/rendering/RenderingAllInOne.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastformsfieldsetabsposchildsizingexpectedhtml">trunk/LayoutTests/fast/forms/fieldset/abs-pos-child-sizing-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetabsposchildsizinghtml">trunk/LayoutTests/fast/forms/fieldset/abs-pos-child-sizing.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetdeprecatedflexboxexpectedhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-deprecated-flexbox-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetdeprecatedflexboxhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-deprecated-flexbox.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetflexboxexpectedhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-flexbox-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetflexboxhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-flexbox.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetgridexpectedhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-grid-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetgridhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-grid.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetmulticolumnexpectedhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-multicolumn-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetmulticolumnhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-multicolumn.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetoverflowautoexpectedhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-auto-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetoverflowautohtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-auto.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetoverflowhiddenexpectedhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-hidden-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetoverflowhiddenhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-hidden.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetpositionedchildrenexpectedhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-children-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetpositionedchildrenhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-children.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetpositionedlegendexpectedhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-legend-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetpositionedlegendhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-legend.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetselfpaintinglegendexpectedhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-self-painting-legend-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetselfpaintinglegendhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-self-painting-legend.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetwritingmodesexpectedhtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-writing-modes-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastformsfieldsetfieldsetwritingmodeshtml">trunk/LayoutTests/fast/forms/fieldset/fieldset-writing-modes.html</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorerenderingRenderFieldsetcpp">trunk/Source/WebCore/rendering/RenderFieldset.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderFieldseth">trunk/Source/WebCore/rendering/RenderFieldset.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/LayoutTests/ChangeLog        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2017-03-06  Dave Hyatt  &lt;hyatt@apple.com&gt;
+
+        Enable fieldsets to be flexboxes, grids and multicolumn.
+        https://bugs.webkit.org/show_bug.cgi?id=169082
+
+        Reviewed by Simon Fraser.
+
+        * fast/forms/fieldset/abs-pos-child-sizing-expected.html: Added.
+        * fast/forms/fieldset/abs-pos-child-sizing.html: Added.
+        * fast/forms/fieldset/fieldset-deprecated-flexbox-expected.html: Added.
+        * fast/forms/fieldset/fieldset-deprecated-flexbox.html: Added.
+        * fast/forms/fieldset/fieldset-flexbox-expected.html: Added.
+        * fast/forms/fieldset/fieldset-flexbox.html: Added.
+        * fast/forms/fieldset/fieldset-grid-expected.html: Added.
+        * fast/forms/fieldset/fieldset-grid.html: Added.
+        * fast/forms/fieldset/fieldset-multicolumn-expected.html: Added.
+        * fast/forms/fieldset/fieldset-multicolumn.html: Added.
+        * fast/forms/fieldset/fieldset-overflow-auto-expected.html: Added.
+        * fast/forms/fieldset/fieldset-overflow-auto.html: Added.
+        * fast/forms/fieldset/fieldset-overflow-hidden-expected.html: Added.
+        * fast/forms/fieldset/fieldset-overflow-hidden.html: Added.
+        * fast/forms/fieldset/fieldset-positioned-children-expected.html: Added.
+        * fast/forms/fieldset/fieldset-positioned-children.html: Added.
+        * fast/forms/fieldset/fieldset-positioned-legend-expected.html: Added.
+        * fast/forms/fieldset/fieldset-positioned-legend.html: Added.
+        * fast/forms/fieldset/fieldset-self-painting-legend-expected.html: Added.
+        * fast/forms/fieldset/fieldset-self-painting-legend.html: Added.
+        * fast/forms/fieldset/fieldset-writing-modes-expected.html: Added.
+        * fast/forms/fieldset/fieldset-writing-modes.html: Added.
+
</ins><span class="cx"> 2017-03-06  Antoine Quint  &lt;graouts@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Modern Media Controls] Tracks panel should clip and scroll content when numerous tracks are available
</span></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetabsposchildsizingexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/abs-pos-child-sizing-expected.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/abs-pos-child-sizing-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/abs-pos-child-sizing-expected.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,79 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;&lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+        &lt;style type=&quot;text/css&quot;&gt;
+            html,body {
+                color:black; background-color:white; font-size:16px; padding:0; margin:0;
+            }
+        
+        div {
+            position: absolute;
+            background: rgba(0,255,0,0.5);
+            top:0; bottom:0;
+            left:0; right:0;
+            z-index: 0;
+        }
+        c {
+            display: block;
+            background: blue;
+            height:100%;
+        }
+        
+        legend { height: 24px; }
+        
+        fieldset {
+            position: absolute;
+            border: 2px green solid;
+            width: 100px;
+            height: 100px;
+            margin-bottom:40px;
+        }
+        
+        #t1,#t3 { padding: 3px 5px 7px 11px; }
+        #t2,#t4 { padding: 0; }
+        
+        #t1 div, #t3 div {
+            /* same numbers as padding above */
+            left: -11px; right: -5px;
+            top:  -3px;  bottom:-7px;
+        }
+        
+        #t2 { top: 120px; }
+        #t3 { top: 240px; }
+        #t4 { top: 360px; }
+        
+        x {
+            position: absolute;
+            width:100px;
+            height:100px;
+        }
+        #t1 x, #t2 x {
+            height:78px; /* compensate for legend */
+        }
+        &lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    
+    
+    &lt;fieldset id=&quot;t1&quot;&gt;
+        &lt;legend&gt;legend&lt;/legend&gt;
+        &lt;x&gt;&lt;div&gt;&lt;/div&gt;&lt;c&gt;&lt;/c&gt;&lt;/x&gt;
+    &lt;/fieldset&gt;
+    
+    &lt;fieldset id=&quot;t2&quot;&gt;
+        &lt;legend&gt;legend&lt;/legend&gt;
+        &lt;x&gt;&lt;div&gt;&lt;/div&gt;&lt;/x&gt;
+    &lt;/fieldset&gt;
+    
+    &lt;fieldset id=&quot;t3&quot;&gt;
+        &lt;x&gt;&lt;div&gt;&lt;/div&gt;&lt;c&gt;&lt;/c&gt;&lt;/x&gt;
+    &lt;/fieldset&gt;
+    
+    &lt;fieldset id=&quot;t4&quot;&gt;
+        &lt;x&gt;&lt;div&gt;&lt;/div&gt;&lt;/x&gt;
+    &lt;/fieldset&gt;
+    
+    
+&lt;/body&gt;
+&lt;/html&gt;
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetabsposchildsizinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/abs-pos-child-sizing.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/abs-pos-child-sizing.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/abs-pos-child-sizing.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;&lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+        &lt;style type=&quot;text/css&quot;&gt;
+            html,body {
+                color:black; background-color:white; font-size:16px; padding:0; margin:0;
+            }
+        
+        div {
+            position: absolute;
+            background: rgba(0,255,0,0.5);
+            top:0; bottom:0;
+            left:0; right:0;
+            z-index: 0;
+        }
+        c {
+            display: block;
+            background: blue;
+            height:100%;
+        }
+        
+        legend { height: 24px; }
+        
+        fieldset {
+            position: absolute;
+            border: 2px green solid;
+            width: 100px;
+            height: 100px;
+            margin-bottom:40px;
+        }
+        
+        #t1,#t3 { padding: 3px 5px 7px 11px; }
+        #t2,#t4 { padding: 0; }
+        
+        #t2 { top: 120px; }
+        #t3 { top: 240px; }
+        #t4 { top: 360px; }
+            &lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    
+    
+    &lt;fieldset id=&quot;t1&quot;&gt;
+        &lt;legend&gt;legend&lt;/legend&gt;
+        &lt;div&gt;&lt;/div&gt;&lt;c&gt;&lt;/c&gt;
+    &lt;/fieldset&gt;
+    
+    &lt;fieldset id=&quot;t2&quot;&gt;
+        &lt;legend&gt;legend&lt;/legend&gt;
+        &lt;div&gt;&lt;/div&gt;
+    &lt;/fieldset&gt;
+    
+    &lt;fieldset id=&quot;t3&quot;&gt;
+        &lt;div&gt;&lt;/div&gt;&lt;c&gt;&lt;/c&gt;
+    &lt;/fieldset&gt;
+    
+    &lt;fieldset id=&quot;t4&quot;&gt;
+        &lt;div&gt;&lt;/div&gt;
+    &lt;/fieldset&gt;
+    
+    
+&lt;/body&gt;
+&lt;/html&gt;
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetdeprecatedflexboxexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-deprecated-flexbox-expected.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-deprecated-flexbox-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-deprecated-flexbox-expected.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            fieldset &gt; div { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px  }
+            fieldset { margin:0; vertical-align:bottom; -webkit-logical-width:320px; -webkit-logical-height:80px; display:flex; justify-content: center; align-items: stretch; background-color:#dddddd; border:12px solid navy; padding:28px }
+            &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;fieldset&gt;
+            &lt;legend&gt;Legend&lt;/legend&gt;
+            &lt;div&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+        &lt;/fieldset&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetdeprecatedflexboxhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-deprecated-flexbox.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-deprecated-flexbox.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-deprecated-flexbox.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            fieldset &gt; div { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px  }
+            fieldset { margin:0; vertical-align:bottom; -webkit-logical-width:320px; -webkit-logical-height:80px; display:-webkit-inline-box; -webkit-box-pack: center; -webkit-box-align: stretch; background-color:#dddddd; border:12px solid navy; padding:28px }
+            &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;fieldset&gt;
+            &lt;legend&gt;Legend&lt;/legend&gt;
+           &lt;div&gt;Fieldset Contents&lt;/div&gt;
+           
+           &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+           
+       &lt;/fieldset&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetflexboxexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-flexbox-expected.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-flexbox-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-flexbox-expected.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            .fieldset &gt; div { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px  }
+            .fieldset { margin:0; vertical-align:bottom; -webkit-logical-width:320px; -webkit-logical-height:80px; display:inline-flex; justify-content: center; align-items: stretch; background-color:#dddddd; border:12px solid navy; padding:28px }
+            &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;div class=fieldset style=&quot;writing-mode:vertical-lr;&quot;&gt;
+            &lt;div&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+        &lt;/div&gt;
+        
+        &lt;div class=fieldset style=&quot;writing-mode:vertical-rl; &quot;&gt;
+            &lt;div&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+        &lt;/div&gt;
+        
+        
+        &lt;div class=fieldset style=&quot;writing-mode:horizontal-bt&quot;&gt;
+            
+            &lt;div&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+        &lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetflexboxhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-flexbox.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-flexbox.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-flexbox.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            fieldset &gt; div { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px  }
+            fieldset { margin:0; vertical-align:bottom; -webkit-logical-width:320px; -webkit-logical-height:80px; display:inline-flex; justify-content: center; align-items: stretch; background-color:#dddddd; border:12px solid navy; padding:28px }
+            &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;fieldset style=&quot;writing-mode:vertical-lr;&quot;&gt;
+            &lt;div&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+        &lt;/fieldset&gt;
+
+        &lt;fieldset style=&quot;writing-mode:vertical-rl; &quot;&gt;
+            &lt;div&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+        &lt;/fieldset&gt;
+        
+        
+       &lt;fieldset style=&quot;writing-mode:horizontal-bt&quot;&gt;
+           &lt;div&gt;Fieldset Contents&lt;/div&gt;
+           
+           &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+           
+       &lt;/fieldset&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetgridexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-grid-expected.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-grid-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-grid-expected.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+    &lt;body&gt;
+        &lt;fieldset style=&quot;overflow:hidden; width:200px; height:200px;&quot;&gt;
+            &lt;legend&gt;Legend&lt;/legend&gt;
+            &lt;div style=&quot;display:grid; grid-template-columns: repeat(4,50px); grid-auto-rows: 20px;&quot;&gt;
+                &lt;p&gt;X
+                &lt;p&gt;X
+                &lt;p&gt;X
+                &lt;p&gt;X
+                &lt;p&gt;X
+                &lt;p&gt;X
+                &lt;p&gt;X
+                &lt;p&gt;X
+                &lt;p&gt;X
+                &lt;p&gt;X
+                &lt;p&gt;X
+            &lt;/div&gt;
+        &lt;/fieldset&gt;
+        &lt;fieldset&gt;
+            &lt;legend&gt;Legend&lt;/legend&gt;
+            &lt;div style=&quot;display:grid; grid-auto-columns: 50px; grid-auto-rows: 20px;&quot;&gt;
+                &lt;p&gt;X
+                &lt;p&gt;X
+                &lt;p&gt;X
+                &lt;p&gt;X
+                &lt;p&gt;X
+                &lt;p&gt;X
+                &lt;p&gt;X
+            &lt;/div&gt;
+        &lt;/fieldset&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetgridhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-grid.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-grid.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-grid.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+    &lt;body&gt;
+        &lt;fieldset style=&quot;display:grid; overflow:hidden; grid-template-columns: repeat(4,50px); grid-auto-rows: 20px; width:200px; height:200px;&quot;&gt;
+            &lt;legend&gt;Legend&lt;/legend&gt;
+            &lt;p&gt;X
+            &lt;p&gt;X
+            &lt;p&gt;X
+            &lt;p&gt;X
+            &lt;p&gt;X
+            &lt;p&gt;X
+            &lt;p&gt;X
+            &lt;p&gt;X
+            &lt;p&gt;X
+            &lt;p&gt;X
+            &lt;p&gt;X
+        &lt;/fieldset&gt;
+        &lt;fieldset style=&quot;display:grid; grid-auto-columns: 50px; grid-auto-rows: 20px;&quot;&gt;
+            &lt;legend&gt;Legend&lt;/legend&gt;
+            &lt;p&gt;X
+            &lt;p&gt;X
+            &lt;p&gt;X
+            &lt;p&gt;X
+            &lt;p&gt;X
+            &lt;p&gt;X
+            &lt;p&gt;X
+        &lt;/fieldset&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetmulticolumnexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-multicolumn-expected.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-multicolumn-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-multicolumn-expected.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+&lt;fieldset style=&quot;float:left&quot;&gt;&lt;legend style=&quot;font-size:48px&quot;&gt;Legend Title&lt;/legend&gt;
+    &lt;div style=&quot;columns:2;&quot;&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    &lt;/div&gt;
+&lt;/fieldset&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetmulticolumnhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-multicolumn.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-multicolumn.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-multicolumn.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;fieldset style=&quot;columns:2;float:left&quot;&gt;&lt;legend style=&quot;font-size:48px&quot;&gt;Legend Title&lt;/legend&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+    This content should be in two columns. It really should be.&lt;br&gt;
+&lt;/fieldset&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetoverflowautoexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-auto-expected.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-auto-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-auto-expected.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            .contents { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px }
+            .fieldset { vertical-align:bottom; -webkit-logical-width:320px; position:relative; display:inline-block;  padding:40px; -webkit-padding-before:0}
+            .legend {  -webkit-logical-height:64px; -webkit-logical-width: 284px; -webkit-margin-after:34px;background-color:#3080f0; border:8px solid lightblue; font-size:48px }
+            .behind-box { position:absolute; border:12px solid navy; z-index:-1 }
+            #scroll { overflow:auto; position:absolute;bottom:0;left:0;right:0; top:80px; bottom:12px; right:12px; left:12px; padding:28px 28px 0 28px  }
+        &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;div class=fieldset&gt;
+            &lt;div class=&quot;behind-box&quot; style=&quot;left:0; top:34px; right:0; bottom:0;&quot;&gt;&lt;/div&gt;
+            &lt;div class=legend&gt;Legend Title&lt;/div&gt;
+            
+            &lt;div id=scroll&gt;
+                
+            &lt;div class=contents&gt;Fieldset Contents&lt;/div&gt;
+            
+                &lt;div class=contents&gt;More Fieldset Contents&lt;/div&gt;
+            &lt;div class=contents&gt;More Fieldset Contents&lt;/div&gt;
+            &lt;div class=contents&gt;More Fieldset Contents&lt;/div&gt;
+            &lt;div class=contents&gt;More Fieldset Contents&lt;/div&gt;
+            &lt;div class=contents&gt;More Fieldset Contents&lt;/div&gt;
+            &lt;div class=contents style=&quot;margin-bottom:0&quot;&gt;More Fieldset Contents&lt;/div&gt;
+            
+            &lt;/div&gt;
+            
+        &lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetoverflowautohtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-auto.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-auto.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-auto.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            fieldset div:not(.positioned) { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px  }
+            fieldset { overflow:auto; position:relative; margin:0; vertical-align:bottom; -webkit-logical-width:320px; display:inline-block; border:12px solid navy; padding:28px }
+            legend { padding:0; -webkit-logical-height:64px; -webkit-logical-width: 284px; background-color:#3080f0; border:8px solid lightblue; font-size:48px }
+            .positioned { height:0 }
+        &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;fieldset&gt;
+            &lt;legend&gt;Legend Title&lt;/legend&gt;
+            
+            &lt;div class=positioned&gt;
+            &lt;div&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            &lt;/div&gt;
+            
+        &lt;/fieldset&gt;
+
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetoverflowhiddenexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-hidden-expected.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-hidden-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-hidden-expected.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            .contents { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px }
+            .fieldset { vertical-align:bottom; -webkit-logical-width:320px; position:relative; display:inline-block;  padding:40px; -webkit-padding-before:0}
+            .legend {  -webkit-logical-height:64px; -webkit-logical-width: 284px; -webkit-margin-after:34px;background-color:#3080f0; border:8px solid lightblue; font-size:48px }
+            .behind-box { position:absolute; border:12px solid navy; z-index:-1 }
+           
+        &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;div class=fieldset&gt;
+            &lt;div class=&quot;behind-box&quot; style=&quot;left:0; top:34px; right:0; bottom:0;&quot;&gt;&lt;/div&gt;
+            &lt;div class=legend&gt;Legend Title&lt;/div&gt;
+            
+            &lt;div class=contents&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div class=contents&gt;More Fieldset Contents&lt;/div&gt;
+            
+            
+        &lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetoverflowhiddenhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-hidden.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-hidden.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-overflow-hidden.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            fieldset &gt; div:not(.positioned) { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px  }
+            fieldset { overflow:hidden; position:relative; margin:0; vertical-align:bottom; -webkit-logical-width:320px; display:inline-block; border:12px solid navy; padding:28px }
+            legend { padding:0; -webkit-logical-height:64px; -webkit-logical-width: 284px; background-color:#3080f0; border:8px solid lightblue; font-size:48px }
+            
+        &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;fieldset&gt;
+            &lt;legend&gt;Legend Title&lt;/legend&gt;
+            
+            &lt;div&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+            
+        &lt;/fieldset&gt;
+
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetpositionedchildrenexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-children-expected.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-children-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-children-expected.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            .contents { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px }
+            .fieldset { vertical-align:bottom; -webkit-logical-width:320px; position:relative; display:inline-block;  padding:40px; -webkit-padding-before:0}
+            .legend {  -webkit-logical-height:64px; -webkit-logical-width: 284px; -webkit-margin-after:34px;background-color:#3080f0; border:8px solid lightblue; font-size:48px }
+            .behind-box { position:absolute; border:12px solid navy; z-index:-1 }
+            .positioned { position:absolute; top:90px; bottom:22px; right:22px; left:22px; background-color:darkblue; z-index:-1 }
+        &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;div class=fieldset&gt;
+            &lt;div class=&quot;behind-box&quot; style=&quot;left:0; top:34px; right:0; bottom:0;&quot;&gt;&lt;/div&gt;
+            &lt;div class=legend&gt;Legend Title&lt;/div&gt;
+            
+            &lt;div class=contents&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div class=contents&gt;More Fieldset Contents&lt;/div&gt;
+            
+            &lt;div class=&quot;positioned&quot;&gt;&lt;/div&gt;
+            
+        &lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetpositionedchildrenhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-children.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-children.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-children.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            fieldset &gt; div:not(.positioned) { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px  }
+            fieldset { position:relative; margin:0; vertical-align:bottom; -webkit-logical-width:320px; display:inline-block; border:12px solid navy; padding:28px }
+            legend { padding:0; -webkit-logical-height:64px; -webkit-logical-width: 284px; background-color:#3080f0; border:8px solid lightblue; font-size:48px }
+            .positioned { position:absolute; top:10px; bottom:10px; right:10px; left:10px; background-color:darkblue; z-index:-1 }
+        &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;fieldset&gt;
+            &lt;legend&gt;Legend Title&lt;/legend&gt;
+            
+            &lt;div&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+            &lt;div class=positioned&gt;&lt;/div&gt;
+        &lt;/fieldset&gt;
+
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetpositionedlegendexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-legend-expected.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-legend-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-legend-expected.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            .contents { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px;  }
+            .fieldset { position:relative; vertical-align:bottom; -webkit-logical-width:320px; position:relative; display:inline-block;   border:12px solid navy; padding:28px; }
+            .legend {  -webkit-logical-height:64px; -webkit-logical-width: 284px;background-color:#3080f080; border:8px solid lightblue; font-size:48px; position:absolute;bottom:0;right:0; position:absolute }
+            .behind-box { position:absolute;; z-index:-1;  }
+           
+        &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;div class=fieldset&gt;
+            &lt;div class=&quot;behind-box&quot; style=&quot;left:0; top:34px; right:0; bottom:0;&quot;&gt;&lt;/div&gt;
+            &lt;div class=legend&gt;Legend Title&lt;/div&gt;
+            
+            &lt;div class=contents&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div class=contents&gt;More Fieldset Contents&lt;/div&gt;
+            
+            
+        &lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetpositionedlegendhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-legend.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-legend.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-positioned-legend.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            fieldset &gt; div:not(.positioned) { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px;   }
+            fieldset { position:relative; margin:0; vertical-align:bottom; -webkit-logical-width:320px; display:inline-block; border:12px solid navy; padding:28px; }
+            legend { padding:0; -webkit-logical-height:64px; -webkit-logical-width: 284px; background-color:#3080f080; border:8px solid lightblue; font-size:48px; position:absolute;bottom:0;right:0 }
+            
+        &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;fieldset&gt;
+            &lt;legend&gt;Legend Title&lt;/legend&gt;
+            
+            &lt;div&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+            
+        &lt;/fieldset&gt;
+
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetselfpaintinglegendexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-self-painting-legend-expected.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-self-painting-legend-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-self-painting-legend-expected.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            .contents { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px;  }
+            .fieldset { vertical-align:bottom; -webkit-logical-width:320px; position:relative; display:inline-block;  padding:40px; -webkit-padding-before:0;  }
+            .legend {  -webkit-logical-height:64px; -webkit-logical-width: 284px; -webkit-margin-after:34px;background-color:#3080f080; border:8px solid lightblue; font-size:48px; transform:translateX(10px) }
+            .behind-box { position:absolute; border:12px solid navy; z-index:-1; border-top:12px solid transparent }
+           
+        &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;div class=fieldset&gt;
+            &lt;div class=&quot;behind-box&quot; style=&quot;left:0; top:34px; right:0; bottom:0;&quot;&gt;&lt;/div&gt;
+            &lt;div class=legend&gt;Legend Title&lt;/div&gt;
+            
+            &lt;div class=contents&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div class=contents&gt;More Fieldset Contents&lt;/div&gt;
+            
+            
+        &lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetselfpaintinglegendhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-self-painting-legend.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-self-painting-legend.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-self-painting-legend.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            fieldset &gt; div:not(.positioned) { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px;   }
+            fieldset { position:relative; margin:0; vertical-align:bottom; -webkit-logical-width:320px; display:inline-block; border:12px solid navy; padding:28px; border-top:12px solid transparent }
+            legend { padding:0; -webkit-logical-height:64px; -webkit-logical-width: 284px; background-color:#3080f080; border:8px solid lightblue; font-size:48px; transform:translateX(10px); }
+            
+        &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;fieldset&gt;
+            &lt;legend&gt;Legend Title&lt;/legend&gt;
+            
+            &lt;div&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+            
+        &lt;/fieldset&gt;
+
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetwritingmodesexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-writing-modes-expected.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-writing-modes-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-writing-modes-expected.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            .contents { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px }
+            .fieldset { vertical-align:bottom; -webkit-logical-width:320px; position:relative; display:inline-block; writing-mode:vertical-rl; padding:40px; -webkit-padding-before:0}
+            .legend {  -webkit-logical-height:64px; -webkit-logical-width: 284px; -webkit-margin-after:34px;background-color:#3080f0; border:8px solid lightblue; font-size:48px }
+            .behind-box { position:absolute; background-color:#dddddd; border:12px solid navy; z-index:-1 }
+        &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;div class=fieldset style=&quot;writing-mode:vertical-lr&quot;&gt;
+            &lt;div class=&quot;behind-box&quot; style=&quot;left:34px; top:0; right:0; bottom:0;&quot;&gt;&lt;/div&gt;
+            &lt;div class=legend&gt;Legend Title&lt;/div&gt;
+            
+            &lt;div class=contents&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div class=contents&gt;More Fieldset Contents&lt;/div&gt;
+            
+        &lt;/div&gt;
+        
+        &lt;div class=fieldset style=&quot;writing-mode:vertical-rl;&quot;&gt;
+            &lt;div class=&quot;behind-box&quot; style=&quot;right:34px; top:0; left:0; bottom:0;&quot;&gt;&lt;/div&gt;
+            &lt;div class=legend&gt;Legend Title&lt;/div&gt;
+            
+            &lt;div class=contents&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div class=contents&gt;More Fieldset Contents&lt;/div&gt;
+            
+        &lt;/div&gt;
+        
+        
+       
+       &lt;div class=fieldset style=&quot;writing-mode:horizontal-bt&quot;&gt;
+           &lt;div class=&quot;behind-box&quot; style=&quot;bottom:34px; top:0; right:0; left:0;&quot;&gt;&lt;/div&gt;
+           &lt;div class=legend&gt;Legend Title&lt;/div&gt;
+           
+           &lt;div class=contents&gt;Fieldset Contents&lt;/div&gt;
+           
+           &lt;div class=contents&gt;More Fieldset Contents&lt;/div&gt;
+           
+       &lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsfieldsetfieldsetwritingmodeshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-writing-modes.html (0 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/fieldset/fieldset-writing-modes.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-writing-modes.html        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;style&gt;
+            fieldset &gt; div { border:2px solid skyblue; background-color:#cccccc; -webkit-margin-before:6px; -webkit-margin-after:6px  }
+            fieldset { margin:0; vertical-align:bottom; -webkit-logical-width:320px; display:inline-block; background-color:#dddddd; border:12px solid navy; padding:28px }
+            legend { padding:0; -webkit-logical-height:64px; -webkit-logical-width: 284px; background-color:#3080f0; border:8px solid lightblue; font-size:48px }
+        &lt;/style&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;fieldset style=&quot;writing-mode:vertical-lr;&quot;&gt;
+            &lt;legend&gt;Legend Title&lt;/legend&gt;
+            
+            &lt;div&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+        &lt;/fieldset&gt;
+
+        &lt;fieldset style=&quot;writing-mode:vertical-rl; &quot;&gt;
+            &lt;legend&gt;Legend Title&lt;/legend&gt;
+            
+            &lt;div&gt;Fieldset Contents&lt;/div&gt;
+            
+            &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+            
+        &lt;/fieldset&gt;
+        
+        
+       &lt;fieldset style=&quot;writing-mode:horizontal-bt&quot;&gt;
+           &lt;legend&gt;Legend Title&lt;/legend&gt;
+           
+           &lt;div&gt;Fieldset Contents&lt;/div&gt;
+           
+           &lt;div&gt;More Fieldset Contents&lt;/div&gt;
+           
+       &lt;/fieldset&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/CMakeLists.txt        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -2422,7 +2422,6 @@
</span><span class="cx">     rendering/RenderDetailsMarker.cpp
</span><span class="cx">     rendering/RenderElement.cpp
</span><span class="cx">     rendering/RenderEmbeddedObject.cpp
</span><del>-    rendering/RenderFieldset.cpp
</del><span class="cx">     rendering/RenderFileUploadControl.cpp
</span><span class="cx">     rendering/RenderFlexibleBox.cpp
</span><span class="cx">     rendering/RenderFlowThread.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/ChangeLog        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -1,3 +1,232 @@
</span><ins>+2017-03-06  Dave Hyatt  &lt;hyatt@apple.com&gt;
+
+        Enable fieldsets to be flexboxes, grids and multicolumn.
+        https://bugs.webkit.org/show_bug.cgi?id=169082
+
+        Reviewed by Simon Fraser .
+
+        Added new tests in fast/forms/fieldset.
+
+        This patch eliminates RenderFieldset and moves the functionality into RenderBlock so that
+        derived classes can also be fieldsets.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        Remove RenderFieldset from the project.
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::titleUIElement):
+        Call in to RenderBlock now instead of RenderFieldset.
+
+        * html/HTMLFieldSetElement.cpp:
+        (WebCore::HTMLFieldSetElement::createElementRenderer):
+        * html/HTMLFieldSetElement.h:
+        The fieldset DOM element now uses RenderElement::createFor to make renderers so that multiple display types
+        can be supported. A special flag has been added that indicates only to make flexbox and block-related
+        renderers (not table display types).
+
+        * rendering/OrderIterator.cpp:
+        (WebCore::OrderIterator::shouldSkipChild):
+        (WebCore::OrderIteratorPopulator::collectChild):
+        * rendering/OrderIterator.h:
+        Streamline child collection for flexboxes and grids to indicate whether the child should be skipped as a return
+        value from collectChild. Add a shouldSkipChild method that skips both out of flow positioned objects and
+        excluded children like the legends of fieldsets.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlockRareData::RenderBlockRareData):
+        When the legend is taller than the fieldset's borderBefore(), intrinsic border is added to the CSS border width.
+        This intrinsic border being factored in ensures that the padding and content boxes of fieldsets are correct
+        across any layout system, since the legend is now just treated as part of the border.
+
+        (WebCore::RenderBlock::computePreferredLogicalWidths):
+        (WebCore::RenderBlock::computeBlockPreferredLogicalWidths):
+        Call the new computePreferredWidthsForExcludedChildren to ensure that excluded children contribute to
+        preferred width in their own way and not as part of a specific layout system.
+
+        (WebCore::RenderBlock::renderName):
+        Hacked to still return RenderFieldSet for RenderBlockFlow-backed fieldsets for layout test compatibility.
+
+        (WebCore::RenderBlock::layoutExcludedChildren):
+        Renamed from layoutSpecialExcludedChild to more accurately reflect the fact that multiple excluded children
+        can be included here (e.g., both a multicolumn flow thread and a legend). The RenderBlock base class handles
+        the layout of legends by both placing them and setting the correct intrinsic border before amount on the
+        block.
+
+        (WebCore::RenderBlock::findFieldsetLegend):
+        Moved from RenderFieldset.
+
+        (WebCore::RenderBlock::adjustBorderBoxRectForPainting):
+        (WebCore::RenderBlock::paintRectToClipOutFromBorder):
+        These methods are used when painting to shrink the border box as needed to account for the legend and to
+        provide the portion of the border that needs to be clipped out. These methods have been enhanced to
+        properly support all writing modes.
+
+        (WebCore::RenderBlock::intrinsicBorderForFieldset):
+        (WebCore::RenderBlock::setIntrinsicBorderForFieldset):
+        (WebCore::RenderBlock::borderTop):
+        (WebCore::RenderBlock::borderLeft):
+        (WebCore::RenderBlock::borderBottom):
+        (WebCore::RenderBlock::borderRight):
+        (WebCore::RenderBlock::borderBefore):
+        These methods are overridden for border to ensure that the intrinsic border added by a tall legend is
+        properly factored in.
+
+        (WebCore::RenderBlock::computePreferredWidthsForExcludedChildren):
+        * rendering/RenderBlock.h:
+        This method computes the preferred widths for legend children in order to ensure that the legend properly
+        grows the width of the fieldset when it is the widest item.
+
+        (WebCore::RenderBlock::adjustBorderBoxLogicalHeightForBoxSizing):
+        (WebCore::RenderBlock::adjustContentBoxLogicalHeightForBoxSizing):
+        Preserve the behavior of fieldsets in that the available content size includes the space lost accounting
+        for the legend. I don't think this makes much sense, but it matches the behavior of other browsers
+        (and our old behavior).
+
+        (WebCore::RenderBlock::paintExcludedChildrenInBorder):
+        Method for painting the excluded children that might be present in our border. We only do this if the
+        paint phase is a box decoration painting phase and if the legend isn't self-painting.
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::willCreateColumns):
+        Allow fieldsets to create columns now.
+
+        (WebCore::RenderBlockFlow::layoutBlockChildren):
+        (WebCore::RenderBlockFlow::layoutExcludedChildren):
+        Renamed this method and change it to call the base class to ensure that legends in multicolumn fieldsets
+        get handled properly.
+
+        (WebCore::RenderBlockFlow::addChild):
+        Patched to make sure legends don't get put into the multicolumn flow thread, as they need to
+        remain outside of it.
+
+        (WebCore::RenderBlockFlow::layoutSpecialExcludedChild): Deleted.
+        Renamed to layoutExcludedChildren.
+
+        * rendering/RenderBlockFlow.h:
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::paintBoxDecorations):
+        (WebCore::RenderBox::paintMask):
+        Patched to call the new adjustBorderBoxRectForPainting and paintRectToClipOutFromBorder methods in
+        order to properly shrink the border box rect for painting and to clip out the portion of the border
+        covered by the legend.
+
+        (WebCore::RenderBox::avoidsFloats):
+        Add fieldsets as avoiding floats. RenderFieldset used to subclass this method to return true, but with
+        its removal, we need to put this in the base class along with legends.
+
+        * rendering/RenderBox.h:
+        (WebCore::RenderBox::isGridItem):
+        (WebCore::RenderBox::isFlexItem):
+        Patched to exclude legends so that they don't try to size like they are really in the grid or flexbox.
+
+        (WebCore::RenderBox::adjustBorderBoxRectForPainting):
+        This method is overridden by RenderBLock to handle adjusting fieldset border rects for painting.
+
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintBorder):
+        * rendering/RenderBoxModelObject.h:
+        (WebCore::RenderBoxModelObject::paintRectToClipOutFromBorder):
+        Patched to properly paint fieldsets using the new helpers.
+
+        * rendering/RenderDeprecatedFlexibleBox.cpp:
+        (WebCore::FlexBoxIterator::next):
+        (WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
+        (WebCore::RenderDeprecatedFlexibleBox::layoutHorizontalBox):
+        Make sure deprecated flexible boxes lay out their legends properly by calling layoutExcludedChildren.
+
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::createFor):
+        * rendering/RenderElement.h:
+        Patched to take a flag that limits what renderers can be created so that fieldsets don't make table
+        display types.
+
+        * rendering/RenderFieldset.cpp: Removed.
+        * rendering/RenderFieldset.h: Removed.
+        Remove RenderFieldset files from the tree.
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::computeIntrinsicLogicalWidths):
+        (WebCore::RenderFlexibleBox::firstLineBaseline):
+        (WebCore::RenderFlexibleBox::layoutBlock):
+        (WebCore::RenderFlexibleBox::layoutFlexItems):
+        (WebCore::RenderFlexibleBox::prepareOrderIteratorAndMargins):
+        Make sure flexible boxes lay out their legends properly by calling layoutExcludedChildren.
+        Patch methods to use the OrderIterator's new shouldSkipChild method to ensure legends aren't
+        part of the flexible box layout.
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::layoutBlock):
+        (WebCore::RenderGrid::computeIntrinsicLogicalWidths):
+        (WebCore::RenderGrid::placeItemsOnGrid):
+        (WebCore::RenderGrid::populateExplicitGridAndOrderIterator):
+        (WebCore::RenderGrid::layoutGridItems):
+        Make sure grids lay out their legends properly by calling layoutExcludedChildren.
+        Patch methods to use the OrderIterator's new shouldSkipChild method to ensure legends aren't
+        part of the grid's layout.
+
+        * rendering/RenderMultiColumnFlowThread.cpp:
+        (WebCore::RenderMultiColumnFlowThread::populate):
+        Pull legends back up into the block and don't let them be part of the flow thread.
+
+        * rendering/RenderMultiColumnSet.cpp:
+        (WebCore::RenderMultiColumnSet::requiresBalancing):
+        Fix an assert to allow legends to exist as siblings of multicolumn sets.
+
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::isFieldset):
+        Changed to examine the HTML element rather than RenderFieldset.
+
+        * rendering/RenderObject.h:
+        (WebCore::RenderObject::isExcludedFromNormalLayout):
+        (WebCore::RenderObject::setIsExcludedFromNormalLayout):
+        (WebCore::RenderObject::RenderObjectBitfields::RenderObjectBitfields):
+        RenderObjects now have a new bit that is set for excluded objects like legends, flow threads,
+        placeholders, and ruby text. This bit lets code easily detect that an object is excluded from
+        the layout system and can be skipped.
+
+        (WebCore::RenderObject::isExcludedAndPlacedInBorder):
+        Helper method for asking if an object is painting inside the border. Used to know we
+        need to factor it into preferred width calculations outside of any one layout system
+        and also to know that we need to paint it when we paint the fieldset's border instead of
+        later (after we might have scrolled or clipped the child painting area).
+
+        * rendering/RenderRubyRun.cpp:
+        (WebCore::RenderRubyRun::layoutExcludedChildren):
+        (WebCore::RenderRubyRun::layoutSpecialExcludedChild): Deleted.
+        * rendering/RenderRubyRun.h:
+        Rename layoutSpecialExcludedChild to layoutExcludedChildren.
+
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::adjustBorderBoxRectForPainting):
+        (WebCore::RenderTable::paintBoxDecorations):
+        (WebCore::RenderTable::paintMask):
+        (WebCore::RenderTable::subtractCaptionRect): Deleted.
+        * rendering/RenderTable.h:
+        Patched tables to share the same border box rect adjustment used by fieldsets when subtracting
+        out captions. This is prep work to allow tables to be fieldsets, but for now I didn't go all the
+        way.
+
+        * rendering/RenderTableCell.cpp:
+        (WebCore::RenderTableCell::paintBoxDecorations):
+        (WebCore::RenderTableCell::paintMask):
+        Make sure table cells adjust their border box rects for painting. Again this is prep work for
+        cells potentially being fieldsets, but not supported yet.
+
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::layoutExcludedChildren):
+        (WebCore::RenderTextControl::layoutSpecialExcludedChild): Deleted.
+        * rendering/RenderTextControl.h:
+        * rendering/RenderTextControlMultiLine.cpp:
+        (WebCore::RenderTextControlMultiLine::layoutExcludedChildren):
+        (WebCore::RenderTextControlMultiLine::layoutSpecialExcludedChild): Deleted.
+        * rendering/RenderTextControlMultiLine.h:
+        Renamed the methods for doing the excluded child layout.
+
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::RenderTreeAsText::writeRenderObject):
+        Make sure to dump the original fieldset border and not the border with the extra legend stuff in it.
+
</ins><span class="cx"> 2017-03-06  Antoine Quint  &lt;graouts@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Modern Media Controls] Tracks panel should clip and scroll content when numerous tracks are available
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -4524,8 +4524,6 @@
</span><span class="cx">                 A8DF4AEF0980C42C0052981B /* RenderTableSection.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF4AE50980C42C0052981B /* RenderTableSection.h */; };
</span><span class="cx">                 A8DF4AF00980C42C0052981B /* RenderTableRow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF4AE60980C42C0052981B /* RenderTableRow.cpp */; };
</span><span class="cx">                 A8DF4AF10980C42C0052981B /* RenderTableCol.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF4AE70980C42C0052981B /* RenderTableCol.h */; };
</span><del>-                A8EA73C30A1900E300A8EF5F /* RenderFieldset.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA73AF0A1900E300A8EF5F /* RenderFieldset.cpp */; };
-                A8EA73C40A1900E300A8EF5F /* RenderFieldset.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA73B00A1900E300A8EF5F /* RenderFieldset.h */; };
</del><span class="cx">                 A8EA79F10A1916DF00A8EF5F /* HTMLOListElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA79E50A1916DF00A8EF5F /* HTMLOListElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A8EA79F20A1916DF00A8EF5F /* HTMLUListElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA79E60A1916DF00A8EF5F /* HTMLUListElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A8EA79F30A1916DF00A8EF5F /* HTMLUListElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA79E70A1916DF00A8EF5F /* HTMLUListElement.cpp */; };
</span><span class="lines">@@ -12442,8 +12440,6 @@
</span><span class="cx">                 A8DF4AE50980C42C0052981B /* RenderTableSection.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderTableSection.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A8DF4AE60980C42C0052981B /* RenderTableRow.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTableRow.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A8DF4AE70980C42C0052981B /* RenderTableCol.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderTableCol.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                A8EA73AF0A1900E300A8EF5F /* RenderFieldset.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFieldset.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
-                A8EA73B00A1900E300A8EF5F /* RenderFieldset.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderFieldset.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 A8EA79E50A1916DF00A8EF5F /* HTMLOListElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLOListElement.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A8EA79E60A1916DF00A8EF5F /* HTMLUListElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLUListElement.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A8EA79E70A1916DF00A8EF5F /* HTMLUListElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLUListElement.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -24329,8 +24325,6 @@
</span><span class="cx">                                 E43A023A17EB370A004CDD25 /* RenderElement.h */,
</span><span class="cx">                                 0F5B7A5210F65D7A00376302 /* RenderEmbeddedObject.cpp */,
</span><span class="cx">                                 0F5B7A5310F65D7A00376302 /* RenderEmbeddedObject.h */,
</span><del>-                                A8EA73AF0A1900E300A8EF5F /* RenderFieldset.cpp */,
-                                A8EA73B00A1900E300A8EF5F /* RenderFieldset.h */,
</del><span class="cx">                                 066C772E0AB603FD00238CC4 /* RenderFileUploadControl.cpp */,
</span><span class="cx">                                 066C772F0AB603FD00238CC4 /* RenderFileUploadControl.h */,
</span><span class="cx">                                 53C8298B13D8D92700DE2DEB /* RenderFlexibleBox.cpp */,
</span><span class="lines">@@ -27936,7 +27930,6 @@
</span><span class="cx">                                 9B32CDA913DF7FA900F34D13 /* RenderedPosition.h in Headers */,
</span><span class="cx">                                 E43A023B17EB370A004CDD25 /* RenderElement.h in Headers */,
</span><span class="cx">                                 0F5B7A5510F65D7A00376302 /* RenderEmbeddedObject.h in Headers */,
</span><del>-                                A8EA73C40A1900E300A8EF5F /* RenderFieldset.h in Headers */,
</del><span class="cx">                                 066C77310AB603FD00238CC4 /* RenderFileUploadControl.h in Headers */,
</span><span class="cx">                                 53C8298E13D8D92700DE2DEB /* RenderFlexibleBox.h in Headers */,
</span><span class="cx">                                 508CCA4F13CF106B003151F3 /* RenderFlowThread.h in Headers */,
</span><span class="lines">@@ -31703,7 +31696,6 @@
</span><span class="cx">                                 9B32CDAA13DF7FA900F34D13 /* RenderedPosition.cpp in Sources */,
</span><span class="cx">                                 E43A023D17EB3713004CDD25 /* RenderElement.cpp in Sources */,
</span><span class="cx">                                 0F5B7A5410F65D7A00376302 /* RenderEmbeddedObject.cpp in Sources */,
</span><del>-                                A8EA73C30A1900E300A8EF5F /* RenderFieldset.cpp in Sources */,
</del><span class="cx">                                 066C77300AB603FD00238CC4 /* RenderFileUploadControl.cpp in Sources */,
</span><span class="cx">                                 53C8298D13D8D92700DE2DEB /* RenderFlexibleBox.cpp in Sources */,
</span><span class="cx">                                 508CCA5013CF106B003151F3 /* RenderFlowThread.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAccessibilityRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -68,7 +68,6 @@
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;ProgressTracker.h&quot;
</span><span class="cx"> #include &quot;RenderButton.h&quot;
</span><del>-#include &quot;RenderFieldset.h&quot;
</del><span class="cx"> #include &quot;RenderFileUploadControl.h&quot;
</span><span class="cx"> #include &quot;RenderHTMLCanvas.h&quot;
</span><span class="cx"> #include &quot;RenderImage.h&quot;
</span><span class="lines">@@ -1081,7 +1080,7 @@
</span><span class="cx">     
</span><span class="cx">     // if isFieldset is true, the renderer is guaranteed to be a RenderFieldset
</span><span class="cx">     if (isFieldset())
</span><del>-        return axObjectCache()-&gt;getOrCreate(downcast&lt;RenderFieldset&gt;(*m_renderer).findLegend(RenderFieldset::IncludeFloatingOrOutOfFlow));
</del><ins>+        return axObjectCache()-&gt;getOrCreate(downcast&lt;RenderBlock&gt;(*m_renderer).findFieldsetLegend(RenderBlock::FieldsetIncludeFloatingOrOutOfFlow));
</ins><span class="cx">     
</span><span class="cx">     if (isFigure())
</span><span class="cx">         return captionForFigure();
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityatkWebKitAccessibleWrapperAtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx"> #include &quot;HTMLTableElement.h&quot;
</span><span class="cx"> #include &quot;HostWindow.h&quot;
</span><span class="cx"> #include &quot;RenderAncestorIterator.h&quot;
</span><del>-#include &quot;RenderFieldset.h&quot;
</del><ins>+#include &quot;RenderBlock.h&quot;
</ins><span class="cx"> #include &quot;RenderObject.h&quot;
</span><span class="cx"> #include &quot;SVGElement.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="lines">@@ -186,9 +186,11 @@
</span><span class="cx">         if (AccessibilityObject* label = coreObject-&gt;titleUIElement())
</span><span class="cx">             atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABELLED_BY, label-&gt;wrapper());
</span><span class="cx">     } else if (coreObject-&gt;roleValue() == LegendRole) {
</span><del>-        if (RenderFieldset* renderFieldset = ancestorsOfType&lt;RenderFieldset&gt;(*coreObject-&gt;renderer()).first()) {
-            AccessibilityObject* fieldset = coreObject-&gt;axObjectCache()-&gt;getOrCreate(renderFieldset);
-            atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABEL_FOR, fieldset-&gt;wrapper());
</del><ins>+        if (RenderBlock* renderFieldset = ancestorsOfType&lt;RenderBlock&gt;(*coreObject-&gt;renderer()).first()) {
+            if (renderFieldset-&gt;isFieldset()) {
+                AccessibilityObject* fieldset = coreObject-&gt;axObjectCache()-&gt;getOrCreate(renderFieldset);
+                atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABEL_FOR, fieldset-&gt;wrapper());
+            }
</ins><span class="cx">         }
</span><span class="cx">     } else if (AccessibilityObject* control = coreObject-&gt;correspondingControlForLabelElement()) {
</span><span class="cx">         atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABEL_FOR, control-&gt;wrapper());
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFieldSetElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFieldSetElement.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFieldSetElement.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/html/HTMLFieldSetElement.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -31,7 +31,7 @@
</span><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;HTMLObjectElement.h&quot;
</span><span class="cx"> #include &quot;NodeRareData.h&quot;
</span><del>-#include &quot;RenderFieldset.h&quot;
</del><ins>+#include &quot;RenderElement.h&quot;
</ins><span class="cx"> #include &lt;wtf/StdLibExtras.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -154,7 +154,7 @@
</span><span class="cx"> 
</span><span class="cx"> RenderPtr&lt;RenderElement&gt; HTMLFieldSetElement::createElementRenderer(RenderStyle&amp;&amp; style, const RenderTreePosition&amp;)
</span><span class="cx"> {
</span><del>-    return createRenderer&lt;RenderFieldset&gt;(*this, WTFMove(style));
</del><ins>+    return RenderElement::createFor(*this, WTFMove(style), RenderElement::OnlyCreateBlockAndFlexboxRenderers);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> HTMLLegendElement* HTMLFieldSetElement::legend() const
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFieldSetElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFieldSetElement.h (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFieldSetElement.h        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/html/HTMLFieldSetElement.h        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -30,7 +30,6 @@
</span><span class="cx"> 
</span><span class="cx"> class FormAssociatedElement;
</span><span class="cx"> class HTMLFormControlsCollection;
</span><del>-class RenderFieldSet;
</del><span class="cx"> 
</span><span class="cx"> class HTMLFieldSetElement final : public HTMLFormControlElement {
</span><span class="cx"> public:
</span><span class="lines">@@ -47,8 +46,6 @@
</span><span class="cx">     void addInvalidDescendant(const HTMLFormControlElement&amp;);
</span><span class="cx">     void removeInvalidDescendant(const HTMLFormControlElement&amp;);
</span><span class="cx"> 
</span><del>-    RenderFieldSet* renderer() const;
-
</del><span class="cx"> private:
</span><span class="cx">     HTMLFieldSetElement(const QualifiedName&amp;, Document&amp;, HTMLFormElement*);
</span><span class="cx">     ~HTMLFieldSetElement();
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingOrderIteratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/OrderIterator.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/OrderIterator.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/OrderIterator.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -77,14 +77,20 @@
</span><span class="cx">     m_isReset = true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool OrderIterator::shouldSkipChild(const RenderObject&amp; child) const
+{
+    return child.isOutOfFlowPositioned() || child.isExcludedFromNormalLayout();
+}
+
</ins><span class="cx"> OrderIteratorPopulator::~OrderIteratorPopulator()
</span><span class="cx"> {
</span><span class="cx">     m_iterator.reset();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void OrderIteratorPopulator::collectChild(const RenderBox&amp; child)
</del><ins>+bool OrderIteratorPopulator::collectChild(const RenderBox&amp; child)
</ins><span class="cx"> {
</span><span class="cx">     m_iterator.m_orderValues.insert(child.style().order());
</span><ins>+    return !m_iterator.shouldSkipChild(child);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingOrderIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/OrderIterator.h (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/OrderIterator.h        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/OrderIterator.h        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class RenderBox;
</span><ins>+class RenderObject;
</ins><span class="cx">     
</span><span class="cx"> class OrderIterator {
</span><span class="cx"> public:
</span><span class="lines">@@ -48,6 +49,8 @@
</span><span class="cx">     RenderBox* first();
</span><span class="cx">     RenderBox* next();
</span><span class="cx"> 
</span><ins>+    bool shouldSkipChild(const RenderObject&amp;) const;
+
</ins><span class="cx"> private:
</span><span class="cx">     void reset();
</span><span class="cx"> 
</span><span class="lines">@@ -69,7 +72,7 @@
</span><span class="cx">     }
</span><span class="cx">     ~OrderIteratorPopulator();
</span><span class="cx"> 
</span><del>-    void collectChild(const RenderBox&amp;);
</del><ins>+    bool collectChild(const RenderBox&amp;);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     OrderIterator&amp; m_iterator;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlock.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -245,15 +245,13 @@
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(RenderBlockRareData); WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="cx">     RenderBlockRareData()
</span><del>-        : m_paginationStrut(0)
-        , m_pageLogicalOffset(0)
-        , m_flowThreadContainingBlock(std::nullopt)
</del><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     LayoutUnit m_paginationStrut;
</span><span class="cx">     LayoutUnit m_pageLogicalOffset;
</span><del>-
</del><ins>+    LayoutUnit m_intrinsicBorderForFieldset;
+    
</ins><span class="cx">     std::optional&lt;RenderFlowThread*&gt; m_flowThreadContainingBlock;
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="lines">@@ -1605,6 +1603,9 @@
</span><span class="cx"> 
</span><span class="cx"> bool RenderBlock::paintChild(RenderBox&amp; child, PaintInfo&amp; paintInfo, const LayoutPoint&amp; paintOffset, PaintInfo&amp; paintInfoForChild, bool usePrintRect, PaintBlockType paintType)
</span><span class="cx"> {
</span><ins>+    if (child.isExcludedAndPlacedInBorder())
+        return true;
+
</ins><span class="cx">     // Check for page-break-before: always, and if it's set, break and bail.
</span><span class="cx">     bool checkBeforeAlways = !childrenInline() &amp;&amp; (usePrintRect &amp;&amp; alwaysPageBreak(child.style().breakBefore()));
</span><span class="cx">     LayoutUnit absoluteChildY = paintOffset.y() + child.y();
</span><span class="lines">@@ -1695,7 +1696,11 @@
</span><span class="cx">                 paintInfo.context().restore();
</span><span class="cx">         }
</span><span class="cx">     }
</span><del>-
</del><ins>+    
+    // Paint legends just above the border before we scroll or clip.
+    if (paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChildBlockBackground || paintPhase == PaintPhaseSelection)
+        paintExcludedChildrenInBorder(paintInfo, paintOffset);
+    
</ins><span class="cx">     if (paintPhase == PaintPhaseMask &amp;&amp; style().visibility() == VISIBLE) {
</span><span class="cx">         paintMask(paintInfo, paintOffset);
</span><span class="cx">         return;
</span><span class="lines">@@ -2767,9 +2772,20 @@
</span><span class="cx">     RenderObject* child = firstChild();
</span><span class="cx">     RenderBlock* containingBlock = this-&gt;containingBlock();
</span><span class="cx">     LayoutUnit floatLeftWidth = 0, floatRightWidth = 0;
</span><ins>+
+    LayoutUnit childMinWidth;
+    LayoutUnit childMaxWidth;
+    bool hadExcludedChildren = computePreferredWidthsForExcludedChildren(childMinWidth, childMaxWidth);
+    if (hadExcludedChildren) {
+        minLogicalWidth = std::max(childMinWidth, minLogicalWidth);
+        maxLogicalWidth = std::max(childMaxWidth, maxLogicalWidth);
+    }
+
</ins><span class="cx">     while (child) {
</span><del>-        // Positioned children don't affect the min/max width
-        if (child-&gt;isOutOfFlowPositioned()) {
</del><ins>+        // Positioned children don't affect the min/max width. Legends in fieldsets are skipped here
+        // since they compute outside of any one layout system. Other children excluded from
+        // normal layout are only used with block flows, so it's ok to calculate them here.
+        if (child-&gt;isOutOfFlowPositioned() || child-&gt;isExcludedAndPlacedInBorder()) {
</ins><span class="cx">             child = child-&gt;nextSibling();
</span><span class="cx">             continue;
</span><span class="cx">         }
</span><span class="lines">@@ -3770,7 +3786,8 @@
</span><span class="cx"> {
</span><span class="cx">     if (isBody())
</span><span class="cx">         return &quot;RenderBody&quot;; // FIXME: Temporary hack until we know that the regression tests pass.
</span><del>-
</del><ins>+    if (isFieldset())
+        return &quot;RenderFieldSet&quot;; // FIXME: Remove eventually, but done to keep tests from breaking.
</ins><span class="cx">     if (isFloating())
</span><span class="cx">         return &quot;RenderBlock (floating)&quot;;
</span><span class="cx">     if (isOutOfFlowPositioned())
</span><span class="lines">@@ -3902,4 +3919,267 @@
</span><span class="cx">     
</span><span class="cx">     return availableHeight;
</span><span class="cx"> }
</span><ins>+    
+void RenderBlock::layoutExcludedChildren(bool relayoutChildren)
+{
+    if (!isFieldset())
+        return;
+
+    setIntrinsicBorderForFieldset(0);
+
+    RenderBox* box = findFieldsetLegend();
+    if (!box)
+        return;
+
+    box-&gt;setIsExcludedFromNormalLayout(true);
+    for (auto&amp; child : childrenOfType&lt;RenderBox&gt;(*this)) {
+        if (&amp;child == box || !child.isLegend())
+            continue;
+        child.setIsExcludedFromNormalLayout(false);
+    }
+
+    RenderBox&amp; legend = *box;
+    if (relayoutChildren)
+        legend.setChildNeedsLayout(MarkOnlyThis);
+    legend.layoutIfNeeded();
+    
+    LayoutUnit logicalLeft;
+    if (style().isLeftToRightDirection()) {
+        switch (legend.style().textAlign()) {
+        case CENTER:
+            logicalLeft = (logicalWidth() - logicalWidthForChild(legend)) / 2;
+            break;
+        case RIGHT:
+            logicalLeft = logicalWidth() - borderEnd() - paddingEnd() - logicalWidthForChild(legend);
+            break;
+        default:
+            logicalLeft = borderStart() + paddingStart() + marginStartForChild(legend);
+            break;
+        }
+    } else {
+        switch (legend.style().textAlign()) {
+        case LEFT:
+            logicalLeft = borderStart() + paddingStart();
+            break;
+        case CENTER: {
+            // Make sure that the extra pixel goes to the end side in RTL (since it went to the end side
+            // in LTR).
+            LayoutUnit centeredWidth = logicalWidth() - logicalWidthForChild(legend);
+            logicalLeft = centeredWidth - centeredWidth / 2;
+            break;
+        }
+        default:
+            logicalLeft = logicalWidth() - borderStart() - paddingStart() - marginStartForChild(legend) - logicalWidthForChild(legend);
+            break;
+        }
+    }
+    
+    setLogicalLeftForChild(legend, logicalLeft);
+    
+    LayoutUnit fieldsetBorderBefore = borderBefore();
+    LayoutUnit legendLogicalHeight = logicalHeightForChild(legend);
+    LayoutUnit legendAfterMargin = marginAfterForChild(legend);
+    LayoutUnit topPositionForLegend = std::max(LayoutUnit(), (fieldsetBorderBefore - legendLogicalHeight) / 2);
+    LayoutUnit bottomPositionForLegend = topPositionForLegend + legendLogicalHeight + legendAfterMargin;
+
+    // Place the legend now.
+    setLogicalTopForChild(legend, topPositionForLegend);
+
+    // If the bottom of the legend (including its after margin) is below the fieldset border,
+    // then we need to add in sufficient intrinsic border to account for this gap.
+    // FIXME: Should we support the before margin of the legend? Not entirely clear.
+    // FIXME: Consider dropping support for the after margin of the legend. Not sure other
+    // browsers support that anyway.
+    if (bottomPositionForLegend &gt; fieldsetBorderBefore)
+        setIntrinsicBorderForFieldset(bottomPositionForLegend - fieldsetBorderBefore);
+    
+    // Now that the legend is included in the border extent, we can set our logical height
+    // to the borderBefore (which includes the legend and its after margin if they were bigger
+    // than the actual fieldset border) and then add in our padding before.
+    setLogicalHeight(borderBefore() + paddingBefore());
+}
+
+RenderBox* RenderBlock::findFieldsetLegend(FieldsetFindLegendOption option) const
+{
+    for (auto&amp; legend : childrenOfType&lt;RenderBox&gt;(*this)) {
+        if (option == FieldsetIgnoreFloatingOrOutOfFlow &amp;&amp; legend.isFloatingOrOutOfFlowPositioned())
+            continue;
+        if (legend.isLegend())
+            return const_cast&lt;RenderBox*&gt;(&amp;legend);
+    }
+    return nullptr;
+}
+
+void RenderBlock::adjustBorderBoxRectForPainting(LayoutRect&amp; paintRect)
+{
+    if (!isFieldset() || !intrinsicBorderForFieldset())
+        return;
+    
+    auto* legend = findFieldsetLegend();
+    if (!legend)
+        return;
+
+    if (style().isHorizontalWritingMode()) {
+        LayoutUnit yOff = std::max(LayoutUnit(), (legend-&gt;height() - RenderBox::borderBefore()) / 2);
+        paintRect.setHeight(paintRect.height() - yOff);
+        if (style().writingMode() == TopToBottomWritingMode)
+            paintRect.setY(paintRect.y() + yOff);
+    } else {
+        LayoutUnit xOff = std::max(LayoutUnit(), (legend-&gt;width() - RenderBox::borderBefore()) / 2);
+        paintRect.setWidth(paintRect.width() - xOff);
+        if (style().writingMode() == LeftToRightWritingMode)
+            paintRect.setX(paintRect.x() + xOff);
+    }
+}
+
+LayoutRect RenderBlock::paintRectToClipOutFromBorder(const LayoutRect&amp; paintRect)
+{
+    LayoutRect clipRect;
+    if (!isFieldset())
+        return clipRect;
+    auto* legend = findFieldsetLegend();
+    if (!legend)
+        return clipRect;
+
+    LayoutUnit borderExtent = RenderBox::borderBefore();
+    if (style().isHorizontalWritingMode()) {
+        clipRect.setX(paintRect.x() + legend-&gt;x());
+        clipRect.setY(style().writingMode() == TopToBottomWritingMode ? paintRect.y() : paintRect.y() + paintRect.height() - borderExtent);
+        clipRect.setWidth(legend-&gt;width());
+        clipRect.setHeight(borderExtent);
+    } else {
+        clipRect.setX(style().writingMode() == LeftToRightWritingMode ? paintRect.x() : paintRect.x() + paintRect.width() - borderExtent);
+        clipRect.setY(paintRect.y() + legend-&gt;y());
+        clipRect.setWidth(borderExtent);
+        clipRect.setHeight(legend-&gt;height());
+    }
+    return clipRect;
+}
+
+LayoutUnit RenderBlock::intrinsicBorderForFieldset() const
+{
+    auto* rareData = getBlockRareData(this);
+    return rareData ? rareData-&gt;m_intrinsicBorderForFieldset : LayoutUnit();
+}
+
+void RenderBlock::setIntrinsicBorderForFieldset(LayoutUnit padding)
+{
+    auto* rareData = getBlockRareData(this);
+    if (!rareData) {
+        if (!padding)
+            return;
+        rareData = &amp;ensureBlockRareData(this);
+    }
+    rareData-&gt;m_intrinsicBorderForFieldset = padding;
+}
+
+LayoutUnit RenderBlock::borderTop() const
+{
+    if (style().writingMode() != TopToBottomWritingMode || !intrinsicBorderForFieldset())
+        return RenderBox::borderTop();
+    return RenderBox::borderTop() + intrinsicBorderForFieldset();
+}
+
+LayoutUnit RenderBlock::borderLeft() const
+{
+    if (style().writingMode() != LeftToRightWritingMode || !intrinsicBorderForFieldset())
+        return RenderBox::borderLeft();
+    return RenderBox::borderLeft() + intrinsicBorderForFieldset();
+}
+
+LayoutUnit RenderBlock::borderBottom() const
+{
+    if (style().writingMode() != BottomToTopWritingMode || !intrinsicBorderForFieldset())
+        return RenderBox::borderBottom();
+    return RenderBox::borderBottom() + intrinsicBorderForFieldset();
+}
+
+LayoutUnit RenderBlock::borderRight() const
+{
+    if (style().writingMode() != RightToLeftWritingMode || !intrinsicBorderForFieldset())
+        return RenderBox::borderRight();
+    return RenderBox::borderRight() + intrinsicBorderForFieldset();
+}
+
+LayoutUnit RenderBlock::borderBefore() const
+{
+    return RenderBox::borderBefore() + intrinsicBorderForFieldset();
+}
+
+bool RenderBlock::computePreferredWidthsForExcludedChildren(LayoutUnit&amp; minWidth, LayoutUnit&amp; maxWidth) const
+{
+    if (!isFieldset())
+        return false;
+    
+    auto* legend = findFieldsetLegend();
+    if (!legend)
+        return false;
+    
+    legend-&gt;setIsExcludedFromNormalLayout(true);
+
+    computeChildPreferredLogicalWidths(*legend, minWidth, maxWidth);
+    
+    // These are going to be added in later, so we subtract them out to reflect the
+    // fact that the legend is outside the scrollable area.
+    auto scrollbarWidth = intrinsicScrollbarLogicalWidth();
+    minWidth -= scrollbarWidth;
+    maxWidth -= scrollbarWidth;
+    
+    const auto&amp; childStyle = legend-&gt;style();
+    auto startMarginLength = childStyle.marginStartUsing(&amp;style());
+    auto endMarginLength = childStyle.marginEndUsing(&amp;style());
+    LayoutUnit margin;
+    LayoutUnit marginStart;
+    LayoutUnit marginEnd;
+    if (startMarginLength.isFixed())
+        marginStart += startMarginLength.value();
+    if (endMarginLength.isFixed())
+        marginEnd += endMarginLength.value();
+    margin = marginStart + marginEnd;
+    
+    minWidth += margin;
+    maxWidth += margin;
+
+    return true;
+}
+
+LayoutUnit RenderBlock::adjustBorderBoxLogicalHeightForBoxSizing(LayoutUnit height) const
+{
+    // FIXME: We're doing this to match other browsers even though it's questionable.
+    // Shouldn't height:100px mean the fieldset content gets 100px of height even if the
+    // resulting fieldset becomes much taller because of the legend?
+    LayoutUnit bordersPlusPadding = borderAndPaddingLogicalHeight();
+    if (style().boxSizing() == CONTENT_BOX)
+        return height + bordersPlusPadding - intrinsicBorderForFieldset();
+    return std::max(height, bordersPlusPadding);
+}
+
+LayoutUnit RenderBlock::adjustContentBoxLogicalHeightForBoxSizing(std::optional&lt;LayoutUnit&gt; height) const
+{
+    // FIXME: We're doing this to match other browsers even though it's questionable.
+    // Shouldn't height:100px mean the fieldset content gets 100px of height even if the
+    // resulting fieldset becomes much taller because of the legend?
+    if (!height)
+        return 0;
+    LayoutUnit result = height.value();
+    if (style().boxSizing() == BORDER_BOX)
+        result -= borderAndPaddingLogicalHeight();
+    else
+        result -= intrinsicBorderForFieldset();
+    return std::max(LayoutUnit(), result);
+}
+
+void RenderBlock::paintExcludedChildrenInBorder(PaintInfo&amp; paintInfo, const LayoutPoint&amp; paintOffset)
+{
+    if (!isFieldset())
+        return;
+    
+    RenderBox* box = findFieldsetLegend();
+    if (!box || !box-&gt;isExcludedFromNormalLayout() || box-&gt;hasSelfPaintingLayer())
+        return;
+    
+    LayoutPoint childPoint = flipForWritingModeForChild(box, paintOffset);
+    box-&gt;paintAsInlineBlock(paintInfo, childPoint);
+}
+    
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlock.h (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlock.h        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderBlock.h        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -230,6 +230,20 @@
</span><span class="cx">     LayoutUnit pageLogicalOffset() const;
</span><span class="cx">     void setPageLogicalOffset(LayoutUnit);
</span><span class="cx"> 
</span><ins>+    // Fieldset legends that are taller than the fieldset border add in intrinsic border
+    // in order to ensure that content gets properly pushed down across all layout systems
+    // (flexbox, block, etc.)
+    LayoutUnit intrinsicBorderForFieldset() const;
+    void setIntrinsicBorderForFieldset(LayoutUnit);
+    LayoutUnit borderTop() const override;
+    LayoutUnit borderBottom() const override;
+    LayoutUnit borderLeft() const override;
+    LayoutUnit borderRight() const override;
+    LayoutUnit borderBefore() const override;
+    LayoutUnit adjustBorderBoxLogicalHeightForBoxSizing(LayoutUnit height) const override;
+    LayoutUnit adjustContentBoxLogicalHeightForBoxSizing(std::optional&lt;LayoutUnit&gt; height) const override;
+    void paintExcludedChildrenInBorder(PaintInfo&amp;, const LayoutPoint&amp;);
+    
</ins><span class="cx">     // Accessors for logical width/height and margins in the containing block's block-flow direction.
</span><span class="cx">     enum ApplyLayoutDeltaMode { ApplyLayoutDelta, DoNotApplyLayoutDelta };
</span><span class="cx">     LayoutUnit logicalWidthForChild(const RenderBox&amp; child) const { return isHorizontalWritingMode() ? child.width() : child.height(); }
</span><span class="lines">@@ -383,6 +397,14 @@
</span><span class="cx">     // children.
</span><span class="cx">     RenderBlock* firstLineBlock() const override;
</span><span class="cx"> 
</span><ins>+    enum FieldsetFindLegendOption { FieldsetIgnoreFloatingOrOutOfFlow, FieldsetIncludeFloatingOrOutOfFlow };
+    RenderBox* findFieldsetLegend(FieldsetFindLegendOption = FieldsetIgnoreFloatingOrOutOfFlow) const;
+    virtual void layoutExcludedChildren(bool /*relayoutChildren*/);
+    virtual bool computePreferredWidthsForExcludedChildren(LayoutUnit&amp;, LayoutUnit&amp;) const;
+    
+    void adjustBorderBoxRectForPainting(LayoutRect&amp;) override;
+    LayoutRect paintRectToClipOutFromBorder(const LayoutRect&amp;) override;
+    
</ins><span class="cx"> protected:
</span><span class="cx">     virtual void addOverflowFromChildren();
</span><span class="cx">     // FIXME-BLOCKFLOW: Remove virtualization when all callers have moved to RenderBlockFlow
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -432,7 +432,7 @@
</span><span class="cx"> bool RenderBlockFlow::willCreateColumns(std::optional&lt;unsigned&gt; desiredColumnCount) const
</span><span class="cx"> {
</span><span class="cx">     // The following types are not supposed to create multicol context.
</span><del>-    if (isFieldset() || isFileUploadControl() || isTextControl() || isListBox())
</del><ins>+    if (isFileUploadControl() || isTextControl() || isListBox())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     if (!firstChild())
</span><span class="lines">@@ -637,7 +637,7 @@
</span><span class="cx">     // Fieldsets need to find their legend and position it inside the border of the object.
</span><span class="cx">     // The legend then gets skipped during normal layout. The same is true for ruby text.
</span><span class="cx">     // It doesn't get included in the normal layout process but is instead skipped.
</span><del>-    RenderObject* childToExclude = layoutSpecialExcludedChild(relayoutChildren);
</del><ins>+    layoutExcludedChildren(relayoutChildren);
</ins><span class="cx"> 
</span><span class="cx">     LayoutUnit previousFloatLogicalBottom = 0;
</span><span class="cx">     maxFloatLogicalBottom = 0;
</span><span class="lines">@@ -648,7 +648,7 @@
</span><span class="cx">         RenderBox&amp; child = *next;
</span><span class="cx">         next = child.nextSiblingBox();
</span><span class="cx"> 
</span><del>-        if (childToExclude == &amp;child)
</del><ins>+        if (child.isExcludedFromNormalLayout())
</ins><span class="cx">             continue; // Skip this child, since it will be positioned by the specialized subclass (fieldsets and ruby runs).
</span><span class="cx"> 
</span><span class="cx">         updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, child);
</span><span class="lines">@@ -3874,12 +3874,16 @@
</span><span class="cx"> }
</span><span class="cx"> #endif // ENABLE(TEXT_AUTOSIZING)
</span><span class="cx"> 
</span><del>-RenderObject* RenderBlockFlow::layoutSpecialExcludedChild(bool relayoutChildren)
</del><ins>+void RenderBlockFlow::layoutExcludedChildren(bool relayoutChildren)
</ins><span class="cx"> {
</span><del>-    RenderMultiColumnFlowThread* flowThread = multiColumnFlowThread();
</del><ins>+    RenderBlock::layoutExcludedChildren(relayoutChildren);
+
+    auto* flowThread = multiColumnFlowThread();
</ins><span class="cx">     if (!flowThread)
</span><del>-        return nullptr;
</del><ins>+        return;
</ins><span class="cx"> 
</span><ins>+    flowThread-&gt;setIsExcludedFromNormalLayout(true);
+
</ins><span class="cx">     setLogicalTopForChild(*flowThread, borderAndPaddingBefore());
</span><span class="cx"> 
</span><span class="cx">     if (relayoutChildren)
</span><span class="lines">@@ -3904,13 +3908,11 @@
</span><span class="cx">         flowThread-&gt;setNeedsHeightsRecalculation(false);
</span><span class="cx">     }
</span><span class="cx">     determineLogicalLeftPositionForChild(*flowThread);
</span><del>-
-    return flowThread;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderBlockFlow::addChild(RenderObject* newChild, RenderObject* beforeChild)
</span><span class="cx"> {
</span><del>-    if (multiColumnFlowThread())
</del><ins>+    if (multiColumnFlowThread() &amp;&amp; (!isFieldset() || !newChild-&gt;isLegend()))
</ins><span class="cx">         return multiColumnFlowThread()-&gt;addChild(newChild, beforeChild);
</span><span class="cx">     auto* beforeChildOrPlaceholder = beforeChild;
</span><span class="cx">     if (auto* containingFlowThread = flowThreadContainingBlock())
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.h        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -469,6 +469,11 @@
</span><span class="cx">     
</span><span class="cx">     virtual void cachePriorCharactersIfNeeded(const LazyLineBreakIterator&amp;) {};
</span><span class="cx">     
</span><ins>+protected:
+    // Called to lay out the legend for a fieldset or the ruby text of a ruby run. Also used by multi-column layout to handle
+    // the flow thread child.
+    void layoutExcludedChildren(bool relayoutChildren) override;
+    
</ins><span class="cx"> private:
</span><span class="cx">     bool recomputeLogicalWidthAndColumnWidth();
</span><span class="cx">     LayoutUnit columnGap() const;
</span><span class="lines">@@ -475,12 +480,8 @@
</span><span class="cx">     
</span><span class="cx">     RenderBlockFlow* previousSiblingWithOverhangingFloats(bool&amp; parentHasFloats) const;
</span><span class="cx"> 
</span><del>-    // Called to lay out the legend for a fieldset or the ruby text of a ruby run. Also used by multi-column layout to handle
-    // the flow thread child.
-    virtual RenderObject* layoutSpecialExcludedChild(bool /*relayoutChildren*/);
</del><ins>+    void checkForPaginationLogicalHeightChange(bool&amp; relayoutChildren, LayoutUnit&amp; pageLogicalHeight, bool&amp; pageLogicalHeightChanged);
</ins><span class="cx"> 
</span><del>-    void checkForPaginationLogicalHeightChange(bool&amp; relayoutChildren, LayoutUnit&amp; pageLogicalHeight, bool&amp; pageLogicalHeightChanged);
-    
</del><span class="cx">     void paintInlineChildren(PaintInfo&amp;, const LayoutPoint&amp;) override;
</span><span class="cx">     void paintFloats(PaintInfo&amp;, const LayoutPoint&amp;, bool preservePhase = false) override;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBox.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -1336,6 +1336,7 @@
</span><span class="cx"> 
</span><span class="cx">     LayoutRect paintRect = borderBoxRectInRegion(currentRenderNamedFlowFragment());
</span><span class="cx">     paintRect.moveBy(paintOffset);
</span><ins>+    adjustBorderBoxRectForPainting(paintRect);
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     // Workaround for &lt;rdar://problem/6209763&gt;. Force the painting bounds of checkboxes and radio controls to be square.
</span><span class="lines">@@ -1585,6 +1586,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     LayoutRect paintRect = LayoutRect(paintOffset, size());
</span><ins>+    adjustBorderBoxRectForPainting(paintRect);
</ins><span class="cx">     paintMaskImages(paintInfo, paintRect);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -4555,7 +4557,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool RenderBox::avoidsFloats() const
</span><span class="cx"> {
</span><del>-    return (isReplaced() &amp;&amp; !isAnonymousInlineBlock()) || isHR() || isLegend() || createsNewFormattingContext();
</del><ins>+    return (isReplaced() &amp;&amp; !isAnonymousInlineBlock()) || isHR() || isLegend() || isFieldset() || createsNewFormattingContext();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderBox::addVisualEffectOverflow()
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBox.h (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBox.h        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderBox.h        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -328,10 +328,12 @@
</span><span class="cx">     LayoutSize offsetFromContainer(RenderElement&amp;, const LayoutPoint&amp;, bool* offsetDependsOnPoint = nullptr) const override;
</span><span class="cx">     
</span><span class="cx">     LayoutUnit adjustBorderBoxLogicalWidthForBoxSizing(LayoutUnit width) const;
</span><del>-    LayoutUnit adjustBorderBoxLogicalHeightForBoxSizing(LayoutUnit height) const;
</del><span class="cx">     LayoutUnit adjustContentBoxLogicalWidthForBoxSizing(LayoutUnit width) const;
</span><del>-    LayoutUnit adjustContentBoxLogicalHeightForBoxSizing(std::optional&lt;LayoutUnit&gt; height) const;
</del><span class="cx"> 
</span><ins>+    // Overridden by fieldsets to subtract out the intrinsic border.
+    virtual LayoutUnit adjustBorderBoxLogicalHeightForBoxSizing(LayoutUnit height) const;
+    virtual LayoutUnit adjustContentBoxLogicalHeightForBoxSizing(std::optional&lt;LayoutUnit&gt; height) const;
+
</ins><span class="cx">     struct ComputedMarginValues {
</span><span class="cx">         LayoutUnit m_before;
</span><span class="cx">         LayoutUnit m_after;
</span><span class="lines">@@ -618,9 +620,11 @@
</span><span class="cx"> 
</span><span class="cx">     const RenderBox* findEnclosingScrollableContainer() const;
</span><span class="cx">     
</span><del>-    bool isGridItem() const { return parent() &amp;&amp; parent()-&gt;isRenderGrid(); }
-    bool isFlexItem() const { return parent() &amp;&amp; parent()-&gt;isFlexibleBox(); }
</del><ins>+    bool isGridItem() const { return parent() &amp;&amp; parent()-&gt;isRenderGrid() &amp;&amp; !isExcludedFromNormalLayout(); }
+    bool isFlexItem() const { return parent() &amp;&amp; parent()-&gt;isFlexibleBox() &amp;&amp; !isExcludedFromNormalLayout(); }
</ins><span class="cx"> 
</span><ins>+    virtual void adjustBorderBoxRectForPainting(LayoutRect&amp;) { };
+
</ins><span class="cx"> protected:
</span><span class="cx">     RenderBox(Element&amp;, RenderStyle&amp;&amp;, BaseTypeFlags);
</span><span class="cx">     RenderBox(Document&amp;, RenderStyle&amp;&amp;, BaseTypeFlags);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -1718,6 +1718,12 @@
</span><span class="cx">     if (rect.isEmpty())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    auto rectToClipOut = paintRectToClipOutFromBorder(rect);
+    bool appliedClipAlready = !rectToClipOut.isEmpty();
+    GraphicsContextStateSaver stateSave(graphicsContext, appliedClipAlready);
+    if (!rectToClipOut.isEmpty())
+        graphicsContext.clipOut(snapRectToDevicePixels(rectToClipOut, document().deviceScaleFactor()));
+
</ins><span class="cx">     // border-image is not affected by border-radius.
</span><span class="cx">     if (paintNinePieceImage(graphicsContext, rect, style, style.borderImage()))
</span><span class="cx">         return;
</span><span class="lines">@@ -1856,7 +1862,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     bool clipToOuterBorder = outerBorder.isRounded();
</span><del>-    GraphicsContextStateSaver stateSaver(graphicsContext, clipToOuterBorder);
</del><ins>+    GraphicsContextStateSaver stateSaver(graphicsContext, clipToOuterBorder &amp;&amp; !appliedClipAlready);
</ins><span class="cx">     if (clipToOuterBorder) {
</span><span class="cx">         // Clip to the inner and outer radii rects.
</span><span class="cx">         if (bleedAvoidance != BackgroundBleedUseTransparencyLayer)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.h (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -236,6 +236,8 @@
</span><span class="cx"> 
</span><span class="cx">     RenderBoxModelObject* continuation() const;
</span><span class="cx"> 
</span><ins>+    virtual LayoutRect paintRectToClipOutFromBorder(const LayoutRect&amp;) { return LayoutRect(); };
+    
</ins><span class="cx"> protected:
</span><span class="cx">     RenderBoxModelObject(Element&amp;, RenderStyle&amp;&amp;, BaseTypeFlags);
</span><span class="cx">     RenderBoxModelObject(Document&amp;, RenderStyle&amp;&amp;, BaseTypeFlags);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderDeprecatedFlexibleBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -95,7 +95,7 @@
</span><span class="cx"> 
</span><span class="cx">             if (m_currentChild &amp;&amp; notFirstOrdinalValue())
</span><span class="cx">                 m_ordinalValues.add(m_currentChild-&gt;style().boxOrdinalGroup());
</span><del>-        } while (!m_currentChild || (!m_currentChild-&gt;isAnonymous()
</del><ins>+        } while (!m_currentChild || m_currentChild-&gt;isExcludedFromNormalLayout() || (!m_currentChild-&gt;isAnonymous()
</ins><span class="cx">                  &amp;&amp; m_currentChild-&gt;style().boxOrdinalGroup() != m_currentOrdinal));
</span><span class="cx">         return m_currentChild;
</span><span class="cx">     }
</span><span class="lines">@@ -302,6 +302,11 @@
</span><span class="cx">     LayoutSize oldLayoutDelta = view().layoutDelta();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    // Fieldsets need to find their legend and position it inside the border of the object.
+    // The legend then gets skipped during normal layout. The same is true for ruby text.
+    // It doesn't get included in the normal layout process but is instead skipped.
+    layoutExcludedChildren(relayoutChildren);
+
</ins><span class="cx">     ChildFrameRects oldChildRects;
</span><span class="cx">     appendChildFrameRects(this, oldChildRects);
</span><span class="cx">     
</span><span class="lines">@@ -427,9 +432,6 @@
</span><span class="cx">             
</span><span class="cx">             // Apply the child's current layout delta.
</span><span class="cx">             layoutChildIfNeededApplyingDelta(child, childLayoutDelta);
</span><del>-            
-            // Now do the layout.
-            layoutChildIfNeededApplyingDelta(child, childLayoutDelta);
</del><span class="cx"> 
</span><span class="cx">             // Update our height and overflow height.
</span><span class="cx">             if (style().boxAlign() == BBASELINE) {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderElement.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -156,13 +156,13 @@
</span><span class="cx">         view().unregisterForVisibleInViewportCallback(*this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderPtr&lt;RenderElement&gt; RenderElement::createFor(Element&amp; element, RenderStyle&amp;&amp; style)
</del><ins>+RenderPtr&lt;RenderElement&gt; RenderElement::createFor(Element&amp; element, RenderStyle&amp;&amp; style, RendererCreationType creationType)
</ins><span class="cx"> {
</span><span class="cx">     // Minimal support for content properties replacing an entire element.
</span><span class="cx">     // Works only if we have exactly one piece of content and it's a URL.
</span><span class="cx">     // Otherwise acts as if we didn't support this feature.
</span><span class="cx">     const ContentData* contentData = style.contentData();
</span><del>-    if (contentData &amp;&amp; !contentData-&gt;next() &amp;&amp; is&lt;ImageContentData&gt;(*contentData) &amp;&amp; !element.isPseudoElement()) {
</del><ins>+    if (creationType == CreateAllRenderers &amp;&amp; contentData &amp;&amp; !contentData-&gt;next() &amp;&amp; is&lt;ImageContentData&gt;(*contentData) &amp;&amp; !element.isPseudoElement()) {
</ins><span class="cx">         Style::loadPendingResources(style, element.document(), &amp;element);
</span><span class="cx">         auto&amp; styleImage = downcast&lt;ImageContentData&gt;(*contentData).image();
</span><span class="cx">         auto image = createRenderer&lt;RenderImage&gt;(element, WTFMove(style), const_cast&lt;StyleImage*&gt;(&amp;styleImage));
</span><span class="lines">@@ -175,7 +175,9 @@
</span><span class="cx">     case CONTENTS:
</span><span class="cx">         return nullptr;
</span><span class="cx">     case INLINE:
</span><del>-        return createRenderer&lt;RenderInline&gt;(element, WTFMove(style));
</del><ins>+        if (creationType == CreateAllRenderers)
+            return createRenderer&lt;RenderInline&gt;(element, WTFMove(style));
+        FALLTHROUGH; // Fieldsets should make a block flow if display:inline is set.
</ins><span class="cx">     case BLOCK:
</span><span class="cx">     case INLINE_BLOCK:
</span><span class="cx">     case COMPACT:
</span><span class="lines">@@ -182,25 +184,6 @@
</span><span class="cx">         return createRenderer&lt;RenderBlockFlow&gt;(element, WTFMove(style));
</span><span class="cx">     case LIST_ITEM:
</span><span class="cx">         return createRenderer&lt;RenderListItem&gt;(element, WTFMove(style));
</span><del>-    case TABLE:
-    case INLINE_TABLE:
-        return createRenderer&lt;RenderTable&gt;(element, WTFMove(style));
-    case TABLE_ROW_GROUP:
-    case TABLE_HEADER_GROUP:
-    case TABLE_FOOTER_GROUP:
-        return createRenderer&lt;RenderTableSection&gt;(element, WTFMove(style));
-    case TABLE_ROW:
-        return createRenderer&lt;RenderTableRow&gt;(element, WTFMove(style));
-    case TABLE_COLUMN_GROUP:
-    case TABLE_COLUMN:
-        return createRenderer&lt;RenderTableCol&gt;(element, WTFMove(style));
-    case TABLE_CELL:
-        return createRenderer&lt;RenderTableCell&gt;(element, WTFMove(style));
-    case TABLE_CAPTION:
-        return createRenderer&lt;RenderTableCaption&gt;(element, WTFMove(style));
-    case BOX:
-    case INLINE_BOX:
-        return createRenderer&lt;RenderDeprecatedFlexibleBox&gt;(element, WTFMove(style));
</del><span class="cx">     case FLEX:
</span><span class="cx">     case INLINE_FLEX:
</span><span class="cx">     case WEBKIT_FLEX:
</span><span class="lines">@@ -209,7 +192,35 @@
</span><span class="cx">     case GRID:
</span><span class="cx">     case INLINE_GRID:
</span><span class="cx">         return createRenderer&lt;RenderGrid&gt;(element, WTFMove(style));
</span><ins>+    case BOX:
+    case INLINE_BOX:
+        return createRenderer&lt;RenderDeprecatedFlexibleBox&gt;(element, WTFMove(style));
+    default: {
+        if (creationType == OnlyCreateBlockAndFlexboxRenderers)
+            return createRenderer&lt;RenderBlockFlow&gt;(element, WTFMove(style));
+        switch (style.display()) {
+        case TABLE:
+        case INLINE_TABLE:
+            return createRenderer&lt;RenderTable&gt;(element, WTFMove(style));
+        case TABLE_CELL:
+            return createRenderer&lt;RenderTableCell&gt;(element, WTFMove(style));
+        case TABLE_CAPTION:
+            return createRenderer&lt;RenderTableCaption&gt;(element, WTFMove(style));
+        case TABLE_ROW_GROUP:
+        case TABLE_HEADER_GROUP:
+        case TABLE_FOOTER_GROUP:
+            return createRenderer&lt;RenderTableSection&gt;(element, WTFMove(style));
+        case TABLE_ROW:
+            return createRenderer&lt;RenderTableRow&gt;(element, WTFMove(style));
+        case TABLE_COLUMN_GROUP:
+        case TABLE_COLUMN:
+            return createRenderer&lt;RenderTableCol&gt;(element, WTFMove(style));
+        default:
+            break;
+        }
+        break;
</ins><span class="cx">     }
</span><ins>+    }
</ins><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="lines">@@ -1208,9 +1219,10 @@
</span><span class="cx">     // Paint all phases atomically, as though the element established its own stacking context.
</span><span class="cx">     // (See Appendix E.2, section 6.4 on inline block/table/replaced elements in the CSS2.1 specification.)
</span><span class="cx">     // This is also used by other elements (e.g. flex items and grid items).
</span><del>-    if (paintInfo.phase == PaintPhaseSelection) {
</del><ins>+    PaintPhase paintPhaseToUse = isExcludedAndPlacedInBorder() ? paintInfo.phase : PaintPhaseForeground;
+    if (paintInfo.phase == PaintPhaseSelection)
</ins><span class="cx">         paint(paintInfo, childPoint);
</span><del>-    } else if (paintInfo.phase == PaintPhaseForeground) {
</del><ins>+    else if (paintInfo.phase == paintPhaseToUse) {
</ins><span class="cx">         paintPhase(*this, PaintPhaseBlockBackground, paintInfo, childPoint);
</span><span class="cx">         paintPhase(*this, PaintPhaseChildBlockBackgrounds, paintInfo, childPoint);
</span><span class="cx">         paintPhase(*this, PaintPhaseFloat, paintInfo, childPoint);
</span><span class="lines">@@ -1218,7 +1230,7 @@
</span><span class="cx">         paintPhase(*this, PaintPhaseOutline, paintInfo, childPoint);
</span><span class="cx"> 
</span><span class="cx">         // Reset |paintInfo| to the original phase.
</span><del>-        paintInfo.phase = PaintPhaseForeground;
</del><ins>+        paintInfo.phase = paintPhaseToUse;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderElement.h (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderElement.h        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderElement.h        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -36,7 +36,8 @@
</span><span class="cx"> public:
</span><span class="cx">     virtual ~RenderElement();
</span><span class="cx"> 
</span><del>-    static RenderPtr&lt;RenderElement&gt; createFor(Element&amp;, RenderStyle&amp;&amp;);
</del><ins>+    enum RendererCreationType { CreateAllRenderers, OnlyCreateBlockAndFlexboxRenderers };
+    static RenderPtr&lt;RenderElement&gt; createFor(Element&amp;, RenderStyle&amp;&amp;, RendererCreationType = CreateAllRenderers);
</ins><span class="cx"> 
</span><span class="cx">     bool hasInitializedStyle() const { return m_hasInitializedStyle; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderFieldsetcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/rendering/RenderFieldset.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderFieldset.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderFieldset.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -1,222 +0,0 @@
</span><del>-/*
- * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- *           (C) 1999 Antti Koivisto (koivisto@kde.org)
- *           (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006 Apple Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include &quot;config.h&quot;
-#include &quot;RenderFieldset.h&quot;
-
-#include &quot;CSSPropertyNames.h&quot;
-#include &quot;GraphicsContext.h&quot;
-#include &quot;HTMLFieldSetElement.h&quot;
-#include &quot;HTMLLegendElement.h&quot;
-#include &quot;HTMLNames.h&quot;
-#include &quot;PaintInfo.h&quot;
-#include &quot;RenderChildIterator.h&quot;
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-RenderFieldset::RenderFieldset(HTMLFieldSetElement&amp; element, RenderStyle&amp;&amp; style)
-    : RenderBlockFlow(element, WTFMove(style))
-{
-}
-
-void RenderFieldset::computePreferredLogicalWidths()
-{
-    RenderBlockFlow::computePreferredLogicalWidths();
-    if (RenderBox* legend = findLegend()) {
-        int legendMinWidth = legend-&gt;minPreferredLogicalWidth();
-
-        Length legendMarginLeft = legend-&gt;style().marginLeft();
-        Length legendMarginRight = legend-&gt;style().marginLeft();
-
-        if (legendMarginLeft.isFixed())
-            legendMinWidth += legendMarginLeft.value();
-
-        if (legendMarginRight.isFixed())
-            legendMinWidth += legendMarginRight.value();
-
-        m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, legendMinWidth + horizontalBorderAndPaddingExtent());
-    }
-}
-
-RenderObject* RenderFieldset::layoutSpecialExcludedChild(bool relayoutChildren)
-{
-    RenderBox* box = findLegend();
-    if (!box)
-        return nullptr;
-
-    RenderBox&amp; legend = *box;
-    if (relayoutChildren)
-        legend.setNeedsLayout();
-    legend.layoutIfNeeded();
-
-    LayoutUnit logicalLeft;
-    if (style().isLeftToRightDirection()) {
-        switch (legend.style().textAlign()) {
-        case CENTER:
-            logicalLeft = (logicalWidth() - logicalWidthForChild(legend)) / 2;
-            break;
-        case RIGHT:
-            logicalLeft = logicalWidth() - borderEnd() - paddingEnd() - logicalWidthForChild(legend);
-            break;
-        default:
-            logicalLeft = borderStart() + paddingStart() + marginStartForChild(legend);
-            break;
-        }
-    } else {
-        switch (legend.style().textAlign()) {
-        case LEFT:
-            logicalLeft = borderStart() + paddingStart();
-            break;
-        case CENTER: {
-            // Make sure that the extra pixel goes to the end side in RTL (since it went to the end side
-            // in LTR).
-            LayoutUnit centeredWidth = logicalWidth() - logicalWidthForChild(legend);
-            logicalLeft = centeredWidth - centeredWidth / 2;
-            break;
-        }
-        default:
-            logicalLeft = logicalWidth() - borderStart() - paddingStart() - marginStartForChild(legend) - logicalWidthForChild(legend);
-            break;
-        }
-    }
-
-    setLogicalLeftForChild(legend, logicalLeft);
-
-    LayoutUnit fieldsetBorderBefore = borderBefore();
-    LayoutUnit legendLogicalHeight = logicalHeightForChild(legend);
-
-    LayoutUnit legendLogicalTop;
-    LayoutUnit collapsedLegendExtent;
-    // FIXME: We need to account for the legend's margin before too.
-    if (fieldsetBorderBefore &gt; legendLogicalHeight) {
-        // The &lt;legend&gt; is smaller than the associated fieldset before border
-        // so the latter determines positioning of the &lt;legend&gt;. The sizing depends
-        // on the legend's margins as we want to still follow the author's cues.
-        // Firefox completely ignores the margins in this case which seems wrong.
-        legendLogicalTop = (fieldsetBorderBefore - legendLogicalHeight) / 2;
-        collapsedLegendExtent = std::max&lt;LayoutUnit&gt;(fieldsetBorderBefore, legendLogicalTop + legendLogicalHeight + marginAfterForChild(legend));
-    } else
-        collapsedLegendExtent = legendLogicalHeight + marginAfterForChild(legend);
-
-    setLogicalTopForChild(legend, legendLogicalTop);
-    setLogicalHeight(paddingBefore() + collapsedLegendExtent);
-
-    return &amp;legend;
-}
-
-RenderBox* RenderFieldset::findLegend(FindLegendOption option)
-{
-    for (auto&amp; legend : childrenOfType&lt;RenderBox&gt;(*this)) {
-        if (option == IgnoreFloatingOrOutOfFlow &amp;&amp; legend.isFloatingOrOutOfFlowPositioned())
-            continue;
-        
-        if (is&lt;HTMLLegendElement&gt;(legend.element()))
-            return &amp;legend;
-    }
-    return nullptr;
-}
-
-void RenderFieldset::paintBoxDecorations(PaintInfo&amp; paintInfo, const LayoutPoint&amp; paintOffset)
-{
-    if (!paintInfo.shouldPaintWithinRoot(*this))
-        return;
-
-    LayoutRect paintRect(paintOffset, size());
-    RenderBox* legend = findLegend();
-    if (!legend)
-        return RenderBlockFlow::paintBoxDecorations(paintInfo, paintOffset);
-
-    // FIXME: We need to work with &quot;rl&quot; and &quot;bt&quot; block flow directions.  In those
-    // cases the legend is embedded in the right and bottom borders respectively.
-    // https://bugs.webkit.org/show_bug.cgi?id=47236
-    if (style().isHorizontalWritingMode()) {
-        LayoutUnit yOff = (legend-&gt;y() &gt; 0) ? LayoutUnit() : (legend-&gt;height() - borderTop()) / 2;
-        paintRect.setHeight(paintRect.height() - yOff);
-        paintRect.setY(paintRect.y() + yOff);
-    } else {
-        LayoutUnit xOff = (legend-&gt;x() &gt; 0) ? LayoutUnit() : (legend-&gt;width() - borderLeft()) / 2;
-        paintRect.setWidth(paintRect.width() - xOff);
-        paintRect.setX(paintRect.x() + xOff);
-    }
-
-    if (!boxShadowShouldBeAppliedToBackground(paintRect.location(), determineBackgroundBleedAvoidance(paintInfo.context())))
-        paintBoxShadow(paintInfo, paintRect, style(), Normal);
-    paintFillLayers(paintInfo, style().visitedDependentColor(CSSPropertyBackgroundColor), style().backgroundLayers(), paintRect);
-    paintBoxShadow(paintInfo, paintRect, style(), Inset);
-
-    if (!style().hasBorder())
-        return;
-    
-    // Create a clipping region around the legend and paint the border as normal
-    GraphicsContext&amp; graphicsContext = paintInfo.context();
-    GraphicsContextStateSaver stateSaver(graphicsContext);
-
-    // FIXME: We need to work with &quot;rl&quot; and &quot;bt&quot; block flow directions.  In those
-    // cases the legend is embedded in the right and bottom borders respectively.
-    // https://bugs.webkit.org/show_bug.cgi?id=47236
-    LayoutRect clipRect;
-    if (style().isHorizontalWritingMode()) {
-        clipRect.setX(paintRect.x() + legend-&gt;x());
-        clipRect.setY(paintRect.y());
-        clipRect.setWidth(legend-&gt;width());
-        clipRect.setHeight(std::max&lt;LayoutUnit&gt;(style().borderTopWidth(), legend-&gt;height() - ((legend-&gt;height() - borderTop()) / 2)));
-    } else {
-        clipRect.setX(paintRect.x());
-        clipRect.setY(paintRect.y() + legend-&gt;y());
-        clipRect.setWidth(std::max&lt;LayoutUnit&gt;(style().borderLeftWidth(), legend-&gt;width()));
-        clipRect.setHeight(legend-&gt;height());
-    }
-    graphicsContext.clipOut(snapRectToDevicePixels(clipRect, document().deviceScaleFactor()));
-
-    paintBorder(paintInfo, paintRect, style());
-}
-
-void RenderFieldset::paintMask(PaintInfo&amp; paintInfo, const LayoutPoint&amp; paintOffset)
-{
-    if (style().visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
-        return;
-
-    LayoutRect paintRect = LayoutRect(paintOffset, size());
-    RenderBox* legend = findLegend();
-    if (!legend)
-        return RenderBlockFlow::paintMask(paintInfo, paintOffset);
-
-    // FIXME: We need to work with &quot;rl&quot; and &quot;bt&quot; block flow directions.  In those
-    // cases the legend is embedded in the right and bottom borders respectively.
-    // https://bugs.webkit.org/show_bug.cgi?id=47236
-    if (style().isHorizontalWritingMode()) {
-        LayoutUnit yOff = (legend-&gt;y() &gt; 0) ? LayoutUnit() : (legend-&gt;height() - borderTop()) / 2;
-        paintRect.expand(0, -yOff);
-        paintRect.move(0, yOff);
-    } else {
-        LayoutUnit xOff = (legend-&gt;x() &gt; 0) ? LayoutUnit() : (legend-&gt;width() - borderLeft()) / 2;
-        paintRect.expand(-xOff, 0);
-        paintRect.move(xOff, 0);
-    }
-
-    paintMaskImages(paintInfo, paintRect);
-}
-
-} // namespace WebCore
</del></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderFieldseth"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/rendering/RenderFieldset.h (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderFieldset.h        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderFieldset.h        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -1,59 +0,0 @@
</span><del>-/*
- * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- *           (C) 1999 Antti Koivisto (koivisto@kde.org)
- *           (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2006, 2009 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#pragma once
-
-#include &quot;HTMLFieldSetElement.h&quot;
-#include &quot;RenderBlockFlow.h&quot;
-
-namespace WebCore {
-
-class HTMLFieldSetElement;
-
-class RenderFieldset final : public RenderBlockFlow {
-public:
-    RenderFieldset(HTMLFieldSetElement&amp;, RenderStyle&amp;&amp;);
-
-    enum FindLegendOption { IgnoreFloatingOrOutOfFlow, IncludeFloatingOrOutOfFlow };
-    RenderBox* findLegend(FindLegendOption = IgnoreFloatingOrOutOfFlow);
-
-    HTMLFieldSetElement&amp; fieldSetElement() const { return downcast&lt;HTMLFieldSetElement&gt;(nodeForNonAnonymous()); }
-
-private:
-    void element() const = delete;
-
-    const char* renderName() const override { return &quot;RenderFieldSet&quot;; }
-    bool isFieldset() const override { return true; }
-
-    RenderObject* layoutSpecialExcludedChild(bool relayoutChildren) override;
-
-    void computePreferredLogicalWidths() override;
-    bool avoidsFloats() const override { return true; }
-
-    void paintBoxDecorations(PaintInfo&amp;, const LayoutPoint&amp;) override;
-    void paintMask(PaintInfo&amp;, const LayoutPoint&amp;) override;
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderFieldset, isFieldset())
</del></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderFlexibleBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -79,12 +79,16 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit&amp; minLogicalWidth, LayoutUnit&amp; maxLogicalWidth) const
</span><span class="cx"> {
</span><ins>+    LayoutUnit childMinWidth;
+    LayoutUnit childMaxWidth;
+    bool hadExcludedChildren = computePreferredWidthsForExcludedChildren(childMinWidth, childMaxWidth);
+
</ins><span class="cx">     // FIXME: We're ignoring flex-basis here and we shouldn't. We can't start
</span><span class="cx">     // honoring it though until the flex shorthand stops setting it to 0. See
</span><span class="cx">     // https://bugs.webkit.org/show_bug.cgi?id=116117 and
</span><span class="cx">     // https://crbug.com/240765.
</span><span class="cx">     for (RenderBox* child = firstChildBox(); child; child = child-&gt;nextSiblingBox()) {
</span><del>-        if (child-&gt;isOutOfFlowPositioned())
</del><ins>+        if (child-&gt;isOutOfFlowPositioned() || child-&gt;isExcludedFromNormalLayout())
</ins><span class="cx">             continue;
</span><span class="cx">         
</span><span class="cx">         LayoutUnit margin = marginIntrinsicLogicalWidthForChild(*child);
</span><span class="lines">@@ -117,6 +121,11 @@
</span><span class="cx">     minLogicalWidth = std::max(LayoutUnit(), minLogicalWidth);
</span><span class="cx">     maxLogicalWidth = std::max(LayoutUnit(), maxLogicalWidth);
</span><span class="cx">     
</span><ins>+    if (hadExcludedChildren) {
+        minLogicalWidth = std::max(minLogicalWidth, childMinWidth);
+        maxLogicalWidth = std::max(maxLogicalWidth, childMaxWidth);
+    }
+
</ins><span class="cx">     LayoutUnit scrollbarWidth(scrollbarLogicalWidth());
</span><span class="cx">     maxLogicalWidth += scrollbarWidth;
</span><span class="cx">     minLogicalWidth += scrollbarWidth;
</span><span class="lines">@@ -174,7 +183,7 @@
</span><span class="cx">     RenderBox* baselineChild = nullptr;
</span><span class="cx">     int childNumber = 0;
</span><span class="cx">     for (RenderBox* child = m_orderIterator.first(); child; child = m_orderIterator.next()) {
</span><del>-        if (child-&gt;isOutOfFlowPositioned())
</del><ins>+        if (m_orderIterator.shouldSkipChild(*child))
</ins><span class="cx">             continue;
</span><span class="cx">         if (alignmentForChild(*child) == ItemPositionBaseline &amp;&amp; !hasAutoMarginsInCrossAxis(*child)) {
</span><span class="cx">             baselineChild = child;
</span><span class="lines">@@ -275,8 +284,14 @@
</span><span class="cx"> 
</span><span class="cx">     prepareOrderIteratorAndMargins();
</span><span class="cx"> 
</span><ins>+    // Fieldsets need to find their legend and position it inside the border of the object.
+    // The legend then gets skipped during normal layout. The same is true for ruby text.
+    // It doesn't get included in the normal layout process but is instead skipped.
+    layoutExcludedChildren(relayoutChildren);
+
</ins><span class="cx">     ChildFrameRects oldChildRects;
</span><span class="cx">     appendChildFrameRects(oldChildRects);
</span><ins>+
</ins><span class="cx">     layoutFlexItems(relayoutChildren);
</span><span class="cx"> 
</span><span class="cx">     endAndCommitUpdateScrollInfoAfterLayoutTransaction();
</span><span class="lines">@@ -502,8 +517,6 @@
</span><span class="cx">     return contentLogicalWidth();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// MERGEPOINT
-
</del><span class="cx"> std::optional&lt;LayoutUnit&gt; RenderFlexibleBox::computeMainAxisExtentForChild(const RenderBox&amp; child, SizeType sizeType, const Length&amp; size)
</span><span class="cx"> {
</span><span class="cx">     // If we have a horizontal flow, that means the main size is the width.
</span><span class="lines">@@ -846,9 +859,10 @@
</span><span class="cx">     Vector&lt;FlexItem&gt; allItems;
</span><span class="cx">     m_orderIterator.first();
</span><span class="cx">     for (RenderBox* child = m_orderIterator.currentChild(); child; child = m_orderIterator.next()) {
</span><del>-        if (child-&gt;isOutOfFlowPositioned()) {
</del><ins>+        if (m_orderIterator.shouldSkipChild(*child)) {
</ins><span class="cx">             // Out-of-flow children are not flex items, so we skip them here.
</span><del>-            prepareChildForPositionedLayout(*child);
</del><ins>+            if (child-&gt;isOutOfFlowPositioned())
+                prepareChildForPositionedLayout(*child);
</ins><span class="cx">             continue;
</span><span class="cx">         }
</span><span class="cx">         allItems.append(constructFlexItem(*child, relayoutChildren));
</span><span class="lines">@@ -1039,9 +1053,7 @@
</span><span class="cx">     OrderIteratorPopulator populator(m_orderIterator);
</span><span class="cx"> 
</span><span class="cx">     for (RenderBox* child = firstChildBox(); child; child = child-&gt;nextSiblingBox()) {
</span><del>-        populator.collectChild(*child);
-
-        if (child-&gt;isOutOfFlowPositioned())
</del><ins>+        if (!populator.collectChild(*child))
</ins><span class="cx">             continue;
</span><span class="cx"> 
</span><span class="cx">         // Before running the flex algorithm, 'auto' has a margin of 0.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderGridcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderGrid.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -241,6 +241,11 @@
</span><span class="cx">     setLogicalHeight(0);
</span><span class="cx">     updateLogicalWidth();
</span><span class="cx"> 
</span><ins>+    // Fieldsets need to find their legend and position it inside the border of the object.
+    // The legend then gets skipped during normal layout. The same is true for ruby text.
+    // It doesn't get included in the normal layout process but is instead skipped.
+    layoutExcludedChildren(relayoutChildren);
+
</ins><span class="cx">     placeItemsOnGrid(m_grid, TrackSizing);
</span><span class="cx"> 
</span><span class="cx">     // At this point the logical width is always definite as the above call to updateLogicalWidth()
</span><span class="lines">@@ -393,6 +398,10 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderGrid::computeIntrinsicLogicalWidths(LayoutUnit&amp; minLogicalWidth, LayoutUnit&amp; maxLogicalWidth) const
</span><span class="cx"> {
</span><ins>+    LayoutUnit childMinWidth;
+    LayoutUnit childMaxWidth;
+    bool hadExcludedChildren = computePreferredWidthsForExcludedChildren(childMinWidth, childMaxWidth);
+    
</ins><span class="cx">     Grid grid(const_cast&lt;RenderGrid&amp;&gt;(*this));
</span><span class="cx">     placeItemsOnGrid(grid, IntrinsicSizeComputation);
</span><span class="cx"> 
</span><span class="lines">@@ -399,6 +408,11 @@
</span><span class="cx">     GridTrackSizingAlgorithm algorithm(this, grid);
</span><span class="cx">     computeTrackSizesForIndefiniteSize(algorithm, ForColumns, grid, minLogicalWidth, maxLogicalWidth);
</span><span class="cx"> 
</span><ins>+    if (hadExcludedChildren) {
+        minLogicalWidth = std::max(minLogicalWidth, childMinWidth);
+        maxLogicalWidth = std::max(maxLogicalWidth, childMaxWidth);
+    }
+
</ins><span class="cx">     LayoutUnit scrollbarWidth = intrinsicScrollbarLogicalWidth();
</span><span class="cx">     minLogicalWidth += scrollbarWidth;
</span><span class="cx">     maxLogicalWidth += scrollbarWidth;
</span><span class="lines">@@ -581,7 +595,7 @@
</span><span class="cx">     Vector&lt;RenderBox*&gt; specifiedMajorAxisAutoGridItems;
</span><span class="cx">     bool hasAnyOrthogonalGridItem = false;
</span><span class="cx">     for (auto* child = grid.orderIterator().first(); child; child = grid.orderIterator().next()) {
</span><del>-        if (child-&gt;isOutOfFlowPositioned())
</del><ins>+        if (grid.orderIterator().shouldSkipChild(*child))
</ins><span class="cx">             continue;
</span><span class="cx"> 
</span><span class="cx">         hasAnyOrthogonalGridItem = hasAnyOrthogonalGridItem || isOrthogonalChild(*child);
</span><span class="lines">@@ -624,7 +638,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(ASSERT)
</span><span class="cx">     for (auto* child = grid.orderIterator().first(); child; child = grid.orderIterator().next()) {
</span><del>-        if (child-&gt;isOutOfFlowPositioned())
</del><ins>+        if (grid.orderIterator().shouldSkipChild(*child))
</ins><span class="cx">             continue;
</span><span class="cx"> 
</span><span class="cx">         GridArea area = grid.gridItemArea(*child);
</span><span class="lines">@@ -644,11 +658,9 @@
</span><span class="cx">     unsigned maximumColumnIndex = GridPositionsResolver::explicitGridColumnCount(style(), autoRepeatColumns);
</span><span class="cx"> 
</span><span class="cx">     for (RenderBox* child = firstChildBox(); child; child = child-&gt;nextSiblingBox()) {
</span><del>-        if (child-&gt;isOutOfFlowPositioned())
</del><ins>+        if (!populator.collectChild(*child))
</ins><span class="cx">             continue;
</span><del>-
-        populator.collectChild(*child);
-
</del><ins>+        
</ins><span class="cx">         GridSpan rowPositions = GridPositionsResolver::resolveGridPositionsFromStyle(style(), *child, ForRows, autoRepeatRows);
</span><span class="cx">         if (!rowPositions.isIndefinite()) {
</span><span class="cx">             smallestRowStart = std::min(smallestRowStart, rowPositions.untranslatedStartLine());
</span><span class="lines">@@ -884,8 +896,10 @@
</span><span class="cx">     populateGridPositionsForDirection(ForRows);
</span><span class="cx"> 
</span><span class="cx">     for (RenderBox* child = firstChildBox(); child; child = child-&gt;nextSiblingBox()) {
</span><del>-        if (child-&gt;isOutOfFlowPositioned()) {
-            prepareChildForPositionedLayout(*child);
</del><ins>+        
+        if (m_grid.orderIterator().shouldSkipChild(*child)) {
+            if (child-&gt;isOutOfFlowPositioned())
+                prepareChildForPositionedLayout(*child);
</ins><span class="cx">             continue;
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderMultiColumnFlowThreadcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnFlowThread.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -153,6 +153,14 @@
</span><span class="cx">     LayoutStateDisabler layoutStateDisabler(view());
</span><span class="cx">     RenderTreeInternalMutationScope reparentingIsOn(view());
</span><span class="cx">     multicolContainer-&gt;moveChildrenTo(this, multicolContainer-&gt;firstChild(), this, true);
</span><ins>+    
+    if (multicolContainer-&gt;isFieldset()) {
+        // Keep legends out of the flow thread.
+        for (auto&amp; box : childrenOfType&lt;RenderBox&gt;(*this)) {
+            if (box.isLegend())
+                moveChildTo(multicolContainer, &amp;box, true);
+        }
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderMultiColumnFlowThread::evacuateAndDestroy()
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderMultiColumnSetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -319,7 +319,7 @@
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     if (RenderBox* next = RenderMultiColumnFlowThread::nextColumnSetOrSpannerSiblingOf(this)) {
</span><del>-        if (!next-&gt;isRenderMultiColumnSet()) {
</del><ins>+        if (!next-&gt;isRenderMultiColumnSet() &amp;&amp; !next-&gt;isLegend()) {
</ins><span class="cx">             // If we're followed by a spanner, we need to balance.
</span><span class="cx">             ASSERT(multiColumnFlowThread()-&gt;findColumnSpannerPlaceholder(next));
</span><span class="cx">             return true;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -158,6 +158,12 @@
</span><span class="cx">     return node() &amp;&amp; node()-&gt;hasTagName(legendTag);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+    
+bool RenderObject::isFieldset() const
+{
+    return node() &amp;&amp; node()-&gt;hasTagName(fieldsetTag);
+}
+
</ins><span class="cx"> bool RenderObject::isHTMLMarquee() const
</span><span class="cx"> {
</span><span class="cx">     return node() &amp;&amp; node()-&gt;renderer() == this &amp;&amp; node()-&gt;hasTagName(marqueeTag);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.h (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.h        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderObject.h        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -226,7 +226,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual bool isDetailsMarker() const { return false; }
</span><span class="cx">     virtual bool isEmbeddedObject() const { return false; }
</span><del>-    virtual bool isFieldset() const { return false; }
</del><ins>+    bool isFieldset() const;
</ins><span class="cx">     virtual bool isFileUploadControl() const { return false; }
</span><span class="cx">     virtual bool isFrame() const { return false; }
</span><span class="cx">     virtual bool isFrameSet() const { return false; }
</span><span class="lines">@@ -448,6 +448,10 @@
</span><span class="cx">     bool hasOutlineAutoAncestor() const { return m_bitfields.hasRareData() &amp;&amp; rareData().hasOutlineAutoAncestor(); }
</span><span class="cx">     bool isRegisteredForVisibleInViewportCallback() { return m_bitfields.hasRareData() &amp;&amp; rareData().isRegisteredForVisibleInViewportCallback(); }
</span><span class="cx"> 
</span><ins>+    bool isExcludedFromNormalLayout() const { return m_bitfields.isExcludedFromNormalLayout(); }
+    void setIsExcludedFromNormalLayout(bool excluded) { m_bitfields.setIsExcludedFromNormalLayout(excluded); }
+    bool isExcludedAndPlacedInBorder() const { return isExcludedFromNormalLayout() &amp;&amp; isLegend(); }
+
</ins><span class="cx">     enum VisibleInViewportState {
</span><span class="cx">         VisibilityUnknown,
</span><span class="cx">         VisibleInViewport,
</span><span class="lines">@@ -901,6 +905,7 @@
</span><span class="cx">             , m_hasTransformRelatedProperty(false)
</span><span class="cx">             , m_everHadLayout(false)
</span><span class="cx">             , m_childrenInline(false)
</span><ins>+            , m_isExcludedFromNormalLayout(false)
</ins><span class="cx">             , m_positionedState(IsStaticallyPositioned)
</span><span class="cx">             , m_selectionState(SelectionNone)
</span><span class="cx">             , m_flowThreadState(NotInsideFlowThread)
</span><span class="lines">@@ -936,6 +941,8 @@
</span><span class="cx"> 
</span><span class="cx">         // from RenderBlock
</span><span class="cx">         ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline);
</span><ins>+        
+        ADD_BOOLEAN_BITFIELD(isExcludedFromNormalLayout, IsExcludedFromNormalLayout);
</ins><span class="cx"> 
</span><span class="cx">     private:
</span><span class="cx">         unsigned m_positionedState : 2; // PositionedState
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderRubyRuncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderRubyRun.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderRubyRun.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderRubyRun.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -213,17 +213,19 @@
</span><span class="cx">     return renderer;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderObject* RenderRubyRun::layoutSpecialExcludedChild(bool relayoutChildren)
</del><ins>+void RenderRubyRun::layoutExcludedChildren(bool relayoutChildren)
</ins><span class="cx"> {
</span><ins>+    RenderBlockFlow::layoutExcludedChildren(relayoutChildren);
+
</ins><span class="cx">     StackStats::LayoutCheckPoint layoutCheckPoint;
</span><span class="cx">     // Don't bother positioning the RenderRubyRun yet.
</span><span class="cx">     RenderRubyText* rt = rubyText();
</span><span class="cx">     if (!rt)
</span><del>-        return 0;
</del><ins>+        return;
+    rt-&gt;setIsExcludedFromNormalLayout(true);
</ins><span class="cx">     if (relayoutChildren)
</span><span class="cx">         rt-&gt;setChildNeedsLayout(MarkOnlyThis);
</span><span class="cx">     rt-&gt;layoutIfNeeded();
</span><del>-    return rt;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderRubyRun::layout()
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderRubyRunh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderRubyRun.h (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderRubyRun.h        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderRubyRun.h        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">     RenderRubyBase* rubyBase() const;
</span><span class="cx">     RenderRubyBase* rubyBaseSafe(); // creates the base if it doesn't already exist
</span><span class="cx"> 
</span><del>-    RenderObject* layoutSpecialExcludedChild(bool relayoutChildren) override;
</del><ins>+    void layoutExcludedChildren(bool relayoutChildren) override;
</ins><span class="cx">     void layout() override;
</span><span class="cx">     void layoutBlock(bool relayoutChildren, LayoutUnit pageHeight = 0) override;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTablecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTable.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -753,7 +753,7 @@
</span><span class="cx">         paintOutline(paintInfo, LayoutRect(paintOffset, size()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderTable::subtractCaptionRect(LayoutRect&amp; rect) const
</del><ins>+void RenderTable::adjustBorderBoxRectForPainting(LayoutRect&amp; rect)
</ins><span class="cx"> {
</span><span class="cx">     for (unsigned i = 0; i &lt; m_captions.size(); i++) {
</span><span class="cx">         LayoutUnit captionLogicalHeight = m_captions[i]-&gt;logicalHeight() + m_captions[i]-&gt;marginBefore() + m_captions[i]-&gt;marginAfter();
</span><span class="lines">@@ -768,6 +768,8 @@
</span><span class="cx">                 rect.move(captionLogicalHeight, 0);
</span><span class="cx">         }
</span><span class="cx">     }
</span><ins>+    
+    RenderBlock::adjustBorderBoxRectForPainting(rect);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderTable::paintBoxDecorations(PaintInfo&amp; paintInfo, const LayoutPoint&amp; paintOffset)
</span><span class="lines">@@ -776,8 +778,8 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     LayoutRect rect(paintOffset, size());
</span><del>-    subtractCaptionRect(rect);
-
</del><ins>+    adjustBorderBoxRectForPainting(rect);
+    
</ins><span class="cx">     BackgroundBleedAvoidance bleedAvoidance = determineBackgroundBleedAvoidance(paintInfo.context());
</span><span class="cx">     if (!boxShadowShouldBeAppliedToBackground(rect.location(), bleedAvoidance))
</span><span class="cx">         paintBoxShadow(paintInfo, rect, style(), Normal);
</span><span class="lines">@@ -794,7 +796,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     LayoutRect rect(paintOffset, size());
</span><del>-    subtractCaptionRect(rect);
</del><ins>+    adjustBorderBoxRectForPainting(rect);
</ins><span class="cx"> 
</span><span class="cx">     paintMaskImages(paintInfo, rect);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTableh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTable.h (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTable.h        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderTable.h        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -314,7 +314,7 @@
</span><span class="cx"> 
</span><span class="cx">     void addOverflowFromChildren() final;
</span><span class="cx"> 
</span><del>-    void subtractCaptionRect(LayoutRect&amp;) const;
</del><ins>+    void adjustBorderBoxRectForPainting(LayoutRect&amp;) override;
</ins><span class="cx"> 
</span><span class="cx">     void recalcCollapsedBorders();
</span><span class="cx">     void recalcSections() const;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTableCellcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTableCell.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTableCell.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderTableCell.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -1307,6 +1307,8 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     LayoutRect paintRect = LayoutRect(paintOffset, frameRect().size());
</span><ins>+    adjustBorderBoxRectForPainting(paintRect);
+
</ins><span class="cx">     paintBoxShadow(paintInfo, paintRect, style(), Normal);
</span><span class="cx">     
</span><span class="cx">     // Paint our cell background.
</span><span class="lines">@@ -1329,7 +1331,10 @@
</span><span class="cx">     if (!tableElt-&gt;collapseBorders() &amp;&amp; style().emptyCells() == HIDE &amp;&amp; !firstChild())
</span><span class="cx">         return;
</span><span class="cx">    
</span><del>-    paintMaskImages(paintInfo, LayoutRect(paintOffset, frameRect().size()));
</del><ins>+    LayoutRect paintRect = LayoutRect(paintOffset, frameRect().size());
+    adjustBorderBoxRectForPainting(paintRect);
+
+    paintMaskImages(paintInfo, paintRect);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool RenderTableCell::boxShadowShouldBeAppliedToBackground(const LayoutPoint&amp;, BackgroundBleedAvoidance, InlineFlowBox*) const
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTextControlcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTextControl.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -197,12 +197,16 @@
</span><span class="cx">         rects.append(LayoutRect(additionalOffset, size()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderObject* RenderTextControl::layoutSpecialExcludedChild(bool relayoutChildren)
</del><ins>+void RenderTextControl::layoutExcludedChildren(bool relayoutChildren)
</ins><span class="cx"> {
</span><ins>+    RenderBlockFlow::layoutExcludedChildren(relayoutChildren);
+
</ins><span class="cx">     HTMLElement* placeholder = textFormControlElement().placeholderElement();
</span><span class="cx">     RenderElement* placeholderRenderer = placeholder ? placeholder-&gt;renderer() : 0;
</span><span class="cx">     if (!placeholderRenderer)
</span><del>-        return 0;
</del><ins>+        return;
+    placeholderRenderer-&gt;setIsExcludedFromNormalLayout(true);
+
</ins><span class="cx">     if (relayoutChildren) {
</span><span class="cx">         // The markParents arguments should be false because this function is
</span><span class="cx">         // called from layout() of the parent and the placeholder layout doesn't
</span><span class="lines">@@ -209,7 +213,6 @@
</span><span class="cx">         // affect the parent layout.
</span><span class="cx">         placeholderRenderer-&gt;setChildNeedsLayout(MarkOnlyThis);
</span><span class="cx">     }
</span><del>-    return placeholderRenderer;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTextControlh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTextControl.h (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTextControl.h        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderTextControl.h        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx">     virtual LayoutUnit computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const = 0;
</span><span class="cx"> 
</span><span class="cx">     LogicalExtentComputedValues computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop) const override;
</span><del>-    RenderObject* layoutSpecialExcludedChild(bool relayoutChildren) override;
</del><ins>+    void layoutExcludedChildren(bool relayoutChildren) override;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void element() const = delete;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTextControlMultiLinecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -87,9 +87,13 @@
</span><span class="cx">     return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderObject* RenderTextControlMultiLine::layoutSpecialExcludedChild(bool relayoutChildren)
</del><ins>+void RenderTextControlMultiLine::layoutExcludedChildren(bool relayoutChildren)
</ins><span class="cx"> {
</span><del>-    RenderObject* placeholderRenderer = RenderTextControl::layoutSpecialExcludedChild(relayoutChildren);
</del><ins>+    RenderTextControl::layoutExcludedChildren(relayoutChildren);
+    HTMLElement* placeholder = textFormControlElement().placeholderElement();
+    RenderElement* placeholderRenderer = placeholder ? placeholder-&gt;renderer() : 0;
+    if (!placeholderRenderer)
+        return;
</ins><span class="cx">     if (is&lt;RenderBox&gt;(placeholderRenderer)) {
</span><span class="cx">         auto&amp; placeholderBox = downcast&lt;RenderBox&gt;(*placeholderRenderer);
</span><span class="cx">         placeholderBox.mutableStyle().setLogicalWidth(Length(contentLogicalWidth() - placeholderBox.borderAndPaddingLogicalWidth(), Fixed));
</span><span class="lines">@@ -97,7 +101,6 @@
</span><span class="cx">         placeholderBox.setX(borderLeft() + paddingLeft());
</span><span class="cx">         placeholderBox.setY(borderTop() + paddingTop());
</span><span class="cx">     }
</span><del>-    return placeholderRenderer;
</del><span class="cx"> }
</span><span class="cx">     
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTextControlMultiLineh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx">     LayoutUnit computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const override;
</span><span class="cx">     int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override;
</span><span class="cx"> 
</span><del>-    RenderObject* layoutSpecialExcludedChild(bool relayoutChildren) override;
</del><ins>+    void layoutExcludedChildren(bool relayoutChildren) override;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> inline RenderTextControlMultiLine* HTMLTextAreaElement::renderer() const
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTreeAsTextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -272,14 +272,30 @@
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         const RenderBoxModelObject&amp; box = downcast&lt;RenderBoxModelObject&gt;(o);
</span><del>-        if (box.borderTop() || box.borderRight() || box.borderBottom() || box.borderLeft()) {
</del><ins>+        LayoutUnit borderTop = box.borderTop();
+        LayoutUnit borderRight = box.borderRight();
+        LayoutUnit borderBottom = box.borderBottom();
+        LayoutUnit borderLeft = box.borderLeft();
+        if (box.isFieldset()) {
+            const auto&amp; block = downcast&lt;RenderBlock&gt;(box);
+            if (o.style().writingMode() == TopToBottomWritingMode)
+                borderTop -= block.intrinsicBorderForFieldset();
+            else if (o.style().writingMode() == BottomToTopWritingMode)
+                borderBottom -= block.intrinsicBorderForFieldset();
+            else if (o.style().writingMode() == LeftToRightWritingMode)
+                borderLeft -= block.intrinsicBorderForFieldset();
+            else if (o.style().writingMode() == RightToLeftWritingMode)
+                borderRight -= block.intrinsicBorderForFieldset();
+            
+        }
+        if (borderTop || borderRight || borderBottom || borderLeft) {
</ins><span class="cx">             ts &lt;&lt; &quot; [border:&quot;;
</span><span class="cx"> 
</span><span class="cx">             BorderValue prevBorder = o.style().borderTop();
</span><del>-            if (!box.borderTop())
</del><ins>+            if (!borderTop)
</ins><span class="cx">                 ts &lt;&lt; &quot; none&quot;;
</span><span class="cx">             else {
</span><del>-                ts &lt;&lt; &quot; (&quot; &lt;&lt; box.borderTop() &lt;&lt; &quot;px &quot;;
</del><ins>+                ts &lt;&lt; &quot; (&quot; &lt;&lt; borderTop &lt;&lt; &quot;px &quot;;
</ins><span class="cx">                 printBorderStyle(ts, o.style().borderTopStyle());
</span><span class="cx">                 Color col = o.style().borderTopColor();
</span><span class="cx">                 if (!col.isValid())
</span><span class="lines">@@ -289,10 +305,10 @@
</span><span class="cx"> 
</span><span class="cx">             if (o.style().borderRight() != prevBorder) {
</span><span class="cx">                 prevBorder = o.style().borderRight();
</span><del>-                if (!box.borderRight())
</del><ins>+                if (!borderRight)
</ins><span class="cx">                     ts &lt;&lt; &quot; none&quot;;
</span><span class="cx">                 else {
</span><del>-                    ts &lt;&lt; &quot; (&quot; &lt;&lt; box.borderRight() &lt;&lt; &quot;px &quot;;
</del><ins>+                    ts &lt;&lt; &quot; (&quot; &lt;&lt; borderRight &lt;&lt; &quot;px &quot;;
</ins><span class="cx">                     printBorderStyle(ts, o.style().borderRightStyle());
</span><span class="cx">                     Color col = o.style().borderRightColor();
</span><span class="cx">                     if (!col.isValid())
</span><span class="lines">@@ -303,10 +319,10 @@
</span><span class="cx"> 
</span><span class="cx">             if (o.style().borderBottom() != prevBorder) {
</span><span class="cx">                 prevBorder = box.style().borderBottom();
</span><del>-                if (!box.borderBottom())
</del><ins>+                if (!borderBottom)
</ins><span class="cx">                     ts &lt;&lt; &quot; none&quot;;
</span><span class="cx">                 else {
</span><del>-                    ts &lt;&lt; &quot; (&quot; &lt;&lt; box.borderBottom() &lt;&lt; &quot;px &quot;;
</del><ins>+                    ts &lt;&lt; &quot; (&quot; &lt;&lt; borderBottom &lt;&lt; &quot;px &quot;;
</ins><span class="cx">                     printBorderStyle(ts, o.style().borderBottomStyle());
</span><span class="cx">                     Color col = o.style().borderBottomColor();
</span><span class="cx">                     if (!col.isValid())
</span><span class="lines">@@ -317,10 +333,10 @@
</span><span class="cx"> 
</span><span class="cx">             if (o.style().borderLeft() != prevBorder) {
</span><span class="cx">                 prevBorder = o.style().borderLeft();
</span><del>-                if (!box.borderLeft())
</del><ins>+                if (!borderLeft)
</ins><span class="cx">                     ts &lt;&lt; &quot; none&quot;;
</span><span class="cx">                 else {
</span><del>-                    ts &lt;&lt; &quot; (&quot; &lt;&lt; box.borderLeft() &lt;&lt; &quot;px &quot;;
</del><ins>+                    ts &lt;&lt; &quot; (&quot; &lt;&lt; borderLeft &lt;&lt; &quot;px &quot;;
</ins><span class="cx">                     printBorderStyle(ts, o.style().borderLeftStyle());
</span><span class="cx">                     Color col = o.style().borderLeftColor();
</span><span class="cx">                     if (!col.isValid())
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderingAllInOnecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderingAllInOne.cpp (213454 => 213455)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderingAllInOne.cpp        2017-03-06 17:49:50 UTC (rev 213454)
+++ trunk/Source/WebCore/rendering/RenderingAllInOne.cpp        2017-03-06 18:00:35 UTC (rev 213455)
</span><span class="lines">@@ -62,7 +62,6 @@
</span><span class="cx"> #include &quot;RenderDetailsMarker.cpp&quot;
</span><span class="cx"> #include &quot;RenderElement.cpp&quot;
</span><span class="cx"> #include &quot;RenderEmbeddedObject.cpp&quot;
</span><del>-#include &quot;RenderFieldset.cpp&quot;
</del><span class="cx"> #include &quot;RenderFileUploadControl.cpp&quot;
</span><span class="cx"> #include &quot;RenderFlexibleBox.cpp&quot;
</span><span class="cx"> #include &quot;RenderFlowThread.cpp&quot;
</span></span></pre>
</div>
</div>

</body>
</html>