gcc 4 fixes for Mac OS X. part 1 of the landing. Patch by Mark Mentovai. b=294244 r=josh sr=darin a=dbaron

This commit is contained in:
joshmoz%gmail.com 2005-06-15 03:49:26 +00:00
Родитель afb2de0edc
Коммит 701969ba26
5 изменённых файлов: 24 добавлений и 250 удалений

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

@ -915,7 +915,7 @@ bool nsDeviceContextMac :: GetMacFontNumber(const nsString& aFontName, short &aF
// fontNum, nsFontMetricsMac::SetFont() wouldn't need to call this at all.
InitFontInfoList();
FontNameKey key(aFontName);
aFontNum = (short)gFontInfoList->Get(&key);
aFontNum = (short) NS_PTR_TO_INT32(gFontInfoList->Get(&key));
return (aFontNum != 0);
}
@ -1116,7 +1116,7 @@ EnumerateFont(nsHashKey *aKey, void *aData, void* closure)
PRBool match = PR_FALSE;
#if TARGET_CARBON
// we need to match the cast of FMFontFamily in nsDeviceContextMac :: InitFontInfoList()
FMFontFamily fontFamily = (FMFontFamily) aData;
FMFontFamily fontFamily = (FMFontFamily) NS_PTR_TO_INT32(aData);
TextEncoding fontEncoding;
OSStatus status = ::FMGetFontFamilyTextEncoding(fontFamily, &fontEncoding);
if (noErr == status) {

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

@ -1,119 +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):
*
* 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 "nsIPref.h"
#include "nsIServiceManager.h"
#include "nsFont.h"
#include "nsDeviceContextMac.h"
#include "nsFontUtils.h"
PRBool nsFontUtils::sDisplayVerySmallFonts = true;
PRBool
nsFontUtils::DisplayVerySmallFonts()
{
static PRBool sInitialized = PR_FALSE;
if (sInitialized)
return sDisplayVerySmallFonts;
sInitialized = PR_TRUE;
nsresult rv;
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && prefs) {
PRBool boolVal;
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.display_very_small_fonts", &boolVal))) {
sDisplayVerySmallFonts = boolVal;
}
}
return sDisplayVerySmallFonts;
}
// A utility routine to the the text style in a convenient manner.
// This is static, which is unfortunate, because it introduces link
// dependencies between libraries that should not exist.
void
nsFontUtils::GetNativeTextStyle(nsIFontMetrics& inMetrics,
const nsIDeviceContext& inDevContext, TextStyle &outStyle)
{
const nsFont *aFont = &inMetrics.Font();
nsFontHandle fontNum;
inMetrics.GetFontHandle(fontNum);
float dev2app;
dev2app = inDevContext.DevUnitsToAppUnits();
short textSize = float(aFont->size) / dev2app;
textSize = PR_MAX(1, textSize);
if (textSize < 9 && !nsFontUtils::DisplayVerySmallFonts())
textSize = 9;
Style textFace = normal;
switch (aFont->style)
{
case NS_FONT_STYLE_NORMAL: break;
case NS_FONT_STYLE_ITALIC: textFace |= italic; break;
case NS_FONT_STYLE_OBLIQUE: textFace |= italic; break; //XXX
}
PRInt32 offset = aFont->weight % 100;
PRInt32 baseWeight = aFont->weight / 100;
NS_ASSERTION((offset < 10) || (offset > 90), "Invalid bolder or lighter value");
if (offset == 0) {
if (aFont->weight >= NS_FONT_WEIGHT_BOLD)
textFace |= bold;
} else {
if (offset < 10)
textFace |= bold;
}
RGBColor black = {0};
outStyle.tsFont = (short)fontNum;
outStyle.tsFace = textFace;
outStyle.tsSize = textSize;
outStyle.tsColor = black;
}

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

@ -1,111 +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):
*
* 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 ***** */
#ifndef nsUnicodeFallbackCache_h__
#define nsUnicodeFallbackCache_h__
#include "prtypes.h"
#include "plhash.h"
#include <Script.h>
#include "nsDebug.h"
#include "nscore.h"
class nsUnicodeFallbackCache
{
public:
nsUnicodeFallbackCache()
{
mTable = PL_NewHashTable(8, (PLHashFunction)HashKey,
(PLHashComparator)CompareKeys,
(PLHashComparator)CompareValues,
nsnull, nsnull);
mCount = 0;
};
~nsUnicodeFallbackCache()
{
if (mTable)
{
PL_HashTableEnumerateEntries(mTable, FreeHashEntries, 0);
PL_HashTableDestroy(mTable);
mTable = nsnull;
}
};
inline PRBool Get(PRUnichar aChar, ScriptCode& oScript)
{
ScriptCode ret = (ScriptCode)PL_HashTableLookup(mTable, (void*)aChar);
oScript = 0x00FF & ret ;
return 0x00 != (0xFF00 & ret);
};
inline void Set(PRUnichar aChar, ScriptCode aScript)
{
PL_HashTableAdd(mTable,(void*) aChar, (void*)(aScript | 0xFF00));
mCount ++;
};
inline static nsUnicodeFallbackCache* GetSingleton()
{
if(! gSingleton)
gSingleton = new nsUnicodeFallbackCache();
return gSingleton;
}
private:
inline static PR_CALLBACK PLHashNumber HashKey(const void *aKey)
{
return (PRUnichar)aKey;
};
inline static PR_CALLBACK PRIntn CompareKeys(const void *v1, const void *v2)
{
return (((PRUnichar ) v1) == ((PRUnichar ) v2));
};
inline static PR_CALLBACK PRIntn CompareValues(const void *v1, const void *v2)
{
return (((ScriptCode)v1) == ((ScriptCode)v2));
};
inline static PR_CALLBACK PRIntn FreeHashEntries(PLHashEntry *he, PRIntn italic, void *arg)
{
return HT_ENUMERATE_REMOVE;
};
struct PLHashTable* mTable;
PRUint32 mCount;
static nsUnicodeFallbackCache* gSingleton;
};
#endif nsUnicodeFallbackCache_h__

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

@ -191,8 +191,10 @@ PR_END_EXTERN_C
#ifdef XP_MACOSX
#define TV2FP(tvp) _TV2FP((void *)tvp)
static void*
TV2FP(void *tvp)
_TV2FP(void *tvp)
{
static uint32 glue[6] = {
0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420
@ -211,8 +213,10 @@ TV2FP(void *tvp)
return newGlue;
}
#define FP2TV(fp) _FP2TV((void *)fp)
static void*
FP2TV(void *fp)
_FP2TV(void *fp)
{
void **newGlue = NULL;
if (fp != NULL) {
@ -474,29 +478,29 @@ ns4xPlugin::~ns4xPlugin(void)
#if defined(XP_MACOSX)
// release all wrapped plugin entry points.
if (fCallbacks.newp)
free(fCallbacks.newp);
free((void *)fCallbacks.newp);
if (fCallbacks.destroy)
free(fCallbacks.destroy);
free((void *)fCallbacks.destroy);
if (fCallbacks.setwindow)
free(fCallbacks.setwindow);
free((void *)fCallbacks.setwindow);
if (fCallbacks.newstream)
free(fCallbacks.newstream);
free((void *)fCallbacks.newstream);
if (fCallbacks.asfile)
free(fCallbacks.asfile);
free((void *)fCallbacks.asfile);
if (fCallbacks.writeready)
free(fCallbacks.writeready);
free((void *)fCallbacks.writeready);
if (fCallbacks.write)
free(fCallbacks.write);
free((void *)fCallbacks.write);
if (fCallbacks.print)
free(fCallbacks.print);
free((void *)fCallbacks.print);
if (fCallbacks.event)
free(fCallbacks.event);
free((void *)fCallbacks.event);
if (fCallbacks.urlnotify)
free(fCallbacks.urlnotify);
free((void *)fCallbacks.urlnotify);
if (fCallbacks.getvalue)
free(fCallbacks.getvalue);
free((void *)fCallbacks.getvalue);
if (fCallbacks.setvalue)
free(fCallbacks.setvalue);
free((void *)fCallbacks.setvalue);
#endif
memset((void*) &fCallbacks, 0, sizeof(fCallbacks));
}
@ -839,7 +843,7 @@ ns4xPlugin::Shutdown(void)
#if defined(XP_MACOSX)
// release the wrapped plugin function.
free(fShutdownEntry);
free((void *)fShutdownEntry);
#endif
fShutdownEntry = nsnull;
}

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

@ -64,9 +64,9 @@ NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(PRBool *aIsRTL)
CFBundleRef bundle =
::CFBundleGetBundleWithIdentifier(CFSTR("com.apple.Carbon"));
if (bundle) {
fpKLGetCurrentKeyboardLayout =
fpKLGetCurrentKeyboardLayout = (fpKLGetCurrentKeyboardLayout_type)
::CFBundleGetFunctionPointerForName(bundle, CFSTR("KLGetCurrentKeyboardLayout"));
fpKLGetKeyboardLayoutProperty =
fpKLGetKeyboardLayoutProperty = (fpKLGetKeyboardLayoutProperty_type)
::CFBundleGetFunctionPointerForName(bundle, CFSTR("KLGetKeyboardLayoutProperty"));
}
@ -76,7 +76,7 @@ NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(PRBool *aIsRTL)
if (fpKLGetCurrentKeyboardLayout) {
OSStatus err;
KeyboardLayoutRef currentKeyboard;
const void* currentKeyboardResID;
void* currentKeyboardResID;
err = fpKLGetCurrentKeyboardLayout(&currentKeyboard);
if (err == noErr)