Bug 1408612 - patch 1 - Use single-precision floats more consistently for glyph position computations when drawing text. r=jrmuizel
authorJonathan Kew <jkew@mozilla.com>
Tue, 24 Oct 2017 09:59:09 +0100
changeset 439101 d1f4b0f6182e43ea986969ddb51b66a7ad0fe713
parent 439100 8d9d8d96e403e8199293e86441f6f07ea45ae39c
child 439102 fb1fc33b95a4c4397c0ba79b615c7c6320fc65f7
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1408612
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1408612 - patch 1 - Use single-precision floats more consistently for glyph position computations when drawing text. r=jrmuizel
dom/canvas/CanvasRenderingContext2D.cpp
gfx/src/nsFontMetrics.cpp
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFont.h
gfx/thebes/gfxTextRun.cpp
gfx/thebes/gfxTextRun.h
layout/generic/TextOverflow.cpp
layout/generic/nsTextFrame.cpp
layout/generic/nsTextFrame.h
layout/mathml/nsMathMLChar.cpp
layout/svg/SVGTextFrame.cpp
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -4355,22 +4355,22 @@ struct MOZ_STACK_CLASS CanvasBidiProcess
     const CanvasPattern* pat = mCtx->CurrentState().patternStyles[aStyle];
     RefPtr<gfxPattern> pattern = new gfxPattern(pat->mSurface, Matrix());
     pattern->SetExtend(CvtCanvasRepeatToGfxRepeat(pat->mRepeat));
     return pattern.forget();
   }
 
   virtual void DrawText(nscoord aXOffset, nscoord aWidth)
   {
-    gfxPoint point = mPt;
+    gfx::Point point = mPt;
     bool rtl = mTextRun->IsRightToLeft();
     bool verticalRun = mTextRun->IsVertical();
     RefPtr<gfxPattern> pattern;
 
-    gfxFloat& inlineCoord = verticalRun ? point.y : point.x;
+    float& inlineCoord = verticalRun ? point.y : point.x;
     inlineCoord += aXOffset;
 
     // offset is given in terms of left side of string
     if (rtl) {
       // Bug 581092 - don't use rounded pixel width to advance to
       // right-hand end of run, because this will cause different
       // glyph positioning for LTR vs RTL drawing of the same
       // glyph string on OS X and DWrite where textrun widths may
@@ -4470,17 +4470,17 @@ struct MOZ_STACK_CLASS CanvasBidiProcess
 
   // pointer to a screen reference context used to measure text and such
   RefPtr<DrawTarget> mDrawTarget;
 
   // Pointer to the draw target we should fill our text to
   CanvasRenderingContext2D* mCtx;
 
   // position of the left side of the string, alphabetic baseline
-  gfxPoint mPt;
+  gfx::Point mPt;
 
   // current font
   gfxFontGroup* mFontgrp;
 
   // to record any unsupported characters found in the text,
   // and notify front-end if it is interested
   nsAutoPtr<gfxMissingFontRecorder> mMissingFonts;
 
@@ -4585,17 +4585,17 @@ CanvasRenderingContext2D::DrawOrMeasureT
   processor.mTextRunFlags = canvasStyle
     ? nsLayoutUtils::GetTextRunFlagsForStyle(canvasStyle,
                                              canvasStyle->StyleFont(),
                                              canvasStyle->StyleText(),
                                              0)
     : gfx::ShapedTextFlags();
 
   GetAppUnitsValues(&processor.mAppUnitsPerDevPixel, nullptr);
-  processor.mPt = gfxPoint(aX, aY);
+  processor.mPt = gfx::Point(aX, aY);
   processor.mDrawTarget =
     gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
 
   // If we don't have a target then we don't have a transform. A target won't
   // be needed in the case where we're measuring the text size. This allows
   // to avoid creating a target if it's only being used to measure text sizes.
   if (mTarget) {
     processor.mDrawTarget->SetTransform(mTarget->GetTransform());
@@ -4692,17 +4692,17 @@ CanvasRenderingContext2D::DrawOrMeasureT
     }
     processor.mPt.x -= baselineAnchor;
   } else {
     processor.mPt.y += baselineAnchor;
   }
 
   // correct bounding box to get it to be the correct size/position
   processor.mBoundingBox.width = totalWidth;
-  processor.mBoundingBox.MoveBy(processor.mPt);
+  processor.mBoundingBox.MoveBy(gfxPoint(processor.mPt.x, processor.mPt.y));
 
   processor.mPt.x *= processor.mAppUnitsPerDevPixel;
   processor.mPt.y *= processor.mAppUnitsPerDevPixel;
 
   EnsureTarget();
   if (!IsTargetValid()) {
     return NS_ERROR_FAILURE;
   }
--- a/gfx/src/nsFontMetrics.cpp
+++ b/gfx/src/nsFontMetrics.cpp
@@ -359,17 +359,17 @@ nsFontMetrics::DrawString(const char *aS
     if (aLength == 0)
         return;
 
     StubPropertyProvider provider;
     AutoTextRun textRun(this, aContext->GetDrawTarget(), aString, aLength);
     if (!textRun.get()) {
         return;
     }
-    gfxPoint pt(aX, aY);
+    gfx::Point pt(aX, aY);
     Range range(0, aLength);
     if (mTextRunRTL) {
         if (mVertical) {
             pt.y += textRun->GetAdvanceWidth(range, &provider);
         } else {
             pt.x += textRun->GetAdvanceWidth(range, &provider);
         }
     }
@@ -387,17 +387,17 @@ nsFontMetrics::DrawString(const char16_t
     if (aLength == 0)
         return;
 
     StubPropertyProvider provider;
     AutoTextRun textRun(this, aTextRunConstructionDrawTarget, aString, aLength);
     if (!textRun.get()) {
         return;
     }
-    gfxPoint pt(aX, aY);
+    gfx::Point pt(aX, aY);
     Range range(0, aLength);
     if (mTextRunRTL) {
         if (mVertical) {
             pt.y += textRun->GetAdvanceWidth(range, &provider);
         } else {
             pt.x += textRun->GetAdvanceWidth(range, &provider);
         }
     }
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -1596,23 +1596,21 @@ public:
     {
     }
 
     ~GlyphBufferAzure()
     {
         Flush(true); // flush any remaining buffered glyphs
     }
 
-    void OutputGlyph(uint32_t aGlyphID, const gfxPoint& aPt)
+    void OutputGlyph(uint32_t aGlyphID, const gfx::Point& aPt)
     {
         Glyph *glyph = AppendGlyph();
         glyph->mIndex = aGlyphID;
-        glyph->mPosition.x = aPt.x;
-        glyph->mPosition.y = aPt.y;
-        glyph->mPosition = mFontParams.matInv.TransformPoint(glyph->mPosition);
+        glyph->mPosition = mFontParams.matInv.TransformPoint(aPt);
         Flush(false); // this will flush only if the buffer is full
     }
 
     const TextRunDrawParams& mRunParams;
     const FontDrawParams& mFontParams;
 
 private:
 #define GLYPH_BUFFER_SIZE (2048/sizeof(Glyph))
@@ -1828,23 +1826,23 @@ gfxFont::CalcXScale(DrawTarget* aDrawTar
     // scale factor so that offsets are 1px in device pixels
     return 1.0 / m;
 }
 
 // Draw an individual glyph at a specific location.
 // *aPt is the glyph position in appUnits; it is converted to device
 // coordinates (devPt) here.
 void
-gfxFont::DrawOneGlyph(uint32_t aGlyphID, double aAdvance, gfxPoint *aPt,
+gfxFont::DrawOneGlyph(uint32_t aGlyphID, float aAdvance, gfx::Point *aPt,
                       GlyphBufferAzure& aBuffer, bool *aEmittedGlyphs) const
 {
     const TextRunDrawParams& runParams(aBuffer.mRunParams);
     const FontDrawParams& fontParams(aBuffer.mFontParams);
 
-    double glyphX, glyphY;
+    float glyphX, glyphY;
     if (fontParams.isVerticalFont) {
         glyphX = aPt->x;
         if (runParams.isRTL) {
             aPt->y -= aAdvance;
             glyphY = aPt->y;
         } else {
             glyphY = aPt->y;
             aPt->y += aAdvance;
@@ -1854,18 +1852,18 @@ gfxFont::DrawOneGlyph(uint32_t aGlyphID,
         if (runParams.isRTL) {
             aPt->x -= aAdvance;
             glyphX = aPt->x;
         } else {
             glyphX = aPt->x;
             aPt->x += aAdvance;
         }
     }
-    gfxPoint devPt(ToDeviceUnits(glyphX, runParams.devPerApp),
-                   ToDeviceUnits(glyphY, runParams.devPerApp));
+    Point devPt(ToDeviceUnits(glyphX, runParams.devPerApp),
+                ToDeviceUnits(glyphY, runParams.devPerApp));
 
     if (fontParams.haveSVGGlyphs) {
         if (!runParams.paintSVGGlyphs) {
             return;
         }
         NS_WARNING_ASSERTION(
           runParams.drawMode != DrawMode::GLYPH_PATH,
           "Rendering SVG glyph despite request for glyph path");
@@ -1875,17 +1873,17 @@ gfxFont::DrawOneGlyph(uint32_t aGlyphID,
             return;
         }
     }
 
     if (fontParams.haveColorGlyphs &&
         RenderColorGlyph(runParams.dt, runParams.context,
                          fontParams.scaledFont, fontParams.renderingOptions,
                          fontParams.drawOptions,
-                         fontParams.matInv.TransformPoint(gfx::Point(devPt.x, devPt.y)),
+                         fontParams.matInv.TransformPoint(devPt),
                          aGlyphID)) {
         return;
     }
 
     aBuffer.OutputGlyph(aGlyphID, devPt);
 
     // Synthetic bolding (if required) by multi-striking.
     for (int32_t i = 0; i < fontParams.extraStrikes; ++i) {
@@ -1898,27 +1896,27 @@ gfxFont::DrawOneGlyph(uint32_t aGlyphID,
     }
 
     *aEmittedGlyphs = true;
 }
 
 // Draw a run of CharacterGlyph records from the given offset in aShapedText.
 // Returns true if glyph paths were actually emitted.
 bool
-gfxFont::DrawGlyphs(const gfxShapedText      *aShapedText,
-                    uint32_t                  aOffset, // offset in the textrun
-                    uint32_t                  aCount, // length of run to draw
-                    gfxPoint                 *aPt,
-                    const TextRunDrawParams&  aRunParams,
-                    const FontDrawParams&     aFontParams)
+gfxFont::DrawGlyphs(const gfxShapedText*     aShapedText,
+                    uint32_t                 aOffset, // offset in the textrun
+                    uint32_t                 aCount, // length of run to draw
+                    gfx::Point*              aPt,
+                    const TextRunDrawParams& aRunParams,
+                    const FontDrawParams&    aFontParams)
 {
     bool emittedGlyphs = false;
     GlyphBufferAzure buffer(aRunParams, aFontParams);
 
-    gfxFloat& inlineCoord = aFontParams.isVerticalFont ? aPt->y : aPt->x;
+    float& inlineCoord = aFontParams.isVerticalFont ? aPt->y : aPt->x;
 
     if (aRunParams.spacing) {
         inlineCoord += aRunParams.isRTL ? -aRunParams.spacing[0].mBefore
                                         : aRunParams.spacing[0].mBefore;
     }
 
     const gfxShapedText::CompressedGlyph *glyphData =
         &aShapedText->GetCharacterGlyphs()[aOffset];
@@ -1930,31 +1928,31 @@ gfxFont::DrawGlyphs(const gfxShapedText 
                          aPt, buffer, &emittedGlyphs);
         } else {
             uint32_t glyphCount = glyphData->GetGlyphCount();
             if (glyphCount > 0) {
                 const gfxShapedText::DetailedGlyph *details =
                     aShapedText->GetDetailedGlyphs(aOffset + i);
                 NS_ASSERTION(details, "detailedGlyph should not be missing!");
                 for (uint32_t j = 0; j < glyphCount; ++j, ++details) {
-                    double advance = details->mAdvance;
+                    float advance = details->mAdvance;
 
                     if (glyphData->IsMissing()) {
                         // Default-ignorable chars will have zero advance width;
                         // we don't have to draw the hexbox for them.
                         if (aRunParams.drawMode != DrawMode::GLYPH_PATH &&
                             advance > 0) {
 
                             if (auto* textDrawer = aRunParams.context->GetTextDrawer()) {
                                 textDrawer->FoundUnsupportedFeature();
                                 return false;
                             }
 
-                            double glyphX = aPt->x;
-                            double glyphY = aPt->y;
+                            float glyphX = aPt->x;
+                            float glyphY = aPt->y;
                             if (aRunParams.isRTL) {
                                 if (aFontParams.isVerticalFont) {
                                     glyphY -= advance;
                                 } else {
                                     glyphX -= advance;
                                 }
                             }
                             Point pt(Float(ToDeviceUnits(glyphX, aRunParams.devPerApp)),
@@ -1985,17 +1983,17 @@ gfxFont::DrawGlyphs(const gfxShapedText 
 
                             // Restore the matrix, if we modified it before
                             // drawing the hexbox.
                             if (aFontParams.passedInvMatrix) {
                                 aRunParams.dt->SetTransform(oldMat);
                             }
                         }
                     } else {
-                        gfxPoint glyphXY(*aPt);
+                        Point glyphXY(*aPt);
                         if (aFontParams.isVerticalFont) {
                             glyphXY.x += details->mYOffset;
                             glyphXY.y += details->mXOffset;
                         } else {
                             glyphXY.x += details->mXOffset;
                             glyphXY.y += details->mYOffset;
                         }
                         DrawOneGlyph(details->mGlyphID, advance, &glyphXY,
@@ -2003,70 +2001,70 @@ gfxFont::DrawGlyphs(const gfxShapedText 
                     }
 
                     inlineCoord += aRunParams.isRTL ? -advance : advance;
                 }
             }
         }
 
         if (aRunParams.spacing) {
-            double space = aRunParams.spacing[i].mAfter;
+            float space = aRunParams.spacing[i].mAfter;
             if (i + 1 < aCount) {
                 space += aRunParams.spacing[i + 1].mBefore;
             }
             inlineCoord += aRunParams.isRTL ? -space : space;
         }
     }
 
     return emittedGlyphs;
 }
 
 // This method is mostly parallel to DrawGlyphs.
 void
-gfxFont::DrawEmphasisMarks(const gfxTextRun* aShapedText, gfxPoint* aPt,
+gfxFont::DrawEmphasisMarks(const gfxTextRun* aShapedText, gfx::Point* aPt,
                            uint32_t aOffset, uint32_t aCount,
                            const EmphasisMarkDrawParams& aParams)
 {
-    gfxFloat& inlineCoord = aParams.isVertical ? aPt->y : aPt->x;
+    float& inlineCoord = aParams.isVertical ? aPt->y : aPt->x;
     gfxTextRun::Range markRange(aParams.mark);
     gfxTextRun::DrawParams params(aParams.context);
 
-    gfxFloat clusterStart = -std::numeric_limits<gfxFloat>::infinity();
+    float clusterStart = -std::numeric_limits<float>::infinity();
     bool shouldDrawEmphasisMark = false;
     for (uint32_t i = 0, idx = aOffset; i < aCount; ++i, ++idx) {
         if (aParams.spacing) {
             inlineCoord += aParams.direction * aParams.spacing[i].mBefore;
         }
         if (aShapedText->IsClusterStart(idx) ||
-            clusterStart == -std::numeric_limits<gfxFloat>::infinity()) {
+            clusterStart == -std::numeric_limits<float>::infinity()) {
             clusterStart = inlineCoord;
         }
         if (aShapedText->CharMayHaveEmphasisMark(idx)) {
             shouldDrawEmphasisMark = true;
         }
         inlineCoord += aParams.direction * aShapedText->GetAdvanceForGlyph(idx);
         if (shouldDrawEmphasisMark &&
             (i + 1 == aCount || aShapedText->IsClusterStart(idx + 1))) {
-            gfxFloat clusterAdvance = inlineCoord - clusterStart;
+            float clusterAdvance = inlineCoord - clusterStart;
             // Move the coord backward to get the needed start point.
-            gfxFloat delta = (clusterAdvance + aParams.advance) / 2;
+            float delta = (clusterAdvance + aParams.advance) / 2;
             inlineCoord -= delta;
             aParams.mark->Draw(markRange, *aPt, params);
             inlineCoord += delta;
             shouldDrawEmphasisMark = false;
         }
         if (aParams.spacing) {
             inlineCoord += aParams.direction * aParams.spacing[i].mAfter;
         }
     }
 }
 
 void
 gfxFont::Draw(const gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
-              gfxPoint *aPt, const TextRunDrawParams& aRunParams,
+              gfx::Point* aPt, const TextRunDrawParams& aRunParams,
               gfx::ShapedTextFlags aOrientation)
 {
     NS_ASSERTION(aRunParams.drawMode == DrawMode::GLYPH_PATH ||
                  !(int(aRunParams.drawMode) & int(DrawMode::GLYPH_PATH)),
                  "GLYPH_PATH cannot be used with GLYPH_FILL, GLYPH_STROKE or GLYPH_STROKE_UNDERNEATH");
 
     if (aStart >= aEnd) {
         return;
@@ -2094,17 +2092,17 @@ gfxFont::Draw(const gfxTextRun *aTextRun
     fontParams.haveColorGlyphs = GetFontEntry()->TryGetColorGlyphs();
     fontParams.contextPaint = aRunParams.runContextPaint;
     fontParams.isVerticalFont =
         aOrientation == gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_UPRIGHT;
 
     bool sideways = false;
     gfxContextMatrixAutoSaveRestore matrixRestore;
 
-    gfxPoint origPt = *aPt;
+    gfx::Point origPt = *aPt;
     if (aRunParams.isVerticalRun && !fontParams.isVerticalFont) {
 
         if (textDrawer) {
             textDrawer->FoundUnsupportedFeature();
             return;
         }
 
         sideways = true;
@@ -2216,18 +2214,18 @@ gfxFont::Draw(const gfxTextRun *aTextRun
 
             fontParams.matInv = mat;
             fontParams.matInv.Invert();
 
             fontParams.passedInvMatrix = &fontParams.matInv;
         }
     }
 
-    gfxFloat& baseline = fontParams.isVerticalFont ? aPt->x : aPt->y;
-    gfxFloat origBaseline = baseline;
+    float& baseline = fontParams.isVerticalFont ? aPt->x : aPt->y;
+    float origBaseline = baseline;
     if (mStyle.baselineOffset != 0.0) {
         baseline +=
             mStyle.baselineOffset * aTextRun->GetAppUnitsPerDevUnit();
     }
 
     bool emittedGlyphs =
         DrawGlyphs(aTextRun, aStart, aEnd - aStart, aPt,
                    aRunParams, fontParams);
@@ -2238,28 +2236,28 @@ gfxFont::Draw(const gfxTextRun *aTextRun
         aRunParams.callbacks->NotifyGlyphPathEmitted();
     }
 
     aRunParams.dt->SetTransform(oldMat);
     aRunParams.dt->SetPermitSubpixelAA(oldSubpixelAA);
 
     if (sideways) {
         // adjust updated aPt to account for the transform we were using
-        gfxFloat advance = aPt->x - origPt.x;
+        float advance = aPt->x - origPt.x;
         if (aOrientation ==
             gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_SIDEWAYS_LEFT) {
-            *aPt = gfxPoint(origPt.x, origPt.y - advance);
+            *aPt = gfx::Point(origPt.x, origPt.y - advance);
         } else {
-            *aPt = gfxPoint(origPt.x, origPt.y + advance);
+            *aPt = gfx::Point(origPt.x, origPt.y + advance);
         }
     }
 }
 
 bool
-gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint,
+gfxFont::RenderSVGGlyph(gfxContext *aContext, gfx::Point aPoint,
                         uint32_t aGlyphId, SVGContextPaint* aContextPaint) const
 {
     if (!GetFontEntry()->HasSVGGlyph(aGlyphId)) {
         return false;
     }
 
     const gfxFloat devUnitsPerSVGUnit =
         GetAdjustedSize() / GetFontEntry()->UnitsPerEm();
@@ -2272,17 +2270,17 @@ gfxFont::RenderSVGGlyph(gfxContext *aCon
     aContextPaint->InitStrokeGeometry(aContext, devUnitsPerSVGUnit);
 
     GetFontEntry()->RenderSVGGlyph(aContext, aGlyphId, aContextPaint);
     aContext->NewPath();
     return true;
 }
 
 bool
-gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint,
+gfxFont::RenderSVGGlyph(gfxContext *aContext, gfx::Point aPoint,
                         uint32_t aGlyphId, SVGContextPaint* aContextPaint,
                         gfxTextRunDrawCallbacks *aCallbacks,
                         bool& aEmittedGlyphs) const
 {
     if (aCallbacks && aEmittedGlyphs) {
         aCallbacks->NotifyGlyphPathEmitted();
         aEmittedGlyphs = false;
     }
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -1696,26 +1696,27 @@ public:
      * .context  the Thebes graphics context to which we're drawing
      * .dt  Moz2D DrawTarget to which we're drawing
      *
      * Callers guarantee:
      * -- aStart and aEnd are aligned to cluster and ligature boundaries
      * -- all glyphs use this font
      */
     void Draw(const gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
-              gfxPoint *aPt, const TextRunDrawParams& aRunParams,
+              mozilla::gfx::Point* aPt, const TextRunDrawParams& aRunParams,
               mozilla::gfx::ShapedTextFlags aOrientation);
 
     /**
      * Draw the emphasis marks for the given text run. Its prerequisite
      * and output are similiar to the method Draw().
      * @param aPt the baseline origin of the emphasis marks.
      * @param aParams some drawing parameters, see EmphasisMarkDrawParams.
      */
-    void DrawEmphasisMarks(const gfxTextRun* aShapedText, gfxPoint* aPt,
+    void DrawEmphasisMarks(const gfxTextRun* aShapedText,
+                           mozilla::gfx::Point* aPt,
                            uint32_t aOffset, uint32_t aCount,
                            const EmphasisMarkDrawParams& aParams);
 
     /**
      * Measure a run of characters. See gfxTextRun::Metrics.
      * @param aTight if false, then return the union of the glyph extents
      * with the font-box for the characters (the rectangle with x=0,width=
      * the advance width for the character run,y=-(font ascent), and height=
@@ -1950,31 +1951,31 @@ protected:
     virtual const Metrics& GetHorizontalMetrics() = 0;
 
     mozilla::UniquePtr<const Metrics> CreateVerticalMetrics();
 
     // Output a single glyph at *aPt, which is updated by the glyph's advance.
     // Normal glyphs are simply accumulated in aBuffer until it is full and
     // gets flushed, but SVG or color-font glyphs will instead be rendered
     // directly to the destination (found from the buffer's parameters).
-    void DrawOneGlyph(uint32_t           aGlyphID,
-                      double             aAdvance,
-                      gfxPoint          *aPt,
-                      GlyphBufferAzure&  aBuffer,
-                      bool              *aEmittedGlyphs) const;
+    void DrawOneGlyph(uint32_t             aGlyphID,
+                      float                aAdvance,
+                      mozilla::gfx::Point* aPt,
+                      GlyphBufferAzure&    aBuffer,
+                      bool*                aEmittedGlyphs) const;
 
     // Output a run of glyphs at *aPt, which is updated to follow the last glyph
     // in the run. This method also takes account of any letter-spacing provided
     // in aRunParams.
-    bool DrawGlyphs(const gfxShapedText      *aShapedText,
-                    uint32_t                  aOffset, // offset in the textrun
-                    uint32_t                  aCount, // length of run to draw
-                    gfxPoint                 *aPt,
-                    const TextRunDrawParams&  aRunParams,
-                    const FontDrawParams&     aFontParams);
+    bool DrawGlyphs(const gfxShapedText*     aShapedText,
+                    uint32_t                 aOffset, // offset in the textrun
+                    uint32_t                 aCount, // length of run to draw
+                    mozilla::gfx::Point*     aPt,
+                    const TextRunDrawParams& aRunParams,
+                    const FontDrawParams&    aFontParams);
 
     // set the font size and offset used for
     // synthetic subscript/superscript glyphs
     void CalculateSubSuperSizeAndOffset(int32_t aAppUnitsPerDevPixel,
                                         gfxFloat& aSubSuperSizeRatio,
                                         float& aBaselineOffset);
 
     // Return a font that is a "clone" of this one, but reduced to 80% size
@@ -2238,19 +2239,19 @@ protected:
     // Helper to calculate various derived metrics from the results of
     // InitMetricsFromSfntTables or equivalent platform code
     void CalculateDerivedMetrics(Metrics& aMetrics);
 
     // some fonts have bad metrics, this method sanitize them.
     // if this font has bad underline offset, aIsBadUnderlineFont should be true.
     void SanitizeMetrics(Metrics *aMetrics, bool aIsBadUnderlineFont);
 
-    bool RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint,
+    bool RenderSVGGlyph(gfxContext *aContext, mozilla::gfx::Point aPoint,
                         uint32_t aGlyphId, SVGContextPaint* aContextPaint) const;
-    bool RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint,
+    bool RenderSVGGlyph(gfxContext *aContext, mozilla::gfx::Point aPoint,
                         uint32_t aGlyphId, SVGContextPaint* aContextPaint,
                         gfxTextRunDrawCallbacks *aCallbacks,
                         bool& aEmittedGlyphs) const;
 
     bool RenderColorGlyph(DrawTarget* aDrawTarget,
                           gfxContext* aContext,
                           mozilla::gfx::ScaledFont* scaledFont,
                           mozilla::gfx::GlyphRenderingOptions* renderingOptions,
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -423,18 +423,18 @@ gfxTextRun::ShrinkToLigatureBoundaries(R
         while (aRange->end > aRange->start &&
                !charGlyphs[aRange->end].IsLigatureGroupStart()) {
             --aRange->end;
         }
     }
 }
 
 void
-gfxTextRun::DrawGlyphs(gfxFont *aFont, Range aRange, gfxPoint *aPt,
-                       PropertyProvider *aProvider, Range aSpacingRange,
+gfxTextRun::DrawGlyphs(gfxFont* aFont, Range aRange, gfx::Point* aPt,
+                       PropertyProvider* aProvider, Range aSpacingRange,
                        TextRunDrawParams& aParams,
                        gfx::ShapedTextFlags aOrientation) const
 {
     AutoTArray<PropertyProvider::Spacing,200> spacingBuffer;
     bool haveSpacing = GetAdjustedSpacingArray(aRange, aProvider,
                                                aSpacingRange, &spacingBuffer);
     aParams.spacing = haveSpacing ? spacingBuffer.Elements() : nullptr;
     aFont->Draw(this, aRange.start, aRange.end, aPt, aParams, aOrientation);
@@ -460,18 +460,18 @@ ClipPartialLigature(const gfxTextRun* aT
             *aStart = std::max(*aStart, endEdge);
         } else {
             *aEnd = std::min(*aEnd, endEdge);
         }
     }
 }
 
 void
-gfxTextRun::DrawPartialLigature(gfxFont *aFont, Range aRange,
-                                gfxPoint *aPt, PropertyProvider *aProvider,
+gfxTextRun::DrawPartialLigature(gfxFont* aFont, Range aRange,
+                                gfx::Point* aPt, PropertyProvider* aProvider,
                                 TextRunDrawParams& aParams,
                                 gfx::ShapedTextFlags aOrientation) const
 {
     if (aRange.start >= aRange.end) {
         return;
     }
 
     if (auto* textDrawer = aParams.context->GetTextDrawer()) {
@@ -502,21 +502,21 @@ gfxTextRun::DrawPartialLigature(gfxFont 
                clipExtents.Width(), (end - start) / mAppUnitsPerDevUnit) :
           Rect(start / mAppUnitsPerDevUnit, clipExtents.Y(),
                (end - start) / mAppUnitsPerDevUnit, clipExtents.Height());
       MaybeSnapToDevicePixels(clipRect, *aParams.dt, true);
 
       aParams.context->Clip(clipRect);
     }
 
-    gfxPoint pt;
+    gfx::Point pt;
     if (aParams.isVerticalRun) {
-        pt = gfxPoint(aPt->x, aPt->y - aParams.direction * data.mPartAdvance);
+        pt = Point(aPt->x, aPt->y - aParams.direction * data.mPartAdvance);
     } else {
-        pt = gfxPoint(aPt->x - aParams.direction * data.mPartAdvance, aPt->y);
+        pt = Point(aPt->x - aParams.direction * data.mPartAdvance, aPt->y);
     }
 
     DrawGlyphs(aFont, data.mRange, &pt,
                aProvider, aRange, aParams, aOrientation);
     aParams.context->PopClip();
 
     if (aParams.isVerticalRun) {
         aPt->y += aParams.direction * data.mPartWidth;
@@ -595,17 +595,17 @@ struct MOZ_STACK_CLASS BufferAlphaColor 
         mContext->PopGroupAndBlend();
         mContext->Restore();
     }
 
     gfxContext *mContext;
 };
 
 void
-gfxTextRun::Draw(Range aRange, gfxPoint aPt, const DrawParams& aParams) const
+gfxTextRun::Draw(Range aRange, gfx::Point aPt, const DrawParams& aParams) const
 {
     NS_ASSERTION(aRange.end <= GetLength(), "Substring out of range");
     NS_ASSERTION(aParams.drawMode == DrawMode::GLYPH_PATH ||
                  !(aParams.drawMode & DrawMode::GLYPH_PATH),
                  "GLYPH_PATH cannot be used with GLYPH_FILL, GLYPH_STROKE or GLYPH_STROKE_UNDERNEATH");
     NS_ASSERTION(aParams.drawMode == DrawMode::GLYPH_PATH || !aParams.callbacks,
                  "callback must not be specified unless using GLYPH_PATH");
 
@@ -650,17 +650,17 @@ gfxTextRun::Draw(Range aRange, gfxPoint 
         // to buffer.
         gfxTextRun::Metrics metrics = MeasureText(
             aRange, gfxFont::LOOSE_INK_EXTENTS,
             aParams.context->GetDrawTarget(), aParams.provider);
         if (IsRightToLeft()) {
             metrics.mBoundingBox.MoveBy(gfxPoint(aPt.x - metrics.mAdvanceWidth,
                                                  aPt.y));
         } else {
-            metrics.mBoundingBox.MoveBy(aPt);
+            metrics.mBoundingBox.MoveBy(gfxPoint(aPt.x, aPt.y));
         }
         syntheticBoldBuffer.PushSolidColor(metrics.mBoundingBox, currentColor,
                                            GetAppUnitsPerDevUnit());
     }
 
     // Set up parameters that will be constant across all glyph runs we need
     // to draw, regardless of the font used.
     TextRunDrawParams params;
@@ -690,17 +690,17 @@ gfxTextRun::Draw(Range aRange, gfxPoint 
         uint32_t start = iter.GetStringStart();
         uint32_t end = iter.GetStringEnd();
         Range ligatureRange(start, end);
         ShrinkToLigatureBoundaries(&ligatureRange);
 
         bool drawPartial = (aParams.drawMode & DrawMode::GLYPH_FILL) ||
                            (aParams.drawMode == DrawMode::GLYPH_PATH &&
                             aParams.callbacks);
-        gfxPoint origPt = aPt;
+        gfx::Point origPt = aPt;
 
         if (drawPartial) {
             DrawPartialLigature(font, Range(start, ligatureRange.start),
                                 &aPt, aParams.provider, params,
                                 iter.GetGlyphRun()->mOrientation);
         }
 
         DrawGlyphs(font, ligatureRange, &aPt,
@@ -729,30 +729,30 @@ gfxTextRun::Draw(Range aRange, gfxPoint 
         *aParams.advanceWidth = advance;
     }
 }
 
 // This method is mostly parallel to Draw().
 void
 gfxTextRun::DrawEmphasisMarks(gfxContext *aContext,
                               gfxTextRun* aMark,
-                              gfxFloat aMarkAdvance, gfxPoint aPt,
+                              gfxFloat aMarkAdvance, gfx::Point aPt,
                               Range aRange, PropertyProvider* aProvider) const
 {
     MOZ_ASSERT(aRange.end <= GetLength());
 
     EmphasisMarkDrawParams params;
     params.context = aContext;
     params.mark = aMark;
     params.advance = aMarkAdvance;
     params.direction = GetDirection();
     params.isVertical = IsVertical();
 
-    gfxFloat& inlineCoord = params.isVertical ? aPt.y : aPt.x;
-    gfxFloat direction = params.direction;
+    float& inlineCoord = params.isVertical ? aPt.y : aPt.x;
+    float direction = params.direction;
 
     GlyphRunIterator iter(this, aRange);
     while (iter.NextRun()) {
         gfxFont* font = iter.GetGlyphRun()->mFont;
         uint32_t start = iter.GetStringStart();
         uint32_t end = iter.GetStringEnd();
         Range ligatureRange(start, end);
         ShrinkToLigatureBoundaries(&ligatureRange);
--- a/gfx/thebes/gfxTextRun.h
+++ b/gfx/thebes/gfxTextRun.h
@@ -272,26 +272,27 @@ public:
      *   Draw(Range(middle, end), pt, ...) followed by
      *   Draw(Range(start, middle), gfxPoint(pt.x + advance, pt.y), ...)
      * should have the same effect as
      *   Draw(Range(start, end), pt, ...)
      *
      * Glyphs should be drawn in logical content order, which can be significant
      * if they overlap (perhaps due to negative spacing).
      */
-    void Draw(Range aRange, gfxPoint aPt, const DrawParams& aParams) const;
+    void Draw(Range aRange, mozilla::gfx::Point aPt,
+              const DrawParams& aParams) const;
 
     /**
      * Draws the emphasis marks for this text run. Uses only GetSpacing
      * from aProvider. The provided point is the baseline origin of the
      * line of emphasis marks.
      */
     void DrawEmphasisMarks(gfxContext* aContext,
                            gfxTextRun* aMark,
-                           gfxFloat aMarkAdvance, gfxPoint aPt,
+                           gfxFloat aMarkAdvance, mozilla::gfx::Point aPt,
                            Range aRange, PropertyProvider* aProvider) const;
 
     /**
      * Computes the ReflowMetrics for a substring.
      * Uses GetSpacing from aBreakProvider.
      * @param aBoundingBoxType which kind of bounding box (loose/tight)
      */
     Metrics MeasureText(Range aRange,
@@ -751,18 +752,19 @@ private:
     // (Platforms do the actual ligaturization, but we need to do a bunch of stuff
     // to handle requests that begin or end inside a ligature)
 
     // if aProvider is null then mBeforeSpacing and mAfterSpacing are set to zero
     LigatureData ComputeLigatureData(Range aPartRange,
                                      PropertyProvider *aProvider) const;
     gfxFloat ComputePartialLigatureWidth(Range aPartRange,
                                          PropertyProvider *aProvider) const;
-    void DrawPartialLigature(gfxFont *aFont, Range aRange,
-                             gfxPoint *aPt, PropertyProvider *aProvider,
+    void DrawPartialLigature(gfxFont* aFont, Range aRange,
+                             mozilla::gfx::Point* aPt,
+                             PropertyProvider* aProvider,
                              TextRunDrawParams& aParams,
                              mozilla::gfx::ShapedTextFlags aOrientation) const;
     // Advance aRange.start to the start of the nearest ligature, back
     // up aRange.end to the nearest ligature end; may result in
     // aRange->start == aRange->end.
     void ShrinkToLigatureBoundaries(Range* aRange) const;
     // result in appunits
     gfxFloat GetPartialLigatureWidth(Range aRange,
@@ -779,18 +781,18 @@ private:
                                  gfxFont::BoundingBoxType aBoundingBoxType,
                                  DrawTarget* aRefDrawTarget,
                                  PropertyProvider *aProvider,
                                  Range aSpacingRange,
                                  mozilla::gfx::ShapedTextFlags aOrientation,
                                  Metrics *aMetrics) const;
 
     // **** drawing helper ****
-    void DrawGlyphs(gfxFont *aFont, Range aRange, gfxPoint *aPt,
-                    PropertyProvider *aProvider, Range aSpacingRange,
+    void DrawGlyphs(gfxFont* aFont, Range aRange, mozilla::gfx::Point* aPt,
+                    PropertyProvider* aProvider, Range aSpacingRange,
                     TextRunDrawParams& aParams,
                     mozilla::gfx::ShapedTextFlags aOrientation) const;
 
     // The textrun holds either a single GlyphRun -or- an array;
     // the flag mHasGlyphRunArray tells us which is present.
     union {
         GlyphRun           mSingleGlyphRun;
         nsTArray<GlyphRun> mGlyphRunArray;
--- a/layout/generic/TextOverflow.cpp
+++ b/layout/generic/TextOverflow.cpp
@@ -274,17 +274,17 @@ nsDisplayTextOverflowMarker::PaintTextTo
   }
   pt += aOffsetFromRect;
 
   if (mStyle->mType == NS_STYLE_TEXT_OVERFLOW_ELLIPSIS) {
     gfxTextRun* textRun = GetEllipsisTextRun(mFrame);
     if (textRun) {
       NS_ASSERTION(!textRun->IsRightToLeft(),
                    "Ellipsis textruns should always be LTR!");
-      gfxPoint gfxPt(pt.x, pt.y);
+      gfx::Point gfxPt(pt.x, pt.y);
       textRun->Draw(gfxTextRun::Range(textRun), gfxPt,
                     gfxTextRun::DrawParams(aCtx));
     }
   } else {
     RefPtr<nsFontMetrics> fm =
       nsLayoutUtils::GetInflatedFontMetricsForFrame(mFrame);
     nsLayoutUtils::DrawString(mFrame, *fm, aCtx, mStyle->mString.get(),
                               mStyle->mString.Length(), pt);
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -5191,17 +5191,17 @@ nsDisplayText::RenderToContext(gfxContex
       // compressed at the same time as text.
       gfxPoint pt = nsLayoutUtils::PointToGfxPoint(framePt, A2D);
       gfxMatrix mat = aCtx->CurrentMatrix()
         .PreTranslate(pt).PreScale(scaleFactor, 1.0).PreTranslate(-pt);
       aCtx->SetMatrix (mat);
     }
   }
   nsTextFrame::PaintTextParams params(aCtx);
-  params.framePt = gfxPoint(framePt.x, framePt.y);
+  params.framePt = gfx::Point(framePt.x, framePt.y);
   params.dirtyRect = extraVisible;
 
   if (aBuilder->IsForGenerateGlyphMask()) {
     MOZ_ASSERT(!aBuilder->IsForPaintingSelectionBG());
     params.state = nsTextFrame::PaintTextParams::GenerateTextMask;
   } else if (aBuilder->IsForPaintingSelectionBG()) {
     params.state = nsTextFrame::PaintTextParams::PaintTextBGColor;
   } else {
@@ -6266,17 +6266,17 @@ AddHyphenToMetrics(nsTextFrame* aTextFra
 
 void
 nsTextFrame::PaintOneShadow(const PaintShadowParams& aParams,
                             nsCSSShadowItem* aShadowDetails,
                             gfxRect& aBoundingBox, uint32_t aBlurFlags)
 {
   AUTO_PROFILER_LABEL("nsTextFrame::PaintOneShadow", GRAPHICS);
 
-  gfxPoint shadowOffset(aShadowDetails->mXOffset, aShadowDetails->mYOffset);
+  gfx::Point shadowOffset(aShadowDetails->mXOffset, aShadowDetails->mYOffset);
   nscoord blurRadius = std::max(aShadowDetails->mRadius, 0);
 
   nscolor shadowColor = aShadowDetails->mHasColor ? aShadowDetails->mColor
                                                   : aParams.foregroundColor;
 
   if (auto* textDrawer = aParams.context->GetTextDrawer()) {
     wr::Shadow wrShadow;
 
@@ -6307,17 +6307,17 @@ nsTextFrame::PaintOneShadow(const PaintS
     }
     shadowGfxRect += gfxPoint(aParams.textBaselinePt.x,
                               aParams.framePt.y + aParams.leftSideOffset);
   } else {
     shadowGfxRect =
       aBoundingBox + gfxPoint(aParams.framePt.x + aParams.leftSideOffset,
                               aParams.textBaselinePt.y);
   }
-  shadowGfxRect += shadowOffset;
+  shadowGfxRect += gfxPoint(shadowOffset.x, shadowOffset.y);
 
   nsRect shadowRect(NSToCoordRound(shadowGfxRect.X()),
                     NSToCoordRound(shadowGfxRect.Y()),
                     NSToCoordRound(shadowGfxRect.Width()),
                     NSToCoordRound(shadowGfxRect.Height()));
 
   nsContextBoxBlur contextBoxBlur;
   const auto A2D = PresContext()->AppUnitsPerDevPixel();
@@ -6492,19 +6492,19 @@ nsTextFrame::PaintTextWithSelectionColor
     nscolor foreground, background;
     if (aParams.IsGenerateTextMask()) {
       foreground = NS_RGBA(0, 0, 0, 255);
     } else {
       GetSelectionTextColors(selectionType, *aParams.textPaintStyle,
                              rangeStyle, &foreground, &background);
     }
 
-    gfxPoint textBaselinePt = vertical ?
-      gfxPoint(aParams.textBaselinePt.x, aParams.framePt.y + iOffset) :
-      gfxPoint(aParams.framePt.x + iOffset, aParams.textBaselinePt.y);
+    gfx::Point textBaselinePt = vertical ?
+      gfx::Point(aParams.textBaselinePt.x, aParams.framePt.y + iOffset) :
+      gfx::Point(aParams.framePt.x + iOffset, aParams.textBaselinePt.y);
 
     // Determine what shadow, if any, to draw - either from textStyle
     // or from the ::-moz-selection pseudo-class if specified there
     nsCSSShadowArray* shadow = textStyle->GetTextShadow();
     GetSelectionTextShadow(this, selectionType, *aParams.textPaintStyle,
                            &shadow);
     if (shadow) {
       nscoord startEdge = iOffset;
@@ -6662,31 +6662,31 @@ nsTextFrame::PaintTextWithSelection(
   }
 
   return true;
 }
 
 void
 nsTextFrame::DrawEmphasisMarks(gfxContext* aContext,
                                WritingMode aWM,
-                               const gfxPoint& aTextBaselinePt,
-                               const gfxPoint& aFramePt, Range aRange,
+                               const gfx::Point& aTextBaselinePt,
+                               const gfx::Point& aFramePt, Range aRange,
                                const nscolor* aDecorationOverrideColor,
                                PropertyProvider* aProvider)
 {
   const EmphasisMarkInfo* info = GetProperty(EmphasisMarkProperty());
   if (!info) {
     return;
   }
 
   bool isTextCombined = StyleContext()->IsTextCombined();
   nscolor color = aDecorationOverrideColor ? *aDecorationOverrideColor :
     nsLayoutUtils::GetColor(this, &nsStyleText::mTextEmphasisColor);
   aContext->SetColor(Color::FromABGR(color));
-  gfxPoint pt;
+  gfx::Point pt;
   if (!isTextCombined) {
     pt = aTextBaselinePt;
   } else {
     MOZ_ASSERT(aWM.IsVertical());
     pt = aFramePt;
     if (aWM.IsVerticalRL()) {
       pt.x += GetSize().width - GetLogicalBaseline(aWM);
     } else {
@@ -6982,35 +6982,35 @@ nsTextFrame::PaintText(const PaintTextPa
   }
   // Trim trailing whitespace, unless we're painting a selection highlight,
   // which should include trailing spaces if present (bug 1146754).
   provider.InitializeForDisplay(!aItem.mIsFrameSelected.value());
 
   const bool reversed = mTextRun->IsInlineReversed();
   const bool verticalRun = mTextRun->IsVertical();
   WritingMode wm = GetWritingMode();
-  const gfxFloat frameWidth = GetSize().width;
-  const gfxFloat frameHeight = GetSize().height;
-  gfxPoint textBaselinePt;
+  const float frameWidth = GetSize().width;
+  const float frameHeight = GetSize().height;
+  gfx::Point textBaselinePt;
   if (verticalRun) {
     if (wm.IsVerticalLR()) {
       textBaselinePt.x = nsLayoutUtils::GetSnappedBaselineX(
         this, aParams.context, nscoord(aParams.framePt.x), mAscent);
     } else {
       textBaselinePt.x = nsLayoutUtils::GetSnappedBaselineX(
         this, aParams.context, nscoord(aParams.framePt.x) + frameWidth,
         -mAscent);
     }
     textBaselinePt.y = reversed ? aParams.framePt.y + frameHeight
                                 : aParams.framePt.y;
   } else {
     textBaselinePt =
-      gfxPoint(reversed ? aParams.framePt.x + frameWidth : aParams.framePt.x,
-               nsLayoutUtils::GetSnappedBaselineY(
-                 this, aParams.context, aParams.framePt.y, mAscent));
+      gfx::Point(reversed ? aParams.framePt.x + frameWidth : aParams.framePt.x,
+                 nsLayoutUtils::GetSnappedBaselineY(
+                   this, aParams.context, aParams.framePt.y, mAscent));
   }
   Range range = ComputeTransformedRange(provider);
   uint32_t startOffset = range.start;
   uint32_t maxLength = range.Length();
   nscoord snappedStartEdge, snappedEndEdge;
   if (!MeasureCharClippedText(provider, aItem.mVisIStartEdge, aItem.mVisIEndEdge,
          &startOffset, &maxLength, &snappedStartEdge, &snappedEndEdge)) {
     return;
@@ -7095,17 +7095,17 @@ nsTextFrame::PaintText(const PaintTextPa
   aParams.context->SetFontSmoothingBackgroundColor(
     Color::FromABGR(StyleUserInterface()->mFontSmoothingBackgroundColor));
   DrawText(range, textBaselinePt, params);
   aParams.context->SetFontSmoothingBackgroundColor(Color());
 }
 
 static void
 DrawTextRun(const gfxTextRun* aTextRun,
-            const gfxPoint& aTextBaselinePt,
+            const gfx::Point& aTextBaselinePt,
             gfxTextRun::Range aRange,
             const nsTextFrame::DrawTextRunParams& aParams)
 {
   gfxTextRun::DrawParams params(aParams.context);
   params.provider = aParams.provider;
   params.advanceWidth = aParams.advanceWidth;
   params.contextPaint = aParams.contextPaint;
   params.callbacks = aParams.callbacks;
@@ -7136,47 +7136,47 @@ DrawTextRun(const gfxTextRun* aTextRun,
       aTextRun->Draw(aRange, aTextBaselinePt, params);
     } else {
       aTextRun->Draw(aRange, aTextBaselinePt, params);
     }
   }
 }
 
 void
-nsTextFrame::DrawTextRun(Range aRange, const gfxPoint& aTextBaselinePt,
+nsTextFrame::DrawTextRun(Range aRange, const gfx::Point& aTextBaselinePt,
                          const DrawTextRunParams& aParams)
 {
   MOZ_ASSERT(aParams.advanceWidth, "Must provide advanceWidth");
 
   ::DrawTextRun(mTextRun, aTextBaselinePt, aRange, aParams);
 
   if (aParams.drawSoftHyphen) {
     // Don't use ctx as the context, because we need a reference context here,
     // ctx may be transformed.
     RefPtr<gfxTextRun> hyphenTextRun =
       GetHyphenTextRun(mTextRun, nullptr, this);
     if (hyphenTextRun) {
       // For right-to-left text runs, the soft-hyphen is positioned at the left
       // of the text, minus its own width
-      gfxFloat hyphenBaselineX = aTextBaselinePt.x +
+      float hyphenBaselineX = aTextBaselinePt.x +
         mTextRun->GetDirection() * (*aParams.advanceWidth) -
         (mTextRun->IsRightToLeft() ? hyphenTextRun->GetAdvanceWidth() : 0);
       DrawTextRunParams params = aParams;
       params.provider = nullptr;
       params.advanceWidth = nullptr;
       ::DrawTextRun(hyphenTextRun.get(),
-                    gfxPoint(hyphenBaselineX, aTextBaselinePt.y),
+                    gfx::Point(hyphenBaselineX, aTextBaselinePt.y),
                     Range(hyphenTextRun.get()), params);
     }
   }
 }
 
 void
 nsTextFrame::DrawTextRunAndDecorations(Range aRange,
-                                       const gfxPoint& aTextBaselinePt,
+                                       const gfx::Point& aTextBaselinePt,
                                        const DrawTextParams& aParams,
                                        const TextDecorations& aDecorations)
 {
     const gfxFloat app =
       aParams.textStyle->PresContext()->AppUnitsPerDevPixel();
     // Writing mode of parent frame is used because the text frame may
     // be orthogonal to its parent when text-combine-upright is used or
     // its parent has "display: contents", and in those cases, we want
@@ -7307,17 +7307,17 @@ nsTextFrame::DrawTextRunAndDecorations(R
     params.decoration = NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH;
     for (const LineDecoration& dec : Reversed(aDecorations.mStrikes)) {
       paintDecorationLine(dec, &Metrics::strikeoutSize,
                           &Metrics::strikeoutOffset);
     }
 }
 
 void
-nsTextFrame::DrawText(Range aRange, const gfxPoint& aTextBaselinePt,
+nsTextFrame::DrawText(Range aRange, const gfx::Point& aTextBaselinePt,
                       const DrawTextParams& aParams)
 {
   TextDecorations decorations;
   GetTextDecorations(aParams.textStyle->PresContext(),
                      aParams.callbacks ? eUnresolvedColors : eResolvedColors,
                      decorations);
 
   // Hide text decorations if we're currently hiding @font-face fallback text
--- a/layout/generic/nsTextFrame.h
+++ b/layout/generic/nsTextFrame.h
@@ -436,17 +436,17 @@ public:
      * has been emitted to the gfxContext.
      */
     virtual void NotifySelectionDecorationLinePathEmitted() {}
   };
 
   struct PaintTextParams
   {
     gfxContext* context;
-    gfxPoint framePt;
+    mozilla::gfx::Point framePt;
     LayoutDeviceRect dirtyRect;
     mozilla::SVGContextPaint* contextPaint = nullptr;
     DrawPathCallbacks* callbacks = nullptr;
     enum
     {
       PaintText,        // Normal text painting.
       PaintTextBGColor, // Only paint background color of the selected text
                         // range in this state.
@@ -463,17 +463,17 @@ public:
 
     bool IsPaintText() const { return state == PaintText; }
     bool IsGenerateTextMask() const { return state == GenerateTextMask; }
     bool IsPaintBGColor() const { return state == PaintTextBGColor; }
   };
 
   struct PaintTextSelectionParams : PaintTextParams
   {
-    gfxPoint textBaselinePt;
+    mozilla::gfx::Point textBaselinePt;
     PropertyProvider* provider = nullptr;
     Range contentRange;
     nsTextPaintStyle* textPaintStyle = nullptr;
     explicit PaintTextSelectionParams(const PaintTextParams& aParams)
       : PaintTextParams(aParams)
     {}
   };
 
@@ -490,17 +490,17 @@ public:
     bool drawSoftHyphen = false;
     explicit DrawTextRunParams(gfxContext* aContext)
       : context(aContext)
     {}
   };
 
   struct DrawTextParams : DrawTextRunParams
   {
-    gfxPoint framePt;
+    mozilla::gfx::Point framePt;
     LayoutDeviceRect dirtyRect;
     const nsTextPaintStyle* textStyle = nullptr;
     const nsCharClipDisplayItem::ClipEdges* clipEdges = nullptr;
     const nscolor* decorationOverrideColor = nullptr;
     explicit DrawTextParams(gfxContext* aContext)
       : DrawTextRunParams(aContext)
     {}
   };
@@ -530,18 +530,18 @@ public:
     const nsCharClipDisplayItem::ClipEdges& aClipEdges);
   // helper: paint text decorations for text selected by aSelectionType
   void PaintTextSelectionDecorations(const PaintTextSelectionParams& aParams,
                                      const mozilla::UniquePtr<SelectionDetails>& aDetails,
                                      SelectionType aSelectionType);
 
   void DrawEmphasisMarks(gfxContext* aContext,
                          mozilla::WritingMode aWM,
-                         const gfxPoint& aTextBaselinePt,
-                         const gfxPoint& aFramePt,
+                         const mozilla::gfx::Point& aTextBaselinePt,
+                         const mozilla::gfx::Point& aFramePt,
                          Range aRange,
                          const nscolor* aDecorationOverrideColor,
                          PropertyProvider* aProvider);
 
   nscolor GetCaretColorAt(int32_t aOffset) override;
 
   int16_t GetSelectionStatus(int16_t* aSelectionFlags);
 
@@ -698,18 +698,18 @@ protected:
   // overflow rect of the emphasis marks.
   nsRect UpdateTextEmphasis(mozilla::WritingMode aWM,
                             PropertyProvider& aProvider);
 
   struct PaintShadowParams
   {
     gfxTextRun::Range range;
     LayoutDeviceRect dirtyRect;
-    gfxPoint framePt;
-    gfxPoint textBaselinePt;
+    mozilla::gfx::Point framePt;
+    mozilla::gfx::Point textBaselinePt;
     gfxContext* context;
     nscolor foregroundColor = NS_RGBA(0, 0, 0, 0);
     const nsCharClipDisplayItem::ClipEdges* clipEdges = nullptr;
     PropertyProvider* provider = nullptr;
     nscoord leftSideOffset = 0;
     explicit PaintShadowParams(const PaintTextParams& aParams)
       : dirtyRect(aParams.dirtyRect)
       , framePt(aParams.framePt)
@@ -796,26 +796,26 @@ protected:
     eResolvedColors,
     eUnresolvedColors
   };
   void GetTextDecorations(nsPresContext* aPresContext,
                           TextDecorationColorResolution aColorResolution,
                           TextDecorations& aDecorations);
 
   void DrawTextRun(Range aRange,
-                   const gfxPoint& aTextBaselinePt,
+                   const mozilla::gfx::Point& aTextBaselinePt,
                    const DrawTextRunParams& aParams);
 
   void DrawTextRunAndDecorations(Range aRange,
-                                 const gfxPoint& aTextBaselinePt,
+                                 const mozilla::gfx::Point& aTextBaselinePt,
                                  const DrawTextParams& aParams,
                                  const TextDecorations& aDecorations);
 
   void DrawText(Range aRange,
-                const gfxPoint& aTextBaselinePt,
+                const mozilla::gfx::Point& aTextBaselinePt,
                 const DrawTextParams& aParams);
 
   // Set non empty rect to aRect, it should be overflow rect or frame rect.
   // If the result rect is larger than the given rect, this returns true.
   bool CombineSelectionUnderlineRect(nsPresContext* aPresContext,
                                      nsRect& aRect);
 
   /**
--- a/layout/mathml/nsMathMLChar.cpp
+++ b/layout/mathml/nsMathMLChar.cpp
@@ -2074,17 +2074,18 @@ nsMathMLChar::PaintForeground(nsIFrame* 
 
   switch(mDraw)
   {
     case DRAW_NORMAL:
     case DRAW_VARIANT:
       // draw a single glyph (base size or size variant)
       // XXXfredw verify if mGlyphs[0] is non-null to workaround bug 973322.
       if (mGlyphs[0]) {
-        mGlyphs[0]->Draw(Range(mGlyphs[0].get()), gfxPoint(0.0, mUnscaledAscent),
+        mGlyphs[0]->Draw(Range(mGlyphs[0].get()),
+                         gfx::Point(0.0, mUnscaledAscent),
                          gfxTextRun::DrawParams(&aRenderingContext));
       }
       break;
     case DRAW_PARTS: {
       // paint by parts
       if (NS_STRETCH_DIRECTION_VERTICAL == mDirection)
         PaintVertically(presContext, &aRenderingContext, r, fgColor);
       else if (NS_STRETCH_DIRECTION_HORIZONTAL == mDirection)
@@ -2232,17 +2233,17 @@ nsMathMLChar::PaintVertically(nsPresCont
         }
         else { // middle
           clipRect.y = start[i];
           clipRect.height = end[i] - start[i];
         }
       }
       if (!clipRect.IsEmpty()) {
         AutoPushClipRect clip(aThebesContext, oneDevPixel, clipRect);
-        mGlyphs[i]->Draw(Range(mGlyphs[i].get()), gfxPoint(dx, dy), params);
+        mGlyphs[i]->Draw(Range(mGlyphs[i].get()), gfx::Point(dx, dy), params);
       }
     }
   }
 
   ///////////////
   // fill the gap between top and middle, and between middle and bottom.
   if (!mGlyphs[3]) { // null glue : draw a rule
     // figure out the dimensions of the rule to be drawn :
@@ -2298,17 +2299,17 @@ nsMathMLChar::PaintVertically(nsPresCont
       // Make sure not to draw outside the character
       nscoord dy = std::max(end[i], aRect.y);
       nscoord fillEnd = std::min(start[i+1], aRect.YMost());
       while (dy < fillEnd) {
         clipRect.y = dy;
         clipRect.height = std::min(bm.ascent + bm.descent, fillEnd - dy);
         AutoPushClipRect clip(aThebesContext, oneDevPixel, clipRect);
         dy += bm.ascent;
-        mGlyphs[3]->Draw(Range(mGlyphs[3].get()), gfxPoint(dx, dy), params);
+        mGlyphs[3]->Draw(Range(mGlyphs[3].get()), gfx::Point(dx, dy), params);
         dy += bm.descent;
       }
     }
   }
 #ifdef DEBUG
   else {
     for (i = 0; i < 2; ++i) {
       NS_ASSERTION(end[i] >= start[i+1],
@@ -2402,17 +2403,17 @@ nsMathMLChar::PaintHorizontally(nsPresCo
         }
         else { // middle
           clipRect.x = start[i];
           clipRect.width = end[i] - start[i];
         }
       }
       if (!clipRect.IsEmpty()) {
         AutoPushClipRect clip(aThebesContext, oneDevPixel, clipRect);
-        mGlyphs[i]->Draw(Range(mGlyphs[i].get()), gfxPoint(dx, dy), params);
+        mGlyphs[i]->Draw(Range(mGlyphs[i].get()), gfx::Point(dx, dy), params);
       }
     }
   }
 
   ////////////////
   // fill the gap between left and middle, and between middle and right.
   if (!mGlyphs[3]) { // null glue : draw a rule
     // figure out the dimensions of the rule to be drawn :
@@ -2466,17 +2467,17 @@ nsMathMLChar::PaintHorizontally(nsPresCo
       // Make sure not to draw outside the character
       nscoord dx = std::max(end[i], aRect.x);
       nscoord fillEnd = std::min(start[i+1], aRect.XMost());
       while (dx < fillEnd) {
         clipRect.x = dx;
         clipRect.width = std::min(bm.rightBearing - bm.leftBearing, fillEnd - dx);
         AutoPushClipRect clip(aThebesContext, oneDevPixel, clipRect);
         dx -= bm.leftBearing;
-        mGlyphs[3]->Draw(Range(mGlyphs[3].get()), gfxPoint(dx, dy), params);
+        mGlyphs[3]->Draw(Range(mGlyphs[3].get()), gfx::Point(dx, dy), params);
         dx += bm.rightBearing;
       }
     }
   }
 #ifdef DEBUG
   else { // no glue
     for (i = 0; i < 2; ++i) {
       NS_ASSERTION(end[i] >= start[i+1],
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -3686,17 +3686,17 @@ SVGTextFrame::PaintSVG(gfxContext& aCont
     gfxMatrix runTransform =
       run.GetTransformFromUserSpaceForPainting(presContext, item) *
       currentMatrix;
     aContext.SetMatrix(runTransform);
 
     if (drawMode != DrawMode(0)) {
       bool paintSVGGlyphs;
       nsTextFrame::PaintTextParams params(&aContext);
-      params.framePt = gfxPoint();
+      params.framePt = gfx::Point();
       params.dirtyRect = LayoutDevicePixel::
         FromAppUnits(frame->GetVisualOverflowRect(), auPerDevPx);
       params.contextPaint = contextPaint;
       if (ShouldRenderAsPath(frame, paintSVGGlyphs)) {
         SVGTextDrawPathCallbacks callbacks(this, aContext, frame,
                                            matrixForPaintServers,
                                            paintSVGGlyphs);
         params.callbacks = &callbacks;