303 m_scrollTimer->Cancel(); |
301 m_scrollTimer->Cancel(); |
304 m_scrollTimer->Start( 0, KScrollIntervalTimeout, TCallBack(&handleScrollTimerEventCallback,this)); |
302 m_scrollTimer->Start( 0, KScrollIntervalTimeout, TCallBack(&handleScrollTimerEventCallback,this)); |
305 m_webView->setViewIsScrolling(true); |
303 m_webView->setViewIsScrolling(true); |
306 m_webView->toggleRepaintTimer(false); |
304 m_webView->toggleRepaintTimer(false); |
307 } |
305 } |
308 |
306 } |
309 |
307 |
310 } |
308 |
|
309 void WebPageScrollHandler::clearScrollingElement() |
|
310 { |
|
311 if (m_scrollableView.m_scrollingElement) { |
|
312 m_scrollableView.m_scrollingElement->deref(); |
|
313 m_scrollableView.m_scrollingElement = NULL; |
|
314 } |
|
315 } |
311 |
316 |
312 void WebPageScrollHandler::scrollContent() |
317 void WebPageScrollHandler::scrollContent() |
313 { |
318 { |
314 TPoint scrollDelta = m_lastPosition - m_currentPosition; |
319 TPoint scrollDelta = m_lastPosition - m_currentPosition; |
315 |
320 scrollContent(scrollDelta); |
|
321 } |
|
322 |
|
323 void WebPageScrollHandler::scrollContent(TPoint& aScrollDelta) |
|
324 { |
316 if(!m_scrollableView.activeFrameView()) |
325 if(!m_scrollableView.activeFrameView()) |
317 return; |
326 return; |
318 |
327 |
319 int absX = Abs(scrollDelta.iX); |
328 |
320 int absY = Abs(scrollDelta.iY); |
329 int absX = Abs(aScrollDelta.iX); |
|
330 int absY = Abs(aScrollDelta.iY); |
321 |
331 |
322 if(absX || absY) //move only if necessary |
332 if(absX || absY) //move only if necessary |
323 { |
333 { |
324 // calculate which direction we are trying to scroll |
334 // calculate which direction we are trying to scroll |
325 if(m_scrollDirectionState == ScrollDirectionUnassigned) { |
335 if(m_scrollDirectionState == ScrollDirectionUnassigned) { |
329 |
339 |
330 switch (m_scrollDirectionState) |
340 switch (m_scrollDirectionState) |
331 { |
341 { |
332 case ScrollDirectionX: //scroll in X dir |
342 case ScrollDirectionX: //scroll in X dir |
333 { |
343 { |
334 scrollDelta.iY = 0; |
344 aScrollDelta.iY = 0; |
335 scrollDelta.iX *= 100; |
345 aScrollDelta.iX *= 100; |
336 //Fallback to XY state if the current position is out of bounds |
346 //Fallback to XY state if the current position is out of bounds |
337 TPoint boundaryCheckpoint = m_focalPoint - m_currentPosition; |
347 TPoint boundaryCheckpoint = m_focalPoint - m_currentPosition; |
338 if(Abs(boundaryCheckpoint.iY) > KScrollDirectionBoundary) |
348 if(Abs(boundaryCheckpoint.iY) > KScrollDirectionBoundary) |
339 m_scrollDirectionState = ScrollDirectionXY; |
349 m_scrollDirectionState = ScrollDirectionXY; |
340 break; |
350 break; |
341 } |
351 } |
342 case ScrollDirectionY: //scroll in Y dir |
352 case ScrollDirectionY: //scroll in Y dir |
343 { |
353 { |
344 scrollDelta.iX = 0; |
354 aScrollDelta.iX = 0; |
345 scrollDelta.iY *= 100; |
355 aScrollDelta.iY *= 100; |
346 //Fallback to XY state if the current position is out of bounds |
356 //Fallback to XY state if the current position is out of bounds |
347 TPoint boundaryCheckpoint = m_focalPoint - m_currentPosition; |
357 TPoint boundaryCheckpoint = m_focalPoint - m_currentPosition; |
348 if(Abs(boundaryCheckpoint.iX) > KScrollDirectionBoundary) |
358 if(Abs(boundaryCheckpoint.iX) > KScrollDirectionBoundary) |
349 m_scrollDirectionState = ScrollDirectionXY; |
359 m_scrollDirectionState = ScrollDirectionXY; |
350 break; |
360 break; |
351 } |
361 } |
352 case ScrollDirectionXY: //scroll in XY |
362 case ScrollDirectionXY: //scroll in XY |
353 { |
363 { |
354 scrollDelta.iX *= 100; |
364 aScrollDelta.iX *= 100; |
355 scrollDelta.iY *= 100; |
365 aScrollDelta.iY *= 100; |
356 m_scrollDirectionState = ScrollDirectionUnassigned; |
366 m_scrollDirectionState = ScrollDirectionUnassigned; |
357 break; |
367 break; |
358 } |
368 } |
359 } |
369 } |
360 if (m_scrollableView.m_scrollingElement) { |
370 if (m_scrollableView.m_scrollingElement) { |
361 bool shouldScrollVertically = false; |
371 bool shouldScrollVertically = false; |
362 bool shouldScrollHorizontally = false; |
372 bool shouldScrollHorizontally = false; |
363 //WebFrameView* mfv = m_webView->mainFrame()->frameView(); |
|
364 WebFrame* frame = kit(m_scrollableView.m_scrollingElement->document()->frame()); |
373 WebFrame* frame = kit(m_scrollableView.m_scrollingElement->document()->frame()); |
365 IntPoint currPoint = frame->frameView()->viewCoordsInFrameCoords(m_currentPosition); |
|
366 RenderObject* render = m_scrollableView.m_scrollingElement->renderer(); |
374 RenderObject* render = m_scrollableView.m_scrollingElement->renderer(); |
367 __ASSERT_DEBUG(render->isScrollable(), User::Panic(_L(""), KErrGeneral)); |
375 __ASSERT_DEBUG(render->isScrollable(), User::Panic(_L(""), KErrGeneral)); |
368 if (scrollDelta.iY) |
376 if (aScrollDelta.iY) |
369 shouldScrollVertically = !render->scroll(ScrollDown, ScrollByPixel, frame->frameView()->toDocCoords(scrollDelta).iY / 100); |
377 shouldScrollVertically = !render->scroll(ScrollDown, ScrollByPixel, frame->frameView()->toDocCoords(aScrollDelta).iY / 100); |
370 if (scrollDelta.iX) |
378 if (aScrollDelta.iX) |
371 shouldScrollHorizontally = !render->scroll(ScrollRight, ScrollByPixel, frame->frameView()->toDocCoords(scrollDelta).iX / 100); |
379 shouldScrollHorizontally = !render->scroll(ScrollRight, ScrollByPixel, frame->frameView()->toDocCoords(aScrollDelta).iX / 100); |
|
380 |
372 TPoint scrollPos = frame->frameView()->contentPos(); |
381 TPoint scrollPos = frame->frameView()->contentPos(); |
373 TPoint newscrollDelta = frame->frameView()->toDocCoords(scrollDelta); |
382 TPoint newscrollDelta = frame->frameView()->toDocCoords(aScrollDelta); |
374 m_currentNormalizedPosition += newscrollDelta; |
383 m_currentNormalizedPosition += newscrollDelta; |
375 |
384 |
376 if (shouldScrollHorizontally) { |
385 if (shouldScrollHorizontally) { |
377 scrollPos.iX = m_currentNormalizedPosition.iX/100; |
386 scrollPos.iX = m_currentNormalizedPosition.iX/100; |
378 } |
387 } |
379 if (shouldScrollVertically) { |
388 if (shouldScrollVertically) { |
380 scrollPos.iY = m_currentNormalizedPosition.iY/100; |
389 scrollPos.iY = m_currentNormalizedPosition.iY/100; |
381 } |
390 } |
382 frame->frameView()->scrollTo(scrollPos); |
391 |
|
392 |
|
393 if (shouldScrollVertically || shouldScrollHorizontally){ |
|
394 if (m_scrollableView.m_frameView->needScroll(scrollPos)) { |
|
395 frame->frameView()->scrollTo(scrollPos); |
|
396 updateScrollbars(scrollPos, newscrollDelta); |
|
397 core(frame)->sendScrollEvent(); |
|
398 } |
|
399 } |
|
400 else { |
|
401 m_webView->syncRepaint(); |
|
402 } |
383 m_lastPosition = m_currentPosition; |
403 m_lastPosition = m_currentPosition; |
384 m_currentNormalizedPosition.iX = frame->frameView()->contentPos().iX * 100; |
404 m_currentNormalizedPosition.iX = frame->frameView()->contentPos().iX * 100; |
385 m_currentNormalizedPosition.iY = frame->frameView()->contentPos().iY * 100; |
405 m_currentNormalizedPosition.iY = frame->frameView()->contentPos().iY * 100; |
386 if (shouldScrollVertically || shouldScrollHorizontally) |
|
387 updateScrollbars(scrollPos, newscrollDelta); |
|
388 currPoint = frame->frameView()->viewCoordsInFrameCoords(m_currentPosition); |
|
389 if (shouldScrollHorizontally || shouldScrollVertically) { |
|
390 core(frame)->sendScrollEvent(); |
|
391 m_webView->DrawNow(); |
|
392 } |
|
393 } |
406 } |
394 else { |
407 else { |
395 TPoint scrollPos; |
408 TPoint scrollPos; |
396 TPoint newscrollDelta = m_scrollableView.m_frameView->toDocCoords(scrollDelta); |
409 TPoint newscrollDelta = m_scrollableView.m_frameView->toDocCoords(aScrollDelta); |
397 m_currentNormalizedPosition += newscrollDelta; |
410 m_currentNormalizedPosition += newscrollDelta; |
398 scrollPos.iX = m_currentNormalizedPosition.iX/100; |
411 scrollPos.iX = m_currentNormalizedPosition.iX/100; |
399 scrollPos.iY = m_currentNormalizedPosition.iY/100; |
412 scrollPos.iY = m_currentNormalizedPosition.iY/100; |
400 TPoint cpos = m_scrollableView.m_frameView->contentPos(); |
413 TPoint cpos = m_scrollableView.m_frameView->contentPos(); |
401 |
414 |
632 m_webView->toggleRepaintTimer(true); |
646 m_webView->toggleRepaintTimer(true); |
633 } |
647 } |
634 else { |
648 else { |
635 m_scrollTimer->Cancel(); |
649 m_scrollTimer->Cancel(); |
636 m_lastPosition = TPoint(0, 0); |
650 m_lastPosition = TPoint(0, 0); |
637 if (m_scrollableView.m_scrollingElement) { |
651 decelDoesScrollbars = startDeceleration(aEvent); |
638 if (m_scrollableView.m_scrollingElement) { |
|
639 m_scrollableView.m_scrollingElement->deref(); |
|
640 m_scrollableView.m_scrollingElement = NULL; |
|
641 } |
|
642 } |
|
643 else { |
|
644 decelDoesScrollbars = startDeceleration(aEvent); |
|
645 |
652 |
646 if (m_webView->viewIsScrolling()) { |
653 if (m_webView->viewIsScrolling()) { |
647 Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame(); |
654 Frame* frame = m_webView->page()->focusController()->focusedOrMainFrame(); |
648 frame->bridge()->sendScrollEvent(); |
655 frame->bridge()->sendScrollEvent(); |
649 } |
|
650 } |
656 } |
651 |
657 |
652 if (!decelDoesScrollbars) { |
658 if (!decelDoesScrollbars) { |
653 m_scrollbarDrawer->fadeScrollbar(); |
659 m_scrollbarDrawer->fadeScrollbar(); |
654 m_webView->setViewIsScrolling(false); |
660 m_webView->setViewIsScrolling(false); |