Changeset 25128 in webkit


Ignore:
Timestamp:
Aug 17, 2007 3:12:56 PM (17 years ago)
Author:
andersca
Message:

LayoutTests:

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):
Location:
trunk
Files:
2 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r25124 r25128  
     12007-08-17  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        <rdar://problem/5379040>
     6        REGRESSION (Tiger-Leopard): ADOBE: Safari calls NPP_SetWindow with bad values sometimes
     7       
     8        Add test.
     9       
     10        * plugins/netscape-plugin-setwindow-size-expected.txt: Added.
     11        * plugins/netscape-plugin-setwindow-size.html: Added.
     12
    1132007-08-17  Oliver Hunt  <oliver@apple.com>
    214
  • trunk/WebCore/ChangeLog

    r25125 r25128  
     12007-08-17  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4       
     5        <rdar://problem/5379040>
     6        REGRESSION (Tiger-Leopard): ADOBE: Safari calls NPP_SetWindow with bad values sometimes
     7
     8        Instantiate plug-ins during the first layout instead of doing so when creating the renderer.
     9        This ensures that the plug-in widget will have a correct initial size.
     10       
     11        * html/HTMLEmbedElement.cpp:
     12        (WebCore::HTMLEmbedElement::getInstance):
     13        Force a layout if the plug-in doesn't have an instance.
     14       
     15        (WebCore::HTMLEmbedElement::attach):
     16        Pass true to updateWidget, causing it to only create a widget if it won't be a plug-in.
     17       
     18        * html/HTMLIFrameElement.cpp:       
     19        (WebCore::HTMLIFrameElement::attach):
     20        Pass false to updateWidget, this will only create subframes anyway.
     21       
     22        * html/HTMLObjectElement.cpp:
     23        (WebCore::HTMLObjectElement::getInstance):
     24        Force a layout if the plug-in doesn't have an instance.
     25       
     26        (WebCore::HTMLObjectElement::attach):
     27        Pass true to updateWidget, causing it to only create a widget if it won't be a plug-in.
     28       
     29        * loader/FrameLoader.cpp:
     30        (WebCore::FrameLoader::loadPlugin):
     31        Get the size from the renderer and pass it to the client.
     32       
     33        * loader/FrameLoaderClient.h:
     34        * page/mac/WebCoreFrameBridge.h:
     35        * platform/graphics/svg/SVGImageEmptyClients.h:
     36        (WebCore::SVGEmptyFrameLoaderClient::createPlugin):
     37        Update declarations.
     38       
     39        * rendering/RenderPart.cpp:
     40        (WebCore::RenderPart::setWidget):
     41        No need to mark the renderer as dirty here.
     42       
     43        * rendering/RenderPartObject.h:
     44        * rendering/RenderPartObject.cpp:
     45        (WebCore::RenderPartObject::updateWidget):
     46        Add a parameter, onlyCreateNonPlugins. If this is true the widget
     47        will only be created if it's not a plug-in.
     48       
     49        (WebCore::RenderPartObject::layout):
     50        Call updateWidget here if m_widget is 0, causing the plug-in to be instantiated.
     51       
    1522007-08-17  Oliver Hunt  <oliver@apple.com>
    253
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r25115 r25128  
    1175111751                        isa = PBXProject;
    1175211752                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
     11753                        compatibilityVersion = "Xcode 2.4";
    1175311754                        hasScannedForEncodings = 1;
    1175411755                        knownRegions = (
  • trunk/WebCore/html/HTMLEmbedElement.cpp

    r24415 r25128  
    6666        return m_instance.get();
    6767   
     68    document()->updateLayoutIgnorePendingStylesheets();
     69
    6870    RenderObject *r = renderer();
    6971    if (!r) {
     
    154156
    155157    if (renderer())
    156         static_cast<RenderPartObject*>(renderer())->updateWidget();
     158        static_cast<RenderPartObject*>(renderer())->updateWidget(true);
    157159}
    158160
  • trunk/WebCore/html/HTMLIFrameElement.cpp

    r20305 r25128  
    122122
    123123    if (RenderPartObject* renderPartObject = static_cast<RenderPartObject*>(renderer()))
    124         renderPartObject->updateWidget();
     124        renderPartObject->updateWidget(false);
    125125}
    126126
  • trunk/WebCore/html/HTMLObjectElement.cpp

    r25098 r25128  
    8282        return m_instance.get();
    8383
     84    document()->updateLayoutIgnorePendingStylesheets();
    8485    RenderObject* r = renderer();
    8586    if (r && r->isWidget()) {
     
    185186                // this method or recalcStyle (which also calls updateWidget) to be called.
    186187                m_needWidgetUpdate = false;
    187                 static_cast<RenderPartObject*>(renderer())->updateWidget();
     188                static_cast<RenderPartObject*>(renderer())->updateWidget(true);
    188189            } else {
    189190                m_needWidgetUpdate = true;
  • trunk/WebCore/loader/FrameLoader.cpp

    r25064 r25128  
    15301530        }
    15311531
    1532         widget = m_client->createPlugin(pluginElement, url, paramNames, paramValues, mimeType,
     1532        widget = m_client->createPlugin(IntSize(renderer->contentWidth(), renderer->contentHeight()),
     1533                                        pluginElement, url, paramNames, paramValues, mimeType,
    15331534                                        m_frame->document()->isPluginDocument());
    15341535        if (widget) {
  • trunk/WebCore/loader/FrameLoaderClient.h

    r24785 r25128  
    199199        virtual Frame* createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
    200200                                   const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) = 0;
    201         virtual Widget* createPlugin(Element*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) = 0;
     201        virtual Widget* createPlugin(const IntSize&, Element*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) = 0;
    202202        virtual void redirectDataToPlugin(Widget* pluginWidget) = 0;
    203203       
  • trunk/WebCore/page/mac/WebCoreFrameBridge.h

    r25000 r25128  
    265265- (void)setNeedsReapplyStyles;
    266266
    267 - (NSView *)viewForPluginWithURL:(NSURL *)URL
    268                   attributeNames:(NSArray *)attributeNames
    269                  attributeValues:(NSArray *)attributeValues
    270                         MIMEType:(NSString *)MIMEType
    271                       DOMElement:(DOMElement *)element
    272                     loadManually:(BOOL)loadManually;
     267- (NSView *)viewForPluginWithFrame:(NSRect)frame
     268                               URL:(NSURL *)URL
     269                    attributeNames:(NSArray *)attributeNames
     270                   attributeValues:(NSArray *)attributeValues
     271                          MIMEType:(NSString *)MIMEType
     272                        DOMElement:(DOMElement *)element
     273                      loadManually:(BOOL)loadManually;
    273274- (NSView *)viewForJavaAppletWithFrame:(NSRect)frame
    274275                        attributeNames:(NSArray *)attributeNames
  • trunk/WebCore/platform/graphics/svg/SVGImageEmptyClients.h

    r24780 r25128  
    265265    virtual Frame* createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
    266266                               const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) { return 0; }
    267     virtual Widget* createPlugin(Element*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool) { return 0; }
     267    virtual Widget* createPlugin(const IntSize&,Element*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool) { return 0; }
    268268    virtual Widget* createJavaAppletWidget(const IntSize&, Element*, const KURL&, const Vector<String>&, const Vector<String>&) { return 0; }
    269269   
  • trunk/WebCore/rendering/RenderPart.cpp

    r21367 r25128  
    6464        RenderWidget::setWidget(widget);
    6565
    66         setNeedsLayoutAndPrefWidthsRecalc();
    67 
    6866        // make sure the scrollbars are set correctly for restore
    6967        // ### find better fix
  • trunk/WebCore/rendering/RenderPartObject.cpp

    r24417 r25128  
    3030#include "Frame.h"
    3131#include "FrameLoader.h"
     32#include "FrameLoaderClient.h"
    3233#include "FrameTree.h"
    3334#include "FrameView.h"
     
    101102}
    102103
    103 void RenderPartObject::updateWidget()
     104void RenderPartObject::updateWidget(bool onlyCreateNonPlugins)
    104105{
    105106  String url;
     
    108109  Vector<String> paramValues;
    109110  Frame* frame = m_view->frame();
    110 
    111   setNeedsLayoutAndPrefWidthsRecalc();
    112 
     111 
    113112  if (element()->hasTagName(objectTag)) {
    114113
     
    218217              m_hasFallbackContent = true;
    219218      }
     219     
     220      if (onlyCreateNonPlugins) {
     221          KURL completedURL;
     222          if (!url.isEmpty())
     223              completedURL = frame->loader()->completeURL(url);
     224       
     225          if (frame->loader()->client()->objectContentType(completedURL, serviceType) == ObjectContentPlugin)
     226              return;
     227      }
     228     
    220229      bool success = frame->loader()->requestObject(this, url, AtomicString(o->name()), serviceType, paramNames, paramValues);
    221230      if (!success && m_hasFallbackContent)
     
    240249          }
    241250      }
     251     
     252      if (onlyCreateNonPlugins) {
     253          KURL completedURL;
     254          if (!url.isEmpty())
     255              completedURL = frame->loader()->completeURL(url);
     256         
     257          if (frame->loader()->client()->objectContentType(completedURL, serviceType) == ObjectContentPlugin)
     258              return;
     259      }
     260     
    242261      frame->loader()->requestObject(this, url, o->getAttribute(nameAttr), serviceType, paramNames, paramValues);
    243262  }
     
    254273    RenderPart::layout();
    255274
     275    if (!m_widget)
     276      updateWidget(false);
     277   
    256278    setNeedsLayout(false);
    257279}
  • trunk/WebCore/rendering/RenderPartObject.h

    r18874 r25128  
    3737
    3838    virtual void layout();
    39     virtual void updateWidget();
     39    void updateWidget(bool onlyCreateNonPlugins);
    4040
    4141    virtual void viewCleared();
  • trunk/WebKit/ChangeLog

    r25114 r25128  
     12007-08-17  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        <rdar://problem/5379040>
     6        REGRESSION (Tiger-Leopard): ADOBE: Safari calls NPP_SetWindow with bad values sometimes
     7       
     8        Pass the right size when creating the views.
     9       
     10        * WebCoreSupport/WebFrameBridge.mm:
     11        (-[WebFrameBridge viewForPluginWithFrame:URL:attributeNames:attributeValues:MIMEType:DOMElement:loadManually:]):
     12        * WebCoreSupport/WebFrameLoaderClient.h:
     13        * WebCoreSupport/WebFrameLoaderClient.mm:
     14        (WebFrameLoaderClient::createPlugin):
     15
    1162007-08-13  Geoffrey Garen  <ggaren@apple.com>
    217
  • trunk/WebKit/WebCoreSupport/WebFrameBridge.mm

    r24947 r25128  
    433433}
    434434
    435 - (NSView *)viewForPluginWithURL:(NSURL *)URL
    436                   attributeNames:(NSArray *)attributeNames
    437                  attributeValues:(NSArray *)attributeValues
    438                         MIMEType:(NSString *)MIMEType
    439                       DOMElement:(DOMElement *)element
    440                     loadManually:(BOOL)loadManually
     435- (NSView *)viewForPluginWithFrame:(NSRect)frame
     436                               URL:(NSURL *)URL
     437                    attributeNames:(NSArray *)attributeNames
     438                   attributeValues:(NSArray *)attributeValues
     439                          MIMEType:(NSString *)MIMEType
     440                        DOMElement:(DOMElement *)element
     441                      loadManually:(BOOL)loadManually
    441442{
    442443    ASSERT([attributeNames count] == [attributeValues count]);
     
    492493#ifndef __LP64__
    493494        else if ([pluginPackage isKindOfClass:[WebNetscapePluginPackage class]]) {
    494             WebNetscapePluginEmbeddedView *embeddedView = [[[WebNetscapePluginEmbeddedView alloc] initWithFrame:NSZeroRect
     495            WebNetscapePluginEmbeddedView *embeddedView = [[[WebNetscapePluginEmbeddedView alloc] initWithFrame:frame
    495496                                                           pluginPackage:(WebNetscapePluginPackage *)pluginPackage
    496497                                                                     URL:URL
     
    518519                                                        pluginName:[pluginPackage name]
    519520                                                          MIMEType:MIMEType];
    520         WebNullPluginView *nullView = [[[WebNullPluginView alloc] initWithFrame:NSZeroRect error:error DOMElement:element] autorelease];
     521        WebNullPluginView *nullView = [[[WebNullPluginView alloc] initWithFrame:frame error:error DOMElement:element] autorelease];
    521522        view = nullView;
    522523        [error release];
  • trunk/WebKit/WebCoreSupport/WebFrameLoaderClient.h

    r24785 r25128  
    185185    virtual WebCore::Frame* createFrame(const WebCore::KURL& url, const WebCore::String& name, WebCore::HTMLFrameOwnerElement*,
    186186                                        const WebCore::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
    187     virtual WebCore::Widget* createPlugin(WebCore::Element*, const WebCore::KURL&, const Vector<WebCore::String>&,
     187    virtual WebCore::Widget* createPlugin(const WebCore::IntSize&, WebCore::Element*, const WebCore::KURL&, const Vector<WebCore::String>&,
    188188                                          const Vector<WebCore::String>&, const WebCore::String&, bool);
    189189    virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget);
  • trunk/WebKit/WebCoreSupport/WebFrameLoaderClient.mm

    r24785 r25128  
    12161216}
    12171217
    1218 Widget* WebFrameLoaderClient::createPlugin(Element* element, const KURL& url, const Vector<String>& paramNames,
     1218Widget* WebFrameLoaderClient::createPlugin(const IntSize& size, Element* element, const KURL& url, const Vector<String>& paramNames,
    12191219                                           const Vector<String>& paramValues, const String& mimeType, bool loadManually)
    12201220{
     
    12221222
    12231223    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    1224     return new Widget([bridge viewForPluginWithURL:url.getNSURL()
    1225                               attributeNames:nsArray(paramNames)
    1226                               attributeValues:nsArray(paramValues)
    1227                               MIMEType:mimeType
    1228                               DOMElement:[DOMElement _wrapElement:element]
    1229                               loadManually:loadManually]);
     1224    return new Widget([bridge viewForPluginWithFrame:NSMakeRect(0, 0, size.width(), size.height())
     1225                                                 URL:url.getNSURL()
     1226                                      attributeNames:nsArray(paramNames)
     1227                                     attributeValues:nsArray(paramValues)
     1228                                            MIMEType:mimeType
     1229                                          DOMElement:[DOMElement _wrapElement:element]
     1230                                        loadManually:loadManually]);
    12301231    END_BLOCK_OBJC_EXCEPTIONS;
    12311232
  • trunk/WebKitTools/ChangeLog

    r25112 r25128  
     12007-08-17  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        <rdar://problem/5379040>
     6        REGRESSION (Tiger-Leopard): ADOBE: Safari calls NPP_SetWindow with bad values sometimes
     7
     8        Add a way for the plug-in to dump the width and height when it gets its  NPP_SetWindow call.
     9       
     10        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c:
     11        (pluginAllocate):
     12        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h:
     13        * DumpRenderTree/TestNetscapePlugIn.subproj/main.c:
     14        (NPP_New):
     15        (NPP_SetWindow):
     16
    1172007-08-16  Alice Liu  <alice.liu@apple.com>
    218
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c

    r24118 r25128  
    335335    newInstance->eventLogging = FALSE;
    336336    newInstance->logDestroy = FALSE;
     337    newInstance->logSetWindow = FALSE;
    337338    newInstance->returnErrorFromNewStream = FALSE;
    338339    newInstance->stream = 0;
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h

    r24118 r25128  
    4040    NPP npp;
    4141    NPBool eventLogging;
     42    NPBool logSetWindow;
    4243    NPBool logDestroy;
    4344    NPBool returnErrorFromNewStream;
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.c

    r24118 r25128  
    8484                     strcasecmp(argv[i], "data:application/x-webkit-test-netscape,returnerrorfromnewstream") == 0)
    8585                obj->returnErrorFromNewStream = TRUE;
     86            else if (strcasecmp(argn[i], "logfirstsetwindow") == 0)
     87                obj->logSetWindow = TRUE;
    8688        }
    8789       
     
    109111NPError NPP_SetWindow(NPP instance, NPWindow *window)
    110112{
     113    PluginObject *obj = instance->pdata;
     114
     115    if (obj) {
     116        if (obj->logSetWindow) {
     117            printf("PLUGIN: NPP_SetWindow: %d %d\n", window->width, window->height);
     118            obj->logSetWindow = false;
     119        }
     120    }
     121   
    111122    return NPERR_NO_ERROR;
    112123}
Note: See TracChangeset for help on using the changeset viewer.