webengine/osswebengine/WebKit/s60/plugins/PluginWin.cpp
branchRCL_3
changeset 48 79859ed3eea9
parent 47 e1bea15f9a39
child 49 919f36ff910f
equal deleted inserted replaced
47:e1bea15f9a39 48:79859ed3eea9
    21 #include <e32std.h>
    21 #include <e32std.h>
    22 #include <e32def.h>
    22 #include <e32def.h>
    23 #include <eikdef.h>
    23 #include <eikdef.h>
    24 #include <eikenv.h>
    24 #include <eikenv.h>
    25 #include <eikappui.h>
    25 #include <eikappui.h>
    26 #include <SysUtil.h>
    26 #include <sysutil.h>
    27 #include <AknUtils.h>
    27 #include <AknUtils.h>
    28 
    28 
    29 #include "WebFrame.h"
    29 #include "WebFrame.h"
    30 #include "HttpDefs.h"
    30 #include "HttpDefs.h"
    31 #include <brctldefs.h>
    31 #include "BrCtlDefs.h"
    32 #include "StaticObjectsContainer.h"
    32 #include "StaticObjectsContainer.h"
    33 #include <pluginadapterinterface.h>
    33 #include <PluginAdapterInterface.h>
    34 #include "PluginWin.h"
    34 #include "PluginWin.h"
    35 #include "PluginSkin.h"
    35 #include "PluginSkin.h"
    36 #include "PluginHandler.h"
    36 #include "PluginHandler.h"
    37 #include "PluginStream.h"
    37 #include "PluginStream.h"
    38 #include "WebView.h"
    38 #include "WebView.h"
    42 #include "Frame.h"
    42 #include "Frame.h"
    43 #include "WebCursor.h"
    43 #include "WebCursor.h"
    44 #include "WebPointerEventHandler.h"
    44 #include "WebPointerEventHandler.h"
    45 #include "WebPageScrollHandler.h"
    45 #include "WebPageScrollHandler.h"
    46 #include "WebKitLogger.h"
    46 #include "WebKitLogger.h"
    47 #include "WebCoreGraphicsContext.h"
       
    48 
       
    49 #include <rt_gestureif.h>
       
    50 
    47 
    51 using namespace WebCore;
    48 using namespace WebCore;
    52 using namespace RT_GestureHelper;
    49 using namespace RT_GestureHelper;
    53 using namespace stmGesture; 
       
    54 // CONSTANTS
    50 // CONSTANTS
    55 const TInt KPluginGranularity = 3;
    51 const TInt KPluginGranularity = 3;
    56 _LIT(KPath,"c:\\system\\temp\\");
    52 _LIT(KPath,"c:\\system\\temp\\");
    57 
    53 
    58 void panicPlugin(TInt error = KErrNone)
    54 void panicPlugin(TInt error = KErrNone)
    66 // might leave.
    62 // might leave.
    67 // -----------------------------------------------------------------------------
    63 // -----------------------------------------------------------------------------
    68 //
    64 //
    69 PluginWin::PluginWin(PluginSkin* pluginskin)
    65 PluginWin::PluginWin(PluginSkin* pluginskin)
    70     : m_pluginskin(pluginskin)
    66     : m_pluginskin(pluginskin)
    71     , m_windowedPlugin(true), m_fullscreen(false), m_windowCreated(false), m_visibilty(false)
    67     , m_windowedPlugin(true), m_fullscreen(false), m_windowCreated(false)
    72 {
    68 {
    73 }
    69 }
    74 
    70 
    75 // -----------------------------------------------------------------------------
    71 // -----------------------------------------------------------------------------
    76 // PluginWin::ConstructL
    72 // PluginWin::ConstructL
    88         TDisplayMode mode = m_transparentPlugin ? EColor16MA : WebCore::StaticObjectsContainer::instance()->webSurface()->displayMode();
    84         TDisplayMode mode = m_transparentPlugin ? EColor16MA : WebCore::StaticObjectsContainer::instance()->webSurface()->displayMode();
    89         m_bitmap->Create(TSize(0,0), mode);
    85         m_bitmap->Create(TSize(0,0), mode);
    90     }
    86     }
    91     // Add the focus/foreground observer
    87     // Add the focus/foreground observer
    92     ControlEnv()->AddForegroundObserverL( *this ) ;
    88     ControlEnv()->AddForegroundObserverL( *this ) ;
    93     m_pluginHasBitmap = false;
       
    94     m_pausedBitmap = NULL;
       
    95     m_BitmapSupported = false;
       
    96 }
    89 }
    97 
    90 
    98 // -----------------------------------------------------------------------------
    91 // -----------------------------------------------------------------------------
    99 // PluginWin::~PluginWin
    92 // PluginWin::~PluginWin
   100 // Deconstructor.
    93 // Deconstructor.
   101 // -----------------------------------------------------------------------------
    94 // -----------------------------------------------------------------------------
   102 //
    95 //
   103 PluginWin::~PluginWin()
    96 PluginWin::~PluginWin()
   104 {
    97 {
   105     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
       
   106 
       
   107     int index = pluginHandler->getVisiblePlugins().Find(m_pluginskin);
       
   108     if (index != KErrNotFound)
       
   109         pluginHandler->getVisiblePlugins().Remove(index);
       
   110 
    98 
   111     TRAP_IGNORE( setPluginFocusL( EFalse ) );
    99     TRAP_IGNORE( setPluginFocusL( EFalse ) );
   112 
   100 
   113     // Remove the foreground observer
   101     // Remove the foreground observer
   114     ControlEnv()->RemoveForegroundObserver( *this );
   102     ControlEnv()->RemoveForegroundObserver( *this );
   115     delete m_bitmap;
   103     delete m_bitmap;
   116    if (m_pausedBitmap)
       
   117         {
       
   118         delete m_pausedBitmap;
       
   119         }
       
   120 }
   104 }
   121 
   105 
   122 // -----------------------------------------------------------------------------
   106 // -----------------------------------------------------------------------------
   123 // PluginWin::NewL
   107 // PluginWin::NewL
   124 // Two-phased constructor.
   108 // Two-phased constructor.
   234                 }
   218                 }
   235             m_notifier->NotifyL( MPluginNotifier::EPluginActivated, (void*) &pt );
   219             m_notifier->NotifyL( MPluginNotifier::EPluginActivated, (void*) &pt );
   236             cursor->cursorUpdate(EFalse);
   220             cursor->cursorUpdate(EFalse);
   237             consumed = ETrue;
   221             consumed = ETrue;
   238             setPluginFocusL( ETrue );
   222             setPluginFocusL( ETrue );
   239             m_pluginskin->pluginFocusChanged(ETrue);
       
   240             }
   223             }
   241 
   224 
   242             else
   225             else
   243             {
   226             {
   244             m_pluginskin->frame()->frameView()->topView()->setFocusedElementType(TBrCtlDefs::EElementBrokenImage);
   227             m_pluginskin->frame()->frameView()->topView()->setFocusedElementType(TBrCtlDefs::EElementBrokenImage);
   287     TKeyResponse ret = EKeyWasNotConsumed;
   270     TKeyResponse ret = EKeyWasNotConsumed;
   288     if ( m_control ) {
   271     if ( m_control ) {
   289         ret = m_control->OfferKeyEventL( aKeyEvent, aType );
   272         ret = m_control->OfferKeyEventL( aKeyEvent, aType );
   290     }
   273     }
   291     else if (!m_windowedPlugin && m_pluginskin->getNPPluginFucs() && m_pluginskin->getNPPluginFucs()->event) {
   274     else if (!m_windowedPlugin && m_pluginskin->getNPPluginFucs() && m_pluginskin->getNPPluginFucs()->event) {
   292         WebCursor* c = StaticObjectsContainer::instance()->webCursor();
       
   293         TPoint pt = (c->position());
       
   294         pt = m_pluginskin->frame()->frameView()->viewCoordsInFrameCoords(pt);
       
   295         pt -= m_pluginskin->rect().iTl;
       
   296         NPEvent event;
   275         NPEvent event;
   297         NPEventKey eventKey;
   276         NPEventKey eventKey;
   298         event.event = ENppEventKey;
   277         event.event = ENppEventKey;
   299         eventKey.keyEvent = &aKeyEvent;
   278         eventKey.keyEvent = &aKeyEvent;
   300         eventKey.type = aType;
   279         eventKey.type = aType;
   301         eventKey.reserved = static_cast<void*>(&pt);
   280         eventKey.reserved = NULL;
   302         event.param = &eventKey;
   281         event.param = &eventKey;
   303         ret = (TKeyResponse)m_pluginskin->getNPPluginFucs()->event(m_pluginskin->getNPP(), static_cast<void*>(&event));
   282         ret = (TKeyResponse)m_pluginskin->getNPPluginFucs()->event(m_pluginskin->getNPP(), static_cast<void*>(&event));
   304     }
   283     }
   305     return ret;
   284     return ret;
   306 }
   285 }
   384 // Hides or shows the PluginInst.
   363 // Hides or shows the PluginInst.
   385 // -----------------------------------------------------------------------------
   364 // -----------------------------------------------------------------------------
   386 //
   365 //
   387 void PluginWin::makeVisible( TBool visible )
   366 void PluginWin::makeVisible( TBool visible )
   388     {
   367     {
   389     WebView* view = control(m_pluginskin->frame())->webView();
   368     if(IsVisible() != visible) 
   390     if(!view)
       
   391         return;
       
   392     
       
   393     if((!m_pluginHasBitmap) && (IsVisible() != visible) && (!view->isPinchZoom()))
       
   394     {
   369     {
   395         CCoeControl::MakeVisible(visible);
   370         CCoeControl::MakeVisible(visible);
   396     }
   371     }
   397     
       
   398     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
       
   399     int index = pluginHandler->getVisiblePlugins().Find(m_pluginskin);
       
   400     if (visible && (m_visibilty != visible) && (index == KErrNotFound)) {
       
   401         pluginHandler->getVisiblePlugins().AppendL(m_pluginskin);
       
   402         m_visibilty = visible;
       
   403     }
       
   404     else if (!visible && (index != KErrNotFound)) {
       
   405         pluginHandler->getVisiblePlugins().Remove(index);
       
   406         m_visibilty = visible;
       
   407     }
       
   408     
       
   409     NotifyPluginVisible(visible);
   372     NotifyPluginVisible(visible);
   410     if (!m_windowedPlugin && m_pluginskin->getNPPluginFucs() && m_pluginskin->getNPPluginFucs()->event) {
   373     if (!m_windowedPlugin && m_pluginskin->getNPPluginFucs() && m_pluginskin->getNPPluginFucs()->event) {
   411         NPEvent event;
   374         NPEvent event;
   412         NpEventVisibility ev;
   375         NpEventVisibility ev;
   413         event.event = ENppEventVisibility;
   376         event.event = ENppEventVisibility;
   488 // -----------------------------------------------------------------------------
   451 // -----------------------------------------------------------------------------
   489 //
   452 //
   490 void PluginWin::HandleGainingForeground()
   453 void PluginWin::HandleGainingForeground()
   491 {
   454 {
   492     if (m_notifier) {
   455     if (m_notifier) {
   493         if(m_pluginHasBitmap)
       
   494             { 
       
   495             ClearPluginBitmap(); 
       
   496             m_pluginskin->activateVisiblePlugins(); 
       
   497             }
       
   498         TRAP_IGNORE(m_notifier->NotifyL(MPluginNotifier::EApplicationFocusChanged, (void*)1));
   456         TRAP_IGNORE(m_notifier->NotifyL(MPluginNotifier::EApplicationFocusChanged, (void*)1));
   499     }
   457     }
   500 }
   458 }
   501 
   459 
   502 // -----------------------------------------------------------------------------
   460 // -----------------------------------------------------------------------------
   574     if (m_pluginskin->pluginPlayer()) {
   532     if (m_pluginskin->pluginPlayer()) {
   575         DrawNow();
   533         DrawNow();
   576     }
   534     }
   577     else {
   535     else {
   578         WebFrame* mf = (m_pluginskin->frame());
   536         WebFrame* mf = (m_pluginskin->frame());
   579         if (mf && mf->frameView()) {
   537         WebFrameView* fv = mf->frameView();
   580             WebFrameView* fv = mf->frameView();
   538         TRect rect(Rect());
   581             TRect rect(Rect());
   539         rect = TRect(fv->viewCoordsInFrameCoords(Rect().iTl), fv->viewCoordsInFrameCoords(Rect().iBr));
   582             rect = TRect(fv->viewCoordsInFrameCoords(Rect().iTl), fv->viewCoordsInFrameCoords(Rect().iBr));
   540     if (mf && mf->frameView())
   583             fv->invalidateRect(rect, drawNow);
   541             mf->frameView()->invalidateRect(rect, drawNow);
   584         }
       
   585     }
   542     }
   586 }
   543 }
   587 
   544 
   588 // -----------------------------------------------------------------------------
   545 // -----------------------------------------------------------------------------
   589 // CPluginWin::MoveWindow
   546 // CPluginWin::MoveWindow
   607             TInt zoomlevel = view->zoomLevel();
   564             TInt zoomlevel = view->zoomLevel();
   608 		    TPoint oldPos(mf->frameView()->contentPos());
   565 		    TPoint oldPos(mf->frameView()->contentPos());
   609 		    TPoint newPos ((aOffset.iX  * 100)/zoomlevel, (aOffset.iY  * 100)/zoomlevel);
   566 		    TPoint newPos ((aOffset.iX  * 100)/zoomlevel, (aOffset.iY  * 100)/zoomlevel);
   610 	        c->offsetCursor( aOffset );
   567 	        c->offsetCursor( aOffset );
   611             mf->frameView()->scrollTo(oldPos + newPos);
   568             mf->frameView()->scrollTo(oldPos + newPos);
   612             view->scrollStatus(false); 
       
   613             c->cursorUpdate(EFalse);        
   569             c->cursorUpdate(EFalse);        
   614         }
   570         }
   615 
   571 
   616     }
   572     }
   617 
   573 
   750             m_notifier->NotifyL( MPluginNotifier::EPluginPause, (void*)0 );
   706             m_notifier->NotifyL( MPluginNotifier::EPluginPause, (void*)0 );
   751         }
   707         }
   752     }
   708     }
   753 }
   709 }
   754 
   710 
   755 TBool PluginWin::IsCollectBitmapSupported ()
       
   756 {
       
   757     if(m_notifier) {
       
   758         m_BitmapSupported = m_notifier->NotifyL( MPluginNotifier::ECollectBitmapSupported, (void*)0 ) ;
       
   759     }
       
   760     return m_BitmapSupported;
       
   761 }
       
   762 
       
   763 
       
   764 void PluginWin::GetBitmapFromPlugin (bool status)
       
   765     {
       
   766     if(m_notifier) {
       
   767          if (status) {
       
   768              //if plugin fails to send bitmap even though the "ECollectBitmapSupported"
       
   769              CBrCtl*   brCtl = control(m_pluginskin->frame());    
       
   770              WebView*  view = brCtl->webView();
       
   771              
       
   772              if(view && view->isPinchZoom())
       
   773                  m_PluginInvisibleOnPinchZoom = ETrue; 
       
   774              m_notifier->NotifyL( MPluginNotifier::ECollectBitmap, (void*)1 );
       
   775 			 
       
   776 			 //if Notify CollectBitmap failed to send bitmap to SetBitmapFromPlugin, 
       
   777 			 //Then forcefully make the plugin window invisible for pinch zoom 
       
   778              if(m_PluginInvisibleOnPinchZoom)
       
   779                  { 
       
   780                  m_PluginInvisibleOnPinchZoom = EFalse; 
       
   781                  if (IsVisible())
       
   782                      {
       
   783                      MakeVisible(false);
       
   784                      }
       
   785                  }
       
   786          }
       
   787          else {
       
   788              m_notifier->NotifyL( MPluginNotifier::ECollectBitmap, (void*)0 );
       
   789              
       
   790              m_pluginHasBitmap = 0;
       
   791              if(m_pausedBitmap)
       
   792                  {
       
   793                  delete m_pausedBitmap;
       
   794                  m_pausedBitmap = NULL;
       
   795                  }
       
   796          }
       
   797        }
       
   798 }
       
   799 
       
   800 
       
   801 void PluginWin::HandlePointerEventFromPluginL(const TPointerEvent& aEvent)
   711 void PluginWin::HandlePointerEventFromPluginL(const TPointerEvent& aEvent)
   802 {
   712 {
   803     CBrCtl*   brCtl = control(m_pluginskin->frame());    
   713     CBrCtl*   brCtl = control(m_pluginskin->frame());    
   804     WebView*  view = brCtl->webView();
   714     WebView*  view = brCtl->webView();
   805 #ifdef BRDO_MULTITOUCH_ENABLED_FF	
   715     TPointerEvent event(aEvent);
   806     if (aEvent.IsAdvancedPointerEvent()) {
   716     
   807         TAdvancedPointerEvent tadvp = *(static_cast<const TAdvancedPointerEvent *>(&aEvent));
   717     if (!StaticObjectsContainer::instance()->isPluginFullscreen()) {
   808         if (!StaticObjectsContainer::instance()->isPluginFullscreen()) {
   718         event.iPosition = aEvent.iPosition - view->PositionRelativeToScreen();
   809             tadvp.iPosition = aEvent.iPosition - view->PositionRelativeToScreen();
   719     }
   810         }
   720     view->pointerEventHandler()->HandlePointerEventL(event);
   811         view->pointerEventHandler()->HandlePointerEventL(tadvp);
   721 }
   812     }
   722 
   813     else {
   723 
   814 #endif 	
   724 TBool PluginWin::HandleGesture(const TGestureEvent& aEvent)
   815         TPointerEvent event(aEvent);
       
   816         if (!StaticObjectsContainer::instance()->isPluginFullscreen()) {
       
   817             event.iPosition = aEvent.iPosition - view->PositionRelativeToScreen();
       
   818         }
       
   819         view->pointerEventHandler()->HandlePointerEventL(event);
       
   820 #ifdef BRDO_MULTITOUCH_ENABLED_FF			
       
   821     }
       
   822 #endif 	
       
   823 }
       
   824 
       
   825 
       
   826 TBool PluginWin::HandleGesture(const TStmGestureEvent& aEvent)
       
   827 {
   725 {
   828     TBool ret = EFalse;
   726     TBool ret = EFalse;
   829     
       
   830     TGestureEvent eventForPlugin; 
       
   831     switch(aEvent.Code()) 
       
   832         {
       
   833         case EGestureUidUnknown :
       
   834             eventForPlugin.SetCode(EGestureUnknown); 
       
   835             break; 
       
   836         case EGestureUidTouch :
       
   837             eventForPlugin.SetCode(EGestureStart);
       
   838             break; 
       
   839         case EGestureUidTap : 
       
   840             if(aEvent.Type() == ETapTypeSingle)
       
   841                 eventForPlugin.SetCode(EGestureTap); 
       
   842             else 
       
   843                 eventForPlugin.SetCode(EGestureDoubleTap); 
       
   844             break; 
       
   845         case EGestureUidLongPress :
       
   846             eventForPlugin.SetCode(EGestureLongTap); 
       
   847             break; 
       
   848         case EGestureUidPan :
       
   849             eventForPlugin.SetCode(EGestureDrag);
       
   850             break; 
       
   851         case EGestureUidRelease :
       
   852             eventForPlugin.SetCode(EGestureReleased); 
       
   853             break; 
       
   854         case EGestureUidFlick :
       
   855             eventForPlugin.SetCode(EGestureFlick);
       
   856             break; 
       
   857         case EGestureUidPinch :
       
   858             eventForPlugin.SetCode(EGesturePinch);
       
   859             break; 
       
   860         default : 
       
   861             break; 
       
   862 
       
   863         }
       
   864     
       
   865     
       
   866     
       
   867     if (m_control) {
   727     if (m_control) {
       
   728         TGestureEvent gestEvent(aEvent);
   868         CBrCtl*   brCtl = control(m_pluginskin->frame());    
   729         CBrCtl*   brCtl = control(m_pluginskin->frame());    
   869         WebView*  view = brCtl->webView();
   730         WebView*  view = brCtl->webView();
   870         TPoint newPos = aEvent.CurrentPos();
   731         TPoint newPos = aEvent.CurrentPos();
   871         // Not sure plugins need the start position of the gesture. Not inlcuded in the new struct
   732         TPoint startPos = aEvent.StartPos();
   872         TPoint startPos = aEvent.CurrentPos();
       
   873         TPoint viewPos = view->PositionRelativeToScreen();
   733         TPoint viewPos = view->PositionRelativeToScreen();
   874         TPoint ctrlPos = m_control->PositionRelativeToScreen();
   734         TPoint ctrlPos = m_control->PositionRelativeToScreen();
   875         
   735         
   876         if (!StaticObjectsContainer::instance()->isPluginFullscreen()) {
   736         if (!StaticObjectsContainer::instance()->isPluginFullscreen()) {
   877         // adjust the position to make it relative to top left corner of 
   737         // adjust the position to make it relative to top left corner of 
   878             newPos += viewPos; 
   738             newPos += viewPos; 
   879             startPos += viewPos;
   739             startPos += viewPos;
   880         }
   740             gestEvent.SetCurrentPos(newPos);
   881         eventForPlugin.SetCurrentPos(newPos);
   741             gestEvent.SetStartPos(startPos);
   882         eventForPlugin.SetStartPos(startPos);
   742         }
   883         if (StaticObjectsContainer::instance()->isPluginFullscreen() ||
   743     
       
   744         if (StaticObjectsContainer::instance()->isPluginFullscreen() || 
   884 	    m_control->Rect().Contains(newPos - ctrlPos)) {
   745 	    m_control->Rect().Contains(newPos - ctrlPos)) {
   885             NPEvent event;
   746             NPEvent event;
   886             NPEventPointer ev;
   747             NPEventPointer ev;
   887             event.event = ENppEventPointer;
   748             event.event = ENppEventPointer;
   888             ev.reserved = &eventForPlugin;
   749             ev.reserved = &gestEvent;
   889             ev.pointerEvent = NULL;
   750             ev.pointerEvent = NULL;
   890             event.param = &ev;
   751             event.param = &ev;
   891             ret = m_pluginskin->getNPPluginFucs()->event(m_pluginskin->getNPP(), 
   752             ret = m_pluginskin->getNPPluginFucs()->event(m_pluginskin->getNPP(), 
   892                                                          static_cast<void*>(&event));
   753                                                          static_cast<void*>(&event));
   893         }
   754         }
   894     }
   755     }
   895     else if(!m_windowedPlugin && m_pluginskin->getNPPluginFucs() && m_pluginskin->getNPPluginFucs()->event){
   756     else if(!m_windowedPlugin && m_pluginskin->getNPPluginFucs() && m_pluginskin->getNPPluginFucs()->event){
   896         TRect cliprect = m_pluginskin->getClipRect();
   757         TRect cliprect = m_pluginskin->getClipRect();
   897         TPoint newPos = aEvent.CurrentPos();
   758         TPoint newpos = aEvent.CurrentPos();
   898         eventForPlugin.SetCurrentPos(newPos);
   759         if(cliprect.Contains(newpos)){
   899         eventForPlugin.SetCurrentPos(newPos);
   760            TGestureEvent gestEvent(aEvent);
   900 
       
   901         if(cliprect.Contains(newPos)){
       
   902            NPEvent event;
   761            NPEvent event;
   903            NPEventPointer ev;
   762            NPEventPointer ev;
   904            event.event = ENppEventPointer;
   763            event.event = ENppEventPointer;
   905            ev.reserved = &eventForPlugin;
   764            ev.reserved = &gestEvent;
   906            ev.pointerEvent = NULL;
   765            ev.pointerEvent = NULL;
   907            event.param = &ev;
   766            event.param = &ev;
   908            ret = m_pluginskin->getNPPluginFucs()->event(m_pluginskin->getNPP(), 
   767            ret = m_pluginskin->getNPPluginFucs()->event(m_pluginskin->getNPP(), 
   909                                                          static_cast<void*>(&event));
   768                                                          static_cast<void*>(&event));
   910         }
   769         }
   911     }    
   770     }    
   912     return ret;
   771     return ret;
   913 
   772 
   914 }
   773 }
   915 
       
   916 bool PluginWin::containsPoint(WebView& view, const TPoint& pt)
       
   917 {
       
   918     if (m_control) {
       
   919         if (StaticObjectsContainer::instance()->isPluginFullscreen()) {
       
   920             return true;
       
   921         }
       
   922         else {
       
   923             TPoint point = pt;
       
   924             TPoint viewPos = view.PositionRelativeToScreen();
       
   925             TPoint ctrlPos = m_control->PositionRelativeToScreen();
       
   926             point += viewPos;
       
   927             return m_control->Rect().Contains(point - ctrlPos);
       
   928         }
       
   929     }
       
   930     else 
       
   931         return false;   
       
   932 }
       
   933 // -----------------------------------------------------------------------------
       
   934 // PluginWin::SetBitmapFromPlugin
       
   935 // Plugin video is captured in CFBsBitmap and handle is passed to plugin window 
       
   936 // Duplicate the bitmap handle and use it to draw while Panning or Pinch zoom
       
   937 // -----------------------------------------------------------------------------
       
   938 void PluginWin::SetBitmapFromPlugin(TInt aHandle)
       
   939     {
       
   940     m_PluginInvisibleOnPinchZoom = EFalse;
       
   941 
       
   942     if (aHandle)
       
   943         {
       
   944         if (m_pausedBitmap)
       
   945             {
       
   946             delete m_pausedBitmap;
       
   947             m_pausedBitmap = NULL;
       
   948             }
       
   949         m_pausedBitmap = new (ELeave) CFbsBitmap();
       
   950         TInt dupStatus = m_pausedBitmap->Duplicate(aHandle);
       
   951         if(dupStatus == KErrNone)
       
   952             { 
       
   953             m_pluginHasBitmap = true;
       
   954             
       
   955             
       
   956             if (IsVisible())
       
   957                    {
       
   958                    MakeVisible(false);
       
   959                    }
       
   960             //setPluginFocusL(false);
       
   961             drawBitmapToWebCoreContext();
       
   962             } 
       
   963        }
       
   964     else
       
   965         {
       
   966         if(m_pausedBitmap)
       
   967         {
       
   968             delete m_pausedBitmap;
       
   969         	m_pausedBitmap = NULL;
       
   970 		}
       
   971         m_pluginHasBitmap = false;
       
   972         }
       
   973     }
       
   974 
       
   975 void PluginWin::ClearPluginBitmap()
       
   976     {
       
   977     if(m_pausedBitmap)
       
   978         {
       
   979         delete m_pausedBitmap;
       
   980         m_pausedBitmap = NULL;
       
   981         m_pluginHasBitmap = false; //clearing plugin bitmap
       
   982         }
       
   983     }
       
   984 
       
   985 void PluginWin::drawBitmapToWebCoreContext()
       
   986     { 
       
   987     CBrCtl* brCtl = control(m_pluginskin->frame());
       
   988     WebView* view = brCtl->webView();
       
   989     WebCoreGraphicsContext* context = view->getGraphicsContext();
       
   990     CFbsBitGc& gc = context->gc();
       
   991     TRect plWinRect(m_pluginskin->getPluginWinRect());
       
   992 
       
   993     TRect oldcontextrect = context->clippingRect();
       
   994     TRect clippingRect = context->clippingRect();
       
   995 
       
   996     // save the gc state
       
   997     TWebCoreSavedContext saved(context->save());
       
   998     
       
   999     if(plWinRect != clippingRect)
       
  1000         {
       
  1001         context->setClippingRect(plWinRect);
       
  1002         }
       
  1003     gc.DrawBitmap(plWinRect, m_pausedBitmap);
       
  1004     context->restore(saved);
       
  1005     }
       
  1006 
       
  1007 // Notify Plugins about the change in Access Point during Upgrade / Downgrade
       
  1008 void PluginWin::notifyAPChange(void* ap)
       
  1009 {
       
  1010     if (m_notifier) {
       
  1011         m_notifier->NotifyL( MPluginNotifier::EAccesPointChanged, ap );
       
  1012     }
       
  1013 }