nsresult nsTableCellFrame::GetColIndex(PRInt32 &aColIndex) const { if (mPrevInFlow) { return ((nsTableCellFrame*)GetFirstInFlow())->GetColIndex(aColIndex); } else { aColIndex = mBits.mColIndex; return NS_OK; } }
NS_IMETHODIMP nsFirstLineFrame::Reflow(nsPresContext* aPresContext, nsHTMLReflowMetrics& aMetrics, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { if (nsnull == aReflowState.mLineLayout) { return NS_ERROR_INVALID_ARG; } nsIFrame* lineContainer = aReflowState.mLineLayout->GetLineContainerFrame(); // Check for an overflow list with our prev-in-flow nsFirstLineFrame* prevInFlow = (nsFirstLineFrame*)GetPrevInFlow(); if (nsnull != prevInFlow) { nsAutoPtr<nsFrameList> prevOverflowFrames(prevInFlow->StealOverflowFrames()); if (prevOverflowFrames) { // Assign all floats to our block if necessary if (lineContainer && lineContainer->GetPrevContinuation()) { ReparentFloatsForInlineChild(lineContainer, prevOverflowFrames->FirstChild(), PR_TRUE); } const nsFrameList::Slice& newFrames = mFrames.InsertFrames(this, nsnull, *prevOverflowFrames); ReParentChildListStyle(aPresContext, newFrames, this); } } // It's also possible that we have an overflow list for ourselves nsAutoPtr<nsFrameList> overflowFrames(StealOverflowFrames()); if (overflowFrames) { NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames"); const nsFrameList::Slice& newFrames = mFrames.AppendFrames(nsnull, *overflowFrames); ReParentChildListStyle(aPresContext, newFrames, this); } // Set our own reflow state (additional state above and beyond // aReflowState) InlineReflowState irs; irs.mPrevFrame = nsnull; irs.mLineContainer = lineContainer; irs.mNextInFlow = (nsInlineFrame*) GetNextInFlow(); nsresult rv; PRBool wasEmpty = mFrames.IsEmpty(); if (wasEmpty) { // Try to pull over one frame before starting so that we know // whether we have an anonymous block or not. PRBool complete; PullOneFrame(aPresContext, irs, &complete); } if (nsnull == GetPrevInFlow()) { // XXX This is pretty sick, but what we do here is to pull-up, in // advance, all of the next-in-flows children. We re-resolve their // style while we are at at it so that when we reflow they have // the right style. // // All of this is so that text-runs reflow properly. irs.mPrevFrame = mFrames.LastChild(); for (;;) { PRBool complete; nsIFrame* frame = PullOneFrame(aPresContext, irs, &complete); if (!frame) { break; } irs.mPrevFrame = frame; } irs.mPrevFrame = nsnull; } else { // XXX do this in the Init method instead // For continuations, we need to check and see if our style // context is right. If its the same as the first-in-flow, then // we need to fix it up (that way :first-line style doesn't leak // into this continuation since we aren't the first line). nsFirstLineFrame* first = (nsFirstLineFrame*) GetFirstInFlow(); if (mStyleContext == first->mStyleContext) { // Fixup our style context and our children. First get the // proper parent context. nsStyleContext* parentContext = first->GetParent()->GetStyleContext(); if (parentContext) { // Create a new style context that is a child of the parent // style context thus removing the :first-line style. This way // we behave as if an anonymous (unstyled) span was the child // of the parent frame. nsRefPtr<nsStyleContext> newSC; newSC = aPresContext->StyleSet()-> ResolvePseudoStyleFor(nsnull, nsCSSAnonBoxes::mozLineFrame, parentContext); if (newSC) { // Switch to the new style context. SetStyleContext(newSC); // Re-resolve all children ReParentChildListStyle(aPresContext, mFrames, this); } } } } NS_ASSERTION(!aReflowState.mLineLayout->GetInFirstLine(), "Nested first-line frames? BOGUS"); aReflowState.mLineLayout->SetInFirstLine(PR_TRUE); rv = ReflowFrames(aPresContext, aReflowState, irs, aMetrics, aStatus); aReflowState.mLineLayout->SetInFirstLine(PR_FALSE); // Note: the line layout code will properly compute our overflow state for us return rv; }