Bug 1144096 part 11 - [css-grid] Add a GetNearestFragmentainer() method that collects some data from the nearest enclosing fragmentainer needed for fragmentation. r=dholbert

This commit is contained in:
Mats Palmgren 2016-03-11 17:39:26 +01:00
Родитель db2d3d747c
Коммит 89b3d6e845
2 изменённых файлов: 82 добавлений и 0 удалений

Просмотреть файл

@ -3914,6 +3914,60 @@ nsGridContainerFrame::GridReflowState::ContainingBlockForAbsPos(
return LogicalRect(mWM, i, b, iSize, bSize);
}
/**
* Return a Fragmentainer object if we have a fragmentainer frame in our
* ancestor chain of containing block (CB) reflow states. We'll only
* continue traversing the ancestor chain as long as the CBs have
* the same writing-mode and have overflow:visible.
*/
Maybe<nsGridContainerFrame::Fragmentainer>
nsGridContainerFrame::GetNearestFragmentainer(const GridReflowState& aState) const
{
Maybe<nsGridContainerFrame::Fragmentainer> data;
WritingMode wm = aState.mWM;
const nsHTMLReflowState* gridRS = aState.mReflowState;
const nsHTMLReflowState* cbRS = gridRS->mCBReflowState;
for ( ; cbRS; cbRS = cbRS->mCBReflowState) {
nsIScrollableFrame* sf = do_QueryFrame(cbRS->frame);
if (sf) {
break;
}
if (wm.IsOrthogonalTo(cbRS->GetWritingMode())) {
break;
}
nsIAtom* frameType = cbRS->frame->GetType();
if ((frameType == nsGkAtoms::canvasFrame &&
PresContext()->IsPaginated()) ||
frameType == nsGkAtoms::columnSetFrame) {
data.emplace();
data->mIsTopOfPage = gridRS->mFlags.mIsTopOfPage;
LogicalMargin bp = gridRS->ComputedLogicalBorderPadding();
const auto logicalSkipSides = GetLogicalSkipSides();
bp.ApplySkipSides(logicalSkipSides);
data->mToFragmentainerEnd = aState.mFragBStart +
gridRS->AvailableBSize() - bp.BStart(wm);
const auto numRows = aState.mRows.mSizes.Length();
data->mCanBreakAtStart =
numRows > 0 && aState.mRows.mSizes[0].mPosition > 0;
nscoord bSize = gridRS->ComputedBSize();
data->mIsAutoBSize = bSize == NS_AUTOHEIGHT;
if (data->mIsAutoBSize) {
bSize = gridRS->ComputedMinBSize();
} else {
bSize = NS_CSS_MINMAX(bSize,
gridRS->ComputedMinBSize(),
gridRS->ComputedMaxBSize());
}
nscoord gridEnd =
aState.mRows.GridLineEdge(numRows, GridLineSide::eBeforeGridGap);
data->mCanBreakAtEnd = bSize > gridEnd &&
bSize > aState.mFragBStart;
break;
}
}
return data;
}
void
nsGridContainerFrame::ReflowChildren(GridReflowState& aState,
const LogicalRect& aContentArea,

Просмотреть файл

@ -155,6 +155,34 @@ protected:
#endif // DEBUG
private:
// Helpers for ReflowChildren
struct Fragmentainer {
/**
* The distance from the first grid container fragment's block-axis content
* edge to the fragmentainer end.
*/
nscoord mToFragmentainerEnd;
/**
* True if the current fragment is at the start of the fragmentainer.
*/
bool mIsTopOfPage;
/**
* Is there a Class C break opportunity at the start content edge?
*/
bool mCanBreakAtStart;
/**
* Is there a Class C break opportunity at the end content edge?
*/
bool mCanBreakAtEnd;
/**
* Is the grid container's block-size unconstrained?
*/
bool mIsAutoBSize;
};
Maybe<nsGridContainerFrame::Fragmentainer>
GetNearestFragmentainer(const GridReflowState& aState) const;
/**
* Cached values to optimize GetMinISize/GetPrefISize.
*/