webengine/osswebengine/WebKit/s60/webview/WebPageScrollHandler.cpp
changeset 36 0ed94ceaa377
parent 13 10e98eab6f85
child 42 d39add9822e2
equal deleted inserted replaced
32:9a9a761f03f1 36:0ed94ceaa377
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include <Browser_platform_variant.hrh>
    20 #include <browser_platform_variant.hrh>
    21 #include <../bidi.h>
    21 #include <../bidi.h>
    22 #include "WebPageScrollHandler.h"
    22 #include "WebPageScrollHandler.h"
    23 #include "BrCtl.h"
    23 #include "BrCtl.h"
    24 #include "WebFrame.h"
    24 #include "WebFrame.h"
    25 #include "WebFrameView.h"
    25 #include "WebFrameView.h"
   370         if (m_scrollableView.m_scrollingElement) {
   370         if (m_scrollableView.m_scrollingElement) {
   371             bool shouldScrollVertically = false;
   371             bool shouldScrollVertically = false;
   372             bool shouldScrollHorizontally = false;
   372             bool shouldScrollHorizontally = false;
   373             WebFrame* frame = kit(m_scrollableView.m_scrollingElement->document()->frame());
   373             WebFrame* frame = kit(m_scrollableView.m_scrollingElement->document()->frame());
   374             RenderObject* render = m_scrollableView.m_scrollingElement->renderer();
   374             RenderObject* render = m_scrollableView.m_scrollingElement->renderer();
   375             __ASSERT_DEBUG(render->isScrollable(), User::Panic(_L(""), KErrGeneral));
   375             if(render) //check if render exits before using it
   376             if (aScrollDelta.iY)
   376                 {
   377                 shouldScrollVertically = !render->scroll(ScrollDown, ScrollByPixel, frame->frameView()->toDocCoords(aScrollDelta).iY / 100);
   377                 __ASSERT_DEBUG(render->isScrollable(), User::Panic(_L(""), KErrGeneral));
   378             if (aScrollDelta.iX)
   378                 if (aScrollDelta.iY)
   379                 shouldScrollHorizontally = !render->scroll(ScrollRight, ScrollByPixel, frame->frameView()->toDocCoords(aScrollDelta).iX / 100);
   379                   shouldScrollVertically = !render->scroll(ScrollDown, ScrollByPixel, frame->frameView()->toDocCoords(aScrollDelta).iY / 100);
   380 
   380                 if (aScrollDelta.iX)
       
   381                   shouldScrollHorizontally = !render->scroll(ScrollRight, ScrollByPixel, frame->frameView()->toDocCoords(aScrollDelta).iX / 100);
       
   382                 }
   381             TPoint scrollPos = frame->frameView()->contentPos();
   383             TPoint scrollPos = frame->frameView()->contentPos();
   382             TPoint newscrollDelta = frame->frameView()->toDocCoords(aScrollDelta);
   384             TPoint newscrollDelta = frame->frameView()->toDocCoords(aScrollDelta);
   383             m_currentNormalizedPosition +=  newscrollDelta;     
   385             m_currentNormalizedPosition +=  newscrollDelta;     
   384 
   386 
   385             if (shouldScrollHorizontally) {
   387             if (shouldScrollHorizontally) {
   557     TPoint pt = frame->frameView()->viewCoordsInFrameCoords(aNewPosition);
   559     TPoint pt = frame->frameView()->viewCoordsInFrameCoords(aNewPosition);
   558     Element* e = core(frame)->document()->elementFromPoint(pt.iX, pt.iY);
   560     Element* e = core(frame)->document()->elementFromPoint(pt.iX, pt.iY);
   559     Element* currElement = NULL;
   561     Element* currElement = NULL;
   560     if(!e) return NULL;
   562     if(!e) return NULL;
   561     RenderObject* render = e->renderer();
   563     RenderObject* render = e->renderer();
   562     if (render && render->isScrollable()) {
   564     if(render) {
   563         RenderLayer* layer = render->enclosingLayer();
   565         RenderLayer* layer = render->enclosingLayer();
   564         Element* parent = e;
   566         Element* parent = e;
   565         currElement = e;
   567 
   566         while (!currElement->isControl() && parent && parent->renderer() && parent->renderer()->enclosingLayer() == layer) {
   568         if (e->isControl()) {
   567             currElement = parent;
   569             if (render->isScrollable()) {
   568             Node* pn = parent;
   570             currElement = e;
   569             do {
   571             }
   570                 pn = pn->parent();
   572         }
   571             } while (pn && !pn->isElementNode());
   573         else {
   572             parent = static_cast<Element*>(pn);
   574             while (parent && parent->renderer()) {
       
   575                 if (parent->renderer()->isScrollable()) {
       
   576                     currElement = parent;
       
   577                     break;
       
   578                     }
       
   579                 parent = static_cast<Element*>(parent->parent());
       
   580                 }
   573         }
   581         }
   574         if (currElement) {
   582         if (currElement) {
       
   583             //check for current element which is scrollable
   575             currElement->ref();
   584             currElement->ref();
   576             m_scrollableView.m_scrollingElement = currElement; 
   585             m_scrollableView.m_scrollingElement = currElement;
   577             m_scrollableView.m_frameView = NULL;
   586             m_scrollableView.m_frameView = NULL;
   578             return true;
   587             return true;
   579         }
   588             }
   580     }
   589         }
   581     return false;
   590     return false;
   582 }
   591 }
   583 
   592 
   584 
   593 
   585 void WebPageScrollHandler::scrollPageOverviewGH()
   594 void WebPageScrollHandler::scrollPageOverviewGH()