Reviewed by Dave Hyatt.
<rdar://problem/
5379040>
REGRESSION (Tiger-Leopard): ADOBE: Safari calls NPP_SetWindow with bad values sometimes
Add test.
* plugins/netscape-plugin-setwindow-size-expected.txt: Added.
* plugins/netscape-plugin-setwindow-size.html: Added.
WebCore:
Reviewed by Dave Hyatt.
<rdar://problem/
5379040>
REGRESSION (Tiger-Leopard): ADOBE: Safari calls NPP_SetWindow with bad values sometimes
Instantiate plug-ins during the first layout instead of doing so when creating the renderer.
This ensures that the plug-in widget will have a correct initial size.
* html/HTMLEmbedElement.cpp:
(WebCore::HTMLEmbedElement::getInstance):
Force a layout if the plug-in doesn't have an instance.
(WebCore::HTMLEmbedElement::attach):
Pass true to updateWidget, causing it to only create a widget if it won't be a plug-in.
* html/HTMLIFrameElement.cpp:
(WebCore::HTMLIFrameElement::attach):
Pass false to updateWidget, this will only create subframes anyway.
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::getInstance):
Force a layout if the plug-in doesn't have an instance.
(WebCore::HTMLObjectElement::attach):
Pass true to updateWidget, causing it to only create a widget if it won't be a plug-in.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadPlugin):
Get the size from the renderer and pass it to the client.
* loader/FrameLoaderClient.h:
* page/mac/WebCoreFrameBridge.h:
* platform/graphics/svg/SVGImageEmptyClients.h:
(WebCore::SVGEmptyFrameLoaderClient::createPlugin):
Update declarations.
* rendering/RenderPart.cpp:
(WebCore::RenderPart::setWidget):
No need to mark the renderer as dirty here.
* rendering/RenderPartObject.h:
* rendering/RenderPartObject.cpp:
(WebCore::RenderPartObject::updateWidget):
Add a parameter, onlyCreateNonPlugins. If this is true the widget
will only be created if it's not a plug-in.
(WebCore::RenderPartObject::layout):
Call updateWidget here if m_widget is 0, causing the plug-in to be instantiated.
WebKit:
Reviewed by Dave Hyatt.
<rdar://problem/
5379040>
REGRESSION (Tiger-Leopard): ADOBE: Safari calls NPP_SetWindow with bad values sometimes
Pass the right size when creating the views.
* WebCoreSupport/WebFrameBridge.mm:
(-[WebFrameBridge viewForPluginWithFrame:URL:attributeNames:attributeValues:MIMEType:DOMElement:loadManually:]):
* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::createPlugin):
WebKitTools:
Reviewed by Dave Hyatt.
<rdar://problem/
5379040>
REGRESSION (Tiger-Leopard): ADOBE: Safari calls NPP_SetWindow with bad values sometimes
Add a way for the plug-in to dump the width and height when it gets its NPP_SetWindow call.
* DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c:
(pluginAllocate):
* DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h:
* DumpRenderTree/TestNetscapePlugIn.subproj/main.c:
(NPP_New):
(NPP_SetWindow):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@25128
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-08-17 Anders Carlsson <andersca@apple.com>
+
+ Reviewed by Dave Hyatt.
+
+ <rdar://problem/5379040>
+ REGRESSION (Tiger-Leopard): ADOBE: Safari calls NPP_SetWindow with bad values sometimes
+
+ Add test.
+
+ * plugins/netscape-plugin-setwindow-size-expected.txt: Added.
+ * plugins/netscape-plugin-setwindow-size.html: Added.
+
2007-08-17 Oliver Hunt <oliver@apple.com>
Reviewed by Maciej.
--- /dev/null
+PLUGIN: NPP_SetWindow: 800 200
+
+This tests that a plug-in with a percentage width gets a correct NPP_SetWindow the first time.
--- /dev/null
+<html>
+<head>
+<script>
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+</script>
+<body style="margin:0px;overflow:hidden">
+<embed id="testPlugin" type="application/x-webkit-test-netscape" logfirstsetwindow="true" width="100%" height="200"></embed>
+<div>
+ This tests that a plug-in with a percentage width gets a correct NPP_SetWindow the first time.
+</div>
+<body>
+</html>
+2007-08-17 Anders Carlsson <andersca@apple.com>
+
+ Reviewed by Dave Hyatt.
+
+ <rdar://problem/5379040>
+ REGRESSION (Tiger-Leopard): ADOBE: Safari calls NPP_SetWindow with bad values sometimes
+
+ Instantiate plug-ins during the first layout instead of doing so when creating the renderer.
+ This ensures that the plug-in widget will have a correct initial size.
+
+ * html/HTMLEmbedElement.cpp:
+ (WebCore::HTMLEmbedElement::getInstance):
+ Force a layout if the plug-in doesn't have an instance.
+
+ (WebCore::HTMLEmbedElement::attach):
+ Pass true to updateWidget, causing it to only create a widget if it won't be a plug-in.
+
+ * html/HTMLIFrameElement.cpp:
+ (WebCore::HTMLIFrameElement::attach):
+ Pass false to updateWidget, this will only create subframes anyway.
+
+ * html/HTMLObjectElement.cpp:
+ (WebCore::HTMLObjectElement::getInstance):
+ Force a layout if the plug-in doesn't have an instance.
+
+ (WebCore::HTMLObjectElement::attach):
+ Pass true to updateWidget, causing it to only create a widget if it won't be a plug-in.
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::loadPlugin):
+ Get the size from the renderer and pass it to the client.
+
+ * loader/FrameLoaderClient.h:
+ * page/mac/WebCoreFrameBridge.h:
+ * platform/graphics/svg/SVGImageEmptyClients.h:
+ (WebCore::SVGEmptyFrameLoaderClient::createPlugin):
+ Update declarations.
+
+ * rendering/RenderPart.cpp:
+ (WebCore::RenderPart::setWidget):
+ No need to mark the renderer as dirty here.
+
+ * rendering/RenderPartObject.h:
+ * rendering/RenderPartObject.cpp:
+ (WebCore::RenderPartObject::updateWidget):
+ Add a parameter, onlyCreateNonPlugins. If this is true the widget
+ will only be created if it's not a plug-in.
+
+ (WebCore::RenderPartObject::layout):
+ Call updateWidget here if m_widget is 0, causing the plug-in to be instantiated.
+
2007-08-17 Oliver Hunt <oliver@apple.com>
Reviewed by Maciej.
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
+ compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
knownRegions = (
English,
if (m_instance)
return m_instance.get();
+ document()->updateLayoutIgnorePendingStylesheets();
+
RenderObject *r = renderer();
if (!r) {
Node *p = parentNode();
HTMLPlugInElement::attach();
if (renderer())
- static_cast<RenderPartObject*>(renderer())->updateWidget();
+ static_cast<RenderPartObject*>(renderer())->updateWidget(true);
}
void HTMLEmbedElement::detach()
HTMLFrameElementBase::attach();
if (RenderPartObject* renderPartObject = static_cast<RenderPartObject*>(renderer()))
- renderPartObject->updateWidget();
+ renderPartObject->updateWidget(false);
}
bool HTMLIFrameElement::isURLAttribute(Attribute* attr) const
if (m_instance)
return m_instance.get();
+ document()->updateLayoutIgnorePendingStylesheets();
RenderObject* r = renderer();
if (r && r->isWidget()) {
if (Widget* widget = static_cast<RenderWidget*>(r)->widget())
// Set m_needWidgetUpdate to false before calling updateWidget because updateWidget may cause
// this method or recalcStyle (which also calls updateWidget) to be called.
m_needWidgetUpdate = false;
- static_cast<RenderPartObject*>(renderer())->updateWidget();
+ static_cast<RenderPartObject*>(renderer())->updateWidget(true);
} else {
m_needWidgetUpdate = true;
setChanged();
return false;
}
- widget = m_client->createPlugin(pluginElement, url, paramNames, paramValues, mimeType,
+ widget = m_client->createPlugin(IntSize(renderer->contentWidth(), renderer->contentHeight()),
+ pluginElement, url, paramNames, paramValues, mimeType,
m_frame->document()->isPluginDocument());
if (widget) {
renderer->setWidget(widget);
virtual Frame* createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) = 0;
- virtual Widget* createPlugin(Element*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) = 0;
+ virtual Widget* createPlugin(const IntSize&, Element*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) = 0;
virtual void redirectDataToPlugin(Widget* pluginWidget) = 0;
virtual Widget* createJavaAppletWidget(const IntSize&, Element*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) = 0;
- (void)setNeedsReapplyStyles;
-- (NSView *)viewForPluginWithURL:(NSURL *)URL
- attributeNames:(NSArray *)attributeNames
- attributeValues:(NSArray *)attributeValues
- MIMEType:(NSString *)MIMEType
- DOMElement:(DOMElement *)element
- loadManually:(BOOL)loadManually;
+- (NSView *)viewForPluginWithFrame:(NSRect)frame
+ URL:(NSURL *)URL
+ attributeNames:(NSArray *)attributeNames
+ attributeValues:(NSArray *)attributeValues
+ MIMEType:(NSString *)MIMEType
+ DOMElement:(DOMElement *)element
+ loadManually:(BOOL)loadManually;
- (NSView *)viewForJavaAppletWithFrame:(NSRect)frame
attributeNames:(NSArray *)attributeNames
attributeValues:(NSArray *)attributeValues
virtual Frame* createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) { return 0; }
- virtual Widget* createPlugin(Element*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool) { return 0; }
+ virtual Widget* createPlugin(const IntSize&,Element*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool) { return 0; }
virtual Widget* createJavaAppletWidget(const IntSize&, Element*, const KURL&, const Vector<String>&, const Vector<String>&) { return 0; }
virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType) { return ObjectContentType(); }
static_cast<FrameView*>(widget)->ref();
RenderWidget::setWidget(widget);
- setNeedsLayoutAndPrefWidthsRecalc();
-
// make sure the scrollbars are set correctly for restore
// ### find better fix
viewCleared();
#include "EventHandler.h"
#include "Frame.h"
#include "FrameLoader.h"
+#include "FrameLoaderClient.h"
#include "FrameTree.h"
#include "FrameView.h"
#include "HTMLEmbedElement.h"
// TODO: add more plugins here
}
-void RenderPartObject::updateWidget()
+void RenderPartObject::updateWidget(bool onlyCreateNonPlugins)
{
String url;
String serviceType;
Vector<String> paramNames;
Vector<String> paramValues;
Frame* frame = m_view->frame();
-
- setNeedsLayoutAndPrefWidthsRecalc();
-
+
if (element()->hasTagName(objectTag)) {
HTMLObjectElement* o = static_cast<HTMLObjectElement*>(element());
(child->isTextNode() && !static_cast<Text*>(child)->containsOnlyWhitespace()))
m_hasFallbackContent = true;
}
+
+ if (onlyCreateNonPlugins) {
+ KURL completedURL;
+ if (!url.isEmpty())
+ completedURL = frame->loader()->completeURL(url);
+
+ if (frame->loader()->client()->objectContentType(completedURL, serviceType) == ObjectContentPlugin)
+ return;
+ }
+
bool success = frame->loader()->requestObject(this, url, AtomicString(o->name()), serviceType, paramNames, paramValues);
if (!success && m_hasFallbackContent)
o->renderFallbackContent();
paramValues.append(it->value().domString());
}
}
+
+ if (onlyCreateNonPlugins) {
+ KURL completedURL;
+ if (!url.isEmpty())
+ completedURL = frame->loader()->completeURL(url);
+
+ if (frame->loader()->client()->objectContentType(completedURL, serviceType) == ObjectContentPlugin)
+ return;
+ }
+
frame->loader()->requestObject(this, url, o->getAttribute(nameAttr), serviceType, paramNames, paramValues);
}
}
RenderPart::layout();
+ if (!m_widget)
+ updateWidget(false);
+
setNeedsLayout(false);
}
virtual const char* renderName() const { return "RenderPartObject"; }
virtual void layout();
- virtual void updateWidget();
+ void updateWidget(bool onlyCreateNonPlugins);
virtual void viewCleared();
};
+2007-08-17 Anders Carlsson <andersca@apple.com>
+
+ Reviewed by Dave Hyatt.
+
+ <rdar://problem/5379040>
+ REGRESSION (Tiger-Leopard): ADOBE: Safari calls NPP_SetWindow with bad values sometimes
+
+ Pass the right size when creating the views.
+
+ * WebCoreSupport/WebFrameBridge.mm:
+ (-[WebFrameBridge viewForPluginWithFrame:URL:attributeNames:attributeValues:MIMEType:DOMElement:loadManually:]):
+ * WebCoreSupport/WebFrameLoaderClient.h:
+ * WebCoreSupport/WebFrameLoaderClient.mm:
+ (WebFrameLoaderClient::createPlugin):
+
2007-08-13 Geoffrey Garen <ggaren@apple.com>
Reviewed by Dave Hyatt.
return nil;
}
-- (NSView *)viewForPluginWithURL:(NSURL *)URL
- attributeNames:(NSArray *)attributeNames
- attributeValues:(NSArray *)attributeValues
- MIMEType:(NSString *)MIMEType
- DOMElement:(DOMElement *)element
- loadManually:(BOOL)loadManually
+- (NSView *)viewForPluginWithFrame:(NSRect)frame
+ URL:(NSURL *)URL
+ attributeNames:(NSArray *)attributeNames
+ attributeValues:(NSArray *)attributeValues
+ MIMEType:(NSString *)MIMEType
+ DOMElement:(DOMElement *)element
+ loadManually:(BOOL)loadManually
{
ASSERT([attributeNames count] == [attributeValues count]);
}
#ifndef __LP64__
else if ([pluginPackage isKindOfClass:[WebNetscapePluginPackage class]]) {
- WebNetscapePluginEmbeddedView *embeddedView = [[[WebNetscapePluginEmbeddedView alloc] initWithFrame:NSZeroRect
+ WebNetscapePluginEmbeddedView *embeddedView = [[[WebNetscapePluginEmbeddedView alloc] initWithFrame:frame
pluginPackage:(WebNetscapePluginPackage *)pluginPackage
URL:URL
baseURL:baseURL
pluginPageURL:pluginPageURL
pluginName:[pluginPackage name]
MIMEType:MIMEType];
- WebNullPluginView *nullView = [[[WebNullPluginView alloc] initWithFrame:NSZeroRect error:error DOMElement:element] autorelease];
+ WebNullPluginView *nullView = [[[WebNullPluginView alloc] initWithFrame:frame error:error DOMElement:element] autorelease];
view = nullView;
[error release];
}
virtual WebCore::Frame* createFrame(const WebCore::KURL& url, const WebCore::String& name, WebCore::HTMLFrameOwnerElement*,
const WebCore::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
- virtual WebCore::Widget* createPlugin(WebCore::Element*, const WebCore::KURL&, const Vector<WebCore::String>&,
+ virtual WebCore::Widget* createPlugin(const WebCore::IntSize&, WebCore::Element*, const WebCore::KURL&, const Vector<WebCore::String>&,
const Vector<WebCore::String>&, const WebCore::String&, bool);
virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget);
return array;
}
-Widget* WebFrameLoaderClient::createPlugin(Element* element, const KURL& url, const Vector<String>& paramNames,
+Widget* WebFrameLoaderClient::createPlugin(const IntSize& size, Element* element, const KURL& url, const Vector<String>& paramNames,
const Vector<String>& paramValues, const String& mimeType, bool loadManually)
{
WebFrameBridge* bridge = m_webFrame->_private->bridge;
BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return new Widget([bridge viewForPluginWithURL:url.getNSURL()
- attributeNames:nsArray(paramNames)
- attributeValues:nsArray(paramValues)
- MIMEType:mimeType
- DOMElement:[DOMElement _wrapElement:element]
- loadManually:loadManually]);
+ return new Widget([bridge viewForPluginWithFrame:NSMakeRect(0, 0, size.width(), size.height())
+ URL:url.getNSURL()
+ attributeNames:nsArray(paramNames)
+ attributeValues:nsArray(paramValues)
+ MIMEType:mimeType
+ DOMElement:[DOMElement _wrapElement:element]
+ loadManually:loadManually]);
END_BLOCK_OBJC_EXCEPTIONS;
return 0;
+2007-08-17 Anders Carlsson <andersca@apple.com>
+
+ Reviewed by Dave Hyatt.
+
+ <rdar://problem/5379040>
+ REGRESSION (Tiger-Leopard): ADOBE: Safari calls NPP_SetWindow with bad values sometimes
+
+ Add a way for the plug-in to dump the width and height when it gets its NPP_SetWindow call.
+
+ * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c:
+ (pluginAllocate):
+ * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h:
+ * DumpRenderTree/TestNetscapePlugIn.subproj/main.c:
+ (NPP_New):
+ (NPP_SetWindow):
+
2007-08-16 Alice Liu <alice.liu@apple.com>
Reviewed by Maciej.
newInstance->testObject = browser->createobject(npp, getTestClass());
newInstance->eventLogging = FALSE;
newInstance->logDestroy = FALSE;
+ newInstance->logSetWindow = FALSE;
newInstance->returnErrorFromNewStream = FALSE;
newInstance->stream = 0;
NPObject header;
NPP npp;
NPBool eventLogging;
+ NPBool logSetWindow;
NPBool logDestroy;
NPBool returnErrorFromNewStream;
NPObject* testObject;
else if (strcasecmp(argn[i], "src") == 0 &&
strcasecmp(argv[i], "data:application/x-webkit-test-netscape,returnerrorfromnewstream") == 0)
obj->returnErrorFromNewStream = TRUE;
+ else if (strcasecmp(argn[i], "logfirstsetwindow") == 0)
+ obj->logSetWindow = TRUE;
}
instance->pdata = obj;
NPError NPP_SetWindow(NPP instance, NPWindow *window)
{
+ PluginObject *obj = instance->pdata;
+
+ if (obj) {
+ if (obj->logSetWindow) {
+ printf("PLUGIN: NPP_SetWindow: %d %d\n", window->width, window->height);
+ obj->logSetWindow = false;
+ }
+ }
+
return NPERR_NO_ERROR;
}