From e76b1a5a6c19582bef7dd04da9df4f48883d79ee Mon Sep 17 00:00:00 2001 From: "cbiesinger%web.de" Date: Sun, 3 Oct 2004 15:50:51 +0000 Subject: [PATCH] 235581 fix warnings in widget/src/mac patch by Ludovic Hirlimann r=pinkerton sr=sfraser --- widget/src/mac/nsClipboard.cpp | 6 ++-- widget/src/mac/nsDragService.cpp | 6 ++-- widget/src/mac/nsFilePicker.cpp | 2 +- widget/src/mac/nsMacEventHandler.cpp | 2 +- widget/src/mac/nsMacMessagePump.cpp | 48 +--------------------------- widget/src/mac/nsMenuBarX.cpp | 4 +-- widget/src/mac/nsMenuBarX.h | 4 +-- widget/src/mac/nsMenuX.cpp | 4 +-- widget/src/mac/nsNativeScrollbar.cpp | 3 +- widget/src/mac/nsTextWidget.cpp | 6 +++- 10 files changed, 20 insertions(+), 65 deletions(-) diff --git a/widget/src/mac/nsClipboard.cpp b/widget/src/mac/nsClipboard.cpp index 0f1c0d444277..27e85068ae84 100644 --- a/widget/src/mac/nsClipboard.cpp +++ b/widget/src/mac/nsClipboard.cpp @@ -363,7 +363,7 @@ nsClipboard :: GetNativeClipboardData ( nsITransferable * aTransferable, PRInt32 loadResult = GetDataOffClipboard ( 'styl', &clipboardData, &dataSize ); if (NS_SUCCEEDED(loadResult) && clipboardData && - (dataSize >= (sizeof(ScrpSTElement) + 2))) { + ((PRUint32)dataSize >= (sizeof(ScrpSTElement) + 2))) { StScrpRec *scrpRecP = (StScrpRec *) clipboardData; ScrpSTElement *styl = scrpRecP->scrpStyleTab; ScriptCode script = styl ? ::FontToScript(styl->scrpFont) : smCurrentScript; @@ -475,8 +475,6 @@ nsClipboard :: GetDataOffClipboard ( ResType inMacFlavor, void** outData, PRInt3 if ( outDataSize ) *outDataSize = 0; - // check if it is on the clipboard - long offsetUnused = 0; #if TARGET_CARBON ScrapRef scrap; @@ -630,7 +628,7 @@ nsClipboard :: CheckIfFlavorPresent ( ResType inMacFlavor ) if ( flavorList ) { err = ::GetScrapFlavorInfoList ( scrap, &flavorCount, flavorList ); if ( !err && flavorList ) { - for ( int i = 0; i < flavorCount; ++i ) { + for ( unsigned int i = 0; i < flavorCount; ++i ) { if ( flavorList[i].flavorType == inMacFlavor ) retval = PR_TRUE; } diff --git a/widget/src/mac/nsDragService.cpp b/widget/src/mac/nsDragService.cpp index 9d717cafaac3..505b20bf5af0 100644 --- a/widget/src/mac/nsDragService.cpp +++ b/widget/src/mac/nsDragService.cpp @@ -273,8 +273,8 @@ nsDragService::InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray * aTran // see it if you're paying attention, but who pays such close attention? Rect dragRect; ::GetRegionBounds(theDragRgn, &dragRect); - theEvent.where.v = rint(dragRect.top + (dragRect.bottom - dragRect.top) / 2); - theEvent.where.h = rint(dragRect.left + (dragRect.right - dragRect.left) / 2); + theEvent.where.v = dragRect.top + ((dragRect.bottom - dragRect.top) / 2); + theEvent.where.h = dragRect.left + ((dragRect.right - dragRect.left) / 2); // register drag send proc which will call us back when asked for the actual // flavor data (instead of placing it all into the drag manager) @@ -548,7 +548,7 @@ nsDragService::GetData ( nsITransferable * aTransferable, PRUint32 aItemIndex ) FlavorFlags unused; PRBool dataFound = PR_FALSE; void* dataBuff = nsnull; - PRInt32 dataSize = 0; + PRUint32 dataSize = 0; if ( macOSFlavor && ::GetFlavorFlags(mDragRef, itemRef, macOSFlavor, &unused) == noErr ) { nsresult loadResult = ExtractDataFromOS(mDragRef, itemRef, macOSFlavor, &dataBuff, &dataSize); if ( NS_SUCCEEDED(loadResult) && dataBuff ) diff --git a/widget/src/mac/nsFilePicker.cpp b/widget/src/mac/nsFilePicker.cpp index 6056f734d9ba..86c0666d9e26 100644 --- a/widget/src/mac/nsFilePicker.cpp +++ b/widget/src/mac/nsFilePicker.cpp @@ -203,7 +203,7 @@ void nsFilePicker::HandleShowPopupMenuSelect(NavCBRecPtr callBackParms) { // Special case Nav Services prior to 2.0 // Make sure the menu item selected was one of ours if ((menuItemSpec.menuType != menuItemSpec.menuCreator) || - (menuItemSpec.menuType < mTypeOffset) || + ((PRInt32)menuItemSpec.menuType < mTypeOffset) || (menuItemSpec.menuType > numMenuItems)) { // Doesn't appear to be one of our items selected so force it to be NavMenuItemSpec menuItem; diff --git a/widget/src/mac/nsMacEventHandler.cpp b/widget/src/mac/nsMacEventHandler.cpp index 84fab50e50c3..022118f4e9fa 100644 --- a/widget/src/mac/nsMacEventHandler.cpp +++ b/widget/src/mac/nsMacEventHandler.cpp @@ -2398,7 +2398,7 @@ nsresult nsMacEventHandler::UnicodeHandleUpdateInputArea(const PRUnichar* text, // so instead we iterate over the range list and map each range individually. it's probably faster than // trying to do collapse all the ranges into a single offset list // - PRUint32 i; + PRInt32 i; for(i = 0; i < rangeArray->fNumOfRanges; i++) { // 2.2.2.1 check each range item in NS_ASSERTION NS_ASSERTION( diff --git a/widget/src/mac/nsMacMessagePump.cpp b/widget/src/mac/nsMacMessagePump.cpp index 99f88eb7853f..ea30d04284aa 100644 --- a/widget/src/mac/nsMacMessagePump.cpp +++ b/widget/src/mac/nsMacMessagePump.cpp @@ -156,40 +156,6 @@ extern nsIWidget * gRollupWidget; #endif //DEBUG -//====================================================================================== - -static Boolean KeyDown(const UInt8 theKey) -{ - KeyMap map; - GetKeys(map); - return ((*((UInt8 *)map + (theKey >> 3)) >> (theKey & 7)) & 1) != 0; -} - -//================================================================= - -static long ConvertOSMenuResultToPPMenuResult(long menuResult) -{ - // Convert MacOS menu item to PowerPlant menu item because - // in our sample app, we use Constructor for resource editing - long menuID = HiWord(menuResult); - long menuItem = LoWord(menuResult); - SInt16** theMcmdH = (SInt16**) ::GetResource('Mcmd', menuID); - if (theMcmdH != nil) - { - if (::GetHandleSize((Handle)theMcmdH) > 0) - { - SInt16 numCommands = (*theMcmdH)[0]; - if (numCommands >= menuItem) - { - SInt32* theCommandNums = (SInt32*)(&(*theMcmdH)[1]); - menuItem = theCommandNums[menuItem-1]; - } - } - ::ReleaseResource((Handle) theMcmdH); - } - menuResult = (menuID << 16) + menuItem; - return (menuResult); -} #pragma mark - #if TARGET_CARBON && !XP_MACOSX @@ -858,20 +824,8 @@ void nsMacMessagePump::DoMouseMove(EventRecord &anEvent) //------------------------------------------------------------------------- void nsMacMessagePump::DoKey(EventRecord &anEvent) { - char theChar = (char)(anEvent.message & charCodeMask); - //if ((anEvent.what == keyDown) && ((anEvent.modifiers & cmdKey) != 0)) - //{ - // do a menu key command - // long menuResult = ::MenuKey(theChar); - // if (HiWord(menuResult) != 0) - // { - // menuResult = ConvertOSMenuResultToPPMenuResult(menuResult); - // DoMenu(anEvent, menuResult); - // } - //} - //else { - PRBool handled = DispatchOSEventToRaptor(anEvent, GetFrontApplicationWindow()); + DispatchOSEventToRaptor(anEvent, GetFrontApplicationWindow()); #if USE_MENUSELECT /* we want to call this if cmdKey is pressed and no other modifier keys are pressed */ if((!handled) && (anEvent.what == keyDown) && (anEvent.modifiers == cmdKey) ) diff --git a/widget/src/mac/nsMenuBarX.cpp b/widget/src/mac/nsMenuBarX.cpp index 77c77e401df0..8c7bd2b61fb9 100644 --- a/widget/src/mac/nsMenuBarX.cpp +++ b/widget/src/mac/nsMenuBarX.cpp @@ -62,7 +62,6 @@ #include #include #include -#include #include #include #include @@ -89,7 +88,7 @@ EventHandlerUPP nsMenuBarX::sCommandEventHandler = nsnull; // nsMenuBarX constructor // nsMenuBarX::nsMenuBarX() - : mNumMenus(0), mParent(nsnull), mIsMenuBarAdded(PR_FALSE), mDocument(nsnull), mCurrentCommandID(1) + : mNumMenus(0), mParent(nsnull), mIsMenuBarAdded(PR_FALSE), mCurrentCommandID(1), mDocument(nsnull) { OSStatus status = ::CreateNewMenu(0, 0, &mRootMenu); NS_ASSERTION(status == noErr, "nsMenuBarX::nsMenuBarX: creation of root menu failed."); @@ -575,6 +574,7 @@ NS_METHOD nsMenuBarX::AddMenu(nsIMenu * aMenu) mNumMenus = 1; ::InsertMenuItem(mRootMenu, "\pA", mNumMenus); OSStatus status = ::SetMenuItemHierarchicalMenu(mRootMenu, 1, sAppleMenu); + NS_ASSERTION(status == noErr, "OS problem with SetMenuItemHierarchicalMenu"); } } diff --git a/widget/src/mac/nsMenuBarX.h b/widget/src/mac/nsMenuBarX.h index d183daecbe18..8660f4cb1d1f 100644 --- a/widget/src/mac/nsMenuBarX.h +++ b/widget/src/mac/nsMenuBarX.h @@ -140,7 +140,6 @@ protected: nsHashtable mObserverTable; // stores observers for content change notification nsHashtable mCommandMapTable; // maps CommandIDs to content nodes for CarbonEvent item selection - PRUint32 mCurrentCommandID; // unique command id (per menu-bar) to give to next item that asks PRUint32 mNumMenus; nsSupportsArray mMenusArray; // holds refs @@ -149,8 +148,9 @@ protected: // been removed from the menubar nsCOMPtr mQuitItemContent; // as above, but for quit nsIWidget* mParent; // weak ref - PRBool mIsMenuBarAdded; + PRUint32 mCurrentCommandID; // unique command id (per menu-bar) to give to next item that asks + nsWeakPtr mWebShellWeakRef; // weak ref to webshell nsIDocument* mDocument; // pointer to document diff --git a/widget/src/mac/nsMenuX.cpp b/widget/src/mac/nsMenuX.cpp index d24df3473f72..123d800219c1 100644 --- a/widget/src/mac/nsMenuX.cpp +++ b/widget/src/mac/nsMenuX.cpp @@ -425,7 +425,7 @@ NS_METHOD nsMenuX::RemoveAll() // clear command id's nsCOMPtr dispatcher ( do_QueryInterface(mManager) ); if ( dispatcher ) { - for ( int i = 1; i <= mNumMenuItems; ++i ) { + for ( unsigned int i = 1; i <= mNumMenuItems; ++i ) { PRUint32 commandID = 0L; OSErr err = ::GetMenuItemCommandID(mMacMenuHandle, i, (unsigned long*)&commandID); if ( !err ) @@ -1180,7 +1180,7 @@ nsMenuX::GetMenuPopupContent(nsIContent** aResult) PRUint32 count = mMenuContent->GetChildCount(); - for (PRInt32 i = 0; i < count; i++) { + for (PRUint32 i = 0; i < count; i++) { PRInt32 dummy; nsIContent *child = mMenuContent->GetChildAt(i); nsCOMPtr tag; diff --git a/widget/src/mac/nsNativeScrollbar.cpp b/widget/src/mac/nsNativeScrollbar.cpp index da90b0fe8662..1a330f47bf4b 100644 --- a/widget/src/mac/nsNativeScrollbar.cpp +++ b/widget/src/mac/nsNativeScrollbar.cpp @@ -147,7 +147,6 @@ nsNativeScrollbar::DoScrollAction(ControlPartCode part) PRUint32 oldPos, newPos; PRUint32 incr; PRUint32 visibleImageSize; - PRInt32 scrollBarMessage = 0; GetPosition(&oldPos); GetLineIncrement(&incr); GetViewSize(&visibleImageSize); @@ -247,7 +246,7 @@ nsNativeScrollbar::DoScrollAction(ControlPartCode part) void nsNativeScrollbar::UpdateContentPosition(PRUint32 inNewPos) { - if ( inNewPos == mValue || !mContent ) // break any possible recursion + if ( (PRInt32)inNewPos == mValue || !mContent ) // break any possible recursion return; // guarantee |inNewPos| is in the range of [0, mMaxValue] so it's correctly unsigned diff --git a/widget/src/mac/nsTextWidget.cpp b/widget/src/mac/nsTextWidget.cpp index 6bf842df16fd..18029a743b96 100644 --- a/widget/src/mac/nsTextWidget.cpp +++ b/widget/src/mac/nsTextWidget.cpp @@ -398,12 +398,14 @@ PRBool nsTextWidget::DispatchWindowEvent(nsGUIEvent &aEvent) StartDraw(); ActivateControl(mControl); OSErr err = SetKeyboardFocus(mWindowPtr, mControl, kControlFocusNextPart); + if (err == noErr ) { nsRect rect = mBounds; rect.x = rect.y = 0; Rect macRect; nsRectToMacRect(rect, macRect); ::InsetRect(&macRect, 2, 2); ::DrawThemeFocusRect(&macRect, true); + } EndDraw(); StartIdling(); break; @@ -414,12 +416,14 @@ PRBool nsTextWidget::DispatchWindowEvent(nsGUIEvent &aEvent) StopIdling(); StartDraw(); OSErr err = SetKeyboardFocus(mWindowPtr, mControl, kControlFocusNoPart); + if ( err == noErr ) { nsRect rect = mBounds; rect.x = rect.y = 0; Rect macRect; nsRectToMacRect(rect, macRect); ::InsetRect(&macRect, 2, 2); ::DrawThemeFocusRect(&macRect, false); + } DeactivateControl(mControl); EndDraw(); break; @@ -606,7 +610,7 @@ NS_METHOD nsTextWidget::InsertText(const nsString &aText, PRUint32 aStartPos, P if (retVal != NS_OK) return retVal; - if ((aStartPos == -1L) && (aEndPos == -1L)) + if (((PRInt32)aStartPos == -1L) && ((PRInt32)aEndPos == -1L)) { textStr.Append(aText); }