GfxBtn now implements method CreateFrameFor so it can create the text node

with the proper style context parentage.
b=49740 =kmcclusk,attinasi
This commit is contained in:
rods%netscape.com 2000-08-23 10:38:42 +00:00
Родитель 835eb1c7c3
Коммит ff8b581e7e
4 изменённых файлов: 98 добавлений и 2 удалений

Просмотреть файл

@ -397,6 +397,54 @@ nsGfxButtonControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
return result;
}
// Create the text content used as label for the button.
// The frame will be generated by the frame constructor.
NS_IMETHODIMP
nsGfxButtonControlFrame::CreateFrameFor(nsIPresContext* aPresContext,
nsIContent * aContent,
nsIFrame** aFrame)
{
nsIFrame * newFrame = nsnull;
nsresult rv = NS_ERROR_FAILURE;
if (aFrame)
*aFrame = nsnull;
nsCOMPtr<nsIContent> content(do_QueryInterface(mTextContent));
if (aContent == content.get()) {
nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell));
nsIFrame * parentFrame = mFrames.FirstChild();
nsCOMPtr<nsIStyleContext> styleContext;
parentFrame->GetStyleContext(getter_AddRefs(styleContext));
rv = NS_NewTextFrame(shell, &newFrame);
if (NS_FAILED(rv)) { return rv; }
if (!newFrame) { return NS_ERROR_NULL_POINTER; }
nsCOMPtr<nsIStyleContext> textStyleContext;
rv = aPresContext->ResolvePseudoStyleContextFor(content,
nsHTMLAtoms::textPseudo,
styleContext,
PR_FALSE,
getter_AddRefs(textStyleContext));
if (NS_FAILED(rv)) { return rv; }
if (!textStyleContext) { return NS_ERROR_NULL_POINTER; }
if (styleContext) {
// initialize the text frame
newFrame->Init(aPresContext, content, parentFrame, textStyleContext, nsnull);
newFrame->SetInitialChildList(aPresContext, nsnull, nsnull);
rv = NS_OK;
}
}
if (aFrame) {
*aFrame = newFrame;
}
return rv;
}
NS_IMETHODIMP
nsGfxButtonControlFrame::SetDocumentForAnonymousContent(nsIDocument* aDocument,
PRBool aDeep,

Просмотреть файл

@ -73,7 +73,7 @@ public:
PRBool aCompileEventHandlers);
NS_IMETHOD CreateFrameFor(nsIPresContext* aPresContext,
nsIContent * aContent,
nsIFrame** aFrame) { if (aFrame) *aFrame = nsnull; return NS_ERROR_FAILURE; }
nsIFrame** aFrame);
protected:
NS_IMETHOD AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize,

Просмотреть файл

@ -397,6 +397,54 @@ nsGfxButtonControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
return result;
}
// Create the text content used as label for the button.
// The frame will be generated by the frame constructor.
NS_IMETHODIMP
nsGfxButtonControlFrame::CreateFrameFor(nsIPresContext* aPresContext,
nsIContent * aContent,
nsIFrame** aFrame)
{
nsIFrame * newFrame = nsnull;
nsresult rv = NS_ERROR_FAILURE;
if (aFrame)
*aFrame = nsnull;
nsCOMPtr<nsIContent> content(do_QueryInterface(mTextContent));
if (aContent == content.get()) {
nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell));
nsIFrame * parentFrame = mFrames.FirstChild();
nsCOMPtr<nsIStyleContext> styleContext;
parentFrame->GetStyleContext(getter_AddRefs(styleContext));
rv = NS_NewTextFrame(shell, &newFrame);
if (NS_FAILED(rv)) { return rv; }
if (!newFrame) { return NS_ERROR_NULL_POINTER; }
nsCOMPtr<nsIStyleContext> textStyleContext;
rv = aPresContext->ResolvePseudoStyleContextFor(content,
nsHTMLAtoms::textPseudo,
styleContext,
PR_FALSE,
getter_AddRefs(textStyleContext));
if (NS_FAILED(rv)) { return rv; }
if (!textStyleContext) { return NS_ERROR_NULL_POINTER; }
if (styleContext) {
// initialize the text frame
newFrame->Init(aPresContext, content, parentFrame, textStyleContext, nsnull);
newFrame->SetInitialChildList(aPresContext, nsnull, nsnull);
rv = NS_OK;
}
}
if (aFrame) {
*aFrame = newFrame;
}
return rv;
}
NS_IMETHODIMP
nsGfxButtonControlFrame::SetDocumentForAnonymousContent(nsIDocument* aDocument,
PRBool aDeep,

Просмотреть файл

@ -73,7 +73,7 @@ public:
PRBool aCompileEventHandlers);
NS_IMETHOD CreateFrameFor(nsIPresContext* aPresContext,
nsIContent * aContent,
nsIFrame** aFrame) { if (aFrame) *aFrame = nsnull; return NS_ERROR_FAILURE; }
nsIFrame** aFrame);
protected:
NS_IMETHOD AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize,