Bug 1227927 Part 3 - Use ranged-based for-loop to rewrite some simple loops in part 2. r=mats

This commit is contained in:
Ting-Yu Lin 2016-01-29 22:42:15 +08:00
parent a6c945b2bc
commit 7f8f643423
29 changed files with 46 additions and 131 deletions

View File

@ -331,12 +331,10 @@ LineHasNonEmptyContentWorker(nsIFrame* aFrame)
// Look for non-empty frames, but ignore inline and br frames.
// For inline frames, descend into the children, if any.
if (aFrame->GetType() == nsGkAtoms::inlineFrame) {
nsIFrame* child = aFrame->PrincipalChildList().FirstChild();
while (child) {
for (nsIFrame* child : aFrame->PrincipalChildList()) {
if (LineHasNonEmptyContentWorker(child)) {
return true;
}
child = child->GetNextSibling();
}
} else {
if (aFrame->GetType() != nsGkAtoms::brFrame &&

View File

@ -9885,13 +9885,11 @@ static nsCanvasFrame* FindCanvasFrame(nsIFrame* aFrame)
return canvasFrame;
}
nsIFrame* kid = aFrame->PrincipalChildList().FirstChild();
while (kid) {
for (nsIFrame* kid : aFrame->PrincipalChildList()) {
canvasFrame = FindCanvasFrame(kid);
if (canvasFrame) {
return canvasFrame;
}
kid = kid->GetNextSibling();
}
return nullptr;

View File

@ -2917,9 +2917,7 @@ HTMLInputElement::Focus(ErrorResult& aError)
// tab to the next one.
nsIFrame* frame = GetPrimaryFrame();
if (frame) {
for (nsIFrame* childFrame = frame->PrincipalChildList().FirstChild();
childFrame;
childFrame = childFrame->GetNextSibling()) {
for (nsIFrame* childFrame : frame->PrincipalChildList()) {
// See if the child is a button control.
nsCOMPtr<nsIFormControl> formCtrl =
do_QueryInterface(childFrame->GetContent());

View File

@ -1650,10 +1650,7 @@ nsBidiPresUtils::InitContinuationStates(nsIFrame* aFrame,
if (!IsBidiLeaf(aFrame) || RubyUtils::IsRubyBox(aFrame->GetType())) {
// Continue for child frames
nsIFrame* frame;
for (frame = aFrame->PrincipalChildList().FirstChild();
frame;
frame = frame->GetNextSibling()) {
for (nsIFrame* frame : aFrame->PrincipalChildList()) {
InitContinuationStates(frame,
aContinuationStates);
}

View File

@ -8566,8 +8566,7 @@ nsCSSFrameConstructor::CreateContinuingTableFrame(nsIPresShell* aPresShell,
// Replicate any header/footer frames
nsFrameItems childFrames;
nsIFrame* childFrame = aFrame->PrincipalChildList().FirstChild();
for ( ; childFrame; childFrame = childFrame->GetNextSibling()) {
for (nsIFrame* childFrame : aFrame->PrincipalChildList()) {
// See if it's a header/footer, possibly wrapped in a scroll frame.
nsTableRowGroupFrame* rowGroupFrame =
static_cast<nsTableRowGroupFrame*>(childFrame);

View File

@ -62,7 +62,7 @@ CheckForTrailingTextFrameRecursive(nsIFrame* aFrame, nsIFrame* aStopAtFrame)
if (!aFrame->IsFrameOfType(nsIFrame::eLineParticipant))
return nullptr;
for (nsIFrame* f = aFrame->PrincipalChildList().FirstChild(); f; f = f->GetNextSibling())
for (nsIFrame* f : aFrame->PrincipalChildList())
{
nsIFrame* r = CheckForTrailingTextFrameRecursive(f, aStopAtFrame);
if (r)

View File

@ -3795,8 +3795,7 @@ nsDocumentViewer::PrintPreviewNavigate(int16_t aType, int32_t aPageNum)
// Now, locate the current page we are on and
// and the page of the page number
nsIFrame* pageFrame = seqFrame->PrincipalChildList().FirstChild();
while (pageFrame != nullptr) {
for (nsIFrame* pageFrame : seqFrame->PrincipalChildList()) {
nsRect pageRect = pageFrame->GetRect();
if (pageRect.Contains(pageRect.x, pt.y)) {
currentPage = pageFrame;
@ -3806,7 +3805,6 @@ nsDocumentViewer::PrintPreviewNavigate(int16_t aType, int32_t aPageNum)
break;
}
pageNum++;
pageFrame = pageFrame->GetNextSibling();
}
if (aType == nsIWebBrowserPrint::PRINTPREVIEW_PREV_PAGE) {

View File

@ -9591,13 +9591,11 @@ FindTopFrame(nsIFrame* aRoot)
}
// Try one of the children
nsIFrame* kid = aRoot->PrincipalChildList().FirstChild();
while (nullptr != kid) {
for (nsIFrame* kid : aRoot->PrincipalChildList()) {
nsIFrame* result = FindTopFrame(kid);
if (nullptr != result) {
return result;
}
kid = kid->GetNextSibling();
}
}
return nullptr;
@ -10177,10 +10175,8 @@ static void RecurseIndiTotals(nsPresContext* aPresContext,
free(name);
}
nsIFrame* child = aParentFrame->PrincipalChildList().FirstChild();
while (child) {
for (nsIFrame* child : aParentFrame->PrincipalChildList()) {
RecurseIndiTotals(aPresContext, aHT, child, aLevel+1);
child = child->GetNextSibling();
}
}

View File

@ -265,8 +265,7 @@ static nscoord
GetMaxOptionBSize(nsIFrame* aContainer, WritingMode aWM)
{
nscoord result = 0;
for (nsIFrame* option = aContainer->PrincipalChildList().FirstChild();
option; option = option->GetNextSibling()) {
for (nsIFrame* option : aContainer->PrincipalChildList()) {
nscoord optionBSize;
if (nsCOMPtr<nsIDOMHTMLOptGroupElement>
(do_QueryInterface(option->GetContent()))) {

View File

@ -380,13 +380,11 @@ TextOverflow::ExamineFrameSubtree(nsIFrame* aFrame,
return;
}
nsIFrame* child = aFrame->PrincipalChildList().FirstChild();
while (child) {
for (nsIFrame* child : aFrame->PrincipalChildList()) {
ExamineFrameSubtree(child, aContentArea, aInsideMarkersArea,
aFramesToHide, aAlignmentEdges,
aFoundVisibleTextOrAtomic,
aClippedMarkerEdges);
child = child->GetNextSibling();
}
}

View File

@ -434,8 +434,7 @@ nsCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
}
}
nsIFrame* kid;
for (kid = PrincipalChildList().FirstChild(); kid; kid = kid->GetNextSibling()) {
for (nsIFrame* kid : PrincipalChildList()) {
// Put our child into its own pseudo-stack.
BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists);
}

View File

@ -3913,8 +3913,7 @@ ScrollFrameHelper::ReloadChildFrames()
mScrollCornerBox = nullptr;
mResizerBox = nullptr;
nsIFrame* frame = mOuter->PrincipalChildList().FirstChild();
while (frame) {
for (nsIFrame* frame : mOuter->PrincipalChildList()) {
nsIContent* content = frame->GetContent();
if (content == mOuter->GetContent()) {
NS_ASSERTION(!mScrolledFrame, "Already found the scrolled frame");
@ -3940,8 +3939,6 @@ ScrollFrameHelper::ReloadChildFrames()
mScrollCornerBox = frame;
}
}
frame = frame->GetNextSibling();
}
}

View File

@ -1771,9 +1771,7 @@ nsPluginFrame::SetIsDocumentActive(bool aIsActive)
nsIObjectFrame *
nsPluginFrame::GetNextObjectFrame(nsPresContext* aPresContext, nsIFrame* aRoot)
{
nsIFrame* child = aRoot->PrincipalChildList().FirstChild();
while (child) {
for (nsIFrame* child : aRoot->PrincipalChildList()) {
nsIObjectFrame* outFrame = do_QueryFrame(child);
if (outFrame) {
RefPtr<nsNPAPIPluginInstance> pi;
@ -1785,7 +1783,6 @@ nsPluginFrame::GetNextObjectFrame(nsPresContext* aPresContext, nsIFrame* aRoot)
outFrame = GetNextObjectFrame(aPresContext, child);
if (outFrame)
return outFrame;
child = child->GetNextSibling();
}
return nullptr;

View File

@ -531,8 +531,7 @@ nsMathMLContainerFrame::FinalizeReflow(DrawTarget* aDrawTarget,
{
// The Place() call above didn't request FinishReflowChild(),
// so let's check that we eventually did through Stretch().
nsIFrame* childFrame = PrincipalChildList().FirstChild();
for ( ; childFrame; childFrame = childFrame->GetNextSibling()) {
for (nsIFrame* childFrame : PrincipalChildList()) {
NS_ASSERTION(!(childFrame->GetStateBits() & NS_FRAME_IN_REFLOW),
"DidReflow() was never called");
}
@ -587,11 +586,9 @@ nsMathMLContainerFrame::PropagatePresentationDataFor(nsIFrame* aFrame,
}
else {
// propagate down the subtrees
nsIFrame* childFrame = aFrame->PrincipalChildList().FirstChild();
while (childFrame) {
for (nsIFrame* childFrame : aFrame->PrincipalChildList()) {
PropagatePresentationDataFor(childFrame,
aFlagsValues, aFlagsToUpdate);
childFrame = childFrame->GetNextSibling();
}
}
}
@ -606,8 +603,7 @@ nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(nsIFrame* aPa
if (!aParentFrame || !aFlagsToUpdate)
return;
int32_t index = 0;
nsIFrame* childFrame = aParentFrame->PrincipalChildList().FirstChild();
while (childFrame) {
for (nsIFrame* childFrame : aParentFrame->PrincipalChildList()) {
if ((index >= aFirstChildIndex) &&
((aLastChildIndex <= 0) || ((aLastChildIndex > 0) &&
(index <= aLastChildIndex)))) {
@ -615,7 +611,6 @@ nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(nsIFrame* aPa
aFlagsValues, aFlagsToUpdate);
}
index++;
childFrame = childFrame->GetNextSibling();
}
}
@ -666,14 +661,12 @@ nsMathMLContainerFrame::RebuildAutomaticDataForChildren(nsIFrame* aParentFrame)
// the parent
// 2. As we ascend the tree, transmit any specific change that we want
// down the subtrees
nsIFrame* childFrame = aParentFrame->PrincipalChildList().FirstChild();
while (childFrame) {
for (nsIFrame* childFrame : aParentFrame->PrincipalChildList()) {
nsIMathMLFrame* childMathMLFrame = do_QueryFrame(childFrame);
if (childMathMLFrame) {
childMathMLFrame->InheritAutomaticData(aParentFrame);
}
RebuildAutomaticDataForChildren(childFrame);
childFrame = childFrame->GetNextSibling();
}
nsIMathMLFrame* mathMLFrame = do_QueryFrame(aParentFrame);
if (mathMLFrame) {
@ -1555,10 +1548,8 @@ nsMathMLContainerFrame::PropagateFrameFlagFor(nsIFrame* aFrame,
return;
aFrame->AddStateBits(aFlags);
nsIFrame* childFrame = aFrame->PrincipalChildList().FirstChild();
while (childFrame) {
for (nsIFrame* childFrame : aFrame->PrincipalChildList()) {
PropagateFrameFlagFor(childFrame, aFlags);
childFrame = childFrame->GetNextSibling();
}
}

View File

@ -132,8 +132,7 @@ nsMathMLTokenFrame::Reflow(nsPresContext* aPresContext,
aDesiredSize.SetBlockStartAscent(0);
aDesiredSize.mBoundingMetrics = nsBoundingMetrics();
nsIFrame* childFrame = PrincipalChildList().FirstChild();
while (childFrame) {
for (nsIFrame* childFrame : PrincipalChildList()) {
// ask our children to compute their bounding metrics
nsHTMLReflowMetrics childDesiredSize(aReflowState.GetWritingMode(),
aDesiredSize.mFlags
@ -148,8 +147,6 @@ nsMathMLTokenFrame::Reflow(nsPresContext* aPresContext,
//NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
childDesiredSize.mBoundingMetrics);
childFrame = childFrame->GetNextSibling();
}
// place and size children
@ -168,8 +165,7 @@ nsMathMLTokenFrame::Place(DrawTarget* aDrawTarget,
nsHTMLReflowMetrics& aDesiredSize)
{
mBoundingMetrics = nsBoundingMetrics();
for (nsIFrame* childFrame = PrincipalChildList().FirstChild(); childFrame;
childFrame = childFrame->GetNextSibling()) {
for (nsIFrame* childFrame :PrincipalChildList()) {
nsHTMLReflowMetrics childSize(aDesiredSize.GetWritingMode());
GetReflowAndBoundingMetricsFor(childFrame, childSize,
childSize.mBoundingMetrics, nullptr);
@ -192,8 +188,7 @@ nsMathMLTokenFrame::Place(DrawTarget* aDrawTarget,
if (aPlaceOrigin) {
nscoord dy, dx = 0;
for (nsIFrame* childFrame = PrincipalChildList().FirstChild(); childFrame;
childFrame = childFrame->GetNextSibling()) {
for (nsIFrame* childFrame : PrincipalChildList()) {
nsHTMLReflowMetrics childSize(aDesiredSize.GetWritingMode());
GetReflowAndBoundingMetricsFor(childFrame, childSize,
childSize.mBoundingMetrics);

View File

@ -626,8 +626,7 @@ nsMathMLmfencedFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingCon
}
int32_t i = 0;
nsIFrame* childFrame = PrincipalChildList().FirstChild();
while (childFrame) {
for (nsIFrame* childFrame : PrincipalChildList()) {
// XXX This includes margin while Reflow currently doesn't consider
// margin, so we may end up with too much space, but, with stretchy
// characters, this is an approximation anyway.
@ -641,8 +640,6 @@ nsMathMLmfencedFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingCon
NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel, em);
}
i++;
childFrame = childFrame->GetNextSibling();
}
if (mCloseChar) {

View File

@ -581,8 +581,7 @@ MapAllAttributesIntoCSS(nsMathMLmtableFrame* aTableFrame)
if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame)
return;
nsIFrame* rowFrame = rgFrame->PrincipalChildList().FirstChild();
for ( ; rowFrame; rowFrame = rowFrame->GetNextSibling()) {
for (nsIFrame* rowFrame : rgFrame->PrincipalChildList()) {
DEBUG_VERIFY_THAT_FRAME_IS(rowFrame, TABLE_ROW);
if (rowFrame->GetType() == nsGkAtoms::tableRowFrame) {
// Map row rowalign.
@ -590,8 +589,7 @@ MapAllAttributesIntoCSS(nsMathMLmtableFrame* aTableFrame)
// Map row columnalign.
ParseFrameAttribute(rowFrame, nsGkAtoms::columnalign_, true);
nsIFrame* cellFrame = rowFrame->PrincipalChildList().FirstChild();
for ( ; cellFrame; cellFrame = cellFrame->GetNextSibling()) {
for (nsIFrame* cellFrame : rowFrame->PrincipalChildList()) {
DEBUG_VERIFY_THAT_FRAME_IS(cellFrame, TABLE_CELL);
if (IS_TABLE_CELL(cellFrame->GetType())) {
// Map cell rowalign.

View File

@ -2238,11 +2238,7 @@ nsPrintEngine::CalcNumPrintablePages(int32_t& aNumPages)
nsIPageSequenceFrame* pageSequence = po->mPresShell->GetPageSequenceFrame();
nsIFrame * seqFrame = do_QueryFrame(pageSequence);
if (seqFrame) {
nsIFrame* frame = seqFrame->PrincipalChildList().FirstChild();
while (frame) {
aNumPages++;
frame = frame->GetNextSibling();
}
aNumPages += seqFrame->PrincipalChildList().GetLength();
}
}
}
@ -2879,8 +2875,7 @@ nsPrintEngine::GetPageRangeForSelection(nsIPageSequenceFrame* aPageSeqFrame,
// Now that we have the page frames
// find out what the page numbers are for each frame
int32_t pageNum = 1;
nsIFrame* page = seqFrame->PrincipalChildList().FirstChild();
while (page != nullptr) {
for (nsIFrame* page : seqFrame->PrincipalChildList()) {
if (page == startPageFrame) {
aStartPageNum = pageNum;
}
@ -2888,7 +2883,6 @@ nsPrintEngine::GetPageRangeForSelection(nsIPageSequenceFrame* aPageSeqFrame,
aEndPageNum = pageNum;
}
pageNum++;
page = page->GetNextSibling();
}
#ifdef DEBUG_rodsX

View File

@ -1477,9 +1477,7 @@ TextNodeCorrespondenceRecorder::TraverseAndRecord(nsIFrame* aFrame)
// Recursively iterate over the frame tree, for frames that correspond
// to text content elements.
if (IsTextContentElement(aFrame->GetContent())) {
for (nsIFrame* f = aFrame->PrincipalChildList().FirstChild();
f;
f = f->GetNextSibling()) {
for (nsIFrame* f : aFrame->PrincipalChildList()) {
TraverseAndRecord(f);
}
return;

View File

@ -340,8 +340,7 @@ nsSVGClipPathFrame::IsValid()
nsIAtom *type = kid->GetType();
if (type == nsGkAtoms::svgUseFrame) {
for (nsIFrame* grandKid = kid->PrincipalChildList().FirstChild(); grandKid;
grandKid = grandKid->GetNextSibling()) {
for (nsIFrame* grandKid : kid->PrincipalChildList()) {
nsIAtom *type = grandKid->GetType();

View File

@ -112,8 +112,7 @@ nsSVGContainerFrame::ReflowSVGNonDisplayText(nsIFrame* aContainer)
!aContainer->IsFrameOfType(nsIFrame::eSVG),
"it is wasteful to call ReflowSVGNonDisplayText on a container "
"frame that is not NS_FRAME_IS_NONDISPLAY");
for (nsIFrame* kid = aContainer->PrincipalChildList().FirstChild(); kid;
kid = kid->GetNextSibling()) {
for (nsIFrame* kid : aContainer->PrincipalChildList()) {
nsIAtom* type = kid->GetType();
if (type == nsGkAtoms::svgTextFrame) {
static_cast<SVGTextFrame*>(kid)->ReflowSVGNonDisplayText();

View File

@ -425,8 +425,7 @@ nsSVGOuterSVGFrame::Reflow(nsPresContext* aPresContext,
if (svgElem->HasViewBoxOrSyntheticViewBox()) {
nsIFrame* anonChild = PrincipalChildList().FirstChild();
anonChild->AddStateBits(NS_FRAME_IS_DIRTY);
for (nsIFrame* child = anonChild->PrincipalChildList().FirstChild(); child;
child = child->GetNextSibling()) {
for (nsIFrame* child : anonChild->PrincipalChildList()) {
child->AddStateBits(NS_FRAME_IS_DIRTY);
}
}

View File

@ -432,9 +432,7 @@ nsSVGUtils::GetUserToCanvasTM(nsIFrame *aFrame)
void
nsSVGUtils::NotifyChildrenOfSVGChange(nsIFrame *aFrame, uint32_t aFlags)
{
nsIFrame *kid = aFrame->PrincipalChildList().FirstChild();
while (kid) {
for (nsIFrame* kid : aFrame->PrincipalChildList()) {
nsISVGChildFrame* SVGFrame = do_QueryFrame(kid);
if (SVGFrame) {
SVGFrame->NotifySVGChanged(aFlags);
@ -447,7 +445,6 @@ nsSVGUtils::NotifyChildrenOfSVGChange(nsIFrame *aFrame, uint32_t aFlags)
NotifyChildrenOfSVGChange(kid, aFlags);
}
}
kid = kid->GetNextSibling();
}
}

View File

@ -1569,8 +1569,7 @@ bool nsCellMap::CellsSpanOut(nsTArray<nsTableRowFrame*>& aRows) const
int32_t numNewRows = aRows.Length();
for (int32_t rowX = 0; rowX < numNewRows; rowX++) {
nsIFrame* rowFrame = (nsIFrame *) aRows.ElementAt(rowX);
nsIFrame* childFrame = rowFrame->PrincipalChildList().FirstChild();
while (childFrame) {
for (nsIFrame* childFrame : rowFrame->PrincipalChildList()) {
nsTableCellFrame *cellFrame = do_QueryFrame(childFrame);
if (cellFrame) {
bool zeroSpan;
@ -1579,7 +1578,6 @@ bool nsCellMap::CellsSpanOut(nsTArray<nsTableRowFrame*>& aRows) const
return true;
}
}
childFrame = childFrame->GetNextSibling();
}
}
return false;
@ -1741,15 +1739,13 @@ nsCellMap::ExpandWithRows(nsTableCellMap& aMap,
for (int32_t rowX = startRowIndex; rowX <= endRowIndex; rowX++) {
nsTableRowFrame* rFrame = aRowFrames.ElementAt(newRowIndex);
// append cells
nsIFrame* cFrame = rFrame->PrincipalChildList().FirstChild();
int32_t colIndex = 0;
while (cFrame) {
for (nsIFrame* cFrame : rFrame->PrincipalChildList()) {
nsTableCellFrame *cellFrame = do_QueryFrame(cFrame);
if (cellFrame) {
AppendCell(aMap, cellFrame, rowX, false, aRgFirstRowIndex, aDamageArea,
&colIndex);
}
cFrame = cFrame->GetNextSibling();
}
newRowIndex++;
}
@ -2186,13 +2182,11 @@ nsCellMap::RebuildConsideringRows(nsTableCellMap& aMap,
int32_t numNewRows = aRowsToInsert->Length();
for (int32_t newRowX = 0; newRowX < numNewRows; newRowX++) {
nsTableRowFrame* rFrame = aRowsToInsert->ElementAt(newRowX);
nsIFrame* cFrame = rFrame->PrincipalChildList().FirstChild();
while (cFrame) {
for (nsIFrame* cFrame : rFrame->PrincipalChildList()) {
nsTableCellFrame *cellFrame = do_QueryFrame(cFrame);
if (cellFrame) {
AppendCell(aMap, cellFrame, rowX, false, 0, damageArea);
}
cFrame = cFrame->GetNextSibling();
}
rowX++;
}

View File

@ -699,8 +699,7 @@ nsTableCellFrame::CellHasVisibleContent(nscoord height,
return true;
if (tableFrame->IsBorderCollapse())
return true;
nsIFrame* innerFrame = kidFrame->PrincipalChildList().FirstChild();
while(innerFrame) {
for (nsIFrame* innerFrame : kidFrame->PrincipalChildList()) {
nsIAtom* frameType = innerFrame->GetType();
if (nsGkAtoms::textFrame == frameType) {
nsTextFrame* textFrame = static_cast<nsTextFrame*>(innerFrame);
@ -715,7 +714,6 @@ nsTableCellFrame::CellHasVisibleContent(nscoord height,
if (floatFrame)
return true;
}
innerFrame = innerFrame->GetNextSibling();
}
return false;
}

View File

@ -988,11 +988,9 @@ nsTableFrame::CollectRows(nsIFrame* aFrame,
{
NS_PRECONDITION(aFrame, "null frame");
int32_t numRows = 0;
nsIFrame* childFrame = aFrame->PrincipalChildList().FirstChild();
while (childFrame) {
for (nsIFrame* childFrame : aFrame->PrincipalChildList()) {
aCollection.AppendElement(static_cast<nsTableRowFrame*>(childFrame));
numRows++;
childFrame = childFrame->GetNextSibling();
}
return numRows;
}
@ -1206,10 +1204,8 @@ nsTableFrame::GenericTraversal(nsDisplayListBuilder* aBuilder, nsFrame* aFrame,
// stacking context, in which case the child won't use its passed-in
// BorderBackground list anyway. It does affect cell borders though; this
// lets us get cell borders into the nsTableFrame's BorderBackground list.
nsIFrame* kid = aFrame->PrincipalChildList().FirstChild();
while (kid) {
for (nsIFrame* kid : aFrame->PrincipalChildList()) {
aFrame->BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists);
kid = kid->GetNextSibling();
}
}
@ -1504,9 +1500,8 @@ nsTableFrame::ProcessRowInserted(nscoord aNewBSize)
for (uint32_t rgIdx = 0; rgIdx < rowGroups.Length(); rgIdx++) {
nsTableRowGroupFrame* rgFrame = rowGroups[rgIdx];
NS_ASSERTION(rgFrame, "Must have rgFrame here");
nsIFrame* childFrame = rgFrame->PrincipalChildList().FirstChild();
// find the row that was inserted first
while (childFrame) {
for (nsIFrame* childFrame : rgFrame->PrincipalChildList()) {
nsTableRowFrame *rowFrame = do_QueryFrame(childFrame);
if (rowFrame) {
if (rowFrame->IsFirstInserted()) {
@ -1518,7 +1513,6 @@ nsTableFrame::ProcessRowInserted(nscoord aNewBSize)
return; // found it, so leave
}
}
childFrame = childFrame->GetNextSibling();
}
}
}
@ -3940,28 +3934,24 @@ nsTableFrame::DumpRowGroup(nsIFrame* aKidFrame)
if (!aKidFrame)
return;
nsIFrame* cFrame = aKidFrame->PrincipalChildList().FirstChild();
while (cFrame) {
for (nsIFrame* cFrame : aKidFrame->PrincipalChildList()) {
nsTableRowFrame *rowFrame = do_QueryFrame(cFrame);
if (rowFrame) {
printf("row(%d)=%p ", rowFrame->GetRowIndex(),
static_cast<void*>(rowFrame));
nsIFrame* childFrame = cFrame->PrincipalChildList().FirstChild();
while (childFrame) {
for (nsIFrame* childFrame : cFrame->PrincipalChildList()) {
nsTableCellFrame *cellFrame = do_QueryFrame(childFrame);
if (cellFrame) {
int32_t colIndex;
cellFrame->GetColIndex(colIndex);
printf("cell(%d)=%p ", colIndex, static_cast<void*>(childFrame));
}
childFrame = childFrame->GetNextSibling();
}
printf("\n");
}
else {
DumpRowGroup(rowFrame);
}
cFrame = cFrame->GetNextSibling();
}
}

View File

@ -233,8 +233,7 @@ nsScrollbarButtonFrame::GetChildWithTag(nsIAtom* atom, nsIFrame* start,
nsIFrame*& result)
{
// recursively search our children
nsIFrame* childFrame = start->PrincipalChildList().FirstChild();
while (nullptr != childFrame)
for (nsIFrame* childFrame : start->PrincipalChildList())
{
// get the content node
nsIContent* child = childFrame->GetContent();
@ -253,8 +252,6 @@ nsScrollbarButtonFrame::GetChildWithTag(nsIAtom* atom, nsIFrame* start,
GetChildWithTag(atom, childFrame, result);
if (result != nullptr)
return NS_OK;
childFrame = childFrame->GetNextSibling();
}
result = nullptr;

View File

@ -2087,10 +2087,7 @@ nsNativeThemeCocoa::GetScrollbarPressStates(nsIFrame* aFrame,
};
// Get the state of any scrollbar buttons in our child frames
for (nsIFrame *childFrame = aFrame->PrincipalChildList().FirstChild();
childFrame;
childFrame = childFrame->GetNextSibling()) {
for (nsIFrame *childFrame : aFrame->PrincipalChildList()) {
nsIContent *childContent = childFrame->GetContent();
if (!childContent) continue;
int32_t attrIndex = childContent->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::sbattr,

View File

@ -486,12 +486,10 @@ nsNativeTheme::IsFirstTab(nsIFrame* aFrame)
if (!aFrame)
return false;
nsIFrame* first = aFrame->GetParent()->PrincipalChildList().FirstChild();
while (first) {
for (nsIFrame* first : aFrame->GetParent()->PrincipalChildList()) {
if (first->GetRect().width > 0 &&
first->GetContent()->IsXULElement(nsGkAtoms::tab))
return (first == aFrame);
first = first->GetNextSibling();
}
return false;
}