Bug 1373232 - Use floating point division when dividing nscoord values with a twipsPerPixel factor. r?mats draft
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Sun, 18 Jun 2017 09:33:25 +0300
changeset 596110 a0e22c4e8ff1bf907de1d3ebcdd606d41c8ffca7
parent 594702 035c25bef7b5e4175006e63eff10c61c2eef73f1
child 633864 6eb6ea3c95ab2f8d25e95abf63269dae131b320e
push id64518
push userbmo:bpostelnicu@mozilla.com
push dateSun, 18 Jun 2017 06:34:15 +0000
reviewersmats
bugs1373232
milestone56.0a1
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;
 }