From 3f096cd0c6bb5196c02ff984b5340b8598f85bda Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Tue, 28 Dec 1999 19:41:57 +0000 Subject: [PATCH] fix warnings git-svn-id: svn://10.0.0.236/trunk@56571 18797224-902f-48f8-a5cc-f745e15eee43 --- .../events/src/nsEventStateManager.cpp | 474 ++++++++++++++---- mozilla/docshell/base/nsDocShell.cpp | 6 +- .../layout/events/src/nsEventStateManager.cpp | 474 ++++++++++++++---- mozilla/layout/forms/nsListControlFrame.cpp | 4 +- .../html/forms/src/nsListControlFrame.cpp | 4 +- .../layout/html/table/src/nsTableFrame.cpp | 2 +- mozilla/layout/tables/nsTableFrame.cpp | 2 +- mozilla/modules/libjar/nsJAR.cpp | 2 + 8 files changed, 759 insertions(+), 209 deletions(-) diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index e53db860baa..c25a04bfbd2 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -51,6 +51,10 @@ #include "nsIGfxTextControlFrame.h" #include "nsPIDOMWindow.h" +#include "nsIServiceManager.h" +#include "nsIPref.h" +#include "prefapi.h" + #undef DEBUG_scroll // define to see ugly mousewheel messages static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -77,6 +81,226 @@ nsIPresContext* gLastFocusedPresContext = 0; // Weak reference PRUint32 nsEventStateManager::mInstanceCount = 0; +// For caching mousewheel prefs +struct IntPrefPair +{ + char* name; + PRInt32 value; +}; + +struct BoolPrefPair +{ + char* name; + PRBool value; +}; + +enum { + MOUSE_SCROLL_N_LINES, + MOUSE_SCROLL_PAGE, + MOUSE_SCROLL_HISTORY +}; + +static IntPrefPair mwIntPrefValues[] = +{ + { "mousewheel.withnokey.action", MOUSE_SCROLL_N_LINES }, + { "mousewheel.withnokey.numlines", 3 }, + { "mousewheel.withcontrolkey.action", MOUSE_SCROLL_N_LINES }, + { "mousewheel.withcontrolkey.numlines", 3 }, + { "mousewheel.withshiftkey.action", MOUSE_SCROLL_N_LINES }, + { "mousewheel.withshiftkey.numlines", 3 }, + { "mousewheel.withaltkey.action", MOUSE_SCROLL_N_LINES }, + { "mousewheel.withaltkey.numlines", 3 } +}; + +static BoolPrefPair mwBoolPrefValues[] = +{ + { "mousewheel.withnokey.sysnumlines", PR_FALSE }, + { "mousewheel.withcontrolkey.sysnumlines", PR_FALSE }, + { "mousewheel.withshiftkey.sysnumlines", PR_FALSE }, + { "mousewheel.withaltkey.sysnumlines", PR_FALSE } +}; + +static PRUint32 numIntPrefValues = + (sizeof(mwIntPrefValues) / sizeof(mwIntPrefValues[0])); + +static PRUint32 numBoolPrefValues = + (sizeof(mwBoolPrefValues) / sizeof(mwBoolPrefValues[0])); + +static PRInt32 getCachedIntPref (const char* aPrefName) +{ + NS_ASSERTION(nsnull != aPrefName, "aPrefName = null"); + + for (PRUint32 i = 0; i < numIntPrefValues; i++) + { + if (nsAutoString(mwIntPrefValues[i].name) == aPrefName) + { + return mwIntPrefValues[i].value; + } + } + + // Hopefully we never reach this code + NS_ASSERTION(PR_FALSE, + "Attempt to get a cached pref that is not in the cache."); + return 0; +} + +static PRBool getCachedBoolPref(const char* aPrefName) +{ + NS_ASSERTION(nsnull != aPrefName, "aPrefName = null"); + + for (PRUint32 i = 0; i < numBoolPrefValues; i++) + { + if (nsAutoString(mwBoolPrefValues[i].name) == aPrefName) + { + return mwBoolPrefValues[i].value; + } + } + + // Hopefully we never reach this code + NS_ASSERTION(PR_FALSE, + "Attempt to get a cached pref that is not in the cache."); + return 0; +} + +static void setCachedIntPref (const char* aPrefName, PRInt32 aValue) +{ + NS_ASSERTION(nsnull != aPrefName, "aPrefName = null"); + + for (PRUint32 i = 0; i < numIntPrefValues; i++) + { + if (nsAutoString(mwIntPrefValues[i].name) == aPrefName) + { + mwIntPrefValues[i].value = aValue; + return; + } + } + + NS_ASSERTION(PR_FALSE, + "Attempt to set a cached pref that is not in the cache."); +} + +static void setCachedBoolPref (const char* aPrefName, PRBool aValue) +{ + NS_ASSERTION(nsnull != aPrefName, "aPrefName = null"); + + for (PRUint32 i = 0; i < numBoolPrefValues; i++) + { + if (nsAutoString(mwBoolPrefValues[i].name) == aPrefName) + { + mwBoolPrefValues[i].value = aValue; + return; + } + } + + NS_ASSERTION(PR_FALSE, + "Attempt to set a cached pref that is not in the cache."); +} + +static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); + +int mwIntPrefChangedCallback(const char* name, void * closure) +{ + nsIPref* prefs = nsnull; + nsresult rv = nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref), + (nsISupports**) &prefs); + NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get prefs service."); + NS_ASSERTION(nsnull != prefs,"Prefs service is null."); + + if (NS_SUCCEEDED(rv)) + { + PRInt32 value; + prefs->GetIntPref(name, &value); + setCachedIntPref(name, value); + NS_RELEASE(prefs); + } + + return PREF_NOERROR; +} + +int mwBoolPrefChangedCallback(const char* name, void * closure) +{ + nsIPref* prefs = nsnull; + nsresult rv = nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref), + (nsISupports**) &prefs); + NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get prefs service."); + NS_ASSERTION(nsnull != prefs,"Prefs service is null."); + + if (NS_SUCCEEDED(rv)) + { + PRBool value; + prefs->GetBoolPref(name, &value); + setCachedBoolPref(name, value); + NS_RELEASE(prefs); + } + + return PREF_NOERROR; +} + +PRInt32 getIntPref(nsIPref* aPrefs, const char* aPrefName) +{ + NS_ASSERTION(nsnull != aPrefName,"aPrefName = null."); + NS_ASSERTION(nsnull != aPrefs,"aPrefs = null."); + + PRInt32 value = 0; + if (aPrefs) + { + aPrefs->GetIntPref(aPrefName, &value); + } + + return value; +} + +PRBool getBoolPref(nsIPref* aPrefs, const char* aPrefName) +{ + NS_ASSERTION(nsnull != aPrefName, "aPrefName = null."); + NS_ASSERTION(nsnull != aPrefs, "aPrefs = null."); + + PRBool value = PR_FALSE; + if (aPrefs) + { + aPrefs->GetBoolPref(aPrefName, &value); + } + + return value; +} + +void mwRegisterPrefCallbacks() +{ + static PRBool once = PR_TRUE; + + if (once) { + once = PR_FALSE; + nsIPref* prefs = nsnull; + nsresult rv = nsServiceManager::GetService(kPrefCID, + NS_GET_IID(nsIPref), (nsISupports**) &prefs); + NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get prefs service."); + NS_ASSERTION(nsnull != prefs,"Prefs services is null."); + + if (NS_SUCCEEDED(rv)) + { + PRUint32 i; + + for (i = 0; i < numIntPrefValues; i++) + { + mwIntPrefValues[i].value = getIntPref(prefs, mwIntPrefValues[i].name); + prefs->RegisterCallback(mwIntPrefValues[i].name, + mwIntPrefChangedCallback, NULL); + } + + for (i = 0; i < numBoolPrefValues; i++) + { + mwBoolPrefValues[i].value = getBoolPref(prefs, + mwBoolPrefValues[i].name); + prefs->RegisterCallback(mwBoolPrefValues[i].name, + mwBoolPrefChangedCallback, NULL); + } + + NS_RELEASE(prefs); + } + } +} + + nsEventStateManager::nsEventStateManager() : mGestureDownPoint(0,0) { @@ -109,6 +333,7 @@ nsEventStateManager::nsEventStateManager() NS_INIT_REFCNT(); ++mInstanceCount; + mwRegisterPrefCallbacks(); } nsEventStateManager::~nsEventStateManager() @@ -564,129 +789,178 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext, break; case NS_MOUSE_SCROLL: if (nsEventStatus_eConsumeNoDefault != *aStatus) { + nsMouseScrollEvent *msEvent = (nsMouseScrollEvent*) aEvent; + PRInt32 action = 0; + PRInt32 numLines = 0; - nsIFrame* focusFrame = nsnull; - nsISelfScrollingFrame* sf = nsnull; - nsIView* focusView = nsnull; - nsCOMPtr presShell; - - aPresContext->GetShell(getter_AddRefs(presShell)); - if(!presShell) // this is bad - break; - -#ifdef DEBUG_scroll - printf("PostHandleEvent: aTargetFrame = %p, aView = %p\n", - aTargetFrame, aView); -#endif - - if (mCurrentFocus) { - // Something is focused - -#ifdef DEBUG_scroll - printf("PostHandleEvent: mCurrentFocus = %p\n", mCurrentFocus); -#endif - - presShell->GetPrimaryFrameFor(mCurrentFocus, &focusFrame); - if (focusFrame) - focusFrame->GetView(aPresContext, &focusView); - + if (msEvent->isShift) { + action = getCachedIntPref("mousewheel.withshiftkey.action"); + if (getCachedBoolPref("mousewheel.withshiftkey.sysnumlines")) + numLines = msEvent->deltaLines; + else + numLines = getCachedIntPref("mousewheel.withshiftkey.numlines"); + } else if (msEvent->isControl) { + action = getCachedIntPref("mousewheel.withcontrolkey.action"); + if (getCachedBoolPref("mousewheel.withcontrolkey.sysnumlines")) + numLines = msEvent->deltaLines; + else + numLines = getCachedIntPref("mousewheel.withcontrolkey.numlines"); + } else if (msEvent->isAlt) { + action = getCachedIntPref("mousewheel.withaltkey.action"); + if (getCachedBoolPref("mousewheel.withaltkey.sysnumlines")) + numLines = msEvent->deltaLines; + else + numLines = getCachedIntPref("mousewheel.withaltkey.numlines"); + } else { + action = getCachedIntPref("mousewheel.withnokey.action"); + if (getCachedBoolPref("mousewheel.withnokey.sysnumlines")) + numLines = msEvent->deltaLines; + else + numLines = getCachedIntPref("mousewheel.withnokey.numlines"); } - if (focusFrame) { - if (!focusView) { - // The focused frame doesn't have a view - // Revert to the parameters passed in - // XXX this might not be right + if ((msEvent->deltaLines < 0) && (numLines > 0)) + numLines = -numLines; + switch (action) { + case MOUSE_SCROLL_N_LINES: + { + nsIFrame* focusFrame = nsnull; + nsISelfScrollingFrame* sf = nsnull; + nsIView* focusView = nsnull; + nsCOMPtr presShell; + + aPresContext->GetShell(getter_AddRefs(presShell)); + if(!presShell) // this is bad + break; + #ifdef DEBUG_scroll - printf("Could not get a view for the focused frame\n"); + printf("PostHandleEvent: aTargetFrame = %p, aView = %p\n", + aTargetFrame, aView); #endif - focusFrame = aTargetFrame; - focusView = aView; - } - } else { - // Focus is null. This means the main document has the focus, - // and we should scroll that. - + if (mCurrentFocus) { + #ifdef DEBUG_scroll - printf("PostHandleEvent: mCurrentFocus = NULL\n"); + printf("PostHandleEvent: mCurrentFocus = %p\n", mCurrentFocus); #endif - - // We need to make an exception here if we can get a SelfScrollingFrame - // This needs reviewed - - sf = GetNearestSelfScrollingFrame(aTargetFrame); - if (sf) { + + presShell->GetPrimaryFrameFor(mCurrentFocus, &focusFrame); + if (focusFrame) + focusFrame->GetView(aPresContext, &focusView); + + } + + if (focusFrame) { + if (!focusView) { + // The focused frame doesn't have a view + // Revert to the parameters passed in + // XXX this might not be right + #ifdef DEBUG_scroll - printf("Found a SelfScrollingFrame: sf = %p\n", sf); + printf("Could not get a view for the focused frame\n"); #endif - focusView = aView; - } else { - focusFrame = GetDocumentFrame(aPresContext); - focusFrame->GetView(aPresContext, &focusView); - + + focusFrame = aTargetFrame; + focusView = aView; + } + } else { + // Focus is null. This means the main document has the focus, + // and we should scroll that. + #ifdef DEBUG_scroll - if (focusView) - printf("Got view for document frame!\n"); - else // hopefully we won't be here - printf("Couldn't get view for document frame\n"); + printf("PostHandleEvent: mCurrentFocus = NULL\n"); #endif - - } - } - + + // We need to make an exception here if we can get a + // SelfScrollingFrame. This needs reviewed + + sf = GetNearestSelfScrollingFrame(aTargetFrame); + if (sf) { #ifdef DEBUG_scroll - printf("PostHandleEvent: focusFrame = %p, focusView = %p\n", focusFrame, - focusView); + printf("Found a SelfScrollingFrame: sf = %p\n", sf); #endif - - nsIScrollableView* sv = GetNearestScrollingView(focusView); - if (sv) { - + focusView = aView; + } else { + focusFrame = GetDocumentFrame(aPresContext); + focusFrame->GetView(aPresContext, &focusView); + #ifdef DEBUG_scroll - printf("Found a ScrollingView\n"); + if (focusView) + printf("Got view for document frame!\n"); + else // hopefully we won't be here + printf("Couldn't get view for document frame\n"); #endif - sv->ScrollByLines(((nsMouseScrollEvent*)aEvent)->deltaLines); - - // force the update to happen now, otherwise multiple scrolls can - // occur before the update is processed. (bug #7354) - nsIViewManager* vm = nsnull; - if (NS_OK == focusView->GetViewManager(vm) && nsnull != vm) { - // I'd use Composite here, but it doesn't always work. - // vm->Composite(); - nsIView* rootView = nsnull; - if (NS_OK == vm->GetRootView(rootView) && nsnull != rootView) { - nsIWidget* rootWidget = nsnull; - if (NS_OK == rootView->GetWidget(rootWidget) && nsnull != rootWidget) { - rootWidget->Update(); - NS_RELEASE(rootWidget); + } } - NS_RELEASE(vm); + +#ifdef DEBUG_scroll + printf("PostHandleEvent: focusFrame = %p, focusView = %p\n", + focusFrame, focusView); +#endif + + nsIScrollableView* sv = GetNearestScrollingView(focusView); + if (sv) { + +#ifdef DEBUG_scroll + printf("Found a ScrollingView\n"); +#endif + sv->ScrollByLines(numLines); + + // force the update to happen now, otherwise multiple scrolls can + // occur before the update is processed. (bug #7354) + nsIViewManager* vm = nsnull; + if (NS_OK == focusView->GetViewManager(vm) && nsnull != vm) { + // I'd use Composite here, but it doesn't always work. + // vm->Composite(); + nsIView* rootView = nsnull; + if (NS_OK == vm->GetRootView(rootView) && nsnull != rootView) { + nsIWidget* rootWidget = nsnull; + if (NS_OK == rootView->GetWidget(rootWidget) && + nsnull != rootWidget) { + rootWidget->Update(); + NS_RELEASE(rootWidget); + } + } + NS_RELEASE(vm); + } + } else { +#ifdef DEBUG_scroll + printf("No scrolling view, looking for a scrolling frame\n"); +#endif + if (!sf) + sf = GetNearestSelfScrollingFrame(focusFrame); + if (sf) { +#ifdef DEBUG_scroll + printf("Found a scrolling frame\n"); +#endif + sf->ScrollByLines(aPresContext, numLines); + // Do we need to do something here like above? + } +#ifdef DEBUG_scroll + else + printf("Could not find a scrolling frame\n"); +#endif + } } - } else { -#ifdef DEBUG_scroll - printf("No scrolling view, looking for a scrolling frame\n"); -#endif - if (!sf) - sf = GetNearestSelfScrollingFrame(focusFrame); - if (sf) { -#ifdef DEBUG_scroll - printf("Found a scrolling frame\n"); -#endif - sf->ScrollByLines(aPresContext, - ((nsMouseScrollEvent*)aEvent)->deltaLines); - // Do we need to do something here like above? + break; + case MOUSE_SCROLL_PAGE: + if (!mCurrentFocus) { + nsIScrollableView* sv = GetNearestScrollingView(aView); + if (sv) { + sv->ScrollByPages((numLines > 0) ? 1 : -1); + } } -#ifdef DEBUG_scroll - else - printf("Could not find a scrolling frame\n"); -#endif + break; + case MOUSE_SCROLL_HISTORY: + break; + } } - break; + break; + case NS_DRAGDROP_DROP: case NS_DRAGDROP_EXIT: // clean up after ourselves. make sure we do this _after_ the event, else we'll @@ -1917,7 +2191,7 @@ nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState) NS_IMETHODIMP nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aContent) { - PRBool suppressBlurAndFocus = PR_FALSE; + // PRBool suppressBlurAndFocus = PR_FALSE; if(mCurrentTarget) { nsCOMPtr context; diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 668c04584e9..ce0753176cf 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -58,11 +58,11 @@ nsDocShell::nsDocShell() : mCreated(PR_FALSE), - mInitInfo(nsnull), mContentListener(nsnull), - mItemType(typeContent), + mInitInfo(nsnull), mMarginWidth(0), mMarginHeight(0), + mItemType(typeContent), mParent(nsnull), mTreeOwner(nsnull), mChromeEventHandler(nsnull) @@ -1517,7 +1517,6 @@ NS_IMETHODIMP nsDocShell::Embed(nsIContentViewer* aContentViewer, ("nsWebShell::Embed: this=%p aDocViewer=%p aCommand=%s aExtraInfo=%p", this, aContentViewer, aCommand ? aCommand : "", aExtraInfo)); - nsRect bounds; // (1) reset state, clean up any left-over data from previous embedding mContentViewer = nsnull; if (nsnull != mScriptContext) { @@ -1537,6 +1536,7 @@ NS_IMETHODIMP nsDocShell::Embed(nsIContentViewer* aContentViewer, by the OS. It's handy, then, that GetNativeData on Windows returns null in this case. */ /* XXX native window + nsRect bounds; if(mWindow && mWindow->GetNativeData(NS_NATIVE_WIDGET)) { mWindow->GetClientBounds(bounds); diff --git a/mozilla/layout/events/src/nsEventStateManager.cpp b/mozilla/layout/events/src/nsEventStateManager.cpp index e53db860baa..c25a04bfbd2 100644 --- a/mozilla/layout/events/src/nsEventStateManager.cpp +++ b/mozilla/layout/events/src/nsEventStateManager.cpp @@ -51,6 +51,10 @@ #include "nsIGfxTextControlFrame.h" #include "nsPIDOMWindow.h" +#include "nsIServiceManager.h" +#include "nsIPref.h" +#include "prefapi.h" + #undef DEBUG_scroll // define to see ugly mousewheel messages static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -77,6 +81,226 @@ nsIPresContext* gLastFocusedPresContext = 0; // Weak reference PRUint32 nsEventStateManager::mInstanceCount = 0; +// For caching mousewheel prefs +struct IntPrefPair +{ + char* name; + PRInt32 value; +}; + +struct BoolPrefPair +{ + char* name; + PRBool value; +}; + +enum { + MOUSE_SCROLL_N_LINES, + MOUSE_SCROLL_PAGE, + MOUSE_SCROLL_HISTORY +}; + +static IntPrefPair mwIntPrefValues[] = +{ + { "mousewheel.withnokey.action", MOUSE_SCROLL_N_LINES }, + { "mousewheel.withnokey.numlines", 3 }, + { "mousewheel.withcontrolkey.action", MOUSE_SCROLL_N_LINES }, + { "mousewheel.withcontrolkey.numlines", 3 }, + { "mousewheel.withshiftkey.action", MOUSE_SCROLL_N_LINES }, + { "mousewheel.withshiftkey.numlines", 3 }, + { "mousewheel.withaltkey.action", MOUSE_SCROLL_N_LINES }, + { "mousewheel.withaltkey.numlines", 3 } +}; + +static BoolPrefPair mwBoolPrefValues[] = +{ + { "mousewheel.withnokey.sysnumlines", PR_FALSE }, + { "mousewheel.withcontrolkey.sysnumlines", PR_FALSE }, + { "mousewheel.withshiftkey.sysnumlines", PR_FALSE }, + { "mousewheel.withaltkey.sysnumlines", PR_FALSE } +}; + +static PRUint32 numIntPrefValues = + (sizeof(mwIntPrefValues) / sizeof(mwIntPrefValues[0])); + +static PRUint32 numBoolPrefValues = + (sizeof(mwBoolPrefValues) / sizeof(mwBoolPrefValues[0])); + +static PRInt32 getCachedIntPref (const char* aPrefName) +{ + NS_ASSERTION(nsnull != aPrefName, "aPrefName = null"); + + for (PRUint32 i = 0; i < numIntPrefValues; i++) + { + if (nsAutoString(mwIntPrefValues[i].name) == aPrefName) + { + return mwIntPrefValues[i].value; + } + } + + // Hopefully we never reach this code + NS_ASSERTION(PR_FALSE, + "Attempt to get a cached pref that is not in the cache."); + return 0; +} + +static PRBool getCachedBoolPref(const char* aPrefName) +{ + NS_ASSERTION(nsnull != aPrefName, "aPrefName = null"); + + for (PRUint32 i = 0; i < numBoolPrefValues; i++) + { + if (nsAutoString(mwBoolPrefValues[i].name) == aPrefName) + { + return mwBoolPrefValues[i].value; + } + } + + // Hopefully we never reach this code + NS_ASSERTION(PR_FALSE, + "Attempt to get a cached pref that is not in the cache."); + return 0; +} + +static void setCachedIntPref (const char* aPrefName, PRInt32 aValue) +{ + NS_ASSERTION(nsnull != aPrefName, "aPrefName = null"); + + for (PRUint32 i = 0; i < numIntPrefValues; i++) + { + if (nsAutoString(mwIntPrefValues[i].name) == aPrefName) + { + mwIntPrefValues[i].value = aValue; + return; + } + } + + NS_ASSERTION(PR_FALSE, + "Attempt to set a cached pref that is not in the cache."); +} + +static void setCachedBoolPref (const char* aPrefName, PRBool aValue) +{ + NS_ASSERTION(nsnull != aPrefName, "aPrefName = null"); + + for (PRUint32 i = 0; i < numBoolPrefValues; i++) + { + if (nsAutoString(mwBoolPrefValues[i].name) == aPrefName) + { + mwBoolPrefValues[i].value = aValue; + return; + } + } + + NS_ASSERTION(PR_FALSE, + "Attempt to set a cached pref that is not in the cache."); +} + +static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); + +int mwIntPrefChangedCallback(const char* name, void * closure) +{ + nsIPref* prefs = nsnull; + nsresult rv = nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref), + (nsISupports**) &prefs); + NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get prefs service."); + NS_ASSERTION(nsnull != prefs,"Prefs service is null."); + + if (NS_SUCCEEDED(rv)) + { + PRInt32 value; + prefs->GetIntPref(name, &value); + setCachedIntPref(name, value); + NS_RELEASE(prefs); + } + + return PREF_NOERROR; +} + +int mwBoolPrefChangedCallback(const char* name, void * closure) +{ + nsIPref* prefs = nsnull; + nsresult rv = nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref), + (nsISupports**) &prefs); + NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get prefs service."); + NS_ASSERTION(nsnull != prefs,"Prefs service is null."); + + if (NS_SUCCEEDED(rv)) + { + PRBool value; + prefs->GetBoolPref(name, &value); + setCachedBoolPref(name, value); + NS_RELEASE(prefs); + } + + return PREF_NOERROR; +} + +PRInt32 getIntPref(nsIPref* aPrefs, const char* aPrefName) +{ + NS_ASSERTION(nsnull != aPrefName,"aPrefName = null."); + NS_ASSERTION(nsnull != aPrefs,"aPrefs = null."); + + PRInt32 value = 0; + if (aPrefs) + { + aPrefs->GetIntPref(aPrefName, &value); + } + + return value; +} + +PRBool getBoolPref(nsIPref* aPrefs, const char* aPrefName) +{ + NS_ASSERTION(nsnull != aPrefName, "aPrefName = null."); + NS_ASSERTION(nsnull != aPrefs, "aPrefs = null."); + + PRBool value = PR_FALSE; + if (aPrefs) + { + aPrefs->GetBoolPref(aPrefName, &value); + } + + return value; +} + +void mwRegisterPrefCallbacks() +{ + static PRBool once = PR_TRUE; + + if (once) { + once = PR_FALSE; + nsIPref* prefs = nsnull; + nsresult rv = nsServiceManager::GetService(kPrefCID, + NS_GET_IID(nsIPref), (nsISupports**) &prefs); + NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get prefs service."); + NS_ASSERTION(nsnull != prefs,"Prefs services is null."); + + if (NS_SUCCEEDED(rv)) + { + PRUint32 i; + + for (i = 0; i < numIntPrefValues; i++) + { + mwIntPrefValues[i].value = getIntPref(prefs, mwIntPrefValues[i].name); + prefs->RegisterCallback(mwIntPrefValues[i].name, + mwIntPrefChangedCallback, NULL); + } + + for (i = 0; i < numBoolPrefValues; i++) + { + mwBoolPrefValues[i].value = getBoolPref(prefs, + mwBoolPrefValues[i].name); + prefs->RegisterCallback(mwBoolPrefValues[i].name, + mwBoolPrefChangedCallback, NULL); + } + + NS_RELEASE(prefs); + } + } +} + + nsEventStateManager::nsEventStateManager() : mGestureDownPoint(0,0) { @@ -109,6 +333,7 @@ nsEventStateManager::nsEventStateManager() NS_INIT_REFCNT(); ++mInstanceCount; + mwRegisterPrefCallbacks(); } nsEventStateManager::~nsEventStateManager() @@ -564,129 +789,178 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext, break; case NS_MOUSE_SCROLL: if (nsEventStatus_eConsumeNoDefault != *aStatus) { + nsMouseScrollEvent *msEvent = (nsMouseScrollEvent*) aEvent; + PRInt32 action = 0; + PRInt32 numLines = 0; - nsIFrame* focusFrame = nsnull; - nsISelfScrollingFrame* sf = nsnull; - nsIView* focusView = nsnull; - nsCOMPtr presShell; - - aPresContext->GetShell(getter_AddRefs(presShell)); - if(!presShell) // this is bad - break; - -#ifdef DEBUG_scroll - printf("PostHandleEvent: aTargetFrame = %p, aView = %p\n", - aTargetFrame, aView); -#endif - - if (mCurrentFocus) { - // Something is focused - -#ifdef DEBUG_scroll - printf("PostHandleEvent: mCurrentFocus = %p\n", mCurrentFocus); -#endif - - presShell->GetPrimaryFrameFor(mCurrentFocus, &focusFrame); - if (focusFrame) - focusFrame->GetView(aPresContext, &focusView); - + if (msEvent->isShift) { + action = getCachedIntPref("mousewheel.withshiftkey.action"); + if (getCachedBoolPref("mousewheel.withshiftkey.sysnumlines")) + numLines = msEvent->deltaLines; + else + numLines = getCachedIntPref("mousewheel.withshiftkey.numlines"); + } else if (msEvent->isControl) { + action = getCachedIntPref("mousewheel.withcontrolkey.action"); + if (getCachedBoolPref("mousewheel.withcontrolkey.sysnumlines")) + numLines = msEvent->deltaLines; + else + numLines = getCachedIntPref("mousewheel.withcontrolkey.numlines"); + } else if (msEvent->isAlt) { + action = getCachedIntPref("mousewheel.withaltkey.action"); + if (getCachedBoolPref("mousewheel.withaltkey.sysnumlines")) + numLines = msEvent->deltaLines; + else + numLines = getCachedIntPref("mousewheel.withaltkey.numlines"); + } else { + action = getCachedIntPref("mousewheel.withnokey.action"); + if (getCachedBoolPref("mousewheel.withnokey.sysnumlines")) + numLines = msEvent->deltaLines; + else + numLines = getCachedIntPref("mousewheel.withnokey.numlines"); } - if (focusFrame) { - if (!focusView) { - // The focused frame doesn't have a view - // Revert to the parameters passed in - // XXX this might not be right + if ((msEvent->deltaLines < 0) && (numLines > 0)) + numLines = -numLines; + switch (action) { + case MOUSE_SCROLL_N_LINES: + { + nsIFrame* focusFrame = nsnull; + nsISelfScrollingFrame* sf = nsnull; + nsIView* focusView = nsnull; + nsCOMPtr presShell; + + aPresContext->GetShell(getter_AddRefs(presShell)); + if(!presShell) // this is bad + break; + #ifdef DEBUG_scroll - printf("Could not get a view for the focused frame\n"); + printf("PostHandleEvent: aTargetFrame = %p, aView = %p\n", + aTargetFrame, aView); #endif - focusFrame = aTargetFrame; - focusView = aView; - } - } else { - // Focus is null. This means the main document has the focus, - // and we should scroll that. - + if (mCurrentFocus) { + #ifdef DEBUG_scroll - printf("PostHandleEvent: mCurrentFocus = NULL\n"); + printf("PostHandleEvent: mCurrentFocus = %p\n", mCurrentFocus); #endif - - // We need to make an exception here if we can get a SelfScrollingFrame - // This needs reviewed - - sf = GetNearestSelfScrollingFrame(aTargetFrame); - if (sf) { + + presShell->GetPrimaryFrameFor(mCurrentFocus, &focusFrame); + if (focusFrame) + focusFrame->GetView(aPresContext, &focusView); + + } + + if (focusFrame) { + if (!focusView) { + // The focused frame doesn't have a view + // Revert to the parameters passed in + // XXX this might not be right + #ifdef DEBUG_scroll - printf("Found a SelfScrollingFrame: sf = %p\n", sf); + printf("Could not get a view for the focused frame\n"); #endif - focusView = aView; - } else { - focusFrame = GetDocumentFrame(aPresContext); - focusFrame->GetView(aPresContext, &focusView); - + + focusFrame = aTargetFrame; + focusView = aView; + } + } else { + // Focus is null. This means the main document has the focus, + // and we should scroll that. + #ifdef DEBUG_scroll - if (focusView) - printf("Got view for document frame!\n"); - else // hopefully we won't be here - printf("Couldn't get view for document frame\n"); + printf("PostHandleEvent: mCurrentFocus = NULL\n"); #endif - - } - } - + + // We need to make an exception here if we can get a + // SelfScrollingFrame. This needs reviewed + + sf = GetNearestSelfScrollingFrame(aTargetFrame); + if (sf) { #ifdef DEBUG_scroll - printf("PostHandleEvent: focusFrame = %p, focusView = %p\n", focusFrame, - focusView); + printf("Found a SelfScrollingFrame: sf = %p\n", sf); #endif - - nsIScrollableView* sv = GetNearestScrollingView(focusView); - if (sv) { - + focusView = aView; + } else { + focusFrame = GetDocumentFrame(aPresContext); + focusFrame->GetView(aPresContext, &focusView); + #ifdef DEBUG_scroll - printf("Found a ScrollingView\n"); + if (focusView) + printf("Got view for document frame!\n"); + else // hopefully we won't be here + printf("Couldn't get view for document frame\n"); #endif - sv->ScrollByLines(((nsMouseScrollEvent*)aEvent)->deltaLines); - - // force the update to happen now, otherwise multiple scrolls can - // occur before the update is processed. (bug #7354) - nsIViewManager* vm = nsnull; - if (NS_OK == focusView->GetViewManager(vm) && nsnull != vm) { - // I'd use Composite here, but it doesn't always work. - // vm->Composite(); - nsIView* rootView = nsnull; - if (NS_OK == vm->GetRootView(rootView) && nsnull != rootView) { - nsIWidget* rootWidget = nsnull; - if (NS_OK == rootView->GetWidget(rootWidget) && nsnull != rootWidget) { - rootWidget->Update(); - NS_RELEASE(rootWidget); + } } - NS_RELEASE(vm); + +#ifdef DEBUG_scroll + printf("PostHandleEvent: focusFrame = %p, focusView = %p\n", + focusFrame, focusView); +#endif + + nsIScrollableView* sv = GetNearestScrollingView(focusView); + if (sv) { + +#ifdef DEBUG_scroll + printf("Found a ScrollingView\n"); +#endif + sv->ScrollByLines(numLines); + + // force the update to happen now, otherwise multiple scrolls can + // occur before the update is processed. (bug #7354) + nsIViewManager* vm = nsnull; + if (NS_OK == focusView->GetViewManager(vm) && nsnull != vm) { + // I'd use Composite here, but it doesn't always work. + // vm->Composite(); + nsIView* rootView = nsnull; + if (NS_OK == vm->GetRootView(rootView) && nsnull != rootView) { + nsIWidget* rootWidget = nsnull; + if (NS_OK == rootView->GetWidget(rootWidget) && + nsnull != rootWidget) { + rootWidget->Update(); + NS_RELEASE(rootWidget); + } + } + NS_RELEASE(vm); + } + } else { +#ifdef DEBUG_scroll + printf("No scrolling view, looking for a scrolling frame\n"); +#endif + if (!sf) + sf = GetNearestSelfScrollingFrame(focusFrame); + if (sf) { +#ifdef DEBUG_scroll + printf("Found a scrolling frame\n"); +#endif + sf->ScrollByLines(aPresContext, numLines); + // Do we need to do something here like above? + } +#ifdef DEBUG_scroll + else + printf("Could not find a scrolling frame\n"); +#endif + } } - } else { -#ifdef DEBUG_scroll - printf("No scrolling view, looking for a scrolling frame\n"); -#endif - if (!sf) - sf = GetNearestSelfScrollingFrame(focusFrame); - if (sf) { -#ifdef DEBUG_scroll - printf("Found a scrolling frame\n"); -#endif - sf->ScrollByLines(aPresContext, - ((nsMouseScrollEvent*)aEvent)->deltaLines); - // Do we need to do something here like above? + break; + case MOUSE_SCROLL_PAGE: + if (!mCurrentFocus) { + nsIScrollableView* sv = GetNearestScrollingView(aView); + if (sv) { + sv->ScrollByPages((numLines > 0) ? 1 : -1); + } } -#ifdef DEBUG_scroll - else - printf("Could not find a scrolling frame\n"); -#endif + break; + case MOUSE_SCROLL_HISTORY: + break; + } } - break; + break; + case NS_DRAGDROP_DROP: case NS_DRAGDROP_EXIT: // clean up after ourselves. make sure we do this _after_ the event, else we'll @@ -1917,7 +2191,7 @@ nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState) NS_IMETHODIMP nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aContent) { - PRBool suppressBlurAndFocus = PR_FALSE; + // PRBool suppressBlurAndFocus = PR_FALSE; if(mCurrentTarget) { nsCOMPtr context; diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index 19bcdd30b0f..b014a02e822 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -411,7 +411,7 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, dc->GetScrollBarDimensions(sbWidth, sbHeight); // Convert to nscoord's by rounding nscoord scrollbarWidth = NSToCoordRound(sbWidth); - nscoord scrollbarHeight = NSToCoordRound(sbHeight); + //nscoord scrollbarHeight = NSToCoordRound(sbHeight); // Subtract out the scrollbar width scrolledAreaWidth -= scrollbarWidth; @@ -1797,7 +1797,7 @@ nsListControlFrame::ToggleSelected(PRInt32 aIndex) PRBool nsListControlFrame::CheckIfAllFramesHere() { // Get the number of optgroups and options - PRInt32 numContentItems = 0; + //PRInt32 numContentItems = 0; nsCOMPtr node(do_QueryInterface(mContent)); if (node) { // XXX Need to find a fail proff way to determine that diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index 19bcdd30b0f..b014a02e822 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -411,7 +411,7 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, dc->GetScrollBarDimensions(sbWidth, sbHeight); // Convert to nscoord's by rounding nscoord scrollbarWidth = NSToCoordRound(sbWidth); - nscoord scrollbarHeight = NSToCoordRound(sbHeight); + //nscoord scrollbarHeight = NSToCoordRound(sbHeight); // Subtract out the scrollbar width scrolledAreaWidth -= scrollbarWidth; @@ -1797,7 +1797,7 @@ nsListControlFrame::ToggleSelected(PRInt32 aIndex) PRBool nsListControlFrame::CheckIfAllFramesHere() { // Get the number of optgroups and options - PRInt32 numContentItems = 0; + //PRInt32 numContentItems = 0; nsCOMPtr node(do_QueryInterface(mContent)); if (node) { // XXX Need to find a fail proff way to determine that diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index 60dade5b320..6c137a5dcb2 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -3803,7 +3803,7 @@ void nsTableFrame::GetTableBorderForRowGroup(nsTableRowGroupFrame* aRowGroupFram PRInt32 rowCount; aRowGroupFrame->GetRowCount(rowCount); nsCellMap* cellMap = GetCellMap(); - PRInt32 colCount = cellMap->GetColCount(); + //PRInt32 colCount = cellMap->GetColCount(); mBorderCollapser->GetMaxBorder(aRowGroupFrame->GetStartRowIndex(), rowCount - 1, 0, cellMap->GetColCount() - 1, aBorder); } diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index 60dade5b320..6c137a5dcb2 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -3803,7 +3803,7 @@ void nsTableFrame::GetTableBorderForRowGroup(nsTableRowGroupFrame* aRowGroupFram PRInt32 rowCount; aRowGroupFrame->GetRowCount(rowCount); nsCellMap* cellMap = GetCellMap(); - PRInt32 colCount = cellMap->GetColCount(); + //PRInt32 colCount = cellMap->GetColCount(); mBorderCollapser->GetMaxBorder(aRowGroupFrame->GetStartRowIndex(), rowCount - 1, 0, cellMap->GetColCount() - 1, aBorder); } diff --git a/mozilla/modules/libjar/nsJAR.cpp b/mozilla/modules/libjar/nsJAR.cpp index 0bcaf421f38..2716c288f88 100644 --- a/mozilla/modules/libjar/nsJAR.cpp +++ b/mozilla/modules/libjar/nsJAR.cpp @@ -69,6 +69,7 @@ ziperr2nsresult(PRInt32 ziperr) } } +#if 0 static PRInt32 nsresult2ziperr(nsresult rv) { @@ -83,6 +84,7 @@ nsresult2ziperr(nsresult rv) default: return ZIP_ERR_GENERAL; } } +#endif /* 0 */ nsJAR::nsJAR() {