Bug 307419. Remove mPresContext from XUL frames. patch by Vidar Harr, r+sr=roc

git-svn-id: svn://10.0.0.236/trunk@186100 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
roc+%cs.cmu.edu 2005-12-15 03:30:17 +00:00
parent 5f3a811473
commit 305c919e9e
17 changed files with 154 additions and 161 deletions

View File

@ -6257,8 +6257,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsFrameConstructorState& aState,
NS_NewListBoxLayout(mPresShell, layout);
newFrame = NS_NewListBoxBodyFrame(mPresShell, PR_FALSE, layout);
((nsListBoxBodyFrame*)newFrame)->InitGroup(this,
aState.mPresContext);
((nsListBoxBodyFrame*)newFrame)->InitGroup(this);
}
else
{

View File

@ -206,8 +206,6 @@ nsBoxFrame::Init(nsPresContext* aPresContext,
nsStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
mPresContext = aPresContext;
nsresult rv = nsContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
// see if we need a widget
@ -2123,18 +2121,19 @@ nsBoxFrame::GetInset(nsMargin& margin)
margin.SizeTo(0,0,0,0);
if (mState & NS_STATE_CURRENTLY_IN_DEBUG) {
nsMargin debugMargin(0,0,0,0);
nsMargin debugBorder(0,0,0,0);
nsMargin debugPadding(0,0,0,0);
GetDebugBorder(debugBorder);
PixelMarginToTwips(mPresContext, debugBorder);
GetDebugMargin(debugMargin);
PixelMarginToTwips(mPresContext, debugMargin);
GetDebugMargin(debugPadding);
PixelMarginToTwips(mPresContext, debugPadding);
margin += debugBorder;
margin += debugMargin;
margin += debugPadding;
nsPresContext* presContext = GetPresContext();
nsMargin debugMargin(0,0,0,0);
nsMargin debugBorder(0,0,0,0);
nsMargin debugPadding(0,0,0,0);
GetDebugBorder(debugBorder);
PixelMarginToTwips(presContext, debugBorder);
GetDebugMargin(debugMargin);
PixelMarginToTwips(presContext, debugMargin);
GetDebugMargin(debugPadding);
PixelMarginToTwips(presContext, debugPadding);
margin += debugBorder;
margin += debugMargin;
margin += debugPadding;
}
return NS_OK;
@ -2527,12 +2526,13 @@ void
nsBoxFrame::FireDOMEvent(const nsAString& aDOMEventName, nsIContent *aContent)
{
nsIContent *content = aContent ? aContent : mContent;
if (content && mPresContext) {
nsPresContext *presContext = GetPresContext();
if (content && presContext) {
// Fire a DOM event
nsCOMPtr<nsIDOMEvent> event;
nsCOMPtr<nsIEventListenerManager> manager;
content->GetListenerManager(getter_AddRefs(manager));
if (manager && NS_SUCCEEDED(manager->CreateEvent(mPresContext, nsnull,
if (manager && NS_SUCCEEDED(manager->CreateEvent(presContext, nsnull,
NS_LITERAL_STRING("Events"),
getter_AddRefs(event)))) {
event->InitEvent(aDOMEventName, PR_TRUE, PR_TRUE);
@ -2541,7 +2541,7 @@ nsBoxFrame::FireDOMEvent(const nsAString& aDOMEventName, nsIContent *aContent)
privateEvent->SetTrusted(PR_TRUE);
PRBool defaultActionEnabled;
mPresContext->EventStateManager()->
presContext->EventStateManager()->
DispatchNewEvent(content, event, &defaultActionEnabled);
}
}

View File

@ -306,8 +306,6 @@ private:
eMouseThrough mMouseThrough;
nsPresContext* mPresContext;
#ifdef DEBUG_LAYOUT
static PRBool gDebug;
static nsIBox* mDebugChild;

View File

@ -506,7 +506,7 @@ nsListBoxBodyFrame::ReflowFinished(nsIPresShell* aPresShell, PRBool* aFlushFlag)
// if the row height changed then mark everything as a style change.
// That will dirty the entire listbox
if (mRowHeightWasSet) {
nsBoxLayoutState state(mPresContext);
nsBoxLayoutState state(GetPresContext());
MarkStyleChange(state);
PRInt32 pos = mCurrentIndex * mRowHeight;
if (mYPosition != pos)
@ -613,7 +613,7 @@ nsListBoxBodyFrame::ScrollByLines(PRInt32 aNumLines)
// I'd use Composite here, but it doesn't always work.
// vm->Composite();
mPresContext->GetViewManager()->ForceUpdate();
GetPresContext()->GetViewManager()->ForceUpdate();
return NS_OK;
}
@ -720,7 +720,7 @@ nsListBoxBodyFrame::SetRowHeight(nscoord aRowHeight)
PRInt32 dummy;
PRInt32 count = rows.ToInteger(&dummy);
float t2p;
t2p = mPresContext->TwipsToPixels();
t2p = GetPresContext()->TwipsToPixels();
PRInt32 rowHeight = NSTwipsToIntPixels(aRowHeight, t2p);
nsAutoString value;
value.AppendInt(rowHeight*count);
@ -842,7 +842,7 @@ nsListBoxBodyFrame::PostReflowCallback()
{
if (!mReflowCallbackPosted) {
mReflowCallbackPosted = PR_TRUE;
mPresContext->PresShell()->PostReflowCallback(this);
GetPresContext()->PresShell()->PostReflowCallback(this);
}
}
@ -899,7 +899,8 @@ nsListBoxBodyFrame::InternalPositionChanged(PRBool aUp, PRInt32 aDelta)
if (aDelta == 0)
return NS_OK;
nsBoxLayoutState state(mPresContext);
nsPresContext *presContext = GetPresContext();
nsBoxLayoutState state(presContext);
// begin timing how long it takes to scroll a row
PRTime start = PR_Now();
@ -908,7 +909,7 @@ nsListBoxBodyFrame::InternalPositionChanged(PRBool aUp, PRInt32 aDelta)
PRInt32 visibleRows = 0;
if (mRowHeight)
visibleRows = GetAvailableHeight()/mRowHeight;
visibleRows = GetAvailableHeight()/mRowHeight;
if (aDelta < visibleRows) {
PRInt32 loseRows = aDelta;
@ -943,7 +944,7 @@ nsListBoxBodyFrame::InternalPositionChanged(PRBool aUp, PRInt32 aDelta)
MarkDirtyChildren(state);
// Flush calls CreateRows
// XXXbz there has to be a better way to do this than flushing!
mPresContext->PresShell()->FlushPendingNotifications(Flush_OnlyReflow);
presContext->PresShell()->FlushPendingNotifications(Flush_OnlyReflow);
mScrolling = PR_FALSE;
VerticalScroll(mYPosition);
@ -1057,7 +1058,7 @@ nsListBoxBodyFrame::DestroyRows(PRInt32& aRowsToLose)
// We need to destroy frames until our row count has been properly
// reduced. A reflow will then pick up and create the new frames.
nsIFrame* childFrame = GetFirstFrame();
nsBoxLayoutState state(mPresContext);
nsBoxLayoutState state(GetPresContext());
while (childFrame && aRowsToLose > 0) {
--aRowsToLose;
@ -1077,7 +1078,7 @@ nsListBoxBodyFrame::ReverseDestroyRows(PRInt32& aRowsToLose)
// We need to destroy frames until our row count has been properly
// reduced. A reflow will then pick up and create the new frames.
nsIFrame* childFrame = GetLastFrame();
nsBoxLayoutState state(mPresContext);
nsBoxLayoutState state(GetPresContext());
while (childFrame && aRowsToLose > 0) {
--aRowsToLose;
@ -1143,7 +1144,7 @@ nsListBoxBodyFrame::GetFirstItemBox(PRInt32 aOffset, PRBool* aCreated)
// XXX check here if frame was even created, it may not have been if
// display: none was on listitem content
PRBool isAppend = mRowsToPrepend <= 0;
mFrameConstructor->CreateListBoxContent(mPresContext, this, nsnull, startContent,
mFrameConstructor->CreateListBoxContent(GetPresContext(), this, nsnull, startContent,
&mTopFrame, isAppend, PR_FALSE, nsnull);
if (mTopFrame) {
@ -1188,7 +1189,7 @@ nsListBoxBodyFrame::GetNextItemBox(nsIBox* aBox, PRInt32 aOffset,
// Either append the new frame, or insert it after the current frame
PRBool isAppend = result != mLinkupFrame && mRowsToPrepend <= 0;
nsIFrame* prevFrame = isAppend ? nsnull : aBox;
mFrameConstructor->CreateListBoxContent(mPresContext, this, prevFrame,
mFrameConstructor->CreateListBoxContent(GetPresContext(), this, prevFrame,
nextContent, &result, isAppend,
PR_FALSE, nsnull);
@ -1225,7 +1226,7 @@ nsListBoxBodyFrame::ContinueReflow(nscoord height)
// We have some hangers on (probably caused by shrinking the size of the window).
// Nuke them.
nsIFrame* currFrame = startingPoint->GetNextSibling();
nsBoxLayoutState state(mPresContext);
nsBoxLayoutState state(GetPresContext());
while (currFrame) {
nsIFrame* nextFrame = currFrame->GetNextSibling();
@ -1245,7 +1246,7 @@ NS_IMETHODIMP
nsListBoxBodyFrame::ListBoxAppendFrames(nsIFrame* aFrameList)
{
// append them after
nsBoxLayoutState state(mPresContext);
nsBoxLayoutState state(GetPresContext());
mFrames.AppendFrames(nsnull, aFrameList);
if (mLayoutManager)
mLayoutManager->ChildrenAppended(this, state, aFrameList);
@ -1258,7 +1259,7 @@ NS_IMETHODIMP
nsListBoxBodyFrame::ListBoxInsertFrames(nsIFrame* aPrevFrame, nsIFrame* aFrameList)
{
// insert the frames to our info list
nsBoxLayoutState state(mPresContext);
nsBoxLayoutState state(GetPresContext());
mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
if (mLayoutManager)
mLayoutManager->ChildrenInserted(this, state, aPrevFrame, aFrameList);
@ -1431,7 +1432,7 @@ nsListBoxBodyFrame::RemoveChildFrame(nsBoxLayoutState &aState,
mFrames.RemoveFrame(aFrame);
if (mLayoutManager)
mLayoutManager->ChildrenRemoved(this, aState, aFrame);
aFrame->Destroy(mPresContext);
aFrame->Destroy(GetPresContext());
}
// Creation Routines ///////////////////////////////////////////////////////////////////////

View File

@ -128,10 +128,9 @@ public:
void PostReflowCallback();
void InitGroup(nsCSSFrameConstructor* aFC, nsPresContext* aContext)
void InitGroup(nsCSSFrameConstructor* aFC)
{
mFrameConstructor = aFC;
mPresContext = aContext;
}
protected:
@ -140,7 +139,6 @@ protected:
// We don't own this. (No addref/release allowed, punk.)
nsCSSFrameConstructor* mFrameConstructor;
nsPresContext* mPresContext;
// row height
PRInt32 mRowCount;

View File

@ -132,9 +132,6 @@ nsMenuBarFrame::Init(nsPresContext* aPresContext,
{
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
// XXX hack
mPresContext = aPresContext;
// Create the menu bar listener.
mMenuBarListener = new nsMenuBarListener(this);
NS_IF_ADDREF(mMenuBarListener);
@ -193,7 +190,7 @@ nsMenuBarFrame::SetActive(PRBool aActiveFlag)
// The caret distracts screen readers and other assistive technologies from the menu selection
// There is 1 caret per document, we need to find the focused document and toggle its caret
do {
nsIPresShell *presShell = mPresContext->GetPresShell();
nsIPresShell *presShell = GetPresContext()->GetPresShell();
if (!presShell)
break;
@ -299,7 +296,7 @@ nsMenuBarFrame::FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent)
// Enumerate over our list of frames.
nsIFrame* immediateParent = nsnull;
GetInsertionPoint(mPresContext->PresShell(), this, nsnull, &immediateParent);
GetInsertionPoint(GetPresContext()->PresShell(), this, nsnull, &immediateParent);
if (!immediateParent)
immediateParent = this;
@ -424,7 +421,7 @@ nsMenuBarFrame::KeyboardNavigation(PRUint32 aKeyCode, PRBool& aHandledFlag)
nsMenuBarFrame::GetNextMenuItem(nsIMenuFrame* aStart)
{
nsIFrame* immediateParent = nsnull;
GetInsertionPoint(mPresContext->PresShell(), this, nsnull, &immediateParent);
GetInsertionPoint(GetPresContext()->PresShell(), this, nsnull, &immediateParent);
if (!immediateParent)
immediateParent = this;
@ -474,7 +471,7 @@ nsMenuBarFrame::GetNextMenuItem(nsIMenuFrame* aStart)
nsMenuBarFrame::GetPreviousMenuItem(nsIMenuFrame* aStart)
{
nsIFrame* immediateParent = nsnull;
GetInsertionPoint(mPresContext->PresShell(), this, nsnull, &immediateParent);
GetInsertionPoint(GetPresContext()->PresShell(), this, nsnull, &immediateParent);
if (!immediateParent)
immediateParent = this;
@ -714,7 +711,7 @@ nsMenuBarFrame::GetWidget(nsIWidget **aWidget)
#if DONT_WANT_TO_DO_THIS
// Get parent view
nsIView * view = nsnull;
nsMenuPopupFrame::GetNearestEnclosingView(mPresContext, this, &view);
nsMenuPopupFrame::GetNearestEnclosingView(GetPresContext(), this, &view);
if (!view)
return NS_OK;

View File

@ -152,9 +152,6 @@ protected:
nsIDOMEventReceiver* mTarget;
// XXX Hack
nsPresContext* mPresContext; // weak reference
private:
PRBool mCaretWasVisible;

View File

@ -150,7 +150,6 @@ nsMenuFrame::nsMenuFrame(nsIPresShell* aShell):nsBoxFrame(aShell),
mChecked(PR_FALSE),
mType(eMenuType_Normal),
mMenuParent(nsnull),
mPresContext(nsnull),
mLastPref(-1,-1)
{
@ -178,8 +177,6 @@ nsMenuFrame::Init(nsPresContext* aPresContext,
nsStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
mPresContext = aPresContext; // Don't addref it. Our lifetime is shorter.
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
nsIFrame* currFrame = aParent;
@ -744,6 +741,8 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag)
if (!mIsMenu)
return;
nsPresContext* presContext = GetPresContext();
if (aActivateFlag) {
// Execute the oncreate handler
if (!OnCreate())
@ -806,14 +805,14 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag)
popupAlign.AssignLiteral("topleft");
}
nsBoxLayoutState state(mPresContext);
nsBoxLayoutState state(presContext);
// if height never set we need to do an initial reflow.
if (mLastPref.height == -1)
{
menuPopup->MarkDirty(state);
mPresContext->PresShell()->FlushPendingNotifications(Flush_OnlyReflow);
presContext->PresShell()->FlushPendingNotifications(Flush_OnlyReflow);
}
nsRect curRect(menuPopup->GetRect());
@ -824,14 +823,14 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag)
if (vm) {
vm->SetViewVisibility(view, nsViewVisibility_kHide);
}
menuPopup->SyncViewWithFrame(mPresContext, popupAnchor, popupAlign, this, -1, -1);
menuPopup->SyncViewWithFrame(presContext, popupAnchor, popupAlign, this, -1, -1);
nscoord newHeight = menuPopup->GetRect().height;
// if the height is different then reflow. It might need scrollbars force a reflow
if (curRect.height != newHeight || mLastPref.height != newHeight)
{
menuPopup->MarkDirty(state);
mPresContext->PresShell()->FlushPendingNotifications(Flush_OnlyReflow);
presContext->PresShell()->FlushPendingNotifications(Flush_OnlyReflow);
}
ActivateMenu(PR_TRUE);
@ -882,7 +881,7 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag)
// mouse_enter/mouse_exit event will be fired to clear current hover state, we should clear it manually.
// This code may not the best solution, but we can leave it here until we find the better approach.
nsIEventStateManager *esm = mPresContext->EventStateManager();
nsIEventStateManager *esm = presContext->EventStateManager();
PRInt32 state;
esm->GetContentState(menuPopup->GetContent(), state);
@ -1632,9 +1631,10 @@ nsMenuFrame::Execute(nsGUIEvent *aEvent)
// important below. We want the pres shell to get released before the
// associated view manager on exit from this function.
// See bug 54233.
nsCOMPtr<nsIViewManager> kungFuDeathGrip = mPresContext->GetViewManager();
nsPresContext* presContext = GetPresContext();
nsCOMPtr<nsIViewManager> kungFuDeathGrip = presContext->GetViewManager();
// keep a reference so we can safely use this after dispatching the DOM event
nsCOMPtr<nsIPresShell> shell = mPresContext->GetPresShell();
nsCOMPtr<nsIPresShell> shell = presContext->GetPresShell();
nsIFrame* me = this;
if (shell) {
shell->HandleDOMEventWithTarget(mContent, &event, &status);
@ -1670,7 +1670,7 @@ nsMenuFrame::OnCreate()
nsresult rv = NS_OK;
nsIPresShell *shell = mPresContext->GetPresShell();
nsIPresShell *shell = GetPresContext()->GetPresShell();
if (shell) {
if (child) {
rv = shell->HandleDOMEventWithTarget(child, &event, &status);
@ -1759,7 +1759,7 @@ nsMenuFrame::OnCreated()
GetMenuChildrenElement(getter_AddRefs(child));
nsresult rv = NS_OK;
nsIPresShell *shell = mPresContext->GetPresShell();
nsIPresShell *shell = GetPresContext()->GetPresShell();
if (shell) {
if (child) {
rv = shell->HandleDOMEventWithTarget(child, &event, &status);
@ -1786,7 +1786,7 @@ nsMenuFrame::OnDestroy()
GetMenuChildrenElement(getter_AddRefs(child));
nsresult rv = NS_OK;
nsIPresShell *shell = mPresContext->GetPresShell();
nsIPresShell *shell = GetPresContext()->GetPresShell();
if (shell) {
if (child) {
rv = shell->HandleDOMEventWithTarget(child, &event, &status);
@ -1813,7 +1813,7 @@ nsMenuFrame::OnDestroyed()
GetMenuChildrenElement(getter_AddRefs(child));
nsresult rv = NS_OK;
nsIPresShell *shell = mPresContext->GetPresShell();
nsIPresShell *shell = GetPresContext()->GetPresShell();
if (shell) {
if (child) {
rv = shell->HandleDOMEventWithTarget(child, &event, &status);
@ -2003,7 +2003,7 @@ nsMenuFrame::SetActiveChild(nsIDOMElement* aChild)
nsCOMPtr<nsIContent> child(do_QueryInterface(aChild));
nsIFrame* kid = mPresContext->PresShell()->GetPrimaryFrameFor(child);
nsIFrame* kid = GetPresContext()->PresShell()->GetPrimaryFrameFor(child);
if (!kid)
return NS_ERROR_FAILURE;
nsIMenuFrame *menuFrame;

View File

@ -233,7 +233,6 @@ protected:
nsIMenuParent* mMenuParent; // Our parent menu.
nsCOMPtr<nsITimer> mOpenTimer;
nsPresContext* mPresContext; // Our pres context.
nsString mGroupName;
nsSize mLastPref;

View File

@ -165,9 +165,6 @@ nsMenuPopupFrame::Init(nsPresContext* aPresContext,
aPresContext->LookAndFeel()->
GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar, tempBool);
mMenuCanOverlapOSBar = tempBool;
// XXX Hack
mPresContext = aPresContext;
CreateViewForFrame(aPresContext, this, aContext, PR_TRUE);
@ -247,13 +244,14 @@ nsMenuPopupFrame::MarkStyleChange(nsBoxLayoutState& aState)
if (menuFrame)
return parent->RelayoutDirtyChild(aState, this);
else {
nsIPopupSetFrame* popupSet = GetPopupSetFrame(mPresContext);
nsPresContext* presContext = GetPresContext();
nsIPopupSetFrame* popupSet = GetPopupSetFrame(presContext);
NS_ASSERTION(popupSet, "popup frame created without a popup set or menu");
if (popupSet) {
nsIFrame *frame;
CallQueryInterface(popupSet, &frame);
if (frame->IsBoxFrame()) {
nsBoxLayoutState state(mPresContext);
nsBoxLayoutState state(presContext);
frame->MarkDirtyChildren(state); // Mark the popupset as dirty.
}
else {
@ -298,13 +296,14 @@ nsMenuPopupFrame::MarkDirty(nsBoxLayoutState& aState)
if (menuFrame)
return parent->RelayoutDirtyChild(aState, this);
else {
nsIPopupSetFrame* popupSet = GetPopupSetFrame(mPresContext);
nsPresContext* presContext = GetPresContext();
nsIPopupSetFrame* popupSet = GetPopupSetFrame(presContext);
NS_ASSERTION(popupSet, "popup frame created without a popup set or menu");
if (popupSet) {
nsIFrame *frame;
CallQueryInterface(popupSet, &frame);
if (frame->IsBoxFrame()) {
nsBoxLayoutState state(mPresContext);
nsBoxLayoutState state(presContext);
frame->MarkDirtyChildren(state); // Mark the popupset as dirty.
}
else {
@ -339,13 +338,14 @@ nsMenuPopupFrame::RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild)
if (menuFrame)
return parent->RelayoutDirtyChild(aState, this);
else {
nsIPopupSetFrame* popupSet = GetPopupSetFrame(mPresContext);
nsPresContext* presContext = GetPresContext();
nsIPopupSetFrame* popupSet = GetPopupSetFrame(presContext);
NS_ASSERTION(popupSet, "popup frame created without a popup set or menu");
nsIFrame *frame = nsnull;
if (popupSet)
CallQueryInterface(popupSet, &frame);
if (frame && frame->IsBoxFrame()) {
nsBoxLayoutState state(mPresContext);
nsBoxLayoutState state(presContext);
frame->MarkDirtyChildren(state); // Mark the popupset as dirty.
}
else
@ -1095,7 +1095,7 @@ nsMenuPopupFrame::SyncViewWithFrame(nsPresContext* aPresContext,
nsBoxFrame::SetPosition(frameOrigin);
if (sizedToPopup) {
nsBoxLayoutState state(mPresContext);
nsBoxLayoutState state(GetPresContext());
SetBounds(state, nsRect(mRect.x, mRect.y, parentRect.width, mRect.height));
}
@ -1123,7 +1123,8 @@ static void GetInsertionPoint(nsIPresShell* aShell, nsIFrame* aFrame, nsIFrame*
nsMenuPopupFrame::GetNextMenuItem(nsIMenuFrame* aStart)
{
nsIFrame* immediateParent = nsnull;
GetInsertionPoint(mPresContext->PresShell(), this, nsnull, &immediateParent);
GetInsertionPoint(GetPresContext()->PresShell(), this, nsnull,
&immediateParent);
if (!immediateParent)
immediateParent = this;
@ -1173,7 +1174,8 @@ nsMenuPopupFrame::GetNextMenuItem(nsIMenuFrame* aStart)
nsMenuPopupFrame::GetPreviousMenuItem(nsIMenuFrame* aStart)
{
nsIFrame* immediateParent = nsnull;
GetInsertionPoint(mPresContext->PresShell(), this, nsnull, &immediateParent);
GetInsertionPoint(GetPresContext()->PresShell(), this, nsnull,
&immediateParent);
if (!immediateParent)
immediateParent = this;
@ -1364,7 +1366,7 @@ NS_IMETHODIMP nsMenuPopupFrame::SetCurrentMenuItem(nsIMenuFrame* aMenuItem)
KillCloseTimer(); // Ensure we don't have another stray waiting closure.
PRInt32 menuDelay = 300; // ms
mPresContext->LookAndFeel()->
GetPresContext()->LookAndFeel()->
GetMetric(nsILookAndFeel::eMetric_SubmenuDelay, menuDelay);
// Kick off the timer.
@ -1399,7 +1401,7 @@ nsMenuPopupFrame::Escape(PRBool& aHandledFlag)
// Get the context menu parent.
nsIFrame* childFrame;
CallQueryInterface(contextMenu, &childFrame);
nsIPopupSetFrame* popupSetFrame = GetPopupSetFrame(mPresContext);
nsIPopupSetFrame* popupSetFrame = GetPopupSetFrame(GetPresContext());
if (popupSetFrame)
// Destroy the popup.
popupSetFrame->DestroyPopup(childFrame, PR_FALSE);
@ -1465,7 +1467,8 @@ nsMenuPopupFrame::FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent, PRBool& doActi
// Enumerate over our list of frames.
nsIFrame* immediateParent = nsnull;
GetInsertionPoint(mPresContext->PresShell(), this, nsnull, &immediateParent);
GetInsertionPoint(GetPresContext()->PresShell(), this, nsnull,
&immediateParent);
if (!immediateParent)
immediateParent = this;
@ -1767,7 +1770,7 @@ nsMenuPopupFrame::HideChain()
if (frame) {
nsIMenuFrame* menuFrame;
if (NS_FAILED(CallQueryInterface(frame, &menuFrame))) {
nsIPopupSetFrame* popupSetFrame = GetPopupSetFrame(mPresContext);
nsIPopupSetFrame* popupSetFrame = GetPopupSetFrame(GetPresContext());
if (popupSetFrame)
// Hide the popup.
popupSetFrame->HidePopup(this);
@ -1802,7 +1805,7 @@ nsMenuPopupFrame::DismissChain()
nsIMenuFrame *menuFrame = nsnull;
CallQueryInterface(frame, &menuFrame);
if (!menuFrame) {
nsIPopupSetFrame* popupSetFrame = GetPopupSetFrame(mPresContext);
nsIPopupSetFrame* popupSetFrame = GetPopupSetFrame(GetPresContext());
if (popupSetFrame) {
// make sure the menu is not highlighted
if (mCurrentMenu) {

View File

@ -209,8 +209,6 @@ protected:
nsIMenuFrame* mCurrentMenu; // The current menu that is active.
// XXX Hack
nsPresContext* mPresContext; // weak reference
nsMenuListener* mKeyboardNavigator; // The listener that tells us about key events.
nsIDOMEventReceiver* mTarget;

View File

@ -136,8 +136,7 @@ NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame)
//
// nsPopupSetFrame cntr
//
nsPopupSetFrame::nsPopupSetFrame(nsIPresShell* aShell):nsBoxFrame(aShell),
mPresContext(nsnull)
nsPopupSetFrame::nsPopupSetFrame(nsIPresShell* aShell):nsBoxFrame(aShell)
{
} // cntr
@ -149,7 +148,6 @@ nsPopupSetFrame::Init(nsPresContext* aPresContext,
nsStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
mPresContext = aPresContext; // Don't addref it. Our lifetime is shorter.
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
nsIRootBox *rootBox;
@ -357,7 +355,7 @@ nsPopupSetFrame::ShowPopup(nsIContent* aElementContent, nsIContent* aPopupConten
entry->mYPos = aYPos;
// If a frame exists already, go ahead and use it.
entry->mPopupFrame = mPresContext->PresShell()
entry->mPopupFrame = GetPresContext()->PresShell()
->GetPrimaryFrameFor(aPopupContent);
#ifdef DEBUG_PINK
@ -405,7 +403,7 @@ nsPopupSetFrame::HidePopup(nsIFrame* aPopup)
// menupopup, then hiding us should also hide the parent menu
// popup.
if (entry->mElementContent->Tag() == nsXULAtoms::menupopup) {
nsIFrame* popupFrame = mPresContext->PresShell()
nsIFrame* popupFrame = GetPresContext()->PresShell()
->GetPrimaryFrameFor(entry->mElementContent);
if (popupFrame) {
nsIMenuParent *menuParent;
@ -436,7 +434,7 @@ nsPopupSetFrame::DestroyPopup(nsIFrame* aPopup, PRBool aDestroyEntireChain)
// menupopup, then destroying us should also dismiss the parent
// menu popup.
if (entry->mElementContent->Tag() == nsXULAtoms::menupopup) {
nsIFrame* popupFrame = mPresContext->PresShell()
nsIFrame* popupFrame = GetPresContext()->PresShell()
->GetPrimaryFrameFor(entry->mElementContent);
if (popupFrame) {
nsIMenuParent *menuParent;
@ -523,7 +521,7 @@ nsPopupSetFrame::OpenPopup(nsPopupFrameList* aEntry, PRBool aActivateFlag)
OnDestroyed(aEntry->mPopupContent);
}
nsBoxLayoutState state(mPresContext);
nsBoxLayoutState state(GetPresContext());
MarkDirtyChildren(state); // Mark ourselves dirty.
}
@ -584,7 +582,7 @@ nsPopupSetFrame::OnCreate(PRInt32 aX, PRInt32 aY, nsIContent* aPopupContent)
event.refPoint.y = aY;
if (aPopupContent) {
nsIPresShell *shell = mPresContext->GetPresShell();
nsIPresShell *shell = GetPresContext()->GetPresShell();
if (shell) {
nsresult rv = shell->HandleDOMEventWithTarget(aPopupContent, &event,
&status);
@ -663,7 +661,7 @@ nsPopupSetFrame::OnCreated(PRInt32 aX, PRInt32 aY, nsIContent* aPopupContent)
//event.point.y = aY;
if (aPopupContent) {
nsIPresShell *shell = mPresContext->GetPresShell();
nsIPresShell *shell = GetPresContext()->GetPresShell();
if (shell) {
nsresult rv = shell->HandleDOMEventWithTarget(aPopupContent, &event,
&status);
@ -684,7 +682,7 @@ nsPopupSetFrame::OnDestroy(nsIContent* aPopupContent)
nsMouseEvent::eReal);
if (aPopupContent) {
nsIPresShell *shell = mPresContext->GetPresShell();
nsIPresShell *shell = GetPresContext()->GetPresShell();
if (shell) {
nsresult rv = shell->HandleDOMEventWithTarget(aPopupContent, &event,
&status);
@ -704,7 +702,7 @@ nsPopupSetFrame::OnDestroyed(nsIContent* aPopupContent)
nsMouseEvent::eReal);
if (aPopupContent) {
nsIPresShell *shell = mPresContext->GetPresShell();
nsIPresShell *shell = GetPresContext()->GetPresShell();
if (shell) {
nsresult rv = shell->HandleDOMEventWithTarget(aPopupContent, &event,
&status);
@ -738,6 +736,7 @@ nsPopupSetFrame::RemovePopupFrame(nsIFrame* aPopup)
// get the popup out of our list, so we don't reflow it later.
nsPopupFrameList* currEntry = mPopupList;
nsPopupFrameList* temp = nsnull;
nsPresContext* presContext = GetPresContext();
while (currEntry) {
if (currEntry->mPopupFrame == aPopup) {
// Remove this entry.
@ -747,7 +746,7 @@ nsPopupSetFrame::RemovePopupFrame(nsIFrame* aPopup)
mPopupList = currEntry->mNextPopup;
// Destroy the frame.
currEntry->mPopupFrame->Destroy(mPresContext);
currEntry->mPopupFrame->Destroy(presContext);
// Delete the entry.
currEntry->mNextPopup = nsnull;

View File

@ -141,8 +141,6 @@ protected:
#endif
nsPopupFrameList* mPopupList;
nsPresContext* mPresContext; // Our pres context.
}; // class nsPopupSetFrame

View File

@ -349,9 +349,6 @@ nsSplitterFrame::Init(nsPresContext* aPresContext,
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
// XXX Hack because we need the pres context in some of the event handling functions...
mPresContext = aPresContext;
nsHTMLContainerFrame::CreateViewForFrame(this, nsnull, PR_TRUE);
nsIView* view = GetView();
@ -672,7 +669,7 @@ nsSplitterFrameInner::MouseUp(nsIDOMEvent* aMouseEvent)
{
mPressed = PR_FALSE;
mOuter->CaptureMouse(mOuter->mPresContext, PR_FALSE);
mOuter->CaptureMouse(mOuter->GetPresContext(), PR_FALSE);
return NS_OK;
}
@ -695,7 +692,8 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
if (disabled.EqualsLiteral("true"))
return NS_OK;
nsBoxLayoutState state(mOuter->mPresContext);
nsPresContext* outerPresContext = mOuter->GetPresContext();
nsBoxLayoutState state(outerPresContext);
mCurrentPos = 0;
mPressed = PR_TRUE;
@ -704,8 +702,8 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
mOuter->GetParentBox(&mParentBox);
// get our index
nscoord childIndex = nsFrameNavigator::IndexOf(mOuter->mPresContext, mParentBox, mOuter);
PRInt32 childCount = nsFrameNavigator::CountFrames(mOuter->mPresContext, mParentBox);
nscoord childIndex = nsFrameNavigator::IndexOf(outerPresContext, mParentBox, mOuter);
PRInt32 childCount = nsFrameNavigator::CountFrames(outerPresContext, mParentBox);
// if its 0 or the last index then stop right here.
if (childIndex == 0 || childIndex == childCount-1) {
@ -852,10 +850,10 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
}
mDragStart = c;
//printf("Pressed mDragStart=%d\n",mDragStart);
mOuter->CaptureMouse(mOuter->mPresContext, PR_TRUE);
mOuter->CaptureMouse(outerPresContext, PR_TRUE);
return NS_OK;
}
@ -866,8 +864,8 @@ nsSplitterFrameInner::MouseMove(nsIDOMEvent* aMouseEvent)
//printf("Mouse move\n");
if (!mPressed)
return NS_OK;
return NS_OK;
if (mDragging)
return NS_OK;
@ -927,7 +925,7 @@ nsSplitterFrameInner::UpdateState()
nsIBox* splitter = mOuter;
// Find the splitter's immediate sibling.
nsIBox* splitterSibling =
nsFrameNavigator::GetChildBeforeAfter(mOuter->mPresContext, splitter,
nsFrameNavigator::GetChildBeforeAfter(mOuter->GetPresContext(), splitter,
(direction == Before));
if (splitterSibling) {
nsIContent* sibling = splitterSibling->GetContent();

View File

@ -113,8 +113,6 @@ private:
friend class nsSplitterFrameInner;
nsSplitterFrameInner* mInner;
// XXX Hack
nsPresContext* mPresContext; // weak reference
}; // class nsSplitterFrame

View File

@ -149,7 +149,7 @@ NS_INTERFACE_MAP_END_INHERITING(nsLeafBoxFrame)
// Constructor
nsTreeBodyFrame::nsTreeBodyFrame(nsIPresShell* aPresShell)
:nsLeafBoxFrame(aPresShell), mPresContext(nsnull), mTreeBoxObject(nsnull), mImageCache(nsnull),
:nsLeafBoxFrame(aPresShell), mTreeBoxObject(nsnull), mImageCache(nsnull),
mScrollbar(nsnull), mHorzScrollbar(nsnull), mColScrollContent(nsnull), mColScrollView(nsnull),
mHorzPosition(0), mHorzWidth(0), mRowHeight(0), mIndentation(0), mStringWidth(-1),
mTopRowIndex(0), mFocused(PR_FALSE), mHasFixedRowCount(PR_FALSE),
@ -243,7 +243,6 @@ NS_IMETHODIMP
nsTreeBodyFrame::Init(nsPresContext* aPresContext, nsIContent* aContent,
nsIFrame* aParent, nsStyleContext* aContext, nsIFrame* aPrevInFlow)
{
mPresContext = aPresContext;
nsresult rv = nsLeafBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
nsBoxFrame::CreateViewForFrame(aPresContext, this, aContext, PR_TRUE);
nsLeafBoxFrame::GetView()->CreateWidget(kWidgetCID);
@ -318,7 +317,7 @@ nsTreeBodyFrame::CalcMaxRowWidth()
nsTreeColumn* col;
nsCOMPtr<nsIRenderingContext> rc;
mPresContext->PresShell()->CreateRenderingContext(this, getter_AddRefs(rc));
GetPresContext()->PresShell()->CreateRenderingContext(this, getter_AddRefs(rc));
for (PRInt32 row = 0; row < mRowCount; ++row) {
rowWidth = 0;
@ -470,7 +469,7 @@ nsTreeBodyFrame::SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRec
{
if ((aRect != mRect || mHorzWidth != CalcHorzWidth()) && !mReflowCallbackPosted) {
mReflowCallbackPosted = PR_TRUE;
mPresContext->PresShell()->PostReflowCallback(this);
GetPresContext()->PresShell()->PostReflowCallback(this);
}
mHorzWidth = CalcHorzWidth();
@ -627,7 +626,7 @@ nsTreeBodyFrame::GetColumns(nsITreeColumns** aColumns)
NS_IMETHODIMP
nsTreeBodyFrame::GetRowHeight(PRInt32* _retval)
{
float t2p = mPresContext->TwipsToPixels();
float t2p = GetPresContext()->TwipsToPixels();
*_retval = NSToCoordRound((float) mRowHeight * t2p);
return NS_OK;
@ -636,7 +635,7 @@ nsTreeBodyFrame::GetRowHeight(PRInt32* _retval)
NS_IMETHODIMP
nsTreeBodyFrame::GetRowWidth(PRInt32 *aRowWidth)
{
float t2p = mPresContext->TwipsToPixels();
float t2p = GetPresContext()->TwipsToPixels();
*aRowWidth = ((float)CalcHorzWidth() * t2p);
return NS_OK;
}
@ -658,7 +657,7 @@ nsTreeBodyFrame::GetLastVisibleRow(PRInt32 *_retval)
NS_IMETHODIMP
nsTreeBodyFrame::GetHorizontalPosition(PRInt32 *aHorizontalPosition)
{
float t2p = mPresContext->TwipsToPixels();
float t2p = GetPresContext()->TwipsToPixels();
*aHorizontalPosition = ((float)mHorzPosition * t2p);
return NS_OK;
}
@ -770,20 +769,21 @@ nsTreeBodyFrame::InvalidateRange(PRInt32 aStart, PRInt32 aEnd)
PRBool
nsTreeBodyFrame::EnsureScrollable(PRBool ensureboth)
{
nsPresContext* presContext = GetPresContext();
if (!mScrollbar || (ensureboth && (!mHorzScrollbar || !mColScrollView))) {
// Try to find it.
nsIContent* parContent = GetBaseElement();
nsIFrame* treeFrame = mPresContext->PresShell()
nsIFrame* treeFrame = presContext->PresShell()
->GetPrimaryFrameFor(parContent);
if (treeFrame)
InitScrollbarFrames(mPresContext, treeFrame, this);
InitScrollbarFrames(presContext, treeFrame, this);
}
NS_ASSERTION(mScrollbar, "no scroll bar");
// The view pointer we have is volatile and strange, update it
mColScrollView = NULL;
nsIFrame* colFrame = mPresContext->PresShell()->GetPrimaryFrameFor(mColScrollContent);
nsIFrame* colFrame = presContext->PresShell()->GetPrimaryFrameFor(mColScrollContent);
if (colFrame) {
nsIScrollableFrame* scrollFrame;
if (NS_SUCCEEDED(CallQueryInterface(colFrame, &scrollFrame)))
@ -799,7 +799,7 @@ nsTreeBodyFrame::UpdateScrollbars()
if (!EnsureScrollable(PR_FALSE))
return;
float t2p = mPresContext->TwipsToPixels();
float t2p = GetPresContext()->TwipsToPixels();
nscoord rowHeightAsPixels = NSToCoordRound((float)mRowHeight*t2p);
nsAutoString curPos;
@ -826,14 +826,16 @@ nsTreeBodyFrame::CheckOverflow()
mVerticalOverflow = PR_FALSE;
verticalOverflowChanged = PR_TRUE;
}
nsPresContext* presContext = GetPresContext();
if (verticalOverflowChanged) {
nsScrollPortEvent event(PR_TRUE, mVerticalOverflow ? NS_SCROLLPORT_OVERFLOW
: NS_SCROLLPORT_UNDERFLOW, nsnull);
event.orient = nsScrollPortEvent::vertical;
nsEventStatus status = nsEventStatus_eIgnore;
mContent->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
mContent->HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
}
PRBool horizontalOverflowChanged = PR_FALSE;
@ -848,7 +850,7 @@ nsTreeBodyFrame::CheckOverflow()
/* Ignore overflows that are less than half a pixel. Yes these happen
all over the place when flex boxes are compressed real small.
Probably a result of a rounding errors somewhere in the layout code. */
float p2t = mPresContext->PixelsToTwips();
float p2t = presContext->PixelsToTwips();
bounds.width += (p2t / 2);
if (!mHorizontalOverflow && bounds.width < mHorzWidth) {
@ -867,7 +869,7 @@ nsTreeBodyFrame::CheckOverflow()
event.orient = nsScrollPortEvent::horizontal;
nsEventStatus status = nsEventStatus_eIgnore;
mContent->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
mContent->HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
}
}
@ -877,12 +879,14 @@ nsTreeBodyFrame::InvalidateScrollbars()
if (mUpdateBatchNest || !mView || !EnsureScrollable(PR_FALSE))
return;
nsPresContext* presContext = GetPresContext();
// Do Vertical Scrollbar
nsIContent* scrollbar = mScrollbar->GetContent();
nsAutoString maxposStr;
float t2p = mPresContext->TwipsToPixels();
float t2p = presContext->TwipsToPixels();
nscoord rowHeightAsPixels = NSToCoordRound((float)mRowHeight*t2p);
PRInt32 size = rowHeightAsPixels * (mRowCount > mPageLength ? mRowCount - mPageLength : 0);
@ -911,7 +915,7 @@ nsTreeBodyFrame::InvalidateScrollbars()
scrollbar->SetAttr(kNameSpaceID_None, nsXULAtoms::pageincrement, pageStr, PR_TRUE);
pageStr.Truncate();
pageStr.AppendInt(NSIntPixelsToTwips(16, mPresContext->PixelsToTwips()));
pageStr.AppendInt(NSIntPixelsToTwips(16, presContext->PixelsToTwips()));
scrollbar->SetAttr(kNameSpaceID_None, nsXULAtoms::increment, pageStr, PR_TRUE);
}
@ -922,27 +926,29 @@ nsTreeBodyFrame::AdjustClientCoordsToBoxCoordSpace(PRInt32 aX, PRInt32 aY,
nscoord* aResultX,
nscoord* aResultY)
{
nsPresContext* presContext = GetPresContext();
// Convert our x and y coords to twips.
// XXXbz should this use IntScaledPixelsToTwips?
float pixelsToTwips = mPresContext->PixelsToTwips();
float pixelsToTwips = presContext->PixelsToTwips();
nsPoint point(NSToIntRound(aX * pixelsToTwips),
NSToIntRound(aY * pixelsToTwips));
// Now get our client offset, in twips, and subtract if from the
// point to get it in our coordinates
nsPoint clientOffset;
nsIView* closestView = GetClosestView(&clientOffset);
point -= clientOffset;
nsIView* rootView;
mPresContext->GetViewManager()->GetRootView(rootView);
presContext->GetViewManager()->GetRootView(rootView);
NS_ASSERTION(closestView && rootView, "No view?");
point -= closestView->GetOffsetTo(rootView);
// Adjust by the inner box coords, so that we're in the inner box's
// coordinate space.
point -= mInnerBox.TopLeft();
*aResultX = point.x;
*aResultY = point.y;
} // AdjustClientCoordsToBoxCoordSpace
@ -1040,6 +1046,8 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, nsITreeColumn* aCol, const n
// The Rect for the requested item.
nsRect theRect;
nsPresContext* presContext = GetPresContext();
for (nsTreeColumn* currCol = mColumns->GetFirstColumn(); currCol && currX < mInnerBox.x + mInnerBox.width;
currCol = currCol->GetNext()) {
@ -1169,7 +1177,7 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, nsITreeColumn* aCol, const n
nsStyleContext* textContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecelltext);
nsCOMPtr<nsIFontMetrics> fm;
mPresContext->DeviceContext()->
presContext->DeviceContext()->
GetMetricsFor(textContext->GetStyleFont()->mFont, *getter_AddRefs(fm));
nscoord height;
fm->GetHeight(height);
@ -1180,7 +1188,7 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, nsITreeColumn* aCol, const n
textRect.height = height + bp.top + bp.bottom;
nsCOMPtr<nsIRenderingContext> rc;
mPresContext->PresShell()->CreateRenderingContext(this, getter_AddRefs(rc));
presContext->PresShell()->CreateRenderingContext(this, getter_AddRefs(rc));
rc->SetFont(fm);
nscoord width;
rc->GetWidth(cellText, width);
@ -1195,7 +1203,7 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, nsITreeColumn* aCol, const n
theRect = textRect;
}
float t2p = mPresContext->TwipsToPixels();
float t2p = presContext->TwipsToPixels();
*aX = NSToIntRound(theRect.x * t2p);
*aY = NSToIntRound(theRect.y * t2p);
@ -1442,7 +1450,7 @@ nsTreeBodyFrame::IsCellCropped(PRInt32 aRow, nsITreeColumn* aCol, PRBool *_retva
{
nscoord currentSize, desiredSize;
nsCOMPtr<nsIRenderingContext> rc;
mPresContext->PresShell()->CreateRenderingContext(this, getter_AddRefs(rc));
GetPresContext()->PresShell()->CreateRenderingContext(this, getter_AddRefs(rc));
nsTreeColumn* col = NS_STATIC_CAST(nsTreeColumn*, aCol);
if (!col)
@ -1466,7 +1474,7 @@ nsTreeBodyFrame::MarkDirtyIfSelect()
// XXX optimize this more
mStringWidth = -1;
nsBoxLayoutState state(mPresContext);
nsBoxLayoutState state(GetPresContext());
MarkDirty(state);
}
}
@ -1478,7 +1486,7 @@ nsTreeBodyFrame::CreateTimer(const nsILookAndFeel::nsMetricID aID,
{
// Get the delay from the look and feel service.
PRInt32 delay = 0;
mPresContext->LookAndFeel()->GetMetric(aID, delay);
GetPresContext()->LookAndFeel()->GetMetric(aID, delay);
nsCOMPtr<nsITimer> timer;
@ -1873,7 +1881,7 @@ nsRect nsTreeBodyFrame::GetImageSize(PRInt32 aRowIndex, nsTreeColumn* aCol, PRBo
if (image) {
if (needWidth || needHeight) {
// Get the natural image size.
float p2t = mPresContext->PixelsToTwips();
float p2t = GetPresContext()->PixelsToTwips();
if (needWidth) {
// Get the size from the image.
@ -1914,10 +1922,11 @@ PRInt32 nsTreeBodyFrame::GetRowHeight()
height = minHeight;
if (height > 0) {
float t2p = mPresContext->TwipsToPixels();
nsPresContext* presContext = GetPresContext();
float t2p = presContext->TwipsToPixels();
height = NSTwipsToIntPixels(height, t2p);
height += height % 2;
float p2t = mPresContext->PixelsToTwips();
float p2t = presContext->PixelsToTwips();
height = NSIntPixelsToTwips(height, p2t);
// XXX Check box-sizing to determine if border/padding should augment the height
@ -1931,7 +1940,7 @@ PRInt32 nsTreeBodyFrame::GetRowHeight()
}
}
float p2t = mPresContext->PixelsToTwips();
float p2t = GetPresContext()->PixelsToTwips();
return NSIntPixelsToTwips(18, p2t); // As good a default as any.
}
@ -1947,7 +1956,7 @@ PRInt32 nsTreeBodyFrame::GetIndentation()
return val;
}
}
float p2t = mPresContext->PixelsToTwips();
float p2t = GetPresContext()->PixelsToTwips();
return NSIntPixelsToTwips(16, p2t); // As good a default as any.
}
@ -2226,7 +2235,7 @@ nsTreeBodyFrame::Paint(nsPresContext* aPresContext,
if (oldPageCount != mPageLength || mHorzWidth != CalcHorzWidth()) {
// Schedule a ResizeReflow that will update our info properly.
nsBoxLayoutState state(mPresContext);
nsBoxLayoutState state(GetPresContext());
MarkDirty(state);
}
@ -2468,7 +2477,7 @@ nsTreeBodyFrame::PaintSeparator(PRInt32 aRowIndex,
height = stylePosition->mHeight.GetCoordValue();
else {
// Use default height 2px.
float p2t = mPresContext->PixelsToTwips();
float p2t = GetPresContext()->PixelsToTwips();
height = NSIntPixelsToTwips(2, p2t);
}
@ -3234,6 +3243,7 @@ nsTreeBodyFrame::PaintDropFeedback(const nsRect& aDropFeedbackRect,
}
const nsStylePosition* stylePosition = feedbackContext->GetStylePosition();
nsPresContext* presContext = GetPresContext();
// Obtain the width for the drop feedback or use default value.
nscoord width;
@ -3241,7 +3251,7 @@ nsTreeBodyFrame::PaintDropFeedback(const nsRect& aDropFeedbackRect,
width = stylePosition->mWidth.GetCoordValue();
else {
// Use default width 50px.
float p2t = mPresContext->PixelsToTwips();
float p2t = presContext->PixelsToTwips();
width = NSIntPixelsToTwips(50, p2t);
}
@ -3251,7 +3261,7 @@ nsTreeBodyFrame::PaintDropFeedback(const nsRect& aDropFeedbackRect,
height = stylePosition->mHeight.GetCoordValue();
else {
// Use default height 2px.
float p2t = mPresContext->PixelsToTwips();
float p2t = presContext->PixelsToTwips();
height = NSIntPixelsToTwips(2, p2t);
}
@ -3368,7 +3378,7 @@ NS_IMETHODIMP nsTreeBodyFrame::ScrollToColumn(nsITreeColumn* aCol)
NS_IMETHODIMP nsTreeBodyFrame::ScrollToHorizontalPosition(PRInt32 aHorizontalPosition)
{
float p2t = mPresContext->PixelsToTwips();
float p2t = GetPresContext()->PixelsToTwips();
ScrollHorzInternal((float)aHorizontalPosition * p2t);
return NS_OK;
}
@ -3447,6 +3457,8 @@ nsTreeBodyFrame::ScrollInternal(PRInt32 aRow)
mTopRowIndex += delta;
nsPresContext* presContext = GetPresContext();
// See if we have a transparent background or a background image.
// If we do, then we cannot blit.
const nsStyleBackground* background = GetStyleBackground();
@ -3456,7 +3468,7 @@ nsTreeBodyFrame::ScrollInternal(PRInt32 aRow)
} else {
nsIWidget* widget = nsLeafBoxFrame::GetView()->GetWidget();
if (widget) {
float t2p = mPresContext->TwipsToPixels();
float t2p = presContext->TwipsToPixels();
nscoord rowHeightAsPixels = NSToCoordRound((float)mRowHeight*t2p);
widget->Scroll(0, -delta*rowHeightAsPixels, nsnull);
}
@ -3466,7 +3478,7 @@ nsTreeBodyFrame::ScrollInternal(PRInt32 aRow)
event.flags = 0;
nsEventStatus status = nsEventStatus_eIgnore;
mContent->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
mContent->HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
return NS_OK;
}
@ -3490,7 +3502,8 @@ nsTreeBodyFrame::ScrollHorzInternal(PRInt32 aPosition)
PRInt32 delta = aPosition - mHorzPosition;
mHorzPosition = aPosition;
float t2p = mPresContext->TwipsToPixels();
nsPresContext* presContext = GetPresContext();
float t2p = presContext->TwipsToPixels();
// See if we have a background image. If we do, then we cannot blit.
const nsStyleBackground* background = GetStyleBackground();
@ -3518,7 +3531,7 @@ nsTreeBodyFrame::ScrollHorzInternal(PRInt32 aPosition)
event.flags = 0;
nsEventStatus status = nsEventStatus_eIgnore;
mContent->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
mContent->HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
return NS_OK;
}
@ -3562,7 +3575,7 @@ nsTreeBodyFrame::PositionChanged(nsISupports* aScrollbar, PRInt32 aOldIndex, PRI
// Vertical Scrollbar
if (mScrollbar == sf) {
float t2p = mPresContext->TwipsToPixels();
float t2p = GetPresContext()->TwipsToPixels();
nscoord rh = NSToCoordRound((float)mRowHeight*t2p);
nscoord newrow = aNewIndex/rh;
@ -3587,7 +3600,7 @@ nsTreeBodyFrame::PositionChanged(nsISupports* aScrollbar, PRInt32 aOldIndex, PRI
nsStyleContext*
nsTreeBodyFrame::GetPseudoStyleContext(nsIAtom* aPseudoElement)
{
return mStyleCache.GetStyleContext(this, mPresContext, mContent,
return mStyleCache.GetStyleContext(this, GetPresContext(), mContent,
mStyleContext, aPseudoElement,
mScratchArray);
}
@ -3775,7 +3788,7 @@ nsTreeBodyFrame::ComputeDropPosition(nsGUIEvent* aEvent, PRInt32* aRow, PRInt16*
if (CanAutoScroll(*aRow)) {
// Get the max value from the look and feel service.
PRInt32 scrollLinesMax = 0;
mPresContext->LookAndFeel()->
GetPresContext()->LookAndFeel()->
GetMetric(nsILookAndFeel::eMetric_TreeScrollLinesMax, scrollLinesMax);
scrollLinesMax--;
if (scrollLinesMax < 0)

View File

@ -328,9 +328,6 @@ protected:
static void ScrollCallback(nsITimer *aTimer, void *aClosure);
protected: // Data Members
// Our cached pres context.
nsPresContext* mPresContext;
// The cached box object parent.
nsCOMPtr<nsITreeBoxObject> mTreeBoxObject;