webengine/osswebengine/WebKit/s60/webview/WebPointerEventHandler.cpp
branchRCL_3
changeset 36 c711bdda59f4
parent 35 1f3c3f2f5b0a
child 37 ac77f89b1d9e
equal deleted inserted replaced
35:1f3c3f2f5b0a 36:c711bdda59f4
    42 #include "Frame.h"
    42 #include "Frame.h"
    43 #include "FrameView.h"
    43 #include "FrameView.h"
    44 #include "EventHandler.h"
    44 #include "EventHandler.h"
    45 #include "EventNames.h"
    45 #include "EventNames.h"
    46 #include "HitTestResult.h"
    46 #include "HitTestResult.h"
    47 #include "HitTestRequest.h"
       
    48 #include "MouseEvent.h"
    47 #include "MouseEvent.h"
    49 #include "WebPageFullScreenHandler.h"
    48 #include "WebPageFullScreenHandler.h"
    50 #include "PluginSkin.h"
    49 #include "PluginSkin.h"
    51 #include "PluginWin.h"
    50 #include "PluginWin.h"
    52 #include "WebFrameBridge.h"
    51 #include "WebFrameBridge.h"
    55 #include "ChromeClient.h"
    54 #include "ChromeClient.h"
    56 #include "FocusController.h"
    55 #include "FocusController.h"
    57 #include "WebTabbedNavigation.h"
    56 #include "WebTabbedNavigation.h"
    58 #include "SettingsContainer.h"
    57 #include "SettingsContainer.h"
    59 #include "PluginHandler.h"
    58 #include "PluginHandler.h"
    60 #include "WebCoreGraphicsContext.h"
       
    61 #include "GraphicsContext.h"
       
    62 #include "RenderStyle.h"
       
    63 #include "RenderObject.h"
       
    64 #include "CSSStyleSelector.h"
       
    65 #include "CSSValueKeywords.h"
       
    66 #include "Settings.h"
       
    67 #include "WebGestureInterface.h"
    59 #include "WebGestureInterface.h"
    68 #include "WebPagePinchZoomHandler.h"
    60 #include "WebPagePinchZoomHandler.h"
    69 #include "WebScrollingDeceleratorGH.h"
    61 #include "WebScrollingDeceleratorGH.h"
    70 
    62 
    71 #include "WebKitLogger.h"
    63 #include "WebKitLogger.h"
   140     TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
   132     TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
   141 
   133 
   142     PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin();
   134     PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin();
   143     if (plugin && plugin->pluginWin()) {
   135     if (plugin && plugin->pluginWin()) {
   144         if (plugin->pluginWin()->HandleGesture(aGesture)) {
   136         if (plugin->pluginWin()->HandleGesture(aGesture)) {
   145          if(!plugin->isActive())
   137          if(!plugin->isActive()) {
   146             plugin->activate();
   138             plugin->activate();
   147             return;
   139          }
       
   140          else {
       
   141             m_webview->mainFrame()->frameView()->topView()->setFocusedElementType(TBrCtlDefs::EElementActivatedObjectBox);
       
   142             m_webview->page()->focusController()->setFocusedNode(plugin->getElement(), m_webview->page()->focusController()->focusedOrMainFrame());                        
       
   143             m_webview->brCtl()->updateDefaultSoftkeys();
       
   144          }
       
   145          return;
   148         }
   146         }
   149     }
   147     }
   150 
   148 
   151     updateCursor(aGesture.CurrentPos());
   149     updateCursor(aGesture.CurrentPos());
   152     if (IS_TABBED_NAVIGATION) {
   150     if (IS_TABBED_NAVIGATION) {
   207             break;
   205             break;
   208         }
   206         }
   209 
   207 
   210         case stmGesture::EGestureUidPinch:
   208         case stmGesture::EGestureUidPinch:
   211         {
   209         {
       
   210         if(!m_webview->inPageViewMode())
       
   211             {
   212             handlePinchZoomL(aGesture);
   212             handlePinchZoomL(aGesture);
       
   213             }
   213             break;
   214             break;
   214         }
   215         }
   215         default:
   216         default:
   216             break;
   217             break;
   217 
   218 
   412     Frame* frm = core(wfrm);
   413     Frame* frm = core(wfrm);
   413     TPoint pt(wfrm->frameView()->viewCoordsInFrameCoords(pos));
   414     TPoint pt(wfrm->frameView()->viewCoordsInFrameCoords(pos));
   414     TPoint nodePoint;
   415     TPoint nodePoint;
   415 
   416 
   416     Element* eventNode = frm->document()->elementFromPoint(pt.iX, pt.iY);
   417     Element* eventNode = frm->document()->elementFromPoint(pt.iX, pt.iY);
   417 
       
   418     if (m_isHighlighted){
       
   419         dehighlight(pos);
       
   420     }
       
   421 
   418 
   422     m_highlightedNode = NULL;
   419     m_highlightedNode = NULL;
   423 
   420 
   424     Node* retNode = 0;
   421     Node* retNode = 0;
   425     frm->bridge()->getTypeFromElement(eventNode, elType, elRect, retNode);
   422     frm->bridge()->getTypeFromElement(eventNode, elType, elRect, retNode);
   485            {
   482            {
   486            feedback->InstantFeedback(ETouchFeedbackBasic);
   483            feedback->InstantFeedback(ETouchFeedbackBasic);
   487            }
   484            }
   488     }
   485     }
   489 #endif // BRDO_TOUCH_ENABLED_FF
   486 #endif // BRDO_TOUCH_ENABLED_FF
   490 
   487     
   491     if (!IS_NAVIGATION_NONE) {
       
   492          m_webview->sendMouseEventToEngine(TPointerEvent::EMove, m_highlightPos, coreFrame);
       
   493      }
       
   494 
       
   495      /*
   488      /*
   496       * We assume that if element visibility has been changed
   489       * We assume that if element visibility has been changed
   497       * between "up" and "down" that means that some node event
   490       * between "up" and "down" that means that some node event
   498       * listener (onMouseOver etc) handling happened and we don't
   491       * listener (onMouseOver etc) handling happened and we don't
   499       * want to send a click (mouse press + mouse release) event.
   492       * want to send a click (mouse press + mouse release) event.
   536 
   529 
   537 
   530 
   538 //-----------------------------------------------------------------------------
   531 //-----------------------------------------------------------------------------
   539 // WebPointerEventHandler::deHighlight
   532 // WebPointerEventHandler::deHighlight
   540 //-----------------------------------------------------------------------------
   533 //-----------------------------------------------------------------------------
   541 void  WebPointerEventHandler::dehighlight(const TPoint &aPoint)
   534 void  WebPointerEventHandler::dehighlight()
   542 {
   535 {
   543     // m_highlightPos should be (-1, -1). 
   536     // send dehighlight event to engine by passing -1, -1
       
   537     // sending any other pointer value may result in highligh of other links
   544     m_highlightPos = TPoint(-1, -1);
   538     m_highlightPos = TPoint(-1, -1);
   545     m_isHighlighted = EFalse;
   539     m_isHighlighted = EFalse;
   546 
   540 
   547     Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
   541     Frame* frm = m_webview->page()->focusController()->focusedOrMainFrame();
   548     m_webview->sendMouseEventToEngine(TPointerEvent::EMove, aPoint, frm);
   542     m_webview->sendMouseEventToEngine(TPointerEvent::EMove, m_highlightPos, frm);
   549 
       
   550 
   543 
   551     m_highlightedNode = NULL;
   544     m_highlightedNode = NULL;
   552 
   545 
   553     m_webview->syncRepaint();
   546     m_webview->syncRepaint();
   554 }
   547 }
   595 {
   588 {
   596     m_buttonDownTimer.stop();
   589     m_buttonDownTimer.stop();
   597 
   590 
   598     Frame* coreFrame = core(m_webview->mainFrame());
   591     Frame* coreFrame = core(m_webview->mainFrame());
   599     TPointerEvent event;
   592     TPointerEvent event;
   600 
       
   601     if (!IS_NAVIGATION_NONE) {
       
   602         m_webview->page()->chrome()->client()->setElementVisibilityChanged(false);
       
   603     }
       
   604     
   593     
   605     TBrCtlDefs::TBrCtlElementType elType = highlitableElement();
   594     TBrCtlDefs::TBrCtlElementType elType = highlitableElement();
   606 
   595 
   607     if (!isHighlitableElement(elType)) {
   596     if (!isHighlitableElement(elType)) {
   608         elType = TBrCtlDefs::EElementNone;
   597         elType = TBrCtlDefs::EElementNone;
   609     }
   598     }
   610     m_isHighlighted = (m_highlightedNode != NULL) && (elType != TBrCtlDefs::EElementNone) ;
   599     m_isHighlighted = (m_highlightedNode != NULL) && (elType != TBrCtlDefs::EElementNone) ;
   611 
   600     m_webview->page()->chrome()->client()->setElementVisibilityChanged(false);
       
   601     
   612     /*
   602     /*
   613      * Tabbed navigation might already set the focused node.
   603      * Tabbed navigation might already set the focused node.
   614      * If it's the same as m_highlightedNode FocuseController::setFocusedNode()
   604      * If it's the same as m_highlightedNode FocuseController::setFocusedNode()
   615      * wouldn't do anything and setEditable won't be called.
   605      * wouldn't do anything and setEditable won't be called.
   616      * So we are setting focused node to NULL here and let mouse event handler
   606      * So we are setting focused node to NULL here and let mouse event handler
   621         elType == TBrCtlDefs::EElementTextAreaBox) {
   611         elType == TBrCtlDefs::EElementTextAreaBox) {
   622         coreFrame->document()->setFocusedNode(NULL);
   612         coreFrame->document()->setFocusedNode(NULL);
   623     }
   613     }
   624 
   614 
   625     if (!IS_NAVIGATION_NONE) {
   615     if (!IS_NAVIGATION_NONE) {
   626         //to initiate hover
   616 		m_webview->sendMouseEventToEngine(TPointerEvent::EMove, m_highlightPos, coreFrame);
   627         if (m_isHighlighted) {
   617     } 
   628             setFocusRing();
       
   629         }
       
   630 
       
   631     }
       
   632     else {
   618     else {
   633         m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Down, m_highlightPos, coreFrame);
   619         m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Down, m_highlightPos, coreFrame);
   634     }
   620     }
   635 
   621 
   636     if (m_waiter->IsStarted()) {
   622     if (m_waiter->IsStarted()) {
   655             cursor->cursorUpdate(false);
   641             cursor->cursorUpdate(false);
   656         }
   642         }
   657     }
   643     }
   658 }
   644 }
   659 
   645 
   660 //-----------------------------------------------------------------------------
       
   661 // WebPointerEventHandler::setFocusRing
       
   662 //----------------------------------------------------------------------------
       
   663 void WebPointerEventHandler::setFocusRing()
       
   664 {
       
   665     Element* e = static_cast<Element*>(m_highlightedNode);
       
   666     RenderStyle* rs = e->renderStyle();
       
   667     RenderStyle* style = new (e->document()->renderArena()) RenderStyle(*rs);
       
   668     Color col(0xffaaaaff);
       
   669 
       
   670     style->ref();
       
   671     style->setOutlineColor(col);
       
   672     style->setOutlineStyle(DOTTED, true);
       
   673     style->setOutlineWidth(4);
       
   674     style->setOutlineOffset(2);
       
   675     e->setRenderStyle(style);
       
   676     style->deref(e->document()->renderArena());
       
   677     e->setChanged();
       
   678 }
       
   679 
   646 
   680 //-----------------------------------------------------------------------------
   647 //-----------------------------------------------------------------------------
   681 // WebPointerEventHandler::handlePinchZoom
   648 // WebPointerEventHandler::handlePinchZoom
   682 //----------------------------------------------------------------------------
   649 //----------------------------------------------------------------------------
   683 void  WebPointerEventHandler::handlePinchZoomL(const TStmGestureEvent& aGesture)
   650 void  WebPointerEventHandler::handlePinchZoomL(const TStmGestureEvent& aGesture)