Bug 1452080: Remove ComputedStyle::PresContext usage from layout and canvas code. r=xidorn
Couldn't find an easy way of splitting these up :( MozReview-Commit-ID: 2kTZ5McREUT
This commit is contained in:
@@ -4299,9 +4299,10 @@ CanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
|
||||
MOZ_ASSERT(!presShell->IsDestroying(),
|
||||
"GetCurrentFontStyle() should have returned null if the presshell is being destroyed");
|
||||
|
||||
nsPresContext* presContext = presShell->GetPresContext();
|
||||
|
||||
// ensure user font set is up to date
|
||||
currentFontStyle->
|
||||
SetUserFontSet(presShell->GetPresContext()->GetUserFontSet());
|
||||
currentFontStyle->SetUserFontSet(presContext->GetUserFontSet());
|
||||
|
||||
if (currentFontStyle->GetStyle()->size == 0.0F) {
|
||||
if (aWidth) {
|
||||
@@ -4320,6 +4321,7 @@ CanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
|
||||
// (for now, at least; perhaps we need new Canvas API to control this).
|
||||
processor.mTextRunFlags = canvasStyle
|
||||
? nsLayoutUtils::GetTextRunFlagsForStyle(canvasStyle,
|
||||
presContext,
|
||||
canvasStyle->StyleFont(),
|
||||
canvasStyle->StyleText(),
|
||||
0)
|
||||
|
||||
@@ -270,10 +270,16 @@ SVGContentUtils::GetStrokeWidth(nsSVGElement* aElement,
|
||||
}
|
||||
|
||||
float
|
||||
SVGContentUtils::GetFontSize(Element *aElement)
|
||||
SVGContentUtils::GetFontSize(Element* aElement)
|
||||
{
|
||||
if (!aElement)
|
||||
if (!aElement) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
nsPresContext* pc = nsContentUtils::GetContextForContent(aElement);
|
||||
if (!pc) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
RefPtr<ComputedStyle> computedStyle =
|
||||
nsComputedDOMStyle::GetComputedStyleNoFlush(aElement, nullptr);
|
||||
@@ -283,63 +289,66 @@ SVGContentUtils::GetFontSize(Element *aElement)
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
return GetFontSize(computedStyle);
|
||||
return GetFontSize(computedStyle, pc);
|
||||
}
|
||||
|
||||
float
|
||||
SVGContentUtils::GetFontSize(nsIFrame *aFrame)
|
||||
SVGContentUtils::GetFontSize(nsIFrame* aFrame)
|
||||
{
|
||||
MOZ_ASSERT(aFrame, "NULL frame in GetFontSize");
|
||||
return GetFontSize(aFrame->Style());
|
||||
return GetFontSize(aFrame->Style(), aFrame->PresContext());
|
||||
}
|
||||
|
||||
float
|
||||
SVGContentUtils::GetFontSize(ComputedStyle *aComputedStyle)
|
||||
SVGContentUtils::GetFontSize(ComputedStyle* aComputedStyle,
|
||||
nsPresContext* aPresContext)
|
||||
{
|
||||
MOZ_ASSERT(aComputedStyle, "NULL ComputedStyle in GetFontSize");
|
||||
|
||||
nsPresContext *presContext = aComputedStyle->PresContext();
|
||||
MOZ_ASSERT(presContext, "NULL pres context in GetFontSize");
|
||||
MOZ_ASSERT(aComputedStyle);
|
||||
MOZ_ASSERT(aPresContext);
|
||||
|
||||
nscoord fontSize = aComputedStyle->StyleFont()->mSize;
|
||||
return nsPresContext::AppUnitsToFloatCSSPixels(fontSize) /
|
||||
presContext->EffectiveTextZoom();
|
||||
aPresContext->EffectiveTextZoom();
|
||||
}
|
||||
|
||||
float
|
||||
SVGContentUtils::GetFontXHeight(Element *aElement)
|
||||
SVGContentUtils::GetFontXHeight(Element* aElement)
|
||||
{
|
||||
if (!aElement)
|
||||
if (!aElement) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
RefPtr<ComputedStyle> computedStyle =
|
||||
nsPresContext* pc = nsContentUtils::GetContextForContent(aElement);
|
||||
if (!pc) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
RefPtr<ComputedStyle> style =
|
||||
nsComputedDOMStyle::GetComputedStyleNoFlush(aElement, nullptr);
|
||||
if (!computedStyle) {
|
||||
if (!style) {
|
||||
// ReportToConsole
|
||||
NS_WARNING("Couldn't get ComputedStyle for content in GetFontStyle");
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
return GetFontXHeight(computedStyle);
|
||||
return GetFontXHeight(style, pc);
|
||||
}
|
||||
|
||||
float
|
||||
SVGContentUtils::GetFontXHeight(nsIFrame *aFrame)
|
||||
{
|
||||
MOZ_ASSERT(aFrame, "NULL frame in GetFontXHeight");
|
||||
return GetFontXHeight(aFrame->Style());
|
||||
return GetFontXHeight(aFrame->Style(), aFrame->PresContext());
|
||||
}
|
||||
|
||||
float
|
||||
SVGContentUtils::GetFontXHeight(ComputedStyle *aComputedStyle)
|
||||
SVGContentUtils::GetFontXHeight(ComputedStyle* aComputedStyle,
|
||||
nsPresContext* aPresContext)
|
||||
{
|
||||
MOZ_ASSERT(aComputedStyle, "NULL ComputedStyle in GetFontXHeight");
|
||||
|
||||
nsPresContext *presContext = aComputedStyle->PresContext();
|
||||
MOZ_ASSERT(presContext, "NULL pres context in GetFontXHeight");
|
||||
MOZ_ASSERT(aComputedStyle && aPresContext);
|
||||
|
||||
RefPtr<nsFontMetrics> fontMetrics =
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(aComputedStyle);
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(aComputedStyle, aPresContext);
|
||||
|
||||
if (!fontMetrics) {
|
||||
// ReportToConsole
|
||||
@@ -349,7 +358,7 @@ SVGContentUtils::GetFontXHeight(ComputedStyle *aComputedStyle)
|
||||
|
||||
nscoord xHeight = fontMetrics->XHeight();
|
||||
return nsPresContext::AppUnitsToFloatCSSPixels(xHeight) /
|
||||
presContext->EffectiveTextZoom();
|
||||
aPresContext->EffectiveTextZoom();
|
||||
}
|
||||
nsresult
|
||||
SVGContentUtils::ReportToConsole(nsIDocument* doc,
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIFrame;
|
||||
class nsPresContext;
|
||||
class nsStyleCoord;
|
||||
class nsSVGElement;
|
||||
|
||||
@@ -180,9 +181,9 @@ public:
|
||||
* XXX document the conditions under which these may fail, and what they
|
||||
* return in those cases.
|
||||
*/
|
||||
static float GetFontSize(mozilla::dom::Element *aElement);
|
||||
static float GetFontSize(nsIFrame *aFrame);
|
||||
static float GetFontSize(ComputedStyle *aComputedStyle);
|
||||
static float GetFontSize(mozilla::dom::Element* aElement);
|
||||
static float GetFontSize(nsIFrame* aFrame);
|
||||
static float GetFontSize(ComputedStyle*, nsPresContext*);
|
||||
/*
|
||||
* Get the number of CSS px (user units) per ex (i.e. the x-height in user
|
||||
* units) for an nsIContent
|
||||
@@ -190,9 +191,9 @@ public:
|
||||
* XXX document the conditions under which these may fail, and what they
|
||||
* return in those cases.
|
||||
*/
|
||||
static float GetFontXHeight(mozilla::dom::Element *aElement);
|
||||
static float GetFontXHeight(nsIFrame *aFrame);
|
||||
static float GetFontXHeight(ComputedStyle *aComputedStyle);
|
||||
static float GetFontXHeight(mozilla::dom::Element* aElement);
|
||||
static float GetFontXHeight(nsIFrame* aFrame);
|
||||
static float GetFontXHeight(ComputedStyle*, nsPresContext*);
|
||||
|
||||
/*
|
||||
* Report a localized error message to the error console.
|
||||
|
||||
@@ -4423,8 +4423,7 @@ const nsCSSFrameConstructor::FrameConstructionData*
|
||||
nsCSSFrameConstructor::FindXULMenubarData(Element* aElement,
|
||||
ComputedStyle* aComputedStyle)
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> treeItem =
|
||||
aComputedStyle->PresContext()->GetDocShell();
|
||||
nsCOMPtr<nsIDocShell> treeItem = aElement->OwnerDoc()->GetDocShell();
|
||||
if (treeItem && nsIDocShellTreeItem::typeChrome == treeItem->ItemType()) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> parent;
|
||||
treeItem->GetParent(getter_AddRefs(parent));
|
||||
|
||||
@@ -4695,16 +4695,16 @@ nsLayoutUtils::GetFontMetricsForFrame(const nsIFrame* aFrame, float aInflation)
|
||||
variantWidth = NS_FONT_VARIANT_WIDTH_QUARTER;
|
||||
}
|
||||
}
|
||||
return GetFontMetricsForComputedStyle(computedStyle, aInflation, variantWidth);
|
||||
return GetFontMetricsForComputedStyle(computedStyle, aFrame->PresContext(),
|
||||
aInflation, variantWidth);
|
||||
}
|
||||
|
||||
already_AddRefed<nsFontMetrics>
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(ComputedStyle* aComputedStyle,
|
||||
float aInflation,
|
||||
uint8_t aVariantWidth)
|
||||
nsPresContext* aPresContext,
|
||||
float aInflation,
|
||||
uint8_t aVariantWidth)
|
||||
{
|
||||
nsPresContext* pc = aComputedStyle->PresContext();
|
||||
|
||||
WritingMode wm(aComputedStyle);
|
||||
const nsStyleFont* styleFont = aComputedStyle->StyleFont();
|
||||
nsFontMetrics::Params params;
|
||||
@@ -4715,8 +4715,8 @@ nsLayoutUtils::GetFontMetricsForComputedStyle(ComputedStyle* aComputedStyle,
|
||||
: gfxFont::eHorizontal;
|
||||
// pass the user font set object into the device context to
|
||||
// pass along to CreateFontGroup
|
||||
params.userFontSet = pc->GetUserFontSet();
|
||||
params.textPerf = pc->GetTextPerfMetrics();
|
||||
params.userFontSet = aPresContext->GetUserFontSet();
|
||||
params.textPerf = aPresContext->GetTextPerfMetrics();
|
||||
|
||||
// When aInflation is 1.0 and we don't require width variant, avoid
|
||||
// making a local copy of the nsFont.
|
||||
@@ -4724,13 +4724,13 @@ nsLayoutUtils::GetFontMetricsForComputedStyle(ComputedStyle* aComputedStyle,
|
||||
// which would be lossy. Fortunately, in such cases, aInflation is
|
||||
// guaranteed to be 1.0f.
|
||||
if (aInflation == 1.0f && aVariantWidth == NS_FONT_VARIANT_WIDTH_NORMAL) {
|
||||
return pc->DeviceContext()->GetMetricsFor(styleFont->mFont, params);
|
||||
return aPresContext->DeviceContext()->GetMetricsFor(styleFont->mFont, params);
|
||||
}
|
||||
|
||||
nsFont font = styleFont->mFont;
|
||||
font.size = NSToCoordRound(font.size * aInflation);
|
||||
font.variantWidth = aVariantWidth;
|
||||
return pc->DeviceContext()->GetMetricsFor(font, params);
|
||||
return aPresContext->DeviceContext()->GetMetricsFor(font, params);
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
@@ -7521,6 +7521,7 @@ nsLayoutUtils::GetReferenceFrame(nsIFrame* aFrame)
|
||||
|
||||
/* static */ gfx::ShapedTextFlags
|
||||
nsLayoutUtils::GetTextRunFlagsForStyle(ComputedStyle* aComputedStyle,
|
||||
nsPresContext* aPresContext,
|
||||
const nsStyleFont* aStyleFont,
|
||||
const nsStyleText* aStyleText,
|
||||
nscoord aLetterSpacing)
|
||||
@@ -7538,8 +7539,7 @@ nsLayoutUtils::GetTextRunFlagsForStyle(ComputedStyle* aComputedStyle,
|
||||
result |= gfx::ShapedTextFlags::TEXT_OPTIMIZE_SPEED;
|
||||
break;
|
||||
case NS_STYLE_TEXT_RENDERING_AUTO:
|
||||
if (aStyleFont->mFont.size <
|
||||
aComputedStyle->PresContext()->GetAutoQualityMinFontSize()) {
|
||||
if (aStyleFont->mFont.size < aPresContext->GetAutoQualityMinFontSize()) {
|
||||
result |= gfx::ShapedTextFlags::TEXT_OPTIMIZE_SPEED;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1303,6 +1303,7 @@ public:
|
||||
*/
|
||||
static already_AddRefed<nsFontMetrics> GetFontMetricsForComputedStyle(
|
||||
ComputedStyle* aComputedStyle,
|
||||
nsPresContext* aPresContext,
|
||||
float aSizeInflation = 1.0f,
|
||||
uint8_t aVariantWidth = NS_FONT_VARIANT_WIDTH_NORMAL);
|
||||
|
||||
@@ -1315,9 +1316,12 @@ public:
|
||||
*/
|
||||
static already_AddRefed<nsFontMetrics> GetFontMetricsOfEmphasisMarks(
|
||||
ComputedStyle* aComputedStyle,
|
||||
nsPresContext* aPresContext,
|
||||
float aInflation)
|
||||
{
|
||||
return GetFontMetricsForComputedStyle(aComputedStyle, aInflation * 0.5f);
|
||||
return GetFontMetricsForComputedStyle(aComputedStyle,
|
||||
aPresContext,
|
||||
aInflation * 0.5f);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2066,6 +2070,7 @@ public:
|
||||
*/
|
||||
static mozilla::gfx::ShapedTextFlags
|
||||
GetTextRunFlagsForStyle(ComputedStyle* aComputedStyle,
|
||||
nsPresContext* aPresContext,
|
||||
const nsStyleFont* aStyleFont,
|
||||
const nsStyleText* aStyleText,
|
||||
nscoord aLetterSpacing);
|
||||
|
||||
@@ -175,8 +175,11 @@ nsTextControlFrame::CalcIntrinsicSize(gfxContext* aRenderingContext,
|
||||
nsLayoutUtils::GetFontMetricsForFrame(this, aFontSizeInflation);
|
||||
|
||||
lineHeight =
|
||||
ReflowInput::CalcLineHeight(GetContent(), Style(),
|
||||
NS_AUTOHEIGHT, aFontSizeInflation);
|
||||
ReflowInput::CalcLineHeight(GetContent(),
|
||||
Style(),
|
||||
PresContext(),
|
||||
NS_AUTOHEIGHT,
|
||||
aFontSizeInflation);
|
||||
charWidth = fontMet->AveCharWidth();
|
||||
charMaxAdvance = fontMet->MaxAdvance();
|
||||
|
||||
@@ -633,8 +636,11 @@ nsTextControlFrame::Reflow(nsPresContext* aPresContext,
|
||||
nscoord lineHeight = aReflowInput.ComputedBSize();
|
||||
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
|
||||
if (!IsSingleLineTextControl()) {
|
||||
lineHeight = ReflowInput::CalcLineHeight(GetContent(), Style(),
|
||||
NS_AUTOHEIGHT, inflation);
|
||||
lineHeight = ReflowInput::CalcLineHeight(GetContent(),
|
||||
Style(),
|
||||
PresContext(),
|
||||
NS_AUTOHEIGHT,
|
||||
inflation);
|
||||
}
|
||||
RefPtr<nsFontMetrics> fontMet =
|
||||
nsLayoutUtils::GetFontMetricsForFrame(this, inflation);
|
||||
|
||||
@@ -2850,6 +2850,7 @@ GetNormalLineHeight(nsFontMetrics* aFontMetrics)
|
||||
|
||||
static inline nscoord
|
||||
ComputeLineHeight(ComputedStyle* aComputedStyle,
|
||||
nsPresContext* aPresContext,
|
||||
nscoord aBlockBSize,
|
||||
float aFontSizeInflation)
|
||||
{
|
||||
@@ -2883,7 +2884,7 @@ ComputeLineHeight(ComputedStyle* aComputedStyle,
|
||||
}
|
||||
|
||||
RefPtr<nsFontMetrics> fm = nsLayoutUtils::
|
||||
GetFontMetricsForComputedStyle(aComputedStyle, aFontSizeInflation);
|
||||
GetFontMetricsForComputedStyle(aComputedStyle, aPresContext, aFontSizeInflation);
|
||||
return GetNormalLineHeight(fm);
|
||||
}
|
||||
|
||||
@@ -2894,20 +2895,27 @@ ReflowInput::CalcLineHeight() const
|
||||
nsLayoutUtils::IsNonWrapperBlock(mFrame) ? ComputedBSize() :
|
||||
(mCBReflowInput ? mCBReflowInput->ComputedBSize() : NS_AUTOHEIGHT);
|
||||
|
||||
return CalcLineHeight(mFrame->GetContent(), mFrame->Style(), blockBSize,
|
||||
return CalcLineHeight(mFrame->GetContent(),
|
||||
mFrame->Style(),
|
||||
mFrame->PresContext(),
|
||||
blockBSize,
|
||||
nsLayoutUtils::FontSizeInflationFor(mFrame));
|
||||
}
|
||||
|
||||
/* static */ nscoord
|
||||
ReflowInput::CalcLineHeight(nsIContent* aContent,
|
||||
ComputedStyle* aComputedStyle,
|
||||
nscoord aBlockBSize,
|
||||
float aFontSizeInflation)
|
||||
ComputedStyle* aComputedStyle,
|
||||
nsPresContext* aPresContext,
|
||||
nscoord aBlockBSize,
|
||||
float aFontSizeInflation)
|
||||
{
|
||||
NS_PRECONDITION(aComputedStyle, "Must have a ComputedStyle");
|
||||
|
||||
nscoord lineHeight =
|
||||
ComputeLineHeight(aComputedStyle, aBlockBSize, aFontSizeInflation);
|
||||
ComputeLineHeight(aComputedStyle,
|
||||
aPresContext,
|
||||
aBlockBSize,
|
||||
aFontSizeInflation);
|
||||
|
||||
NS_ASSERTION(lineHeight >= 0, "ComputeLineHeight screwed up");
|
||||
|
||||
|
||||
@@ -771,6 +771,7 @@ public:
|
||||
*/
|
||||
static nscoord CalcLineHeight(nsIContent* aContent,
|
||||
ComputedStyle* aComputedStyle,
|
||||
nsPresContext* aPresContext,
|
||||
nscoord aBlockBSize,
|
||||
float aFontSizeInflation);
|
||||
|
||||
|
||||
@@ -530,8 +530,11 @@ nsBlockFrame::GetCaretBaseline() const
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
nsLayoutUtils::GetFontMetricsForFrame(this, inflation);
|
||||
nscoord lineHeight =
|
||||
ReflowInput::CalcLineHeight(GetContent(), Style(),
|
||||
contentRect.height, inflation);
|
||||
ReflowInput::CalcLineHeight(GetContent(),
|
||||
Style(),
|
||||
PresContext(),
|
||||
contentRect.height,
|
||||
inflation);
|
||||
const WritingMode wm = GetWritingMode();
|
||||
return nsLayoutUtils::GetCenteredFontBaseline(fm, lineHeight,
|
||||
wm.IsLineInverted()) + bp.top;
|
||||
|
||||
@@ -487,7 +487,7 @@ nsImageFrame::ShouldCreateImageFrameFor(Element* aElement,
|
||||
// text).
|
||||
useSizedBox = true;
|
||||
}
|
||||
else if (aComputedStyle->PresContext()->CompatibilityMode() !=
|
||||
else if (aElement->OwnerDoc()->GetCompatibilityMode() !=
|
||||
eCompatibility_NavQuirks) {
|
||||
useSizedBox = false;
|
||||
}
|
||||
|
||||
@@ -1662,8 +1662,10 @@ nsLineLayout::PlaceTopBottomFrames(PerSpanData* psd,
|
||||
static nscoord
|
||||
GetBSizeOfEmphasisMarks(nsIFrame* aSpanFrame, float aInflation)
|
||||
{
|
||||
RefPtr<nsFontMetrics> fm = nsLayoutUtils::
|
||||
GetFontMetricsOfEmphasisMarks(aSpanFrame->Style(), aInflation);
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
nsLayoutUtils::GetFontMetricsOfEmphasisMarks(aSpanFrame->Style(),
|
||||
aSpanFrame->PresContext(),
|
||||
aInflation);
|
||||
return fm->MaxHeight();
|
||||
}
|
||||
|
||||
@@ -1884,10 +1886,12 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
|
||||
// compute the top leading.
|
||||
float inflation =
|
||||
GetInflationForBlockDirAlignment(spanFrame, mInflationMinFontSize);
|
||||
nscoord logicalBSize = ReflowInput::
|
||||
CalcLineHeight(spanFrame->GetContent(), spanFrame->Style(),
|
||||
mBlockReflowInput->ComputedHeight(),
|
||||
inflation);
|
||||
nscoord logicalBSize =
|
||||
ReflowInput::CalcLineHeight(spanFrame->GetContent(),
|
||||
spanFrame->Style(),
|
||||
spanFrame->PresContext(),
|
||||
mBlockReflowInput->ComputedHeight(),
|
||||
inflation);
|
||||
nscoord contentBSize = spanFramePFD->mBounds.BSize(lineWM) -
|
||||
spanFramePFD->mBorderPadding.BStartEnd(lineWM);
|
||||
|
||||
@@ -2173,8 +2177,11 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
|
||||
// of the elements line block size value.
|
||||
float inflation =
|
||||
GetInflationForBlockDirAlignment(frame, mInflationMinFontSize);
|
||||
pctBasis = ReflowInput::CalcLineHeight(frame->GetContent(),
|
||||
frame->Style(), mBlockReflowInput->ComputedBSize(),
|
||||
pctBasis = ReflowInput::CalcLineHeight(
|
||||
frame->GetContent(),
|
||||
frame->Style(),
|
||||
frame->PresContext(),
|
||||
mBlockReflowInput->ComputedBSize(),
|
||||
inflation);
|
||||
}
|
||||
nscoord offset = verticalAlign.ComputeCoordPercentCalc(pctBasis);
|
||||
|
||||
@@ -1897,6 +1897,9 @@ BuildTextRunsScanner::ContinueTextRunAcrossFrames(nsTextFrame* aFrame1, nsTextFr
|
||||
if (sc1 == sc2)
|
||||
return true;
|
||||
|
||||
nsPresContext* pc = aFrame1->PresContext();
|
||||
MOZ_ASSERT(pc == aFrame2->PresContext());
|
||||
|
||||
const nsStyleFont* fontStyle1 = sc1->StyleFont();
|
||||
const nsStyleFont* fontStyle2 = sc2->StyleFont();
|
||||
nscoord letterSpacing1 = LetterSpacing(aFrame1);
|
||||
@@ -1904,8 +1907,8 @@ BuildTextRunsScanner::ContinueTextRunAcrossFrames(nsTextFrame* aFrame1, nsTextFr
|
||||
return fontStyle1->mFont == fontStyle2->mFont &&
|
||||
fontStyle1->mLanguage == fontStyle2->mLanguage &&
|
||||
textStyle1->mTextTransform == textStyle2->mTextTransform &&
|
||||
nsLayoutUtils::GetTextRunFlagsForStyle(sc1, fontStyle1, textStyle1, letterSpacing1) ==
|
||||
nsLayoutUtils::GetTextRunFlagsForStyle(sc2, fontStyle2, textStyle2, letterSpacing2);
|
||||
nsLayoutUtils::GetTextRunFlagsForStyle(sc1, pc, fontStyle1, textStyle1, letterSpacing1) ==
|
||||
nsLayoutUtils::GetTextRunFlagsForStyle(sc2, pc, fontStyle2, textStyle2, letterSpacing2);
|
||||
}
|
||||
|
||||
void BuildTextRunsScanner::ScanFrame(nsIFrame* aFrame)
|
||||
@@ -2300,7 +2303,8 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
|
||||
// frame's style is used, so we use a mixture of the first frame and
|
||||
// last frame's style
|
||||
flags |= nsLayoutUtils::GetTextRunFlagsForStyle(lastComputedStyle,
|
||||
fontStyle, textStyle, LetterSpacing(firstFrame, textStyle));
|
||||
firstFrame->PresContext(), fontStyle, textStyle,
|
||||
LetterSpacing(firstFrame, textStyle));
|
||||
// XXX this is a bit of a hack. For performance reasons, if we're favouring
|
||||
// performance over quality, don't try to get accurate glyph extents.
|
||||
if (!(flags & gfx::ShapedTextFlags::TEXT_OPTIMIZE_SPEED)) {
|
||||
@@ -2349,7 +2353,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
|
||||
// want to create new nsTransformedCharStyle for them anyway.
|
||||
if (sc != f->Style() || sc->IsTextCombined()) {
|
||||
sc = f->Style();
|
||||
charStyle = new nsTransformedCharStyle(sc);
|
||||
charStyle = new nsTransformedCharStyle(sc, f->PresContext());
|
||||
if (sc->IsTextCombined() && f->CountGraphemeClusters() > 1) {
|
||||
charStyle->mForceNonFullWidth = true;
|
||||
}
|
||||
@@ -5555,8 +5559,10 @@ nsTextFrame::UpdateTextEmphasis(WritingMode aWM, PropertyProvider& aProvider)
|
||||
if (isTextCombined) {
|
||||
computedStyle = GetParent()->Style();
|
||||
}
|
||||
RefPtr<nsFontMetrics> fm = nsLayoutUtils::
|
||||
GetFontMetricsOfEmphasisMarks(computedStyle, GetFontSizeInflation());
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
nsLayoutUtils::GetFontMetricsOfEmphasisMarks(computedStyle,
|
||||
PresContext(),
|
||||
GetFontSizeInflation());
|
||||
EmphasisMarkInfo* info = new EmphasisMarkInfo;
|
||||
info->textRun =
|
||||
GenerateTextRunForEmphasisMarks(this, fm, computedStyle, styleText);
|
||||
@@ -5787,8 +5793,10 @@ nsTextFrame::ComputeDescentLimitForSelectionUnderline(
|
||||
gfxFloat app = aPresContext->AppUnitsPerDevPixel();
|
||||
nscoord lineHeightApp =
|
||||
ReflowInput::CalcLineHeight(GetContent(),
|
||||
Style(), NS_AUTOHEIGHT,
|
||||
GetFontSizeInflation());
|
||||
Style(),
|
||||
PresContext(),
|
||||
NS_AUTOHEIGHT,
|
||||
GetFontSizeInflation());
|
||||
gfxFloat lineHeight = gfxFloat(lineHeightApp) / app;
|
||||
if (lineHeight <= aFontMetrics.maxHeight) {
|
||||
return aFontMetrics.maxDescent;
|
||||
|
||||
@@ -12,24 +12,26 @@
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "gfxTextRun.h"
|
||||
#include "mozilla/ComputedStyle.h"
|
||||
#include "nsPresContext.h"
|
||||
|
||||
class nsTransformedTextRun;
|
||||
|
||||
struct nsTransformedCharStyle final {
|
||||
NS_INLINE_DECL_REFCOUNTING(nsTransformedCharStyle)
|
||||
|
||||
explicit nsTransformedCharStyle(mozilla::ComputedStyle* aStyle)
|
||||
explicit nsTransformedCharStyle(mozilla::ComputedStyle* aStyle,
|
||||
nsPresContext* aPresContext)
|
||||
: mFont(aStyle->StyleFont()->mFont)
|
||||
, mLanguage(aStyle->StyleFont()->mLanguage)
|
||||
, mPresContext(aStyle->PresContext())
|
||||
, mPresContext(aPresContext)
|
||||
, mScriptSizeMultiplier(aStyle->StyleFont()->mScriptSizeMultiplier)
|
||||
, mTextTransform(aStyle->StyleText()->mTextTransform)
|
||||
, mMathVariant(aStyle->StyleFont()->mMathVariant)
|
||||
, mExplicitLanguage(aStyle->StyleFont()->mExplicitLanguage) {}
|
||||
|
||||
nsFont mFont;
|
||||
RefPtr<nsAtom> mLanguage;
|
||||
RefPtr<nsPresContext> mPresContext;
|
||||
RefPtr<nsAtom> mLanguage;
|
||||
RefPtr<nsPresContext> mPresContext;
|
||||
float mScriptSizeMultiplier;
|
||||
uint8_t mTextTransform;
|
||||
uint8_t mMathVariant;
|
||||
|
||||
@@ -231,7 +231,9 @@ nsMathMLFrame::CalcLength(nsPresContext* aPresContext,
|
||||
else if (eCSSUnit_XHeight == unit) {
|
||||
aPresContext->SetUsesExChUnits(true);
|
||||
RefPtr<nsFontMetrics> fm = nsLayoutUtils::
|
||||
GetFontMetricsForComputedStyle(aComputedStyle, aFontSizeInflation);
|
||||
GetFontMetricsForComputedStyle(aComputedStyle,
|
||||
aPresContext,
|
||||
aFontSizeInflation);
|
||||
nscoord xHeight = fm->XHeight();
|
||||
return NSToCoordRound(aCSSValue.GetFloatValue() * (float)xHeight);
|
||||
}
|
||||
|
||||
@@ -5636,9 +5636,13 @@ nsComputedDOMStyle::GetLineHeightCoord(nscoord& aCoord)
|
||||
}
|
||||
}
|
||||
|
||||
nsPresContext* presContext = mPresShell->GetPresContext();
|
||||
|
||||
// lie about font size inflation since we lie about font size (since
|
||||
// the inflation only applies to text)
|
||||
aCoord = ReflowInput::CalcLineHeight(mContent, mComputedStyle,
|
||||
aCoord = ReflowInput::CalcLineHeight(mContent,
|
||||
mComputedStyle,
|
||||
presContext,
|
||||
blockHeight, 1.0f);
|
||||
|
||||
// CalcLineHeight uses font->mFont.size, but we want to use
|
||||
@@ -5647,7 +5651,7 @@ nsComputedDOMStyle::GetLineHeightCoord(nscoord& aCoord)
|
||||
const nsStyleFont* font = StyleFont();
|
||||
float fCoord = float(aCoord);
|
||||
if (font->mAllowZoom) {
|
||||
fCoord /= mPresShell->GetPresContext()->EffectiveTextZoom();
|
||||
fCoord /= presContext->EffectiveTextZoom();
|
||||
}
|
||||
if (font->mFont.size != font->mSize) {
|
||||
fCoord = fCoord * (float(font->mSize) / float(font->mFont.size));
|
||||
|
||||
@@ -18,6 +18,7 @@ using namespace mozilla;
|
||||
|
||||
static bool
|
||||
ComputedStyleContainsFont(ComputedStyle* aComputedStyle,
|
||||
nsPresContext* aPresContext,
|
||||
const gfxUserFontSet* aUserFontSet,
|
||||
const gfxUserFontEntry* aFont)
|
||||
{
|
||||
@@ -38,7 +39,9 @@ ComputedStyleContainsFont(ComputedStyle* aComputedStyle,
|
||||
// family name is in the fontlist, check to see if the font group
|
||||
// associated with the frame includes the specific userfont
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(aComputedStyle, 1.0f);
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(aComputedStyle,
|
||||
aPresContext,
|
||||
1.0f);
|
||||
|
||||
if (fm->GetThebesFontGroup()->ContainsUserFont(aFont)) {
|
||||
return true;
|
||||
@@ -51,8 +54,9 @@ static bool
|
||||
FrameUsesFont(nsIFrame* aFrame, const gfxUserFontEntry* aFont)
|
||||
{
|
||||
// check the style of the frame
|
||||
gfxUserFontSet* ufs = aFrame->PresContext()->GetUserFontSet();
|
||||
if (ComputedStyleContainsFont(aFrame->Style(), ufs, aFont)) {
|
||||
nsPresContext* pc = aFrame->PresContext();
|
||||
gfxUserFontSet* ufs = pc->GetUserFontSet();
|
||||
if (ComputedStyleContainsFont(aFrame->Style(), pc, ufs, aFont)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -61,7 +65,7 @@ FrameUsesFont(nsIFrame* aFrame, const gfxUserFontEntry* aFont)
|
||||
for (ComputedStyle* extraContext;
|
||||
(extraContext = aFrame->GetAdditionalComputedStyle(contextIndex));
|
||||
++contextIndex) {
|
||||
if (ComputedStyleContainsFont(extraContext, ufs, aFont)) {
|
||||
if (ComputedStyleContainsFont(extraContext, pc, ufs, aFont)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ NS_IMPL_FRAMEARENA_HELPERS(nsSVGOuterSVGFrame)
|
||||
nsSVGOuterSVGFrame::nsSVGOuterSVGFrame(ComputedStyle* aStyle)
|
||||
: nsSVGDisplayContainerFrame(aStyle, kClassID)
|
||||
, mCallingReflowSVG(false)
|
||||
, mFullZoom(aStyle->PresContext()->GetFullZoom())
|
||||
, mFullZoom(PresContext()->GetFullZoom())
|
||||
, mViewportInitialized(false)
|
||||
, mIsRootContent(false)
|
||||
{
|
||||
|
||||
@@ -741,7 +741,8 @@ nsListBoxBodyFrame::ComputeIntrinsicISize(nsBoxLayoutState& aBoxLayoutState)
|
||||
}
|
||||
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(computedStyle);
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(computedStyle,
|
||||
presContext);
|
||||
|
||||
nscoord textWidth =
|
||||
nsLayoutUtils::AppUnitWidthOfStringBidi(value, this, *fm,
|
||||
|
||||
@@ -1252,7 +1252,7 @@ nsTreeBodyFrame::GetCoordsForCellItem(int32_t aRow, nsITreeColumn* aCol, const n
|
||||
ComputedStyle* textContext = GetPseudoComputedStyle(nsCSSAnonBoxes::mozTreeCellText);
|
||||
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(textContext);
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(textContext, presContext);
|
||||
nscoord height = fm->MaxHeight();
|
||||
|
||||
nsMargin textMargin;
|
||||
@@ -1626,7 +1626,7 @@ nsTreeBodyFrame::GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect,
|
||||
AdjustForBorderPadding(textContext, textRect);
|
||||
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(textContext);
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(textContext, presContext);
|
||||
AdjustForCellText(cellText, aRowIndex, aColumn, *rc, *fm, textRect);
|
||||
|
||||
if (aX >= textRect.x && aX < textRect.x + textRect.width)
|
||||
@@ -1754,7 +1754,7 @@ nsTreeBodyFrame::GetCellWidth(int32_t aRow, nsTreeColumn* aCol,
|
||||
GetBorderPadding(textContext, bp);
|
||||
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(textContext);
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(textContext, PresContext());
|
||||
// Get the width of the text itself
|
||||
nscoord width = nsLayoutUtils::AppUnitWidthOfStringBidi(cellText, this, *fm,
|
||||
*aRenderingContext);
|
||||
@@ -3752,7 +3752,7 @@ nsTreeBodyFrame::PaintText(int32_t aRowIndex,
|
||||
|
||||
// Compute our text size.
|
||||
RefPtr<nsFontMetrics> fontMet =
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(textContext);
|
||||
nsLayoutUtils::GetFontMetricsForComputedStyle(textContext, PresContext());
|
||||
|
||||
nscoord height = fontMet->MaxHeight();
|
||||
nscoord baseline = fontMet->MaxAscent();
|
||||
|
||||
Reference in New Issue
Block a user