webengine/osswebengine/WebKit/s60/webview/WebView.cpp
changeset 65 5bfc169077b2
parent 42 d39add9822e2
child 68 92a765b5b3e7
equal deleted inserted replaced
42:d39add9822e2 65:5bfc169077b2
    26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    29 */
    29 */
    30 
    30 
    31 #include <browser_platform_variant.hrh>
    31 #include <Browser_platform_variant.hrh>
    32 #include "config.h"
    32 #include "config.h"
    33 #include "../../bidi.h"
    33 #include "../../bidi.h"
    34 #include "brctl.h"
    34 #include "brctl.h"
    35 #include "HistoryController.h"
    35 #include "HistoryController.h"
    36 #include "PageView.h"
    36 #include "PageView.h"
    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 #include "WebPagePinchZoomHandler.h"
    63 
    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"
    88 #include "HTMLInputElement.h"
    88 #include "HTMLInputElement.h"
    89 
    89 
    90 using namespace HTMLNames;
    90 using namespace HTMLNames;
    91 
    91 
    92 #include <AknUtils.h>
    92 #include <AknUtils.h>
    93 #include <cuseragent.h>
    93 #include <CUserAgent.h>
    94 #include "WebPageZoomHandler.h"
    94 #include "WebPageZoomHandler.h"
    95 
    95 
    96 #include "PlatformFontCache.h"
    96 #include "PlatformFontCache.h"
    97 #include "WebPageFullScreenHandler.h"
    97 #include "WebPageFullScreenHandler.h"
    98 #include "eikon.hrh"
    98 #include "eikon.hrh"
   198 , m_ptrbuffer(0)
   198 , m_ptrbuffer(0)
   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)
       
   204 , m_pinchZoomHandler(NULL)
       
   205 , m_isPinchZoom(false)
       
   206 {
   203 {
   207 }
   204 }
   208 
   205 
   209 WebView::~WebView()
   206 WebView::~WebView()
   210 {
   207 {
   227     if (m_fastScrollTimer)
   224     if (m_fastScrollTimer)
   228         m_fastScrollTimer->Cancel();
   225         m_fastScrollTimer->Cancel();
   229     delete m_fastScrollTimer;
   226     delete m_fastScrollTimer;
   230 
   227 
   231     delete [] m_ptrbuffer;
   228     delete [] m_ptrbuffer;
   232 	delete m_pinchZoomHandler;
       
   233     delete m_repainttimer;
   229     delete m_repainttimer;
   234     delete m_webfeptexteditor;
   230     delete m_webfeptexteditor;
   235     delete m_webcorecontext;
   231     delete m_webcorecontext;
   236     delete m_bitmapdevice;
   232     delete m_bitmapdevice;
   237     delete m_page;
   233     delete m_page;
   238     delete m_pageScaler;
   234     delete m_pageScaler;
   239 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF    
       
   240     m_pageScaler = NULL;
       
   241 #endif    
       
   242     delete m_pageView;
   235     delete m_pageView;
   243     delete m_webFormFill;
   236     delete m_webFormFill;
   244     delete m_toolbar;
   237     delete m_toolbar;
   245     delete m_toolbarinterface;
   238     delete m_toolbarinterface;
   246     delete m_widgetextension;
   239     delete m_widgetextension;
   247     delete m_webpointerEventHandler;
   240     delete m_webpointerEventHandler;
   248     delete m_pageScrollHandler;
   241     delete m_pageScrollHandler;
   249     delete m_pluginplayer;
   242     delete m_pluginplayer;
   250     delete m_fepTimer;
   243     delete m_fepTimer;
   251     delete m_waitTimer;
       
   252     delete m_waiter;
       
   253     delete m_popupDrawer;
   244     delete m_popupDrawer;
   254     delete m_tabbedNavigation;
   245     delete m_tabbedNavigation;
   255     delete m_userAgent;
   246     delete m_userAgent;
   256     delete m_pageFullScreenHandler;
   247     delete m_pageFullScreenHandler;
   257     delete m_bridge;
   248     delete m_bridge;
   341         m_pageScalerEnabled = true;
   332         m_pageScalerEnabled = true;
   342     }
   333     }
   343     if (m_brctl->capabilities() & TBrCtlDefs::ECapabilityAutoFormFill) {
   334     if (m_brctl->capabilities() & TBrCtlDefs::ECapabilityAutoFormFill) {
   344         m_webFormFill = new WebFormFill(this);
   335         m_webFormFill = new WebFormFill(this);
   345     }
   336     }
   346     
   337 
   347     //Creates the Pinch Zoom Handler
       
   348     m_pinchZoomHandler = WebPagePinchZoomHandler::NewL(this);
       
   349     
       
   350     // Create the PointerEventHandler
   338     // Create the PointerEventHandler
   351     m_ptrbuffer = new TPoint[256];
   339     m_ptrbuffer = new TPoint[256];
   352     m_webpointerEventHandler = WebPointerEventHandler::NewL(this);
   340     m_webpointerEventHandler = WebPointerEventHandler::NewL(this);
   353 
   341 
   354     // Create the ScrollHandler
   342     // Create the ScrollHandler
   367     CleanupStack::PopAndDestroy(2); // userAgent8, usrAgnt
   355     CleanupStack::PopAndDestroy(2); // userAgent8, usrAgnt
   368 
   356 
   369     MakeViewVisible(ETrue);
   357     MakeViewVisible(ETrue);
   370     m_isPluginsVisible=ETrue;
   358     m_isPluginsVisible=ETrue;
   371     CCoeControl::SetFocus(ETrue);
   359     CCoeControl::SetFocus(ETrue);
   372 #ifdef BRDO_MULTITOUCH_ENABLED_FF
   360 
   373     //To enable advance pointer info for multi-touch
       
   374     Window().EnableAdvancedPointers();
       
   375 #endif 
       
   376     cache()->setCapacities(0, 0, defaultCacheCapacity);
   361     cache()->setCapacities(0, 0, defaultCacheCapacity);
   377     
       
   378     m_waiter = new(ELeave) CActiveSchedulerWait();
       
   379 }
   362 }
   380 
   363 
   381 void WebView::initializePageScalerL()
   364 void WebView::initializePageScalerL()
   382 {
   365 {
   383     TBool lowQuality = !( m_brctl->capabilities() & TBrCtlDefs::ECapabilityGraphicalHistory );
   366     TBool lowQuality = !( m_brctl->capabilities() & TBrCtlDefs::ECapabilityGraphicalHistory );
   414     }
   397     }
   415     else {
   398     else {
   416         gc.DrawBitmap( m_destRectForZooming, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), m_srcRectForZooming );
   399         gc.DrawBitmap( m_destRectForZooming, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), m_srcRectForZooming );
   417 
   400 
   418         if ( m_startZoomLevel > m_currentZoomLevel) {
   401         if ( m_startZoomLevel > m_currentZoomLevel) {
   419 #ifdef BRDO_MULTITOUCH_ENABLED_FF
   402 
   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 
       
   434             TRect rectLeft( TPoint( rect.iTl.iX + m_destRectForZooming.Width() - 2, rect.iTl.iY ),
   403             TRect rectLeft( TPoint( rect.iTl.iX + m_destRectForZooming.Width() - 2, rect.iTl.iY ),
   435                             TPoint( rect.iBr ));
   404                             TPoint( rect.iBr ));
   436 
   405 
   437             TRect rectBottom( TPoint( rect.iTl.iX, rect.iTl.iY + m_destRectForZooming.Height() - 2 ),
   406             TRect rectBottom( TPoint( rect.iTl.iX, rect.iTl.iY + m_destRectForZooming.Height() - 2 ),
   438                               TPoint( rect.iBr.iX + m_destRectForZooming.Width(), rect.iBr.iY ));
   407                               TPoint( rect.iBr.iX + m_destRectForZooming.Width(), rect.iBr.iY ));
   439 #endif 
   408 
   440 
   409 
   441             const TRgb colorTest(KZoomBgRectColor,KZoomBgRectColor,KZoomBgRectColor);
   410             const TRgb colorTest(KZoomBgRectColor,KZoomBgRectColor,KZoomBgRectColor);
   442             gc.SetPenColor(colorTest);
   411             gc.SetPenColor(colorTest);
   443             gc.SetBrushStyle( CGraphicsContext::EForwardDiagonalHatchBrush );
   412             gc.SetBrushStyle( CGraphicsContext::EForwardDiagonalHatchBrush );
   444             gc.SetBrushColor(colorTest);
   413             gc.SetBrushColor(colorTest);
   445             gc.DrawRect( rectLeft );
   414             gc.DrawRect( rectLeft );
   446             gc.DrawRect( rectBottom );
   415             gc.DrawRect( rectBottom );
   447 #ifdef BRDO_MULTITOUCH_ENABLED_FF
       
   448             gc.DrawRect( rectRight );
       
   449             gc.DrawRect( rectTop );
       
   450 #endif 
       
   451 
   416 
   452         }
   417         }
   453 
   418 
   454     }
   419     }
   455 
   420 
   518         if (visible) {
   483         if (visible) {
   519             cursor->setCurrentView(*this);
   484             cursor->setCurrentView(*this);
   520             //Reset the iFocusedElementType to be the same as before the second window is opened.
   485             //Reset the iFocusedElementType to be the same as before the second window is opened.
   521             cursor->setPosition(m_savedCursorPosition);
   486             cursor->setPosition(m_savedCursorPosition);
   522             cursor->updatePositionAndElemType(m_savedCursorPosition);
   487             cursor->updatePositionAndElemType(m_savedCursorPosition);
   523             if ( m_widgetextension && m_focusedElementType == TBrCtlDefs::EElementSelectBox){
       
   524                 m_focusedElementType = TBrCtlDefs::EElementNone;
       
   525             }
       
   526         } else
   488         } else
   527             m_savedCursorPosition = cursor->position();
   489             m_savedCursorPosition = cursor->position();
   528         cursor->cursorUpdate(visible & !AknLayoutUtils::PenEnabled());
   490         cursor->cursorUpdate(visible & !AknLayoutUtils::PenEnabled());
   529     }
   491     }
   530     Frame* f = m_page->mainFrame();
   492     Frame* f = m_page->mainFrame();
   551         m_webFormFillPopup->MakeVisible(EFalse);
   513         m_webFormFillPopup->MakeVisible(EFalse);
   552     }
   514     }
   553 
   515 
   554     if ( visible ) {
   516     if ( visible ) {
   555       clearOffScreenBitmap();
   517       clearOffScreenBitmap();
   556       m_tabbedNavigation->initializeForPage();
       
   557       syncRepaint( mainFrame()->frameView()->visibleRect() );
   518       syncRepaint( mainFrame()->frameView()->visibleRect() );
   558       TRAP_IGNORE( m_webfeptexteditor->EnableCcpuL() ); 
       
   559     }
   519     }
   560 
   520 
   561 }
   521 }
   562 
   522 
   563 
   523 
   564 
   524 
   565 void WebView::doLayout()
   525 void WebView::doLayout()
   566 {
   526 {
   567 
   527 
   568     int zoomLevel = m_currentZoomLevel;
   528     int zoomLevel = m_currentZoomLevel;
   569     if(m_widgetextension && !(m_widgetextension->IsWidgetPublising())) {
   529     if(!(   m_widgetextension && m_widgetextension->IsWidgetPublising())) {
   570         zoomLevelChanged( KZoomLevelDefaultValue );
   530         zoomLevelChanged( KZoomLevelDefaultValue );
   571     }
   531     }
   572     Frame* f = m_page->mainFrame();
   532     Frame* f = m_page->mainFrame();
   573 
   533 
   574     while ( f ) {
   534     while ( f ) {
  1102      */
  1062      */
  1103      if ((m_focusedElementType == TBrCtlDefs::EElementNone ||
  1063      if ((m_focusedElementType == TBrCtlDefs::EElementNone ||
  1104           m_focusedElementType == TBrCtlDefs::EElementBrokenImage ) &&
  1064           m_focusedElementType == TBrCtlDefs::EElementBrokenImage ) &&
  1105           keyevent.iRepeats && !m_brctl->wmlMode() ) {
  1065           keyevent.iRepeats && !m_brctl->wmlMode() ) {
  1106          launchToolBarL();
  1066          launchToolBarL();
  1107         if(m_toolbar) {
       
  1108 			 sendMouseEventToEngineIfNeeded(TPointerEvent::EButton1Up, cursor->position(), frame);
       
  1109         }
       
  1110      }
  1067      }
  1111     
  1068     
  1112      return true;
  1069      return true;
  1113 }
  1070 }
  1114 
  1071 
  1115 bool WebView::handleNaviKeyEvent(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame)  
  1072 bool WebView::handleNaviKeyEvent(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame)  
  1116 {
  1073 {
  1117     bool downEventConsumed = false;
  1074     bool downEventConsumed = false;
  1118     bool consumed = false;
  1075     bool consumed = false;
  1119     bool tabbedNavigation = (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed);
  1076     bool tabbedNavigation = (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed);
  1120     bool navigationNone = (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeNone);
       
  1121     /*
  1077     /*
  1122      * For each platform keyDown event EventHandler::keEvent() generates 
  1078      * For each platform keyDown event EventHandler::keEvent() generates 
  1123      * keydown and keypress.
  1079      * keydown and keypress.
  1124      * For keypress event we need a char code and since we don't 
  1080      * For keypress event we need a char code and since we don't 
  1125      * have it at the time of EEventKeyDown we pospond it until EEventKey 
  1081      * have it at the time of EEventKeyDown we pospond it until EEventKey 
  1126      * and send it here.
  1082      * and send it here.
  1127      */
  1083      */
  1128     if (eventcode == EEventKeyDown){
  1084     if (eventcode == EEventKeyDown){
  1129         downEventConsumed = sendKeyEventToEngine(keyevent, EEventKeyDown, frame) || 
  1085         downEventConsumed = sendKeyEventToEngine(keyevent, EEventKeyDown, frame);
  1130                             ((m_focusedElementType == TBrCtlDefs::EElementActivatedInputBox && // style of input box     
  1086     }
  1131                               page()->chrome()->client()->elementVisibilityChanged()));
       
  1132     }
       
  1133      
       
  1134     /*
  1087     /*
  1135      * downEventConsumed will be true if JavaScript consumes key event
  1088      * downEventConsumed will be true if JavaScript consumes key event
  1136      * If we are not in the widget mode we want to deactivate input box
  1089      * If we are not in the widget mode we want to deactivate input box
  1137      * regardless of whether event was consumed by JavaScript or not.
  1090      * regardless of whether event was consumed by JavaScript or not.
  1138      * Othrerwise we have a risk to be trapped inside input box.
  1091      * Othrerwise we have a risk to be trapped inside input box.
  1140     bool widgetDownEventConsumed = downEventConsumed && (m_widgetextension != NULL);
  1093     bool widgetDownEventConsumed = downEventConsumed && (m_widgetextension != NULL);
  1141   
  1094   
  1142     if (!widgetDownEventConsumed && needDeactivateEditable(keyevent, eventcode, frame, downEventConsumed)) {
  1095     if (!widgetDownEventConsumed && needDeactivateEditable(keyevent, eventcode, frame, downEventConsumed)) {
  1143         deactivateEditable();
  1096         deactivateEditable();
  1144     }
  1097     }
  1145     if(!navigationNone)
  1098 
  1146     if(frame->document()->focusedNode() != NULL && IS_DOWN_KEY(keyevent) && frame->document()->focusedNode()->changed())
       
  1147         {
       
  1148         deactivateEditable();
       
  1149         }
       
  1150     if (tabbedNavigation) {
  1099     if (tabbedNavigation) {
  1151         consumed = downEventConsumed || handleTabbedNavigation(m_currentEventKey, m_currentEventCode);
  1100         consumed = downEventConsumed || handleTabbedNavigation(m_currentEventKey, m_currentEventCode);
  1152     }
  1101     }
  1153     else {  
  1102     else {  
  1154         consumed = (!m_isEditable &&  //avoid showing the cursor when we are in the input box 
  1103         consumed = (!m_isEditable &&  //avoid showing the cursor when we are in the input box 
  1416 
  1365 
  1417     if ( (keyevent.iScanCode == EStdKeyDevice3) ||
  1366     if ( (keyevent.iScanCode == EStdKeyDevice3) ||
  1418        (keyevent.iScanCode == EStdKeyEnter) ) {
  1367        (keyevent.iScanCode == EStdKeyEnter) ) {
  1419        // pass it to webcore
  1368        // pass it to webcore
  1420 
  1369 
  1421         if (( m_focusedElementType == TBrCtlDefs::EElementActivatedInputBox ||
  1370         if (( m_focusedElementType == TBrCtlDefs::EElementInputBox ||
  1422             m_focusedElementType == TBrCtlDefs::EElementTextAreaBox) &&
  1371             m_focusedElementType == TBrCtlDefs::EElementTextAreaBox) &&
  1423             m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed ) {
  1372             m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed ) {
  1424             if (!m_prevEditMode) {
  1373             if (!m_prevEditMode) {
  1425                 setEditable(true);
  1374                 setEditable(true);
  1426             }
  1375             }
  1514     if (m_toolbar)
  1463     if (m_toolbar)
  1515         return m_toolbar->HandleOfferKeyEventL(keyevent, eventcode);
  1464         return m_toolbar->HandleOfferKeyEventL(keyevent, eventcode);
  1516 
  1465 
  1517     if (m_popupDrawer)
  1466     if (m_popupDrawer)
  1518         return m_popupDrawer->handleOfferKeyEventL(keyevent, eventcode );
  1467         return m_popupDrawer->handleOfferKeyEventL(keyevent, eventcode );
  1519     
       
  1520     if (m_focusedElementType == TBrCtlDefs::EElementObjectBox 
       
  1521         || m_focusedElementType == TBrCtlDefs::EElementActivatedObjectBox) {
       
  1522         
       
  1523         Node* node = static_cast<Node*>(cursor->getElementUnderCursor());
       
  1524         MWebCoreObjectWidget* view = widget(node);
       
  1525         PluginSkin* plugin = static_cast<PluginSkin*>(view);
       
  1526         if (plugin && plugin->pluginWin() && !(plugin->pluginWin()->Windowed())) {
       
  1527             if (EKeyWasConsumed == plugin->pluginWin()->OfferKeyEventL(keyevent, eventcode))
       
  1528                 return EKeyWasConsumed;
       
  1529         }
       
  1530     }    
       
  1531 
  1468 
  1532     if ( m_webFormFillPopup && m_webFormFillPopup->IsVisible() && AknLayoutUtils::PenEnabled() ) {
  1469     if ( m_webFormFillPopup && m_webFormFillPopup->IsVisible() && AknLayoutUtils::PenEnabled() ) {
  1533 	    if (EKeyWasConsumed == m_webFormFillPopup->HandleKeyEventL(keyevent, eventcode)) {
  1470 	    if (EKeyWasConsumed == m_webFormFillPopup->HandleKeyEventL(keyevent, eventcode)) {
  1534             return EKeyWasConsumed;
  1471             return EKeyWasConsumed;
  1535 	    }
  1472 	    }
  1764 }
  1701 }
  1765 
  1702 
  1766 void WebView::setEditable(TBool editable)
  1703 void WebView::setEditable(TBool editable)
  1767 {
  1704 {
  1768     Frame* frame = core(mainFrame());
  1705     Frame* frame = core(mainFrame());
  1769     
       
  1770     page()->chrome()->client()->setElementVisibilityChanged(false);
       
  1771     if (!frame || m_isEditable == editable)
  1706     if (!frame || m_isEditable == editable)
  1772         return;
  1707         return;
  1773 
  1708 
  1774     m_isEditable = editable;
  1709     m_isEditable = editable;
  1775 
  1710 
  2047     m_inFindState = false;
  1982     m_inFindState = false;
  2048     delete m_findKeyword;
  1983     delete m_findKeyword;
  2049     m_findKeyword = NULL;
  1984     m_findKeyword = NULL;
  2050     WebFrame* selectedFrame = mainFrame()->findFrameWithSelection();
  1985     WebFrame* selectedFrame = mainFrame()->findFrameWithSelection();
  2051     selectedFrame->clearSelection();
  1986     selectedFrame->clearSelection();
  2052     setFocusNone();
       
  2053 }
  1987 }
  2054 
  1988 
  2055 bool WebView::isSmallPage()
  1989 bool WebView::isSmallPage()
  2056 {
  1990 {
  2057     TSize docSize = DocumentSize();
  1991     TSize docSize = DocumentSize();
  2061 
  1995 
  2062 void WebView::willSubmitForm(FormState* formState)
  1996 void WebView::willSubmitForm(FormState* formState)
  2063 {
  1997 {
  2064     if (m_webFormFill) {
  1998     if (m_webFormFill) {
  2065         m_webFormFill->willSubmitForm(formState);
  1999         m_webFormFill->willSubmitForm(formState);
       
  2000     }
       
  2001 }
       
  2002 
       
  2003 
       
  2004 //-------------------------------------------------------------------------------
       
  2005 // WebView::HandlePointerBufferReadyL
       
  2006 // Handles pointer move events
       
  2007 //-------------------------------------------------------------------------------
       
  2008 void WebView::HandlePointerBufferReadyL()
       
  2009 {
       
  2010     memset(m_ptrbuffer,0,256*sizeof(TPoint));
       
  2011     TPtr8 ptr((TUint8 *)m_ptrbuffer,256*sizeof(TPoint));
       
  2012 
       
  2013     TInt numPnts = Window().RetrievePointerMoveBuffer(ptr);
       
  2014     int i = 0;
       
  2015     if (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeNone) {
       
  2016         if (numPnts > 20)
       
  2017             i = numPnts - 20;
       
  2018     }
       
  2019     for (; i < numPnts; i++) {
       
  2020         TPointerEvent pe;
       
  2021         pe.iType = TPointerEvent::EDrag;
       
  2022         pe.iPosition = m_ptrbuffer[i];
       
  2023         m_webpointerEventHandler->HandlePointerEventL(pe);
  2066     }
  2024     }
  2067 }
  2025 }
  2068 
  2026 
  2069 //-------------------------------------------------------------------------------
  2027 //-------------------------------------------------------------------------------
  2070 // WebView::HandlePointerEventL
  2028 // WebView::HandlePointerEventL
  2417 
  2375 
  2418     view->setContentPos( pt );
  2376     view->setContentPos( pt );
  2419     mainFrame()->scalingFactorChanged(z);
  2377     mainFrame()->scalingFactorChanged(z);
  2420     view->checkScrollbarVisibility();
  2378     view->checkScrollbarVisibility();
  2421 
  2379 
  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    
       
  2441     TRect rect = view->rect();
  2380     TRect rect = view->rect();
  2442 
  2381 
  2443     TInt tlx = (rect.iTl.iX * currZoomLevel) / m_currentZoomLevel;
  2382     TInt tlx = (rect.iTl.iX * currZoomLevel) / m_currentZoomLevel;
  2444     TInt tly = (rect.iTl.iY * currZoomLevel) / m_currentZoomLevel;
  2383     TInt tly = (rect.iTl.iY * currZoomLevel) / m_currentZoomLevel;
  2445     TInt brx = (rect.iBr.iX * currZoomLevel) / m_currentZoomLevel;
  2384     TInt brx = (rect.iBr.iX * currZoomLevel) / m_currentZoomLevel;
  2534     // zoom it
  2473     // zoom it
  2535     m_lastZoomLevel = m_currentZoomLevel;
  2474     m_lastZoomLevel = m_currentZoomLevel;
  2536 
  2475 
  2537     setZoomLevel(zoomLevel);
  2476     setZoomLevel(zoomLevel);
  2538     mainFrame()->notifyPluginsOfScrolling();
  2477     mainFrame()->notifyPluginsOfScrolling();
  2539     
  2478 }
  2540     if (zoomLevel == KZoomLevelDefaultValue)
       
  2541         {
       
  2542         // for pages based on tables this is required
       
  2543         doLayout();
       
  2544         }
       
  2545     
       
  2546  }
       
  2547 
  2479 
  2548 //-------------------------------------------------------------------------------
  2480 //-------------------------------------------------------------------------------
  2549 // WebView::openPluginPlayerL
  2481 // WebView::openPluginPlayerL
  2550 // Called when user clicks a plugin which is able to accept user input,
  2482 // Called when user clicks a plugin which is able to accept user input,
  2551 // this feature is only used in US build
  2483 // this feature is only used in US build
  2597     if (!m_widgetextension) {
  2529     if (!m_widgetextension) {
  2598         m_widgetextension = CWidgetExtension::NewL(*this, aWidgetCallback);
  2530         m_widgetextension = CWidgetExtension::NewL(*this, aWidgetCallback);
  2599 #if USE(LOW_BANDWIDTH_DISPLAY)
  2531 #if USE(LOW_BANDWIDTH_DISPLAY)
  2600         m_page->mainFrame()->loader()->setUseLowBandwidthDisplay(false);
  2532         m_page->mainFrame()->loader()->setUseLowBandwidthDisplay(false);
  2601 #endif
  2533 #endif
  2602     StaticObjectsContainer::instance()->setIconDatabaseEnabled(false);
       
  2603     }
  2534     }
  2604 
  2535 
  2605     //Widgets dont need memory cache for dead objects. hence set it to 0
  2536     //Widgets dont need memory cache for dead objects. hence set it to 0
  2606     cache()->setCapacities(0, 0, 0);
  2537     cache()->setCapacities(0, 0, 0);
  2607     return m_widgetextension;
  2538     return m_widgetextension;
  2953         WebView* that = const_cast<WebView*>(this);
  2884         WebView* that = const_cast<WebView*>(this);
  2954         that->m_widgetextension->windowObjectCleared();
  2885         that->m_widgetextension->windowObjectCleared();
  2955     }
  2886     }
  2956 }
  2887 }
  2957 
  2888 
  2958 void WebView::wait(double t)
       
  2959 {
       
  2960     if (!m_waitTimer) {
       
  2961         m_waitTimer = new WebCore::Timer<WebView>(this, &WebView::waitTimerCB);
       
  2962     }
       
  2963     
       
  2964     if (!m_waitTimer->isActive()) {
       
  2965         m_waitTimer->startOneShot(t);
       
  2966     }
       
  2967     
       
  2968     if (!m_waitTimer->isActive() && !m_waiter->IsStarted()) {
       
  2969         m_waiter->Start();  
       
  2970     }
       
  2971 }
       
  2972 
       
  2973 void WebView::waitTimerCB(WebCore::Timer<WebView>* t)
       
  2974 {
       
  2975     if (m_waiter->IsStarted()) {
       
  2976         m_waiter->AsyncStop();
       
  2977     }
       
  2978 }
       
  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 }
       
  3071 
       
  3072 // END OF FILE
  2889 // END OF FILE