From 42df5a5b2210140e8441145ede608f0d3cdf74ea Mon Sep 17 00:00:00 2001 From: "bryner%uiuc.edu" Date: Sun, 10 Sep 2000 05:35:36 +0000 Subject: [PATCH] Fixing bug 51096 - crash after changing mousewheel prefs twice. Also remove some assertions and fix a longstanding inconsistency/bug with mousewheel text zoom and history navigation. r=ben. git-svn-id: svn://10.0.0.236/trunk@78653 18797224-902f-48f8-a5cc-f745e15eee43 --- .../events/src/nsEventStateManager.cpp | 32 +++++++++++-------- .../layout/events/src/nsEventStateManager.cpp | 32 +++++++++++-------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 318d880b1fa..dcdbe9e2649 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -773,45 +773,49 @@ nsEventStateManager :: GenerateDragGesture ( nsIPresContext* aPresContext, nsGUI nsresult nsEventStateManager::ChangeTextSize(PRInt32 change) { + if(!gLastFocusedDocument) return NS_ERROR_FAILURE; + nsCOMPtr ourGlobal; gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); - nsCOMPtr rootWindow; + if(!ourGlobal) return NS_ERROR_FAILURE; + nsCOMPtr ourWindow = do_QueryInterface(ourGlobal); - NS_ENSURE_TRUE(ourWindow, NS_ERROR_FAILURE); + if(!ourWindow) return NS_ERROR_FAILURE; + nsCOMPtr rootWindow; ourWindow->GetPrivateRoot(getter_AddRefs(rootWindow)); - NS_ENSURE_TRUE(rootWindow, NS_ERROR_FAILURE); + if(!rootWindow) return NS_ERROR_FAILURE; nsCOMPtr windowContent; rootWindow->Get_content(getter_AddRefs(windowContent)); - NS_ENSURE_TRUE(windowContent, NS_ERROR_FAILURE); + if(!windowContent) return NS_ERROR_FAILURE; nsCOMPtr domDoc; windowContent->GetDocument(getter_AddRefs(domDoc)); - NS_ENSURE_TRUE(domDoc, NS_ERROR_FAILURE); + if(!domDoc) return NS_ERROR_FAILURE; nsCOMPtr doc = do_QueryInterface(domDoc); - NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE); + if(!doc) return NS_ERROR_FAILURE; nsCOMPtr presShell = getter_AddRefs(doc->GetShellAt(0)); - NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); + if(!presShell) return NS_ERROR_FAILURE; nsCOMPtr presContext; presShell->GetPresContext(getter_AddRefs(presContext)); - NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); + if(!presContext) return NS_ERROR_FAILURE; nsCOMPtr pcContainer; presContext->GetContainer(getter_AddRefs(pcContainer)); - NS_ENSURE_TRUE(pcContainer, NS_ERROR_FAILURE); + if(!pcContainer) return NS_ERROR_FAILURE; nsCOMPtr docshell(do_QueryInterface(pcContainer)); - NS_ENSURE_TRUE(docshell, NS_ERROR_FAILURE); + if(!docshell) return NS_ERROR_FAILURE; nsCOMPtr cv; docshell->GetContentViewer(getter_AddRefs(cv)); - NS_ENSURE_TRUE(cv, NS_ERROR_FAILURE); + if(!cv) return NS_ERROR_FAILURE; nsCOMPtr mv(do_QueryInterface(cv)); - NS_ENSURE_TRUE(mv, NS_ERROR_FAILURE); + if(!mv) return NS_ERROR_FAILURE; float textzoom; mv->GetTextZoom(&textzoom); @@ -1040,7 +1044,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext, if (pcContainer) { nsCOMPtr webNav(do_QueryInterface(pcContainer)); if (webNav) { - if (numLines > 0) + if (msEvent->deltaLines > 0) webNav->GoBack(); else webNav->GoForward(); @@ -1050,7 +1054,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext, break; case MOUSE_SCROLL_TEXTSIZE: - ChangeTextSize((numLines > 0) ? 1 : -1); + ChangeTextSize((msEvent->deltaLines > 0) ? 1 : -1); break; } *aStatus = nsEventStatus_eConsumeNoDefault; diff --git a/mozilla/layout/events/src/nsEventStateManager.cpp b/mozilla/layout/events/src/nsEventStateManager.cpp index 318d880b1fa..dcdbe9e2649 100644 --- a/mozilla/layout/events/src/nsEventStateManager.cpp +++ b/mozilla/layout/events/src/nsEventStateManager.cpp @@ -773,45 +773,49 @@ nsEventStateManager :: GenerateDragGesture ( nsIPresContext* aPresContext, nsGUI nsresult nsEventStateManager::ChangeTextSize(PRInt32 change) { + if(!gLastFocusedDocument) return NS_ERROR_FAILURE; + nsCOMPtr ourGlobal; gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); - nsCOMPtr rootWindow; + if(!ourGlobal) return NS_ERROR_FAILURE; + nsCOMPtr ourWindow = do_QueryInterface(ourGlobal); - NS_ENSURE_TRUE(ourWindow, NS_ERROR_FAILURE); + if(!ourWindow) return NS_ERROR_FAILURE; + nsCOMPtr rootWindow; ourWindow->GetPrivateRoot(getter_AddRefs(rootWindow)); - NS_ENSURE_TRUE(rootWindow, NS_ERROR_FAILURE); + if(!rootWindow) return NS_ERROR_FAILURE; nsCOMPtr windowContent; rootWindow->Get_content(getter_AddRefs(windowContent)); - NS_ENSURE_TRUE(windowContent, NS_ERROR_FAILURE); + if(!windowContent) return NS_ERROR_FAILURE; nsCOMPtr domDoc; windowContent->GetDocument(getter_AddRefs(domDoc)); - NS_ENSURE_TRUE(domDoc, NS_ERROR_FAILURE); + if(!domDoc) return NS_ERROR_FAILURE; nsCOMPtr doc = do_QueryInterface(domDoc); - NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE); + if(!doc) return NS_ERROR_FAILURE; nsCOMPtr presShell = getter_AddRefs(doc->GetShellAt(0)); - NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); + if(!presShell) return NS_ERROR_FAILURE; nsCOMPtr presContext; presShell->GetPresContext(getter_AddRefs(presContext)); - NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); + if(!presContext) return NS_ERROR_FAILURE; nsCOMPtr pcContainer; presContext->GetContainer(getter_AddRefs(pcContainer)); - NS_ENSURE_TRUE(pcContainer, NS_ERROR_FAILURE); + if(!pcContainer) return NS_ERROR_FAILURE; nsCOMPtr docshell(do_QueryInterface(pcContainer)); - NS_ENSURE_TRUE(docshell, NS_ERROR_FAILURE); + if(!docshell) return NS_ERROR_FAILURE; nsCOMPtr cv; docshell->GetContentViewer(getter_AddRefs(cv)); - NS_ENSURE_TRUE(cv, NS_ERROR_FAILURE); + if(!cv) return NS_ERROR_FAILURE; nsCOMPtr mv(do_QueryInterface(cv)); - NS_ENSURE_TRUE(mv, NS_ERROR_FAILURE); + if(!mv) return NS_ERROR_FAILURE; float textzoom; mv->GetTextZoom(&textzoom); @@ -1040,7 +1044,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext, if (pcContainer) { nsCOMPtr webNav(do_QueryInterface(pcContainer)); if (webNav) { - if (numLines > 0) + if (msEvent->deltaLines > 0) webNav->GoBack(); else webNav->GoForward(); @@ -1050,7 +1054,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext, break; case MOUSE_SCROLL_TEXTSIZE: - ChangeTextSize((numLines > 0) ? 1 : -1); + ChangeTextSize((msEvent->deltaLines > 0) ? 1 : -1); break; } *aStatus = nsEventStatus_eConsumeNoDefault;