From 6582dac7502ef24f515719698393f565a30c09e9 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Wed, 3 Oct 2012 13:43:19 +0100 Subject: [PATCH] Backout ffcdd896a1fa (bug 787947) for reftest failures --- layout/base/nsCSSRendering.cpp | 42 ++++++++++++-------------- layout/reftests/bugs/787947-1-ref.html | 3 -- layout/reftests/bugs/787947-1.html | 3 -- layout/reftests/bugs/reftest.list | 1 - 4 files changed, 19 insertions(+), 30 deletions(-) delete mode 100644 layout/reftests/bugs/787947-1-ref.html delete mode 100644 layout/reftests/bugs/787947-1.html diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index a6773f64b04..f8a773b8560 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -2283,7 +2283,6 @@ nsCSSRendering::PaintGradient(nsPresContext* aPresContext, gfxRect areaToFill = nsLayoutUtils::RectToGfxRect(aFillArea, appUnitsPerPixel); gfxMatrix ctm = ctx->CurrentMatrix(); - bool isCTMPreservingAxisAlignedRectangles = ctm.PreservesAxisAlignedRectangles(); // xStart/yStart are the top-left corner of the top-left tile. nscoord xStart = FindTileStart(dirty.x, aOneCellArea.x, aOneCellArea.width); @@ -2303,30 +2302,27 @@ nsCSSRendering::PaintGradient(nsPresContext* aPresContext, gfxRect fillRect = pattern->mCoversTile ? areaToFill : tileRect.Intersect(areaToFill); ctx->NewPath(); - // Try snapping the fill rect. Snap its top-left and bottom-right - // independently to preserve the orientation. - gfxPoint snappedFillRectTopLeft = fillRect.TopLeft(); - gfxPoint snappedFillRectBottomRight = fillRect.BottomRight(); - if (isCTMPreservingAxisAlignedRectangles && - ctx->UserToDevicePixelSnapped(snappedFillRectTopLeft, true) && - ctx->UserToDevicePixelSnapped(snappedFillRectBottomRight, true)) { - if (snappedFillRectTopLeft.x == snappedFillRectBottomRight.x || - snappedFillRectTopLeft.y == snappedFillRectBottomRight.y) { - // Nothing to draw; avoid scaling by zero and other weirdness that - // could put the context in an error state. - continue; - } - // Set the context's transform to the transform that maps fillRect to - // snappedFillRect. The part of the gradient that was going to - // exactly fill fillRect will fill snappedFillRect instead. + // If we can snap the gradient tile and fill rects, do so, but make sure + // that the gradient is scaled precisely to the tile rect. + gfxRect fillRectSnapped = fillRect; + // Don't snap the tileRect directly since that would lose information + // about the orientation of the current transform (i.e. vertical or + // horizontal flipping). Instead snap the corners independently so if + // the CTM has a flip, our Scale() below preserves the flip. + gfxPoint tileRectSnappedTopLeft = tileRect.TopLeft(); + gfxPoint tileRectSnappedBottomRight = tileRect.BottomRight(); + if (ctx->UserToDevicePixelSnapped(fillRectSnapped, true) && + ctx->UserToDevicePixelSnapped(tileRectSnappedTopLeft, true) && + ctx->UserToDevicePixelSnapped(tileRectSnappedBottomRight, true)) { ctx->IdentityMatrix(); - ctx->Translate(snappedFillRectTopLeft); - ctx->Scale((snappedFillRectBottomRight.x - snappedFillRectTopLeft.x)/fillRect.width, - (snappedFillRectBottomRight.y - snappedFillRectTopLeft.y)/fillRect.height); - ctx->Translate(-fillRect.TopLeft()); + ctx->Rectangle(fillRectSnapped); + ctx->Translate(tileRectSnappedTopLeft); + ctx->Scale((tileRectSnappedBottomRight.x - tileRectSnappedTopLeft.x)/tileRect.width, + (tileRectSnappedBottomRight.y - tileRectSnappedTopLeft.y)/tileRect.height); + } else { + ctx->Rectangle(fillRect); + ctx->Translate(tileRect.TopLeft()); } - ctx->Rectangle(fillRect); - ctx->Translate(tileRect.TopLeft()); ctx->SetPattern(pattern->mPattern); ctx->Fill(); ctx->SetMatrix(ctm); diff --git a/layout/reftests/bugs/787947-1-ref.html b/layout/reftests/bugs/787947-1-ref.html deleted file mode 100644 index 88e6fc66827..00000000000 --- a/layout/reftests/bugs/787947-1-ref.html +++ /dev/null @@ -1,3 +0,0 @@ - -
-

Hello diff --git a/layout/reftests/bugs/787947-1.html b/layout/reftests/bugs/787947-1.html deleted file mode 100644 index c5ee3e0c127..00000000000 --- a/layout/reftests/bugs/787947-1.html +++ /dev/null @@ -1,3 +0,0 @@ - -

-

Hello diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index cdb3c3b9c7d..95950bf5fff 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -1719,4 +1719,3 @@ fuzzy-if(true,17,5859) == 759036-2.html 759036-2-ref.html == 776265-2b.html 776265-2-ref.html == 776265-2c.html 776265-2-ref.html == 776265-2d.html 776265-2-ref.html -== 787947-1.html 787947-1-ref.html