131 const int KZoomBgRectColor = 209; |
131 const int KZoomBgRectColor = 209; |
132 const int KZoomDefaultLevel = 8; //100% |
132 const int KZoomDefaultLevel = 8; //100% |
133 const int defaultCacheCapacity = 256 * 1024; |
133 const int defaultCacheCapacity = 256 * 1024; |
134 |
134 |
135 const int KMaxMissedDrawsAllowed = 5;//Max missed repaint allowed before paint happens |
135 const int KMaxMissedDrawsAllowed = 5;//Max missed repaint allowed before paint happens |
|
136 const int KCheckerSize = 10; |
|
137 const int KZoomFgRectColor = 150; |
|
138 const int KCheckerBoardDestroyTimeout = 2*1000*1000; |
136 |
139 |
137 // LOCAL FUNCTION PROTOTYPES |
140 // LOCAL FUNCTION PROTOTYPES |
138 TInt doRepaintCb( TAny* ptr ); |
141 TInt doRepaintCb( TAny* ptr ); |
139 TInt doFepCb( TAny* ptr ); |
142 TInt doFepCb( TAny* ptr ); |
|
143 TInt doDestroyCheckerBoardCb(TAny *ptr); |
140 |
144 |
141 static WebFrame* incrementFrame(WebFrame* curr, bool forward, bool wrapFlag) |
145 static WebFrame* incrementFrame(WebFrame* curr, bool forward, bool wrapFlag) |
142 { |
146 { |
143 Frame* coreFrame = core(curr); |
147 Frame* coreFrame = core(curr); |
144 return kit(forward |
148 return kit(forward |
378 CleanupStack::PopAndDestroy(2); // userAgent8, usrAgnt |
391 CleanupStack::PopAndDestroy(2); // userAgent8, usrAgnt |
379 |
392 |
380 MakeViewVisible(ETrue); |
393 MakeViewVisible(ETrue); |
381 m_isPluginsVisible=ETrue; |
394 m_isPluginsVisible=ETrue; |
382 CCoeControl::SetFocus(ETrue); |
395 CCoeControl::SetFocus(ETrue); |
383 |
|
384 #if defined(BRDO_MULTITOUCH_ENABLED_FF) && !defined (__WINSCW__) |
|
385 //Enable advance pointer info for multi-touch. |
|
386 Window().EnableAdvancedPointers(); |
|
387 #endif |
|
388 |
396 |
389 cache()->setCapacities(0, 0, defaultCacheCapacity); |
397 cache()->setCapacities(0, 0, defaultCacheCapacity); |
390 |
398 |
391 m_waiter = new(ELeave) CActiveSchedulerWait(); |
399 m_waiter = new(ELeave) CActiveSchedulerWait(); |
|
400 |
|
401 m_checkerBoardDestroyTimer = CPeriodic::NewL(CActive::EPriorityIdle); |
|
402 |
392 } |
403 } |
393 |
404 |
394 void WebView::initializePageScalerL() |
405 void WebView::initializePageScalerL() |
395 { |
406 { |
396 TBool lowQuality = !( m_brctl->capabilities() & TBrCtlDefs::ECapabilityGraphicalHistory ); |
407 TBool lowQuality = !( m_brctl->capabilities() & TBrCtlDefs::ECapabilityGraphicalHistory ); |
424 if (m_widgetextension){ |
435 if (m_widgetextension){ |
425 m_widgetextension->DrawTransition(gc,StaticObjectsContainer::instance()->webSurface()->offscreenBitmap()); |
436 m_widgetextension->DrawTransition(gc,StaticObjectsContainer::instance()->webSurface()->offscreenBitmap()); |
426 } |
437 } |
427 } |
438 } |
428 else { |
439 else { |
|
440 #ifndef BRDO_MULTITOUCH_ENABLED_FF |
429 gc.DrawBitmap( m_destRectForZooming, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), m_srcRectForZooming ); |
441 gc.DrawBitmap( m_destRectForZooming, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), m_srcRectForZooming ); |
430 |
442 |
431 if ( m_startZoomLevel > m_currentZoomLevel) { |
443 if ( m_startZoomLevel > m_currentZoomLevel) { |
432 #ifdef BRDO_MULTITOUCH_ENABLED_FF |
444 |
433 TInt destRectWidth = m_destRectForZooming.Width(); |
|
434 TInt destRectHeight = m_destRectForZooming.Height(); |
|
435 TRect rectLeft(TPoint(rect.iTl), |
|
436 TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX, rect.iBr.iY)); |
|
437 |
|
438 TRect rectRight(TPoint(rect.iTl.iX + destRectWidth + m_destRectForZooming.iTl.iX, rect.iTl.iY), |
|
439 TPoint(rect.iBr)); |
|
440 |
|
441 TRect rectTop(TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX, rect.iTl.iY), |
|
442 TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX + destRectWidth, rect.iTl.iY + m_destRectForZooming.iTl.iY)); |
|
443 |
|
444 TRect rectBottom(TPoint(rect.iTl.iX + m_destRectForZooming.iTl.iX, rect.iTl.iY + m_destRectForZooming.iTl.iY + destRectHeight), |
|
445 TPoint(rect.iTl.iX + destRectWidth + m_destRectForZooming.iTl.iX, rect.iBr.iY)); |
|
446 #else |
|
447 TRect rectLeft( TPoint( rect.iTl.iX + m_destRectForZooming.Width() - 2, rect.iTl.iY ), |
445 TRect rectLeft( TPoint( rect.iTl.iX + m_destRectForZooming.Width() - 2, rect.iTl.iY ), |
448 TPoint( rect.iBr )); |
446 TPoint( rect.iBr )); |
449 |
447 |
450 TRect rectBottom( TPoint( rect.iTl.iX, rect.iTl.iY + m_destRectForZooming.Height() - 2 ), |
448 TRect rectBottom( TPoint( rect.iTl.iX, rect.iTl.iY + m_destRectForZooming.Height() - 2 ), |
451 TPoint( rect.iBr.iX + m_destRectForZooming.Width(), rect.iBr.iY )); |
449 TPoint( rect.iBr.iX + m_destRectForZooming.Width(), rect.iBr.iY )); |
452 #endif |
450 |
453 |
451 |
454 const TRgb colorTest(KZoomBgRectColor,KZoomBgRectColor,KZoomBgRectColor); |
452 const TRgb colorTest(KZoomBgRectColor,KZoomBgRectColor,KZoomBgRectColor); |
455 gc.SetPenColor(colorTest); |
453 gc.SetPenColor(colorTest); |
456 gc.SetBrushStyle( CGraphicsContext::EForwardDiagonalHatchBrush ); |
454 gc.SetBrushStyle( CGraphicsContext::EForwardDiagonalHatchBrush ); |
457 gc.SetBrushColor(colorTest); |
455 gc.SetBrushColor(colorTest); |
458 gc.DrawRect( rectLeft ); |
456 gc.DrawRect( rectLeft ); |
459 gc.DrawRect( rectBottom ); |
457 gc.DrawRect( rectBottom ); |
460 #ifdef BRDO_MULTITOUCH_ENABLED_FF |
458 } |
461 gc.DrawRect( rectRight ); |
459 #else |
462 gc.DrawRect( rectTop ); |
460 if ( m_startZoomLevel > m_currentZoomLevel) { |
463 #endif |
461 gc.BitBlt(rect.iTl,m_checkerBoardBitmap); |
464 |
462 } |
465 } |
463 gc.DrawBitmap( m_destRectForZooming, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), m_srcRectForZooming ); |
466 |
464 #endif |
467 } |
465 } |
468 |
466 |
469 if (m_pageScalerEnabled && m_pageScaler->Visible()) { |
467 if (m_pageScalerEnabled && m_pageScaler->Visible()) { |
470 m_pageScaler->Draw( gc, rect ); |
468 m_pageScaler->Draw( gc, rect ); |
471 } |
469 } |
602 return; |
615 return; |
603 if(!( m_widgetextension && m_widgetextension->IsWidgetPublising())) { |
616 if(!( m_widgetextension && m_widgetextension->IsWidgetPublising())) { |
604 mainFrame()->frameView()->draw( *m_webcorecontext, rect ); |
617 mainFrame()->frameView()->draw( *m_webcorecontext, rect ); |
605 if ( zoomLevel < m_minZoomLevel ) zoomLevel = m_minZoomLevel; |
618 if ( zoomLevel < m_minZoomLevel ) zoomLevel = m_minZoomLevel; |
606 zoomLevelChanged( zoomLevel ); |
619 zoomLevelChanged( zoomLevel ); |
607 } |
620 |
|
621 #ifndef BRDO_MULTITOUCH_ENABLED_FF |
|
622 if(m_pageZoomHandler) { |
|
623 //Slider value will change if the content size is changed when layout is done |
|
624 //hide the slider, so that user will get new min and max zoom level |
|
625 if (m_pageZoomHandler->isActive()) { |
|
626 TRAP_IGNORE( |
|
627 m_pageZoomHandler->hideZoomSliderL(); |
|
628 ); |
|
629 } |
|
630 } |
|
631 #endif |
|
632 } |
|
633 mainFrame()->notifyPluginsOfPositionChange(); |
608 } |
634 } |
609 //------------------------------------------------------------------------------- |
635 //------------------------------------------------------------------------------- |
610 // WebView::syncRepaint |
636 // WebView::syncRepaint |
611 // Repaint the current repaint region synchronously and clear it |
637 // Repaint the current repaint region synchronously and clear it |
612 //------------------------------------------------------------------------------- |
638 //------------------------------------------------------------------------------- |
2465 if (cpos.iX < 0) cpos.iX = 0; |
2500 if (cpos.iX < 0) cpos.iX = 0; |
2466 if (cpos.iY < 0) cpos.iY = 0; |
2501 if (cpos.iY < 0) cpos.iY = 0; |
2467 mainFrame()->frameView()->setContentPos(cpos); |
2502 mainFrame()->frameView()->setContentPos(cpos); |
2468 } |
2503 } |
2469 m_isPinchZoom = false; |
2504 m_isPinchZoom = false; |
|
2505 m_isPinchZoomOut = false; |
2470 } |
2506 } |
2471 |
2507 |
2472 TRect rect = view->rect(); |
2508 TRect rect = view->rect(); |
2473 |
2509 TRect rectToZoom; |
2474 TInt tlx = (rect.iTl.iX * currZoomLevel) / m_currentZoomLevel; |
2510 calculateZoomRect(rect, rectToZoom, currZoomLevel, m_currentZoomLevel); |
2475 TInt tly = (rect.iTl.iY * currZoomLevel) / m_currentZoomLevel; |
2511 view->setRect(rectToZoom); |
2476 TInt brx = (rect.iBr.iX * currZoomLevel) / m_currentZoomLevel; |
|
2477 TInt bry = (rect.iBr.iY * currZoomLevel) / m_currentZoomLevel; |
|
2478 |
|
2479 // rounding |
|
2480 |
|
2481 if (( rect.iTl.iX * currZoomLevel) % m_currentZoomLevel ){ |
|
2482 tlx -= 1; |
|
2483 } |
|
2484 if (( rect.iTl.iY * currZoomLevel) % m_currentZoomLevel ){ |
|
2485 tly -= 1; |
|
2486 } |
|
2487 if ((rect.iBr.iX * currZoomLevel) % m_currentZoomLevel ){ |
|
2488 brx += 1; |
|
2489 } |
|
2490 if ((rect.iBr.iY * currZoomLevel) % m_currentZoomLevel ){ |
|
2491 bry += 1; |
|
2492 } |
|
2493 |
|
2494 view->setRect(TRect(tlx, tly, brx, bry)); |
|
2495 |
2512 |
2496 // now just do a repaint, should be very fast |
2513 // now just do a repaint, should be very fast |
2497 if ( currZoomLevel > newZoomLevel ) { |
2514 if ( currZoomLevel > newZoomLevel ) { |
2498 clearOffScreenBitmap(); |
2515 clearOffScreenBitmap(); |
2499 } |
2516 } |
3014 m_waiter->AsyncStop(); |
3031 m_waiter->AsyncStop(); |
3015 } |
3032 } |
3016 } |
3033 } |
3017 |
3034 |
3018 //------------------------------------------------------------------------------- |
3035 //------------------------------------------------------------------------------- |
3019 // WebView::setPinchBitmapZoomLevel |
3036 // WebView::setPinchBitmapZoomLevelL |
3020 //------------------------------------------------------------------------------- |
3037 //------------------------------------------------------------------------------- |
3021 void WebView::setPinchBitmapZoomLevel(int zoomLevel) |
3038 void WebView::setPinchBitmapZoomLevelL(int zoomLevel) |
3022 { |
3039 { |
3023 m_zoomLevelChangedByUser = true; |
3040 m_zoomLevelChangedByUser = true; |
3024 m_dirtyZoomMode = true; |
3041 m_dirtyZoomMode = true; |
3025 m_isPluginsVisible = false; |
3042 m_isPluginsVisible = false; |
3026 m_isPinchZoom = true; |
3043 m_isPinchZoom = true; |
3027 |
3044 |
3028 if (zoomLevel > m_startZoomLevel) { |
3045 if (zoomLevel > m_startZoomLevel) { |
3029 setPinchBitmapZoomIn(zoomLevel); |
3046 setPinchBitmapZoomIn(zoomLevel); |
3030 } |
3047 } |
3031 else { |
3048 else { |
3032 setPinchBitmapZoomOut(zoomLevel); |
3049 setPinchBitmapZoomOutL(zoomLevel); |
|
3050 m_isPinchZoomOut = true; |
3033 } |
3051 } |
3034 m_currentZoomLevel = zoomLevel; |
3052 m_currentZoomLevel = zoomLevel; |
3035 DrawNow(); |
3053 DrawNow(); |
3036 PluginSkin* pluginskin = mainFrame()->focusedPlugin(); |
3054 PluginSkin* pluginskin = mainFrame()->focusedPlugin(); |
3037 if(pluginskin) |
3055 if(pluginskin) |
3107 //srcRectForZooming is the Coecontrol Rect itself |
3125 //srcRectForZooming is the Coecontrol Rect itself |
3108 m_srcRectForZooming = Rect(); |
3126 m_srcRectForZooming = Rect(); |
3109 //get the shift in the document so that during the next engine re-draw, the origin needs to be updated based on that |
3127 //get the shift in the document so that during the next engine re-draw, the origin needs to be updated based on that |
3110 m_pinchDocDelta.iX = (float)shiftInView.iX * 100 / zoomLevel; |
3128 m_pinchDocDelta.iX = (float)shiftInView.iX * 100 / zoomLevel; |
3111 m_pinchDocDelta.iY = (float)shiftInView.iY * 100 / zoomLevel; |
3129 m_pinchDocDelta.iY = (float)shiftInView.iY * 100 / zoomLevel; |
3112 } |
3130 |
3113 |
3131 if(!m_isPinchZoomOut) |
3114 void WebView::reCreatePlugins() |
3132 createCheckerBoardL(); |
3115 { |
3133 } |
3116 Frame* coreFrame = core(mainFrame()); |
|
3117 MWebCoreObjectWidget* view = NULL; |
|
3118 for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) { |
|
3119 PassRefPtr<HTMLCollection> objects = frame->document()->objects(); |
|
3120 for (Node* n = objects->firstItem(); n; n = objects->nextItem()) { |
|
3121 view = widget(n); |
|
3122 if (view) { |
|
3123 PluginSkin* plg = static_cast<PluginSkin*>(view); |
|
3124 if(plg->activeStreams() > 0) |
|
3125 plg->reCreatePlugin(); |
|
3126 } |
|
3127 } |
|
3128 |
|
3129 PassRefPtr<HTMLCollection> embeds = frame->document()->embeds(); |
|
3130 for (Node* n = embeds->firstItem(); n; n = embeds->nextItem()) { |
|
3131 view = widget(n); |
|
3132 if (view) { |
|
3133 PluginSkin* plg = static_cast<PluginSkin*>(view); |
|
3134 if(plg->activeStreams() > 0) |
|
3135 plg->reCreatePlugin(); |
|
3136 } |
|
3137 } |
|
3138 } |
|
3139 } |
|
3140 |
|
3141 |
3134 |
3142 void WebView::setScrolling(bool scroll) |
3135 void WebView::setScrolling(bool scroll) |
3143 { |
3136 { |
3144 m_scroll = scroll; |
3137 m_scroll = scroll; |
3145 mainFrame()->PlayPausePlugins(m_scroll); |
3138 mainFrame()->PlayPausePlugins(m_scroll); |
3146 } |
3139 } |
3147 |
3140 |
|
3141 void drawCheckerBoard(CBitmapContext *gc,const TRect &rect) |
|
3142 { |
|
3143 for(int i = rect.iTl.iX; i <= (rect.iTl.iX + rect.Width()); i = i + (2 * KCheckerSize)) { |
|
3144 for(int j = rect.iTl.iY; j <= (rect.iTl.iY + rect.Height()); j = j + (2 * KCheckerSize)) { |
|
3145 const TRgb lightGrey(KZoomBgRectColor, KZoomBgRectColor, KZoomBgRectColor); |
|
3146 gc->SetPenColor(lightGrey); |
|
3147 gc->SetBrushColor(lightGrey); |
|
3148 |
|
3149 TRect topLeft(TPoint(i, j),TPoint(i + KCheckerSize, j + KCheckerSize)); |
|
3150 gc->DrawRect(topLeft); |
|
3151 |
|
3152 TRect bottomRight(TPoint(i + KCheckerSize, j + KCheckerSize),TPoint(i + (2 * KCheckerSize), j + (2 * KCheckerSize))); |
|
3153 gc->DrawRect(bottomRight); |
|
3154 |
|
3155 const TRgb darkGrey(KZoomFgRectColor, KZoomFgRectColor, KZoomFgRectColor); |
|
3156 gc->SetPenColor(darkGrey); |
|
3157 gc->SetBrushColor(darkGrey); |
|
3158 |
|
3159 TRect topRight(TPoint(i + KCheckerSize, j),TPoint(i + (2 * KCheckerSize), j + KCheckerSize)); |
|
3160 gc->DrawRect(topRight); |
|
3161 |
|
3162 TRect bottomLeft(TPoint(i, j + KCheckerSize),TPoint(i + KCheckerSize, j + (2 * KCheckerSize))); |
|
3163 gc->DrawRect(bottomLeft); |
|
3164 } |
|
3165 } |
|
3166 } |
|
3167 |
|
3168 void WebView::createCheckerBoardL() |
|
3169 { |
|
3170 //Cancel the destroy timer, if it is already scheduled. |
|
3171 //Otherwise it will destroy the checkerboard created now. |
|
3172 if(m_checkerBoardDestroyTimer |
|
3173 && m_checkerBoardDestroyTimer->IsActive()) |
|
3174 m_checkerBoardDestroyTimer->Cancel(); |
|
3175 |
|
3176 if(m_checkerBoardBitmap && m_checkerBoardBitmap->SizeInPixels()!=Rect().Size()) { |
|
3177 destroyCheckerBoard(); |
|
3178 } |
|
3179 |
|
3180 if(!m_checkerBoardBitmap) { |
|
3181 m_checkerBoardBitmap =new(ELeave) CFbsBitmap; |
|
3182 TInt err= m_checkerBoardBitmap->Create(Rect().Size(),StaticObjectsContainer::instance()->webSurface()->displayMode()); |
|
3183 User::LeaveIfError(err); |
|
3184 |
|
3185 m_checkerBoardDevice = CFbsBitmapDevice::NewL(m_checkerBoardBitmap); |
|
3186 |
|
3187 err = m_checkerBoardDevice->CreateContext(m_checkerBoardGc); |
|
3188 User::LeaveIfError(err); |
|
3189 |
|
3190 m_checkerBoardGc->SetBrushStyle( CGraphicsContext::EForwardDiagonalHatchBrush ); |
|
3191 drawCheckerBoard(m_checkerBoardGc,Rect()); |
|
3192 } |
|
3193 } |
|
3194 |
|
3195 void WebView::destroyCheckerBoard() |
|
3196 { |
|
3197 if(m_checkerBoardBitmap) { |
|
3198 delete m_checkerBoardGc; |
|
3199 delete m_checkerBoardDevice; |
|
3200 delete m_checkerBoardBitmap; |
|
3201 |
|
3202 m_checkerBoardBitmap = NULL; |
|
3203 m_checkerBoardDevice = NULL; |
|
3204 m_checkerBoardGc = NULL; |
|
3205 } |
|
3206 if(m_checkerBoardDestroyTimer |
|
3207 && m_checkerBoardDestroyTimer->IsActive()) |
|
3208 m_checkerBoardDestroyTimer->Cancel(); |
|
3209 } |
|
3210 |
|
3211 TInt doDestroyCheckerBoardCb(TAny *ptr) |
|
3212 { |
|
3213 static_cast<WebView*>(ptr)->destroyCheckerBoard(); |
|
3214 return ETrue; |
|
3215 } |
|
3216 |
|
3217 void WebView::startCheckerBoardDestroyTimer() |
|
3218 { |
|
3219 if(!m_checkerBoardDestroyTimer || !m_checkerBoardBitmap) { |
|
3220 return; |
|
3221 } |
|
3222 if(m_checkerBoardDestroyTimer->IsActive()) { |
|
3223 m_checkerBoardDestroyTimer->Cancel(); |
|
3224 } |
|
3225 m_checkerBoardDestroyTimer->Start(KCheckerBoardDestroyTimeout,0,TCallBack(doDestroyCheckerBoardCb,this)); |
|
3226 } |
|
3227 |
|
3228 //------------------------------------------------------------------------------- |
|
3229 // WebView::calculateZoomRect |
|
3230 //------------------------------------------------------------------------------- |
|
3231 void WebView::calculateZoomRect(TRect &aOldRect, TRect &aNewRect, TInt aOldZoom, TInt aNewZoom) |
|
3232 { |
|
3233 aNewRect.iTl.iX = (aOldRect.iTl.iX * aOldZoom) / aNewZoom; |
|
3234 aNewRect.iTl.iY = (aOldRect.iTl.iY * aOldZoom) / aNewZoom; |
|
3235 aNewRect.iBr.iX = (aOldRect.iBr.iX * aOldZoom) / aNewZoom; |
|
3236 aNewRect.iBr.iY = (aOldRect.iBr.iY * aOldZoom) / aNewZoom; |
|
3237 |
|
3238 // rounding |
|
3239 if (( aOldRect.iTl.iX * aNewZoom) % aOldZoom ) { |
|
3240 aNewRect.iTl.iX -= 1; |
|
3241 } |
|
3242 if (( aOldRect.iTl.iY * aNewZoom) % aOldZoom ) { |
|
3243 aNewRect.iTl.iY -= 1; |
|
3244 } |
|
3245 if ((aOldRect.iBr.iX * aNewZoom) % aOldZoom ) { |
|
3246 aNewRect.iBr.iX += 1; |
|
3247 } |
|
3248 if ((aOldRect.iBr.iY * aNewZoom) % aOldZoom ) { |
|
3249 aNewRect.iBr.iY += 1; |
|
3250 } |
|
3251 } |
|
3252 |
3148 // END OF FILE |
3253 // END OF FILE |