webengine/osswebengine/WebKit/s60/webview/WebPointerEventHandler.cpp
changeset 15 60c5402cb945
parent 11 c8a366e56285
child 25 0ed94ceaa377
equal deleted inserted replaced
11:c8a366e56285 15:60c5402cb945
   146       if (plugin->pluginWin()->HandleGesture(aEvent)) {
   146       if (plugin->pluginWin()->HandleGesture(aEvent)) {
   147           return;
   147           return;
   148       }
   148       }
   149     }
   149     }
   150     updateCursor(aEvent.CurrentPos());
   150     updateCursor(aEvent.CurrentPos());
   151 
   151     if (IS_TABBED_NAVIGATION) {
       
   152         m_webview->tabbedNavigation()->updateCursorPosition(m_highlightPos);
       
   153     }
   152     switch (gtype) {
   154     switch (gtype) {
   153       // sent on touch down
   155       // sent on touch down
   154       case EGestureStart:  
   156       case EGestureStart:  
   155       {
   157       {
   156           if (m_webview->viewIsScrolling()) {
   158           if (m_webview->viewIsScrolling()) {
   193       case EGestureSwipeUp:
   195       case EGestureSwipeUp:
   194       case EGestureSwipeDown:
   196       case EGestureSwipeDown:
   195       {
   197       {
   196           m_ignoreTap = false;
   198           m_ignoreTap = false;
   197           if (!IS_NAVIGATION_NONE) {
   199           if (!IS_NAVIGATION_NONE) {
   198           handleTouchUp(aEvent);      
   200               handleTouchUp(aEvent);
   199           }
   201           }
   200           else {
   202           else {
   201               Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
   203               Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
   202               m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Up, m_highlightPos, frm);
   204               m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Up, m_highlightPos, frm);
   203           }
   205           }
   263     if ( !m_buttonDownTimer.isActive() && !m_webview->inPageViewMode()){
   265     if ( !m_buttonDownTimer.isActive() && !m_webview->inPageViewMode()){
   264         m_buttonDownTimer.startOneShot(0.1f);        
   266         m_buttonDownTimer.startOneShot(0.1f);        
   265     }
   267     }
   266 
   268 
   267     if (!IS_NAVIGATION_NONE) {
   269     if (!IS_NAVIGATION_NONE) {
   268     m_webview->pageScrollHandler()->handleTouchDownGH(aEvent);
   270         m_webview->pageScrollHandler()->handleTouchDownGH(aEvent);
   269     }
   271     }
   270 
   272 
   271     if ( TBrCtlDefs::EElementActivatedObjectBox == elType) {
   273     if ( TBrCtlDefs::EElementActivatedObjectBox == elType) {
   272         PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin();
   274         PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin();
   273         if (plugin && plugin->pluginWin()) {
   275         if (plugin && plugin->pluginWin()) {
   303     m_highlightPos = TPoint(-1,-1);
   305     m_highlightPos = TPoint(-1,-1);
   304     m_highlightedNode = NULL;
   306     m_highlightedNode = NULL;
   305     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
   307     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
   306     pluginHandler->setPluginToActivate(NULL);
   308     pluginHandler->setPluginToActivate(NULL);
   307     if (!IS_NAVIGATION_NONE) {
   309     if (!IS_NAVIGATION_NONE) {
   308     m_webview->pageScrollHandler()->handleTouchUpGH(aEvent);
   310         m_webview->pageScrollHandler()->handleTouchUpGH(aEvent);
   309     }
   311     }
   310 }
   312 }
   311 
   313 
   312 // ======================================================================
   314 // ======================================================================
   313 // WebPointerEventHandler::handleMoveL
   315 // WebPointerEventHandler::handleMoveL
   358             m_webview->GetContainerWindow().EnablePointerMoveBuffer();
   360             m_webview->GetContainerWindow().EnablePointerMoveBuffer();
   359         }
   361         }
   360         else if (aPointerEvent.iType == TPointerEvent::EButton1Up) {
   362         else if (aPointerEvent.iType == TPointerEvent::EButton1Up) {
   361             m_webview->GetContainerWindow().DisablePointerMoveBuffer();
   363             m_webview->GetContainerWindow().DisablePointerMoveBuffer();
   362         }
   364         }
   363 
       
   364         }
       
   365 
       
   366 
       
   367     if (m_webview->brCtl()->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed) {
       
   368         m_webview->tabbedNavigation()->updateCursorPosition(aPointerEvent.iPosition);
       
   369     }
   365     }
   370 
   366 
   371 #ifdef BRDO_USE_GESTURE_HELPER
   367 #ifdef BRDO_USE_GESTURE_HELPER
   372     m_gestureHelper->HandlePointerEventL(aPointerEvent);
   368     m_gestureHelper->HandlePointerEventL(aPointerEvent);
   373 #endif    
   369 #endif    
   410 {
   406 {
   411     TRect elRect;
   407     TRect elRect;
   412     TBrCtlDefs::TBrCtlElementType elType = TBrCtlDefs::EElementNone;
   408     TBrCtlDefs::TBrCtlElementType elType = TBrCtlDefs::EElementNone;
   413     Frame* coreFrame = core(m_webview->mainFrame());
   409     Frame* coreFrame = core(m_webview->mainFrame());
   414     WebCursor* cursor = StaticObjectsContainer::instance()->webCursor();
   410     WebCursor* cursor = StaticObjectsContainer::instance()->webCursor();
   415     m_webview->page()->chrome()->client()->setElementVisibilityChanged(false);
   411     
   416     TPointerEvent event;
   412     TPointerEvent event;
   417     TPoint pos = cursor->position();
   413     TPoint pos = cursor->position();
   418     IntPoint point(pos.iX, pos.iY);   
   414     WebFrame* wfrm = cursor->getFrameAtPoint(pos);
   419     HitTestResult htresult = coreFrame->eventHandler()->hitTestResultAtPoint(point, true);
   415     Frame* frm = core(wfrm);
   420     Node* eventNode = htresult.innerNode();
       
   421     Frame* frm = eventNode->document()->frame();
       
   422     WebFrame* wfrm = kit(frm);
       
   423     TPoint pt(wfrm->frameView()->viewCoordsInFrameCoords(pos));
   416     TPoint pt(wfrm->frameView()->viewCoordsInFrameCoords(pos));
   424     TPoint nodePoint;
   417     TPoint nodePoint;
   425     
   418     
       
   419     Element* eventNode = frm->document()->elementFromPoint(pos.iX, pos.iY);
       
   420     
   426     m_highlightedNode = NULL;
   421     m_highlightedNode = NULL;
   427 
   422 
   428     frm->bridge()->getTypeFromElement(eventNode, elType, elRect);
   423     Node* retNode = 0;
       
   424     frm->bridge()->getTypeFromElement(eventNode, elType, elRect, retNode);
       
   425 
   429     if (elType == TBrCtlDefs::EElementNone) {
   426     if (elType == TBrCtlDefs::EElementNone) {
   430         
       
   431         Node* n = wfrm->getClosestAnchorElement(cursor->position(), pos);
   427         Node* n = wfrm->getClosestAnchorElement(cursor->position(), pos);
   432         if (n) {
   428         if (n) {          
   433             point.setX(pos.iX);
   429             wfrm = cursor->getFrameAtPoint(pos);
   434             point.setY(pos.iY);
   430             frm = core(wfrm);
   435             htresult = coreFrame->eventHandler()->hitTestResultAtPoint(point, true);
   431             eventNode = frm->document()->elementFromPoint(pos.iX, pos.iY);
   436             eventNode = htresult.innerNode();
   432             frm->bridge()->getTypeFromElement(eventNode, elType, elRect, retNode);
   437             frm = eventNode->document()->frame();
       
   438             frm->bridge()->getTypeFromElement(eventNode, elType, elRect);
       
   439             TPoint nodePoint = n->getRect().Rect().Center();
   433             TPoint nodePoint = n->getRect().Rect().Center();
   440             m_offset = (pt.iX- nodePoint.iX)*(pt.iX- nodePoint.iX) +
   434             m_offset = (pt.iX- nodePoint.iX)*(pt.iX- nodePoint.iX) +
   441                        (pt.iY- nodePoint.iY)*(pt.iY- nodePoint.iY);
   435                        (pt.iY- nodePoint.iY)*(pt.iY- nodePoint.iY);
   442             
       
   443             
       
   444         }
   436         }
   445     }
   437     }
   446     m_highlightedNode = eventNode;
   438     m_highlightedNode = eventNode;
   447     if (m_highlightedNode) {
   439     if (m_highlightedNode) {
   448         m_highlightPos = pos;
   440         m_highlightPos = pos;
   491            feedback->InstantFeedback(ETouchFeedbackBasic);
   483            feedback->InstantFeedback(ETouchFeedbackBasic);
   492            }
   484            }
   493     }
   485     }
   494 #endif // BRDO_TOUCH_ENABLED_FF
   486 #endif // BRDO_TOUCH_ENABLED_FF
   495     
   487     
   496 
   488      /*
   497      // We assume that if element visibility has been changed  
   489       * We assume that if element visibility has been changed  
   498      // between "up" and "down" that means that some node event 
   490       * between "up" and "down" that means that some node event 
   499      // listener (onMouseOver etc) handling happened and we don't 
   491       * listener (onMouseOver etc) handling happened and we don't 
   500      // want to send a click (mouse press + mouse release) event.
   492       * want to send a click (mouse press = mouse release) event.
   501      if (!IS_NAVIGATION_NONE && 
   493       * The exception is editable element, since we want VKB anyway
   502          m_webview->page()->chrome()->client()->elementVisibilityChanged()) {
   494       */
       
   495      if (!IS_NAVIGATION_NONE &&
       
   496          elType != TBrCtlDefs::EElementActivatedInputBox && 
       
   497          elType != TBrCtlDefs::EElementTextAreaBox &&     
       
   498          m_webview->page()->chrome()->client()->elementVisibilityChangedByMouse()) {
   503          return;
   499          return;
   504      }
   500      }
   505 
   501 
   506      m_lastTapEvent.iPosition = m_buttonDownEvent.iPosition;
   502      m_lastTapEvent.iPosition = m_buttonDownEvent.iPosition;
   507      m_lastTapEvent.iType = TPointerEvent::EButton1Up;
   503      m_lastTapEvent.iType = TPointerEvent::EButton1Up;
   508      m_lastTapEvent.iModifiers = 0;
   504      m_lastTapEvent.iModifiers = 0;
   509 
   505 
   510     // don't pass the event if the text input is not in valid format
   506     // don't pass the event if the text input is not in valid format
   511     if (isHighlitableElement(elType) || m_webview->fepTextEditor()->validateTextFormat()) {
   507     if (isHighlitableElement(elType) || m_webview->fepTextEditor()->validateTextFormat()) {
   512         // because of scrolling we delay sending EButton1Down till we get EButton1Up event and if the content is not scrolling
   508         m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Up,  m_lastTapEvent.iPosition, coreFrame);
   513         coreFrame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(m_lastTapEvent));
       
   514     }
   509     }
   515 
   510 
   516     // special handling for broken image (why is this here??)
   511     // special handling for broken image (why is this here??)
   517     if (m_webview->focusedElementType() == TBrCtlDefs::EElementBrokenImage) {
   512     if (elType == TBrCtlDefs::EElementBrokenImage) {
   518         loadFocusedImage(m_webview);
   513         loadFocusedImage(m_webview);
   519     }
   514     }
   520     else if (elType == TBrCtlDefs::EElementActivatedObjectBox) {
   515     else if (elType == TBrCtlDefs::EElementActivatedObjectBox) {
   521         PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin();
   516         PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin();
   522         if(plugin && plugin->pluginWin() && plugin->getClipRect().Contains(m_lastTapEvent.iPosition)){
   517         if(plugin && plugin->pluginWin() && plugin->getClipRect().Contains(m_lastTapEvent.iPosition)){
   599     if (!isHighlitableElement(elType)) {
   594     if (!isHighlitableElement(elType)) {
   600         elType = TBrCtlDefs::EElementNone;
   595         elType = TBrCtlDefs::EElementNone;
   601     }
   596     }
   602     m_isHighlighted = (m_highlightedNode != NULL) && (elType != TBrCtlDefs::EElementNone) ;
   597     m_isHighlighted = (m_highlightedNode != NULL) && (elType != TBrCtlDefs::EElementNone) ;
   603     
   598     
       
   599     m_webview->page()->chrome()->client()->setElementVisibilityChanged(false);
       
   600     
       
   601     /*
       
   602      * Tabbed navigation might already set the focused node.
       
   603      * If it's the same as m_highlightedNode FocuseController::setFocusedNode()
       
   604      * wouldn't do anything and setEditable won't be called.
       
   605      * So we are setting focused node to NULL here and let mouse event handler
       
   606      * set it through ocuseController::setFocusedNode()
       
   607      */
       
   608     if (IS_TABBED_NAVIGATION &&
       
   609         elType == TBrCtlDefs::EElementInputBox || 
       
   610         elType == TBrCtlDefs::EElementTextAreaBox) {
       
   611         coreFrame->document()->setFocusedNode(NULL);
       
   612     }
       
   613          
   604     m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Down, m_highlightPos, coreFrame);
   614     m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Down, m_highlightPos, coreFrame);
   605 
   615 
   606     m_webview->sendMouseEventToEngine(TPointerEvent::EMove, m_highlightPos, coreFrame);
   616     m_webview->sendMouseEventToEngine(TPointerEvent::EMove, m_highlightPos, coreFrame);
   607     m_waiter->AsyncStop();
   617     m_waiter->AsyncStop();
   608 }
   618 }