Bug 478245 - Crash [@ nsEventStateManager::PreHandleEvent], r+sr=dbaron

This commit is contained in:
Olli Pettay 2009-03-11 17:43:08 +02:00
Родитель 350911cd4e
Коммит b6cf78a6a8
19 изменённых файлов: 54 добавлений и 45 удалений

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

@ -211,8 +211,10 @@ nsIMEStateManager::IsActive(nsPresContext* aPresContext)
// This root window is not active.
return PR_FALSE;
}
NS_ENSURE_TRUE(aPresContext->GetPresShell(), PR_FALSE);
nsIViewManager* vm = aPresContext->GetViewManager();
nsIPresShell* shell = aPresContext->GetPresShell();
NS_ENSURE_TRUE(shell, NS_ERROR_NOT_AVAILABLE);
nsIViewManager* vm = shell->GetViewManager();
NS_ENSURE_TRUE(vm, PR_FALSE);
nsCOMPtr<nsIViewObserver> observer;
vm->GetViewObserver(*getter_AddRefs(observer));
@ -274,7 +276,10 @@ nsIMEStateManager::SetIMEState(nsPresContext* aPresContext,
nsIWidget*
nsIMEStateManager::GetWidget(nsPresContext* aPresContext)
{
nsIViewManager* vm = aPresContext->GetViewManager();
nsIPresShell* shell = aPresContext->GetPresShell();
NS_ENSURE_TRUE(shell, nsnull);
nsIViewManager* vm = shell->GetViewManager();
if (!vm)
return nsnull;
nsCOMPtr<nsIWidget> widget = nsnull;
@ -540,7 +545,10 @@ nsIMEStateManager::OnTextStateFocus(nsPresContext* aPresContext,
nsINode *editableNode = GetRootEditableNode(aPresContext, aContent);
if (!editableNode) return NS_OK;
nsIViewManager* vm = aPresContext->GetViewManager();
nsIPresShell* shell = aPresContext->GetPresShell();
NS_ENSURE_TRUE(shell, NS_ERROR_NOT_AVAILABLE);
nsIViewManager* vm = shell->GetViewManager();
NS_ENSURE_TRUE(vm, NS_ERROR_NOT_AVAILABLE);
nsCOMPtr<nsIWidget> widget;

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

@ -479,12 +479,8 @@ nsImageDocument::ScrollImageTo(PRInt32 aX, PRInt32 aY, PRBool restoreImage)
nsIPresShell *shell = GetPrimaryShell();
if (!shell)
return NS_OK;
nsPresContext* context = shell->GetPresContext();
if (!context)
return NS_OK;
nsIViewManager* vm = context->GetViewManager();
nsIViewManager* vm = shell->GetViewManager();
if (!vm)
return NS_OK;

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

@ -3950,11 +3950,11 @@ nsDocShell::DoGetPositionAndSize(PRInt32 * x, PRInt32 * y, PRInt32 * cx,
NS_IMETHODIMP
nsDocShell::Repaint(PRBool aForce)
{
nsCOMPtr<nsPresContext> context;
GetPresContext(getter_AddRefs(context));
NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
nsCOMPtr<nsIPresShell> presShell;
GetPresShell(getter_AddRefs(presShell));
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsIViewManager* viewManager = context->GetViewManager();
nsIViewManager* viewManager = presShell->GetViewManager();
NS_ENSURE_TRUE(viewManager, NS_ERROR_FAILURE);
// what about aForce ?

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

@ -490,7 +490,12 @@ nsDOMWindowUtils::ProcessUpdates()
nsPresContext* presContext = GetPresContext();
if (!presContext)
return NS_ERROR_UNEXPECTED;
nsIViewManager *viewManager = presContext->GetViewManager();
nsIPresShell* shell = presContext->GetPresShell();
if (!shell)
return NS_ERROR_UNEXPECTED;
nsIViewManager *viewManager = shell->GetViewManager();
if (!viewManager)
return NS_ERROR_UNEXPECTED;

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

@ -8164,10 +8164,10 @@ nsGlobalWindow::GetScrollInfo(nsIScrollableView **aScrollableView)
return NS_OK;
}
nsCOMPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
if (presContext) {
nsIViewManager* vm = presContext->GetViewManager();
nsCOMPtr<nsIPresShell> presShell;
mDocShell->GetPresShell(getter_AddRefs(presShell));
if (presShell) {
nsIViewManager* vm = presShell->GetViewManager();
if (vm)
return vm->GetRootScrollableView(aScrollableView);
}

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

@ -8656,7 +8656,7 @@ ApplyRenderingChangeToTree(nsPresContext* aPresContext,
NS_ASSERTION(aFrame, "root frame must paint");
}
nsIViewManager* viewManager = aPresContext->GetViewManager();
nsIViewManager* viewManager = shell->GetViewManager();
// Trigger rendering updates by damaging this frame and any
// continuations of this frame.
@ -8732,7 +8732,7 @@ InvalidateCanvasIfNeeded(nsIFrame* aFrame)
// Wrap this in a DEFERRED view update batch so we don't try to
// flush out layout here
nsIViewManager::UpdateViewBatch batch(presContext->GetViewManager());
nsIViewManager::UpdateViewBatch batch(presContext->GetPresShell()->GetViewManager());
ApplyRenderingChangeToTree(presContext, ancestor,
nsChangeHint_RepaintFrame);
batch.EndUpdateViewBatch(NS_VMREFRESH_DEFERRED);

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

@ -2777,7 +2777,7 @@ DocumentViewerImpl::SetFullZoom(float aFullZoom)
nsCOMPtr<nsIPresShell> shell = pc->GetPresShell();
NS_ENSURE_TRUE(shell, NS_OK);
nsIViewManager::UpdateViewBatch batch(pc->GetViewManager());
nsIViewManager::UpdateViewBatch batch(shell->GetViewManager());
if (!mPrintPreviewZoomed) {
mOriginalPrintPreviewScale = pc->GetPrintPreviewScale();
mPrintPreviewZoomed = PR_TRUE;

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

@ -755,7 +755,7 @@ nsPresContext::PreferenceChanged(const char* aPrefName)
// Re-fetch the view manager's window dimensions in case there's a deferred
// resize which hasn't affected our mVisibleArea yet
nscoord oldWidthAppUnits, oldHeightAppUnits;
nsIViewManager* vm = GetViewManager();
nsIViewManager* vm = mShell->GetViewManager();
vm->GetWindowDimensions(&oldWidthAppUnits, &oldHeightAppUnits);
float oldWidthDevPixels = oldWidthAppUnits/oldAppUnitsPerDevPixel;
float oldHeightDevPixels = oldHeightAppUnits/oldAppUnitsPerDevPixel;
@ -1211,7 +1211,7 @@ nsPresContext::SetFullZoom(float aZoom)
// Re-fetch the view manager's window dimensions in case there's a deferred
// resize which hasn't affected our mVisibleArea yet
nscoord oldWidthAppUnits, oldHeightAppUnits;
GetViewManager()->GetWindowDimensions(&oldWidthAppUnits, &oldHeightAppUnits);
mShell->GetViewManager()->GetWindowDimensions(&oldWidthAppUnits, &oldHeightAppUnits);
float oldWidthDevPixels = oldWidthAppUnits / float(mCurAppUnitsPerDevPixel);
float oldHeightDevPixels = oldHeightAppUnits / float(mCurAppUnitsPerDevPixel);
if (mDeviceContext->SetPixelScale(aZoom)) {
@ -1222,8 +1222,9 @@ nsPresContext::SetFullZoom(float aZoom)
mSupressResizeReflow = PR_TRUE;
mFullZoom = aZoom;
GetViewManager()->SetWindowDimensions(NSToCoordRound(oldWidthDevPixels * AppUnitsPerDevPixel()),
NSToCoordRound(oldHeightDevPixels * AppUnitsPerDevPixel()));
mShell->GetViewManager()->
SetWindowDimensions(NSToCoordRound(oldWidthDevPixels * AppUnitsPerDevPixel()),
NSToCoordRound(oldHeightDevPixels * AppUnitsPerDevPixel()));
if (HasCachedStyleData()) {
MediaFeatureValuesChanged(PR_TRUE);
RebuildAllStyleData(NS_STYLE_HINT_REFLOW);

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

@ -207,7 +207,6 @@ public:
return mDocument;
}
nsIViewManager* GetViewManager() { return GetPresShell()->GetViewManager(); }
#ifdef _IMPL_NS_LAYOUT
nsStyleSet* StyleSet() { return GetPresShell()->StyleSet(); }

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

@ -358,7 +358,7 @@ nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
// This is only needed for embedding, the focus may go to
// the chrome that is not part of the Gecko system (Bug 83493)
// XXX this is rather inefficient
nsIViewManager* vm = PresContext()->GetViewManager();
nsIViewManager* vm = PresContext()->GetPresShell()->GetViewManager();
if (vm) {
vm->UpdateAllViews(NS_VMREFRESH_NO_SYNC);
}

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

@ -768,7 +768,8 @@ static nsIFrame*
GetActiveSelectionFrame(nsIFrame* aFrame)
{
nsIView* mouseGrabber;
aFrame->PresContext()->GetViewManager()->GetMouseEventGrabber(mouseGrabber);
aFrame->PresContext()->GetPresShell()->
GetViewManager()->GetMouseEventGrabber(mouseGrabber);
if (mouseGrabber) {
nsIFrame* activeFrame = nsLayoutUtils::GetFrameFor(mouseGrabber);
if (activeFrame) {

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

@ -311,10 +311,11 @@ nsHTMLFramesetFrame::Init(nsIContent* aContent,
}
}
nsPresContext* aPresContext = PresContext();
nsPresContext* presContext = PresContext();
nsIPresShell* shell = presContext->PresShell();
// create the view. a view is needed since it needs to be a mouse grabber
nsIViewManager* viewMan = aPresContext->GetViewManager();
nsIViewManager* viewMan = shell->GetViewManager();
nsIView *parView = GetAncestorWithView()->GetView();
nsRect boundBox(0, 0, 0, 0);
@ -325,11 +326,9 @@ nsHTMLFramesetFrame::Init(nsIContent* aContent,
// XXX Put it last in document order until we can do better
viewMan->InsertChild(parView, view, nsnull, PR_TRUE);
SetView(view);
nsIPresShell *shell = aPresContext->PresShell();
nsFrameborder frameborder = GetFrameBorder();
PRInt32 borderWidth = GetBorderWidth(aPresContext, PR_FALSE);
PRInt32 borderWidth = GetBorderWidth(presContext, PR_FALSE);
nscolor borderColor = GetBorderColor();
// Get the rows= cols= data
@ -1575,7 +1574,7 @@ nsHTMLFramesetFrame::MouseDrag(nsPresContext* aPresContext,
}
// Update the view immediately (make drag appear snappier)
nsIViewManager* vm = aPresContext->GetViewManager();
nsIViewManager* vm = aPresContext->GetPresShell()->GetViewManager();
if (vm) {
nsIView* root;
vm->GetRootView(root);

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

@ -203,7 +203,7 @@ CanvasFrame::Init(nsIContent* aContent,
{
nsresult rv = nsHTMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
mViewManager = PresContext()->GetViewManager();
mViewManager = PresContext()->GetPresShell()->GetViewManager();
nsIScrollableView* scrollingView = nsnull;
mViewManager->GetRootScrollableView(&scrollingView);

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

@ -5134,16 +5134,15 @@ nsTypedSelection::ScrollPointIntoClipView(nsPresContext *aPresContext, nsIView *
if (dx != 0 || dy != 0)
{
nsCOMPtr<nsIPresShell> presShell;
GetPresShell(getter_AddRefs(presShell));
NS_ASSERTION(presShell, "no pres shell");
nsCOMPtr<nsIPresShell> presShell = aPresContext->GetPresShell();
NS_ENSURE_STATE(presShell);
nsWeakView weakView = scrollableView->View();
// Make sure latest bits are available before we scroll them. This flushes
// pending notifications and thus might destroy stuff (bug 421839).
// We need to hold a strong ref on the view manager to keep it alive.
nsCOMPtr<nsIViewManager> viewManager = aPresContext->GetViewManager();
nsCOMPtr<nsIViewManager> viewManager = presShell->GetViewManager();
viewManager->Composite();
if (!weakView.IsAlive()) {

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

@ -1826,7 +1826,7 @@ nsBoxFrame::CreateViewForFrame(nsPresContext* aPresContext,
if (aForce) {
nsIView* parentView;
nsIViewManager* viewManager = aPresContext->GetViewManager();
nsIViewManager* viewManager = aPresContext->GetPresShell()->GetViewManager();
NS_ASSERTION(nsnull != viewManager, "null view manager");
// Create a view

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

@ -567,7 +567,7 @@ nsListBoxBodyFrame::ScrollByLines(PRInt32 aNumLines)
// I'd use Composite here, but it doesn't always work.
// vm->Composite();
PresContext()->GetViewManager()->ForceUpdate();
PresContext()->GetPresShell()->GetViewManager()->ForceUpdate();
return NS_OK;
}

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

@ -1083,7 +1083,8 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, PRBool aIsMove)
// determine the x and y position of the view by subtracting the desired
// screen position from the screen position of the root frame.
nsPoint viewPoint = screenPoint - rootScreenRect.TopLeft();
presContext->GetViewManager()->MoveViewTo(GetView(), viewPoint.x, viewPoint.y);
presContext->GetPresShell()->GetViewManager()->
MoveViewTo(GetView(), viewPoint.x, viewPoint.y);
// Now that we've positioned the view, sync up the frame's origin.
nsBoxFrame::SetPosition(viewPoint - GetParent()->GetOffsetTo(rootFrame));

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

@ -2059,8 +2059,8 @@ nsXULMenuCommandEvent::Run()
}
nsPresContext* presContext = menuFrame->PresContext();
nsCOMPtr<nsIViewManager> kungFuDeathGrip = presContext->GetViewManager();
nsCOMPtr<nsIPresShell> shell = presContext->PresShell();
nsCOMPtr<nsIViewManager> kungFuDeathGrip = shell->GetViewManager();
// Deselect ourselves.
if (mCloseMenuMode != CloseMenuMode_None)

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

@ -1044,7 +1044,7 @@ nsTreeBodyFrame::AdjustClientCoordsToBoxCoordSpace(PRInt32 aX, PRInt32 aY,
point -= clientOffset;
nsIView* rootView;
presContext->GetViewManager()->GetRootView(rootView);
presContext->GetPresShell()->GetViewManager()->GetRootView(rootView);
NS_ASSERTION(closestView && rootView, "No view?");
point -= closestView->GetOffsetTo(rootView);