webengine/osswebengine/WebKit/s60/webview/WebScrollingDeceleratorGH.cpp
branchRCL_3
changeset 49 919f36ff910f
parent 48 79859ed3eea9
equal deleted inserted replaced
48:79859ed3eea9 49:919f36ff910f
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
       
    20 #include <browser_platform_variant.hrh>
    20 #include <../bidi.h>
    21 #include <../bidi.h>
    21 #include "WebScrollingDeceleratorGH.h"
    22 #include "WebScrollingDeceleratorGH.h"
    22 #include "WebView.h"
    23 #include "WebView.h"
    23 #include "WebFrame.h"
    24 #include "WebFrame.h"
    24 #include "WebFrameView.h"
    25 #include "WebFrameView.h"
    26 #include "PlatformScrollbar.h"
    27 #include "PlatformScrollbar.h"
    27 #include "WebScrollbarDrawer.h"
    28 #include "WebScrollbarDrawer.h"
    28 
    29 
    29 #include "WebKitLogger.h"
    30 #include "WebKitLogger.h"
    30 
    31 
    31 using namespace RT_GestureHelper;
       
    32 // constants
    32 // constants
    33 const int KRecordSize = 4;
    33 const int KRecordSize = 4;
    34 
    34 
    35 // The following deceleration curve is generated by a script
    35 // The following deceleration curve is generated by a script
    36 // It lists the timeout dt values in microseconds.
    36 // It lists the timeout dt values in microseconds.
    37 const int KDecelCurveSize = 10;
    37 const int KDecelCurveSize = 10;
    38 
    38 
       
    39 #ifdef BRDO_PERF_IMPROVEMENTS_ENABLED_FF
       
    40 const int KScrollIntervalTimeout = 30000; // scroll timer interval in microseconds
       
    41 #else
    39 const int KScrollIntervalTimeout = 60000; // scroll timer interval in microseconds
    42 const int KScrollIntervalTimeout = 60000; // scroll timer interval in microseconds
    40 
    43 #endif
    41 const float KDecceleration = -700.0;
    44 
       
    45 #ifdef BRDO_MULTITOUCH_ENABLED_FF
       
    46 const float KDecceleration = -1300.0;
       
    47 #else 
       
    48 const float KDecceleration = -750.0;
       
    49 #endif 
       
    50 const float KSpeedHigh = 2000.0;
    42 
    51 
    43 int decelTimerCB(TAny* ptr);
    52 int decelTimerCB(TAny* ptr);
    44 
    53 
    45 
    54 
    46 // ============================ MEMBER FUNCTIONS ===============================
    55 // ============================ MEMBER FUNCTIONS ===============================
    76 // WebScrollingDeceleratorGH::ConstructL
    85 // WebScrollingDeceleratorGH::ConstructL
    77 // -----------------------------------------------------------------------------
    86 // -----------------------------------------------------------------------------
    78 void WebScrollingDeceleratorGH::ConstructL()
    87 void WebScrollingDeceleratorGH::ConstructL()
    79 {
    88 {
    80     m_decelTimer = CPeriodic::NewL(CActive::EPriorityStandard);
    89     m_decelTimer = CPeriodic::NewL(CActive::EPriorityStandard);
       
    90     m_deceleration = KDecceleration;
    81 }
    91 }
    82 
    92 
    83 // -----------------------------------------------------------------------------
    93 // -----------------------------------------------------------------------------
    84 // Destructor
    94 // Destructor
    85 // -----------------------------------------------------------------------------
    95 // -----------------------------------------------------------------------------
    89 }
    99 }
    90 
   100 
    91 
   101 
    92 int WebScrollingDeceleratorGH::getDecceleration()
   102 int WebScrollingDeceleratorGH::getDecceleration()
    93 {
   103 {
    94    return  KDecceleration;  
   104    return  m_deceleration;  
    95 }
   105 }
    96 
   106 
    97 
   107 
    98 int decelTimerCB(TAny* ptr)
   108 int decelTimerCB(TAny* ptr)
    99 {
   109 {
   104 
   114 
   105 void WebScrollingDeceleratorGH::cancelDecel() 
   115 void WebScrollingDeceleratorGH::cancelDecel() 
   106 { 
   116 { 
   107     m_decelelatorSwitch = false;
   117     m_decelelatorSwitch = false;
   108     if (m_decelTimer->IsActive()) {
   118     if (m_decelTimer->IsActive()) {
       
   119         m_webView.setViewIsScrolling(false);
       
   120 		m_webView.resumeJsTimers();		
   109         m_decelTimer->Cancel();
   121         m_decelTimer->Cancel();
   110     }
   122     }
   111 }
   123 }
   112 
   124 
   113 void WebScrollingDeceleratorGH::startDecel(TRealPoint& speed, WebScrollbarDrawer* scrollbarDrawer)
   125 bool WebScrollingDeceleratorGH::startDecel(TRealPoint& speed, WebScrollbarDrawer* scrollbarDrawer)
   114 {
   126 {
       
   127     bool started = false;
   115     m_decelelatorSwitch = true;
   128     m_decelelatorSwitch = true;
   116     m_scrollbarDrawer = scrollbarDrawer;
   129     m_scrollbarDrawer = scrollbarDrawer;
   117     m_initSpeed.iX = (-1) * speed.iX;
   130     float speedX = speed.iX;
   118     m_initSpeed.iY = (-1) * speed.iY;
   131     float speedY = speed.iY;
       
   132     float absSpeedX = abs(speedX);
       
   133     float absSpeedY = abs(speedY);
       
   134     
       
   135     if (absSpeedX > KSpeedHigh) {
       
   136         speedX = KSpeedHigh * speedX/absSpeedX ;
       
   137     }
       
   138     if (absSpeedY > KSpeedHigh) {
       
   139         speedY = KSpeedHigh * speedY/absSpeedY;
       
   140     }
       
   141     
       
   142     m_initSpeed.iX = (-1) * speedX;
       
   143     m_initSpeed.iY = (-1) * speedY;
   119     
   144     
   120     m_numscrollsteps = 0;
   145     m_numscrollsteps = 0;
   121     if (m_decelTimer->IsActive()) {
   146     if (m_decelTimer->IsActive()) {
       
   147         m_webView.setViewIsScrolling(false);
       
   148     	m_webView.resumeJsTimers();
   122         m_decelTimer->Cancel();
   149         m_decelTimer->Cancel();
   123     }
   150     }
   124     
   151     
   125     WebFrameView* scrollingView = m_webView.pageScrollHandler()->currentScrollingFrameView();
   152     WebFrameView* scrollingView = m_webView.pageScrollHandler()->currentScrollingFrameView();
   126     if (scrollingView) {
   153     if (scrollingView) {
       
   154         m_webView.pauseJsTimers(); // pause the JS timers
       
   155         m_webView.setViewIsScrolling(true);
   127         m_startPos = scrollingView->contentPos();
   156         m_startPos = scrollingView->contentPos();
   128         m_lastPos = m_startPos;
   157         m_lastPos = m_startPos;
   129         m_decelTimer->Start(0, KScrollIntervalTimeout, 
   158         m_decelTimer->Start(0, KScrollIntervalTimeout, 
   130                             TCallBack(&decelTimerCB, this));
   159                             TCallBack(&decelTimerCB, this));
   131     }
   160         started = true;
       
   161     }
       
   162     return started;
   132 }
   163 }
   133 
   164 
   134 void WebScrollingDeceleratorGH::scroll()
   165 void WebScrollingDeceleratorGH::scroll()
   135 {
   166 {
   136     if (!m_decelelatorSwitch) return;
   167     if (!m_decelelatorSwitch) return;
   143     TReal32 vx = 0.0;
   174     TReal32 vx = 0.0;
   144     TReal32 vy = 0.0;
   175     TReal32 vy = 0.0;
   145     TReal32 accelX = 0.0;
   176     TReal32 accelX = 0.0;
   146     TReal32 accelY = 0.0;
   177     TReal32 accelY = 0.0;
   147     
   178     
       
   179     TReal32 deceleration = getDecceleration();
       
   180     
   148     if (m_initSpeed.iX) {
   181     if (m_initSpeed.iX) {
   149         accelX = (m_initSpeed.iX > 0) ?  KDecceleration : (-1) * KDecceleration;
   182         accelX = (m_initSpeed.iX > 0) ?  deceleration : (-1) * deceleration;
   150         vx = m_initSpeed.iX + accelX * t;
   183         vx = m_initSpeed.iX + accelX * t;
   151         dx = m_initSpeed.iX * t + 0.5 * accelX * (t * t);
   184         dx = m_initSpeed.iX * t + 0.5 * accelX * (t * t);
   152     }
   185     }
   153         
   186         
   154     if (m_initSpeed.iY) {
   187     if (m_initSpeed.iY) {
   155         accelY = (m_initSpeed.iY > 0) ?  KDecceleration : (-1) * KDecceleration;
   188         accelY = (m_initSpeed.iY > 0) ?  deceleration : (-1) * deceleration;
   156         vy = m_initSpeed.iY + accelY * t;
   189         vy = m_initSpeed.iY + accelY * t;
   157         dy = m_initSpeed.iY * t + 0.5 * accelY * (t * t);
   190         dy = m_initSpeed.iY * t + 0.5 * accelY * (t * t);
   158     }
   191     }
   159     
   192     
   160     dist.SetXY(static_cast<TInt>(dx), static_cast<TInt>(dy));
   193     dist.SetXY(static_cast<TInt>(dx), static_cast<TInt>(dy));
   170         (m_numscrollsteps > 1 && !scrollingView->needScroll(pos) && 
   203         (m_numscrollsteps > 1 && !scrollingView->needScroll(pos) && 
   171         !handler->currentScrollingElement())) {
   204         !handler->currentScrollingElement())) {
   172         if (m_scrollbarDrawer) {
   205         if (m_scrollbarDrawer) {
   173             m_scrollbarDrawer->fadeScrollbar();
   206             m_scrollbarDrawer->fadeScrollbar();
   174         }
   207         }
       
   208 		
       
   209         m_webView.resumeJsTimers(); // resume the js timers
       
   210         m_webView.setViewIsScrolling(false);
   175         m_decelTimer->Cancel();
   211         m_decelTimer->Cancel();
   176         handler->clearScrollingElement();
   212         handler->clearScrollingElement();
   177         m_webView.setViewIsScrolling(false);
   213         m_webView.setViewIsScrolling(false);
   178         m_webView.toggleRepaintTimer(true);
   214         m_webView.toggleRepaintTimer(true);
   179     }
   215     }