diff --git a/content/base/public/nsIContent.h b/content/base/public/nsIContent.h index 13ae43232cff..5cdaa5abed3d 100644 --- a/content/base/public/nsIContent.h +++ b/content/base/public/nsIContent.h @@ -118,9 +118,6 @@ public: */ NS_IMETHOD GetAttribute(const nsString& aName, nsString& aResult) const = 0; - // XXX deprecated - virtual nsIContentDelegate* GetDelegate(nsIPresContext* aCX) = 0; - /** * List the content (and anything it contains) out to the given * file stream. Use aIndent as the base indent during formatting. diff --git a/content/base/src/nsStyleSet.cpp b/content/base/src/nsStyleSet.cpp index 9f9c947c5337..e48927ffc995 100644 --- a/content/base/src/nsStyleSet.cpp +++ b/content/base/src/nsStyleSet.cpp @@ -764,12 +764,8 @@ NS_IMETHODIMP StyleSetImpl::ContentInserted(nsIPresContext* aPresContext, nsIContent* aChild, PRInt32 aIndexInContainer) { -#if 0 return mFrameConstructor->ContentInserted(aPresContext, aDocument, aContainer, aChild, aIndexInContainer); -#else - return NS_OK; -#endif } NS_IMETHODIMP StyleSetImpl::ContentReplaced(nsIPresContext* aPresContext, diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index ea83c7e0d1a3..e4219f309013 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -85,26 +85,6 @@ static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID); static NS_DEFINE_IID(kICSSStyleRuleIID, NS_ICSS_STYLE_RULE_IID); static NS_DEFINE_IID(kIDOMNodeListIID, NS_IDOMNODELIST_IID); -static nsIContentDelegate* gContentDelegate; - -/** - * THE html content delegate. There is exactly one instance of this - * class and it's used for all html content. It just turns around - * and asks the content object to create the frame. - */ -class ZContentDelegate : public nsIContentDelegate { -public: - ZContentDelegate(); - NS_DECL_ISUPPORTS - NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); -protected: - ~ZContentDelegate(); -}; - // Attribute helper class used to wrap up an attribute with a dom // object that implements nsIDOMAttribute and nsIDOMNode and // nsIScriptObjectOwner @@ -218,50 +198,6 @@ private: //---------------------------------------------------------------------- -ZContentDelegate::ZContentDelegate() -{ - NS_INIT_REFCNT(); -} - -NS_IMPL_ISUPPORTS(ZContentDelegate, kIContentDelegateIID); - -ZContentDelegate::~ZContentDelegate() -{ -} - -NS_METHOD -ZContentDelegate::CreateFrame(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult) -{ - NS_PRECONDITION(nsnull != aContent, "null ptr"); - - // Make sure the content is html content - nsIHTMLContent* hc; - nsIFrame* frame = nsnull; - nsresult rv = aContent->QueryInterface(kIHTMLContentIID, (void**) &hc); - if (NS_OK != rv) { - // This means that *somehow* somebody which is not an html - // content object got ahold of this delegate and tried to - // create a frame with it. Give them back an nsFrame. - rv = nsFrame::NewFrame(&frame, aContent, aParentFrame); - if (NS_OK == rv) { - frame->SetStyleContext(aPresContext, aStyleContext); - } - } - else { - // Ask the content object to create the frame - rv = hc->CreateFrame(aPresContext, aParentFrame, aStyleContext, frame); - NS_RELEASE(hc); - } - aResult = frame; - return rv; -} - -//---------------------------------------------------------------------- - DOMAttribute::DOMAttribute(const nsString& aName, const nsString& aValue) : mName(aName), mValue(aValue) { @@ -708,13 +644,6 @@ nsGenericHTMLElement::nsGenericHTMLElement() mContent = nsnull; mScriptObject = nsnull; mListenerManager = nsnull; - - // Create shared content delegate if this is the first html content - // object being created. - if (nsnull == gContentDelegate) { - NS_NEWXPCOM(gContentDelegate, ZContentDelegate); - NS_ADDREF(gContentDelegate); - } } nsGenericHTMLElement::~nsGenericHTMLElement() @@ -725,22 +654,6 @@ nsGenericHTMLElement::~nsGenericHTMLElement() NS_IF_RELEASE(mTag); NS_IF_RELEASE(mListenerManager); // XXX what about mScriptObject? it's now safe to GC it... - -#if 0 - // This code didn't work; and since content delegates are going - // away, I'm not going to fix it. So for now, we will leak a content - // delegate per address space. whoope doopie. -- kipp - NS_PRECONDITION(nsnull != gContentDelegate, "null content delegate"); - if (nsnull != gContentDelegate) { - // Remove our reference to the shared content delegate object. If - // the last reference just went away, null out gContentDelegate. - nsrefcnt rc; - NS_RELEASE2(gContentDelegate, rc); - if (0 == rc) { - gContentDelegate = nsnull; - } - } -#endif } void @@ -1533,13 +1446,6 @@ nsGenericHTMLElement::GetStyleRule(nsIStyleRule*& aResult) return NS_OK; } -nsIContentDelegate* -nsGenericHTMLElement::GetDelegate(nsIPresContext* aCX) -{ - NS_ADDREF(gContentDelegate); - return gContentDelegate; -} - void nsGenericHTMLElement::ListAttributes(FILE* out) const { diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index 289fb1b9d1f5..ef3e81572d75 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -121,7 +121,6 @@ public: nsresult SetAttribute(const nsString& aName, const nsString& aValue, PRBool aNotify); nsresult GetAttribute(const nsString& aName, nsString& aResult) const; - nsIContentDelegate* GetDelegate(nsIPresContext* aCX); nsresult List(FILE* out, PRInt32 aIndent) const; nsresult HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, @@ -667,9 +666,6 @@ public: nsString& aResult) const { \ return _g.GetAttribute(aName, aResult); \ } \ - virtual nsIContentDelegate* GetDelegate(nsIPresContext* aCX) { \ - return _g.GetDelegate(aCX); \ - } \ NS_IMETHOD List(FILE* out, PRInt32 aIndent) const { \ return _g.List(out, aIndent); \ } \ diff --git a/content/html/style/src/nsHTMLStyleSheet.cpp b/content/html/style/src/nsHTMLStyleSheet.cpp index 89446a620f79..1cd771b575de 100644 --- a/content/html/style/src/nsHTMLStyleSheet.cpp +++ b/content/html/style/src/nsHTMLStyleSheet.cpp @@ -246,6 +246,12 @@ public: nsIContent* aContainer, PRInt32 aNewIndexInContainer); + NS_IMETHOD ContentInserted(nsIPresContext* aPresContext, + nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer); + // XXX style rule enumerations virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; @@ -1311,10 +1317,11 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresContext, return rv; } -NS_IMETHODIMP HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParentFrame, - nsIFrame*& aFrameSubTree) +NS_IMETHODIMP +HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext, + nsIContent* aContent, + nsIFrame* aParentFrame, + nsIFrame*& aFrameSubTree) { nsresult rv; @@ -1354,10 +1361,11 @@ NS_IMETHODIMP HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext, return rv; } -NS_IMETHODIMP HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext, - nsIDocument* aDocument, - nsIContent* aContainer, - PRInt32 aNewIndexInContainer) +NS_IMETHODIMP +HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext, + nsIDocument* aDocument, + nsIContent* aContainer, + PRInt32 aNewIndexInContainer) { nsIPresShell* shell = aPresContext->GetShell(); nsIFrame* parentFrame = shell->FindFrameWithContent(aContainer); @@ -1423,6 +1431,73 @@ NS_IMETHODIMP HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext, return NS_OK; } +NS_IMETHODIMP +HTMLStyleSheetImpl::ContentInserted(nsIPresContext* aPresContext, + nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer) +{ + nsIPresShell* shell = aPresContext->GetShell(); + nsresult rv = NS_OK; + + // Find the frame that precedes the insertion point. + nsIFrame* prevSibling = nsnull; + + // Note: not all content objects are associated with a frame so + // keep looking until we find a previous frame + for (PRInt32 index = aIndexInContainer; index > 0; index--) { + nsIContent* precedingContent; + aContainer->ChildAt(index - 1, precedingContent); + prevSibling = shell->FindFrameWithContent(precedingContent); + NS_RELEASE(precedingContent); + + if (nsnull != prevSibling) { + // The frame may have a next-in-flow. Get the last-in-flow + nsIFrame* nextInFlow; + do { + prevSibling->GetNextInFlow(nextInFlow); + if (nsnull != nextInFlow) { + prevSibling = nextInFlow; + } + } while (nsnull != nextInFlow); + + break; + } + } + + // Get the geometric parent. + // XXX Deal with frame moved out of the flow, e.g., floated and absolutely + // positioned frames... + nsIFrame* parentFrame; + if (nsnull == prevSibling) { + parentFrame = shell->FindFrameWithContent(aContainer); + } else { + prevSibling->GetGeometricParent(parentFrame); + } + + // Construct a new frame + if (nsnull != parentFrame) { + nsIFrame* newFrame; + rv = ConstructFrame(aPresContext, aChild, parentFrame, newFrame); + + // Notify the parent frame with a reflow command, passing it the + // new child frame + if (NS_SUCCEEDED(rv) && (nsnull != newFrame)) { + nsIReflowCommand* reflowCmd; + + rv = NS_NewHTMLReflowCommand(&reflowCmd, parentFrame, newFrame, prevSibling); + if (NS_SUCCEEDED(rv)) { + shell->AppendReflowCommand(reflowCmd); + NS_RELEASE(reflowCmd); + } + } + } + + NS_RELEASE(shell); + return rv; +} + void HTMLStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const { nsAutoString buffer; diff --git a/layout/base/public/nsIContent.h b/layout/base/public/nsIContent.h index 13ae43232cff..5cdaa5abed3d 100644 --- a/layout/base/public/nsIContent.h +++ b/layout/base/public/nsIContent.h @@ -118,9 +118,6 @@ public: */ NS_IMETHOD GetAttribute(const nsString& aName, nsString& aResult) const = 0; - // XXX deprecated - virtual nsIContentDelegate* GetDelegate(nsIPresContext* aCX) = 0; - /** * List the content (and anything it contains) out to the given * file stream. Use aIndent as the base indent during formatting. diff --git a/layout/base/public/nsIFrame.h b/layout/base/public/nsIFrame.h index 422f5c0fddd0..5562615b5e3f 100644 --- a/layout/base/public/nsIFrame.h +++ b/layout/base/public/nsIFrame.h @@ -496,6 +496,8 @@ public: nsIContent* aContainer) = 0; #endif + // XXX CONSTRUCTION +#if 0 /** * This call is invoked when content is inserted in the content * tree. @@ -516,6 +518,7 @@ public: nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInParent) = 0; +#endif /** * This call is invoked when content is replaced in the content diff --git a/layout/base/public/nsIReflowCommand.h b/layout/base/public/nsIReflowCommand.h index fdd0356d88d5..b206a1fabbd8 100644 --- a/layout/base/public/nsIReflowCommand.h +++ b/layout/base/public/nsIReflowCommand.h @@ -116,6 +116,12 @@ public: * Get the child frame associated with the reflow command. */ NS_IMETHOD GetChildFrame(nsIFrame*& aChildFrame) const = 0; + + /** + * Get the previous sibling frame associated with the reflow command. + * This is used for FrameInserted reflow commands. + */ + NS_IMETHOD GetPrevSiblingFrame(nsIFrame*& aSiblingFrame) const = 0; }; #endif /* nsIReflowCommand_h___ */ diff --git a/layout/base/public/nsIStyleFrameConstruction.h b/layout/base/public/nsIStyleFrameConstruction.h index 4ff15c61c775..d2e03042855f 100644 --- a/layout/base/public/nsIStyleFrameConstruction.h +++ b/layout/base/public/nsIStyleFrameConstruction.h @@ -42,6 +42,12 @@ public: nsIDocument* aDocument, nsIContent* aContainer, PRInt32 aNewIndexInContainer) = 0; + + NS_IMETHOD ContentInserted(nsIPresContext* aPresContext, + nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer) = 0; }; #endif /* nsIStyleFrameConstruction_h___ */ diff --git a/layout/base/src/nsFrame.cpp b/layout/base/src/nsFrame.cpp index 775715658fc3..4ee02a159f48 100644 --- a/layout/base/src/nsFrame.cpp +++ b/layout/base/src/nsFrame.cpp @@ -1190,7 +1190,6 @@ NS_METHOD nsFrame::ContentAppended(nsIPresShell* aShell, { return NS_OK; } -#endif NS_METHOD nsFrame::ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, @@ -1200,6 +1199,7 @@ NS_METHOD nsFrame::ContentInserted(nsIPresShell* aShell, { return NS_OK; } +#endif NS_METHOD nsFrame::ContentReplaced(nsIPresShell* aShell, nsIPresContext* aPresContext, diff --git a/layout/base/src/nsFrame.h b/layout/base/src/nsFrame.h index f78cdf8c3d39..58e00a0f6855 100644 --- a/layout/base/src/nsFrame.h +++ b/layout/base/src/nsFrame.h @@ -158,12 +158,12 @@ public: NS_IMETHOD ContentAppended(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer); -#endif NS_IMETHOD ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInParent); +#endif NS_IMETHOD ContentReplaced(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, diff --git a/layout/base/src/nsPresShell.cpp b/layout/base/src/nsPresShell.cpp index a4e43e9c7967..6d0dd2c30cb3 100644 --- a/layout/base/src/nsPresShell.cpp +++ b/layout/base/src/nsPresShell.cpp @@ -723,29 +723,10 @@ PresShell::ContentInserted(nsIDocument* aDocument, nsIContent* aChild, PRInt32 aIndexInContainer) { -#ifdef FRAME_CONSTRUCTION EnterReflowLock(); nsresult rv = mPresContext->ContentInserted(aDocument, aContainer, aChild, aIndexInContainer); ExitReflowLock(); return rv; -#else - NS_PRECONDITION(nsnull != mRootFrame, "null root frame"); - - EnterReflowLock(); - - nsIFrame* frame = FindFrameWithContent(aContainer); - NS_PRECONDITION(nsnull != frame, "null frame"); - NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, - ("PresShell::ContentInserted: container=%p[%s] child=%p[%s][%d] frame=%p", - aContainer, ContentTag(aContainer, 0), - aChild, ContentTag(aChild, 1), aIndexInContainer, - frame)); - frame->ContentInserted(this, mPresContext, aContainer, aChild, - aIndexInContainer); - - ExitReflowLock(); - return NS_OK; -#endif } NS_IMETHODIMP diff --git a/layout/base/src/nsStyleSet.cpp b/layout/base/src/nsStyleSet.cpp index 9f9c947c5337..e48927ffc995 100644 --- a/layout/base/src/nsStyleSet.cpp +++ b/layout/base/src/nsStyleSet.cpp @@ -764,12 +764,8 @@ NS_IMETHODIMP StyleSetImpl::ContentInserted(nsIPresContext* aPresContext, nsIContent* aChild, PRInt32 aIndexInContainer) { -#if 0 return mFrameConstructor->ContentInserted(aPresContext, aDocument, aContainer, aChild, aIndexInContainer); -#else - return NS_OK; -#endif } NS_IMETHODIMP StyleSetImpl::ContentReplaced(nsIPresContext* aPresContext, diff --git a/layout/base/tests/TestContainerFrame.cpp b/layout/base/tests/TestContainerFrame.cpp index 23fa7da74dda..cb7ed3f79f08 100644 --- a/layout/base/tests/TestContainerFrame.cpp +++ b/layout/base/tests/TestContainerFrame.cpp @@ -118,9 +118,6 @@ public: NS_IMETHOD GetAttribute(const nsString& aName, nsString& aRet) const { return NS_CONTENT_ATTR_NOT_THERE; } - nsIContentDelegate* GetDelegate(nsIPresContext* aCX) { - return nsnull; - } NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const { return NS_OK; } diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index e008218f5662..23486174ded2 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -131,11 +131,14 @@ public: nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); + // XXX CONSTRUCTION +#if 0 NS_IMETHOD ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInParent); +#endif NS_IMETHOD ContentDeleted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, @@ -1956,6 +1959,17 @@ nsBlockFrame::FindTextRuns(nsBlockReflowState& aState) nsresult nsBlockFrame::FrameInsertedReflow(nsBlockReflowState& aState) { + // Get the inserted frame + nsIFrame* newFrame; + aState.reflowCommand->GetChildFrame(newFrame); + + // Get the previous sibling frame + nsIFrame* prevSibling; + aState.reflowCommand->GetPrevSiblingFrame(prevSibling); + + // Insert the frame. This marks the line dirty... + InsertNewFrame(this, newFrame, prevSibling); + LineData* line = mLines; while (nsnull != line->mNext) { if (line->IsDirty()) { @@ -3210,6 +3224,8 @@ nsBlockFrame::InsertNewFrame(nsBlockFrame* aParentFrame, return NS_OK; } +// XXX CONSTRUCTION +#if 0 // XXX we assume that the insertion is really an assertion and never an append // XXX what about zero lines case NS_IMETHODIMP @@ -3293,6 +3309,7 @@ nsBlockFrame::ContentInserted(nsIPresShell* aShell, return NS_OK; } +#endif NS_IMETHODIMP nsBlockFrame::ContentDeleted(nsIPresShell* aShell, diff --git a/layout/generic/nsBlockReflowState.cpp b/layout/generic/nsBlockReflowState.cpp index e008218f5662..23486174ded2 100644 --- a/layout/generic/nsBlockReflowState.cpp +++ b/layout/generic/nsBlockReflowState.cpp @@ -131,11 +131,14 @@ public: nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); + // XXX CONSTRUCTION +#if 0 NS_IMETHOD ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInParent); +#endif NS_IMETHOD ContentDeleted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, @@ -1956,6 +1959,17 @@ nsBlockFrame::FindTextRuns(nsBlockReflowState& aState) nsresult nsBlockFrame::FrameInsertedReflow(nsBlockReflowState& aState) { + // Get the inserted frame + nsIFrame* newFrame; + aState.reflowCommand->GetChildFrame(newFrame); + + // Get the previous sibling frame + nsIFrame* prevSibling; + aState.reflowCommand->GetPrevSiblingFrame(prevSibling); + + // Insert the frame. This marks the line dirty... + InsertNewFrame(this, newFrame, prevSibling); + LineData* line = mLines; while (nsnull != line->mNext) { if (line->IsDirty()) { @@ -3210,6 +3224,8 @@ nsBlockFrame::InsertNewFrame(nsBlockFrame* aParentFrame, return NS_OK; } +// XXX CONSTRUCTION +#if 0 // XXX we assume that the insertion is really an assertion and never an append // XXX what about zero lines case NS_IMETHODIMP @@ -3293,6 +3309,7 @@ nsBlockFrame::ContentInserted(nsIPresShell* aShell, return NS_OK; } +#endif NS_IMETHODIMP nsBlockFrame::ContentDeleted(nsIPresShell* aShell, diff --git a/layout/generic/nsBlockReflowState.h b/layout/generic/nsBlockReflowState.h index e008218f5662..23486174ded2 100644 --- a/layout/generic/nsBlockReflowState.h +++ b/layout/generic/nsBlockReflowState.h @@ -131,11 +131,14 @@ public: nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); + // XXX CONSTRUCTION +#if 0 NS_IMETHOD ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInParent); +#endif NS_IMETHOD ContentDeleted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, @@ -1956,6 +1959,17 @@ nsBlockFrame::FindTextRuns(nsBlockReflowState& aState) nsresult nsBlockFrame::FrameInsertedReflow(nsBlockReflowState& aState) { + // Get the inserted frame + nsIFrame* newFrame; + aState.reflowCommand->GetChildFrame(newFrame); + + // Get the previous sibling frame + nsIFrame* prevSibling; + aState.reflowCommand->GetPrevSiblingFrame(prevSibling); + + // Insert the frame. This marks the line dirty... + InsertNewFrame(this, newFrame, prevSibling); + LineData* line = mLines; while (nsnull != line->mNext) { if (line->IsDirty()) { @@ -3210,6 +3224,8 @@ nsBlockFrame::InsertNewFrame(nsBlockFrame* aParentFrame, return NS_OK; } +// XXX CONSTRUCTION +#if 0 // XXX we assume that the insertion is really an assertion and never an append // XXX what about zero lines case NS_IMETHODIMP @@ -3293,6 +3309,7 @@ nsBlockFrame::ContentInserted(nsIPresShell* aShell, return NS_OK; } +#endif NS_IMETHODIMP nsBlockFrame::ContentDeleted(nsIPresShell* aShell, diff --git a/layout/generic/nsHTMLContainerFrame.cpp b/layout/generic/nsHTMLContainerFrame.cpp index 9b18bf45b751..a76984f0adca 100644 --- a/layout/generic/nsHTMLContainerFrame.cpp +++ b/layout/generic/nsHTMLContainerFrame.cpp @@ -140,26 +140,8 @@ NS_METHOD nsHTMLContainerFrame::GetCursorAndContentAt(nsIPresContext& aPresConte return NS_OK; } -NS_METHOD nsHTMLContainerFrame::ContentAppended(nsIPresShell* aShell, - nsIPresContext* aPresContext, - nsIContent* aContainer) -{ - // Get the last-in-flow - nsHTMLContainerFrame* lastInFlow = (nsHTMLContainerFrame*)GetLastInFlow(); - - // Generate a reflow command for the frame - nsIReflowCommand* cmd; - nsresult result; - - result = NS_NewHTMLReflowCommand(&cmd, lastInFlow, nsIReflowCommand::FrameAppended); - if (NS_OK == result) { - aShell->AppendReflowCommand(cmd); - NS_RELEASE(cmd); - } - - return NS_OK; -} - +// XXX CONSTRUCTION +#if 0 NS_IMETHODIMP nsHTMLContainerFrame::ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, @@ -239,6 +221,7 @@ nsHTMLContainerFrame::ContentInserted(nsIPresShell* aShell, } return rv; } +#endif NS_IMETHODIMP nsHTMLContainerFrame::ContentDeleted(nsIPresShell* aShell, diff --git a/layout/generic/nsHTMLContainerFrame.h b/layout/generic/nsHTMLContainerFrame.h index a01d12cafab6..285d74ce2653 100644 --- a/layout/generic/nsHTMLContainerFrame.h +++ b/layout/generic/nsHTMLContainerFrame.h @@ -40,14 +40,14 @@ public: nsIFrame** aFrame, nsIContent** aContent, PRInt32& aCursor); - NS_IMETHOD ContentAppended(nsIPresShell* aShell, - nsIPresContext* aPresContext, - nsIContent* aContainer); + // XXX CONSTRUCTION +#if 0 NS_IMETHOD ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInParent); +#endif NS_IMETHOD ContentDeleted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, diff --git a/layout/generic/nsHTMLParts.h b/layout/generic/nsHTMLParts.h index 5325a277ca2a..ee1b33d7e8bd 100644 --- a/layout/generic/nsHTMLParts.h +++ b/layout/generic/nsHTMLParts.h @@ -429,4 +429,11 @@ NS_NewHTMLReflowCommand(nsIReflowCommand** aInstancePtrResult, nsIReflowCommand::ReflowType aReflowType, nsIFrame* aChildFrame = nsnull); +/** Create a new HTML 'FrameInserted' reflow command */ +extern nsresult +NS_NewHTMLReflowCommand(nsIReflowCommand** aInstancePtrResult, + nsIFrame* aTargetFrame, + nsIFrame* aChildFrame, + nsIFrame* aPrevSiblingFrame); + #endif /* nsHTMLParts_h___ */ diff --git a/layout/generic/nsHTMLReflowCommand.cpp b/layout/generic/nsHTMLReflowCommand.cpp index a2a6840cb96d..0dd1dd206246 100644 --- a/layout/generic/nsHTMLReflowCommand.cpp +++ b/layout/generic/nsHTMLReflowCommand.cpp @@ -45,13 +45,42 @@ NS_NewHTMLReflowCommand(nsIReflowCommand** aInstancePtrResult, return cmd->QueryInterface(kIReflowCommandIID, (void**)aInstancePtrResult); } +nsresult +NS_NewHTMLReflowCommand(nsIReflowCommand** aInstancePtrResult, + nsIFrame* aTargetFrame, + nsIFrame* aChildFrame, + nsIFrame* aPrevSiblingFrame) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsHTMLReflowCommand* cmd = new nsHTMLReflowCommand(aTargetFrame, aChildFrame, + aPrevSiblingFrame); + if (nsnull == cmd) { + return NS_ERROR_OUT_OF_MEMORY; + } + + return cmd->QueryInterface(kIReflowCommandIID, (void**)aInstancePtrResult); +} // Construct a reflow command given a target frame, reflow command type, // and optional child frame nsHTMLReflowCommand::nsHTMLReflowCommand(nsIFrame* aTargetFrame, ReflowType aReflowType, nsIFrame* aChildFrame) - : mType(aReflowType), mTargetFrame(aTargetFrame), mChildFrame(aChildFrame) + : mType(aReflowType), mTargetFrame(aTargetFrame), mChildFrame(aChildFrame), + mPrevSiblingFrame(nsnull) +{ + NS_PRECONDITION(mTargetFrame != nsnull, "null target frame"); + NS_INIT_REFCNT(); +} + +nsHTMLReflowCommand::nsHTMLReflowCommand(nsIFrame* aTargetFrame, + nsIFrame* aChildFrame, + nsIFrame* aPrevSiblingFrame) + : mType(FrameInserted), mTargetFrame(aTargetFrame), mChildFrame(aChildFrame), + mPrevSiblingFrame(aPrevSiblingFrame) { NS_PRECONDITION(mTargetFrame != nsnull, "null target frame"); NS_INIT_REFCNT(); @@ -169,3 +198,9 @@ NS_IMETHODIMP nsHTMLReflowCommand::GetChildFrame(nsIFrame*& aChildFrame) const return NS_OK; } +NS_IMETHODIMP nsHTMLReflowCommand::GetPrevSiblingFrame(nsIFrame*& aSiblingFrame) const +{ + aSiblingFrame = mPrevSiblingFrame; + return NS_OK; +} + diff --git a/layout/generic/nsHTMLReflowCommand.h b/layout/generic/nsHTMLReflowCommand.h index c289973e4408..c732f42f8b28 100644 --- a/layout/generic/nsHTMLReflowCommand.h +++ b/layout/generic/nsHTMLReflowCommand.h @@ -35,6 +35,15 @@ public: ReflowType aReflowType, nsIFrame* aChildFrame = nsnull); + /** + * Construct an HTML reflow command of type FrameInserted, with target + * frame aTargetFrame, and with the specified child and previous sibling + * frames. + */ + nsHTMLReflowCommand(nsIFrame* aTargetFrame, + nsIFrame* aChildFrame, + nsIFrame* aPrevSiblingFrame); + virtual ~nsHTMLReflowCommand(); // nsISupports @@ -49,6 +58,7 @@ public: NS_IMETHOD SetTarget(nsIFrame* aTargetFrame); NS_IMETHOD GetType(ReflowType& aReflowType) const; NS_IMETHOD GetChildFrame(nsIFrame*& aChildFrame) const; + NS_IMETHOD GetPrevSiblingFrame(nsIFrame*& aSiblingFrame) const; protected: void BuildPath(); @@ -58,6 +68,7 @@ private: ReflowType mType; nsIFrame* mTargetFrame; nsIFrame* mChildFrame; + nsIFrame* mPrevSiblingFrame; nsVoidArray mPath; }; diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 422f5c0fddd0..5562615b5e3f 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -496,6 +496,8 @@ public: nsIContent* aContainer) = 0; #endif + // XXX CONSTRUCTION +#if 0 /** * This call is invoked when content is inserted in the content * tree. @@ -516,6 +518,7 @@ public: nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInParent) = 0; +#endif /** * This call is invoked when content is replaced in the content diff --git a/layout/generic/nsPageFrame.cpp b/layout/generic/nsPageFrame.cpp index 6712b0e02c42..c9c16998b7c2 100644 --- a/layout/generic/nsPageFrame.cpp +++ b/layout/generic/nsPageFrame.cpp @@ -44,6 +44,8 @@ void nsPageFrame::CreateFirstChild(nsIPresContext* aPresContext) child->GetTag(tag); // XXX added frameset check, is it necessary, what is a page frame anyway if ((nsHTMLAtoms::body == tag) || (nsHTMLAtoms::frameset == tag)) { + // XXX CONSTRUCTION +#if 0 // Create a frame nsIContentDelegate* cd = child->GetDelegate(aPresContext); if (nsnull != cd) { @@ -59,6 +61,7 @@ void nsPageFrame::CreateFirstChild(nsIPresContext* aPresContext) } NS_RELEASE(cd); } +#endif } NS_IF_RELEASE(tag); NS_RELEASE(child); diff --git a/layout/generic/nsPlaceholderFrame.cpp b/layout/generic/nsPlaceholderFrame.cpp index 91c6a200aeb4..01f41e87735d 100644 --- a/layout/generic/nsPlaceholderFrame.cpp +++ b/layout/generic/nsPlaceholderFrame.cpp @@ -140,6 +140,8 @@ nsPlaceholderFrame::Paint(nsIPresContext& aPresContext, return NS_OK; } +// XXX CONSTRUCTION +#if 0 NS_IMETHODIMP nsPlaceholderFrame::ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, @@ -156,6 +158,7 @@ NS_IMETHODIMP nsPlaceholderFrame::ContentInserted(nsIPresShell* aShell, return NS_OK; } +#endif NS_IMETHODIMP nsPlaceholderFrame::ContentReplaced(nsIPresShell* aShell, nsIPresContext* aPresContext, diff --git a/layout/generic/nsPlaceholderFrame.h b/layout/generic/nsPlaceholderFrame.h index cbe30d557ca1..c74d1009ac55 100644 --- a/layout/generic/nsPlaceholderFrame.h +++ b/layout/generic/nsPlaceholderFrame.h @@ -50,11 +50,14 @@ public: nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); +// XXX CONSTRUCTION +#if 0 NS_IMETHOD ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInParent); +#endif NS_IMETHOD ContentReplaced(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, diff --git a/layout/html/base/src/nsAbsoluteFrame.cpp b/layout/html/base/src/nsAbsoluteFrame.cpp index 51dd76ac3541..d59559fd92a2 100644 --- a/layout/html/base/src/nsAbsoluteFrame.cpp +++ b/layout/html/base/src/nsAbsoluteFrame.cpp @@ -66,6 +66,8 @@ NS_IMETHODIMP nsAbsoluteFrame::Reflow(nsIPresContext& aPresContext, mFrame->SetStyleContext(&aPresContext, mStyleContext); } else { + // XXX CONSTRUCTION +#if 0 // Ask the content delegate to create the frame nsIContentDelegate* delegate = mContent->GetDelegate(&aPresContext); @@ -75,6 +77,7 @@ NS_IMETHODIMP nsAbsoluteFrame::Reflow(nsIPresContext& aPresContext, if (NS_OK != rv) { return rv; } +#endif } // Get the containing block @@ -97,21 +100,6 @@ NS_IMETHODIMP nsAbsoluteFrame::Reflow(nsIPresContext& aPresContext, // XXX CONSTRUCTION #if 0 -NS_IMETHODIMP nsAbsoluteFrame::ContentAppended(nsIPresShell* aShell, - nsIPresContext* aPresContext, - nsIContent* aContainer) -{ - NS_ASSERTION(mContent == aContainer, "bad content-appended target"); - - // Forward the notification to the absolutely positioned frame - if (nsnull != mFrame) { - return mFrame->ContentAppended(aShell, aPresContext, aContainer); - } - - return NS_OK; -} -#endif - NS_IMETHODIMP nsAbsoluteFrame::ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, @@ -128,6 +116,7 @@ NS_IMETHODIMP nsAbsoluteFrame::ContentInserted(nsIPresShell* aShell, return NS_OK; } +#endif NS_IMETHODIMP nsAbsoluteFrame::ContentReplaced(nsIPresShell* aShell, nsIPresContext* aPresContext, diff --git a/layout/html/base/src/nsAbsoluteFrame.h b/layout/html/base/src/nsAbsoluteFrame.h index 8a9a50f288eb..a6b20eee4a2b 100644 --- a/layout/html/base/src/nsAbsoluteFrame.h +++ b/layout/html/base/src/nsAbsoluteFrame.h @@ -48,12 +48,12 @@ public: NS_IMETHOD ContentAppended(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer); -#endif NS_IMETHOD ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInParent); +#endif NS_IMETHOD ContentReplaced(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, diff --git a/layout/html/base/src/nsBlockFrame.cpp b/layout/html/base/src/nsBlockFrame.cpp index e008218f5662..23486174ded2 100644 --- a/layout/html/base/src/nsBlockFrame.cpp +++ b/layout/html/base/src/nsBlockFrame.cpp @@ -131,11 +131,14 @@ public: nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); + // XXX CONSTRUCTION +#if 0 NS_IMETHOD ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInParent); +#endif NS_IMETHOD ContentDeleted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, @@ -1956,6 +1959,17 @@ nsBlockFrame::FindTextRuns(nsBlockReflowState& aState) nsresult nsBlockFrame::FrameInsertedReflow(nsBlockReflowState& aState) { + // Get the inserted frame + nsIFrame* newFrame; + aState.reflowCommand->GetChildFrame(newFrame); + + // Get the previous sibling frame + nsIFrame* prevSibling; + aState.reflowCommand->GetPrevSiblingFrame(prevSibling); + + // Insert the frame. This marks the line dirty... + InsertNewFrame(this, newFrame, prevSibling); + LineData* line = mLines; while (nsnull != line->mNext) { if (line->IsDirty()) { @@ -3210,6 +3224,8 @@ nsBlockFrame::InsertNewFrame(nsBlockFrame* aParentFrame, return NS_OK; } +// XXX CONSTRUCTION +#if 0 // XXX we assume that the insertion is really an assertion and never an append // XXX what about zero lines case NS_IMETHODIMP @@ -3293,6 +3309,7 @@ nsBlockFrame::ContentInserted(nsIPresShell* aShell, return NS_OK; } +#endif NS_IMETHODIMP nsBlockFrame::ContentDeleted(nsIPresShell* aShell, diff --git a/layout/html/base/src/nsBlockReflowState.cpp b/layout/html/base/src/nsBlockReflowState.cpp index e008218f5662..23486174ded2 100644 --- a/layout/html/base/src/nsBlockReflowState.cpp +++ b/layout/html/base/src/nsBlockReflowState.cpp @@ -131,11 +131,14 @@ public: nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); + // XXX CONSTRUCTION +#if 0 NS_IMETHOD ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInParent); +#endif NS_IMETHOD ContentDeleted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, @@ -1956,6 +1959,17 @@ nsBlockFrame::FindTextRuns(nsBlockReflowState& aState) nsresult nsBlockFrame::FrameInsertedReflow(nsBlockReflowState& aState) { + // Get the inserted frame + nsIFrame* newFrame; + aState.reflowCommand->GetChildFrame(newFrame); + + // Get the previous sibling frame + nsIFrame* prevSibling; + aState.reflowCommand->GetPrevSiblingFrame(prevSibling); + + // Insert the frame. This marks the line dirty... + InsertNewFrame(this, newFrame, prevSibling); + LineData* line = mLines; while (nsnull != line->mNext) { if (line->IsDirty()) { @@ -3210,6 +3224,8 @@ nsBlockFrame::InsertNewFrame(nsBlockFrame* aParentFrame, return NS_OK; } +// XXX CONSTRUCTION +#if 0 // XXX we assume that the insertion is really an assertion and never an append // XXX what about zero lines case NS_IMETHODIMP @@ -3293,6 +3309,7 @@ nsBlockFrame::ContentInserted(nsIPresShell* aShell, return NS_OK; } +#endif NS_IMETHODIMP nsBlockFrame::ContentDeleted(nsIPresShell* aShell, diff --git a/layout/html/base/src/nsBlockReflowState.h b/layout/html/base/src/nsBlockReflowState.h index e008218f5662..23486174ded2 100644 --- a/layout/html/base/src/nsBlockReflowState.h +++ b/layout/html/base/src/nsBlockReflowState.h @@ -131,11 +131,14 @@ public: nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); + // XXX CONSTRUCTION +#if 0 NS_IMETHOD ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInParent); +#endif NS_IMETHOD ContentDeleted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, @@ -1956,6 +1959,17 @@ nsBlockFrame::FindTextRuns(nsBlockReflowState& aState) nsresult nsBlockFrame::FrameInsertedReflow(nsBlockReflowState& aState) { + // Get the inserted frame + nsIFrame* newFrame; + aState.reflowCommand->GetChildFrame(newFrame); + + // Get the previous sibling frame + nsIFrame* prevSibling; + aState.reflowCommand->GetPrevSiblingFrame(prevSibling); + + // Insert the frame. This marks the line dirty... + InsertNewFrame(this, newFrame, prevSibling); + LineData* line = mLines; while (nsnull != line->mNext) { if (line->IsDirty()) { @@ -3210,6 +3224,8 @@ nsBlockFrame::InsertNewFrame(nsBlockFrame* aParentFrame, return NS_OK; } +// XXX CONSTRUCTION +#if 0 // XXX we assume that the insertion is really an assertion and never an append // XXX what about zero lines case NS_IMETHODIMP @@ -3293,6 +3309,7 @@ nsBlockFrame::ContentInserted(nsIPresShell* aShell, return NS_OK; } +#endif NS_IMETHODIMP nsBlockFrame::ContentDeleted(nsIPresShell* aShell, diff --git a/layout/html/base/src/nsBodyFrame.cpp b/layout/html/base/src/nsBodyFrame.cpp index ae8e13ac647d..57504a04cc59 100644 --- a/layout/html/base/src/nsBodyFrame.cpp +++ b/layout/html/base/src/nsBodyFrame.cpp @@ -335,6 +335,8 @@ NS_METHOD nsBodyFrame::Reflow(nsIPresContext& aPresContext, return NS_OK; } +// XXX CONSTRUCTION +#if 0 NS_METHOD nsBodyFrame::ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, @@ -347,6 +349,7 @@ NS_METHOD nsBodyFrame::ContentInserted(nsIPresShell* aShell, return mFirstChild->ContentInserted(aShell, aPresContext, aContainer, aChild, aIndexInParent); } +#endif NS_METHOD nsBodyFrame::ContentDeleted(nsIPresShell* aShell, nsIPresContext* aPresContext, diff --git a/layout/html/base/src/nsBodyFrame.h b/layout/html/base/src/nsBodyFrame.h index 60b8a95f0705..b5ac1b204286 100644 --- a/layout/html/base/src/nsBodyFrame.h +++ b/layout/html/base/src/nsBodyFrame.h @@ -50,13 +50,13 @@ public: NS_IMETHOD ContentAppended(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer); -#endif NS_IMETHOD ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInParent); +#endif NS_IMETHOD ContentDeleted(nsIPresShell* aShell, nsIPresContext* aPresContext, diff --git a/layout/html/base/src/nsHTMLBase.cpp b/layout/html/base/src/nsHTMLBase.cpp index 214390de948c..e36c173687e4 100644 --- a/layout/html/base/src/nsHTMLBase.cpp +++ b/layout/html/base/src/nsHTMLBase.cpp @@ -125,6 +125,8 @@ nsHTMLBase::CreateViewForFrame(nsIPresContext* aPresContext, return NS_OK; } +// XXX CONSTRUCTION +#if 0 nsresult nsHTMLBase::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, @@ -206,3 +208,4 @@ nsHTMLBase::CreateFrame(nsIPresContext* aPresContext, NS_RELEASE(kidSC); return rv; } +#endif diff --git a/layout/html/base/src/nsHTMLBase.h b/layout/html/base/src/nsHTMLBase.h index c4cdc6df679e..a07066f74c21 100644 --- a/layout/html/base/src/nsHTMLBase.h +++ b/layout/html/base/src/nsHTMLBase.h @@ -38,11 +38,14 @@ public: * Create a frame for a given piece of content using the style * as a guide for determining which frame to create. */ + // XXX CONSTRUCTION +#if 0 static nsresult CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIContent* aKid, nsIFrame* aKidPrevInFlow, nsIFrame*& aResult); +#endif }; #endif /* nsHTMLBase_h___ */ diff --git a/layout/html/base/src/nsHTMLContainerFrame.cpp b/layout/html/base/src/nsHTMLContainerFrame.cpp index 9b18bf45b751..a76984f0adca 100644 --- a/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -140,26 +140,8 @@ NS_METHOD nsHTMLContainerFrame::GetCursorAndContentAt(nsIPresContext& aPresConte return NS_OK; } -NS_METHOD nsHTMLContainerFrame::ContentAppended(nsIPresShell* aShell, - nsIPresContext* aPresContext, - nsIContent* aContainer) -{ - // Get the last-in-flow - nsHTMLContainerFrame* lastInFlow = (nsHTMLContainerFrame*)GetLastInFlow(); - - // Generate a reflow command for the frame - nsIReflowCommand* cmd; - nsresult result; - - result = NS_NewHTMLReflowCommand(&cmd, lastInFlow, nsIReflowCommand::FrameAppended); - if (NS_OK == result) { - aShell->AppendReflowCommand(cmd); - NS_RELEASE(cmd); - } - - return NS_OK; -} - +// XXX CONSTRUCTION +#if 0 NS_IMETHODIMP nsHTMLContainerFrame::ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, @@ -239,6 +221,7 @@ nsHTMLContainerFrame::ContentInserted(nsIPresShell* aShell, } return rv; } +#endif NS_IMETHODIMP nsHTMLContainerFrame::ContentDeleted(nsIPresShell* aShell, diff --git a/layout/html/base/src/nsHTMLContainerFrame.h b/layout/html/base/src/nsHTMLContainerFrame.h index a01d12cafab6..285d74ce2653 100644 --- a/layout/html/base/src/nsHTMLContainerFrame.h +++ b/layout/html/base/src/nsHTMLContainerFrame.h @@ -40,14 +40,14 @@ public: nsIFrame** aFrame, nsIContent** aContent, PRInt32& aCursor); - NS_IMETHOD ContentAppended(nsIPresShell* aShell, - nsIPresContext* aPresContext, - nsIContent* aContainer); + // XXX CONSTRUCTION +#if 0 NS_IMETHOD ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInParent); +#endif NS_IMETHOD ContentDeleted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, diff --git a/layout/html/base/src/nsHTMLContent.cpp b/layout/html/base/src/nsHTMLContent.cpp index ad04a4ea42b4..64d832ed7c4f 100644 --- a/layout/html/base/src/nsHTMLContent.cpp +++ b/layout/html/base/src/nsHTMLContent.cpp @@ -41,68 +41,6 @@ static NS_DEFINE_IID(kIEventListenerManagerIID, NS_IEVENTLISTENERMANAGER_IID); static NS_DEFINE_IID(kIDOMEventReceiverIID, NS_IDOMEVENTRECEIVER_IID); static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID); -static nsIContentDelegate* gContentDelegate; - -/** - * THE html content delegate. There is exactly one instance of this - * class and it's used for all html content. It just turns around - * and asks the content object to create the frame. - */ -class ContentDelegate : public nsIContentDelegate { -public: - ContentDelegate(); - NS_DECL_ISUPPORTS - NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); -protected: - ~ContentDelegate(); -}; - -ContentDelegate::ContentDelegate() -{ - NS_INIT_REFCNT(); -} - -NS_IMPL_ISUPPORTS(ContentDelegate, kIContentDelegateIID); - -ContentDelegate::~ContentDelegate() -{ -} - -NS_METHOD -ContentDelegate::CreateFrame(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult) -{ - NS_PRECONDITION(nsnull != aContent, "null ptr"); - - // Make sure the content is html content - nsIHTMLContent* hc; - nsIFrame* frame = nsnull; - nsresult rv = aContent->QueryInterface(kIHTMLContentIID, (void**) &hc); - if (NS_OK != rv) { - // This means that *somehow* somebody which is not an html - // content object got ahold of this delegate and tried to - // create a frame with it. Give them back an nsFrame. - rv = nsFrame::NewFrame(&frame, aContent, aParentFrame); - if (NS_OK == rv) { - frame->SetStyleContext(aPresContext, aStyleContext); - } - } - else { - // Ask the content object to create the frame - rv = hc->CreateFrame(aPresContext, aParentFrame, aStyleContext, frame); - NS_RELEASE(hc); - } - aResult = frame; - return rv; -} - //---------------------------------------------------------------------- void* nsHTMLContent::operator new(size_t size) @@ -133,30 +71,11 @@ void nsHTMLContent::operator delete(void* ptr) nsHTMLContent::nsHTMLContent() { - // Create shared content delegate if this is the first html content - // object being created. - if (nsnull == gContentDelegate) { - gContentDelegate = new ContentDelegate(); - } - mListenerManager = nsnull; - - // Add a reference to the shared content delegate object - NS_ADDREF(gContentDelegate); } nsHTMLContent::~nsHTMLContent() { - NS_PRECONDITION(nsnull != gContentDelegate, "null content delegate"); - if (nsnull != gContentDelegate) { - // Remove our reference to the shared content delegate object. If - // the last reference just went away, null out gContentDelegate. - nsrefcnt rc = gContentDelegate->Release(); - if (0 == rc) { - gContentDelegate = nsnull; - } - } - NS_IF_RELEASE(mListenerManager); } @@ -499,12 +418,6 @@ nsHTMLContent::ToHTML(FILE* out) const return NS_OK; } -nsIContentDelegate* nsHTMLContent::GetDelegate(nsIPresContext* aCX) -{ - gContentDelegate->AddRef(); - return gContentDelegate; -} - nsresult nsHTMLContent::SetScriptObject(void *aScriptObject) { mScriptObject = aScriptObject; diff --git a/layout/html/base/src/nsHTMLContent.h b/layout/html/base/src/nsHTMLContent.h index a53108595c1e..9a8d48a4e9a5 100644 --- a/layout/html/base/src/nsHTMLContent.h +++ b/layout/html/base/src/nsHTMLContent.h @@ -139,8 +139,6 @@ public: NS_IMETHOD ToHTML(FILE* out) const; - virtual nsIContentDelegate* GetDelegate(nsIPresContext* aCX); - static void QuoteForHTML(const nsString& aValue, nsString& aResult); NS_IMETHOD SetScriptObject(void *aScriptObject); diff --git a/layout/html/base/src/nsHTMLParts.h b/layout/html/base/src/nsHTMLParts.h index 5325a277ca2a..ee1b33d7e8bd 100644 --- a/layout/html/base/src/nsHTMLParts.h +++ b/layout/html/base/src/nsHTMLParts.h @@ -429,4 +429,11 @@ NS_NewHTMLReflowCommand(nsIReflowCommand** aInstancePtrResult, nsIReflowCommand::ReflowType aReflowType, nsIFrame* aChildFrame = nsnull); +/** Create a new HTML 'FrameInserted' reflow command */ +extern nsresult +NS_NewHTMLReflowCommand(nsIReflowCommand** aInstancePtrResult, + nsIFrame* aTargetFrame, + nsIFrame* aChildFrame, + nsIFrame* aPrevSiblingFrame); + #endif /* nsHTMLParts_h___ */ diff --git a/layout/html/base/src/nsHTMLReflowCommand.cpp b/layout/html/base/src/nsHTMLReflowCommand.cpp index a2a6840cb96d..0dd1dd206246 100644 --- a/layout/html/base/src/nsHTMLReflowCommand.cpp +++ b/layout/html/base/src/nsHTMLReflowCommand.cpp @@ -45,13 +45,42 @@ NS_NewHTMLReflowCommand(nsIReflowCommand** aInstancePtrResult, return cmd->QueryInterface(kIReflowCommandIID, (void**)aInstancePtrResult); } +nsresult +NS_NewHTMLReflowCommand(nsIReflowCommand** aInstancePtrResult, + nsIFrame* aTargetFrame, + nsIFrame* aChildFrame, + nsIFrame* aPrevSiblingFrame) +{ + NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); + if (nsnull == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + nsHTMLReflowCommand* cmd = new nsHTMLReflowCommand(aTargetFrame, aChildFrame, + aPrevSiblingFrame); + if (nsnull == cmd) { + return NS_ERROR_OUT_OF_MEMORY; + } + + return cmd->QueryInterface(kIReflowCommandIID, (void**)aInstancePtrResult); +} // Construct a reflow command given a target frame, reflow command type, // and optional child frame nsHTMLReflowCommand::nsHTMLReflowCommand(nsIFrame* aTargetFrame, ReflowType aReflowType, nsIFrame* aChildFrame) - : mType(aReflowType), mTargetFrame(aTargetFrame), mChildFrame(aChildFrame) + : mType(aReflowType), mTargetFrame(aTargetFrame), mChildFrame(aChildFrame), + mPrevSiblingFrame(nsnull) +{ + NS_PRECONDITION(mTargetFrame != nsnull, "null target frame"); + NS_INIT_REFCNT(); +} + +nsHTMLReflowCommand::nsHTMLReflowCommand(nsIFrame* aTargetFrame, + nsIFrame* aChildFrame, + nsIFrame* aPrevSiblingFrame) + : mType(FrameInserted), mTargetFrame(aTargetFrame), mChildFrame(aChildFrame), + mPrevSiblingFrame(aPrevSiblingFrame) { NS_PRECONDITION(mTargetFrame != nsnull, "null target frame"); NS_INIT_REFCNT(); @@ -169,3 +198,9 @@ NS_IMETHODIMP nsHTMLReflowCommand::GetChildFrame(nsIFrame*& aChildFrame) const return NS_OK; } +NS_IMETHODIMP nsHTMLReflowCommand::GetPrevSiblingFrame(nsIFrame*& aSiblingFrame) const +{ + aSiblingFrame = mPrevSiblingFrame; + return NS_OK; +} + diff --git a/layout/html/base/src/nsHTMLReflowCommand.h b/layout/html/base/src/nsHTMLReflowCommand.h index c289973e4408..c732f42f8b28 100644 --- a/layout/html/base/src/nsHTMLReflowCommand.h +++ b/layout/html/base/src/nsHTMLReflowCommand.h @@ -35,6 +35,15 @@ public: ReflowType aReflowType, nsIFrame* aChildFrame = nsnull); + /** + * Construct an HTML reflow command of type FrameInserted, with target + * frame aTargetFrame, and with the specified child and previous sibling + * frames. + */ + nsHTMLReflowCommand(nsIFrame* aTargetFrame, + nsIFrame* aChildFrame, + nsIFrame* aPrevSiblingFrame); + virtual ~nsHTMLReflowCommand(); // nsISupports @@ -49,6 +58,7 @@ public: NS_IMETHOD SetTarget(nsIFrame* aTargetFrame); NS_IMETHOD GetType(ReflowType& aReflowType) const; NS_IMETHOD GetChildFrame(nsIFrame*& aChildFrame) const; + NS_IMETHOD GetPrevSiblingFrame(nsIFrame*& aSiblingFrame) const; protected: void BuildPath(); @@ -58,6 +68,7 @@ private: ReflowType mType; nsIFrame* mTargetFrame; nsIFrame* mChildFrame; + nsIFrame* mPrevSiblingFrame; nsVoidArray mPath; }; diff --git a/layout/html/base/src/nsPageFrame.cpp b/layout/html/base/src/nsPageFrame.cpp index 6712b0e02c42..c9c16998b7c2 100644 --- a/layout/html/base/src/nsPageFrame.cpp +++ b/layout/html/base/src/nsPageFrame.cpp @@ -44,6 +44,8 @@ void nsPageFrame::CreateFirstChild(nsIPresContext* aPresContext) child->GetTag(tag); // XXX added frameset check, is it necessary, what is a page frame anyway if ((nsHTMLAtoms::body == tag) || (nsHTMLAtoms::frameset == tag)) { + // XXX CONSTRUCTION +#if 0 // Create a frame nsIContentDelegate* cd = child->GetDelegate(aPresContext); if (nsnull != cd) { @@ -59,6 +61,7 @@ void nsPageFrame::CreateFirstChild(nsIPresContext* aPresContext) } NS_RELEASE(cd); } +#endif } NS_IF_RELEASE(tag); NS_RELEASE(child); diff --git a/layout/html/base/src/nsPlaceholderFrame.cpp b/layout/html/base/src/nsPlaceholderFrame.cpp index 91c6a200aeb4..01f41e87735d 100644 --- a/layout/html/base/src/nsPlaceholderFrame.cpp +++ b/layout/html/base/src/nsPlaceholderFrame.cpp @@ -140,6 +140,8 @@ nsPlaceholderFrame::Paint(nsIPresContext& aPresContext, return NS_OK; } +// XXX CONSTRUCTION +#if 0 NS_IMETHODIMP nsPlaceholderFrame::ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, @@ -156,6 +158,7 @@ NS_IMETHODIMP nsPlaceholderFrame::ContentInserted(nsIPresShell* aShell, return NS_OK; } +#endif NS_IMETHODIMP nsPlaceholderFrame::ContentReplaced(nsIPresShell* aShell, nsIPresContext* aPresContext, diff --git a/layout/html/base/src/nsPlaceholderFrame.h b/layout/html/base/src/nsPlaceholderFrame.h index cbe30d557ca1..c74d1009ac55 100644 --- a/layout/html/base/src/nsPlaceholderFrame.h +++ b/layout/html/base/src/nsPlaceholderFrame.h @@ -50,11 +50,14 @@ public: nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); +// XXX CONSTRUCTION +#if 0 NS_IMETHOD ContentInserted(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInParent); +#endif NS_IMETHOD ContentReplaced(nsIPresShell* aShell, nsIPresContext* aPresContext, nsIContent* aContainer, diff --git a/layout/html/content/src/nsGenericDOMDataNode.cpp b/layout/html/content/src/nsGenericDOMDataNode.cpp index ad16b31114ae..72a030cb130d 100644 --- a/layout/html/content/src/nsGenericDOMDataNode.cpp +++ b/layout/html/content/src/nsGenericDOMDataNode.cpp @@ -37,83 +37,6 @@ extern void NS_QuoteForHTML(const nsString& aValue, nsString& aResult); static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID); -// XXX temporary code until troy gets done whacking things - -#include "nsIContentDelegate.h" -#include "nsFrame.h" -#include "nsHTMLParts.h" -static nsIContentDelegate* gContentDelegate; -static NS_DEFINE_IID(kIContentDelegateIID, NS_ICONTENTDELEGATE_IID); - -/** - * THE html content delegate. There is exactly one instance of this - * class and it's used for all html content. It just turns around - * and asks the content object to create the frame. - */ -class ZZContentDelegate : public nsIContentDelegate { -public: - ZZContentDelegate(); - NS_DECL_ISUPPORTS - NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); -protected: - ~ZZContentDelegate(); -}; - -ZZContentDelegate::ZZContentDelegate() -{ - NS_INIT_REFCNT(); -} - -NS_IMPL_ISUPPORTS(ZZContentDelegate, kIContentDelegateIID); - -ZZContentDelegate::~ZZContentDelegate() -{ -} - -NS_METHOD -ZZContentDelegate::CreateFrame(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult) -{ - NS_PRECONDITION(nsnull != aContent, "null ptr"); - - // Make sure the content is html content - nsIDOMNode* dn; - nsIFrame* frame = nsnull; - nsresult rv = aContent->QueryInterface(kIDOMNodeIID, (void**) &dn); - if (NS_OK != rv) { - // This means that *somehow* somebody which is not an dom - // node object got ahold of this delegate and tried to - // create a frame with it. Give them back an nsFrame. - rv = nsFrame::NewFrame(&frame, aContent, aParentFrame); - } - else { - PRInt32 nodeType; - dn->GetNodeType(&nodeType); - switch (nodeType) { - case nsIDOMNode::TEXT: - rv = NS_NewTextFrame(aContent, aParentFrame, frame); - break; - - case nsIDOMNode::COMMENT: - rv = NS_NewCommentFrame(aContent, aParentFrame, frame); - break; - } - NS_RELEASE(dn); - } - if (nsnull != frame) { - frame->SetStyleContext(aPresContext, aStyleContext); - } - aResult = frame; - return rv; -} - //---------------------------------------------------------------------- nsGenericDOMDataNode::nsGenericDOMDataNode() @@ -125,15 +48,6 @@ nsGenericDOMDataNode::nsGenericDOMDataNode() mListenerManager = nsnull; mText = nsnull; mTextLength = 0; - - // Create shared content delegate if this is the first html content - // object being created. - if (nsnull == gContentDelegate) { - gContentDelegate = new ZZContentDelegate(); - } - - // Add a reference to the shared content delegate object - NS_ADDREF(gContentDelegate); } nsGenericDOMDataNode::~nsGenericDOMDataNode() @@ -143,16 +57,6 @@ nsGenericDOMDataNode::~nsGenericDOMDataNode() } NS_IF_RELEASE(mListenerManager); // XXX what about mScriptObject? its now safe to GC it... - - NS_PRECONDITION(nsnull != gContentDelegate, "null content delegate"); - if (nsnull != gContentDelegate) { - // Remove our reference to the shared content delegate object. If - // the last reference just went away, null out gContentDelegate. - nsrefcnt rc = gContentDelegate->Release(); - if (0 == rc) { - gContentDelegate = nsnull; - } - } } void @@ -673,9 +577,3 @@ nsGenericDOMDataNode::SizeOf(nsISizeOfHandler* aHandler) const return NS_OK; } -nsIContentDelegate* -nsGenericDOMDataNode::GetDelegate(nsIPresContext* aCX) -{ - NS_ADDREF(gContentDelegate); - return gContentDelegate; -} diff --git a/layout/html/content/src/nsGenericDOMDataNode.h b/layout/html/content/src/nsGenericDOMDataNode.h index 9880d4938153..1c9f22d5f68b 100644 --- a/layout/html/content/src/nsGenericDOMDataNode.h +++ b/layout/html/content/src/nsGenericDOMDataNode.h @@ -137,7 +137,6 @@ struct nsGenericDOMDataNode { nsresult GetAttribute(const nsString& aName, nsString& aResult) const { return NS_CONTENT_ATTR_NOT_THERE; } - nsIContentDelegate* GetDelegate(nsIPresContext* aCX); nsresult List(FILE* out, PRInt32 aIndent) const; nsresult HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, @@ -430,9 +429,6 @@ struct nsGenericDOMDataNode { nsString& aResult) const { \ return _g.GetAttribute(aName, aResult); \ } \ - virtual nsIContentDelegate* GetDelegate(nsIPresContext* aCX) { \ - return _g.GetDelegate(aCX); \ - } \ NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; \ NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const { \ return _g.BeginConvertToXIF(aConverter); \ diff --git a/layout/html/content/src/nsGenericHTMLElement.cpp b/layout/html/content/src/nsGenericHTMLElement.cpp index ea83c7e0d1a3..e4219f309013 100644 --- a/layout/html/content/src/nsGenericHTMLElement.cpp +++ b/layout/html/content/src/nsGenericHTMLElement.cpp @@ -85,26 +85,6 @@ static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID); static NS_DEFINE_IID(kICSSStyleRuleIID, NS_ICSS_STYLE_RULE_IID); static NS_DEFINE_IID(kIDOMNodeListIID, NS_IDOMNODELIST_IID); -static nsIContentDelegate* gContentDelegate; - -/** - * THE html content delegate. There is exactly one instance of this - * class and it's used for all html content. It just turns around - * and asks the content object to create the frame. - */ -class ZContentDelegate : public nsIContentDelegate { -public: - ZContentDelegate(); - NS_DECL_ISUPPORTS - NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); -protected: - ~ZContentDelegate(); -}; - // Attribute helper class used to wrap up an attribute with a dom // object that implements nsIDOMAttribute and nsIDOMNode and // nsIScriptObjectOwner @@ -218,50 +198,6 @@ private: //---------------------------------------------------------------------- -ZContentDelegate::ZContentDelegate() -{ - NS_INIT_REFCNT(); -} - -NS_IMPL_ISUPPORTS(ZContentDelegate, kIContentDelegateIID); - -ZContentDelegate::~ZContentDelegate() -{ -} - -NS_METHOD -ZContentDelegate::CreateFrame(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult) -{ - NS_PRECONDITION(nsnull != aContent, "null ptr"); - - // Make sure the content is html content - nsIHTMLContent* hc; - nsIFrame* frame = nsnull; - nsresult rv = aContent->QueryInterface(kIHTMLContentIID, (void**) &hc); - if (NS_OK != rv) { - // This means that *somehow* somebody which is not an html - // content object got ahold of this delegate and tried to - // create a frame with it. Give them back an nsFrame. - rv = nsFrame::NewFrame(&frame, aContent, aParentFrame); - if (NS_OK == rv) { - frame->SetStyleContext(aPresContext, aStyleContext); - } - } - else { - // Ask the content object to create the frame - rv = hc->CreateFrame(aPresContext, aParentFrame, aStyleContext, frame); - NS_RELEASE(hc); - } - aResult = frame; - return rv; -} - -//---------------------------------------------------------------------- - DOMAttribute::DOMAttribute(const nsString& aName, const nsString& aValue) : mName(aName), mValue(aValue) { @@ -708,13 +644,6 @@ nsGenericHTMLElement::nsGenericHTMLElement() mContent = nsnull; mScriptObject = nsnull; mListenerManager = nsnull; - - // Create shared content delegate if this is the first html content - // object being created. - if (nsnull == gContentDelegate) { - NS_NEWXPCOM(gContentDelegate, ZContentDelegate); - NS_ADDREF(gContentDelegate); - } } nsGenericHTMLElement::~nsGenericHTMLElement() @@ -725,22 +654,6 @@ nsGenericHTMLElement::~nsGenericHTMLElement() NS_IF_RELEASE(mTag); NS_IF_RELEASE(mListenerManager); // XXX what about mScriptObject? it's now safe to GC it... - -#if 0 - // This code didn't work; and since content delegates are going - // away, I'm not going to fix it. So for now, we will leak a content - // delegate per address space. whoope doopie. -- kipp - NS_PRECONDITION(nsnull != gContentDelegate, "null content delegate"); - if (nsnull != gContentDelegate) { - // Remove our reference to the shared content delegate object. If - // the last reference just went away, null out gContentDelegate. - nsrefcnt rc; - NS_RELEASE2(gContentDelegate, rc); - if (0 == rc) { - gContentDelegate = nsnull; - } - } -#endif } void @@ -1533,13 +1446,6 @@ nsGenericHTMLElement::GetStyleRule(nsIStyleRule*& aResult) return NS_OK; } -nsIContentDelegate* -nsGenericHTMLElement::GetDelegate(nsIPresContext* aCX) -{ - NS_ADDREF(gContentDelegate); - return gContentDelegate; -} - void nsGenericHTMLElement::ListAttributes(FILE* out) const { diff --git a/layout/html/content/src/nsGenericHTMLElement.h b/layout/html/content/src/nsGenericHTMLElement.h index 289fb1b9d1f5..ef3e81572d75 100644 --- a/layout/html/content/src/nsGenericHTMLElement.h +++ b/layout/html/content/src/nsGenericHTMLElement.h @@ -121,7 +121,6 @@ public: nsresult SetAttribute(const nsString& aName, const nsString& aValue, PRBool aNotify); nsresult GetAttribute(const nsString& aName, nsString& aResult) const; - nsIContentDelegate* GetDelegate(nsIPresContext* aCX); nsresult List(FILE* out, PRInt32 aIndent) const; nsresult HandleDOMEvent(nsIPresContext& aPresContext, nsEvent* aEvent, @@ -667,9 +666,6 @@ public: nsString& aResult) const { \ return _g.GetAttribute(aName, aResult); \ } \ - virtual nsIContentDelegate* GetDelegate(nsIPresContext* aCX) { \ - return _g.GetDelegate(aCX); \ - } \ NS_IMETHOD List(FILE* out, PRInt32 aIndent) const { \ return _g.List(out, aIndent); \ } \ diff --git a/layout/html/content/src/nsHTMLGenericContent.cpp b/layout/html/content/src/nsHTMLGenericContent.cpp index b400630078a9..3a36696782bd 100644 --- a/layout/html/content/src/nsHTMLGenericContent.cpp +++ b/layout/html/content/src/nsHTMLGenericContent.cpp @@ -71,26 +71,6 @@ static NS_DEFINE_IID(kIPrivateDOMEventIID, NS_IPRIVATEDOMEVENT_IID); static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID); static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID); -static nsIContentDelegate* gContentDelegate; - -/** - * THE html content delegate. There is exactly one instance of this - * class and it's used for all html content. It just turns around - * and asks the content object to create the frame. - */ -class ZContentDelegate : public nsIContentDelegate { -public: - ZContentDelegate(); - NS_DECL_ISUPPORTS - NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult); -protected: - ~ZContentDelegate(); -}; - // Attribute helper class used to wrap up an attribute with a dom // object that implements nsIDOMAttribute and nsIDOMNode and // nsIScriptObjectOwner @@ -165,50 +145,6 @@ private: //---------------------------------------------------------------------- -ZContentDelegate::ZContentDelegate() -{ - NS_INIT_REFCNT(); -} - -NS_IMPL_ISUPPORTS(ZContentDelegate, kIContentDelegateIID); - -ZContentDelegate::~ZContentDelegate() -{ -} - -NS_METHOD -ZContentDelegate::CreateFrame(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParentFrame, - nsIStyleContext* aStyleContext, - nsIFrame*& aResult) -{ - NS_PRECONDITION(nsnull != aContent, "null ptr"); - - // Make sure the content is html content - nsIHTMLContent* hc; - nsIFrame* frame = nsnull; - nsresult rv = aContent->QueryInterface(kIHTMLContentIID, (void**) &hc); - if (NS_OK != rv) { - // This means that *somehow* somebody which is not an html - // content object got ahold of this delegate and tried to - // create a frame with it. Give them back an nsFrame. - rv = nsFrame::NewFrame(&frame, aContent, aParentFrame); - if (NS_OK == rv) { - frame->SetStyleContext(aPresContext, aStyleContext); - } - } - else { - // Ask the content object to create the frame - rv = hc->CreateFrame(aPresContext, aParentFrame, aStyleContext, frame); - NS_RELEASE(hc); - } - aResult = frame; - return rv; -} - -//---------------------------------------------------------------------- - DOMAttribute::DOMAttribute(const nsString& aName, const nsString& aValue) : mName(aName), mValue(aValue) { @@ -620,15 +556,6 @@ nsHTMLGenericContent::nsHTMLGenericContent() mContent = nsnull; mScriptObject = nsnull; mListenerManager = nsnull; - - // Create shared content delegate if this is the first html content - // object being created. - if (nsnull == gContentDelegate) { - gContentDelegate = new ZContentDelegate(); - } - - // Add a reference to the shared content delegate object - NS_ADDREF(gContentDelegate); } nsHTMLGenericContent::~nsHTMLGenericContent() @@ -639,16 +566,6 @@ nsHTMLGenericContent::~nsHTMLGenericContent() NS_IF_RELEASE(mTag); NS_IF_RELEASE(mListenerManager); // XXX what about mScriptObject? it's now safe to GC it... - - NS_PRECONDITION(nsnull != gContentDelegate, "null content delegate"); - if (nsnull != gContentDelegate) { - // Remove our reference to the shared content delegate object. If - // the last reference just went away, null out gContentDelegate. - nsrefcnt rc = gContentDelegate->Release(); - if (0 == rc) { - gContentDelegate = nsnull; - } - } } void @@ -1394,13 +1311,6 @@ nsHTMLGenericContent::GetStyleRule(nsIStyleRule*& aResult) return NS_OK; } -nsIContentDelegate* -nsHTMLGenericContent::GetDelegate(nsIPresContext* aCX) -{ - gContentDelegate->AddRef(); - return gContentDelegate; -} - void nsHTMLGenericContent::ListAttributes(FILE* out) const { diff --git a/layout/html/style/src/nsHTMLStyleSheet.cpp b/layout/html/style/src/nsHTMLStyleSheet.cpp index 89446a620f79..1cd771b575de 100644 --- a/layout/html/style/src/nsHTMLStyleSheet.cpp +++ b/layout/html/style/src/nsHTMLStyleSheet.cpp @@ -246,6 +246,12 @@ public: nsIContent* aContainer, PRInt32 aNewIndexInContainer); + NS_IMETHOD ContentInserted(nsIPresContext* aPresContext, + nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer); + // XXX style rule enumerations virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; @@ -1311,10 +1317,11 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresContext, return rv; } -NS_IMETHODIMP HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParentFrame, - nsIFrame*& aFrameSubTree) +NS_IMETHODIMP +HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext, + nsIContent* aContent, + nsIFrame* aParentFrame, + nsIFrame*& aFrameSubTree) { nsresult rv; @@ -1354,10 +1361,11 @@ NS_IMETHODIMP HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext, return rv; } -NS_IMETHODIMP HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext, - nsIDocument* aDocument, - nsIContent* aContainer, - PRInt32 aNewIndexInContainer) +NS_IMETHODIMP +HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext, + nsIDocument* aDocument, + nsIContent* aContainer, + PRInt32 aNewIndexInContainer) { nsIPresShell* shell = aPresContext->GetShell(); nsIFrame* parentFrame = shell->FindFrameWithContent(aContainer); @@ -1423,6 +1431,73 @@ NS_IMETHODIMP HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext, return NS_OK; } +NS_IMETHODIMP +HTMLStyleSheetImpl::ContentInserted(nsIPresContext* aPresContext, + nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer) +{ + nsIPresShell* shell = aPresContext->GetShell(); + nsresult rv = NS_OK; + + // Find the frame that precedes the insertion point. + nsIFrame* prevSibling = nsnull; + + // Note: not all content objects are associated with a frame so + // keep looking until we find a previous frame + for (PRInt32 index = aIndexInContainer; index > 0; index--) { + nsIContent* precedingContent; + aContainer->ChildAt(index - 1, precedingContent); + prevSibling = shell->FindFrameWithContent(precedingContent); + NS_RELEASE(precedingContent); + + if (nsnull != prevSibling) { + // The frame may have a next-in-flow. Get the last-in-flow + nsIFrame* nextInFlow; + do { + prevSibling->GetNextInFlow(nextInFlow); + if (nsnull != nextInFlow) { + prevSibling = nextInFlow; + } + } while (nsnull != nextInFlow); + + break; + } + } + + // Get the geometric parent. + // XXX Deal with frame moved out of the flow, e.g., floated and absolutely + // positioned frames... + nsIFrame* parentFrame; + if (nsnull == prevSibling) { + parentFrame = shell->FindFrameWithContent(aContainer); + } else { + prevSibling->GetGeometricParent(parentFrame); + } + + // Construct a new frame + if (nsnull != parentFrame) { + nsIFrame* newFrame; + rv = ConstructFrame(aPresContext, aChild, parentFrame, newFrame); + + // Notify the parent frame with a reflow command, passing it the + // new child frame + if (NS_SUCCEEDED(rv) && (nsnull != newFrame)) { + nsIReflowCommand* reflowCmd; + + rv = NS_NewHTMLReflowCommand(&reflowCmd, parentFrame, newFrame, prevSibling); + if (NS_SUCCEEDED(rv)) { + shell->AppendReflowCommand(reflowCmd); + NS_RELEASE(reflowCmd); + } + } + } + + NS_RELEASE(shell); + return rv; +} + void HTMLStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const { nsAutoString buffer; diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp index 048fe2cdf718..9791025c3701 100644 --- a/layout/html/table/src/nsTableFrame.cpp +++ b/layout/html/table/src/nsTableFrame.cpp @@ -682,11 +682,12 @@ void nsTableFrame::EnsureColumnFrameAt(PRInt32 aColIndex, // Resolve style for the child nsIStyleContext* colGroupStyleContext = aPresContext->ResolveStyleContextFor(lastColGroup, this, PR_TRUE); // kidStyleContext: REFCNT++ - nsIContentDelegate* kidDel = nsnull; - kidDel = lastColGroup->GetDelegate(aPresContext); // kidDel: REFCNT++ - rv = kidDel->CreateFrame(aPresContext, lastColGroup, this, - colGroupStyleContext, (nsIFrame *&)lastColGroupFrame); - NS_RELEASE(kidDel); // kidDel: REFCNT-- + + // Create a col group frame + nsIFrame* newFrame; + NS_NewTableColGroupFrame(lastColGroup, this, newFrame); + lastColGroupFrame = (nsTableColGroupFrame*)newFrame; + lastColGroupFrame->SetStyleContext(aPresContext, colGroupStyleContext); NS_RELEASE(colGroupStyleContext); // kidStyleContenxt: REFCNT-- // hook lastColGroupFrame into child list @@ -1555,7 +1556,6 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext, nscoord bottomInset = borderPadding.bottom; nscoord leftInset = borderPadding.left; nsReflowReason reflowReason = aReflowState.reason; - nsIContent * prevKid; // do NOT hold a reference for this temp pointer! for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; kidFrame->GetNextSibling(kidFrame)) { nsSize maxKidElementSize(0,0); @@ -2687,12 +2687,10 @@ nsTableFrame::CreateContinuingFrame(nsIPresContext& aPresContext, // Resolve style for the child nsIStyleContext* kidStyleContext = aPresContext.ResolveStyleContextFor(content, cf); // kidStyleContext: REFCNT++ - nsIContentDelegate* kidDel = nsnull; - kidDel = content->GetDelegate(&aPresContext); // kidDel: REFCNT++ + nsIFrame* duplicateFrame; - nsresult rv = kidDel->CreateFrame(&aPresContext, content, cf, - kidStyleContext, duplicateFrame); - NS_RELEASE(kidDel); // kidDel: REFCNT-- + NS_NewTableRowGroupFrame(content, cf, duplicateFrame); + duplicateFrame->SetStyleContext(&aPresContext, kidStyleContext); NS_RELEASE(kidStyleContext); // kidStyleContenxt: REFCNT-- if (nsnull==lastSib) diff --git a/layout/html/table/src/nsTableOuterFrame.cpp b/layout/html/table/src/nsTableOuterFrame.cpp index d797daa983dc..df1e064dfc92 100644 --- a/layout/html/table/src/nsTableOuterFrame.cpp +++ b/layout/html/table/src/nsTableOuterFrame.cpp @@ -607,6 +607,8 @@ void nsTableOuterFrame::PlaceChild( OuterTableReflowState& aState, } } +// XXX CONSTRUCTION +#if 0 nsresult nsTableOuterFrame::CreateChildFrames(nsIPresContext* aPresContext) { // Create the inner table frame @@ -674,6 +676,7 @@ nsresult nsTableOuterFrame::CreateChildFrames(nsIPresContext* aPresContext) return NS_OK; } +#endif NS_METHOD nsTableOuterFrame::CreateContinuingFrame(nsIPresContext& aPresContext, diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index 89446a620f79..1cd771b575de 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -246,6 +246,12 @@ public: nsIContent* aContainer, PRInt32 aNewIndexInContainer); + NS_IMETHOD ContentInserted(nsIPresContext* aPresContext, + nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer); + // XXX style rule enumerations virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; @@ -1311,10 +1317,11 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresContext, return rv; } -NS_IMETHODIMP HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParentFrame, - nsIFrame*& aFrameSubTree) +NS_IMETHODIMP +HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext, + nsIContent* aContent, + nsIFrame* aParentFrame, + nsIFrame*& aFrameSubTree) { nsresult rv; @@ -1354,10 +1361,11 @@ NS_IMETHODIMP HTMLStyleSheetImpl::ConstructFrame(nsIPresContext* aPresContext, return rv; } -NS_IMETHODIMP HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext, - nsIDocument* aDocument, - nsIContent* aContainer, - PRInt32 aNewIndexInContainer) +NS_IMETHODIMP +HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext, + nsIDocument* aDocument, + nsIContent* aContainer, + PRInt32 aNewIndexInContainer) { nsIPresShell* shell = aPresContext->GetShell(); nsIFrame* parentFrame = shell->FindFrameWithContent(aContainer); @@ -1423,6 +1431,73 @@ NS_IMETHODIMP HTMLStyleSheetImpl::ContentAppended(nsIPresContext* aPresContext, return NS_OK; } +NS_IMETHODIMP +HTMLStyleSheetImpl::ContentInserted(nsIPresContext* aPresContext, + nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer) +{ + nsIPresShell* shell = aPresContext->GetShell(); + nsresult rv = NS_OK; + + // Find the frame that precedes the insertion point. + nsIFrame* prevSibling = nsnull; + + // Note: not all content objects are associated with a frame so + // keep looking until we find a previous frame + for (PRInt32 index = aIndexInContainer; index > 0; index--) { + nsIContent* precedingContent; + aContainer->ChildAt(index - 1, precedingContent); + prevSibling = shell->FindFrameWithContent(precedingContent); + NS_RELEASE(precedingContent); + + if (nsnull != prevSibling) { + // The frame may have a next-in-flow. Get the last-in-flow + nsIFrame* nextInFlow; + do { + prevSibling->GetNextInFlow(nextInFlow); + if (nsnull != nextInFlow) { + prevSibling = nextInFlow; + } + } while (nsnull != nextInFlow); + + break; + } + } + + // Get the geometric parent. + // XXX Deal with frame moved out of the flow, e.g., floated and absolutely + // positioned frames... + nsIFrame* parentFrame; + if (nsnull == prevSibling) { + parentFrame = shell->FindFrameWithContent(aContainer); + } else { + prevSibling->GetGeometricParent(parentFrame); + } + + // Construct a new frame + if (nsnull != parentFrame) { + nsIFrame* newFrame; + rv = ConstructFrame(aPresContext, aChild, parentFrame, newFrame); + + // Notify the parent frame with a reflow command, passing it the + // new child frame + if (NS_SUCCEEDED(rv) && (nsnull != newFrame)) { + nsIReflowCommand* reflowCmd; + + rv = NS_NewHTMLReflowCommand(&reflowCmd, parentFrame, newFrame, prevSibling); + if (NS_SUCCEEDED(rv)) { + shell->AppendReflowCommand(reflowCmd); + NS_RELEASE(reflowCmd); + } + } + } + + NS_RELEASE(shell); + return rv; +} + void HTMLStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const { nsAutoString buffer; diff --git a/layout/style/nsStyleSet.cpp b/layout/style/nsStyleSet.cpp index 9f9c947c5337..e48927ffc995 100644 --- a/layout/style/nsStyleSet.cpp +++ b/layout/style/nsStyleSet.cpp @@ -764,12 +764,8 @@ NS_IMETHODIMP StyleSetImpl::ContentInserted(nsIPresContext* aPresContext, nsIContent* aChild, PRInt32 aIndexInContainer) { -#if 0 return mFrameConstructor->ContentInserted(aPresContext, aDocument, aContainer, aChild, aIndexInContainer); -#else - return NS_OK; -#endif } NS_IMETHODIMP StyleSetImpl::ContentReplaced(nsIPresContext* aPresContext, diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 048fe2cdf718..9791025c3701 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -682,11 +682,12 @@ void nsTableFrame::EnsureColumnFrameAt(PRInt32 aColIndex, // Resolve style for the child nsIStyleContext* colGroupStyleContext = aPresContext->ResolveStyleContextFor(lastColGroup, this, PR_TRUE); // kidStyleContext: REFCNT++ - nsIContentDelegate* kidDel = nsnull; - kidDel = lastColGroup->GetDelegate(aPresContext); // kidDel: REFCNT++ - rv = kidDel->CreateFrame(aPresContext, lastColGroup, this, - colGroupStyleContext, (nsIFrame *&)lastColGroupFrame); - NS_RELEASE(kidDel); // kidDel: REFCNT-- + + // Create a col group frame + nsIFrame* newFrame; + NS_NewTableColGroupFrame(lastColGroup, this, newFrame); + lastColGroupFrame = (nsTableColGroupFrame*)newFrame; + lastColGroupFrame->SetStyleContext(aPresContext, colGroupStyleContext); NS_RELEASE(colGroupStyleContext); // kidStyleContenxt: REFCNT-- // hook lastColGroupFrame into child list @@ -1555,7 +1556,6 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext, nscoord bottomInset = borderPadding.bottom; nscoord leftInset = borderPadding.left; nsReflowReason reflowReason = aReflowState.reason; - nsIContent * prevKid; // do NOT hold a reference for this temp pointer! for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; kidFrame->GetNextSibling(kidFrame)) { nsSize maxKidElementSize(0,0); @@ -2687,12 +2687,10 @@ nsTableFrame::CreateContinuingFrame(nsIPresContext& aPresContext, // Resolve style for the child nsIStyleContext* kidStyleContext = aPresContext.ResolveStyleContextFor(content, cf); // kidStyleContext: REFCNT++ - nsIContentDelegate* kidDel = nsnull; - kidDel = content->GetDelegate(&aPresContext); // kidDel: REFCNT++ + nsIFrame* duplicateFrame; - nsresult rv = kidDel->CreateFrame(&aPresContext, content, cf, - kidStyleContext, duplicateFrame); - NS_RELEASE(kidDel); // kidDel: REFCNT-- + NS_NewTableRowGroupFrame(content, cf, duplicateFrame); + duplicateFrame->SetStyleContext(&aPresContext, kidStyleContext); NS_RELEASE(kidStyleContext); // kidStyleContenxt: REFCNT-- if (nsnull==lastSib) diff --git a/layout/tables/nsTableOuterFrame.cpp b/layout/tables/nsTableOuterFrame.cpp index d797daa983dc..df1e064dfc92 100644 --- a/layout/tables/nsTableOuterFrame.cpp +++ b/layout/tables/nsTableOuterFrame.cpp @@ -607,6 +607,8 @@ void nsTableOuterFrame::PlaceChild( OuterTableReflowState& aState, } } +// XXX CONSTRUCTION +#if 0 nsresult nsTableOuterFrame::CreateChildFrames(nsIPresContext* aPresContext) { // Create the inner table frame @@ -674,6 +676,7 @@ nsresult nsTableOuterFrame::CreateChildFrames(nsIPresContext* aPresContext) return NS_OK; } +#endif NS_METHOD nsTableOuterFrame::CreateContinuingFrame(nsIPresContext& aPresContext,