Bug 1088071, part 1 - Wrap the callers of the final nsRenderingContext::DrawString method up in a new nsLayoutUtils::DrawUniDirString method. r=jfkthame
authorJonathan Watt <jwatt@jwatt.org>
Fri, 24 Oct 2014 11:00:23 +0100
changeset 212103 449a78f0febc78b469c1b6d42363c7bd75034d7e
parent 212102 2b6b6c03d82bb023ab19c85b2837ddef9d3c68c9
child 212104 90cd5968c9ce2a57bf0b278537005f89a268eb31
push id27697
push usercbook@mozilla.com
push dateFri, 24 Oct 2014 13:48:53 +0000
treeherdermozilla-central@de805196bbc4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1088071
milestone36.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 1088071, part 1 - Wrap the callers of the final nsRenderingContext::DrawString method up in a new nsLayoutUtils::DrawUniDirString method. r=jfkthame
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/generic/nsImageFrame.cpp
layout/mathml/nsMathMLContainerFrame.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -4644,18 +4644,27 @@ nsLayoutUtils::DrawString(const nsIFrame
                                           aStyleContext : aFrame->StyleContext());
     rv = nsBidiPresUtils::RenderText(aString, aLength, level,
                                      presContext, *aContext, *aContext,
                                      aPoint.x, aPoint.y);
   }
   if (NS_FAILED(rv))
   {
     aContext->SetTextRunRTL(false);
-    aContext->DrawString(aString, aLength, aPoint.x, aPoint.y);
-  }
+    DrawUniDirString(aString, aLength, aPoint, *aContext);
+  }
+}
+
+void
+nsLayoutUtils::DrawUniDirString(const char16_t* aString,
+                                uint32_t aLength,
+                                nsPoint aPoint,
+                                nsRenderingContext& aContext)
+{
+  aContext.DrawString(aString, aLength, aPoint.x, aPoint.y);
 }
 
 nscoord
 nsLayoutUtils::GetStringWidth(const nsIFrame*      aFrame,
                               nsRenderingContext* aContext,
                               const char16_t*     aString,
                               int32_t              aLength)
 {
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -1319,16 +1319,21 @@ public:
 
   static void DrawString(const nsIFrame*       aFrame,
                          nsRenderingContext*   aContext,
                          const char16_t*      aString,
                          int32_t               aLength,
                          nsPoint               aPoint,
                          nsStyleContext*       aStyleContext = nullptr);
 
+  static void DrawUniDirString(const char16_t* aString,
+                               uint32_t aLength,
+                               nsPoint aPoint,
+                               nsRenderingContext& aContext);
+
   static nscoord GetStringWidth(const nsIFrame*      aFrame,
                                 nsRenderingContext* aContext,
                                 const char16_t*     aString,
                                 int32_t              aLength);
 
   /**
    * Helper function for drawing text-shadow. The callback's job
    * is to draw whatever needs to be blurred onto the given context.
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -1118,18 +1118,21 @@ nsImageFrame::DisplayAltText(nsPresConte
                                          aRenderingContext,
                                          aRect.XMost() - strWidth, y + maxAscent);
       else
         rv = nsBidiPresUtils::RenderText(str, maxFit, NSBIDI_LTR,
                                          aPresContext, aRenderingContext,
                                          aRenderingContext,
                                          aRect.x, y + maxAscent);
     }
-    if (NS_FAILED(rv))
-      aRenderingContext.DrawString(str, maxFit, aRect.x, y + maxAscent);
+    if (NS_FAILED(rv)) {
+      nsLayoutUtils::DrawUniDirString(str, maxFit,
+                                      nsPoint(aRect.x, y + maxAscent),
+                                      aRenderingContext);
+    }
 
     // Move to the next line
     str += maxFit;
     strLen -= maxFit;
     y += height;
     firstLine = false;
   }
 }
--- a/layout/mathml/nsMathMLContainerFrame.cpp
+++ b/layout/mathml/nsMathMLContainerFrame.cpp
@@ -105,18 +105,20 @@ void nsDisplayMathMLError::Paint(nsDispl
                                   appUnitsPerDevPixel,
                                   *drawTarget);
   ColorPattern red(ToDeviceColor(Color(1.f, 0.f, 0.f, 1.f)));
   drawTarget->FillRect(rect, red);
 
   aCtx->ThebesContext()->SetColor(NS_RGB(255,255,255));
   nscoord ascent = aCtx->FontMetrics()->MaxAscent();
   NS_NAMED_LITERAL_STRING(errorMsg, "invalid-markup");
-  aCtx->DrawString(errorMsg.get(), uint32_t(errorMsg.Length()),
-                   pt.x, pt.y+ascent);
+  nsLayoutUtils::DrawUniDirString(errorMsg.get(),
+                                  uint32_t(errorMsg.Length()),
+                                  nsPoint(pt.x, pt.y + ascent),
+                                  *aCtx);
 }
 
 /* /////////////
  * nsIMathMLFrame - support methods for stretchy elements
  * =============================================================================
  */
 
 static bool