From 6c7b4a707c48e69d19ceff07cb14fe75761e76f1 Mon Sep 17 00:00:00 2001 From: "peterlubczynski%netscape.com" Date: Fri, 30 Mar 2001 03:07:52 +0000 Subject: [PATCH] Fix to make printing OBJECTs safer bug 73846 a=av sr=waterson --- layout/generic/nsObjectFrame.cpp | 34 +++++++++++++++++++------- layout/html/base/src/nsObjectFrame.cpp | 34 +++++++++++++++++++------- 2 files changed, 50 insertions(+), 18 deletions(-) diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 1de0d3150f2..c7cda93bba6 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -64,6 +64,7 @@ #include "nsIDocumentEncoder.h" #include "nsXPIDLString.h" #include "nsIDOMRange.h" +#include "nsIPrintContext.h" // XXX For temporary paint code #include "nsIStyleContext.h" @@ -674,6 +675,13 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, if(child != nsnull) return HandleImage(aPresContext, aMetrics, aReflowState, aStatus, child); + // determine if we are a printcontext + nsCOMPtr thePrinterContext = do_QueryInterface(aPresContext); + if (thePrinterContext) { + // we are printing bail for now + return rv; + } + // if mInstance is null, we need to determine what kind of object we are and instantiate ourselves if(!mInstanceOwner) { @@ -1324,16 +1332,24 @@ nsObjectFrame::Paint(nsIPresContext* aPresContext, const nsRect& aDirtyRect, nsFramePaintLayer aWhichLayer) { - const nsStyleDisplay* disp = (const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display); - if ((disp != nsnull) && !disp->IsVisibleOrCollapsed()) { - return NS_OK; - } + // determine if we are a printcontext + nsCOMPtr thePrinterContext = do_QueryInterface(aPresContext); + if (thePrinterContext) { + // we are printing bail for now + return NS_OK; + } - nsIFrame * child = mFrames.FirstChild(); - if (child != NULL) { // This is an image - nsObjectFrameSuper::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); - return NS_OK; - } + + const nsStyleDisplay* disp = (const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display); + if ((disp != nsnull) && !disp->IsVisibleOrCollapsed()) { + return NS_OK; + } + + nsIFrame * child = mFrames.FirstChild(); + if (child != NULL) { // This is an image + nsObjectFrameSuper::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); + return NS_OK; + } #if defined (XP_MAC) // delegate all painting to the plugin instance. diff --git a/layout/html/base/src/nsObjectFrame.cpp b/layout/html/base/src/nsObjectFrame.cpp index 1de0d3150f2..c7cda93bba6 100644 --- a/layout/html/base/src/nsObjectFrame.cpp +++ b/layout/html/base/src/nsObjectFrame.cpp @@ -64,6 +64,7 @@ #include "nsIDocumentEncoder.h" #include "nsXPIDLString.h" #include "nsIDOMRange.h" +#include "nsIPrintContext.h" // XXX For temporary paint code #include "nsIStyleContext.h" @@ -674,6 +675,13 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, if(child != nsnull) return HandleImage(aPresContext, aMetrics, aReflowState, aStatus, child); + // determine if we are a printcontext + nsCOMPtr thePrinterContext = do_QueryInterface(aPresContext); + if (thePrinterContext) { + // we are printing bail for now + return rv; + } + // if mInstance is null, we need to determine what kind of object we are and instantiate ourselves if(!mInstanceOwner) { @@ -1324,16 +1332,24 @@ nsObjectFrame::Paint(nsIPresContext* aPresContext, const nsRect& aDirtyRect, nsFramePaintLayer aWhichLayer) { - const nsStyleDisplay* disp = (const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display); - if ((disp != nsnull) && !disp->IsVisibleOrCollapsed()) { - return NS_OK; - } + // determine if we are a printcontext + nsCOMPtr thePrinterContext = do_QueryInterface(aPresContext); + if (thePrinterContext) { + // we are printing bail for now + return NS_OK; + } - nsIFrame * child = mFrames.FirstChild(); - if (child != NULL) { // This is an image - nsObjectFrameSuper::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); - return NS_OK; - } + + const nsStyleDisplay* disp = (const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display); + if ((disp != nsnull) && !disp->IsVisibleOrCollapsed()) { + return NS_OK; + } + + nsIFrame * child = mFrames.FirstChild(); + if (child != NULL) { // This is an image + nsObjectFrameSuper::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); + return NS_OK; + } #if defined (XP_MAC) // delegate all painting to the plugin instance.