webengine/osswebengine/WebKit/s60/webview/WebView.cpp
changeset 42 d39add9822e2
parent 38 6297cdf66332
child 58 220a17280356
child 65 5bfc169077b2
equal deleted inserted replaced
38:6297cdf66332 42:d39add9822e2
    58 #include "WebPopupDrawer.h"
    58 #include "WebPopupDrawer.h"
    59 #include "PluginSkin.h"
    59 #include "PluginSkin.h"
    60 #include "PluginWin.h"
    60 #include "PluginWin.h"
    61 #include "PluginPlayer.h"
    61 #include "PluginPlayer.h"
    62 #include "WebKitLogger.h"
    62 #include "WebKitLogger.h"
    63 
    63 #include "WebPagePinchZoomHandler.h"
    64 
    64 
    65 #include "Page.h"
    65 #include "Page.h"
    66 #include "Settings.h"
    66 #include "Settings.h"
    67 #include "Frame.h"
    67 #include "Frame.h"
    68 #include "FrameView.h"
    68 #include "FrameView.h"
   199 , m_showCursor(false)
   199 , m_showCursor(false)
   200 , m_allowRepaints(true)
   200 , m_allowRepaints(true)
   201 , m_prevEditMode(false)
   201 , m_prevEditMode(false)
   202 , m_firedEvent(0)
   202 , m_firedEvent(0)
   203 , m_waitTimer(0)
   203 , m_waitTimer(0)
       
   204 , m_pinchZoomHandler(NULL)
       
   205 , m_isPinchZoom(false)
   204 {
   206 {
   205 }
   207 }
   206 
   208 
   207 WebView::~WebView()
   209 WebView::~WebView()
   208 {
   210 {
   225     if (m_fastScrollTimer)
   227     if (m_fastScrollTimer)
   226         m_fastScrollTimer->Cancel();
   228         m_fastScrollTimer->Cancel();
   227     delete m_fastScrollTimer;
   229     delete m_fastScrollTimer;
   228 
   230 
   229     delete [] m_ptrbuffer;
   231     delete [] m_ptrbuffer;
       
   232 	delete m_pinchZoomHandler;
   230     delete m_repainttimer;
   233     delete m_repainttimer;
   231     delete m_webfeptexteditor;
   234     delete m_webfeptexteditor;
   232     delete m_webcorecontext;
   235     delete m_webcorecontext;
   233     delete m_bitmapdevice;
   236     delete m_bitmapdevice;
   234     delete m_page;
   237     delete m_page;
   235     delete m_pageScaler;
   238     delete m_pageScaler;
       
   239 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF    
       
   240     m_pageScaler = NULL;
       
   241 #endif    
   236     delete m_pageView;
   242     delete m_pageView;
   237     delete m_webFormFill;
   243     delete m_webFormFill;
   238     delete m_toolbar;
   244     delete m_toolbar;
   239     delete m_toolbarinterface;
   245     delete m_toolbarinterface;
   240     delete m_widgetextension;
   246     delete m_widgetextension;
   335         m_pageScalerEnabled = true;
   341         m_pageScalerEnabled = true;
   336     }
   342     }
   337     if (m_brctl->capabilities() & TBrCtlDefs::ECapabilityAutoFormFill) {
   343     if (m_brctl->capabilities() & TBrCtlDefs::ECapabilityAutoFormFill) {
   338         m_webFormFill = new WebFormFill(this);
   344         m_webFormFill = new WebFormFill(this);
   339     }
   345     }
   340 
   346     
       
   347     //Creates the Pinch Zoom Handler
       
   348     m_pinchZoomHandler = WebPagePinchZoomHandler::NewL(this);
       
   349     
   341     // Create the PointerEventHandler
   350     // Create the PointerEventHandler
   342     m_ptrbuffer = new TPoint[256];
   351     m_ptrbuffer = new TPoint[256];
   343     m_webpointerEventHandler = WebPointerEventHandler::NewL(this);
   352     m_webpointerEventHandler = WebPointerEventHandler::NewL(this);
   344 
   353 
   345     // Create the ScrollHandler
   354     // Create the ScrollHandler
   358     CleanupStack::PopAndDestroy(2); // userAgent8, usrAgnt
   367     CleanupStack::PopAndDestroy(2); // userAgent8, usrAgnt
   359 
   368 
   360     MakeViewVisible(ETrue);
   369     MakeViewVisible(ETrue);
   361     m_isPluginsVisible=ETrue;
   370     m_isPluginsVisible=ETrue;
   362     CCoeControl::SetFocus(ETrue);
   371     CCoeControl::SetFocus(ETrue);
   363 
   372 #ifdef BRDO_MULTITOUCH_ENABLED_FF
       
   373     //To enable advance pointer info for multi-touch
       
   374     Window().EnableAdvancedPointers();
       
   375 #endif 
   364     cache()->setCapacities(0, 0, defaultCacheCapacity);
   376     cache()->setCapacities(0, 0, defaultCacheCapacity);
   365     
   377     
   366     m_waiter = new(ELeave) CActiveSchedulerWait();
   378     m_waiter = new(ELeave) CActiveSchedulerWait();
   367 }
   379 }
   368 
   380 
   402     }
   414     }
   403     else {
   415     else {
   404         gc.DrawBitmap( m_destRectForZooming, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), m_srcRectForZooming );
   416         gc.DrawBitmap( m_destRectForZooming, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), m_srcRectForZooming );
   405 
   417 
   406         if ( m_startZoomLevel > m_currentZoomLevel) {
   418         if ( m_startZoomLevel > m_currentZoomLevel) {
   407 
   419 #ifdef BRDO_MULTITOUCH_ENABLED_FF
       
   420             TInt destRectWidth = m_destRectForZooming.Width();
       
   421             TInt destRectHeight = m_destRectForZooming.Height();
       
   422             TRect rectLeft(TPoint(rect.iTl),
       
   423                             TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX, rect.iBr.iY));
       
   424             
       
   425             TRect rectRight(TPoint(rect.iTl.iX + destRectWidth + m_destRectForZooming.iTl.iX, rect.iTl.iY),
       
   426                             TPoint(rect.iBr));
       
   427             
       
   428             TRect rectTop(TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX, rect.iTl.iY),
       
   429                               TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX + destRectWidth, rect.iTl.iY + m_destRectForZooming.iTl.iY));
       
   430 
       
   431             TRect rectBottom(TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX, rect.iTl.iY + m_destRectForZooming.iTl.iY + destRectHeight),
       
   432                               TPoint(rect.iTl.iX + destRectWidth + m_destRectForZooming.iTl.iX, rect.iBr.iY));
       
   433 #else 
   408             TRect rectLeft( TPoint( rect.iTl.iX + m_destRectForZooming.Width() - 2, rect.iTl.iY ),
   434             TRect rectLeft( TPoint( rect.iTl.iX + m_destRectForZooming.Width() - 2, rect.iTl.iY ),
   409                             TPoint( rect.iBr ));
   435                             TPoint( rect.iBr ));
   410 
   436 
   411             TRect rectBottom( TPoint( rect.iTl.iX, rect.iTl.iY + m_destRectForZooming.Height() - 2 ),
   437             TRect rectBottom( TPoint( rect.iTl.iX, rect.iTl.iY + m_destRectForZooming.Height() - 2 ),
   412                               TPoint( rect.iBr.iX + m_destRectForZooming.Width(), rect.iBr.iY ));
   438                               TPoint( rect.iBr.iX + m_destRectForZooming.Width(), rect.iBr.iY ));
   413 
   439 #endif 
   414 
   440 
   415             const TRgb colorTest(KZoomBgRectColor,KZoomBgRectColor,KZoomBgRectColor);
   441             const TRgb colorTest(KZoomBgRectColor,KZoomBgRectColor,KZoomBgRectColor);
   416             gc.SetPenColor(colorTest);
   442             gc.SetPenColor(colorTest);
   417             gc.SetBrushStyle( CGraphicsContext::EForwardDiagonalHatchBrush );
   443             gc.SetBrushStyle( CGraphicsContext::EForwardDiagonalHatchBrush );
   418             gc.SetBrushColor(colorTest);
   444             gc.SetBrushColor(colorTest);
   419             gc.DrawRect( rectLeft );
   445             gc.DrawRect( rectLeft );
   420             gc.DrawRect( rectBottom );
   446             gc.DrawRect( rectBottom );
       
   447 #ifdef BRDO_MULTITOUCH_ENABLED_FF
       
   448             gc.DrawRect( rectRight );
       
   449             gc.DrawRect( rectTop );
       
   450 #endif 
   421 
   451 
   422         }
   452         }
   423 
   453 
   424     }
   454     }
   425 
   455 
   523 
   553 
   524     if ( visible ) {
   554     if ( visible ) {
   525       clearOffScreenBitmap();
   555       clearOffScreenBitmap();
   526       m_tabbedNavigation->initializeForPage();
   556       m_tabbedNavigation->initializeForPage();
   527       syncRepaint( mainFrame()->frameView()->visibleRect() );
   557       syncRepaint( mainFrame()->frameView()->visibleRect() );
       
   558       TRAP_IGNORE( m_webfeptexteditor->EnableCcpuL() ); 
   528     }
   559     }
   529 
   560 
   530 }
   561 }
   531 
   562 
   532 
   563 
  1071      */
  1102      */
  1072      if ((m_focusedElementType == TBrCtlDefs::EElementNone ||
  1103      if ((m_focusedElementType == TBrCtlDefs::EElementNone ||
  1073           m_focusedElementType == TBrCtlDefs::EElementBrokenImage ) &&
  1104           m_focusedElementType == TBrCtlDefs::EElementBrokenImage ) &&
  1074           keyevent.iRepeats && !m_brctl->wmlMode() ) {
  1105           keyevent.iRepeats && !m_brctl->wmlMode() ) {
  1075          launchToolBarL();
  1106          launchToolBarL();
       
  1107         if(m_toolbar) {
       
  1108 			 sendMouseEventToEngineIfNeeded(TPointerEvent::EButton1Up, cursor->position(), frame);
       
  1109         }
  1076      }
  1110      }
  1077     
  1111     
  1078      return true;
  1112      return true;
  1079 }
  1113 }
  1080 
  1114 
  2013     m_inFindState = false;
  2047     m_inFindState = false;
  2014     delete m_findKeyword;
  2048     delete m_findKeyword;
  2015     m_findKeyword = NULL;
  2049     m_findKeyword = NULL;
  2016     WebFrame* selectedFrame = mainFrame()->findFrameWithSelection();
  2050     WebFrame* selectedFrame = mainFrame()->findFrameWithSelection();
  2017     selectedFrame->clearSelection();
  2051     selectedFrame->clearSelection();
       
  2052     setFocusNone();
  2018 }
  2053 }
  2019 
  2054 
  2020 bool WebView::isSmallPage()
  2055 bool WebView::isSmallPage()
  2021 {
  2056 {
  2022     TSize docSize = DocumentSize();
  2057     TSize docSize = DocumentSize();
  2026 
  2061 
  2027 void WebView::willSubmitForm(FormState* formState)
  2062 void WebView::willSubmitForm(FormState* formState)
  2028 {
  2063 {
  2029     if (m_webFormFill) {
  2064     if (m_webFormFill) {
  2030         m_webFormFill->willSubmitForm(formState);
  2065         m_webFormFill->willSubmitForm(formState);
  2031     }
       
  2032 }
       
  2033 
       
  2034 
       
  2035 //-------------------------------------------------------------------------------
       
  2036 // WebView::HandlePointerBufferReadyL
       
  2037 // Handles pointer move events
       
  2038 //-------------------------------------------------------------------------------
       
  2039 void WebView::HandlePointerBufferReadyL()
       
  2040 {
       
  2041     memset(m_ptrbuffer,0,256*sizeof(TPoint));
       
  2042     TPtr8 ptr((TUint8 *)m_ptrbuffer,256*sizeof(TPoint));
       
  2043 
       
  2044     TInt numPnts = Window().RetrievePointerMoveBuffer(ptr);
       
  2045     int i = 0;
       
  2046     for (; i < numPnts; i++) {
       
  2047         TPointerEvent pe;
       
  2048         pe.iType = TPointerEvent::EDrag;
       
  2049         pe.iPosition = m_ptrbuffer[i];
       
  2050         m_webpointerEventHandler->HandlePointerEventL(pe);
       
  2051     }
  2066     }
  2052 }
  2067 }
  2053 
  2068 
  2054 //-------------------------------------------------------------------------------
  2069 //-------------------------------------------------------------------------------
  2055 // WebView::HandlePointerEventL
  2070 // WebView::HandlePointerEventL
  2402 
  2417 
  2403     view->setContentPos( pt );
  2418     view->setContentPos( pt );
  2404     mainFrame()->scalingFactorChanged(z);
  2419     mainFrame()->scalingFactorChanged(z);
  2405     view->checkScrollbarVisibility();
  2420     view->checkScrollbarVisibility();
  2406 
  2421 
       
  2422     if (m_isPinchZoom) {
       
  2423         if (newZoomLevel > m_startZoomLevel) {
       
  2424             TPoint cpos( mainFrame()->frameView()->contentPos());
       
  2425             cpos.iX = cpos.iX + m_pinchDocDelta.iX +.5;
       
  2426             cpos.iY = cpos.iY + m_pinchDocDelta.iY +.5;
       
  2427             mainFrame()->frameView()->setContentPos(cpos);
       
  2428         }
       
  2429         if (m_startZoomLevel > newZoomLevel) {
       
  2430             TPoint cpos( mainFrame()->frameView()->contentPos());
       
  2431             cpos.iX = cpos.iX - m_pinchDocDelta.iX +.5;
       
  2432             cpos.iY = cpos.iY - m_pinchDocDelta.iY +.5;
       
  2433            
       
  2434             if (cpos.iX < 0) cpos.iX = 0;
       
  2435             if (cpos.iY < 0) cpos.iY = 0;
       
  2436             mainFrame()->frameView()->setContentPos(cpos);
       
  2437         }
       
  2438         m_isPinchZoom = false;
       
  2439     }
       
  2440    
  2407     TRect rect = view->rect();
  2441     TRect rect = view->rect();
  2408 
  2442 
  2409     TInt tlx = (rect.iTl.iX * currZoomLevel) / m_currentZoomLevel;
  2443     TInt tlx = (rect.iTl.iX * currZoomLevel) / m_currentZoomLevel;
  2410     TInt tly = (rect.iTl.iY * currZoomLevel) / m_currentZoomLevel;
  2444     TInt tly = (rect.iTl.iY * currZoomLevel) / m_currentZoomLevel;
  2411     TInt brx = (rect.iBr.iX * currZoomLevel) / m_currentZoomLevel;
  2445     TInt brx = (rect.iBr.iX * currZoomLevel) / m_currentZoomLevel;
  2941     if (m_waiter->IsStarted()) {
  2975     if (m_waiter->IsStarted()) {
  2942         m_waiter->AsyncStop();
  2976         m_waiter->AsyncStop();
  2943     }
  2977     }
  2944 }
  2978 }
  2945 
  2979 
       
  2980 //-------------------------------------------------------------------------------
       
  2981 // WebView::setPinchBitmapZoomLevel
       
  2982 //-------------------------------------------------------------------------------
       
  2983 void WebView::setPinchBitmapZoomLevel(int zoomLevel)
       
  2984 {
       
  2985     m_zoomLevelChangedByUser = true;
       
  2986     m_dirtyZoomMode = true;
       
  2987     m_isPluginsVisible = false;
       
  2988     mainFrame()->makeVisiblePlugins(false);
       
  2989     m_isPinchZoom = true;
       
  2990 
       
  2991     if (zoomLevel > m_startZoomLevel) {
       
  2992         setPinchBitmapZoomIn(zoomLevel);
       
  2993     }
       
  2994     else {
       
  2995         setPinchBitmapZoomOut(zoomLevel);
       
  2996     }
       
  2997     m_currentZoomLevel = zoomLevel;
       
  2998     DrawNow();
       
  2999 }
       
  3000 
       
  3001 //-------------------------------------------------------------------------------
       
  3002 // WebView::setPinchBitmapZoomIn
       
  3003 //-------------------------------------------------------------------------------
       
  3004 void WebView::setPinchBitmapZoomIn(int zoomLevel)
       
  3005 {
       
  3006     TPoint pinchCenter = m_pinchZoomHandler->pinchCenter();
       
  3007     
       
  3008     // cut m_srcRectForZooming from m_offscreenrect and enlarge it to fit the view rect
       
  3009     TRealPoint centerAfterZoom; 
       
  3010     //find out the new position of Pinch Center after applying zoom
       
  3011     centerAfterZoom.iX = (float)pinchCenter.iX * zoomLevel/m_startZoomLevel;
       
  3012     centerAfterZoom.iY = (float)pinchCenter.iY * zoomLevel/m_startZoomLevel;
       
  3013     TRealPoint centerDelta;
       
  3014     //get the shift in the Pinch Center
       
  3015     centerDelta.iX = centerAfterZoom.iX - pinchCenter.iX;
       
  3016     centerDelta.iY = centerAfterZoom.iY - pinchCenter.iY;
       
  3017     TPoint shiftInView;
       
  3018     //find out how much shift needs to be applied to the current zoom, w.r.t. the new view
       
  3019     shiftInView.iX = centerDelta.iX * m_startZoomLevel / zoomLevel;
       
  3020     shiftInView.iY = centerDelta.iY * m_startZoomLevel / zoomLevel;
       
  3021     //width and height of the rectangle that should be used for bitmap stretching 
       
  3022     float newWidth  = (float)m_offscreenrect.Width()  * m_startZoomLevel / zoomLevel;
       
  3023     float newHeight = (float)m_offscreenrect.Height() * m_startZoomLevel /zoomLevel;
       
  3024     //defining the source rectangle which needs to be bitmap stretched
       
  3025     m_srcRectForZooming.iTl.iX = shiftInView.iX;
       
  3026     m_srcRectForZooming.iTl.iY = shiftInView.iY;
       
  3027     m_srcRectForZooming.iBr.iX = newWidth  + shiftInView.iX; 
       
  3028     m_srcRectForZooming.iBr.iY = newHeight + shiftInView.iY;
       
  3029     //destRectForZooming is the Coecontrol Rect itself
       
  3030     m_destRectForZooming = Rect();
       
  3031     //get the shift in the document so that during the next engine re-draw, the origin needs to be updated based on that
       
  3032     m_pinchDocDelta.iX = (float)shiftInView.iX * 100 / m_startZoomLevel;   
       
  3033     m_pinchDocDelta.iY = (float)shiftInView.iY * 100 / m_startZoomLevel;
       
  3034 }
       
  3035 
       
  3036 
       
  3037 //-------------------------------------------------------------------------------
       
  3038 // WebView::setPinchBitmapZoomOut
       
  3039 //-------------------------------------------------------------------------------
       
  3040 void WebView::setPinchBitmapZoomOut(int zoomLevel)
       
  3041 {
       
  3042     TPoint pinchCenter = m_pinchZoomHandler->pinchCenter();
       
  3043 
       
  3044     // take the whole rect and calculate new rect to fit it the rest of view rect paint gray colour
       
  3045     TRealPoint centerAfterZoom; 
       
  3046     //find out the new position of Pinch Center after applying zoom
       
  3047     centerAfterZoom.iX = (float)pinchCenter.iX * m_startZoomLevel / zoomLevel;
       
  3048     centerAfterZoom.iY = (float)pinchCenter.iY * m_startZoomLevel / zoomLevel;
       
  3049     TRealPoint centerDelta;
       
  3050     //get the shift in the Pinch Center
       
  3051     centerDelta.iX = centerAfterZoom.iX - pinchCenter.iX;
       
  3052     centerDelta.iY = centerAfterZoom.iY - pinchCenter.iY;
       
  3053     TPoint shiftInView;
       
  3054     //find out how much shift needs to be applied to the current zoom, w.r.t. the new view
       
  3055     shiftInView.iX = centerDelta.iX * zoomLevel / m_startZoomLevel;
       
  3056     shiftInView.iY = centerDelta.iY * zoomLevel / m_startZoomLevel;
       
  3057     //width and height of the rectangle
       
  3058     float newWidth  = (float)m_offscreenrect.Width()  * zoomLevel / m_startZoomLevel;
       
  3059     float newHeight = (float)m_offscreenrect.Height() * zoomLevel / m_startZoomLevel;
       
  3060     //defining the co-ordinates of the destination rectangle.
       
  3061     m_destRectForZooming.iTl.iX = shiftInView.iX;
       
  3062     m_destRectForZooming.iTl.iY = shiftInView.iY;
       
  3063     m_destRectForZooming.iBr.iX = newWidth  + shiftInView.iX;
       
  3064     m_destRectForZooming.iBr.iY = newHeight + shiftInView.iY;
       
  3065     //srcRectForZooming is the Coecontrol Rect itself
       
  3066     m_srcRectForZooming = Rect();
       
  3067     //get the shift in the document so that during the next engine re-draw, the origin needs to be updated based on that
       
  3068     m_pinchDocDelta.iX = (float)shiftInView.iX * 100 / zoomLevel;   
       
  3069     m_pinchDocDelta.iY = (float)shiftInView.iY * 100 / zoomLevel;
       
  3070 }
  2946 
  3071 
  2947 // END OF FILE
  3072 // END OF FILE