webengine/osswebengine/WebKit/s60/webview/WebView.cpp
branchRCL_3
changeset 48 79859ed3eea9
parent 47 e1bea15f9a39
child 49 919f36ff910f
equal deleted inserted replaced
47:e1bea15f9a39 48:79859ed3eea9
    26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    29 */
    29 */
    30 
    30 
    31 #include <browser_platform_variant.hrh>
    31 #include <Browser_platform_variant.hrh>
    32 #include "config.h"
    32 #include "config.h"
    33 #include "../../bidi.h"
    33 #include "../../bidi.h"
    34 #include "brctl.h"
    34 #include "BrCtl.h"
    35 #include "HistoryController.h"
    35 #include "HistoryController.h"
    36 #include "PageView.h"
    36 #include "PageView.h"
    37 #include "SettingsContainer.h"
    37 #include "SettingsContainer.h"
    38 #include "WebFrame.h"
    38 #include "WebFrame.h"
    39 #include "WebFrameBridge.h"
    39 #include "WebFrameBridge.h"
    58 #include "WebPopupDrawer.h"
    58 #include "WebPopupDrawer.h"
    59 #include "PluginSkin.h"
    59 #include "PluginSkin.h"
    60 #include "PluginWin.h"
    60 #include "PluginWin.h"
    61 #include "PluginPlayer.h"
    61 #include "PluginPlayer.h"
    62 #include "WebKitLogger.h"
    62 #include "WebKitLogger.h"
    63 #include "WebPagePinchZoomHandler.h"
    63 
    64 
    64 
    65 #include "Page.h"
    65 #include "Page.h"
    66 #include "Settings.h"
    66 #include "Settings.h"
    67 #include "Frame.h"
    67 #include "Frame.h"
    68 #include "FrameView.h"
    68 #include "FrameView.h"
    88 #include "HTMLInputElement.h"
    88 #include "HTMLInputElement.h"
    89 
    89 
    90 using namespace HTMLNames;
    90 using namespace HTMLNames;
    91 
    91 
    92 #include <AknUtils.h>
    92 #include <AknUtils.h>
    93 #include <cuseragent.h>
    93 #include <CUserAgent.h>
    94 #include "WebPageZoomHandler.h"
    94 #include "WebPageZoomHandler.h"
    95 
    95 
    96 #include "PlatformFontCache.h"
    96 #include "PlatformFontCache.h"
    97 #include "WebPageFullScreenHandler.h"
    97 #include "WebPageFullScreenHandler.h"
    98 #include "eikon.hrh"
    98 #include "eikon.hrh"
    99 #include "WebScrollbarDrawer.h"
    99 #include "WebScrollbarDrawer.h"
   100 #include "EventNames.h"
   100 #include "EventNames.h"
   101 #include "Editor.h"
   101 #include "Editor.h"
   102 #include "ThumbnailGenerator.h"
       
   103 #include <kjs_window.h>
       
   104 #include "PluginHandler.h"
       
   105 
   102 
   106 using namespace WebCore;
   103 using namespace WebCore;
   107 using namespace EventNames;
   104 using namespace EventNames;
   108 
   105 
   109 const int KRepaintDelayLoading = 500*1000; // dont do repaints more often than this during loading (0.5s)
   106 const int KRepaintDelayLoading = 500*1000; // dont do repaints more often than this during loading (0.5s)
   132 
   129 
   133 const int KZoomBgRectColor = 209;
   130 const int KZoomBgRectColor = 209;
   134 const int KZoomDefaultLevel = 8; //100%
   131 const int KZoomDefaultLevel = 8; //100%
   135 const int defaultCacheCapacity = 256 * 1024;
   132 const int defaultCacheCapacity = 256 * 1024;
   136 
   133 
   137 const int KMaxMissedDrawsAllowed = 5;//Max missed repaint allowed before paint happens
       
   138 const int KCheckerSize = 10;
       
   139 const int KZoomFgRectColor = 150;
       
   140 const int KCheckerBoardDestroyTimeout = 2*1000*1000;
       
   141 
       
   142 // LOCAL FUNCTION PROTOTYPES
   134 // LOCAL FUNCTION PROTOTYPES
   143 TInt doRepaintCb( TAny* ptr );
   135 TInt doRepaintCb( TAny* ptr );
   144 TInt doFepCb( TAny* ptr );
   136 TInt doFepCb( TAny* ptr );
   145 TInt doDestroyCheckerBoardCb(TAny *ptr);
       
   146 
   137 
   147 static WebFrame* incrementFrame(WebFrame* curr, bool forward, bool wrapFlag)
   138 static WebFrame* incrementFrame(WebFrame* curr, bool forward, bool wrapFlag)
   148 {
   139 {
   149     Frame* coreFrame = core(curr);
   140     Frame* coreFrame = core(curr);
   150     return kit(forward
   141     return kit(forward
   202 , m_maxZoomLevel(KZoomLevelMaxValue)
   193 , m_maxZoomLevel(KZoomLevelMaxValue)
   203 , m_minZoomLevel(KZoomLevelMinValue)
   194 , m_minZoomLevel(KZoomLevelMinValue)
   204 , m_defaultZoomLevel(KZoomLevelDefaultValue)
   195 , m_defaultZoomLevel(KZoomLevelDefaultValue)
   205 , m_pageFullScreenHandler(NULL)
   196 , m_pageFullScreenHandler(NULL)
   206 , m_viewIsScrolling(false)
   197 , m_viewIsScrolling(false)
       
   198 , m_ptrbuffer(0)
   207 , m_showCursor(false)
   199 , m_showCursor(false)
   208 , m_allowRepaints(true)
   200 , m_allowRepaints(true)
   209 , m_prevEditMode(false)
   201 , m_prevEditMode(false)
   210 , m_firedEvent(0)
   202 , m_firedEvent(0)
   211 , m_waitTimer(0)
       
   212 , m_pinchZoomHandler(NULL)
       
   213 , m_isPinchZoom(false)
       
   214 , m_drawsMissed(0)
       
   215 , m_thumbnailGenerator(NULL)
       
   216 , m_checkerBoardBitmap(NULL)
       
   217 , m_checkerBoardDevice(NULL)
       
   218 , m_checkerBoardGc(NULL)
       
   219 , m_checkerBoardDestroyTimer(NULL)
       
   220 , m_isPinchZoomOut(false)
       
   221 , m_jsTimeouts(0)
       
   222 {
   203 {
   223 }
   204 }
   224 
   205 
   225 WebView::~WebView()
   206 WebView::~WebView()
   226 {
   207 {
   227     StaticObjectsContainer::instance()->webCursor()->stopTransparencyTimer();
   208     StaticObjectsContainer::instance()->webCursor()->stopTransparencyTimer();
   228     if ( StaticObjectsContainer::instance()->webCursor()->getCursorWebView() == this)
   209 
   229          StaticObjectsContainer::instance()->webCursor()->setCurrentView(NULL);
       
   230     // the zoom handler is a client of WebView (also owned by
   210     // the zoom handler is a client of WebView (also owned by
   231     // WebView--a circular dependency) so it must be deleted before
   211     // WebView--a circular dependency) so it must be deleted before
   232     // the WebView object is destroyed because in its destructor it
   212     // the WebView object is destroyed because in its destructor it
   233     // operates on the WebView object
   213     // operates on the WebView object
   234     delete m_pageZoomHandler;
   214     delete m_pageZoomHandler;
   242     m_page->setGroupName(String());
   222     m_page->setGroupName(String());
   243 
   223 
   244     if (m_fastScrollTimer)
   224     if (m_fastScrollTimer)
   245         m_fastScrollTimer->Cancel();
   225         m_fastScrollTimer->Cancel();
   246     delete m_fastScrollTimer;
   226     delete m_fastScrollTimer;
   247     delete m_webpointerEventHandler;
   227 
   248 	delete m_pinchZoomHandler;
   228     delete [] m_ptrbuffer;
   249     delete m_repainttimer;
   229     delete m_repainttimer;
   250     delete m_webfeptexteditor;
   230     delete m_webfeptexteditor;
   251     delete m_webcorecontext;
   231     delete m_webcorecontext;
   252     delete m_bitmapdevice;
   232     delete m_bitmapdevice;
   253     delete m_page;
   233     delete m_page;
   254     delete m_pageScaler;
   234     delete m_pageScaler;
   255 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF    
       
   256     m_pageScaler = NULL;
       
   257 #endif    
       
   258     delete m_pageView;
   235     delete m_pageView;
   259     delete m_webFormFill;
   236     delete m_webFormFill;
   260     delete m_toolbar;
   237     delete m_toolbar;
   261     delete m_toolbarinterface;
   238     delete m_toolbarinterface;
   262     delete m_widgetextension;
   239     delete m_widgetextension;
   263     
   240     delete m_webpointerEventHandler;
   264     delete m_pageScrollHandler;
   241     delete m_pageScrollHandler;
   265     delete m_pluginplayer;
   242     delete m_pluginplayer;
   266     delete m_fepTimer;
   243     delete m_fepTimer;
   267     delete m_waitTimer;
       
   268     delete m_waiter;
       
   269     delete m_popupDrawer;
   244     delete m_popupDrawer;
   270     delete m_tabbedNavigation;
   245     delete m_tabbedNavigation;
   271     delete m_userAgent;
   246     delete m_userAgent;
   272     delete m_pageFullScreenHandler;
   247     delete m_pageFullScreenHandler;
   273     delete m_bridge;
   248     delete m_bridge;
   274     delete m_frameView;
   249     delete m_frameView;
   275     delete m_thumbnailGenerator;    
       
   276     
       
   277     destroyCheckerBoard();
       
   278     delete m_checkerBoardDestroyTimer;
       
   279     
       
   280     if (StaticObjectsContainer::instance()->webSurface()->topView() == this) 
       
   281         StaticObjectsContainer::instance()->webSurface()->setView( NULL ); 
       
   282     
       
   283 }
   250 }
   284 
   251 
   285 // -----------------------------------------------------------------------------
   252 // -----------------------------------------------------------------------------
   286 // WebView::ConstructL
   253 // WebView::ConstructL
   287 // Private Class Method
   254 // Private Class Method
   359 
   326 
   360     if ( m_brctl->capabilities() & TBrCtlDefs::ECapabilityWebKitLite ) {
   327     if ( m_brctl->capabilities() & TBrCtlDefs::ECapabilityWebKitLite ) {
   361         m_pageScalerEnabled = false;
   328         m_pageScalerEnabled = false;
   362     }
   329     }
   363     else  {
   330     else  {
   364         if((m_brctl->capabilities() & TBrCtlDefs::ECapabilityGraphicalHistory)
   331         initializePageScalerL();
   365         	&& !(m_brctl->capabilities() & TBrCtlDefs::ECapabilityGraphicalPage))
   332         m_pageScalerEnabled = true;
   366             {
       
   367             m_thumbnailGenerator = CThumbnailGenerator::NewL(*this);          
       
   368             }
       
   369         else 
       
   370             {
       
   371             initializePageScalerL();
       
   372             m_pageScalerEnabled = true;
       
   373             }        
       
   374     }
   333     }
   375     if (m_brctl->capabilities() & TBrCtlDefs::ECapabilityAutoFormFill) {
   334     if (m_brctl->capabilities() & TBrCtlDefs::ECapabilityAutoFormFill) {
   376         m_webFormFill = new WebFormFill(this);
   335         m_webFormFill = new WebFormFill(this);
   377     }
   336     }
   378     
   337 
   379     //Creates the Pinch Zoom Handler
       
   380     m_pinchZoomHandler = WebPagePinchZoomHandler::NewL(this);
       
   381     
       
   382     // Create the PointerEventHandler
   338     // Create the PointerEventHandler
       
   339     m_ptrbuffer = new TPoint[256];
   383     m_webpointerEventHandler = WebPointerEventHandler::NewL(this);
   340     m_webpointerEventHandler = WebPointerEventHandler::NewL(this);
   384 
   341 
   385     // Create the ScrollHandler
   342     // Create the ScrollHandler
   386     m_pageScrollHandler = WebPageScrollHandler::NewL( *this );
   343     m_pageScrollHandler = WebPageScrollHandler::NewL( *this );
   387     if (AknLayoutUtils::PenEnabled()) {
   344     if (AknLayoutUtils::PenEnabled()) {
   396     m_userAgent = HBufC::NewL(userAgent8->Length());
   353     m_userAgent = HBufC::NewL(userAgent8->Length());
   397     m_userAgent->Des().Copy(userAgent8->Des());
   354     m_userAgent->Des().Copy(userAgent8->Des());
   398     CleanupStack::PopAndDestroy(2); // userAgent8, usrAgnt
   355     CleanupStack::PopAndDestroy(2); // userAgent8, usrAgnt
   399 
   356 
   400     MakeViewVisible(ETrue);
   357     MakeViewVisible(ETrue);
       
   358     m_isPluginsVisible=ETrue;
   401     CCoeControl::SetFocus(ETrue);
   359     CCoeControl::SetFocus(ETrue);
   402 
   360 
   403 #ifndef BRDO_PERF_IMPROVEMENTS_ENABLED_FF
       
   404     cache()->setCapacities(0, 0, defaultCacheCapacity);
   361     cache()->setCapacities(0, 0, defaultCacheCapacity);
   405 #endif    
       
   406     
       
   407     m_waiter = new(ELeave) CActiveSchedulerWait();
       
   408     
       
   409     m_checkerBoardDestroyTimer = CPeriodic::NewL(CActive::EPriorityIdle);
       
   410     
       
   411 }
   362 }
   412 
   363 
   413 void WebView::initializePageScalerL()
   364 void WebView::initializePageScalerL()
   414 {
   365 {
   415     TBool lowQuality = !( m_brctl->capabilities() & TBrCtlDefs::ECapabilityGraphicalHistory );
   366     TBool lowQuality = !( m_brctl->capabilities() & TBrCtlDefs::ECapabilityGraphicalHistory );
   443         if (m_widgetextension){
   394         if (m_widgetextension){
   444             m_widgetextension->DrawTransition(gc,StaticObjectsContainer::instance()->webSurface()->offscreenBitmap());
   395             m_widgetextension->DrawTransition(gc,StaticObjectsContainer::instance()->webSurface()->offscreenBitmap());
   445         }
   396         }
   446     }
   397     }
   447     else {
   398     else {
   448 #ifndef BRDO_MULTITOUCH_ENABLED_FF
       
   449         gc.DrawBitmap( m_destRectForZooming, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), m_srcRectForZooming );
   399         gc.DrawBitmap( m_destRectForZooming, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), m_srcRectForZooming );
   450 
   400 
   451         if ( m_startZoomLevel > m_currentZoomLevel) {
   401         if ( m_startZoomLevel > m_currentZoomLevel) {
   452 
   402 
   453             TRect rectLeft( TPoint( rect.iTl.iX + m_destRectForZooming.Width() - 2, rect.iTl.iY ),
   403             TRect rectLeft( TPoint( rect.iTl.iX + m_destRectForZooming.Width() - 2, rect.iTl.iY ),
   454                     TPoint( rect.iBr ));
   404                             TPoint( rect.iBr ));
   455 
   405 
   456             TRect rectBottom( TPoint( rect.iTl.iX, rect.iTl.iY + m_destRectForZooming.Height() - 2 ),
   406             TRect rectBottom( TPoint( rect.iTl.iX, rect.iTl.iY + m_destRectForZooming.Height() - 2 ),
   457                     TPoint( rect.iBr.iX + m_destRectForZooming.Width(), rect.iBr.iY ));
   407                               TPoint( rect.iBr.iX + m_destRectForZooming.Width(), rect.iBr.iY ));
   458 
   408 
   459 
   409 
   460             const TRgb colorTest(KZoomBgRectColor,KZoomBgRectColor,KZoomBgRectColor);
   410             const TRgb colorTest(KZoomBgRectColor,KZoomBgRectColor,KZoomBgRectColor);
   461             gc.SetPenColor(colorTest);
   411             gc.SetPenColor(colorTest);
   462             gc.SetBrushStyle( CGraphicsContext::EForwardDiagonalHatchBrush );
   412             gc.SetBrushStyle( CGraphicsContext::EForwardDiagonalHatchBrush );
   463             gc.SetBrushColor(colorTest);
   413             gc.SetBrushColor(colorTest);
   464             gc.DrawRect( rectLeft );
   414             gc.DrawRect( rectLeft );
   465             gc.DrawRect( rectBottom );
   415             gc.DrawRect( rectBottom );
   466         }
   416 
   467 #else                   
   417         }
   468         if ( m_startZoomLevel > m_currentZoomLevel) {
   418 
   469             gc.BitBlt(rect.iTl,m_checkerBoardBitmap);
       
   470         }
       
   471         gc.DrawBitmap( m_destRectForZooming, StaticObjectsContainer::instance()->webSurface()->offscreenBitmap(), m_srcRectForZooming );
       
   472 #endif        
       
   473     }
   419     }
   474 
   420 
   475     if (m_pageScalerEnabled && m_pageScaler->Visible()) {
   421     if (m_pageScalerEnabled && m_pageScaler->Visible()) {
   476         m_pageScaler->Draw( gc, rect );
   422         m_pageScaler->Draw( gc, rect );
   477     }
   423     }
   533         m_webcorecontext->resized();
   479         m_webcorecontext->resized();
   534     }
   480     }
   535     WebCursor* cursor = StaticObjectsContainer::instance()->webCursor();
   481     WebCursor* cursor = StaticObjectsContainer::instance()->webCursor();
   536     if (cursor) {
   482     if (cursor) {
   537         if (visible) {
   483         if (visible) {
   538             cursor->setCurrentView(this);
   484             cursor->setCurrentView(*this);
   539             //Reset the iFocusedElementType to be the same as before the second window is opened.
   485             //Reset the iFocusedElementType to be the same as before the second window is opened.
   540             cursor->setPosition(m_savedCursorPosition);
   486             cursor->setPosition(m_savedCursorPosition);
   541             cursor->updatePositionAndElemType(m_savedCursorPosition);
   487             cursor->updatePositionAndElemType(m_savedCursorPosition);
   542             if ( m_widgetextension && m_focusedElementType == TBrCtlDefs::EElementSelectBox){
       
   543                 m_focusedElementType = TBrCtlDefs::EElementNone;
       
   544             }
       
   545         } else
   488         } else
   546             m_savedCursorPosition = cursor->position();
   489             m_savedCursorPosition = cursor->position();
   547         cursor->cursorUpdate(visible & !AknLayoutUtils::PenEnabled());
   490         cursor->cursorUpdate(visible & !AknLayoutUtils::PenEnabled());
   548     }
   491     }
   549     Frame* f = m_page->mainFrame();
   492     Frame* f = m_page->mainFrame();
   570         m_webFormFillPopup->MakeVisible(EFalse);
   513         m_webFormFillPopup->MakeVisible(EFalse);
   571     }
   514     }
   572 
   515 
   573     if ( visible ) {
   516     if ( visible ) {
   574       clearOffScreenBitmap();
   517       clearOffScreenBitmap();
   575       if ( m_brctl && m_brctl->settings() && SettingsContainer::NavigationTypeTabbed == m_brctl->settings()->getNavigationType() ) {
       
   576           m_tabbedNavigation->initializeForPage();
       
   577       }
       
   578       syncRepaint( mainFrame()->frameView()->visibleRect() );
   518       syncRepaint( mainFrame()->frameView()->visibleRect() );
   579       TRAP_IGNORE( m_webfeptexteditor->EnableCcpuL() ); 
   519     }
   580     }
   520 
   581 }
   521 }
   582 
   522 
   583 
   523 
   584 
   524 
   585 void WebView::doLayout()
   525 void WebView::doLayout()
   586 {
   526 {
   587 
   527 
   588     int zoomLevel = m_currentZoomLevel;
   528     int zoomLevel = m_currentZoomLevel;
   589     if(m_widgetextension && !(m_widgetextension->IsWidgetPublising())) {
   529     if(!(   m_widgetextension && m_widgetextension->IsWidgetPublising())) {
   590         zoomLevelChanged( KZoomLevelDefaultValue );
   530         zoomLevelChanged( KZoomLevelDefaultValue );
   591     }
   531     }
   592     else {
       
   593         //Layout the content based on Default zoom level (100) and zoom it back to existing zoom
       
   594         //level after the layout is complete
       
   595         WebFrameView* view = mainFrame()->frameView();
       
   596         if(view) { 
       
   597             m_startZoomLevel = KZoomLevelDefaultValue;
       
   598             mainFrame()->scalingFactorChanged(KZoomLevelDefaultValue);
       
   599             TRect currentZoomedRect = view->rect();
       
   600             TRect rectWithDefaultZoom; 
       
   601             calculateZoomRect(currentZoomedRect, rectWithDefaultZoom, m_currentZoomLevel, KZoomLevelDefaultValue); 
       
   602             view->setRect(rectWithDefaultZoom);
       
   603             m_currentZoomLevel = KZoomLevelDefaultValue;
       
   604         } 
       
   605     }
       
   606     
       
   607     Frame* f = m_page->mainFrame();
   532     Frame* f = m_page->mainFrame();
   608 
   533 
   609     while ( f ) {
   534     while ( f ) {
   610         f->sendResizeEvent();
   535         f->sendResizeEvent();
   611         f->view()->layout();
   536         f->view()->layout();
   624         return;
   549         return;
   625     if(!(   m_widgetextension && m_widgetextension->IsWidgetPublising())) {
   550     if(!(   m_widgetextension && m_widgetextension->IsWidgetPublising())) {
   626         mainFrame()->frameView()->draw( *m_webcorecontext, rect );
   551         mainFrame()->frameView()->draw( *m_webcorecontext, rect );
   627         if ( zoomLevel < m_minZoomLevel ) zoomLevel = m_minZoomLevel;
   552         if ( zoomLevel < m_minZoomLevel ) zoomLevel = m_minZoomLevel;
   628         zoomLevelChanged( zoomLevel );
   553         zoomLevelChanged( zoomLevel );
   629         
       
   630 #ifndef  BRDO_MULTITOUCH_ENABLED_FF
       
   631         if(m_pageZoomHandler) {
       
   632             //Slider value will change if the content size is changed when layout is done
       
   633             //hide the slider, so that user will get new min and max zoom level 
       
   634             if (m_pageZoomHandler->isActive()) {
       
   635                       TRAP_IGNORE(
       
   636                       m_pageZoomHandler->hideZoomSliderL();
       
   637                       );
       
   638                   }
       
   639             }
       
   640 #endif         
       
   641     }
   554     }
   642 }
   555 }
   643 //-------------------------------------------------------------------------------
   556 //-------------------------------------------------------------------------------
   644 // WebView::syncRepaint
   557 // WebView::syncRepaint
   645 // Repaint the current repaint region synchronously and clear it
   558 // Repaint the current repaint region synchronously and clear it
   649     if (m_pageScaler && m_pageScaler->FullScreenMode()) {
   562     if (m_pageScaler && m_pageScaler->FullScreenMode()) {
   650       ScaledPageChanged(m_pageScaler->Rect(), EFalse, EFalse);
   563       ScaledPageChanged(m_pageScaler->Rect(), EFalse, EFalse);
   651       return;
   564       return;
   652     }
   565     }
   653 
   566 
   654     if (!IsVisible() || ( StaticObjectsContainer::instance()->webSurface()->topView() != this ) ) {
   567     if (!IsVisible()) {
   655       return;
   568       return;
   656     }
   569     }
   657 
   570 
   658     if (StaticObjectsContainer::instance()->isPluginFullscreen()) return;
   571     if (StaticObjectsContainer::instance()->isPluginFullscreen()) return;
   659     CFbsBitGc& gc = m_webcorecontext->gc();
   572     CFbsBitGc& gc = m_webcorecontext->gc();
   675             f = f->tree()->traverseNext();
   588             f = f->tree()->traverseNext();
   676         }
   589         }
   677         layoutPending = false;
   590         layoutPending = false;
   678     }
   591     }
   679 
   592 
   680     if ( !layoutPending || (m_drawsMissed >= KMaxMissedDrawsAllowed  && !isLoading())) {
   593     if ( !layoutPending || !isLoading()) {
   681         m_drawsMissed = 0;
       
   682         bool needsDraw = false;
   594         bool needsDraw = false;
   683         m_repaints.Tidy();
   595         m_repaints.Tidy();
   684         for (int i=0; i<m_repaints.Count(); ++i) {
   596         for (int i=0; i<m_repaints.Count(); ++i) {
   685             TRect r = m_repaints[i];
   597             TRect r = m_repaints[i];
   686             if (r.Intersects(viewRect)) {
   598             if (r.Intersects(viewRect)) {
   699         }
   611         }
   700 
   612 
   701         // dont do next async repaint until KRepaintDelay
   613         // dont do next async repaint until KRepaintDelay
   702         m_repaints.Clear();
   614         m_repaints.Clear();
   703     }
   615     }
   704     else{
       
   705         m_drawsMissed++;
       
   706     }
       
   707     m_repainttimer->Cancel();
   616     m_repainttimer->Cancel();
   708     // tot:fixme TBool complete = iWebkitControl->IsProgressComplete(); && CImageRendererFactory::Instance()->DecodeCount()==0;
   617     // tot:fixme TBool complete = iWebkitControl->IsProgressComplete(); && CImageRendererFactory::Instance()->DecodeCount()==0;
   709 
   618 
   710     TBool complete = ETrue;
   619     TBool complete = ETrue;
   711     int timeout = complete ? KRepaintDelayComplete : KRepaintDelayLoading;
   620     int timeout = complete ? KRepaintDelayComplete : KRepaintDelayLoading;
   754 // WebView::collectOffscreenbitmap
   663 // WebView::collectOffscreenbitmap
   755 // Get offscreen bitmap
   664 // Get offscreen bitmap
   756 //-------------------------------------------------------------------------------
   665 //-------------------------------------------------------------------------------
   757 void WebView::collectOffscreenbitmapL(CFbsBitmap& snapshot)
   666 void WebView::collectOffscreenbitmapL(CFbsBitmap& snapshot)
   758 {
   667 {
   759     if ( snapshot.Handle() == 0) {
   668     if(   m_widgetextension && m_widgetextension->IsWidgetPublising()) {
   760         // Create bitmap only once
   669         if ( snapshot.Handle() == 0) {
   761         (snapshot).Create(m_brctl->Size(), StaticObjectsContainer::instance()->webSurface()->displayMode());
   670             // Create bitmap only once
   762     }
   671             (snapshot).Create(m_brctl->Size(), StaticObjectsContainer::instance()->webSurface()->displayMode());
   763     CFbsBitmapDevice* device = CFbsBitmapDevice::NewL( &snapshot);
   672         }
   764     CleanupStack::PushL(device);
   673         CFbsBitmapDevice* device = CFbsBitmapDevice::NewL( &snapshot);
       
   674         CleanupStack::PushL(device);
   765 
   675 
   766         WebCoreGraphicsContext* gc = WebCoreGraphicsContext::NewL( device, &snapshot, mainFrame()->frameView());
   676         WebCoreGraphicsContext* gc = WebCoreGraphicsContext::NewL( device, &snapshot, mainFrame()->frameView());
   767         CleanupStack::PushL(gc);
   677         CleanupStack::PushL(gc);
   768 
   678 
   769         if( snapshot.Handle() != 0 ) {
   679         if( snapshot.Handle() != 0 ) {
   774         if (snapshot.SizeInPixels()!=m_brctl->Size()) {
   684         if (snapshot.SizeInPixels()!=m_brctl->Size()) {
   775             snapshot.Resize(m_brctl->Size());
   685             snapshot.Resize(m_brctl->Size());
   776         }
   686         }
   777         mainFrame()->frameView()->draw( *gc, mainFrame()->frameView()->visibleRect() );
   687         mainFrame()->frameView()->draw( *gc, mainFrame()->frameView()->visibleRect() );
   778 
   688 
   779    CleanupStack::PopAndDestroy(2);
   689        CleanupStack::PopAndDestroy(2);
   780    	
   690     }
   781    PluginHandler* pluginHandler = StaticObjectsContainer::instance()->pluginHandler();
       
   782    if (!m_widgetextension->IsWidgetPublising() && pluginHandler && pluginHandler->getVisiblePlugins().Count() > 0) {
       
   783        (snapshot).Reset();
       
   784    } 
       
   785 
   691 
   786 }
   692 }
   787 
   693 
   788 //-------------------------------------------------------------------------------
   694 //-------------------------------------------------------------------------------
   789 // WebView::scheduleRepaint
   695 // WebView::scheduleRepaint
   790 // Schedule an asynchronous repaint
   696 // Schedule an asynchronous repaint
   791 //-------------------------------------------------------------------------------
   697 //-------------------------------------------------------------------------------
   792 void WebView::scheduleRepaint(
   698 void WebView::scheduleRepaint(
   793                               const TRect& rect )
   699                               const TRect& rect )
   794 {
   700 {
   795     // prevent frameViews to access members when topView is closing down.
       
   796     if( m_isClosing )
       
   797         return;
       
   798 
       
   799     m_repaints.AddRect( rect );
   701     m_repaints.AddRect( rect );
   800     if(   m_widgetextension && m_widgetextension->IsWidgetPublising())
   702     if(   m_widgetextension && m_widgetextension->IsWidgetPublising())
   801         {
   703         {
   802 #ifdef BRDO_WRT_HS_FF
   704 #ifdef BRDO_WRT_HS_FF
   803         // Draw the miniview
   705         // Draw the miniview
   833                 TPoint ptInit(0,0);
   735                 TPoint ptInit(0,0);
   834                 TPoint ptFromHistory = m_brctl->historyHandler()->historyController()->currentEntryPosition();
   736                 TPoint ptFromHistory = m_brctl->historyHandler()->historyController()->currentEntryPosition();
   835                 TPoint ptCurr = mainFrame()->frameView()->contentPos();
   737                 TPoint ptCurr = mainFrame()->frameView()->contentPos();
   836 
   738 
   837                 if ( ptCurr != ptFromHistory ) {
   739                 if ( ptCurr != ptFromHistory ) {
   838                     if((mainFrame()->bridge()->m_rtl) && (ptInit != ptFromHistory)) {
   740                     if ( ptInit == ptCurr ) {
   839                           mainFrame()->frameView()->scrollTo(ptFromHistory);
       
   840                           }
       
   841                     else if ( ptInit == ptCurr ) {
       
   842                         mainFrame()->frameView()->scrollTo(ptFromHistory);
   741                         mainFrame()->frameView()->scrollTo(ptFromHistory);
   843                     }
   742                     }
   844                     else {
   743                     else {
   845                         m_brctl->historyHandler()->historyController()->updateCurrentEntryPositionIfNeeded();
   744                         m_brctl->historyHandler()->historyController()->updateCurrentEntryPositionIfNeeded();
   846                     }
   745                     }
   868     }
   767     }
   869     if ( m_pageScaler ) {
   768     if ( m_pageScaler ) {
   870         m_pageScaler->DocumentCompleted();
   769         m_pageScaler->DocumentCompleted();
   871         TRAP_IGNORE(m_pageScaler->DocumentChangedL());
   770         TRAP_IGNORE(m_pageScaler->DocumentChangedL());
   872     }
   771     }
   873     else if(m_thumbnailGenerator) {
       
   874         TRAP_IGNORE(m_thumbnailGenerator->CreatePageThumbnailL());    
       
   875     }    
       
   876 
   772 
   877     Node* focusedNode = NULL;
   773     Node* focusedNode = NULL;
   878     Frame* focusedFrame = page()->focusController()->focusedFrame();
   774     Frame* focusedFrame = page()->focusController()->focusedFrame();
   879 
   775 
   880     if (focusedFrame)
   776     if (focusedFrame)
  1166      */
  1062      */
  1167      if ((m_focusedElementType == TBrCtlDefs::EElementNone ||
  1063      if ((m_focusedElementType == TBrCtlDefs::EElementNone ||
  1168           m_focusedElementType == TBrCtlDefs::EElementBrokenImage ) &&
  1064           m_focusedElementType == TBrCtlDefs::EElementBrokenImage ) &&
  1169           keyevent.iRepeats && !m_brctl->wmlMode() ) {
  1065           keyevent.iRepeats && !m_brctl->wmlMode() ) {
  1170          launchToolBarL();
  1066          launchToolBarL();
  1171         if(m_toolbar) {
       
  1172 			 sendMouseEventToEngineIfNeeded(TPointerEvent::EButton1Up, cursor->position(), frame);
       
  1173         }
       
  1174      }
  1067      }
  1175     
  1068     
  1176      return true;
  1069      return true;
  1177 }
  1070 }
  1178 
  1071 
  1179 bool WebView::handleNaviKeyEvent(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame)  
  1072 bool WebView::handleNaviKeyEvent(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame)  
  1180 {
  1073 {
  1181     bool downEventConsumed = false;
  1074     bool downEventConsumed = false;
  1182     bool consumed = false;
  1075     bool consumed = false;
  1183     bool tabbedNavigation = (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed);
  1076     bool tabbedNavigation = (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed);
  1184     bool navigationNone = (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeNone);
       
  1185     /*
  1077     /*
  1186      * For each platform keyDown event EventHandler::keEvent() generates 
  1078      * For each platform keyDown event EventHandler::keEvent() generates 
  1187      * keydown and keypress.
  1079      * keydown and keypress.
  1188      * For keypress event we need a char code and since we don't 
  1080      * For keypress event we need a char code and since we don't 
  1189      * have it at the time of EEventKeyDown we pospond it until EEventKey 
  1081      * have it at the time of EEventKeyDown we pospond it until EEventKey 
  1201     bool widgetDownEventConsumed = downEventConsumed && (m_widgetextension != NULL);
  1093     bool widgetDownEventConsumed = downEventConsumed && (m_widgetextension != NULL);
  1202   
  1094   
  1203     if (!widgetDownEventConsumed && needDeactivateEditable(keyevent, eventcode, frame, downEventConsumed)) {
  1095     if (!widgetDownEventConsumed && needDeactivateEditable(keyevent, eventcode, frame, downEventConsumed)) {
  1204         deactivateEditable();
  1096         deactivateEditable();
  1205     }
  1097     }
  1206     if(!navigationNone)
  1098 
  1207     if(frame->document()->focusedNode() != NULL && IS_DOWN_KEY(keyevent) && frame->document()->focusedNode()->changed())
       
  1208         {
       
  1209         deactivateEditable();
       
  1210         }
       
  1211     if (tabbedNavigation) {
  1099     if (tabbedNavigation) {
  1212         consumed = downEventConsumed || handleTabbedNavigation(m_currentEventKey, m_currentEventCode);
  1100         consumed = downEventConsumed || handleTabbedNavigation(m_currentEventKey, m_currentEventCode);
  1213     }
  1101     }
  1214     else {  
  1102     else {  
  1215           //Check is editable node and couples of NULL checking  
  1103         consumed = (!m_isEditable &&  //avoid showing the cursor when we are in the input box 
  1216          if( m_isEditable && frame && frame->document() && frame->document()->focusedNode() ) {
  1104                     handleKeyNavigation(keyevent, eventcode, frame)) ||
  1217              //Is inputTag
  1105                     downEventConsumed;
  1218              TBool isInputTag = frame->document()->focusedNode()->hasTagName(inputTag); 
       
  1219              HTMLInputElement* ie = static_cast<HTMLInputElement*>(frame->document()->focusedNode());
       
  1220              TInt length  = 0;
       
  1221              //Null checking etc.
       
  1222              if( ie && isInputTag ) {
       
  1223                  //Get length of inputelement string
       
  1224                  length = ie->value().length();
       
  1225              }
       
  1226              //Check is there data in input field
       
  1227              if( length > 0 || !ie ) {
       
  1228                  //If there is data, do the old thing 
       
  1229                  consumed = ( !m_isEditable &&  //avoid showing the cursor when we are in the input box 
       
  1230                          handleKeyNavigation(keyevent, eventcode, frame)) ||
       
  1231                          downEventConsumed;
       
  1232              } 
       
  1233              else {
       
  1234                    //else continue navigation and avoid jamming in some inputboxes
       
  1235                    consumed = handleKeyNavigation( keyevent, eventcode, frame );    
       
  1236              }
       
  1237          } 
       
  1238          else {
       
  1239                consumed = ( !m_isEditable &&  //avoid showing the cursor when we are in the input box 
       
  1240                        handleKeyNavigation(keyevent, eventcode, frame)) ||
       
  1241                        downEventConsumed;    
       
  1242          }
       
  1243     }
  1106     }
  1244     return consumed;
  1107     return consumed;
  1245 }
  1108 }
  1246 
  1109 
  1247 bool WebView::handleInputElement(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame)
  1110 bool WebView::handleInputElement(const TKeyEvent& keyevent, TEventCode eventcode, Frame* frame)
  1502 
  1365 
  1503     if ( (keyevent.iScanCode == EStdKeyDevice3) ||
  1366     if ( (keyevent.iScanCode == EStdKeyDevice3) ||
  1504        (keyevent.iScanCode == EStdKeyEnter) ) {
  1367        (keyevent.iScanCode == EStdKeyEnter) ) {
  1505        // pass it to webcore
  1368        // pass it to webcore
  1506 
  1369 
  1507         if (( m_focusedElementType == TBrCtlDefs::EElementActivatedInputBox ||
  1370         if (( m_focusedElementType == TBrCtlDefs::EElementInputBox ||
  1508             m_focusedElementType == TBrCtlDefs::EElementTextAreaBox) &&
  1371             m_focusedElementType == TBrCtlDefs::EElementTextAreaBox) &&
  1509             m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed ) {
  1372             m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed ) {
  1510             if (!m_prevEditMode) {
  1373             if (!m_prevEditMode) {
  1511                 setEditable(true);
  1374                 setEditable(true);
  1512             }
  1375             }
  1600     if (m_toolbar)
  1463     if (m_toolbar)
  1601         return m_toolbar->HandleOfferKeyEventL(keyevent, eventcode);
  1464         return m_toolbar->HandleOfferKeyEventL(keyevent, eventcode);
  1602 
  1465 
  1603     if (m_popupDrawer)
  1466     if (m_popupDrawer)
  1604         return m_popupDrawer->handleOfferKeyEventL(keyevent, eventcode );
  1467         return m_popupDrawer->handleOfferKeyEventL(keyevent, eventcode );
  1605     
       
  1606     if (m_focusedElementType == TBrCtlDefs::EElementObjectBox 
       
  1607         || m_focusedElementType == TBrCtlDefs::EElementActivatedObjectBox) {
       
  1608         
       
  1609         Node* node = static_cast<Node*>(cursor->getElementUnderCursor());
       
  1610         MWebCoreObjectWidget* view = widget(node);
       
  1611         PluginSkin* plugin = static_cast<PluginSkin*>(view);
       
  1612         if (plugin && plugin->pluginWin() && !(plugin->pluginWin()->Windowed())) {
       
  1613             if (EKeyWasConsumed == plugin->pluginWin()->OfferKeyEventL(keyevent, eventcode))
       
  1614                 return EKeyWasConsumed;
       
  1615         }
       
  1616     }    
       
  1617 
  1468 
  1618     if ( m_webFormFillPopup && m_webFormFillPopup->IsVisible() && AknLayoutUtils::PenEnabled() ) {
  1469     if ( m_webFormFillPopup && m_webFormFillPopup->IsVisible() && AknLayoutUtils::PenEnabled() ) {
  1619 	    if (EKeyWasConsumed == m_webFormFillPopup->HandleKeyEventL(keyevent, eventcode)) {
  1470 	    if (EKeyWasConsumed == m_webFormFillPopup->HandleKeyEventL(keyevent, eventcode)) {
  1620             return EKeyWasConsumed;
  1471             return EKeyWasConsumed;
  1621 	    }
  1472 	    }
  1810         Window().Invalidate( aRect );
  1661         Window().Invalidate( aRect );
  1811     }
  1662     }
  1812 
  1663 
  1813     if ( !aScroll && aFullScreen )
  1664     if ( !aScroll && aFullScreen )
  1814     {
  1665     {
  1815     	  // update the history with new bitmap
  1666         // update the history with new bitmap
  1816         CFbsBitmap* scaledPage = NULL;
  1667         CFbsBitmap* scaledPage = m_pageScaler->ScaledPage();
  1817         if(m_thumbnailGenerator)
       
  1818             {
       
  1819             scaledPage = m_thumbnailGenerator->PageThumbnail();
       
  1820             }
       
  1821         else if(m_pageScaler)
       
  1822             {
       
  1823             scaledPage = m_pageScaler->ScaledPage();
       
  1824             }
       
  1825         if (scaledPage) {
  1668         if (scaledPage) {
  1826             // Get the browser control rect
  1669             // Get the browser control rect
  1827             TRAP_IGNORE( m_brctl->historyHandler()->historyController()->updateHistoryEntryThumbnailL(scaledPage));
  1670             TRAP_IGNORE( m_brctl->historyHandler()->historyController()->updateHistoryEntryThumbnailL(scaledPage));
  1828 
  1671 
  1829             m_brctl->HandleBrowserLoadEventL( TBrCtlDefs::EEventThumbnailAvailable, 0, 0 );
  1672             m_brctl->HandleBrowserLoadEventL( TBrCtlDefs::EEventThumbnailAvailable, 0, 0 );
  1858 }
  1701 }
  1859 
  1702 
  1860 void WebView::setEditable(TBool editable)
  1703 void WebView::setEditable(TBool editable)
  1861 {
  1704 {
  1862     Frame* frame = core(mainFrame());
  1705     Frame* frame = core(mainFrame());
  1863     
       
  1864     page()->chrome()->client()->setElementVisibilityChanged(false);
       
  1865     if (!frame || m_isEditable == editable)
  1706     if (!frame || m_isEditable == editable)
  1866         return;
  1707         return;
  1867 
  1708 
  1868     m_isEditable = editable;
  1709     m_isEditable = editable;
  1869 
  1710 
  1944     return TSize((Rect().Size().iWidth-20),(Rect().Size().iHeight-20));
  1785     return TSize((Rect().Size().iWidth-20),(Rect().Size().iHeight-20));
  1945 }
  1786 }
  1946 
  1787 
  1947 void WebView::clearOffScreenBitmap()
  1788 void WebView::clearOffScreenBitmap()
  1948 {
  1789 {
  1949     if ( (!IsVisible()) || ( StaticObjectsContainer::instance()->webSurface()->topView() != this ) ) 
       
  1950       return;
       
  1951     TSize bmSize = StaticObjectsContainer::instance()->webSurface()->offscreenBitmap()->SizeInPixels();
       
  1952     if (bmSize.iWidth != Rect().Width() || bmSize.iHeight != Rect().Height()) {
       
  1953         return; 
       
  1954     }
       
  1955     m_webcorecontext->gc().Reset();
  1790     m_webcorecontext->gc().Reset();
  1956     m_webcorecontext->gc().Clear();
  1791     m_webcorecontext->gc().Clear();
  1957 }
  1792 }
  1958 
  1793 
  1959 void WebView::scrollBuffer(TPoint to, TPoint from, TBool usecopyscroll)
  1794 void WebView::scrollBuffer(TPoint to, TPoint from, TBool usecopyscroll)
  1960 {
  1795 {
  1961     if(!IsVisible())
       
  1962         return;
       
  1963     
       
  1964     TRect rect(m_offscreenrect);
  1796     TRect rect(m_offscreenrect);
  1965 
  1797 
  1966     TSize bufSize( rect.Size() );
  1798     TSize bufSize( rect.Size() );
  1967 
  1799 
  1968     CFbsBitGc& gc = m_webcorecontext->gc();
  1800     CFbsBitGc& gc = m_webcorecontext->gc();
  2133     // first-searched frame up to the selection. However, the API doesn't provide a way to search only up to a particular point. The only
  1965     // first-searched frame up to the selection. However, the API doesn't provide a way to search only up to a particular point. The only
  2134     // way to make sure the entire frame is searched is to pass YES for the wrapFlag. When there are no matches, this will search again
  1966     // way to make sure the entire frame is searched is to pass YES for the wrapFlag. When there are no matches, this will search again
  2135     // some content that we already searched on the first pass. In the worst case, we could search the entire contents of this frame twice.
  1967     // some content that we already searched on the first pass. In the worst case, we could search the entire contents of this frame twice.
  2136     // To fix this, we'd need to add a mechanism to specify a range in which to search.
  1968     // To fix this, we'd need to add a mechanism to specify a range in which to search.
  2137     if (wrapFlag && lastFrame) {
  1969     if (wrapFlag && lastFrame) {
  2138         if (frame && frame->bridge() && frame->bridge()->searchFor(keyword, forward, false, true, false))
  1970         if (frame->bridge()->searchFor(keyword, forward, false, true, false))
  2139             return TBrCtlDefs::EFindMatch;
  1971             return TBrCtlDefs::EFindMatch;
  2140     }
  1972     }
  2141 
  1973 
  2142     if (frame) {
  1974     if (frame) {
  2143         frame->clearSelection();
  1975         frame->clearSelection();
  2150     m_inFindState = false;
  1982     m_inFindState = false;
  2151     delete m_findKeyword;
  1983     delete m_findKeyword;
  2152     m_findKeyword = NULL;
  1984     m_findKeyword = NULL;
  2153     WebFrame* selectedFrame = mainFrame()->findFrameWithSelection();
  1985     WebFrame* selectedFrame = mainFrame()->findFrameWithSelection();
  2154     selectedFrame->clearSelection();
  1986     selectedFrame->clearSelection();
  2155     setFocusNone();
       
  2156 }
  1987 }
  2157 
  1988 
  2158 bool WebView::isSmallPage()
  1989 bool WebView::isSmallPage()
  2159 {
  1990 {
  2160     TSize docSize = DocumentSize();
  1991     TSize docSize = DocumentSize();
  2161     TSize viewSize = DocumentViewport().Size();
  1992     TSize viewSize = DocumentViewport().Size();
  2162     return (docSize.iWidth/viewSize.iWidth) * (docSize.iHeight/viewSize.iHeight) * 100 < KSmallPageScale;
  1993     return ((docSize.iWidth * docSize.iHeight*100)/(viewSize.iWidth*viewSize.iHeight) < KSmallPageScale);
  2163 }
  1994 }
  2164 
  1995 
  2165 void WebView::willSubmitForm(FormState* formState)
  1996 void WebView::willSubmitForm(FormState* formState)
  2166 {
  1997 {
  2167     if (m_webFormFill) {
  1998     if (m_webFormFill) {
  2168         m_webFormFill->willSubmitForm(formState);
  1999         m_webFormFill->willSubmitForm(formState);
       
  2000     }
       
  2001 }
       
  2002 
       
  2003 
       
  2004 //-------------------------------------------------------------------------------
       
  2005 // WebView::HandlePointerBufferReadyL
       
  2006 // Handles pointer move events
       
  2007 //-------------------------------------------------------------------------------
       
  2008 void WebView::HandlePointerBufferReadyL()
       
  2009 {
       
  2010     memset(m_ptrbuffer,0,256*sizeof(TPoint));
       
  2011     TPtr8 ptr((TUint8 *)m_ptrbuffer,256*sizeof(TPoint));
       
  2012 
       
  2013     TInt numPnts = Window().RetrievePointerMoveBuffer(ptr);
       
  2014     int i = 0;
       
  2015     if (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeNone) {
       
  2016         if (numPnts > 20)
       
  2017             i = numPnts - 20;
       
  2018     }
       
  2019     for (; i < numPnts; i++) {
       
  2020         TPointerEvent pe;
       
  2021         pe.iType = TPointerEvent::EDrag;
       
  2022         pe.iPosition = m_ptrbuffer[i];
       
  2023         m_webpointerEventHandler->HandlePointerEventL(pe);
  2169     }
  2024     }
  2170 }
  2025 }
  2171 
  2026 
  2172 //-------------------------------------------------------------------------------
  2027 //-------------------------------------------------------------------------------
  2173 // WebView::HandlePointerEventL
  2028 // WebView::HandlePointerEventL
  2185             m_brctl->settings()->setNavigationType(SettingsContainer::NavigationTypeTabbed);
  2040             m_brctl->settings()->setNavigationType(SettingsContainer::NavigationTypeTabbed);
  2186             StaticObjectsContainer::instance()->webCursor()->cursorUpdate(true);
  2041             StaticObjectsContainer::instance()->webCursor()->cursorUpdate(true);
  2187         }
  2042         }
  2188         else if (value == "none") {
  2043         else if (value == "none") {
  2189             m_brctl->settings()->setNavigationType(SettingsContainer::NavigationTypeNone);
  2044             m_brctl->settings()->setNavigationType(SettingsContainer::NavigationTypeNone);
  2190         }
       
  2191     }
       
  2192     else if (name == "widgetAppBackgroundColour") {
       
  2193         if (value == "black") {
       
  2194             WebCore::Frame *frame = core(mainFrame());
       
  2195             if (frame) {
       
  2196                 WebCore::FrameView* frameView = frame->view();
       
  2197                 if (frameView) {
       
  2198                     WebCore::Color bc = Color::black;
       
  2199                     frameView->setBaseBackgroundColor(bc);
       
  2200                 }
       
  2201             }
       
  2202         }
  2045         }
  2203     }
  2046     }
  2204 }
  2047 }
  2205 
  2048 
  2206 //-------------------------------------------------------------------------------
  2049 //-------------------------------------------------------------------------------
  2310     m_zoomLevelChangedByUser = true;
  2153     m_zoomLevelChangedByUser = true;
  2311     WebFrameView* view = mainFrame()->frameView();
  2154     WebFrameView* view = mainFrame()->frameView();
  2312     if (!view) return;
  2155     if (!view) return;
  2313 
  2156 
  2314     m_dirtyZoomMode = true;
  2157     m_dirtyZoomMode = true;
       
  2158     m_isPluginsVisible = false;
       
  2159     mainFrame()->makeVisiblePlugins(false);
  2315 
  2160 
  2316     if (zoomLevel > m_startZoomLevel) {
  2161     if (zoomLevel > m_startZoomLevel) {
  2317 
  2162 
  2318         // cut m_srcRectForZooming from m_offscreenrect and enlarge it to fit the view rect
  2163         // cut m_srcRectForZooming from m_offscreenrect and enlarge it to fit the view rect
  2319 
  2164 
  2363 void WebView::restoreZoomLevel(int zoomLevel)
  2208 void WebView::restoreZoomLevel(int zoomLevel)
  2364 {
  2209 {
  2365     m_dirtyZoomMode = false;
  2210     m_dirtyZoomMode = false;
  2366     clearOffScreenBitmap();
  2211     clearOffScreenBitmap();
  2367     zoomLevelChanged(zoomLevel);
  2212     zoomLevelChanged(zoomLevel);
  2368 	//update the position position after the relayout is completed, 
  2213     mainFrame()->notifyPluginsOfScrolling();
  2369 	//This will minimize the plugins flickering
  2214     m_isPluginsVisible = false;
  2370     scrollStatus(false);
  2215     mainFrame()->makeVisiblePlugins(true);
       
  2216     m_isPluginsVisible = true;
  2371 }
  2217 }
  2372 
  2218 
  2373 //-------------------------------------------------------------------------------
  2219 //-------------------------------------------------------------------------------
  2374 // WebView::resetZoomLevel
  2220 // WebView::resetZoomLevel
  2375 //-------------------------------------------------------------------------------
  2221 //-------------------------------------------------------------------------------
  2434         if ( newMinZoomLevel > m_currentZoomLevel ) newMinZoomLevel = m_currentZoomLevel;
  2280         if ( newMinZoomLevel > m_currentZoomLevel ) newMinZoomLevel = m_currentZoomLevel;
  2435     }
  2281     }
  2436     else {
  2282     else {
  2437         newMinZoomLevel = KZoomLevelDefaultValue;
  2283         newMinZoomLevel = KZoomLevelDefaultValue;
  2438     }
  2284     }
  2439 #ifndef  BRDO_MULTITOUCH_ENABLED_FF
  2285 
  2440     //if the min zoom is in fraction (like 86.33) this will give us 6 pixel white patch 
       
  2441     //to reduce the patch, always min zoom factor incremented in one step of zoom step 
       
  2442     if(newMinZoomLevel % KZoomLevelMinValue)
       
  2443         { 
       
  2444         newMinZoomLevel += KZoomLevelMinValue;
       
  2445         }
       
  2446     newMinZoomLevel = (newMinZoomLevel/m_pageZoomHandler->stepSize())*m_pageZoomHandler->stepSize();
  2286     newMinZoomLevel = (newMinZoomLevel/m_pageZoomHandler->stepSize())*m_pageZoomHandler->stepSize();
  2447 #endif     
  2287 
  2448   TBool needsUpdateArray = EFalse;
  2288   TBool needsUpdateArray = EFalse;
  2449   //Update the new array
  2289   //Update the new array
  2450   if ( m_minZoomLevel!= newMinZoomLevel)
  2290   if ( m_minZoomLevel!= newMinZoomLevel)
  2451   {
  2291   {
  2452     needsUpdateArray = ETrue;
  2292     needsUpdateArray = ETrue;
  2480     {
  2320     {
  2481     return;
  2321     return;
  2482     }
  2322     }
  2483 
  2323 
  2484     m_zoomLevelArray.Reset();
  2324     m_zoomLevelArray.Reset();
  2485 #ifndef  BRDO_MULTITOUCH_ENABLED_FF
  2325 
  2486     m_minZoomLevel = TInt(m_minZoomLevel/10) * 10;
  2326     m_minZoomLevel = TInt(m_minZoomLevel/10) * 10;
  2487 #endif 
       
  2488     
       
  2489     m_zoomLevelArray.Append(KZoomLevelDefaultValue);
  2327     m_zoomLevelArray.Append(KZoomLevelDefaultValue);
  2490 
  2328 
  2491     //construct the zoom array from the default level
  2329     //construct the zoom array from the default level
  2492     TInt toAddZoomLevel = KZoomLevelDefaultValue + KZoomLevelDefaultValue*KZoomLevelDelta/100;
  2330     TInt toAddZoomLevel = KZoomLevelDefaultValue + KZoomLevelDefaultValue*KZoomLevelDelta/100;
  2493     while (toAddZoomLevel <= m_maxZoomLevel)
  2331     while (toAddZoomLevel <= m_maxZoomLevel)
  2537 
  2375 
  2538     view->setContentPos( pt );
  2376     view->setContentPos( pt );
  2539     mainFrame()->scalingFactorChanged(z);
  2377     mainFrame()->scalingFactorChanged(z);
  2540     view->checkScrollbarVisibility();
  2378     view->checkScrollbarVisibility();
  2541 
  2379 
  2542     if (m_isPinchZoom) {
       
  2543         if (newZoomLevel > m_startZoomLevel) {
       
  2544             TPoint cpos( mainFrame()->frameView()->contentPos());
       
  2545             cpos.iX = cpos.iX + m_pinchDocDelta.iX +.5;
       
  2546             cpos.iY = cpos.iY + m_pinchDocDelta.iY +.5;
       
  2547             mainFrame()->frameView()->setContentPos(cpos);
       
  2548         }
       
  2549         if (m_startZoomLevel > newZoomLevel) {
       
  2550             TPoint cpos( mainFrame()->frameView()->contentPos());
       
  2551             cpos.iX = cpos.iX - m_pinchDocDelta.iX +.5;
       
  2552             cpos.iY = cpos.iY - m_pinchDocDelta.iY +.5;
       
  2553            
       
  2554             if (cpos.iX < 0) cpos.iX = 0;
       
  2555             if (cpos.iY < 0) cpos.iY = 0;
       
  2556             mainFrame()->frameView()->setContentPos(cpos);
       
  2557         }
       
  2558         m_isPinchZoom = false;
       
  2559         m_isPinchZoomOut = false;
       
  2560     }
       
  2561    
       
  2562     TRect rect = view->rect();
  2380     TRect rect = view->rect();
  2563     TRect rectToZoom; 
  2381 
  2564     calculateZoomRect(rect, rectToZoom, currZoomLevel, m_currentZoomLevel);
  2382     TInt tlx = (rect.iTl.iX * currZoomLevel) / m_currentZoomLevel;
  2565     view->setRect(rectToZoom);
  2383     TInt tly = (rect.iTl.iY * currZoomLevel) / m_currentZoomLevel;
       
  2384     TInt brx = (rect.iBr.iX * currZoomLevel) / m_currentZoomLevel;
       
  2385     TInt bry = (rect.iBr.iY * currZoomLevel) / m_currentZoomLevel;
       
  2386 
       
  2387     // rounding
       
  2388 
       
  2389     if (( rect.iTl.iX * currZoomLevel) % m_currentZoomLevel ){
       
  2390         tlx -= 1;
       
  2391     }
       
  2392     if (( rect.iTl.iY * currZoomLevel) % m_currentZoomLevel ){
       
  2393         tly -= 1;
       
  2394     }
       
  2395     if ((rect.iBr.iX * currZoomLevel) % m_currentZoomLevel ){
       
  2396         brx += 1;
       
  2397     }
       
  2398     if ((rect.iBr.iY * currZoomLevel) % m_currentZoomLevel ){
       
  2399         bry += 1;
       
  2400     }
       
  2401 
       
  2402     view->setRect(TRect(tlx, tly, brx, bry));
  2566 
  2403 
  2567     // now just do a repaint, should be very fast
  2404     // now just do a repaint, should be very fast
  2568     if ( currZoomLevel > newZoomLevel ) {
  2405     if ( currZoomLevel > newZoomLevel ) {
  2569         clearOffScreenBitmap();
  2406         clearOffScreenBitmap();
  2570     }
  2407     }
  2573     m_startZoomLevel = m_currentZoomLevel;
  2410     m_startZoomLevel = m_currentZoomLevel;
  2574 
  2411 
  2575     updateScrollbars(mainFrame()->frameView()->contentSize().iHeight, mainFrame()->frameView()->contentPos().iY,
  2412     updateScrollbars(mainFrame()->frameView()->contentSize().iHeight, mainFrame()->frameView()->contentPos().iY,
  2576         mainFrame()->frameView()->contentSize().iWidth, mainFrame()->frameView()->contentPos().iX);
  2413         mainFrame()->frameView()->contentSize().iWidth, mainFrame()->frameView()->contentPos().iX);
  2577 
  2414 
  2578     m_allowRepaints = true;
       
  2579     syncRepaint(view->visibleRect());
  2415     syncRepaint(view->visibleRect());
  2580 
  2416 
  2581     int zoomLevel = m_brctl->historyHandler()->historyController()->currentEntryZoomLevel();
  2417     int zoomLevel = m_brctl->historyHandler()->historyController()->currentEntryZoomLevel();
  2582     if (zoomLevel != m_currentZoomLevel) m_brctl->historyHandler()->historyController()->updateCurrentEntryZoomLevelIfNeeded();
  2418     if (zoomLevel != m_currentZoomLevel) m_brctl->historyHandler()->historyController()->updateCurrentEntryZoomLevelIfNeeded();
  2583 }
  2419 }
  2636 
  2472 
  2637     // zoom it
  2473     // zoom it
  2638     m_lastZoomLevel = m_currentZoomLevel;
  2474     m_lastZoomLevel = m_currentZoomLevel;
  2639 
  2475 
  2640     setZoomLevel(zoomLevel);
  2476     setZoomLevel(zoomLevel);
  2641     mainFrame()->notifyPluginsOfPositionChange();
  2477     mainFrame()->notifyPluginsOfScrolling();
  2642     
  2478 }
  2643     if (zoomLevel == KZoomLevelDefaultValue)
       
  2644         {
       
  2645         // for pages based on tables this is required
       
  2646         doLayout();
       
  2647         }
       
  2648     
       
  2649  }
       
  2650 
  2479 
  2651 //-------------------------------------------------------------------------------
  2480 //-------------------------------------------------------------------------------
  2652 // WebView::openPluginPlayerL
  2481 // WebView::openPluginPlayerL
  2653 // Called when user clicks a plugin which is able to accept user input,
  2482 // Called when user clicks a plugin which is able to accept user input,
  2654 // this feature is only used in US build
  2483 // this feature is only used in US build
  2700     if (!m_widgetextension) {
  2529     if (!m_widgetextension) {
  2701         m_widgetextension = CWidgetExtension::NewL(*this, aWidgetCallback);
  2530         m_widgetextension = CWidgetExtension::NewL(*this, aWidgetCallback);
  2702 #if USE(LOW_BANDWIDTH_DISPLAY)
  2531 #if USE(LOW_BANDWIDTH_DISPLAY)
  2703         m_page->mainFrame()->loader()->setUseLowBandwidthDisplay(false);
  2532         m_page->mainFrame()->loader()->setUseLowBandwidthDisplay(false);
  2704 #endif
  2533 #endif
  2705     if (!(m_brctl->capabilities() & TBrCtlDefs::ECapabilityAutoFormFill))    
       
  2706         StaticObjectsContainer::instance()->setIconDatabaseEnabled(false);
       
  2707     }
  2534     }
  2708 
  2535 
  2709     //Widgets dont need memory cache for dead objects. hence set it to 0
  2536     //Widgets dont need memory cache for dead objects. hence set it to 0
  2710     cache()->setCapacities(0, 0, 0);
  2537     cache()->setCapacities(0, 0, 0);
  2711     cache()->setDisabled(true);
       
  2712     return m_widgetextension;
  2538     return m_widgetextension;
  2713 }
  2539 }
  2714 
  2540 
  2715 //-------------------------------------------------------------------------------
  2541 //-------------------------------------------------------------------------------
  2716 // WebView::forceLayoutAndResize
  2542 // WebView::forceLayoutAndResize
  2860 
  2686 
  2861 
  2687 
  2862 void WebView::activateVirtualKeyboard()
  2688 void WebView::activateVirtualKeyboard()
  2863 {
  2689 {
  2864     if (isEditable() && iCoeEnv->Fep()) {
  2690     if (isEditable() && iCoeEnv->Fep()) {
  2865         fepTextEditor()->ReportEventL();
       
  2866         fepTextEditor()->CancelEditingMode();
  2691         fepTextEditor()->CancelEditingMode();
  2867         fepTextEditor()->UpdateEditingMode();
  2692         fepTextEditor()->UpdateEditingMode();
  2868         iCoeEnv->Fep()->HandleChangeInFocus();
  2693         iCoeEnv->Fep()->HandleChangeInFocus();
  2869         fepTextEditor()->ActivatePenInputRequest();
  2694         fepTextEditor()->ActivatePenInputRequest();
  2870     }
  2695     }
  2871 }
  2696 }
  2872 
  2697 
  2873 void WebView::Stop()
  2698 void WebView::Stop()
  2874 {
  2699 {
  2875 	  if (m_thumbnailGenerator)
       
  2876         {
       
  2877         //Create a thumbnail for page history
       
  2878         TRAP_IGNORE(m_thumbnailGenerator->CreatePageThumbnailL());
       
  2879         }
       
  2880     mainFrame()->stopLoading();
  2700     mainFrame()->stopLoading();
  2881 }
  2701 }
  2882 void WebView::synchRequestPending(bool flag)
  2702 void WebView::synchRequestPending(bool flag)
  2883 {
  2703 {
  2884     m_synchRequestPending = flag;
  2704     m_synchRequestPending = flag;
  2914 
  2734 
  2915 void WebView::setFastScrollingMode(bool fastScrolling)
  2735 void WebView::setFastScrollingMode(bool fastScrolling)
  2916 {
  2736 {
  2917   if (fastScrolling != m_viewIsFastScrolling) {
  2737   if (fastScrolling != m_viewIsFastScrolling) {
  2918   setViewIsFastScrolling (fastScrolling);
  2738   setViewIsFastScrolling (fastScrolling);
       
  2739   m_isPluginsVisible = false;
  2919   mainFrame()->makeVisiblePlugins(!m_viewIsFastScrolling);
  2740   mainFrame()->makeVisiblePlugins(!m_viewIsFastScrolling);
       
  2741   m_isPluginsVisible = !m_viewIsFastScrolling;
  2920 
  2742 
  2921   if (!m_viewIsFastScrolling) {
  2743   if (!m_viewIsFastScrolling) {
  2922     mainFrame()->notifyPluginsOfPositionChange();
  2744     mainFrame()->notifyPluginsOfScrolling();
  2923   }
  2745   }
  2924   toggleRepaintTimer(!m_viewIsFastScrolling);
  2746   toggleRepaintTimer(!m_viewIsFastScrolling);
  2925 }
  2747 }
  2926 }
  2748 }
  2927 
  2749 
  2977         TPoint cp = view->contentPos();
  2799         TPoint cp = view->contentPos();
  2978         cp += TPoint(xOff, yOff);
  2800         cp += TPoint(xOff, yOff);
  2979         view->setContentPos(cp);
  2801         view->setContentPos(cp);
  2980     }
  2802     }
  2981     //setZoomLevel(zoomLevel);
  2803     //setZoomLevel(zoomLevel);
  2982     mainFrame()->notifyPluginsOfPositionChange();
  2804     mainFrame()->notifyPluginsOfScrolling();
  2983 }
  2805 }
  2984 
  2806 
  2985 
  2807 
  2986 // ---------------------------------------------------------------------------
  2808 // ---------------------------------------------------------------------------
  2987 // WebView::FindCurrentZoomIndex
  2809 // WebView::FindCurrentZoomIndex
  3012     StaticObjectsContainer::instance()->webCursor()->setCursorVisible(showCursor);
  2834     StaticObjectsContainer::instance()->webCursor()->setCursorVisible(showCursor);
  3013 }
  2835 }
  3014 
  2836 
  3015 void WebView::focusedElementChanged(Element* element)
  2837 void WebView::focusedElementChanged(Element* element)
  3016 {
  2838 {
  3017     if (!element || !element->document() ||!element->renderer()) return;
       
  3018     
       
  3019     Frame* frame = element->document()->frame();
  2839     Frame* frame = element->document()->frame();
  3020     if(!frame || !kit(frame)) return;
       
  3021     
       
  3022     WebFrameView* fv = kit(frame)->frameView();
  2840     WebFrameView* fv = kit(frame)->frameView();
  3023     if(!fv) return;
       
  3024     
       
  3025     if (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed || m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeNone) {
  2841     if (m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeTabbed || m_brctl->settings()->getNavigationType() == SettingsContainer::NavigationTypeNone) {
       
  2842         if (!element || !element->document() ||!element->renderer()) return;
  3026         if (element->hasTagName(textareaTag) || (element->hasTagName(inputTag) && (reinterpret_cast<HTMLInputElement*>(element))->isTextField())) {
  2843         if (element->hasTagName(textareaTag) || (element->hasTagName(inputTag) && (reinterpret_cast<HTMLInputElement*>(element))->isTextField())) {
  3027             TPoint point = TRect(element->getRect()).iTl;
  2844             TPoint point = TRect(element->getRect()).iTl;
  3028             point = fv->frameCoordsInViewCoords(point);
  2845             point = fv->frameCoordsInViewCoords(point);
  3029             StaticObjectsContainer::instance()->webCursor()->setPosition(point);
  2846             StaticObjectsContainer::instance()->webCursor()->setPosition(point);
  3030             TPointerEvent event;
  2847             TPointerEvent event;
  3067         WebView* that = const_cast<WebView*>(this);
  2884         WebView* that = const_cast<WebView*>(this);
  3068         that->m_widgetextension->windowObjectCleared();
  2885         that->m_widgetextension->windowObjectCleared();
  3069     }
  2886     }
  3070 }
  2887 }
  3071 
  2888 
  3072 void WebView::wait(double t)
       
  3073 {
       
  3074     if (!m_waitTimer) {
       
  3075         m_waitTimer = new WebCore::Timer<WebView>(this, &WebView::waitTimerCB);
       
  3076     }
       
  3077     
       
  3078     if (!m_waitTimer->isActive()) {
       
  3079         m_waitTimer->startOneShot(t);
       
  3080     }
       
  3081     
       
  3082     if (!m_waitTimer->isActive() && !m_waiter->IsStarted()) {
       
  3083         m_waiter->Start();  
       
  3084     }
       
  3085 }
       
  3086 
       
  3087 void WebView::waitTimerCB(WebCore::Timer<WebView>* t)
       
  3088 {
       
  3089     if (m_waiter->IsStarted()) {
       
  3090         m_waiter->AsyncStop();
       
  3091     }
       
  3092 }
       
  3093 
       
  3094 //-------------------------------------------------------------------------------
       
  3095 // WebView::setPinchBitmapZoomLevelL
       
  3096 //-------------------------------------------------------------------------------
       
  3097 void WebView::setPinchBitmapZoomLevelL(int zoomLevel)
       
  3098 {
       
  3099     m_zoomLevelChangedByUser = true;
       
  3100 
       
  3101     m_isPinchZoom = true;
       
  3102     if(!m_dirtyZoomMode)
       
  3103     {
       
  3104     //If panning or scroll is in progress, we will be notifiying to plugins for collecting bitmap
       
  3105     //in case of pinchZoom, we need to deactivate the plugins which are not supported for bitmap
       
  3106     //sharing.
       
  3107     if(m_scrollingstatus)
       
  3108         {
       
  3109         m_scrollingstatus = false;
       
  3110         }
       
  3111     scrollStatus(true);
       
  3112 	}
       
  3113     m_dirtyZoomMode = true;
       
  3114 
       
  3115     if (zoomLevel > m_startZoomLevel) {
       
  3116         setPinchBitmapZoomIn(zoomLevel);
       
  3117     }
       
  3118     else {
       
  3119         setPinchBitmapZoomOutL(zoomLevel);
       
  3120         m_isPinchZoomOut = true;
       
  3121     }
       
  3122     m_currentZoomLevel = zoomLevel;
       
  3123     DrawNow();
       
  3124 
       
  3125 }
       
  3126 
       
  3127 //-------------------------------------------------------------------------------
       
  3128 // WebView::setPinchBitmapZoomIn
       
  3129 //-------------------------------------------------------------------------------
       
  3130 void WebView::setPinchBitmapZoomIn(int zoomLevel)
       
  3131 {
       
  3132     TPoint pinchCenter = m_pinchZoomHandler->pinchCenter();
       
  3133     
       
  3134     // cut m_srcRectForZooming from m_offscreenrect and enlarge it to fit the view rect
       
  3135     TRealPoint centerAfterZoom; 
       
  3136     //find out the new position of Pinch Center after applying zoom
       
  3137     centerAfterZoom.iX = (float)pinchCenter.iX * zoomLevel/m_startZoomLevel;
       
  3138     centerAfterZoom.iY = (float)pinchCenter.iY * zoomLevel/m_startZoomLevel;
       
  3139     TRealPoint centerDelta;
       
  3140     //get the shift in the Pinch Center
       
  3141     centerDelta.iX = centerAfterZoom.iX - pinchCenter.iX;
       
  3142     centerDelta.iY = centerAfterZoom.iY - pinchCenter.iY;
       
  3143     TPoint shiftInView;
       
  3144     //find out how much shift needs to be applied to the current zoom, w.r.t. the new view
       
  3145     shiftInView.iX = centerDelta.iX * m_startZoomLevel / zoomLevel;
       
  3146     shiftInView.iY = centerDelta.iY * m_startZoomLevel / zoomLevel;
       
  3147     //width and height of the rectangle that should be used for bitmap stretching 
       
  3148     float newWidth  = (float)m_offscreenrect.Width()  * m_startZoomLevel / zoomLevel;
       
  3149     float newHeight = (float)m_offscreenrect.Height() * m_startZoomLevel /zoomLevel;
       
  3150     //defining the source rectangle which needs to be bitmap stretched
       
  3151     m_srcRectForZooming.iTl.iX = shiftInView.iX;
       
  3152     m_srcRectForZooming.iTl.iY = shiftInView.iY;
       
  3153     m_srcRectForZooming.iBr.iX = newWidth  + shiftInView.iX; 
       
  3154     m_srcRectForZooming.iBr.iY = newHeight + shiftInView.iY;
       
  3155     //destRectForZooming is the Coecontrol Rect itself
       
  3156     m_destRectForZooming = Rect();
       
  3157     //get the shift in the document so that during the next engine re-draw, the origin needs to be updated based on that
       
  3158     m_pinchDocDelta.iX = (float)shiftInView.iX * 100 / m_startZoomLevel;   
       
  3159     m_pinchDocDelta.iY = (float)shiftInView.iY * 100 / m_startZoomLevel;
       
  3160 }
       
  3161 
       
  3162 
       
  3163 //-------------------------------------------------------------------------------
       
  3164 // WebView::setPinchBitmapZoomOutL
       
  3165 //-------------------------------------------------------------------------------
       
  3166 void WebView::setPinchBitmapZoomOutL(int zoomLevel)
       
  3167 {
       
  3168     TPoint pinchCenter = m_pinchZoomHandler->pinchCenter();
       
  3169 
       
  3170     // take the whole rect and calculate new rect to fit it the rest of view rect paint gray colour
       
  3171     TRealPoint centerAfterZoom; 
       
  3172     //find out the new position of Pinch Center after applying zoom
       
  3173     centerAfterZoom.iX = (float)pinchCenter.iX * m_startZoomLevel / zoomLevel;
       
  3174     centerAfterZoom.iY = (float)pinchCenter.iY * m_startZoomLevel / zoomLevel;
       
  3175     TRealPoint centerDelta;
       
  3176     //get the shift in the Pinch Center
       
  3177     centerDelta.iX = centerAfterZoom.iX - pinchCenter.iX;
       
  3178     centerDelta.iY = centerAfterZoom.iY - pinchCenter.iY;
       
  3179     TPoint shiftInView;
       
  3180     //find out how much shift needs to be applied to the current zoom, w.r.t. the new view
       
  3181     shiftInView.iX = centerDelta.iX * zoomLevel / m_startZoomLevel;
       
  3182     shiftInView.iY = centerDelta.iY * zoomLevel / m_startZoomLevel;
       
  3183     //width and height of the rectangle
       
  3184     float newWidth  = (float)m_offscreenrect.Width()  * zoomLevel / m_startZoomLevel;
       
  3185     float newHeight = (float)m_offscreenrect.Height() * zoomLevel / m_startZoomLevel;
       
  3186     //defining the co-ordinates of the destination rectangle.
       
  3187     m_destRectForZooming.iTl.iX = shiftInView.iX;
       
  3188     m_destRectForZooming.iTl.iY = shiftInView.iY;
       
  3189     m_destRectForZooming.iBr.iX = newWidth  + shiftInView.iX;
       
  3190     m_destRectForZooming.iBr.iY = newHeight + shiftInView.iY;
       
  3191     //srcRectForZooming is the Coecontrol Rect itself
       
  3192     m_srcRectForZooming = Rect();
       
  3193     //get the shift in the document so that during the next engine re-draw, the origin needs to be updated based on that
       
  3194     m_pinchDocDelta.iX = (float)shiftInView.iX * 100 / zoomLevel;   
       
  3195     m_pinchDocDelta.iY = (float)shiftInView.iY * 100 / zoomLevel;
       
  3196     
       
  3197     if(!m_isPinchZoomOut)
       
  3198         createCheckerBoardL();
       
  3199 }
       
  3200 
       
  3201 
       
  3202 void drawCheckerBoard(CBitmapContext *gc,const TRect &rect)
       
  3203 {
       
  3204     for(int i = rect.iTl.iX; i <= (rect.iTl.iX + rect.Width()); i = i + (2 * KCheckerSize)) {
       
  3205         for(int j = rect.iTl.iY; j <= (rect.iTl.iY + rect.Height()); j = j + (2 * KCheckerSize)) {
       
  3206              const TRgb lightGrey(KZoomBgRectColor, KZoomBgRectColor, KZoomBgRectColor);
       
  3207              gc->SetPenColor(lightGrey);
       
  3208              gc->SetBrushColor(lightGrey);
       
  3209              
       
  3210              TRect topLeft(TPoint(i, j),TPoint(i + KCheckerSize, j + KCheckerSize));
       
  3211              gc->DrawRect(topLeft);
       
  3212              
       
  3213              TRect bottomRight(TPoint(i + KCheckerSize, j + KCheckerSize),TPoint(i + (2 * KCheckerSize), j + (2 * KCheckerSize)));
       
  3214              gc->DrawRect(bottomRight);
       
  3215              
       
  3216              const TRgb darkGrey(KZoomFgRectColor, KZoomFgRectColor, KZoomFgRectColor);
       
  3217              gc->SetPenColor(darkGrey);
       
  3218              gc->SetBrushColor(darkGrey);
       
  3219              
       
  3220              TRect topRight(TPoint(i + KCheckerSize, j),TPoint(i + (2 * KCheckerSize), j + KCheckerSize));
       
  3221              gc->DrawRect(topRight);
       
  3222              
       
  3223              TRect bottomLeft(TPoint(i, j + KCheckerSize),TPoint(i + KCheckerSize, j + (2 * KCheckerSize)));
       
  3224              gc->DrawRect(bottomLeft);
       
  3225         }
       
  3226     }
       
  3227 }
       
  3228 
       
  3229 void WebView::createCheckerBoardL() 
       
  3230 {
       
  3231     //Cancel the destroy timer, if it is already scheduled.
       
  3232     //Otherwise it will destroy the checkerboard created now.
       
  3233     if(m_checkerBoardDestroyTimer 
       
  3234                 && m_checkerBoardDestroyTimer->IsActive())
       
  3235             m_checkerBoardDestroyTimer->Cancel();
       
  3236     
       
  3237     if(m_checkerBoardBitmap && m_checkerBoardBitmap->SizeInPixels()!=Rect().Size())  {
       
  3238         destroyCheckerBoard();
       
  3239     }
       
  3240     
       
  3241     if(!m_checkerBoardBitmap) {
       
  3242         m_checkerBoardBitmap =new(ELeave) CFbsBitmap;             
       
  3243         TInt err= m_checkerBoardBitmap->Create(Rect().Size(),StaticObjectsContainer::instance()->webSurface()->displayMode());
       
  3244         User::LeaveIfError(err);
       
  3245 
       
  3246         m_checkerBoardDevice = CFbsBitmapDevice::NewL(m_checkerBoardBitmap);
       
  3247     
       
  3248         err = m_checkerBoardDevice->CreateContext(m_checkerBoardGc);
       
  3249         User::LeaveIfError(err);
       
  3250         
       
  3251         m_checkerBoardGc->SetBrushStyle( CGraphicsContext::EForwardDiagonalHatchBrush );
       
  3252         drawCheckerBoard(m_checkerBoardGc,Rect());
       
  3253     }
       
  3254 }
       
  3255 
       
  3256 void WebView::destroyCheckerBoard()
       
  3257 {
       
  3258     if(m_checkerBoardBitmap) {
       
  3259          delete m_checkerBoardGc;
       
  3260          delete m_checkerBoardDevice;
       
  3261          delete m_checkerBoardBitmap;    
       
  3262           
       
  3263          m_checkerBoardBitmap = NULL;
       
  3264          m_checkerBoardDevice = NULL;
       
  3265          m_checkerBoardGc     = NULL;
       
  3266     }
       
  3267     if(m_checkerBoardDestroyTimer 
       
  3268             && m_checkerBoardDestroyTimer->IsActive())
       
  3269         m_checkerBoardDestroyTimer->Cancel();
       
  3270 }
       
  3271 
       
  3272 TInt doDestroyCheckerBoardCb(TAny *ptr)
       
  3273 {
       
  3274     static_cast<WebView*>(ptr)->destroyCheckerBoard();
       
  3275     return ETrue;  
       
  3276 }
       
  3277 
       
  3278 void WebView::startCheckerBoardDestroyTimer()
       
  3279 {
       
  3280     if(!m_checkerBoardDestroyTimer || !m_checkerBoardBitmap) {
       
  3281         return;
       
  3282     }
       
  3283     if(m_checkerBoardDestroyTimer->IsActive())  {
       
  3284         m_checkerBoardDestroyTimer->Cancel();
       
  3285     }
       
  3286     m_checkerBoardDestroyTimer->Start(KCheckerBoardDestroyTimeout,0,TCallBack(doDestroyCheckerBoardCb,this));
       
  3287 }
       
  3288 
       
  3289 //-------------------------------------------------------------------------------
       
  3290 // WebView::calculateZoomRect
       
  3291 //-------------------------------------------------------------------------------
       
  3292 void WebView::calculateZoomRect(TRect &aOldRect, TRect &aNewRect, TInt aOldZoom, TInt aNewZoom)
       
  3293     { 
       
  3294     aNewRect.iTl.iX = (aOldRect.iTl.iX * aOldZoom) / aNewZoom;
       
  3295     aNewRect.iTl.iY = (aOldRect.iTl.iY * aOldZoom) / aNewZoom;
       
  3296     aNewRect.iBr.iX = (aOldRect.iBr.iX * aOldZoom) / aNewZoom;
       
  3297     aNewRect.iBr.iY = (aOldRect.iBr.iY * aOldZoom) / aNewZoom;
       
  3298 
       
  3299     // rounding
       
  3300     if (( aOldRect.iTl.iX * aNewZoom) % aOldZoom ) {
       
  3301         aNewRect.iTl.iX -= 1;
       
  3302         }
       
  3303     if (( aOldRect.iTl.iY * aNewZoom) % aOldZoom ) {
       
  3304         aNewRect.iTl.iY -= 1;
       
  3305         }
       
  3306     if ((aOldRect.iBr.iX * aNewZoom) % aOldZoom ) {
       
  3307         aNewRect.iBr.iX += 1;
       
  3308         }
       
  3309     if ((aOldRect.iBr.iY * aNewZoom) % aOldZoom ) {
       
  3310         aNewRect.iBr.iY += 1;
       
  3311         }
       
  3312     }
       
  3313 
       
  3314 void WebView::pauseJsTimers()
       
  3315 {
       
  3316     if(m_jsTimeouts==0) {        
       
  3317         WebCore::Frame *frame = core(mainFrame());
       
  3318         KJS::Window* window = KJS::Window::retrieveWindow(frame);
       
  3319         if(window) {
       
  3320             m_jsTimeouts = window->pauseTimeouts();
       
  3321         }
       
  3322     }
       
  3323 }
       
  3324 
       
  3325 void WebView::resumeJsTimers()
       
  3326 {
       
  3327     if(m_jsTimeouts) {
       
  3328         WebCore::Frame *frame = core(mainFrame());
       
  3329         KJS::Window* window = KJS::Window::retrieveWindow(frame);
       
  3330         if(window) {
       
  3331             window->resumeTimeouts(m_jsTimeouts);
       
  3332             delete m_jsTimeouts;
       
  3333             m_jsTimeouts = 0;
       
  3334         }
       
  3335     }
       
  3336 }
       
  3337 // END OF FILE
  2889 // END OF FILE
  3338 void WebView::scrollStatus(bool status)
       
  3339     {
       
  3340     if(m_scrollingstatus != status)
       
  3341         {
       
  3342         m_scrollingstatus = status;
       
  3343 #ifdef BRDO_MULTITOUCH_ENABLED_FF
       
  3344         mainFrame()->ScrollOrPinchStatus(m_scrollingstatus);
       
  3345 #endif         
       
  3346         }
       
  3347     }
       
  3348 
       
  3349 
       
  3350 void WebView::setViewIsScrolling(bool scrolling)
       
  3351     {
       
  3352     m_viewIsScrolling = scrolling;
       
  3353     if(!scrolling)
       
  3354         {
       
  3355         scrollStatus(scrolling);
       
  3356         }
       
  3357     };