diff --git a/layout/generic/nsHTMLContainerFrame.cpp b/layout/generic/nsHTMLContainerFrame.cpp index f42c5ba15b9b..94c880dbb968 100644 --- a/layout/generic/nsHTMLContainerFrame.cpp +++ b/layout/generic/nsHTMLContainerFrame.cpp @@ -247,6 +247,7 @@ nsHTMLContainerFrame::CreateWrapperFrame(nsIPresContext& aPresContext, return isContainer; } +// XXX pass in aFrame's style context instead PRBool nsHTMLContainerFrame::MoveFrameOutOfFlow(nsIPresContext& aPresContext, nsIFrame* aFrame, @@ -269,6 +270,7 @@ nsHTMLContainerFrame::MoveFrameOutOfFlow(nsIPresContext& aPresContext, aFrame->GetNextSibling(nextSibling); aFrame->SetNextSibling(nsnull); + nsIFrame* frameToWrapWithAView = aFrame; if (isFloated) { // Create a placeholder frame that will serve as the anchor point. nsPlaceholderFrame* placeholder = @@ -279,6 +281,7 @@ nsHTMLContainerFrame::MoveFrameOutOfFlow(nsIPresContext& aPresContext, if (CreateWrapperFrame(aPresContext, aFrame, wrapperFrame)) { // Bind the wrapper frame to the placeholder placeholder->SetAnchoredItem(wrapperFrame); + frameToWrapWithAView = wrapperFrame; } aPlaceholderFrame = placeholder; @@ -293,11 +296,22 @@ nsHTMLContainerFrame::MoveFrameOutOfFlow(nsIPresContext& aPresContext, if (CreateWrapperFrame(aPresContext, aFrame, wrapperFrame)) { // Bind the wrapper frame to the placeholder placeholder->SetAbsoluteFrame(wrapperFrame); + frameToWrapWithAView = wrapperFrame; } aPlaceholderFrame = placeholder; } + // Wrap the frame in a view if necessary + nsIStyleContext* kidSC; + aFrame->GetStyleContext(&aPresContext, kidSC); + nsresult rv = CreateViewForFrame(aPresContext, frameToWrapWithAView, + kidSC, PR_FALSE); + NS_RELEASE(kidSC); + if (NS_OK != rv) { + return rv; + } + // Set the placeholder's next sibling to what aFrame's next sibling was aPlaceholderFrame->SetNextSibling(nextSibling); return PR_TRUE; diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index 7ea85a231fc0..c1fcc27c842c 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -126,9 +126,9 @@ public: nsresult AppendNewFrames(nsIPresContext& aPresContext, nsIFrame*); - void InsertNewFrame(nsIPresContext& aPresContext, - nsIFrame* aNewFrame, - nsIFrame* aPrevSibling); + nsresult InsertNewFrame(nsIPresContext& aPresContext, + nsIFrame* aNewFrame, + nsIFrame* aPrevSibling); PRBool SafeToPull(nsIFrame* aFrame); @@ -184,6 +184,7 @@ nsInlineFrame::AppendNewFrames(nsIPresContext& aPresContext, frame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)kidDisplay); frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&) kidPosition); + // XXX encapsulte the move-out-of-flow and CreateViewForFrame nsIFrame* placeholder; if (MoveFrameOutOfFlow(aPresContext, frame, kidDisplay, kidPosition, placeholder)) { // Reset the previous frame's next sibling pointer @@ -194,6 +195,16 @@ nsInlineFrame::AppendNewFrames(nsIPresContext& aPresContext, } frame = placeholder; } + else { + // Wrap the frame in a view if necessary + nsIStyleContext* kidSC; + frame->GetStyleContext(&aPresContext, kidSC); + nsresult rv = CreateViewForFrame(aPresContext, frame, kidSC, PR_FALSE); + NS_RELEASE(kidSC); + if (NS_OK != rv) { + return rv; + } + } prevFrame = frame; } @@ -271,7 +282,7 @@ nsInlineFrame::FindTextRuns(nsLineLayout& aLineLayout) return rv; } -void +nsresult nsInlineFrame::InsertNewFrame(nsIPresContext& aPresContext, nsIFrame* aNewFrame, nsIFrame* aPrevSibling) @@ -288,6 +299,16 @@ nsInlineFrame::InsertNewFrame(nsIPresContext& aPresContext, // Add the placeholder frame to the flow aNewFrame = placeholder; } + else { + // Wrap the frame in a view if necessary + nsIStyleContext* kidSC; + aNewFrame->GetStyleContext(&aPresContext, kidSC); + nsresult rv = CreateViewForFrame(aPresContext, aNewFrame, kidSC, PR_FALSE); + NS_RELEASE(kidSC); + if (NS_OK != rv) { + return rv; + } + } // Add the new frame to the child list nsIFrame* nextSibling; @@ -299,6 +320,8 @@ nsInlineFrame::InsertNewFrame(nsIPresContext& aPresContext, aPrevSibling->SetNextSibling(aNewFrame); } aNewFrame->SetNextSibling(nextSibling); + + return NS_OK; } NS_IMETHODIMP diff --git a/layout/html/base/src/nsHTMLContainerFrame.cpp b/layout/html/base/src/nsHTMLContainerFrame.cpp index f42c5ba15b9b..94c880dbb968 100644 --- a/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -247,6 +247,7 @@ nsHTMLContainerFrame::CreateWrapperFrame(nsIPresContext& aPresContext, return isContainer; } +// XXX pass in aFrame's style context instead PRBool nsHTMLContainerFrame::MoveFrameOutOfFlow(nsIPresContext& aPresContext, nsIFrame* aFrame, @@ -269,6 +270,7 @@ nsHTMLContainerFrame::MoveFrameOutOfFlow(nsIPresContext& aPresContext, aFrame->GetNextSibling(nextSibling); aFrame->SetNextSibling(nsnull); + nsIFrame* frameToWrapWithAView = aFrame; if (isFloated) { // Create a placeholder frame that will serve as the anchor point. nsPlaceholderFrame* placeholder = @@ -279,6 +281,7 @@ nsHTMLContainerFrame::MoveFrameOutOfFlow(nsIPresContext& aPresContext, if (CreateWrapperFrame(aPresContext, aFrame, wrapperFrame)) { // Bind the wrapper frame to the placeholder placeholder->SetAnchoredItem(wrapperFrame); + frameToWrapWithAView = wrapperFrame; } aPlaceholderFrame = placeholder; @@ -293,11 +296,22 @@ nsHTMLContainerFrame::MoveFrameOutOfFlow(nsIPresContext& aPresContext, if (CreateWrapperFrame(aPresContext, aFrame, wrapperFrame)) { // Bind the wrapper frame to the placeholder placeholder->SetAbsoluteFrame(wrapperFrame); + frameToWrapWithAView = wrapperFrame; } aPlaceholderFrame = placeholder; } + // Wrap the frame in a view if necessary + nsIStyleContext* kidSC; + aFrame->GetStyleContext(&aPresContext, kidSC); + nsresult rv = CreateViewForFrame(aPresContext, frameToWrapWithAView, + kidSC, PR_FALSE); + NS_RELEASE(kidSC); + if (NS_OK != rv) { + return rv; + } + // Set the placeholder's next sibling to what aFrame's next sibling was aPlaceholderFrame->SetNextSibling(nextSibling); return PR_TRUE; diff --git a/layout/html/base/src/nsInlineFrame.cpp b/layout/html/base/src/nsInlineFrame.cpp index 7ea85a231fc0..c1fcc27c842c 100644 --- a/layout/html/base/src/nsInlineFrame.cpp +++ b/layout/html/base/src/nsInlineFrame.cpp @@ -126,9 +126,9 @@ public: nsresult AppendNewFrames(nsIPresContext& aPresContext, nsIFrame*); - void InsertNewFrame(nsIPresContext& aPresContext, - nsIFrame* aNewFrame, - nsIFrame* aPrevSibling); + nsresult InsertNewFrame(nsIPresContext& aPresContext, + nsIFrame* aNewFrame, + nsIFrame* aPrevSibling); PRBool SafeToPull(nsIFrame* aFrame); @@ -184,6 +184,7 @@ nsInlineFrame::AppendNewFrames(nsIPresContext& aPresContext, frame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)kidDisplay); frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&) kidPosition); + // XXX encapsulte the move-out-of-flow and CreateViewForFrame nsIFrame* placeholder; if (MoveFrameOutOfFlow(aPresContext, frame, kidDisplay, kidPosition, placeholder)) { // Reset the previous frame's next sibling pointer @@ -194,6 +195,16 @@ nsInlineFrame::AppendNewFrames(nsIPresContext& aPresContext, } frame = placeholder; } + else { + // Wrap the frame in a view if necessary + nsIStyleContext* kidSC; + frame->GetStyleContext(&aPresContext, kidSC); + nsresult rv = CreateViewForFrame(aPresContext, frame, kidSC, PR_FALSE); + NS_RELEASE(kidSC); + if (NS_OK != rv) { + return rv; + } + } prevFrame = frame; } @@ -271,7 +282,7 @@ nsInlineFrame::FindTextRuns(nsLineLayout& aLineLayout) return rv; } -void +nsresult nsInlineFrame::InsertNewFrame(nsIPresContext& aPresContext, nsIFrame* aNewFrame, nsIFrame* aPrevSibling) @@ -288,6 +299,16 @@ nsInlineFrame::InsertNewFrame(nsIPresContext& aPresContext, // Add the placeholder frame to the flow aNewFrame = placeholder; } + else { + // Wrap the frame in a view if necessary + nsIStyleContext* kidSC; + aNewFrame->GetStyleContext(&aPresContext, kidSC); + nsresult rv = CreateViewForFrame(aPresContext, aNewFrame, kidSC, PR_FALSE); + NS_RELEASE(kidSC); + if (NS_OK != rv) { + return rv; + } + } // Add the new frame to the child list nsIFrame* nextSibling; @@ -299,6 +320,8 @@ nsInlineFrame::InsertNewFrame(nsIPresContext& aPresContext, aPrevSibling->SetNextSibling(aNewFrame); } aNewFrame->SetNextSibling(nextSibling); + + return NS_OK; } NS_IMETHODIMP