Bug 1426092 - Fix the inflation of the text bounding rect to account for stroke-width correctly. r=xidorn
authorJonathan Kew <jkew@mozilla.com>
Fri, 22 Dec 2017 08:59:12 +0000
changeset 449106 4d0e3c825e42b0b9ba5cc1ab7172c4a2a4e7dd69
parent 449105 433caabd1b475f08feca72a9860d035fd8edfa64
child 449107 ea5bf2a0a2ee1d20fcbfeeab03bafd04c1b98660
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1426092
milestone59.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 1426092 - Fix the inflation of the text bounding rect to account for stroke-width correctly. r=xidorn
layout/generic/nsTextFrame.cpp
layout/reftests/text-stroke/reftest.list
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -5781,24 +5781,23 @@ nsTextFrame::UnionAdditionalOverflow(nsP
         verticalDec ? nsRect(topOrLeft, 0, bottomOrRight - topOrLeft, measure)
                     : nsRect(0, topOrLeft, measure, bottomOrRight - topOrLeft));
     }
 
     aVisualOverflowRect->UnionRect(*aVisualOverflowRect,
                                    UpdateTextEmphasis(parentWM, aProvider));
   }
 
-  // text-stroke overflows
+  // text-stroke overflows: add half of text-stroke-width on all sides
   nscoord textStrokeWidth = StyleText()->mWebkitTextStrokeWidth;
   if (textStrokeWidth > 0) {
+    // Inflate rect by stroke-width/2; we add an extra pixel to allow for
+    // antialiasing, rounding errors, etc.
     nsRect strokeRect = *aVisualOverflowRect;
-    strokeRect.x -= textStrokeWidth;
-    strokeRect.y -= textStrokeWidth;
-    strokeRect.width += textStrokeWidth;
-    strokeRect.height += textStrokeWidth;
+    strokeRect.Inflate(textStrokeWidth / 2 + appUnitsPerDevUnit);
     aVisualOverflowRect->UnionRect(*aVisualOverflowRect, strokeRect);
   }
 
   // Text-shadow overflows
   nsRect shadowRect =
     nsLayoutUtils::GetTextShadowRectsUnion(*aVisualOverflowRect, this);
   aVisualOverflowRect->UnionRect(*aVisualOverflowRect, shadowRect);
 
--- a/layout/reftests/text-stroke/reftest.list
+++ b/layout/reftests/text-stroke/reftest.list
@@ -2,9 +2,9 @@
 # fuzzy is needed here for platform dependent backends
 default-preferences pref(layout.css.prefixes.webkit,true)
 
 fuzzy-if(gtkWidget,255,20) fuzzy-if(winWidget,20,10) fails-if(skiaContent&&(gtkWidget||winWidget)) == webkit-text-stroke-property-001.html webkit-text-stroke-property-001-ref.html
 fuzzy-if(gtkWidget,255,20) fuzzy-if(winWidget,20,10) fails-if(skiaContent&&(gtkWidget||winWidget)) == webkit-text-stroke-property-002.html webkit-text-stroke-property-002-ref.html
 fuzzy-if(gtkWidget,255,20) fuzzy-if(winWidget,20,10) fails-if(skiaContent&&(gtkWidget||winWidget)) == webkit-text-stroke-property-003.html webkit-text-stroke-property-003-ref.html
 fuzzy-if(gtkWidget,255,20) fuzzy-if(winWidget,20,10) fails-if(skiaContent&&(gtkWidget||winWidget)) == webkit-text-stroke-property-004.html webkit-text-stroke-property-004-ref.html
 fuzzy-if(gtkWidget,255,20) fuzzy-if(winWidget,20,10) fails-if(skiaContent&&(gtkWidget||winWidget)) == webkit-text-stroke-property-005.html webkit-text-stroke-property-005-ref.html
-fails == webkit-text-stroke-property-006.html webkit-text-stroke-property-006-ref.html # bug 1426092
+fuzzy-if(gtkWidget,255,392) fuzzy-if(winWidget&&!d2d,48,372) fuzzy-if(winWidget&&d2d,71,10) == webkit-text-stroke-property-006.html webkit-text-stroke-property-006-ref.html