backing out previous changes since depend versions of the tree won't build

This commit is contained in:
nhotta%netscape.com 2000-09-29 02:20:25 +00:00
Родитель 75554a6a69
Коммит ecb57dd16d
4 изменённых файлов: 36 добавлений и 223 удалений

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

@ -728,6 +728,7 @@ nsFontMetricsGTK::~nsFontMetricsGTK()
}
mWesternFont = nsnull;
mFontHandle = nsnull;
if (!--gFontMetricsGTKCount) {
FreeGlobals();
@ -892,6 +893,7 @@ NS_IMETHODIMP nsFontMetricsGTK::Init(const nsFont& aFont, nsIAtom* aLangGroup,
if (!mWesternFont) {
return NS_ERROR_FAILURE;
}
mFontHandle = mWesternFont->mFont;
RealizeFont();
@ -908,7 +910,7 @@ void nsFontMetricsGTK::RealizeFont()
{
XFontStruct *fontInfo;
fontInfo = (XFontStruct *)GDK_FONT_XFONT(mWesternFont->GetGDKFont());
fontInfo = (XFontStruct *)GDK_FONT_XFONT(mFontHandle);
float f;
mDeviceContext->GetDevUnitsToAppUnits(f);
@ -934,7 +936,7 @@ void nsFontMetricsGTK::RealizeFont()
// 56% of ascent, best guess for non-true type
mXHeight = NSToCoordRound((float) fontInfo->ascent* f * 0.56f);
gint rawWidth = gdk_text_width(mWesternFont->GetGDKFont(), " ", 1);
gint rawWidth = gdk_text_width(mFontHandle, " ", 1);
mSpaceWidth = NSToCoordRound(rawWidth * f);
unsigned long pr = 0;
@ -1133,7 +1135,7 @@ NS_IMETHODIMP nsFontMetricsGTK::GetLangGroup(nsIAtom** aLangGroup)
NS_IMETHODIMP nsFontMetricsGTK::GetFontHandle(nsFontHandle &aHandle)
{
aHandle = (nsFontHandle)mWesternFont;
aHandle = (nsFontHandle)mFontHandle;
return NS_OK;
}
@ -1670,18 +1672,6 @@ nsFontGTK::LoadFont(void)
}
GdkFont*
nsFontGTK::GetGDKFont(void)
{
return mFont;
}
PRBool
nsFontGTK::GetGDKFontIs10646(void)
{
return ((PRBool) (mCharSetInfo == &ISO106461));
}
MOZ_DECL_CTOR_COUNTER(nsFontGTK);
nsFontGTK::nsFontGTK()
@ -1816,8 +1806,6 @@ public:
nsFontGTKSubstitute(nsFontGTK* aFont);
virtual ~nsFontGTKSubstitute();
virtual GdkFont* GetGDKFont(void);
virtual PRBool GetGDKFontIs10646(void);
virtual gint GetWidth(const PRUnichar* aString, PRUint32 aLength);
virtual gint DrawString(nsRenderingContextGTK* aContext,
nsDrawingSurfaceGTK* aSurface, nscoord aX,
@ -1938,18 +1926,6 @@ nsFontGTKSubstitute::GetBoundingMetrics(const PRUnichar* aString,
}
#endif
GdkFont*
nsFontGTKSubstitute::GetGDKFont(void)
{
return mSubstituteFont->GetGDKFont();
}
PRBool
nsFontGTKSubstitute::GetGDKFontIs10646(void)
{
return mSubstituteFont->GetGDKFontIs10646();
}
class nsFontGTKUserDefined : public nsFontGTK
{
public:
@ -1983,13 +1959,13 @@ nsFontGTKUserDefined::~nsFontGTKUserDefined()
PRBool
nsFontGTKUserDefined::Init(nsFontGTK* aFont)
{
if (!aFont->GetGDKFont()) {
if (!aFont->mFont) {
aFont->LoadFont();
if (!aFont->GetGDKFont()) {
if (!aFont->mFont) {
return PR_FALSE;
}
}
mFont = aFont->GetGDKFont();
mFont = aFont->mFont;
mMap = gUserDefinedMap;
mName = aFont->mName;
@ -2145,7 +2121,7 @@ nsFontMetricsGTK::PickASizeAndLoad(nsFontStretch* aStretch,
font->mMap = aCharSet->mMap;
if (FONT_HAS_GLYPH(font->mMap, aChar)) {
font->LoadFont();
if (!font->GetGDKFont()) {
if (!font->mFont) {
return nsnull;
}
}
@ -2153,7 +2129,7 @@ nsFontMetricsGTK::PickASizeAndLoad(nsFontStretch* aStretch,
else {
if (aCharSet == &ISO106461) {
font->LoadFont();
if (!font->GetGDKFont()) {
if (!font->mFont) {
return nsnull;
}
}
@ -2772,7 +2748,7 @@ GetFontNames(char* aPattern, nsFontNodeArray* aNodes)
}
stretch->mSizes[stretch->mSizesCount++] = size;
size->mName = copy;
// size->mFont is initialized in the constructor
size->mFont = nsnull;
size->mSize = pixels;
size->mBaselineAdjust = 0;
size->mMap = nsnull;

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

@ -67,8 +67,6 @@ public:
inline int SupportsChar(PRUnichar aChar)
{ return mFont && FONT_HAS_GLYPH(mMap, aChar); };
virtual GdkFont* GetGDKFont(void);
virtual PRBool GetGDKFontIs10646(void);
virtual gint GetWidth(const PRUnichar* aString, PRUint32 aLength) = 0;
virtual gint DrawString(nsRenderingContextGTK* aContext,
nsDrawingSurfaceGTK* aSurface, nscoord aX,
@ -84,15 +82,13 @@ public:
nsBoundingMetrics& aBoundingMetrics) = 0;
#endif
GdkFont* mFont;
PRUint32* mMap;
nsFontCharSetInfo* mCharSetInfo;
char* mName;
nsFontGTKUserDefined* mUserDefinedFont;
PRUint16 mSize;
PRInt16 mBaselineAdjust;
protected:
GdkFont* mFont;
};
class nsFontMetricsGTK : public nsIFontMetrics
@ -174,6 +170,7 @@ protected:
nsIDeviceContext *mDeviceContext;
nsFont *mFont;
nsFontGTK *mWesternFont;
GdkFont *mFontHandle;
nscoord mLeading;
nscoord mEmHeight;

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

@ -29,7 +29,6 @@
#include <math.h>
#include "nsGCCache.h"
#include <gtk/gtk.h>
#include "prmem.h"
#define NS_TO_GDK_RGB(ns) (ns & 0xff) << 16 | (ns & 0xff00) | ((ns >> 16) & 0xff)
@ -500,12 +499,13 @@ void nsRenderingContextGTK::UpdateGC()
memset(&values, 0, sizeof(GdkGCValues));
values.font = mCurrentFont;
values.foreground.pixel = gdk_rgb_xpixel_from_rgb(NS_TO_GDK_RGB(mCurrentColor));
valuesMask = GDK_GC_FOREGROUND;
if ((mCurrentFont) && (mCurrentFont->GetGDKFont())) {
if (mCurrentFont) {
valuesMask = GdkGCValuesMask(valuesMask | GDK_GC_FONT);
values.font = mCurrentFont->GetGDKFont();
values.font = mCurrentFont;
}
valuesMask = GdkGCValuesMask(valuesMask | GDK_GC_LINE_STYLE);
@ -645,7 +645,7 @@ NS_IMETHODIMP nsRenderingContextGTK::SetFont(nsIFontMetrics *aFontMetrics)
{
nsFontHandle fontHandle;
mFontMetrics->GetFontHandle(fontHandle);
mCurrentFont = (nsFontGTK*) fontHandle;
mCurrentFont = (GdkFont *)fontHandle;
}
return NS_OK;
@ -1144,74 +1144,6 @@ NS_IMETHODIMP nsRenderingContextGTK::FillArc(nscoord aX, nscoord aY,
return NS_OK;
}
// do the 8 to 16 bit conversion on the stack
// if the data is less than this size
#define WIDEN_8_TO_16_BUF_SIZE 1024
// handle 8 bit data with a 16 bit font
gint
Widen8To16AndMove(const gchar *char_p,
gint char_len,
XChar2b *xchar2b_p)
{
int i;
for (i=0; i<char_len; i++) {
(xchar2b_p)->byte1 = 0;
(xchar2b_p++)->byte2 = *char_p++;
}
return(char_len*2);
}
// handle 8 bit data with a 16 bit font
gint
Widen8To16AndGetWidth (GdkFont *font,
const gchar *text,
gint text_length)
{
XChar2b buf[WIDEN_8_TO_16_BUF_SIZE];
XChar2b *p = buf;
int uchar_size;
gint rawWidth;
if (text_length > WIDEN_8_TO_16_BUF_SIZE) {
p = (XChar2b*)PR_Malloc(text_length*sizeof(XChar2b));
if (!p) return(0); // handle malloc failure
}
uchar_size = Widen8To16AndMove(text, text_length, p);
rawWidth = gdk_text_width(font, (const gchar *)p, uchar_size);
if (text_length > WIDEN_8_TO_16_BUF_SIZE) {
PR_Free((char*)p);
}
return(rawWidth);
}
/* static */ void
nsRenderingContextGTK::Widen8To16AndDraw (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *text,
gint text_length)
{
XChar2b buf[WIDEN_8_TO_16_BUF_SIZE];
XChar2b *p = buf;
int uchar_size;
if (text_length > WIDEN_8_TO_16_BUF_SIZE) {
p = (XChar2b*)PR_Malloc(text_length*sizeof(XChar2b));
if (!p) return; // handle malloc failure
}
uchar_size = Widen8To16AndMove(text, text_length, p);
my_gdk_draw_text(drawable, font, gc, x, y, (const gchar *)p, uchar_size);
if (text_length > WIDEN_8_TO_16_BUF_SIZE) {
PR_Free((char*)p);
}
}
NS_IMETHODIMP
nsRenderingContextGTK::GetWidth(char aC, nscoord &aWidth)
@ -1254,16 +1186,7 @@ nsRenderingContextGTK::GetWidth(const char* aString, PRUint32 aLength,
}
else {
g_return_val_if_fail(aString != NULL, NS_ERROR_FAILURE);
g_return_val_if_fail(mCurrentFont != NULL, NS_ERROR_FAILURE);
gint rawWidth;
if (!mCurrentFont->GetGDKFontIs10646()) {
// 8 bit data with an 8 bit font
rawWidth = gdk_text_width (mCurrentFont->GetGDKFont(), aString, aLength);
}
else {
// we have 8 bit data but a 16 bit font
rawWidth = Widen8To16AndGetWidth (mCurrentFont->GetGDKFont(), aString, aLength);
}
gint rawWidth = gdk_text_width (mCurrentFont, aString, aLength);
aWidth = NSToCoordRound(rawWidth * mP2T);
}
return NS_OK;
@ -1333,7 +1256,6 @@ nsRenderingContextGTK::DrawString(const char *aString, PRUint32 aLength,
g_return_val_if_fail(mTranMatrix != NULL, NS_ERROR_FAILURE);
g_return_val_if_fail(mSurface != NULL, NS_ERROR_FAILURE);
g_return_val_if_fail(aString != NULL, NS_ERROR_FAILURE);
g_return_val_if_fail(mCurrentFont != NULL, NS_ERROR_FAILURE);
nscoord x = aX;
nscoord y = aY;
@ -1354,33 +1276,17 @@ nsRenderingContextGTK::DrawString(const char *aString, PRUint32 aLength,
nscoord xx = x;
nscoord yy = y;
mTranMatrix->TransformCoord(&xx, &yy);
if (!mCurrentFont->GetGDKFontIs10646()) {
// 8 bit data with an 8 bit font
nsRenderingContextGTK::my_gdk_draw_text(mSurface->GetDrawable(),
mCurrentFont->GetGDKFont(), mGC,
nsRenderingContextGTK::my_gdk_draw_text(mSurface->GetDrawable(), mCurrentFont,
mGC,
xx, yy, &ch, 1);
}
else {
// we have 8 bit data but a 16 bit font
Widen8To16AndDraw(mSurface->GetDrawable(), mCurrentFont->GetGDKFont(), mGC,
xx, yy, &ch, 1);
}
x += *aSpacing++;
}
}
else {
mTranMatrix->TransformCoord(&x, &y);
if (!mCurrentFont->GetGDKFontIs10646()) { // keep 8 bit path fast
// 8 bit data with an 8 bit font
nsRenderingContextGTK::my_gdk_draw_text (mSurface->GetDrawable(),
mCurrentFont->GetGDKFont(), mGC,
x, y, aString, aLength);
}
else {
// we have 8 bit data but a 16 bit font
Widen8To16AndDraw(mSurface->GetDrawable(), mCurrentFont->GetGDKFont(), mGC,
nsRenderingContextGTK::my_gdk_draw_text (mSurface->GetDrawable(), mCurrentFont,
mGC,
x, y, aString, aLength);
}
}
}
@ -1468,8 +1374,8 @@ FoundFont:
const PRUnichar* end = &aString[i];
// save off mCurrentFont and set it so that we cache the GC's font correctly
nsFontGTK *oldFont = mCurrentFont;
mCurrentFont = prevFont;
GdkFont *oldFont = mCurrentFont;
mCurrentFont = prevFont->mFont;
UpdateGC();
while (str < end) {
@ -1483,8 +1389,8 @@ FoundFont:
mCurrentFont = oldFont;
}
else {
nsFontGTK *oldFont = mCurrentFont;
mCurrentFont = prevFont;
GdkFont *oldFont = mCurrentFont;
mCurrentFont = prevFont->mFont;
UpdateGC();
x += prevFont->DrawString(this, mSurface, x, y, &aString[start],
i - start);
@ -1502,8 +1408,8 @@ FoundFont:
if (prevFont) {
nsFontGTK *oldFont = mCurrentFont;
mCurrentFont = prevFont;
GdkFont *oldFont = mCurrentFont;
mCurrentFont = prevFont->mFont;
UpdateGC();
if (aSpacing) {
@ -1760,49 +1666,6 @@ NS_IMETHODIMP nsRenderingContextGTK::RetrieveCurrentNativeGraphicData(PRUint32 *
#ifdef MOZ_MATHML
// bstell Sept. 22, 2000:
// added code to handle displaying 8 bit data using a 16 bit font.
// have not tested the MOZ_MATHML code path
void
Widen8To16AndGetTextExtents (GdkFont *font,
const gchar *text,
gint text_length,
gint *lbearing,
gint *rbearing,
gint *width,
gint *ascent,
gint *descent)
{
XChar2b buf[WIDEN_8_TO_16_BUF_SIZE];
XChar2b *p = buf;
int uchar_size;
if (text_length > WIDEN_8_TO_16_BUF_SIZE) {
p = (XChar2b*)PR_Malloc(text_length*sizeof(XChar2b));
if (!p) { // handle malloc failure
*lbearing = 0;
*rbearing = 0;
*width = 0;
*ascent = 0;
*descent = 0;
return;
}
}
uchar_size = Widen8To16AndMove(text, text_length, p);
gdk_text_extents (font, (const char*)p, uchar_size,
lbearing,
rbearing,
width,
ascent,
descent);
if (text_length > WIDEN_8_TO_16_BUF_SIZE) {
PR_Free((char*)p);
}
}
NS_IMETHODIMP
nsRenderingContextGTK::GetBoundingMetrics(const char* aString,
PRUint32 aLength,
@ -1811,25 +1674,12 @@ nsRenderingContextGTK::GetBoundingMetrics(const char* aString,
aBoundingMetrics.Clear();
if (aString && 0 < aLength) {
g_return_val_if_fail(aString != NULL, NS_ERROR_FAILURE);
g_return_val_if_fail(mCurrentFont != NULL, NS_ERROR_FAILURE);
if (!mCurrentFont->GetGDKFontIs10646()) {
// 8 bit data with an 8 bit font
gdk_text_extents (mCurrentFont->GetGDKFont(), aString, aLength,
&aBoundingMetrics.leftBearing,
&aBoundingMetrics.rightBearing,
&aBoundingMetrics.width,
&aBoundingMetrics.ascent,
&aBoundingMetrics.descent);
}
else {
// we have 8 bit data but a 16 bit font
Widen8To16AndGetTextExtents (mCurrentFont->GetGDKFont(), aString, aLength,
&aBoundingMetrics.leftBearing,
&aBoundingMetrics.rightBearing,
&aBoundingMetrics.width,
&aBoundingMetrics.ascent,
&aBoundingMetrics.descent);
}
gdk_text_extents (mCurrentFont, aString, aLength,
&aBoundingMetrics.leftBearing,
&aBoundingMetrics.rightBearing,
&aBoundingMetrics.width,
&aBoundingMetrics.ascent,
&aBoundingMetrics.descent);
aBoundingMetrics.leftBearing = NSToCoordRound(aBoundingMetrics.leftBearing * mP2T);
aBoundingMetrics.rightBearing = NSToCoordRound(aBoundingMetrics.rightBearing * mP2T);
@ -1919,6 +1769,7 @@ nsRenderingContextGTK::GetBoundingMetrics(const PRUnichar* aString,
#endif /* MOZ_MATHML */
/* static */ void
nsRenderingContextGTK::my_gdk_draw_text (GdkDrawable *drawable,
GdkFont *font,

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

@ -44,8 +44,6 @@
#define USE_NATIVE_TILING 1
class nsFontGTK;
class nsRenderingContextGTK : public nsRenderingContextImpl
{
public:
@ -207,15 +205,6 @@ public:
GdkGC *GetGC() { return gdk_gc_ref(mGC); }
// handle drawing 8 bit data with a 16 bit font
static void Widen8To16AndDraw(GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *text,
gint text_length);
// replacment for gdk_draw_text that doesn't do XSetFont
static void my_gdk_draw_text(GdkDrawable *drawable,
GdkFont *font,
@ -244,7 +233,7 @@ private:
gchar *mDashList;
gint mDashes;
nscolor mCurrentColor;
nsFontGTK *mCurrentFont;
GdkFont *mCurrentFont;
nsLineStyle mCurrentLineStyle;
void UpdateGC();