webengine/osswebengine/WebKit/s60/plugins/PluginSkin.cpp
branchRCL_3
changeset 44 800203832575
parent 42 a1a5d4e727e8
child 46 30342f40acbf
equal deleted inserted replaced
42:a1a5d4e727e8 44:800203832575
   166       m_instance(0),    
   166       m_instance(0),    
   167       m_pluginfuncs(0),
   167       m_pluginfuncs(0),
   168       m_resized(false),
   168       m_resized(false),
   169       m_oldRect(TRect(0,0,0,0)),
   169       m_oldRect(TRect(0,0,0,0)),
   170       m_oldViewport(TRect(0,0,0,0)),
   170       m_oldViewport(TRect(0,0,0,0)),
   171       m_loadmode(ELoadModeNone)
   171       m_loadmode(ELoadModeNone),
       
   172       m_NPObject(0)
   172   {
   173   {
   173   }
   174   }
   174 
   175 
   175 
   176 
   176 void PluginSkin::addWidgetAttributesL()
   177 void PluginSkin::addWidgetAttributesL()
   410     delete m_url; m_url = 0;
   411     delete m_url; m_url = 0;
   411     delete iJavascriptTimer; iJavascriptTimer = 0;
   412     delete iJavascriptTimer; iJavascriptTimer = 0;
   412     m_pluginfuncs = 0;
   413     m_pluginfuncs = 0;
   413     m_pluginSupported = EFalse;
   414     m_pluginSupported = EFalse;
   414     m_pluginClosed = true;
   415     m_pluginClosed = true;
       
   416     
   415  }
   417  }
   416 
   418 
   417 
   419 
   418 // ----------------------------------------------------------------------------
   420 // ----------------------------------------------------------------------------
   419 // PluginSkin::pluginFocusChanged()
   421 // PluginSkin::pluginFocusChanged()
   481         gc->BitBltMasked( bitmapStartPoint, m_cannedimg.m_img,
   483         gc->BitBltMasked( bitmapStartPoint, m_cannedimg.m_img,
   482                         bmpSize, m_cannedimg.m_msk, ETrue );
   484                         bmpSize, m_cannedimg.m_msk, ETrue );
   483         }
   485         }
   484     if(m_pluginwin)
   486     if(m_pluginwin)
   485         {
   487         {
   486         positionChanged();
   488         //if bitmap is shared from plugins then draw the shared bitmap
   487         // Force the control to be redrawn.
   489         if(m_pluginwin->IsPluginBitMapSet())
   488         m_pluginwin->refreshPlugin(*gc,newRect);
   490             {
       
   491             CFbsBitmap* bitmap = m_pluginwin->PluginBitmap();
       
   492             if(bitmap)
       
   493                 {
       
   494                 TRect clippingRect = context.clippingRect();
       
   495                 TRect oldcontextrect = context.clippingRect();
       
   496 
       
   497                 if(newRect != clippingRect)
       
   498                     {
       
   499                     context.setClippingRect(newRect);
       
   500                     }
       
   501                  gc->DrawBitmap(newRect, bitmap);
       
   502                  context.setClippingRect(oldcontextrect);
       
   503                 }
       
   504             else
       
   505                 {
       
   506                 //if not a valid bitmap, then hide that plugin
       
   507                 m_pluginwin->MakeVisible(EFalse);
       
   508                 }
       
   509                 positionChanged();
       
   510             }
       
   511         else
       
   512             {
       
   513             positionChanged();
       
   514             // Force the control to be redrawn, for window less plugins
       
   515             m_pluginwin->refreshPlugin(*gc,newRect);
       
   516             }
   489         }
   517         }
   490     }
   518     }
   491 
   519 
   492 // ----------------------------------------------------------------------------
   520 // ----------------------------------------------------------------------------
   493 // PluginSkin::IsVisible
   521 // PluginSkin::IsVisible
  1017 
  1045 
  1018 */
  1046 */
  1019 
  1047 
  1020 void* PluginSkin::pluginScriptableObject()
  1048 void* PluginSkin::pluginScriptableObject()
  1021 {
  1049 {
  1022     //
  1050     if (!m_NPObject && m_pluginfuncs && m_pluginfuncs->getvalue) {
  1023     if (m_pluginfuncs && m_pluginfuncs->getvalue) {
  1051         NPError npErr = m_pluginfuncs->getvalue( m_instance, NPPVpluginScriptableNPObject, &m_NPObject);
  1024         void *value = 0;
  1052         if (npErr != NPERR_NO_ERROR) {
  1025         NPError npErr = m_pluginfuncs->getvalue( m_instance, NPPVpluginScriptableNPObject, (void *)&value);
  1053             m_NPObject = 0;
  1026         if (npErr == NPERR_NO_ERROR) {
  1054         }
  1027             return value;
  1055     }
  1028         }
  1056     return m_NPObject;
  1029     }
       
  1030     return (void *)0;
       
  1031 }
  1057 }
  1032 
  1058 
  1033 TBool validateDataScheme(const TPtrC8& url)
  1059 TBool validateDataScheme(const TPtrC8& url)
  1034 {
  1060 {
  1035     // Check if body part of "data:" exists = data:[<mediatype>][;base64],<body>. RFC-2397 : http://www.faqs.org/rfcs/rfc2397
  1061     // Check if body part of "data:" exists = data:[<mediatype>][;base64],<body>. RFC-2397 : http://www.faqs.org/rfcs/rfc2397
  1263     RFs& rfs = StaticObjectsContainer::instance()->fsSession();
  1289     RFs& rfs = StaticObjectsContainer::instance()->fsSession();
  1264     for(TInt i=0; i < m_tempFilesArray.Count(); i++)
  1290     for(TInt i=0; i < m_tempFilesArray.Count(); i++)
  1265         {
  1291         {
  1266           rfs.Delete(m_tempFilesArray[i]->Des());
  1292           rfs.Delete(m_tempFilesArray[i]->Des());
  1267         }
  1293         }
  1268     
       
  1269     m_tempFilesArray.ResetAndDestroy();
  1294     m_tempFilesArray.ResetAndDestroy();
  1270     
  1295        
  1271     
       
  1272     //create/load the destroyed plugin again
  1296     //create/load the destroyed plugin again
  1273     
  1297     
  1274     NetscapePlugInStreamLoaderClient* pluginloader = NetscapePlugInStreamLoaderClient::NewL(m_url->Des(), this, core(m_frame));
  1298     NetscapePlugInStreamLoaderClient* pluginloader = NetscapePlugInStreamLoaderClient::NewL(m_url->Des(), this, core(m_frame));
  1275     if (pluginloader) {
  1299     if (pluginloader) {
  1276         pluginloader->start();                            
  1300         pluginloader->start();                            
  1277     }    
  1301     }    
  1278 }
  1302 }
  1279 
  1303 
  1280 void PluginSkin::PlayPauseNotify(bool pause)
  1304 // -----------------------------------------------------------------------------
  1281 {
  1305 // PluginWin::NotifyPluginsForScrollOrPinch
       
  1306 // When ever there is Scroll or Pinch zoom is in progress, the webframe will
       
  1307 // Notify all the plugins "ETrue" for Start and "EFalse" for end
       
  1308 // -----------------------------------------------------------------------------
       
  1309 void PluginSkin::NotifyPluginsForScrollOrPinch(bool status)
       
  1310     {
  1282     if(m_pluginwin)
  1311     if(m_pluginwin)
  1283         m_pluginwin->PlayPausePluginL(pause);
  1312        {
  1284 }
  1313         //while pinch zoom, deactivate and activate the plugins.
       
  1314     WebView* view = control(frame())->webView();
       
  1315     if(!view)
       
  1316         return;
       
  1317 
       
  1318        //check weather the collect bitmap is supported or not
       
  1319         TBool bitmapSupported  = m_pluginwin->IsCollectBitmapSupported();
       
  1320 
       
  1321         //if bitmap is not supported, check for pinch zoom and deactivate the plugins.
       
  1322         if((view->isPinchZoom()))
       
  1323             {
       
  1324             //if bitmap sharing is not supported then deactivate or activate the plugins
       
  1325             if(!bitmapSupported)
       
  1326                 {
       
  1327                 if(status)
       
  1328                     {
       
  1329                     if(m_pluginwin->IsVisible())
       
  1330                         {
       
  1331                         m_pluginwin->MakeVisible(false);
       
  1332                         m_pluginwin->setPluginFocusL(false);
       
  1333                         }
       
  1334                     }
       
  1335                 else
       
  1336                     {
       
  1337                     activate();
       
  1338                     }
       
  1339                 }
       
  1340 
       
  1341             }
       
  1342 
       
  1343         if(bitmapSupported)
       
  1344            {
       
  1345             m_pluginwin->GetBitmapFromPlugin(status);
       
  1346             if(!status)
       
  1347                 {
       
  1348                 m_pluginwin->ClearPluginBitmap();
       
  1349                 activateVisiblePlugins();
       
  1350                 }
       
  1351           }
       
  1352        }
       
  1353 }
       
  1354 
       
  1355 // -----------------------------------------------------------------------------
       
  1356 // PluginWin::IsCollectBitmapSupported
       
  1357 // Check Plugin are supported for Bitmap Sharing
       
  1358 // -----------------------------------------------------------------------------
       
  1359 TBool PluginSkin::IsCollectBitmapSupported()
       
  1360     {
       
  1361     if(m_pluginwin)
       
  1362         {
       
  1363         return  m_pluginwin->IsCollectBitmapSupported();
       
  1364         }
       
  1365     return false;
       
  1366     }
       
  1367 
       
  1368 void PluginSkin::activateVisiblePlugins()
       
  1369     {
       
  1370     TRect fullRect(getPluginWinRect());
       
  1371     TRect clipRect(getClipRect());
       
  1372     TRect frameRect(m_frame->frameView()->rect());
       
  1373     TRect viewRect = control(m_frame)->webView()->Rect();
       
  1374     TBool isPageViewMode = control(m_frame)->webView()->inPageViewMode();
       
  1375     WebFrame* pf = m_frame;
       
  1376     TPoint p = frameRect.iTl;
       
  1377 
       
  1378     if (m_frame->parentFrame())
       
  1379         {
       
  1380         pf = m_frame->parentFrame();
       
  1381         p = pf->frameView()->frameCoordsInViewCoords(frameRect.iTl);
       
  1382         }
       
  1383 
       
  1384     TSize  sz = pf->frameView()->toViewCoords(frameRect.Size());
       
  1385     TRect frameRectInViewCoord = TRect(p, sz);
       
  1386     TBool isPluginVisible = frameRectInViewCoord.Intersects(fullRect);
       
  1387     TBool isFrameVisible = m_frame->frameView()->isVisible() &&
       
  1388             frameRectInViewCoord.Intersects(viewRect);
       
  1389 
       
  1390     TBool visibility = isFrameVisible && !isPageViewMode && isPluginVisible;
       
  1391     if(fullRect.Size() != TSize(0,0))
       
  1392         {
       
  1393         if (visibility)
       
  1394             {
       
  1395             m_pluginwin->MakeVisible(true); //forcefully make the plugin visible, this is for pinch exit
       
  1396             m_pluginwin->makeVisible(true);
       
  1397             }
       
  1398         else
       
  1399             {
       
  1400             //this is required for flash plugin to clear the EGL surface
       
  1401             //when the plugin window is outside the view port
       
  1402             m_pluginwin->makeVisible(false);
       
  1403             }
       
  1404         }
       
  1405 
       
  1406     }