From a08b5a7e8d3e5b745d4295880006c21fe65a1a9d Mon Sep 17 00:00:00 2001 From: "av%netscape.com" Date: Thu, 30 Sep 1999 08:07:23 +0000 Subject: [PATCH] Fixing bug #8036, reviewd by beard git-svn-id: svn://10.0.0.236/trunk@49418 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsObjectFrame.cpp | 47 +++++++++++++++++++ .../layout/html/base/src/nsObjectFrame.cpp | 47 +++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 9fa05d8b7f6..2486d3ce110 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -236,6 +236,10 @@ protected: nsIPluginHost* aPluginHost, const char* aMimetype, nsIURI* aURL); + //~~~ + nsresult ReinstantiatePlugin(nsIPresContext& aPresContext, + nsHTMLReflowMetrics& aMetrics, + const nsHTMLReflowState& aReflowState); nsresult HandleImage(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aMetrics, @@ -919,6 +923,8 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext, NS_IF_RELEASE(cv); NS_IF_RELEASE(container); } + else + rv = ReinstantiatePlugin(aPresContext, aMetrics, aReflowState); // finish up if(rv == NS_OK) @@ -1015,6 +1021,47 @@ nsObjectFrame::InstantiatePlugin(nsIPresContext& aPresContext, return aPluginHost->InstantiateEmbededPlugin(aMimetype, aURL, mInstanceOwner); } +//~~~This is called when the page containing plugin is resized, and plugin has its dimensions +// specified in percentage, so it needs to follow the page on the fly. +nsresult +nsObjectFrame::ReinstantiatePlugin(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aMetrics, const nsHTMLReflowState& aReflowState) +{ + nsIView *parentWithView; + nsPoint origin; + nsPluginWindow *window; + float t2p; + aPresContext.GetTwipsToPixels(&t2p); + + // we need to recalculate this now that we have access to the nsPluginInstanceOwner + // and its size info (as set in the tag) + GetDesiredSize(&aPresContext, aReflowState, aMetrics); + if (nsnull != aMetrics.maxElementSize) + { + //XXX AddBorderPaddingToMaxElementSize(borderPadding); + aMetrics.maxElementSize->width = aMetrics.width; + aMetrics.maxElementSize->height = aMetrics.height; + } + + mInstanceOwner->GetWindow(window); + + GetOffsetFromView(origin, &parentWithView); + window->x = NSTwipsToIntPixels(origin.x, t2p); + window->y = NSTwipsToIntPixels(origin.y, t2p); + window->width = NSTwipsToIntPixels(aMetrics.width, t2p); + window->height = NSTwipsToIntPixels(aMetrics.height, t2p); + + window->clipRect.top = 0; + window->clipRect.left = 0; + window->clipRect.bottom = NSTwipsToIntPixels(aMetrics.height, t2p); + window->clipRect.right = NSTwipsToIntPixels(aMetrics.width, t2p); + +#ifdef XP_UNIX + window->ws_info = nsnull; //XXX need to figure out what this is. MMP +#endif + + return NS_OK; +} + nsresult nsObjectFrame::HandleImage(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aMetrics, diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 9fa05d8b7f6..2486d3ce110 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -236,6 +236,10 @@ protected: nsIPluginHost* aPluginHost, const char* aMimetype, nsIURI* aURL); + //~~~ + nsresult ReinstantiatePlugin(nsIPresContext& aPresContext, + nsHTMLReflowMetrics& aMetrics, + const nsHTMLReflowState& aReflowState); nsresult HandleImage(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aMetrics, @@ -919,6 +923,8 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext, NS_IF_RELEASE(cv); NS_IF_RELEASE(container); } + else + rv = ReinstantiatePlugin(aPresContext, aMetrics, aReflowState); // finish up if(rv == NS_OK) @@ -1015,6 +1021,47 @@ nsObjectFrame::InstantiatePlugin(nsIPresContext& aPresContext, return aPluginHost->InstantiateEmbededPlugin(aMimetype, aURL, mInstanceOwner); } +//~~~This is called when the page containing plugin is resized, and plugin has its dimensions +// specified in percentage, so it needs to follow the page on the fly. +nsresult +nsObjectFrame::ReinstantiatePlugin(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aMetrics, const nsHTMLReflowState& aReflowState) +{ + nsIView *parentWithView; + nsPoint origin; + nsPluginWindow *window; + float t2p; + aPresContext.GetTwipsToPixels(&t2p); + + // we need to recalculate this now that we have access to the nsPluginInstanceOwner + // and its size info (as set in the tag) + GetDesiredSize(&aPresContext, aReflowState, aMetrics); + if (nsnull != aMetrics.maxElementSize) + { + //XXX AddBorderPaddingToMaxElementSize(borderPadding); + aMetrics.maxElementSize->width = aMetrics.width; + aMetrics.maxElementSize->height = aMetrics.height; + } + + mInstanceOwner->GetWindow(window); + + GetOffsetFromView(origin, &parentWithView); + window->x = NSTwipsToIntPixels(origin.x, t2p); + window->y = NSTwipsToIntPixels(origin.y, t2p); + window->width = NSTwipsToIntPixels(aMetrics.width, t2p); + window->height = NSTwipsToIntPixels(aMetrics.height, t2p); + + window->clipRect.top = 0; + window->clipRect.left = 0; + window->clipRect.bottom = NSTwipsToIntPixels(aMetrics.height, t2p); + window->clipRect.right = NSTwipsToIntPixels(aMetrics.width, t2p); + +#ifdef XP_UNIX + window->ws_info = nsnull; //XXX need to figure out what this is. MMP +#endif + + return NS_OK; +} + nsresult nsObjectFrame::HandleImage(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aMetrics,