Bug 1318539 - Correct the bounds of the buffer used for drawing colored text with opacity when the run direction is RTL. r=jrmuizel
authorJonathan Kew <jkew@mozilla.com>
Wed, 22 Feb 2017 23:10:29 +0000
changeset 373451 1c364b17c93ffb5745d283596bdc788bc028f675
parent 373450 9b98ddcdbfdae76e5cd45decbc2249e5b7df837a
child 373452 ce729354cba0048085a9851ac14feaf7439bb238
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1318539
milestone54.0a1
Bug 1318539 - Correct the bounds of the buffer used for drawing colored text with opacity when the run direction is RTL. r=jrmuizel
gfx/thebes/gfxTextRun.cpp
layout/reftests/text/reftest.list
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -611,21 +611,27 @@ gfxTextRun::Draw(Range aRange, gfxPoint 
     BufferAlphaColor syntheticBoldBuffer(aParams.context);
     Color currentColor;
     bool needToRestore = false;
 
     if (aParams.drawMode & DrawMode::GLYPH_FILL &&
         HasNonOpaqueNonTransparentColor(aParams.context, currentColor) &&
         HasSyntheticBoldOrColor(this, aRange)) {
         needToRestore = true;
-        // measure text, use the bounding box
+        // Measure text; use the bounding box to determine the area we need
+        // to buffer.
         gfxTextRun::Metrics metrics = MeasureText(
             aRange, gfxFont::LOOSE_INK_EXTENTS,
             aParams.context->GetDrawTarget(), aParams.provider);
-        metrics.mBoundingBox.MoveBy(aPt);
+        if (IsRightToLeft()) {
+            metrics.mBoundingBox.MoveBy(gfxPoint(aPt.x - metrics.mAdvanceWidth,
+                                                 aPt.y));
+        } else {
+            metrics.mBoundingBox.MoveBy(aPt);
+        }
         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;
     params.context = aParams.context;
--- a/layout/reftests/text/reftest.list
+++ b/layout/reftests/text/reftest.list
@@ -339,10 +339,10 @@ pref(layout.css.control-characters.visib
 # font fallback for <space> when not supported in the primary font family - bug 970891
 HTTP(..) == space-font-1.html space-font-1-ref.html
 
 # handling of highly negative letter-spacing and intrinsic width
 == negative-letter-spacing-1.html negative-letter-spacing-1-ref.html
 == segment-break-transformation-1.html segment-break-transformation-1-ref.html
 
 # color glyphs, opacity, and RTL runs - bug 1318539
-fails == color-opacity-rtl-1.html color-opacity-rtl-1-ref.html
-fails == color-opacity-rtl-2.html color-opacity-rtl-2-ref.html
+== color-opacity-rtl-1.html color-opacity-rtl-1-ref.html
+== color-opacity-rtl-2.html color-opacity-rtl-2-ref.html