Landing changes from CHIMERA_M1_0_1_BRANCH. Code that depends on other mozilla changes is #ifdef'd BRANCH_CHANGES_NEED_MERGED.

This commit is contained in:
bryner%netscape.com 2003-02-13 10:29:21 +00:00
parent 513721f882
commit c2ebb735d9
6 changed files with 128 additions and 38 deletions

View File

@ -1627,19 +1627,76 @@ NS_IMETHODIMP nsChildView::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
NSRect horizInvalid = frame;
NSRect vertInvalid = frame;
horizInvalid.size.width = abs(aDx);
vertInvalid.size.height = abs(aDy);
if (aDy < 0)
vertInvalid.origin.y = frame.origin.y + frame.size.height + aDy;
if (aDx < 0)
horizInvalid.origin.x = frame.origin.x + frame.size.width + aDx;
if (aDx != 0)
if (aDx != 0) {
horizInvalid.size.width = abs(aDx);
if (aDx < 0)
horizInvalid.origin.x = frame.origin.x + frame.size.width + aDx;
[mView setNeedsDisplayInRect: horizInvalid];
if (aDy != 0)
[mView setNeedsDisplayInRect: vertInvalid];
}
if (aDy != 0) {
vertInvalid.size.height = abs(aDy);
if (aDy < 0)
vertInvalid.origin.y = frame.origin.y + frame.size.height + aDy;
[mView setNeedsDisplayInRect: vertInvalid];
}
// We also need to check for any ChildViews which overlap this widget
// but are not descendent widgets. If there are any, we need to
// invalidate the area of this view that these ChildViews will have been
// blitted into, since these widgets aren't supposed to scroll with
// this widget.
// To do this, start at the root Gecko NSView, and walk down along
// our ancestor view chain, looking at all the subviews in each level
// of the hierarchy. If we find a non-ancestor view that overlaps
// this view, invalidate the area around it.
// We need to convert all rects to a common ancestor view to intersect
// them, since a view's frame is in the coordinate space of its parent.
// Use mParentView as the frame of reference.
NSRect selfFrame = [mParentView convertRect:[mView frame] fromView:[mView superview]];
NSView* view = mParentView;
BOOL selfLevel = NO;
while (!selfLevel) {
NSView* nextAncestorView;
NSArray* subviews = [view subviews];
for (int i = 0; i < [subviews count]; ++i) {
NSView* subView = [subviews objectAtIndex: i];
if (subView == mView)
selfLevel = YES;
else if ([mView isDescendantOf:subView])
nextAncestorView = subView;
else {
NSRect intersectArea = NSIntersectionRect([mParentView convertRect:[subView frame] fromView:[subView superview]], selfFrame);
if (!NSIsEmptyRect(intersectArea)) {
NSPoint origin = [mView convertPoint:intersectArea.origin fromView:mParentView];
if (aDy != 0) {
vertInvalid.origin.x = origin.x;
if (aDy < 0) // scrolled down, invalidate above
vertInvalid.origin.y = origin.y + aDy;
else // invalidate below
vertInvalid.origin.y = origin.y + intersectArea.size.height;
vertInvalid.size.width = intersectArea.size.width;
[mView setNeedsDisplayInRect: vertInvalid];
}
if (aDx != 0) {
horizInvalid.origin.y = origin.y;
if (aDx < 0) // scrolled right, invalidate to the left
horizInvalid.origin.x = origin.x + aDx;
else // invalidate to the right
horizInvalid.origin.x = origin.x + intersectArea.size.width;
horizInvalid.size.height = intersectArea.size.height;
[mView setNeedsDisplayInRect: horizInvalid];
}
}
}
}
view = nextAncestorView;
}
}
}

View File

@ -56,7 +56,6 @@
#include "nsMimeMapper.h"
#include "nsIComponentManager.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsXPIDLString.h"
#include "nsPrimitiveHelpers.h"

View File

@ -53,7 +53,6 @@
#include "nsClipboard.h"
#include "nsIRegion.h"
#include "nsVoidArray.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
@ -553,7 +552,7 @@ printf("looking for data in type %s, mac flavor %ld\n", NS_STATIC_CAST(const cha
// check if it is present in the current drag item.
FlavorFlags unused;
PRBool dataFound = PR_FALSE;
void* dataBuff;
void* dataBuff = nsnull;
PRInt32 dataSize = 0;
if ( macOSFlavor && ::GetFlavorFlags(mDragRef, itemRef, macOSFlavor, &unused) == noErr ) {
nsresult loadResult = ExtractDataFromOS(mDragRef, itemRef, macOSFlavor, &dataBuff, &dataSize);
@ -584,17 +583,38 @@ printf("looking for data in type %s, mac flavor %ld\n", NS_STATIC_CAST(const cha
} // if looking for text/unicode
} // else we try one last ditch effort to find our data
if ( dataFound ) {
if ( dataFound )
{
nsCOMPtr<nsISupports> genericDataWrapper;
if ( strcmp(flavorStr, kFileMime) == 0 ) {
// we have a HFSFlavor struct in |dataBuff|. Create an nsLocalFileMac object.
HFSFlavor* fileData = NS_REINTERPRET_CAST(HFSFlavor*, dataBuff);
NS_ASSERTION ( sizeof(HFSFlavor) == dataSize, "Ooops, we realy don't have a HFSFlavor" );
nsCOMPtr<nsILocalFileMac> file;
if ( NS_SUCCEEDED(NS_NewLocalFileWithFSSpec(&fileData->fileSpec, PR_TRUE, getter_AddRefs(file))) )
genericDataWrapper = do_QueryInterface(file);
}
else {
if (strcmp(flavorStr, kFileMime) == 0)
{
// we have a HFSFlavor struct in |dataBuff|. Create an nsLocalFileMac object.
HFSFlavor* fileData = NS_REINTERPRET_CAST(HFSFlavor*, dataBuff);
NS_ASSERTION ( sizeof(HFSFlavor) == dataSize, "Ooops, we realy don't have a HFSFlavor" );
nsCOMPtr<nsILocalFileMac> file;
if ( NS_SUCCEEDED(NS_NewLocalFileWithFSSpec(&fileData->fileSpec, PR_TRUE, getter_AddRefs(file))) )
genericDataWrapper = do_QueryInterface(file);
}
#ifdef BRANCH_CHANGES_NEED_MERGED
else if ((strcmp(flavorStr, kURLDataMime) == 0) || (strcmp(flavorStr, kURLDescriptionMime) == 0))
{
// need to convert platform data to unicode
const char* castedText = NS_REINTERPRET_CAST(char*, dataBuff);
PRUnichar* convertedText = nsnull;
PRInt32 convertedTextLen = 0;
nsPrimitiveHelpers::ConvertPlatformPlainTextToUnicode(castedText, dataSize,
&convertedText, &convertedTextLen);
if (convertedText)
{
nsMemory::Free(dataBuff);
dataBuff = convertedText;
dataSize = convertedTextLen * 2;
nsPrimitiveHelpers::CreatePrimitiveForData(flavorStr, (void *)dataBuff, dataSize, getter_AddRefs(genericDataWrapper));
}
}
#endif
else
{
// we probably have some form of text. The DOM only wants LF, so convert k
// from MacOS line endings to DOM line endings.
nsLinebreakHelpers::ConvertPlatformToDOMLinebreaks ( flavorStr, &dataBuff, NS_REINTERPRET_CAST(int*, &dataSize) );
@ -808,11 +828,22 @@ nsDragService :: GetDataForFlavor ( nsISupportsArray* inDragItems, DragReference
// if someone was asking for text/plain, lookup unicode instead so we can convert it.
PRBool needToDoConversionToPlainText = PR_FALSE;
const char* actualFlavor = mimeFlavor.get();
if ( strcmp(actualFlavor,kTextMime) == 0 ) {
if (strcmp(actualFlavor, kTextMime) == 0)
{
actualFlavor = kUnicodeMime;
needToDoConversionToPlainText = PR_TRUE;
}
else if ( strcmp(actualFlavor, kFilePromiseMime) == 0 ) {
#ifdef BRANCH_CHANGES_NEED_MERGED
else if (strcmp(actualFlavor, kURLDataMime) == 0)
{
needToDoConversionToPlainText = PR_TRUE;
}
else if (strcmp(actualFlavor, kURLDescriptionMime) == 0)
{
needToDoConversionToPlainText = PR_TRUE;
}
else if (strcmp(actualFlavor, kFilePromiseMime) == 0)
{
nsCOMPtr<nsISupports> imageURLPrimitive;
PRUint32 dataSize = 0;
rv = item->GetTransferData(kFilePromiseURLMime, getter_AddRefs(imageURLPrimitive), &dataSize);
@ -834,7 +865,9 @@ nsDragService :: GetDataForFlavor ( nsISupportsArray* inDragItems, DragReference
return HandleHFSPromiseDrop(inDragRef, inItemIndex, inFlavor, imageURLString, outData, outDataSize);
}
else if ( strcmp(actualFlavor, kNativeImageMime) == 0 ) {
#endif
else if (strcmp(actualFlavor, kNativeImageMime) == 0)
{
PRUint32 dataSize = 0;
nsCOMPtr<nsISupports> transferSupports;
rv = item->GetTransferData(actualFlavor, getter_AddRefs(transferSupports), &dataSize);
@ -853,7 +886,9 @@ nsDragService :: GetDataForFlavor ( nsISupportsArray* inDragItems, DragReference
if (!picture) return cantGetFlavorErr;
PRInt32 pictSize = ::GetHandleSize((Handle)picture);
char* pictData = (char*)nsMemory::Alloc(pictSize);
char* pictData = nsnull;
if (pictSize > 0)
pictData = (char*)nsMemory::Alloc(pictSize);
if (pictData) {
::BlockMoveData(*picture, pictData, pictSize); // doesn't move memory
*outData = (void*)pictData;
@ -862,13 +897,14 @@ nsDragService :: GetDataForFlavor ( nsISupportsArray* inDragItems, DragReference
}
else
retVal = cantGetFlavorErr;
::KillPicture(picture);
return retVal;
}
nsCOMPtr<nsISupports> data;
if ( NS_SUCCEEDED(item->GetTransferData(actualFlavor, getter_AddRefs(data), outDataSize)) ) {
if (NS_SUCCEEDED(item->GetTransferData(actualFlavor, getter_AddRefs(data), outDataSize)))
{
nsPrimitiveHelpers::CreateDataFromPrimitive ( actualFlavor, data, outData, *outDataSize );
// Convert unix to mac linebreaks, since mac linebreaks are required for clipboard compatibility.
@ -886,7 +922,7 @@ nsDragService :: GetDataForFlavor ( nsISupportsArray* inDragItems, DragReference
if ( needToDoConversionToPlainText ) {
char* plainTextData = nsnull;
PRInt32 plainTextLen = 0;
nsPrimitiveHelpers::ConvertUnicodeToPlatformPlainText ( castedUnicode, *outDataSize / 2, &plainTextData, &plainTextLen );
nsPrimitiveHelpers::ConvertUnicodeToPlatformPlainText(castedUnicode, *outDataSize / 2, &plainTextData, &plainTextLen);
if ( *outData ) {
nsMemory::Free(*outData);
*outData = plainTextData;
@ -1113,7 +1149,7 @@ static OSErr GetFolderFileSpec(const FSSpec *inFolderSpec, ConstStr255Param inFi
return ::FSMakeFSSpec(inFolderSpec->vRefNum, cipbp.dirInfo.ioDrDirID, inFileName, outFSSpec);
}
#ifdef BRANCH_CHANGES_NEED_MERGED
OSErr
nsDragService::HandleHFSPromiseDrop(DragReference inDragRef, unsigned int inItemIndex,
FlavorType inFlavor, const nsAString& inSourceURL, void** outData, unsigned int* outDataSize)
@ -1166,5 +1202,5 @@ nsDragService::HandleHFSPromiseDrop(DragReference inDragRef, unsigned int inItem
return err;
}
#endif

View File

@ -95,8 +95,10 @@ private:
// compute a screen rect from the frame associated with the given dom node
PRBool ComputeGlobalRectFromFrame ( nsIDOMNode* aDOMNode, Rect & outScreenRect ) ;
#ifdef BRANCH_CHANGES_NEED_MERGED
OSErr HandleHFSPromiseDrop(DragReference inDragRef, unsigned int inItemIndex,
FlavorType inFlavor, const nsAString& inSourceURL, void** outData, unsigned int* outDataSize);
#endif
// callback for the MacOS DragManager when a drop site asks for data
static pascal OSErr DragSendDataProc ( FlavorType inFlavor, void* inRefCon,

View File

@ -96,10 +96,6 @@ static NS_DEFINE_CID(kMenuItemCID, NS_MENUITEM_CID);
class nsDummyMenuItemX : public nsISupports {
public:
NS_DECL_ISUPPORTS
nsDummyMenuItemX()
{
}
};
NS_IMETHODIMP_(nsrefcnt) nsDummyMenuItemX::AddRef() { return ++mRefCnt; }

View File

@ -170,7 +170,7 @@ static nsModuleComponentInfo components[] =
NS_DRAGHELPERSERVICE_CID,
"@mozilla.org/widget/draghelperservice;1",
nsDragHelperServiceConstructor },
{ "Gtk Bidi Keyboard",
{ "Cocoa Bidi Keyboard",
NS_BIDIKEYBOARD_CID,
"@mozilla.org/widget/bidikeyboard;1",
nsBidiKeyboardConstructor },