webengine/osswebengine/WebKit/s60/plugins/PluginWin.cpp
branchRCL_3
changeset 44 800203832575
parent 42 a1a5d4e727e8
child 46 30342f40acbf
equal deleted inserted replaced
42:a1a5d4e727e8 44:800203832575
    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"
    47 
    48 
    48 #include <rt_gestureif.h>
    49 #include <rt_gestureif.h>
    49 
    50 
    50 using namespace WebCore;
    51 using namespace WebCore;
    51 using namespace RT_GestureHelper;
    52 using namespace RT_GestureHelper;
    87         TDisplayMode mode = m_transparentPlugin ? EColor16MA : WebCore::StaticObjectsContainer::instance()->webSurface()->displayMode();
    88         TDisplayMode mode = m_transparentPlugin ? EColor16MA : WebCore::StaticObjectsContainer::instance()->webSurface()->displayMode();
    88         m_bitmap->Create(TSize(0,0), mode);
    89         m_bitmap->Create(TSize(0,0), mode);
    89     }
    90     }
    90     // Add the focus/foreground observer
    91     // Add the focus/foreground observer
    91     ControlEnv()->AddForegroundObserverL( *this ) ;
    92     ControlEnv()->AddForegroundObserverL( *this ) ;
       
    93     m_pluginHasBitmap = false;
       
    94     m_pausedBitmap = NULL;
       
    95     m_BitmapSupported = false;
    92 }
    96 }
    93 
    97 
    94 // -----------------------------------------------------------------------------
    98 // -----------------------------------------------------------------------------
    95 // PluginWin::~PluginWin
    99 // PluginWin::~PluginWin
    96 // Deconstructor.
   100 // Deconstructor.
    97 // -----------------------------------------------------------------------------
   101 // -----------------------------------------------------------------------------
    98 //
   102 //
    99 PluginWin::~PluginWin()
   103 PluginWin::~PluginWin()
   100 {
   104 {
   101     CBrCtl* brCtl = control(m_pluginskin->frame());
   105     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
   102     if (brCtl) {
   106 
   103         WebView*  view = brCtl->webView();
   107     int index = pluginHandler->getVisiblePlugins().Find(m_pluginskin);
   104         if (view) {
   108     if (index != KErrNotFound)
   105             int index = view->getVisiblePlugins().Find(m_pluginskin);
   109         pluginHandler->getVisiblePlugins().Remove(index);
   106             if (index != KErrNotFound)
       
   107                 view->getVisiblePlugins().Remove(index);
       
   108         }
       
   109     }
       
   110 
   110 
   111     TRAP_IGNORE( setPluginFocusL( EFalse ) );
   111     TRAP_IGNORE( setPluginFocusL( EFalse ) );
   112 
   112 
   113     // Remove the foreground observer
   113     // Remove the foreground observer
   114     ControlEnv()->RemoveForegroundObserver( *this );
   114     ControlEnv()->RemoveForegroundObserver( *this );
   115     delete m_bitmap;
   115     delete m_bitmap;
       
   116    if (m_pausedBitmap)
       
   117         {
       
   118         delete m_pausedBitmap;
       
   119         }
   116 }
   120 }
   117 
   121 
   118 // -----------------------------------------------------------------------------
   122 // -----------------------------------------------------------------------------
   119 // PluginWin::NewL
   123 // PluginWin::NewL
   120 // Two-phased constructor.
   124 // Two-phased constructor.
   159 }
   163 }
   160 
   164 
   161 void PluginWin::windowChangedL()
   165 void PluginWin::windowChangedL()
   162 {
   166 {
   163     if (m_fullscreen) return;
   167     if (m_fullscreen) return;
       
   168     PlayPausePluginL();
   164     if (m_pluginskin->getNPPluginFucs() && m_pluginskin->getNPPluginFucs()->setwindow ){
   169     if (m_pluginskin->getNPPluginFucs() && m_pluginskin->getNPPluginFucs()->setwindow ){
   165         NPWindow  window;
   170         NPWindow  window;
   166     TRect rect( m_pluginskin->getPluginWinRect() );
   171     TRect rect( m_pluginskin->getPluginWinRect() );
   167     TRect clipRect = m_pluginskin->getClipRect();
   172     TRect clipRect = m_pluginskin->getClipRect();
   168     TRect myRect = Rect();
   173     TRect myRect = Rect();
   379 // Hides or shows the PluginInst.
   384 // Hides or shows the PluginInst.
   380 // -----------------------------------------------------------------------------
   385 // -----------------------------------------------------------------------------
   381 //
   386 //
   382 void PluginWin::makeVisible( TBool visible )
   387 void PluginWin::makeVisible( TBool visible )
   383     {
   388     {
   384     if(IsVisible() != visible) 
   389     WebView* view = control(m_pluginskin->frame())->webView();
       
   390     if(!view)
       
   391         return;
       
   392     
       
   393     if((!m_pluginHasBitmap) && (IsVisible() != visible) && (!view->isPinchZoom()))
   385     {
   394     {
   386         CCoeControl::MakeVisible(visible);
   395         CCoeControl::MakeVisible(visible);
   387     }
   396     }
   388     TPluginLoadMode loadmode = m_pluginskin->getLoadMode();
   397     TPluginLoadMode loadmode = m_pluginskin->getLoadMode();
   389     if(loadmode == ELoadModeNew ){
   398     if(loadmode == ELoadModeNew ){
   392             HandleGainingForeground();
   401             HandleGainingForeground();
   393         else
   402         else
   394             HandleLosingForeground();
   403             HandleLosingForeground();
   395     }
   404     }
   396     
   405     
   397     WebView* view = control(m_pluginskin->frame())->webView();
   406     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
   398     int index = view->getVisiblePlugins().Find(m_pluginskin);
   407     int index = pluginHandler->getVisiblePlugins().Find(m_pluginskin);
   399     if (visible && (m_visibilty != visible) && (index == KErrNotFound)) {
   408     if (visible && (m_visibilty != visible) && (index == KErrNotFound)) {
   400         view->getVisiblePlugins().AppendL(m_pluginskin);
   409         pluginHandler->getVisiblePlugins().AppendL(m_pluginskin);
   401         m_visibilty = visible;
   410         m_visibilty = visible;
   402     }
   411     }
   403     else if (!visible && (index != KErrNotFound)) {
   412     else if (!visible && (index != KErrNotFound)) {
   404         view->getVisiblePlugins().Remove(index);
   413         pluginHandler->getVisiblePlugins().Remove(index);
   405         m_visibilty = visible;
   414         m_visibilty = visible;
   406     }
   415     }
   407     
   416     
   408     NotifyPluginVisible(visible);
   417     NotifyPluginVisible(visible);
   409     if (!m_windowedPlugin && m_pluginskin->getNPPluginFucs() && m_pluginskin->getNPPluginFucs()->event) {
   418     if (!m_windowedPlugin && m_pluginskin->getNPPluginFucs() && m_pluginskin->getNPPluginFucs()->event) {
   726       {
   735       {
   727         TRAP_IGNORE(m_notifier->NotifyL(MPluginNotifier::EPluginInvisible, (void*)0));
   736         TRAP_IGNORE(m_notifier->NotifyL(MPluginNotifier::EPluginInvisible, (void*)0));
   728       }	
   737       }	
   729     }
   738     }
   730 }
   739 }
   731 void PluginWin::PlayPausePluginL (bool pause)
   740 void PluginWin::PlayPausePluginL ()
   732 {
   741 {
   733     if(m_notifier) {        
   742     if(m_notifier) 
   734       if (pause) {
   743     {
   735           m_notifier->NotifyL( MPluginNotifier::EPluginPause, (void*)1 );
   744         CBrCtl*   brCtl = control(m_pluginskin->frame());    
   736       }
   745         WebView*  view = brCtl->webView();
   737       else {
   746         TBool scrolling = view->viewIsScrolling();
   738           m_notifier->NotifyL( MPluginNotifier::EPluginPause, (void*)0 );
   747         if (scrolling) {
   739       }
   748             m_notifier->NotifyL( MPluginNotifier::EPluginPause, (void*)1 );
   740     }
   749         }
   741 }
   750         else {
       
   751             m_notifier->NotifyL( MPluginNotifier::EPluginPause, (void*)0 );
       
   752         }
       
   753     }
       
   754 }
       
   755 
       
   756 TBool PluginWin::IsCollectBitmapSupported ()
       
   757 {
       
   758     if(m_notifier) {
       
   759         m_BitmapSupported = m_notifier->NotifyL( MPluginNotifier::ECollectBitmapSupported, (void*)0 ) ;
       
   760     }
       
   761     return m_BitmapSupported;
       
   762 }
       
   763 
       
   764 
       
   765 void PluginWin::GetBitmapFromPlugin (bool status)
       
   766     {
       
   767     if(m_notifier) {
       
   768          if (status) {
       
   769              m_notifier->NotifyL( MPluginNotifier::ECollectBitmap, (void*)1 );
       
   770          }
       
   771          else {
       
   772              m_notifier->NotifyL( MPluginNotifier::ECollectBitmap, (void*)0 );
       
   773              
       
   774              m_pluginHasBitmap = 0;
       
   775              if(m_pausedBitmap)
       
   776                  {
       
   777                  delete m_pausedBitmap;
       
   778                  m_pausedBitmap = NULL;
       
   779                  }
       
   780          }
       
   781        }
       
   782 }
       
   783 
   742 
   784 
   743 void PluginWin::HandlePointerEventFromPluginL(const TPointerEvent& aEvent)
   785 void PluginWin::HandlePointerEventFromPluginL(const TPointerEvent& aEvent)
   744 {
   786 {
   745     CBrCtl*   brCtl = control(m_pluginskin->frame());    
   787     CBrCtl*   brCtl = control(m_pluginskin->frame());    
   746     WebView*  view = brCtl->webView();
   788     WebView*  view = brCtl->webView();
   870         }
   912         }
   871     }
   913     }
   872     else 
   914     else 
   873         return false;   
   915         return false;   
   874 }
   916 }
       
   917 // -----------------------------------------------------------------------------
       
   918 // PluginWin::SetBitmapFromPlugin
       
   919 // Plugin video is captured in CFBsBitmap and handle is passed to plugin window 
       
   920 // Duplicate the bitmap handle and use it to draw while Panning or Pinch zoom
       
   921 // -----------------------------------------------------------------------------
       
   922 void PluginWin::SetBitmapFromPlugin(TInt aHandle)
       
   923     {
       
   924 
       
   925 //    m_pluginfocus = 1;
       
   926 
       
   927     if (aHandle)
       
   928         {
       
   929         if (m_pausedBitmap)
       
   930             {
       
   931             delete m_pausedBitmap;
       
   932             m_pausedBitmap = NULL;
       
   933             }
       
   934         m_pausedBitmap = new (ELeave) CFbsBitmap();
       
   935         TInt dupStatus = m_pausedBitmap->Duplicate(aHandle);
       
   936         if(dupStatus == KErrNone)
       
   937             { 
       
   938             m_pluginHasBitmap = true;
       
   939             
       
   940             
       
   941             if (IsVisible())
       
   942                    {
       
   943                    MakeVisible(false);
       
   944                    }
       
   945             //setPluginFocusL(false);
       
   946             drawBitmapToWebCoreContext();
       
   947             } 
       
   948        }
       
   949     else
       
   950         {
       
   951         if(m_pausedBitmap)
       
   952         {
       
   953             delete m_pausedBitmap;
       
   954         	m_pausedBitmap = NULL;
       
   955 		}
       
   956         m_pluginHasBitmap = false;
       
   957         }
       
   958     }
       
   959 
       
   960 void PluginWin::ClearPluginBitmap()
       
   961     {
       
   962     if(m_pausedBitmap)
       
   963         {
       
   964         delete m_pausedBitmap;
       
   965         m_pausedBitmap = NULL;
       
   966         m_pluginHasBitmap = false; //clearing plugin bitmap
       
   967         }
       
   968     }
       
   969 
       
   970 void PluginWin::drawBitmapToWebCoreContext()
       
   971     { 
       
   972     CBrCtl* brCtl = control(m_pluginskin->frame());
       
   973     WebView* view = brCtl->webView();
       
   974     WebCoreGraphicsContext* context = view->getGraphicsContext();
       
   975     CFbsBitGc& gc = context->gc();
       
   976     TRect plWinRect(m_pluginskin->getPluginWinRect());
       
   977 
       
   978     TRect oldcontextrect = context->clippingRect();
       
   979     TRect clippingRect = context->clippingRect();
       
   980 
       
   981     // save the gc state
       
   982     TWebCoreSavedContext saved(context->save());
       
   983     
       
   984     if(plWinRect != clippingRect)
       
   985         {
       
   986         context->setClippingRect(plWinRect);
       
   987         }
       
   988     gc.DrawBitmap(plWinRect, m_pausedBitmap);
       
   989     context->restore(saved);
       
   990     }