Bug 172258 - Horizontal scrollbar is malfunction in RTL mode
Summary: Horizontal scrollbar is malfunction in RTL mode
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml (show other bugs)
Version: unspecified
Platform: Ubuntu Unspecified
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-06 09:54 UTC by Zayed Al-Saidi
Modified: 2008-10-10 01:45 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
testcase for this bug. (646 bytes, text/html)
2008-10-06 09:55 UTC, Zayed Al-Saidi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zayed Al-Saidi 2008-10-06 09:54:18 UTC
Version:            (using KDE 4.1.2)
Installed from:    Ubuntu Packages

The horizontal scrollbar really broken in RTL mode !! When I scroll left, it goes right and when I scroll right, it goes left. 

Way to reproduce this bug:
1- open konqueror in reverse mode : konqueror -reverse
2- download the testcase, in the attachment.
3- try to scroll left and right 

The expected behavior should be same as LTR mode .
Comment 1 Zayed Al-Saidi 2008-10-06 09:55:03 UTC
Created attachment 27710 [details]
testcase for this bug.
Comment 2 Germain Garand 2008-10-10 01:45:22 UTC
SVN commit 869761 by ggarand:

- fix incomplete repaints happening from time to time
  when jumping early during page load. (#166413)

- various RTL layout application (-reverse cmdline option) fixes
  . implement RTL scrollbars on CSS containers
  . fix iframes scrollbars in RTL mode
  . fix wrong direction when scrolling horizontally (#172258)
  . fix grey block on left of view (#170679)

- avoid smooth scrolling during early stage of layout if the option has
  the WhenEfficient value

BUG: 166413, 172258, 170679


 M  +1 -1      khtml_part.cpp  
 M  +18 -3     khtmlview.cpp  
 M  +2 -1      rendering/render_block.cpp  
 M  +3 -2      rendering/render_layer.cpp  
 M  +2 -1      rendering/render_replaced.cpp  


--- trunk/KDE/kdelibs/khtml/khtml_part.cpp #869760:869761
@@ -2576,7 +2576,7 @@
   bool quirkyName = !n && !d->m_doc->inStrictMode() && (name.isEmpty() || name.toLower() == "top");
 
   if (quirkyName) {
-      d->m_view->setContentsPos(0, 0);
+      d->m_view->setContentsPos( d->m_view->contentsX(), 0);
       return true;
   } else if (!n) {
       kDebug(6050) << name << "not found";
--- trunk/KDE/kdelibs/khtml/khtmlview.cpp #869760:869761
@@ -786,7 +786,8 @@
 
 void KHTMLView::setContentsPos( int x, int y)
 {
-   horizontalScrollBar()->setValue( x );
+   horizontalScrollBar()->setValue( QApplication::isRightToLeft() ?
+                           horizontalScrollBar()->maximum()-x : x );
    verticalScrollBar()->setValue( y );
 }
 
@@ -2382,6 +2383,13 @@
             }
         }
       }
+      case QEvent::Move: {
+          if (static_cast<QMoveEvent*>(e)->pos() != QPoint(0,0)) {
+              widget()->move(0,0);
+              updateScrollBars();
+              return true;
+          }
+      }
       default:
         break;
     }
@@ -3870,6 +3878,8 @@
             unscheduleRelayout();
             layout();
         }
+        if (d->smoothScrollMode == KHTMLView::SSMWhenEfficient)
+            d->shouldSmoothScroll = false;
     }
 
     if ( d->smoothScrollMode != SSMDisabled &&
@@ -3888,6 +3898,9 @@
     if (m_part->xmlDocImpl() && m_part->xmlDocImpl()->documentElement())
         m_part->xmlDocImpl()->documentElement()->dispatchHTMLEvent(EventImpl::SCROLL_EVENT, false, false);
 
+    if (QApplication::isRightToLeft())
+        dx = -dx;
+
     if (!d->smoothScrolling) {
         d->updateContentsXY();
     } else {
@@ -3907,6 +3920,7 @@
         KHTMLView* v = m_kwp->rootViewPos( off );
         if (v)
             w = v->widget();
+        off = viewport()->mapTo(this, off);
     }
 
 #ifdef FIX_QT_BROKEN_QWIDGET_SCROLL
@@ -3967,8 +3981,6 @@
         }
         return;
     }
-    if (d->firstRepaintPending)
-        return;
 
 #ifdef FIX_QT_BROKEN_QWIDGET_SCROLL
     if (hideScrollBars) {
@@ -4359,6 +4371,9 @@
     horizontalScrollBar()->setPageStep(p.width());
     verticalScrollBar()->setRange(0, v.height() - p.height());
     verticalScrollBar()->setPageStep(p.height());
+    if (!d->smoothScrolling) {
+        d->updateContentsXY();
+    }
 }
 
 void KHTMLView::slotMouseScrollTimer()
--- trunk/KDE/kdelibs/khtml/rendering/render_block.cpp #869760:869761
@@ -2617,7 +2617,8 @@
         return false;
 
     if (m_layer->verticalScrollbarWidth()) {
-        QRect vertRect(_tx + width() - borderRight() - m_layer->verticalScrollbarWidth(),
+        bool rtl = QApplication::isRightToLeft();
+        QRect vertRect(_tx + (rtl ? borderLeft() :  width() - borderRight() - m_layer->verticalScrollbarWidth()),
                        _ty + borderTop() - borderTopExtra(),
                        m_layer->verticalScrollbarWidth(),
                        height() + borderTopExtra() + borderBottomExtra()-borderTop()-borderBottom());
--- trunk/KDE/kdelibs/khtml/rendering/render_layer.cpp #869760:869761
@@ -843,15 +843,16 @@
     if (!m_hBar)
        b = m_vBar;
     int sw = b->style()->pixelMetric(QStyle::PM_ScrollBarExtent);
+    bool rtl = b->layoutDirection() == Qt::RightToLeft;
 
     if (m_vBar) {
-       QRect vBarRect = QRect(tx + w - sw, ty, sw, h - (m_hBar ? sw : 0));
+       QRect vBarRect = QRect(tx + (rtl ? 0 : w-sw), ty, sw, h - (m_hBar ? sw : 0));
         m_vBar->resize(vBarRect.width(), vBarRect.height());
         m_vBar->m_kwp->setPos(QPoint(vBarRect.x(), vBarRect.y()));
     }
 
     if (m_hBar) {
-       QRect hBarRect = QRect(tx, ty + h - sw, w - (m_vBar ? sw : 0), sw);
+       QRect hBarRect = QRect(tx + (rtl && m_vBar ? sw : 0), ty + h - sw, w - (!rtl && m_vBar ? sw : 0), sw);
         m_hBar->resize(hBarRect.width(), hBarRect.height());
         m_hBar->m_kwp->setPos(QPoint(hBarRect.x(), hBarRect.y()));
     }
--- trunk/KDE/kdelibs/khtml/rendering/render_replaced.cpp #869760:869761
@@ -794,7 +794,8 @@
             if (hbr.isValid() && !hbr.isEmpty())
                 copyWidget(hbr, p, v->horizontalScrollBar(), tx+ of.x(), ty+ of.y(), buffered, buffer[1]);
         }
-        QRect vr = (r & v->viewport()->rect());
+        QPoint of = v->viewport()->mapTo(v, QPoint(0,0));
+        QRect vr = (r & v->viewport()->rect().translated(of));
         if (vr.isValid() && !vr.isEmpty())
             v->render(p, vr, thePoint);
     } else {