Bug 347836, Add static method to get nsIRootBox, r+sr=roc

This commit is contained in:
Olli.Pettay%helsinki.fi 2006-08-08 10:40:11 +00:00
Родитель 107935fa3c
Коммит ecb4b6158f
9 изменённых файлов: 52 добавлений и 62 удалений

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

@ -6375,11 +6375,8 @@ nsCSSFrameConstructor::ConstructXULFrame(nsFrameConstructorState& aState,
if (aTag == nsXULAtoms::tooltip) {
if (aContent->AttrValueIs(kNameSpaceID_None, nsXULAtoms::_default,
nsXULAtoms::_true, eIgnoreCase)) {
// Locate the root frame and tell it about the tooltip.
nsIFrame* rootFrame = aState.mFrameManager->GetRootFrame();
if (rootFrame)
rootFrame = rootFrame->GetFirstChild(nsnull);
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
// Locate the root box and tell it about the tooltip.
nsIRootBox* rootBox = nsIRootBox::GetRootBox(mPresShell);
if (rootBox)
rootBox->SetDefaultTooltip(aContent);
}
@ -6485,10 +6482,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsFrameConstructorState& aState,
// Locate the root popup set and add ourselves to the popup set's list
// of popup frames.
nsIFrame* rootFrame = aState.mFrameManager->GetRootFrame();
if (rootFrame)
rootFrame = rootFrame->GetFirstChild(nsnull);
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
nsIRootBox* rootBox = nsIRootBox::GetRootBox(mPresShell);
PRBool added = PR_FALSE;
if (rootBox) {
nsIFrame* popupSetFrame = rootBox->GetPopupSetFrame();
@ -6554,10 +6548,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsFrameConstructorState& aState,
aContent->HasAttr(kNameSpaceID_None, nsXULAtoms::tooltiptext) ||
aContent->HasAttr(kNameSpaceID_None, nsXULAtoms::tooltip))
{
nsIFrame* rootFrame = aState.mFrameManager->GetRootFrame();
if (rootFrame)
rootFrame = rootFrame->GetFirstChild(nsnull);
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
nsIRootBox* rootBox = nsIRootBox::GetRootBox(mPresShell);
if (rootBox)
rootBox->AddTooltipSupport(aContent);
}
@ -9835,10 +9826,8 @@ DeletingFrameSubtree(nsFrameManager* aFrameManager,
if (display->mDisplay == NS_STYLE_DISPLAY_POPUP) {
// Locate the root popup set and remove ourselves from the popup set's list
// of popup frames.
nsIFrame* rootFrame = aFrameManager->GetRootFrame();
if (rootFrame)
rootFrame = rootFrame->GetFirstChild(nsnull);
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
nsIRootBox* rootBox =
nsIRootBox::GetRootBox(aFrameManager->GetPresShell());
NS_ASSERTION(rootBox, "unexpected null pointer");
if (rootBox) {
nsIFrame* popupSetFrame = rootBox->GetPopupSetFrame();
@ -10028,10 +10017,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
// Locate the root popup set and remove ourselves from the popup set's list
// of popup frames.
nsIFrame* rootFrame = frameManager->GetRootFrame();
if (rootFrame)
rootFrame = rootFrame->GetFirstChild(nsnull);
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
nsIRootBox* rootBox = nsIRootBox::GetRootBox(mPresShell);
if (rootBox) {
nsIFrame* popupSetFrame = rootBox->GetPopupSetFrame();
if (popupSetFrame) {
@ -10691,10 +10677,7 @@ nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent,
if (aAttribute == nsXULAtoms::tooltiptext ||
aAttribute == nsXULAtoms::tooltip)
{
nsIFrame* rootFrame = shell->FrameManager()->GetRootFrame();
if (rootFrame)
rootFrame = rootFrame->GetFirstChild(nsnull);
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
nsIRootBox* rootBox = nsIRootBox::GetRootBox(mPresShell);
if (rootBox) {
if (aModType == nsIDOMMutationEvent::REMOVAL)
rootBox->RemoveTooltipSupport(aContent);

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

@ -216,13 +216,12 @@ public:
NS_HIDDEN_(void) DebugVerifyStyleTree(nsIFrame* aFrame);
#endif
private:
NS_HIDDEN_(nsIPresShell*) GetPresShell() const { return mPresShell; }
NS_HIDDEN_(nsPresContext*) GetPresContext() const {
return mPresShell->GetPresContext();
}
private:
NS_HIDDEN_(nsChangeHint)
ReResolveStyleContext(nsPresContext *aPresContext,
nsIFrame *aFrame,

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

@ -58,7 +58,6 @@
#include "nsIPresShell.h"
#include "nsBoxFrame.h"
#include "nsStackLayout.h"
#include "nsIRootBox.h"
#include "nsIAnonymousContentCreator.h"
#include "nsINodeInfo.h"
#include "nsIServiceManager.h"

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

@ -43,10 +43,13 @@
#include "nsISupports.h"
class nsIFrame;
class nsIContent;
class nsIPresShell;
// {DF05F6AB-320B-4e06-AFB3-E39E632A7555}
// {2256d568-3f5a-42ec-b932-3d0f78551a1a}
#define NS_IROOTBOX_IID \
{ 0xdf05f6ab, 0x320b, 0x4e06, { 0xaf, 0xb3, 0xe3, 0x9e, 0x63, 0x2a, 0x75, 0x55 } }
{ 0x2256d568, 0x3f5a, 0x42ec, \
{ 0xb9, 0x32, 0x3d, 0x0f, 0x78, 0x55, 0x1a, 0x1a } }
class nsIRootBox : public nsISupports {
@ -61,6 +64,8 @@ public:
virtual nsresult AddTooltipSupport(nsIContent* aNode) = 0;
virtual nsresult RemoveTooltipSupport(nsIContent* aNode) = 0;
static nsIRootBox* GetRootBox(nsIPresShell* aShell);
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIRootBox, NS_IROOTBOX_IID)

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

@ -86,15 +86,7 @@ const PRInt32 kMaxZ = 0x7fffffff; //XXX: Shouldn't there be a define somewhere f
static nsIPopupSetFrame*
GetPopupSetFrame(nsPresContext* aPresContext)
{
nsIFrame* rootFrame =
aPresContext->PresShell()->FrameManager()->GetRootFrame();
if (!rootFrame)
return nsnull;
if (rootFrame)
rootFrame = rootFrame->GetFirstChild(nsnull);
nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));
nsIRootBox* rootBox = nsIRootBox::GetRootBox(aPresContext->PresShell());
if (!rootBox)
return nsnull;

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

@ -77,21 +77,7 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsPopupBoxObject, nsBoxObject, nsIPopupBoxObject)
nsIPopupSetFrame*
nsPopupBoxObject::GetPopupSetFrame()
{
nsIPresShell* shell = GetPresShell(PR_FALSE);
if (!shell) {
return nsnull;
}
nsIFrame* rootFrame = shell->FrameManager()->GetRootFrame();
if (!rootFrame)
return nsnull;
if (rootFrame) {
rootFrame = rootFrame->GetFirstChild(nsnull);
}
nsIRootBox *rootBox = nsnull;
CallQueryInterface(rootFrame, &rootBox);
nsIRootBox* rootBox = nsIRootBox::GetRootBox(GetPresShell(PR_FALSE));
if (!rootBox)
return nsnull;

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

@ -60,11 +60,35 @@
#include "nsIRootBox.h"
#include "nsIContent.h"
#include "nsXULTooltipListener.h"
#include "nsFrameManager.h"
// Interface IDs
//#define DEBUG_REFLOW
// static
nsIRootBox*
nsIRootBox::GetRootBox(nsIPresShell* aShell)
{
if (!aShell) {
return nsnull;
}
nsIFrame* rootFrame = aShell->FrameManager()->GetRootFrame();
if (!rootFrame) {
return nsnull;
}
if (rootFrame) {
rootFrame = rootFrame->GetFirstChild(nsnull);
}
nsIRootBox* rootBox = nsnull;
if (rootFrame) {
CallQueryInterface(rootFrame, &rootBox);
}
return rootBox;
}
class nsRootBoxFrame : public nsBoxFrame, public nsIRootBox {
public:
@ -304,7 +328,7 @@ nsRootBoxFrame::AddTooltipSupport(nsIContent* aNode)
if (!listener)
return NS_ERROR_OUT_OF_MEMORY;
listener->Init(aNode, this);
listener->Init(aNode);
return NS_OK;
}

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

@ -59,6 +59,7 @@
#include "nsIScriptContext.h"
#include "nsPIDOMWindow.h"
#include "nsContentUtils.h"
#include "nsIRootBox.h"
//////////////////////////////////////////////////////////////////////////
//// nsISupports
@ -274,9 +275,8 @@ PRBool nsXULTooltipListener::sShowTooltips = PR_FALSE;
// XXX: This could all be done in the ctor.
nsresult
nsXULTooltipListener::Init(nsIContent* aSourceNode, nsIRootBox* aRootBox)
nsXULTooltipListener::Init(nsIContent* aSourceNode)
{
mRootBox = aRootBox;
mSourceNode = aSourceNode;
AddTooltipSupport(aSourceNode);
@ -585,7 +585,9 @@ nsXULTooltipListener::FindTooltip(nsIContent* aTarget, nsIContent** aTooltip)
aTarget->GetAttr(kNameSpaceID_None, nsXULAtoms::tooltiptext, tooltipText);
if (!tooltipText.IsEmpty()) {
// specifying tooltiptext means we will always use the default tooltip
*aTooltip = mRootBox->GetDefaultTooltip();
nsIRootBox* rootBox = nsIRootBox::GetRootBox(document->GetShellAt(0));
NS_ENSURE_STATE(rootBox);
*aTooltip = rootBox->GetDefaultTooltip();
if (*aTooltip) {
NS_ADDREF(*aTooltip);
(*aTooltip)->SetAttr(kNameSpaceID_None, nsXULAtoms::label, tooltipText, PR_TRUE);
@ -625,7 +627,9 @@ nsXULTooltipListener::FindTooltip(nsIContent* aTarget, nsIContent** aTooltip)
#ifdef MOZ_XUL
// titletips should just use the default tooltip
if (mIsSourceTree && mNeedTitletip) {
NS_IF_ADDREF(*aTooltip = mRootBox->GetDefaultTooltip());
nsIRootBox* rootBox = nsIRootBox::GetRootBox(document->GetShellAt(0));
NS_ENSURE_STATE(rootBox);
NS_IF_ADDREF(*aTooltip = rootBox->GetDefaultTooltip());
}
#endif

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

@ -46,7 +46,6 @@
#include "nsIContent.h"
#include "nsIDOMElement.h"
#include "nsITimer.h"
#include "nsIRootBox.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#ifdef MOZ_XUL
@ -97,7 +96,7 @@ public:
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
nsresult Init(nsIContent* aSourceNode, nsIRootBox* aRootBox);
nsresult Init(nsIContent* aSourceNode);
nsresult AddTooltipSupport(nsIContent* aNode);
nsresult RemoveTooltipSupport(nsIContent* aNode);
@ -127,7 +126,6 @@ protected:
static int ToolbarTipsPrefChanged(const char *aPref, void *aClosure);
nsIRootBox* mRootBox;
nsIContent* mSourceNode;
nsCOMPtr<nsIContent> mTargetNode;
nsCOMPtr<nsIContent> mCurrentTooltip;