removing nsWatchTask, removing cocoa widget dependancies on gfx/src/mac. bug 330786. r=josh

This commit is contained in:
pavlov%pavlov.net 2006-03-17 23:35:39 +00:00
Родитель dfa1ea4fa2
Коммит 70590e7254
20 изменённых файлов: 160 добавлений и 299 удалений

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

@ -83,6 +83,10 @@ CPPSRCS = \
nsFontUtils.cpp \
$(NULL)
EXPORTS = \
nsIImageMac.h \
$(NULL)
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
CPPSRCS += nsQDFlushManager.cpp
CMMSRCS = nsCocoaImageUtils.mm

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

@ -340,74 +340,6 @@ protected:
};
/** ------------------------------------------------------------
* Utility class stack-based handle ownership
*/
class StHandleOwner
{
public:
StHandleOwner(Handle inHandle)
: mHandle(inHandle)
{
}
~StHandleOwner()
{
if (mHandle)
::DisposeHandle(mHandle);
}
Handle GetHandle() { return mHandle; }
void ClearHandle(Boolean disposeIt = false)
{
if (disposeIt)
::DisposeHandle(mHandle);
mHandle = nsnull;
}
protected:
Handle mHandle;
};
/** ------------------------------------------------------------
* Utility class for saving, locking, and restoring handle state
* Ok with null handle
*/
class StHandleLocker
{
public:
StHandleLocker(Handle theHandle)
: mHandle(theHandle)
{
if (mHandle)
{
mOldHandleState = ::HGetState(mHandle);
::HLock(mHandle);
}
}
~StHandleLocker()
{
if (mHandle)
::HSetState(mHandle, mOldHandleState);
}
protected:
Handle mHandle;
SInt8 mOldHandleState;
};
/**
* Stack based utility class for releasing a Quartz color space.
* Use as follows:

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

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

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

@ -50,7 +50,8 @@ THEBES_IMPL_REFCOUNTING(gfxAtsuiFont)
gfxAtsuiFont::gfxAtsuiFont(ATSUFontID fontID,
gfxAtsuiFontGroup *fontGroup)
: mATSUFontID(fontID), mFontGroup(fontGroup)
: gfxFont(EmptyString(), fontGroup),
mATSUFontID(fontID), mFontGroup(fontGroup)
{
ATSFontRef fontRef = FMGetATSFontRefFromFont(fontID);

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

@ -85,10 +85,6 @@ EXPORTS = \
mozView.h \
$(NULL)
GFX_LCPPSRCS = \
nsWatchTask.cpp \
$(NULL)
MAC_LCPPSRCS = \
nsBidiKeyboard.cpp \
nsClipboard.cpp \
@ -98,8 +94,6 @@ MAC_LCPPSRCS = \
nsMacNativeUnicodeConverter.cpp \
nsMacResources.cpp \
nsMimeMapper.cpp \
nsNativeThemeMac.cpp \
nsSound.cpp \
nsStylClipboardUtils.cpp \
nsToolkitBase.cpp \
nsTSMStrategy.cpp \
@ -113,9 +107,14 @@ MAC_LCPPSRCS = \
$(NULL)
ifndef MOZ_ENABLE_CAIRO_GFX
MAC_LCPPSRCS += nsNativeThemeMac.cpp \
nsSound.cpp \
$(NULL)
endif
CPPSRCS = \
$(MAC_LCPPSRCS) \
$(GFX_LCPPSRCS) \
$(NULL)
CMMSRCS = \
@ -195,7 +194,6 @@ libs:: $(RES_DEST)
LOCAL_INCLUDES = \
$(TK_CFLAGS) \
-I$(topsrcdir)/gfx/src/mac \
-I$(srcdir)/../xpwidgets \
-I$(srcdir)/../mac \
-I/System/Library/Frameworks/Carbon.Framework/Headers \
@ -212,4 +210,3 @@ CXXFLAGS += \
-DUSE_COCOA \
$(NULL)

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

@ -220,11 +220,13 @@ public:
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
virtual PRBool DispatchMouseEvent(nsMouseEvent &aEvent);
#ifndef MOZ_CAIRO_GFX
virtual void StartDraw(nsIRenderingContext* aRenderingContext = nsnull);
virtual void EndDraw();
void UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext);
#endif
NS_IMETHOD Update();
virtual void UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext);
virtual void ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY);
void LocalToWindowCoordinate(nsPoint& aPoint) { ConvertToDeviceCoordinates(aPoint.x, aPoint.y); }
void LocalToWindowCoordinate(nscoord& aX, nscoord& aY) { ConvertToDeviceCoordinates(aX, aY); }
@ -296,14 +298,16 @@ protected:
NSView<mozView>* mParentView;
nsIWidget* mParentWidget;
nsIFontMetrics* mFontMetrics;
nsIRenderingContext* mTempRenderingContext;
#ifndef MOZ_CAIRO_GFX
nsCOMPtr<nsIFontMetrics> mFontMetrics;
nsCOMPtr<nsIRenderingContext> mTempRenderingContext;
PRPackedBool mTempRenderingContextMadeHere;
#endif
PRPackedBool mDestructorCalled;
PRPackedBool mVisible;
PRPackedBool mDrawing;
PRPackedBool mTempRenderingContextMadeHere;
PRPackedBool mAcceptFocusOnClick;
PRPackedBool mLiveResizeInProgress;

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

@ -55,8 +55,6 @@
#include "nsIInterfaceRequestor.h"
#include "nsIServiceManager.h"
#include "nsCarbonHelpers.h"
#include "nsGfxUtils.h"
#include "nsMacResources.h"
#include "nsIQDFlushManager.h"
@ -66,6 +64,8 @@
#ifdef MOZ_CAIRO_GFX
#include "gfxContext.h"
#include "gfxQuartzSurface.h"
#else
#include "nsGfxUtils.h" // for StPortSetter
#endif
#define NSAppKitVersionNumber10_2 663
@ -302,12 +302,12 @@ nsChildView::nsChildView() : nsBaseWidget()
, mView(nsnull)
, mParentView(nsnull)
, mParentWidget(nsnull)
, mFontMetrics(nsnull)
, mTempRenderingContext(nsnull)
#ifndef MOZ_CAIRO_GFX
, mTempRenderingContextMadeHere(PR_FALSE)
#endif
, mDestructorCalled(PR_FALSE)
, mVisible(PR_FALSE)
, mDrawing(PR_FALSE)
, mTempRenderingContextMadeHere(PR_FALSE)
, mAcceptFocusOnClick(PR_TRUE)
, mLiveResizeInProgress(PR_FALSE)
, mPluginDrawing(PR_FALSE)
@ -334,9 +334,6 @@ nsChildView::~nsChildView()
TearDownView(); // should have already been done from Destroy
NS_IF_RELEASE(mTempRenderingContext);
NS_IF_RELEASE(mFontMetrics);
delete mPluginPort;
if (mVisRgn)
@ -756,7 +753,11 @@ NS_IMETHODIMP nsChildView::SetFocus(PRBool aRaise)
//-------------------------------------------------------------------------
nsIFontMetrics* nsChildView::GetFont(void)
{
#ifdef MOZ_CAIRO_GFX
return nsnull;
#else
return mFontMetrics;
#endif
}
@ -767,10 +768,14 @@ nsIFontMetrics* nsChildView::GetFont(void)
//-------------------------------------------------------------------------
NS_IMETHODIMP nsChildView::SetFont(const nsFont &aFont)
{
#ifdef MOZ_CAIRO_GFX
return NS_ERROR_NOT_IMPLEMENTED;
#else
NS_IF_RELEASE(mFontMetrics);
if (mContext)
mContext->GetMetricsFor(aFont, mFontMetrics);
return NS_OK;
#endif
}
@ -1030,6 +1035,7 @@ NS_IMETHODIMP nsChildView::GetPluginClipRect(nsRect& outClipRect, nsPoint& outOr
//-------------------------------------------------------------------------
NS_IMETHODIMP nsChildView::StartDrawPlugin()
{
#ifndef MOZ_CAIRO_GFX
NS_ASSERTION(mPluginPort, "StartDrawPlugin must only be called on a plugin widget");
if (!mPluginPort)
return NS_ERROR_FAILURE;
@ -1080,6 +1086,7 @@ NS_IMETHODIMP nsChildView::StartDrawPlugin()
}
NS_ASSERTION(0, "lockFocusIfCanDraw returned false\n");
#endif
return NS_ERROR_FAILURE;
}
@ -1261,6 +1268,8 @@ inline PRUint16 COLOR8TOCOLOR16(PRUint8 color8)
return (color8 << 8) | color8; /* (color8 * 257) == (color8 * 0x0101) */
}
#ifndef MOZ_CAIRO_GFX
//-------------------------------------------------------------------------
// StartDraw
//
@ -1274,13 +1283,12 @@ void nsChildView::StartDraw(nsIRenderingContext* aRenderingContext)
if (aRenderingContext == nsnull)
{
// make sure we have a rendering context
mTempRenderingContext = GetRenderingContext();
mTempRenderingContext = getter_AddRefs(GetRenderingContext());
mTempRenderingContextMadeHere = PR_TRUE;
}
else
{
// if we already have a rendering context, save its state
NS_IF_ADDREF(aRenderingContext);
mTempRenderingContext = aRenderingContext;
mTempRenderingContextMadeHere = PR_FALSE;
mTempRenderingContext->PushState();
@ -1326,9 +1334,10 @@ void nsChildView::EndDraw()
if (mTempRenderingContextMadeHere)
mTempRenderingContext->PopState();
NS_RELEASE(mTempRenderingContext);
}
mTempRenderingContext = nsnull;
}
#endif /* MOZ_CAIRO_GFX */
//-------------------------------------------------------------------------
//
@ -1337,7 +1346,7 @@ void nsChildView::EndDraw()
void
nsChildView::Flash(nsPaintEvent &aEvent)
{
#if DEBUG
#if 0
Rect flashRect;
if (debug_WantPaintFlashing() && aEvent.rect ) {
::SetRect ( &flashRect, aEvent.rect->x, aEvent.rect->y, aEvent.rect->x + aEvent.rect->width,
@ -1381,6 +1390,7 @@ NS_IMETHODIMP nsChildView::Update()
#pragma mark -
#ifndef MOZ_CAIRO_GFX
//
// UpdateWidget
//
@ -1428,6 +1438,7 @@ nsChildView::UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext)
EndDraw();
#endif
}
#endif
//
@ -2453,16 +2464,14 @@ nsChildView::GetThebesSurface()
nsRect geckoBounds;
mGeckoChild->GetBounds(geckoBounds);
nsRefPtr<gfxQuartzSurface> targetSurface =
new gfxQuartzSurface(cgContext, geckoBounds.width, geckoBounds.height,
PR_FALSE);
new gfxQuartzSurface(cgContext, geckoBounds.width, geckoBounds.height, PR_FALSE);
//fprintf (stderr, "Update[%p] [%f %f %f %f] cgc: %p gecko bounds: [%d %d %d %d]\n", mGeckoChild, aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height, cgContext, geckoBounds.x, geckoBounds.y, geckoBounds.width, geckoBounds.height);
CGAffineTransform xform = CGContextGetCTM(cgContext);
//fprintf (stderr, " context xform: t: %f %f xx: %f xy: %f yx: %f yy: %f\n", xform.tx, xform.ty, xform.a, xform.b, xform.c, xform.d);
nsRefPtr<gfxContext> targetContext =
new gfxContext(targetSurface);
nsRefPtr<gfxContext> targetContext = new gfxContext(targetSurface);
#if 0
targetContext->Rectangle(gfxRect(aRect.origin.x, aRect.origin.y,
@ -2504,7 +2513,7 @@ nsChildView::GetThebesSurface()
//fprintf (stderr, "---- update done ----\n");
#else
#else /* MOZ_CAIRO_GFX */
// tell gecko to paint.
// If < 10.3, just paint the rect
if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_2) {

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -46,8 +46,6 @@
#include "nsIScreen.h"
#include "nsIScreenManager.h"
#include "nsGUIEvent.h"
#include "nsCarbonHelpers.h"
#include "nsGfxUtils.h"
#include "nsMacResources.h"
#include "nsIRollupListener.h"
#import "nsChildView.h"
@ -71,7 +69,7 @@ NS_IMPL_ISUPPORTS_INHERITED0(nsCocoaWindow, Inherited)
* (0,0) in the bottom-left of the screen. Both nsRect and NSRect
* contain width/height info, with no difference in their use.
*/
static NSRect geckoRectToCocoaRect(nsRect geckoRect)
static NSRect geckoRectToCocoaRect(const nsRect &geckoRect)
{
// first we get the highest point on all screens
float highestScreenPoint = 0.0;
@ -174,8 +172,6 @@ nsresult nsCocoaWindow::StandardCreate(nsIWidget *aParent,
// Configure the window we will create based on the window type
switch (mWindowType)
{
case eWindowType_popup:
break;
case eWindowType_child:
// In Carbon, we made this a window of type kPlainWindowClass.
// I think that is pretty much equiv to NSBorderlessWindowMask.
@ -230,6 +226,9 @@ nsresult nsCocoaWindow::StandardCreate(nsIWidget *aParent,
features = NSMiniaturizableWindowMask;
}
break;
case eWindowType_popup:
features |= NSBorderlessWindowMask;
break;
case eWindowType_toplevel:
features |= NSTitledWindowMask;
features |= NSMiniaturizableWindowMask;
@ -268,6 +267,7 @@ nsresult nsCocoaWindow::StandardCreate(nsIWidget *aParent,
// compensate for difference between frame and content area height (e.g. title bar)
NSRect newWindowFrame = [NSWindow frameRectForContentRect:rect styleMask:features];
rect.origin.y -= (newWindowFrame.size.height - rect.size.height);
if (mWindowType != eWindowType_popup)
@ -282,6 +282,11 @@ nsresult nsCocoaWindow::StandardCreate(nsIWidget *aParent,
mWindow = [[NSWindow alloc] initWithContentRect:rect styleMask:features
backing:NSBackingStoreBuffered defer:NO];
if (mWindowType == eWindowType_popup) {
[mWindow setLevel:NSPopUpMenuWindowLevel];
[mWindow setHasShadow:YES];
}
[mWindow setReleasedWhenClosed:NO];
// register for mouse-moved events. The default is to ignore them for perf reasons.
@ -371,14 +376,14 @@ nsCocoaWindow::IsVisible(PRBool & aState)
//-------------------------------------------------------------------------
NS_IMETHODIMP nsCocoaWindow::Show(PRBool bState)
{
if (bState)
[mWindow orderFront:NULL];
else
[mWindow orderOut:NULL];
if (bState)
[mWindow orderFront:NULL];
else
[mWindow orderOut:NULL];
mVisible = bState;
mVisible = bState;
return NS_OK;
return NS_OK;
}

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

@ -40,7 +40,6 @@
#include "nsReadableUtils.h"
#include "nsWidgetAtoms.h"
#include "nsWatchTask.h"
#include "nsINameSpaceManager.h"
#include "nsIDOMElement.h"
#include "nsIScrollbarMediator.h"

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

@ -62,6 +62,7 @@
#include "nsLookAndFeel.h"
#include "nsSound.h"
#include "nsNativeScrollbar.h"
#include "nsScreenManagerMac.h"
#include "nsDeviceContextSpecX.h"
@ -140,10 +141,12 @@ static const nsModuleComponentInfo gComponents[] =
NS_MENUITEM_CID,
"@mozilla.org/widget/menuitem/mac;1",
nsMenuItemXConstructor },
#ifndef MOZ_CAIRO_GFX
{ "Sound",
NS_SOUND_CID,
"@mozilla.org/sound;1",
nsSoundConstructor },
#endif
{ "Transferable",
NS_TRANSFERABLE_CID,
"@mozilla.org/widget/transferable;1",

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

@ -85,7 +85,6 @@ endif
GFX_LCPPSRCS = \
nsRepeater.cpp \
nsWatchTask.cpp \
$(NULL)
CPPSRCS = nsAppShell.cpp \

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

@ -58,7 +58,9 @@
#include "nsISupportsPrimitives.h"
#include "nsXPIDLString.h"
#include "nsPrimitiveHelpers.h"
#ifndef MOZ_CAIRO_GFX
#include "nsIImageMac.h"
#endif
#include "nsMemory.h"
#include "nsMacNativeUnicodeConverter.h"
#include "nsICharsetConverterManager.h"
@ -225,6 +227,7 @@ nsClipboard :: SetNativeClipboardData ( PRInt32 aWhichClipboard )
nsCOMPtr<nsISupports> transferSupports;
errCode = mTransferable->GetTransferData ( flavorStr, getter_AddRefs(transferSupports), &dataSize );
nsCOMPtr<nsISupportsInterfacePointer> ptrPrimitive(do_QueryInterface(transferSupports));
#ifndef MOZ_CAIRO_GFX
nsCOMPtr<nsIImageMac> image;
if (ptrPrimitive) {
nsCOMPtr<nsISupports> primitiveData;
@ -240,6 +243,7 @@ nsClipboard :: SetNativeClipboardData ( PRInt32 aWhichClipboard )
}
}
else
#endif
NS_WARNING ( "Image isn't an nsIImageMac in transferable" );
}
else {

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

@ -59,7 +59,6 @@
#include "nsCOMPtr.h"
#include "nsCRT.h"
#include "nsPrimitiveHelpers.h"
#include "nsWatchTask.h"
#include "nsLinebreakConverter.h"
#include "nsIContent.h"
@ -72,15 +71,17 @@
#include "nsRect.h"
#include "nsPoint.h"
#include "nsIWidget.h"
#ifndef MOZ_WIDGET_COCOA
#include "nsCarbonHelpers.h"
#include "nsGfxUtils.h"
#endif
// file save stuff
#include "nsNetUtil.h"
#include "nsILocalFileMac.h"
#include "nsIDOMElement.h"
#ifndef MOZ_CAIRO_GFX
#include "nsIImageMac.h"
#endif
#include "nsIImage.h"
#include "nsMacNativeUnicodeConverter.h"
#include "nsICharsetConverterManager.h"
@ -104,6 +105,15 @@ GetPrimaryFrameFor(nsIContent* aContent)
}
static void
SetPortToKnownGoodPort()
{
WindowPtr firstWindow = GetWindowList();
if (firstWindow)
::SetGWorld(::GetWindowPort(firstWindow), ::GetMainDevice());
}
// we need our own stuff for MacOS because of nsIDragSessionMac.
NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService)
NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService)
@ -230,7 +240,7 @@ NS_IMETHODIMP
nsDragService::InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray * aTransferableArray, nsIScriptableRegion * aDragRgn, PRUint32 aActionType)
{
#ifdef MOZ_WIDGET_COCOA
nsGraphicsUtils::SetPortToKnownGoodPort();
SetPortToKnownGoodPort();
GrafPtr port;
GDHandle handle;
::GetGWorld(&port, &handle);
@ -333,7 +343,7 @@ nsDragService::BuildDragRegion ( nsIScriptableRegion* inRegion, nsIDOMNode* inNo
inRegion->GetRegion(getter_AddRefs(geckoRegion));
#ifdef MOZ_WIDGET_COCOA
nsGraphicsUtils::SetPortToKnownGoodPort();
SetPortToKnownGoodPort();
GrafPtr port;
GDHandle handle;
::GetGWorld(&port, &handle);
@ -906,6 +916,7 @@ nsDragService::GetDataForFlavor(nsISupportsArray* inDragItems, DragReference inD
nsCOMPtr<nsISupports> primitiveData;
ptrPrimitive->GetData(getter_AddRefs(primitiveData));
#ifndef MOZ_CAIRO_GFX
nsCOMPtr<nsIImageMac> image = do_QueryInterface(primitiveData);
if (!image) return cantGetFlavorErr;
@ -927,6 +938,9 @@ nsDragService::GetDataForFlavor(nsISupportsArray* inDragItems, DragReference inD
retVal = cantGetFlavorErr;
::KillPicture(picture);
#else
retVal = cantGetFlavorErr;
#endif
return retVal;
}
@ -1115,16 +1129,12 @@ nsDragService::ExtractDataFromOS ( DragReference inDragRef, ItemReference inItem
nsresult
nsDragService::StartDragSession ( )
{
nsWatchTask::GetTask().Suspend();
return nsBaseDragService::StartDragSession();
}
nsresult
nsDragService::EndDragSession ( )
{
nsWatchTask::GetTask().Resume();
return nsBaseDragService::EndDragSession();
}

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

@ -56,8 +56,6 @@
#include "nsCarbonHelpers.h"
#include "nsFilePicker.h"
#include "nsWatchTask.h"
#include "nsIInternetConfigService.h"
#include "nsIMIMEInfo.h"
@ -419,9 +417,7 @@ nsFilePicker::GetLocalFiles(const nsString& inTitle, PRBool inAllowMultiple, nsC
&dialog);
if (anErr == noErr)
{
nsWatchTask::GetTask().Suspend();
anErr = ::NavDialogRun(dialog);
nsWatchTask::GetTask().Resume();
if (anErr == noErr)
{
@ -521,9 +517,7 @@ nsFilePicker::GetLocalFolder(const nsString& inTitle, nsILocalFile** outFile)
if (anErr == noErr)
{
nsWatchTask::GetTask().Suspend();
anErr = ::NavDialogRun(dialog);
nsWatchTask::GetTask().Resume();
if (anErr == noErr)
{
NavReplyRecord reply;
@ -619,9 +613,7 @@ nsFilePicker::PutLocalFile(const nsString& inTitle, const nsString& inDefaultNam
if (anErr == noErr)
{
nsWatchTask::GetTask().Suspend();
anErr = ::NavDialogRun(dialog);
nsWatchTask::GetTask().Resume();
if (anErr == noErr)
{

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

@ -36,10 +36,11 @@
* ***** END LICENSE BLOCK ***** */
#include "nsLookAndFeel.h"
#include "nsCarbonHelpers.h"
#include "nsIInternetConfigService.h"
#include "nsIServiceManager.h"
#include "nsSize.h"
#include <ControlDefinitions.h>
#include <MacWindows.h>
//-------------------------------------------------------------------------

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

@ -77,7 +77,6 @@
#include <Sound.h>
#include <Quickdraw.h>
#include "nsCarbonHelpers.h"
#include "nsWatchTask.h"
#include "nsIEventSink.h"
#include "nsPIWidgetMac.h"
@ -196,9 +195,6 @@ nsMacMessagePump::nsMacMessagePump(nsToolkit *aToolkit)
mTSMMessagePump = nsMacTSMMessagePump::GetSingleton();
NS_ASSERTION(mTSMMessagePump!=NULL,"nsMacMessagePump::nsMacMessagePump: Unable to create TSM Message Pump.");
// startup the watch cursor idle time vbl task
nsWatchTask::GetTask().Start();
#if !XP_MACOSX
// added to support Menu Sharing API. Initializes the Menu Sharing API.
InitSharedMenus (ErrorDialog, EventFilter);
@ -383,8 +379,6 @@ PRBool nsMacMessagePump::GetEvent(EventRecord &theEvent)
::SetEventMask(everyEvent); // we need keyUp events
PRBool haveEvent = ::WaitNextEvent(everyEvent, &theEvent, sleepTime, mouseRgn);
nsWatchTask::GetTask().EventLoopReached();
return haveEvent;
}
@ -537,10 +531,8 @@ PRBool nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
}
else
{
nsWatchTask::GetTask().Suspend();
long menuResult = ::MenuSelect(anEvent.where);
handled = PR_TRUE;
nsWatchTask::GetTask().Resume();
#if USE_MENUSELECT
if (HiWord(menuResult) != 0)
{
@ -567,9 +559,7 @@ PRBool nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
// it was a click or a drag. If it was a drag, send a drag gesture to the
// background window. We don't need to rely on the ESM to track the gesture,
// the OS has just told us. If it was a click, bring it to the front like normal.
nsWatchTask::GetTask().Suspend();
Boolean initiateDragFromBGWindow = ::WaitMouseMoved(anEvent.where);
nsWatchTask::GetTask().Resume();
if ( initiateDragFromBGWindow ) {
nsCOMPtr<nsIEventSink> sink ( do_QueryInterface(topWidget) );
if ( sink ) {
@ -606,8 +596,6 @@ PRBool nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
Point oldTopLeft = {0, 0};
::LocalToGlobal(&oldTopLeft);
nsWatchTask::GetTask().Suspend();
// roll up popups BEFORE we start the drag
if ( gRollupListener && gRollupWidget )
gRollupListener->Rollup();
@ -616,8 +604,6 @@ PRBool nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
::GetRegionBounds(::GetGrayRgn(), &screenRect);
::DragWindow(whichWindow, anEvent.where, &screenRect);
nsWatchTask::GetTask().Resume();
Point newTopLeft = {0, 0};
::LocalToGlobal(&newTopLeft);
@ -702,9 +688,7 @@ PRBool nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
sizeRect.left = kMinWindowWidth;
sizeRect.bottom = 0x7FFF;
sizeRect.right = 0x7FFF;
nsWatchTask::GetTask().Suspend();
long newSize = ::GrowWindow(whichWindow, anEvent.where, &sizeRect);
nsWatchTask::GetTask().Resume();
if (newSize != 0)
::SizeWindow(whichWindow, newSize & 0x0FFFF, (newSize >> 16) & 0x0FFFF, true);
Rect portRect;
@ -719,19 +703,15 @@ PRBool nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
case inGoAway:
{
nsWatchTask::GetTask().Suspend();
nsGraphicsUtils::SafeSetPortWindowPort(whichWindow);
if (::TrackGoAway(whichWindow, anEvent.where)) {
nsWatchTask::GetTask().Resume();
handled = DispatchOSEventToRaptor(anEvent, whichWindow);
}
nsWatchTask::GetTask().Resume();
break;
}
case inZoomIn:
case inZoomOut:
nsWatchTask::GetTask().Suspend();
if (::TrackBox(whichWindow, anEvent.where, partCode))
{
if (partCode == inZoomOut)
@ -748,14 +728,11 @@ PRBool nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
handled = DispatchOSEventToRaptor(anEvent, whichWindow);
}
nsWatchTask::GetTask().Resume();
break;
case inToolbarButton: // Mac OS X only
nsWatchTask::GetTask().Suspend();
nsGraphicsUtils::SafeSetPortWindowPort(whichWindow);
handled = DispatchOSEventToRaptor(anEvent, whichWindow);
nsWatchTask::GetTask().Resume();
break;
}

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

@ -1,140 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Simon Fraser <sfraser@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <PMApplication.h>
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsPrintOptionsX.h"
#include "nsPrintSettingsX.h"
#include "nsGfxUtils.h"
#include "nsCRT.h"
#include "plbase64.h"
#include "prmem.h"
/** ---------------------------------------------------
*/
nsPrintOptionsX::nsPrintOptionsX()
{
}
/** ---------------------------------------------------
*/
nsPrintOptionsX::~nsPrintOptionsX()
{
}
/** ---------------------------------------------------
* See documentation in nsPrintOptionsImpl.h
*/
nsresult nsPrintOptionsX::_CreatePrintSettings(nsIPrintSettings **_retval)
{
nsresult rv;
*_retval = nsnull;
nsPrintSettingsX* printSettings = new nsPrintSettingsX; // does not initially ref count
NS_ENSURE_TRUE(printSettings, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*_retval = printSettings); // ref count
rv = printSettings->Init();
if (NS_FAILED(rv)) {
NS_RELEASE(*_retval);
return rv;
}
(void)InitPrintSettingsFromPrefs(*_retval, PR_FALSE,
nsIPrintSettings::kInitSaveAll);
return rv;
}
/** ---------------------------------------------------
*/
NS_IMETHODIMP
nsPrintOptionsX::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* [noscript] voidPtr GetNativeData (in short aDataType); */
NS_IMETHODIMP
nsPrintOptionsX::GetNativeData(PRInt16 aDataType, void * *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
#pragma mark -
nsresult
nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags)
{
nsresult rv;
rv = nsPrintOptions::ReadPrefs(aPS, aPrinterName, aFlags);
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::ReadPrefs() failed");
nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
if (!printSettingsX)
return NS_ERROR_NO_INTERFACE;
rv = printSettingsX->ReadPageFormatFromPrefs();
NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::ReadPageFormatFromPrefs() failed");
return NS_OK;
}
nsresult
nsPrintOptionsX::WritePrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags)
{
nsresult rv;
rv = nsPrintOptions::WritePrefs(aPS, aPrinterName, aFlags);
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::WritePrefs() failed");
nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
if (!printSettingsX)
return NS_ERROR_NO_INTERFACE;
rv = printSettingsX->WritePageFormatToPrefs();
NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::WritePageFormatToPrefs() failed");
return NS_OK;
}

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

@ -45,13 +45,78 @@
#include "plbase64.h"
#include "prmem.h"
#include "nsGfxUtils.h"
// Constants
#define PRINTING_PREF_BRANCH "print."
#define MAC_OS_X_PAGE_SETUP_PREFNAME "macosx.pagesetup"
/** ------------------------------------------------------------
* Utility class stack-based handle ownership
*/
class StHandleOwner
{
public:
StHandleOwner(Handle inHandle)
: mHandle(inHandle)
{
}
~StHandleOwner()
{
if (mHandle)
::DisposeHandle(mHandle);
}
Handle GetHandle() { return mHandle; }
void ClearHandle(Boolean disposeIt = false)
{
if (disposeIt)
::DisposeHandle(mHandle);
mHandle = nsnull;
}
protected:
Handle mHandle;
};
/** ------------------------------------------------------------
* Utility class for saving, locking, and restoring handle state
* Ok with null handle
*/
class StHandleLocker
{
public:
StHandleLocker(Handle theHandle)
: mHandle(theHandle)
{
if (mHandle)
{
mOldHandleState = ::HGetState(mHandle);
::HLock(mHandle);
}
}
~StHandleLocker()
{
if (mHandle)
::HSetState(mHandle, mOldHandleState);
}
protected:
Handle mHandle;
SInt8 mOldHandleState;
};
NS_IMPL_ISUPPORTS_INHERITED1(nsPrintSettingsX,
nsPrintSettings,
nsIPrintSettingsX)

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

@ -37,7 +37,6 @@
#include "nsStylClipboardUtils.h"
#include "nsMemory.h"
#include "nsCarbonHelpers.h"
#include <Appearance.h>