Source/WebCore/ChangeLog

 12011-07-29 Emil A Eklund <eae@chromium.org>
 2
 3 Switch RenderBlock to to new layout types
 4 https://bugs.webkit.org/show_bug.cgi?id=65396
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 No new tests, no new functionality.
 9
 10 * platform/graphics/IntRect.cpp:
 11 (WebCore::enclosingIntRect):
 12 * platform/graphics/IntRect.h:
 13 Add no-op IntRect version of enclosingIntRect.
 14
 15 * rendering/LayoutTypes.h:
 16 (WebCore::layoutUnitEquals):
 17 Add layoutUnitEquals for comparing layout values. Float implementation
 18 will use epsilon.
 19
 20 * rendering/RenderBlock.cpp:
 21 (WebCore::RenderBlock::MarginInfo::MarginInfo):
 22 (WebCore::RenderBlock::layoutBlock):
 23 (WebCore::RenderBlock::addOverflowFromChildren):
 24 (WebCore::RenderBlock::computeOverflow):
 25 (WebCore::RenderBlock::adjustPositionedBlock):
 26 (WebCore::RenderBlock::adjustFloatingBlock):
 27 (WebCore::RenderBlock::collapseMargins):
 28 (WebCore::RenderBlock::clearFloatsIfNeeded):
 29 (WebCore::RenderBlock::estimateLogicalTopPosition):
 30 (WebCore::RenderBlock::determineLogicalLeftPositionForChild):
 31 (WebCore::RenderBlock::setLogicalLeftForChild):
 32 (WebCore::RenderBlock::setLogicalTopForChild):
 33 (WebCore::RenderBlock::layoutBlockChildren):
 34 (WebCore::RenderBlock::layoutBlockChild):
 35 (WebCore::RenderBlock::paint):
 36 (WebCore::RenderBlock::flipFloatForWritingMode):
 37 (WebCore::RenderBlock::isPointInOverflowControl):
 38 (WebCore::RenderBlock::hitTestFloats):
 39 * rendering/RenderBlock.h:
 40 (WebCore::RenderBlock::logicalTopForFloat):
 41 (WebCore::RenderBlock::logicalBottomForFloat):
 42 (WebCore::RenderBlock::logicalLeftForFloat):
 43 (WebCore::RenderBlock::logicalRightForFloat):
 44 (WebCore::RenderBlock::logicalWidthForFloat):
 45 (WebCore::RenderBlock::setLogicalTopForFloat):
 46 (WebCore::RenderBlock::setLogicalLeftForFloat):
 47 (WebCore::RenderBlock::setLogicalHeightForFloat):
 48 (WebCore::RenderBlock::setLogicalWidthForFloat):
 49
1502011-07-29 Sam Weinig <sam@webkit.org>
251
352 Move Region code from WebKit2 to WebCore
92016

Source/WebCore/platform/graphics/IntRect.cpp

@@IntRect unionRect(const Vector<IntRect>&
136136 return result;
137137}
138138
 139IntRect enclosingIntRect(const IntRect& rect)
 140{
 141 return IntRect(rect);
 142}
 143
139144} // namespace WebCore
91946

Source/WebCore/platform/graphics/IntRect.h

@@inline bool operator!=(const IntRect& a,
248248 return a.location() != b.location() || a.size() != b.size();
249249}
250250
 251IntRect enclosingIntRect(const IntRect&);
 252
251253#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
252254IntRect enclosingIntRect(const CGRect&);
253255#endif
91946

Source/WebCore/rendering/LayoutTypes.h

@@inline LayoutPoint toLayoutPoint(const L
8686 return LayoutPoint(p.width(), p.height());
8787}
8888
 89inline bool layoutUnitEquals(LayoutUnit a, LayoutUnit b)
 90{
 91 return a == b;
 92}
 93
8994} // namespace WebCore
9095
9196#endif // LayoutTypes_h
91946

Source/WebCore/rendering/RenderBlock.cpp

@@static DelayedUpdateScrollInfoSet* gDela
8181bool RenderBlock::s_canPropagateFloatIntoSibling = false;
8282
8383// Our MarginInfo state used when laying out block children.
84 RenderBlock::MarginInfo::MarginInfo(RenderBlock* block, int beforeBorderPadding, int afterBorderPadding)
 84RenderBlock::MarginInfo::MarginInfo(RenderBlock* block, LayoutUnit beforeBorderPadding, LayoutUnit afterBorderPadding)
8585 : m_atBeforeSideOfBlock(true)
8686 , m_atAfterSideOfBlock(false)
8787 , m_marginBeforeQuirk(false)

@@void RenderBlock::layout()
11651165 clearLayoutOverflow();
11661166}
11671167
1168 void RenderBlock::layoutBlock(bool relayoutChildren, int pageLogicalHeight)
 1168void RenderBlock::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight)
11691169{
11701170 ASSERT(needsLayout());
11711171

@@void RenderBlock::layoutBlock(bool relay
11771177
11781178 LayoutRepainter repainter(*this, m_everHadLayout && checkForRepaintDuringLayout());
11791179
1180  int oldWidth = logicalWidth();
1181  int oldColumnWidth = desiredColumnWidth();
 1180 LayoutUnit oldWidth = logicalWidth();
 1181 LayoutUnit oldColumnWidth = desiredColumnWidth();
11821182
11831183 computeLogicalWidth();
11841184 calcColumnWidth();

@@void RenderBlock::layoutBlock(bool relay
11901190
11911191 clearFloats();
11921192
1193  int previousHeight = logicalHeight();
 1193 LayoutUnit previousHeight = logicalHeight();
11941194 setLogicalHeight(0);
11951195 bool hasSpecifiedPageLogicalHeight = false;
11961196 bool pageLogicalHeightChanged = false;

@@void RenderBlock::layoutBlock(bool relay
12531253 layer()->setHasVerticalScrollbar(true);
12541254 }
12551255
1256  int repaintLogicalTop = 0;
1257  int repaintLogicalBottom = 0;
1258  int maxFloatLogicalBottom = 0;
 1256 LayoutUnit repaintLogicalTop = 0;
 1257 LayoutUnit repaintLogicalBottom = 0;
 1258 LayoutUnit maxFloatLogicalBottom = 0;
12591259 if (!firstChild() && !isAnonymousBlock())
12601260 setChildrenInline(true);
12611261 if (childrenInline())

@@void RenderBlock::layoutBlock(bool relay
12641264 layoutBlockChildren(relayoutChildren, maxFloatLogicalBottom);
12651265
12661266 // Expand our intrinsic height to encompass floats.
1267  int toAdd = borderAfter() + paddingAfter() + scrollbarLogicalHeight();
 1267 LayoutUnit toAdd = borderAfter() + paddingAfter() + scrollbarLogicalHeight();
12681268 if (lowestFloatLogicalBottom() > (logicalHeight() - toAdd) && expandsToEncloseOverhangingFloats())
12691269 setLogicalHeight(lowestFloatLogicalBottom() + toAdd);
12701270

@@void RenderBlock::layoutBlock(bool relay
12721272 return;
12731273
12741274 // Calculate our new height.
1275  int oldHeight = logicalHeight();
1276  int oldClientAfterEdge = clientLogicalBottom();
 1275 LayoutUnit oldHeight = logicalHeight();
 1276 LayoutUnit oldClientAfterEdge = clientLogicalBottom();
12771277 computeLogicalHeight();
1278  int newHeight = logicalHeight();
 1278 LayoutUnit newHeight = logicalHeight();
12791279 if (oldHeight != newHeight) {
12801280 if (oldHeight > newHeight && maxFloatLogicalBottom > newHeight && !childrenInline()) {
12811281 // One of our children's floats may have become an overhanging float for us. We need to look for it.

@@void RenderBlock::layoutBlock(bool relay
13141314 if (!didFullRepaint && repaintLogicalTop != repaintLogicalBottom && (style()->visibility() == VISIBLE || enclosingLayer()->hasVisibleContent())) {
13151315 // FIXME: We could tighten up the left and right invalidation points if we let layoutInlineChildren fill them in based off the particular lines
13161316 // it had to lay out. We wouldn't need the hasOverflowClip() hack in that case either.
1317  int repaintLogicalLeft = logicalLeftVisualOverflow();
1318  int repaintLogicalRight = logicalRightVisualOverflow();
 1317 LayoutUnit repaintLogicalLeft = logicalLeftVisualOverflow();
 1318 LayoutUnit repaintLogicalRight = logicalRightVisualOverflow();
13191319 if (hasOverflowClip()) {
13201320 // If we have clipped overflow, we should use layout overflow as well, since visual overflow from lines didn't propagate to our block's overflow.
13211321 // Note the old code did this as well but even for overflow:visible. The addition of hasOverflowClip() at least tightens up the hack a bit.

@@void RenderBlock::layoutBlock(bool relay
13241324 repaintLogicalRight = max(repaintLogicalRight, logicalRightLayoutOverflow());
13251325 }
13261326
1327  IntRect repaintRect;
 1327 LayoutRect repaintRect;
13281328 if (isHorizontalWritingMode())
1329  repaintRect = IntRect(repaintLogicalLeft, repaintLogicalTop, repaintLogicalRight - repaintLogicalLeft, repaintLogicalBottom - repaintLogicalTop);
 1329 repaintRect = LayoutRect(repaintLogicalLeft, repaintLogicalTop, repaintLogicalRight - repaintLogicalLeft, repaintLogicalBottom - repaintLogicalTop);
13301330 else
1331  repaintRect = IntRect(repaintLogicalTop, repaintLogicalLeft, repaintLogicalBottom - repaintLogicalTop, repaintLogicalRight - repaintLogicalLeft);
 1331 repaintRect = LayoutRect(repaintLogicalTop, repaintLogicalLeft, repaintLogicalBottom - repaintLogicalTop, repaintLogicalRight - repaintLogicalLeft);
13321332
13331333 // The repaint rect may be split across columns, in which case adjustRectForColumns() will return the union.
13341334 adjustRectForColumns(repaintRect);

@@void RenderBlock::layoutBlock(bool relay
13451345
13461346 // Make sure the rect is still non-empty after intersecting for overflow above
13471347 if (!repaintRect.isEmpty()) {
1348  repaintRectangle(repaintRect); // We need to do a partial repaint of our content.
 1348 repaintRectangle(enclosingIntRect(repaintRect)); // We need to do a partial repaint of our content.
13491349 if (hasReflection())
1350  repaintRectangle(reflectedRect(repaintRect));
 1350 repaintRectangle(enclosingIntRect(reflectedRect(repaintRect)));
13511351 }
13521352 }
13531353 setNeedsLayout(false);

@@void RenderBlock::addOverflowFromChildre
13651365 if (columnCount(colInfo)) {
13661366 LayoutRect lastRect = columnRectAt(colInfo, columnCount(colInfo) - 1);
13671367 if (isHorizontalWritingMode()) {
1368  int overflowLeft = !style()->isLeftToRightDirection() ? min(0, lastRect.x()) : 0;
1369  int overflowRight = style()->isLeftToRightDirection() ? max(width(), lastRect.maxX()) : 0;
1370  int overflowHeight = borderBefore() + paddingBefore() + colInfo->columnHeight();
1371  addLayoutOverflow(IntRect(overflowLeft, 0, overflowRight - overflowLeft, overflowHeight));
 1368 LayoutUnit overflowLeft = !style()->isLeftToRightDirection() ? min<LayoutUnit>(0, lastRect.x()) : 0;
 1369 LayoutUnit overflowRight = style()->isLeftToRightDirection() ? max(width(), lastRect.maxX()) : 0;
 1370 LayoutUnit overflowHeight = borderBefore() + paddingBefore() + colInfo->columnHeight();
 1371 addLayoutOverflow(LayoutRect(overflowLeft, 0, overflowRight - overflowLeft, overflowHeight));
13721372 if (!hasOverflowClip())
1373  addVisualOverflow(IntRect(overflowLeft, 0, overflowRight - overflowLeft, overflowHeight));
 1373 addVisualOverflow(LayoutRect(overflowLeft, 0, overflowRight - overflowLeft, overflowHeight));
13741374 } else {
13751375 LayoutRect lastRect = columnRectAt(colInfo, columnCount(colInfo) - 1);
1376  int overflowTop = !style()->isLeftToRightDirection() ? min(0, lastRect.y()) : 0;
1377  int overflowBottom = style()->isLeftToRightDirection() ? max(height(), lastRect.maxY()) : 0;
1378  int overflowWidth = borderBefore() + paddingBefore() + colInfo->columnHeight();
1379  addLayoutOverflow(IntRect(0, overflowTop, overflowWidth, overflowBottom - overflowTop));
 1376 LayoutUnit overflowTop = !style()->isLeftToRightDirection() ? min<LayoutUnit>(0, lastRect.y()) : 0;
 1377 LayoutUnit overflowBottom = style()->isLeftToRightDirection() ? max(height(), lastRect.maxY()) : 0;
 1378 LayoutUnit overflowWidth = borderBefore() + paddingBefore() + colInfo->columnHeight();
 1379 addLayoutOverflow(LayoutRect(0, overflowTop, overflowWidth, overflowBottom - overflowTop));
13801380 if (!hasOverflowClip())
1381  addVisualOverflow(IntRect(0, overflowTop, overflowWidth, overflowBottom - overflowTop));
 1381 addVisualOverflow(LayoutRect(0, overflowTop, overflowWidth, overflowBottom - overflowTop));
13821382 }
13831383 }
13841384 }
13851385}
13861386
1387 void RenderBlock::computeOverflow(int oldClientAfterEdge, bool recomputeFloats)
 1387void RenderBlock::computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeFloats)
13881388{
13891389 // Add overflow from children.
13901390 addOverflowFromChildren();

@@void RenderBlock::computeOverflow(int ol
13991399 // When we have overflow clip, propagate the original spillout since it will include collapsed bottom margins
14001400 // and bottom padding. Set the axis we don't care about to be 1, since we want this overflow to always
14011401 // be considered reachable.
1402  IntRect clientRect(clientBoxRect());
1403  IntRect rectToApply;
 1402 LayoutRect clientRect(clientBoxRect());
 1403 LayoutRect rectToApply;
14041404 if (isHorizontalWritingMode())
1405  rectToApply = IntRect(clientRect.x(), clientRect.y(), 1, max(0, oldClientAfterEdge - clientRect.y()));
 1405 rectToApply = LayoutRect(clientRect.x(), clientRect.y(), 1, max(0, oldClientAfterEdge - clientRect.y()));
14061406 else
1407  rectToApply = IntRect(clientRect.x(), clientRect.y(), max(0, oldClientAfterEdge - clientRect.x()), 1);
 1407 rectToApply = LayoutRect(clientRect.x(), clientRect.y(), max(0, oldClientAfterEdge - clientRect.x()), 1);
14081408 addLayoutOverflow(rectToApply);
14091409 }
14101410

@@void RenderBlock::adjustPositionedBlock(
14651465
14661466 childLayer->setStaticInlinePosition(borderAndPaddingStart());
14671467
1468  int logicalTop = logicalHeight();
 1468 LayoutUnit logicalTop = logicalHeight();
14691469 if (!marginInfo.canCollapseWithMarginBefore()) {
14701470 child->computeBlockDirectionMargins(this);
1471  int marginBefore = marginBeforeForChild(child);
1472  int collapsedBeforePos = marginInfo.positiveMargin();
1473  int collapsedBeforeNeg = marginInfo.negativeMargin();
 1471 LayoutUnit marginBefore = marginBeforeForChild(child);
 1472 LayoutUnit collapsedBeforePos = marginInfo.positiveMargin();
 1473 LayoutUnit collapsedBeforeNeg = marginInfo.negativeMargin();
14741474 if (marginBefore > 0) {
14751475 if (marginBefore > collapsedBeforePos)
14761476 collapsedBeforePos = marginBefore;

@@void RenderBlock::adjustFloatingBlock(co
15021502 // for by simply calling canCollapseWithMarginBefore. See
15031503 // http://www.hixie.ch/tests/adhoc/css/box/block/margin-collapse/046.html for
15041504 // an example of this scenario.
1505  int marginOffset = marginInfo.canCollapseWithMarginBefore() ? 0 : marginInfo.margin();
 1505 LayoutUnit marginOffset = marginInfo.canCollapseWithMarginBefore() ? 0 : marginInfo.margin();
15061506 setLogicalHeight(logicalHeight() + marginOffset);
15071507 positionNewFloats();
15081508 setLogicalHeight(logicalHeight() - marginOffset);

@@bool RenderBlock::handleRunInChild(Rende
15981598 return true;
15991599}
16001600
1601 int RenderBlock::collapseMargins(RenderBox* child, MarginInfo& marginInfo)
 1601LayoutUnit RenderBlock::collapseMargins(RenderBox* child, MarginInfo& marginInfo)
16021602{
16031603 // Get the four margin values for the child and cache them.
16041604 const MarginValues childMargins = marginValuesForChild(child);
16051605
16061606 // Get our max pos and neg top margins.
1607  int posTop = childMargins.positiveMarginBefore();
1608  int negTop = childMargins.negativeMarginBefore();
 1607 LayoutUnit posTop = childMargins.positiveMarginBefore();
 1608 LayoutUnit negTop = childMargins.negativeMarginBefore();
16091609
16101610 // For self-collapsing blocks, collapse our bottom margins into our
16111611 // top to get new posTop and negTop values.

@@int RenderBlock::collapseMargins(RenderB
16461646 if (marginInfo.quirkContainer() && marginInfo.atBeforeSideOfBlock() && (posTop - negTop))
16471647 marginInfo.setMarginBeforeQuirk(topQuirk);
16481648
1649  int beforeCollapseLogicalTop = logicalHeight();
1650  int logicalTop = beforeCollapseLogicalTop;
 1649 LayoutUnit beforeCollapseLogicalTop = logicalHeight();
 1650 LayoutUnit logicalTop = beforeCollapseLogicalTop;
16511651 if (child->isSelfCollapsingBlock()) {
16521652 // This child has no height. We need to compute our
16531653 // position before we collapse the child's margins together,
16541654 // so that we can get an accurate position for the zero-height block.
1655  int collapsedBeforePos = max(marginInfo.positiveMargin(), childMargins.positiveMarginBefore());
1656  int collapsedBeforeNeg = max(marginInfo.negativeMargin(), childMargins.negativeMarginBefore());
 1655 LayoutUnit collapsedBeforePos = max(marginInfo.positiveMargin(), childMargins.positiveMarginBefore());
 1656 LayoutUnit collapsedBeforeNeg = max(marginInfo.negativeMargin(), childMargins.negativeMarginBefore());
16571657 marginInfo.setMargin(collapsedBeforePos, collapsedBeforeNeg);
16581658
16591659 // Now collapse the child's margins together, which means examining our

@@int RenderBlock::collapseMargins(RenderB
16931693 // collapsed into the page edge.
16941694 LayoutState* layoutState = view()->layoutState();
16951695 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logicalTop > beforeCollapseLogicalTop) {
1696  int oldLogicalTop = logicalTop;
 1696 LayoutUnit oldLogicalTop = logicalTop;
16971697 logicalTop = min(logicalTop, nextPageLogicalTopExcludingBoundaryPoint(beforeCollapseLogicalTop));
16981698 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop));
16991699 }
17001700 return logicalTop;
17011701}
17021702
1703 int RenderBlock::clearFloatsIfNeeded(RenderBox* child, MarginInfo& marginInfo, int oldTopPosMargin, int oldTopNegMargin, int yPos)
 1703LayoutUnit RenderBlock::clearFloatsIfNeeded(RenderBox* child, MarginInfo& marginInfo, int oldTopPosMargin, int oldTopNegMargin, int yPos)
17041704{
1705  int heightIncrease = getClearDelta(child, yPos);
 1705 LayoutUnit heightIncrease = getClearDelta(child, yPos);
17061706 if (!heightIncrease)
17071707 return yPos;
17081708

@@int RenderBlock::clearFloatsIfNeeded(Ren
17311731
17321732 // Adjust our height such that we are ready to be collapsed with subsequent siblings (or the bottom
17331733 // of the parent block).
1734  setLogicalHeight(child->y() - max(0, marginInfo.margin()));
 1734 setLogicalHeight(child->y() - max<LayoutUnit>(0, marginInfo.margin()));
17351735 } else
17361736 // Increase our height by the amount we had to clear.
17371737 setLogicalHeight(height() + heightIncrease);

@@int RenderBlock::clearFloatsIfNeeded(Ren
17491749 return yPos + heightIncrease;
17501750}
17511751
1752 int RenderBlock::estimateLogicalTopPosition(RenderBox* child, const MarginInfo& marginInfo)
 1752LayoutUnit RenderBlock::estimateLogicalTopPosition(RenderBox* child, const MarginInfo& marginInfo)
17531753{
17541754 // FIXME: We need to eliminate the estimation of vertical position, because when it's wrong we sometimes trigger a pathological
17551755 // relayout if there are intruding floats.
1756  int logicalTopEstimate = logicalHeight();
 1756 LayoutUnit logicalTopEstimate = logicalHeight();
17571757 if (!marginInfo.canCollapseWithMarginBefore()) {
1758  int childMarginBefore = child->selfNeedsLayout() ? marginBeforeForChild(child) : collapsedMarginBeforeForChild(child);
 1758 LayoutUnit childMarginBefore = child->selfNeedsLayout() ? marginBeforeForChild(child) : collapsedMarginBeforeForChild(child);
17591759 logicalTopEstimate += max(marginInfo.margin(), childMarginBefore);
17601760 }
17611761

@@int RenderBlock::estimateLogicalTopPosit
17831783
17841784void RenderBlock::determineLogicalLeftPositionForChild(RenderBox* child)
17851785{
1786  int startPosition = borderStart() + paddingStart();
1787  int totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + availableLogicalWidth();
 1786 LayoutUnit startPosition = borderStart() + paddingStart();
 1787 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + availableLogicalWidth();
17881788
17891789 // Add in our start margin.
1790  int childMarginStart = marginStartForChild(child);
1791  int newPosition = startPosition + childMarginStart;
 1790 LayoutUnit childMarginStart = marginStartForChild(child);
 1791 LayoutUnit newPosition = startPosition + childMarginStart;
17921792
17931793 // Some objects (e.g., tables, horizontal rules, overflow:auto blocks) avoid floats. They need
17941794 // to shift over as necessary to dodge any floats that might get in the way.
17951795 if (child->avoidsFloats()) {
1796  int startOff = style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(logicalHeight(), false) : totalAvailableLogicalWidth - logicalRightOffsetForLine(logicalHeight(), false);
 1796 LayoutUnit startOff = style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(logicalHeight(), false) : totalAvailableLogicalWidth - logicalRightOffsetForLine(logicalHeight(), false);
17971797 if (style()->textAlign() != WEBKIT_CENTER && !child->style()->marginStartUsing(style()).isAuto()) {
17981798 if (childMarginStart < 0)
17991799 startOff += childMarginStart;
18001800 newPosition = max(newPosition, startOff); // Let the float sit in the child's margin if it can fit.
1801  } else if (startOff != startPosition) {
 1801 } else if (!layoutUnitEquals(startOff, startPosition)) {
18021802 // The object is shifting to the "end" side of the block. The object might be centered, so we need to
18031803 // recalculate our inline direction margins. Note that the containing block content
18041804 // width computation will take into account the delta between |startOff| and |startPosition|

@@void RenderBlock::handleAfterSideOfBlock
18501850 setCollapsedBottomMargin(marginInfo);
18511851}
18521852
1853 void RenderBlock::setLogicalLeftForChild(RenderBox* child, int logicalLeft, ApplyLayoutDeltaMode applyDelta)
 1853void RenderBlock::setLogicalLeftForChild(RenderBox* child, LayoutUnit logicalLeft, ApplyLayoutDeltaMode applyDelta)
18541854{
18551855 if (isHorizontalWritingMode()) {
18561856 if (applyDelta == ApplyLayoutDelta)
1857  view()->addLayoutDelta(IntSize(child->x() - logicalLeft, 0));
 1857 view()->addLayoutDelta(LayoutSize(child->x() - logicalLeft, 0));
18581858 child->setX(logicalLeft);
18591859 } else {
18601860 if (applyDelta == ApplyLayoutDelta)
1861  view()->addLayoutDelta(IntSize(0, child->y() - logicalLeft));
 1861 view()->addLayoutDelta(LayoutSize(0, child->y() - logicalLeft));
18621862 child->setY(logicalLeft);
18631863 }
18641864}
18651865
1866 void RenderBlock::setLogicalTopForChild(RenderBox* child, int logicalTop, ApplyLayoutDeltaMode applyDelta)
 1866void RenderBlock::setLogicalTopForChild(RenderBox* child, LayoutUnit logicalTop, ApplyLayoutDeltaMode applyDelta)
18671867{
18681868 if (isHorizontalWritingMode()) {
18691869 if (applyDelta == ApplyLayoutDelta)
1870  view()->addLayoutDelta(IntSize(0, child->y() - logicalTop));
 1870 view()->addLayoutDelta(LayoutSize(0, child->y() - logicalTop));
18711871 child->setY(logicalTop);
18721872 } else {
18731873 if (applyDelta == ApplyLayoutDelta)
1874  view()->addLayoutDelta(IntSize(child->x() - logicalTop, 0));
 1874 view()->addLayoutDelta(LayoutSize(child->x() - logicalTop, 0));
18751875 child->setX(logicalTop);
18761876 }
18771877}
18781878
1879 void RenderBlock::layoutBlockChildren(bool relayoutChildren, int& maxFloatLogicalBottom)
 1879void RenderBlock::layoutBlockChildren(bool relayoutChildren, LayoutUnit& maxFloatLogicalBottom)
18801880{
18811881 if (gPercentHeightDescendantsMap) {
18821882 if (HashSet<RenderBox*>* descendants = gPercentHeightDescendantsMap->get(this)) {

@@void RenderBlock::layoutBlockChildren(bo
18961896 }
18971897 }
18981898
1899  int beforeEdge = borderBefore() + paddingBefore();
1900  int afterEdge = borderAfter() + paddingAfter() + scrollbarLogicalHeight();
 1899 LayoutUnit beforeEdge = borderBefore() + paddingBefore();
 1900 LayoutUnit afterEdge = borderAfter() + paddingAfter() + scrollbarLogicalHeight();
19011901
19021902 setLogicalHeight(beforeEdge);
19031903

@@void RenderBlock::layoutBlockChildren(bo
19091909 // It doesn't get included in the normal layout process but is instead skipped.
19101910 RenderObject* childToExclude = layoutSpecialExcludedChild(relayoutChildren);
19111911
1912  int previousFloatLogicalBottom = 0;
 1912 LayoutUnit previousFloatLogicalBottom = 0;
19131913 maxFloatLogicalBottom = 0;
19141914
19151915 RenderBox* next = firstChildBox();

@@void RenderBlock::layoutBlockChildren(bo
19451945 handleAfterSideOfBlock(beforeEdge, afterEdge, marginInfo);
19461946}
19471947
1948 void RenderBlock::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, int& previousFloatLogicalBottom, int& maxFloatLogicalBottom)
 1948void RenderBlock::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, LayoutUnit& previousFloatLogicalBottom, LayoutUnit& maxFloatLogicalBottom)
19491949{
1950  int oldPosMarginBefore = maxPositiveMarginBefore();
1951  int oldNegMarginBefore = maxNegativeMarginBefore();
 1950 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore();
 1951 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore();
19521952
19531953 // The child is a normal flow object. Compute the margins we will use for collapsing now.
19541954 child->computeBlockDirectionMargins(this);

@@void RenderBlock::layoutBlockChild(Rende
19621962 // Try to guess our correct logical top position. In most cases this guess will
19631963 // be correct. Only if we're wrong (when we compute the real logical top position)
19641964 // will we have to potentially relayout.
1965  int logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo);
 1965 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo);
19661966
19671967 // Cache our old rect so that we can dirty the proper repaint rects if the child moves.
1968  IntRect oldRect(child->x(), child->y() , child->width(), child->height());
1969  int oldLogicalTop = logicalTopForChild(child);
 1968 LayoutRect oldRect(child->x(), child->y() , child->width(), child->height());
 1969 LayoutUnit oldLogicalTop = logicalTopForChild(child);
19701970
19711971#ifndef NDEBUG
1972  IntSize oldLayoutDelta = view()->layoutDelta();
 1972 LayoutSize oldLayoutDelta = view()->layoutDelta();
19731973#endif
19741974 // Go ahead and position the child as though it didn't collapse with the top.
19751975 setLogicalTopForChild(child, logicalTopEstimate, ApplyLayoutDelta);

@@void RenderBlock::layoutBlockChild(Rende
19811981 else if (!child->avoidsFloats() || child->shrinkToAvoidFloats()) {
19821982 // If an element might be affected by the presence of floats, then always mark it for
19831983 // layout.
1984  int fb = max(previousFloatLogicalBottom, lowestFloatLogicalBottom());
 1984 LayoutUnit fb = max(previousFloatLogicalBottom, lowestFloatLogicalBottom());
19851985 if (fb > logicalTopEstimate)
19861986 markDescendantsWithFloats = true;
19871987 }

@@void RenderBlock::layoutBlockChild(Rende
20062006
20072007 // Now determine the correct ypos based off examination of collapsing margin
20082008 // values.
2009  int logicalTopBeforeClear = collapseMargins(child, marginInfo);
 2009 LayoutUnit logicalTopBeforeClear = collapseMargins(child, marginInfo);
20102010
20112011 // Now check for clear.
2012  int logicalTopAfterClear = clearFloatsIfNeeded(child, marginInfo, oldPosMarginBefore, oldNegMarginBefore, logicalTopBeforeClear);
 2012 LayoutUnit logicalTopAfterClear = clearFloatsIfNeeded(child, marginInfo, oldPosMarginBefore, oldNegMarginBefore, logicalTopBeforeClear);
20132013
20142014 bool paginated = view()->layoutState()->isPaginated();
20152015 if (paginated) {
2016  int oldTop = logicalTopAfterClear;
 2016 LayoutUnit oldTop = logicalTopAfterClear;
20172017
20182018 // If the object has a page or column break value of "before", then we should shift to the top of the next page.
20192019 logicalTopAfterClear = applyBeforeBreak(child, logicalTopAfterClear);
20202020
20212021 // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one.
2022  int logicalTopBeforeUnsplittableAdjustment = logicalTopAfterClear;
2023  int logicalTopAfterUnsplittableAdjustment = adjustForUnsplittableChild(child, logicalTopAfterClear);
 2022 LayoutUnit logicalTopBeforeUnsplittableAdjustment = logicalTopAfterClear;
 2023 LayoutUnit logicalTopAfterUnsplittableAdjustment = adjustForUnsplittableChild(child, logicalTopAfterClear);
20242024
2025  int paginationStrut = 0;
2026  int unsplittableAdjustmentDelta = logicalTopAfterUnsplittableAdjustment - logicalTopBeforeUnsplittableAdjustment;
 2025 LayoutUnit paginationStrut = 0;
 2026 LayoutUnit unsplittableAdjustmentDelta = logicalTopAfterUnsplittableAdjustment - logicalTopBeforeUnsplittableAdjustment;
20272027 if (unsplittableAdjustmentDelta)
20282028 paginationStrut = unsplittableAdjustmentDelta;
20292029 else if (childRenderBlock && childRenderBlock->paginationStrut())

@@void RenderBlock::layoutBlockChild(Rende
20882088 if (childRenderBlock && childRenderBlock->containsFloats())
20892089 maxFloatLogicalBottom = max(maxFloatLogicalBottom, addOverhangingFloats(toRenderBlock(child), -child->logicalLeft(), -child->logicalTop(), !childNeededLayout));
20902090
2091  IntSize childOffset(child->x() - oldRect.x(), child->y() - oldRect.y());
 2091 LayoutSize childOffset(child->x() - oldRect.x(), child->y() - oldRect.y());
20922092 if (childOffset.width() || childOffset.height()) {
20932093 view()->addLayoutDelta(childOffset);
20942094

@@void RenderBlock::layoutBlockChild(Rende
21062106
21072107 if (paginated) {
21082108 // Check for an after page/column break.
2109  int newHeight = applyAfterBreak(child, logicalHeight(), marginInfo);
 2109 LayoutUnit newHeight = applyAfterBreak(child, logicalHeight(), marginInfo);
21102110 if (newHeight != height())
21112111 setLogicalHeight(newHeight);
21122112 }
21132113
2114  ASSERT(oldLayoutDelta == view()->layoutDelta());
 2114 ASSERT(oldLayoutDelta.isRoughlyEqualTo(view()->layoutDelta()));
21152115}
21162116
21172117void RenderBlock::simplifiedNormalFlowLayout()

@@void RenderBlock::paintObject(PaintInfo&
25642564 }
25652565}
25662566
2567 IntPoint RenderBlock::flipFloatForWritingMode(const FloatingObject* child, const IntPoint& point) const
 2567LayoutPoint RenderBlock::flipFloatForWritingMode(const FloatingObject* child, const LayoutPoint& point) const
25682568{
25692569 if (!style()->isFlippedBlocksWritingMode())
25702570 return point;

@@IntPoint RenderBlock::flipFloatForWritin
25732573 // it's going to get added back in. We hide this complication here so that the calling code looks normal for the unflipped
25742574 // case.
25752575 if (isHorizontalWritingMode())
2576  return IntPoint(point.x(), point.y() + height() - child->renderer()->height() - 2 * yPositionForFloatIncludingMargin(child));
2577  return IntPoint(point.x() + width() - child->width() - 2 * xPositionForFloatIncludingMargin(child), point.y());
 2576 return LayoutPoint(point.x(), point.y() + height() - child->renderer()->height() - 2 * yPositionForFloatIncludingMargin(child));
 2577 return LayoutPoint(point.x() + width() - child->width() - 2 * xPositionForFloatIncludingMargin(child), point.y());
25782578}
25792579
25802580void RenderBlock::paintFloats(PaintInfo& paintInfo, const LayoutPoint& paintOffset, bool preservePhase)

@@bool RenderBlock::isPointInOverflowContr
39413941 if (!scrollsOverflow())
39423942 return false;
39433943
3944  return layer()->hitTestOverflowControls(result, pointInContainer - toSize(accumulatedOffset));
 3944 return layer()->hitTestOverflowControls(result, pointInContainer - toLayoutSize(accumulatedOffset));
39453945}
39463946
39473947bool RenderBlock::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction)

@@bool RenderBlock::hitTestFloats(const Hi
40104010
40114011 LayoutPoint adjustedLocation = accumulatedOffset;
40124012 if (isRenderView()) {
4013  adjustedLocation += toSize(toRenderView(this)->frameView()->scrollPosition());
 4013 adjustedLocation += toLayoutSize(toRenderView(this)->frameView()->scrollPosition());
40144014 }
40154015
40164016 FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
91946

Source/WebCore/rendering/RenderBlock.h

@@public:
8989 virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
9090 virtual void removeChild(RenderObject*);
9191
92  virtual void layoutBlock(bool relayoutChildren, int pageLogicalHeight = 0);
 92 virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0);
9393
9494 void insertPositionedObject(RenderBox*);
9595 void removePositionedObject(RenderBox*);

@@public:
198198 int logicalWidthForChild(RenderBox* child) { return isHorizontalWritingMode() ? child->width() : child->height(); }
199199 int logicalHeightForChild(RenderBox* child) { return isHorizontalWritingMode() ? child->height() : child->width(); }
200200 int logicalTopForChild(RenderBox* child) { return isHorizontalWritingMode() ? child->y() : child->x(); }
201  void setLogicalLeftForChild(RenderBox* child, int logicalLeft, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
202  void setLogicalTopForChild(RenderBox* child, int logicalTop, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
 201 void setLogicalLeftForChild(RenderBox* child, LayoutUnit logicalLeft, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
 202 void setLogicalTopForChild(RenderBox* child, LayoutUnit logicalTop, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
203203 LayoutUnit marginBeforeForChild(RenderBoxModelObject* child) const;
204204 LayoutUnit marginAfterForChild(RenderBoxModelObject* child) const;
205205 LayoutUnit marginStartForChild(RenderBoxModelObject* child) const;

@@protected:
331331 bool simplifiedLayout();
332332 void simplifiedNormalFlowLayout();
333333
334  void computeOverflow(int oldClientAfterEdge, bool recomputeFloats = false);
 334 void computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeFloats = false);
335335 virtual void addOverflowFromChildren();
336336 void addOverflowFromFloats();
337337 void addOverflowFromPositionedObjects();

@@private:
377377
378378 virtual void repaintOverhangingFloats(bool paintAllDescendants);
379379
380  void layoutBlockChildren(bool relayoutChildren, int& maxFloatLogicalBottom);
 380 void layoutBlockChildren(bool relayoutChildren, LayoutUnit& maxFloatLogicalBottom);
381381 void layoutInlineChildren(bool relayoutChildren, int& repaintLogicalTop, int& repaintLogicalBottom);
382382 BidiRun* handleTrailingSpaces(BidiRunList<BidiRun>&, BidiContext*);
383383

@@private:
463463 bool m_isPlaced : 1;
464464 };
465465
466  IntPoint flipFloatForWritingMode(const FloatingObject*, const IntPoint&) const;
 466 LayoutPoint flipFloatForWritingMode(const FloatingObject*, const LayoutPoint&) const;
467467
468  int logicalTopForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->y() : child->x(); }
469  int logicalBottomForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->maxY() : child->maxX(); }
470  int logicalLeftForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->x() : child->y(); }
471  int logicalRightForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->maxX() : child->maxY(); }
472  int logicalWidthForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->width() : child->height(); }
473  void setLogicalTopForFloat(FloatingObject* child, int logicalTop)
 468 LayoutUnit logicalTopForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->y() : child->x(); }
 469 LayoutUnit logicalBottomForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->maxY() : child->maxX(); }
 470 LayoutUnit logicalLeftForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->x() : child->y(); }
 471 LayoutUnit logicalRightForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->maxX() : child->maxY(); }
 472 LayoutUnit logicalWidthForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->width() : child->height(); }
 473 void setLogicalTopForFloat(FloatingObject* child, LayoutUnit logicalTop)
474474 {
475475 if (isHorizontalWritingMode())
476476 child->setY(logicalTop);
477477 else
478478 child->setX(logicalTop);
479479 }
480  void setLogicalLeftForFloat(FloatingObject* child, int logicalLeft)
 480 void setLogicalLeftForFloat(FloatingObject* child, LayoutUnit logicalLeft)
481481 {
482482 if (isHorizontalWritingMode())
483483 child->setX(logicalLeft);
484484 else
485485 child->setY(logicalLeft);
486486 }
487  void setLogicalHeightForFloat(FloatingObject* child, int logicalHeight)
 487 void setLogicalHeightForFloat(FloatingObject* child, LayoutUnit logicalHeight)
488488 {
489489 if (isHorizontalWritingMode())
490490 child->setHeight(logicalHeight);
491491 else
492492 child->setWidth(logicalHeight);
493493 }
494  void setLogicalWidthForFloat(FloatingObject* child, int logicalWidth)
 494 void setLogicalWidthForFloat(FloatingObject* child, LayoutUnit logicalWidth)
495495 {
496496 if (isHorizontalWritingMode())
497497 child->setWidth(logicalWidth);

@@private:
704704 int m_negativeMargin;
705705
706706 public:
707  MarginInfo(RenderBlock* b, int beforeBorderPadding, int afterBorderPadding);
 707 MarginInfo(RenderBlock*, LayoutUnit beforeBorderPadding, LayoutUnit afterBorderPadding);
708708
709709 void setAtBeforeSideOfBlock(bool b) { m_atBeforeSideOfBlock = b; }
710710 void setAtAfterSideOfBlock(bool b) { m_atAfterSideOfBlock = b; }

@@private:
733733 int margin() const { return m_positiveMargin - m_negativeMargin; }
734734 };
735735
736  void layoutBlockChild(RenderBox* child, MarginInfo&, int& previousFloatLogicalBottom, int& maxFloatLogicalBottom);
 736 void layoutBlockChild(RenderBox* child, MarginInfo&, LayoutUnit& previousFloatLogicalBottom, LayoutUnit& maxFloatLogicalBottom);
737737 void adjustPositionedBlock(RenderBox* child, const MarginInfo&);
738738 void adjustFloatingBlock(const MarginInfo&);
739739 bool handleSpecialChild(RenderBox* child, const MarginInfo&);
740740 bool handleFloatingChild(RenderBox* child, const MarginInfo&);
741741 bool handlePositionedChild(RenderBox* child, const MarginInfo&);
742742 bool handleRunInChild(RenderBox* child);
743  int collapseMargins(RenderBox* child, MarginInfo&);
744  int clearFloatsIfNeeded(RenderBox* child, MarginInfo&, int oldTopPosMargin, int oldTopNegMargin, int yPos);
745  int estimateLogicalTopPosition(RenderBox* child, const MarginInfo&);
 743 LayoutUnit collapseMargins(RenderBox* child, MarginInfo&);
 744 LayoutUnit clearFloatsIfNeeded(RenderBox* child, MarginInfo&, int oldTopPosMargin, int oldTopNegMargin, int yPos);
 745 LayoutUnit estimateLogicalTopPosition(RenderBox* child, const MarginInfo&);
746746 void determineLogicalLeftPositionForChild(RenderBox* child);
747747 void handleAfterSideOfBlock(int top, int bottom, MarginInfo&);
748748 void setCollapsedBottomMargin(const MarginInfo&);
91946