diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 8bb399334b1d..6133c571692c 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -736,8 +736,7 @@ nsCSSRendering::PaintBorderWithStyleBorder(nsPresContext* aPresContext, joinedBorderArea.width, joinedBorderArea.height); // start drawing - gfxContext* ctx = aRenderingContext.ThebesContext(); - ctx->Save(); + bool needToPopClip = false; if (::IsBoxDecorationSlice(aStyleBorder)) { if (joinedBorderArea.IsEqualEdges(aBorderArea)) { @@ -746,10 +745,11 @@ nsCSSRendering::PaintBorderWithStyleBorder(nsPresContext* aPresContext, } else { // We're drawing borders around the joined continuation boxes so we need // to clip that to the slice that we want for this frame. - aRenderingContext.ThebesContext()-> - Clip(NSRectToSnappedRect(aBorderArea, - aForFrame->PresContext()->AppUnitsPerDevPixel(), - aDrawTarget)); + aDrawTarget.PushClipRect( + NSRectToSnappedRect(aBorderArea, + aForFrame->PresContext()->AppUnitsPerDevPixel(), + aDrawTarget)); + needToPopClip = true; } } else { MOZ_ASSERT(joinedBorderArea.IsEqualEdges(aBorderArea), @@ -803,7 +803,9 @@ nsCSSRendering::PaintBorderWithStyleBorder(nsPresContext* aPresContext, bgColor); br.DrawBorders(); - ctx->Restore(); + if (needToPopClip) { + aDrawTarget.PopClip(); + } PrintAsStringNewline();