Bug 1373232 - Use floating point division when dividing nscoord values with a twipsPerPixel factor. r=mats
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Sun, 18 Jun 2017 09:33:25 +0300
changeset 364572 84a58eb9d35b2457426421f0e95f5aa23f9c9e3c
parent 364571 35bc216e83145c998ea604b198f5443fe0fe0ca9
child 364573 db39e769326ceb042f31ad3a8e13bcc7f40e8b0d
push id32049
push usercbook@mozilla.com
push dateMon, 19 Jun 2017 11:36:23 +0000
treeherdermozilla-central@26d62a1ac0e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1373232
milestone56.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 1373232 - Use floating point division when dividing nscoord values with a twipsPerPixel factor. r=mats MozReview-Commit-ID: JR3EDkDuwVA
layout/painting/nsCSSRendering.cpp
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -1040,20 +1040,20 @@ nsCSSRendering::CreateBorderRendererForO
   nscolor outlineColor =
     aStyleContext->GetVisitedDependentColor(&nsStyleOutline::mOutlineColor);
   nscolor outlineColors[4] = { outlineColor,
                                outlineColor,
                                outlineColor,
                                outlineColor };
 
   // convert the border widths
-  Float outlineWidths[4] = { Float(width / twipsPerPixel),
-                             Float(width / twipsPerPixel),
-                             Float(width / twipsPerPixel),
-                             Float(width / twipsPerPixel) };
+  Float outlineWidths[4] = { Float(width) / twipsPerPixel,
+                             Float(width) / twipsPerPixel,
+                             Float(width) / twipsPerPixel,
+                             Float(width) / twipsPerPixel };
   Rect dirtyRect = NSRectToRect(aDirtyRect, twipsPerPixel);
 
   nsIDocument* document = nullptr;
   nsIContent* content = aForFrame->GetContent();
   if (content) {
     document = content->OwnerDoc();
   }
 
@@ -1108,20 +1108,20 @@ nsCSSRendering::PaintFocus(nsPresContext
 
   Rect focusRect(NSRectToRect(aFocusRect, oneDevPixel));
 
   RectCornerRadii focusRadii;
   {
     nscoord twipsRadii[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
     ComputePixelRadii(twipsRadii, oneDevPixel, &focusRadii);
   }
-  Float focusWidths[4] = { Float(oneCSSPixel / oneDevPixel),
-                           Float(oneCSSPixel / oneDevPixel),
-                           Float(oneCSSPixel / oneDevPixel),
-                           Float(oneCSSPixel / oneDevPixel) };
+  Float focusWidths[4] = { Float(oneCSSPixel) / oneDevPixel,
+                           Float(oneCSSPixel) / oneDevPixel,
+                           Float(oneCSSPixel) / oneDevPixel,
+                           Float(oneCSSPixel) / oneDevPixel };
 
   uint8_t focusStyles[4] = { NS_STYLE_BORDER_STYLE_DOTTED,
                              NS_STYLE_BORDER_STYLE_DOTTED,
                              NS_STYLE_BORDER_STYLE_DOTTED,
                              NS_STYLE_BORDER_STYLE_DOTTED };
   nscolor focusColors[4] = { aColor, aColor, aColor, aColor };
 
   // Because this renders a dotted border, the background color
@@ -1640,17 +1640,17 @@ nsCSSRendering::PaintBoxShadowOuter(nsPr
       fragmentClip = fragmentClip.Intersect(aDirtyRect);
       aRenderingContext.
         Clip(NSRectToSnappedRect(fragmentClip,
                                  aForFrame->PresContext()->AppUnitsPerDevPixel(),
                                  aDrawTarget));
 
       RectCornerRadii clipRectRadii;
       if (hasBorderRadius) {
-        Float spreadDistance = shadowItem->mSpread / twipsPerPixel;
+        Float spreadDistance = Float(shadowItem->mSpread) / twipsPerPixel;
 
         Float borderSizes[4];
 
         borderSizes[eSideLeft] = spreadDistance;
         borderSizes[eSideTop] = spreadDistance;
         borderSizes[eSideRight] = spreadDistance;
         borderSizes[eSideBottom] = spreadDistance;
 
@@ -1722,20 +1722,20 @@ nsCSSRendering::GetShadowInnerRadii(nsIF
 
   RectCornerRadii borderRadii;
 
   hasBorderRadius = GetBorderRadii(frameRect, aFrameArea, aFrame, borderRadii);
   if (hasBorderRadius) {
     ComputePixelRadii(twipsRadii, twipsPerPixel, &borderRadii);
 
     Float borderSizes[4] = {
-      Float(border.top / twipsPerPixel),
-      Float(border.right / twipsPerPixel),
-      Float(border.bottom / twipsPerPixel),
-      Float(border.left / twipsPerPixel)
+      Float(border.top) / twipsPerPixel,
+      Float(border.right) / twipsPerPixel,
+      Float(border.bottom) / twipsPerPixel,
+      Float(border.left) / twipsPerPixel
     };
     nsCSSBorderRenderer::ComputeInnerRadii(borderRadii,
                                            borderSizes,
                                            &aOutInnerRadii);
   }
 
   return hasBorderRadius;
 }