From 46a8719065107ac9ea3d152947b678fb296672d7 Mon Sep 17 00:00:00 2001 From: "peterlubczynski%netscape.com" Date: Fri, 9 Nov 2001 00:42:02 +0000 Subject: [PATCH] Mac fix for HTML embed region being painted the default background color bug 83159 r=av sr=sfraser a=asa git-svn-id: svn://10.0.0.236/trunk@107713 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsObjectFrame.cpp | 20 +++++++++++++++++++ .../layout/html/base/src/nsObjectFrame.cpp | 20 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 17e9ae8e2d2..4834218e48a 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -3728,6 +3728,11 @@ static void ConvertTwipsToPixels(nsIPresContext& aPresContext, nsRect& aTwipsRec } #endif // DO_DIRTY_INTERSECT +inline PRUint16 COLOR8TOCOLOR16(PRUint8 color8) +{ + return (color8 << 8) | color8; /* (color8 * 257) == (color8 * 0x0101) */ +} + void nsPluginInstanceOwner::FixUpPluginWindow() { if (mWidget) { @@ -3745,6 +3750,21 @@ void nsPluginInstanceOwner::FixUpPluginWindow() mPluginWindow.clipRect.left = widgetClip.x; mPluginWindow.clipRect.bottom = mPluginWindow.clipRect.top + widgetClip.height; mPluginWindow.clipRect.right = mPluginWindow.clipRect.left + widgetClip.width; + + // the Mac widget doesn't set the background color right away!! + // the background color needs to be set here on the plugin port + GrafPtr savePort; + ::GetPort(&savePort); // save our current port + nsPluginPort* pluginPort = GetPluginPort(); + ::SetPort((GrafPtr)pluginPort->port); + + nscolor color = mWidget->GetBackgroundColor(); + RGBColor macColor; + macColor.red = COLOR8TOCOLOR16(NS_GET_R(color)); // convert to Mac color + macColor.green = COLOR8TOCOLOR16(NS_GET_G(color)); + macColor.blue = COLOR8TOCOLOR16(NS_GET_B(color)); + ::RGBBackColor(&macColor); + ::SetPort(savePort); // restore port } } diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 17e9ae8e2d2..4834218e48a 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -3728,6 +3728,11 @@ static void ConvertTwipsToPixels(nsIPresContext& aPresContext, nsRect& aTwipsRec } #endif // DO_DIRTY_INTERSECT +inline PRUint16 COLOR8TOCOLOR16(PRUint8 color8) +{ + return (color8 << 8) | color8; /* (color8 * 257) == (color8 * 0x0101) */ +} + void nsPluginInstanceOwner::FixUpPluginWindow() { if (mWidget) { @@ -3745,6 +3750,21 @@ void nsPluginInstanceOwner::FixUpPluginWindow() mPluginWindow.clipRect.left = widgetClip.x; mPluginWindow.clipRect.bottom = mPluginWindow.clipRect.top + widgetClip.height; mPluginWindow.clipRect.right = mPluginWindow.clipRect.left + widgetClip.width; + + // the Mac widget doesn't set the background color right away!! + // the background color needs to be set here on the plugin port + GrafPtr savePort; + ::GetPort(&savePort); // save our current port + nsPluginPort* pluginPort = GetPluginPort(); + ::SetPort((GrafPtr)pluginPort->port); + + nscolor color = mWidget->GetBackgroundColor(); + RGBColor macColor; + macColor.red = COLOR8TOCOLOR16(NS_GET_R(color)); // convert to Mac color + macColor.green = COLOR8TOCOLOR16(NS_GET_G(color)); + macColor.blue = COLOR8TOCOLOR16(NS_GET_B(color)); + ::RGBBackColor(&macColor); + ::SetPort(savePort); // restore port } }