зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
835eb1c7c3
Коммит
ff8b581e7e
|
@ -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,
|
||||
|
|
Загрузка…
Ссылка в новой задаче