NS_IMETHODIMP nsTableOuterFrame::SetInitialChildList(nsIAtom* aListName, nsFrameList& aChildList) { if (nsGkAtoms::captionList == aListName) { // the frame constructor already checked for table-caption display type mCaptionFrames.SetFrames(aChildList); mCaptionFrame = mCaptionFrames.FirstChild(); } else { NS_ASSERTION(!aListName, "wrong childlist"); NS_ASSERTION(mFrames.IsEmpty(), "Frame leak!"); mInnerTableFrame = nsnull; if (aChildList.NotEmpty()) { if (nsGkAtoms::tableFrame == aChildList.FirstChild()->GetType()) { mInnerTableFrame = (nsTableFrame*)aChildList.FirstChild(); mFrames.SetFrames(aChildList); } else { NS_ERROR("expected a table frame"); return NS_ERROR_INVALID_ARG; } } } return NS_OK; }
NS_IMETHODIMP nsTableOuterFrame::AppendFrames(ChildListID aListID, nsFrameList& aFrameList) { nsresult rv; // We only have two child frames: the inner table and a caption frame. // The inner frame is provided when we're initialized, and it cannot change if (kCaptionList == aListID) { NS_ASSERTION(aFrameList.IsEmpty() || aFrameList.FirstChild()->GetType() == nsGkAtoms::tableCaptionFrame, "appending non-caption frame to captionList"); mCaptionFrames.AppendFrames(this, aFrameList); rv = NS_OK; // Reflow the new caption frame. It's already marked dirty, so // just tell the pres shell. PresContext()->PresShell()-> FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_HAS_DIRTY_CHILDREN); } else { NS_PRECONDITION(false, "unexpected child list"); rv = NS_ERROR_UNEXPECTED; } return rv; }
NS_IMETHODIMP nsCanvasFrame::AppendFrames(ChildListID aListID, nsFrameList& aFrameList) { NS_ASSERTION(aListID == kPrincipalList || aListID == kAbsoluteList, "unexpected child list ID"); NS_PRECONDITION(aListID != kAbsoluteList || mFrames.IsEmpty(), "already have a child frame"); if (aListID != kPrincipalList) { // We only support the Principal and Absolute child lists. return NS_ERROR_INVALID_ARG; } if (!mFrames.IsEmpty()) { // We only allow a single principal child frame. return NS_ERROR_INVALID_ARG; } // Insert the new frames NS_ASSERTION(aFrameList.FirstChild() == aFrameList.LastChild(), "Only one principal child frame allowed"); #ifdef DEBUG nsFrame::VerifyDirtyBitSet(aFrameList); #endif mFrames.AppendFrames(nullptr, aFrameList); PresContext()->PresShell()-> FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_HAS_DIRTY_CHILDREN); return NS_OK; }
NS_IMETHODIMP nsTableOuterFrame::InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame, nsFrameList& aFrameList) { if (kCaptionList == aListID) { NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this, "inserting after sibling frame with different parent"); NS_ASSERTION(aFrameList.IsEmpty() || aFrameList.FirstChild()->GetType() == nsGkAtoms::tableCaptionFrame, "inserting non-caption frame into captionList"); mCaptionFrames.InsertFrames(nsnull, aPrevFrame, aFrameList); // Reflow the new caption frame. It's already marked dirty, so // just tell the pres shell. PresContext()->PresShell()-> FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_HAS_DIRTY_CHILDREN); return NS_OK; } else { NS_PRECONDITION(!aPrevFrame, "invalid previous frame"); return AppendFrames(aListID, aFrameList); } }
NS_IMETHODIMP nsCanvasFrame::SetInitialChildList(ChildListID aListID, nsFrameList& aChildList) { NS_ASSERTION(aListID != kPrincipalList || aChildList.IsEmpty() || aChildList.OnlyChild(), "Primary child list can have at most one frame in it"); return nsContainerFrame::SetInitialChildList(aListID, aChildList); }
void nsCanvasFrame::AppendFrames(ChildListID aListID, nsFrameList& aFrameList) { MOZ_ASSERT(aListID == kPrincipalList, "unexpected child list"); MOZ_ASSERT(mFrames.IsEmpty(), "already have a child frame"); MOZ_ASSERT(aFrameList.FirstChild() == aFrameList.LastChild(), "Only one principal child frame allowed"); nsFrame::VerifyDirtyBitSet(aFrameList); nsContainerFrame::AppendFrames(aListID, aFrameList); }
nsresult nsPopupSetFrame::AddPopupFrameList(nsFrameList& aPopupFrameList) { while (!aPopupFrameList.IsEmpty()) { nsIFrame* f = aPopupFrameList.FirstChild(); // Clears out prev/next sibling points appropriately. Every frame // in our popup list has null next and prev pointers, they're logically // each in their own list. aPopupFrameList.RemoveFrame(f); nsresult rv = AddPopupFrame(f); NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; }
NS_IMETHODIMP nsSVGDisplayContainerFrame::InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame, nsFrameList& aFrameList) { // memorize first old frame after insertion point // XXXbz once again, this would work a lot better if the nsIFrame // methods returned framelist iterators.... nsIFrame* firstOldFrame = aPrevFrame ? aPrevFrame->GetNextSibling() : GetChildList(aListID).FirstChild(); nsIFrame* firstNewFrame = aFrameList.FirstChild(); // Insert the new frames nsSVGContainerFrame::InsertFrames(aListID, aPrevFrame, aFrameList); // Call InitialUpdate on the new frames ONLY if our nsSVGOuterSVGFrame has had // its initial reflow (our NS_FRAME_FIRST_REFLOW bit is clear) - bug 399863. if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) { for (nsIFrame* kid = firstNewFrame; kid != firstOldFrame; kid = kid->GetNextSibling()) { nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { SVGFrame->InitialUpdate(); } } } return NS_OK; }
// don't set mColCount here, it is done in AddColsToTable NS_IMETHODIMP nsTableColGroupFrame::SetInitialChildList(ChildListID aListID, nsFrameList& aChildList) { if (!mFrames.IsEmpty()) { // We already have child frames which means we've already been // initialized NS_NOTREACHED("unexpected second call to SetInitialChildList"); return NS_ERROR_UNEXPECTED; } if (aListID != kPrincipalList) { // All we know about is the principal child list. NS_NOTREACHED("unknown frame list"); return NS_ERROR_INVALID_ARG; } nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this); if (aChildList.IsEmpty()) { tableFrame->AppendAnonymousColFrames(this, GetSpan(), eColAnonymousColGroup, false); return NS_OK; } mFrames.AppendFrames(this, aChildList); return NS_OK; }
void nsMenuFrame::InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame, nsFrameList& aFrameList) { if (!HasPopup() && (aListID == kPrincipalList || aListID == kPopupList)) { SetPopupFrame(aFrameList); if (HasPopup()) { #ifdef DEBUG_LAYOUT nsBoxLayoutState state(PresContext()); SetXULDebug(state, aFrameList, mState & NS_STATE_CURRENTLY_IN_DEBUG); #endif PresContext()->PresShell()-> FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_HAS_DIRTY_CHILDREN); } } if (aFrameList.IsEmpty()) return; if (MOZ_UNLIKELY(aPrevFrame && aPrevFrame == GetPopup())) { aPrevFrame = nullptr; } nsBoxFrame::InsertFrames(aListID, aPrevFrame, aFrameList); }
NS_IMETHODIMP nsMenuFrame::InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame, nsFrameList& aFrameList) { if (!mPopupFrame && (aListID == kPrincipalList || aListID == kPopupList)) { SetPopupFrame(aFrameList); if (mPopupFrame) { #ifdef DEBUG_LAYOUT nsBoxLayoutState state(PresContext()); SetDebug(state, aFrameList, mState & NS_STATE_CURRENTLY_IN_DEBUG); #endif PresContext()->PresShell()-> FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_HAS_DIRTY_CHILDREN); } } if (aFrameList.IsEmpty()) return NS_OK; if (NS_UNLIKELY(aPrevFrame == mPopupFrame)) { aPrevFrame = nsnull; } return nsBoxFrame::InsertFrames(aListID, aPrevFrame, aFrameList); }
void nsColumnSetFrame::SetInitialChildList(ChildListID aListID, nsFrameList& aChildList) { MOZ_ASSERT(aListID != kPrincipalList || aChildList.OnlyChild(), "initial principal child list must have exactly one child"); nsContainerFrame::SetInitialChildList(kPrincipalList, aChildList); }
void nsTableWrapperFrame::AppendFrames(ChildListID aListID, nsFrameList& aFrameList) { // We only have two child frames: the inner table and a caption frame. // The inner frame is provided when we're initialized, and it cannot change MOZ_ASSERT(kCaptionList == aListID, "unexpected child list"); MOZ_ASSERT(aFrameList.IsEmpty() || aFrameList.FirstChild()->IsTableCaption(), "appending non-caption frame to captionList"); mCaptionFrames.AppendFrames(this, aFrameList); // Reflow the new caption frame. It's already marked dirty, so // just tell the pres shell. PresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_HAS_DIRTY_CHILDREN); }
void nsTableWrapperFrame::SetInitialChildList(ChildListID aListID, nsFrameList& aChildList) { if (kCaptionList == aListID) { // the frame constructor already checked for table-caption display type MOZ_ASSERT(mCaptionFrames.IsEmpty(), "already have child frames in CaptionList"); mCaptionFrames.SetFrames(aChildList); } else { MOZ_ASSERT(kPrincipalList != aListID || (aChildList.FirstChild() && aChildList.FirstChild() == aChildList.LastChild() && nsGkAtoms::tableFrame == aChildList.FirstChild()->GetType()), "expected a single table frame in principal child list"); nsContainerFrame::SetInitialChildList(aListID, aChildList); } }
void nsTableWrapperFrame::InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame, nsFrameList& aFrameList) { MOZ_ASSERT(kCaptionList == aListID, "unexpected child list"); MOZ_ASSERT(aFrameList.IsEmpty() || aFrameList.FirstChild()->IsTableCaption(), "inserting non-caption frame into captionList"); MOZ_ASSERT(!aPrevFrame || aPrevFrame->GetParent() == this, "inserting after sibling frame with different parent"); mCaptionFrames.InsertFrames(nullptr, aPrevFrame, aFrameList); // Reflow the new caption frame. It's already marked dirty, so // just tell the pres shell. PresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_HAS_DIRTY_CHILDREN); }
NS_IMETHODIMP nsTableOuterFrame::SetInitialChildList(ChildListID aListID, nsFrameList& aChildList) { if (kCaptionList == aListID) { // the frame constructor already checked for table-caption display type mCaptionFrames.SetFrames(aChildList); } else { NS_ASSERTION(aListID == kPrincipalList, "wrong childlist"); NS_ASSERTION(mFrames.IsEmpty(), "Frame leak!"); NS_ASSERTION(aChildList.FirstChild() && nsGkAtoms::tableFrame == aChildList.FirstChild()->GetType(), "expected a table frame"); mFrames.SetFrames(aChildList); } return NS_OK; }
void nsTableOuterFrame::SetInitialChildList(ChildListID aListID, nsFrameList& aChildList) { MOZ_ASSERT(kCaptionList == aListID || aListID == kPrincipalList, "unexpected child list"); MOZ_ASSERT(GetChildList(aListID).IsEmpty(), "already have child frames in SetInitialChildList"); if (kCaptionList == aListID) { // the frame constructor already checked for table-caption display type mCaptionFrames.SetFrames(aChildList); } else { MOZ_ASSERT(aChildList.FirstChild() && aChildList.FirstChild() == aChildList.LastChild() && nsGkAtoms::tableFrame == aChildList.FirstChild()->GetType(), "expected a single table frame"); mFrames.SetFrames(aChildList); } }
NS_IMETHODIMP nsColumnSetFrame::SetInitialChildList(ChildListID aListID, nsFrameList& aChildList) { NS_ASSERTION(aListID == kPrincipalList, "Only default child list supported"); NS_ASSERTION(aChildList.OnlyChild(), "initial child list must have exactly one child"); // Queue up the frames for the content frame return nsContainerFrame::SetInitialChildList(kPrincipalList, aChildList); }
void nsMenuFrame::SetPopupFrame(nsFrameList& aFrameList) { for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) { if (e.get()->GetType() == nsGkAtoms::menuPopupFrame) { // Remove this frame from the list and set it as mPopupFrame mPopupFrame = (nsMenuPopupFrame *)e.get(); aFrameList.RemoveFrame(e.get()); break; } } }
void DetailsFrame::SetInitialChildList(ChildListID aListID, nsFrameList& aChildList) { if (aListID == kPrincipalList) { auto* details = HTMLDetailsElement::FromContent(GetContent()); bool isOpen = details->Open(); if (isOpen) { // If details is open, the first summary needs to be rendered as if it is // the first child. for (nsIFrame* child : aChildList) { auto* realFrame = nsPlaceholderFrame::GetRealFrameFor(child); auto* cif = realFrame->GetContentInsertionFrame(); if (cif && cif->GetType() == nsGkAtoms::summaryFrame) { // Take out the first summary frame and insert it to the beginning of // the list. aChildList.RemoveFrame(child); aChildList.InsertFrame(nullptr, nullptr, child); break; } } } #ifdef DEBUG nsIFrame* realFrame = nsPlaceholderFrame::GetRealFrameFor(isOpen ? aChildList.FirstChild() : aChildList.OnlyChild()); MOZ_ASSERT(realFrame, "Principal list of details should not be empty!"); nsIFrame* summaryFrame = realFrame->GetContentInsertionFrame(); MOZ_ASSERT(summaryFrame->GetType() == nsGkAtoms::summaryFrame, "The frame should be summary frame!"); #endif } nsBlockFrame::SetInitialChildList(aListID, aChildList); }
void nsMenuFrame::SetPopupFrame(nsFrameList& aFrameList) { for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) { nsMenuPopupFrame* popupFrame = do_QueryFrame(e.get()); if (popupFrame) { // Remove the frame from the list and store it in a nsFrameList* property. aFrameList.RemoveFrame(popupFrame); nsFrameList* popupList = new (PresContext()->PresShell()) nsFrameList(popupFrame, popupFrame); Properties().Set(PopupListProperty(), popupList); AddStateBits(NS_STATE_MENU_HAS_POPUP_LIST); break; } } }
void nsMenuFrame::SetPopupFrame(nsFrameList& aFrameList) { for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) { if (e.get()->GetType() == nsGkAtoms::menuPopupFrame) { // Remove the frame from the list and store it in a nsFrameList* property. nsIFrame* popupFrame = e.get(); aFrameList.RemoveFrame(popupFrame); nsFrameList* popupList = new nsFrameList(popupFrame, popupFrame); Properties().Set(PopupListProperty(), popupList); AddStateBits(NS_STATE_MENU_HAS_POPUP_LIST); break; } } }
// don't set mColCount here, it is done in AddColsToTable void nsTableColGroupFrame::SetInitialChildList(ChildListID aListID, nsFrameList& aChildList) { MOZ_ASSERT(mFrames.IsEmpty(), "unexpected second call to SetInitialChildList"); MOZ_ASSERT(aListID == kPrincipalList, "unexpected child list"); if (aChildList.IsEmpty()) { GetTableFrame()->AppendAnonymousColFrames(this, GetSpan(), eColAnonymousColGroup, false); return; } mFrames.AppendFrames(this, aChildList); }
nsRect nsSVGUtils::GetCoveredRegion(const nsFrameList &aFrames) { nsRect rect; for (nsIFrame* kid = aFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { nsISVGChildFrame* child = do_QueryFrame(kid); if (child) { nsRect childRect = child->GetCoveredRegion(); rect.UnionRect(rect, childRect); } } return rect; }
NS_IMETHODIMP nsSVGDisplayContainerFrame::InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame, nsFrameList& aFrameList) { // memorize first old frame after insertion point // XXXbz once again, this would work a lot better if the nsIFrame // methods returned framelist iterators.... nsIFrame* firstOldFrame = aPrevFrame ? aPrevFrame->GetNextSibling() : GetChildList(aListID).FirstChild(); nsIFrame* firstNewFrame = aFrameList.FirstChild(); // Insert the new frames nsSVGContainerFrame::InsertFrames(aListID, aPrevFrame, aFrameList); // If we are not a non-display SVG frame and we do not have a bounds update // pending, then we need to schedule one for our new children: if (!(GetStateBits() & (NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN | NS_STATE_SVG_NONDISPLAY_CHILD))) { for (nsIFrame* kid = firstNewFrame; kid != firstOldFrame; kid = kid->GetNextSibling()) { nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { NS_ABORT_IF_FALSE(!(kid->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD), "Check for this explicitly in the |if|, then"); bool isFirstReflow = (kid->GetStateBits() & NS_FRAME_FIRST_REFLOW); // Remove bits so that ScheduleBoundsUpdate will work: kid->RemoveStateBits(NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN); // No need to invalidate the new kid's old bounds, so we just use // nsSVGUtils::ScheduleBoundsUpdate. nsSVGUtils::ScheduleReflowSVG(kid); if (isFirstReflow) { // Add back the NS_FRAME_FIRST_REFLOW bit: kid->AddStateBits(NS_FRAME_FIRST_REFLOW); } } } } return NS_OK; }
nsFrameList::Slice nsFrameList::InsertFrames(nsIFrame* aParent, nsIFrame* aPrevSibling, nsFrameList& aFrameList) { NS_PRECONDITION(aFrameList.NotEmpty(), "Unexpected empty list"); if (aParent) { aFrameList.ApplySetParent(aParent); } NS_ASSERTION(IsEmpty() || FirstChild()->GetParent() == aFrameList.FirstChild()->GetParent(), "frame to add has different parent"); NS_ASSERTION(!aPrevSibling || aPrevSibling->GetParent() == aFrameList.FirstChild()->GetParent(), "prev sibling has different parent"); #ifdef DEBUG_FRAME_LIST // ContainsFrame is O(N) NS_ASSERTION(!aPrevSibling || ContainsFrame(aPrevSibling), "prev sibling is not on this list"); #endif nsIFrame* firstNewFrame = aFrameList.FirstChild(); nsIFrame* nextSibling; if (aPrevSibling) { nextSibling = aPrevSibling->GetNextSibling(); aPrevSibling->SetNextSibling(firstNewFrame); } else { nextSibling = mFirstChild; mFirstChild = firstNewFrame; } nsIFrame* lastNewFrame = aFrameList.LastChild(); lastNewFrame->SetNextSibling(nextSibling); if (!nextSibling) { mLastChild = lastNewFrame; } VerifyList(); aFrameList.Clear(); return Slice(*this, firstNewFrame, nextSibling); }
NS_IMETHODIMP nsMenuFrame::AppendFrames(ChildListID aListID, nsFrameList& aFrameList) { if (!HasPopup() && (aListID == kPrincipalList || aListID == kPopupList)) { SetPopupFrame(aFrameList); if (HasPopup()) { #ifdef DEBUG_LAYOUT nsBoxLayoutState state(PresContext()); SetDebug(state, aFrameList, mState & NS_STATE_CURRENTLY_IN_DEBUG); #endif PresContext()->PresShell()-> FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_HAS_DIRTY_CHILDREN); } } if (aFrameList.IsEmpty()) return NS_OK; return nsBoxFrame::AppendFrames(aListID, aFrameList); }
NS_IMETHODIMP nsMenuFrame::AppendFrames(nsIAtom* aListName, nsFrameList& aFrameList) { if (!mPopupFrame && (!aListName || aListName == nsGkAtoms::popupList)) { SetPopupFrame(aFrameList); if (mPopupFrame) { #ifdef DEBUG_LAYOUT nsBoxLayoutState state(PresContext()); SetDebug(state, aFrameList, mState & NS_STATE_CURRENTLY_IN_DEBUG); #endif PresContext()->PresShell()-> FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_HAS_DIRTY_CHILDREN); } } if (aFrameList.IsEmpty()) return NS_OK; return nsBoxFrame::AppendFrames(aListName, aFrameList); }