--- a/dom/plugins/base/PluginPRLibrary.cpp
+++ b/dom/plugins/base/PluginPRLibrary.cpp
@@ -274,16 +274,18 @@ PluginPRLibrary::GetImageContainer(NPP i
nsresult
PluginPRLibrary::IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing)
{
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
*aDrawing = false;
return NS_OK;
}
+#endif
+#if defined(XP_MACOSX) || defined(XP_WIN)
nsresult
PluginPRLibrary::ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor)
{
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
return NS_OK;
}
#endif
--- a/dom/plugins/base/PluginPRLibrary.h
+++ b/dom/plugins/base/PluginPRLibrary.h
@@ -109,16 +109,18 @@ public:
virtual nsresult NPP_GetSitesWithData(nsCOMPtr<nsIGetSitesWithDataCallback> callback) override;
virtual nsresult AsyncSetWindow(NPP aInstance, NPWindow* aWindow) override;
virtual nsresult GetImageContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) override;
virtual nsresult GetImageSize(NPP aInstance, nsIntSize* aSize) override;
virtual bool IsOOP() override { return false; }
#if defined(XP_MACOSX)
virtual nsresult IsRemoteDrawingCoreAnimation(NPP aInstance, bool* aDrawing) override;
+#endif
+#if defined(XP_MACOSX) || defined(XP_WIN)
virtual nsresult ContentsScaleFactorChanged(NPP aInstance, double aContentsScaleFactor) override;
#endif
virtual nsresult SetBackgroundUnknown(NPP instance) override;
virtual nsresult BeginUpdateBackground(NPP instance, const nsIntRect&,
DrawTarget** aDrawTarget) override;
virtual nsresult EndUpdateBackground(NPP instance,
const nsIntRect&) override;
virtual void DidComposite(NPP aInstance) override { }
--- a/dom/plugins/base/npapi.h
+++ b/dom/plugins/base/npapi.h
@@ -411,18 +411,20 @@ typedef enum {
NPNVsupportsAdvancedKeyHandling = 21,
NPNVdocumentOrigin = 22,
NPNVCSSZoomFactor = 23,
NPNVpluginDrawingModel = 1000 /* Get the current drawing model (NPDrawingModel) */
+#if defined(XP_MACOSX) || defined(XP_WIN)
+ , NPNVcontentsScaleFactor = 1001
+#endif
#if defined(XP_MACOSX)
- , NPNVcontentsScaleFactor = 1001
#ifndef NP_NO_QUICKDRAW
, NPNVsupportsQuickDrawBool = 2000
#endif
, NPNVsupportsCoreGraphicsBool = 2001
, NPNVsupportsOpenGLBool = 2002
, NPNVsupportsCoreAnimationBool = 2003
, NPNVsupportsInvalidatingCoreAnimationBool = 2004
#endif
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -2008,17 +2008,19 @@ NPError
return NPERR_NO_ERROR;
}
case NPNVsupportsUpdatedCocoaTextInputBool: {
*(NPBool*)result = true;
return NPERR_NO_ERROR;
}
-
+#endif
+
+#if defined(XP_MACOSX) || defined(XP_WIN)
case NPNVcontentsScaleFactor: {
nsNPAPIPluginInstance *inst =
(nsNPAPIPluginInstance *) (npp ? npp->ndata : nullptr);
double scaleFactor = inst ? inst->GetContentsScaleFactor() : 1.0;
*(double*)result = scaleFactor;
return NPERR_NO_ERROR;
}
#endif
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -1000,17 +1000,17 @@ nsresult nsNPAPIPluginInstance::IsRemote
#else
return NS_ERROR_FAILURE;
#endif
}
nsresult
nsNPAPIPluginInstance::ContentsScaleFactorChanged(double aContentsScaleFactor)
{
-#ifdef XP_MACOSX
+#if defined(XP_MACOSX) || defined(XP_WIN)
if (!mPlugin)
return NS_ERROR_FAILURE;
PluginLibrary* library = mPlugin->GetLibrary();
if (!library)
return NS_ERROR_FAILURE;
// We only need to call this if the plugin is running OOP.
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -1348,24 +1348,16 @@ bool nsPluginInstanceOwner::IsRemoteDraw
bool coreAnimation;
if (!NS_SUCCEEDED(mInstance->IsRemoteDrawingCoreAnimation(&coreAnimation)))
return false;
return coreAnimation;
}
-nsresult nsPluginInstanceOwner::ContentsScaleFactorChanged(double aContentsScaleFactor)
-{
- if (!mInstance) {
- return NS_ERROR_NULL_POINTER;
- }
- return mInstance->ContentsScaleFactorChanged(aContentsScaleFactor);
-}
-
NPEventModel nsPluginInstanceOwner::GetEventModel()
{
return mEventModel;
}
#define DEFAULT_REFRESH_RATE 20 // 50 FPS
nsCOMPtr<nsITimer> *nsPluginInstanceOwner::sCATimer = nullptr;
@@ -1446,16 +1438,26 @@ void nsPluginInstanceOwner::RemoveFromCA
void nsPluginInstanceOwner::SetPluginPort()
{
void* pluginPort = GetPluginPort();
if (!pluginPort || !mPluginWindow)
return;
mPluginWindow->window = pluginPort;
}
#endif
+#if defined(XP_MACOSX) || defined(XP_WIN)
+nsresult nsPluginInstanceOwner::ContentsScaleFactorChanged(double aContentsScaleFactor)
+{
+ if (!mInstance) {
+ return NS_ERROR_NULL_POINTER;
+ }
+ return mInstance->ContentsScaleFactorChanged(aContentsScaleFactor);
+}
+#endif
+
// static
uint32_t
nsPluginInstanceOwner::GetEventloopNestingLevel()
{
nsCOMPtr<nsIAppShell> appShell = do_GetService(kAppShellCID);
uint32_t currentLevel = 0;
if (appShell) {
@@ -3618,17 +3620,17 @@ nsPluginInstanceOwner::UpdateWindowVisib
mPluginWindowVisible = aVisible;
UpdateWindowPositionAndClipRect(true);
}
#endif // XP_MACOSX
void
nsPluginInstanceOwner::ResolutionMayHaveChanged()
{
-#ifdef XP_MACOSX
+#if defined(XP_MACOSX) || defined(XP_WIN)
double scaleFactor = 1.0;
GetContentsScaleFactor(&scaleFactor);
if (scaleFactor != mLastScaleFactor) {
ContentsScaleFactorChanged(scaleFactor);
mLastScaleFactor = scaleFactor;
}
#endif
float zoomFactor = 1.0;
@@ -3704,17 +3706,17 @@ nsPluginInstanceOwner::CallSetWindow()
NS_IMETHODIMP
nsPluginInstanceOwner::GetContentsScaleFactor(double *result)
{
NS_ENSURE_ARG_POINTER(result);
double scaleFactor = 1.0;
// On Mac, device pixels need to be translated to (and from) "display pixels"
// for plugins. On other platforms, plugin coordinates are always in device
// pixels.
-#if defined(XP_MACOSX)
+#if defined(XP_MACOSX) || defined(XP_WIN)
nsCOMPtr<nsIContent> content = do_QueryReferent(mContent);
nsIPresShell* presShell = nsContentUtils::FindPresShellForDocument(content->OwnerDoc());
if (presShell) {
scaleFactor = double(nsPresContext::AppUnitsPerCSSPixel())/
presShell->GetPresContext()->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
}
#endif
*result = scaleFactor;
--- a/dom/plugins/base/nsPluginInstanceOwner.h
+++ b/dom/plugins/base/nsPluginInstanceOwner.h
@@ -136,33 +136,37 @@ public:
enum { ePluginPaintEnable, ePluginPaintDisable };
void WindowFocusMayHaveChanged();
bool WindowIsActive();
void SendWindowFocusChanged(bool aIsActive);
NPDrawingModel GetDrawingModel();
bool IsRemoteDrawingCoreAnimation();
- nsresult ContentsScaleFactorChanged(double aContentsScaleFactor);
+
NPEventModel GetEventModel();
static void CARefresh(nsITimer *aTimer, void *aClosure);
void AddToCARefreshTimer();
void RemoveFromCARefreshTimer();
// This calls into the plugin (NPP_SetWindow) and can run script.
void FixUpPluginWindow(int32_t inPaintState);
void HidePluginWindow();
// Set plugin port info in the plugin (in the 'window' member of the
// NPWindow structure passed to the plugin by SetWindow()).
void SetPluginPort();
#else // XP_MACOSX
void UpdateWindowPositionAndClipRect(bool aSetWindow);
void UpdateWindowVisibility(bool aVisible);
#endif // XP_MACOSX
void ResolutionMayHaveChanged();
+#if defined(XP_MACOSX) || defined(XP_WIN)
+ nsresult ContentsScaleFactorChanged(double aContentsScaleFactor);
+#endif
+
void UpdateDocumentActiveState(bool aIsActive);
void SetFrame(nsPluginFrame *aFrame);
nsPluginFrame* GetFrame();
uint32_t GetLastEventloopNestingLevel() const {
return mLastEventloopNestingLevel;
}
@@ -332,20 +336,20 @@ private:
RefPtr<nsPluginHost> mPluginHost;
#ifdef XP_MACOSX
static nsCOMPtr<nsITimer> *sCATimer;
static nsTArray<nsPluginInstanceOwner*> *sCARefreshListeners;
bool mSentInitialTopLevelWindowEvent;
bool mLastWindowIsActive;
bool mLastContentFocused;
- double mLastScaleFactor;
// True if, the next time the window is activated, we should blur ourselves.
bool mShouldBlurOnActivate;
#endif
+ double mLastScaleFactor;
double mLastCSSZoomFactor;
// Initially, the event loop nesting level we were created on, it's updated
// if we detect the appshell is on a lower level as long as we're not stopped.
// We delay DoStopPlugin() until the appshell reaches this level or lower.
uint32_t mLastEventloopNestingLevel;
bool mContentFocused;
bool mWidgetVisible; // used on Mac to store our widget's visible state
#ifdef MOZ_X11
--- a/dom/plugins/ipc/NPEventWindows.h
+++ b/dom/plugins/ipc/NPEventWindows.h
@@ -20,16 +20,17 @@ namespace plugins {
// the stack so that we don't need to worry about managing the memory.
struct NPRemoteEvent
{
NPEvent event;
union {
RECT rect;
WINDOWPOS windowpos;
} lParamData;
+ double contentsScaleFactor;
};
}
}
namespace IPC {
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -135,17 +135,17 @@ PluginInstanceChild::PluginInstanceChild
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues)
: mPluginIface(aPluginIface)
, mMimeType(aMimeType)
, mMode(aMode)
, mNames(aNames)
, mValues(aValues)
-#if defined(XP_DARWIN)
+#if defined(XP_DARWIN) || defined (XP_WIN)
, mContentsScaleFactor(1.0)
#endif
, mPostingKeyEvents(0)
, mPostingKeyEventsOutdated(0)
, mDrawingModel(kDefaultDrawingModel)
, mCurrentDirectSurface(nullptr)
, mAsyncInvalidateMutex("PluginInstanceChild::mAsyncInvalidateMutex")
, mAsyncInvalidateTask(0)
@@ -528,22 +528,24 @@ PluginInstanceChild::NPN_GetValue(NPNVar
}
#ifndef NP_NO_QUICKDRAW
case NPNVsupportsQuickDrawBool: {
*((NPBool*)aValue) = false;
return NPERR_NO_ERROR;
}
#endif /* NP_NO_QUICKDRAW */
-
+#endif /* XP_MACOSX */
+
+#if defined(XP_MACOSX) || defined(XP_WIN)
case NPNVcontentsScaleFactor: {
*static_cast<double*>(aValue) = mContentsScaleFactor;
return NPERR_NO_ERROR;
}
-#endif /* XP_MACOSX */
+#endif /* defined(XP_MACOSX) || defined(XP_WIN) */
case NPNVCSSZoomFactor: {
*static_cast<double*>(aValue) = mCSSZoomFactor;
return NPERR_NO_ERROR;
}
#ifdef DEBUG
case NPNVjavascriptEnabledBool:
case NPNVasdEnabledBool:
@@ -865,33 +867,36 @@ PluginInstanceChild::AnswerNPP_HandleEve
if (GraphicsExpose == event.event.type)
PLUGIN_LOG_DEBUG((" received drawable 0x%lx\n",
event.event.xgraphicsexpose.drawable));
#endif
#ifdef XP_MACOSX
// Mac OS X does not define an NPEvent structure. It defines more specific types.
NPCocoaEvent evcopy = event.event;
- // event.contentsScaleFactor <= 0 is a signal we shouldn't use it,
- // for example when AnswerNPP_HandleEvent() is called from elsewhere
- // in the child process (not via rpc code from the parent process).
- if (event.contentsScaleFactor > 0) {
- mContentsScaleFactor = event.contentsScaleFactor;
- }
// Make sure we reset mCurrentEvent in case of an exception
AutoRestore<const NPCocoaEvent*> savePreviousEvent(mCurrentEvent);
// Track the current event for NPN_PopUpContextMenu.
mCurrentEvent = &event.event;
#else
// Make a copy since we may modify values.
NPEvent evcopy = event.event;
#endif
+#if defined(XP_MACOSX) || defined(XP_WIN)
+ // event.contentsScaleFactor <= 0 is a signal we shouldn't use it,
+ // for example when AnswerNPP_HandleEvent() is called from elsewhere
+ // in the child process (not via rpc code from the parent process).
+ if (event.contentsScaleFactor > 0) {
+ mContentsScaleFactor = event.contentsScaleFactor;
+ }
+#endif
+
#ifdef OS_WIN
// FIXME/bug 567645: temporarily drop the "dummy event" on the floor
if (WM_NULL == evcopy.event)
return true;
*handled = WinlessHandleEvent(evcopy);
return true;
#endif
@@ -1127,27 +1132,29 @@ PluginInstanceChild::RecvWindowPosChange
NS_RUNTIMEABORT("WindowPosChanged is a windows-only message");
return false;
#endif
}
bool
PluginInstanceChild::RecvContentsScaleFactorChanged(const double& aContentsScaleFactor)
{
-#ifdef XP_MACOSX
+#if defined(XP_MACOSX) || defined(XP_WIN)
mContentsScaleFactor = aContentsScaleFactor;
+#if defined(XP_MACOSX)
if (mShContext) {
// Release the shared context so that it is reallocated
// with the new size.
::CGContextRelease(mShContext);
mShContext = nullptr;
}
+#endif
return true;
#else
- NS_RUNTIMEABORT("ContentsScaleFactorChanged is an OSX-only message");
+ NS_RUNTIMEABORT("ContentsScaleFactorChanged is an Windows or OSX only message");
return false;
#endif
}
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
// Create a new window from NPWindow
bool PluginInstanceChild::CreateWindow(const NPRemoteWindow& aWindow)
{
@@ -1332,16 +1339,17 @@ PluginInstanceChild::AnswerNPP_SetWindow
SizePluginWindow(aWindow.width, aWindow.height);
mWindow.window = (void*)mPluginWindowHWND;
mWindow.x = aWindow.x;
mWindow.y = aWindow.y;
mWindow.width = aWindow.width;
mWindow.height = aWindow.height;
mWindow.type = aWindow.type;
+ mContentsScaleFactor = aWindow.contentsScaleFactor;
if (mPluginIface->setwindow) {
SetProp(mPluginWindowHWND, kPluginIgnoreSubclassProperty, (HANDLE)1);
(void) mPluginIface->setwindow(&mData, &mWindow);
WNDPROC wndProc = reinterpret_cast<WNDPROC>(
GetWindowLongPtr(mPluginWindowHWND, GWLP_WNDPROC));
if (wndProc != PluginWindowProc) {
mPluginWndProc = reinterpret_cast<WNDPROC>(
@@ -3323,17 +3331,17 @@ PluginInstanceChild::DoAsyncSetWindow(co
mAccumulatedInvalidRect = nsIntRect(0, 0, aWindow.width, aWindow.height);
mWindow.x = aWindow.x;
mWindow.y = aWindow.y;
mWindow.width = aWindow.width;
mWindow.height = aWindow.height;
mWindow.clipRect = aWindow.clipRect;
mWindow.type = aWindow.type;
-#ifdef XP_MACOSX
+#if defined(XP_MACOSX) || defined(XP_WIN)
mContentsScaleFactor = aWindow.contentsScaleFactor;
#endif
if (GetQuirks() & QUIRK_SILVERLIGHT_DEFAULT_TRANSPARENT)
mIsTransparent = true;
mLayersRendering = true;
mSurfaceType = aSurfaceType;
--- a/dom/plugins/ipc/PluginInstanceChild.h
+++ b/dom/plugins/ipc/PluginInstanceChild.h
@@ -405,17 +405,17 @@ private:
#endif // #if defined(OS_WIN)
const NPPluginFuncs* mPluginIface;
nsCString mMimeType;
uint16_t mMode;
InfallibleTArray<nsCString> mNames;
InfallibleTArray<nsCString> mValues;
NPP_t mData;
NPWindow mWindow;
-#if defined(XP_DARWIN)
+#if defined(XP_DARWIN) || defined(XP_WIN)
double mContentsScaleFactor;
#endif
double mCSSZoomFactor;
uint32_t mPostingKeyEvents;
uint32_t mPostingKeyEventsOutdated;
int16_t mDrawingModel;
NPAsyncSurface* mCurrentDirectSurface;
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -987,17 +987,17 @@ PluginInstanceParent::AsyncSetWindow(NPW
mWindowType = aWindow->type;
window.window = reinterpret_cast<uint64_t>(aWindow->window);
window.x = aWindow->x;
window.y = aWindow->y;
window.width = aWindow->width;
window.height = aWindow->height;
window.clipRect = aWindow->clipRect;
window.type = aWindow->type;
-#ifdef XP_MACOSX
+#if defined(XP_MACOSX) || defined(XP_WIN)
double scaleFactor = 1.0;
mNPNIface->getvalue(mNPP, NPNVcontentsScaleFactor, &scaleFactor);
window.contentsScaleFactor = scaleFactor;
#endif
#if defined(OS_WIN)
MaybeCreateChildPopupSurrogate();
#endif
@@ -1101,17 +1101,18 @@ PluginInstanceParent::DidComposite()
#ifdef XP_MACOSX
nsresult
PluginInstanceParent::IsRemoteDrawingCoreAnimation(bool *aDrawing)
{
*aDrawing = (NPDrawingModelCoreAnimation == (NPDrawingModel)mDrawingModel ||
NPDrawingModelInvalidatingCoreAnimation == (NPDrawingModel)mDrawingModel);
return NS_OK;
}
-
+#endif
+#if defined(XP_MACOSX) || defined(XP_WIN)
nsresult
PluginInstanceParent::ContentsScaleFactorChanged(double aContentsScaleFactor)
{
bool rv = SendContentsScaleFactorChanged(aContentsScaleFactor);
return rv ? NS_OK : NS_ERROR_FAILURE;
}
#endif // #ifdef XP_MACOSX
@@ -1360,22 +1361,23 @@ PluginInstanceParent::NPP_SetWindow(cons
window.x = aWindow->x;
window.y = aWindow->y;
window.width = aWindow->width;
window.height = aWindow->height;
window.clipRect = aWindow->clipRect; // MacOS specific
window.type = aWindow->type;
#endif
-#if defined(XP_MACOSX)
+#if defined(XP_MACOSX) || defined(XP_WIN)
double floatScaleFactor = 1.0;
mNPNIface->getvalue(mNPP, NPNVcontentsScaleFactor, &floatScaleFactor);
int scaleFactor = ceil(floatScaleFactor);
window.contentsScaleFactor = floatScaleFactor;
-
+#endif
+#if defined(XP_MACOSX)
if (mShWidth != window.width * scaleFactor || mShHeight != window.height * scaleFactor) {
if (mDrawingModel == NPDrawingModelCoreAnimation ||
mDrawingModel == NPDrawingModelInvalidatingCoreAnimation) {
mIOSurface = MacIOSurface::CreateIOSurface(window.width, window.height,
floatScaleFactor);
} else if (uint32_t(mShWidth * mShHeight) !=
window.width * scaleFactor * window.height * scaleFactor) {
if (mShWidth != 0 && mShHeight != 0) {
@@ -1560,17 +1562,17 @@ PluginInstanceParent::NPP_HandleEvent(vo
#if defined(XP_MACOSX)
NPCocoaEvent* npevent = reinterpret_cast<NPCocoaEvent*>(event);
#else
NPEvent* npevent = reinterpret_cast<NPEvent*>(event);
#endif
NPRemoteEvent npremoteevent;
npremoteevent.event = *npevent;
-#if defined(XP_MACOSX)
+#if defined(XP_MACOSX) || defined(XP_WIN)
double scaleFactor = 1.0;
mNPNIface->getvalue(mNPP, NPNVcontentsScaleFactor, &scaleFactor);
npremoteevent.contentsScaleFactor = scaleFactor;
#endif
int16_t handled = 0;
#if defined(OS_WIN)
if (mWindowType == NPWindowTypeDrawable) {
--- a/dom/plugins/ipc/PluginInstanceParent.h
+++ b/dom/plugins/ipc/PluginInstanceParent.h
@@ -319,16 +319,18 @@ public:
virtual bool
AnswerPluginFocusChange(const bool& gotFocus) override;
nsresult AsyncSetWindow(NPWindow* window);
nsresult GetImageContainer(mozilla::layers::ImageContainer** aContainer);
nsresult GetImageSize(nsIntSize* aSize);
#ifdef XP_MACOSX
nsresult IsRemoteDrawingCoreAnimation(bool *aDrawing);
+#endif
+#if defined(XP_MACOSX) || defined(XP_WIN)
nsresult ContentsScaleFactorChanged(double aContentsScaleFactor);
#endif
nsresult SetBackgroundUnknown();
nsresult BeginUpdateBackground(const nsIntRect& aRect,
DrawTarget** aDrawTarget);
nsresult EndUpdateBackground(const nsIntRect& aRect);
#if defined(XP_WIN)
nsresult SetScrollCaptureId(uint64_t aScrollCaptureId);
--- a/dom/plugins/ipc/PluginLibrary.h
+++ b/dom/plugins/ipc/PluginLibrary.h
@@ -80,16 +80,18 @@ public:
virtual nsresult AsyncSetWindow(NPP instance, NPWindow* window) = 0;
virtual nsresult GetImageContainer(NPP instance, mozilla::layers::ImageContainer** aContainer) = 0;
virtual nsresult GetImageSize(NPP instance, nsIntSize* aSize) = 0;
virtual void DidComposite(NPP instance) = 0;
virtual bool IsOOP() = 0;
#if defined(XP_MACOSX)
virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing) = 0;
+#endif
+#if defined(XP_MACOSX) || defined(XP_WIN)
virtual nsresult ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor) = 0;
#endif
#if defined(XP_WIN)
virtual nsresult GetScrollCaptureContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) = 0;
#endif
virtual nsresult HandledWindowedPluginKeyEvent(
NPP aInstance,
const mozilla::NativeEventData& aNativeKeyData,
--- a/dom/plugins/ipc/PluginMessageUtils.h
+++ b/dom/plugins/ipc/PluginMessageUtils.h
@@ -88,17 +88,17 @@ struct NPRemoteWindow
uint32_t width;
uint32_t height;
NPRect clipRect;
NPWindowType type;
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
VisualID visualID;
Colormap colormap;
#endif /* XP_UNIX */
-#if defined(XP_MACOSX)
+#if defined(XP_MACOSX) || defined(XP_WIN)
double contentsScaleFactor;
#endif
};
#ifdef XP_WIN
typedef HWND NativeWindowHandle;
#elif defined(MOZ_X11)
typedef XID NativeWindowHandle;
@@ -341,17 +341,17 @@ struct ParamTraits<mozilla::plugins::NPR
WriteParam(aMsg, aParam.width);
WriteParam(aMsg, aParam.height);
WriteParam(aMsg, aParam.clipRect);
WriteParam(aMsg, aParam.type);
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
aMsg->WriteULong(aParam.visualID);
aMsg->WriteULong(aParam.colormap);
#endif
-#if defined(XP_MACOSX)
+#if defined(XP_MACOSX) || defined(XP_WIN)
aMsg->WriteDouble(aParam.contentsScaleFactor);
#endif
}
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
{
uint64_t window;
int32_t x, y;
@@ -370,34 +370,34 @@ struct ParamTraits<mozilla::plugins::NPR
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
unsigned long visualID;
unsigned long colormap;
if (!(aMsg->ReadULong(aIter, &visualID) &&
aMsg->ReadULong(aIter, &colormap)))
return false;
#endif
-#if defined(XP_MACOSX)
+#if defined(XP_MACOSX) || defined(XP_WIN)
double contentsScaleFactor;
if (!aMsg->ReadDouble(aIter, &contentsScaleFactor))
return false;
#endif
aResult->window = window;
aResult->x = x;
aResult->y = y;
aResult->width = width;
aResult->height = height;
aResult->clipRect = clipRect;
aResult->type = type;
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
aResult->visualID = visualID;
aResult->colormap = colormap;
#endif
-#if defined(XP_MACOSX)
+#if defined(XP_MACOSX) || defined(XP_WIN)
aResult->contentsScaleFactor = contentsScaleFactor;
#endif
return true;
}
static void Log(const paramType& aParam, std::wstring* aLog)
{
aLog->append(StringPrintf(L"[%u, %d, %d, %u, %u, %d",
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -2850,17 +2850,18 @@ nsresult
PluginModuleParent::IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing)
{
PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
if (!i)
return NS_ERROR_FAILURE;
return i->IsRemoteDrawingCoreAnimation(aDrawing);
}
-
+#endif
+#if defined(XP_MACOSX) || defined(XP_WIN)
nsresult
PluginModuleParent::ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor)
{
PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
if (!i)
return NS_ERROR_FAILURE;
return i->ContentsScaleFactorChanged(aContentsScaleFactor);
--- a/dom/plugins/ipc/PluginModuleParent.h
+++ b/dom/plugins/ipc/PluginModuleParent.h
@@ -300,16 +300,18 @@ private:
nsCString mPluginFilename;
int mQuirks;
void InitQuirksModes(const nsCString& aMimeType);
public:
#if defined(XP_MACOSX)
virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing) override;
+#endif
+#if defined(XP_MACOSX) || defined(XP_WIN)
virtual nsresult ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor) override;
#endif
void InitAsyncSurrogates();
layers::TextureClientRecycleAllocator* EnsureTextureAllocator();
protected:
--- a/layout/generic/nsPluginFrame.cpp
+++ b/layout/generic/nsPluginFrame.cpp
@@ -565,25 +565,33 @@ nsPluginFrame::FixupWindow(const nsSize&
NS_ENSURE_TRUE_VOID(window);
bool windowless = (window->type == NPWindowTypeDrawable);
nsIntPoint origin = GetWindowOriginInPixels(windowless);
// window must be in "display pixels"
+#if defined(XP_MACOSX)
+ // window must be in "display pixels"
double scaleFactor = 1.0;
if (NS_FAILED(mInstanceOwner->GetContentsScaleFactor(&scaleFactor))) {
scaleFactor = 1.0;
}
int intScaleFactor = ceil(scaleFactor);
window->x = origin.x / intScaleFactor;
window->y = origin.y / intScaleFactor;
window->width = presContext->AppUnitsToDevPixels(aSize.width) / intScaleFactor;
window->height = presContext->AppUnitsToDevPixels(aSize.height) / intScaleFactor;
+#else
+ window->x = origin.x;
+ window->y = origin.y;
+ window->width = presContext->AppUnitsToDevPixels(aSize.width);
+ window->height = presContext->AppUnitsToDevPixels(aSize.height);
+#endif
#ifndef XP_MACOSX
mInstanceOwner->UpdateWindowPositionAndClipRect(false);
#endif
NotifyPluginReflowObservers();
}
@@ -634,27 +642,34 @@ nsPluginFrame::CallSetWindow(bool aCheck
nsIntRect intBounds = bounds.ToNearestPixels(appUnitsPerDevPixel);
// In e10s, this returns the offset to the top level window, in non-e10s
// it return 0,0.
LayoutDeviceIntPoint intOffset = GetRemoteTabChromeOffset();
intBounds.x += intOffset.x;
intBounds.y += intOffset.y;
+#if defined(XP_MACOSX)
// window must be in "display pixels"
double scaleFactor = 1.0;
if (NS_FAILED(instanceOwnerRef->GetContentsScaleFactor(&scaleFactor))) {
scaleFactor = 1.0;
}
+
size_t intScaleFactor = ceil(scaleFactor);
window->x = intBounds.x / intScaleFactor;
window->y = intBounds.y / intScaleFactor;
window->width = intBounds.width / intScaleFactor;
window->height = intBounds.height / intScaleFactor;
-
+#else
+ window->x = intBounds.x;
+ window->y = intBounds.y;
+ window->width = intBounds.width;
+ window->height = intBounds.height;
+#endif
// BE CAREFUL: By the time we get here the PluginFrame is sometimes destroyed
// and poisoned. If we reference local fields (implicit this deref),
// we will crash.
instanceOwnerRef->ResolutionMayHaveChanged();
// This will call pi->SetWindow and take care of window subclassing
// if needed, see bug 132759. Calling SetWindow can destroy this frame
// so check for that before doing anything else with this frame's memory.
@@ -1437,22 +1452,29 @@ nsPluginFrame::BuildLayer(nsDisplayListB
NPWindow* window = nullptr;
mInstanceOwner->GetWindow(window);
if (!window)
return nullptr;
if (window->width <= 0 || window->height <= 0)
return nullptr;
+#if defined(XP_MACOSX)
// window is in "display pixels", but size needs to be in device pixels
+ // window must be in "display pixels"
double scaleFactor = 1.0;
if (NS_FAILED(mInstanceOwner->GetContentsScaleFactor(&scaleFactor))) {
scaleFactor = 1.0;
}
- int intScaleFactor = ceil(scaleFactor);
+
+ size_t intScaleFactor = ceil(scaleFactor);
+#else
+ size_t intScaleFactor = 1;
+#endif
+
IntSize size(window->width * intScaleFactor, window->height * intScaleFactor);
nsRect area = GetContentRectRelativeToSelf() + aItem->ToReferenceFrame();
gfxRect r = nsLayoutUtils::RectToGfxRect(area, PresContext()->AppUnitsPerDevPixel());
// to provide crisper and faster drawing.
r.Round();
RefPtr<Layer> layer =
(aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem));