<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>121065</bug_id>
          
          <creation_ts>2006-01-30 21:55:19 +0000</creation_ts>
          <short_desc>DIV with scroll bar can&apos;t be scrolled with the mouse wheel</short_desc>
          <delta_ts>2007-08-13 08:56:27 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>konqueror</product>
          <component>khtml</component>
          <version>unspecified</version>
          <rep_platform>unspecified</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Iñaki Baz Castillo">ibc</reporter>
          <assigned_to name="Konqueror Bugs">konqueror-bugs-null</assigned_to>
          <cc>fh</cc>
    
    <cc>ismail</cc>
    
    <cc>paulpach</cc>
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>410139</commentid>
    <comment_count>0</comment_count>
    <who name="Iñaki Baz Castillo">ibc</who>
    <bug_when>2006-01-30 21:55:19 +0000</bug_when>
    <thetext>Version:           3.5.1 (using KDE 3.5.1, Debian Package 4:3.5.1-1 (testing/unstable))
Compiler:          Target: i486-linux-gnu
OS:                Linux (i686) release 2.6.14

The mouse wheel can&apos;t work in DIV&apos;s with scroll bar.

For example, go to his page: http://www.musicalibre.es

The left and right columns are not frames, they are DIV&apos;s. So, put the mouse over each one and try to scroll down the content of the div with the mouse wheel. It&apos;s impossible. The only way is to use the mouse wheel just over the scroll bar, that is not very usable.

In Firefox this doesn&apos;t occur, and it&apos;s not necessary to focus the div for scrolling it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>411042</commentid>
    <comment_count>1</comment_count>
    <who name="Thiago Macieira">thiago</who>
    <bug_when>2006-02-02 20:30:24 +0000</bug_when>
    <thetext>Confirmed. Annoying behaviour.

r500000</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>434473</commentid>
    <comment_count>2</comment_count>
    <who name="Iñaki Baz Castillo">ibc</who>
    <bug_when>2006-04-27 17:31:03 +0000</bug_when>
    <thetext>Note the the page I set as example (http://www.musicalibre.es) has changed so now there are not these DIV&apos;s with scroll bar. I&apos;ll try to find another web example.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>440251</commentid>
    <comment_count>3</comment_count>
    <who name="Paul Pacheco">paulpach</who>
    <bug_when>2006-05-19 15:19:23 +0000</bug_when>
    <thetext>I found some examples of this behaviour which is annoying me too to the point where I have to switch browser because our company uses this.

http://www.cssplay.co.uk/layouts/bodyfix.html
http://www.cssplay.co.uk/layouts/body2.html
http://www.cssplay.co.uk/layouts/body4.html
http://www.cssplay.co.uk/layouts/body5.html

Note firefox and IE work fine with these pages</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>440274</commentid>
    <comment_count>4</comment_count>
    <who name="Allan Sandfeld">kde</who>
    <bug_when>2006-05-19 16:03:34 +0000</bug_when>
    <thetext>*** Bug 126897 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>503668</commentid>
    <comment_count>5</comment_count>
    <who name="Germain Garand">germain</who>
    <bug_when>2007-01-24 15:57:06 +0000</bug_when>
    <thetext>SVN commit 626756 by ggarand:

implement scrolling of CSS containers with the mousewheel

BUG: 121065



 M  +53 -0     rendering/render_box.cpp  
 M  +2 -0      rendering/render_box.h  
 M  +2 -0      rendering/render_object.h  
 M  +5 -1      xml/dom_nodeimpl.cpp  


--- trunk/KDE/kdelibs/khtml/rendering/render_box.cpp #626755:626756
@@ -6,6 +6,7 @@
  *           (C) 2002-2003 Apple Computer, Inc.
  *           (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
  *           (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
+ *           (C) 2007 Germain Garand (germain@ebooksfrance.org)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -31,6 +32,7 @@
 #include &lt;qpainter.h&gt;
 
 #include &quot;misc/loader.h&quot;
+#include &quot;rendering/render_form.h&quot;
 #include &quot;rendering/render_replaced.h&quot;
 #include &quot;rendering/render_canvas.h&quot;
 #include &quot;rendering/render_table.h&quot;
@@ -41,8 +43,10 @@
 #include &quot;misc/htmlhashes.h&quot;
 #include &quot;xml/dom_nodeimpl.h&quot;
 #include &quot;xml/dom_docimpl.h&quot;
+#include &quot;xml/dom2_eventsimpl.h&quot;
 #include &quot;html/html_elementimpl.h&quot;
 
+#include &lt;QWheelEvent&gt;
 #include &lt;khtmlview.h&gt;
 #include &lt;kdebug.h&gt;
 #include &lt;kglobal.h&gt;
@@ -2204,6 +2208,55 @@
         return false;
 }
 
+bool RenderBox::handleEvent(const DOM::EventImpl&amp; e) 
+{
+    if ( e.id() == EventImpl::KHTML_MOUSEWHEEL_EVENT &amp;&amp; scrollsOverflow()) {
+
+        const MouseEventImpl&amp; me = static_cast&lt;const MouseEventImpl&amp;&gt;(e);
+        Qt::MouseButtons buttons = Qt::NoButton;
+        Qt::KeyboardModifiers state = 0;
+        Qt::Orientation orient = Qt::Vertical;
+
+        switch (me.button()) {
+        case 0:
+            buttons = Qt::LeftButton;
+            break;
+        case 1:
+            buttons = Qt::MidButton;
+            break;
+        case 2:
+            buttons = Qt::RightButton;
+            break;
+        default:
+            break;
+        }
+
+        if (me.orientation() == MouseEventImpl::OHorizontal)
+            orient = Qt::Horizontal;
+
+        int absx = 0;
+        int absy = 0;
+        absolutePosition(absx, absy);
+        absx += borderLeft()+paddingLeft();
+        absy += borderTop()+paddingTop();
+        QPoint p(me.clientX() - absx + canvas()-&gt;view()-&gt;contentsX(),
+                 me.clientY() - absy + canvas()-&gt;view()-&gt;contentsY());
+
+        QWheelEvent we(p, -me.detail()*40, buttons, state, orient);
+        KHTMLAssert(layer());
+        if (orient == Qt::Vertical) {
+            if (QWidget* w = dynamic_cast&lt;QWidget*&gt;( layer()-&gt;verticalScrollbar() ))
+                QApplication::sendEvent( w, &amp;we);
+        } else {
+            if (QWidget* w = dynamic_cast&lt;QWidget*&gt;( layer()-&gt;horizontalScrollbar() ))
+                QApplication::sendEvent( w, &amp;we);
+        }
+        if (we.isAccepted())
+            return true;
+    }
+    return RenderContainer::handleEvent(e);
+}
+
 void RenderBox::caretPos(int /*offset*/, int flags, int &amp;_x, int &amp;_y, int &amp;width, int &amp;height)
 {
 #if 0
--- trunk/KDE/kdelibs/khtml/rendering/render_box.h #626755:626756
@@ -120,6 +120,8 @@
 
     virtual int pageTopAfter(int y) const;
     virtual int crossesPageBreak(int t, int b) const;
+    
+    virtual bool handleEvent(const DOM::EventImpl&amp; ev);
 
     int calcBoxWidth(int w) const;
     int calcBoxHeight(int h) const;
--- trunk/KDE/kdelibs/khtml/rendering/render_object.h #626755:626756
@@ -317,6 +317,8 @@
     DOM::DocumentImpl* document() const;
     DOM::NodeImpl* element() const { return isAnonymous() ? 0L : m_node; }
     DOM::NodeImpl* node() const { return m_node; }
+    
+    virtual bool handleEvent(const DOM::EventImpl&amp;) { return false; };
 
    /**
      * returns the object containing this one. can be different from parent for
--- trunk/KDE/kdelibs/khtml/xml/dom_nodeimpl.cpp #626755:626756
@@ -623,8 +623,12 @@
     }
 }
 
-void NodeImpl::defaultEventHandler(EventImpl *)
+void NodeImpl::defaultEventHandler(EventImpl *e)
 {
+    if (e-&gt;isMouseEvent() &amp;&amp; e-&gt;id() == EventImpl::KHTML_MOUSEWHEEL_EVENT &amp;&amp; e-&gt;target() == this)
+        if (m_render &amp;&amp; m_render-&gt;scrollsOverflow())
+            if (m_render-&gt;handleEvent(*e))
+                e-&gt;setDefaultHandled();
 }
 
 unsigned long NodeImpl::childNodeCount()
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>503676</commentid>
    <comment_count>6</comment_count>
    <who name="Germain Garand">germain</who>
    <bug_when>2007-01-24 16:23:25 +0000</bug_when>
    <thetext>*** Bug 86224 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>503729</commentid>
    <comment_count>7</comment_count>
    <who name="Leo Savernik">l.savernik</who>
    <bug_when>2007-01-24 19:48:44 +0000</bug_when>
    <thetext>Note that this only fixes half the bug. You still can&apos;t scroll using the 
keyboard.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>503818</commentid>
    <comment_count>8</comment_count>
    <who name="Germain Garand">germain</who>
    <bug_when>2007-01-25 00:25:00 +0000</bug_when>
    <thetext>mmh, right but then this would only make sense if scrollable layers are made focusable, wouldn&apos;t it? 

I can&apos;t seem to find this in any spec, but OTOH as scrollbars are controls, it makes a lot of sense... I&apos;ll have a look.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>503944</commentid>
    <comment_count>9</comment_count>
    <who name="Germain Garand">germain</who>
    <bug_when>2007-01-25 15:26:02 +0000</bug_when>
    <thetext>SVN commit 627032 by ggarand:

elaborate on scrollable containers event handling: 
make them focusable and add keyboard events handling 
so as to make keyboard-only navigation possible.

CCBUG: 121065



 M  +50 -4     rendering/render_box.cpp  
 M  +22 -0     xml/dom_elementimpl.cpp  
 M  +2 -0      xml/dom_elementimpl.h  
 M  +0 -4      xml/dom_nodeimpl.cpp  


--- trunk/KDE/kdelibs/khtml/rendering/render_box.cpp #627031:627032
@@ -2210,8 +2210,12 @@
 
 bool RenderBox::handleEvent(const DOM::EventImpl&amp; e) 
 {
-    if ( e.id() == EventImpl::KHTML_MOUSEWHEEL_EVENT &amp;&amp; scrollsOverflow()) {
+    KHTMLAssert( scrollsOverflow() );
+    bool accepted = false;
 
+    switch ( e.id() ) {
+      case EventImpl::KHTML_MOUSEWHEEL_EVENT: {
+
         const MouseEventImpl&amp; me = static_cast&lt;const MouseEventImpl&amp;&gt;(e);
         Qt::MouseButtons buttons = Qt::NoButton;
         Qt::KeyboardModifiers state = 0;
@@ -2239,21 +2243,63 @@
         absolutePosition(absx, absy);
         absx += borderLeft()+paddingLeft();
         absy += borderTop()+paddingTop();
+
         QPoint p(me.clientX() - absx + canvas()-&gt;view()-&gt;contentsX(),
                  me.clientY() - absy + canvas()-&gt;view()-&gt;contentsY());
 
         QWheelEvent we(p, -me.detail()*40, buttons, state, orient);
         KHTMLAssert(layer());
         if (orient == Qt::Vertical) {
-            if (QWidget* w = dynamic_cast&lt;QWidget*&gt;( layer()-&gt;verticalScrollbar() ))
+            if (QWidget* w = layer()-&gt;verticalScrollbar())
                 QApplication::sendEvent( w, &amp;we);
         } else {
-            if (QWidget* w = dynamic_cast&lt;QWidget*&gt;( layer()-&gt;horizontalScrollbar() ))
+            if (QWidget* w = layer()-&gt;horizontalScrollbar())
                 QApplication::sendEvent( w, &amp;we);
         }
         if (we.isAccepted())
-            return true;
+            accepted = true;
+        break;
+      }
+      case EventImpl::KEYDOWN_EVENT:
+      case EventImpl::KEYUP_EVENT: 
+        break;
+      case EventImpl::KEYPRESS_EVENT:
+      {
+        if (!e.isKeyRelatedEvent()) break;
+        const KeyEventBaseImpl&amp; domKeyEv = static_cast&lt;const KeyEventBaseImpl &amp;&gt;(e);
+
+        QKeyEvent* const ke = domKeyEv.qKeyEvent();
+        QScrollBar* vbar = layer()-&gt;verticalScrollbar();
+        QScrollBar* hbar = layer()-&gt;horizontalScrollbar();
+        switch (ke-&gt;key()) {
+          case Qt::Key_PageUp:
+            if(vbar) vbar-&gt;triggerAction(QScrollBar::SliderPageStepSub);
+            break;
+          case Qt::Key_PageDown:
+            if(vbar) vbar-&gt;triggerAction(QScrollBar::SliderPageStepAdd);
+            break;
+          case Qt::Key_Up:
+            if(vbar) vbar-&gt;triggerAction(QScrollBar::SliderSingleStepSub);
+            break;
+          case Qt::Key_Down:
+            if(vbar) vbar-&gt;triggerAction(QScrollBar::SliderSingleStepAdd);
+            break;
+          case Qt::Key_Left:
+            if (hbar) hbar-&gt;triggerAction(QScrollBar::SliderSingleStepSub);
+            break;
+          case Qt::Key_Right:
+            if (hbar) hbar-&gt;triggerAction(QScrollBar::SliderSingleStepAdd);
+            break;
+          default:
+            break;
+        }
+        break;
+      }
+      default: 
+        break;
     }
+    if (accepted)
+        return true;
     return RenderContainer::handleEvent(e);
 }
 
--- trunk/KDE/kdelibs/khtml/xml/dom_elementimpl.cpp #627031:627032
@@ -626,6 +626,25 @@
         m_prefix-&gt;ref();
 }
 
+void ElementImpl::defaultEventHandler(EventImpl *e)
+{
+    if (m_render &amp;&amp; m_render-&gt;scrollsOverflow()) {
+        switch( e-&gt;id() ) {
+          case EventImpl::KEYDOWN_EVENT:
+          case EventImpl::KEYUP_EVENT:
+          case EventImpl::KEYPRESS_EVENT:
+            if (!focused() || e-&gt;target() != this)
+              break;
+          // fall through
+          case EventImpl::KHTML_MOUSEWHEEL_EVENT:
+            if (m_render-&gt;handleEvent(*e))
+                e-&gt;setDefaultHandled();
+          default:
+            break;
+        }
+    }
+}
+
 void ElementImpl::createAttributeMap() const
 {
     namedAttrMap = new NamedAttrMapImpl(const_cast&lt;ElementImpl*&gt;(this));
@@ -789,6 +808,9 @@
 
 bool ElementImpl::isFocusable() const
 {
+    if (m_render &amp;&amp; m_render-&gt;scrollsOverflow())
+        return true;
+
     // Only make editable elements selectable if its parent element
     // is not editable. FIXME: this is not 100% right as non-editable elements
     // within editable elements are focusable too.
--- trunk/KDE/kdelibs/khtml/xml/dom_elementimpl.h #627031:627032
@@ -209,6 +209,8 @@
     virtual void structureChanged();
     virtual void backwardsStructureChanged();
     virtual void attributeChanged(NodeImpl::Id attrId);
+    
+    virtual void defaultEventHandler(EventImpl *evt);
 
     virtual khtml::RenderStyle *styleForRenderer(khtml::RenderObject *parent);
     virtual khtml::RenderObject *createRenderer(khtml::RenderArena *, khtml::RenderStyle *);
--- trunk/KDE/kdelibs/khtml/xml/dom_nodeimpl.cpp #627031:627032
@@ -625,10 +625,6 @@
 
 void NodeImpl::defaultEventHandler(EventImpl *e)
 {
-    if (e-&gt;isMouseEvent() &amp;&amp; e-&gt;id() == EventImpl::KHTML_MOUSEWHEEL_EVENT &amp;&amp; e-&gt;target() == this)
-        if (m_render &amp;&amp; m_render-&gt;scrollsOverflow())
-            if (m_render-&gt;handleEvent(*e))
-                e-&gt;setDefaultHandled();
 }
 
 unsigned long NodeImpl::childNodeCount()
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>540464</commentid>
    <comment_count>10</comment_count>
    <who name="David Lee">davidomundo</who>
    <bug_when>2007-08-11 11:29:49 +0000</bug_when>
    <thetext>Has this been committed into the most recent version (3.5.7)?
It&apos;s not working for me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>540473</commentid>
    <comment_count>11</comment_count>
    <who name="Bram Schoenmakers">me</who>
    <bug_when>2007-08-11 12:51:05 +0000</bug_when>
    <thetext>It should be in KDE 3.5.7, indeed.

So reopening because of comment #10.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>540676</commentid>
    <comment_count>12</comment_count>
    <who name="Tommi Tervo">tommi.tervo</who>
    <bug_when>2007-08-13 08:56:27 +0000</bug_when>
    <thetext>Hmm, Germain didn&apos;t backport this fix to 3.5-branch, so it&apos;s fixed only in KDE4.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>