Commit 820af6d2 authored by mstensho's avatar mstensho Committed by Commit bot

"Inline" auto-positioned out-of-flow objects are affected by pagination struts.

An out-of-flow positioned object that "belongs" to a line may need to adjust
its block position after the line has been laid out, since the line may have
been pushed to the next fragmentainer by a pagination strut.

BUG=291616

Review-Url: https://codereview.chromium.org/2249853007
Cr-Commit-Position: refs/heads/master@{#412546}
parent 13f9eb44
<!DOCTYPE html>
<p>The word "PASS" should be seen below.</p>
<div style="line-height:20px; margin-top:100px; margin-left:7em; orphans:1; widows:1;">
PASS
</div>
<!DOCTYPE html>
<p>The word "PASS" should be seen below.</p>
<div style="columns:3; column-gap:0; column-fill:auto; height:50px; line-height:20px; margin-top:100px; width:21em; orphans:1; widows:1;">
<br>
<br>
PA<span style="position:absolute;">SS</span>
</div>
<!DOCTYPE html>
<p>There should be a hotpink square below.</p>
<div style="line-height:20px; margin-top:100px; margin-left:7em;">
<div style="float:left;">&nbsp;&nbsp;</div>
<div style="float:left; width:15px; height:15px; background:hotpink;"></div>
</div>
<!DOCTYPE html>
<style>
#abspos { position:absolute; line-height:9px; width:15px; background:hotpink; }
#inline-block { display:inline-block; width:15px; height:10px; background:hotpink; }
</style>
<p>There should be a hotpink square below.</p>
<div style="columns:3; column-gap:0; column-fill:auto; height:50px; line-height:20px; margin-top:100px; width:21em; orphans:1; widows:1;">
<div style="position:relative;">
<br>
<br>
&nbsp;&nbsp;<span id="abspos"><br></span><div id="inline-block"></div>
</div>
</div>
...@@ -873,6 +873,7 @@ void LayoutBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, ...@@ -873,6 +873,7 @@ void LayoutBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState,
} }
ASSERT(endOfLine != resolver.position()); ASSERT(endOfLine != resolver.position());
RootInlineBox* lineBox = nullptr;
// This is a short-cut for empty lines. // This is a short-cut for empty lines.
if (layoutState.lineInfo().isEmpty()) { if (layoutState.lineInfo().isEmpty()) {
...@@ -901,7 +902,7 @@ void LayoutBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, ...@@ -901,7 +902,7 @@ void LayoutBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState,
// inline flow boxes. // inline flow boxes.
LayoutUnit oldLogicalHeight = logicalHeight(); LayoutUnit oldLogicalHeight = logicalHeight();
RootInlineBox* lineBox = createLineBoxesFromBidiRuns(resolver.status().context->level(), bidiRuns, endOfLine, layoutState.lineInfo(), verticalPositionCache, trailingSpaceRun, wordMeasurements); lineBox = createLineBoxesFromBidiRuns(resolver.status().context->level(), bidiRuns, endOfLine, layoutState.lineInfo(), verticalPositionCache, trailingSpaceRun, wordMeasurements);
bidiRuns.deleteRuns(); bidiRuns.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).
...@@ -946,8 +947,17 @@ void LayoutBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, ...@@ -946,8 +947,17 @@ void LayoutBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState,
} }
if (!paginationStrutFromDeletedLine) { if (!paginationStrutFromDeletedLine) {
for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i) for (const auto& positionedObject : lineBreaker.positionedObjects()) {
setStaticPositions(LineLayoutBlockFlow(this), LineLayoutBox(lineBreaker.positionedObjects()[i]), DoNotIndentText); 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.
if (paginated && lineBox)
positionedObject.layer()->setStaticBlockPosition(lineBox->lineTopWithLeading());
continue;
}
setStaticPositions(LineLayoutBlockFlow(this), positionedObject, DoNotIndentText);
}
if (!layoutState.lineInfo().isEmpty()) if (!layoutState.lineInfo().isEmpty())
layoutState.lineInfo().setFirstLine(false); layoutState.lineInfo().setFirstLine(false);
......
...@@ -376,20 +376,22 @@ inline void BreakingContext::handleOutOfFlowPositioned(Vector<LineLayoutBox>& po ...@@ -376,20 +376,22 @@ inline void BreakingContext::handleOutOfFlowPositioned(Vector<LineLayoutBox>& po
if (!isInlineType) { if (!isInlineType) {
m_block.setStaticInlinePositionForChild(box, m_block.startOffsetForContent()); m_block.setStaticInlinePositionForChild(box, m_block.startOffsetForContent());
} else { } else {
// If our original display was an INLINE type, then we can go ahead // If our original display was an INLINE type, then we can determine our static y position
// and determine our static y position now. // now. Note, however, that if we're paginated, we may have to update this position after
// the line has been laid out, since the line may be pushed by a pagination strut.
box.layer()->setStaticBlockPosition(m_block.logicalHeight()); box.layer()->setStaticBlockPosition(m_block.logicalHeight());
} }
// If we're ignoring spaces, we have to stop and include this object and // If we're ignoring spaces, we have to stop and include this object and
// then start ignoring spaces again. // then start ignoring spaces again.
if (isInlineType || box.container().isLayoutInline()) { bool containerIsInline = box.container().isLayoutInline();
if (isInlineType || containerIsInline) {
if (m_ignoringSpaces) if (m_ignoringSpaces)
ensureLineBoxInsideIgnoredSpaces(&m_lineMidpointState, box); ensureLineBoxInsideIgnoredSpaces(&m_lineMidpointState, box);
m_trailingObjects.appendObjectIfNeeded(box); m_trailingObjects.appendObjectIfNeeded(box);
} else {
positionedObjects.append(box);
} }
if (!containerIsInline)
positionedObjects.append(box);
m_width.addUncommittedWidth(inlineLogicalWidthFromAncestorsIfNeeded(box).toFloat()); m_width.addUncommittedWidth(inlineLogicalWidthFromAncestorsIfNeeded(box).toFloat());
// Reset prior line break context characters. // Reset prior line break context characters.
m_layoutTextInfo.m_lineBreakIterator.resetPriorContext(); m_layoutTextInfo.m_lineBreakIterator.resetPriorContext();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment