Bug 1324700 - Resolve font property for servo. r?heycam
MozReview-Commit-ID: BvQXFMP0Zr9
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -3897,32 +3897,50 @@ CanvasRenderingContext2D::SetFontInterna
}
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
if (!presShell) {
aError.Throw(NS_ERROR_FAILURE);
return false;
}
+ RefPtr<nsStyleContext> sc;
+ RefPtr<ServoComputedValues> computedValues;
nsString usedFont;
- RefPtr<nsStyleContext> sc =
- GetFontStyleContext(mCanvasElement, aFont, presShell, usedFont, aError);
- if (!sc) {
- return false;
- }
-
- const nsStyleFont* fontStyle = sc->StyleFont();
+ const nsStyleFont* fontStyle;
+ if (presShell->StyleSet()->IsServo()) {
+ computedValues = GetFontStyleForServo(mCanvasElement,
+ aFont,
+ presShell,
+ usedFont,
+ aError);
+ if (!computedValues) {
+ return false;
+ }
+ fontStyle = Servo_GetStyleFont(computedValues);
+ } else {
+ sc = GetFontStyleContext(mCanvasElement,
+ aFont,
+ presShell,
+ usedFont,
+ aError);
+ if (!sc) {
+ return false;
+ }
+ fontStyle = sc->StyleFont();
+ }
nsPresContext* c = presShell->GetPresContext();
// Purposely ignore the font size that respects the user's minimum
// font preference (fontStyle->mFont.size) in favor of the computed
// size (fontStyle->mSize). See
// https://bugzilla.mozilla.org/show_bug.cgi?id=698652.
- MOZ_ASSERT(!fontStyle->mAllowZoom,
+ // FIXME: Nobody initializes mAllowZoom for servo?
+ MOZ_ASSERT(presShell->StyleSet()->IsServo() || !fontStyle->mAllowZoom,
"expected text zoom to be disabled on this nsStyleFont");
nsFont resizedFont(fontStyle->mFont);
// Create a font group working in units of CSS pixels instead of the usual
// device pixels, to avoid being affected by page zoom. nsFontMetrics will
// convert nsFont size in app units to device pixels for the font group, so
// here we first apply to the size the equivalent of a conversion from device
// pixels to CSS pixels, to adjust for the difference in expectations from
// other nsFontMetrics clients.