Changeset 41977 in webkit


Ignore:
Timestamp:
Mar 25, 2009 10:30:01 AM (15 years ago)
Author:
kdecker@apple.com
Message:

Reviewed by Kevin Decker.


<rdar://problem/6453738> call SetWindow when user creates a new tab


CoreGraphics plug-ins now receive an NPP_SetWindow call when moving to a background tab.
Flash is excluded from this change in behavior, as it has historical WebKit-specific code
that isn't compatible with this change.

  • Plugins/WebNetscapePluginView.h:

Added an _isFlash ivar.

  • Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView _createPlugin]):

Set the new _isFlash ivar based on the bundle identifier.

(-[WebNetscapePluginView saveAndSetNewPortStateForUpdate:]):

When using the CG drawing model and in a non-drawable state, set the portState
to NULL and return early.

(-[WebNetscapePluginView updateAndSetWindow]):

When using the CG drawing model, call -setWindowIfNecessary even if the portState is NULL.
Flash is an exception to this, due to its historical behavior.

(-[WebNetscapePluginView setWindowIfNecessary]):

Removed an assertion that was no longer true. The [NSView focus] view
is no longer guaranteed to be 'self' at this point.
Also modified the debug logging for CG plug-ins to include the size of the
window's clipRect, which was useful in verifying the correct behavior of this patch.

Location:
trunk/WebKit/mac
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/mac/ChangeLog

    r41937 r41977  
     12009-03-25  Mike Thole  <mthole@apple.com>
     2
     3        Reviewed by Kevin Decker.
     4       
     5        <rdar://problem/6453738> call SetWindow when user creates a new tab
     6       
     7        CoreGraphics plug-ins now receive an NPP_SetWindow call when moving to a background tab.
     8        Flash is excluded from this change in behavior, as it has historical WebKit-specific code
     9        that isn't compatible with this change.
     10
     11        * Plugins/WebNetscapePluginView.h:
     12            Added an _isFlash ivar.
     13        * Plugins/WebNetscapePluginView.mm:
     14        (-[WebNetscapePluginView _createPlugin]):
     15            Set the new _isFlash ivar based on the bundle identifier.
     16        (-[WebNetscapePluginView saveAndSetNewPortStateForUpdate:]):
     17            When using the CG drawing model and in a non-drawable state,  set the portState
     18            to NULL and return early.
     19        (-[WebNetscapePluginView updateAndSetWindow]):
     20            When using the CG drawing model, call -setWindowIfNecessary even if the portState is NULL.
     21            Flash is an exception to this, due to its historical behavior.
     22        (-[WebNetscapePluginView setWindowIfNecessary]):
     23            Removed an assertion that was no longer true.  The [NSView focus] view
     24            is no longer guaranteed to be 'self' at this point.
     25            Also modified the debug logging for CG plug-ins to include the size of the
     26            window's clipRect, which was useful in verifying the correct behavior of this patch.
     27
    1282009-03-24  Dan Bernstein  <mitz@apple.com>
    229
  • trunk/WebKit/mac/Plugins/WebNetscapePluginView.h

    r41674 r41977  
    100100    RetainPtr<NSMutableDictionary> _pendingFrameLoads;
    101101   
     102    BOOL _isFlash;
    102103    BOOL _isSilverlight;
    103104}
  • trunk/WebKit/mac/Plugins/WebNetscapePluginView.mm

    r41783 r41977  
    495495
    496496        case NPDrawingModelCoreGraphics: {           
     497            if (![self canDraw]) {
     498                portState = NULL;
     499                break;
     500            }
     501           
    497502            ASSERT([NSView focusView] == self);
    498503
     
    893898    // A plug-in can only update if it's (1) already been started (2) isn't stopped
    894899    // and (3) is able to draw on-screen. To meet condition (3) the plug-in must not
    895     // be hidden and be attached to a window. QuickDraw plug-ins are an important
    896     // excpetion to rule (3) because they manually must be told when to stop writing
     900    // be hidden and be attached to a window. There are two exceptions to this rule:
     901    //
     902    // Exception 1: QuickDraw plug-ins must be manually told when to stop writing
    897903    // bits to the window backing store, thus to do so requires a new call to
    898904    // NPP_SetWindow() with an empty NPWindow struct.
     905    //
     906    // Exception 2: CoreGraphics plug-ins expect to have their drawable area updated
     907    // when they are moved to a background tab, via a NPP_SetWindow call. This is
     908    // accomplished by allowing -saveAndSetNewPortStateForUpdate to "clip-out" the window's
     909    // clipRect. Flash is curently an exception to this. See 6453738.
     910    //
     911   
    899912    if (!_isStarted)
    900913        return;
     
    906919    if (drawingModel == NPDrawingModelQuickDraw)
    907920        [self tellQuickTimeToChill];
    908     else if (drawingModel == NPDrawingModelCoreGraphics && ![self canDraw])
    909         return;
    910    
     921    else if (drawingModel == NPDrawingModelCoreGraphics && ![self canDraw] && _isFlash) {
     922        // The Flash plug-in does not expect an NPP_SetWindow call from WebKit in this case.
     923        // See Exception 2 above.
     924        return;
     925    }
    911926#endif // NP_NO_QUICKDRAW
    912927   
     
    919934        if (portState != (PortState)1)
    920935            free(portState);
    921     }   
     936    } else if (drawingModel == NPDrawingModelCoreGraphics)
     937        [self setWindowIfNecessary];       
     938
    922939    if (didLockFocus)
    923940        [self unlockFocus];
     
    937954        ASSERT(!inSetWindow);
    938955       
    939         inSetWindow = YES;
    940        
    941         // A CoreGraphics plugin's window may only be set while the plugin is being updated
    942         ASSERT((drawingModel != NPDrawingModelCoreGraphics) || [NSView focusView] == self);
    943        
     956        inSetWindow = YES;       
    944957        [self willCallPlugInFunction];
    945958        {
     
    960973           
    961974            case NPDrawingModelCoreGraphics:
    962                 LOG(Plugins, "NPP_SetWindow (CoreGraphics): %d, window=%p, context=%p, window.x:%d window.y:%d window.width:%d window.height:%d",
    963                 npErr, nPort.cgPort.window, nPort.cgPort.context, (int)window.x, (int)window.y, (int)window.width, (int)window.height);
     975                LOG(Plugins, "NPP_SetWindow (CoreGraphics): %d, window=%p, context=%p, window.x:%d window.y:%d window.width:%d window.height:%d window.clipRect size:%dx%d",
     976                npErr, nPort.cgPort.window, nPort.cgPort.context, (int)window.x, (int)window.y, (int)window.width, (int)window.height,
     977                    window.clipRect.right - window.clipRect.left, window.clipRect.bottom - window.clipRect.top);
    964978            break;
    965979
     
    20602074    PluginMainThreadScheduler::scheduler().registerPlugin(plugin);
    20612075   
     2076    _isFlash = [[[_pluginPackage.get() bundle] bundleIdentifier] isEqualToString:@"com.macromedia.Flash Player.plugin"];
    20622077    _isSilverlight = [[[_pluginPackage.get() bundle] bundleIdentifier] isEqualToString:@"com.microsoft.SilverlightPlugin"];
    20632078
Note: See TracChangeset for help on using the changeset viewer.