Index: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp |
index 1db10e88cfd54350d1c0147cebcb257289894492..cfeedd4c6bbd355bf8b39c708de3956c23141360 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp |
@@ -75,33 +75,27 @@ |
// Caches all our current margin collapsing state. |
class MarginInfo { |
- // Collapsing flags for whether we can collapse our margins with our |
- // children's margins. |
+ // Collapsing flags for whether we can collapse our margins with our children's margins. |
bool m_canCollapseWithChildren : 1; |
bool m_canCollapseMarginBeforeWithChildren : 1; |
bool m_canCollapseMarginAfterWithChildren : 1; |
bool m_canCollapseMarginAfterWithLastChild : 1; |
- // Whether or not we are a quirky container, i.e., do we collapse away top and |
- // bottom margins in our container. Table cells and the body are the common |
- // examples. We also have a custom style property for Safari RSS to deal with |
- // TypePad blog articles. |
+ // Whether or not we are a quirky container, i.e., do we collapse away top and bottom |
+ // margins in our container. Table cells and the body are the common examples. We |
+ // also have a custom style property for Safari RSS to deal with TypePad blog articles. |
bool m_quirkContainer : 1; |
- // This flag tracks whether we are still looking at child margins that can all |
- // collapse together at the beginning of a block. They may or may not collapse |
- // with the top margin of the block (|m_canCollapseTopWithChildren| tells us |
- // that), but they will always be collapsing with one another. This variable |
- // can remain set to true through multiple iterations as long as we keep |
- // encountering self-collapsing blocks. |
+ // This flag tracks whether we are still looking at child margins that can all collapse together at the beginning of a block. |
+ // They may or may not collapse with the top margin of the block (|m_canCollapseTopWithChildren| tells us that), but they will |
+ // always be collapsing with one another. This variable can remain set to true through multiple iterations |
+ // as long as we keep encountering self-collapsing blocks. |
bool m_atBeforeSideOfBlock : 1; |
- // This flag is set when we know we're examining bottom margins and we know |
- // we're at the bottom of the block. |
+ // This flag is set when we know we're examining bottom margins and we know we're at the bottom of the block. |
bool m_atAfterSideOfBlock : 1; |
- // These variables are used to detect quirky margins that we need to collapse |
- // away (in table cells |
+ // These variables are used to detect quirky margins that we need to collapse away (in table cells |
// and in the body element). |
bool m_hasMarginBeforeQuirk : 1; |
bool m_hasMarginAfterQuirk : 1; |
@@ -196,10 +190,9 @@ |
} |
}; |
-// Some features, such as floats, margin collapsing and fragmentation, require |
-// some knowledge about things that happened when laying out previous block |
-// child siblings. Only looking at the object currently being laid out isn't |
-// always enough. |
+// Some features, such as floats, margin collapsing and fragmentation, require some knowledge about |
+// things that happened when laying out previous block child siblings. Only looking at the object |
+// currently being laid out isn't always enough. |
class BlockChildrenLayoutInfo { |
public: |
BlockChildrenLayoutInfo(LayoutBlockFlow* blockFlow, |
@@ -209,10 +202,9 @@ |
m_previousBreakAfterValue(BreakAuto), |
m_isAtFirstInFlowChild(true) {} |
- // Store multicol layout state before first layout of a block child. The child |
- // may contain a column spanner. If we need to re-lay out the block child |
- // because our initial logical top estimate was wrong, we need to roll back to |
- // how things were before laying out the child. |
+ // Store multicol layout state before first layout of a block child. The child may contain a |
+ // column spanner. If we need to re-lay out the block child because our initial logical top |
+ // estimate was wrong, we need to roll back to how things were before laying out the child. |
void storeMultiColumnLayoutState(const LayoutFlowThread& flowThread) { |
m_multiColumnLayoutState = flowThread.multiColumnLayoutState(); |
} |
@@ -282,17 +274,15 @@ |
bool& pageLogicalHeightChanged, |
bool& hasSpecifiedPageLogicalHeight) { |
if (LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread()) { |
- // Calculate the non-auto content box height, or set it to 0 if it's auto. |
- // We need to know this before layout, so that we can figure out where to |
- // insert column breaks. We also treat LayoutView (which may be paginated, |
- // which uses the multicol implmentation) as having non-auto height, since |
- // its height is deduced from the viewport height. |
- // We use computeLogicalHeight() to calculate the content box height. That |
- // method will clamp against max-height and min-height. Since we're now at |
- // the beginning of layout, and we don't know the actual height of the |
- // content yet, only call that method when height is definite, or we might |
- // fool ourselves into believing that columns have a definite height when |
- // they in fact don't. |
+ // Calculate the non-auto content box height, or set it to 0 if it's auto. We need to know |
+ // this before layout, so that we can figure out where to insert column breaks. We also |
+ // treat LayoutView (which may be paginated, which uses the multicol implmentation) as |
+ // having non-auto height, since its height is deduced from the viewport height. We use |
+ // computeLogicalHeight() to calculate the content box height. That method will clamp |
+ // against max-height and min-height. Since we're now at the beginning of layout, and we |
+ // don't know the actual height of the content yet, only call that method when height is |
+ // definite, or we might fool ourselves into believing that columns have a definite height |
+ // when they in fact don't. |
LayoutUnit columnHeight; |
if (hasDefiniteLogicalHeight() || isLayoutView()) { |
LogicalExtentComputedValues computedValues; |
@@ -306,17 +296,15 @@ |
} else if (isLayoutFlowThread()) { |
LayoutFlowThread* flowThread = toLayoutFlowThread(this); |
- // FIXME: This is a hack to always make sure we have a page logical height, |
- // if said height is known. The page logical height thing in LayoutState is |
- // meaningless for flow thread-based pagination (page height isn't |
- // necessarily uniform throughout the flow thread), but as long as it is |
- // used universally as a means to determine whether page height is known or |
- // not, we need this. Page height is unknown when column balancing is |
- // enabled and flow thread height is still unknown (i.e. during the first |
- // layout pass). When it's unknown, we need to prevent the pagination code |
- // from assuming page breaks everywhere and thereby eating every top margin. |
- // It should be trivial to clean up and get rid of this hack once the old |
- // multicol implementation is gone. |
+ // FIXME: This is a hack to always make sure we have a page logical height, if said height |
+ // is known. The page logical height thing in LayoutState is meaningless for flow |
+ // thread-based pagination (page height isn't necessarily uniform throughout the flow |
+ // thread), but as long as it is used universally as a means to determine whether page |
+ // height is known or not, we need this. Page height is unknown when column balancing is |
+ // enabled and flow thread height is still unknown (i.e. during the first layout pass). When |
+ // it's unknown, we need to prevent the pagination code from assuming page breaks everywhere |
+ // and thereby eating every top margin. It should be trivial to clean up and get rid of this |
+ // hack once the old multicol implementation is gone. |
pageLogicalHeight = |
flowThread->isPageLogicalHeightKnown() ? LayoutUnit(1) : LayoutUnit(); |
@@ -334,8 +322,8 @@ |
void LayoutBlockFlow::setDidBreakAtLineToAvoidWidow() { |
ASSERT(!shouldBreakAtLineToAvoidWidow()); |
- // This function should be called only after a break was applied to avoid |
- // widows so assert |m_rareData| exists. |
+ // This function should be called only after a break was applied to avoid widows |
+ // so assert |m_rareData| exists. |
ASSERT(m_rareData); |
m_rareData->m_didBreakAtLineToAvoidWidow = true; |
@@ -358,10 +346,9 @@ |
bool LayoutBlockFlow::isSelfCollapsingBlock() const { |
if (needsLayout()) { |
- // Sometimes we don't lay out objects in DOM order (column spanners being |
- // one such relevant type of object right here). As long as the object in |
- // question establishes a new formatting context, that's nothing to worry |
- // about, though. |
+ // Sometimes we don't lay out objects in DOM order (column spanners being one such relevant |
+ // type of object right here). As long as the object in question establishes a new |
+ // formatting context, that's nothing to worry about, though. |
ASSERT(createsNewFormattingContext()); |
return false; |
} |
@@ -371,12 +358,10 @@ |
bool LayoutBlockFlow::checkIfIsSelfCollapsingBlock() const { |
// We are not self-collapsing if we |
- // (a) have a non-zero height according to layout (an optimization to avoid |
- // wasting time) |
+ // (a) have a non-zero height according to layout (an optimization to avoid wasting time) |
// (b) have border/padding, |
// (c) have a min-height |
- // (d) have specified that one of our margins can't collapse using a CSS |
- // extension |
+ // (d) have specified that one of our margins can't collapse using a CSS extension |
// (e) establish a new block formatting context. |
// The early exit must be done before we check for clean layout. |
@@ -386,10 +371,9 @@ |
if (createsNewFormattingContext()) |
return false; |
- // Placeholder elements are not laid out until the dimensions of their parent |
- // text control are known, so they don't get layout until their parent has had |
- // layout - this is unique in the layout tree and means when we call |
- // isSelfCollapsingBlock on them we find that they still need layout. |
+ // Placeholder elements are not laid out until the dimensions of their parent text control are known, so they |
+ // don't get layout until their parent has had layout - this is unique in the layout tree and means |
+ // when we call isSelfCollapsingBlock on them we find that they still need layout. |
ASSERT(!needsLayout() || |
(node() && node()->isElementNode() && |
toElement(node())->shadowPseudoId() == "-webkit-input-placeholder")); |
@@ -411,20 +395,18 @@ |
} |
} |
- // If the height is 0 or auto, then whether or not we are a self-collapsing |
- // block depends on whether we have content that is all self-collapsing. |
+ // If the height is 0 or auto, then whether or not we are a self-collapsing block depends |
+ // on whether we have content that is all self-collapsing or not. |
// TODO(alancutter): Make this work correctly for calc lengths. |
if (hasAutoHeight || ((logicalHeightLength.isFixed() || |
logicalHeightLength.isPercentOrCalc()) && |
logicalHeightLength.isZero())) { |
- // If the block has inline children, see if we generated any line boxes. |
- // If we have any line boxes, then we can't be self-collapsing, since we |
- // have content. |
+ // If the block has inline children, see if we generated any line boxes. If we have any |
+ // line boxes, then we can't be self-collapsing, since we have content. |
if (childrenInline()) |
return !firstLineBox(); |
- // Whether or not we collapse is dependent on whether all our normal flow |
- // children |
+ // Whether or not we collapse is dependent on whether all our normal flow children |
// are also self-collapsing. |
for (LayoutBox* child = firstChildBox(); child; |
child = child->nextSiblingBox()) { |
@@ -492,17 +474,16 @@ |
LayoutState state(*this, locationOffset(), pageLogicalHeight, |
pageLogicalHeightChanged, logicalWidthChanged); |
- // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, |
- // to track our current maximal positive and negative margins. These values |
- // are used when we are collapsed with adjacent blocks, so for example, if you |
- // have block A and B collapsing together, then you'd take the maximal |
- // positive margin from both A and B and subtract it from the maximal negative |
- // margin from both A and B to get the true collapsed margin. This algorithm |
- // is recursive, so when we finish layout() our block knows its current |
- // maximal positive/negative values. |
+ // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, to track |
+ // our current maximal positive and negative margins. These values are used when we |
+ // are collapsed with adjacent blocks, so for example, if you have block A and B |
+ // collapsing together, then you'd take the maximal positive margin from both A and B |
+ // and subtract it from the maximal negative margin from both A and B to get the |
+ // true collapsed margin. This algorithm is recursive, so when we finish layout() |
+ // our block knows its current maximal positive/negative values. |
// |
- // Start out by setting our margin values to our current margins. Table cells |
- // have no margins, so we don't fill in the values for table cells. |
+ // Start out by setting our margin values to our current margins. Table cells have |
+ // no margins, so we don't fill in the values for table cells. |
if (!isTableCell()) { |
initMaxMarginValues(); |
setHasMarginBeforeQuirk(style()->hasMarginBeforeQuirk()); |
@@ -512,13 +493,12 @@ |
if (state.isPaginated()) { |
setPaginationStrutPropagatedFromChild(LayoutUnit()); |
- // Start with any applicable computed break-after and break-before values |
- // for this object. During child layout, breakBefore will be joined with the |
- // breakBefore value of the first in-flow child, and breakAfter will be |
- // joined with the breakAfter value of the last in-flow child. This is done |
- // in order to honor the requirement that a class A break point [1] may only |
- // exists *between* in-flow siblings (i.e. not before the first child and |
- // not after the last child). |
+ // Start with any applicable computed break-after and break-before values for this |
+ // object. During child layout, breakBefore will be joined with the breakBefore value of |
+ // the first in-flow child, and breakAfter will be joined with the breakAfter value of the |
+ // last in-flow child. This is done in order to honor the requirement that a class A break |
+ // point [1] may only exists *between* in-flow siblings (i.e. not before the first child |
+ // and not after the last child). |
// |
// [1] https://drafts.csswg.org/css-break/#possible-breaks |
setBreakBefore(LayoutBlock::breakBefore()); |
@@ -549,10 +529,9 @@ |
bool preferredLogicalWidthsBecameDirty = |
!preferredLogicalWidthsWereDirty && preferredLogicalWidthsDirty(); |
if (preferredLogicalWidthsBecameDirty) { |
- // The only thing that should dirty preferred widths at this point is the |
- // addition of overflow:auto scrollbars in a descendant. To avoid a |
- // potential infinite loop, run layout again with auto scrollbars frozen in |
- // their current state. |
+ // The only thing that should dirty preferred widths at this point is the addition of |
+ // overflow:auto scrollbars in a descendant. To avoid a potential infinite loop, |
+ // run layout again with auto scrollbars frozen in their current state. |
PaintLayerScrollableArea::FreezeScrollbarsScope freezeScrollbars; |
return layoutBlockFlow(relayoutChildren, pageLogicalHeight, layoutScope); |
} |
@@ -586,8 +565,7 @@ |
// One of our children's floats may have become an overhanging float for us. |
for (LayoutObject* child = lastChild(); child; |
child = child->previousSibling()) { |
- // TODO(robhogan): We should exclude blocks that create formatting |
- // contexts, not just out of flow or floating blocks. |
+ // TODO(robhogan): We should exclude blocks that create formatting contexts, not just out of flow or floating blocks. |
if (child->isLayoutBlockFlow() && |
!child->isFloatingOrOutOfFlowPositioned()) { |
LayoutBlockFlow* block = toLayoutBlockFlow(child); |
@@ -602,10 +580,8 @@ |
addedOverhangingFloats = true; |
} |
} |
- // If we have no overhanging floats we still pass a record of the lowest |
- // non-overhanging float up the tree so we can enclose it if we are a |
- // formatting context and allow siblings to avoid it if they have negative |
- // margin and find themselves in its vicinity. |
+ // If we have no overhanging floats we still pass a record of the lowest non-overhanging float up the tree so we can enclose it if |
+ // we are a formatting context and allow siblings to avoid it if they have negative margin and find themselves in its vicinity. |
if (!addedOverhangingFloats) |
addLowestFloatFromChildren(lowestBlock); |
} |
@@ -619,8 +595,7 @@ |
? ForcedLayoutAfterContainingBlockMoved |
: DefaultLayout); |
- // Add overflow from children (unless we're multi-column, since in that case |
- // all our child overflow is clipped anyway). |
+ // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway). |
computeOverflow(oldClientAfterEdge); |
m_descendantsWithFloatsMarkedForLayout = false; |
@@ -666,11 +641,10 @@ |
startOffsetForLine(logicalTopForChild(child), DoNotIndentText, |
logicalHeightForChild(child)); |
- // If the child has an offset from the content edge to avoid floats then use |
- // that, otherwise let any negative margin pull it back over the content |
- // edge or any positive margin push it out. |
- // If the child is being centred then the margin calculated to do that has |
- // factored in any offset required to avoid floats, so use it if necessary. |
+ // If the child has an offset from the content edge to avoid floats then use that, otherwise let any negative |
+ // margin pull it back over the content edge or any positive margin push it out. |
+ // If the child is being centred then the margin calculated to do that has factored in any offset required to |
+ // avoid floats, so use it if necessary. |
if (style()->textAlign() == WEBKIT_CENTER || |
child.style()->marginStartUsing(style()).isAuto()) |
newPosition = |
@@ -707,21 +681,21 @@ |
LayoutBlockFlow& child, |
LayoutUnit newLogicalTop, |
LayoutUnit previousFloatLogicalBottom) { |
- // TODO(mstensho): rework the code to return early when there is no need for |
- // marking, instead of this |markDescendantsWithFloats| flag. |
+ // TODO(mstensho): rework the code to return early when there is no need for marking, instead |
+ // of this |markDescendantsWithFloats| flag. |
bool markDescendantsWithFloats = false; |
if (newLogicalTop != child.logicalTop() && !child.avoidsFloats() && |
child.containsFloats()) { |
markDescendantsWithFloats = true; |
} else if (UNLIKELY(newLogicalTop.mightBeSaturated())) { |
- // The logical top might be saturated for very large elements. Comparing |
- // with the old logical top might then yield a false negative, as adding and |
- // removing margins, borders etc. from a saturated number might yield |
- // incorrect results. If this is the case, always mark for layout. |
+ // The logical top might be saturated for very large elements. Comparing with the old |
+ // logical top might then yield a false negative, as adding and removing margins, borders |
+ // etc. from a saturated number might yield incorrect results. If this is the case, always |
+ // mark for layout. |
markDescendantsWithFloats = true; |
} else if (!child.avoidsFloats() || child.shrinkToAvoidFloats()) { |
- // If an element might be affected by the presence of floats, then always |
- // mark it for layout. |
+ // If an element might be affected by the presence of floats, then always mark it for |
+ // layout. |
if (std::max(previousFloatLogicalBottom, lowestFloatLogicalBottom()) > |
newLogicalTop) |
markDescendantsWithFloats = true; |
@@ -746,9 +720,8 @@ |
markDescendantsWithFloatsForLayoutIfNeeded(childBlockFlow, newLogicalTop, |
previousFloatLogicalBottom); |
- // TODO(mstensho): A writing mode root is one thing, but we should be able |
- // to skip anything that establishes a new block formatting context here. |
- // Their floats don't affect us. |
+ // TODO(mstensho): A writing mode root is one thing, but we should be able to skip anything |
+ // that establishes a new block formatting context here. Their floats don't affect us. |
if (!childBlockFlow.isWritingModeRoot()) |
previousFloatLogicalBottom = |
std::max(previousFloatLogicalBottom, |
@@ -762,9 +735,8 @@ |
SubtreeLayoutScope layoutScope(child); |
if (!child.needsLayout()) { |
if (newLogicalTop != oldLogicalTop && child.shrinkToAvoidFloats()) { |
- // The child's width is affected by adjacent floats. When the child shifts |
- // to clear an item, its width can change (because it has more available |
- // width). |
+ // The child's width is affected by adjacent floats. When the child shifts to clear an |
+ // item, its width can change (because it has more available width). |
layoutScope.setChildNeedsLayout(&child); |
} else { |
markChildForPaginationRelayoutIfNeeded(child, layoutScope); |
@@ -781,17 +753,15 @@ |
LayoutBox& child, |
BlockChildrenLayoutInfo& layoutInfo) { |
if (layoutInfo.isAtFirstInFlowChild()) { |
- // There's no class A break point before the first child (only *between* |
- // siblings), so steal its break value and join it with what we already have |
- // here. |
+ // There's no class A break point before the first child (only *between* siblings), so |
+ // steal its break value and join it with what we already have here. |
setBreakBefore( |
joinFragmentainerBreakValues(breakBefore(), child.breakBefore())); |
return; |
} |
- // Figure out if a forced break should be inserted in front of the child. If |
- // we insert a forced break, the margins on this child may not collapse with |
- // those preceding the break. |
+ // Figure out if a forced break should be inserted in front of the child. If we insert a forced |
+ // break, the margins on this child may not collapse with those preceding the break. |
EBreak classABreakPointValue = |
child.classABreakPointValue(layoutInfo.previousBreakAfterValue()); |
if (isForcedFragmentainerBreakValue(classABreakPointValue)) { |
@@ -813,28 +783,25 @@ |
LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); |
LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); |
- // The child is a normal flow object. Compute the margins we will use for |
- // collapsing now. |
+ // The child is a normal flow object. Compute the margins we will use for collapsing now. |
child.computeAndSetBlockDirectionMargins(this); |
- // Try to guess our correct logical top position. In most cases this guess |
- // will be correct. Only if we're wrong (when we compute the real logical top |
- // position) will we have to potentially relayout. |
+ // Try to guess our correct logical top position. In most cases this guess will |
+ // be correct. Only if we're wrong (when we compute the real logical top position) |
+ // will we have to potentially relayout. |
LayoutUnit estimateWithoutPagination; |
LayoutUnit logicalTopEstimate = |
estimateLogicalTopPosition(child, layoutInfo, estimateWithoutPagination); |
- // Cache our old rect so that we can dirty the proper paint invalidation rects |
- // if the child moves. |
+ // Cache our old rect so that we can dirty the proper paint invalidation rects if the child moves. |
LayoutRect oldRect = child.frameRect(); |
if (LayoutFlowThread* flowThread = flowThreadContainingBlock()) |
layoutInfo.storeMultiColumnLayoutState(*flowThread); |
- // Use the estimated block position and lay out the child if needed. After |
- // child layout, when we have enough information to perform proper margin |
- // collapsing, float clearing and pagination, we may have to reposition and |
- // lay out again if the estimate was wrong. |
+ // Use the estimated block position and lay out the child if needed. After child layout, when |
+ // we have enough information to perform proper margin collapsing, float clearing and |
+ // pagination, we may have to reposition and lay out again if the estimate was wrong. |
bool childNeededLayout = |
positionAndLayoutOnceIfNeeded(child, logicalTopEstimate, layoutInfo); |
@@ -845,14 +812,13 @@ |
bool childDiscardMarginAfter = mustDiscardMarginAfterForChild(child); |
bool paginated = view()->layoutState()->isPaginated(); |
- // If there should be a forced break before the child, we need to insert it |
- // before attempting to collapse margins or apply clearance. |
+ // If there should be a forced break before the child, we need to insert it before attempting |
+ // to collapse margins or apply clearance. |
if (paginated) { |
- // We will now insert the strut needed by any forced break. After this |
- // operation, we will have calculated the offset where we can apply margin |
- // collapsing and clearance. After having applied those things, we'll be at |
- // the position where we can honor requirements of unbreakable content, |
- // which may extend the strut further. |
+ // We will now insert the strut needed by any forced break. After this operation, we will |
+ // have calculated the offset where we can apply margin collapsing and clearance. After |
+ // having applied those things, we'll be at the position where we can honor requirements of |
+ // unbreakable content, which may extend the strut further. |
child.resetPaginationStrut(); |
insertForcedBreakBeforeChildIfNeeded(child, layoutInfo); |
} |
@@ -869,50 +835,44 @@ |
child, marginInfo, oldPosMarginBefore, oldNegMarginBefore, |
logicalTopBeforeClear, childIsSelfCollapsing, childDiscardMargin); |
- // If there's a forced break in front of this child, its final position has |
- // already been determined. Otherwise, see if there are other reasons for |
- // breaking before it (break-inside:avoid, or not enough space for the first |
- // piece of child content to fit in the current fragmentainer), and adjust the |
- // position accordingly. |
+ // If there's a forced break in front of this child, its final position has already been |
+ // determined. Otherwise, see if there are other reasons for breaking before it |
+ // (break-inside:avoid, or not enough space for the first piece of child content to fit in the |
+ // current fragmentainer), and adjust the position accordingly. |
if (paginated) { |
if (estimateWithoutPagination != newLogicalTop) { |
- // We got a new position due to clearance or margin collapsing. Before we |
- // attempt to paginate (which may result in the position changing again), |
- // let's try again at the new position (since a new position may result in |
- // a new logical height). |
+ // We got a new position due to clearance or margin collapsing. Before we attempt to |
+ // paginate (which may result in the position changing again), let's try again at the |
+ // new position (since a new position may result in a new logical height). |
positionAndLayoutOnceIfNeeded(child, newLogicalTop, layoutInfo); |
} |
- // We have now applied forced breaks, margin collapsing and clearance, and |
- // we're at the position where we can honor requirements of unbreakable |
- // content. |
+ // We have now applied forced breaks, margin collapsing and clearance, and we're at the |
+ // position where we can honor requirements of unbreakable content. |
newLogicalTop = adjustBlockChildForPagination( |
newLogicalTop, child, layoutInfo, |
atBeforeSideOfBlock && logicalTopBeforeClear == newLogicalTop); |
} |
- // Clearance, margin collapsing or pagination may have given us a new logical |
- // top, in which case we may have to reposition and possibly relayout as well. |
- // If we determined during child layout that we need to insert a break to |
- // honor widows, we also need to relayout. |
+ // Clearance, margin collapsing or pagination may have given us a new logical top, in which |
+ // case we may have to reposition and possibly relayout as well. If we determined during child |
+ // layout that we need to insert a break to honor widows, we also need to relayout. |
if (newLogicalTop != logicalTopEstimate || child.needsLayout() || |
(paginated && childLayoutBlockFlow && |
childLayoutBlockFlow->shouldBreakAtLineToAvoidWidow())) { |
positionAndLayoutOnceIfNeeded(child, newLogicalTop, layoutInfo); |
} |
- // If we previously encountered a self-collapsing sibling of this child that |
- // had clearance then we set this bit to ensure we would not collapse the |
- // child's margins, and those of any subsequent self-collapsing siblings, with |
- // our parent. If this child is not self-collapsing then it can collapse its |
- // margins with the parent so reset the bit. |
+ // If we previously encountered a self-collapsing sibling of this child that had clearance then |
+ // we set this bit to ensure we would not collapse the child's margins, and those of any subsequent |
+ // self-collapsing siblings, with our parent. If this child is not self-collapsing then it can |
+ // collapse its margins with the parent so reset the bit. |
if (!marginInfo.canCollapseMarginAfterWithLastChild() && |
!childIsSelfCollapsing) |
marginInfo.setCanCollapseMarginAfterWithLastChild(true); |
// We are no longer at the top of the block if we encounter a non-empty child. |
- // This has to be done after checking for clear, so that margins can be reset |
- // if a clear occurred. |
+ // This has to be done after checking for clear, so that margins can be reset if a clear occurred. |
if (marginInfo.atBeforeSideOfBlock() && !childIsSelfCollapsing) |
marginInfo.setAtBeforeSideOfBlock(false); |
@@ -921,40 +881,35 @@ |
LayoutSize childOffset = child.location() - oldRect.location(); |
- // Update our height now that the child has been placed in the correct |
- // position. |
+ // Update our height now that the child has been placed in the correct position. |
setLogicalHeight(logicalHeight() + logicalHeightForChild(child)); |
if (mustSeparateMarginAfterForChild(child)) { |
setLogicalHeight(logicalHeight() + marginAfterForChild(child)); |
marginInfo.clearMargin(); |
} |
- // If the child has overhanging floats that intrude into following siblings |
- // (or possibly out of this block), then the parent gets notified of the |
- // floats now. |
+ // If the child has overhanging floats that intrude into following siblings (or possibly out |
+ // of this block), then the parent gets notified of the floats now. |
if (childLayoutBlockFlow) |
addOverhangingFloats(childLayoutBlockFlow, !childNeededLayout); |
- // If the child moved, we have to invalidate its paint as well as any |
- // floating/positioned descendants. An exception is if we need a layout. |
- // In this case, we know we're going to invalidate our paint (and the child) |
- // anyway. |
+ // If the child moved, we have to invalidate its paint as well as any floating/positioned |
+ // descendants. An exception is if we need a layout. In this case, we know we're going to |
+ // invalidate our paint (and the child) anyway. |
if (!selfNeedsLayout() && (childOffset.width() || childOffset.height()) && |
child.isLayoutBlockFlow()) |
BlockFlowPaintInvalidator(toLayoutBlockFlow(child)) |
.invalidatePaintForOverhangingFloats(); |
if (paginated) { |
- // Keep track of the break-after value of the child, so that it can be |
- // joined with the break-before value of the next in-flow object at the next |
- // class A break point. |
+ // Keep track of the break-after value of the child, so that it can be joined with the |
+ // break-before value of the next in-flow object at the next class A break point. |
layoutInfo.setPreviousBreakAfterValue(child.breakAfter()); |
paginatedContentWasLaidOut(child.logicalBottom()); |
} |
if (child.isLayoutMultiColumnSpannerPlaceholder()) { |
- // The actual column-span:all element is positioned by this placeholder |
- // child. |
+ // The actual column-span:all element is positioned by this placeholder child. |
positionSpannerDescendant(toLayoutMultiColumnSpannerPlaceholder(child)); |
} |
} |
@@ -967,55 +922,49 @@ |
LayoutBlockFlow* childBlockFlow = |
child.isLayoutBlockFlow() ? toLayoutBlockFlow(&child) : 0; |
- // See if we need a soft (unforced) break in front of this child, and set the |
- // pagination strut in that case. An unforced break may come from two sources: |
- // 1. The first piece of content inside the child doesn't fit in the current |
- // page or column |
- // 2. The child itself has breaking restrictions (break-inside:avoid, replaced |
- // content, etc.) and doesn't fully fit in the current page or column. |
+ // See if we need a soft (unforced) break in front of this child, and set the pagination strut |
+ // in that case. An unforced break may come from two sources: |
+ // 1. The first piece of content inside the child doesn't fit in the current page or column |
+ // 2. The child itself has breaking restrictions (break-inside:avoid, replaced content, etc.) |
+ // and doesn't fully fit in the current page or column. |
// |
- // No matter which source, if we need to insert a strut, it should always take |
- // us to the exact top of a page or column further ahead, or be zero. |
- |
- // The first piece of content inside the child may have set a strut during |
- // layout. Currently, only block flows support strut propagation, but this may |
- // (and should) change in the future. See crbug.com/539873 |
+ // No matter which source, if we need to insert a strut, it should always take us to the exact |
+ // top of a page or column further ahead, or be zero. |
+ |
+ // The first piece of content inside the child may have set a strut during layout. Currently, |
+ // only block flows support strut propagation, but this may (and should) change in the future. |
+ // See crbug.com/539873 |
LayoutUnit strutFromContent = |
childBlockFlow ? childBlockFlow->paginationStrutPropagatedFromChild() |
: LayoutUnit(); |
LayoutUnit logicalTopWithContentStrut = logicalTop + strutFromContent; |
- // For replaced elements and scrolled elements, we want to shift them to the |
- // next page if they don't fit on the current one. |
+ // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one. |
LayoutUnit logicalTopAfterUnsplittable = |
adjustForUnsplittableChild(child, logicalTop); |
- // Pick the largest offset. Tall unsplittable content may take us to a page or |
- // column further ahead than the next one. |
+ // Pick the largest offset. Tall unsplittable content may take us to a page or column further |
+ // ahead than the next one. |
LayoutUnit logicalTopAfterPagination = |
std::max(logicalTopWithContentStrut, logicalTopAfterUnsplittable); |
LayoutUnit newLogicalTop = logicalTop; |
- // Forced breaks may already have caused a strut, and this needs to be added |
- // together with any strut detected here in this method. |
+ // Forced breaks may already have caused a strut, and this needs to be added together with |
+ // any strut detected here in this method. |
LayoutUnit previousStrut = child.paginationStrut(); |
if (LayoutUnit paginationStrut = |
logicalTopAfterPagination - logicalTop + previousStrut) { |
ASSERT(paginationStrut > 0); |
- // If we're not at the first in-flow child, there's a class A break point |
- // before the child. If we *are* at the first in-flow child, but the child |
- // isn't flush with the content edge of its container, due to e.g. |
- // clearance, there's a class C break point before the child. Otherwise we |
- // should propagate the strut to our parent block, and attempt to break |
- // there instead. See https://drafts.csswg.org/css-break/#possible-breaks |
+ // If we're not at the first in-flow child, there's a class A break point before the child. If we *are* at the |
+ // first in-flow child, but the child isn't flush with the content edge of its container, due to e.g. clearance, |
+ // there's a class C break point before the child. Otherwise we should propagate the strut to our parent block, |
+ // and attempt to break there instead. See https://drafts.csswg.org/css-break/#possible-breaks |
if (layoutInfo.isAtFirstInFlowChild() && atBeforeSideOfBlock && |
allowsPaginationStrut()) { |
- // FIXME: Should really check if we're exceeding the page height before |
- // propagating the strut, but we don't have all the information to do so |
- // (the strut only has the remaining amount to push). Gecko gets this |
- // wrong too and pushes to the next page anyway, so not too concerned |
- // about it. |
+ // FIXME: Should really check if we're exceeding the page height before propagating the strut, but we don't |
+ // have all the information to do so (the strut only has the remaining amount to push). Gecko gets this wrong too |
+ // and pushes to the next page anyway, so not too concerned about it. |
paginationStrut += logicalTop + marginBeforeIfFloating(); |
setPaginationStrutPropagatedFromChild(paginationStrut); |
child.resetPaginationStrut(); |
@@ -1023,14 +972,12 @@ |
childBlockFlow->setPaginationStrutPropagatedFromChild(LayoutUnit()); |
} else { |
child.setPaginationStrut(paginationStrut); |
- // |previousStrut| was already baked into the logical top, so don't add it |
- // again. |
+ // |previousStrut| was already baked into the logical top, so don't add it again. |
newLogicalTop += paginationStrut - previousStrut; |
} |
} |
- // Similar to how we apply clearance. Go ahead and boost height() to be the |
- // place where we're going to position the child. |
+ // Similar to how we apply clearance. Go ahead and boost height() to be the place where we're going to position the child. |
setLogicalHeight(logicalHeight() + (newLogicalTop - logicalTop)); |
// Return the final adjusted logical top. |
@@ -1043,14 +990,13 @@ |
int lineIndex, |
LayoutUnit pageLogicalHeight) { |
if (lineBox == block.firstRootBox()) { |
- // This is the first line in the block. We can take the whole block with us |
- // to the next page or column, rather than keeping a content-less portion of |
- // it in the previous one. Only do this if the line is flush with the |
- // content edge of the block, though. If it isn't, it means that the line |
- // was pushed downwards by preceding floats that didn't fit beside the line, |
- // and we don't want to move all that, since it has already been established |
- // that it fits nicely where it is. In this case we have a class "C" break |
- // point [1] in front of this line. |
+ // This is the first line in the block. We can take the whole block with us to the next page |
+ // or column, rather than keeping a content-less portion of it in the previous one. Only do |
+ // this if the line is flush with the content edge of the block, though. If it isn't, it |
+ // means that the line was pushed downwards by preceding floats that didn't fit beside the |
+ // line, and we don't want to move all that, since it has already been established that it |
+ // fits nicely where it is. In this case we have a class "C" break point [1] in front of |
+ // this line. |
// |
// [1] https://drafts.csswg.org/css-break/#possible-breaks |
if (lineLogicalOffset > block.borderAndPaddingBefore()) |
@@ -1060,8 +1006,7 @@ |
lineBox.lineBottomWithLeading() - lineBox.lineTopWithLeading(); |
LayoutUnit totalLogicalHeight = |
lineHeight + lineLogicalOffset.clampNegativeToZero(); |
- // It's rather pointless to break before the block if the current line isn't |
- // going to |
+ // It's rather pointless to break before the block if the current line isn't going to |
// fit in the same column or page, so check that as well. |
if (totalLogicalHeight > pageLogicalHeight) |
return false; |
@@ -1069,31 +1014,27 @@ |
if (lineIndex > block.style()->orphans()) |
return false; |
- // Not enough orphans here. Push the entire block to the next column / page |
- // as an attempt to better satisfy the orphans requirement. |
+ // Not enough orphans here. Push the entire block to the next column / page as an attempt to |
+ // better satisfy the orphans requirement. |
// |
- // Note that we should ideally check if the first line in the block is flush |
- // with the content edge of the block here, because if it isn't, we should |
- // break at the class "C" break point in front of the first line, rather |
- // than before the entire block. |
+ // Note that we should ideally check if the first line in the block is flush with the |
+ // content edge of the block here, because if it isn't, we should break at the class "C" |
+ // break point in front of the first line, rather than before the entire block. |
} |
return block.allowsPaginationStrut(); |
} |
void LayoutBlockFlow::adjustLinePositionForPagination(RootInlineBox& lineBox, |
LayoutUnit& delta) { |
- // TODO(mstensho): Pay attention to line overflow. It should be painted in the |
- // same column as the rest of the line, possibly overflowing the column. We |
- // currently only allow overflow above the first column. We clip at all other |
- // column boundaries, and that's how it has to be for now. The paint we have |
- // to do when a column has overflow has to be special. |
- // We need to exclude content that paints in a previous column (and content |
- // that paints in the following column). |
+ // TODO(mstensho): Pay attention to line overflow. It should be painted in the same column as |
+ // the rest of the line, possibly overflowing the column. We currently only allow overflow above |
+ // the first column. We clip at all other column boundaries, and that's how it has to be for |
+ // now. The paint we have to do when a column has overflow has to be special. We need to exclude |
+ // content that paints in a previous column (and content that paints in the following column). |
// |
- // FIXME: Another problem with simply moving lines is that the available line |
- // width may change (because of floats). Technically if the location we move |
- // the line to has a different line width than our old position, then we need |
- // to dirty the line and all following lines. |
+ // FIXME: Another problem with simply moving lines is that the available line width may change (because of floats). |
+ // Technically if the location we move the line to has a different line width than our old position, then we need to dirty the |
+ // line and all following lines. |
LayoutUnit logicalOffset = lineBox.lineTopWithLeading(); |
LayoutUnit lineHeight = lineBox.lineBottomWithLeading() - logicalOffset; |
logicalOffset += delta; |
@@ -1111,23 +1052,20 @@ |
LayoutUnit paginationStrut = calculatePaginationStrutToFitContent( |
logicalOffset, remainingLogicalHeight, lineHeight); |
LayoutUnit newLogicalOffset = logicalOffset + paginationStrut; |
- // Moving to a different page or column may mean that its height is |
- // different. |
+ // Moving to a different page or column may mean that its height is different. |
pageLogicalHeight = pageLogicalHeightForOffset(newLogicalOffset); |
if (lineHeight > pageLogicalHeight) { |
- // Too tall to fit in one page / column. Give up. Don't push to the next |
- // page / column. |
- // TODO(mstensho): Get rid of this. This is just utter weirdness, but the |
- // other browsers also do something slightly similar, although in much |
- // more specific cases than we do here, and printing Google Docs depends |
- // on it. |
+ // Too tall to fit in one page / column. Give up. Don't push to the next page / column. |
+ // TODO(mstensho): Get rid of this. This is just utter weirdness, but the other browsers |
+ // also do something slightly similar, although in much more specific cases than we do here, |
+ // and printing Google Docs depends on it. |
paginatedContentWasLaidOut(logicalOffset + lineHeight); |
return; |
} |
- // We need to insert a break now, either because there's no room for the |
- // line in the current column / page, or because we have determined that we |
- // need a break to satisfy widow requirements. |
+ // We need to insert a break now, either because there's no room for the line in the |
+ // current column / page, or because we have determined that we need a break to satisfy |
+ // widow requirements. |
if (shouldBreakAtLineToAvoidWidow() && |
lineBreakToAvoidWidow() == lineIndex) { |
clearShouldBreakAtLineToAvoidWidow(); |
@@ -1135,12 +1073,11 @@ |
} |
if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, |
pageLogicalHeight)) { |
- // Note that when setting the strut on a block, it may be propagated to |
- // parent blocks later on, if a block's logical top is flush with that of |
- // its parent. We don't want content-less portions (struts) at the |
- // beginning of a block before a break, if it can be avoided. After all, |
- // that's the reason for setting struts on blocks and not lines in the |
- // first place. |
+ // Note that when setting the strut on a block, it may be propagated to parent blocks |
+ // later on, if a block's logical top is flush with that of its parent. We don't want |
+ // content-less portions (struts) at the beginning of a block before a break, if it can |
+ // be avoided. After all, that's the reason for setting struts on blocks and not lines |
+ // in the first place. |
LayoutUnit strut = |
paginationStrut + logicalOffset + marginBeforeIfFloating(); |
setPaginationStrutPropagatedFromChild(strut); |
@@ -1158,37 +1095,34 @@ |
// We're at the very top of a page or column. |
if (lineBox != firstRootBox()) |
lineBox.setIsFirstAfterPageBreak(true); |
- // If this is the first line in the block, and the block has a top border, |
- // padding, or (in case it's a float) margin, we may want to set a strut on |
- // the block, so that everything ends up in the next column or page. Setting |
- // a strut on the block is also important when it comes to satisfying orphan |
- // requirements. |
+ // If this is the first line in the block, and the block has a top border, padding, or (in |
+ // case it's a float) margin, we may want to set a strut on the block, so that everything |
+ // ends up in the next column or page. Setting a strut on the block is also important when |
+ // it comes to satisfying orphan requirements. |
if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, |
pageLogicalHeight)) |
strutToPropagate = logicalOffset + marginBeforeIfFloating(); |
} else if (lineBox == firstRootBox() && allowsPaginationStrut()) { |
- // This is the first line in the block. The block may still start in the |
- // previous column or page, and if that's the case, attempt to pull it over |
- // to where this line is, so that we don't split the top border, padding, or |
- // (in case it's a float) margin. |
+ // This is the first line in the block. The block may still start in the previous column or |
+ // page, and if that's the case, attempt to pull it over to where this line is, so that we |
+ // don't split the top border, padding, or (in case it's a float) margin. |
LayoutUnit totalLogicalOffset = logicalOffset + marginBeforeIfFloating(); |
LayoutUnit strut = |
remainingLogicalHeight + totalLogicalOffset - pageLogicalHeight; |
if (strut > 0) { |
- // The block starts in a previous column or page. Set a strut on the block |
- // if there's room for the top border, padding and (if it's a float) |
- // margin and the line in one column or page. |
+ // The block starts in a previous column or page. Set a strut on the block if there's |
+ // room for the top border, padding and (if it's a float) margin and the line in one |
+ // column or page. |
if (totalLogicalOffset + lineHeight <= pageLogicalHeight) |
strutToPropagate = strut; |
} |
} |
- // If we found that some preceding content (lines, border and padding) belongs |
- // together with this line, we should pull the entire block with us to the |
- // fragmentainer we're currently in. We need to avoid this when the block |
- // precedes the first fragmentainer, though. We shouldn't fragment content |
- // there, but rather let it appear in the overflow area before the first |
- // fragmentainer. |
+ // If we found that some preceding content (lines, border and padding) belongs together with |
+ // this line, we should pull the entire block with us to the fragmentainer we're currently |
+ // in. We need to avoid this when the block precedes the first fragmentainer, though. We |
+ // shouldn't fragment content there, but rather let it appear in the overflow area before the |
+ // first fragmentainer. |
if (strutToPropagate && offsetFromLogicalTopOfFirstPage() > LayoutUnit()) |
setPaginationStrutPropagatedFromChild(strutToPropagate); |
@@ -1216,8 +1150,8 @@ |
logicalOffset, remainingLogicalHeight, childLogicalHeight); |
if (paginationStrut == remainingLogicalHeight && |
remainingLogicalHeight == pageLogicalHeight) { |
- // Don't break if we were at the top of a page, and we failed to fit the |
- // content completely. No point in leaving a page completely blank. |
+ // Don't break if we were at the top of a page, and we failed to fit the content |
+ // completely. No point in leaving a page completely blank. |
return logicalOffset; |
} |
return logicalOffset + paginationStrut; |
@@ -1240,8 +1174,7 @@ |
} |
} |
- // Inline blocks are covered by the isAtomicInlineLevel() check in the |
- // avoidFloats method. |
+ // Inline blocks are covered by the isAtomicInlineLevel() check in the avoidFloats method. |
if (avoidsFloats() || isDocumentElement() || isLayoutView() || |
isFloatingOrOutOfFlowPositioned() || isTableCell()) { |
if (m_floatingObjects) { |
@@ -1261,18 +1194,15 @@ |
m_floatingObjects->clear(); |
} |
- // We should not process floats if the parent node is not a LayoutBlockFlow. |
- // Otherwise, we will add floats in an invalid context. This will cause a |
- // crash arising from a bad cast on the parent. |
- // See <rdar://problem/8049753>, where float property is applied on a text |
- // node in a SVG. |
+ // We should not process floats if the parent node is not a LayoutBlockFlow. Otherwise, we will add |
+ // floats in an invalid context. This will cause a crash arising from a bad cast on the parent. |
+ // See <rdar://problem/8049753>, where float property is applied on a text node in a SVG. |
if (!parent() || !parent()->isLayoutBlockFlow()) |
return; |
- // Attempt to locate a previous sibling with overhanging floats. We skip any |
- // elements that may have shifted to avoid floats, and any objects whose |
- // floats cannot interact with objects outside it (i.e. objects that create a |
- // new block formatting context). |
+ // Attempt to locate a previous sibling with overhanging floats. We skip any elements that |
+ // may have shifted to avoid floats, and any objects whose floats cannot interact with objects |
+ // outside it (i.e. objects that create a new block formatting context). |
LayoutBlockFlow* parentBlockFlow = toLayoutBlockFlow(parent()); |
bool siblingFloatMayIntrude = false; |
LayoutObject* prev = previousSibling(); |
@@ -1284,11 +1214,9 @@ |
prev = prev->previousSibling(); |
} |
- // First add in floats from the parent. Self-collapsing blocks let their |
- // parent track any floats that intrude into them (as opposed to floats they |
- // contain themselves) so check for those here too. If margin collapsing has |
- // moved us up past the top a previous sibling then we need to check for |
- // floats from the parent too. |
+ // First add in floats from the parent. Self-collapsing blocks let their parent track any floats that intrude into |
+ // them (as opposed to floats they contain themselves) so check for those here too. If margin collapsing has moved |
+ // us up past the top a previous sibling then we need to check for floats from the parent too. |
bool parentFloatsMayIntrude = |
!siblingFloatMayIntrude && |
(!prev || toLayoutBlockFlow(prev)->isSelfCollapsingBlock() || |
@@ -1299,8 +1227,7 @@ |
parentBlockFlow->logicalLeftOffsetForContent(), |
logicalTop()); |
- // Add overhanging floats from the previous LayoutBlockFlow, but only if it |
- // has a float that intrudes into our space. |
+ // Add overhanging floats from the previous LayoutBlockFlow, but only if it has a float that intrudes into our space. |
if (prev) { |
LayoutBlockFlow* previousBlockFlow = toLayoutBlockFlow(prev); |
if (logicalTop() < previousBlockFlow->logicalTop() + |
@@ -1377,9 +1304,8 @@ |
markLinesDirtyInBlockRange(changeLogicalTop, changeLogicalBottom); |
} else if (!oldIntrudingFloatSet.isEmpty()) { |
- // If there are previously intruding floats that no longer intrude, then |
- // children with floats should also get layout because they might need their |
- // floating object lists cleared. |
+ // If there are previously intruding floats that no longer intrude, then children with floats |
+ // should also get layout because they might need their floating object lists cleared. |
if (m_floatingObjects->set().size() < oldIntrudingFloatSet.size()) { |
markAllDescendantsWithFloatsForLayout(); |
} else { |
@@ -1423,8 +1349,7 @@ |
child->setMayNeedPaintInvalidation(); |
if (childToExclude == child) |
- continue; // Skip this child, since it will be positioned by the |
- // specialized subclass (ruby runs). |
+ continue; // Skip this child, since it will be positioned by the specialized subclass (ruby runs). |
updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, *child); |
@@ -1439,12 +1364,11 @@ |
continue; |
} |
if (child->isColumnSpanAll()) { |
- // This is not the containing block of the spanner. The spanner's |
- // placeholder will lay it out in due course. For now we just need to |
- // consult our flow thread, so that the columns (if any) preceding and |
- // following the spanner are laid out correctly. But first we apply the |
- // pending margin, so that it's taken into consideration and doesn't end |
- // up on the other side of the spanner. |
+ // This is not the containing block of the spanner. The spanner's placeholder will lay |
+ // it out in due course. For now we just need to consult our flow thread, so that the |
+ // columns (if any) preceding and following the spanner are laid out correctly. But |
+ // first we apply the pending margin, so that it's taken into consideration and doesn't |
+ // end up on the other side of the spanner. |
setLogicalHeight(logicalHeight() + marginInfo.margin()); |
marginInfo.clearMargin(); |
@@ -1459,9 +1383,8 @@ |
lastNormalFlowChild = child; |
} |
- // Now do the handling of the bottom of the block, adding in our bottom |
- // border/padding and determining the correct collapsed bottom margin |
- // information. |
+ // Now do the handling of the bottom of the block, adding in our bottom border/padding and |
+ // determining the correct collapsed bottom margin information. |
handleAfterSideOfBlock(lastNormalFlowChild, beforeEdge, afterEdge, |
marginInfo); |
} |
@@ -1488,11 +1411,10 @@ |
m_canCollapseWithChildren && !beforeBorderPadding && |
blockStyle.marginBeforeCollapse() != MarginCollapseSeparate; |
- // If any height other than auto is specified in CSS, then we don't collapse |
- // our bottom margins with our children's margins. To do otherwise would be to |
- // risk odd visual effects when the children overflow out of the parent block |
- // and yet still collapse with it. We also don't collapse if we have any |
- // bottom border/padding. |
+ // If any height other than auto is specified in CSS, then we don't collapse our bottom |
+ // margins with our children's margins. To do otherwise would be to risk odd visual |
+ // effects when the children overflow out of the parent block and yet still collapse |
+ // with it. We also don't collapse if we have any bottom border/padding. |
m_canCollapseMarginAfterWithChildren = |
m_canCollapseWithChildren && !afterBorderPadding && |
(blockStyle.logicalHeight().isAuto() && |
@@ -1527,8 +1449,8 @@ |
LayoutBlockFlow* childLayoutBlockFlow = |
child.isLayoutBlockFlow() ? toLayoutBlockFlow(&child) : 0; |
- // If the child has the same directionality as we do, then we can just return |
- // its margins in the same direction. |
+ // If the child has the same directionality as we do, then we can just return its |
+ // margins in the same direction. |
if (!child.isWritingModeRoot()) { |
if (childLayoutBlockFlow) { |
childBeforePositive = childLayoutBlockFlow->maxPositiveMarginBefore(); |
@@ -1540,9 +1462,8 @@ |
afterMargin = child.marginAfter(); |
} |
} else if (child.isHorizontalWritingMode() == isHorizontalWritingMode()) { |
- // The child has a different directionality. If the child is parallel, then |
- // it's just flipped relative to us. We can use the margins for the opposite |
- // edges. |
+ // The child has a different directionality. If the child is parallel, then it's just |
+ // flipped relative to us. We can use the margins for the opposite edges. |
if (childLayoutBlockFlow) { |
childBeforePositive = childLayoutBlockFlow->maxPositiveMarginAfter(); |
childBeforeNegative = childLayoutBlockFlow->maxNegativeMarginAfter(); |
@@ -1553,9 +1474,8 @@ |
afterMargin = child.marginBefore(); |
} |
} else { |
- // The child is perpendicular to us, which means its margins don't collapse |
- // but are on the "logical left/right" sides of the child box. We can just |
- // return the raw margin in this case. |
+ // The child is perpendicular to us, which means its margins don't collapse but are on the |
+ // "logical left/right" sides of the child box. We can just return the raw margin in this case. |
beforeMargin = marginBeforeForChild(child); |
afterMargin = marginAfterForChild(child); |
} |
@@ -1583,8 +1503,7 @@ |
bool childIsSelfCollapsing, |
bool childDiscardMarginBefore, |
bool childDiscardMarginAfter) { |
- // The child discards the before margin when the the after margin has discard |
- // in the case of a self collapsing block. |
+ // The child discards the before margin when the the after margin has discard in the case of a self collapsing block. |
childDiscardMarginBefore = childDiscardMarginBefore || |
(childDiscardMarginAfter && childIsSelfCollapsing); |
@@ -1637,14 +1556,12 @@ |
setHasMarginBeforeQuirk(true); |
} |
} else { |
- // The before margin of the container will also discard all the margins it |
- // is collapsing with. |
+ // The before margin of the container will also discard all the margins it is collapsing with. |
setMustDiscardMarginBefore(); |
} |
} |
- // Once we find a child with discardMarginBefore all the margins collapsing |
- // with us must also discard. |
+ // Once we find a child with discardMarginBefore all the margins collapsing with us must also discard. |
if (childDiscardMarginBefore) { |
marginInfo.setDiscardMargin(true); |
marginInfo.clearMargin(); |
@@ -1663,13 +1580,9 @@ |
!prev->isFloatingOrOutOfFlowPositioned() |
? toLayoutBlockFlow(prev) |
: 0; |
- // If the child's previous sibling is a self-collapsing block that cleared a |
- // float then its top border edge has been set at the bottom border edge of |
- // the float. Since we want to collapse the child's top margin with the self- |
- // collapsing block's top and bottom margins we need to adjust our parent's |
- // height to match the margin top of the self-collapsing block. If the |
- // resulting collapsed margin leaves the child still intruding into the float |
- // then we will want to clear it. |
+ // If the child's previous sibling is a self-collapsing block that cleared a float then its top border edge has been set at the bottom border edge |
+ // of the float. Since we want to collapse the child's top margin with the self-collapsing block's top and bottom margins we need to adjust our parent's height to match the |
+ // margin top of the self-collapsing block. If the resulting collapsed margin leaves the child still intruding into the float then we will want to clear it. |
if (!marginInfo.canCollapseWithMarginBefore() && previousBlockFlow && |
marginInfo.lastChildIsSelfCollapsingBlockWithClearance()) |
setLogicalHeight( |
@@ -1677,10 +1590,8 @@ |
marginValuesForChild(*previousBlockFlow).positiveMarginBefore()); |
if (childIsSelfCollapsing) { |
- // For a self collapsing block both the before and after margins get |
- // discarded. The block doesn't contribute anything to the height of the |
- // block. Also, the child's top position equals the logical height of the |
- // container. |
+ // For a self collapsing block both the before and after margins get discarded. The block doesn't contribute anything to the height of the block. |
+ // Also, the child's top position equals the logical height of the container. |
if (!childDiscardMarginBefore && !marginInfo.discardMargin()) { |
// This child has no height. We need to compute our |
// position before we collapse the child's margins together, |
@@ -1708,9 +1619,9 @@ |
if (mustSeparateMarginBeforeForChild(child)) { |
ASSERT(!marginInfo.discardMargin() || |
(marginInfo.discardMargin() && !marginInfo.margin())); |
- // If we are at the before side of the block and we collapse, ignore the |
- // computed margin and just add the child margin to the container height. |
- // This will correctly position the child inside the container. |
+ // If we are at the before side of the block and we collapse, ignore the computed margin |
+ // and just add the child margin to the container height. This will correctly position |
+ // the child inside the container. |
LayoutUnit separateMargin = !marginInfo.canCollapseWithMarginBefore() |
? marginInfo.margin() |
: LayoutUnit(); |
@@ -1743,8 +1654,8 @@ |
marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(&child)); |
} |
- // If margins would pull us past the top of the next page, then we need to |
- // pull back and pretend like the margins collapsed into the page edge. |
+ // If margins would pull us past the top of the next page, then we need to pull back and pretend like the margins |
+ // collapsed into the page edge. |
LayoutState* layoutState = view()->layoutState(); |
if (layoutState->isPaginated() && |
isPageLogicalHeightKnown(beforeCollapseLogicalTop) && |
@@ -1756,9 +1667,8 @@ |
} |
if (previousBlockFlow) { |
- // If |child| is a self-collapsing block it may have collapsed into a |
- // previous sibling and although it hasn't reduced the height of the parent |
- // yet any floats from the parent will now overhang. |
+ // If |child| is a self-collapsing block it may have collapsed into a previous sibling and although it hasn't reduced the height of the parent yet |
+ // any floats from the parent will now overhang. |
LayoutUnit oldLogicalHeight = logicalHeight(); |
setLogicalHeight(logicalTop); |
if (!previousBlockFlow->avoidsFloats() && |
@@ -1767,11 +1677,9 @@ |
addOverhangingFloats(previousBlockFlow, false); |
setLogicalHeight(oldLogicalHeight); |
- // If |child|'s previous sibling is or contains a self-collapsing block that |
- // cleared a float and margin collapsing resulted in |child| moving up |
- // into the margin area of the self-collapsing block then the float it |
- // clears is now intruding into |child|. Layout again so that we can look |
- // for floats in the parent that overhang |child|'s new logical top. |
+ // If |child|'s previous sibling is or contains a self-collapsing block that cleared a float and margin collapsing resulted in |child| moving up |
+ // into the margin area of the self-collapsing block then the float it clears is now intruding into |child|. Layout again so that we can look for |
+ // floats in the parent that overhang |child|'s new logical top. |
bool logicalTopIntrudesIntoFloat = logicalTop < beforeCollapseLogicalTop; |
if (logicalTopIntrudesIntoFloat && containsFloats() && |
!child.avoidsFloats() && lowestFloatLogicalBottom() > logicalTop) |
@@ -1787,9 +1695,8 @@ |
const BlockChildrenLayoutInfo& layoutInfo) { |
LayoutUnit logicalTop = logicalHeight(); |
- // Forced breaks are only specified on in-flow objects, but auto-positioned |
- // out-of-flow objects may be affected by a break-after value of the previous |
- // in-flow object. |
+ // Forced breaks are only specified on in-flow objects, but auto-positioned out-of-flow objects |
+ // may be affected by a break-after value of the previous in-flow object. |
if (view()->layoutState()->isPaginated()) |
logicalTop = |
applyForcedBreak(logicalTop, layoutInfo.previousBreakAfterValue()); |
@@ -1799,8 +1706,7 @@ |
const MarginInfo& marginInfo = layoutInfo.marginInfo(); |
if (!marginInfo.canCollapseWithMarginBefore()) { |
// Positioned blocks don't collapse margins, so add the margin provided by |
- // the container now. The child's own margin is added later when calculating |
- // its logical top. |
+ // the container now. The child's own margin is added later when calculating its logical top. |
LayoutUnit collapsedBeforePos = marginInfo.positiveMargin(); |
LayoutUnit collapsedBeforeNeg = marginInfo.negativeMargin(); |
logicalTop += collapsedBeforePos - collapsedBeforeNeg; |
@@ -1831,8 +1737,7 @@ |
// For self-collapsing blocks that clear, they can still collapse their |
// margins with following siblings. Reset the current margins to represent |
// the self-collapsing block's margins only. |
- // If DISCARD is specified for -webkit-margin-collapse, reset the margin |
- // values. |
+ // If DISCARD is specified for -webkit-margin-collapse, reset the margin values. |
LayoutBlockFlow::MarginValues childMargins = marginValuesForChild(child); |
if (!childDiscardMargin) { |
marginInfo.setPositiveMargin( |
@@ -1846,28 +1751,18 @@ |
} |
// CSS2.1 states: |
- // "If the top and bottom margins of an element with clearance are |
- // adjoining, its margins collapse with the adjoining margins of following |
- // siblings but that resulting margin does not collapse with the bottom |
- // margin of the parent block." |
- // So the parent's bottom margin cannot collapse through this block or any |
- // subsequent self-collapsing blocks. Set a bit to ensure this happens; it |
- // will get reset if we encounter an in-flow sibling that is not |
- // self-collapsing. |
+ // "If the top and bottom margins of an element with clearance are adjoining, its margins collapse with |
+ // the adjoining margins of following siblings but that resulting margin does not collapse with the bottom margin of the parent block." |
+ // So the parent's bottom margin cannot collapse through this block or any subsequent self-collapsing blocks. Set a bit to ensure |
+ // this happens; it will get reset if we encounter an in-flow sibling that is not self-collapsing. |
marginInfo.setCanCollapseMarginAfterWithLastChild(false); |
- // For now set the border-top of |child| flush with the bottom border-edge |
- // of the float so it can layout any floating or positioned children of its |
- // own at the correct vertical position. If subsequent siblings attempt to |
- // collapse with |child|'s margins in |collapseMargins| we will adjust the |
- // height of the parent to |child|'s margin top (which if it is positive |
- // sits up 'inside' the float it's clearing) so that all three margins can |
- // collapse at the correct vertical position. |
- // Per CSS2.1 we need to ensure that any negative margin-top clears |child| |
- // beyond the bottom border-edge of the float so that the top border edge of |
- // the child (i.e. its clearance) is at a position that satisfies the |
- // equation: "the amount of clearance is set so that: |
- // clearance + margin-top = [height of float], |
+ // For now set the border-top of |child| flush with the bottom border-edge of the float so it can layout any floating or positioned children of |
+ // its own at the correct vertical position. If subsequent siblings attempt to collapse with |child|'s margins in |collapseMargins| we will |
+ // adjust the height of the parent to |child|'s margin top (which if it is positive sits up 'inside' the float it's clearing) so that all three |
+ // margins can collapse at the correct vertical position. |
+ // Per CSS2.1 we need to ensure that any negative margin-top clears |child| beyond the bottom border-edge of the float so that the top border edge of the child |
+ // (i.e. its clearance) is at a position that satisfies the equation: "the amount of clearance is set so that clearance + margin-top = [height of float], |
// i.e., clearance = [height of float] - margin-top". |
setLogicalHeight(child.logicalTop() + childMargins.negativeMarginBefore()); |
} else { |
@@ -1881,8 +1776,7 @@ |
setMaxMarginBeforeValues(oldTopPosMargin, oldTopNegMargin); |
marginInfo.setAtBeforeSideOfBlock(false); |
- // In case the child discarded the before margin of the block we need to |
- // reset the mustDiscardMarginBefore flag to the initial value. |
+ // In case the child discarded the before margin of the block we need to reset the mustDiscardMarginBefore flag to the initial value. |
setMustDiscardMarginBefore(style()->marginBeforeCollapse() == |
MarginCollapseDiscard); |
} |
@@ -1893,16 +1787,15 @@ |
void LayoutBlockFlow::setCollapsedBottomMargin(const MarginInfo& marginInfo) { |
if (marginInfo.canCollapseWithMarginAfter() && |
!marginInfo.canCollapseWithMarginBefore()) { |
- // Update the after side margin of the container to discard if the after |
- // margin of the last child also discards and we collapse with it. |
+ // Update the after side margin of the container to discard if the after margin of the last child also discards and we collapse with it. |
// Don't update the max margin values because we won't need them anyway. |
if (marginInfo.discardMargin()) { |
setMustDiscardMarginAfter(); |
return; |
} |
- // Update our max pos/neg bottom margins, since we collapsed our bottom |
- // margins with our children. |
+ // Update our max pos/neg bottom margins, since we collapsed our bottom margins |
+ // with our children. |
setMaxMarginAfterValues( |
std::max(maxPositiveMarginAfter(), marginInfo.positiveMargin()), |
std::max(maxNegativeMarginAfter(), marginInfo.negativeMargin())); |
@@ -1925,18 +1818,15 @@ |
LayoutUnit& positiveMarginBefore, |
LayoutUnit& negativeMarginBefore, |
bool& discardMarginBefore) const { |
- // Give up if in quirks mode and we're a body/table cell and the top margin of |
- // the child box is quirky. |
- // Give up if the child specified -webkit-margin-collapse: separate that |
- // prevents collapsing. |
+ // Give up if in quirks mode and we're a body/table cell and the top margin of the child box is quirky. |
+ // Give up if the child specified -webkit-margin-collapse: separate that prevents collapsing. |
// FIXME: Use writing mode independent accessor for marginBeforeCollapse. |
if ((document().inQuirksMode() && hasMarginBeforeQuirk(&child) && |
(isTableCell() || isBody())) || |
child.style()->marginBeforeCollapse() == MarginCollapseSeparate) |
return; |
- // The margins are discarded by a child that specified |
- // -webkit-margin-collapse: discard. |
+ // The margins are discarded by a child that specified -webkit-margin-collapse: discard. |
// FIXME: Use writing mode independent accessor for marginBeforeCollapse. |
if (child.style()->marginBeforeCollapse() == MarginCollapseDiscard) { |
positiveMarginBefore = LayoutUnit(); |
@@ -1973,8 +1863,7 @@ |
if (!grandchildBox) |
return; |
- // Make sure to update the block margins now for the grandchild box so that |
- // we're looking at current values. |
+ // Make sure to update the block margins now for the grandchild box so that we're looking at current values. |
if (grandchildBox->needsLayout()) { |
grandchildBox->computeAndSetBlockDirectionMargins(this); |
if (grandchildBox->isLayoutBlock()) { |
@@ -1986,16 +1875,14 @@ |
} |
} |
- // If we have a 'clear' value but also have a margin we may not actually |
- // require clearance to move past any floats. If that's the case we want to be |
- // sure we estimate the correct position including margins after any floats |
- // rather than use 'clearance' later which could give us the wrong position. |
+ // If we have a 'clear' value but also have a margin we may not actually require clearance to move past any floats. |
+ // If that's the case we want to be sure we estimate the correct position including margins after any floats rather |
+ // than use 'clearance' later which could give us the wrong position. |
if (grandchildBox->style()->clear() != ClearNone && |
childBlockFlow->marginBeforeForChild(*grandchildBox) == 0) |
return; |
- // Collapse the margin of the grandchild box with our own to produce an |
- // estimate. |
+ // Collapse the margin of the grandchild box with our own to produce an estimate. |
childBlockFlow->marginBeforeEstimateForChild( |
*grandchildBox, positiveMarginBefore, negativeMarginBefore, |
discardMarginBefore); |
@@ -2006,8 +1893,7 @@ |
const BlockChildrenLayoutInfo& layoutInfo, |
LayoutUnit& estimateWithoutPagination) { |
const MarginInfo& marginInfo = layoutInfo.marginInfo(); |
- // FIXME: We need to eliminate the estimation of vertical position, because |
- // when it's wrong we sometimes trigger a pathological |
+ // FIXME: We need to eliminate the estimation of vertical position, because when it's wrong we sometimes trigger a pathological |
// relayout if there are intruding floats. |
LayoutUnit logicalTopEstimate = logicalHeight(); |
LayoutUnit positiveMarginBefore; |
@@ -2019,8 +1905,8 @@ |
marginBeforeEstimateForChild(child, positiveMarginBefore, |
negativeMarginBefore, discardMarginBefore); |
} else { |
- // Use the cached collapsed margin values from a previous layout. Most of |
- // the time they will be right. |
+ // Use the cached collapsed margin values from a previous layout. Most of the time they |
+ // will be right. |
LayoutBlockFlow::MarginValues marginValues = marginValuesForChild(child); |
positiveMarginBefore = |
std::max(positiveMarginBefore, marginValues.positiveMarginBefore()); |
@@ -2036,8 +1922,8 @@ |
std::max(marginInfo.negativeMargin(), negativeMarginBefore); |
} |
- // Adjust logicalTopEstimate down to the next page if the margins are so large |
- // that we don't fit on the current page. |
+ // Adjust logicalTopEstimate down to the next page if the margins are so large that we don't fit on the current |
+ // page. |
LayoutState* layoutState = view()->layoutState(); |
if (layoutState->isPaginated() && isPageLogicalHeightKnown(logicalHeight()) && |
logicalTopEstimate > logicalHeight()) |
@@ -2050,18 +1936,17 @@ |
if (layoutState->isPaginated()) { |
if (!layoutInfo.isAtFirstInFlowChild()) { |
- // Estimate the need for a forced break in front of this child. The final |
- // break policy at this class A break point isn't known until we have laid |
- // out the children of |child|. There may be forced break-before values |
- // set on first-children inside that get propagated up to the child. |
- // Just make an estimate with what we know so far. |
+ // Estimate the need for a forced break in front of this child. The final break policy |
+ // at this class A break point isn't known until we have laid out the children of |
+ // |child|. There may be forced break-before values set on first-children inside that |
+ // get propagated up to the child. Just make an estimate with what we know so far. |
EBreak breakValue = |
child.classABreakPointValue(layoutInfo.previousBreakAfterValue()); |
if (isForcedFragmentainerBreakValue(breakValue)) { |
logicalTopEstimate = applyForcedBreak(logicalHeight(), breakValue); |
- // Disregard previous margins, since they will collapse with the |
- // fragmentainer boundary, due to the forced break. Only apply margins |
- // that have been specified on the child or its descendants. |
+ // Disregard previous margins, since they will collapse with the fragmentainer |
+ // boundary, due to the forced break. Only apply margins that have been specified |
+ // on the child or its descendants. |
if (!discardMarginBefore) |
logicalTopEstimate += positiveMarginBefore - negativeMarginBefore; |
@@ -2071,8 +1956,7 @@ |
} |
} |
- // For replaced elements and scrolled elements, we want to shift them to the |
- // next page if they don't fit on the current one. |
+ // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one. |
logicalTopEstimate = adjustForUnsplittableChild(child, logicalTopEstimate); |
} |
@@ -2089,8 +1973,8 @@ |
// |
// Note also that the previous flow may collapse its margin into the top of |
// our block. If this is the case, then we do not add the margin in to our |
- // height when computing the position of the float. This condition can be |
- // tested for by simply calling canCollapseWithMarginBefore. See |
+ // height when computing the position of the float. This condition can be tested |
+ // for by simply calling canCollapseWithMarginBefore. See |
// http://www.hixie.ch/tests/adhoc/css/box/block/margin-collapse/046.html for |
// an example of this scenario. |
LayoutUnit marginOffset = marginInfo.canCollapseWithMarginBefore() |
@@ -2107,11 +1991,9 @@ |
MarginInfo& marginInfo) { |
marginInfo.setAtAfterSideOfBlock(true); |
- // If our last child was a self-collapsing block with clearance then our |
- // logical height is flush with the bottom edge of the float that the child |
- // clears. The correct vertical position for the margin-collapsing we want to |
- // perform now is at the child's margin-top - so adjust our height to that |
- // position. |
+ // If our last child was a self-collapsing block with clearance then our logical height is flush with the |
+ // bottom edge of the float that the child clears. The correct vertical position for the margin-collapsing we want |
+ // to perform now is at the child's margin-top - so adjust our height to that position. |
if (marginInfo.lastChildIsSelfCollapsingBlockWithClearance()) { |
ASSERT(lastChild); |
setLogicalHeight(logicalHeight() - |
@@ -2122,8 +2004,7 @@ |
!marginInfo.canCollapseMarginAfterWithLastChild()) |
marginInfo.setCanCollapseMarginAfterWithChildren(false); |
- // If we can't collapse with children then go ahead and add in the bottom |
- // margin. |
+ // If we can't collapse with children then go ahead and add in the bottom margin. |
if (!marginInfo.discardMargin() && |
(!marginInfo.canCollapseWithMarginAfter() && |
!marginInfo.canCollapseWithMarginBefore() && |
@@ -2134,18 +2015,17 @@ |
// Now add in our bottom border/padding. |
setLogicalHeight(logicalHeight() + afterSide); |
- // Negative margins can cause our height to shrink below our minimal height |
- // (border/padding). If this happens, ensure that the computed height is |
- // increased to the minimal height. |
+ // Negative margins can cause our height to shrink below our minimal height (border/padding). |
+ // If this happens, ensure that the computed height is increased to the minimal height. |
setLogicalHeight(std::max(logicalHeight(), beforeSide + afterSide)); |
// Update our bottom collapsed margin info. |
setCollapsedBottomMargin(marginInfo); |
- // There's no class A break point right after the last child, only *between* |
- // siblings. So propagate the break-after value, and keep looking for a class |
- // A break point (at the next in-flow block-level object), where we'll join |
- // this break-after value with the break-before value there. |
+ // There's no class A break point right after the last child, only *between* siblings. So |
+ // propagate the break-after value, and keep looking for a class A break point (at the next |
+ // in-flow block-level object), where we'll join this break-after value with the break-before |
+ // value there. |
if (view()->layoutState()->isPaginated() && lastChild) |
setBreakAfter( |
joinFragmentainerBreakValues(breakAfter(), lastChild->breakAfter())); |
@@ -2205,10 +2085,8 @@ |
: (child.style()->marginAfterCollapse() == |
MarginCollapseDiscard); |
- // FIXME: We return false here because the implementation is not geometrically |
- // complete. We have values only for before/after, not start/end. |
- // In case the boxes are perpendicular we assume the property is not |
- // specified. |
+ // FIXME: We return false here because the implementation is not geometrically complete. We have values only for before/after, not start/end. |
+ // In case the boxes are perpendicular we assume the property is not specified. |
return false; |
} |
@@ -2282,20 +2160,17 @@ |
EBreak breakValue) { |
if (!isForcedFragmentainerBreakValue(breakValue)) |
return logicalOffset; |
- // TODO(mstensho): honor breakValue. There are different types of forced |
- // breaks. We currently just assume that we want to break to the top of the |
- // next fragmentainer of the fragmentation context we're in. However, we may |
- // want to find the next left or right page - even if we're inside a multicol |
- // container when printing. |
+ // TODO(mstensho): honor breakValue. There are different types of forced breaks. We currently |
+ // just assume that we want to break to the top of the next fragmentainer of the fragmentation |
+ // context we're in. However, we may want to find the next left or right page - even if we're |
+ // inside a multicol container when printing. |
LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); |
if (!pageLogicalHeight) |
- return logicalOffset; // Page height is still unknown, so we cannot insert |
- // forced breaks. |
+ return logicalOffset; // Page height is still unknown, so we cannot insert forced breaks. |
LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset( |
logicalOffset, AssociateWithLatterPage); |
if (remainingLogicalHeight == pageLogicalHeight) |
- return logicalOffset; // Don't break if we're already at the block start of |
- // a fragmentainer. |
+ return logicalOffset; // Don't break if we're already at the block start of a fragmentainer. |
return logicalOffset + remainingLogicalHeight; |
} |
@@ -2363,8 +2238,7 @@ |
std::min<LayoutUnit>(curr->lineBottom(), curr->top() + curr->height()); |
LayoutRect rect(layerOffset.x() + curr->x(), layerOffset.y() + top, |
curr->width(), bottom - top); |
- // It's common for this rect to be entirely contained in our box, so exclude |
- // that simple case. |
+ // It's common for this rect to be entirely contained in our box, so exclude that simple case. |
if (!rect.isEmpty() && (rects.isEmpty() || !rects[0].contains(rect))) |
rects.append(rect); |
} |
@@ -2377,9 +2251,9 @@ |
LayoutBlock::absoluteRects(rects, accumulatedOffset); |
return; |
} |
- // For blocks inside inlines, we go ahead and include margins so that we run |
- // right up to the inline boxes above and below us (thus getting merged with |
- // them to form a single irregular shape). |
+ // For blocks inside inlines, we go ahead and include margins so that we run right up to the |
+ // inline boxes above and below us (thus getting merged with them to form a single irregular |
+ // shape). |
// FIXME: This is wrong for vertical writing-modes. |
// https://bugs.webkit.org/show_bug.cgi?id=46781 |
LayoutRect rect(accumulatedOffset, size()); |
@@ -2398,9 +2272,9 @@ |
LayoutBlock::absoluteQuads(quads); |
return; |
} |
- // For blocks inside inlines, we go ahead and include margins so that we run |
- // right up to the inline boxes above and below us (thus getting merged with |
- // them to form a single irregular shape). |
+ // For blocks inside inlines, we go ahead and include margins so that we run right up to the |
+ // inline boxes above and below us (thus getting merged with them to form a single irregular |
+ // shape). |
// FIXME: This is wrong for vertical writing-modes. |
// https://bugs.webkit.org/show_bug.cgi?id=46781 |
LayoutRect localRect(LayoutPoint(), size()); |
@@ -2473,8 +2347,7 @@ |
if ((!style()->isOverflowVisible() && |
!shouldIgnoreOverflowPropertyForInlineBlockBaseline()) || |
style()->containsSize()) { |
- // We are not calling baselinePosition here because the caller should add |
- // the margin-top/margin-right, not us. |
+ // We are not calling baselinePosition here because the caller should add the margin-top/margin-right, not us. |
return (lineDirection == HorizontalLine ? size().height() + marginBottom() |
: size().width() + marginLeft()) |
.toInt(); |
@@ -2507,17 +2380,14 @@ |
removeFloatingObjects(); |
setChildNeedsLayout(MarkOnlyThis); |
- // If our children are inline, then the only boxes which could contain floats |
- // are atomic inlines (e.g. inline-block, float etc.) and these create |
- // formatting contexts, so can't pick up intruding floats from |
- // ancestors/siblings - making them safe to skip. |
+ // If our children are inline, then the only boxes which could contain floats are atomic inlines (e.g. inline-block, float etc.) |
+ // and these create formatting contexts, so can't pick up intruding floats from ancestors/siblings - making them safe to skip. |
if (childrenInline()) |
return; |
for (LayoutObject* child = firstChild(); child; |
child = child->nextSibling()) { |
- // We don't skip blocks that create formatting contexts as they may have |
- // only recently changed style and their float lists may still contain |
- // floats from siblings and ancestors. |
+ // We don't skip blocks that create formatting contexts as they may have only recently |
+ // changed style and their float lists may still contain floats from siblings and ancestors. |
if (child->isLayoutBlockFlow()) |
toLayoutBlockFlow(child)->removeFloatingObjectsFromDescendants(); |
} |
@@ -2539,11 +2409,9 @@ |
if (floatToRemove) |
removeFloatingObject(floatToRemove); |
- // Iterate over our children and mark them as needed. If our children are |
- // inline, then the only boxes which could contain floats are atomic inlines |
- // (e.g. inline-block, float etc.) and these create formatting contexts, so |
- // can't pick up intruding floats from ancestors/siblings - making them safe |
- // to skip. |
+ // Iterate over our children and mark them as needed. If our children are inline, then the |
+ // only boxes which could contain floats are atomic inlines (e.g. inline-block, float etc.) and these create formatting |
+ // contexts, so can't pick up intruding floats from ancestors/siblings - making them safe to skip. |
if (!childrenInline()) { |
for (LayoutObject* child = firstChild(); child; |
child = child->nextSibling()) { |
@@ -2598,8 +2466,7 @@ |
if (!containsFloats()) |
return LayoutUnit(); |
- // At least one float is present. We need to perform the clearance |
- // computation. |
+ // At least one float is present. We need to perform the clearance computation. |
bool clearSet = child->style()->clear() != ClearNone; |
LayoutUnit logicalBottom; |
switch (child->style()->clear()) { |
@@ -2616,8 +2483,7 @@ |
break; |
} |
- // We also clear floats if we are too big to sit on the same line as a float |
- // (and wish to avoid floats by default). |
+ // We also clear floats if we are too big to sit on the same line as a float (and wish to avoid floats by default). |
LayoutUnit result = clearSet |
? (logicalBottom - logicalTop).clampNegativeToZero() |
: LayoutUnit(); |
@@ -2642,12 +2508,9 @@ |
if (childLogicalWidthAtNewLogicalTopOffset <= |
availableLogicalWidthAtNewLogicalTopOffset) { |
- // Even though we may not be moving, if the logical width did shrink |
- // because of the presence of new floats, then we need to force a |
- // relayout as though we shifted. This happens because of the dynamic |
- // addition of overhanging floats from previous siblings when negative |
- // margins exist on a child (see the addOverhangingFloats call at the |
- // end of collapseMargins). |
+ // Even though we may not be moving, if the logical width did shrink because of the presence of new floats, then |
+ // we need to force a relayout as though we shifted. This happens because of the dynamic addition of overhanging floats |
+ // from previous siblings when negative margins exist on a child (see the addOverhangingFloats call at the end of collapseMargins). |
if (childLogicalWidthAtOldLogicalTopOffset != |
childLogicalWidthAtNewLogicalTopOffset) |
child->setChildNeedsLayout(MarkOnlyThis); |
@@ -2673,16 +2536,13 @@ |
// Mark as being destroyed to avoid trouble with merges in removeChild(). |
m_beingDestroyed = true; |
- // Make sure to destroy anonymous children first while they are still |
- // connected to the rest of the tree, so that they will properly dirty line |
- // boxes that they are removed from. Effects that do :before/:after only on |
- // hover could crash otherwise. |
+ // Make sure to destroy anonymous children first while they are still connected to the rest of the tree, so that they will |
+ // properly dirty line boxes that they are removed from. Effects that do :before/:after only on hover could crash otherwise. |
children()->destroyLeftoverChildren(); |
// Destroy our continuation before anything other than anonymous children. |
// The reason we don't destroy it before anonymous children is that they may |
- // have continuations of their own that are anonymous children of our |
- // continuation. |
+ // have continuations of their own that are anonymous children of our continuation. |
LayoutBoxModelObject* continuation = this->continuation(); |
if (continuation) { |
continuation->destroy(); |
@@ -2690,8 +2550,8 @@ |
} |
if (!documentBeingDestroyed()) { |
- // TODO(mstensho): figure out if we need this. We have no test coverage for |
- // it. It looks like all line boxes have been removed at this point. |
+ // TODO(mstensho): figure out if we need this. We have no test coverage for it. It looks |
+ // like all line boxes have been removed at this point. |
if (firstLineBox()) { |
// We can't wait for LayoutBox::destroy to clear the selection, |
// because by then we will have nuked the line boxes. |
@@ -2738,20 +2598,18 @@ |
bool hadSelfPaintingLayer = hasSelfPaintingLayer(); |
LayoutBlock::styleDidChange(diff, oldStyle); |
- // After our style changed, if we lose our ability to propagate floats into |
- // next sibling blocks, then we need to find the top most parent containing |
- // that overhanging float and then mark its descendants with floats for layout |
- // and clear all floats from its next sibling blocks that exist in our |
- // floating objects list. See crbug.com/56299 and crbug.com/62875. |
+ // After our style changed, if we lose our ability to propagate floats into next sibling |
+ // blocks, then we need to find the top most parent containing that overhanging float and |
+ // then mark its descendants with floats for layout and clear all floats from its next |
+ // sibling blocks that exist in our floating objects list. See bug 56299 and 62875. |
bool canPropagateFloatIntoSibling = |
!isFloatingOrOutOfFlowPositioned() && !avoidsFloats(); |
bool siblingFloatPropagationChanged = |
diff.needsFullLayout() && s_canPropagateFloatIntoSibling && |
!canPropagateFloatIntoSibling && hasOverhangingFloats(); |
- // When this object's self-painting layer status changed, we should update |
- // FloatingObjects::shouldPaint() flags for descendant overhanging floats in |
- // ancestors. |
+ // When this object's self-painting layer status changed, we should update FloatingObjects::shouldPaint() flags for |
+ // descendant overhanging floats in ancestors. |
bool needsUpdateAncestorFloatObjectShouldPaintFlags = false; |
if (hasSelfPaintingLayer() != hadSelfPaintingLayer && |
hasOverhangingFloats()) { |
@@ -2796,8 +2654,8 @@ |
if (oldStyle) { |
if (LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread()) { |
if (!style()->columnRuleEquivalent(oldStyle)) { |
- // Column rules are painted by anonymous column set children of the |
- // multicol container. We need to notify them. |
+ // Column rules are painted by anonymous column set children of the multicol |
+ // container. We need to notify them. |
flowThread->columnRuleStyleDidChange(); |
} |
} |
@@ -2853,16 +2711,15 @@ |
bool madeBoxesNonInline = false; |
- // A block has to either have all of its children inline, or all of its |
- // children as blocks. |
- // So, if our children are currently inline and a block child has to be |
- // inserted, we move all our inline children into anonymous block boxes. |
+ // A block has to either have all of its children inline, or all of its children as blocks. |
+ // So, if our children are currently inline and a block child has to be inserted, we move all our |
+ // inline children into anonymous block boxes. |
bool childIsBlockLevel = |
!newChild->isInline() && !newChild->isFloatingOrOutOfFlowPositioned(); |
if (childrenInline()) { |
if (childIsBlockLevel) { |
- // Wrap the inline content in anonymous blocks, to allow for the new block |
- // child to be inserted. |
+ // Wrap the inline content in anonymous blocks, to allow for the new block child to be |
+ // inserted. |
makeChildrenNonInline(beforeChild); |
madeBoxesNonInline = true; |
@@ -2873,12 +2730,11 @@ |
} |
} |
} else if (!childIsBlockLevel) { |
- // This block has block children. We may want to put the new child into an |
- // anomyous block. Floats and out-of-flow children may live among either |
- // block or inline children, so for such children, only put them inside an |
- // anonymous block if one already exists. If the child is inline, on the |
- // other hand, we *have to* put it inside an anonymous block, so create a |
- // new one if there is none for us there already. |
+ // This block has block children. We may want to put the new child into an anomyous |
+ // block. Floats and out-of-flow children may live among either block or inline children, |
+ // so for such children, only put them inside an anonymous block if one already exists. If |
+ // the child is inline, on the other hand, we *have to* put it inside an anonymous block, |
+ // so create a new one if there is none for us there already. |
LayoutObject* afterChild = |
beforeChild ? beforeChild->previousSibling() : lastChild(); |
@@ -2899,9 +2755,8 @@ |
} |
} |
- // Skip the LayoutBlock override, since that one deals with anonymous child |
- // insertion in a way that isn't sufficient for us, and can only cause trouble |
- // at this point. |
+ // Skip the LayoutBlock override, since that one deals with anonymous child insertion in a way |
+ // that isn't sufficient for us, and can only cause trouble at this point. |
LayoutBox::addChild(newChild, beforeChild); |
if (madeBoxesNonInline && parent() && isAnonymousBlock() && |
@@ -2991,8 +2846,7 @@ |
} else if (!beingDestroyed() && |
!oldChild->isFloatingOrOutOfFlowPositioned() && |
!oldChild->isAnonymousBlock()) { |
- // If the child we're removing means that we can now treat all children as |
- // inline without the need for anonymous blocks, then do that. |
+ // If the child we're removing means that we can now treat all children as inline without the need for anonymous blocks, then do that. |
makeChildrenInlineIfPossible(); |
} |
} |
@@ -3007,14 +2861,14 @@ |
// anonymous block later in the tree is merged into the one preceding it. |
// It can happen that the later block (this) contains floats that the |
// previous block (toBlockFlow) did not contain, and thus are not in the |
- // floating objects list for toBlockFlow. This can result in toBlockFlow |
- // containing floats that are not in it's floating objects list, but are in |
- // the floating objects lists of siblings and parents. This can cause problems |
- // when the float itself is deleted, since the deletion code assumes that if a |
- // float is not in it's containing block's floating objects list, it isn't in |
- // any floating objects list. In order to preserve this condition (removing it |
- // has serious performance implications), we need to copy the floating objects |
- // from the old block (this) to the new block (toBlockFlow). |
+ // floating objects list for toBlockFlow. This can result in toBlockFlow containing |
+ // floats that are not in it's floating objects list, but are in the |
+ // floating objects lists of siblings and parents. This can cause problems |
+ // when the float itself is deleted, since the deletion code assumes that |
+ // if a float is not in it's containing block's floating objects list, it |
+ // isn't in any floating objects list. In order to preserve this condition |
+ // (removing it has serious performance implications), we need to copy the |
+ // floating objects from the old block (this) to the new block (toBlockFlow). |
// The float's metrics will likely all be wrong, but since toBlockFlow is |
// already marked for layout, this will get fixed before anything gets |
// displayed. |
@@ -3047,8 +2901,8 @@ |
if (prev && prev->isAnonymousBlock() && prev->isLayoutBlockFlow()) { |
LayoutBlockFlow* newContainer = toLayoutBlockFlow(prev); |
moveChildTo(newContainer, child, nullptr, false); |
- // The anonymous block we've moved to may now be adjacent to former siblings |
- // of ours that it can contain also. |
+ // The anonymous block we've moved to may now be adjacent to former siblings of ours |
+ // that it can contain also. |
newContainer->reparentSubsequentFloatingOrOutOfFlowSiblings(); |
return; |
} |
@@ -3067,8 +2921,7 @@ |
return; |
if (child->continuation()) |
return; |
- // Ruby elements use anonymous wrappers for ruby runs and ruby bases by |
- // design, so we don't remove them. |
+ // Ruby elements use anonymous wrappers for ruby runs and ruby bases by design, so we don't remove them. |
if (child->isRubyRun() || child->isRubyBase()) |
return; |
setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( |
@@ -3083,9 +2936,8 @@ |
bool LayoutBlockFlow::mergeSiblingContiguousAnonymousBlock( |
LayoutBlockFlow* siblingThatMayBeDeleted) { |
- // Note: |this| and |siblingThatMayBeDeleted| may not be adjacent siblings at |
- // this point. There may be an object between them which is about to be |
- // removed. |
+ // Note: |this| and |siblingThatMayBeDeleted| may not be adjacent siblings at this point. There |
+ // may be an object between them which is about to be removed. |
if (!isMergeableAnonymousBlock(this) || |
!isMergeableAnonymousBlock(siblingThatMayBeDeleted)) |
@@ -3094,8 +2946,8 @@ |
setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( |
LayoutInvalidationReason::AnonymousBlockChange); |
- // If the inlineness of children of the two block don't match, we'd need |
- // special code here (but there should be no need for it). |
+ // If the inlineness of children of the two block don't match, we'd need special code here |
+ // (but there should be no need for it). |
ASSERT(siblingThatMayBeDeleted->childrenInline() == childrenInline()); |
// Take all the children out of the |next| block and put them in |
// the |prev| block. |
@@ -3141,8 +2993,7 @@ |
} |
void LayoutBlockFlow::makeChildrenInlineIfPossible() { |
- // Collapsing away anonymous wrappers isn't relevant for the children of |
- // anonymous blocks, unless they are ruby bases. |
+ // Collapsing away anonymous wrappers isn't relevant for the children of anonymous blocks, unless they are ruby bases. |
if (isAnonymousBlock() && !isRubyBase()) |
return; |
@@ -3154,35 +3005,29 @@ |
if (child->isOutOfFlowPositioned()) |
continue; |
- // There are still block children in the container, so any anonymous |
- // wrappers are still needed. |
+ // There are still block children in the container, so any anonymous wrappers are still needed. |
if (!child->isAnonymousBlock() || !child->isLayoutBlockFlow()) |
return; |
- // If one of the children is being destroyed then it is unsafe to clean up |
- // anonymous wrappers as the |
+ // If one of the children is being destroyed then it is unsafe to clean up anonymous wrappers as the |
// entire branch may be being destroyed. |
if (toLayoutBlockFlow(child)->beingDestroyed()) |
return; |
- // We can't remove anonymous wrappers if they contain continuations as this |
- // means there are block children present. |
+ // We can't remove anonymous wrappers if they contain continuations as this means there are block children present. |
if (toLayoutBlockFlow(child)->continuation()) |
return; |
- // We are only interested in removing anonymous wrappers if there are inline |
- // siblings underneath them. |
+ // We are only interested in removing anonymous wrappers if there are inline siblings underneath them. |
if (!child->childrenInline()) |
return; |
- // Ruby elements use anonymous wrappers for ruby runs and ruby bases by |
- // design, so we don't remove them. |
+ // Ruby elements use anonymous wrappers for ruby runs and ruby bases by design, so we don't remove them. |
if (child->isRubyRun() || child->isRubyBase()) |
return; |
blocksToRemove.append(toLayoutBlockFlow(child)); |
} |
- // If we make an object's children inline we are going to frustrate any future |
- // attempts to remove floats from its children's float-lists before the next |
- // layout happens so clear down all the floatlists now - they will be rebuilt |
- // at layout. |
+ // If we make an object's children inline we are going to frustrate any future attempts to remove |
+ // floats from its children's float-lists before the next layout happens so clear down all the floatlists |
+ // now - they will be rebuilt at layout. |
removeFloatingObjectsFromDescendants(); |
for (size_t i = 0; i < blocksToRemove.size(); i++) |
@@ -3202,9 +3047,9 @@ |
// We skip any non-inlines we encounter as long as we haven't found any |
// inlines yet. |
// |
- // |boundary| indicates a non-inclusive boundary point. Regardless of whether |
- // |boundary| is inline or not, we will not include it in a run with inlines |
- // before it. It's as though we encountered a non-inline. |
+ // |boundary| indicates a non-inclusive boundary point. Regardless of whether |boundary| |
+ // is inline or not, we will not include it in a run with inlines before it. It's as though we encountered |
+ // a non-inline. |
// Start by skipping as many non-inlines as we can. |
LayoutObject* curr = start; |
@@ -3235,12 +3080,12 @@ |
void LayoutBlockFlow::makeChildrenNonInline(LayoutObject* insertionPoint) { |
// makeChildrenNonInline takes a block whose children are *all* inline and it |
- // makes sure that inline children are coalesced under anonymous blocks. |
- // If |insertionPoint| is defined, then it represents the insertion point for |
- // the new block child that is causing us to have to wrap all the inlines. |
- // This means that we cannot coalesce inlines before |insertionPoint| with |
- // inlines following |insertionPoint|, because the new child is going to be |
- // inserted in between the inlines, splitting them. |
+ // makes sure that inline children are coalesced under anonymous |
+ // blocks. If |insertionPoint| is defined, then it represents the insertion point for |
+ // the new block child that is causing us to have to wrap all the inlines. This |
+ // means that we cannot coalesce inlines before |insertionPoint| with inlines following |
+ // |insertionPoint|, because the new child is going to be inserted in between the inlines, |
+ // splitting them. |
ASSERT(!isInline() || isAtomicInlineLevel()); |
ASSERT(!insertionPoint || insertionPoint->parent() == this); |
@@ -3323,10 +3168,9 @@ |
if (!style()->isFlippedBlocksWritingMode()) |
return point; |
- // This is similar to LayoutBox::flipForWritingModeForChild. We have to |
- // subtract out our left offsets twice, since it's going to get added back in. |
- // We hide this complication here so that the calling code looks normal for |
- // the unflipped case. |
+ // This is similar to LayoutBox::flipForWritingModeForChild. We have to subtract out our left offsets twice, since |
+ // it's going to get added back in. We hide this complication here so that the calling code looks normal for the unflipped |
+ // case. |
return LayoutPoint(point.x() + size().width() - |
child.layoutObject()->size().width() - |
2 * xPositionForFloatIncludingMargin(child), |
@@ -3469,8 +3313,8 @@ |
std::unique_ptr<FloatingObject> newObj = FloatingObject::create(&floatBox); |
- // Our location is irrelevant if we're unsplittable or no pagination is in |
- // effect. Just go ahead and lay out the float. |
+ // Our location is irrelevant if we're unsplittable or no pagination is in effect. |
+ // Just go ahead and lay out the float. |
bool isChildLayoutBlock = floatBox.isLayoutBlock(); |
if (isChildLayoutBlock && !floatBox.needsLayout() && |
view()->layoutState()->pageLogicalHeightChanged()) |
@@ -3501,9 +3345,9 @@ |
logicalTop == LayoutUnit::max()) { |
logicalBottom = LayoutUnit::max(); |
} else { |
- // Special-case zero- and less-than-zero-height floats: those don't |
- // touch the line that they're on, but it still needs to be dirtied. |
- // This is accomplished by pretending they have a height of 1. |
+ // Special-case zero- and less-than-zero-height floats: those don't touch |
+ // the line that they're on, but it still needs to be dirtied. This is |
+ // accomplished by pretending they have a height of 1. |
logicalBottom = std::max(logicalBottom, logicalTop + 1); |
} |
if (floatingObject.originatingLine()) { |
@@ -3552,9 +3396,9 @@ |
if (floatingObjectSet.last()->isPlaced()) |
return false; |
- // Move backwards through our floating object list until we find a float that |
- // has already been positioned. Then we'll be able to move forward, |
- // positioning all of the new floats that need it. |
+ // Move backwards through our floating object list until we find a float that has |
+ // already been positioned. Then we'll be able to move forward, positioning all of |
+ // the new floats that need it. |
FloatingObjectSetIterator it = floatingObjectSet.end(); |
--it; // Go to last item. |
FloatingObjectSetIterator begin = floatingObjectSet.begin(); |
@@ -3579,9 +3423,8 @@ |
// Now walk through the set of unpositioned floats and place them. |
for (; it != end; ++it) { |
FloatingObject& floatingObject = *it->get(); |
- // The containing block is responsible for positioning floats, so if we have |
- // floats in our list that come from somewhere else, do not attempt to |
- // position them. |
+ // The containing block is responsible for positioning floats, so if we have floats in our |
+ // list that come from somewhere else, do not attempt to position them. |
if (floatingObject.layoutObject()->containingBlock() != this) |
continue; |
@@ -3602,8 +3445,8 @@ |
bool isPaginated = view()->layoutState()->isPaginated(); |
if (isPaginated && !childrenInline()) { |
- // Forced breaks are inserted at class A break points. Floats may be |
- // affected by a break-after value on the previous in-flow sibling. |
+ // Forced breaks are inserted at class A break points. Floats may be affected by a |
+ // break-after value on the previous in-flow sibling. |
if (LayoutBox* previousInFlowBox = childBox->previousInFlowSiblingBox()) |
logicalTop = |
applyForcedBreak(logicalTop, previousInFlowBox->breakAfter()); |
@@ -3628,14 +3471,13 @@ |
if (isPaginated) { |
LayoutBlockFlow* childBlockFlow = |
childBox->isLayoutBlockFlow() ? toLayoutBlockFlow(childBox) : nullptr; |
- // The first piece of content inside the child may have set a strut during |
- // layout. |
+ // The first piece of content inside the child may have set a strut during layout. |
LayoutUnit strut = |
childBlockFlow ? childBlockFlow->paginationStrutPropagatedFromChild() |
: LayoutUnit(); |
if (!strut) { |
- // Otherwise, if we are unsplittable and don't fit, move to the next |
- // page or column if that helps the situation. |
+ // Otherwise, if we are unsplittable and don't fit, move to the next page or column |
+ // if that helps the situation. |
strut = |
adjustForUnsplittableChild(*childBox, floatLogicalLocation.y()) - |
floatLogicalLocation.y(); |
@@ -3694,13 +3536,11 @@ |
LayoutUnit logicalTopOffset) { |
ASSERT(!avoidsFloats()); |
- // If we create our own block formatting context then our contents don't |
- // interact with floats outside it, even those from our parent. |
+ // If we create our own block formatting context then our contents don't interact with floats outside it, even those from our parent. |
if (createsNewFormattingContext()) |
return; |
- // If the parent or previous sibling doesn't have any floats to add, don't |
- // bother. |
+ // If the parent or previous sibling doesn't have any floats to add, don't bother. |
if (!prev->m_floatingObjects) |
return; |
@@ -3718,12 +3558,11 @@ |
if (!m_floatingObjects) |
createFloatingObjects(); |
- // Applying the child's margin makes no sense in the case where the |
- // child was passed in since this margin was added already through the |
- // modification of the |logicalLeftOffset| variable above. |
- // |logicalLeftOffset| will equal the margin in this case, so it's |
- // already been taken into account. Only apply this code if prev is the |
- // parent, since otherwise the left margin will get applied twice. |
+ // Applying the child's margin makes no sense in the case where the child was passed in. |
+ // since this margin was added already through the modification of the |logicalLeftOffset| variable |
+ // above. |logicalLeftOffset| will equal the margin in this case, so it's already been taken |
+ // into account. Only apply this code if prev is the parent, since otherwise the left margin |
+ // will get applied twice. |
LayoutSize offset = |
isHorizontalWritingMode() |
? LayoutSize( |
@@ -3743,16 +3582,15 @@ |
void LayoutBlockFlow::addOverhangingFloats(LayoutBlockFlow* child, |
bool makeChildPaintOtherFloats) { |
- // Prevent floats from being added to the canvas by the root element, e.g., |
- // <html>. |
+ // Prevent floats from being added to the canvas by the root element, e.g., <html>. |
if (!child->containsFloats() || child->createsNewFormattingContext()) |
return; |
LayoutUnit childLogicalTop = child->logicalTop(); |
LayoutUnit childLogicalLeft = child->logicalLeft(); |
- // Floats that will remain the child's responsibility to paint should factor |
- // into its overflow. |
+ // Floats that will remain the child's responsibility to paint should factor into its |
+ // overflow. |
FloatingObjectSetIterator childEnd = child->m_floatingObjects->set().end(); |
for (FloatingObjectSetIterator childIt = |
child->m_floatingObjects->set().begin(); |
@@ -3772,11 +3610,10 @@ |
: LayoutSize(-childLogicalTop, -childLogicalLeft); |
bool shouldPaint = false; |
- // The nearest enclosing layer always paints the float (so that zindex |
- // and stacking behaves properly). We always want to propagate the |
- // desire to paint the float as far out as we can, to the outermost |
- // block that overlaps the float, stopping only if we hit a |
- // self-painting layer boundary. |
+ // The nearest enclosing layer always paints the float (so that zindex and stacking |
+ // behaves properly). We always want to propagate the desire to paint the float as |
+ // far out as we can, to the outermost block that overlaps the float, stopping only |
+ // if we hit a self-painting layer boundary. |
if (floatingObject.layoutObject()->enclosingFloatPaintingLayer() == |
enclosingFloatPaintingLayer() && |
!floatingObject.isLowestNonOverhangingFloatInChild()) { |
@@ -3797,17 +3634,16 @@ |
floatingObject.layoutObject()->isDescendantOf(child) && |
floatingObject.layoutObject()->enclosingFloatPaintingLayer() == |
child->enclosingFloatPaintingLayer()) { |
- // The float is not overhanging from this block, so if it is a |
- // descendant of the child, the child should paint it (the other case is |
- // that it is intruding into the child), unless it has its own layer or |
- // enclosing layer. |
- // If makeChildPaintOtherFloats is false, it means that the child must |
- // already know about all the floats it should paint. |
+ // The float is not overhanging from this block, so if it is a descendant of the child, the child should |
+ // paint it (the other case is that it is intruding into the child), unless it has its own layer or enclosing |
+ // layer. |
+ // If makeChildPaintOtherFloats is false, it means that the child must already know about all the floats |
+ // it should paint. |
floatingObject.setShouldPaint(true); |
} |
- // Since the float doesn't overhang, it didn't get put into our list. We |
- // need to go ahead and add its overflow in to the child now. |
+ // Since the float doesn't overhang, it didn't get put into our list. We need to go ahead and add its overflow in to the |
+ // child now. |
if (floatingObject.isDescendant()) |
child->addOverflowFromChild( |
floatingObject.layoutObject(), |
@@ -3970,12 +3806,10 @@ |
FloatingObject& floatingObject = **it; |
if (!floatBoxIsSelfPaintingLayer) { |
- // This repeats the logic in addOverhangingFloats() about shouldPaint |
- // flag: |
- // - The nearest enclosing block in which the float doesn't overhang |
- // paints the float; |
- // - Or even if the float overhangs, if the ancestor block has |
- // self-painting layer, it paints the float. |
+ // This repeats the logic in addOverhangingFloats() about shouldPaint flag: |
+ // - The nearest enclosing block in which the float doesn't overhang paints the float; |
+ // - Or even if the float overhangs, if the ancestor block has self-painting layer, it |
+ // paints the float. |
if (ancestorBlock->hasSelfPaintingLayer() || |
!ancestorBlock->isOverhangingFloat(floatingObject)) { |
floatingObject.setShouldPaint(true); |
@@ -3988,23 +3822,21 @@ |
} |
bool LayoutBlockFlow::allowsPaginationStrut() const { |
- // The block needs to be contained by a LayoutBlockFlow (and not by e.g. a |
- // flexbox, grid, or a table (the latter being the case for table cell or |
- // table caption)). The reason for this limitation is simply that |
- // LayoutBlockFlow child layout code is the only place where we pick up the |
- // struts and handle them. We handle floats and regular in-flow children, and |
- // that's all. We could handle this in other layout modes as well (and even |
- // for out-of-flow children), but currently we don't. |
+ // The block needs to be contained by a LayoutBlockFlow (and not by e.g. a flexbox, grid, or a |
+ // table (the latter being the case for table cell or table caption)). The reason for this |
+ // limitation is simply that LayoutBlockFlow child layout code is the only place where we pick |
+ // up the struts and handle them. We handle floats and regular in-flow children, and that's |
+ // all. We could handle this in other layout modes as well (and even for out-of-flow children), |
+ // but currently we don't. |
// TODO(mstensho): But we *should*. |
if (isOutOfFlowPositioned()) |
return false; |
if (isLayoutFlowThread()) { |
// Don't let the strut escape the fragmentation context and get lost. |
- // TODO(mstensho): If we're in a nested fragmentation context, we should |
- // ideally convert and propagate the strut to the outer fragmentation |
- // context, so that the inner one is fully pushed to the next outer |
- // fragmentainer, instead of taking up unusable space in the previous one. |
- // But currently we have no mechanism in place to handle this. |
+ // TODO(mstensho): If we're in a nested fragmentation context, we should ideally convert |
+ // and propagate the strut to the outer fragmentation context, so that the inner one is |
+ // fully pushed to the next outer fragmentainer, instead of taking up unusable space in the |
+ // previous one. But currently we have no mechanism in place to handle this. |
return false; |
} |
LayoutBlock* containingBlock = this->containingBlock(); |
@@ -4024,17 +3856,15 @@ |
void LayoutBlockFlow::positionSpannerDescendant( |
LayoutMultiColumnSpannerPlaceholder& child) { |
LayoutBox& spanner = *child.layoutObjectInFlowThread(); |
- // FIXME: |spanner| is a descendant, but never a direct child, so the names |
- // here are bad, if nothing else. |
+ // FIXME: |spanner| is a descendant, but never a direct child, so the names here are bad, if |
+ // nothing else. |
setLogicalTopForChild(spanner, child.logicalTop()); |
determineLogicalLeftPositionForChild(spanner); |
} |
bool LayoutBlockFlow::avoidsFloats() const { |
- // Floats can't intrude into our box if we have a non-auto column count or |
- // width. |
- // Note: we need to use LayoutBox::avoidsFloats here since |
- // LayoutBlock::avoidsFloats is always true. |
+ // Floats can't intrude into our box if we have a non-auto column count or width. |
+ // Note: we need to use LayoutBox::avoidsFloats here since LayoutBlock::avoidsFloats is always true. |
return LayoutBox::avoidsFloats() || !style()->hasAutoColumnCount() || |
!style()->hasAutoColumnWidth(); |
} |
@@ -4116,20 +3946,18 @@ |
void LayoutBlockFlow::createOrDestroyMultiColumnFlowThreadIfNeeded( |
const ComputedStyle* oldStyle) { |
- // Paged overflow trumps multicol in this implementation. Ideally, it should |
- // be possible to have both paged overflow and multicol on the same element, |
- // but then we need two flow threads. Anyway, this is nothing to worry about |
- // until we can actually nest multicol properly inside other fragmentation |
- // contexts. |
+ // Paged overflow trumps multicol in this implementation. Ideally, it should be possible to have |
+ // both paged overflow and multicol on the same element, but then we need two flow |
+ // threads. Anyway, this is nothing to worry about until we can actually nest multicol properly |
+ // inside other fragmentation contexts. |
FlowThreadType type = getFlowThreadType(styleRef()); |
if (multiColumnFlowThread()) { |
ASSERT(oldStyle); |
if (type != getFlowThreadType(*oldStyle)) { |
- // If we're no longer to be multicol/paged, destroy the flow thread. Also |
- // destroy it when switching between multicol and paged, since that |
- // affects the column set structure (multicol containers may have |
- // spanners, paged containers may not). |
+ // If we're no longer to be multicol/paged, destroy the flow thread. Also destroy it |
+ // when switching between multicol and paged, since that affects the column set |
+ // structure (multicol containers may have spanners, paged containers may not). |
multiColumnFlowThread()->evacuateAndDestroy(); |
ASSERT(!multiColumnFlowThread()); |
} |
@@ -4138,22 +3966,19 @@ |
if (type == NoFlowThread || multiColumnFlowThread()) |
return; |
- // Ruby elements manage child insertion in a special way, and would mess up |
- // insertion of the flow thread. The flow thread needs to be a direct child of |
- // the multicol block (|this|). |
+ // Ruby elements manage child insertion in a special way, and would mess up insertion of the |
+ // flow thread. The flow thread needs to be a direct child of the multicol block (|this|). |
if (isRuby()) |
return; |
- // Form controls are replaced content, and are therefore not supposed to |
- // support multicol. |
+ // Form controls are replaced content, and are therefore not supposed to support multicol. |
if (isFileUploadControl() || isTextControl() || isListBox()) |
return; |
LayoutMultiColumnFlowThread* flowThread = createMultiColumnFlowThread(type); |
addChild(flowThread); |
- // Check that addChild() put the flow thread as a direct child, and didn't do |
- // fancy things. |
+ // Check that addChild() put the flow thread as a direct child, and didn't do fancy things. |
ASSERT(flowThread->parent() == this); |
flowThread->populate(); |
@@ -4221,8 +4046,7 @@ |
} |
} |
- // FIXME: Glyph overflow will get lost in this case, but not really a big |
- // deal. |
+ // FIXME: Glyph overflow will get lost in this case, but not really a big deal. |
GlyphOverflowAndFallbackFontsMap textBoxDataMap; |
for (ListHashSet<RootInlineBox*>::const_iterator it = lineBoxes.begin(); |
it != lineBoxes.end(); ++it) { |
@@ -4246,8 +4070,7 @@ |
} |
} |
- // FIXME: Glyph overflow will get lost in this case, but not really a big |
- // deal. |
+ // FIXME: Glyph overflow will get lost in this case, but not really a big deal. |
GlyphOverflowAndFallbackFontsMap textBoxDataMap; |
for (ListHashSet<RootInlineBox*>::const_iterator it = lineBoxes.begin(); |
it != lineBoxes.end(); ++it) { |
@@ -4281,8 +4104,7 @@ |
bool linesAreFlipped = style()->isFlippedLinesWritingMode(); |
bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); |
- // look for the closest line box in the root box which is at the passed-in y |
- // coordinate |
+ // look for the closest line box in the root box which is at the passed-in y coordinate |
InlineBox* closestBox = nullptr; |
RootInlineBox* firstRootBoxWithChildren = nullptr; |
RootInlineBox* lastRootBoxWithChildren = nullptr; |
@@ -4353,8 +4175,7 @@ |
if (InlineBox* newBox = box->nextLeafChildIgnoringLineBreak()) |
box = newBox; |
} |
- // y coordinate is above first root line box, so return the start of the |
- // first |
+ // y coordinate is above first root line box, so return the start of the first |
return PositionWithAffinity(positionForBox(box, true)); |
} |
} |
@@ -4371,8 +4192,7 @@ |
} |
if (lastRootBoxWithChildren) { |
- // We hit this case for Mac behavior when the Y coordinate is below the last |
- // box. |
+ // We hit this case for Mac behavior when the Y coordinate is below the last box. |
ASSERT(moveCaretToBoundary); |
InlineBox* logicallyLastBox; |
if (lastRootBoxWithChildren->getLogicalEndBoxWithNode(logicallyLastBox)) |
@@ -4405,16 +4225,15 @@ |
Vector<LayoutRect>& rects, |
const LayoutPoint& additionalOffset, |
IncludeBlockVisualOverflowOrNot includeBlockOverflows) const { |
- // For blocks inside inlines, we go ahead and include margins so that we run |
- // right up to the inline boxes above and below us (thus getting merged with |
- // them to form a single irregular shape). |
+ // For blocks inside inlines, we go ahead and include margins so that we run right up to the |
+ // inline boxes above and below us (thus getting merged with them to form a single irregular |
+ // shape). |
const LayoutInline* inlineElementContinuation = |
this->inlineElementContinuation(); |
if (inlineElementContinuation) { |
// FIXME: This check really isn't accurate. |
bool nextInlineHasLineBox = inlineElementContinuation->firstLineBox(); |
- // FIXME: This is wrong. The principal layoutObject may not be the |
- // continuation preceding this block. |
+ // FIXME: This is wrong. The principal layoutObject may not be the continuation preceding this block. |
// FIXME: This is wrong for vertical writing-modes. |
// https://bugs.webkit.org/show_bug.cgi?id=46781 |
bool prevInlineHasLineBox = |