diff -r 6297cdf66332 -r d39add9822e2 webengine/osswebengine/WebKit/s60/webview/WebView.cpp --- a/webengine/osswebengine/WebKit/s60/webview/WebView.cpp Mon Jan 18 21:20:18 2010 +0200 +++ b/webengine/osswebengine/WebKit/s60/webview/WebView.cpp Tue Feb 02 00:56:45 2010 +0200 @@ -60,7 +60,7 @@ #include "PluginWin.h" #include "PluginPlayer.h" #include "WebKitLogger.h" - +#include "WebPagePinchZoomHandler.h" #include "Page.h" #include "Settings.h" @@ -201,6 +201,8 @@ , m_prevEditMode(false) , m_firedEvent(0) , m_waitTimer(0) +, m_pinchZoomHandler(NULL) +, m_isPinchZoom(false) { } @@ -227,12 +229,16 @@ delete m_fastScrollTimer; delete [] m_ptrbuffer; + delete m_pinchZoomHandler; delete m_repainttimer; delete m_webfeptexteditor; delete m_webcorecontext; delete m_bitmapdevice; delete m_page; delete m_pageScaler; +#ifdef BRDO_SINGLE_CLICK_ENABLED_FF + m_pageScaler = NULL; +#endif delete m_pageView; delete m_webFormFill; delete m_toolbar; @@ -337,7 +343,10 @@ if (m_brctl->capabilities() & TBrCtlDefs::ECapabilityAutoFormFill) { m_webFormFill = new WebFormFill(this); } - + + //Creates the Pinch Zoom Handler + m_pinchZoomHandler = WebPagePinchZoomHandler::NewL(this); + // Create the PointerEventHandler m_ptrbuffer = new TPoint[256]; m_webpointerEventHandler = WebPointerEventHandler::NewL(this); @@ -360,7 +369,10 @@ MakeViewVisible(ETrue); m_isPluginsVisible=ETrue; CCoeControl::SetFocus(ETrue); - +#ifdef BRDO_MULTITOUCH_ENABLED_FF + //To enable advance pointer info for multi-touch + Window().EnableAdvancedPointers(); +#endif cache()->setCapacities(0, 0, defaultCacheCapacity); m_waiter = new(ELeave) CActiveSchedulerWait(); @@ -404,13 +416,27 @@ gc.DrawBitmap( m_destRectForZooming, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), m_srcRectForZooming ); if ( m_startZoomLevel > m_currentZoomLevel) { - +#ifdef BRDO_MULTITOUCH_ENABLED_FF + TInt destRectWidth = m_destRectForZooming.Width(); + TInt destRectHeight = m_destRectForZooming.Height(); + TRect rectLeft(TPoint(rect.iTl), + TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX, rect.iBr.iY)); + + TRect rectRight(TPoint(rect.iTl.iX + destRectWidth + m_destRectForZooming.iTl.iX, rect.iTl.iY), + TPoint(rect.iBr)); + + TRect rectTop(TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX, rect.iTl.iY), + TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX + destRectWidth, rect.iTl.iY + m_destRectForZooming.iTl.iY)); + + TRect rectBottom(TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX, rect.iTl.iY + m_destRectForZooming.iTl.iY + destRectHeight), + TPoint(rect.iTl.iX + destRectWidth + m_destRectForZooming.iTl.iX, rect.iBr.iY)); +#else TRect rectLeft( TPoint( rect.iTl.iX + m_destRectForZooming.Width() - 2, rect.iTl.iY ), TPoint( rect.iBr )); TRect rectBottom( TPoint( rect.iTl.iX, rect.iTl.iY + m_destRectForZooming.Height() - 2 ), TPoint( rect.iBr.iX + m_destRectForZooming.Width(), rect.iBr.iY )); - +#endif const TRgb colorTest(KZoomBgRectColor,KZoomBgRectColor,KZoomBgRectColor); gc.SetPenColor(colorTest); @@ -418,6 +444,10 @@ gc.SetBrushColor(colorTest); gc.DrawRect( rectLeft ); gc.DrawRect( rectBottom ); +#ifdef BRDO_MULTITOUCH_ENABLED_FF + gc.DrawRect( rectRight ); + gc.DrawRect( rectTop ); +#endif } @@ -525,6 +555,7 @@ clearOffScreenBitmap(); m_tabbedNavigation->initializeForPage(); syncRepaint( mainFrame()->frameView()->visibleRect() ); + TRAP_IGNORE( m_webfeptexteditor->EnableCcpuL() ); } } @@ -1073,6 +1104,9 @@ m_focusedElementType == TBrCtlDefs::EElementBrokenImage ) && keyevent.iRepeats && !m_brctl->wmlMode() ) { launchToolBarL(); + if(m_toolbar) { + sendMouseEventToEngineIfNeeded(TPointerEvent::EButton1Up, cursor->position(), frame); + } } return true; @@ -2015,6 +2049,7 @@ m_findKeyword = NULL; WebFrame* selectedFrame = mainFrame()->findFrameWithSelection(); selectedFrame->clearSelection(); + setFocusNone(); } bool WebView::isSmallPage() @@ -2031,26 +2066,6 @@ } } - -//------------------------------------------------------------------------------- -// WebView::HandlePointerBufferReadyL -// Handles pointer move events -//------------------------------------------------------------------------------- -void WebView::HandlePointerBufferReadyL() -{ - memset(m_ptrbuffer,0,256*sizeof(TPoint)); - TPtr8 ptr((TUint8 *)m_ptrbuffer,256*sizeof(TPoint)); - - TInt numPnts = Window().RetrievePointerMoveBuffer(ptr); - int i = 0; - for (; i < numPnts; i++) { - TPointerEvent pe; - pe.iType = TPointerEvent::EDrag; - pe.iPosition = m_ptrbuffer[i]; - m_webpointerEventHandler->HandlePointerEventL(pe); - } -} - //------------------------------------------------------------------------------- // WebView::HandlePointerEventL // Handles pointer events @@ -2404,6 +2419,25 @@ mainFrame()->scalingFactorChanged(z); view->checkScrollbarVisibility(); + if (m_isPinchZoom) { + if (newZoomLevel > m_startZoomLevel) { + TPoint cpos( mainFrame()->frameView()->contentPos()); + cpos.iX = cpos.iX + m_pinchDocDelta.iX +.5; + cpos.iY = cpos.iY + m_pinchDocDelta.iY +.5; + mainFrame()->frameView()->setContentPos(cpos); + } + if (m_startZoomLevel > newZoomLevel) { + TPoint cpos( mainFrame()->frameView()->contentPos()); + cpos.iX = cpos.iX - m_pinchDocDelta.iX +.5; + cpos.iY = cpos.iY - m_pinchDocDelta.iY +.5; + + if (cpos.iX < 0) cpos.iX = 0; + if (cpos.iY < 0) cpos.iY = 0; + mainFrame()->frameView()->setContentPos(cpos); + } + m_isPinchZoom = false; + } + TRect rect = view->rect(); TInt tlx = (rect.iTl.iX * currZoomLevel) / m_currentZoomLevel; @@ -2943,5 +2977,96 @@ } } +//------------------------------------------------------------------------------- +// WebView::setPinchBitmapZoomLevel +//------------------------------------------------------------------------------- +void WebView::setPinchBitmapZoomLevel(int zoomLevel) +{ + m_zoomLevelChangedByUser = true; + m_dirtyZoomMode = true; + m_isPluginsVisible = false; + mainFrame()->makeVisiblePlugins(false); + m_isPinchZoom = true; + + if (zoomLevel > m_startZoomLevel) { + setPinchBitmapZoomIn(zoomLevel); + } + else { + setPinchBitmapZoomOut(zoomLevel); + } + m_currentZoomLevel = zoomLevel; + DrawNow(); +} + +//------------------------------------------------------------------------------- +// WebView::setPinchBitmapZoomIn +//------------------------------------------------------------------------------- +void WebView::setPinchBitmapZoomIn(int zoomLevel) +{ + TPoint pinchCenter = m_pinchZoomHandler->pinchCenter(); + + // cut m_srcRectForZooming from m_offscreenrect and enlarge it to fit the view rect + TRealPoint centerAfterZoom; + //find out the new position of Pinch Center after applying zoom + centerAfterZoom.iX = (float)pinchCenter.iX * zoomLevel/m_startZoomLevel; + centerAfterZoom.iY = (float)pinchCenter.iY * zoomLevel/m_startZoomLevel; + TRealPoint centerDelta; + //get the shift in the Pinch Center + centerDelta.iX = centerAfterZoom.iX - pinchCenter.iX; + centerDelta.iY = centerAfterZoom.iY - pinchCenter.iY; + TPoint shiftInView; + //find out how much shift needs to be applied to the current zoom, w.r.t. the new view + shiftInView.iX = centerDelta.iX * m_startZoomLevel / zoomLevel; + shiftInView.iY = centerDelta.iY * m_startZoomLevel / zoomLevel; + //width and height of the rectangle that should be used for bitmap stretching + float newWidth = (float)m_offscreenrect.Width() * m_startZoomLevel / zoomLevel; + float newHeight = (float)m_offscreenrect.Height() * m_startZoomLevel /zoomLevel; + //defining the source rectangle which needs to be bitmap stretched + m_srcRectForZooming.iTl.iX = shiftInView.iX; + m_srcRectForZooming.iTl.iY = shiftInView.iY; + m_srcRectForZooming.iBr.iX = newWidth + shiftInView.iX; + m_srcRectForZooming.iBr.iY = newHeight + shiftInView.iY; + //destRectForZooming is the Coecontrol Rect itself + m_destRectForZooming = Rect(); + //get the shift in the document so that during the next engine re-draw, the origin needs to be updated based on that + m_pinchDocDelta.iX = (float)shiftInView.iX * 100 / m_startZoomLevel; + m_pinchDocDelta.iY = (float)shiftInView.iY * 100 / m_startZoomLevel; +} + + +//------------------------------------------------------------------------------- +// WebView::setPinchBitmapZoomOut +//------------------------------------------------------------------------------- +void WebView::setPinchBitmapZoomOut(int zoomLevel) +{ + TPoint pinchCenter = m_pinchZoomHandler->pinchCenter(); + + // take the whole rect and calculate new rect to fit it the rest of view rect paint gray colour + TRealPoint centerAfterZoom; + //find out the new position of Pinch Center after applying zoom + centerAfterZoom.iX = (float)pinchCenter.iX * m_startZoomLevel / zoomLevel; + centerAfterZoom.iY = (float)pinchCenter.iY * m_startZoomLevel / zoomLevel; + TRealPoint centerDelta; + //get the shift in the Pinch Center + centerDelta.iX = centerAfterZoom.iX - pinchCenter.iX; + centerDelta.iY = centerAfterZoom.iY - pinchCenter.iY; + TPoint shiftInView; + //find out how much shift needs to be applied to the current zoom, w.r.t. the new view + shiftInView.iX = centerDelta.iX * zoomLevel / m_startZoomLevel; + shiftInView.iY = centerDelta.iY * zoomLevel / m_startZoomLevel; + //width and height of the rectangle + float newWidth = (float)m_offscreenrect.Width() * zoomLevel / m_startZoomLevel; + float newHeight = (float)m_offscreenrect.Height() * zoomLevel / m_startZoomLevel; + //defining the co-ordinates of the destination rectangle. + m_destRectForZooming.iTl.iX = shiftInView.iX; + m_destRectForZooming.iTl.iY = shiftInView.iY; + m_destRectForZooming.iBr.iX = newWidth + shiftInView.iX; + m_destRectForZooming.iBr.iY = newHeight + shiftInView.iY; + //srcRectForZooming is the Coecontrol Rect itself + m_srcRectForZooming = Rect(); + //get the shift in the document so that during the next engine re-draw, the origin needs to be updated based on that + m_pinchDocDelta.iX = (float)shiftInView.iX * 100 / zoomLevel; + m_pinchDocDelta.iY = (float)shiftInView.iY * 100 / zoomLevel; +} // END OF FILE