Bug 174055, part 6: eliminate pointless nsresult return values.
This commit is contained in:
@@ -2492,10 +2492,9 @@ GetScrollableLineHeight(nsIFrame* aTargetFrame)
|
|||||||
const nsFont& f = font->mFont;
|
const nsFont& f = font->mFont;
|
||||||
nsRefPtr<nsFontMetrics> fm = aTargetFrame->PresContext()->GetMetricsFor(f);
|
nsRefPtr<nsFontMetrics> fm = aTargetFrame->PresContext()->GetMetricsFor(f);
|
||||||
NS_ASSERTION(fm, "FontMetrics is null!");
|
NS_ASSERTION(fm, "FontMetrics is null!");
|
||||||
nscoord lineHeight = 0;
|
|
||||||
if (fm)
|
if (fm)
|
||||||
fm->GetMaxHeight(lineHeight);
|
return fm->MaxHeight();
|
||||||
return lineHeight;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -40,31 +40,31 @@
|
|||||||
#include "nsBoundingMetrics.h"
|
#include "nsBoundingMetrics.h"
|
||||||
#include "nsRenderingContext.h"
|
#include "nsRenderingContext.h"
|
||||||
#include "nsThebesDeviceContext.h"
|
#include "nsThebesDeviceContext.h"
|
||||||
|
#include "gfxTextRunCache.h"
|
||||||
|
|
||||||
class AutoTextRun {
|
namespace {
|
||||||
|
|
||||||
|
class AutoTextRun : public gfxTextRunCache::AutoTextRun {
|
||||||
public:
|
public:
|
||||||
AutoTextRun(nsFontMetrics* aMetrics, nsRenderingContext* aRC,
|
AutoTextRun(nsFontMetrics* aMetrics, nsRenderingContext* aRC,
|
||||||
const char* aString, PRInt32 aLength) {
|
const char* aString, PRInt32 aLength)
|
||||||
mTextRun = gfxTextRunCache::MakeTextRun(
|
: gfxTextRunCache::AutoTextRun(gfxTextRunCache::MakeTextRun(
|
||||||
reinterpret_cast<const PRUint8*>(aString), aLength,
|
reinterpret_cast<const PRUint8*>(aString), aLength,
|
||||||
aMetrics->GetThebesFontGroup(), aRC->ThebesContext(),
|
aMetrics->GetThebesFontGroup(), aRC->ThebesContext(),
|
||||||
aMetrics->AppUnitsPerDevPixel(),
|
aMetrics->AppUnitsPerDevPixel(),
|
||||||
ComputeFlags(aMetrics));
|
ComputeFlags(aMetrics)))
|
||||||
}
|
{}
|
||||||
|
|
||||||
AutoTextRun(nsFontMetrics* aMetrics, nsRenderingContext* aRC,
|
AutoTextRun(nsFontMetrics* aMetrics, nsRenderingContext* aRC,
|
||||||
const PRUnichar* aString, PRInt32 aLength) {
|
const PRUnichar* aString, PRInt32 aLength)
|
||||||
mTextRun = gfxTextRunCache::MakeTextRun(
|
: gfxTextRunCache::AutoTextRun(gfxTextRunCache::MakeTextRun(
|
||||||
aString, aLength, aMetrics->GetThebesFontGroup(),
|
aString, aLength, aMetrics->GetThebesFontGroup(),
|
||||||
aRC->ThebesContext(),
|
aRC->ThebesContext(),
|
||||||
aMetrics->AppUnitsPerDevPixel(),
|
aMetrics->AppUnitsPerDevPixel(),
|
||||||
ComputeFlags(aMetrics));
|
ComputeFlags(aMetrics)))
|
||||||
}
|
{}
|
||||||
gfxTextRun* operator->() { return mTextRun.get(); }
|
|
||||||
gfxTextRun* get() { return mTextRun.get(); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
gfxTextRunCache::AutoTextRun mTextRun;
|
|
||||||
|
|
||||||
static PRUint32 ComputeFlags(nsFontMetrics* aMetrics) {
|
static PRUint32 ComputeFlags(nsFontMetrics* aMetrics) {
|
||||||
PRUint32 flags = 0;
|
PRUint32 flags = 0;
|
||||||
if (aMetrics->GetRightToLeftTextRunMode()) {
|
if (aMetrics->GetRightToLeftTextRunMode()) {
|
||||||
@@ -74,6 +74,24 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class StubPropertyProvider : public gfxTextRun::PropertyProvider {
|
||||||
|
public:
|
||||||
|
virtual void GetHyphenationBreaks(PRUint32 aStart, PRUint32 aLength,
|
||||||
|
PRPackedBool* aBreakBefore) {
|
||||||
|
NS_ERROR("This shouldn't be called because we never call BreakAndMeasureText");
|
||||||
|
}
|
||||||
|
virtual gfxFloat GetHyphenWidth() {
|
||||||
|
NS_ERROR("This shouldn't be called because we never enable hyphens");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
virtual void GetSpacing(PRUint32 aStart, PRUint32 aLength,
|
||||||
|
Spacing* aSpacing) {
|
||||||
|
NS_ERROR("This shouldn't be called because we never enable spacing");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // anon namespace
|
||||||
|
|
||||||
nsFontMetrics::nsFontMetrics()
|
nsFontMetrics::nsFontMetrics()
|
||||||
{
|
{
|
||||||
mFontStyle = nsnull;
|
mFontStyle = nsnull;
|
||||||
@@ -118,11 +136,10 @@ nsFontMetrics::Init(const nsFont& aFont, nsIAtom* aLanguage,
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
nsFontMetrics::Destroy()
|
nsFontMetrics::Destroy()
|
||||||
{
|
{
|
||||||
mDeviceContext = nsnull;
|
mDeviceContext = nsnull;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXXTODO get rid of this macro
|
// XXXTODO get rid of this macro
|
||||||
@@ -134,42 +151,36 @@ const gfxFont::Metrics& nsFontMetrics::GetMetrics() const
|
|||||||
return mFontGroup->GetFontAt(0)->GetMetrics();
|
return mFontGroup->GetFontAt(0)->GetMetrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nscoord
|
||||||
nsFontMetrics::GetXHeight(nscoord& aResult)
|
nsFontMetrics::XHeight()
|
||||||
{
|
{
|
||||||
aResult = ROUND_TO_TWIPS(GetMetrics().xHeight);
|
return ROUND_TO_TWIPS(GetMetrics().xHeight);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nscoord
|
||||||
nsFontMetrics::GetSuperscriptOffset(nscoord& aResult)
|
nsFontMetrics::SuperscriptOffset()
|
||||||
{
|
{
|
||||||
aResult = ROUND_TO_TWIPS(GetMetrics().superscriptOffset);
|
return ROUND_TO_TWIPS(GetMetrics().superscriptOffset);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nscoord
|
||||||
nsFontMetrics::GetSubscriptOffset(nscoord& aResult)
|
nsFontMetrics::SubscriptOffset()
|
||||||
{
|
{
|
||||||
aResult = ROUND_TO_TWIPS(GetMetrics().subscriptOffset);
|
return ROUND_TO_TWIPS(GetMetrics().subscriptOffset);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
nsFontMetrics::GetStrikeout(nscoord& aOffset, nscoord& aSize)
|
nsFontMetrics::GetStrikeout(nscoord& aOffset, nscoord& aSize)
|
||||||
{
|
{
|
||||||
aOffset = ROUND_TO_TWIPS(GetMetrics().strikeoutOffset);
|
aOffset = ROUND_TO_TWIPS(GetMetrics().strikeoutOffset);
|
||||||
aSize = ROUND_TO_TWIPS(GetMetrics().strikeoutSize);
|
aSize = ROUND_TO_TWIPS(GetMetrics().strikeoutSize);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
nsFontMetrics::GetUnderline(nscoord& aOffset, nscoord& aSize)
|
nsFontMetrics::GetUnderline(nscoord& aOffset, nscoord& aSize)
|
||||||
{
|
{
|
||||||
aOffset = ROUND_TO_TWIPS(mFontGroup->GetUnderlineOffset());
|
aOffset = ROUND_TO_TWIPS(mFontGroup->GetUnderlineOffset());
|
||||||
aSize = ROUND_TO_TWIPS(GetMetrics().underlineSize);
|
aSize = ROUND_TO_TWIPS(GetMetrics().underlineSize);
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMaxAscent/GetMaxDescent/GetMaxHeight must contain the
|
// GetMaxAscent/GetMaxDescent/GetMaxHeight must contain the
|
||||||
@@ -191,91 +202,80 @@ static gfxFloat ComputeMaxAscent(const gfxFont::Metrics& aMetrics)
|
|||||||
return NS_floor(aMetrics.maxAscent + 0.5);
|
return NS_floor(aMetrics.maxAscent + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nscoord
|
||||||
nsFontMetrics::GetInternalLeading(nscoord &aLeading)
|
nsFontMetrics::InternalLeading()
|
||||||
{
|
{
|
||||||
aLeading = ROUND_TO_TWIPS(GetMetrics().internalLeading);
|
return ROUND_TO_TWIPS(GetMetrics().internalLeading);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nscoord
|
||||||
nsFontMetrics::GetExternalLeading(nscoord &aLeading)
|
nsFontMetrics::ExternalLeading()
|
||||||
{
|
{
|
||||||
aLeading = ROUND_TO_TWIPS(GetMetrics().externalLeading);
|
return ROUND_TO_TWIPS(GetMetrics().externalLeading);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nscoord
|
||||||
nsFontMetrics::GetEmHeight(nscoord &aHeight)
|
nsFontMetrics::EmHeight()
|
||||||
{
|
{
|
||||||
aHeight = ROUND_TO_TWIPS(GetMetrics().emHeight);
|
return ROUND_TO_TWIPS(GetMetrics().emHeight);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nscoord
|
||||||
nsFontMetrics::GetEmAscent(nscoord &aAscent)
|
nsFontMetrics::EmAscent()
|
||||||
{
|
{
|
||||||
aAscent = ROUND_TO_TWIPS(GetMetrics().emAscent);
|
return ROUND_TO_TWIPS(GetMetrics().emAscent);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nscoord
|
||||||
nsFontMetrics::GetEmDescent(nscoord &aDescent)
|
nsFontMetrics::EmDescent()
|
||||||
{
|
{
|
||||||
aDescent = ROUND_TO_TWIPS(GetMetrics().emDescent);
|
return ROUND_TO_TWIPS(GetMetrics().emDescent);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nscoord
|
||||||
nsFontMetrics::GetMaxHeight(nscoord &aHeight)
|
nsFontMetrics::MaxHeight()
|
||||||
{
|
{
|
||||||
aHeight = CEIL_TO_TWIPS(ComputeMaxAscent(GetMetrics())) +
|
return CEIL_TO_TWIPS(ComputeMaxAscent(GetMetrics())) +
|
||||||
CEIL_TO_TWIPS(ComputeMaxDescent(GetMetrics(), mFontGroup));
|
CEIL_TO_TWIPS(ComputeMaxDescent(GetMetrics(), mFontGroup));
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nscoord
|
||||||
nsFontMetrics::GetMaxAscent(nscoord &aAscent)
|
nsFontMetrics::MaxAscent()
|
||||||
{
|
{
|
||||||
aAscent = CEIL_TO_TWIPS(ComputeMaxAscent(GetMetrics()));
|
return CEIL_TO_TWIPS(ComputeMaxAscent(GetMetrics()));
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nscoord
|
||||||
nsFontMetrics::GetMaxDescent(nscoord &aDescent)
|
nsFontMetrics::MaxDescent()
|
||||||
{
|
{
|
||||||
aDescent = CEIL_TO_TWIPS(ComputeMaxDescent(GetMetrics(), mFontGroup));
|
return CEIL_TO_TWIPS(ComputeMaxDescent(GetMetrics(), mFontGroup));
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nscoord
|
||||||
nsFontMetrics::GetMaxAdvance(nscoord &aAdvance)
|
nsFontMetrics::MaxAdvance()
|
||||||
{
|
{
|
||||||
aAdvance = CEIL_TO_TWIPS(GetMetrics().maxAdvance);
|
return CEIL_TO_TWIPS(GetMetrics().maxAdvance);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nscoord
|
||||||
nsFontMetrics::GetLanguage(nsIAtom** aLanguage)
|
nsFontMetrics::AveCharWidth()
|
||||||
{
|
|
||||||
*aLanguage = mLanguage;
|
|
||||||
NS_IF_ADDREF(*aLanguage);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsFontMetrics::GetAveCharWidth(nscoord& aAveCharWidth)
|
|
||||||
{
|
{
|
||||||
// Use CEIL instead of ROUND for consistency with GetMaxAdvance
|
// Use CEIL instead of ROUND for consistency with GetMaxAdvance
|
||||||
aAveCharWidth = CEIL_TO_TWIPS(GetMetrics().aveCharWidth);
|
return CEIL_TO_TWIPS(GetMetrics().aveCharWidth);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nscoord
|
||||||
nsFontMetrics::GetSpaceWidth(nscoord& aSpaceCharWidth)
|
nsFontMetrics::SpaceWidth()
|
||||||
{
|
{
|
||||||
aSpaceCharWidth = CEIL_TO_TWIPS(GetMetrics().spaceWidth);
|
return CEIL_TO_TWIPS(GetMetrics().spaceWidth);
|
||||||
return NS_OK;
|
}
|
||||||
|
|
||||||
|
already_AddRefed<nsIAtom>
|
||||||
|
nsFontMetrics::GetLanguage()
|
||||||
|
{
|
||||||
|
nsIAtom* result = mLanguage.get();
|
||||||
|
NS_IF_ADDREF(result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRInt32
|
PRInt32
|
||||||
@@ -287,145 +287,93 @@ nsFontMetrics::GetMaxStringLength()
|
|||||||
return PR_MAX(1, len);
|
return PR_MAX(1, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
class StubPropertyProvider : public gfxTextRun::PropertyProvider {
|
nscoord
|
||||||
public:
|
nsFontMetrics::GetWidth(const char* aString, PRUint32 aLength,
|
||||||
virtual void GetHyphenationBreaks(PRUint32 aStart, PRUint32 aLength,
|
|
||||||
PRPackedBool* aBreakBefore) {
|
|
||||||
NS_ERROR("This shouldn't be called because we never call BreakAndMeasureText");
|
|
||||||
}
|
|
||||||
virtual gfxFloat GetHyphenWidth() {
|
|
||||||
NS_ERROR("This shouldn't be called because we never enable hyphens");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
virtual void GetSpacing(PRUint32 aStart, PRUint32 aLength,
|
|
||||||
Spacing* aSpacing) {
|
|
||||||
NS_ERROR("This shouldn't be called because we never enable spacing");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsFontMetrics::GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth,
|
|
||||||
nsRenderingContext *aContext)
|
nsRenderingContext *aContext)
|
||||||
{
|
{
|
||||||
if (aLength == 0) {
|
if (aLength == 0)
|
||||||
aWidth = 0;
|
return 0;
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// callers that hit this should not be so stupid
|
if (aLength == 1 && aString[0] == ' ')
|
||||||
if ((aLength == 1) && (aString[0] == ' '))
|
return SpaceWidth();
|
||||||
return GetSpaceWidth(aWidth);
|
|
||||||
|
|
||||||
StubPropertyProvider provider;
|
StubPropertyProvider provider;
|
||||||
AutoTextRun textRun(this, aContext, aString, aLength);
|
AutoTextRun textRun(this, aContext, aString, aLength);
|
||||||
if (!textRun.get())
|
return NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider));
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
aWidth = NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider));
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nscoord
|
||||||
nsFontMetrics::GetWidth(const PRUnichar* aString, PRUint32 aLength,
|
nsFontMetrics::GetWidth(const PRUnichar* aString, PRUint32 aLength,
|
||||||
nscoord& aWidth, PRInt32 *aFontID,
|
|
||||||
nsRenderingContext *aContext)
|
nsRenderingContext *aContext)
|
||||||
{
|
{
|
||||||
if (aLength == 0) {
|
if (aLength == 0)
|
||||||
aWidth = 0;
|
return 0;
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// callers that hit this should not be so stupid
|
if (aLength == 1 && aString[0] == ' ')
|
||||||
if ((aLength == 1) && (aString[0] == ' '))
|
return SpaceWidth();
|
||||||
return GetSpaceWidth(aWidth);
|
|
||||||
|
|
||||||
StubPropertyProvider provider;
|
StubPropertyProvider provider;
|
||||||
AutoTextRun textRun(this, aContext, aString, aLength);
|
AutoTextRun textRun(this, aContext, aString, aLength);
|
||||||
if (!textRun.get())
|
return NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider));
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
aWidth = NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider));
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a string using this font handle on the surface passed in.
|
// Draw a string using this font handle on the surface passed in.
|
||||||
nsresult
|
void
|
||||||
nsFontMetrics::DrawString(const char *aString, PRUint32 aLength,
|
nsFontMetrics::DrawString(const char *aString, PRUint32 aLength,
|
||||||
nscoord aX, nscoord aY,
|
nscoord aX, nscoord aY,
|
||||||
const nscoord* aSpacing,
|
|
||||||
nsRenderingContext *aContext)
|
nsRenderingContext *aContext)
|
||||||
{
|
{
|
||||||
if (aLength == 0)
|
if (aLength == 0)
|
||||||
return NS_OK;
|
return;
|
||||||
|
|
||||||
NS_ASSERTION(!aSpacing, "Spacing not supported here");
|
|
||||||
StubPropertyProvider provider;
|
StubPropertyProvider provider;
|
||||||
AutoTextRun textRun(this, aContext, aString, aLength);
|
AutoTextRun textRun(this, aContext, aString, aLength);
|
||||||
if (!textRun.get())
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
gfxPoint pt(aX, aY);
|
gfxPoint pt(aX, aY);
|
||||||
if (mTextRunRTL) {
|
if (mTextRunRTL) {
|
||||||
pt.x += textRun->GetAdvanceWidth(0, aLength, &provider);
|
pt.x += textRun->GetAdvanceWidth(0, aLength, &provider);
|
||||||
}
|
}
|
||||||
textRun->Draw(aContext->ThebesContext(), pt, 0, aLength,
|
textRun->Draw(aContext->ThebesContext(), pt, 0, aLength, &provider, nsnull);
|
||||||
&provider, nsnull);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
nsFontMetrics::DrawString(const PRUnichar* aString, PRUint32 aLength,
|
nsFontMetrics::DrawString(const PRUnichar* aString, PRUint32 aLength,
|
||||||
nscoord aX, nscoord aY,
|
nscoord aX, nscoord aY,
|
||||||
nsRenderingContext *aContext,
|
nsRenderingContext *aContext,
|
||||||
nsRenderingContext *aTextRunConstructionContext)
|
nsRenderingContext *aTextRunConstructionContext)
|
||||||
{
|
{
|
||||||
if (aLength == 0)
|
if (aLength == 0)
|
||||||
return NS_OK;
|
return;
|
||||||
|
|
||||||
StubPropertyProvider provider;
|
StubPropertyProvider provider;
|
||||||
AutoTextRun textRun(this, aTextRunConstructionContext, aString, aLength);
|
AutoTextRun textRun(this, aTextRunConstructionContext, aString, aLength);
|
||||||
if (!textRun.get())
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
gfxPoint pt(aX, aY);
|
gfxPoint pt(aX, aY);
|
||||||
if (mTextRunRTL) {
|
if (mTextRunRTL) {
|
||||||
pt.x += textRun->GetAdvanceWidth(0, aLength, &provider);
|
pt.x += textRun->GetAdvanceWidth(0, aLength, &provider);
|
||||||
}
|
}
|
||||||
textRun->Draw(aContext->ThebesContext(), pt, 0, aLength,
|
textRun->Draw(aContext->ThebesContext(), pt, 0, aLength, &provider, nsnull);
|
||||||
&provider, nsnull);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MOZ_MATHML
|
#ifdef MOZ_MATHML
|
||||||
nsresult
|
nsBoundingMetrics
|
||||||
nsFontMetrics::GetBoundingMetrics(const PRUnichar *aString, PRUint32 aLength,
|
nsFontMetrics::GetBoundingMetrics(const PRUnichar *aString, PRUint32 aLength,
|
||||||
nsRenderingContext *aContext,
|
nsRenderingContext *aContext)
|
||||||
nsBoundingMetrics &aBoundingMetrics)
|
|
||||||
{
|
{
|
||||||
if (aLength == 0) {
|
if (aLength == 0)
|
||||||
aBoundingMetrics = nsBoundingMetrics();
|
return nsBoundingMetrics();
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoTextRun textRun(this, aContext, aString, aLength);
|
|
||||||
if (!textRun.get())
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
// note that TIGHT_HINTED_OUTLINE_EXTENTS can be expensive (on Windows)
|
|
||||||
// but this is only used for MathML positioning so it's not critical
|
|
||||||
StubPropertyProvider provider;
|
StubPropertyProvider provider;
|
||||||
|
AutoTextRun textRun(this, aContext, aString, aLength);
|
||||||
gfxTextRun::Metrics theMetrics =
|
gfxTextRun::Metrics theMetrics =
|
||||||
textRun->MeasureText(0, aLength,
|
textRun->MeasureText(0, aLength,
|
||||||
gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS,
|
gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS,
|
||||||
aContext->ThebesContext(), &provider);
|
aContext->ThebesContext(), &provider);
|
||||||
|
|
||||||
aBoundingMetrics.leftBearing = NSToCoordFloor(theMetrics.mBoundingBox.X());
|
nsBoundingMetrics m;
|
||||||
aBoundingMetrics.rightBearing
|
m.leftBearing = NSToCoordFloor( theMetrics.mBoundingBox.X());
|
||||||
= NSToCoordCeil(theMetrics.mBoundingBox.XMost());
|
m.rightBearing = NSToCoordCeil( theMetrics.mBoundingBox.XMost());
|
||||||
aBoundingMetrics.width = NSToCoordRound(theMetrics.mAdvanceWidth);
|
m.ascent = NSToCoordCeil( -theMetrics.mBoundingBox.Y());
|
||||||
aBoundingMetrics.ascent = NSToCoordCeil(- theMetrics.mBoundingBox.Y());
|
m.descent = NSToCoordCeil( theMetrics.mBoundingBox.YMost());
|
||||||
aBoundingMetrics.descent = NSToCoordCeil(theMetrics.mBoundingBox.YMost());
|
m.width = NSToCoordRound( theMetrics.mAdvanceWidth);
|
||||||
|
return m;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
#endif /* MOZ_MATHML */
|
#endif /* MOZ_MATHML */
|
||||||
|
|||||||
@@ -43,14 +43,10 @@
|
|||||||
#include "nsCoord.h"
|
#include "nsCoord.h"
|
||||||
#include "nsFont.h"
|
#include "nsFont.h"
|
||||||
#include "gfxFont.h"
|
#include "gfxFont.h"
|
||||||
#include "gfxTextRunCache.h"
|
|
||||||
|
|
||||||
class gfxFontGroup;
|
|
||||||
class gfxUserFontSet;
|
|
||||||
class nsIAtom;
|
class nsIAtom;
|
||||||
class nsIDeviceContext;
|
class nsIDeviceContext;
|
||||||
class nsRenderingContext;
|
class nsRenderingContext;
|
||||||
class nsString;
|
|
||||||
class nsThebesDeviceContext;
|
class nsThebesDeviceContext;
|
||||||
struct nsBoundingMetrics;
|
struct nsBoundingMetrics;
|
||||||
|
|
||||||
@@ -94,93 +90,103 @@ public:
|
|||||||
* Destroy this font metrics. This breaks the association between
|
* Destroy this font metrics. This breaks the association between
|
||||||
* the font metrics and the device context.
|
* the font metrics and the device context.
|
||||||
*/
|
*/
|
||||||
nsresult Destroy();
|
void Destroy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the font's x-height.
|
* Return the font's x-height.
|
||||||
*/
|
*/
|
||||||
nsresult GetXHeight(nscoord& aResult);
|
nscoord XHeight();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the font's superscript offset (the distance from the
|
* Return the font's superscript offset (the distance from the
|
||||||
* baseline to where a superscript's baseline should be placed).
|
* baseline to where a superscript's baseline should be placed).
|
||||||
* The value returned will be positive.
|
* The value returned will be positive.
|
||||||
*/
|
*/
|
||||||
nsresult GetSuperscriptOffset(nscoord& aResult);
|
nscoord SuperscriptOffset();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the font's subscript offset (the distance from the
|
* Return the font's subscript offset (the distance from the
|
||||||
* baseline to where a subscript's baseline should be placed).
|
* baseline to where a subscript's baseline should be placed).
|
||||||
* The value returned will be positive.
|
* The value returned will be positive.
|
||||||
*/
|
*/
|
||||||
nsresult GetSubscriptOffset(nscoord& aResult);
|
nscoord SubscriptOffset();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the font's strikeout offset (the distance from the
|
* Return the font's strikeout offset (the distance from the
|
||||||
* baseline to where a strikeout should be placed) and size.
|
* baseline to where a strikeout should be placed) and size.
|
||||||
* Positive values are above the baseline, negative below.
|
* Positive values are above the baseline, negative below.
|
||||||
*/
|
*/
|
||||||
nsresult GetStrikeout(nscoord& aOffset, nscoord& aSize);
|
void GetStrikeout(nscoord& aOffset, nscoord& aSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the font's underline offset (the distance from the
|
* Return the font's underline offset (the distance from the
|
||||||
* baseline to where a underline should be placed) and size.
|
* baseline to where a underline should be placed) and size.
|
||||||
* Positive values are above the baseline, negative below.
|
* Positive values are above the baseline, negative below.
|
||||||
*/
|
*/
|
||||||
nsresult GetUnderline(nscoord& aOffset, nscoord& aSize);
|
void GetUnderline(nscoord& aOffset, nscoord& aSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the amount of internal leading for the font.
|
* Returns the amount of internal leading for the font.
|
||||||
* This is normally the difference between the max ascent
|
* This is normally the difference between the max ascent
|
||||||
* and the em ascent.
|
* and the em ascent.
|
||||||
*/
|
*/
|
||||||
nsresult GetInternalLeading(nscoord &aLeading);
|
nscoord InternalLeading();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the amount of external leading for the font.
|
* Returns the amount of external leading for the font.
|
||||||
* em ascent(?) plus external leading is the font designer's
|
* em ascent(?) plus external leading is the font designer's
|
||||||
* recommended line-height for this font.
|
* recommended line-height for this font.
|
||||||
*/
|
*/
|
||||||
nsresult GetExternalLeading(nscoord &aLeading);
|
nscoord ExternalLeading();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the height of the em square.
|
* Returns the height of the em square.
|
||||||
* This is em ascent plus em descent.
|
* This is em ascent plus em descent.
|
||||||
*/
|
*/
|
||||||
nsresult GetEmHeight(nscoord &aHeight);
|
nscoord EmHeight();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ascent part of the em square.
|
* Returns the ascent part of the em square.
|
||||||
*/
|
*/
|
||||||
nsresult GetEmAscent(nscoord &aAscent);
|
nscoord EmAscent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the descent part of the em square.
|
* Returns the descent part of the em square.
|
||||||
*/
|
*/
|
||||||
nsresult GetEmDescent(nscoord &aDescent);
|
nscoord EmDescent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the height of the bounding box.
|
* Returns the height of the bounding box.
|
||||||
* This is max ascent plus max descent.
|
* This is max ascent plus max descent.
|
||||||
*/
|
*/
|
||||||
nsresult GetMaxHeight(nscoord &aHeight);
|
nscoord MaxHeight();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum distance characters in this font extend
|
* Returns the maximum distance characters in this font extend
|
||||||
* above the base line.
|
* above the base line.
|
||||||
*/
|
*/
|
||||||
nsresult GetMaxAscent(nscoord &aAscent);
|
nscoord MaxAscent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum distance characters in this font extend
|
* Returns the maximum distance characters in this font extend
|
||||||
* below the base line.
|
* below the base line.
|
||||||
*/
|
*/
|
||||||
nsresult GetMaxDescent(nscoord &aDescent);
|
nscoord MaxDescent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum character advance for the font.
|
* Returns the maximum character advance for the font.
|
||||||
*/
|
*/
|
||||||
nsresult GetMaxAdvance(nscoord &aAdvance);
|
nscoord MaxAdvance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the average character width
|
||||||
|
*/
|
||||||
|
nscoord AveCharWidth();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the often needed width of the space character
|
||||||
|
*/
|
||||||
|
nscoord SpaceWidth();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the font associated with these metrics. The return value
|
* Returns the font associated with these metrics. The return value
|
||||||
@@ -191,44 +197,31 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Returns the language associated with these metrics
|
* Returns the language associated with these metrics
|
||||||
*/
|
*/
|
||||||
nsresult GetLanguage(nsIAtom** aLanguage);
|
already_AddRefed<nsIAtom> GetLanguage();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the average character width
|
|
||||||
*/
|
|
||||||
nsresult GetAveCharWidth(nscoord& aAveCharWidth);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the often needed width of the space character
|
|
||||||
*/
|
|
||||||
nsresult GetSpaceWidth(nscoord& aSpaceCharWidth);
|
|
||||||
|
|
||||||
PRInt32 GetMaxStringLength();
|
PRInt32 GetMaxStringLength();
|
||||||
|
|
||||||
// Get the width for this string. aWidth will be updated with the
|
// Get the width for this string. aWidth will be updated with the
|
||||||
// width in points, not twips. Callers must convert it if they
|
// width in points, not twips. Callers must convert it if they
|
||||||
// want it in another format.
|
// want it in another format.
|
||||||
nsresult GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth,
|
nscoord GetWidth(const char* aString, PRUint32 aLength,
|
||||||
nsRenderingContext *aContext);
|
nsRenderingContext *aContext);
|
||||||
nsresult GetWidth(const PRUnichar* aString, PRUint32 aLength,
|
nscoord GetWidth(const PRUnichar* aString, PRUint32 aLength,
|
||||||
nscoord& aWidth, PRInt32 *aFontID,
|
nsRenderingContext *aContext);
|
||||||
nsRenderingContext *aContext);
|
|
||||||
|
|
||||||
// Draw a string using this font handle on the surface passed in.
|
// Draw a string using this font handle on the surface passed in.
|
||||||
nsresult DrawString(const char *aString, PRUint32 aLength,
|
void DrawString(const char *aString, PRUint32 aLength,
|
||||||
nscoord aX, nscoord aY,
|
nscoord aX, nscoord aY,
|
||||||
const nscoord* aSpacing,
|
nsRenderingContext *aContext);
|
||||||
nsRenderingContext *aContext);
|
void DrawString(const PRUnichar* aString, PRUint32 aLength,
|
||||||
nsresult DrawString(const PRUnichar* aString, PRUint32 aLength,
|
nscoord aX, nscoord aY,
|
||||||
nscoord aX, nscoord aY,
|
nsRenderingContext *aContext,
|
||||||
nsRenderingContext *aContext,
|
nsRenderingContext *aTextRunConstructionContext);
|
||||||
nsRenderingContext *aTextRunConstructionContext);
|
|
||||||
|
|
||||||
#ifdef MOZ_MATHML
|
#ifdef MOZ_MATHML
|
||||||
nsresult GetBoundingMetrics(const PRUnichar *aString,
|
nsBoundingMetrics GetBoundingMetrics(const PRUnichar *aString,
|
||||||
PRUint32 aLength,
|
PRUint32 aLength,
|
||||||
nsRenderingContext *aContext,
|
nsRenderingContext *aContext);
|
||||||
nsBoundingMetrics &aBoundingMetrics);
|
|
||||||
#endif /* MOZ_MATHML */
|
#endif /* MOZ_MATHML */
|
||||||
|
|
||||||
// Set the direction of the text rendering
|
// Set the direction of the text rendering
|
||||||
|
|||||||
@@ -494,9 +494,7 @@ nscoord
|
|||||||
nsRenderingContext::GetWidth(char aC)
|
nsRenderingContext::GetWidth(char aC)
|
||||||
{
|
{
|
||||||
if (aC == ' ' && mFontMetrics) {
|
if (aC == ' ' && mFontMetrics) {
|
||||||
nscoord width;
|
return mFontMetrics->SpaceWidth();
|
||||||
mFontMetrics->GetSpaceWidth(width);
|
|
||||||
return width;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetWidth(&aC, 1);
|
return GetWidth(&aC, 1);
|
||||||
@@ -527,7 +525,7 @@ nsRenderingContext::GetWidth(const char* aString, PRUint32 aLength)
|
|||||||
nscoord width = 0;
|
nscoord width = 0;
|
||||||
while (aLength > 0) {
|
while (aLength > 0) {
|
||||||
PRInt32 len = FindSafeLength(aString, aLength, maxChunkLength);
|
PRInt32 len = FindSafeLength(aString, aLength, maxChunkLength);
|
||||||
width += GetWidthInternal(aString, len);
|
width += mFontMetrics->GetWidth(aString, len, this);
|
||||||
aLength -= len;
|
aLength -= len;
|
||||||
aString += len;
|
aString += len;
|
||||||
}
|
}
|
||||||
@@ -541,7 +539,7 @@ nsRenderingContext::GetWidth(const PRUnichar *aString, PRUint32 aLength)
|
|||||||
nscoord width = 0;
|
nscoord width = 0;
|
||||||
while (aLength > 0) {
|
while (aLength > 0) {
|
||||||
PRInt32 len = FindSafeLength(aString, aLength, maxChunkLength);
|
PRInt32 len = FindSafeLength(aString, aLength, maxChunkLength);
|
||||||
width += GetWidthInternal(aString, len);
|
width += mFontMetrics->GetWidth(aString, len, this);
|
||||||
aLength -= len;
|
aLength -= len;
|
||||||
aString += len;
|
aString += len;
|
||||||
}
|
}
|
||||||
@@ -558,15 +556,15 @@ nsRenderingContext::GetBoundingMetrics(const PRUnichar* aString,
|
|||||||
// Assign directly in the first iteration. This ensures that
|
// Assign directly in the first iteration. This ensures that
|
||||||
// negative ascent/descent can be returned and the left bearing
|
// negative ascent/descent can be returned and the left bearing
|
||||||
// is properly initialized.
|
// is properly initialized.
|
||||||
nsBoundingMetrics totalMetrics;
|
nsBoundingMetrics totalMetrics
|
||||||
mFontMetrics->GetBoundingMetrics(aString, len, this, totalMetrics);
|
= mFontMetrics->GetBoundingMetrics(aString, len, this);
|
||||||
aLength -= len;
|
aLength -= len;
|
||||||
aString += len;
|
aString += len;
|
||||||
|
|
||||||
while (aLength > 0) {
|
while (aLength > 0) {
|
||||||
len = FindSafeLength(aString, aLength, maxChunkLength);
|
len = FindSafeLength(aString, aLength, maxChunkLength);
|
||||||
nsBoundingMetrics metrics;
|
nsBoundingMetrics metrics
|
||||||
mFontMetrics->GetBoundingMetrics(aString, len, this, metrics);
|
= mFontMetrics->GetBoundingMetrics(aString, len, this);
|
||||||
totalMetrics += metrics;
|
totalMetrics += metrics;
|
||||||
aLength -= len;
|
aLength -= len;
|
||||||
aString += len;
|
aString += len;
|
||||||
@@ -582,11 +580,11 @@ nsRenderingContext::DrawString(const char *aString, PRUint32 aLength,
|
|||||||
PRUint32 maxChunkLength = GetMaxChunkLength();
|
PRUint32 maxChunkLength = GetMaxChunkLength();
|
||||||
while (aLength > 0) {
|
while (aLength > 0) {
|
||||||
PRInt32 len = FindSafeLength(aString, aLength, maxChunkLength);
|
PRInt32 len = FindSafeLength(aString, aLength, maxChunkLength);
|
||||||
mFontMetrics->DrawString(aString, len, aX, aY, nsnull, this);
|
mFontMetrics->DrawString(aString, len, aX, aY, this);
|
||||||
aLength -= len;
|
aLength -= len;
|
||||||
|
|
||||||
if (aLength > 0) {
|
if (aLength > 0) {
|
||||||
nscoord width = GetWidthInternal(aString, len);
|
nscoord width = mFontMetrics->GetWidth(aString, len, this);
|
||||||
aX += width;
|
aX += width;
|
||||||
aString += len;
|
aString += len;
|
||||||
}
|
}
|
||||||
@@ -618,7 +616,7 @@ nsRenderingContext::DrawString(const PRUnichar *aString, PRUint32 aLength,
|
|||||||
|
|
||||||
while (aLength > 0) {
|
while (aLength > 0) {
|
||||||
PRInt32 len = FindSafeLength(aString, aLength, maxChunkLength);
|
PRInt32 len = FindSafeLength(aString, aLength, maxChunkLength);
|
||||||
nscoord width = GetWidthInternal(aString, len);
|
nscoord width = mFontMetrics->GetWidth(aString, len, this);
|
||||||
if (isRTL) {
|
if (isRTL) {
|
||||||
aX -= width;
|
aX -= width;
|
||||||
}
|
}
|
||||||
@@ -630,27 +628,3 @@ nsRenderingContext::DrawString(const PRUnichar *aString, PRUint32 aLength,
|
|||||||
aString += len;
|
aString += len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord
|
|
||||||
nsRenderingContext::GetWidthInternal(const char* aString, PRUint32 aLength)
|
|
||||||
{
|
|
||||||
if (aLength == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
nscoord width;
|
|
||||||
mFontMetrics->GetWidth(aString, aLength, width, this);
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
nscoord
|
|
||||||
nsRenderingContext::GetWidthInternal(const PRUnichar *aString, PRUint32 aLength)
|
|
||||||
{
|
|
||||||
if (aLength == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
nscoord width;
|
|
||||||
mFontMetrics->GetWidth(aString, aLength, width, nsnull, this);
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -146,8 +146,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
PRInt32 GetMaxChunkLength();
|
PRInt32 GetMaxChunkLength();
|
||||||
nscoord GetWidthInternal(const char *aString, PRUint32 aLength);
|
|
||||||
nscoord GetWidthInternal(const PRUnichar *aString, PRUint32 aLength);
|
|
||||||
|
|
||||||
nsRefPtr<gfxContext> mThebes;
|
nsRefPtr<gfxContext> mThebes;
|
||||||
nsCOMPtr<nsIDeviceContext> mDeviceContext;
|
nsCOMPtr<nsIDeviceContext> mDeviceContext;
|
||||||
|
|||||||
@@ -151,8 +151,7 @@ nsFontCache::GetMetricsFor(const nsFont& aFont, nsIAtom* aLanguage,
|
|||||||
for (PRInt32 i = n; i >= 0; --i) {
|
for (PRInt32 i = n; i >= 0; --i) {
|
||||||
fm = mFontMetrics[i];
|
fm = mFontMetrics[i];
|
||||||
if (fm->Font().Equals(aFont) && fm->GetUserFontSet() == aUserFontSet) {
|
if (fm->Font().Equals(aFont) && fm->GetUserFontSet() == aUserFontSet) {
|
||||||
nsCOMPtr<nsIAtom> language;
|
nsCOMPtr<nsIAtom> language = fm->GetLanguage();
|
||||||
fm->GetLanguage(getter_AddRefs(language));
|
|
||||||
if (aLanguage == language.get()) {
|
if (aLanguage == language.get()) {
|
||||||
if (i != n) {
|
if (i != n) {
|
||||||
// promote it to the end of the cache
|
// promote it to the end of the cache
|
||||||
|
|||||||
@@ -360,8 +360,8 @@ nsCaret::GetGeometryForFrame(nsIFrame* aFrame,
|
|||||||
nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm));
|
nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm));
|
||||||
NS_ASSERTION(fm, "We should be able to get the font metrics");
|
NS_ASSERTION(fm, "We should be able to get the font metrics");
|
||||||
if (fm) {
|
if (fm) {
|
||||||
fm->GetMaxAscent(ascent);
|
ascent = fm->MaxAscent();
|
||||||
fm->GetMaxDescent(descent);
|
descent = fm->MaxDescent();
|
||||||
}
|
}
|
||||||
nscoord height = ascent + descent;
|
nscoord height = ascent + descent;
|
||||||
framePos.y = baseline - ascent;
|
framePos.y = baseline - ascent;
|
||||||
|
|||||||
@@ -1644,7 +1644,7 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
|
|||||||
nsIWidget *widget = aFrame->GetNearestWidget();
|
nsIWidget *widget = aFrame->GetNearestWidget();
|
||||||
if (widget) {
|
if (widget) {
|
||||||
PRInt32 pixelRatio = presContext->AppUnitsPerDevPixel();
|
PRInt32 pixelRatio = presContext->AppUnitsPerDevPixel();
|
||||||
nsIntRegion visibleWindowRegion(visibleRegion.ToOutsidePixels(presContext->AppUnitsPerDevPixel()));
|
nsIntRegion visibleWindowRegion(visibleRegion.ToOutsidePixels(pixelRatio));
|
||||||
widget->UpdateTransparentRegion(visibleWindowRegion);
|
widget->UpdateTransparentRegion(visibleWindowRegion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2845,9 +2845,8 @@ nsLayoutUtils::GetStringWidth(const nsIFrame* aFrame,
|
|||||||
nsLayoutUtils::GetCenteredFontBaseline(nsFontMetrics* aFontMetrics,
|
nsLayoutUtils::GetCenteredFontBaseline(nsFontMetrics* aFontMetrics,
|
||||||
nscoord aLineHeight)
|
nscoord aLineHeight)
|
||||||
{
|
{
|
||||||
nscoord fontAscent, fontHeight;
|
nscoord fontAscent = aFontMetrics->MaxAscent();
|
||||||
aFontMetrics->GetMaxAscent(fontAscent);
|
nscoord fontHeight = aFontMetrics->MaxHeight();
|
||||||
aFontMetrics->GetMaxHeight(fontHeight);
|
|
||||||
|
|
||||||
nscoord leading = aLineHeight - fontHeight;
|
nscoord leading = aLineHeight - fontHeight;
|
||||||
return fontAscent + leading/2;
|
return fontAscent + leading/2;
|
||||||
|
|||||||
@@ -8809,12 +8809,10 @@ void ReflowCountMgr::PaintCount(const char* aName,
|
|||||||
aRenderingContext->SetFont(fm);
|
aRenderingContext->SetFont(fm);
|
||||||
char buf[16];
|
char buf[16];
|
||||||
sprintf(buf, "%d", counter->mCount);
|
sprintf(buf, "%d", counter->mCount);
|
||||||
nscoord x = 0, y;
|
nscoord x = 0, y = fm->MaxAscent();
|
||||||
nscoord width, height;
|
nscoord width, height = fm->MaxHeight();
|
||||||
aRenderingContext->SetTextRunRTL(PR_FALSE);
|
aRenderingContext->SetTextRunRTL(PR_FALSE);
|
||||||
aRenderingContext->GetWidth((char*)buf, width);
|
aRenderingContext->GetWidth((char*)buf, width);
|
||||||
fm->GetMaxHeight(height);
|
|
||||||
fm->GetMaxAscent(y);
|
|
||||||
|
|
||||||
PRUint32 color;
|
PRUint32 color;
|
||||||
PRUint32 color2;
|
PRUint32 color2;
|
||||||
|
|||||||
@@ -1878,11 +1878,11 @@ nscoord
|
|||||||
nsListControlFrame::CalcFallbackRowHeight()
|
nsListControlFrame::CalcFallbackRowHeight()
|
||||||
{
|
{
|
||||||
nscoord rowHeight = 0;
|
nscoord rowHeight = 0;
|
||||||
|
|
||||||
nsRefPtr<nsFontMetrics> fontMet;
|
nsRefPtr<nsFontMetrics> fontMet;
|
||||||
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet));
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet));
|
||||||
if (fontMet) {
|
if (fontMet) {
|
||||||
fontMet->GetMaxHeight(rowHeight);
|
rowHeight = fontMet->MaxHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
return rowHeight;
|
return rowHeight;
|
||||||
|
|||||||
@@ -237,8 +237,8 @@ nsTextControlFrame::CalcIntrinsicSize(nsRenderingContext* aRenderingContext,
|
|||||||
|
|
||||||
lineHeight =
|
lineHeight =
|
||||||
nsHTMLReflowState::CalcLineHeight(GetStyleContext(), NS_AUTOHEIGHT);
|
nsHTMLReflowState::CalcLineHeight(GetStyleContext(), NS_AUTOHEIGHT);
|
||||||
fontMet->GetAveCharWidth(charWidth);
|
charWidth = fontMet->AveCharWidth();
|
||||||
fontMet->GetMaxAdvance(charMaxAdvance);
|
charMaxAdvance = fontMet->MaxAdvance();
|
||||||
|
|
||||||
// Set the width equal to the width in characters
|
// Set the width equal to the width in characters
|
||||||
PRInt32 cols = GetCols();
|
PRInt32 cols = GetCols();
|
||||||
|
|||||||
@@ -239,8 +239,7 @@ BRFrame::GetBaseline() const
|
|||||||
if (GetStateBits() & BR_USING_CENTERED_FONT_BASELINE) {
|
if (GetStateBits() & BR_USING_CENTERED_FONT_BASELINE) {
|
||||||
ascent = nsLayoutUtils::GetCenteredFontBaseline(fm, logicalHeight);
|
ascent = nsLayoutUtils::GetCenteredFontBaseline(fm, logicalHeight);
|
||||||
} else {
|
} else {
|
||||||
fm->GetMaxAscent(ascent);
|
ascent = fm->MaxAscent() + GetUsedBorderAndPadding().top;
|
||||||
ascent += GetUsedBorderAndPadding().top;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NS_MIN(mRect.height, ascent);
|
return NS_MIN(mRect.height, ascent);
|
||||||
|
|||||||
@@ -388,8 +388,7 @@ nsBulletFrame::PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt,
|
|||||||
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
|
||||||
GetListItemText(*myList, text);
|
GetListItemText(*myList, text);
|
||||||
aRenderingContext.SetFont(fm);
|
aRenderingContext.SetFont(fm);
|
||||||
nscoord ascent;
|
nscoord ascent = fm->MaxAscent();
|
||||||
fm->GetMaxAscent(ascent);
|
|
||||||
aRenderingContext.SetTextRunRTL(mTextIsRTL);
|
aRenderingContext.SetTextRunRTL(mTextIsRTL);
|
||||||
aRenderingContext.DrawString(text, mPadding.left + aPt.x,
|
aRenderingContext.DrawString(text, mPadding.left + aPt.x,
|
||||||
mPadding.top + aPt.y + ascent);
|
mPadding.top + aPt.y + ascent);
|
||||||
@@ -1361,7 +1360,7 @@ nsBulletFrame::GetDesiredSize(nsPresContext* aCX,
|
|||||||
case NS_STYLE_LIST_STYLE_DISC:
|
case NS_STYLE_LIST_STYLE_DISC:
|
||||||
case NS_STYLE_LIST_STYLE_CIRCLE:
|
case NS_STYLE_LIST_STYLE_CIRCLE:
|
||||||
case NS_STYLE_LIST_STYLE_SQUARE:
|
case NS_STYLE_LIST_STYLE_SQUARE:
|
||||||
fm->GetMaxAscent(ascent);
|
ascent = fm->MaxAscent();
|
||||||
bulletSize = NS_MAX(nsPresContext::CSSPixelsToAppUnits(MIN_BULLET_SIZE),
|
bulletSize = NS_MAX(nsPresContext::CSSPixelsToAppUnits(MIN_BULLET_SIZE),
|
||||||
NSToCoordRound(0.8f * (float(ascent) / 2.0f)));
|
NSToCoordRound(0.8f * (float(ascent) / 2.0f)));
|
||||||
mPadding.bottom = NSToCoordRound(float(ascent) / 8.0f);
|
mPadding.bottom = NSToCoordRound(float(ascent) / 8.0f);
|
||||||
@@ -1422,11 +1421,13 @@ nsBulletFrame::GetDesiredSize(nsPresContext* aCX,
|
|||||||
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER:
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER:
|
||||||
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET:
|
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET:
|
||||||
GetListItemText(*myList, text);
|
GetListItemText(*myList, text);
|
||||||
fm->GetMaxHeight(aMetrics.height);
|
aMetrics.height = fm->MaxHeight();
|
||||||
aRenderingContext->SetFont(fm);
|
aRenderingContext->SetFont(fm);
|
||||||
aMetrics.width = nsLayoutUtils::GetStringWidth(this, aRenderingContext, text.get(), text.Length());
|
aMetrics.width =
|
||||||
|
nsLayoutUtils::GetStringWidth(this, aRenderingContext,
|
||||||
|
text.get(), text.Length());
|
||||||
aMetrics.width += mPadding.right;
|
aMetrics.width += mPadding.right;
|
||||||
fm->GetMaxAscent(aMetrics.ascent);
|
aMetrics.ascent = fm->MaxAscent();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1601,7 +1602,7 @@ nsBulletFrame::GetBaseline() const
|
|||||||
case NS_STYLE_LIST_STYLE_DISC:
|
case NS_STYLE_LIST_STYLE_DISC:
|
||||||
case NS_STYLE_LIST_STYLE_CIRCLE:
|
case NS_STYLE_LIST_STYLE_CIRCLE:
|
||||||
case NS_STYLE_LIST_STYLE_SQUARE:
|
case NS_STYLE_LIST_STYLE_SQUARE:
|
||||||
fm->GetMaxAscent(ascent);
|
ascent = fm->MaxAscent();
|
||||||
bottomPadding = NSToCoordRound(float(ascent) / 8.0f);
|
bottomPadding = NSToCoordRound(float(ascent) / 8.0f);
|
||||||
ascent = NS_MAX(nsPresContext::CSSPixelsToAppUnits(MIN_BULLET_SIZE),
|
ascent = NS_MAX(nsPresContext::CSSPixelsToAppUnits(MIN_BULLET_SIZE),
|
||||||
NSToCoordRound(0.8f * (float(ascent) / 2.0f)));
|
NSToCoordRound(0.8f * (float(ascent) / 2.0f)));
|
||||||
@@ -1609,7 +1610,7 @@ nsBulletFrame::GetBaseline() const
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fm->GetMaxAscent(ascent);
|
ascent = fm->MaxAscent();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2206,7 +2206,7 @@ nsGfxScrollFrameInner::GetLineScrollAmount() const
|
|||||||
NS_ASSERTION(fm, "FontMetrics is null, assuming fontHeight == 1 appunit");
|
NS_ASSERTION(fm, "FontMetrics is null, assuming fontHeight == 1 appunit");
|
||||||
nscoord fontHeight = 1;
|
nscoord fontHeight = 1;
|
||||||
if (fm) {
|
if (fm) {
|
||||||
fm->GetMaxHeight(fontHeight);
|
fontHeight = fm->MaxHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
return nsSize(fontHeight, fontHeight);
|
return nsSize(fontHeight, fontHeight);
|
||||||
|
|||||||
@@ -2112,10 +2112,9 @@ GetNormalLineHeight(nsFontMetrics* aFontMetrics)
|
|||||||
|
|
||||||
nscoord normalLineHeight;
|
nscoord normalLineHeight;
|
||||||
|
|
||||||
nscoord externalLeading, internalLeading, emHeight;
|
nscoord externalLeading = aFontMetrics->ExternalLeading();
|
||||||
aFontMetrics->GetExternalLeading(externalLeading);
|
nscoord internalLeading = aFontMetrics->InternalLeading();
|
||||||
aFontMetrics->GetInternalLeading(internalLeading);
|
nscoord emHeight = aFontMetrics->EmHeight();
|
||||||
aFontMetrics->GetEmHeight(emHeight);
|
|
||||||
switch (GetNormalLineHeightCalcControl()) {
|
switch (GetNormalLineHeightCalcControl()) {
|
||||||
case eIncludeExternalLeading:
|
case eIncludeExternalLeading:
|
||||||
normalLineHeight = emHeight+ internalLeading + externalLeading;
|
normalLineHeight = emHeight+ internalLeading + externalLeading;
|
||||||
|
|||||||
@@ -976,10 +976,9 @@ nsImageFrame::DisplayAltText(nsPresContext* aPresContext,
|
|||||||
// Format the text to display within the formatting rect
|
// Format the text to display within the formatting rect
|
||||||
nsFontMetrics* fm = aRenderingContext.FontMetrics();
|
nsFontMetrics* fm = aRenderingContext.FontMetrics();
|
||||||
|
|
||||||
nscoord maxAscent, maxDescent, height;
|
nscoord maxAscent = fm->MaxAscent();
|
||||||
fm->GetMaxAscent(maxAscent);
|
nscoord maxDescent = fm->MaxDescent();
|
||||||
fm->GetMaxDescent(maxDescent);
|
nscoord height = fm->MaxHeight();
|
||||||
fm->GetMaxHeight(height);
|
|
||||||
|
|
||||||
// XXX It would be nice if there was a way to have the font metrics tell
|
// XXX It would be nice if there was a way to have the font metrics tell
|
||||||
// use where to break the text given a maximum width. At a minimum we need
|
// use where to break the text given a maximum width. At a minimum we need
|
||||||
|
|||||||
@@ -656,8 +656,8 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
|
|||||||
// The height of our box is the sum of our font size plus the top
|
// The height of our box is the sum of our font size plus the top
|
||||||
// and bottom border and padding. The height of children do not
|
// and bottom border and padding. The height of children do not
|
||||||
// affect our height.
|
// affect our height.
|
||||||
fm->GetMaxAscent(aMetrics.ascent);
|
aMetrics.ascent = fm->MaxAscent();
|
||||||
fm->GetMaxHeight(aMetrics.height);
|
aMetrics.height = fm->MaxHeight();
|
||||||
} else {
|
} else {
|
||||||
NS_WARNING("Cannot get font metrics - defaulting sizes to 0");
|
NS_WARNING("Cannot get font metrics - defaulting sizes to 0");
|
||||||
aMetrics.ascent = aMetrics.height = 0;
|
aMetrics.ascent = aMetrics.height = 0;
|
||||||
@@ -914,8 +914,9 @@ nsInlineFrame::GetBaseline() const
|
|||||||
{
|
{
|
||||||
nscoord ascent = 0;
|
nscoord ascent = 0;
|
||||||
nsRefPtr<nsFontMetrics> fm;
|
nsRefPtr<nsFontMetrics> fm;
|
||||||
if (NS_SUCCEEDED(nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm)))) {
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
|
||||||
fm->GetMaxAscent(ascent);
|
if (fm) {
|
||||||
|
ascent = fm->MaxAscent();
|
||||||
}
|
}
|
||||||
return NS_MIN(mRect.height, ascent + GetUsedBorderAndPadding().top);
|
return NS_MIN(mRect.height, ascent + GetUsedBorderAndPadding().top);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1810,8 +1810,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
|
|||||||
// of the parent's box. This is identical to the baseline
|
// of the parent's box. This is identical to the baseline
|
||||||
// alignment except for the addition of the subscript
|
// alignment except for the addition of the subscript
|
||||||
// offset to the baseline Y.
|
// offset to the baseline Y.
|
||||||
nscoord parentSubscript;
|
nscoord parentSubscript = fm->SubscriptOffset();
|
||||||
fm->GetSubscriptOffset(parentSubscript);
|
|
||||||
nscoord revisedBaselineY = baselineY + parentSubscript;
|
nscoord revisedBaselineY = baselineY + parentSubscript;
|
||||||
pfd->mBounds.y = revisedBaselineY - pfd->mAscent;
|
pfd->mBounds.y = revisedBaselineY - pfd->mAscent;
|
||||||
pfd->mVerticalAlign = VALIGN_OTHER;
|
pfd->mVerticalAlign = VALIGN_OTHER;
|
||||||
@@ -1824,8 +1823,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
|
|||||||
// of the parent's box. This is identical to the baseline
|
// of the parent's box. This is identical to the baseline
|
||||||
// alignment except for the subtraction of the superscript
|
// alignment except for the subtraction of the superscript
|
||||||
// offset to the baseline Y.
|
// offset to the baseline Y.
|
||||||
nscoord parentSuperscript;
|
nscoord parentSuperscript = fm->SuperscriptOffset();
|
||||||
fm->GetSuperscriptOffset(parentSuperscript);
|
|
||||||
nscoord revisedBaselineY = baselineY - parentSuperscript;
|
nscoord revisedBaselineY = baselineY - parentSuperscript;
|
||||||
pfd->mBounds.y = revisedBaselineY - pfd->mAscent;
|
pfd->mBounds.y = revisedBaselineY - pfd->mAscent;
|
||||||
pfd->mVerticalAlign = VALIGN_OTHER;
|
pfd->mVerticalAlign = VALIGN_OTHER;
|
||||||
@@ -1866,8 +1864,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
|
|||||||
{
|
{
|
||||||
// Align the midpoint of the frame with 1/2 the parents
|
// Align the midpoint of the frame with 1/2 the parents
|
||||||
// x-height above the baseline.
|
// x-height above the baseline.
|
||||||
nscoord parentXHeight;
|
nscoord parentXHeight = fm->XHeight();
|
||||||
fm->GetXHeight(parentXHeight);
|
|
||||||
if (frameSpan) {
|
if (frameSpan) {
|
||||||
pfd->mBounds.y = baselineY -
|
pfd->mBounds.y = baselineY -
|
||||||
(parentXHeight + pfd->mBounds.height)/2;
|
(parentXHeight + pfd->mBounds.height)/2;
|
||||||
@@ -1884,8 +1881,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
|
|||||||
{
|
{
|
||||||
// The top of the logical box is aligned with the top of
|
// The top of the logical box is aligned with the top of
|
||||||
// the parent element's text.
|
// the parent element's text.
|
||||||
nscoord parentAscent;
|
nscoord parentAscent = fm->MaxAscent();
|
||||||
fm->GetMaxAscent(parentAscent);
|
|
||||||
if (frameSpan) {
|
if (frameSpan) {
|
||||||
pfd->mBounds.y = baselineY - parentAscent -
|
pfd->mBounds.y = baselineY - parentAscent -
|
||||||
pfd->mBorderPadding.top + frameSpan->mTopLeading;
|
pfd->mBorderPadding.top + frameSpan->mTopLeading;
|
||||||
@@ -1901,8 +1897,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
|
|||||||
{
|
{
|
||||||
// The bottom of the logical box is aligned with the
|
// The bottom of the logical box is aligned with the
|
||||||
// bottom of the parent elements text.
|
// bottom of the parent elements text.
|
||||||
nscoord parentDescent;
|
nscoord parentDescent = fm->MaxDescent();
|
||||||
fm->GetMaxDescent(parentDescent);
|
|
||||||
if (frameSpan) {
|
if (frameSpan) {
|
||||||
pfd->mBounds.y = baselineY + parentDescent -
|
pfd->mBounds.y = baselineY + parentDescent -
|
||||||
pfd->mBounds.height + pfd->mBorderPadding.bottom -
|
pfd->mBounds.height + pfd->mBorderPadding.bottom -
|
||||||
|
|||||||
@@ -520,8 +520,8 @@ nsPageFrame::PaintHeaderFooter(nsRenderingContext& aRenderingContext,
|
|||||||
nscoord ascent = 0;
|
nscoord ascent = 0;
|
||||||
nscoord visibleHeight = 0;
|
nscoord visibleHeight = 0;
|
||||||
if (fontMet) {
|
if (fontMet) {
|
||||||
fontMet->GetMaxHeight(visibleHeight);
|
visibleHeight = fontMet->MaxHeight();
|
||||||
fontMet->GetMaxAscent(ascent);
|
ascent = fontMet->MaxAscent();
|
||||||
}
|
}
|
||||||
|
|
||||||
// print document headers and footers
|
// print document headers and footers
|
||||||
|
|||||||
@@ -4338,10 +4338,9 @@ nsTextFrame::UnionTextDecorationOverflow(nsPresContext* aPresContext,
|
|||||||
if (IsFloatingFirstLetterChild()) {
|
if (IsFloatingFirstLetterChild()) {
|
||||||
// The underline/overline drawable area must be contained in the overflow
|
// The underline/overline drawable area must be contained in the overflow
|
||||||
// rect when this is in floating first letter frame at *both* modes.
|
// rect when this is in floating first letter frame at *both* modes.
|
||||||
nscoord fontAscent, fontHeight;
|
|
||||||
nsFontMetrics* fm = aProvider.GetFontMetrics();
|
nsFontMetrics* fm = aProvider.GetFontMetrics();
|
||||||
fm->GetMaxAscent(fontAscent);
|
nscoord fontAscent = fm->MaxAscent();
|
||||||
fm->GetMaxHeight(fontHeight);
|
nscoord fontHeight = fm->MaxHeight();
|
||||||
nsRect fontRect(0, mAscent - fontAscent, GetSize().width, fontHeight);
|
nsRect fontRect(0, mAscent - fontAscent, GetSize().width, fontHeight);
|
||||||
aVisualOverflowRect->UnionRect(*aVisualOverflowRect, fontRect);
|
aVisualOverflowRect->UnionRect(*aVisualOverflowRect, fontRect);
|
||||||
}
|
}
|
||||||
@@ -6786,11 +6785,8 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
|
|||||||
// the height manually.
|
// the height manually.
|
||||||
nsFontMetrics* fm = provider.GetFontMetrics();
|
nsFontMetrics* fm = provider.GetFontMetrics();
|
||||||
if (fm) {
|
if (fm) {
|
||||||
nscoord ascent, descent;
|
textMetrics.mAscent = gfxFloat(fm->MaxAscent());
|
||||||
fm->GetMaxAscent(ascent);
|
textMetrics.mDescent = gfxFloat(fm->MaxDescent());
|
||||||
fm->GetMaxDescent(descent);
|
|
||||||
textMetrics.mAscent = gfxFloat(ascent);
|
|
||||||
textMetrics.mDescent = gfxFloat(descent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// The "end" iterator points to the first character after the string mapped
|
// The "end" iterator points to the first character after the string mapped
|
||||||
@@ -6895,10 +6891,9 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
|
|||||||
// Otherwise, ascent should contain the overline drawable area.
|
// Otherwise, ascent should contain the overline drawable area.
|
||||||
// And also descent should contain the underline drawable area.
|
// And also descent should contain the underline drawable area.
|
||||||
// nsFontMetrics::GetMaxAscent/GetMaxDescent contains them.
|
// nsFontMetrics::GetMaxAscent/GetMaxDescent contains them.
|
||||||
nscoord fontAscent, fontDescent;
|
|
||||||
nsFontMetrics* fm = provider.GetFontMetrics();
|
nsFontMetrics* fm = provider.GetFontMetrics();
|
||||||
fm->GetMaxAscent(fontAscent);
|
nscoord fontAscent = fm->MaxAscent();
|
||||||
fm->GetMaxDescent(fontDescent);
|
nscoord fontDescent = fm->MaxDescent();
|
||||||
aMetrics.ascent = NS_MAX(NSToCoordCeil(textMetrics.mAscent), fontAscent);
|
aMetrics.ascent = NS_MAX(NSToCoordCeil(textMetrics.mAscent), fontAscent);
|
||||||
nscoord descent = NS_MAX(NSToCoordCeil(textMetrics.mDescent), fontDescent);
|
nscoord descent = NS_MAX(NSToCoordCeil(textMetrics.mDescent), fontDescent);
|
||||||
aMetrics.height = aMetrics.ascent + descent;
|
aMetrics.height = aMetrics.ascent + descent;
|
||||||
|
|||||||
@@ -100,9 +100,8 @@ nsMathMLContainerFrame::ReflowError(nsRenderingContext& aRenderingContext,
|
|||||||
|
|
||||||
// reflow metrics
|
// reflow metrics
|
||||||
nsFontMetrics* fm = aRenderingContext.FontMetrics();
|
nsFontMetrics* fm = aRenderingContext.FontMetrics();
|
||||||
fm->GetMaxAscent(aDesiredSize.ascent);
|
aDesiredSize.ascent = fm->MaxAscent();
|
||||||
nscoord descent;
|
nscoord descent = fm->MaxDescent();
|
||||||
fm->GetMaxDescent(descent);
|
|
||||||
aDesiredSize.height = aDesiredSize.ascent + descent;
|
aDesiredSize.height = aDesiredSize.ascent + descent;
|
||||||
aDesiredSize.width = mBoundingMetrics.width;
|
aDesiredSize.width = mBoundingMetrics.width;
|
||||||
|
|
||||||
@@ -140,11 +139,11 @@ void nsDisplayMathMLError::Paint(nsDisplayListBuilder* aBuilder,
|
|||||||
aCtx->FillRect(nsRect(pt, mFrame->GetSize()));
|
aCtx->FillRect(nsRect(pt, mFrame->GetSize()));
|
||||||
aCtx->SetColor(NS_RGB(255,255,255));
|
aCtx->SetColor(NS_RGB(255,255,255));
|
||||||
|
|
||||||
nscoord ascent;
|
nscoord ascent = aCtx->FontMetrics()->MaxAscent();
|
||||||
aCtx->FontMetrics()->GetMaxAscent(ascent);
|
|
||||||
|
|
||||||
nsAutoString errorMsg; errorMsg.AssignLiteral("invalid-markup");
|
NS_NAMED_LITERAL_STRING(errorMsg, "invalid-markup");
|
||||||
aCtx->DrawString(errorMsg.get(), PRUint32(errorMsg.Length()), pt.x, pt.y+ascent);
|
aCtx->DrawString(errorMsg.get(), PRUint32(errorMsg.Length()),
|
||||||
|
pt.x, pt.y+ascent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* /////////////
|
/* /////////////
|
||||||
|
|||||||
@@ -286,8 +286,7 @@ nsMathMLFrame::GetRuleThickness(nsRenderingContext& aRenderingContext,
|
|||||||
Equals(aFontMetrics->Font()),
|
Equals(aFontMetrics->Font()),
|
||||||
"unexpected state");
|
"unexpected state");
|
||||||
|
|
||||||
nscoord xHeight;
|
nscoord xHeight = aFontMetrics->XHeight();
|
||||||
aFontMetrics->GetXHeight(xHeight);
|
|
||||||
PRUnichar overBar = 0x00AF;
|
PRUnichar overBar = 0x00AF;
|
||||||
nsBoundingMetrics bm = aRenderingContext.GetBoundingMetrics(&overBar, 1);
|
nsBoundingMetrics bm = aRenderingContext.GetBoundingMetrics(&overBar, 1);
|
||||||
aRuleThickness = bm.ascent + bm.descent;
|
aRuleThickness = bm.ascent + bm.descent;
|
||||||
@@ -308,8 +307,7 @@ nsMathMLFrame::GetAxisHeight(nsRenderingContext& aRenderingContext,
|
|||||||
Equals(aFontMetrics->Font()),
|
Equals(aFontMetrics->Font()),
|
||||||
"unexpected state");
|
"unexpected state");
|
||||||
|
|
||||||
nscoord xHeight;
|
nscoord xHeight = aFontMetrics->XHeight();
|
||||||
aFontMetrics->GetXHeight(xHeight);
|
|
||||||
PRUnichar minus = 0x2212; // not '-', but official Unicode minus sign
|
PRUnichar minus = 0x2212; // not '-', but official Unicode minus sign
|
||||||
nsBoundingMetrics bm = aRenderingContext.GetBoundingMetrics(&minus, 1);
|
nsBoundingMetrics bm = aRenderingContext.GetBoundingMetrics(&minus, 1);
|
||||||
aAxisHeight = bm.ascent - (bm.ascent + bm.descent)/2;
|
aAxisHeight = bm.ascent - (bm.ascent + bm.descent)/2;
|
||||||
@@ -340,10 +338,9 @@ nsMathMLFrame::CalcLength(nsPresContext* aPresContext,
|
|||||||
return NSToCoordRound(aCSSValue.GetFloatValue() * (float)font->mFont.size);
|
return NSToCoordRound(aCSSValue.GetFloatValue() * (float)font->mFont.size);
|
||||||
}
|
}
|
||||||
else if (eCSSUnit_XHeight == unit) {
|
else if (eCSSUnit_XHeight == unit) {
|
||||||
nscoord xHeight;
|
|
||||||
const nsStyleFont* font = aStyleContext->GetStyleFont();
|
const nsStyleFont* font = aStyleContext->GetStyleFont();
|
||||||
nsRefPtr<nsFontMetrics> fm = aPresContext->GetMetricsFor(font->mFont);
|
nsRefPtr<nsFontMetrics> fm = aPresContext->GetMetricsFor(font->mFont);
|
||||||
fm->GetXHeight(xHeight);
|
nscoord xHeight = fm->XHeight();
|
||||||
return NSToCoordRound(aCSSValue.GetFloatValue() * (float)xHeight);
|
return NSToCoordRound(aCSSValue.GetFloatValue() * (float)xHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -270,8 +270,7 @@ public:
|
|||||||
nscoord& aSubScriptShift1,
|
nscoord& aSubScriptShift1,
|
||||||
nscoord& aSubScriptShift2)
|
nscoord& aSubScriptShift2)
|
||||||
{
|
{
|
||||||
nscoord xHeight;
|
nscoord xHeight = fm->XHeight();
|
||||||
fm->GetXHeight(xHeight);
|
|
||||||
aSubScriptShift1 = NSToCoordRound(150.000f/430.556f * xHeight);
|
aSubScriptShift1 = NSToCoordRound(150.000f/430.556f * xHeight);
|
||||||
aSubScriptShift2 = NSToCoordRound(247.217f/430.556f * xHeight);
|
aSubScriptShift2 = NSToCoordRound(247.217f/430.556f * xHeight);
|
||||||
}
|
}
|
||||||
@@ -283,8 +282,7 @@ public:
|
|||||||
nscoord& aSupScriptShift2,
|
nscoord& aSupScriptShift2,
|
||||||
nscoord& aSupScriptShift3)
|
nscoord& aSupScriptShift3)
|
||||||
{
|
{
|
||||||
nscoord xHeight;
|
nscoord xHeight = fm->XHeight();
|
||||||
fm->GetXHeight(xHeight);
|
|
||||||
aSupScriptShift1 = NSToCoordRound(412.892f/430.556f * xHeight);
|
aSupScriptShift1 = NSToCoordRound(412.892f/430.556f * xHeight);
|
||||||
aSupScriptShift2 = NSToCoordRound(362.892f/430.556f * xHeight);
|
aSupScriptShift2 = NSToCoordRound(362.892f/430.556f * xHeight);
|
||||||
aSupScriptShift3 = NSToCoordRound(288.889f/430.556f * xHeight);
|
aSupScriptShift3 = NSToCoordRound(288.889f/430.556f * xHeight);
|
||||||
@@ -296,8 +294,7 @@ public:
|
|||||||
GetSubDrop(nsFontMetrics* fm,
|
GetSubDrop(nsFontMetrics* fm,
|
||||||
nscoord& aSubDrop)
|
nscoord& aSubDrop)
|
||||||
{
|
{
|
||||||
nscoord xHeight;
|
nscoord xHeight = fm->XHeight();
|
||||||
fm->GetXHeight(xHeight);
|
|
||||||
aSubDrop = NSToCoordRound(50.000f/430.556f * xHeight);
|
aSubDrop = NSToCoordRound(50.000f/430.556f * xHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,8 +302,7 @@ public:
|
|||||||
GetSupDrop(nsFontMetrics* fm,
|
GetSupDrop(nsFontMetrics* fm,
|
||||||
nscoord& aSupDrop)
|
nscoord& aSupDrop)
|
||||||
{
|
{
|
||||||
nscoord xHeight;
|
nscoord xHeight = fm->XHeight();
|
||||||
fm->GetXHeight(xHeight);
|
|
||||||
aSupDrop = NSToCoordRound(386.108f/430.556f * xHeight);
|
aSupDrop = NSToCoordRound(386.108f/430.556f * xHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,8 +312,7 @@ public:
|
|||||||
nscoord& numShift2,
|
nscoord& numShift2,
|
||||||
nscoord& numShift3)
|
nscoord& numShift3)
|
||||||
{
|
{
|
||||||
nscoord xHeight;
|
nscoord xHeight = fm->XHeight();
|
||||||
fm->GetXHeight(xHeight);
|
|
||||||
numShift1 = NSToCoordRound(676.508f/430.556f * xHeight);
|
numShift1 = NSToCoordRound(676.508f/430.556f * xHeight);
|
||||||
numShift2 = NSToCoordRound(393.732f/430.556f * xHeight);
|
numShift2 = NSToCoordRound(393.732f/430.556f * xHeight);
|
||||||
numShift3 = NSToCoordRound(443.731f/430.556f * xHeight);
|
numShift3 = NSToCoordRound(443.731f/430.556f * xHeight);
|
||||||
@@ -328,8 +323,7 @@ public:
|
|||||||
nscoord& denShift1,
|
nscoord& denShift1,
|
||||||
nscoord& denShift2)
|
nscoord& denShift2)
|
||||||
{
|
{
|
||||||
nscoord xHeight;
|
nscoord xHeight = fm->XHeight();
|
||||||
fm->GetXHeight(xHeight);
|
|
||||||
denShift1 = NSToCoordRound(685.951f/430.556f * xHeight);
|
denShift1 = NSToCoordRound(685.951f/430.556f * xHeight);
|
||||||
denShift2 = NSToCoordRound(344.841f/430.556f * xHeight);
|
denShift2 = NSToCoordRound(344.841f/430.556f * xHeight);
|
||||||
}
|
}
|
||||||
@@ -338,9 +332,9 @@ public:
|
|||||||
GetEmHeight(nsFontMetrics* fm,
|
GetEmHeight(nsFontMetrics* fm,
|
||||||
nscoord& emHeight)
|
nscoord& emHeight)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
// should switch to this API in order to scale with changes of TextZoom
|
// should switch to this API in order to scale with changes of TextZoom
|
||||||
fm->GetEmHeight(emHeight);
|
emHeight = fm->EmHeight();
|
||||||
#else
|
#else
|
||||||
emHeight = NSToCoordRound(float(fm->Font().size));
|
emHeight = NSToCoordRound(float(fm->Font().size));
|
||||||
#endif
|
#endif
|
||||||
@@ -350,8 +344,7 @@ public:
|
|||||||
GetAxisHeight (nsFontMetrics* fm,
|
GetAxisHeight (nsFontMetrics* fm,
|
||||||
nscoord& axisHeight)
|
nscoord& axisHeight)
|
||||||
{
|
{
|
||||||
fm->GetXHeight (axisHeight);
|
axisHeight = NSToCoordRound(250.000f/430.556f * fm->XHeight());
|
||||||
axisHeight = NSToCoordRound(250.000f/430.556f * axisHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -362,8 +355,7 @@ public:
|
|||||||
nscoord& bigOpSpacing4,
|
nscoord& bigOpSpacing4,
|
||||||
nscoord& bigOpSpacing5)
|
nscoord& bigOpSpacing5)
|
||||||
{
|
{
|
||||||
nscoord xHeight;
|
nscoord xHeight = fm->XHeight();
|
||||||
fm->GetXHeight(xHeight);
|
|
||||||
bigOpSpacing1 = NSToCoordRound(111.111f/430.556f * xHeight);
|
bigOpSpacing1 = NSToCoordRound(111.111f/430.556f * xHeight);
|
||||||
bigOpSpacing2 = NSToCoordRound(166.667f/430.556f * xHeight);
|
bigOpSpacing2 = NSToCoordRound(166.667f/430.556f * xHeight);
|
||||||
bigOpSpacing3 = NSToCoordRound(200.000f/430.556f * xHeight);
|
bigOpSpacing3 = NSToCoordRound(200.000f/430.556f * xHeight);
|
||||||
@@ -375,8 +367,7 @@ public:
|
|||||||
GetRuleThickness(nsFontMetrics* fm,
|
GetRuleThickness(nsFontMetrics* fm,
|
||||||
nscoord& ruleThickness)
|
nscoord& ruleThickness)
|
||||||
{
|
{
|
||||||
nscoord xHeight;
|
nscoord xHeight = fm->XHeight();
|
||||||
fm->GetXHeight(xHeight);
|
|
||||||
ruleThickness = NSToCoordRound(40.000f/430.556f * xHeight);
|
ruleThickness = NSToCoordRound(40.000f/430.556f * xHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -211,9 +211,8 @@ nsMathMLTokenFrame::Place(nsRenderingContext& aRenderingContext,
|
|||||||
|
|
||||||
nsRefPtr<nsFontMetrics> fm =
|
nsRefPtr<nsFontMetrics> fm =
|
||||||
PresContext()->GetMetricsFor(GetStyleFont()->mFont);
|
PresContext()->GetMetricsFor(GetStyleFont()->mFont);
|
||||||
nscoord ascent, descent;
|
nscoord ascent = fm->MaxAscent();
|
||||||
fm->GetMaxAscent(ascent);
|
nscoord descent = fm->MaxDescent();
|
||||||
fm->GetMaxDescent(descent);
|
|
||||||
|
|
||||||
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
||||||
aDesiredSize.width = mBoundingMetrics.width;
|
aDesiredSize.width = mBoundingMetrics.width;
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
|||||||
// Rule 11, App. G, TeXbook
|
// Rule 11, App. G, TeXbook
|
||||||
// psi = clearance between rule and content
|
// psi = clearance between rule and content
|
||||||
if (NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags))
|
if (NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags))
|
||||||
fm->GetXHeight(phi);
|
phi = fm->XHeight();
|
||||||
else
|
else
|
||||||
phi = mRuleThickness;
|
phi = mRuleThickness;
|
||||||
psi = mRuleThickness + phi / 4;
|
psi = mRuleThickness + phi / 4;
|
||||||
|
|||||||
@@ -269,10 +269,11 @@ nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext,
|
|||||||
nsIFrame* childFrame = firstChild;
|
nsIFrame* childFrame = firstChild;
|
||||||
nscoord ascent = 0, descent = 0;
|
nscoord ascent = 0, descent = 0;
|
||||||
if (firstChild || mOpenChar || mCloseChar || mSeparatorsCount > 0) {
|
if (firstChild || mOpenChar || mCloseChar || mSeparatorsCount > 0) {
|
||||||
// We use the ASCII metrics to get our minimum height. This way, if we have
|
// We use the ASCII metrics to get our minimum height. This way,
|
||||||
// borders or a background, they will fit better with other elements on the line
|
// if we have borders or a background, they will fit better with
|
||||||
fm->GetMaxAscent(ascent);
|
// other elements on the line.
|
||||||
fm->GetMaxDescent(descent);
|
ascent = fm->MaxAscent();
|
||||||
|
descent = fm->MaxDescent();
|
||||||
}
|
}
|
||||||
while (childFrame) {
|
while (childFrame) {
|
||||||
nsHTMLReflowMetrics childDesiredSize(aDesiredSize.mFlags
|
nsHTMLReflowMetrics childDesiredSize(aDesiredSize.mFlags
|
||||||
|
|||||||
@@ -436,8 +436,7 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
|||||||
nscoord slashRatio = 3;
|
nscoord slashRatio = 3;
|
||||||
|
|
||||||
// Define the constant used in the expression of the maximum width
|
// Define the constant used in the expression of the maximum width
|
||||||
nscoord em;
|
nscoord em = fm->EmHeight();
|
||||||
fm->GetEmHeight(em);
|
|
||||||
nscoord slashMaxWidthConstant = 2 * em;
|
nscoord slashMaxWidthConstant = 2 * em;
|
||||||
|
|
||||||
// For large line thicknesses the minimum slash height is limited to the
|
// For large line thicknesses the minimum slash height is limited to the
|
||||||
@@ -477,8 +476,7 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
|||||||
numShift += delta;
|
numShift += delta;
|
||||||
denShift += delta;
|
denShift += delta;
|
||||||
} else {
|
} else {
|
||||||
nscoord xHeight = 0;
|
nscoord xHeight = fm->XHeight();
|
||||||
fm->GetXHeight (xHeight);
|
|
||||||
numShift += xHeight / 2;
|
numShift += xHeight / 2;
|
||||||
denShift += xHeight / 4;
|
denShift += xHeight / 4;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,8 +164,7 @@ nsMathMLmmultiscriptsFrame::Place(nsRenderingContext& aRenderingContext,
|
|||||||
PresContext()->GetUserFontSet());
|
PresContext()->GetUserFontSet());
|
||||||
nsFontMetrics* fm = aRenderingContext.FontMetrics();
|
nsFontMetrics* fm = aRenderingContext.FontMetrics();
|
||||||
|
|
||||||
nscoord xHeight;
|
nscoord xHeight = fm->XHeight();
|
||||||
fm->GetXHeight (xHeight);
|
|
||||||
|
|
||||||
nscoord ruleSize;
|
nscoord ruleSize;
|
||||||
GetRuleThickness (aRenderingContext, fm, ruleSize);
|
GetRuleThickness (aRenderingContext, fm, ruleSize);
|
||||||
|
|||||||
@@ -854,9 +854,8 @@ nsMathMLmoFrame::Stretch(nsRenderingContext& aRenderingContext,
|
|||||||
firstChild->SetPosition(firstChild->GetPosition() - nsPoint(0, dy));
|
firstChild->SetPosition(firstChild->GetPosition() - nsPoint(0, dy));
|
||||||
}
|
}
|
||||||
else if (useMathMLChar) {
|
else if (useMathMLChar) {
|
||||||
nscoord ascent, descent;
|
nscoord ascent = fm->MaxAscent();
|
||||||
fm->GetMaxAscent(ascent);
|
nscoord descent = fm->MaxDescent();
|
||||||
fm->GetMaxDescent(descent);
|
|
||||||
aDesiredStretchSize.ascent = NS_MAX(mBoundingMetrics.ascent + leading, ascent);
|
aDesiredStretchSize.ascent = NS_MAX(mBoundingMetrics.ascent + leading, ascent);
|
||||||
aDesiredStretchSize.height = aDesiredStretchSize.ascent +
|
aDesiredStretchSize.height = aDesiredStretchSize.ascent +
|
||||||
NS_MAX(mBoundingMetrics.descent + leading, descent);
|
NS_MAX(mBoundingMetrics.descent + leading, descent);
|
||||||
|
|||||||
@@ -285,8 +285,7 @@ nsMathMLmoverFrame::Place(nsRenderingContext& aRenderingContext,
|
|||||||
PresContext()->GetUserFontSet());
|
PresContext()->GetUserFontSet());
|
||||||
nsFontMetrics* fm = aRenderingContext.FontMetrics();
|
nsFontMetrics* fm = aRenderingContext.FontMetrics();
|
||||||
|
|
||||||
nscoord xHeight = 0;
|
nscoord xHeight = fm->XHeight();
|
||||||
fm->GetXHeight (xHeight);
|
|
||||||
|
|
||||||
nscoord ruleThickness;
|
nscoord ruleThickness;
|
||||||
GetRuleThickness (aRenderingContext, fm, ruleThickness);
|
GetRuleThickness (aRenderingContext, fm, ruleThickness);
|
||||||
|
|||||||
@@ -161,8 +161,7 @@ GetRadicalXOffsets(nscoord aIndexWidth, nscoord aSqrWidth,
|
|||||||
// The index is tucked in closer to the radical while making sure
|
// The index is tucked in closer to the radical while making sure
|
||||||
// that the kern does not make the index and radical collide
|
// that the kern does not make the index and radical collide
|
||||||
nscoord dxIndex, dxSqr;
|
nscoord dxIndex, dxSqr;
|
||||||
nscoord xHeight = 0;
|
nscoord xHeight = aFontMetrics->XHeight();
|
||||||
aFontMetrics->GetXHeight(xHeight);
|
|
||||||
nscoord indexRadicalKern = NSToCoordRound(1.35f * xHeight);
|
nscoord indexRadicalKern = NSToCoordRound(1.35f * xHeight);
|
||||||
if (indexRadicalKern > aIndexWidth) {
|
if (indexRadicalKern > aIndexWidth) {
|
||||||
dxIndex = indexRadicalKern - aIndexWidth;
|
dxIndex = indexRadicalKern - aIndexWidth;
|
||||||
@@ -281,7 +280,7 @@ nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
|
|||||||
// psi = clearance between rule and content
|
// psi = clearance between rule and content
|
||||||
nscoord phi = 0, psi = 0;
|
nscoord phi = 0, psi = 0;
|
||||||
if (NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags))
|
if (NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags))
|
||||||
fm->GetXHeight(phi);
|
phi = fm->XHeight();
|
||||||
else
|
else
|
||||||
phi = ruleThickness;
|
phi = ruleThickness;
|
||||||
psi = ruleThickness + phi/4;
|
psi = ruleThickness + phi/4;
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ nsMathMLmsubFrame::PlaceSubScript (nsPresContext* aPresContext,
|
|||||||
nsRefPtr<nsFontMetrics> fm =
|
nsRefPtr<nsFontMetrics> fm =
|
||||||
aPresContext->GetMetricsFor(baseFrame->GetStyleFont()->mFont);
|
aPresContext->GetMetricsFor(baseFrame->GetStyleFont()->mFont);
|
||||||
|
|
||||||
fm->GetXHeight (xHeight);
|
xHeight = fm->XHeight();
|
||||||
nscoord minShiftFromXHeight = (nscoord)
|
nscoord minShiftFromXHeight = (nscoord)
|
||||||
(bmSubScript.ascent - (4.0f/5.0f) * xHeight);
|
(bmSubScript.ascent - (4.0f/5.0f) * xHeight);
|
||||||
|
|
||||||
|
|||||||
@@ -198,8 +198,7 @@ nsMathMLmsubsupFrame::PlaceSubSupScript(nsPresContext* aPresContext,
|
|||||||
nsFontMetrics* fm = aRenderingContext.FontMetrics();
|
nsFontMetrics* fm = aRenderingContext.FontMetrics();
|
||||||
|
|
||||||
// get x-height (an ex)
|
// get x-height (an ex)
|
||||||
nscoord xHeight;
|
nscoord xHeight = fm->XHeight();
|
||||||
fm->GetXHeight (xHeight);
|
|
||||||
|
|
||||||
nscoord ruleSize;
|
nscoord ruleSize;
|
||||||
GetRuleThickness (aRenderingContext, fm, ruleSize);
|
GetRuleThickness (aRenderingContext, fm, ruleSize);
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ nsMathMLmsupFrame::PlaceSuperScript(nsPresContext* aPresContext,
|
|||||||
nsRefPtr<nsFontMetrics> fm =
|
nsRefPtr<nsFontMetrics> fm =
|
||||||
aPresContext->GetMetricsFor(baseFrame->GetStyleFont()->mFont);
|
aPresContext->GetMetricsFor(baseFrame->GetStyleFont()->mFont);
|
||||||
|
|
||||||
fm->GetXHeight (xHeight);
|
xHeight = fm->XHeight();
|
||||||
nscoord minShiftFromXHeight = (nscoord)
|
nscoord minShiftFromXHeight = (nscoord)
|
||||||
(bmSupScript.descent + (1.0f/4.0f) * xHeight);
|
(bmSupScript.descent + (1.0f/4.0f) * xHeight);
|
||||||
nscoord italicCorrection;
|
nscoord italicCorrection;
|
||||||
|
|||||||
@@ -282,8 +282,7 @@ nsMathMLmunderFrame::Place(nsRenderingContext& aRenderingContext,
|
|||||||
PresContext()->GetUserFontSet());
|
PresContext()->GetUserFontSet());
|
||||||
nsFontMetrics* fm = aRenderingContext.FontMetrics();
|
nsFontMetrics* fm = aRenderingContext.FontMetrics();
|
||||||
|
|
||||||
nscoord xHeight = 0;
|
nscoord xHeight = fm->XHeight();
|
||||||
fm->GetXHeight (xHeight);
|
|
||||||
|
|
||||||
nscoord ruleThickness;
|
nscoord ruleThickness;
|
||||||
GetRuleThickness (aRenderingContext, fm, ruleThickness);
|
GetRuleThickness (aRenderingContext, fm, ruleThickness);
|
||||||
|
|||||||
@@ -324,8 +324,7 @@ nsMathMLmunderoverFrame::Place(nsRenderingContext& aRenderingContext,
|
|||||||
PresContext()->GetUserFontSet());
|
PresContext()->GetUserFontSet());
|
||||||
nsFontMetrics* fm = aRenderingContext.FontMetrics();
|
nsFontMetrics* fm = aRenderingContext.FontMetrics();
|
||||||
|
|
||||||
nscoord xHeight = 0;
|
nscoord xHeight = fm->XHeight();
|
||||||
fm->GetXHeight (xHeight);
|
|
||||||
|
|
||||||
nscoord ruleThickness;
|
nscoord ruleThickness;
|
||||||
GetRuleThickness (aRenderingContext, fm, ruleThickness);
|
GetRuleThickness (aRenderingContext, fm, ruleThickness);
|
||||||
|
|||||||
@@ -310,9 +310,7 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue,
|
|||||||
font.size = aFontSize;
|
font.size = aFontSize;
|
||||||
nsRefPtr<nsFontMetrics> fm =
|
nsRefPtr<nsFontMetrics> fm =
|
||||||
aPresContext->GetMetricsFor(font, aUseUserFontSet);
|
aPresContext->GetMetricsFor(font, aUseUserFontSet);
|
||||||
nscoord xHeight;
|
return ScaleCoord(aValue, float(fm->XHeight()));
|
||||||
fm->GetXHeight(xHeight);
|
|
||||||
return ScaleCoord(aValue, float(xHeight));
|
|
||||||
}
|
}
|
||||||
case eCSSUnit_Char: {
|
case eCSSUnit_Char: {
|
||||||
nsFont font = styleFont->mFont;
|
nsFont font = styleFont->mFont;
|
||||||
|
|||||||
@@ -297,8 +297,7 @@ nsSVGUtils::GetFontXHeight(nsStyleContext *aStyleContext)
|
|||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord xHeight;
|
nscoord xHeight = fontMetrics->XHeight();
|
||||||
fontMetrics->GetXHeight(xHeight);
|
|
||||||
return nsPresContext::AppUnitsToFloatCSSPixels(xHeight) /
|
return nsPresContext::AppUnitsToFloatCSSPixels(xHeight) /
|
||||||
presContext->TextZoom();
|
presContext->TextZoom();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ nsListBoxBodyFrame::Init(nsIContent* aContent,
|
|||||||
}
|
}
|
||||||
nsRefPtr<nsFontMetrics> fm;
|
nsRefPtr<nsFontMetrics> fm;
|
||||||
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
|
||||||
fm->GetMaxHeight(mRowHeight);
|
mRowHeight = fm->MaxHeight();
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -481,8 +481,7 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
|
|||||||
|
|
||||||
nscoord offset;
|
nscoord offset;
|
||||||
nscoord size;
|
nscoord size;
|
||||||
nscoord ascent;
|
nscoord ascent = fontMet->MaxAscent();
|
||||||
fontMet->GetMaxAscent(ascent);
|
|
||||||
|
|
||||||
nscoord baseline =
|
nscoord baseline =
|
||||||
presContext->RoundAppUnitsToNearestDevPixels(aTextRect.y + ascent);
|
presContext->RoundAppUnitsToNearestDevPixels(aTextRect.y + ascent);
|
||||||
@@ -657,7 +656,7 @@ nsTextBoxFrame::CalculateUnderline(nsRenderingContext& aRenderingContext)
|
|||||||
nscoord offset, baseline;
|
nscoord offset, baseline;
|
||||||
nsFontMetrics* metrics = aRenderingContext.FontMetrics();
|
nsFontMetrics* metrics = aRenderingContext.FontMetrics();
|
||||||
metrics->GetUnderline(offset, mAccessKeyInfo->mAccessUnderlineSize);
|
metrics->GetUnderline(offset, mAccessKeyInfo->mAccessUnderlineSize);
|
||||||
metrics->GetMaxAscent(baseline);
|
baseline = metrics->MaxAscent();
|
||||||
mAccessKeyInfo->mAccessOffset = baseline - offset;
|
mAccessKeyInfo->mAccessOffset = baseline - offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -996,16 +995,19 @@ nsTextBoxFrame::MarkIntrinsicWidthsDirty()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsTextBoxFrame::GetTextSize(nsPresContext* aPresContext, nsRenderingContext& aRenderingContext,
|
nsTextBoxFrame::GetTextSize(nsPresContext* aPresContext,
|
||||||
const nsString& aString, nsSize& aSize, nscoord& aAscent)
|
nsRenderingContext& aRenderingContext,
|
||||||
|
const nsString& aString,
|
||||||
|
nsSize& aSize, nscoord& aAscent)
|
||||||
{
|
{
|
||||||
nsRefPtr<nsFontMetrics> fontMet;
|
nsRefPtr<nsFontMetrics> fontMet;
|
||||||
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet));
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet));
|
||||||
fontMet->GetMaxHeight(aSize.height);
|
aSize.height = fontMet->MaxHeight();
|
||||||
aRenderingContext.SetFont(fontMet);
|
aRenderingContext.SetFont(fontMet);
|
||||||
aSize.width =
|
aSize.width =
|
||||||
nsLayoutUtils::GetStringWidth(this, &aRenderingContext, aString.get(), aString.Length());
|
nsLayoutUtils::GetStringWidth(this, &aRenderingContext,
|
||||||
fontMet->GetMaxAscent(aAscent);
|
aString.get(), aString.Length());
|
||||||
|
aAscent = fontMet->MaxAscent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -1264,8 +1264,7 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, nsITreeColumn* aCol, const n
|
|||||||
nsRefPtr<nsFontMetrics> fm;
|
nsRefPtr<nsFontMetrics> fm;
|
||||||
nsLayoutUtils::GetFontMetricsForStyleContext(textContext,
|
nsLayoutUtils::GetFontMetricsForStyleContext(textContext,
|
||||||
getter_AddRefs(fm));
|
getter_AddRefs(fm));
|
||||||
nscoord height;
|
nscoord height = fm->MaxHeight();
|
||||||
fm->GetMaxHeight(height);
|
|
||||||
|
|
||||||
nsMargin textMargin;
|
nsMargin textMargin;
|
||||||
textContext->GetStyleMargin()->GetMargin(textMargin);
|
textContext->GetStyleMargin()->GetMargin(textMargin);
|
||||||
@@ -3572,9 +3571,8 @@ nsTreeBodyFrame::PaintText(PRInt32 aRowIndex,
|
|||||||
nsLayoutUtils::GetFontMetricsForStyleContext(textContext,
|
nsLayoutUtils::GetFontMetricsForStyleContext(textContext,
|
||||||
getter_AddRefs(fontMet));
|
getter_AddRefs(fontMet));
|
||||||
|
|
||||||
nscoord height, baseline;
|
nscoord height = fontMet->MaxHeight();
|
||||||
fontMet->GetMaxHeight(height);
|
nscoord baseline = fontMet->MaxAscent();
|
||||||
fontMet->GetMaxAscent(baseline);
|
|
||||||
|
|
||||||
// Center the text. XXX Obey vertical-align style prop?
|
// Center the text. XXX Obey vertical-align style prop?
|
||||||
if (height < textRect.height) {
|
if (height < textRect.height) {
|
||||||
|
|||||||
Reference in New Issue
Block a user