mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1065002 pt 2 - Add an orientation field to nsFontMetrics. r=jdaggett
This commit is contained in:
parent
9407713a2b
commit
840d8b0fd5
@ -2169,7 +2169,8 @@ public:
|
||||
gfxTextPerfMetrics* tp = mPresContext->GetTextPerfMetrics();
|
||||
nsRefPtr<nsFontMetrics> fontMetrics;
|
||||
nsDeviceContext* dc = mPresContext->DeviceContext();
|
||||
dc->GetMetricsFor(mFont, mFontLanguage, nullptr, tp,
|
||||
dc->GetMetricsFor(mFont, mFontLanguage, gfxFont::eHorizontal,
|
||||
nullptr, tp,
|
||||
*getter_AddRefs(fontMetrics));
|
||||
return NSAppUnitsToFloatPixels(fontMetrics->XHeight(),
|
||||
nsPresContext::AppUnitsPerCSSPixel());
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
void Destroy();
|
||||
|
||||
nsresult GetMetricsFor(const nsFont& aFont, nsIAtom* aLanguage,
|
||||
gfxFont::Orientation aOrientation,
|
||||
gfxUserFontSet* aUserFontSet,
|
||||
gfxTextPerfMetrics* aTextPerf,
|
||||
nsFontMetrics*& aMetrics);
|
||||
@ -122,6 +123,7 @@ nsFontCache::Observe(nsISupports*, const char* aTopic, const char16_t*)
|
||||
|
||||
nsresult
|
||||
nsFontCache::GetMetricsFor(const nsFont& aFont, nsIAtom* aLanguage,
|
||||
gfxFont::Orientation aOrientation,
|
||||
gfxUserFontSet* aUserFontSet,
|
||||
gfxTextPerfMetrics* aTextPerf,
|
||||
nsFontMetrics*& aMetrics)
|
||||
@ -137,7 +139,7 @@ nsFontCache::GetMetricsFor(const nsFont& aFont, nsIAtom* aLanguage,
|
||||
for (int32_t i = n; i >= 0; --i) {
|
||||
fm = mFontMetrics[i];
|
||||
if (fm->Font().Equals(aFont) && fm->GetUserFontSet() == aUserFontSet &&
|
||||
fm->Language() == aLanguage) {
|
||||
fm->Language() == aLanguage && fm->Orientation() == aOrientation) {
|
||||
if (i != n) {
|
||||
// promote it to the end of the cache
|
||||
mFontMetrics.RemoveElementAt(i);
|
||||
@ -153,7 +155,8 @@ nsFontCache::GetMetricsFor(const nsFont& aFont, nsIAtom* aLanguage,
|
||||
|
||||
fm = new nsFontMetrics();
|
||||
NS_ADDREF(fm);
|
||||
nsresult rv = fm->Init(aFont, aLanguage, mContext, aUserFontSet, aTextPerf);
|
||||
nsresult rv = fm->Init(aFont, aLanguage, aOrientation, mContext,
|
||||
aUserFontSet, aTextPerf);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// the mFontMetrics list has the "head" at the end, because append
|
||||
// is cheaper than insert
|
||||
@ -172,7 +175,8 @@ nsFontCache::GetMetricsFor(const nsFont& aFont, nsIAtom* aLanguage,
|
||||
Compact();
|
||||
fm = new nsFontMetrics();
|
||||
NS_ADDREF(fm);
|
||||
rv = fm->Init(aFont, aLanguage, mContext, aUserFontSet, aTextPerf);
|
||||
rv = fm->Init(aFont, aLanguage, aOrientation, mContext, aUserFontSet,
|
||||
aTextPerf);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mFontMetrics.AppendElement(fm);
|
||||
aMetrics = fm;
|
||||
@ -260,6 +264,7 @@ nsDeviceContext::~nsDeviceContext()
|
||||
nsresult
|
||||
nsDeviceContext::GetMetricsFor(const nsFont& aFont,
|
||||
nsIAtom* aLanguage,
|
||||
gfxFont::Orientation aOrientation,
|
||||
gfxUserFontSet* aUserFontSet,
|
||||
gfxTextPerfMetrics* aTextPerf,
|
||||
nsFontMetrics*& aMetrics)
|
||||
@ -270,8 +275,8 @@ nsDeviceContext::GetMetricsFor(const nsFont& aFont,
|
||||
mFontCache->Init(this);
|
||||
}
|
||||
|
||||
return mFontCache->GetMetricsFor(aFont, aLanguage, aUserFontSet,
|
||||
aTextPerf, aMetrics);
|
||||
return mFontCache->GetMetricsFor(aFont, aLanguage, aOrientation,
|
||||
aUserFontSet, aTextPerf, aMetrics);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <stdint.h> // for uint32_t
|
||||
#include <sys/types.h> // for int32_t
|
||||
#include "gfxTypes.h" // for gfxFloat
|
||||
#include "gfxFont.h" // for gfxFont::Orientation
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
|
||||
#include "nsAutoPtr.h" // for nsRefPtr
|
||||
#include "nsCOMPtr.h" // for nsCOMPtr
|
||||
@ -118,6 +119,7 @@ public:
|
||||
* @return error status
|
||||
*/
|
||||
nsresult GetMetricsFor(const nsFont& aFont, nsIAtom* aLanguage,
|
||||
gfxFont::Orientation aOrientation,
|
||||
gfxUserFontSet* aUserFontSet,
|
||||
gfxTextPerfMetrics* aTextPerf,
|
||||
nsFontMetrics*& aMetrics);
|
||||
|
@ -104,6 +104,7 @@ nsFontMetrics::~nsFontMetrics()
|
||||
|
||||
nsresult
|
||||
nsFontMetrics::Init(const nsFont& aFont, nsIAtom* aLanguage,
|
||||
gfxFont::Orientation aOrientation,
|
||||
nsDeviceContext *aContext,
|
||||
gfxUserFontSet *aUserFontSet,
|
||||
gfxTextPerfMetrics *aTextPerf)
|
||||
@ -112,6 +113,7 @@ nsFontMetrics::Init(const nsFont& aFont, nsIAtom* aLanguage,
|
||||
|
||||
mFont = aFont;
|
||||
mLanguage = aLanguage;
|
||||
mOrientation = aOrientation;
|
||||
mDeviceContext = aContext;
|
||||
mP2A = mDeviceContext->AppUnitsPerDevPixel();
|
||||
|
||||
@ -147,7 +149,7 @@ nsFontMetrics::Destroy()
|
||||
|
||||
const gfxFont::Metrics& nsFontMetrics::GetMetrics() const
|
||||
{
|
||||
return mFontGroup->GetFirstValidFont()->GetMetrics(gfxFont::eHorizontal); // XXX vertical?
|
||||
return mFontGroup->GetFirstValidFont()->GetMetrics(mOrientation);
|
||||
}
|
||||
|
||||
nscoord
|
||||
|
@ -57,6 +57,7 @@ public:
|
||||
* @see nsDeviceContext#GetMetricsFor()
|
||||
*/
|
||||
nsresult Init(const nsFont& aFont, nsIAtom* aLanguage,
|
||||
gfxFont::Orientation aOrientation,
|
||||
nsDeviceContext *aContext,
|
||||
gfxUserFontSet *aUserFontSet,
|
||||
gfxTextPerfMetrics *aTextPerf);
|
||||
@ -174,6 +175,11 @@ public:
|
||||
*/
|
||||
nsIAtom* Language() { return mLanguage; }
|
||||
|
||||
/**
|
||||
* Returns the orientation (horizontal/vertical) of these metrics.
|
||||
*/
|
||||
gfxFont::Orientation Orientation() { return mOrientation; }
|
||||
|
||||
int32_t GetMaxStringLength();
|
||||
|
||||
// Get the width for this string. aWidth will be updated with the
|
||||
@ -223,6 +229,7 @@ private:
|
||||
nsDeviceContext *mDeviceContext;
|
||||
int32_t mP2A;
|
||||
bool mTextRunRTL;
|
||||
gfxFont::Orientation mOrientation;
|
||||
};
|
||||
|
||||
#endif /* NSFONTMETRICS__H__ */
|
||||
|
@ -3434,8 +3434,10 @@ nsLayoutUtils::GetFontMetricsForStyleContext(nsStyleContext* aStyleContext,
|
||||
if (aInflation != 1.0f) {
|
||||
font.size = NSToCoordRound(font.size * aInflation);
|
||||
}
|
||||
WritingMode wm(aStyleContext->StyleVisibility());
|
||||
return pc->DeviceContext()->GetMetricsFor(
|
||||
font, aStyleContext->StyleFont()->mLanguage,
|
||||
wm.IsVertical() ? gfxFont::eVertical : gfxFont::eHorizontal,
|
||||
fs, tp, *aFontMetrics);
|
||||
}
|
||||
|
||||
|
@ -10060,6 +10060,7 @@ void ReflowCountMgr::PaintCount(const char* aName,
|
||||
// We have one frame, therefore we must have a root...
|
||||
aPresContext->GetPresShell()->GetRootFrame()->
|
||||
StyleFont()->mLanguage,
|
||||
gfxFont::eHorizontal,
|
||||
aPresContext->GetUserFontSet(),
|
||||
aPresContext->GetTextPerfMetrics(),
|
||||
*getter_AddRefs(fm));
|
||||
|
@ -740,6 +740,7 @@ MathMLTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
||||
nsRefPtr<nsFontMetrics> metrics;
|
||||
pc->DeviceContext()->GetMetricsFor(font,
|
||||
styles[0]->StyleFont()->mLanguage,
|
||||
gfxFont::eHorizontal,
|
||||
pc->GetUserFontSet(),
|
||||
pc->GetTextPerfMetrics(),
|
||||
*getter_AddRefs(metrics));
|
||||
|
@ -583,6 +583,7 @@ nsPageFrame::PaintHeaderFooter(nsRenderingContext& aRenderingContext,
|
||||
// Get the FontMetrics to determine width.height of strings
|
||||
nsRefPtr<nsFontMetrics> fontMet;
|
||||
pc->DeviceContext()->GetMetricsFor(mPD->mHeadFootFont, nullptr,
|
||||
gfxFont::eHorizontal,
|
||||
pc->GetUserFontSet(),
|
||||
pc->GetTextPerfMetrics(),
|
||||
*getter_AddRefs(fontMet));
|
||||
|
@ -989,6 +989,7 @@ nsMathMLChar::SetFontFamily(nsPresContext* aPresContext,
|
||||
aPresContext->DeviceContext()->
|
||||
GetMetricsFor(font,
|
||||
mStyleContext->StyleFont()->mLanguage,
|
||||
gfxFont::eHorizontal,
|
||||
aPresContext->GetUserFontSet(),
|
||||
aPresContext->GetTextPerfMetrics(),
|
||||
*getter_AddRefs(fm));
|
||||
@ -1529,6 +1530,7 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
|
||||
aPresContext->DeviceContext()->
|
||||
GetMetricsFor(font,
|
||||
mStyleContext->StyleFont()->mLanguage,
|
||||
gfxFont::eHorizontal,
|
||||
aPresContext->GetUserFontSet(),
|
||||
aPresContext->GetTextPerfMetrics(),
|
||||
*getter_AddRefs(fm));
|
||||
|
@ -285,9 +285,17 @@ GetMetricsFor(nsPresContext* aPresContext,
|
||||
fs = aPresContext->GetUserFontSet();
|
||||
}
|
||||
gfxTextPerfMetrics *tp = aPresContext->GetTextPerfMetrics();
|
||||
gfxFont::Orientation orientation = gfxFont::eHorizontal;
|
||||
if (aStyleContext) {
|
||||
WritingMode wm(aStyleContext->StyleVisibility());
|
||||
if (wm.IsVertical()) {
|
||||
orientation = gfxFont::eVertical;
|
||||
}
|
||||
}
|
||||
nsRefPtr<nsFontMetrics> fm;
|
||||
aPresContext->DeviceContext()->GetMetricsFor(font,
|
||||
aStyleFont->mLanguage,
|
||||
orientation,
|
||||
fs, tp, *getter_AddRefs(fm));
|
||||
return fm.forget();
|
||||
}
|
||||
@ -502,7 +510,7 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue,
|
||||
aFontSize, aUseUserFontSet);
|
||||
gfxFloat zeroWidth =
|
||||
fm->GetThebesFontGroup()->GetFirstValidFont()->
|
||||
GetMetrics(gfxFont::eHorizontal).zeroOrAveCharWidth; // XXX vertical?
|
||||
GetMetrics(fm->Orientation()).zeroOrAveCharWidth;
|
||||
|
||||
return ScaleCoordRound(aValue, ceil(aPresContext->AppUnitsPerDevPixel() *
|
||||
zeroWidth));
|
||||
|
Loading…
Reference in New Issue
Block a user