From 163e763cde7301bfc9250d9ee47a183ba05455c3 Mon Sep 17 00:00:00 2001 From: "joshmoz%gmail.com" Date: Tue, 19 Dec 2006 20:47:53 +0000 Subject: [PATCH] Remove non-cairo gfx support from cocoa widgets. This isn't going to work soon anyway, camino can't build without cairo already, and it is a lot of clutter. Carbon widgets will still build with non-cairo gfx. b=364379 r=smorgan r=mento sr=pinkerton git-svn-id: svn://10.0.0.236/trunk@217211 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/cocoa/Makefile.in | 22 +- mozilla/widget/src/cocoa/nsChildView.h | 34 +-- mozilla/widget/src/cocoa/nsChildView.mm | 207 +----------------- mozilla/widget/src/cocoa/nsClipboard.mm | 25 +-- mozilla/widget/src/cocoa/nsDragService.mm | 35 +-- .../widget/src/cocoa/nsNativeThemeCocoa.cpp | 27 --- mozilla/widget/src/cocoa/nsToolkit.h | 21 -- mozilla/widget/src/cocoa/nsToolkit.mm | 83 ------- mozilla/widget/src/cocoa/nsWidgetFactory.mm | 12 - 9 files changed, 21 insertions(+), 445 deletions(-) diff --git a/mozilla/widget/src/cocoa/Makefile.in b/mozilla/widget/src/cocoa/Makefile.in index 1d88efe14bb..c46a6fd75d7 100644 --- a/mozilla/widget/src/cocoa/Makefile.in +++ b/mozilla/widget/src/cocoa/Makefile.in @@ -72,15 +72,13 @@ REQUIRES = xpcom \ unicharutil \ exthandler \ appshell \ + thebes \ + cairo \ $(NULL) -ifdef MOZ_ENABLE_CAIRO_GFX -REQUIRES += thebes cairo - ifdef MOZ_ENABLE_GLITZ REQUIRES += glitz glitzagl endif -endif ifdef ACCESSIBILITY REQUIRES += accessibility @@ -97,20 +95,11 @@ MAC_LCPPSRCS = \ nsPrintSessionX.cpp \ $(NULL) - -ifndef MOZ_ENABLE_CAIRO_GFX -MAC_LCPPSRCS += nsNativeThemeMac.cpp \ - $(NULL) -endif - CPPSRCS = \ $(MAC_LCPPSRCS) \ + nsNativeThemeCocoa.cpp \ $(NULL) -ifdef MOZ_ENABLE_CAIRO_GFX -CPPSRCS += nsNativeThemeCocoa.cpp -endif - CMMSRCS = \ nsBidiKeyboard.mm \ nsClipboard.mm \ @@ -150,12 +139,9 @@ EXTRA_DSO_LDOPTS += \ $(TK_LIBS) \ $(call EXPAND_LIBNAME_PATH,gkgfx,$(DEPTH)/gfx/src) \ $(MOZ_COMPONENT_LIBS) \ + -lthebes \ $(NULL) -ifdef MOZ_ENABLE_CAIRO_GFX -EXTRA_DSO_LDOPTS += -lthebes -endif - GARBAGE += $(GFX_LCPPSRCS) $(MAC_LCPPSRCS) include $(topsrcdir)/config/rules.mk diff --git a/mozilla/widget/src/cocoa/nsChildView.h b/mozilla/widget/src/cocoa/nsChildView.h index 7ac1f18958a..8ac29bec2dd 100644 --- a/mozilla/widget/src/cocoa/nsChildView.h +++ b/mozilla/widget/src/cocoa/nsChildView.h @@ -65,10 +65,7 @@ #include "nsplugindefs.h" #include - -#ifdef MOZ_CAIRO_GFX class gfxASurface; -#endif #define NSRGB_2_COLOREF(color) \ RGB(NS_GET_R(color),NS_GET_G(color),NS_GET_B(color)) @@ -80,18 +77,11 @@ struct nsPluginPort; class nsChildView; -// Depending on whether we're on cairo, and if accessibility is on, we support different @protocols -// and have a different superclass. -@interface ChildView : -#ifdef MOZ_CAIRO_GFX - NSView< -#else - NSQuickDrawView< -#endif +@interface ChildView : NSView< #ifdef ACCESSIBILITY - mozAccessible, + mozAccessible, #endif - mozView, NSTextInput> + mozView, NSTextInput> { @private NSWindow* mWindow; // shortcut to the top window, [WEAK] @@ -243,11 +233,6 @@ 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, nsIRegion *aRegion); -#endif NS_IMETHOD Update(); virtual void ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY); @@ -292,9 +277,8 @@ public: void GetDocumentAccessible(nsIAccessible** aAccessible); #endif -#ifdef MOZ_CAIRO_GFX virtual gfxASurface* GetThebesSurface(); -#endif + protected: PRBool ReportDestroyEvent(); @@ -324,22 +308,14 @@ protected: NSView* mParentView; nsIWidget* mParentWidget; - -#ifndef MOZ_CAIRO_GFX - nsCOMPtr mFontMetrics; - nsCOMPtr mTempRenderingContext; - PRPackedBool mTempRenderingContextMadeHere; -#endif - + #ifdef ACCESSIBILITY // weak ref to this childview's associated mozAccessible for speed reasons // (we get queried for it *a lot* but don't want to own it) nsWeakPtr mAccessible; #endif -#ifdef MOZ_CAIRO_GFX nsRefPtr mTempThebesSurface; -#endif PRPackedBool mDestructorCalled; PRPackedBool mVisible; diff --git a/mozilla/widget/src/cocoa/nsChildView.mm b/mozilla/widget/src/cocoa/nsChildView.mm index c45c33f8f59..8079d3ed259 100644 --- a/mozilla/widget/src/cocoa/nsChildView.mm +++ b/mozilla/widget/src/cocoa/nsChildView.mm @@ -68,7 +68,6 @@ static NS_DEFINE_CID(kRegionCID, NS_REGION_CID); -#ifdef MOZ_CAIRO_GFX #include "gfxContext.h" #include "gfxQuartzSurface.h" @@ -80,10 +79,6 @@ CG_EXTERN void CGContextResetClip (CGContextRef); #undef DEBUG_UPDATE -#else -#include "nsGfxUtils.h" // for StPortSetter -#endif - #ifdef ACCESSIBILITY #include "nsIAccessible.h" @@ -337,9 +332,6 @@ nsChildView::nsChildView() : nsBaseWidget() , mView(nsnull) , mParentView(nsnull) , mParentWidget(nsnull) -#ifndef MOZ_CAIRO_GFX -, mTempRenderingContextMadeHere(PR_FALSE) -#endif , mDestructorCalled(PR_FALSE) , mVisible(PR_FALSE) , mDrawing(PR_FALSE) @@ -757,11 +749,7 @@ NS_IMETHODIMP nsChildView::SetFocus(PRBool aRaise) //------------------------------------------------------------------------- nsIFontMetrics* nsChildView::GetFont(void) { -#ifdef MOZ_CAIRO_GFX return nsnull; -#else - return mFontMetrics; -#endif } @@ -772,14 +760,7 @@ nsIFontMetrics* nsChildView::GetFont(void) //------------------------------------------------------------------------- NS_IMETHODIMP nsChildView::SetFont(const nsFont &aFont) { -#ifdef MOZ_CAIRO_GFX return NS_ERROR_NOT_IMPLEMENTED; -#else - mFontMetrics = nsnull; - if (mContext) - mContext->GetMetricsFor(aFont, *getter_AddRefs(mFontMetrics)); - return NS_OK; -#endif } @@ -1274,77 +1255,6 @@ inline PRUint16 COLOR8TOCOLOR16(PRUint8 color8) } -#ifndef MOZ_CAIRO_GFX -//------------------------------------------------------------------------- -// StartDraw -// -//------------------------------------------------------------------------- -void nsChildView::StartDraw(nsIRenderingContext* aRenderingContext) -{ - if (mDrawing) - return; - mDrawing = PR_TRUE; - - if (aRenderingContext == nsnull) { - // make sure we have a rendering context - mTempRenderingContext = getter_AddRefs(GetRenderingContext()); - mTempRenderingContextMadeHere = PR_TRUE; - } - else { - // if we already have a rendering context, save its state - mTempRenderingContext = aRenderingContext; - mTempRenderingContextMadeHere = PR_FALSE; - mTempRenderingContext->PushState(); - - // set the environment to the current widget - mTempRenderingContext->Init(mContext, this); - } - - // set the widget font. nsMacControl implements SetFont, which is where - // the font should get set. - if (mFontMetrics) { - mTempRenderingContext->SetFont(mFontMetrics); - } - - // set the widget background and foreground colors - nscolor color = GetBackgroundColor(); - RGBColor macColor; - macColor.red = COLOR8TOCOLOR16(NS_GET_R(color)); - macColor.green = COLOR8TOCOLOR16(NS_GET_G(color)); - macColor.blue = COLOR8TOCOLOR16(NS_GET_B(color)); - ::RGBBackColor(&macColor); - - color = GetForegroundColor(); - macColor.red = COLOR8TOCOLOR16(NS_GET_R(color)); - macColor.green = COLOR8TOCOLOR16(NS_GET_G(color)); - macColor.blue = COLOR8TOCOLOR16(NS_GET_B(color)); - ::RGBForeColor(&macColor); - - mTempRenderingContext->SetColor(color); // just in case, set the rendering context color too -} - - -//------------------------------------------------------------------------- -// EndDraw -// -//------------------------------------------------------------------------- -void nsChildView::EndDraw() -{ - if (!mDrawing) - return; - mDrawing = PR_FALSE; - - if (mTempRenderingContextMadeHere) - mTempRenderingContext->PopState(); - - mTempRenderingContext = nsnull; -} -#endif /* MOZ_CAIRO_GFX */ - -//------------------------------------------------------------------------- -// -// -//------------------------------------------------------------------------- void nsChildView::Flash(nsPaintEvent &aEvent) { @@ -1392,54 +1302,6 @@ NS_IMETHODIMP nsChildView::Update() #pragma mark - -#ifndef MOZ_CAIRO_GFX -// -// UpdateWidget -// -// Dispatches the Paint event into Gecko. Usually called from our -// NSView in response to the display system noticing that something -// needs repainting. We don't have to worry about painting our child views -// because the display system will take care of that for us. -// -void -nsChildView::UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext, nsIRegion *aRegion) -{ - if (! mVisible) - return; - - // For updating widgets, we _always_ want to use the NSQuickDrawView's port, - // since that's the correct port for gecko to use to make rendering contexts. - // The plugin is the only thing that uses the plugin port. - GrafPtr curPort = GetChildViewQuickDrawPort(); - if (!curPort) return; - - StPortSetter port(curPort); - - // initialize the paint event - nsPaintEvent paintEvent(PR_TRUE, NS_PAINT, this); - paintEvent.renderingContext = aContext; // nsPaintEvent - paintEvent.rect = &aRect; - paintEvent.region = aRegion; - - // offscreen drawing is pointless. - if (paintEvent.rect->x < 0) - paintEvent.rect->x = 0; - if (paintEvent.rect->y < 0) - paintEvent.rect->y = 0; - - // draw the widget - StartDraw(aContext); - if ( OnPaint(paintEvent) ) { - nsEventStatus eventStatus; - DispatchWindowEvent(paintEvent,eventStatus); - if(eventStatus != nsEventStatus_eIgnore) - Flash(paintEvent); - } - EndDraw(); -} -#endif - - // // Scroll // @@ -1611,7 +1473,7 @@ NS_IMETHODIMP nsChildView::DispatchEvent(nsGUIEvent* event, nsEventStatus& aStat return NS_OK; } -//------------------------------------------------------------------------- + PRBool nsChildView::DispatchWindowEvent(nsGUIEvent &event) { nsEventStatus status; @@ -1619,18 +1481,15 @@ PRBool nsChildView::DispatchWindowEvent(nsGUIEvent &event) return ConvertStatus(status); } -//------------------------------------------------------------------------- + PRBool nsChildView::DispatchWindowEvent(nsGUIEvent &event,nsEventStatus &aStatus) { DispatchEvent(&event, aStatus); return ConvertStatus(aStatus); } -//------------------------------------------------------------------------- -// + // Deal with all sort of mouse event -// -//------------------------------------------------------------------------- PRBool nsChildView::DispatchMouseEvent(nsMouseEvent &aEvent) { PRBool result = PR_FALSE; @@ -1659,12 +1518,10 @@ PRBool nsChildView::DispatchMouseEvent(nsMouseEvent &aEvent) return result; } + #pragma mark - -//------------------------------------------------------------------------- -// -// -//------------------------------------------------------------------------- + PRBool nsChildView::ReportDestroyEvent() { // nsEvent @@ -1675,10 +1532,7 @@ PRBool nsChildView::ReportDestroyEvent() return (DispatchWindowEvent(event)); } -//------------------------------------------------------------------------- -// -// -//------------------------------------------------------------------------- + PRBool nsChildView::ReportMoveEvent() { // nsEvent @@ -1691,10 +1545,7 @@ PRBool nsChildView::ReportMoveEvent() return (DispatchWindowEvent(moveEvent)); } -//------------------------------------------------------------------------- -// -// -//------------------------------------------------------------------------- + PRBool nsChildView::ReportSizeEvent() { // nsEvent @@ -1711,29 +1562,21 @@ PRBool nsChildView::ReportSizeEvent() } - #pragma mark - -//------------------------------------------------------------------------- -// -// -//------------------------------------------------------------------------- void nsChildView::CalcWindowRegions() { // i don't think this is necessary anymore... } - -//------------------------------------------------------------------------- /* Calculate the x and y offsets for this particular widget * @update ps 09/22/98 * @param aX -- x offset amount * @param aY -- y offset amount * @return NOTHING */ - NS_IMETHODIMP nsChildView::CalcOffset(PRInt32 &aX,PRInt32 &aY) { aX = aY = 0; @@ -1746,10 +1589,7 @@ NS_IMETHODIMP nsChildView::CalcOffset(PRInt32 &aX,PRInt32 &aY) } -//------------------------------------------------------------------------- -// PointInWidget -// Find if a point in local coordinates is inside this object -//------------------------------------------------------------------------- +// Find if a point in local coordinates is inside this object PRBool nsChildView::PointInWidget(Point aThePoint) { // get the origin in local coordinates @@ -2043,7 +1883,7 @@ nsChildView::Idle() return NS_ERROR_NOT_IMPLEMENTED; } -#ifdef MOZ_CAIRO_GFX + gfxASurface* nsChildView::GetThebesSurface() { @@ -2056,7 +1896,7 @@ nsChildView::GetThebesSurface() NS_ADDREF(surf); return surf; } -#endif + #ifdef ACCESSIBILITY void @@ -2363,12 +2203,8 @@ NSEvent* globalDragEvent = nil; // - (BOOL)isOpaque { -#ifdef MOZ_CAIRO_GFX // this will be NO when we can do transparent windows/views return YES; -#else - return mIsPluginView; -#endif } -(void)setIsPluginView:(BOOL)aIsPlugin @@ -2484,7 +2320,6 @@ NSEvent* globalDragEvent = nil; if ([self isRectObscuredBySubview:aRect]) return; -#ifdef MOZ_CAIRO_GFX CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; nsRect geckoBounds; mGeckoChild->GetBounds(geckoBounds); @@ -2563,28 +2398,6 @@ NSEvent* globalDragEvent = nil; CGContextStrokeRect (cgContext, CGRectMake(aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height)); #endif - -#else - /* non-MOZ_CAIRO_GFX */ - nsCOMPtr rgn(do_CreateInstance(kRegionCID)); - if (rgn) { - rgn->Init(); - - nsRect r; - const NSRect *rects; - int count, i; - [self getRectsBeingDrawn:&rects count:&count]; - for (i = 0; i < count; ++i) { - NSRectToGeckoRect(rects[i], r); - rgn->Union(r.x, r.y, r.width, r.height); - } - } - - nsRect fullRect; - NSRectToGeckoRect(aRect, fullRect); - nsCOMPtr rendContext = getter_AddRefs(mGeckoChild->GetRenderingContext()); - mGeckoChild->UpdateWidget(fullRect, rendContext, rgn); -#endif } - (BOOL)isRectObscuredBySubview:(NSRect)inRect diff --git a/mozilla/widget/src/cocoa/nsClipboard.mm b/mozilla/widget/src/cocoa/nsClipboard.mm index f74fec646be..be2357d5e21 100644 --- a/mozilla/widget/src/cocoa/nsClipboard.mm +++ b/mozilla/widget/src/cocoa/nsClipboard.mm @@ -47,10 +47,6 @@ #include "nsMemory.h" #include "nsIImage.h" -#ifndef MOZ_CAIRO_GFX -#include "nsIImageMac.h" -#endif - #include nsClipboard::nsClipboard() : nsBaseClipboard() @@ -103,7 +99,7 @@ nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard) nsCOMPtr primitiveData; ptrPrimitive->GetData(getter_AddRefs(primitiveData)); -#ifdef MOZ_CAIRO_GFX + nsCOMPtr image(do_QueryInterface(primitiveData)); if (!image) { NS_WARNING("Image isn't an nsIImage in transferable"); @@ -154,25 +150,6 @@ nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard) continue; [pasteboardOutputDict setObject:tiffData forKey:NSTIFFPboardType]; -#else - // We have an image, which is in the transferable as an nsIImageMac. Convert it - // to PICT and put those bits on the clipboard. The actual size - // of the picture is the size of the handle, not sizeof(Picture). - nsCOMPtr image = do_QueryInterface(primitiveData); - - if (!image) { - NS_WARNING("Image isn't an nsIImageMac in transferable"); - continue; - } - - PicHandle picture = nsnull; - image->ConvertToPICT(&picture); - if (picture) { - NSData* pictData = [NSData dataWithBytes:*picture length:(::GetHandleSize((Handle)picture))]; - [pasteboardOutputDict setObject:pictData forKey:NSPICTPboardType]; - ::KillPicture(picture); - } -#endif } else { /* If it isn't an image, we just throw the data on the clipboard with the mime string diff --git a/mozilla/widget/src/cocoa/nsDragService.mm b/mozilla/widget/src/cocoa/nsDragService.mm index bea04469a2b..7cc847c5d99 100644 --- a/mozilla/widget/src/cocoa/nsDragService.mm +++ b/mozilla/widget/src/cocoa/nsDragService.mm @@ -61,11 +61,6 @@ #include "nsIView.h" #include "nsIRegion.h" -#ifndef MOZ_CAIRO_GFX -#include "nsIImageMac.h" -#include "nsGfxUtils.h" -#endif - #include extern NSPasteboard* globalDragPboard; @@ -218,7 +213,7 @@ static nsresult SetUpDragClipboard(nsISupportsArray* aTransferableArray) nsCOMPtr primitiveData; ptrPrimitive->GetData(getter_AddRefs(primitiveData)); -#ifdef MOZ_CAIRO_GFX + nsCOMPtr image(do_QueryInterface(primitiveData)); if (!image) { NS_WARNING("Image isn't an nsIImage in transferable"); @@ -269,25 +264,6 @@ static nsresult SetUpDragClipboard(nsISupportsArray* aTransferableArray) continue; [pasteboardOutputDict setObject:tiffData forKey:NSTIFFPboardType]; -#else - // We have an image, which is in the transferable as an nsIImageMac. Convert it - // to PICT and put those bits on the clipboard. The actual size - // of the picture is the size of the handle, not sizeof(Picture). - nsCOMPtr image = do_QueryInterface(primitiveData); - - if (!image) { - NS_WARNING("Image isn't an nsIImageMac in transferable"); - continue; - } - - PicHandle picture = nsnull; - image->ConvertToPICT(&picture); - if (picture) { - NSData* pictData = [NSData dataWithBytes:*picture length:(::GetHandleSize((Handle)picture))]; - [pasteboardOutputDict setObject:pictData forKey:NSPICTPboardType]; - ::KillPicture(picture); - } -#endif } else { /* If it isn't an image, we just throw the data on the clipboard with the mime string @@ -343,15 +319,6 @@ NS_IMETHODIMP nsDragService::InvokeDragSession(nsIDOMNode* aDOMNode, nsISupportsArray* aTransferableArray, nsIScriptableRegion* aDragRgn, PRUint32 aActionType) { -#ifndef MOZ_CAIRO_GFX - nsGraphicsUtils::SetPortToKnownGoodPort(); - GrafPtr port; - GDHandle handle; - ::GetGWorld(&port, &handle); - if (!IsValidPort(port)) - return NS_ERROR_FAILURE; -#endif - nsBaseDragService::InvokeDragSession(aDOMNode, aTransferableArray, aDragRgn, aActionType); // put data on the clipboard diff --git a/mozilla/widget/src/cocoa/nsNativeThemeCocoa.cpp b/mozilla/widget/src/cocoa/nsNativeThemeCocoa.cpp index c85911813d8..fdc87aae3de 100644 --- a/mozilla/widget/src/cocoa/nsNativeThemeCocoa.cpp +++ b/mozilla/widget/src/cocoa/nsNativeThemeCocoa.cpp @@ -56,7 +56,6 @@ #include "nsUnicharUtils.h" #include "nsWidgetAtoms.h" -#ifdef MOZ_CAIRO_GFX #include "gfxContext.h" #include "gfxQuartzSurface.h" @@ -66,13 +65,6 @@ extern "C" { #define HITHEME_ORIENTATION kHIThemeOrientationNormal -#else -/* non-CAIRO */ -#include "nsIDrawingSurfaceMac.h" -#define HITHEME_ORIENTATION kHIThemeOrientationNormal - -#endif - NS_IMPL_ISUPPORTS1(nsNativeThemeCocoa, nsITheme) static PRBool sInitializedBorders = PR_FALSE; @@ -289,7 +281,6 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame // setup to draw into the correct port CGContextRef cgContext; -#ifdef MOZ_CAIRO_GFX nsCOMPtr dctx; aContext->GetDeviceContext(*getter_AddRefs(dctx)); float t2p = dctx->TwipsToDevUnits(); @@ -363,20 +354,6 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame NSTwipsToIntPixels(aRect.height, t2p)); macRect.origin.x -= offsetX; macRect.origin.y -= offsetY; -#else - nsIDrawingSurface* surf; - aContext->GetDrawingSurface(&surf); - nsCOMPtr macSurface(do_QueryInterface(surf)); - cgContext = macSurface->StartQuartzDrawing(); - - // transform rect coordinates to correct coord system - nsTransform2D* transformMatrix; - aContext->GetCurrentTransform(transformMatrix); - nsRect transRect(aRect), transClipRect(aClipRect); - - transformMatrix->TransformCoord(&transRect.x, &transRect.y, &transRect.width, &transRect.height); - CGRect macRect = CGRectMake (transRect.x, transRect.y, transRect.width, transRect.height); -#endif #if 0 fprintf (stderr, " --> macRect %f %f %f %f\n", @@ -633,11 +610,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame break; } -#ifdef MOZ_CAIRO_GFX CGContextRestoreGState(cgContext); -#else - macSurface->EndQuartzDrawing(cgContext); -#endif return NS_OK; } diff --git a/mozilla/widget/src/cocoa/nsToolkit.h b/mozilla/widget/src/cocoa/nsToolkit.h index 17289e4fa9d..223ce345417 100644 --- a/mozilla/widget/src/cocoa/nsToolkit.h +++ b/mozilla/widget/src/cocoa/nsToolkit.h @@ -36,17 +36,8 @@ * * ***** END LICENSE BLOCK ***** */ -// see bug 180535 -#ifndef MOZ_CAIRO_GFX -#define USE_QUARTZ_FONT_PREFS 1 -#endif - #include "nsIToolkit.h" -#ifdef USE_QUARTZ_FONT_PREFS -#include "nsIObserver.h" -#endif - #include /** @@ -77,9 +68,6 @@ #define MAC_OS_X_VERSION_10_4_HEX 0x00001040 class nsToolkit : public nsIToolkit -#ifdef USE_QUARTZ_FONT_PREFS - , public nsIObserver -#endif { public: nsToolkit(); @@ -87,9 +75,6 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSITOOLKIT -#ifdef USE_QUARTZ_FONT_PREFS - NS_DECL_NSIOBSERVER -#endif // Returns the OS X version as returned from Gestalt(gestaltSystemVersion, ...) static long OSXVersion(); @@ -101,12 +86,6 @@ protected: nsresult RegisterForSleepWakeNotifcations(); void RemoveSleepWakeNotifcations(); -#ifdef USE_QUARTZ_FONT_PREFS -protected: - - static void SetupQuartzRendering(); -#endif - protected: bool mInited; diff --git a/mozilla/widget/src/cocoa/nsToolkit.mm b/mozilla/widget/src/cocoa/nsToolkit.mm index be2da3bd69f..216fb67f743 100644 --- a/mozilla/widget/src/cocoa/nsToolkit.mm +++ b/mozilla/widget/src/cocoa/nsToolkit.mm @@ -59,15 +59,6 @@ #include "nsIObserverService.h" #include "nsIServiceManager.h" -#ifdef USE_QUARTZ_FONT_PREFS -#include "nsIPrefBranch2.h" -#include "nsIPrefBranch.h" -#include "nsIPrefService.h" - -static const char kQuartzRenderingPref[] = "browser.quartz.enable"; -static const char kAllFontSizesPref[] = "browser.quartz.enable.all_font_sizes"; -#endif - static io_connect_t gRootPort = MACH_PORT_NULL; // Static thread local storage index of the Toolkit @@ -90,11 +81,7 @@ nsToolkit::~nsToolkit() } -#ifdef USE_QUARTZ_FONT_PREFS -NS_IMPL_THREADSAFE_ISUPPORTS2(nsToolkit, nsIToolkit, nsIObserver); -#else NS_IMPL_THREADSAFE_ISUPPORTS1(nsToolkit, nsIToolkit); -#endif NS_IMETHODIMP @@ -106,33 +93,10 @@ nsToolkit::Init(PRThread * aThread) RegisterForSleepWakeNotifcations(); -#ifdef USE_QUARTZ_FONT_PREFS - SetupQuartzRendering(); - - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (prefs) { - prefs->AddObserver(kQuartzRenderingPref, this, PR_FALSE); - prefs->AddObserver(kAllFontSizesPref, this, PR_FALSE); - } -#endif - return NS_OK; } -#ifdef USE_QUARTZ_FONT_PREFS -// The pref changed, reset the app to use quartz rendering as dictated by the pref -NS_IMETHODIMP -nsToolkit::Observe(nsISupports* aSubject, - const char* aTopic, - const PRUnichar* aData) -{ - SetupQuartzRendering(); - return NS_OK; -} -#endif - - nsToolkit* NS_CreateToolkitInstance() { return new nsToolkit(); @@ -212,53 +176,6 @@ nsToolkit::RemoveSleepWakeNotifcations() } -#ifdef USE_QUARTZ_FONT_PREFS -// SetupQuartzRendering -// -// Use apple's technote for 10.1.5 to turn on quartz rendering with CG metrics. This -// slows us down about 12% when turned on. -void -nsToolkit::SetupQuartzRendering() -{ - // from Apple's technote at http://developer.apple.com/qa/qa2001/qa1193.html - enum { - kQDDontChangeFlags = 0xFFFFFFFF, // don't change anything - kQDUseDefaultTextRendering = 0, // bit 0 - kQDUseTrueTypeScalerGlyphs = (1 << 0), // bit 1 - kQDUseCGTextRendering = (1 << 1), // bit 2 - kQDUseCGTextMetrics = (1 << 2) - }; - - const int kFlagsWeUse = kQDUseCGTextRendering | kQDUseCGTextMetrics; - - // Just turn on the bits that we need, don't turn off what someone else might have wanted. - // If the pref isn't found, assume we want it on. That way, we have to explicitly put - // in a pref to disable it, rather than force everyone who wants it to carry around - // an extra pref. - nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); - if (!prefs) - return; - - PRBool enableQuartz = PR_TRUE; - nsresult rv = prefs->GetBoolPref(kQuartzRenderingPref, &enableQuartz); - UInt32 oldFlags = QDSwapTextFlags(kQDDontChangeFlags); - if (NS_FAILED(rv) || enableQuartz) { - QDSwapTextFlags(oldFlags | kFlagsWeUse); - - // the system defaults to not anti-aliasing small fonts, but some people - // think it looks better that way. If the pref is set, turn them on - PRBool antiAliasAllFontSizes = PR_FALSE; - rv = prefs->GetBoolPref(kAllFontSizesPref, &antiAliasAllFontSizes); - if (NS_SUCCEEDED(rv) && antiAliasAllFontSizes) - SetOutlinePreferred(true); - } - else { - QDSwapTextFlags(oldFlags & ~kFlagsWeUse); - } -} -#endif - - // Return the nsIToolkit for the current thread. If a toolkit does not // yet exist, then one will be created... NS_METHOD NS_GetCurrentToolkit(nsIToolkit* *aResult) diff --git a/mozilla/widget/src/cocoa/nsWidgetFactory.mm b/mozilla/widget/src/cocoa/nsWidgetFactory.mm index 6755f4505d8..fdc8bc7c2df 100644 --- a/mozilla/widget/src/cocoa/nsWidgetFactory.mm +++ b/mozilla/widget/src/cocoa/nsWidgetFactory.mm @@ -92,13 +92,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSessionX, Init) #include "nsBidiKeyboard.h" NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) -#ifdef MOZ_CAIRO_GFX #include "nsNativeThemeCocoa.h" NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeCocoa) -#else -#include "nsNativeThemeMac.h" -NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeMac) -#endif static const nsModuleComponentInfo gComponents[] = { @@ -174,17 +169,10 @@ static const nsModuleComponentInfo gComponents[] = NS_NATIVESCROLLBAR_CID, "@mozilla.org/widget/nativescrollbar;1", nsNativeScrollbarConstructor }, -#ifdef MOZ_CAIRO_GFX { "Native Theme Renderer", NS_THEMERENDERER_CID, "@mozilla.org/chrome/chrome-native-theme;1", nsNativeThemeCocoaConstructor }, -#else - { "Native Theme Renderer", - NS_THEMERENDERER_CID, - "@mozilla.org/chrome/chrome-native-theme;1", - nsNativeThemeMacConstructor }, -#endif { "nsScreenManager", NS_SCREENMANAGER_CID, "@mozilla.org/gfx/screenmanager;1",