[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.1/kdelibs/khtml
From:       Germain Garand <germain () ebooksfrance ! org>
Date:       2008-09-15 4:14:26
Message-ID: 1221452066.944219.17989.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 861073 by ggarand:

automatically merged revision 858966:
Simplify and guard the smoothscroll algoritm a little. 
Thanks to Manuel Mommertz for solving the bug.
CCBUG: 166870

 M  +24 -17    khtmlview.cpp  


--- branches/KDE/4.1/kdelibs/khtml/khtmlview.cpp #861072:861073
@@ -226,7 +226,7 @@
         scrollingFromWheel = QPoint(-1,-1);
 	borderX = 30;
 	borderY = 30;
-	dx = dy = ddx = ddy = rdx = rdy = dddx = dddy = rddx = rddy = 0;
+	dx = dy = ddx = ddy = rdx = rdy = dddx = dddy = 0;
         paged = false;
 	clickX = -1;
 	clickY = -1;
@@ -320,6 +320,9 @@
     {
         smoothScrollTimer.stop();
         dx = dy = 0;
+        ddx = ddy = 0;
+        rdx = rdy = 0;
+        dddx = dddy = 0;
         updateContentsXY();
         smoothScrolling = false;
         shouldSmoothScroll = false;
@@ -361,7 +364,7 @@
 
     int zoomLevel;
     int borderX, borderY;
-    int dx, dy, ddx, ddy, rdx, rdy, dddx, dddy, rddy, rddx;
+    int dx, dy, ddx, ddy, rdx, rdy, dddx, dddy;
     KConfig *formCompletions;
 
     int clickX, clickY, clickCount;
@@ -1469,7 +1472,7 @@
             d->cursorIconWidget->setPixmap( icon_pixmap);
             d->cursorIconWidget->update();
         }
-        
+
         QPoint c_pos = QCursor::pos();
         d->cursorIconWidget->move( c_pos.x() + 15, c_pos.y() + 15 );
 #ifdef Q_WS_X11
@@ -3912,8 +3915,8 @@
     d->ddy *= 2;
 
     // deacceleration speed
-    d->dddx = (d->ddx*16)/steps;
-    d->dddy = (d->ddy*16)/steps;
+    d->dddx = (d->ddx+1)/steps;
+    d->dddy = (d->ddy+1)/steps;
 
     if (!d->smoothScrolling) {
         d->startScrolling();
@@ -3945,25 +3948,29 @@
     d->rdy = tddy % 16;
 
     // limit step to requested scrolling distance
-    if (d->dx > 0 && ddx > d->dx) ddx = d->dx;
-    if (d->dx < 0 && ddx < d->dx) ddx = d->dx;
-    if (d->dy > 0 && ddy > d->dy) ddy = d->dy;
-    if (d->dy < 0 && ddy < d->dy) ddy = d->dy;
+    if (abs(ddx) > abs(d->dx)) ddx = d->dx;
+    if (abs(ddy) > abs(d->dy)) ddy = d->dy;
 
+    // Don't stop if deaccelerated too fast
+    if (!ddx) ddx = d->dx;
+    if (!ddy) ddy = d->dy;
+
     // update remaining scroll
     d->dx -= ddx;
     d->dy -= ddy;
 
-    int tdddx = d->dddx + d->rddx;
-    int tdddy = d->dddy + d->rddy;
+    d->shouldSmoothScroll = false;
+    scrollContentsBy(ddx, ddy);
+
     // update scrolling speed
-    d->ddx = d->ddx - tdddx/16;
-    d->ddy = d->ddy - tdddy/16;
-    d->rddx = tdddx % 16;
-    d->rddy = tdddy % 16;
+    int dddx = d->dddx;
+    int dddy = d->dddy;
+    // don't change direction
+    if (abs(dddx) > abs(d->ddx)) dddx = d->ddx;
+    if (abs(dddy) > abs(d->ddy)) dddy = d->ddy;
 
-    d->shouldSmoothScroll = false;
-    scrollContentsBy(ddx, ddy);
+    d->ddx -= dddx;
+    d->ddy -= dddy;
 }
 
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic