diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index 267afdda4d61..759e06e4a622 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -356,14 +356,16 @@ RestyleManager::RecomputePosition(nsIFrame* aFrame) // For relative positioning, we can simply update the frame rect if (display->IsRelativelyPositionedStyle()) { + if (display->IsInnerTableStyle()) { + // We don't currently support relative positioning of inner table + // elements (bug 35168). If we apply offsets to things we haven't + // previously offset, we'll get confused. So bail. + return true; + } + + // Move the frame if (display->mPosition == NS_STYLE_POSITION_STICKY) { - if (display->IsInnerTableStyle()) { - // We don't currently support sticky positioning of inner table - // elements (bug 975644). Bail. - return true; - } - // Update sticky positioning for an entire element at once, starting with // the first continuation or ib-split sibling. // It's rare that the frame we already have isn't already the first diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index be370f5bc4df..f5a672d18146 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -5168,19 +5168,6 @@ nsIFrame::MovePositionBy(const nsPoint& aTranslation) SetPosition(position); } -nsRect -nsIFrame::GetNormalRect() const -{ - // It might be faster to first check - // StyleDisplay()->IsRelativelyPositionedStyle(). - nsPoint* normalPosition = static_cast - (Properties().Get(NormalPositionProperty())); - if (normalPosition) { - return nsRect(*normalPosition, GetSize()); - } - return GetRect(); -} - nsPoint nsIFrame::GetNormalPosition() const { diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 2e4568698f48..451a5bf83333 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -745,11 +745,6 @@ public: */ void MovePositionBy(const nsPoint& aTranslation); - /** - * Return frame's rect without relative positioning - */ - nsRect GetNormalRect() const; - /** * Return frame's position without relative positioning */ diff --git a/layout/reftests/position-relative/reftest.list b/layout/reftests/position-relative/reftest.list deleted file mode 100644 index cabfe4f47ffa..000000000000 --- a/layout/reftests/position-relative/reftest.list +++ /dev/null @@ -1,16 +0,0 @@ -== table-collapse-1.html table-collapse-1-ref.html -== table-collapse-2.html table-collapse-2-ref.html -== table-collapse-3.html table-collapse-3-ref.html -== table-collapse-4.html table-collapse-4-ref.html -== table-separate-1.html table-separate-1-ref.html -== table-separate-2.html table-separate-2-ref.html -== table-separate-3.html table-separate-3-ref.html -== table-separate-4.html table-separate-4-ref.html -# == table-collapse-dynamic-1.html table-collapse-dynamic-1-ref.html -# == table-collapse-dynamic-2.html table-collapse-dynamic-2-ref.html -# == table-collapse-dynamic-3.html table-collapse-dynamic-3-ref.html -# == table-collapse-dynamic-4.html table-collapse-dynamic-4-ref.html -# == table-separate-dynamic-1.html table-separate-dynamic-1-ref.html -# == table-separate-dynamic-2.html table-separate-dynamic-2-ref.html -# == table-separate-dynamic-3.html table-separate-dynamic-3-ref.html -# == table-separate-dynamic-4.html table-separate-dynamic-4-ref.html diff --git a/layout/reftests/position-relative/table-collapse-1-ref.html b/layout/reftests/position-relative/table-collapse-1-ref.html deleted file mode 100644 index e2f9edd47291..000000000000 --- a/layout/reftests/position-relative/table-collapse-1-ref.html +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
 
XXX
XXX 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/position-relative/table-collapse-1.html b/layout/reftests/position-relative/table-collapse-1.html deleted file mode 100644 index 80ee9fe2207b..000000000000 --- a/layout/reftests/position-relative/table-collapse-1.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/position-relative/table-collapse-2-ref.html b/layout/reftests/position-relative/table-collapse-2-ref.html deleted file mode 100644 index f99d2ef74f02..000000000000 --- a/layout/reftests/position-relative/table-collapse-2-ref.html +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
 
XXX
XXX 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/position-relative/table-collapse-2.html b/layout/reftests/position-relative/table-collapse-2.html deleted file mode 100644 index c1c96d830194..000000000000 --- a/layout/reftests/position-relative/table-collapse-2.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/position-relative/table-collapse-3-ref.html b/layout/reftests/position-relative/table-collapse-3-ref.html deleted file mode 100644 index e2c6d43b468a..000000000000 --- a/layout/reftests/position-relative/table-collapse-3-ref.html +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
 
XXX
XXX 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/position-relative/table-collapse-3.html b/layout/reftests/position-relative/table-collapse-3.html deleted file mode 100644 index 00d8539b022e..000000000000 --- a/layout/reftests/position-relative/table-collapse-3.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/position-relative/table-collapse-4-ref.html b/layout/reftests/position-relative/table-collapse-4-ref.html deleted file mode 100644 index b64b332147ea..000000000000 --- a/layout/reftests/position-relative/table-collapse-4-ref.html +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
 
XXX
XXX 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/position-relative/table-collapse-4.html b/layout/reftests/position-relative/table-collapse-4.html deleted file mode 100644 index fc7b48de261e..000000000000 --- a/layout/reftests/position-relative/table-collapse-4.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/position-relative/table-separate-1-ref.html b/layout/reftests/position-relative/table-separate-1-ref.html deleted file mode 100644 index b46232714dec..000000000000 --- a/layout/reftests/position-relative/table-separate-1-ref.html +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
 
XXX
XXX 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/position-relative/table-separate-1.html b/layout/reftests/position-relative/table-separate-1.html deleted file mode 100644 index d97fa15d8a7e..000000000000 --- a/layout/reftests/position-relative/table-separate-1.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/position-relative/table-separate-2-ref.html b/layout/reftests/position-relative/table-separate-2-ref.html deleted file mode 100644 index 90d7c6884b75..000000000000 --- a/layout/reftests/position-relative/table-separate-2-ref.html +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
 
XXX
XXX 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/position-relative/table-separate-2.html b/layout/reftests/position-relative/table-separate-2.html deleted file mode 100644 index 583771328c35..000000000000 --- a/layout/reftests/position-relative/table-separate-2.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/position-relative/table-separate-3-ref.html b/layout/reftests/position-relative/table-separate-3-ref.html deleted file mode 100644 index 52765315178d..000000000000 --- a/layout/reftests/position-relative/table-separate-3-ref.html +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
 
XXX
XXX 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/position-relative/table-separate-3.html b/layout/reftests/position-relative/table-separate-3.html deleted file mode 100644 index a739fb771287..000000000000 --- a/layout/reftests/position-relative/table-separate-3.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/position-relative/table-separate-4-ref.html b/layout/reftests/position-relative/table-separate-4-ref.html deleted file mode 100644 index b5cfd2783fd8..000000000000 --- a/layout/reftests/position-relative/table-separate-4-ref.html +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
 
XXX
XXX 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/position-relative/table-separate-4.html b/layout/reftests/position-relative/table-separate-4.html deleted file mode 100644 index 9634117b7467..000000000000 --- a/layout/reftests/position-relative/table-separate-4.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XXXYYY
XXXYYY
XXXYYY
XXX
XXX
XXXYYY
- diff --git a/layout/reftests/reftest.list b/layout/reftests/reftest.list index 8f8ac3135322..9e99bb9c7518 100644 --- a/layout/reftests/reftest.list +++ b/layout/reftests/reftest.list @@ -17,7 +17,6 @@ include w3c-css/received/reftest.list # relative and absolute positioning include abs-pos/reftest.list -include position-relative/reftest.list include async-scrolling/reftest.list diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index a91a77405214..a44e49c13ac4 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -1845,7 +1845,7 @@ nsTableFrame::Reflow(nsPresContext* aPresContext, // if there is an incomplete child, then set the desired height to include it but not the next one nsMargin borderPadding = GetChildAreaOffset(&aReflowState); aDesiredSize.Height() = borderPadding.bottom + GetCellSpacingY(GetRowCount()) + - lastChildReflowed->GetNormalRect().YMost(); + lastChildReflowed->GetRect().YMost(); } haveDesiredHeight = true; @@ -2649,7 +2649,6 @@ nsTableFrame::InitChildReflowState(nsHTMLReflowState& aReflowState) // aKidRect is relative to the upper-left origin of our frame void nsTableFrame::PlaceChild(nsTableReflowState& aReflowState, nsIFrame* aKidFrame, - nsPoint aKidPosition, nsHTMLReflowMetrics& aKidDesiredSize, const nsRect& aOriginalKidRect, const nsRect& aOriginalKidVisualOverflow) @@ -2659,7 +2658,7 @@ void nsTableFrame::PlaceChild(nsTableReflowState& aReflowState, // Place and size the child FinishReflowChild(aKidFrame, PresContext(), aKidDesiredSize, nullptr, - aKidPosition.x, aKidPosition.y, 0); + aReflowState.x, aReflowState.y, 0); InvalidateTableFrame(aKidFrame, aOriginalKidRect, aOriginalKidVisualOverflow, isFirstReflow); @@ -2843,10 +2842,7 @@ nsTableFrame::PlaceRepeatedFooter(nsTableReflowState& aReflowState, desiredSize.ClearSize(); ReflowChild(aTfoot, presContext, desiredSize, footerReflowState, aReflowState.x, aReflowState.y, 0, footerStatus); - nsPoint kidPosition(aReflowState.x, aReflowState.y); - footerReflowState.ApplyRelativePositioning(&kidPosition); - - PlaceChild(aReflowState, aTfoot, kidPosition, desiredSize, origTfootRect, + PlaceChild(aReflowState, aTfoot, desiredSize, origTfootRect, origTfootVisualOverflow); } @@ -2966,7 +2962,7 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState, // We ignore a repeated head row group in this check to avoid causing // infinite loops in some circumstances - see bug 344883. if (childX > ((thead && IsRepeatedFrame(thead)) ? 1u : 0u) && - (rowGroups[childX - 1]->GetNormalRect().YMost() > 0)) { + (rowGroups[childX - 1]->GetRect().YMost() > 0)) { kidReflowState.mFlags.mIsTopOfPage = false; } aReflowState.y += cellSpacingY; @@ -2981,8 +2977,6 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState, ReflowChild(kidFrame, presContext, desiredSize, kidReflowState, aReflowState.x, aReflowState.y, 0, aStatus); - nsPoint kidPosition(aReflowState.x, aReflowState.y); - kidReflowState.ApplyRelativePositioning(&kidPosition); if (reorder) { // reorder row groups the reflow may have changed the nextinflows @@ -3014,8 +3008,8 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState, if (childX+1 < rowGroups.Length()) { nsIFrame* nextRowGroupFrame = rowGroups[childX + 1]; if (nextRowGroupFrame) { - PlaceChild(aReflowState, kidFrame, kidPosition, desiredSize, - oldKidRect, oldKidVisualOverflow); + PlaceChild(aReflowState, kidFrame, desiredSize, oldKidRect, + oldKidVisualOverflow); if (allowRepeatedFooter) { PlaceRepeatedFooter(aReflowState, tfoot, footerHeight); } @@ -3043,8 +3037,8 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState, break; } else { // we can't push so lets make clear how much space we need - PlaceChild(aReflowState, kidFrame, kidPosition, desiredSize, - oldKidRect, oldKidVisualOverflow); + PlaceChild(aReflowState, kidFrame, desiredSize, oldKidRect, + oldKidVisualOverflow); aLastChildReflowed = kidFrame; if (allowRepeatedFooter) { PlaceRepeatedFooter(aReflowState, tfoot, footerHeight); @@ -3067,7 +3061,7 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState, } // Place the child - PlaceChild(aReflowState, kidFrame, kidPosition, desiredSize, oldKidRect, + PlaceChild(aReflowState, kidFrame, desiredSize, oldKidRect, oldKidVisualOverflow); // Remember where we just were in case we end up pushing children @@ -3114,12 +3108,12 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState, } else { // it isn't being reflowed aReflowState.y += cellSpacingY; - nsRect kidRect = kidFrame->GetNormalRect(); + nsRect kidRect = kidFrame->GetRect(); if (kidRect.y != aReflowState.y) { // invalidate the old position kidFrame->InvalidateFrameSubtree(); - // move to the new position - kidFrame->MovePositionBy(nsPoint(0, aReflowState.y - kidRect.y)); + kidRect.y = aReflowState.y; + kidFrame->SetRect(kidRect); // move to the new position RePositionViews(kidFrame); // invalidate the new position kidFrame->InvalidateFrameSubtree(); @@ -3272,64 +3266,64 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState, nsTableRowGroupFrame* rgFrame = rowGroups[rgX]; nscoord amountUsedByRG = 0; nscoord yOriginRow = 0; - nsRect rgNormalRect = rgFrame->GetNormalRect(); + nsRect rgRect = rgFrame->GetRect(); if (!rgFrame->HasStyleHeight()) { nsTableRowFrame* rowFrame = rgFrame->GetFirstRow(); while (rowFrame) { - nsRect rowNormalRect = rowFrame->GetNormalRect(); + nsRect rowRect = rowFrame->GetRect(); nscoord cellSpacingY = GetCellSpacingY(rowFrame->GetRowIndex()); if ((amountUsed < aAmount) && rowFrame->HasPctHeight()) { nscoord pctHeight = rowFrame->GetHeight(pctBasis); - nscoord amountForRow = std::min(aAmount - amountUsed, - pctHeight - rowNormalRect.height); + nscoord amountForRow = std::min(aAmount - amountUsed, pctHeight - rowRect.height); if (amountForRow > 0) { - // XXXbz we don't need to move the row's y position to yOriginRow? - nsRect origRowRect = rowFrame->GetRect(); - nscoord newRowHeight = rowNormalRect.height + amountForRow; - rowFrame->SetSize(nsSize(rowNormalRect.width, newRowHeight)); - yOriginRow += newRowHeight + cellSpacingY; - yEndRG += newRowHeight + cellSpacingY; + nsRect oldRowRect = rowRect; + rowRect.height += amountForRow; + // XXXbz we don't need to change rowRect.y to be yOriginRow? + rowFrame->SetRect(rowRect); + yOriginRow += rowRect.height + cellSpacingY; + yEndRG += rowRect.height + cellSpacingY; amountUsed += amountForRow; amountUsedByRG += amountForRow; //rowFrame->DidResize(); nsTableFrame::RePositionViews(rowFrame); - rgFrame->InvalidateFrameWithRect(origRowRect); + rgFrame->InvalidateFrameWithRect(oldRowRect); rgFrame->InvalidateFrame(); } } else { - if (amountUsed > 0 && yOriginRow != rowNormalRect.y && + if (amountUsed > 0 && yOriginRow != rowRect.y && !(GetStateBits() & NS_FRAME_FIRST_REFLOW)) { rowFrame->InvalidateFrameSubtree(); - rowFrame->MovePositionBy(nsPoint(0, yOriginRow - rowNormalRect.y)); + rowFrame->SetPosition(nsPoint(rowRect.x, yOriginRow)); nsTableFrame::RePositionViews(rowFrame); rowFrame->InvalidateFrameSubtree(); } - yOriginRow += rowNormalRect.height + cellSpacingY; - yEndRG += rowNormalRect.height + cellSpacingY; + yOriginRow += rowRect.height + cellSpacingY; + yEndRG += rowRect.height + cellSpacingY; } rowFrame = rowFrame->GetNextRow(); } if (amountUsed > 0) { - if (rgNormalRect.y != yOriginRG) { + if (rgRect.y != yOriginRG) { rgFrame->InvalidateFrameSubtree(); } - nsRect origRgNormalRect = rgFrame->GetRect(); + nsRect origRgRect = rgRect; nsRect origRgVisualOverflow = rgFrame->GetVisualOverflowRect(); - rgFrame->MovePositionBy(nsPoint(0, yOriginRG - rgNormalRect.y)); - rgFrame->SetSize(nsSize(rgNormalRect.width, - rgNormalRect.height + amountUsedByRG)); + rgRect.y = yOriginRG; + rgRect.height += amountUsedByRG; - nsTableFrame::InvalidateTableFrame(rgFrame, origRgNormalRect, + rgFrame->SetRect(rgRect); + + nsTableFrame::InvalidateTableFrame(rgFrame, origRgRect, origRgVisualOverflow, false); } } - else if (amountUsed > 0 && yOriginRG != rgNormalRect.y) { + else if (amountUsed > 0 && yOriginRG != rgRect.y) { rgFrame->InvalidateFrameSubtree(); - rgFrame->MovePositionBy(nsPoint(0, yOriginRG - rgNormalRect.y)); + rgFrame->SetPosition(nsPoint(rgRect.x, yOriginRG)); // Make sure child views are properly positioned nsTableFrame::RePositionViews(rgFrame); rgFrame->InvalidateFrameSubtree(); @@ -3409,14 +3403,14 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState, nsTableRowGroupFrame* rgFrame = rowGroups[rgX]; nscoord amountUsedByRG = 0; nscoord yOriginRow = 0; - nsRect rgNormalRect = rgFrame->GetNormalRect(); + nsRect rgRect = rgFrame->GetRect(); nsRect rgVisualOverflow = rgFrame->GetVisualOverflowRect(); // see if there is an eligible row group or we distribute to all rows if (!firstUnStyledRG || !rgFrame->HasStyleHeight() || !eligibleRows) { nsTableRowFrame* rowFrame = rgFrame->GetFirstRow(); while (rowFrame) { nscoord cellSpacingY = GetCellSpacingY(rowFrame->GetRowIndex()); - nsRect rowNormalRect = rowFrame->GetNormalRect(); + nsRect rowRect = rowFrame->GetRect(); nsRect rowVisualOverflow = rowFrame->GetVisualOverflowRect(); // see if there is an eligible row or we distribute to all rows if (!firstUnStyledRow || !rowFrame->HasStyleHeight() || !eligibleRows) { @@ -3425,7 +3419,7 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState, if (!expandEmptyRows) { // The amount of additional space each row gets is proportional to // its height - ratio = float(rowNormalRect.height) / float(divisor); + ratio = float(rowRect.height) / float(divisor); } else { // empty rows get all the same additional space ratio = 1.0f / float(eligibleRows); @@ -3441,18 +3435,17 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState, ? aAmount - amountUsed : NSToCoordRound(((float)(heightToDistribute)) * ratio); amountForRow = std::min(amountForRow, aAmount - amountUsed); - if (yOriginRow != rowNormalRect.y) { + if (yOriginRow != rowRect.y) { rowFrame->InvalidateFrameSubtree(); } // update the row height - nsRect origRowRect = rowFrame->GetRect(); - nscoord newRowHeight = rowNormalRect.height + amountForRow; - rowFrame->MovePositionBy(nsPoint(0, yOriginRow - rowNormalRect.y)); - rowFrame->SetSize(nsSize(rowNormalRect.width, newRowHeight)); + nsRect newRowRect(rowRect.x, yOriginRow, rowRect.width, + rowRect.height + amountForRow); + rowFrame->SetRect(newRowRect); - yOriginRow += newRowHeight + cellSpacingY; - yEndRG += newRowHeight + cellSpacingY; + yOriginRow += newRowRect.height + cellSpacingY; + yEndRG += newRowRect.height + cellSpacingY; amountUsed += amountForRow; amountUsedByRG += amountForRow; @@ -3460,39 +3453,37 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState, //rowFrame->DidResize(); nsTableFrame::RePositionViews(rowFrame); - nsTableFrame::InvalidateTableFrame(rowFrame, origRowRect, - rowVisualOverflow, false); + nsTableFrame::InvalidateTableFrame(rowFrame, rowRect, rowVisualOverflow, + false); } else { - if (amountUsed > 0 && yOriginRow != rowNormalRect.y) { + if (amountUsed > 0 && yOriginRow != rowRect.y) { rowFrame->InvalidateFrameSubtree(); - rowFrame->MovePositionBy(nsPoint(0, yOriginRow - rowNormalRect.y)); + rowFrame->SetPosition(nsPoint(rowRect.x, yOriginRow)); nsTableFrame::RePositionViews(rowFrame); rowFrame->InvalidateFrameSubtree(); } - yOriginRow += rowNormalRect.height + cellSpacingY; - yEndRG += rowNormalRect.height + cellSpacingY; + yOriginRow += rowRect.height + cellSpacingY; + yEndRG += rowRect.height + cellSpacingY; } rowFrame = rowFrame->GetNextRow(); } if (amountUsed > 0) { - if (rgNormalRect.y != yOriginRG) { + if (rgRect.y != yOriginRG) { rgFrame->InvalidateFrameSubtree(); } - nsRect origRgNormalRect = rgFrame->GetRect(); - rgFrame->MovePositionBy(nsPoint(0, yOriginRG - rgNormalRect.y)); - rgFrame->SetSize(nsSize(rgNormalRect.width, - rgNormalRect.height + amountUsedByRG)); + rgFrame->SetRect(nsRect(rgRect.x, yOriginRG, rgRect.width, + rgRect.height + amountUsedByRG)); - nsTableFrame::InvalidateTableFrame(rgFrame, origRgNormalRect, - rgVisualOverflow, false); + nsTableFrame::InvalidateTableFrame(rgFrame, rgRect, rgVisualOverflow, + false); } // Make sure child views are properly positioned } - else if (amountUsed > 0 && yOriginRG != rgNormalRect.y) { + else if (amountUsed > 0 && yOriginRG != rgRect.y) { rgFrame->InvalidateFrameSubtree(); - rgFrame->MovePositionBy(nsPoint(0, yOriginRG - rgNormalRect.y)); + rgFrame->SetPosition(nsPoint(rgRect.x, yOriginRG)); // Make sure child views are properly positioned nsTableFrame::RePositionViews(rgFrame); rgFrame->InvalidateFrameSubtree(); @@ -3592,15 +3583,8 @@ nsTableFrame::GetLogicalBaseline(WritingMode aWritingMode) const nsTableRowGroupFrame* rgFrame = orderedRowGroups[rgIndex]; if (rgFrame->GetRowCount()) { firstRow = rgFrame->GetFirstRow(); - - nscoord rgNormalBStart = - LogicalRect(aWritingMode, rgFrame->GetNormalRect(), containerWidth) - .Origin(aWritingMode).B(aWritingMode); - nscoord firstRowNormalBStart = - LogicalRect(aWritingMode, firstRow->GetNormalRect(), containerWidth) - .Origin(aWritingMode).B(aWritingMode); - - ascent = rgNormalBStart + firstRowNormalBStart + + ascent = rgFrame->BStart(aWritingMode, containerWidth) + + firstRow->BStart(aWritingMode, containerWidth) + firstRow->GetRowBaseline(aWritingMode); break; } diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index 6efaa4656ad6..4f4e8655f28c 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -666,7 +666,6 @@ protected: void PlaceChild(nsTableReflowState& aReflowState, nsIFrame* aKidFrame, - nsPoint aKidPosition, nsHTMLReflowMetrics& aKidDesiredSize, const nsRect& aOriginalKidRect, const nsRect& aOriginalKidVisualOverflow); diff --git a/layout/tables/nsTablePainter.cpp b/layout/tables/nsTablePainter.cpp index 82db2dbf4aec..7281245ae645 100644 --- a/layout/tables/nsTablePainter.cpp +++ b/layout/tables/nsTablePainter.cpp @@ -92,7 +92,11 @@ Elements with stacking contexts set up their own painter to finish the painting process, since they were skipped. They call the appropriate sub-part of the loop (e.g. PaintRow) which will paint the frame and - descendants. + descendants. Note that it is permissible according to CSS2.1 to ignore' + 'position:relative' (and implicitly, 'opacity') on table parts so that + table parts can never create stacking contexts; if we want to, we can + implement that, and then we won't have to deal with TableBackgroundPainter + being used anywhere but from the nsTableFrame. XXX views are going */ @@ -418,15 +422,7 @@ TableBackgroundPainter::PaintTable(nsTableFrame* aTableFrame, // Need to compute the right rect via GetOffsetTo, since the row // group may not be a child of the table. mRowGroup.mRect.MoveTo(rg->GetOffsetTo(aTableFrame)); - - // We have to draw backgrounds not only within the overflow region of this - // row group, but also possibly (in the case of column / column group - // backgrounds) at its pre-relative-positioning location. - nsRect rgVisualOverflow = rg->GetVisualOverflowRectRelativeToSelf(); - nsRect rgOverflowRect = rgVisualOverflow + rg->GetPosition(); - nsRect rgNormalRect = rgVisualOverflow + rg->GetNormalPosition(); - - if (rgOverflowRect.Union(rgNormalRect).Intersects(mDirtyRect - mRenderPt)) { + if (mRowGroup.mRect.Intersects(mDirtyRect - mRenderPt)) { nsresult rv = PaintRowGroup(rg, rg->IsPseudoStackingContextFromStyle()); if (NS_FAILED(rv)) return rv; } @@ -474,12 +470,16 @@ TableBackgroundPainter::PaintRowGroup(nsTableRowGroupFrame* aFrame, mRowGroup.mRect.MoveTo(0, 0); /* Find the right row to start with */ + nscoord ignored; // We don't care about overflow above, since what we really + // care about are backgrounds and overflow above doesn't + // correspond to backgrounds, since cells can't span up from + // their originating row. We do care about overflow below, + // however, since that can be due to rowspans. // Note that mDirtyRect - mRenderPt is guaranteed to be in the row // group's coordinate system here, so passing its .y to // GetFirstRowContaining is ok. - nscoord overflowAbove; - nsIFrame* cursor = aFrame->GetFirstRowContaining(mDirtyRect.y - mRenderPt.y, &overflowAbove); + nsIFrame* cursor = aFrame->GetFirstRowContaining(mDirtyRect.y - mRenderPt.y, &ignored); // Sadly, it seems like there may be non-row frames in there... or something? // There are certainly null-checks in GetFirstRow() and GetNextRow(). :( @@ -500,12 +500,9 @@ TableBackgroundPainter::PaintRowGroup(nsTableRowGroupFrame* aFrame, /* Finally paint */ for (; row; row = row->GetNextRow()) { mRow.SetFrame(row); - // Be sure to consider our positions both pre- and post-relative - // positioning, since we potentially need to paint at both places. - nscoord rowY = std::min(mRow.mRect.y, row->GetNormalPosition().y); + if (mDirtyRect.YMost() - mRenderPt.y < mRow.mRect.y) { // Intersect wouldn't handle + // rowspans. - // Intersect wouldn't handle rowspans. - if ((mDirtyRect.YMost() - mRenderPt.y) <= (rowY - overflowAbove)) { // All done; cells originating in later rows can't intersect mDirtyRect. break; } @@ -567,20 +564,10 @@ TableBackgroundPainter::PaintRow(nsTableRowFrame* aFrame, //else: Use row group's coord system -> no translation necessary for (nsTableCellFrame* cell = aFrame->GetFirstCell(); cell; cell = cell->GetNextCell()) { - nsRect cellBGRect, rowBGRect, rowGroupBGRect, colBGRect; - ComputeCellBackgrounds(cell, cellBGRect, rowBGRect, - rowGroupBGRect, colBGRect); - - // Find the union of all the cell background layers. - nsRect combinedRect(cellBGRect); - combinedRect.UnionRect(combinedRect, rowBGRect); - combinedRect.UnionRect(combinedRect, rowGroupBGRect); - combinedRect.UnionRect(combinedRect, colBGRect); - - if (combinedRect.Intersects(mDirtyRect)) { - bool passCell = aPassThrough || cell->IsPseudoStackingContextFromStyle(); - nsresult rv = PaintCell(cell, cellBGRect, rowBGRect, rowGroupBGRect, - colBGRect, passCell); + //Translate to use the same coord system as mRow. + mCellRect = cell->GetRect() + mRow.mRect.TopLeft() + mRenderPt; + if (mCellRect.Intersects(mDirtyRect)) { + nsresult rv = PaintCell(cell, aPassThrough || cell->IsPseudoStackingContextFromStyle()); if (NS_FAILED(rv)) return rv; } } @@ -592,11 +579,7 @@ TableBackgroundPainter::PaintRow(nsTableRowFrame* aFrame, nsresult TableBackgroundPainter::PaintCell(nsTableCellFrame* aCell, - nsRect& aCellBGRect, - nsRect& aRowBGRect, - nsRect& aRowGroupBGRect, - nsRect& aColBGRect, - bool aPassSelf) + bool aPassSelf) { NS_PRECONDITION(aCell, "null frame"); @@ -621,7 +604,7 @@ TableBackgroundPainter::PaintCell(nsTableCellFrame* aCell, mCols[colIndex].mColGroup->mRect + mRenderPt, mCols[colIndex].mColGroup->mFrame->StyleContext(), *mCols[colIndex].mColGroup->mBorder, - mBGPaintFlags, &aColBGRect); + mBGPaintFlags, &mCellRect); } //Paint column background @@ -631,7 +614,7 @@ TableBackgroundPainter::PaintCell(nsTableCellFrame* aCell, mCols[colIndex].mCol.mRect + mRenderPt, mCols[colIndex].mCol.mFrame->StyleContext(), *mCols[colIndex].mCol.mBorder, - mBGPaintFlags, &aColBGRect); + mBGPaintFlags, &mCellRect); } //Paint row group background @@ -641,7 +624,7 @@ TableBackgroundPainter::PaintCell(nsTableCellFrame* aCell, mRowGroup.mRect + mRenderPt, mRowGroup.mFrame->StyleContext(), *mRowGroup.mBorder, - mBGPaintFlags, &aRowGroupBGRect); + mBGPaintFlags, &mCellRect); } //Paint row background @@ -651,69 +634,14 @@ TableBackgroundPainter::PaintCell(nsTableCellFrame* aCell, mRow.mRect + mRenderPt, mRow.mFrame->StyleContext(), *mRow.mBorder, - mBGPaintFlags, &aRowBGRect); + mBGPaintFlags, &mCellRect); } //Paint cell background in border-collapse unless we're just passing if (mIsBorderCollapse && !aPassSelf) { aCell->PaintCellBackground(mRenderingContext, mDirtyRect, - aCellBGRect.TopLeft(), mBGPaintFlags); + mCellRect.TopLeft(), mBGPaintFlags); } return NS_OK; } - -void -TableBackgroundPainter::ComputeCellBackgrounds(nsTableCellFrame* aCell, - nsRect& aCellBGRect, - nsRect& aRowBGRect, - nsRect& aRowGroupBGRect, - nsRect& aColBGRect) -{ - // We need to compute table background layer rects for this cell space, - // adjusted for possible relative positioning. This behavior is not specified - // at the time of this writing, but the approach below should be web - // compatible. - // - // Our goal is that relative positioning of a table part should leave - // backgrounds *under* that part unchanged. ("Under" being defined by CSS 2.1 - // Section 17.5.1.) If a cell is positioned, we do not expect the row - // background to move. On the other hand, the backgrounds of layers *above* - // the positioned part are taken along for the ride -- for example, - // positioning a row group will also cause the row background to be drawn in - // the new location, unless it has further positioning applied. - // - // Each table part layer has its position stored in the coordinate space of - // the layer below (which is to say, its geometric parent), and the stored - // position is the post-relative-positioning one. The position of each - // background layer rect is thus determined by peeling off successive table - // part layers, removing the contribution of each layer's positioning one by - // one. Every rect we generate will be the same size, the size of the cell - // space. - - // We cannot rely on the row group background data to be available, since some - // callers enter through PaintRow. - nsIFrame* rowGroupFrame = - mRowGroup.mFrame ? mRowGroup.mFrame : mRow.mFrame->GetParent(); - - // The cell background goes at the cell's position, translated to use the same - // coordinate system as mRow. - aCellBGRect = aCell->GetRect() + mRow.mRect.TopLeft() + mRenderPt; - - // The row background goes at the normal position of the cell, which is to say - // the position without relative positioning applied. - aRowBGRect = aCellBGRect + (aCell->GetNormalPosition() - aCell->GetPosition()); - - // The row group background goes at the position we'd find the cell if neither - // the cell's relative positioning nor the row's were applied. - aRowGroupBGRect = aRowBGRect + - (mRow.mFrame->GetNormalPosition() - mRow.mFrame->GetPosition()); - - // The column and column group backgrounds (they're always at the same - // location, since relative positioning doesn't apply to columns or column - // groups) are drawn at the position we'd find the cell if none of the cell's, - // row's, or row group's relative positioning were applied. - aColBGRect = aRowGroupBGRect + - (rowGroupFrame->GetNormalPosition() - rowGroupFrame->GetPosition()); - -} diff --git a/layout/tables/nsTablePainter.h b/layout/tables/nsTablePainter.h index 73d2874a09ac..bc00642a370b 100644 --- a/layout/tables/nsTablePainter.h +++ b/layout/tables/nsTablePainter.h @@ -131,34 +131,12 @@ class TableBackgroundPainter /** Paint table background layers for this cell space * Also paints cell's own background in border-collapse mode - * @param aCell - the cell - * @param aCellBGRect - background rect for the cell - * @param aRowBGRect - background rect for the row - * @param aRowGroupBGRect - background rect for the row group - * @param aColBGRect - background rect for the column and column group - * @param aPassSelf - pass this cell; i.e. paint only underlying layers + * @param aFrame - the cell + * @param aPassSelf - pass this cell; i.e. paint only underlying layers */ - nsresult PaintCell(nsTableCellFrame* aCell, - nsRect& aCellBGRect, - nsRect& aRowBGRect, - nsRect& aRowGroupBGRect, - nsRect& aColBGRect, + nsresult PaintCell(nsTableCellFrame* aFrame, bool aPassSelf); - /** Compute table background layer positions for this cell space - * @param aCell - the cell - * @param aCellBGRectOut - outparam: background rect for the cell - * @param aRowBGRectOut - outparam: background rect for the row - * @param aRowGroupBGRectOut - outparam: background rect for the row group - * @param aColBGRectOut - outparam: background rect for the column - and column group - */ - void ComputeCellBackgrounds(nsTableCellFrame* aCell, - nsRect& aCellBGRect, - nsRect& aRowBGRect, - nsRect& aRowGroupBGRect, - nsRect& aColBGRect); - /** Translate mRenderingContext, mDirtyRect, and mCols' column and * colgroup coords * @param aDX - origin's x-coord change @@ -236,6 +214,7 @@ class TableBackgroundPainter uint32_t mNumCols; TableBackgroundData mRowGroup; //current row group TableBackgroundData mRow; //current row + nsRect mCellRect; //current cell's rect nsStyleBorder mZeroBorder; //cached zero-width border uint32_t mBGPaintFlags; diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index 841e9b7423aa..843f167ece94 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -2,9 +2,6 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/Maybe.h" - #include "nsTableRowFrame.h" #include "nsTableRowGroupFrame.h" #include "nsIPresShell.h" @@ -398,7 +395,7 @@ nscoord nsTableRowFrame::GetRowBaseline(WritingMode aWritingMode) while (childFrame) { if (IS_TABLE_CELL(childFrame->GetType())) { nsIFrame* firstKid = childFrame->GetFirstPrincipalChild(); - ascent = std::max(ascent, firstKid->GetNormalRect().YMost()); + ascent = std::max(ascent, firstKid->GetRect().YMost()); } // Get the next child childFrame = iter.Next(); @@ -864,10 +861,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext, // Reflow the child frame nsRect kidRect = kidFrame->GetRect(); - nsPoint origKidNormalPosition = kidFrame->GetNormalPosition(); - MOZ_ASSERT(origKidNormalPosition.y == 0); nsRect kidVisualOverflow = kidFrame->GetVisualOverflowRect(); - nsPoint kidPosition(x, 0); bool firstReflow = (kidFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0; @@ -876,7 +870,6 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext, nscoord availCellWidth = CalcAvailWidth(aTableFrame, *cellFrame); - Maybe kidReflowState; nsHTMLReflowMetrics desiredSize(aReflowState); // If the avail width is not the same as last time we reflowed the cell or @@ -897,18 +890,19 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext, HasPctHeight()) { // Reflow the cell to fit the available width, height // XXX The old IR_ChildIsDirty code used availCellWidth here. - nsSize kidAvailSize(availCellWidth, aReflowState.AvailableHeight()); + nsSize kidAvailSize(availCellWidth, aReflowState.AvailableHeight()); // Reflow the child - kidReflowState.emplace(aPresContext, aReflowState, kidFrame, - LogicalSize(kidFrame->GetWritingMode(), - kidAvailSize), - nsHTMLReflowState::CALLER_WILL_INIT); + nsTableCellReflowState + kidReflowState(aPresContext, aReflowState, kidFrame, + LogicalSize(kidFrame->GetWritingMode(), + kidAvailSize), + nsHTMLReflowState::CALLER_WILL_INIT); InitChildReflowState(*aPresContext, kidAvailSize, borderCollapse, - *kidReflowState); + kidReflowState); nsReflowStatus status; - ReflowChild(kidFrame, aPresContext, desiredSize, *kidReflowState, + ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, x, 0, 0, status); // allow the table to determine if/how the table needs to be rebalanced @@ -918,7 +912,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext, } } else { - if (x != origKidNormalPosition.x) { + if (x != kidRect.x) { kidFrame->InvalidateFrameSubtree(); } @@ -963,18 +957,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext, // Place the child desiredSize.ISize(rowWM) = availCellWidth; - if (kidReflowState) { - // We reflowed. Apply relative positioning in the normal way. - kidReflowState->ApplyRelativePositioning(&kidPosition); - } else { - // We didn't reflow. To take relative positioning into account, - // translate the new position by the vector from the previous 'normal' - // position to the previous position. - // XXX(seth): This doesn't work for 'position: sticky'. - kidPosition += kidRect.TopLeft() - origKidNormalPosition; - } - FinishReflowChild(kidFrame, aPresContext, desiredSize, nullptr, - kidPosition.x, kidPosition.y, 0); + FinishReflowChild(kidFrame, aPresContext, desiredSize, nullptr, x, 0, 0); nsTableFrame::InvalidateTableFrame(kidFrame, kidRect, kidVisualOverflow, firstReflow); @@ -982,12 +965,11 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext, x += desiredSize.Width(); } else { - if (x != origKidNormalPosition.x) { + if (kidRect.x != x) { // Invalidate the old position kidFrame->InvalidateFrameSubtree(); - // Move to the new position. As above, we need to account for relative - // positioning. - kidFrame->MovePositionBy(nsPoint(x - origKidNormalPosition.x, 0)); + // move to the new position + kidFrame->SetPosition(nsPoint(x, kidRect.y)); nsTableFrame::RePositionViews(kidFrame); // invalidate the new position kidFrame->InvalidateFrameSubtree(); @@ -1277,16 +1259,14 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset, } nsRect oldCellRect = cellFrame->GetRect(); - nsPoint oldCellNormalPos = cellFrame->GetNormalPosition(); nsRect oldCellVisualOverflow = cellFrame->GetVisualOverflowRect(); - if (aRowOffset == 0 && cRect.TopLeft() != oldCellNormalPos) { + if (aRowOffset == 0 && cRect.TopLeft() != oldCellRect.TopLeft()) { // We're moving the cell. Invalidate the old overflow area cellFrame->InvalidateFrameSubtree(); } - cellFrame->MovePositionBy(cRect.TopLeft() - oldCellNormalPos); - cellFrame->SetSize(cRect.Size()); + cellFrame->SetRect(cRect); // XXXbz This looks completely bogus in the cases when we didn't // collapse the cell! diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index 47e0a2559630..09838eb3a5a8 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -205,8 +205,7 @@ DisplayRows(nsDisplayListBuilder* aBuilder, nsFrame* aFrame, if (kid) { // have a cursor, use it while (kid) { - if (kid->GetRect().y - overflowAbove >= aDirtyRect.YMost() && - kid->GetNormalRect().y - overflowAbove >= aDirtyRect.YMost()) + if (kid->GetRect().y - overflowAbove >= aDirtyRect.YMost()) break; f->BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists); kid = kid->GetNextSibling(); @@ -278,7 +277,6 @@ void nsTableRowGroupFrame::PlaceChild(nsPresContext* aPresContext, nsRowGroupReflowState& aReflowState, nsIFrame* aKidFrame, - nsPoint aKidPosition, nsHTMLReflowMetrics& aDesiredSize, const nsRect& aOriginalKidRect, const nsRect& aOriginalKidVisualOverflow) @@ -287,8 +285,8 @@ nsTableRowGroupFrame::PlaceChild(nsPresContext* aPresContext, (aKidFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0; // Place and size the child - FinishReflowChild(aKidFrame, aPresContext, aDesiredSize, nullptr, - aKidPosition.x, aKidPosition.y, 0); + FinishReflowChild(aKidFrame, aPresContext, aDesiredSize, nullptr, 0, + aReflowState.y, 0); nsTableFrame::InvalidateTableFrame(aKidFrame, aOriginalKidRect, aOriginalKidVisualOverflow, isFirstReflow); @@ -401,18 +399,16 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext, "If we're not on the first frame, we should have a " "previous sibling..."); // If prev row has nonzero YMost, then we can't be at the top of the page - if (prevKidFrame && prevKidFrame->GetNormalRect().YMost() > 0) { + if (prevKidFrame && prevKidFrame->GetRect().YMost() > 0) { kidReflowState.mFlags.mIsTopOfPage = false; } ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, 0, aReflowState.y, 0, aStatus); - nsPoint kidPosition(0, aReflowState.y); - kidReflowState.ApplyRelativePositioning(&kidPosition); // Place the child - PlaceChild(aPresContext, aReflowState, kidFrame, kidPosition, - desiredSize, oldKidRect, oldKidVisualOverflow); + PlaceChild(aPresContext, aReflowState, kidFrame, desiredSize, + oldKidRect, oldKidVisualOverflow); aReflowState.y += cellSpacingY; if (!reflowAllKids) { @@ -426,6 +422,8 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext, unit != eStyleUnit_Coord) { // Because other cells in the row may need to be aligned // differently, repaint the entire row + nsRect kidRect(0, aReflowState.y, + desiredSize.Width(), desiredSize.Height()); InvalidateFrame(); } else if (oldKidRect.height != desiredSize.Height()) @@ -550,7 +548,7 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext, if (!startRowFrame) return; // the current row group height is the y origin of the 1st row we are about to calculated a height for - nscoord startRowGroupHeight = startRowFrame->GetNormalPosition().y; + nscoord startRowGroupHeight = startRowFrame->GetPosition().y; int32_t numRows = GetRowCount() - (startRowFrame->GetRowIndex() - GetStartRowIndex()); // collect the current height of each row. nscoord* rowHeights = nullptr; @@ -779,26 +777,25 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext, for (rowFrame = startRowFrame, rowIndex = 0; rowFrame; rowFrame = rowFrame->GetNextRow(), rowIndex++) { nsRect rowBounds = rowFrame->GetRect(); nsRect rowVisualOverflow = rowFrame->GetVisualOverflowRect(); - nscoord deltaY = yOrigin - rowFrame->GetNormalPosition().y; + bool movedFrame = (rowBounds.y != yOrigin); nscoord rowHeight = (rowInfo[rowIndex].height > 0) ? rowInfo[rowIndex].height : 0; - if (deltaY != 0 || (rowHeight != rowBounds.height)) { + if (movedFrame || (rowHeight != rowBounds.height)) { // Resize/move the row to its final size and position - if (deltaY != 0) { + if (movedFrame) { rowFrame->InvalidateFrameSubtree(); } - rowFrame->MovePositionBy(nsPoint(0, deltaY)); - rowFrame->SetSize(nsSize(rowBounds.width, rowHeight)); + rowFrame->SetRect(nsRect(rowBounds.x, yOrigin, rowBounds.width, + rowHeight)); nsTableFrame::InvalidateTableFrame(rowFrame, rowBounds, rowVisualOverflow, false); - - if (deltaY != 0) { - nsTableFrame::RePositionViews(rowFrame); - // XXXbz we don't need to update our overflow area? - } + } + if (movedFrame) { + nsTableFrame::RePositionViews(rowFrame); + // XXXbz we don't need to update our overflow area? } yOrigin += rowHeight + tableFrame->GetCellSpacingY(startRowIndex + rowIndex); } @@ -871,12 +868,11 @@ nsTableRowGroupFrame::SlideChild(nsRowGroupReflowState& aReflowState, nsIFrame* aKidFrame) { // Move the frame if we need to - nsPoint oldPosition = aKidFrame->GetNormalPosition(); + nsPoint oldPosition = aKidFrame->GetPosition(); nsPoint newPosition = oldPosition; newPosition.y = aReflowState.y; if (oldPosition.y != newPosition.y) { aKidFrame->InvalidateFrameSubtree(); - aReflowState.reflowState.ApplyRelativePositioning(&newPosition); aKidFrame->SetPosition(newPosition); nsTableFrame::RePositionViews(aKidFrame); aKidFrame->InvalidateFrameSubtree(); @@ -930,7 +926,7 @@ nsTableRowGroupFrame::SplitSpanningCells(nsPresContext& aPresContext, for (nsTableRowFrame* row = &aFirstRow; !wasLast; row = row->GetNextRow()) { wasLast = (row == &aLastRow); int32_t rowIndex = row->GetRowIndex(); - nsPoint rowPos = row->GetNormalPosition(); + nsPoint rowPos = row->GetPosition(); // Iterate the cells looking for those that have rowspan > 1 for (nsTableCellFrame* cell = row->GetFirstCell(); cell; cell = cell->GetNextCell()) { int32_t rowSpan = aTable.GetEffectiveRowSpan(rowIndex, *cell); @@ -945,7 +941,7 @@ nsTableRowGroupFrame::SplitSpanningCells(nsPresContext& aPresContext, NS_ASSERTION(cellAvailHeight >= 0, "No space for cell?"); bool isTopOfPage = (row == &aFirstRow) && aFirstRowIsTopOfPage; - nsRect rowRect = row->GetNormalRect(); + nsRect rowRect = row->GetRect(); nsSize rowAvailSize(aReflowState.AvailableWidth(), std::max(aReflowState.AvailableHeight() - rowRect.y, 0)); @@ -995,7 +991,7 @@ nsTableRowGroupFrame::SplitSpanningCells(nsPresContext& aPresContext, } } if (!haveRowSpan) { - aDesiredHeight = aLastRow.GetNormalRect().YMost(); + aDesiredHeight = aLastRow.GetRect().YMost(); } } @@ -1076,7 +1072,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext, for (nsTableRowFrame* rowFrame = firstRowThisPage; rowFrame; rowFrame = rowFrame->GetNextRow()) { bool rowIsOnPage = true; nscoord cellSpacingY = aTableFrame->GetCellSpacingY(rowFrame->GetRowIndex()); - nsRect rowRect = rowFrame->GetNormalRect(); + nsRect rowRect = rowFrame->GetRect(); // See if the row fits on this page if (rowRect.YMost() > availHeight) { nsTableRowFrame* contRow = nullptr; @@ -1182,7 +1178,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext, break; } if (prevRowFrame) { - spanningRowBottom = prevRowFrame->GetNormalRect().YMost(); + spanningRowBottom = prevRowFrame->GetRect().YMost(); lastRowThisPage = prevRowFrame; isTopOfPage = (lastRowThisPage == firstRowThisPage) && aReflowState.mFlags.mIsTopOfPage; aStatus = NS_FRAME_NOT_COMPLETE; @@ -1219,7 +1215,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext, // Try to put firstTruncateRow on the next page nsTableRowFrame* rowBefore = ::GetRowBefore(*firstRowThisPage, *firstTruncatedRow); nscoord oldSpanningRowBottom = spanningRowBottom; - spanningRowBottom = rowBefore->GetNormalRect().YMost(); + spanningRowBottom = rowBefore->GetRect().YMost(); UndoContinuedRow(aPresContext, contRow); contRow = nullptr; @@ -1890,12 +1886,12 @@ nsTableRowGroupFrame::GetFirstRowContaining(nscoord aY, nscoord* aOverflowAbove) // encountering a row whose overflowArea.YMost() is <= aY but which has // a row above it containing cell(s) that span to include aY. while (cursorIndex > 0 && - cursorFrame->GetNormalRect().YMost() + property->mOverflowBelow > aY) { + cursorFrame->GetRect().YMost() + property->mOverflowBelow > aY) { --cursorIndex; cursorFrame = property->mFrames[cursorIndex]; } while (cursorIndex + 1 < frameCount && - cursorFrame->GetNormalRect().YMost() + property->mOverflowBelow <= aY) { + cursorFrame->GetRect().YMost() + property->mOverflowBelow <= aY) { ++cursorIndex; cursorFrame = property->mFrames[cursorIndex]; } @@ -1908,18 +1904,7 @@ nsTableRowGroupFrame::GetFirstRowContaining(nscoord aY, nscoord* aOverflowAbove) bool nsTableRowGroupFrame::FrameCursorData::AppendFrame(nsIFrame* aFrame) { - // Relative positioning can cause table parts to move, but we will still paint - // the backgrounds for the parts under them at their 'normal' position. That - // means that we must consider the overflow rects at both positions. For - // example, if we use relative positioning to move a row-spanning cell, we - // will still paint the row background for that cell at its normal position, - // which will overflow the row. - // XXX(seth): This probably isn't correct in the presence of transforms. - nsRect positionedOverflowRect = aFrame->GetVisualOverflowRect(); - nsPoint positionedToNormal = aFrame->GetNormalPosition() - aFrame->GetPosition(); - nsRect normalOverflowRect = positionedOverflowRect + positionedToNormal; - - nsRect overflowRect = positionedOverflowRect.Union(normalOverflowRect); + nsRect overflowRect = aFrame->GetVisualOverflowRect(); if (overflowRect.IsEmpty()) return true; nscoord overflowAbove = -overflowRect.y; diff --git a/layout/tables/nsTableRowGroupFrame.h b/layout/tables/nsTableRowGroupFrame.h index c10e6a092868..5becf9d55e6a 100644 --- a/layout/tables/nsTableRowGroupFrame.h +++ b/layout/tables/nsTableRowGroupFrame.h @@ -339,7 +339,6 @@ protected: void PlaceChild(nsPresContext* aPresContext, nsRowGroupReflowState& aReflowState, nsIFrame* aKidFrame, - nsPoint aKidPosition, nsHTMLReflowMetrics& aDesiredSize, const nsRect& aOriginalKidRect, const nsRect& aOriginalKidVisualOverflow);