Bug 1324700 - Resolve font property for servo. r?heycam draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sat, 15 Apr 2017 07:37:35 +0900
changeset 563190 97b9c7c16b78703602c97f55b030739e6fbfef67
parent 563189 fa32ddcb26af8aa79b8550479e4c2992831f53e3
child 563191 52090a04f6cd37a335e10d10e79b106b48b1a26d
push id54220
push userhikezoe@mozilla.com
push dateSat, 15 Apr 2017 04:25:00 +0000
reviewersheycam
bugs1324700
milestone55.0a1
Bug 1324700 - Resolve font property for servo. r?heycam MozReview-Commit-ID: BvQXFMP0Zr9
dom/canvas/CanvasRenderingContext2D.cpp
--- 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.