Bug 1185636 - Part 4b - don't use a css border skirt when printing. r=mstange
authorLee Salzman <lsalzman@mozilla.com>
Fri, 31 Jul 2015 14:09:29 -0400
changeset 287520 0ba60c89c282428d1d4a86227065d778df34a838
parent 287519 942beac221e4b6a89ffe096da593871b4d7649b9
child 287521 706f21f9e34949d4a0896d1f0ade153012bc0d60
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1185636
milestone42.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 1185636 - Part 4b - don't use a css border skirt when printing. r=mstange
layout/base/nsCSSRendering.cpp
layout/base/nsCSSRenderingBorders.cpp
layout/base/nsCSSRenderingBorders.h
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -772,17 +772,18 @@ nsCSSRendering::PaintBorderWithStyleBord
   //PrintAsFormatString ("bgRadii: %f %f %f %f\n", bgRadii[0], bgRadii[1], bgRadii[2], bgRadii[3]);
 
 #if 0
   // this will draw a transparent red backround underneath the border area
   ColorPattern color(ToDeviceColor(Color(1.f, 0.f, 0.f, 0.5f)));
   aDrawTarget.FillRect(joinedBorderAreaPx, color);
 #endif
 
-  nsCSSBorderRenderer br(&aDrawTarget,
+  nsCSSBorderRenderer br(aPresContext->Type(),
+                         &aDrawTarget,
                          joinedBorderAreaPx,
                          borderStyles,
                          borderWidths,
                          bgRadii,
                          borderColors,
                          compositeColors,
                          bgColor);
   br.DrawBorders();
@@ -907,17 +908,18 @@ nsCSSRendering::PaintOutline(nsPresConte
   Float outlineWidths[4] = { Float(width / twipsPerPixel),
                              Float(width / twipsPerPixel),
                              Float(width / twipsPerPixel),
                              Float(width / twipsPerPixel) };
 
   // start drawing
   gfxContext *ctx = aRenderingContext.ThebesContext();
 
-  nsCSSBorderRenderer br(ctx->GetDrawTarget(),
+  nsCSSBorderRenderer br(aPresContext->Type(),
+                         ctx->GetDrawTarget(),
                          oRect,
                          outlineStyles,
                          outlineWidths,
                          outlineRadii,
                          outlineColors,
                          nullptr,
                          bgColor);
   br.DrawBorders();
@@ -955,17 +957,18 @@ nsCSSRendering::PaintFocus(nsPresContext
   gfxContext *ctx = aRenderingContext.ThebesContext();
 
   // Because this renders a dotted border, the background color
   // should not be used.  Therefore, we provide a value that will
   // be blatantly wrong if it ever does get used.  (If this becomes
   // something that CSS can style, this function will then have access
   // to a style context and can use the same logic that PaintBorder
   // and PaintOutline do.)
-  nsCSSBorderRenderer br(ctx->GetDrawTarget(),
+  nsCSSBorderRenderer br(aPresContext->Type(),
+                         ctx->GetDrawTarget(),
                          focusRect,
                          focusStyles,
                          focusWidths,
                          focusRadii,
                          focusColors,
                          nullptr,
                          NS_RGB(255, 0, 0));
   br.DrawBorders();
--- a/layout/base/nsCSSRenderingBorders.cpp
+++ b/layout/base/nsCSSRenderingBorders.cpp
@@ -113,25 +113,27 @@ typedef enum {
   // adjacent corners.
   CORNER_SOLID,
 
   // Paint the corner as a dot, the size of the bigger of the adjacent
   // sides.
   CORNER_DOT
 } CornerStyle;
 
-nsCSSBorderRenderer::nsCSSBorderRenderer(DrawTarget* aDrawTarget,
+nsCSSBorderRenderer::nsCSSBorderRenderer(nsPresContext::nsPresContextType aPresContextType,
+                                         DrawTarget* aDrawTarget,
                                          Rect& aOuterRect,
                                          const uint8_t* aBorderStyles,
                                          const Float* aBorderWidths,
                                          RectCornerRadii& aBorderRadii,
                                          const nscolor* aBorderColors,
                                          nsBorderColors* const* aCompositeColors,
                                          nscolor aBackgroundColor)
-  : mDrawTarget(aDrawTarget),
+  : mPresContextType(aPresContextType),
+    mDrawTarget(aDrawTarget),
     mOuterRect(aOuterRect),
     mBorderStyles(aBorderStyles),
     mBorderWidths(aBorderWidths),
     mBorderRadii(aBorderRadii),
     mBorderColors(aBorderColors),
     mCompositeColors(aCompositeColors),
     mBackgroundColor(aBackgroundColor)
 {
@@ -1443,17 +1445,18 @@ nsCSSBorderRenderer::DrawNoCompositeColo
     Point sideEnd = outerCorner + cornerMults[i] * mBorderCornerDimensions[c];
     // if the side is inverted, don't draw it
     if (-(sideEnd - sideStart).DotProduct(cornerMults[i]) <= 0) {
       sideWidth = 0.0f;
     }
 
     Float skirtSize = 0.0f, skirtSlope = 0.0f;
     // the sides don't match, so compute a skirt
-    if (firstColor != secondColor) {
+    if (firstColor != secondColor &&
+        mPresContextType != nsPresContext::eContext_Print) {
       Point cornerDir = outerCorner - innerCorner;
       ComputeCornerSkirtSize(firstColor.a, secondColor.a,
                              cornerDir.DotProduct(cornerMults[i]),
                              cornerDir.DotProduct(cornerMults[i3]),
                              skirtSize, skirtSlope);
     }
 
     if (!mBorderRadii[c].IsEmpty()) {
--- a/layout/base/nsCSSRenderingBorders.h
+++ b/layout/base/nsCSSRenderingBorders.h
@@ -10,16 +10,17 @@
 #include "gfxRect.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/PathHelpers.h"
 #include "mozilla/RefPtr.h"
 #include "nsColor.h"
 #include "nsCOMPtr.h"
 #include "nsStyleConsts.h"
+#include "nsPresContext.h"
 
 struct nsBorderColors;
 
 namespace mozilla {
 namespace gfx {
 class GradientStops;
 } // namespace gfx
 } // namespace mozilla
@@ -80,17 +81,18 @@ class nsCSSBorderRenderer final
   typedef mozilla::gfx::DrawTarget DrawTarget;
   typedef mozilla::gfx::Float Float;
   typedef mozilla::gfx::Path Path;
   typedef mozilla::gfx::Rect Rect;
   typedef mozilla::gfx::RectCornerRadii RectCornerRadii;
 
 public:
 
-  nsCSSBorderRenderer(DrawTarget* aDrawTarget,
+  nsCSSBorderRenderer(nsPresContext::nsPresContextType aPresContextType,
+                      DrawTarget* aDrawTarget,
                       Rect& aOuterRect,
                       const uint8_t* aBorderStyles,
                       const Float* aBorderWidths,
                       RectCornerRadii& aBorderRadii,
                       const nscolor* aBorderColors,
                       nsBorderColors* const* aCompositeColors,
                       nscolor aBackgroundColor);
 
@@ -109,16 +111,19 @@ public:
   static void ComputeOuterRadii(const RectCornerRadii& aRadii,
                                 const Float* aBorderSizes,
                                 RectCornerRadii* aOuterRadiiRet);
 
 private:
 
   RectCornerRadii mBorderCornerDimensions;
 
+  // the PresContext type
+  nsPresContext::nsPresContextType mPresContextType;
+
   // destination DrawTarget
   DrawTarget* mDrawTarget;
 
   // the rectangle of the outside and the inside of the border
   Rect mOuterRect;
   Rect mInnerRect;
 
   // the style and size of the border