webengine/osswebengine/WebKit/s60/webview/WebView.cpp
branchRCL_3
changeset 67 4917f9bf7995
parent 64 ac77f89b1d9e
child 70 8bfb9186a8b8
equal deleted inserted replaced
64:ac77f89b1d9e 67:4917f9bf7995
   131 const int KZoomBgRectColor = 209;
   131 const int KZoomBgRectColor = 209;
   132 const int KZoomDefaultLevel = 8; //100%
   132 const int KZoomDefaultLevel = 8; //100%
   133 const int defaultCacheCapacity = 256 * 1024;
   133 const int defaultCacheCapacity = 256 * 1024;
   134 
   134 
   135 const int KMaxMissedDrawsAllowed = 5;//Max missed repaint allowed before paint happens
   135 const int KMaxMissedDrawsAllowed = 5;//Max missed repaint allowed before paint happens
       
   136 const int KCheckerSize = 10;
       
   137 const int KZoomFgRectColor = 150;
       
   138 const int KCheckerBoardDestroyTimeout = 2*1000*1000;
   136 
   139 
   137 // LOCAL FUNCTION PROTOTYPES
   140 // LOCAL FUNCTION PROTOTYPES
   138 TInt doRepaintCb( TAny* ptr );
   141 TInt doRepaintCb( TAny* ptr );
   139 TInt doFepCb( TAny* ptr );
   142 TInt doFepCb( TAny* ptr );
       
   143 TInt doDestroyCheckerBoardCb(TAny *ptr);
   140 
   144 
   141 static WebFrame* incrementFrame(WebFrame* curr, bool forward, bool wrapFlag)
   145 static WebFrame* incrementFrame(WebFrame* curr, bool forward, bool wrapFlag)
   142 {
   146 {
   143     Frame* coreFrame = core(curr);
   147     Frame* coreFrame = core(curr);
   144     return kit(forward
   148     return kit(forward
   206 , m_pinchZoomHandler(NULL)
   210 , m_pinchZoomHandler(NULL)
   207 , m_isPinchZoom(false)
   211 , m_isPinchZoom(false)
   208 , m_drawsMissed(0)
   212 , m_drawsMissed(0)
   209 , m_scroll(false)
   213 , m_scroll(false)
   210 , m_thumbnailGenerator(NULL)
   214 , m_thumbnailGenerator(NULL)
       
   215 , m_checkerBoardBitmap(NULL)
       
   216 , m_checkerBoardDevice(NULL)
       
   217 , m_checkerBoardGc(NULL)
       
   218 , m_checkerBoardDestroyTimer(NULL)
       
   219 , m_isPinchZoomOut(false)
   211 {
   220 {
   212 }
   221 }
   213 
   222 
   214 WebView::~WebView()
   223 WebView::~WebView()
   215 {
   224 {
   259     delete m_userAgent;
   268     delete m_userAgent;
   260     delete m_pageFullScreenHandler;
   269     delete m_pageFullScreenHandler;
   261     delete m_bridge;
   270     delete m_bridge;
   262     delete m_frameView;
   271     delete m_frameView;
   263     delete m_thumbnailGenerator;    
   272     delete m_thumbnailGenerator;    
       
   273     
       
   274     destroyCheckerBoard();
       
   275     delete m_checkerBoardDestroyTimer;
       
   276     
   264 }
   277 }
   265 
   278 
   266 // -----------------------------------------------------------------------------
   279 // -----------------------------------------------------------------------------
   267 // WebView::ConstructL
   280 // WebView::ConstructL
   268 // Private Class Method
   281 // Private Class Method
   378     CleanupStack::PopAndDestroy(2); // userAgent8, usrAgnt
   391     CleanupStack::PopAndDestroy(2); // userAgent8, usrAgnt
   379 
   392 
   380     MakeViewVisible(ETrue);
   393     MakeViewVisible(ETrue);
   381     m_isPluginsVisible=ETrue;
   394     m_isPluginsVisible=ETrue;
   382     CCoeControl::SetFocus(ETrue);
   395     CCoeControl::SetFocus(ETrue);
   383 
       
   384 #if defined(BRDO_MULTITOUCH_ENABLED_FF) && !defined (__WINSCW__)   
       
   385     //Enable advance pointer info for multi-touch.
       
   386     Window().EnableAdvancedPointers();
       
   387 #endif 
       
   388     
   396     
   389     cache()->setCapacities(0, 0, defaultCacheCapacity);
   397     cache()->setCapacities(0, 0, defaultCacheCapacity);
   390     
   398     
   391     m_waiter = new(ELeave) CActiveSchedulerWait();
   399     m_waiter = new(ELeave) CActiveSchedulerWait();
       
   400     
       
   401     m_checkerBoardDestroyTimer = CPeriodic::NewL(CActive::EPriorityIdle);
       
   402     
   392 }
   403 }
   393 
   404 
   394 void WebView::initializePageScalerL()
   405 void WebView::initializePageScalerL()
   395 {
   406 {
   396     TBool lowQuality = !( m_brctl->capabilities() & TBrCtlDefs::ECapabilityGraphicalHistory );
   407     TBool lowQuality = !( m_brctl->capabilities() & TBrCtlDefs::ECapabilityGraphicalHistory );
   424         if (m_widgetextension){
   435         if (m_widgetextension){
   425             m_widgetextension->DrawTransition(gc,StaticObjectsContainer::instance()->webSurface()->offscreenBitmap());
   436             m_widgetextension->DrawTransition(gc,StaticObjectsContainer::instance()->webSurface()->offscreenBitmap());
   426         }
   437         }
   427     }
   438     }
   428     else {
   439     else {
       
   440 #ifndef BRDO_MULTITOUCH_ENABLED_FF
   429         gc.DrawBitmap( m_destRectForZooming, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), m_srcRectForZooming );
   441         gc.DrawBitmap( m_destRectForZooming, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), m_srcRectForZooming );
   430 
   442 
   431         if ( m_startZoomLevel > m_currentZoomLevel) {
   443         if ( m_startZoomLevel > m_currentZoomLevel) {
   432 #ifdef BRDO_MULTITOUCH_ENABLED_FF
   444 
   433             TInt destRectWidth = m_destRectForZooming.Width();
       
   434             TInt destRectHeight = m_destRectForZooming.Height();
       
   435             TRect rectLeft(TPoint(rect.iTl),
       
   436                             TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX, rect.iBr.iY));
       
   437             
       
   438             TRect rectRight(TPoint(rect.iTl.iX + destRectWidth + m_destRectForZooming.iTl.iX, rect.iTl.iY),
       
   439                             TPoint(rect.iBr));
       
   440             
       
   441             TRect rectTop(TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX, rect.iTl.iY),
       
   442                               TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX + destRectWidth, rect.iTl.iY + m_destRectForZooming.iTl.iY));
       
   443 
       
   444             TRect rectBottom(TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX, rect.iTl.iY + m_destRectForZooming.iTl.iY + destRectHeight),
       
   445                               TPoint(rect.iTl.iX + destRectWidth + m_destRectForZooming.iTl.iX, rect.iBr.iY));
       
   446 #else 
       
   447             TRect rectLeft( TPoint( rect.iTl.iX + m_destRectForZooming.Width() - 2, rect.iTl.iY ),
   445             TRect rectLeft( TPoint( rect.iTl.iX + m_destRectForZooming.Width() - 2, rect.iTl.iY ),
   448                             TPoint( rect.iBr ));
   446                     TPoint( rect.iBr ));
   449 
   447 
   450             TRect rectBottom( TPoint( rect.iTl.iX, rect.iTl.iY + m_destRectForZooming.Height() - 2 ),
   448             TRect rectBottom( TPoint( rect.iTl.iX, rect.iTl.iY + m_destRectForZooming.Height() - 2 ),
   451                               TPoint( rect.iBr.iX + m_destRectForZooming.Width(), rect.iBr.iY ));
   449                     TPoint( rect.iBr.iX + m_destRectForZooming.Width(), rect.iBr.iY ));
   452 #endif 
   450 
   453 
   451 
   454             const TRgb colorTest(KZoomBgRectColor,KZoomBgRectColor,KZoomBgRectColor);
   452             const TRgb colorTest(KZoomBgRectColor,KZoomBgRectColor,KZoomBgRectColor);
   455             gc.SetPenColor(colorTest);
   453             gc.SetPenColor(colorTest);
   456             gc.SetBrushStyle( CGraphicsContext::EForwardDiagonalHatchBrush );
   454             gc.SetBrushStyle( CGraphicsContext::EForwardDiagonalHatchBrush );
   457             gc.SetBrushColor(colorTest);
   455             gc.SetBrushColor(colorTest);
   458             gc.DrawRect( rectLeft );
   456             gc.DrawRect( rectLeft );
   459             gc.DrawRect( rectBottom );
   457             gc.DrawRect( rectBottom );
   460 #ifdef BRDO_MULTITOUCH_ENABLED_FF
   458         }
   461             gc.DrawRect( rectRight );
   459 #else                   
   462             gc.DrawRect( rectTop );
   460         if ( m_startZoomLevel > m_currentZoomLevel) {
   463 #endif 
   461             gc.BitBlt(rect.iTl,m_checkerBoardBitmap);
   464 
   462         }
   465         }
   463         gc.DrawBitmap( m_destRectForZooming, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), m_srcRectForZooming );
   466 
   464 #endif        
   467     }
   465     }
   468 
   466 
   469     if (m_pageScalerEnabled && m_pageScaler->Visible()) {
   467     if (m_pageScalerEnabled && m_pageScaler->Visible()) {
   470         m_pageScaler->Draw( gc, rect );
   468         m_pageScaler->Draw( gc, rect );
   471     }
   469     }
   580 
   578 
   581     int zoomLevel = m_currentZoomLevel;
   579     int zoomLevel = m_currentZoomLevel;
   582     if(m_widgetextension && !(m_widgetextension->IsWidgetPublising())) {
   580     if(m_widgetextension && !(m_widgetextension->IsWidgetPublising())) {
   583         zoomLevelChanged( KZoomLevelDefaultValue );
   581         zoomLevelChanged( KZoomLevelDefaultValue );
   584     }
   582     }
       
   583     else {
       
   584         //Layout the content based on Default zoom level (100) and zoom it back to existing zoom
       
   585         //level after the layout is complete
       
   586         WebFrameView* view = mainFrame()->frameView();
       
   587         if(view) { 
       
   588             m_startZoomLevel = KZoomLevelDefaultValue;
       
   589             mainFrame()->scalingFactorChanged(KZoomLevelDefaultValue);
       
   590             TRect currentZoomedRect = view->rect();
       
   591             TRect rectWithDefaultZoom; 
       
   592             calculateZoomRect(currentZoomedRect, rectWithDefaultZoom, m_currentZoomLevel, KZoomLevelDefaultValue); 
       
   593             view->setRect(rectWithDefaultZoom);
       
   594             m_currentZoomLevel = KZoomLevelDefaultValue;
       
   595         } 
       
   596     }
       
   597     
   585     Frame* f = m_page->mainFrame();
   598     Frame* f = m_page->mainFrame();
   586 
   599 
   587     while ( f ) {
   600     while ( f ) {
   588         f->sendResizeEvent();
   601         f->sendResizeEvent();
   589         f->view()->layout();
   602         f->view()->layout();
   602         return;
   615         return;
   603     if(!(   m_widgetextension && m_widgetextension->IsWidgetPublising())) {
   616     if(!(   m_widgetextension && m_widgetextension->IsWidgetPublising())) {
   604         mainFrame()->frameView()->draw( *m_webcorecontext, rect );
   617         mainFrame()->frameView()->draw( *m_webcorecontext, rect );
   605         if ( zoomLevel < m_minZoomLevel ) zoomLevel = m_minZoomLevel;
   618         if ( zoomLevel < m_minZoomLevel ) zoomLevel = m_minZoomLevel;
   606         zoomLevelChanged( zoomLevel );
   619         zoomLevelChanged( zoomLevel );
   607     }
   620         
       
   621 #ifndef  BRDO_MULTITOUCH_ENABLED_FF
       
   622         if(m_pageZoomHandler) {
       
   623             //Slider value will change if the content size is changed when layout is done
       
   624             //hide the slider, so that user will get new min and max zoom level 
       
   625             if (m_pageZoomHandler->isActive()) {
       
   626                       TRAP_IGNORE(
       
   627                       m_pageZoomHandler->hideZoomSliderL();
       
   628                       );
       
   629                   }
       
   630             }
       
   631 #endif         
       
   632     }
       
   633     mainFrame()->notifyPluginsOfPositionChange();
   608 }
   634 }
   609 //-------------------------------------------------------------------------------
   635 //-------------------------------------------------------------------------------
   610 // WebView::syncRepaint
   636 // WebView::syncRepaint
   611 // Repaint the current repaint region synchronously and clear it
   637 // Repaint the current repaint region synchronously and clear it
   612 //-------------------------------------------------------------------------------
   638 //-------------------------------------------------------------------------------
   790                 TPoint ptInit(0,0);
   816                 TPoint ptInit(0,0);
   791                 TPoint ptFromHistory = m_brctl->historyHandler()->historyController()->currentEntryPosition();
   817                 TPoint ptFromHistory = m_brctl->historyHandler()->historyController()->currentEntryPosition();
   792                 TPoint ptCurr = mainFrame()->frameView()->contentPos();
   818                 TPoint ptCurr = mainFrame()->frameView()->contentPos();
   793 
   819 
   794                 if ( ptCurr != ptFromHistory ) {
   820                 if ( ptCurr != ptFromHistory ) {
   795                     if ( ptInit == ptCurr ) {
   821                     if((mainFrame()->bridge()->m_rtl) && (ptInit != ptFromHistory)) {
       
   822                           mainFrame()->frameView()->scrollTo(ptFromHistory);
       
   823                           }
       
   824                     else if ( ptInit == ptCurr ) {
   796                         mainFrame()->frameView()->scrollTo(ptFromHistory);
   825                         mainFrame()->frameView()->scrollTo(ptFromHistory);
   797                     }
   826                     }
   798                     else {
   827                     else {
   799                         m_brctl->historyHandler()->historyController()->updateCurrentEntryPositionIfNeeded();
   828                         m_brctl->historyHandler()->historyController()->updateCurrentEntryPositionIfNeeded();
   800                     }
   829                     }
  2279 void WebView::restoreZoomLevel(int zoomLevel)
  2308 void WebView::restoreZoomLevel(int zoomLevel)
  2280 {
  2309 {
  2281     m_dirtyZoomMode = false;
  2310     m_dirtyZoomMode = false;
  2282     clearOffScreenBitmap();
  2311     clearOffScreenBitmap();
  2283     zoomLevelChanged(zoomLevel);
  2312     zoomLevelChanged(zoomLevel);
  2284     mainFrame()->notifyPluginsOfScrolling();
  2313     mainFrame()->notifyPluginsOfPositionChange();
  2285     m_isPluginsVisible = false;
  2314     m_isPluginsVisible = false;
  2286     mainFrame()->makeVisiblePlugins(true);
  2315     mainFrame()->makeVisiblePlugins(true);
  2287     m_isPluginsVisible = true;
  2316     m_isPluginsVisible = true;
  2288 }
  2317 }
  2289 
  2318 
  2352     }
  2381     }
  2353     else {
  2382     else {
  2354         newMinZoomLevel = KZoomLevelDefaultValue;
  2383         newMinZoomLevel = KZoomLevelDefaultValue;
  2355     }
  2384     }
  2356 #ifndef  BRDO_MULTITOUCH_ENABLED_FF
  2385 #ifndef  BRDO_MULTITOUCH_ENABLED_FF
       
  2386     //if the min zoom is in fraction (like 86.33) this will give us 6 pixel white patch 
       
  2387     //to reduce the patch, always min zoom factor incremented in one step of zoom step 
       
  2388     if(newMinZoomLevel % KZoomLevelMinValue)
       
  2389         { 
       
  2390         newMinZoomLevel += KZoomLevelMinValue;
       
  2391         }
  2357     newMinZoomLevel = (newMinZoomLevel/m_pageZoomHandler->stepSize())*m_pageZoomHandler->stepSize();
  2392     newMinZoomLevel = (newMinZoomLevel/m_pageZoomHandler->stepSize())*m_pageZoomHandler->stepSize();
  2358 #endif     
  2393 #endif     
  2359   TBool needsUpdateArray = EFalse;
  2394   TBool needsUpdateArray = EFalse;
  2360   //Update the new array
  2395   //Update the new array
  2361   if ( m_minZoomLevel!= newMinZoomLevel)
  2396   if ( m_minZoomLevel!= newMinZoomLevel)
  2465             if (cpos.iX < 0) cpos.iX = 0;
  2500             if (cpos.iX < 0) cpos.iX = 0;
  2466             if (cpos.iY < 0) cpos.iY = 0;
  2501             if (cpos.iY < 0) cpos.iY = 0;
  2467             mainFrame()->frameView()->setContentPos(cpos);
  2502             mainFrame()->frameView()->setContentPos(cpos);
  2468         }
  2503         }
  2469         m_isPinchZoom = false;
  2504         m_isPinchZoom = false;
       
  2505         m_isPinchZoomOut = false;
  2470     }
  2506     }
  2471    
  2507    
  2472     TRect rect = view->rect();
  2508     TRect rect = view->rect();
  2473 
  2509     TRect rectToZoom; 
  2474     TInt tlx = (rect.iTl.iX * currZoomLevel) / m_currentZoomLevel;
  2510     calculateZoomRect(rect, rectToZoom, currZoomLevel, m_currentZoomLevel);
  2475     TInt tly = (rect.iTl.iY * currZoomLevel) / m_currentZoomLevel;
  2511     view->setRect(rectToZoom);
  2476     TInt brx = (rect.iBr.iX * currZoomLevel) / m_currentZoomLevel;
       
  2477     TInt bry = (rect.iBr.iY * currZoomLevel) / m_currentZoomLevel;
       
  2478 
       
  2479     // rounding
       
  2480 
       
  2481     if (( rect.iTl.iX * currZoomLevel) % m_currentZoomLevel ){
       
  2482         tlx -= 1;
       
  2483     }
       
  2484     if (( rect.iTl.iY * currZoomLevel) % m_currentZoomLevel ){
       
  2485         tly -= 1;
       
  2486     }
       
  2487     if ((rect.iBr.iX * currZoomLevel) % m_currentZoomLevel ){
       
  2488         brx += 1;
       
  2489     }
       
  2490     if ((rect.iBr.iY * currZoomLevel) % m_currentZoomLevel ){
       
  2491         bry += 1;
       
  2492     }
       
  2493 
       
  2494     view->setRect(TRect(tlx, tly, brx, bry));
       
  2495 
  2512 
  2496     // now just do a repaint, should be very fast
  2513     // now just do a repaint, should be very fast
  2497     if ( currZoomLevel > newZoomLevel ) {
  2514     if ( currZoomLevel > newZoomLevel ) {
  2498         clearOffScreenBitmap();
  2515         clearOffScreenBitmap();
  2499     }
  2516     }
  2564 
  2581 
  2565     // zoom it
  2582     // zoom it
  2566     m_lastZoomLevel = m_currentZoomLevel;
  2583     m_lastZoomLevel = m_currentZoomLevel;
  2567 
  2584 
  2568     setZoomLevel(zoomLevel);
  2585     setZoomLevel(zoomLevel);
  2569     mainFrame()->notifyPluginsOfScrolling();
  2586     mainFrame()->notifyPluginsOfPositionChange();
  2570     
  2587     
  2571     if (zoomLevel == KZoomLevelDefaultValue)
  2588     if (zoomLevel == KZoomLevelDefaultValue)
  2572         {
  2589         {
  2573         // for pages based on tables this is required
  2590         // for pages based on tables this is required
  2574         doLayout();
  2591         doLayout();
  2846   m_isPluginsVisible = false;
  2863   m_isPluginsVisible = false;
  2847   mainFrame()->makeVisiblePlugins(!m_viewIsFastScrolling);
  2864   mainFrame()->makeVisiblePlugins(!m_viewIsFastScrolling);
  2848   m_isPluginsVisible = !m_viewIsFastScrolling;
  2865   m_isPluginsVisible = !m_viewIsFastScrolling;
  2849 
  2866 
  2850   if (!m_viewIsFastScrolling) {
  2867   if (!m_viewIsFastScrolling) {
  2851     mainFrame()->notifyPluginsOfScrolling();
  2868     mainFrame()->notifyPluginsOfPositionChange();
  2852   }
  2869   }
  2853   toggleRepaintTimer(!m_viewIsFastScrolling);
  2870   toggleRepaintTimer(!m_viewIsFastScrolling);
  2854 }
  2871 }
  2855 }
  2872 }
  2856 
  2873 
  2906         TPoint cp = view->contentPos();
  2923         TPoint cp = view->contentPos();
  2907         cp += TPoint(xOff, yOff);
  2924         cp += TPoint(xOff, yOff);
  2908         view->setContentPos(cp);
  2925         view->setContentPos(cp);
  2909     }
  2926     }
  2910     //setZoomLevel(zoomLevel);
  2927     //setZoomLevel(zoomLevel);
  2911     mainFrame()->notifyPluginsOfScrolling();
  2928     mainFrame()->notifyPluginsOfPositionChange();
  2912 }
  2929 }
  2913 
  2930 
  2914 
  2931 
  2915 // ---------------------------------------------------------------------------
  2932 // ---------------------------------------------------------------------------
  2916 // WebView::FindCurrentZoomIndex
  2933 // WebView::FindCurrentZoomIndex
  3014         m_waiter->AsyncStop();
  3031         m_waiter->AsyncStop();
  3015     }
  3032     }
  3016 }
  3033 }
  3017 
  3034 
  3018 //-------------------------------------------------------------------------------
  3035 //-------------------------------------------------------------------------------
  3019 // WebView::setPinchBitmapZoomLevel
  3036 // WebView::setPinchBitmapZoomLevelL
  3020 //-------------------------------------------------------------------------------
  3037 //-------------------------------------------------------------------------------
  3021 void WebView::setPinchBitmapZoomLevel(int zoomLevel)
  3038 void WebView::setPinchBitmapZoomLevelL(int zoomLevel)
  3022 {
  3039 {
  3023     m_zoomLevelChangedByUser = true;
  3040     m_zoomLevelChangedByUser = true;
  3024     m_dirtyZoomMode = true;
  3041     m_dirtyZoomMode = true;
  3025     m_isPluginsVisible = false;
  3042     m_isPluginsVisible = false;
  3026     m_isPinchZoom = true;
  3043     m_isPinchZoom = true;
  3027 
  3044 
  3028     if (zoomLevel > m_startZoomLevel) {
  3045     if (zoomLevel > m_startZoomLevel) {
  3029         setPinchBitmapZoomIn(zoomLevel);
  3046         setPinchBitmapZoomIn(zoomLevel);
  3030     }
  3047     }
  3031     else {
  3048     else {
  3032         setPinchBitmapZoomOut(zoomLevel);
  3049         setPinchBitmapZoomOutL(zoomLevel);
       
  3050         m_isPinchZoomOut = true;
  3033     }
  3051     }
  3034     m_currentZoomLevel = zoomLevel;
  3052     m_currentZoomLevel = zoomLevel;
  3035     DrawNow();
  3053     DrawNow();
  3036     PluginSkin* pluginskin = mainFrame()->focusedPlugin();
  3054     PluginSkin* pluginskin = mainFrame()->focusedPlugin();
  3037     if(pluginskin)
  3055     if(pluginskin)
  3075     m_pinchDocDelta.iY = (float)shiftInView.iY * 100 / m_startZoomLevel;
  3093     m_pinchDocDelta.iY = (float)shiftInView.iY * 100 / m_startZoomLevel;
  3076 }
  3094 }
  3077 
  3095 
  3078 
  3096 
  3079 //-------------------------------------------------------------------------------
  3097 //-------------------------------------------------------------------------------
  3080 // WebView::setPinchBitmapZoomOut
  3098 // WebView::setPinchBitmapZoomOutL
  3081 //-------------------------------------------------------------------------------
  3099 //-------------------------------------------------------------------------------
  3082 void WebView::setPinchBitmapZoomOut(int zoomLevel)
  3100 void WebView::setPinchBitmapZoomOutL(int zoomLevel)
  3083 {
  3101 {
  3084     TPoint pinchCenter = m_pinchZoomHandler->pinchCenter();
  3102     TPoint pinchCenter = m_pinchZoomHandler->pinchCenter();
  3085 
  3103 
  3086     // take the whole rect and calculate new rect to fit it the rest of view rect paint gray colour
  3104     // take the whole rect and calculate new rect to fit it the rest of view rect paint gray colour
  3087     TRealPoint centerAfterZoom; 
  3105     TRealPoint centerAfterZoom; 
  3107     //srcRectForZooming is the Coecontrol Rect itself
  3125     //srcRectForZooming is the Coecontrol Rect itself
  3108     m_srcRectForZooming = Rect();
  3126     m_srcRectForZooming = Rect();
  3109     //get the shift in the document so that during the next engine re-draw, the origin needs to be updated based on that
  3127     //get the shift in the document so that during the next engine re-draw, the origin needs to be updated based on that
  3110     m_pinchDocDelta.iX = (float)shiftInView.iX * 100 / zoomLevel;   
  3128     m_pinchDocDelta.iX = (float)shiftInView.iX * 100 / zoomLevel;   
  3111     m_pinchDocDelta.iY = (float)shiftInView.iY * 100 / zoomLevel;
  3129     m_pinchDocDelta.iY = (float)shiftInView.iY * 100 / zoomLevel;
  3112 }
  3130     
  3113 
  3131     if(!m_isPinchZoomOut)
  3114 void WebView::reCreatePlugins()
  3132         createCheckerBoardL();
  3115 {
  3133 }
  3116       Frame* coreFrame = core(mainFrame());
       
  3117       MWebCoreObjectWidget* view = NULL;
       
  3118       for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) {
       
  3119            PassRefPtr<HTMLCollection> objects = frame->document()->objects();
       
  3120            for (Node* n = objects->firstItem(); n; n = objects->nextItem()) {
       
  3121                view = widget(n);
       
  3122                if (view) {
       
  3123                    PluginSkin* plg = static_cast<PluginSkin*>(view);
       
  3124                    if(plg->activeStreams() > 0)
       
  3125                       plg->reCreatePlugin();
       
  3126                }
       
  3127            }
       
  3128 
       
  3129            PassRefPtr<HTMLCollection> embeds = frame->document()->embeds();
       
  3130            for (Node* n = embeds->firstItem(); n; n = embeds->nextItem()) {
       
  3131                view = widget(n);
       
  3132                if (view) {
       
  3133                    PluginSkin* plg = static_cast<PluginSkin*>(view);
       
  3134                    if(plg->activeStreams() > 0)
       
  3135                       plg->reCreatePlugin();
       
  3136                }
       
  3137            }
       
  3138       }
       
  3139 }
       
  3140 
       
  3141 
  3134 
  3142 void WebView::setScrolling(bool scroll)
  3135 void WebView::setScrolling(bool scroll)
  3143 {
  3136 {
  3144     m_scroll = scroll;
  3137     m_scroll = scroll;
  3145     mainFrame()->PlayPausePlugins(m_scroll);
  3138     mainFrame()->PlayPausePlugins(m_scroll);
  3146 }
  3139 }
  3147 
  3140 
       
  3141 void drawCheckerBoard(CBitmapContext *gc,const TRect &rect)
       
  3142 {
       
  3143     for(int i = rect.iTl.iX; i <= (rect.iTl.iX + rect.Width()); i = i + (2 * KCheckerSize)) {
       
  3144         for(int j = rect.iTl.iY; j <= (rect.iTl.iY + rect.Height()); j = j + (2 * KCheckerSize)) {
       
  3145              const TRgb lightGrey(KZoomBgRectColor, KZoomBgRectColor, KZoomBgRectColor);
       
  3146              gc->SetPenColor(lightGrey);
       
  3147              gc->SetBrushColor(lightGrey);
       
  3148              
       
  3149              TRect topLeft(TPoint(i, j),TPoint(i + KCheckerSize, j + KCheckerSize));
       
  3150              gc->DrawRect(topLeft);
       
  3151              
       
  3152              TRect bottomRight(TPoint(i + KCheckerSize, j + KCheckerSize),TPoint(i + (2 * KCheckerSize), j + (2 * KCheckerSize)));
       
  3153              gc->DrawRect(bottomRight);
       
  3154              
       
  3155              const TRgb darkGrey(KZoomFgRectColor, KZoomFgRectColor, KZoomFgRectColor);
       
  3156              gc->SetPenColor(darkGrey);
       
  3157              gc->SetBrushColor(darkGrey);
       
  3158              
       
  3159              TRect topRight(TPoint(i + KCheckerSize, j),TPoint(i + (2 * KCheckerSize), j + KCheckerSize));
       
  3160              gc->DrawRect(topRight);
       
  3161              
       
  3162              TRect bottomLeft(TPoint(i, j + KCheckerSize),TPoint(i + KCheckerSize, j + (2 * KCheckerSize)));
       
  3163              gc->DrawRect(bottomLeft);
       
  3164         }
       
  3165     }
       
  3166 }
       
  3167 
       
  3168 void WebView::createCheckerBoardL() 
       
  3169 {
       
  3170     //Cancel the destroy timer, if it is already scheduled.
       
  3171     //Otherwise it will destroy the checkerboard created now.
       
  3172     if(m_checkerBoardDestroyTimer 
       
  3173                 && m_checkerBoardDestroyTimer->IsActive())
       
  3174             m_checkerBoardDestroyTimer->Cancel();
       
  3175     
       
  3176     if(m_checkerBoardBitmap && m_checkerBoardBitmap->SizeInPixels()!=Rect().Size())  {
       
  3177         destroyCheckerBoard();
       
  3178     }
       
  3179     
       
  3180     if(!m_checkerBoardBitmap) {
       
  3181         m_checkerBoardBitmap =new(ELeave) CFbsBitmap;             
       
  3182         TInt err= m_checkerBoardBitmap->Create(Rect().Size(),StaticObjectsContainer::instance()->webSurface()->displayMode());
       
  3183         User::LeaveIfError(err);
       
  3184 
       
  3185         m_checkerBoardDevice = CFbsBitmapDevice::NewL(m_checkerBoardBitmap);
       
  3186     
       
  3187         err = m_checkerBoardDevice->CreateContext(m_checkerBoardGc);
       
  3188         User::LeaveIfError(err);
       
  3189         
       
  3190         m_checkerBoardGc->SetBrushStyle( CGraphicsContext::EForwardDiagonalHatchBrush );
       
  3191         drawCheckerBoard(m_checkerBoardGc,Rect());
       
  3192     }
       
  3193 }
       
  3194 
       
  3195 void WebView::destroyCheckerBoard()
       
  3196 {
       
  3197     if(m_checkerBoardBitmap) {
       
  3198          delete m_checkerBoardGc;
       
  3199          delete m_checkerBoardDevice;
       
  3200          delete m_checkerBoardBitmap;    
       
  3201           
       
  3202          m_checkerBoardBitmap = NULL;
       
  3203          m_checkerBoardDevice = NULL;
       
  3204          m_checkerBoardGc     = NULL;
       
  3205     }
       
  3206     if(m_checkerBoardDestroyTimer 
       
  3207             && m_checkerBoardDestroyTimer->IsActive())
       
  3208         m_checkerBoardDestroyTimer->Cancel();
       
  3209 }
       
  3210 
       
  3211 TInt doDestroyCheckerBoardCb(TAny *ptr)
       
  3212 {
       
  3213     static_cast<WebView*>(ptr)->destroyCheckerBoard();
       
  3214     return ETrue;  
       
  3215 }
       
  3216 
       
  3217 void WebView::startCheckerBoardDestroyTimer()
       
  3218 {
       
  3219     if(!m_checkerBoardDestroyTimer || !m_checkerBoardBitmap) {
       
  3220         return;
       
  3221     }
       
  3222     if(m_checkerBoardDestroyTimer->IsActive())  {
       
  3223         m_checkerBoardDestroyTimer->Cancel();
       
  3224     }
       
  3225     m_checkerBoardDestroyTimer->Start(KCheckerBoardDestroyTimeout,0,TCallBack(doDestroyCheckerBoardCb,this));
       
  3226 }
       
  3227 
       
  3228 //-------------------------------------------------------------------------------
       
  3229 // WebView::calculateZoomRect
       
  3230 //-------------------------------------------------------------------------------
       
  3231 void WebView::calculateZoomRect(TRect &aOldRect, TRect &aNewRect, TInt aOldZoom, TInt aNewZoom)
       
  3232     { 
       
  3233     aNewRect.iTl.iX = (aOldRect.iTl.iX * aOldZoom) / aNewZoom;
       
  3234     aNewRect.iTl.iY = (aOldRect.iTl.iY * aOldZoom) / aNewZoom;
       
  3235     aNewRect.iBr.iX = (aOldRect.iBr.iX * aOldZoom) / aNewZoom;
       
  3236     aNewRect.iBr.iY = (aOldRect.iBr.iY * aOldZoom) / aNewZoom;
       
  3237 
       
  3238     // rounding
       
  3239     if (( aOldRect.iTl.iX * aNewZoom) % aOldZoom ) {
       
  3240         aNewRect.iTl.iX -= 1;
       
  3241         }
       
  3242     if (( aOldRect.iTl.iY * aNewZoom) % aOldZoom ) {
       
  3243         aNewRect.iTl.iY -= 1;
       
  3244         }
       
  3245     if ((aOldRect.iBr.iX * aNewZoom) % aOldZoom ) {
       
  3246         aNewRect.iBr.iX += 1;
       
  3247         }
       
  3248     if ((aOldRect.iBr.iY * aNewZoom) % aOldZoom ) {
       
  3249         aNewRect.iBr.iY += 1;
       
  3250         }
       
  3251     }
       
  3252 
  3148 // END OF FILE
  3253 // END OF FILE