Index: third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp b/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp |
index af5405f380b0c3bbbf88c9c7dcb0f90b7d0b1b74..93715aa4d673007059b7cb7992a9dd445650b0c9 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp |
@@ -1,7 +1,6 @@ |
/* |
* Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
- * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
- * All right reserved. |
+ * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All right reserved. |
* Copyright (C) 2010 Google Inc. All rights reserved. |
* |
* This library is free software; you can redistribute it and/or |
@@ -146,9 +145,8 @@ |
LineLayoutText text = LineLayoutText(run.m_lineLayoutItem); |
InlineTextBox* textBox = |
text.createInlineTextBox(run.m_start, run.m_stop - run.m_start); |
- // We only treat a box as text for a <br> if we are on a line by ourself or in |
- // strict mode (Note the use of strict mode. In "almost strict" mode, we |
- // don't treat the box for <br> as text.) |
+ // We only treat a box as text for a <br> if we are on a line by ourself or in strict mode |
+ // (Note the use of strict mode. In "almost strict" mode, we don't treat the box for <br> as text.) |
if (text.isBR()) |
textBox->setIsText(isOnlyRun || text.document().inNoQuirksMode()); |
textBox->setDirOverride( |
@@ -195,12 +193,11 @@ |
parentBox = inlineFlow ? inlineFlow.lastLineBox() |
: LineLayoutBlockFlow(lineLayoutItem).lastLineBox(); |
- // If this box or its ancestor is constructed then it is from a previous |
- // line, and we need to make a new box for our line. If this box or its |
- // ancestor is unconstructed but it has something following it on the line, |
- // then we know we have to make a new box as well. In this situation our |
- // inline has actually been split in two on the same line (this can happen |
- // with very fancy language mixtures). |
+ // If this box or its ancestor is constructed then it is from a previous line, and we need |
+ // to make a new box for our line. If this box or its ancestor is unconstructed but it has |
+ // something following it on the line, then we know we have to make a new box |
+ // as well. In this situation our inline has actually been split in two on |
+ // the same line (this can happen with very fancy language mixtures). |
bool constructedNewBox = false; |
bool allowedToConstructNewBox = |
!inlineFlow || inlineFlow.alwaysCreateLineBoxes(); |
@@ -223,8 +220,8 @@ |
result = parentBox; |
// If we have hit the block itself, then |box| represents the root |
- // inline box for the line, and it doesn't have to be appended to any |
- // parent inline. |
+ // inline box for the line, and it doesn't have to be appended to any parent |
+ // inline. |
if (childBox) |
parentBox->addToLine(childBox); |
@@ -234,8 +231,8 @@ |
childBox = parentBox; |
} |
- // If we've exceeded our line depth, then jump straight to the root and skip |
- // all the remaining intermediate inline flows. |
+ // If we've exceeded our line depth, then jump straight to the root and skip all the remaining |
+ // intermediate inline flows. |
lineLayoutItem = (++lineDepth >= cMaxLineDepth) ? LineLayoutItem(this) |
: lineLayoutItem.parent(); |
@@ -309,13 +306,12 @@ |
rootHasSelectedChildren = true; |
// If we have no parent box yet, or if the run is not simply a sibling, |
- // then we need to construct inline boxes as necessary to properly enclose |
- // the run's inline box. Segments can only be siblings at the root level, as |
+ // then we need to construct inline boxes as necessary to properly enclose the |
+ // run's inline box. Segments can only be siblings at the root level, as |
// they are positioned separately. |
if (!parentBox || |
(parentBox->getLineLayoutItem() != r->m_lineLayoutItem.parent())) { |
- // Create new inline boxes all the way back to the appropriate insertion |
- // point. |
+ // Create new inline boxes all the way back to the appropriate insertion point. |
parentBox = createLineBoxes(r->m_lineLayoutItem.parent(), lineInfo, box); |
} else { |
// Append the inline box to this line. |
@@ -334,8 +330,8 @@ |
// be the last continuation of our line list. |
ASSERT(lastLineBox() && !lastLineBox()->isConstructed()); |
- // Set the m_selectedChildren flag on the root inline box if one of the leaf |
- // inline box from the bidi runs walk above has a selection state. |
+ // Set the m_selectedChildren flag on the root inline box if one of the leaf inline box |
+ // from the bidi runs walk above has a selection state. |
if (rootHasSelectedChildren) |
lastLineBox()->root().setHasSelectedChildren(true); |
@@ -394,8 +390,7 @@ |
LayoutUnit totalLogicalWidth, |
LayoutUnit availableLogicalWidth) { |
// The direction of the block should determine what happens with wide lines. |
- // In particular with RTL blocks, wide lines should still spill out to the |
- // left. |
+ // In particular with RTL blocks, wide lines should still spill out to the left. |
if (isLeftToRightDirection) { |
if (totalLogicalWidth > availableLogicalWidth && trailingSpaceRun) |
trailingSpaceRun->m_box->setLogicalWidth(std::max( |
@@ -417,8 +412,8 @@ |
LayoutUnit& totalLogicalWidth, |
LayoutUnit availableLogicalWidth) { |
// Wide lines spill out of the block based off direction. |
- // So even if text-align is right, if direction is LTR, wide lines should |
- // overflow out of the right side of the block. |
+ // So even if text-align is right, if direction is LTR, wide lines should overflow out of the right |
+ // side of the block. |
if (isLeftToRightDirection) { |
if (trailingSpaceRun) { |
totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); |
@@ -548,8 +543,8 @@ |
font.getFontDescription().getTypesettingFeatures() & Kerning; |
#if OS(MACOSX) |
- // FIXME: Having any font feature settings enabled can lead to selection gaps |
- // on Chromium-mac. https://bugs.webkit.org/show_bug.cgi?id=113418 |
+ // FIXME: Having any font feature settings enabled can lead to selection gaps on |
+ // Chromium-mac. https://bugs.webkit.org/show_bug.cgi?id=113418 |
bool canUseCachedWordMeasurements = |
font.canShapeWordByWord() && !font.getFontDescription().featureSettings(); |
#else |
@@ -602,17 +597,14 @@ |
} |
} |
- // Don't put this into 'else' part of the above 'if' because |
- // canUseCachedWordMeasurements may be modified in the 'if' block. |
+ // Don't put this into 'else' part of the above 'if' because canUseCachedWordMeasurements may be modified in the 'if' block. |
if (!canUseCachedWordMeasurements) |
measuredWidth = layoutText.width( |
run->m_start, run->m_stop - run->m_start, xPos, run->direction(), |
lineInfo.isFirstLine(), &fallbackFonts, &glyphBounds); |
- // Negative word-spacing and/or letter-spacing may cause some glyphs to |
- // overflow the left boundary and result negative measured width. Reset |
- // measured width to 0 and adjust glyph bounds accordingly to cover the |
- // overflow. |
+ // Negative word-spacing and/or letter-spacing may cause some glyphs to overflow the left boundary and result |
+ // negative measured width. Reset measured width to 0 and adjust glyph bounds accordingly to cover the overflow. |
if (measuredWidth < 0) { |
if (measuredWidth < glyphBounds.x()) { |
glyphBounds.expand(glyphBounds.x() - measuredWidth, 0); |
@@ -667,9 +659,9 @@ |
direction = style()->direction(); |
// Armed with the total width of the line (without justification), |
- // we now examine our text-align property in order to determine where to |
- // position the objects horizontally. The total width of the line can be |
- // increased if we end up justifying text. |
+ // we now examine our text-align property in order to determine where to position the |
+ // objects horizontally. The total width of the line can be increased if we end up |
+ // justifying text. |
switch (textAlign) { |
case LEFT: |
case WEBKIT_LEFT: |
@@ -753,12 +745,10 @@ |
ETextAlign textAlign = |
textAlignmentForLine(!reachedEnd && !lineBox->endsWithBreak()); |
- // CSS 2.1: "'Text-indent' only affects a line if it is the first formatted |
- // line of an element. For example, the first line of an anonymous block |
+ // CSS 2.1: "'Text-indent' only affects a line if it is the first formatted line of an element. For example, the first line of an anonymous block |
// box is only affected if it is the first child of its parent element." |
- // CSS3 "text-indent", "each-line" affects the first line of the block |
- // container as well as each line after a forced line break, but does not |
- // affect lines after a soft wrap break. |
+ // CSS3 "text-indent", "each-line" affects the first line of the block container as well as each line after a forced line break, |
+ // but does not affect lines after a soft wrap break. |
bool isFirstLine = |
lineInfo.isFirstLine() && |
!(isAnonymousBlock() && parent()->slowFirstChild() != this); |
@@ -785,8 +775,8 @@ |
lineBox, lineInfo, textAlign, lineLogicalLeft, availableLogicalWidth, |
firstRun, trailingSpaceRun, textBoxDataMap, verticalPositionCache, |
wordMeasurements); |
- // The widths of all runs are now known. We can now place every inline box |
- // (and compute accurate widths for the inline flow boxes). |
+ // The widths of all runs are now known. We can now place every inline box (and |
+ // compute accurate widths for the inline flow boxes). |
needsWordSpacing = lineBox->isLeftToRightDirection() ? false : true; |
lineBox->placeBoxesInInlineDirection(lineLogicalLeft, needsWordSpacing); |
} |
@@ -814,10 +804,9 @@ |
for (; r; r = r->next()) { |
if (!r->m_box || r->m_lineLayoutItem.isOutOfFlowPositioned() || |
r->m_box->isLineBreak()) { |
- continue; // Positioned objects are only participating to figure out |
- // their correct static x position. They have no effect on the |
- // width. Similarly, line break boxes have no effect on the |
- // width. |
+ continue; // Positioned objects are only participating to figure out their |
+ // correct static x position. They have no effect on the width. |
+ // Similarly, line break boxes have no effect on the width. |
} |
if (r->m_lineLayoutItem.isText()) { |
LineLayoutText rt(r->m_lineLayoutItem); |
@@ -909,8 +898,7 @@ |
lastRootBox()->appendFloat(floatingObject.layoutObject()); |
} |
-// This function constructs line boxes for all of the text runs in the resolver |
-// and computes their position. |
+// This function constructs line boxes for all of the text runs in the resolver and computes their position. |
RootInlineBox* LayoutBlockFlow::createLineBoxesFromBidiRuns( |
unsigned bidiLevel, |
BidiRunList<BidiRun>& bidiRuns, |
@@ -968,9 +956,8 @@ |
RootInlineBox* stopLine = 0) { |
RootInlineBox* boxToDelete = startLine; |
while (boxToDelete && boxToDelete != stopLine) { |
- // Note: deleteLineRange(firstRootBox()) is not identical to |
- // deleteLineBoxTree(). deleteLineBoxTree uses nextLineBox() instead of |
- // nextRootBox() when traversing. |
+ // Note: deleteLineRange(firstRootBox()) is not identical to deleteLineBoxTree(). |
+ // deleteLineBoxTree uses nextLineBox() instead of nextRootBox() when traversing. |
RootInlineBox* next = boxToDelete->nextRootBox(); |
boxToDelete->deleteLine(); |
boxToDelete = next; |
@@ -985,9 +972,8 @@ |
if (containsFloats()) |
layoutState.setLastFloat(m_floatingObjects->set().last().get()); |
- // We also find the first clean line and extract these lines. We will add |
- // them back if we determine that we're able to synchronize after handling all |
- // our dirty lines. |
+ // We also find the first clean line and extract these lines. We will add them back |
+ // if we determine that we're able to synchronize after handling all our dirty lines. |
InlineIterator cleanLineStart; |
BidiStatus cleanLineBidiStatus; |
if (!layoutState.isFullLayout() && startLine) |
@@ -1003,8 +989,7 @@ |
markDirtyFloatsForPaintInvalidation(layoutState.floats()); |
} |
-// Before restarting the layout loop with a new logicalHeight, remove all floats |
-// that were added and reset the resolver. |
+// Before restarting the layout loop with a new logicalHeight, remove all floats that were added and reset the resolver. |
inline const InlineIterator& LayoutBlockFlow::restartLayoutRunsAndFloatsInRange( |
LayoutUnit oldLogicalHeight, |
LayoutUnit newLogicalHeight, |
@@ -1035,8 +1020,7 @@ |
} |
for (; it != end; ++it) { |
FloatingObject& floatingObject = *it->get(); |
- // If we've reached the start of clean lines any remaining floating children |
- // belong to them. |
+ // If we've reached the start of clean lines any remaining floating children belong to them. |
if (cleanLineStart.getLineLayoutItem().isEqual( |
floatingObject.layoutObject()) && |
layoutState.endLine()) { |
@@ -1078,8 +1062,7 @@ |
LayoutTextInfo layoutTextInfo; |
VerticalPositionCache verticalPositionCache; |
- // Pagination may require us to delete and re-create a line due to floats. |
- // When this happens, |
+ // Pagination may require us to delete and re-create a line due to floats. When this happens, |
// we need to store the pagination strut in the meantime. |
LayoutUnit paginationStrutFromDeletedLine; |
@@ -1089,8 +1072,7 @@ |
// The runs from the previous line should have been cleaned up. |
ASSERT(!resolver.runs().runCount()); |
- // FIXME: Is this check necessary before the first iteration or can it be |
- // moved to the end? |
+ // FIXME: Is this check necessary before the first iteration or can it be moved to the end? |
if (layoutState.endLine()) { |
layoutState.setEndLineMatched(layoutState.endLineMatched() || |
matchedEndLine(layoutState, resolver, |
@@ -1118,12 +1100,11 @@ |
layoutTextInfo, wordMeasurements); |
layoutTextInfo.m_lineBreakIterator.resetPriorContext(); |
if (resolver.position().atEnd()) { |
- // FIXME: We shouldn't be creating any runs in nextLineBreak to begin |
- // with! Once BidiRunList is separated from BidiResolver this will not be |
- // needed. |
+ // FIXME: We shouldn't be creating any runs in nextLineBreak to begin with! |
+ // Once BidiRunList is separated from BidiResolver this will not be needed. |
resolver.runs().deleteRuns(); |
- resolver.markCurrentRunEmpty(); // FIXME: This can probably be replaced |
- // by an ASSERT (or just removed). |
+ resolver |
+ .markCurrentRunEmpty(); // FIXME: This can probably be replaced by an ASSERT (or just removed). |
resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0), 0); |
break; |
} |
@@ -1152,8 +1133,7 @@ |
resolver.setStatus( |
BidiStatus(direction, isOverride(styleToUse.unicodeBidi()))); |
} |
- // FIXME: This ownership is reversed. We should own the BidiRunList and |
- // pass it to createBidiRunsForLine. |
+ // FIXME: This ownership is reversed. We should own the BidiRunList and pass it to createBidiRunsForLine. |
BidiRunList<BidiRun>& bidiRuns = resolver.runs(); |
constructBidiRunsForLine( |
resolver, bidiRuns, endOfLine, override, |
@@ -1166,8 +1146,7 @@ |
bidiRuns.logicallyLastRun()->m_hasHyphen = true; |
// Now that the runs have been ordered, we create the line boxes. |
- // At the same time we figure out where border/padding/margin should be |
- // applied for |
+ // At the same time we figure out where border/padding/margin should be applied for |
// inline flow boxes. |
LayoutUnit oldLogicalHeight = logicalHeight(); |
@@ -1177,11 +1156,10 @@ |
wordMeasurements); |
bidiRuns.deleteRuns(); |
- resolver.markCurrentRunEmpty(); // FIXME: This can probably be replaced |
- // by an ASSERT (or just removed). |
- |
- // If we decided to re-create the line due to pagination, we better have a |
- // new line now. |
+ resolver |
+ .markCurrentRunEmpty(); // FIXME: This can probably be replaced by an ASSERT (or just removed). |
+ |
+ // If we decided to re-create the line due to pagination, we better have a new line now. |
ASSERT(lineBox || !paginationStrutFromDeletedLine); |
if (lineBox) { |
@@ -1189,10 +1167,9 @@ |
endOfLine.offset(), resolver.status()); |
if (paginated) { |
if (paginationStrutFromDeletedLine) { |
- // This is a line that got re-created because it got pushed to the |
- // next fragmentainer, and there were floats in the vicinity that |
- // affected the available width. |
- // Restore the pagination info for this line. |
+ // This is a line that got re-created because it got pushed to the next fragmentainer, and there |
+ // were floats in the vicinity that affected the available width. Restore the pagination info |
+ // for this line. |
lineBox->setIsFirstAfterPageBreak(true); |
lineBox->setPaginationStrut(paginationStrutFromDeletedLine); |
paginationStrutFromDeletedLine = LayoutUnit(); |
@@ -1210,14 +1187,13 @@ |
layoutState.lineInfo().isFirstLine() |
? IndentText |
: DoNotIndentText) != oldLineWidth) { |
- // We have to delete this line, remove all floats that got |
- // added, and let line layout re-run. We had just calculated the |
- // pagination strut for this line, and we need to stow it away, |
- // so that we can re-apply it when the new line has been created. |
+ // We have to delete this line, remove all floats that got added, and let line layout |
+ // re-run. We had just calculated the pagination strut for this line, and we need to |
+ // stow it away, so that we can re-apply it when the new line has been created. |
paginationStrutFromDeletedLine = lineBox->paginationStrut(); |
ASSERT(paginationStrutFromDeletedLine); |
- // We're also going to assume that we're right after a page |
- // break when re-creating this line, so it better be so. |
+ // We're also going to assume that we're right after a page break when re-creating this |
+ // line, so it better be so. |
ASSERT(lineBox->isFirstAfterPageBreak()); |
lineBox->deleteLine(); |
endOfLine = restartLayoutRunsAndFloatsInRange( |
@@ -1235,10 +1211,9 @@ |
if (!paginationStrutFromDeletedLine) { |
for (const auto& positionedObject : lineBreaker.positionedObjects()) { |
if (positionedObject.style()->isOriginalDisplayInlineType()) { |
- // Auto-positioend "inline" out-of-flow objects have already been |
- // positioned, but if we're paginated, we need to update their |
- // position now, since the line they "belong" to may have been pushed |
- // by a pagination strut. |
+ // Auto-positioend "inline" out-of-flow objects have already been positioned, |
+ // but if we're paginated, we need to update their position now, since the line |
+ // they "belong" to may have been pushed by a pagination strut. |
if (paginated && lineBox) |
positionedObject.layer()->setStaticBlockPosition( |
lineBox->lineTopWithLeading()); |
@@ -1269,10 +1244,9 @@ |
// The resolver runs should have been cleared, otherwise they're leaking. |
ASSERT(!resolver.runs().runCount()); |
- // In case we already adjusted the line positions during this layout to avoid |
- // widows then we need to ignore the possibility of having a new widows |
- // situation. Otherwise, we risk leaving empty containers which is against the |
- // block fragmentation principles. |
+ // In case we already adjusted the line positions during this layout to avoid widows |
+ // then we need to ignore the possibility of having a new widows situation. |
+ // Otherwise, we risk leaving empty containers which is against the block fragmentation principles. |
if (paginated && style()->widows() > 1 && !didBreakAtLineToAvoidWidow()) { |
// Check the line boxes to make sure we didn't create unacceptable widows. |
// However, we'll prioritize orphans - so nothing we do here should create |
@@ -1311,12 +1285,11 @@ |
lineBox = lineBox->prevRootBox(); |
} |
- // If there was an explicit value for orphans, respect that. If not, we |
- // still shouldn't create a situation where we make an orphan bigger than |
- // the initial value. This means that setting widows implies we also care |
- // about orphans, but given the specification says the initial orphan |
- // value is non-zero, this is ok. The author is always free to set orphans |
- // explicitly as well. |
+ // If there was an explicit value for orphans, respect that. If not, we still |
+ // shouldn't create a situation where we make an orphan bigger than the initial value. |
+ // This means that setting widows implies we also care about orphans, but given |
+ // the specification says the initial orphan value is non-zero, this is ok. The |
+ // author is always free to set orphans explicitly as well. |
int orphans = style()->orphans(); |
int numLinesAvailable = numLinesInPreviousPage - orphans; |
if (numLinesAvailable <= 0) |
@@ -1328,8 +1301,7 @@ |
for (int i = 0; i < numLinesToTake; ++i) |
lineBox = lineBox->prevRootBox(); |
- // We now want to break at this line. Remember for next layout and trigger |
- // relayout. |
+ // We now want to break at this line. Remember for next layout and trigger relayout. |
setBreakAtLineToAvoidWidow(lineCount(lineBox)); |
markLinesDirtyInBlockRange(lastRootBox()->lineBottomWithLeading(), |
lineBox->lineBottomWithLeading(), lineBox); |
@@ -1344,8 +1316,7 @@ |
if (layoutState.endLineMatched()) { |
bool paginated = |
view()->layoutState() && view()->layoutState()->isPaginated(); |
- // Attach all the remaining lines, and then adjust their y-positions as |
- // needed. |
+ // Attach all the remaining lines, and then adjust their y-positions as needed. |
LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop(); |
for (RootInlineBox* line = layoutState.endLine(); line; |
line = line->nextRootBox()) { |
@@ -1374,9 +1345,8 @@ |
} |
} |
- // In case we have a float on the last line, it might not be positioned up to |
- // now. This has to be done before adding in the bottom border/padding, or the |
- // float will |
+ // In case we have a float on the last line, it might not be positioned up to now. |
+ // This has to be done before adding in the bottom border/padding, or the float will |
// include the padding incorrectly. -dwh |
if (positionNewFloats() && lastRootBox()) |
appendFloatsToLastLine(layoutState, InlineIterator(), InlineBidiResolver(), |
@@ -1386,9 +1356,9 @@ |
void LayoutBlockFlow::markDirtyFloatsForPaintInvalidation( |
Vector<FloatWithRect>& floats) { |
size_t floatCount = floats.size(); |
- // Floats that did not have layout did not paint invalidations when we laid |
- // them out. They would have painted by now if they had moved, but if they |
- // stayed at (0, 0), they still need to be painted. |
+ // Floats that did not have layout did not paint invalidations when we laid them out. They would have |
+ // painted by now if they had moved, but if they stayed at (0, 0), they still need to be |
+ // painted. |
for (size_t i = 0; i < floatCount; ++i) { |
LayoutBox* f = floats[i].object; |
if (!floats[i].everHadLayout) { |
@@ -1400,17 +1370,15 @@ |
positionNewFloats(); |
} |
-// InlineMinMaxIterator is a class that will iterate over all layout objects |
-// that contribute to inline min/max width calculations. Note the following |
-// about the way it walks: |
-// (1) Positioned content is skipped (since it does not contribute to min/max |
-// width of a block) |
-// (2) We do not drill into the children of floats or replaced elements, since |
-// you can't break in the middle of such an element. |
-// (3) Inline flows (e.g., <a>, <span>, <i>) are walked twice, since each side |
-// can have distinct borders/margin/padding that contribute to the min/max |
-// width. |
struct InlineMinMaxIterator { |
+ /* InlineMinMaxIterator is a class that will iterate over all layout objects that contribute to |
+ inline min/max width calculations. Note the following about the way it walks: |
+ (1) Positioned content is skipped (since it does not contribute to min/max width of a block) |
+ (2) We do not drill into the children of floats or replaced elements, since you can't break |
+ in the middle of such an element. |
+ (3) Inline flows (e.g., <a>, <span>, <i>) are walked twice, since each side can have |
+ distinct borders/margin/padding that contribute to the min/max width. |
+*/ |
LayoutObject* parent; |
LayoutObject* current; |
bool endOfInline; |
@@ -1520,10 +1488,10 @@ |
} |
} |
-// When converting between floating point and LayoutUnits we risk losing |
-// precision with each conversion. When this occurs while accumulating our |
-// preferred widths, we can wind up with a line width that's larger than our |
-// maxPreferredWidth due to pure float accumulation. |
+// When converting between floating point and LayoutUnits we risk losing precision |
+// with each conversion. When this occurs while accumulating our preferred widths, |
+// we can wind up with a line width that's larger than our maxPreferredWidth due to |
+// pure float accumulation. |
static inline LayoutUnit adjustFloatForSubPixelLayout(float value) { |
return LayoutUnit::fromFloatCeil(value); |
} |
@@ -1556,8 +1524,7 @@ |
} |
// FIXME: This function should be broken into something less monolithic. |
-// FIXME: The main loop here is very similar to LineBreaker::nextSegmentBreak. |
-// They can probably reuse code. |
+// FIXME: The main loop here is very similar to LineBreaker::nextSegmentBreak. They can probably reuse code. |
DISABLE_CFI_PERF |
void LayoutBlockFlow::computeInlinePreferredLogicalWidths( |
LayoutUnit& minLogicalWidth, |
@@ -1575,10 +1542,9 @@ |
bool stripFrontSpaces = true; |
LayoutObject* trailingSpaceChild = nullptr; |
- // Firefox and Opera will allow a table cell to grow to fit an image inside it |
- // under very specific cirucumstances (in order to match common WinIE |
- // layouts). Not supporting the quirk has caused us to mis-layout some real |
- // sites. (See Bugzilla 10517.) |
+ // Firefox and Opera will allow a table cell to grow to fit an image inside it under |
+ // very specific cirucumstances (in order to match common WinIE layouts). |
+ // Not supporting the quirk has caused us to mis-layout some real sites. (See Bugzilla 10517.) |
bool allowImagesToBreak = !document().inQuirksMode() || !isTableCell() || |
!styleToUse.logicalWidth().isIntrinsicOrAuto(); |
@@ -1606,39 +1572,37 @@ |
// terminate our current line. Each discrete chunk can become |
// the new min-width, if it is the widest chunk seen so far, and |
// it can also become the max-width. |
- // |
+ |
// Children fall into three categories: |
// (1) An inline flow object. These objects always have a min/max of 0, |
- // and are included in the iteration solely so that their margins can |
- // be added in. |
+ // and are included in the iteration solely so that their margins can |
+ // be added in. |
// |
- // (2) An inline non-text non-flow object, e.g., an inline replaced |
- // element. These objects can always be on a line by themselves, so in |
- // this situation we need to go ahead and break the current line, and |
- // then add in our own margins and min/max width on its own line, and |
- // then terminate the line. |
+ // (2) An inline non-text non-flow object, e.g., an inline replaced element. |
+ // These objects can always be on a line by themselves, so in this situation |
+ // we need to go ahead and break the current line, and then add in our own |
+ // margins and min/max width on its own line, and then terminate the line. |
// |
- // (3) A text object. Text runs can have breakable characters at the |
- // start, the middle or the end. They may also lose whitespace off the |
- // front if we're already ignoring whitespace. In order to compute |
- // accurate min-width information, we need three pieces of |
- // information. |
- // (a) the min-width of the first non-breakable run. Should be 0 if |
- // the text string starts with whitespace. |
- // (b) the min-width of the last non-breakable run. Should be 0 if the |
- // text string ends with whitespace. |
- // (c) the min/max width of the string (trimmed for whitespace). |
+ // (3) A text object. Text runs can have breakable characters at the start, |
+ // the middle or the end. They may also lose whitespace off the front if |
+ // we're already ignoring whitespace. In order to compute accurate min-width |
+ // information, we need three pieces of information. |
+ // (a) the min-width of the first non-breakable run. Should be 0 if the text string |
+ // starts with whitespace. |
+ // (b) the min-width of the last non-breakable run. Should be 0 if the text string |
+ // ends with whitespace. |
+ // (c) the min/max width of the string (trimmed for whitespace). |
// |
// If the text string starts with whitespace, then we need to go ahead and |
- // terminate our current line (unless we're already in a whitespace |
- // stripping mode. |
+ // terminate our current line (unless we're already in a whitespace stripping |
+ // mode. |
// |
- // If the text string has a breakable character in the middle, but didn't |
- // start with whitespace, then we add the width of the first non-breakable |
- // run and then end the current line. We then need to use the intermediate |
- // min/max width values (if any of them are larger than our current |
- // min/max). We then look at the width of the last non-breakable run and |
- // use that to start a new line (unless we end in whitespace). |
+ // If the text string has a breakable character in the middle, but didn't start |
+ // with whitespace, then we add the width of the first non-breakable run and |
+ // then end the current line. We then need to use the intermediate min/max width |
+ // values (if any of them are larger than our current min/max). We then look at |
+ // the width of the last non-breakable run and use that to start a new line |
+ // (unless we end in whitespace). |
LayoutUnit childMin; |
LayoutUnit childMax; |
@@ -1688,8 +1652,7 @@ |
inlineMin = LayoutUnit(); |
} |
- // If we're supposed to clear the previous float, then terminate |
- // maxwidth as well. |
+ // If we're supposed to clear the previous float, then terminate maxwidth as well. |
if (clearPreviousFloat) { |
maxLogicalWidth = std::max(maxLogicalWidth, inlineMax); |
inlineMax = LayoutUnit(); |
@@ -1759,8 +1722,7 @@ |
lastLineMaxWidth, childMin, childMax, |
stripFrontSpaces, styleToUse.direction()); |
- // This text object will not be laid out, but it may still provide a |
- // breaking opportunity. |
+ // This text object will not be laid out, but it may still provide a breaking opportunity. |
if (!hasBreak && !childMax) { |
if (autoWrap && (hasBreakableStart || hasBreakableEnd)) { |
minLogicalWidth = std::max(minLogicalWidth, inlineMin); |
@@ -1781,10 +1743,9 @@ |
childMin += ti; |
firstLineMinWidth += ti; |
- // It the text indent negative and larger than the child minimum, we |
- // re-use the remainder in future minimum calculations, but using the |
- // negative value again on the maximum will lead to under-counting the |
- // max pref width. |
+ // It the text indent negative and larger than the child minimum, we re-use the remainder |
+ // in future minimum calculations, but using the negative value again on the maximum |
+ // will lead to under-counting the max pref width. |
if (!addedTextIndent) { |
childMax += ti; |
firstLineMaxWidth += ti; |
@@ -1894,12 +1855,11 @@ |
lineBoxes()->deleteLineBoxes(); |
} |
- // Text truncation kicks in if overflow isn't visible and text-overflow isn't |
- // 'clip'. If this is an anonymous block, we have to examine the parent. |
- // FIXME: CSS3 says that descendants that are clipped must also know how to |
- // truncate. This is insanely difficult to figure out in general (especially |
- // in the middle of doing layout), so we only handle the simple case of an |
- // anonymous block truncating when its parent is clipped. |
+ // Text truncation kicks in if overflow isn't visible and text-overflow isn't 'clip'. If this is |
+ // an anonymous block, we have to examine the parent. |
+ // FIXME: CSS3 says that descendants that are clipped must also know how to truncate. This is insanely |
+ // difficult to figure out in general (especially in the middle of doing layout), so we only handle the |
+ // simple case of an anonymous block truncating when its parent is clipped. |
bool hasTextOverflow = shouldTruncateOverflowingText(this); |
// Walk all the lines and delete our ellipsis line boxes if they exist. |
@@ -1927,9 +1887,8 @@ |
layoutState.floats().append(FloatWithRect(box)); |
if (box->needsLayout()) { |
box->layout(); |
- // Dirty any lineboxes potentially affected by the float, but don't |
- // search outside this object as we are only interested in dirtying |
- // lineboxes to which we may attach the float. |
+ // Dirty any lineboxes potentially affected by the float, but don't search outside this |
+ // object as we are only interested in dirtying lineboxes to which we may attach the float. |
dirtyLinesFromChangedChild(box, MarkOnlyThis); |
} |
} else if (isFullLayout || o->needsLayout()) { |
@@ -1980,8 +1939,8 @@ |
: VerticalLine, |
PositionOfInteriorLineBoxes)); |
- // See if we have any lines that spill out of our block. If we do, then we |
- // will possibly need to truncate text. |
+ // See if we have any lines that spill out of our block. If we do, then we will possibly need to |
+ // truncate text. |
if (hasTextOverflow) |
checkLinesForTextOverflow(); |
@@ -1997,8 +1956,7 @@ |
RootInlineBox* last = nullptr; |
RootInlineBox* firstLineBoxWithBreakAndClearance = 0; |
- // FIXME: This entire float-checking block needs to be broken into a new |
- // function. |
+ // FIXME: This entire float-checking block needs to be broken into a new function. |
if (!layoutState.isFullLayout()) { |
// Paginate all of the clean lines. |
bool paginated = |
@@ -2011,8 +1969,7 @@ |
adjustLinePositionForPagination(*curr, paginationDelta); |
if (paginationDelta) { |
if (containsFloats() || !layoutState.floats().isEmpty()) { |
- // FIXME: Do better eventually. For now if we ever shift because of |
- // pagination and floats are present just go to a full layout. |
+ // FIXME: Do better eventually. For now if we ever shift because of pagination and floats are present just go to a full layout. |
layoutState.markForFullLayout(); |
break; |
} |
@@ -2020,9 +1977,7 @@ |
} |
} |
- // If the linebox breaks cleanly and with clearance then dirty from at |
- // least this point onwards so that we can clear the correct floats |
- // without difficulty. |
+ // If the linebox breaks cleanly and with clearance then dirty from at least this point onwards so that we can clear the correct floats without difficulty. |
if (!firstLineBoxWithBreakAndClearance && lineBoxHasBRWithClearance(curr)) |
firstLineBoxWithBreakAndClearance = curr; |
@@ -2032,8 +1987,7 @@ |
} |
if (layoutState.isFullLayout()) { |
- // If we encountered a new float and have inline children, mark ourself to |
- // force us to issue paint invalidations. |
+ // If we encountered a new float and have inline children, mark ourself to force us to issue paint invalidations. |
if (layoutState.hasInlineChild() && !selfNeedsLayout()) { |
setNeedsLayoutAndFullPaintInvalidation( |
LayoutInvalidationReason::FloatDescendantChanged, MarkOnlyThis); |
@@ -2123,9 +2077,7 @@ |
} |
bool LayoutBlockFlow::lineBoxHasBRWithClearance(RootInlineBox* curr) { |
- // If the linebox breaks cleanly and with clearance then dirty from at least |
- // this point onwards so that we can clear the correct floats without |
- // difficulty. |
+ // If the linebox breaks cleanly and with clearance then dirty from at least this point onwards so that we can clear the correct floats without difficulty. |
if (!curr->endsWithBreak()) |
return false; |
InlineBox* lastBox = style()->isLeftToRightDirection() |
@@ -2155,8 +2107,8 @@ |
if (!last) |
return; |
- // At this point, |last| is the first line in a run of clean lines that ends |
- // with the last line in the block. |
+ // At this point, |last| is the first line in a run of clean lines that ends with the last line |
+ // in the block. |
RootInlineBox* prev = last->prevRootBox(); |
cleanLineStart = |
@@ -2166,8 +2118,8 @@ |
layoutState.setEndLineLogicalTop(prev->lineBottomWithLeading()); |
for (RootInlineBox* line = last; line; line = line->nextRootBox()) |
- line->extractLine(); // Disconnect all line boxes from their layout objects |
- // while preserving their connections to one another. |
+ line->extractLine(); // Disconnect all line boxes from their layout objects while preserving |
+ // their connections to one another. |
layoutState.setEndLine(last); |
} |
@@ -2182,13 +2134,12 @@ |
bool paginated = |
view()->layoutState() && view()->layoutState()->isPaginated(); |
if (paginated) { |
- // Check all lines from here to the end, and see if the hypothetical new |
- // position for the lines will result |
+ // Check all lines from here to the end, and see if the hypothetical new position for the lines will result |
// in a different available line width. |
for (RootInlineBox* lineBox = layoutState.endLine(); lineBox; |
lineBox = lineBox->nextRootBox()) { |
- // This isn't the real move we're going to do, so don't update the line |
- // box's pagination strut yet. |
+ // This isn't the real move we're going to do, so don't update the line box's pagination |
+ // strut yet. |
LayoutUnit oldPaginationStrut = lineBox->paginationStrut(); |
lineDelta -= oldPaginationStrut; |
adjustLinePositionForPagination(*lineBox, lineDelta); |
@@ -2198,8 +2149,7 @@ |
if (!lineDelta) |
return true; |
- // See if any floats end in the range along which we want to shift the lines |
- // vertically. |
+ // See if any floats end in the range along which we want to shift the lines vertically. |
LayoutUnit logicalTop = |
std::min(logicalHeight(), layoutState.endLineLogicalTop()); |
@@ -2234,8 +2184,8 @@ |
return checkPaginationAndFloatsAtEndLine(layoutState); |
} |
- // The first clean line doesn't match, but we can check a handful of following |
- // lines to try to match back up. |
+ // The first clean line doesn't match, but we can check a handful of following lines to try |
+ // to match back up. |
static int numLines = 8; // The # of lines we're willing to match against. |
RootInlineBox* originalEndLine = layoutState.endLine(); |
RootInlineBox* line = originalEndLine; |
@@ -2278,8 +2228,7 @@ |
void LayoutBlockFlow::addOverflowFromInlineChildren() { |
LayoutUnit endPadding = hasOverflowClip() ? paddingEnd() : LayoutUnit(); |
- // FIXME: Need to find another way to do this, since scrollbars could show |
- // when we don't want them to. |
+ // FIXME: Need to find another way to do this, since scrollbars could show when we don't want them to. |
if (hasOverflowClip() && !endPadding && node() && |
isRootEditableElement(*node()) && style()->isLeftToRightDirection()) |
endPadding = LayoutUnit(1); |
@@ -2293,8 +2242,7 @@ |
if (!containsInlineWithOutlineAndContinuation()) |
return; |
- // Add outline rects of continuations of descendant inlines into visual |
- // overflow of this block. |
+ // Add outline rects of continuations of descendant inlines into visual overflow of this block. |
LayoutRect outlineBoundsOfAllContinuations; |
for (InlineWalker walker(LineLayoutBlockFlow(this)); !walker.atEnd(); |
walker.advance()) { |
@@ -2322,8 +2270,7 @@ |
if (curr->hasEllipsisBox()) { |
curr->clearTruncation(); |
- // Shift the line back where it belongs if we cannot accommodate an |
- // ellipsis. |
+ // Shift the line back where it belongs if we cannot accommodate an ellipsis. |
LayoutUnit logicalLeft = |
logicalLeftOffsetForLine(curr->lineTop(), indentText); |
LayoutUnit availableLogicalWidth = |
@@ -2354,14 +2301,13 @@ |
AtomicString& selectedEllipsisStr = ellipsisStr; |
const Font& firstLineFont = firstLineStyle()->font(); |
- // FIXME: We should probably not hard-code the direction here. |
- // https://crbug.com/333004 |
+ // FIXME: We should probably not hard-code the direction here. https://crbug.com/333004 |
TextDirection ellipsisDirection = LTR; |
float firstLineEllipsisWidth = 0; |
float ellipsisWidth = 0; |
- // As per CSS3 http://www.w3.org/TR/2003/CR-css3-text-20030514/ sequence of |
- // three Full Stops (002E) can be used. |
+ // As per CSS3 http://www.w3.org/TR/2003/CR-css3-text-20030514/ sequence of three |
+ // Full Stops (002E) can be used. |
ASSERT(firstLineFont.primaryFont()); |
if (firstLineFont.primaryFont()->glyphForCharacter( |
horizontalEllipsisCharacter)) { |
@@ -2391,11 +2337,10 @@ |
} |
} |
- // For LTR text truncation, we want to get the right edge of our padding box, |
- // and then we want to see if the right edge of a line box exceeds that. |
- // For RTL, we use the left edge of the padding box and check the left edge of |
- // the line box to see if it is less Include the scrollbar for overflow |
- // blocks, which means we want to use "contentWidth()". |
+ // For LTR text truncation, we want to get the right edge of our padding box, and then we want to see |
+ // if the right edge of a line box exceeds that. For RTL, we use the left edge of the padding box and |
+ // check the left edge of the line box to see if it is less |
+ // Include the scrollbar for overflow blocks, which means we want to use "contentWidth()" |
bool ltr = style()->isLeftToRightDirection(); |
ETextAlign textAlign = style()->textAlign(); |
IndentTextOrNot indentText = IndentText; |
@@ -2409,11 +2354,10 @@ |
ltr ? currLogicalLeft + curr->logicalWidth() : currLogicalLeft; |
if ((ltr && lineBoxEdge > blockRightEdge) || |
(!ltr && lineBoxEdge < blockLeftEdge)) { |
- // This line spills out of our box in the appropriate direction. Now we |
- // need to see if the line can be truncated. In order for truncation to |
- // be possible, the line must have sufficient space to accommodate our |
- // truncation string, and no replaced elements (images, tables) can |
- // overlap the ellipsis space. |
+ // This line spills out of our box in the appropriate direction. Now we need to see if the line |
+ // can be truncated. In order for truncation to be possible, the line must have sufficient space to |
+ // accommodate our truncation string, and no replaced elements (images, tables) can overlap the ellipsis |
+ // space. |
LayoutUnit width(indentText == IndentText ? firstLineEllipsisWidth |
: ellipsisWidth); |
@@ -2422,8 +2366,8 @@ |
ltr, blockEdge.toInt(), lineBoxEdge.toInt(), width.toInt())) { |
LayoutUnit totalLogicalWidth = curr->placeEllipsis( |
selectedEllipsisStr, ltr, blockLeftEdge, blockRightEdge, width); |
- LayoutUnit logicalLeft; // We are only interested in the delta from the |
- // base position. |
+ LayoutUnit |
+ logicalLeft; // We are only interested in the delta from the base position. |
LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdge; |
updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, |
totalLogicalWidth, availableLogicalWidth, |
@@ -2487,8 +2431,7 @@ |
if (applyIndentText) |
return startOffsetForLine(position, indentText); |
- // updateLogicalWidthForAlignment() handles the direction of the block so no |
- // need to consider it here |
+ // updateLogicalWidthForAlignment() handles the direction of the block so no need to consider it here |
LayoutUnit totalLogicalWidth; |
LayoutUnit logicalLeft = |
logicalLeftOffsetForLine(logicalHeight(), DoNotIndentText); |