From 225400d1aa4e6a88e49906ea2dec9812d86b7ddf Mon Sep 17 00:00:00 2001 From: "av%netscape.com" Date: Sat, 8 Dec 2001 01:13:05 +0000 Subject: [PATCH] Fixing bug 113264 -- making NPPrint struct compatible with older versions of plugins, r=peterl, sr=beard git-svn-id: svn://10.0.0.236/trunk@110061 18797224-902f-48f8-a5cc-f745e15eee43 --- .../plugin/base/src/ns4xPluginInstance.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp b/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp index 845f9512f31..7d324e6e283 100644 --- a/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp +++ b/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp @@ -989,6 +989,26 @@ NS_IMETHODIMP ns4xPluginInstance::Print(nsPluginPrint* platformPrint) NPPrint* thePrint = (NPPrint *)platformPrint; + // to be compatible with the older SDK versions and to match what + // 4.x and other browsers do, overwrite |window.type| field with one + // more copy of |platformPrint|. See bug 113264 + if(fCallbacks) { + PRUint16 sdkmajorversion = (fCallbacks->version & 0xff00)>>8; + PRUint16 sdkminorversion = fCallbacks->version & 0x00ff; + if((sdkmajorversion == 0) && (sdkminorversion < 11)) { + // Let's copy platformPrint bytes over to where it was supposed to be + // in older versions -- four bytes towards the beginning of the struct + // but we should be careful about possible misalignments + if(sizeof(NPWindowType) >= sizeof(void *)) { + void* source = thePrint->print.embedPrint.platformPrint; + void** destination = (void **)&(thePrint->print.embedPrint.window.type); + *destination = source; + } + else + NS_ASSERTION(PR_FALSE, "Incompatible OS for assignment"); + } + } + NS_TRY_SAFE_CALL_VOID(CallNPP_PrintProc(fCallbacks->print, &fNPP, thePrint), fLibrary);