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