Bug 1176555 - Replace explicit bit-twiddling of frame state flags by human-readable nsIFrame state-manipulation methods in table layout code. r=dholbert

This commit is contained in:
Jonathan Kew 2015-06-23 13:41:29 -07:00
Родитель 3ce10dc57a
Коммит d1f05cc84f
8 изменённых файлов: 56 добавлений и 59 удалений

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

@ -82,7 +82,7 @@ nsTableCellFrame::Init(nsIContent* aContent,
// Let the base class do its initialization
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
if (GetStateBits() & NS_FRAME_FONT_INFLATION_CONTAINER) {
if (HasAnyStateBits(NS_FRAME_FONT_INFLATION_CONTAINER)) {
AddStateBits(NS_FRAME_FONT_INFLATION_FLOW_ROOT);
}
@ -98,7 +98,7 @@ nsTableCellFrame::Init(nsIContent* aContent,
void
nsTableCellFrame::DestroyFrom(nsIFrame* aDestructRoot)
{
if (GetStateBits() & NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN) {
if (HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN)) {
nsTableFrame::UnregisterPositionedTablePart(this, aDestructRoot);
}
@ -133,8 +133,8 @@ nsTableCellFrame::NotifyPercentBSize(const nsHTMLReflowState& aReflowState)
if (nsTableFrame::AncestorsHaveStyleBSize(*cellRS) ||
(GetTableFrame()->GetEffectiveRowSpan(*this) == 1 &&
(cellRS->parentReflowState->frame->GetStateBits() &
NS_ROW_HAS_CELL_WITH_STYLE_BSIZE))) {
cellRS->parentReflowState->frame->
HasAnyStateBits(NS_ROW_HAS_CELL_WITH_STYLE_BSIZE))) {
for (const nsHTMLReflowState *rs = aReflowState.parentReflowState;
rs != cellRS;
@ -937,7 +937,7 @@ nsTableCellFrame::Reflow(nsPresContext* aPresContext,
kidReflowState.mFlags.mSpecialBSizeReflow = false;
if (aReflowState.mFlags.mSpecialBSizeReflow ||
(FirstInFlow()->GetStateBits() & NS_TABLE_CELL_HAD_SPECIAL_REFLOW)) {
FirstInFlow()->HasAnyStateBits(NS_TABLE_CELL_HAD_SPECIAL_REFLOW)) {
// We need to force the kid to have mBResize set if we've had a
// special reflow in the past, since the non-special reflow needs to
// resize back to what it was without the special bsize reflow.
@ -956,7 +956,7 @@ nsTableCellFrame::Reflow(nsPresContext* aPresContext,
borderPadding.BStart(wm));
nsRect origRect = firstKid->GetRect();
nsRect origVisualOverflow = firstKid->GetVisualOverflowRect();
bool firstReflow = (firstKid->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
bool firstReflow = firstKid->HasAnyStateBits(NS_FRAME_FIRST_REFLOW);
ReflowChild(firstKid, aPresContext, kidSize, kidReflowState,
wm, kidOrigin, containerWidth, 0, aStatus);
@ -968,7 +968,7 @@ nsTableCellFrame::Reflow(nsPresContext* aPresContext,
}
// XXXbz is this invalidate actually needed, really?
if (GetStateBits() & NS_FRAME_IS_DIRTY) {
if (HasAnyStateBits(NS_FRAME_IS_DIRTY)) {
InvalidateFrameSubtree();
}
@ -1029,7 +1029,7 @@ nsTableCellFrame::Reflow(nsPresContext* aPresContext,
// If our parent is in initial reflow, it'll handle invalidating our
// entire overflow rect.
if (!(GetParent()->GetStateBits() & NS_FRAME_FIRST_REFLOW) &&
if (!GetParent()->HasAnyStateBits(NS_FRAME_FIRST_REFLOW) &&
nsSize(aDesiredSize.Width(), aDesiredSize.Height()) != mRect.Size()) {
InvalidateFrame();
}

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

@ -279,31 +279,29 @@ inline void nsTableCellFrame::SetDesiredSize(const nsHTMLReflowMetrics & aDesire
inline bool nsTableCellFrame::GetContentEmpty()
{
return (mState & NS_TABLE_CELL_CONTENT_EMPTY) ==
NS_TABLE_CELL_CONTENT_EMPTY;
return HasAnyStateBits(NS_TABLE_CELL_CONTENT_EMPTY);
}
inline void nsTableCellFrame::SetContentEmpty(bool aContentEmpty)
{
if (aContentEmpty) {
mState |= NS_TABLE_CELL_CONTENT_EMPTY;
AddStateBits(NS_TABLE_CELL_CONTENT_EMPTY);
} else {
mState &= ~NS_TABLE_CELL_CONTENT_EMPTY;
RemoveStateBits(NS_TABLE_CELL_CONTENT_EMPTY);
}
}
inline bool nsTableCellFrame::HasPctOverBSize()
{
return (mState & NS_TABLE_CELL_HAS_PCT_OVER_BSIZE) ==
NS_TABLE_CELL_HAS_PCT_OVER_BSIZE;
return HasAnyStateBits(NS_TABLE_CELL_HAS_PCT_OVER_BSIZE);
}
inline void nsTableCellFrame::SetHasPctOverBSize(bool aValue)
{
if (aValue) {
mState |= NS_TABLE_CELL_HAS_PCT_OVER_BSIZE;
AddStateBits(NS_TABLE_CELL_HAS_PCT_OVER_BSIZE);
} else {
mState &= ~NS_TABLE_CELL_HAS_PCT_OVER_BSIZE;
RemoveStateBits(NS_TABLE_CELL_HAS_PCT_OVER_BSIZE);
}
}

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

@ -214,7 +214,7 @@ IsRepeatedFrame(nsIFrame* kidFrame)
{
return (kidFrame->GetType() == nsGkAtoms::tableRowFrame ||
kidFrame->GetType() == nsGkAtoms::tableRowGroupFrame) &&
(kidFrame->GetStateBits() & NS_REPEATED_ROW_OR_ROWGROUP);
kidFrame->HasAnyStateBits(NS_REPEATED_ROW_OR_ROWGROUP);
}
bool
@ -1849,7 +1849,7 @@ nsTableFrame::Reflow(nsPresContext* aPresContext,
}
bool needToInitiateSpecialReflow =
!!(GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_BSIZE);
HasAnyStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE);
// see if an extra reflow will be necessary in pagination mode
// when there is a specified table bsize
if (isPaginated && !GetPrevInFlow() && (NS_UNCONSTRAINEDSIZE != aReflowState.AvailableBSize())) {
@ -1878,7 +1878,7 @@ nsTableFrame::Reflow(nsPresContext* aPresContext,
lastChildReflowed, aStatus);
// reevaluate special bsize reflow conditions
if (GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_BSIZE) {
if (HasAnyStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE)) {
needToInitiateSpecialReflow = true;
}
@ -1947,7 +1947,7 @@ nsTableFrame::Reflow(nsPresContext* aPresContext,
}
aDesiredSize.mOverflowAreas.UnionAllWith(tableRect);
if ((GetStateBits() & NS_FRAME_FIRST_REFLOW) ||
if (HasAnyStateBits(NS_FRAME_FIRST_REFLOW) ||
nsSize(aDesiredSize.Width(), aDesiredSize.Height()) != mRect.Size()) {
nsIFrame::InvalidateFrame();
}
@ -2733,7 +2733,7 @@ nsTableFrame::PlaceChild(nsTableReflowState& aReflowState,
{
WritingMode wm = aReflowState.reflowState.GetWritingMode();
bool isFirstReflow =
(aKidFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
aKidFrame->HasAnyStateBits(NS_FRAME_FIRST_REFLOW);
// Place and size the child
FinishReflowChild(aKidFrame, PresContext(), aKidDesiredSize, nullptr,
@ -3026,7 +3026,7 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState,
if (reflowAllKids ||
NS_SUBTREE_DIRTY(kidFrame) ||
(aReflowState.reflowState.mFlags.mSpecialBSizeReflow &&
(isPaginated || (kidFrame->GetStateBits() &
(isPaginated || kidFrame->HasAnyStateBits(
NS_FRAME_CONTAINS_RELATIVE_BSIZE)))) {
if (pageBreak) {
if (allowRepeatedFooter) {
@ -3421,7 +3421,7 @@ nsTableFrame::DistributeBSizeToRows(const nsHTMLReflowState& aReflowState,
}
else {
if (amountUsed > 0 && bOriginRow != rowNormalRect.BStart(wm) &&
!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
!HasAnyStateBits(NS_FRAME_FIRST_REFLOW)) {
rowFrame->InvalidateFrameSubtree();
rowFrame->MovePositionBy(wm, LogicalPoint(wm, 0, bOriginRow -
rowNormalRect.BStart(wm)));
@ -7444,7 +7444,7 @@ nsTableFrame::InvalidateTableFrame(nsIFrame* aFrame,
nsIFrame* parent = aFrame->GetParent();
NS_ASSERTION(parent, "What happened here?");
if (parent->GetStateBits() & NS_FRAME_FIRST_REFLOW) {
if (parent->HasAnyStateBits(NS_FRAME_FIRST_REFLOW)) {
// Don't bother; we'll invalidate the parent's overflow rect when
// we finish reflowing it.
return;

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

@ -797,7 +797,7 @@ nsTableOuterFrame::Reflow(nsPresContext* aPresContext,
aDesiredSize.ClearSize();
aStatus = NS_FRAME_COMPLETE;
if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
if (!HasAnyStateBits(NS_FRAME_FIRST_REFLOW)) {
// Set up our kids. They're already present, on an overflow list,
// or there are none so we'll create them now
MoveOverflowToChildList();
@ -809,7 +809,7 @@ nsTableOuterFrame::Reflow(nsPresContext* aPresContext,
nsRect origInnerRect = InnerTableFrame()->GetRect();
nsRect origInnerVisualOverflow = InnerTableFrame()->GetVisualOverflowRect();
bool innerFirstReflow =
(InnerTableFrame()->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
InnerTableFrame()->HasAnyStateBits(NS_FRAME_FIRST_REFLOW);
nsRect origCaptionRect;
nsRect origCaptionVisualOverflow;
bool captionFirstReflow;
@ -818,7 +818,7 @@ nsTableOuterFrame::Reflow(nsPresContext* aPresContext,
origCaptionVisualOverflow =
mCaptionFrames.FirstChild()->GetVisualOverflowRect();
captionFirstReflow =
(mCaptionFrames.FirstChild()->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
mCaptionFrames.FirstChild()->HasAnyStateBits(NS_FRAME_FIRST_REFLOW);
}
// ComputeAutoSize has to match this logic.

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

@ -158,7 +158,7 @@ nsTableRowFrame::Init(nsIContent* aContent,
void
nsTableRowFrame::DestroyFrom(nsIFrame* aDestructRoot)
{
if (GetStateBits() & NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN) {
if (HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN)) {
nsTableFrame::UnregisterPositionedTablePart(this, aDestructRoot);
}
@ -828,8 +828,8 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
}
}
if (aReflowState.mFlags.mSpecialBSizeReflow) {
if (!isPaginated && !(cellFrame->GetStateBits() &
NS_FRAME_CONTAINS_RELATIVE_BSIZE)) {
if (!isPaginated &&
!cellFrame->HasAnyStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE)) {
continue;
}
}
@ -859,8 +859,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
MOZ_ASSERT(origKidNormalPosition.B(wm) == 0 || wm.IsVerticalRL());
nsRect kidVisualOverflow = kidFrame->GetVisualOverflowRect();
LogicalPoint kidPosition(wm, iCoord, 0);
bool firstReflow =
(kidFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
bool firstReflow = kidFrame->HasAnyStateBits(NS_FRAME_FIRST_REFLOW);
if (doReflowChild) {
// Calculate the available isize for the table cell using the known
@ -879,13 +878,13 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
NS_ASSERTION(cellFrame->GetWritingMode() == wm,
"expected consistent writing-mode within table");
LogicalSize cellDesiredSize = cellFrame->GetDesiredSize();
if ((availCellISize != cellFrame->GetPriorAvailISize()) ||
if ((availCellISize != cellFrame->GetPriorAvailISize()) ||
(cellDesiredSize.ISize(wm) > cellFrame->GetPriorAvailISize()) ||
(GetStateBits() & NS_FRAME_IS_DIRTY) ||
isPaginated ||
NS_SUBTREE_DIRTY(cellFrame) ||
HasAnyStateBits(NS_FRAME_IS_DIRTY) ||
isPaginated ||
NS_SUBTREE_DIRTY(cellFrame) ||
// See if it needs a special reflow, or if it had one that we need to undo.
(cellFrame->GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_BSIZE) ||
cellFrame->HasAnyStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE) ||
HasPctBSize()) {
// Reflow the cell to fit the available isize, bsize
// XXX The old IR_ChildIsDirty code used availCellISize here.
@ -1100,7 +1099,7 @@ nsTableRowFrame::Reflow(nsPresContext* aPresContext,
// If our parent is in initial reflow, it'll handle invalidating our
// entire overflow rect.
if (!(GetParent()->GetStateBits() & NS_FRAME_FIRST_REFLOW) &&
if (!GetParent()->HasAnyStateBits(NS_FRAME_FIRST_REFLOW) &&
nsSize(aDesiredSize.Width(), aDesiredSize.Height()) != mRect.Size()) {
InvalidateFrame();
}
@ -1165,8 +1164,8 @@ nsTableRowFrame::ReflowCellFrame(nsPresContext* aPresContext,
nsTableFrame::InvalidateTableFrame(aCellFrame,
cellRect.GetPhysicalRect(wm, containerWidth),
cellVisualOverflow,
(aCellFrame->GetStateBits() &
NS_FRAME_FIRST_REFLOW) != 0);
aCellFrame->
HasAnyStateBits(NS_FRAME_FIRST_REFLOW));
aCellFrame->DidReflow(aPresContext, nullptr, nsDidReflowStatus::FINISHED);

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

@ -391,16 +391,15 @@ inline float nsTableRowFrame::GetPctBSize() const
inline bool nsTableRowFrame::HasUnpaginatedBSize()
{
return (mState & NS_TABLE_ROW_HAS_UNPAGINATED_BSIZE) ==
NS_TABLE_ROW_HAS_UNPAGINATED_BSIZE;
return HasAnyStateBits(NS_TABLE_ROW_HAS_UNPAGINATED_BSIZE);
}
inline void nsTableRowFrame::SetHasUnpaginatedBSize(bool aValue)
{
if (aValue) {
mState |= NS_TABLE_ROW_HAS_UNPAGINATED_BSIZE;
AddStateBits(NS_TABLE_ROW_HAS_UNPAGINATED_BSIZE);
} else {
mState &= ~NS_TABLE_ROW_HAS_UNPAGINATED_BSIZE;
RemoveStateBits(NS_TABLE_ROW_HAS_UNPAGINATED_BSIZE);
}
}

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

@ -37,7 +37,7 @@ nsTableRowGroupFrame::~nsTableRowGroupFrame()
void
nsTableRowGroupFrame::DestroyFrom(nsIFrame* aDestructRoot)
{
if (GetStateBits() & NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN) {
if (HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN)) {
nsTableFrame::UnregisterPositionedTablePart(this, aDestructRoot);
}
@ -267,8 +267,7 @@ nsTableRowGroupFrame::PlaceChild(nsPresContext* aPresContext,
const nsRect& aOriginalKidRect,
const nsRect& aOriginalKidVisualOverflow)
{
bool isFirstReflow =
(aKidFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
bool isFirstReflow = aKidFrame->HasAnyStateBits(NS_FRAME_FIRST_REFLOW);
// Place and size the child
FinishReflowChild(aKidFrame, aPresContext, aDesiredSize, nullptr,
@ -370,8 +369,8 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
if (reflowAllKids ||
NS_SUBTREE_DIRTY(kidFrame) ||
(aReflowState.reflowState.mFlags.mSpecialBSizeReflow &&
(isPaginated || (kidFrame->GetStateBits() &
NS_FRAME_CONTAINS_RELATIVE_BSIZE)))) {
(isPaginated ||
kidFrame->HasAnyStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE)))) {
LogicalRect oldKidRect = kidFrame->GetLogicalRect(wm, containerWidth);
nsRect oldKidVisualOverflow = kidFrame->GetVisualOverflowRect();
@ -1384,7 +1383,7 @@ nsTableRowGroupFrame::Reflow(nsPresContext* aPresContext,
// If our parent is in initial reflow, it'll handle invalidating our
// entire overflow rect.
if (!(GetParent()->GetStateBits() & NS_FRAME_FIRST_REFLOW) &&
if (!GetParent()->HasAnyStateBits(NS_FRAME_FIRST_REFLOW) &&
nsSize(aDesiredSize.Width(), aDesiredSize.Height()) != mRect.Size()) {
InvalidateFrame();
}
@ -1867,8 +1866,9 @@ NS_DECLARE_FRAME_PROPERTY(RowCursorProperty,
void
nsTableRowGroupFrame::ClearRowCursor()
{
if (!(GetStateBits() & NS_ROWGROUP_HAS_ROW_CURSOR))
if (!HasAnyStateBits(NS_ROWGROUP_HAS_ROW_CURSOR)) {
return;
}
RemoveStateBits(NS_ROWGROUP_HAS_ROW_CURSOR);
Properties().Delete(RowCursorProperty());
@ -1877,7 +1877,7 @@ nsTableRowGroupFrame::ClearRowCursor()
nsTableRowGroupFrame::FrameCursorData*
nsTableRowGroupFrame::SetupRowCursor()
{
if (GetStateBits() & NS_ROWGROUP_HAS_ROW_CURSOR) {
if (HasAnyStateBits(NS_ROWGROUP_HAS_ROW_CURSOR)) {
// We already have a valid row cursor. Don't waste time rebuilding it.
return nullptr;
}
@ -1903,8 +1903,9 @@ nsTableRowGroupFrame::SetupRowCursor()
nsIFrame*
nsTableRowGroupFrame::GetFirstRowContaining(nscoord aY, nscoord* aOverflowAbove)
{
if (!(GetStateBits() & NS_ROWGROUP_HAS_ROW_CURSOR))
if (!HasAnyStateBits(NS_ROWGROUP_HAS_ROW_CURSOR)) {
return nullptr;
}
FrameCursorData* property = static_cast<FrameCursorData*>
(Properties().Get(RowCursorProperty()));

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

@ -429,29 +429,29 @@ public:
inline bool nsTableRowGroupFrame::IsRepeatable() const
{
return (mState & NS_ROWGROUP_REPEATABLE) == NS_ROWGROUP_REPEATABLE;
return HasAnyStateBits(NS_ROWGROUP_REPEATABLE);
}
inline void nsTableRowGroupFrame::SetRepeatable(bool aRepeatable)
{
if (aRepeatable) {
mState |= NS_ROWGROUP_REPEATABLE;
AddStateBits(NS_ROWGROUP_REPEATABLE);
} else {
mState &= ~NS_ROWGROUP_REPEATABLE;
RemoveStateBits(NS_ROWGROUP_REPEATABLE);
}
}
inline bool nsTableRowGroupFrame::HasStyleBSize() const
{
return (mState & NS_ROWGROUP_HAS_STYLE_BSIZE) == NS_ROWGROUP_HAS_STYLE_BSIZE;
return HasAnyStateBits(NS_ROWGROUP_HAS_STYLE_BSIZE);
}
inline void nsTableRowGroupFrame::SetHasStyleBSize(bool aValue)
{
if (aValue) {
mState |= NS_ROWGROUP_HAS_STYLE_BSIZE;
AddStateBits(NS_ROWGROUP_HAS_STYLE_BSIZE);
} else {
mState &= ~NS_ROWGROUP_HAS_STYLE_BSIZE;
RemoveStateBits(NS_ROWGROUP_HAS_STYLE_BSIZE);
}
}