webengine/osswebengine/WebKit/s60/webview/WebPointerEventHandler.cpp
changeset 36 0ed94ceaa377
parent 27 60c5402cb945
child 37 cb62a4f66ebe
equal deleted inserted replaced
32:9a9a761f03f1 36:0ed94ceaa377
    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"
    20 #include "../../bidi.h"
    20 #include "../../bidi.h"
    21 #include <AknUtils.h>
    21 #include <AknUtils.h>
    22 #ifdef BRDO_TOUCH_ENABLED_FF
    22 #ifdef BRDO_TOUCH_ENABLED_FF
    23 #include <touchfeedback.h>
    23 #include <touchfeedback.h>
    24 #endif // BRDO_TOUCH_ENABLED_FF
    24 #endif // BRDO_TOUCH_ENABLED_FF
    25 #include "brctl.h"
    25 #include "brctl.h"
    26 #include "BrCtlDefs.h"
    26 #include "brctldefs.h"
    27 #include "WebPointerEventHandler.h"
    27 #include "WebPointerEventHandler.h"
    28 #include "WebView.h"
    28 #include "WebView.h"
    29 #include "WebFrame.h"
    29 #include "WebFrame.h"
    30 #include "WebFrameView.h"
    30 #include "WebFrameView.h"
    31 #include "WebCursor.h"
    31 #include "WebCursor.h"
    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"
    47 #include "MouseEvent.h"
    48 #include "MouseEvent.h"
    48 #include "WebPageFullScreenHandler.h"
    49 #include "WebPageFullScreenHandler.h"
    49 #include "PluginSkin.h"
    50 #include "PluginSkin.h"
    50 #include "PluginWin.h"
    51 #include "PluginWin.h"
    51 #include "WebFrameBridge.h"
    52 #include "WebFrameBridge.h"
    54 #include "ChromeClient.h"
    55 #include "ChromeClient.h"
    55 #include "FocusController.h"
    56 #include "FocusController.h"
    56 #include "WebTabbedNavigation.h"
    57 #include "WebTabbedNavigation.h"
    57 #include "SettingsContainer.h"
    58 #include "SettingsContainer.h"
    58 #include "PluginHandler.h"
    59 #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"
    59 
    67 
    60 #include "WebKitLogger.h"
    68 #include "WebKitLogger.h"
    61 using namespace WebCore;
    69 using namespace WebCore;
    62 using namespace EventNames;
    70 using namespace EventNames;
    63 using namespace RT_GestureHelper;
    71 using namespace RT_GestureHelper;
   135  *                 sent: EGestureDrop, EGestureReleased
   143  *                 sent: EGestureDrop, EGestureReleased
   136  */
   144  */
   137 void WebPointerEventHandler::HandleGestureL( const TGestureEvent& aEvent )
   145 void WebPointerEventHandler::HandleGestureL( const TGestureEvent& aEvent )
   138 {
   146 {
   139     TGestureCode gtype = aEvent.Code(EAxisBoth);
   147     TGestureCode gtype = aEvent.Code(EAxisBoth);
   140     TPoint gpos = aEvent.CurrentPos();
   148     
   141     
   149     m_highlightPos = aEvent.CurrentPos();
       
   150 
   142     TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
   151     TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
   143     
   152     
   144     PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin();
   153     PluginSkin* plugin = m_webview->mainFrame()->focusedPlugin();
   145     if (plugin && plugin->pluginWin()) {
   154     if (plugin && plugin->pluginWin()) {
   146       if (plugin->pluginWin()->HandleGesture(aEvent)) {
   155       if (plugin->pluginWin()->HandleGesture(aEvent)) {
   147           return;
   156           return;
   148       }
   157       }
   149     }
   158     }
   150     updateCursor(aEvent.CurrentPos());
   159     updateCursor(aEvent.CurrentPos());
   151     if (IS_TABBED_NAVIGATION) {
   160     if (IS_TABBED_NAVIGATION) {
   152         m_webview->tabbedNavigation()->updateCursorPosition(m_highlightPos);
   161         m_webview->tabbedNavigation()->updateCursorPosition(aEvent.CurrentPos());
   153     }
   162     }
   154     switch (gtype) {
   163     switch (gtype) {
   155       // sent on touch down
   164       // sent on touch down
   156       case EGestureStart:  
   165       case EGestureStart:  
   157       {
   166       {
   258 {
   267 {
   259     TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
   268     TBrCtlDefs::TBrCtlElementType elType = m_webview->focusedElementType();
   260     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
   269     PluginHandler* pluginHandler = WebCore::StaticObjectsContainer::instance()->pluginHandler();
   261     PluginSkin* pluginToActivate = pluginHandler->pluginToActivate();
   270     PluginSkin* pluginToActivate = pluginHandler->pluginToActivate();
   262     m_buttonDownEvent = m_currentEvent;
   271     m_buttonDownEvent = m_currentEvent;
   263     m_highlightPos = aEvent.CurrentPos();
       
   264     
   272     
   265     if ( !m_buttonDownTimer.isActive() && !m_webview->inPageViewMode()){
   273     if ( !m_buttonDownTimer.isActive() && !m_webview->inPageViewMode()){
   266         m_buttonDownTimer.startOneShot(0.1f);        
   274         m_buttonDownTimer.startOneShot(0.1f);        
   267     }
   275     }
   268 
   276 
   291      * timer callback and only way for us to "tell" about this is to stop RunL() 
   299      * timer callback and only way for us to "tell" about this is to stop RunL() 
   292      * of CGestureEventSender (HandleGestureL() is inside it) and finish buttondown 
   300      * of CGestureEventSender (HandleGestureL() is inside it) and finish buttondown 
   293      * timer callback first.  
   301      * timer callback first.  
   294      */    
   302      */    
   295     if ( m_buttonDownTimer.isActive()){
   303     if ( m_buttonDownTimer.isActive()){
   296     	m_waiter->Start();	
   304         m_waiter->Start();	
   297     }
   305     }
   298 }
   306 }
   299 
   307 
   300 // ======================================================================
   308 // ======================================================================
   301 // WebPointerEventHandler::handleTouchUp 
   309 // WebPointerEventHandler::handleTouchUp 
   482            {
   490            {
   483            feedback->InstantFeedback(ETouchFeedbackBasic);
   491            feedback->InstantFeedback(ETouchFeedbackBasic);
   484            }
   492            }
   485     }
   493     }
   486 #endif // BRDO_TOUCH_ENABLED_FF
   494 #endif // BRDO_TOUCH_ENABLED_FF
   487     
   495      
       
   496     if (!IS_NAVIGATION_NONE) {
       
   497          m_webview->sendMouseEventToEngine(TPointerEvent::EMove, m_highlightPos, coreFrame);
       
   498      }
       
   499      
   488      /*
   500      /*
   489       * We assume that if element visibility has been changed  
   501       * We assume that if element visibility has been changed  
   490       * between "up" and "down" that means that some node event 
   502       * between "up" and "down" that means that some node event 
   491       * listener (onMouseOver etc) handling happened and we don't 
   503       * listener (onMouseOver etc) handling happened and we don't 
   492       * want to send a click (mouse press = mouse release) event.
   504       * want to send a click (mouse press + mouse release) event.
   493       * The exception is editable element, since we want VKB anyway
   505       * The exception is editable element, since we want VKB anyway
   494       */
   506       */
   495      if (!IS_NAVIGATION_NONE &&
   507      if (!IS_NAVIGATION_NONE &&
   496          elType != TBrCtlDefs::EElementActivatedInputBox && 
   508          elType != TBrCtlDefs::EElementActivatedInputBox && 
   497          elType != TBrCtlDefs::EElementTextAreaBox &&     
   509          elType != TBrCtlDefs::EElementTextAreaBox &&     
   498          m_webview->page()->chrome()->client()->elementVisibilityChangedByMouse()) {
   510          m_webview->page()->chrome()->client()->elementVisibilityChangedByMouse()) {
   499          return;
   511          return;
   500      }
   512      }
   501 
   513      
   502      m_lastTapEvent.iPosition = m_buttonDownEvent.iPosition;
   514      m_lastTapEvent.iPosition = m_buttonDownEvent.iPosition;
   503      m_lastTapEvent.iType = TPointerEvent::EButton1Up;
   515      m_lastTapEvent.iType = TPointerEvent::EButton1Up;
   504      m_lastTapEvent.iModifiers = 0;
   516      m_lastTapEvent.iModifiers = 0;
   505 
   517 
   506     // don't pass the event if the text input is not in valid format
   518     // don't pass the event if the text input is not in valid format
   507     if (isHighlitableElement(elType) || m_webview->fepTextEditor()->validateTextFormat()) {
   519     if (m_webview->fepTextEditor()->validateTextFormat()) {
   508         m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Up,  m_lastTapEvent.iPosition, coreFrame);
   520         if (!IS_NAVIGATION_NONE) {
       
   521             // in case of navigation none button down was sent in buttonDownTimerCB()
       
   522             m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Down, m_highlightPos, coreFrame);
       
   523         }
       
   524         m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Up,  m_highlightPos, coreFrame);
   509     }
   525     }
   510 
   526 
   511     // special handling for broken image (why is this here??)
   527     // special handling for broken image (why is this here??)
   512     if (elType == TBrCtlDefs::EElementBrokenImage) {
   528     if (elType == TBrCtlDefs::EElementBrokenImage) {
   513         loadFocusedImage(m_webview);
   529         loadFocusedImage(m_webview);
   582 // WebPointerEventHandler::buttonDownTimerCallback
   598 // WebPointerEventHandler::buttonDownTimerCallback
   583 //-----------------------------------------------------------------------------
   599 //-----------------------------------------------------------------------------
   584 void WebPointerEventHandler::buttonDownTimerCB(Timer<WebPointerEventHandler>* t)
   600 void WebPointerEventHandler::buttonDownTimerCB(Timer<WebPointerEventHandler>* t)
   585 {
   601 {
   586     m_buttonDownTimer.stop();
   602     m_buttonDownTimer.stop();
   587 
       
   588     
   603     
   589     Frame* coreFrame = core(m_webview->mainFrame());
   604     Frame* coreFrame = core(m_webview->mainFrame());
   590     TPointerEvent event;
   605     TPointerEvent event;
   591     
   606     
   592     TBrCtlDefs::TBrCtlElementType elType = highlitableElement();
   607     TBrCtlDefs::TBrCtlElementType elType = highlitableElement();
   593     
   608     
   594     if (!isHighlitableElement(elType)) {
   609     if (!isHighlitableElement(elType)) {
   595         elType = TBrCtlDefs::EElementNone;
   610         elType = TBrCtlDefs::EElementNone;
   596     }
   611     }
   597     m_isHighlighted = (m_highlightedNode != NULL) && (elType != TBrCtlDefs::EElementNone) ;
   612     m_isHighlighted = (m_highlightedNode != NULL) && (elType != TBrCtlDefs::EElementNone) ;
   598     
       
   599     m_webview->page()->chrome()->client()->setElementVisibilityChanged(false);
       
   600     
   613     
   601     /*
   614     /*
   602      * Tabbed navigation might already set the focused node.
   615      * Tabbed navigation might already set the focused node.
   603      * If it's the same as m_highlightedNode FocuseController::setFocusedNode()
   616      * If it's the same as m_highlightedNode FocuseController::setFocusedNode()
   604      * wouldn't do anything and setEditable won't be called.
   617      * 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
   618      * So we are setting focused node to NULL here and let mouse event handler
   606      * set it through ocuseController::setFocusedNode()
   619      * set it through FocuseController::setFocusedNode()
   607      */
   620      */
   608     if (IS_TABBED_NAVIGATION &&
   621     if (IS_TABBED_NAVIGATION &&
   609         elType == TBrCtlDefs::EElementInputBox || 
   622         elType == TBrCtlDefs::EElementInputBox || 
   610         elType == TBrCtlDefs::EElementTextAreaBox) {
   623         elType == TBrCtlDefs::EElementTextAreaBox) {
   611         coreFrame->document()->setFocusedNode(NULL);
   624         coreFrame->document()->setFocusedNode(NULL);
   612     }
   625     }
   613          
   626          
   614     m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Down, m_highlightPos, coreFrame);
   627     if (!IS_NAVIGATION_NONE) {
   615 
   628         m_webview->page()->chrome()->client()->setElementVisibilityChanged(false);
   616     m_webview->sendMouseEventToEngine(TPointerEvent::EMove, m_highlightPos, coreFrame);
   629         //to initiate hover 
   617     m_waiter->AsyncStop();
   630         if (m_isHighlighted) {
       
   631             setFocusRing();
       
   632         }
       
   633         
       
   634     }
       
   635     else {
       
   636         m_webview->sendMouseEventToEngine(TPointerEvent::EButton1Down, m_highlightPos, coreFrame);
       
   637     }
       
   638     
       
   639     if (m_waiter->IsStarted()) {    
       
   640         m_waiter->AsyncStop();
       
   641     }
   618 }
   642 }
   619 
   643 
   620 
   644 
   621 //-----------------------------------------------------------------------------
   645 //-----------------------------------------------------------------------------
   622 // WebPointerEventHandler::updateCursor
   646 // WebPointerEventHandler::updateCursor
   633             m_webview->setShowCursor(false);
   657             m_webview->setShowCursor(false);
   634             cursor->cursorUpdate(false); 
   658             cursor->cursorUpdate(false); 
   635         }
   659         }
   636     }
   660     }
   637 }
   661 }
       
   662 
       
   663 //-----------------------------------------------------------------------------
       
   664 // WebPointerEventHandler::setFocusRing
       
   665 //----------------------------------------------------------------------------
       
   666 void WebPointerEventHandler::setFocusRing()
       
   667 {
       
   668     Element* e = static_cast<Element*>(m_highlightedNode);
       
   669     RenderStyle* rs = e->renderStyle();
       
   670     RenderStyle* style = new (e->document()->renderArena()) RenderStyle(*rs);
       
   671     Color col(0xffaaaaff);
       
   672 
       
   673     style->ref();   
       
   674     style->setOutlineColor(col);
       
   675     style->setOutlineStyle(DOTTED, true);
       
   676     style->setOutlineWidth(4);
       
   677     style->setOutlineOffset(2);
       
   678     e->setRenderStyle(style);
       
   679     style->deref(e->document()->renderArena());
       
   680     e->setChanged();
       
   681 }