Bug 616495: Deal with some sides having no moz-border-colors at all. r=vlad a=blocking-beta8
authorBas Schouten <bschouten@mozilla.com>
Sat, 04 Dec 2010 05:21:20 +0100
changeset 58595 ec5c700a5f7e88919a17886450de9897d74caacf
parent 58594 e19fb998583e3484ce77557d47710d00c0737de2
child 58596 cd392793b0c0c1331485caa48b65e4de53f91658
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersvlad, blocking-beta8
bugs616495
milestone2.0b8pre
Bug 616495: Deal with some sides having no moz-border-colors at all. r=vlad a=blocking-beta8
layout/base/nsCSSRenderingBorders.cpp
--- a/layout/base/nsCSSRenderingBorders.cpp
+++ b/layout/base/nsCSSRenderingBorders.cpp
@@ -1313,46 +1313,51 @@ nsCSSBorderRenderer::DrawRectangularComp
 
       gfxPoint firstCorner = rect.CCWCorner(side);
       firstCorner.x += cornerAdjusts[side].a;
       firstCorner.y += cornerAdjusts[side].b;
       gfxPoint secondCorner = rect.CWCorner(side);
       secondCorner.x -= cornerAdjusts[side].a;
       secondCorner.y -= cornerAdjusts[side].b;
         
-      gfxRGBA currentColor = gfxRGBA(currentColors[side]->mColor);
+      gfxRGBA currentColor =
+        currentColors[side] ? gfxRGBA(currentColors[side]->mColor)
+                            : gfxRGBA(mBorderColors[side]);
 
       mContext->SetColor(currentColor);
       mContext->NewPath();
       mContext->MoveTo(firstCorner);
       mContext->LineTo(secondCorner);
       mContext->Stroke();
 
       mContext->NewPath();
       gfxPoint cornerTopLeft = rect.CWCorner(side);
       cornerTopLeft.x -= 0.5;
       cornerTopLeft.y -= 0.5;
       mContext->Rectangle(gfxRect(cornerTopLeft, gfxSize(1, 1)));
-      gfxRGBA nextColor = gfxRGBA(currentColors[sideNext]->mColor);
+      gfxRGBA nextColor =
+        currentColors[sideNext] ? gfxRGBA(currentColors[sideNext]->mColor)
+                                : gfxRGBA(mBorderColors[sideNext]);
+
       gfxRGBA cornerColor((currentColor.r + nextColor.r) / 2.0,
                           (currentColor.g + nextColor.g) / 2.0,
                           (currentColor.b + nextColor.b) / 2.0,
                           (currentColor.a + nextColor.a) / 2.0);
       mContext->SetColor(cornerColor);
       mContext->Fill();
 
       if (side != 0) {
         // We'll have to keep side 0 for the color averaging on side 3.
-        if (currentColors[side]->mNext) {
+        if (currentColors[side] && currentColors[side]->mNext) {
           currentColors[side] = currentColors[side]->mNext;
         }
       }
     }
     // Now advance the color for side 0.
-    if (currentColors[0]->mNext) {
+    if (currentColors[0] && currentColors[0]->mNext) {
       currentColors[0] = currentColors[0]->mNext;
     }
     rect.Inset(1);
   }
 }
 
 void
 nsCSSBorderRenderer::DrawBorders()