Bug 415686: remove FONT_LEADING_APIS_V2 ifdefs which are no longer useful for cairo builds. Also remove related functions and tests. r/sr=dbaron, r=pavlov, a=beltzner

This commit is contained in:
mozilla@weilbacher.org 2008-02-19 11:41:56 -08:00
parent 655d0e3e4a
commit 4c60ecfb31
6 changed files with 0 additions and 484 deletions

View File

@ -137,12 +137,6 @@ public:
*/ */
NS_IMETHOD GetHeight(nscoord &aHeight) = 0; NS_IMETHOD GetHeight(nscoord &aHeight) = 0;
#if defined(XP_WIN) || defined(XP_OS2) || defined(MOZ_CAIRO_GFX)
#define FONT_LEADING_APIS_V2 1
#endif
#ifdef FONT_LEADING_APIS_V2
/** /**
* Returns the amount of internal leading (in app units) for the font. This * Returns the amount of internal leading (in app units) for the font. This
* is computed as the "height - (ascent + descent)" * is computed as the "height - (ascent + descent)"
@ -155,18 +149,6 @@ public:
* beside font height. * beside font height.
*/ */
NS_IMETHOD GetExternalLeading(nscoord &aLeading) = 0; NS_IMETHOD GetExternalLeading(nscoord &aLeading) = 0;
#else
/**
* Returns the amount of internal leading (in app units) for the font. This
* is computed as the "height - (ascent + descent)"
*/
NS_IMETHOD GetLeading(nscoord &aLeading) = 0;
/**
* Returns the normal line height (em height + leading).
*/
NS_IMETHOD GetNormalLineHeight(nscoord &aHeight) = 0;
#endif /* FONT_LEADING_APIS_V2 */
/** /**
* Returns the height (in app units) of the Western font's em square. This is * Returns the height (in app units) of the Western font's em square. This is

View File

@ -1,343 +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 "nsRegressionTestFontMetrics.h"
#define MAPPING_FACTOR_FOR_SPACE 0.02f
#define MAPPING_FACTOR_FOR_LOWER_CASE 0.50f
#define MAPPING_FACTOR_FOR_OTHERS 0.70f
nsresult
NS_NewRegressionTestFontMetrics(nsIFontMetrics** aMetrics)
{
if (aMetrics == nsnull) {
return NS_ERROR_NULL_POINTER;
}
nsRegressionTestFontMetrics *fm = new nsRegressionTestFontMetrics();
if (nsnull == fm) {
return NS_ERROR_OUT_OF_MEMORY;
}
return CallQueryInterface(fm, aMetrics);
}
nsRegressionTestFontMetrics:: nsRegressionTestFontMetrics()
{
mDeviceContext = nsnull;
mHeight = 0;
mAscent = 0;
mDescent = 0;
mLeading = 0;
mMaxAscent = 0;
mMaxDescent = 0;
mMaxAdvance = 0;
mXHeight = 0;
mSuperscriptOffset = 0;
mSubscriptOffset = 0;
mStrikeoutSize = 0;
mStrikeoutOffset = 0;
mUnderlineSize = 0;
mUnderlineOffset = 0;
}
NS_IMPL_ISUPPORTS1(nsRegressionTestFontMetrics, nsIFontMetrics)
nsRegressionTestFontMetrics::~nsRegressionTestFontMetrics()
{
mDeviceContext = nsnull;
}
NS_IMETHODIMP
nsRegressionTestFontMetrics::Init(const nsFont& aFont, nsIDeviceContext *aContext)
{
mFont = aFont;
mDeviceContext = aContext;
RealizeFont();
return NS_OK;
}
NS_IMETHODIMP
nsRegressionTestFontMetrics::Destroy()
{
mDeviceContext = nsnull;
return NS_OK;
}
void
nsRegressionTestFontMetrics::RealizeFont()
{
float dev2app;
dev2app = mDeviceContext->DevUnitsToAppUnits();
nscoord onepixel = NSToCoordRound(1 * dev2app);
PRUint32 fontsize = mFont.size;
// Most of the numbers are just made up....
// feel free to play around.
mHeight = fontsize;
mXHeight = NSToCoordRound((float)mHeight * 0.50f);
mSuperscriptOffset = mXHeight;
mSubscriptOffset = mXHeight;
mStrikeoutSize = onepixel;
mStrikeoutOffset = NSToCoordRound(mXHeight / 3.5f);
mAscent = NSToCoordRound((float)fontsize * 0.60f);
mDescent = NSToCoordRound((float)fontsize * 0.20f);
mLeading = NSToCoordRound((float)fontsize * 0.10f);
mMaxAscent = mAscent;
mMaxDescent = mDescent;
mMaxAdvance = NSToCoordRound((float)fontsize * 0.80f);
mUnderlineSize = onepixel;
mUnderlineOffset = NSToCoordRound(fontsize / 100.0f);
}
/**
* This routine determines a character width without relying on the
* underlying OS.
*
* @update harishd 02/07/1999
* @param aChar -- A valid character whose width needs to be computed
* @param aWidth -- Holds the computed character width
*/
NS_METHOD
nsRegressionTestFontMetrics::GetWidth(const char aChar, nscoord& aWidth)
{
float size = (float)mFont.size;
aWidth = 0;
if(aChar == ' ')
size *= MAPPING_FACTOR_FOR_SPACE;
else if(aChar >= 'a' && aChar <= 'z')
size *= MAPPING_FACTOR_FOR_LOWER_CASE;
else
size *= MAPPING_FACTOR_FOR_OTHERS;
aWidth = NSToCoordRound(size);
return NS_OK;
}
/**
* This routine determines a character width without relying on the
* underlying OS.
*
* @update harishd 02/07/1999
* @param aChar -- A valid character whose width needs to be computed
* @param aWidth -- Holds the computed character width
*/
NS_METHOD
nsRegressionTestFontMetrics::GetWidth(const PRUnichar aChar,nscoord& aWidth)
{
float size = (float)mFont.size;
aWidth = 0;
if(aChar == ' ')
size *= MAPPING_FACTOR_FOR_SPACE;
else if(aChar >= 'a' && aChar <= 'z')
size *= MAPPING_FACTOR_FOR_LOWER_CASE;
else
size *= MAPPING_FACTOR_FOR_OTHERS;
aWidth = NSToCoordRound(size);
return NS_OK;
}
/**
* This routine determines width of a string without relying on the
* underlying OS.
*
* @update harishd 02/07/1999
* @param aString -- A string whose width needs to be computed
* @param aLength -- Length of the string
* @param aWidth -- Holds the computed string width
*
* @return error code -- 0 if success, non-zero if error
*/
NS_METHOD
nsRegressionTestFontMetrics::GetWidth(const PRUnichar* aString, PRUint32 aLength, nscoord& aWidth)
{
aWidth = 0;
if(aString == nsnull)
return NS_ERROR_NULL_POINTER;
float size;
float totalsize = 0;
for(PRUint32 index = 0; index < aLength; index++){
size = (float)mFont.size;
if(aString[index] == ' ')
size *= MAPPING_FACTOR_FOR_SPACE;
else if(aString[index] >= 'a' && aString[index] <= 'z')
size *= MAPPING_FACTOR_FOR_LOWER_CASE;
else
size *= MAPPING_FACTOR_FOR_OTHERS;
totalsize += size;
}
aWidth = NSToCoordRound(totalsize);
return NS_OK;
}
/**
* This routine determines width of a string without relying on the
* underlying OS.
*
* @update harishd 02/07/1999
* @param aString -- A string whose width needs to be computed
* @param aLength -- Length of the string
* @param aWidth -- Holds the computed string width
*
* @return error code -- 0 if success, non-zero if error
*/
NS_METHOD
nsRegressionTestFontMetrics::GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth)
{
aWidth = 0;
if(aString == nsnull)
return NS_ERROR_NULL_POINTER;
float size;
float totalsize = 0;
for(PRUint32 index=0; index < aLength; index++){
size = (float)mFont.size;
if(aString[index] == ' ')
size *= MAPPING_FACTOR_FOR_SPACE;
else if(aString[index] >= 'a' && aString[index] <= 'z')
size *= MAPPING_FACTOR_FOR_LOWER_CASE;
else
size *= MAPPING_FACTOR_FOR_OTHERS;
totalsize += size;
}
aWidth += NSToCoordRound(totalsize);
return NS_OK;
}
NS_IMETHODIMP
nsRegressionTestFontMetrics::GetXHeight(nscoord& aResult)
{
aResult = mXHeight;
return NS_OK;
}
NS_IMETHODIMP
nsRegressionTestFontMetrics::GetSuperscriptOffset(nscoord& aResult)
{
aResult = mSuperscriptOffset;
return NS_OK;
}
NS_IMETHODIMP
nsRegressionTestFontMetrics::GetSubscriptOffset(nscoord& aResult)
{
aResult = mSubscriptOffset;
return NS_OK;
}
NS_IMETHODIMP
nsRegressionTestFontMetrics::GetStrikeout(nscoord& aOffset, nscoord& aSize)
{
aOffset = mStrikeoutOffset;
aSize = mStrikeoutSize;
return NS_OK;
}
NS_IMETHODIMP
nsRegressionTestFontMetrics::GetUnderline(nscoord& aOffset, nscoord& aSize)
{
aOffset = mUnderlineOffset;
aSize = mUnderlineSize;
return NS_OK;
}
NS_IMETHODIMP
nsRegressionTestFontMetrics::GetHeight(nscoord &aHeight)
{
aHeight = mHeight;
return NS_OK;
}
NS_IMETHODIMP
nsRegressionTestFontMetrics::GetLeading(nscoord &aLeading)
{
aLeading = mLeading;
return NS_OK;
}
NS_IMETHODIMP
nsRegressionTestFontMetrics::GetMaxAscent(nscoord &aAscent)
{
aAscent = mMaxAscent;
return NS_OK;
}
NS_IMETHODIMP
nsRegressionTestFontMetrics::GetMaxDescent(nscoord &aDescent)
{
aDescent = mMaxDescent;
return NS_OK;
}
NS_IMETHODIMP
nsRegressionTestFontMetrics::GetMaxAdvance(nscoord &aAdvance)
{
aAdvance = mMaxAdvance;
return NS_OK;
}
nsRegressionTestFontMetrics::GetFontHandle(nsFontHandle &aHandle)
{
//We don't have a font handler
aHandle = NULL;
return NS_OK;
}

View File

@ -1,98 +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 nsRegressionTestFontMetrics_h__
#define nsRegressionTestFontMetrics_h__
#include "nsIFontMetrics.h"
#include "nsFont.h"
#include "nsString.h"
#include "nsIDeviceContext.h"
class nsRegressionTestFontMetrics : public nsIFontMetrics
{
public:
friend nsresult NS_NewRegressionTestFontMetrics(nsIFontMetrics** aMetrics);
virtual ~nsRegressionTestFontMetrics();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(const nsFont& aFont, nsIDeviceContext *aContext);
NS_IMETHOD Destroy();
NS_IMETHOD GetXHeight(nscoord& aResult);
NS_IMETHOD GetSuperscriptOffset(nscoord& aResult);
NS_IMETHOD GetSubscriptOffset(nscoord& aResult);
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize);
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize);
NS_IMETHOD GetHeight(nscoord &aHeight);
NS_IMETHOD GetLeading(nscoord &aLeading);
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
NS_METHOD GetWidth(const char aChar, nscoord& aWidth);
NS_METHOD GetWidth(const PRUnichar aChar, nscoord& aWidth);
NS_METHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord& aWidth);
NS_METHOD GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth);
protected:
nsRegressionTestFontMetrics();
void RealizeFont();
nsIDeviceContext *mDeviceContext;
nscoord mHeight;
nscoord mAscent;
nscoord mDescent;
nscoord mLeading;
nscoord mMaxAscent;
nscoord mMaxDescent;
nscoord mMaxAdvance;
nscoord mXHeight;
nscoord mSuperscriptOffset;
nscoord mSubscriptOffset;
nscoord mStrikeoutSize;
nscoord mStrikeoutOffset;
nscoord mUnderlineSize;
nscoord mUnderlineOffset;
};
#endif

View File

@ -245,21 +245,6 @@ nsThebesFontMetrics::GetSpaceWidth(nscoord& aSpaceCharWidth)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsThebesFontMetrics::GetLeading(nscoord& aLeading)
{
aLeading = ROUND_TO_TWIPS(GetMetrics().internalLeading);
return NS_OK;
}
NS_IMETHODIMP
nsThebesFontMetrics::GetNormalLineHeight(nscoord& aLineHeight)
{
const gfxFont::Metrics& m = GetMetrics();
aLineHeight = ROUND_TO_TWIPS(m.emHeight + m.internalLeading);
return NS_OK;
}
PRInt32 PRInt32
nsThebesFontMetrics::GetMaxStringLength() nsThebesFontMetrics::GetMaxStringLength()
{ {

View File

@ -78,8 +78,6 @@ public:
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle); NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
NS_IMETHOD GetAveCharWidth(nscoord& aAveCharWidth); NS_IMETHOD GetAveCharWidth(nscoord& aAveCharWidth);
NS_IMETHOD GetSpaceWidth(nscoord& aSpaceCharWidth); NS_IMETHOD GetSpaceWidth(nscoord& aSpaceCharWidth);
NS_IMETHOD GetLeading(nscoord& aLeading);
NS_IMETHOD GetNormalLineHeight(nscoord& aLineHeight);
virtual PRInt32 GetMaxStringLength(); virtual PRInt32 GetMaxStringLength();

View File

@ -78,9 +78,7 @@ enum eNormalLineHeightControl {
eCompensateLeading // compensate leading if leading provided by font vendor is not enough eCompensateLeading // compensate leading if leading provided by font vendor is not enough
}; };
#ifdef FONT_LEADING_APIS_V2
static eNormalLineHeightControl sNormalLineHeightControl = eUninitialized; static eNormalLineHeightControl sNormalLineHeightControl = eUninitialized;
#endif
// Initialize a <b>root</b> reflow state with a rendering context to // Initialize a <b>root</b> reflow state with a rendering context to
// use for measuring things. // use for measuring things.
@ -1574,7 +1572,6 @@ static PRBool BlinkIsAllowed(void)
return sBlinkIsAllowed; return sBlinkIsAllowed;
} }
#ifdef FONT_LEADING_APIS_V2
static eNormalLineHeightControl GetNormalLineHeightCalcControl(void) static eNormalLineHeightControl GetNormalLineHeightCalcControl(void)
{ {
if (sNormalLineHeightControl == eUninitialized) { if (sNormalLineHeightControl == eUninitialized) {
@ -1586,7 +1583,6 @@ static eNormalLineHeightControl GetNormalLineHeightCalcControl(void)
} }
return sNormalLineHeightControl; return sNormalLineHeightControl;
} }
#endif
// XXX refactor this code to have methods for each set of properties // XXX refactor this code to have methods for each set of properties
// we are computing: width,height,line-height; margin; offsets // we are computing: width,height,line-height; margin; offsets
@ -1987,7 +1983,6 @@ GetNormalLineHeight(nsIFontMetrics* aFontMetrics)
nscoord normalLineHeight; nscoord normalLineHeight;
#ifdef FONT_LEADING_APIS_V2
nscoord externalLeading, internalLeading, emHeight; nscoord externalLeading, internalLeading, emHeight;
aFontMetrics->GetExternalLeading(externalLeading); aFontMetrics->GetExternalLeading(externalLeading);
aFontMetrics->GetInternalLeading(internalLeading); aFontMetrics->GetInternalLeading(internalLeading);
@ -2006,9 +2001,6 @@ GetNormalLineHeight(nsIFontMetrics* aFontMetrics)
//case eNoExternalLeading: //case eNoExternalLeading:
normalLineHeight = emHeight + internalLeading; normalLineHeight = emHeight + internalLeading;
} }
#else
aFontMetrics->GetNormalLineHeight(normalLineHeight);
#endif // FONT_LEADING_APIS_V2
return normalLineHeight; return normalLineHeight;
} }