webengine/osswebengine/WebKit/s60/webview/WebPointerEventHandler.cpp
changeset 28 d39add9822e2
parent 27 6297cdf66332
child 34 220a17280356
equal deleted inserted replaced
27:6297cdf66332 28:d39add9822e2
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:   
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <browser_platform_variant.hrh>
    18 #include <browser_platform_variant.hrh>
    19 #include "config.h"
    19 #include "config.h"
    62 #include "RenderStyle.h"
    62 #include "RenderStyle.h"
    63 #include "RenderObject.h"
    63 #include "RenderObject.h"
    64 #include "CSSStyleSelector.h"
    64 #include "CSSStyleSelector.h"
    65 #include "CSSValueKeywords.h"
    65 #include "CSSValueKeywords.h"
    66 #include "Settings.h"
    66 #include "Settings.h"
       
    67 #include "WebGestureInterface.h"
       
    68 #include "WebPagePinchZoomHandler.h"
    67 
    69 
    68 #include "WebKitLogger.h"
    70 #include "WebKitLogger.h"
    69 using namespace WebCore;
    71 using namespace WebCore;
    70 using namespace EventNames;
    72 using namespace EventNames;
    71 using namespace RT_GestureHelper;
       
    72 
    73 
    73 static const int KMinScrollAndTapInterval = 200000;				// 200 ms
    74 static const int KMinScrollAndTapInterval = 200000;				// 200 ms
    74 static const int KDoubleTapMinActivationInterval = 100000;     // 100 ms
    75 static const int KDoubleTapMinActivationInterval = 100000;     // 100 ms
    75 static const int KDoubleTapMaxActivationInterval = 500000;     // 500 ms
    76 static const int KDoubleTapMaxActivationInterval = 500000;     // 500 ms
    76 static const int KDoubleTapIdleInterval = 700000;			// 700 ms, to prevent triple-tap effects
    77 static const int KDoubleTapIdleInterval = 700000;			// 700 ms, to prevent triple-tap effects
    95 WebPointerEventHandler::WebPointerEventHandler(WebView* view)
    96 WebPointerEventHandler::WebPointerEventHandler(WebView* view)
    96     : m_webview(view),
    97     : m_webview(view),
    97       m_isHighlighted(false),
    98       m_isHighlighted(false),
    98       m_highlightedNode(NULL),
    99       m_highlightedNode(NULL),
    99       m_buttonDownTimer( this, &WebPointerEventHandler::buttonDownTimerCB ),
   100       m_buttonDownTimer( this, &WebPointerEventHandler::buttonDownTimerCB ),
   100       m_ignoreTap(false)
   101       m_ignoreTap(false),
       
   102       m_gestureInterface(NULL)
   101 {
   103 {
   102 }
   104 }
   103 
   105 
   104 //-----------------------------------------------------------------------------
   106 //-----------------------------------------------------------------------------
   105 // WebPointerEventHandler::~WebPointerEventHandler
   107 // WebPointerEventHandler::~WebPointerEventHandler
   106 //-----------------------------------------------------------------------------
   108 //-----------------------------------------------------------------------------
   107 WebPointerEventHandler::~WebPointerEventHandler()
   109 WebPointerEventHandler::~WebPointerEventHandler()
   108 {
   110 {
   109     delete m_gestureHelper;
   111    delete m_gestureInterface;
   110     delete m_waiter;
   112     delete m_waiter;
   111 }
   113 }
   112 
   114 
   113 //-----------------------------------------------------------------------------
   115 //-----------------------------------------------------------------------------
   114 // WebPointerEventHandler::ConstructL
   116 // WebPointerEventHandler::ConstructL
   115 //-----------------------------------------------------------------------------
   117 //-----------------------------------------------------------------------------
   116 void WebPointerEventHandler::ConstructL()
   118 void WebPointerEventHandler::ConstructL()
   117 {
   119 {
   118 #ifdef BRDO_USE_GESTURE_HELPER  
   120 #ifdef BRDO_USE_GESTURE_HELPER
   119   m_gestureHelper = CGestureHelper::NewL( *this );
   121   m_gestureInterface = WebGestureInterface::NewL(m_webview);
   120   m_gestureHelper->SetDoubleTapEnabled(true);
       
   121   m_gestureHelper->SetHoldingEnabled(false);
       
   122 #else
   122 #else
   123   m_gestureHelper = NULL;
   123   m_gestureInterface = NULL;
   124 #endif  
   124 #endif
   125   m_waiter = new(ELeave) CActiveSchedulerWait();
   125   m_waiter = new(ELeave) CActiveSchedulerWait();
   126 }
   126 }
   127 /**
   127 
   128  * EGestureStart is sent on touch down
   128 
   129  * EGestureReleased is sent on touch up
   129 // ======================================================================
   130  * EGestureTap = touch down + touch up - events sent: EGestureStart, EGestureTap
   130 // WebPointerEventHandler::HandleGestureEventL
   131  *                EGestureReleased
   131 // ======================================================================
   132  * EGestureDrag = touch down + "move" - events sent: EGestureStart, EGestureDrag
   132 void  WebPointerEventHandler::HandleGestureEventL(const TStmGestureEvent& aGesture)
   133  * EGestureDoubleTap = 2 * (touch down + touch up) - events sent EGestureStart, 
   133 {
   134  *                     EGestureDoubleTap, EGestureReleased
   134     TStmGestureUid uid = aGesture.Code();
   135  * EGestureLongTap = touch down + "long touch" - events sent: EGestureStart, 
   135 
   136  *                   EGestureLongTap
   136     if (m_webview->pinchZoomHandler()->isPinchActive() && uid != stmGesture::EGestureUidPinch)
   137  * EGestureSwipe<Up/Down/Left/Right> - drag + touch up, where movements is
   137         return;
   138  *                   close to particular direction - event sent: EGestureSwipe, 
   138 
   139  *                   EGestureReleased
       
   140  * EGestureFlick - "fast" drag + touch up - events sent: EGestureFlick, 
       
   141  *                  EGestureReleased
       
   142  * EGestureDrop -  drag + touch up, !(EGestureSwipe || EGestureFlick) - events
       
   143  *                 sent: EGestureDrop, EGestureReleased
       
   144  */
       
   145 void WebPointerEventHandler::HandleGestureL( const TGestureEvent& aEvent )
       
   146 {
       
   147     TGestureCode gtype = aEvent.Code(EAxisBoth);
       
   148     
       
   149     TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
   139     TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
   150     
   140 
   151     PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin();
   141     PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin();
   152     if (plugin && plugin->pluginWin()) {
   142     if (plugin && plugin->pluginWin()) {
   153       if (plugin->pluginWin()->HandleGesture(aEvent)) {
   143         if (plugin->pluginWin()->HandleGesture(aGesture)) {
   154          if(!plugin->isActive())
   144          if(!plugin->isActive())
   155             plugin->activate();
   145             plugin->activate();
   156           return;
   146             return;
   157       }
   147         }
   158     }
   148     }
   159     updateCursor(aEvent.CurrentPos());
   149 
       
   150     updateCursor(aGesture.CurrentPos());
   160     if (IS_TABBED_NAVIGATION) {
   151     if (IS_TABBED_NAVIGATION) {
   161         m_webview->tabbedNavigation()->updateCursorPosition(aEvent.CurrentPos());
   152         m_webview->tabbedNavigation()->updateCursorPosition(aGesture.CurrentPos());
   162     }
   153     }
   163     switch (gtype) {
   154 
   164       // sent on touch down
   155 
   165       case EGestureStart:  
   156     switch(uid) {
   166       {
   157         case stmGesture::EGestureUidTouch:
   167           if (m_webview->viewIsScrolling()) {
   158         {
   168               m_ignoreTap = true;
   159             if (m_webview->viewIsScrolling()) {
   169               m_webview->pageScrollHandler()->handleTouchDownGH(aEvent);
   160                 m_ignoreTap = true;
   170           }
   161                 m_webview->pageScrollHandler()->handleTouchDownGH(aGesture);
   171           else {
   162             }
   172               handleTouchDownL(aEvent);   
   163             else {
   173           }
   164                 handleTouchDownL(aGesture);
   174           break;
   165             }
   175       }
   166             break;
   176       
   167         }
   177       // sent on tap
   168 
   178       case EGestureTap:
   169 
   179       {
   170         case stmGesture::EGestureUidTap:
   180           if (!m_ignoreTap) {
   171         {
   181               handleTapL(aEvent);
   172             if (aGesture.Type() == stmGesture::ETapTypeSingle) {
   182           }
   173                 if (!m_ignoreTap) {
   183           break;    
   174                     handleTapL(aGesture);
   184       }
   175                 }
   185       
   176             }
   186       // sent on double tap
   177             else {
   187       case EGestureDoubleTap:
   178                 handleDoubleTap(aGesture);
   188       {
   179             }
   189           handleDoubleTap(aEvent);
   180 
   190           break;    
   181                 break;
   191       }
   182         }
   192       
   183 
   193       // sent on long tap
   184         case stmGesture::EGestureUidRelease:
   194       case EGestureLongTap:
   185         {
   195       {
   186             m_ignoreTap = false;
   196           break;    
   187             handleTouchUp(aGesture);
   197       }
   188             break;
   198 
   189         }
   199       // sent on touch up after drag
   190 
   200       case EGestureDrop:
   191         case stmGesture::EGestureUidPan:
   201       case EGestureFlick:
   192         {
   202       case EGestureSwipeLeft:
   193             handleMove(aGesture);
   203       case EGestureSwipeRight:
   194             break;
   204       case EGestureSwipeUp:
   195         }
   205       case EGestureSwipeDown:
   196         case stmGesture::EGestureUidFlick:
   206       {
   197         {
   207           m_ignoreTap = false;
   198             m_ignoreTap = false;
   208           if (!IS_NAVIGATION_NONE) {
   199             if (!IS_NAVIGATION_NONE) {
   209               handleTouchUp(aEvent);
   200                 handleTouchUp(aGesture);
   210           }
   201             }
   211           else {
   202             else {
   212               Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
   203                 Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
   213               m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Up, m_highlightPos, frm);
   204                 m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Up, m_highlightPos, frm);
   214           }
   205             }
   215           break;    
   206             break;
   216       }
   207         }
   217       // sent on move
   208 
   218       case EGestureDrag:
   209         case stmGesture::EGestureUidPinch:
   219       {
   210         {
   220           handleMove(aEvent);
   211             handlePinchZoomL(aGesture);
   221           break;    
   212             break;
   222       }
   213         }
   223       
   214         default:
   224       // sent on touch up after tap double tap and long tap
   215             break;
   225       case EGestureReleased:
   216 
   226       {
   217     }
   227           m_ignoreTap = false;
   218     return;
   228           handleTouchUp(aEvent);      
       
   229           break;    
       
   230       }
       
   231     }
       
   232 }
   219 }
   233 
   220 
   234 
   221 
   235 // ======================================================================
   222 // ======================================================================
   236 // WebPointerEventHandler::handleTap
   223 // WebPointerEventHandler::handleTap
   237 // ======================================================================
   224 // ======================================================================
   238 void WebPointerEventHandler::handleTapL(const TGestureEvent& aEvent)
   225 void WebPointerEventHandler::handleTapL(const TStmGestureEvent& aGesture)
   239 {
   226 {
   240     m_buttonDownTimer.stop();
   227     m_buttonDownTimer.stop();
   241     m_lastTapEvent = m_currentEvent; 
   228     m_lastTapEvent = m_currentEvent;
   242     if(!m_webview->inPageViewMode()){
   229     if(!m_webview->inPageViewMode()){
   243     	doTapL();
   230     	doTapL();
   244     }
   231     }
   245 }
   232 }
   246 // ======================================================================
   233 // ======================================================================
   247 //  WebPointerEventHandler::handleDoubleTap
   234 //  WebPointerEventHandler::handleDoubleTap
   248 //======================================================================
   235 //======================================================================
   249 void WebPointerEventHandler::handleDoubleTap(const TGestureEvent& aEvent)
   236 void WebPointerEventHandler::handleDoubleTap(const TStmGestureEvent& aGesture)
   250 {
   237 {
   251     if ( !m_webview->viewIsScrolling() &&
   238     if ( !m_webview->viewIsScrolling() &&
   252          (m_webview->brCtl()->capabilities() & TBrCtlDefs::ECapabilityFitToScreen)) {
   239          (m_webview->brCtl()->capabilities() & TBrCtlDefs::ECapabilityFitToScreen)) {
   253         if (m_isHighlighted){
   240         if (m_isHighlighted){
   254             dehighlight();                
   241             dehighlight();
   255         }
   242         }
   256         m_webview->setZoomLevelAdaptively();
   243         m_webview->setZoomLevelAdaptively();
   257     }
   244     }
   258     else {
   245     else {
   259         m_webview->resetLastZoomLevelIfNeeded();
   246         m_webview->resetLastZoomLevelIfNeeded();
   261 }
   248 }
   262 
   249 
   263 // ======================================================================
   250 // ======================================================================
   264 // WebPointerEventHandler::handleTouchDownL
   251 // WebPointerEventHandler::handleTouchDownL
   265 //======================================================================
   252 //======================================================================
   266 void WebPointerEventHandler::handleTouchDownL(const TGestureEvent& aEvent)
   253 void WebPointerEventHandler::handleTouchDownL(const TStmGestureEvent& aGesture)
   267 {
   254 {
   268     TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
   255     TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
   269     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
   256     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
   270     PluginSkin* pluginToActivate = pluginHandler->pluginToActivate();
   257     PluginSkin* pluginToActivate = pluginHandler->pluginToActivate();
   271     m_buttonDownEvent = m_currentEvent;
   258     m_buttonDownEvent = m_currentEvent;
   272     m_highlightPos = aEvent.CurrentPos();    
   259     m_highlightPos = aGesture.CurrentPos();
   273     
   260 
   274     if ( !m_buttonDownTimer.isActive() && !m_webview->inPageViewMode()){
   261     if ( !m_buttonDownTimer.isActive() && !m_webview->inPageViewMode()){
   275         m_buttonDownTimer.startOneShot(0.1f);        
   262         m_buttonDownTimer.startOneShot(0.1f);
   276     }
   263     }
   277 
   264 
   278     if (!IS_NAVIGATION_NONE) {
   265     if (!IS_NAVIGATION_NONE) {
   279         m_webview->pageScrollHandler()->handleTouchDownGH(aEvent);
   266         m_webview->pageScrollHandler()->handleTouchDownGH(aGesture);
   280     }
   267     }
   281 
   268 
   282     if ( TBrCtlDefs::EElementActivatedObjectBox == elType) {
   269     if ( TBrCtlDefs::EElementActivatedObjectBox == elType) {
   283         PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin();
   270         PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin();
   284         if (plugin && plugin->pluginWin()) {
   271         if (plugin && plugin->pluginWin()) {
   288             else {
   275             else {
   289                 plugin->pluginWin()->HandlePointerEventL(m_buttonDownEvent);
   276                 plugin->pluginWin()->HandlePointerEventL(m_buttonDownEvent);
   290             }
   277             }
   291         }
   278         }
   292     }
   279     }
   293     
   280 
   294     /*
   281     /*
   295      * After introducing "link selection" pointer down action is done in 
   282      * After introducing "link selection" pointer down action is done in
   296      * buttondown timer callback. When "down" gesture event is arrived we start 
   283      * buttondown timer callback. When "down" gesture event is arrived we start
   297      * timer end exit, so gesture helper is ready to deliver next gesture event. 
   284      * timer end exit, so gesture helper is ready to deliver next gesture event.
   298      * Meanwhile the processing of the first gesture event hasn't been finished yet. 
   285      * Meanwhile the processing of the first gesture event hasn't been finished yet.
   299      * The gesture helper doesn't "know" about our plans to handle the event inside 
   286      * The gesture helper doesn't "know" about our plans to handle the event inside
   300      * timer callback and only way for us to "tell" about this is to stop RunL() 
   287      * timer callback and only way for us to "tell" about this is to stop RunL()
   301      * of CGestureEventSender (HandleGestureL() is inside it) and finish buttondown 
   288      * of CGestureEventSender (HandleGestureL() is inside it) and finish buttondown
   302      * timer callback first.  
   289      * timer callback first.
   303      */    
   290      */
   304     if ( m_buttonDownTimer.isActive()){
   291     if ( m_buttonDownTimer.isActive()){
   305         m_waiter->Start();	
   292         m_waiter->Start();
   306     }
   293     }
   307 }
   294 }
   308 
   295 
   309 // ======================================================================
   296 // ======================================================================
   310 // WebPointerEventHandler::handleTouchUp 
   297 // WebPointerEventHandler::handleTouchUp
   311 // ======================================================================
   298 // ======================================================================
   312 void WebPointerEventHandler::handleTouchUp(const TGestureEvent& aEvent)
   299 void WebPointerEventHandler::handleTouchUp(const TStmGestureEvent& aGesture)
   313 {
   300 {
   314     m_highlightPos = TPoint(-1,-1);
   301     m_highlightPos = TPoint(-1,-1);
   315     m_highlightedNode = NULL;
   302     m_highlightedNode = NULL;
   316     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
   303     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
   317     pluginHandler->setPluginToActivate(NULL);
   304     pluginHandler->setPluginToActivate(NULL);
   318     if (!IS_NAVIGATION_NONE) {
   305     if (!IS_NAVIGATION_NONE) {
   319         m_webview->pageScrollHandler()->handleTouchUpGH(aEvent);
   306         m_webview->pageScrollHandler()->handleTouchUpGH(aGesture);
   320     }
   307     }
   321 }
   308 }
   322 
   309 
   323 // ======================================================================
   310 // ======================================================================
   324 // WebPointerEventHandler::handleMoveL
   311 // WebPointerEventHandler::handleMoveL
   325 // ======================================================================
   312 // ======================================================================
   326 void WebPointerEventHandler::handleMove(const TGestureEvent& aEvent)
   313 void WebPointerEventHandler::handleMove(const TStmGestureEvent& aGesture)
   327 {
   314 {
   328     TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
   315     TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
   329     TPoint curPos = aEvent.CurrentPos();
   316     TPoint curPos =  aGesture.CurrentPos();
   330     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
   317     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
   331     pluginHandler->setPluginToActivate(NULL);
   318     pluginHandler->setPluginToActivate(NULL);
   332     m_buttonDownTimer.stop();
   319     m_buttonDownTimer.stop();
   333     if (IS_NAVIGATION_NONE) {
   320     if (IS_NAVIGATION_NONE) {
   334         Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
   321         Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
   335         m_webview->sendMouseEventToEngine(TPointerEvent::EMove, curPos, frm);
   322         m_webview->sendMouseEventToEngine(TPointerEvent::EMove, curPos, frm);
   336     }
   323     }
   337     else {
   324     else {
   338     HandleHighlightChange(curPos);
   325     HandleHighlightChange(curPos);
   339     
   326 
   340     m_webview->pageScrollHandler()->handleScrollingGH(aEvent);
   327     m_webview->pageScrollHandler()->handleScrollingGH(aGesture);
   341     }
   328     }
   342 }
   329 }
   343 
   330 
   344 
   331 
   345 // ======================================================================
   332 // ======================================================================
   346 // WebPointerEventHandler::HandlePointerEventL
   333 // WebPointerEventHandler::HandlePointerEventL
   347 // ======================================================================
   334 // ======================================================================
   348 void WebPointerEventHandler::HandlePointerEventL(const TPointerEvent& aPointerEvent)
   335 void WebPointerEventHandler::HandlePointerEventL(const TPointerEvent& aPointerEvent)
   349 {
   336 {
   350     m_currentEvent = aPointerEvent;
   337     m_currentEvent = aPointerEvent;
   351     
   338 
   352     if (m_webview->isSynchRequestPending()) { 
   339     if (m_webview->isSynchRequestPending()) {
   353        return;
   340        return;
   354     }
   341     }
   355     
   342 
   356     // Handle graphical history - should never happen, as HistoryView handles this event by itself
   343     // Handle graphical history - should never happen, as HistoryView handles this event by itself
   357     if ( m_webview->brCtl()->historyHandler()->historyController()->historyView()) {
   344     if ( m_webview->brCtl()->historyHandler()->historyController()->historyView()) {
   358         return;
   345         return;
   359     }
   346     }
   360 
   347 
   361     // Handle FormFill popup
   348     // Handle FormFill popup
   362     if (m_webview->formFillPopup() && m_webview->formFillPopup()->IsVisible()) {
   349     if (m_webview->formFillPopup() && m_webview->formFillPopup()->IsVisible()) {
   363         m_webview->formFillPopup()->HandlePointerEventL(aPointerEvent);
   350         m_webview->formFillPopup()->HandlePointerEventL(aPointerEvent);
   364         return;
   351         return;
   365     }
   352     }
   366     
       
   367     if (!m_webview->inPageViewMode()) {
       
   368         if (aPointerEvent.iType == TPointerEvent::EButton1Down) {
       
   369             m_webview->GetContainerWindow().EnablePointerMoveBuffer();
       
   370         }
       
   371         else if (aPointerEvent.iType == TPointerEvent::EButton1Up) {
       
   372             m_webview->GetContainerWindow().DisablePointerMoveBuffer();
       
   373         }
       
   374     }
       
   375 
   353 
   376 #ifdef BRDO_USE_GESTURE_HELPER
   354 #ifdef BRDO_USE_GESTURE_HELPER
   377     m_gestureHelper->HandlePointerEventL(aPointerEvent);
   355       m_gestureInterface->HandlePointerEventL(aPointerEvent);
   378 #endif    
   356 #endif
   379 }
   357 }
   380 
   358 
   381 //-----------------------------------------------------------------------------
   359 //-----------------------------------------------------------------------------
   382 // WebPointerEventHandler::HandleHighlightChange
   360 // WebPointerEventHandler::HandleHighlightChange
   383 //-----------------------------------------------------------------------------
   361 //-----------------------------------------------------------------------------
   415 {
   393 {
   416     TRect elRect;
   394     TRect elRect;
   417     TBrCtlDefs::TBrCtlElementType elType = TBrCtlDefs::EElementNone;
   395     TBrCtlDefs::TBrCtlElementType elType = TBrCtlDefs::EElementNone;
   418     Frame* coreFrame = core(m_webview->mainFrame());
   396     Frame* coreFrame = core(m_webview->mainFrame());
   419     WebCursor* cursor = StaticObjectsContainer::instance()->webCursor();
   397     WebCursor* cursor = StaticObjectsContainer::instance()->webCursor();
   420     
   398 
   421     TPointerEvent event;
   399     TPointerEvent event;
   422     TPoint pos = cursor->position();
   400     TPoint pos = cursor->position();
   423     WebFrame* wfrm = cursor->getFrameAtPoint(pos);
   401     WebFrame* wfrm = cursor->getFrameAtPoint(pos);
   424     Frame* frm = core(wfrm);
   402     Frame* frm = core(wfrm);
   425     TPoint pt(wfrm->frameView()->viewCoordsInFrameCoords(pos));
   403     TPoint pt(wfrm->frameView()->viewCoordsInFrameCoords(pos));
   426     TPoint nodePoint;
   404     TPoint nodePoint;
   427     
   405 
   428     Element* eventNode = frm->document()->elementFromPoint(pt.iX, pt.iY);
   406     Element* eventNode = frm->document()->elementFromPoint(pt.iX, pt.iY);
   429     
   407 
   430     if (m_isHighlighted){
   408     if (m_isHighlighted){
   431                dehighlight();                
   409                dehighlight();
   432            }
   410            }
   433     
   411 
   434     m_highlightedNode = NULL;
   412     m_highlightedNode = NULL;
   435 
   413 
   436     Node* retNode = 0;
   414     Node* retNode = 0;
   437     frm->bridge()->getTypeFromElement(eventNode, elType, elRect, retNode);
   415     frm->bridge()->getTypeFromElement(eventNode, elType, elRect, retNode);
   438 
   416 
   439     if (elType == TBrCtlDefs::EElementNone) {
   417     if (elType == TBrCtlDefs::EElementNone) {
   440         Node* n = wfrm->getClosestAnchorElement(cursor->position(), pos);
   418         Node* n = wfrm->getClosestAnchorElement(cursor->position(), pos);
   441         if (n) {          
   419         if (n) {
   442             wfrm = cursor->getFrameAtPoint(pos);
   420             wfrm = cursor->getFrameAtPoint(pos);
   443             frm = core(wfrm);
   421             frm = core(wfrm);
   444             eventNode = frm->document()->elementFromPoint(pos.iX, pos.iY);
   422             //eventNode = frm->document()->elementFromPoint(pos.iX, pos.iY);
       
   423             TPoint newPos(wfrm->frameView()->viewCoordsInFrameCoords(pos));
       
   424             eventNode = frm->document()->elementFromPoint(newPos.iX, newPos.iY);
   445             frm->bridge()->getTypeFromElement(eventNode, elType, elRect, retNode);
   425             frm->bridge()->getTypeFromElement(eventNode, elType, elRect, retNode);
   446             TPoint nodePoint = n->getRect().Rect().Center();
   426             TPoint nodePoint = n->getRect().Rect().Center();
   447             m_offset = (pt.iX- nodePoint.iX)*(pt.iX- nodePoint.iX) +
   427             m_offset = (pt.iX- nodePoint.iX)*(pt.iX- nodePoint.iX) +
   448                        (pt.iY- nodePoint.iY)*(pt.iY- nodePoint.iY);
   428                        (pt.iY- nodePoint.iY)*(pt.iY- nodePoint.iY);
   449         }
   429         }
   484 //-----------------------------------------------------------------------------
   464 //-----------------------------------------------------------------------------
   485 void WebPointerEventHandler::doTapL()
   465 void WebPointerEventHandler::doTapL()
   486 {
   466 {
   487     TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
   467     TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
   488     Frame* coreFrame = core(m_webview->mainFrame());
   468     Frame* coreFrame = core(m_webview->mainFrame());
   489     
   469 
   490 #ifdef BRDO_TOUCH_ENABLED_FF
   470 #ifdef BRDO_TOUCH_ENABLED_FF
   491     if (m_isHighlighted)
   471     if (m_isHighlighted)
   492     {
   472     {
   493         MTouchFeedback* feedback = MTouchFeedback::Instance();
   473         MTouchFeedback* feedback = MTouchFeedback::Instance();
   494         if (feedback)
   474         if (feedback)
   495            {
   475            {
   496            feedback->InstantFeedback(ETouchFeedbackBasic);
   476            feedback->InstantFeedback(ETouchFeedbackBasic);
   497            }
   477            }
   498     }
   478     }
   499 #endif // BRDO_TOUCH_ENABLED_FF
   479 #endif // BRDO_TOUCH_ENABLED_FF
   500      
   480 
   501     if (!IS_NAVIGATION_NONE) {
   481     if (!IS_NAVIGATION_NONE) {
   502          m_webview->sendMouseEventToEngine(TPointerEvent::EMove, m_highlightPos, coreFrame);
   482          m_webview->sendMouseEventToEngine(TPointerEvent::EMove, m_highlightPos, coreFrame);
   503      }
   483      }
   504      
   484 
   505      /*
   485      /*
   506       * We assume that if element visibility has been changed  
   486       * We assume that if element visibility has been changed
   507       * between "up" and "down" that means that some node event 
   487       * between "up" and "down" that means that some node event
   508       * listener (onMouseOver etc) handling happened and we don't 
   488       * listener (onMouseOver etc) handling happened and we don't
   509       * want to send a click (mouse press + mouse release) event.
   489       * want to send a click (mouse press + mouse release) event.
   510       * The exception is editable element, since we want VKB anyway
   490       * The exception is editable element, since we want VKB anyway
   511       */
   491       */
   512      if (!IS_NAVIGATION_NONE &&
   492      if (!IS_NAVIGATION_NONE &&
   513          elType != TBrCtlDefs::EElementActivatedInputBox && 
   493          elType != TBrCtlDefs::EElementActivatedInputBox &&
   514          elType != TBrCtlDefs::EElementTextAreaBox &&     
   494          elType != TBrCtlDefs::EElementTextAreaBox &&
   515          m_webview->page()->chrome()->client()->elementVisibilityChangedByMouse()) {
   495          m_webview->page()->chrome()->client()->elementVisibilityChangedByMouse()) {
   516          return;
   496          return;
   517      }
   497      }
   518      
   498 
   519      m_lastTapEvent.iPosition = m_buttonDownEvent.iPosition;
   499      m_lastTapEvent.iPosition = m_buttonDownEvent.iPosition;
   520      m_lastTapEvent.iType = TPointerEvent::EButton1Up;
   500      m_lastTapEvent.iType = TPointerEvent::EButton1Up;
   521      m_lastTapEvent.iModifiers = 0;
   501      m_lastTapEvent.iModifiers = 0;
   522 
   502 
   523     // don't pass the event if the text input is not in valid format
   503     // don't pass the event if the text input is not in valid format
   556     m_isHighlighted = EFalse;
   536     m_isHighlighted = EFalse;
   557 
   537 
   558     Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
   538     Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
   559     m_webview->sendMouseEventToEngine(TPointerEvent::EMove, m_highlightPos, frm);
   539     m_webview->sendMouseEventToEngine(TPointerEvent::EMove, m_highlightPos, frm);
   560 
   540 
   561     
   541 
   562     m_highlightedNode = NULL;
   542     m_highlightedNode = NULL;
   563        
   543 
   564     m_webview->syncRepaint();   
   544     m_webview->syncRepaint();
   565 }
   545 }
   566 
   546 
   567 
   547 
   568 //-----------------------------------------------------------------------------
   548 //-----------------------------------------------------------------------------
   569 // WebPointerEventHandler::canDehighlight
   549 // WebPointerEventHandler::canDehighlight
   603 // WebPointerEventHandler::buttonDownTimerCallback
   583 // WebPointerEventHandler::buttonDownTimerCallback
   604 //-----------------------------------------------------------------------------
   584 //-----------------------------------------------------------------------------
   605 void WebPointerEventHandler::buttonDownTimerCB(Timer<WebPointerEventHandler>* t)
   585 void WebPointerEventHandler::buttonDownTimerCB(Timer<WebPointerEventHandler>* t)
   606 {
   586 {
   607     m_buttonDownTimer.stop();
   587     m_buttonDownTimer.stop();
   608     
   588 
   609     Frame* coreFrame = core(m_webview->mainFrame());
   589     Frame* coreFrame = core(m_webview->mainFrame());
   610     TPointerEvent event;
   590     TPointerEvent event;
   611     
   591 
   612     TBrCtlDefs::TBrCtlElementType elType = highlitableElement();
   592     TBrCtlDefs::TBrCtlElementType elType = highlitableElement();
   613     
   593 
   614     if (!isHighlitableElement(elType)) {
   594     if (!isHighlitableElement(elType)) {
   615         elType = TBrCtlDefs::EElementNone;
   595         elType = TBrCtlDefs::EElementNone;
   616     }
   596     }
   617     m_isHighlighted = (m_highlightedNode != NULL) && (elType != TBrCtlDefs::EElementNone) ;
   597     m_isHighlighted = (m_highlightedNode != NULL) && (elType != TBrCtlDefs::EElementNone) ;
   618     
   598 
   619     /*
   599     /*
   620      * Tabbed navigation might already set the focused node.
   600      * Tabbed navigation might already set the focused node.
   621      * If it's the same as m_highlightedNode FocuseController::setFocusedNode()
   601      * If it's the same as m_highlightedNode FocuseController::setFocusedNode()
   622      * wouldn't do anything and setEditable won't be called.
   602      * wouldn't do anything and setEditable won't be called.
   623      * So we are setting focused node to NULL here and let mouse event handler
   603      * So we are setting focused node to NULL here and let mouse event handler
   624      * set it through FocuseController::setFocusedNode()
   604      * set it through FocuseController::setFocusedNode()
   625      */
   605      */
   626     if (IS_TABBED_NAVIGATION &&
   606     if (IS_TABBED_NAVIGATION &&
   627         elType == TBrCtlDefs::EElementInputBox || 
   607         elType == TBrCtlDefs::EElementInputBox ||
   628         elType == TBrCtlDefs::EElementTextAreaBox) {
   608         elType == TBrCtlDefs::EElementTextAreaBox) {
   629         coreFrame->document()->setFocusedNode(NULL);
   609         coreFrame->document()->setFocusedNode(NULL);
   630     }
   610     }
   631          
   611 
   632     if (!IS_NAVIGATION_NONE) {
   612     if (!IS_NAVIGATION_NONE) {
   633         m_webview->page()->chrome()->client()->setElementVisibilityChanged(false);
   613         m_webview->page()->chrome()->client()->setElementVisibilityChanged(false);
   634         //to initiate hover 
   614         //to initiate hover
   635         if (m_isHighlighted) {
   615         if (m_isHighlighted) {
   636             setFocusRing();
   616             setFocusRing();
   637         }
   617         }
   638         
   618 
   639     }
   619     }
   640     else {
   620     else {
   641         m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Down, m_highlightPos, coreFrame);
   621         m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Down, m_highlightPos, coreFrame);
   642     }
   622     }
   643     
   623 
   644     if (m_waiter->IsStarted()) {    
   624     if (m_waiter->IsStarted()) {
   645         m_waiter->AsyncStop();
   625         m_waiter->AsyncStop();
   646     }
   626     }
   647 }
   627 }
   648 
   628 
   649 
   629 
   658             cursor->setPosition(pos);
   638             cursor->setPosition(pos);
   659         }
   639         }
   660         if (m_webview->showCursor()) {
   640         if (m_webview->showCursor()) {
   661             cursor->resetTransparency();
   641             cursor->resetTransparency();
   662             m_webview->setShowCursor(false);
   642             m_webview->setShowCursor(false);
   663             cursor->cursorUpdate(false); 
   643             cursor->cursorUpdate(false);
   664         }
   644         }
   665     }
   645     }
   666 }
   646 }
   667 
   647 
   668 //-----------------------------------------------------------------------------
   648 //-----------------------------------------------------------------------------
   673     Element* e = static_cast<Element*>(m_highlightedNode);
   653     Element* e = static_cast<Element*>(m_highlightedNode);
   674     RenderStyle* rs = e->renderStyle();
   654     RenderStyle* rs = e->renderStyle();
   675     RenderStyle* style = new (e->document()->renderArena()) RenderStyle(*rs);
   655     RenderStyle* style = new (e->document()->renderArena()) RenderStyle(*rs);
   676     Color col(0xffaaaaff);
   656     Color col(0xffaaaaff);
   677 
   657 
   678     style->ref();   
   658     style->ref();
   679     style->setOutlineColor(col);
   659     style->setOutlineColor(col);
   680     style->setOutlineStyle(DOTTED, true);
   660     style->setOutlineStyle(DOTTED, true);
   681     style->setOutlineWidth(4);
   661     style->setOutlineWidth(4);
   682     style->setOutlineOffset(2);
   662     style->setOutlineOffset(2);
   683     e->setRenderStyle(style);
   663     e->setRenderStyle(style);
   684     style->deref(e->document()->renderArena());
   664     style->deref(e->document()->renderArena());
   685     e->setChanged();
   665     e->setChanged();
   686 }
   666 }
       
   667 
       
   668 //-----------------------------------------------------------------------------
       
   669 // WebPointerEventHandler::handlePinchZoom
       
   670 //----------------------------------------------------------------------------
       
   671 void  WebPointerEventHandler::handlePinchZoomL(const TStmGestureEvent& aGesture)
       
   672 {
       
   673  //dehighlight anything which is highlighted already
       
   674     if (m_isHighlighted){
       
   675         dehighlight();
       
   676     }
       
   677     m_webview->pinchZoomHandler()->handlePinchGestureEventL(aGesture);
       
   678 }