mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-18 14:56:07 +00:00
Replacing TARGET_CARBON ifdefs with inline functions in nsCarbonHelpers.h to make code more readable.
This commit is contained in:
parent
71d28f9b6d
commit
13f4b1427e
@ -38,6 +38,7 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsQuickSort.h"
|
||||
#include "nsUnicodeMappingUtil.h"
|
||||
#include "nsCarbonHelpers.h"
|
||||
|
||||
|
||||
PRUint32 nsDeviceContextMac::mPixelsPerInch = 96;
|
||||
@ -330,8 +331,8 @@ NS_IMETHODIMP nsDeviceContextMac :: CheckFontExistence(const nsString& aFontName
|
||||
NS_IMETHODIMP nsDeviceContextMac::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight)
|
||||
{
|
||||
// FIXME: could just union all of the GDevice rectangles together.
|
||||
RgnHandle grayRgn = ::GetGrayRgn();
|
||||
Rect bounds = (**grayRgn).rgnBBox;
|
||||
Rect bounds;
|
||||
::GetRegionBounds ( ::GetGrayRgn(), &bounds );
|
||||
//aWidth = bounds.right - bounds.left;
|
||||
//aHeight = bounds.bottom - bounds.top;
|
||||
|
||||
@ -352,8 +353,8 @@ NS_IMETHODIMP nsDeviceContextMac::GetClientRect(nsRect &aRect)
|
||||
{
|
||||
// FIXME: equally as broken as GetDeviceSurfaceDimensions,
|
||||
// this doesn't do what you want with multiple screens.
|
||||
RgnHandle grayRgn = ::GetGrayRgn();
|
||||
Rect bounds = (**grayRgn).rgnBBox;
|
||||
Rect bounds;
|
||||
::GetRegionBounds ( ::GetGrayRgn(), &bounds );
|
||||
|
||||
aRect.x = NSToIntRound(bounds.left * mDevUnitsToAppUnits);
|
||||
aRect.y = NSToIntRound(bounds.top * mDevUnitsToAppUnits);
|
||||
|
@ -38,31 +38,10 @@
|
||||
|
||||
#include <FixMath.h>
|
||||
#include <Gestalt.h>
|
||||
#include "nsCarbonHelpers.h"
|
||||
|
||||
#define STACK_TREASHOLD 1000
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Carbon compatible accessor functions
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#if !TARGET_CARBON
|
||||
|
||||
inline void GetPortClipRegion(GrafPtr port, RgnHandle clipRgn)
|
||||
{
|
||||
::CopyRgn(port->clipRgn, clipRgn);
|
||||
}
|
||||
|
||||
inline void GetPortBounds(GrafPtr port, Rect* portRect)
|
||||
{
|
||||
*portRect = port->portRect;
|
||||
}
|
||||
|
||||
inline void SetPortWindowPort(WindowRef window)
|
||||
{
|
||||
::SetPort(window);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// utility port setting class
|
||||
@ -666,11 +645,7 @@ NS_IMETHODIMP nsRenderingContextMac::GetClipRect(nsRect &aRect, PRBool &aClipVal
|
||||
Rect cliprect;
|
||||
|
||||
if (mGS->mClipRegion != nsnull) {
|
||||
#if TARGET_CARBON
|
||||
::GetRegionBounds(mGS->mClipRegion, &cliprect);
|
||||
#else
|
||||
cliprect = (**mGS->mClipRegion).rgnBBox;
|
||||
#endif
|
||||
aRect.SetRect(cliprect.left, cliprect.top, cliprect.right - cliprect.left, cliprect.bottom - cliprect.top);
|
||||
aClipValid = PR_TRUE;
|
||||
} else {
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "nsFontMetricsMac.h"
|
||||
#include "nsGraphicState.h"
|
||||
#include "prprf.h"
|
||||
#include "nsCarbonHelpers.h"
|
||||
|
||||
#define BAD_FONT_NUM -1
|
||||
#define BAD_SCRIPT 0x7F
|
||||
@ -281,17 +282,13 @@ PRBool nsUnicodeRenderingToolkit :: QuestionMarkFallbackGetWidth(
|
||||
const PRUnichar *aCharPt,
|
||||
short& oWidth)
|
||||
{
|
||||
GrafPtr thePort;
|
||||
::GetPort(&thePort);
|
||||
#if TARGET_CARBON
|
||||
short saveSize = GetPortTextSize(thePort);
|
||||
#else
|
||||
short saveSize = thePort->txSize;
|
||||
#endif
|
||||
::TextSize(QUESTION_FALLBACKSIZE);
|
||||
GetScriptTextWidth(question, 3,oWidth);
|
||||
::TextSize(saveSize);
|
||||
return PR_TRUE;
|
||||
GrafPtr thePort;
|
||||
::GetPort(&thePort);
|
||||
short saveSize = ::GetPortTextSize(thePort);
|
||||
::TextSize(QUESTION_FALLBACKSIZE);
|
||||
GetScriptTextWidth(question, 3,oWidth);
|
||||
::TextSize(saveSize);
|
||||
return PR_TRUE;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
@ -301,17 +298,13 @@ PRBool nsUnicodeRenderingToolkit :: QuestionMarkFallbackDrawChar(
|
||||
PRInt32 y,
|
||||
short& oWidth)
|
||||
{
|
||||
GrafPtr thePort;
|
||||
::GetPort(&thePort);
|
||||
#if TARGET_CARBON
|
||||
short saveSize = GetPortTextSize(thePort);
|
||||
#else
|
||||
short saveSize = thePort->txSize;
|
||||
#endif
|
||||
::TextSize(QUESTION_FALLBACKSIZE);
|
||||
DrawScriptText(question, 3, x, y, oWidth);
|
||||
::TextSize(saveSize);
|
||||
return PR_TRUE;
|
||||
GrafPtr thePort;
|
||||
::GetPort(&thePort);
|
||||
short saveSize = ::GetPortTextSize(thePort);
|
||||
::TextSize(QUESTION_FALLBACKSIZE);
|
||||
DrawScriptText(question, 3, x, y, oWidth);
|
||||
::TextSize(saveSize);
|
||||
return PR_TRUE;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
@ -319,20 +312,16 @@ PRBool nsUnicodeRenderingToolkit :: UPlusFallbackGetWidth(
|
||||
const PRUnichar *aCharPt,
|
||||
short& oWidth)
|
||||
{
|
||||
GrafPtr thePort;
|
||||
::GetPort(&thePort);
|
||||
#if TARGET_CARBON
|
||||
short saveSize = GetPortTextSize(thePort);
|
||||
#else
|
||||
short saveSize = thePort->txSize;
|
||||
#endif
|
||||
char buf[16];
|
||||
PRUint32 len = PR_snprintf(buf, 16 , "<U+%04X>", *aCharPt);
|
||||
::TextSize(UPLUS_FALLBACKSIZE);
|
||||
if(len != -1)
|
||||
GetScriptTextWidth(buf, len, oWidth);
|
||||
::TextSize(saveSize);
|
||||
return (-1 != len);
|
||||
GrafPtr thePort;
|
||||
::GetPort(&thePort);
|
||||
short saveSize = ::GetPortTextSize(thePort);
|
||||
char buf[16];
|
||||
PRUint32 len = PR_snprintf(buf, 16 , "<U+%04X>", *aCharPt);
|
||||
::TextSize(UPLUS_FALLBACKSIZE);
|
||||
if(len != -1)
|
||||
GetScriptTextWidth(buf, len, oWidth);
|
||||
::TextSize(saveSize);
|
||||
return (-1 != len);
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
@ -342,20 +331,16 @@ PRBool nsUnicodeRenderingToolkit :: UPlusFallbackDrawChar(
|
||||
PRInt32 y,
|
||||
short& oWidth)
|
||||
{
|
||||
GrafPtr thePort;
|
||||
::GetPort(&thePort);
|
||||
#if TARGET_CARBON
|
||||
short saveSize = GetPortTextSize(thePort);
|
||||
#else
|
||||
short saveSize = thePort->txSize;
|
||||
#endif
|
||||
char buf[16];
|
||||
PRUint32 len = PR_snprintf(buf, 16 , "<U+%04X>", *aCharPt);
|
||||
::TextSize(UPLUS_FALLBACKSIZE);
|
||||
if(len != -1)
|
||||
DrawScriptText(buf, len, x, y, oWidth);
|
||||
::TextSize(saveSize);
|
||||
return (-1 != len);
|
||||
GrafPtr thePort;
|
||||
::GetPort(&thePort);
|
||||
short saveSize = ::GetPortTextSize(thePort);
|
||||
char buf[16];
|
||||
PRUint32 len = PR_snprintf(buf, 16 , "<U+%04X>", *aCharPt);
|
||||
::TextSize(UPLUS_FALLBACKSIZE);
|
||||
if(len != -1)
|
||||
DrawScriptText(buf, len, x, y, oWidth);
|
||||
::TextSize(saveSize);
|
||||
return (-1 != len);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user