From 1561fa16ce9413c8faabc50eed6469e3fbc0760c Mon Sep 17 00:00:00 2001 From: "vladimir@pobox.com" Date: Fri, 7 Mar 2008 16:58:57 -0800 Subject: [PATCH] b=418882, crash on www.rhein-zeitung.de, potential fix; r+sr=roc --- layout/generic/nsObjectFrame.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 85241f1c677a..c54cf5421240 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -1358,14 +1358,6 @@ nsObjectFrame::PaintPlugin(nsIRenderingContext& aRenderingContext, // the offset of the DC nsPoint origin; - // check if we need to update hdc - HDC hdc = (HDC)aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_WINDOWS_DC); - - if (reinterpret_cast(window->window) != hdc) { - window->window = reinterpret_cast(hdc); - doupdatewindow = PR_TRUE; - } - /* * Layout now has an optimized way of painting. Now we always get * a new drawing surface, sized to be just what's needed. Windowless @@ -1391,8 +1383,6 @@ nsObjectFrame::PaintPlugin(nsIRenderingContext& aRenderingContext, origin.x = NSToIntRound(float(ctxMatrix.GetTranslation().x)); origin.y = NSToIntRound(float(ctxMatrix.GetTranslation().y)); - SaveDC(hdc); - /* Need to force the clip to be set */ ctx->UpdateSurfaceClip(); @@ -1400,6 +1390,21 @@ nsObjectFrame::PaintPlugin(nsIRenderingContext& aRenderingContext, gfxFloat xoff, yoff; nsRefPtr surf = ctx->CurrentSurface(&xoff, &yoff); + if (surf->CairoStatus() != 0) { + NS_WARNING("Plugin is being asked to render to a surface that's in error!"); + return; + } + + // check if we need to update hdc + HDC hdc = (HDC)aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_WINDOWS_DC); + + if (reinterpret_cast(window->window) != hdc) { + window->window = reinterpret_cast(hdc); + doupdatewindow = PR_TRUE; + } + + SaveDC(hdc); + POINT origViewportOrigin; GetViewportOrgEx(hdc, &origViewportOrigin); SetViewportOrgEx(hdc, origViewportOrigin.x + (int) xoff, origViewportOrigin.y + (int) yoff, NULL);