https://bugs.webkit.org/show_bug.cgi?id=67226
Reviewed by Sam Weinig.
Source/WebKit2:
* PluginProcess/PluginControllerProxy.cpp:
(WebKit::PluginControllerProxy::geometryDidChange):
* PluginProcess/PluginControllerProxy.h:
This now takes the contentsScaleFactor and calls contentsScaleFactorChanged on its plug-in
if the scale factor changes.
* PluginProcess/PluginControllerProxy.messages.in:
GeometryDidChange now takes a contents scale factor parameter.
* WebProcess/Plugins/Netscape/NetscapePlugin.h:
* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::NetscapePlugin::contentsScaleFactorChanged):
Implement contentsScaleFactorChanged and call NPP_SetValue with the new scale factor.
* WebProcess/Plugins/PDF/BuiltInPDFView.cpp:
(WebKit::BuiltInPDFView::contentsScaleFactorChanged):
* WebProcess/Plugins/PDF/BuiltInPDFView.h:
Add stub.
* WebProcess/Plugins/Plugin.h:
Add pure virtual contentsScaleFactorChanged member function.
* WebProcess/Plugins/PluginProxy.cpp:
(WebKit::PluginProxy::geometryDidChange):
Add geometryDidChange overload that doesn't take any parameters. Make it send over the
new scale factor to the plug-in process.
(WebKit::PluginProxy::contentsScaleFactorChanged):
Call geometryDidChange.
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::setDeviceScaleFactor):
Call Plugin::contentsScaleFactorChanged.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setDeviceScaleFactor):
Call setDeviceScaleFactor on all registered plug-ins.
Tools:
Keep a cached copy of the contents scale and update it when it changes.
* DumpRenderTree/TestNetscapePlugIn/Tests/mac/ContentsScaleFactor.cpp:
(ContentsScaleFactor::ContentsScaleFactor):
(ContentsScaleFactor::cachedContentsScaleFactor):
(ContentsScaleFactor::ScriptableObject::hasProperty):
(ContentsScaleFactor::ScriptableObject::getProperty):
(ContentsScaleFactor::NPP_New):
(ContentsScaleFactor::NPP_SetValue):
LayoutTests:
Update test to check that the scale factor is updated correctly.
* platform/mac-wk2/plugins/contents-scale-factor.html:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@98413
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-10-25 Anders Carlsson <andersca@apple.com>
+
+ Plug-ins have no way to find out when the device scale factor changes
+ https://bugs.webkit.org/show_bug.cgi?id=67226
+
+ Reviewed by Sam Weinig.
+
+ Update test to check that the scale factor is updated correctly.
+
+ * platform/mac-wk2/plugins/contents-scale-factor.html:
+
2011-10-25 Fady Samuel <fsamuel@chromium.org>
Made Table tests for Bug 70678 Platform Independent
document.body.appendChild(plugin1);
shouldBe("plugin1.contentsScaleFactor", "1.0");
+ shouldBe("plugin1.cachedContentsScaleFactor", "1.0");
// Now change the backing scale factor.
layoutTestController.setBackingScaleFactor(2, function() {
+ shouldBe("plugin1.contentsScaleFactor", "2.0");
+ shouldBe("plugin1.cachedContentsScaleFactor", "2.0");
plugin2 = createTestPlugin('contents-scale-factor');
document.body.appendChild(plugin2);
shouldBe("plugin2.contentsScaleFactor", "2.0");
+ shouldBe("plugin2.cachedContentsScaleFactor", "2.0");
layoutTestController.notifyDone();
});
+2011-10-25 Anders Carlsson <andersca@apple.com>
+
+ Plug-ins have no way to find out when the device scale factor changes
+ https://bugs.webkit.org/show_bug.cgi?id=67226
+
+ Reviewed by Sam Weinig.
+
+ * PluginProcess/PluginControllerProxy.cpp:
+ (WebKit::PluginControllerProxy::geometryDidChange):
+ * PluginProcess/PluginControllerProxy.h:
+ This now takes the contentsScaleFactor and calls contentsScaleFactorChanged on its plug-in
+ if the scale factor changes.
+
+ * PluginProcess/PluginControllerProxy.messages.in:
+ GeometryDidChange now takes a contents scale factor parameter.
+
+ * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+ * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+ (WebKit::NetscapePlugin::contentsScaleFactorChanged):
+ Implement contentsScaleFactorChanged and call NPP_SetValue with the new scale factor.
+
+ * WebProcess/Plugins/PDF/BuiltInPDFView.cpp:
+ (WebKit::BuiltInPDFView::contentsScaleFactorChanged):
+ * WebProcess/Plugins/PDF/BuiltInPDFView.h:
+ Add stub.
+
+ * WebProcess/Plugins/Plugin.h:
+ Add pure virtual contentsScaleFactorChanged member function.
+
+ * WebProcess/Plugins/PluginProxy.cpp:
+ (WebKit::PluginProxy::geometryDidChange):
+ Add geometryDidChange overload that doesn't take any parameters. Make it send over the
+ new scale factor to the plug-in process.
+
+ (WebKit::PluginProxy::contentsScaleFactorChanged):
+ Call geometryDidChange.
+
+ * WebProcess/Plugins/PluginView.cpp:
+ (WebKit::PluginView::setDeviceScaleFactor):
+ Call Plugin::contentsScaleFactorChanged.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::setDeviceScaleFactor):
+ Call setDeviceScaleFactor on all registered plug-ins.
+
2011-10-25 Beth Dakin <bdakin@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=70852
m_plugin->frameDidFail(requestID, wasCancelled);
}
-void PluginControllerProxy::geometryDidChange(const IntRect& frameRect, const IntRect& clipRect, const ShareableBitmap::Handle& backingStoreHandle)
+void PluginControllerProxy::geometryDidChange(const IntRect& frameRect, const IntRect& clipRect, float contentsScaleFactor, const ShareableBitmap::Handle& backingStoreHandle)
{
m_frameRect = frameRect;
m_clipRect = clipRect;
ASSERT(m_plugin);
+ if (contentsScaleFactor != m_contentsScaleFactor) {
+ m_contentsScaleFactor = contentsScaleFactor;
+ m_plugin->contentsScaleFactorChanged(m_contentsScaleFactor);
+ }
+
platformGeometryDidChange();
if (!backingStoreHandle.isNull()) {
// Message handlers.
void frameDidFinishLoading(uint64_t requestID);
void frameDidFail(uint64_t requestID, bool wasCancelled);
- void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, const ShareableBitmap::Handle& backingStoreHandle);
+ void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, float contentsScaleFactor, const ShareableBitmap::Handle& backingStoreHandle);
void didEvaluateJavaScript(uint64_t requestID, const String& result);
void streamDidReceiveResponse(uint64_t streamID, const String& responseURLString, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers);
void streamDidReceiveData(uint64_t streamID, const CoreIPC::DataReference& data);
messages -> PluginControllerProxy {
# Sent when the plug-in geometry changes.
- GeometryDidChange(WebCore::IntRect frameRect, WebCore::IntRect clipRect, WebKit::ShareableBitmap::Handle backingStoreHandle)
+ GeometryDidChange(WebCore::IntRect frameRect, WebCore::IntRect clipRect, float scaleFactor, WebKit::ShareableBitmap::Handle backingStoreHandle)
# Sent when a frame has finished loading.
FrameDidFinishLoading(uint64_t requestID)
virtual void windowFocusChanged(bool);
virtual void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates);
virtual void windowVisibilityChanged(bool);
+ virtual void contentsScaleFactorChanged(float);
virtual uint64_t pluginComplexTextInputIdentifier() const;
virtual void sendComplexTextInput(const String& textInput);
// FIXME: Implement.
}
+void NetscapePlugin::contentsScaleFactorChanged(float scaleFactor)
+{
+ double contentsScaleFactor = scaleFactor;
+ NPP_SetValue(NPNVcontentsScaleFactor, &contentsScaleFactor);
+}
+
uint64_t NetscapePlugin::pluginComplexTextInputIdentifier() const
{
// Just return a dummy value; this is only called for in-process plug-ins, which we don't support on Mac.
{
}
+void BuiltInPDFView::contentsScaleFactorChanged(float)
+{
+}
+
uint64_t BuiltInPDFView::pluginComplexTextInputIdentifier() const
{
return 0;
virtual void windowFocusChanged(bool);
virtual void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates);
virtual void windowVisibilityChanged(bool);
+ virtual void contentsScaleFactorChanged(float);
virtual uint64_t pluginComplexTextInputIdentifier() const;
virtual void sendComplexTextInput(const String& textInput);
#endif
// Tells the plug-in about window visibility changes.
virtual void windowVisibilityChanged(bool) = 0;
+ // Tells the plug-in about scale factor changes.
+ virtual void contentsScaleFactorChanged(float) = 0;
+
// Get the per complex text input identifier.
virtual uint64_t pluginComplexTextInputIdentifier() const = 0;
return false;
}
-void PluginProxy::geometryDidChange(const IntRect& frameRect, const IntRect& clipRect)
+void PluginProxy::geometryDidChange()
{
ASSERT(m_isStarted);
- m_frameRect = frameRect;
+ float contentsScaleFactor = controller()->contentsScaleFactor();
if (m_frameRect.isEmpty() || !needsBackingStore()) {
ShareableBitmap::Handle pluginBackingStoreHandle;
- m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(frameRect, clipRect, pluginBackingStoreHandle), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
+ m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(m_frameRect, m_clipRect, contentsScaleFactor, pluginBackingStoreHandle), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
return;
}
bool didUpdateBackingStore = false;
if (!m_backingStore) {
- m_backingStore = ShareableBitmap::create(frameRect.size(), ShareableBitmap::SupportsAlpha);
+ m_backingStore = ShareableBitmap::create(m_frameRect.size(), ShareableBitmap::SupportsAlpha);
didUpdateBackingStore = true;
- } else if (frameRect.size() != m_backingStore->size()) {
+ } else if (m_frameRect.size() != m_backingStore->size()) {
// The backing store already exists, just resize it.
- if (!m_backingStore->resize(frameRect.size()))
+ if (!m_backingStore->resize(m_frameRect.size()))
return;
didUpdateBackingStore = true;
if (didUpdateBackingStore) {
// Create a new plug-in backing store.
- m_pluginBackingStore = ShareableBitmap::createShareable(frameRect.size(), ShareableBitmap::SupportsAlpha);
+ m_pluginBackingStore = ShareableBitmap::createShareable(m_frameRect.size(), ShareableBitmap::SupportsAlpha);
if (!m_pluginBackingStore)
return;
m_pluginBackingStoreContainsValidData = false;
}
- m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(frameRect, clipRect, pluginBackingStoreHandle), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
+ m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(m_frameRect, m_clipRect, contentsScaleFactor, pluginBackingStoreHandle), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
+}
+
+void PluginProxy::geometryDidChange(const IntRect& frameRect, const IntRect& clipRect)
+{
+ m_frameRect = frameRect;
+ m_clipRect = clipRect;
+
+ geometryDidChange();
}
void PluginProxy::visibilityDidChange()
m_connection->connection()->send(Messages::PluginControllerProxy::WindowVisibilityChanged(isVisible), m_pluginInstanceID);
}
+void PluginProxy::contentsScaleFactorChanged(float scaleFactor)
+{
+ geometryDidChange();
+}
+
uint64_t PluginProxy::pluginComplexTextInputIdentifier() const
{
return m_pluginInstanceID;
virtual void windowFocusChanged(bool);
virtual void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates);
virtual void windowVisibilityChanged(bool);
+ virtual void contentsScaleFactorChanged(float);
virtual uint64_t pluginComplexTextInputIdentifier() const;
virtual void sendComplexTextInput(const String& textInput);
#endif
bool needsBackingStore() const;
uint64_t windowNPObjectID();
+ void geometryDidChange();
+
// Message handlers.
void loadURL(uint64_t requestID, const String& method, const String& urlString, const String& target, const WebCore::HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups);
void update(const WebCore::IntRect& paintedRect);
// The plug-in rect in window coordinates.
WebCore::IntRect m_frameRect;
+ // The plug-in clip rect in window coordinates.
+ WebCore::IntRect m_clipRect;
+
// This is the backing store that we paint when we're told to paint.
RefPtr<ShareableBitmap> m_backingStore;
m_plugin->windowFocusChanged(windowIsFocused);
}
+void PluginView::setDeviceScaleFactor(float scaleFactor)
+{
+ if (!m_isInitialized || !m_plugin)
+ return;
+
+ m_plugin->contentsScaleFactorChanged(scaleFactor);
+}
+
void PluginView::windowAndViewFramesChanged(const IntRect& windowFrameInScreenCoordinates, const IntRect& viewFrameInWindowCoordinates)
{
if (!m_isInitialized || !m_plugin)
#if PLATFORM(MAC)
void setWindowIsVisible(bool);
void setWindowIsFocused(bool);
+ void setDeviceScaleFactor(float);
void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates);
bool sendComplexTextInput(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
#endif
return;
m_page->setDeviceScaleFactor(scaleFactor);
+
+ // Tell all our plug-in views that the device scale factor changed.
+#if PLATFORM(MAC)
+ for (HashSet<PluginView*>::const_iterator it = m_pluginViews.begin(), end = m_pluginViews.end(); it != end; ++it)
+ (*it)->setDeviceScaleFactor(scaleFactor);
+#endif
}
void WebPage::setUseFixedLayout(bool fixed)
+2011-10-25 Anders Carlsson <andersca@apple.com>
+
+ Plug-ins have no way to find out when the device scale factor changes
+ https://bugs.webkit.org/show_bug.cgi?id=67226
+
+ Reviewed by Sam Weinig.
+
+ Keep a cached copy of the contents scale and update it when it changes.
+
+ * DumpRenderTree/TestNetscapePlugIn/Tests/mac/ContentsScaleFactor.cpp:
+ (ContentsScaleFactor::ContentsScaleFactor):
+ (ContentsScaleFactor::cachedContentsScaleFactor):
+ (ContentsScaleFactor::ScriptableObject::hasProperty):
+ (ContentsScaleFactor::ScriptableObject::getProperty):
+ (ContentsScaleFactor::NPP_New):
+ (ContentsScaleFactor::NPP_SetValue):
+
2011-10-25 Sam Weinig <sam@webkit.org>
Add WKBrowsingContextLoadDelegateTest test for a failed load
public:
ContentsScaleFactor(NPP npp, const string& identifier)
: PluginTest(npp, identifier)
+ , m_cachedContentsScaleFactor(1.0)
{
}
return contentsScaleFactor;
}
+ double cachedContentsScaleFactor()
+ {
+ return m_cachedContentsScaleFactor;
+ }
+
class ScriptableObject : public Object<ScriptableObject> {
public:
bool hasProperty(NPIdentifier propertyName)
{
- return identifierIs(propertyName, "contentsScaleFactor");
+ return identifierIs(propertyName, "contentsScaleFactor")
+ || identifierIs(propertyName, "cachedContentsScaleFactor");
}
bool getProperty(NPIdentifier propertyName, NPVariant* result)
return true;
}
+ if (identifierIs(propertyName, "cachedContentsScaleFactor")) {
+ DOUBLE_TO_NPVARIANT(pluginTest()->cachedContentsScaleFactor(), *result);
+ return true;
+ }
return false;
}
};
+ virtual NPError NPP_New(NPMIMEType pluginType, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData *saved)
+ {
+ m_cachedContentsScaleFactor = contentsScaleFactor();
+ return NPERR_NO_ERROR;
+ }
+
virtual NPError NPP_GetValue(NPPVariable variable, void* value)
{
if (variable != NPPVpluginScriptableNPObject)
return NPERR_NO_ERROR;
}
+
+ virtual NPError NPP_SetValue(NPNVariable variable, void* value)
+ {
+ switch (variable) {
+ case NPNVcontentsScaleFactor:
+ m_cachedContentsScaleFactor = *(double*)value;
+ return NPERR_NO_ERROR;
+ default:
+ return NPERR_GENERIC_ERROR;
+ }
+ }
+ double m_cachedContentsScaleFactor;
};
static PluginTest::Register<ContentsScaleFactor> contentsScaleFactor("contents-scale-factor");