ginebra2/ContentViews/GWebContentView.cpp
changeset 16 3c88a81ff781
parent 12 afcd8e6d025b
equal deleted inserted replaced
14:6aeb7a756187 16:3c88a81ff781
    26 #include "ChromeWidget.h"
    26 #include "ChromeWidget.h"
    27 #include "WebViewEventContext.h"
    27 #include "WebViewEventContext.h"
    28 #include "browserpagefactory.h"
    28 #include "browserpagefactory.h"
    29 #include "wrtbrowsercontainer.h"
    29 #include "wrtbrowsercontainer.h"
    30 
    30 
       
    31 #ifdef Q_WS_MAEMO_5
       
    32 #include "ContentViewContextMenu.h"
       
    33 #endif
       
    34 
    31 #ifdef BEDROCK_TILED_BACKING_STORE
    35 #ifdef BEDROCK_TILED_BACKING_STORE
    32 #include "WebContentViewWidget.h"
    36 #include "WebContentViewWidget.h"
    33 #endif
    37 #endif
    34 
    38 
    35 #include "webpagecontroller.h"
    39 #include "webpagecontroller.h"
    36 #include "Utilities.h"
    40 #include "Utilities.h"
    37 #include "GSuperWebPage.h"
    41 #include "GSuperWebPage.h"
    38 #ifndef NO_QSTM_GESTURE
       
    39 #include "qstmgestureevent.h"
    42 #include "qstmgestureevent.h"
    40 #endif
    43 
    41 
    44 
    42 #include <QGraphicsWebView>
    45 #include <QGraphicsWebView>
    43 #include <QWebHistory>
    46 #include <QWebHistory>
    44 #include <QWebPage>
    47 #include <QWebPage>
    45 #include <QWebFrame>
    48 #include <QWebFrame>
    66       m_sharedPage(0),
    69       m_sharedPage(0),
    67       m_currentSuperPage(m_superPages.begin()),
    70       m_currentSuperPage(m_superPages.begin()),
    68       m_currentPageIsSuperPage(false),
    71       m_currentPageIsSuperPage(false),
    69       m_timer(NULL),
    72       m_timer(NULL),
    70       m_enabled(true),
    73       m_enabled(true),
    71       m_savedZoomValueInView(KInitialZoomFactorValue) 
    74       m_savedZoomValueInView(KInitialZoomFactorValue),
       
    75       m_firstLoadHack(true),
       
    76       m_savedZoomData(0)
    72   {
    77   {
    73       setObjectName(objectName);
    78       setObjectName(objectName);
    74       WRT::WrtBrowserContainer* page = BrowserPageFactory::openBrowserPage();
    79       WRT::WrtBrowserContainer* page = BrowserPageFactory::openBrowserPage();
    75 
    80 
    76       setActions();
    81       setActions();
    77 
    82 
    78 #ifdef BEDROCK_TILED_BACKING_STORE
    83 #ifdef BEDROCK_TILED_BACKING_STORE
    79       m_widget = new WebContentViewWidget(parent, page);
    84       m_widget = new WebContentViewWidget(parent, this, page);
    80       connect(m_widget
    85       connect(m_widget
    81               , SIGNAL(updateZoomActions(bool,bool))
    86               , SIGNAL(updateZoomActions(bool,bool))
    82               , this
    87               , this
    83               , SLOT(setZoomActions(bool, bool)));
    88               , SLOT(setZoomActions(bool, bool)));
       
    89 
       
    90       connect(m_widget
       
    91               , SIGNAL(mouseEvent(QEvent::Type)) 
       
    92               , this
       
    93               , SIGNAL(contentViewMouseEvent(QEvent::Type)));
    84 #else
    94 #else
    85       m_widget = new GWebContentViewWidget(parent, this, page);
    95       m_widget = new GWebContentViewWidget(parent, this, page);
    86 #endif
    96 #endif
    87 
    97 
    88 #ifndef __gva_no_chrome__
    98 #ifndef __gva_no_chrome__
    92 
   102 
    93       webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
   103       webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
    94       webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
   104       webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
    95 
   105 
    96 #ifndef BEDROCK_TILED_BACKING_STORE
   106 #ifndef BEDROCK_TILED_BACKING_STORE
    97 #ifdef NO_QSTM_GESTURE
   107 
    98       m_touchNavigation = new GContentViewTouchNavigation(page, m_widget);
   108       m_touchNavigation = new GContentViewTouchNavigation(page, m_widget);
    99       m_touchNavigation->setChromeWidget(m_chrome);
   109       m_touchNavigation->setChromeWidget(m_chrome);
   100       m_touchNavigation->setParent(m_jsObject);
   110       m_touchNavigation->setParent(m_jsObject);
   101       m_touchNavigation->setObjectName("touchNav");
   111       m_touchNavigation->setObjectName("touchNav");
   102       safe_connect(m_touchNavigation, SIGNAL(mouseEvent(QEvent::Type)) , this, SIGNAL(contentViewMouseEvent(QEvent::Type)));
   112       safe_connect(m_touchNavigation, SIGNAL(mouseEvent(QEvent::Type)) , this, SIGNAL(contentViewMouseEvent(QEvent::Type)));
   103       safe_connect(m_touchNavigation, SIGNAL(longPressEvent(QPoint)),
   113       safe_connect(m_touchNavigation, SIGNAL(longPressEvent(QPoint)),
   104                    webWidget(), SLOT(onLongPressEvent(QPoint)));
   114                    webWidget(), SLOT(onLongPressEvent(QPoint)));
   105 #endif
   115 
   106 #endif
   116 #endif
   107       WRT::WrtBrowserContainer * wrtPage = static_cast<WRT::WrtBrowserContainer *>(page);
   117       WRT::WrtBrowserContainer * wrtPage = static_cast<WRT::WrtBrowserContainer *>(page);
   108       if (wrtPage) {
   118       if (wrtPage) {
   109           wrtPage->setWebWidget(webWidget());
   119           wrtPage->setWebWidget(webWidget());
   110           pageCreated(wrtPage);
   120           //pageCreated(wrtPage);
   111       }
   121       }
   112 
   122 
   113       connectAll();
   123       connectAll();
   114   }
   124   }
   115 
   125 
   116   GWebContentView::~GWebContentView() {
   126   GWebContentView::~GWebContentView() {
       
   127       deactivate();
   117       disconnect(m_jsObject);
   128       disconnect(m_jsObject);
   118       disconnect(webWidget());
   129       disconnect(webWidget());
   119 #ifndef BEDROCK_TILED_BACKING_STORE
   130 #ifndef BEDROCK_TILED_BACKING_STORE
   120       delete m_touchNavigation;
   131       delete m_touchNavigation;
   121 #endif
   132 #endif
   247     }
   258     }
   248 }
   259 }
   249 
   260 
   250 #endif
   261 #endif
   251 
   262 
   252 
       
   253 bool GWebContentView::gesturesEnabled() const 
       
   254 { 
       
   255 #ifndef BEDROCK_TILED_BACKING_STORE
       
   256     return m_touchNavigation->enabled(); 
       
   257 #else	
       
   258     return m_widget->gesturesEnabled();
       
   259 #endif
       
   260 }
       
   261 
       
   262 void GWebContentView::setGesturesEnabled(bool value) 
       
   263 { 
       
   264 #ifndef BEDROCK_TILED_BACKING_STORE		  
       
   265     m_touchNavigation->setEnabled(value); 
       
   266 #else
       
   267     m_widget->setGesturesEnabled(value);
       
   268 #endif
       
   269 }
       
   270 
       
   271   void GWebContentView::connectAll() {
   263   void GWebContentView::connectAll() {
   272     //qDebug() << "GWebContentView::connectAll: " << widget();
   264     //qDebug() << "GWebContentView::connectAll: " << widget();
   273 
   265 
   274 #ifndef __gva_no_chrome__
   266 #ifndef __gva_no_chrome__
   275 #ifndef BEDROCK_TILED_BACKING_STORE
   267 #ifndef BEDROCK_TILED_BACKING_STORE
   280                  , SIGNAL(contextEvent(::WebViewEventContext*))
   272                  , SIGNAL(contextEvent(::WebViewEventContext*))
   281                  ,  m_jsObject
   273                  ,  m_jsObject
   282                  , SLOT(onContextEvent(::WebViewEventContext*)));
   274                  , SLOT(onContextEvent(::WebViewEventContext*)));
   283 
   275 
   284     safe_connect(m_widget
   276     safe_connect(m_widget
   285                 , SIGNAL(contextEventObject(QWebHitTestResult*))
   277                 , SIGNAL(contextEventObject(QWebHitTestResult*, QPointF))
   286                 , this
   278                 , this
   287                 , SLOT(handleContextEventObject(QWebHitTestResult*)));
   279                 , SLOT(handleContextEventObject(QWebHitTestResult*, QPointF)));
   288 
   280 
   289     safe_connect(m_widget
   281     safe_connect(m_widget
   290                  , SIGNAL(viewScrolled(QPoint&, QPoint&))
   282                  , SIGNAL(viewScrolled(QPoint&, QPoint&))
   291                  , this
   283                  , this
   292                  , SLOT(handleViewScrolled(QPoint&, QPoint&)));
   284                  , SLOT(handleViewScrolled(QPoint&, QPoint&)));
   297                  , SIGNAL(contentViewMouseEvent(QEvent::Type)));
   289                  , SIGNAL(contentViewMouseEvent(QEvent::Type)));
   298 
   290 
   299     
   291     
   300 #endif
   292 #endif
   301     QObject::connect(webWidget(), SIGNAL(titleChanged(const QString &)), m_jsObject, SIGNAL(titleChanged(const QString &)));
   293     QObject::connect(webWidget(), SIGNAL(titleChanged(const QString &)), m_jsObject, SIGNAL(titleChanged(const QString &)));
       
   294     #ifdef Q_WS_MAEMO_5
       
   295     QObject::connect(webWidget(), SIGNAL(titleChanged(const QString &)), this, SIGNAL(titleChanged(const QString &)));    
       
   296     #endif
   302     QObject::connect(webWidget(), SIGNAL(loadStarted()), m_jsObject, SIGNAL(loadStarted()));
   297     QObject::connect(webWidget(), SIGNAL(loadStarted()), m_jsObject, SIGNAL(loadStarted()));
   303     QObject::connect(webWidget(), SIGNAL(loadProgress(int)), m_jsObject, SIGNAL(loadProgress(int)));
   298     QObject::connect(webWidget(), SIGNAL(loadProgress(int)), m_jsObject, SIGNAL(loadProgress(int)));
   304     QObject::connect(webWidget(), SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int)));
   299     QObject::connect(webWidget(), SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int)));
   305 #endif
   300 #endif
   306     QObject::connect(webWidget(), SIGNAL(loadStarted()), this, SLOT(onLoadStarted()));
   301     QObject::connect(webWidget(), SIGNAL(loadStarted()), this, SLOT(onLoadStarted()));
   316 #ifndef BEDROCK_TILED_BACKING_STORE
   311 #ifndef BEDROCK_TILED_BACKING_STORE
   317     connect(m_touchNavigation, SIGNAL(startingPanGesture(int)), m_jsObject, SIGNAL(startingPanGesture(int)));
   312     connect(m_touchNavigation, SIGNAL(startingPanGesture(int)), m_jsObject, SIGNAL(startingPanGesture(int)));
   318 #else
   313 #else
   319     connect(this, SIGNAL(startingPanGesture(int)), m_jsObject, SIGNAL(startingPanGesture(int)));
   314     connect(this, SIGNAL(startingPanGesture(int)), m_jsObject, SIGNAL(startingPanGesture(int)));
   320 #endif
   315 #endif
   321 
   316     safe_connect(this, SIGNAL(superPageShown(const QString&)), m_jsObject, SIGNAL(superPageShown(const QString&)));
   322 	QObject::connect(this, SIGNAL(superPageShown(const QString&)), m_jsObject, SIGNAL(superPageShown(const QString&)));         
   317     safe_connect(this, SIGNAL(normalPageShown()), m_jsObject, SIGNAL(normalPageShown()));
   323 #endif
   318 #endif
   324     connect(WebPageController::getSingleton(), SIGNAL(pageCreated(WRT::WrtBrowserContainer*)),
   319     connect(WebPageController::getSingleton(), SIGNAL(pageCreated(WRT::WrtBrowserContainer*)),
   325             this, SLOT(pageCreated(WRT::WrtBrowserContainer*)));
   320             this, SLOT(pageCreated(WRT::WrtBrowserContainer*)));
   326     connect(WebPageController::getSingleton(), SIGNAL(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*)),
   321     connect(WebPageController::getSingleton(), SIGNAL(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*)),
   327             this, SLOT(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*)));
   322             this, SLOT(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*)));
   402       action = m_actions["toggletb"] = new QAction("toggletb", this);
   397       action = m_actions["toggletb"] = new QAction("toggletb", this);
   403       action->setObjectName("toggletb");
   398       action->setObjectName("toggletb");
   404 
   399 
   405   }
   400   }
   406 
   401 
   407   void GWebContentView::triggerAction(const QString & action)
   402    void GWebContentView::triggerAction(const QString & action)
   408   {
   403   {
   409     QWebPage::WebAction webAction;
       
   410     if (action=="Stop")
   404     if (action=="Stop")
   411       webAction = QWebPage::Stop;
   405         webWidget()->triggerPageAction(QWebPage::Stop);
   412     else if (action=="Back")
   406     else if (action=="Back")
   413       webAction = QWebPage::Back;
   407         webWidget()->triggerPageAction(QWebPage::Back);
   414     else if (action=="Reload")
   408     else if (action=="Reload")
   415       webAction = QWebPage::Reload;
   409         webWidget()->triggerPageAction(QWebPage::Reload);
   416     else if (action=="Forward")
   410     else if (action=="Forward")
   417       webAction = QWebPage::Forward;
   411         webWidget()->triggerPageAction(QWebPage::Forward);
   418     else
   412     else if (action=="ZoomIn")
   419       return;
   413         triggerZoomInAction();
   420     webWidget()->triggerPageAction(webAction);
   414     else if (action=="ZoomOut")
   421   }
   415         triggerZoomOutAction();
       
   416   }
       
   417 
       
   418   void GWebContentView::triggerZoomInAction() {
       
   419       if(m_actions.contains("zoomIn"))
       
   420           m_actions["zoomIn"]->trigger();
       
   421   }
       
   422 
       
   423   void GWebContentView::triggerZoomOutAction() {
       
   424       if(m_actions.contains("zoomOut"))
       
   425           m_actions["zoomOut"]->trigger();
       
   426   }
       
   427 
   422 
   428 
   423   void GWebContentView::deactivateZoomActions()
   429   void GWebContentView::deactivateZoomActions()
   424   {
   430   {
   425     m_actions.value("zoomIn")->setEnabled(false);
   431     m_actions.value("zoomIn")->setEnabled(false);
   426     m_actions.value("zoomOut")->setEnabled(false);
   432     m_actions.value("zoomOut")->setEnabled(false);
   427   }
   433   }
   428 
   434 
   429   void GWebContentView::changeZoomAction(qreal zoom){
   435   void GWebContentView::changeZoomAction(qreal zoom){
       
   436     Q_UNUSED(zoom)
   430   #ifndef BEDROCK_TILED_BACKING_STORE
   437   #ifndef BEDROCK_TILED_BACKING_STORE
   431     if (!webWidget()) return;
   438     if (!webWidget()) return;
   432     if (!(webWidget()->isUserScalable() ) ){
   439     if (!(webWidget()->isUserScalable() ) ){
   433         deactivateZoomActions();
   440         deactivateZoomActions();
   434     }
   441     }
   469 void GWebContentView::setZoomActions(bool enableZoomIn, bool enableZoomOut)
   476 void GWebContentView::setZoomActions(bool enableZoomIn, bool enableZoomOut)
   470 {
   477 {
   471     m_actions.value("zoomIn")->setEnabled(enableZoomIn);
   478     m_actions.value("zoomIn")->setEnabled(enableZoomIn);
   472     m_actions.value("zoomOut")->setEnabled(enableZoomOut);
   479     m_actions.value("zoomOut")->setEnabled(enableZoomOut);
   473 }
   480 }
   474   qreal GWebContentView::getZoomFactor(){
   481 
       
   482 qreal GWebContentView::getZoomFactor(){
   475     return webWidgetConst() ? webWidgetConst()->scale() : 0.0;
   483     return webWidgetConst() ? webWidgetConst()->scale() : 0.0;
   476   }
   484 }
   477 
   485 
   478 #else
   486 #else
   479   qreal GWebContentView::getZoomFactor() const {
   487   qreal GWebContentView::getZoomFactor() const {
   480     return webWidgetConst() ? webWidgetConst()->zoomFactor() : 0.0;
   488     return webWidgetConst() ? webWidgetConst()->zoomFactor() : 0.0;
   481   }
   489   }
   491 
   499 
   492   void GWebContentView::deactivate() {
   500   void GWebContentView::deactivate() {
   493 #ifdef BEDROCK_TILED_BACKING_STORE
   501 #ifdef BEDROCK_TILED_BACKING_STORE
   494     if (!currentPageIsSuperPage()) {
   502     if (!currentPageIsSuperPage()) {
   495         WRT::WrtBrowserContainer* currentPage = WebPageController::getSingleton()->currentPage();
   503         WRT::WrtBrowserContainer* currentPage = WebPageController::getSingleton()->currentPage();
   496         currentPage->setPageZoomMetaData(m_widget->currentPageInfo());
   504         currentPage->setPageZoomMetaData(m_widget->pageDataFromViewportInfo());
   497     }
   505     }
   498 #endif
   506 #endif
   499       ControllableViewBase::deactivate();
   507       ControllableViewBase::deactivate();
   500   }
   508   }
   501 
   509 
   784 
   792 
   785           setCurrentSuperPage(name);
   793           setCurrentSuperPage(name);
   786           m_currentPageIsSuperPage = true;
   794           m_currentPageIsSuperPage = true;
   787 #ifndef BEDROCK_TILED_BACKING_STORE
   795 #ifndef BEDROCK_TILED_BACKING_STORE
   788           webWidget()->setPage(currentSuperPage()->page());
   796           webWidget()->setPage(currentSuperPage()->page());
   789           m_touchNavigation->setPage(webWidget()->page());
   797           m_touchNavigation->setPage(webWidget()->page(), false);
   790           m_touchNavigation->setWantSlideViewCalls(false);
       
   791           webWidget()->page()->setPreferredContentsSize(webWidget()->size().toSize());
   798           webWidget()->page()->setPreferredContentsSize(webWidget()->size().toSize());
   792 #else
   799 #else
   793           WRT::WrtBrowserContainer *pg = WebPageController::getSingleton()->currentPage();
   800           WRT::WrtBrowserContainer *pg = WebPageController::getSingleton()->currentPage();
   794           pg->setPageZoomMetaData(m_widget->currentPageInfo());
   801           pg->setPageZoomMetaData(m_widget->pageDataFromViewportInfo());
   795           m_widget->setPage(currentSuperPage()->page());
   802           m_widget->setPage(currentSuperPage()->page());
   796           m_widget->showPage(true);
   803           m_widget->showPage(true);
   797 #endif  
   804 #endif  
   798           emit superPageShown(name);
   805           emit superPageShown(name);
   799           currentSuperPage()->onShown();
   806           currentSuperPage()->onShown();
   803       }
   810       }
   804   }
   811   }
   805 
   812 
   806   void GWebContentView::showNormalPage() {
   813   void GWebContentView::showNormalPage() {
   807     if (webWidget()) {
   814     if (webWidget()) {
       
   815 #ifndef BEDROCK_TILED_BACKING_STORE
       
   816       webWidget()->showNormalPage();
       
   817       webWidget()->setViewportSize();
       
   818       m_touchNavigation->setPage(currentPage());
       
   819       m_touchNavigation->setWantSlideViewCalls(true);
       
   820 #else
       
   821       m_widget->showPage(false);
       
   822 #endif
   808       //TODO: Further testing is needed to show if the following is a net benefit.
   823       //TODO: Further testing is needed to show if the following is a net benefit.
   809       if (currentPageIsSuperPage()) {
   824       if (currentPageIsSuperPage()) {
   810           if(currentSuperPage()->page() == m_sharedPage){
   825           if(currentSuperPage()->page() == m_sharedPage){
   811               //Clear contents of shared page to free resources. This should save
   826               //Clear contents of shared page to free resources. This should save
   812               //memory for big pages, but at the performance cost of loading an empty page.
   827               //memory for big pages, but at the performance cost of loading an empty page.
   819           m_currentPageIsSuperPage =false;
   834           m_currentPageIsSuperPage =false;
   820       }
   835       }
   821 #ifndef BEDROCK_TILED_BACKING_STORE
   836 #ifndef BEDROCK_TILED_BACKING_STORE
   822     webWidget()->showNormalPage();
   837     webWidget()->showNormalPage();
   823     webWidget()->setViewportSize();
   838     webWidget()->setViewportSize();
   824     m_touchNavigation->setPage(currentPage());
   839     m_touchNavigation->setPage(currentPage(), true);
   825     m_touchNavigation->setWantSlideViewCalls(true);
       
   826 #else
   840 #else
   827     m_widget->showPage(false);
   841     m_widget->showPage(false);
   828 #endif
   842 #endif
   829     }
   843     emit normalPageShown(); 
   830 	WRT::WrtBrowserContainer * currPage = WebPageController::getSingleton()->currentPage();
   844     }
   831 			if(currPage){
       
   832 			  webWidget()->initializeViewportParams();
       
   833 			  webWidget()->setZoomFactor(currPage->pageZoomMetaData().zoomValue);
       
   834 			}
   845 			}
   835   }
       
   836 
   846 
   837   QObjectList GWebContentView::getSuperPages() {
   847   QObjectList GWebContentView::getSuperPages() {
   838     QObjectList *result = new QObjectList;
   848     QObjectList *result = new QObjectList;
   839     foreach(GVA::GSuperWebPage *page, m_superPages) {
   849     foreach(GVA::GSuperWebPage *page, m_superPages) {
   840       result->append(page);
   850       result->append(page);
   852   {
   862   {
   853     //qDebug() << "GWebContentView::onLoadStarted: " << QTime::currentTime();
   863     //qDebug() << "GWebContentView::onLoadStarted: " << QTime::currentTime();
   854 #if defined(__gva_no_chrome__) || defined(NO_RESIZE_ON_LOAD)
   864 #if defined(__gva_no_chrome__) || defined(NO_RESIZE_ON_LOAD)
   855       m_widget->onLoadStarted();
   865       m_widget->onLoadStarted();
   856 #endif
   866 #endif
       
   867 
   857     emit loadStarted();
   868     emit loadStarted();
   858   }
   869   }
   859 
   870 
   860   void GWebContentView::onLoadFinished(bool ok)
   871   void GWebContentView::onLoadFinished(bool ok)
   861   {
   872   {
   885         m_widget->setFocus();
   896         m_widget->setFocus();
   886 
   897 
   887 #if defined(__gva_no_chrome__) || defined(NO_RESIZE_ON_LOAD)
   898 #if defined(__gva_no_chrome__) || defined(NO_RESIZE_ON_LOAD)
   888     m_widget->onLoadFinished();
   899     m_widget->onLoadFinished();
   889 #endif
   900 #endif
       
   901     if(m_savedZoomData) {
       
   902         WrtBrowserContainer* curPage = WebPageController::getSingleton()->currentPage();
       
   903         curPage->setPageZoomMetaData(*m_savedZoomData);
       
   904         delete m_savedZoomData;
       
   905         m_savedZoomData = 0;
       
   906         m_widget->restoreViewportFromHistory(curPage->mainFrame());
       
   907     }
   890   }
   908   }
   891 
   909 
   892   void GWebContentView::dump() {
   910   void GWebContentView::dump() {
   893     qDebug() << "-------------";
   911     qDebug() << "-------------";
   894     qDebug() << "GWebContentView::dump: " << this;
   912     qDebug() << "GWebContentView::dump: " << this;
   913 
   931 
   914       /* save the page snapshot before changing the current page to the new page*/
   932       /* save the page snapshot before changing the current page to the new page*/
   915       WRT::WrtBrowserContainer * currPage = WebPageController::getSingleton()->currentPage();
   933       WRT::WrtBrowserContainer * currPage = WebPageController::getSingleton()->currentPage();
   916       if (currPage) {
   934       if (currPage) {
   917           QWebHistoryItem item = currPage->history()->currentItem();
   935           QWebHistoryItem item = currPage->history()->currentItem();
   918           currPage->savePageDataToHistoryItem(currPage->mainFrame(), &item);
   936           //currPage->savePageDataToHistoryItem(currPage->mainFrame(), &item);
   919       }
   937       }
   920 
   938 
   921       // When new windows are created from window view, as the content is empty, we should disable
   939       // When new windows are created from window view, as the content is empty, we should disable
   922       // zoom actions. Set the user-scalable to false and also init the other zoom params
   940       // zoom actions. Set the user-scalable to false and also init the other zoom params
   923       // so that even if we change to windows view again without loading a page we are safe.
   941       // so that even if we change to windows view again without loading a page we are safe.
   924       // In the code-driven window usecase, this will be overwritten when the page is loaded and setViewportSize is invoked
   942       // In the code-driven window usecase, this will be overwritten when the page is loaded and setViewportSize is invoked
   925 #ifndef BEDROCK_TILED_BACKING_STORE
   943 #ifndef BEDROCK_TILED_BACKING_STORE
   926       newPage->setPageZoomMetaData(webWidget()->defaultZoomData());
   944       newPage->setPageZoomMetaData(webWidget()->defaultZoomData());
   927 #else
   945 #else
       
   946       if(newPage->pageZoomMetaData()->isValid())
       
   947          m_widget->setPageDataToViewportInfo(*(newPage->pageZoomMetaData())); // data from history
       
   948       else
   928 	newPage->setPageZoomMetaData(m_widget->defaultZoomData());
   949 	newPage->setPageZoomMetaData(m_widget->defaultZoomData());
   929 #endif
   950 #endif
   930       /* Set the new page as the current page */
   951       /* Set the new page as the current page */
   931       WebPageController::getSingleton()->setCurrentPage(newPage);
   952       WebPageController::getSingleton()->setCurrentPage(newPage);
   932 
   953 
   956       {
   977       {
   957           pg->setWebWidget(w);
   978           pg->setWebWidget(w);
   958 
   979 
   959 #ifndef BEDROCK_TILED_BACKING_STORE
   980 #ifndef BEDROCK_TILED_BACKING_STORE
   960           // Change navigation also to the current page
   981           // Change navigation also to the current page
   961           m_touchNavigation->setPage(pg);
   982           m_touchNavigation->setPage(pg,true );
   962           m_touchNavigation->setWantSlideViewCalls(true);
   983           m_touchNavigation->setLoadingFlag( WebPageController::getSingleton()->isPageLoading());
   963 #endif
   984 #endif
   964 
   985 
   965       }
   986       }
   966   }
   987   }
   967 
   988 
   974       changeContentViewZoomInfo(newPage);
   995       changeContentViewZoomInfo(newPage);
   975 #endif
   996 #endif
   976   }
   997   }
   977 
   998 
   978 #ifdef BEDROCK_TILED_BACKING_STORE
   999 #ifdef BEDROCK_TILED_BACKING_STORE
   979   void GWebContentView::handleContextEventObject(QWebHitTestResult* eventTarget)
  1000   void GWebContentView::handleContextEventObject(QWebHitTestResult* hitTest, QPointF position)
   980   {
  1001   {
   981       WebViewEventContext context(type(), *eventTarget);
  1002       WebViewEventContext context(type(),  *hitTest);
   982       if (currentPageIsSuperPage()) {
  1003       if (currentPageIsSuperPage()) {
   983           // Let the superpage handle the event.
  1004           // Let the superpage handle the event.
   984           currentSuperPage()->onContextEvent(&context);
  1005           //currentSuperPage()->onContextEvent(&context);
       
  1006           emit contextEvent(&context);
   985       }
  1007       }
   986       else {
  1008       else {
   987           // Send the event directly.
  1009           #ifdef Q_WS_MAEMO_5
       
  1010           ContentViewContextMenu menu(hitTest, 0);
       
  1011           menu.exec(widget()->mapToScene(position).toPoint());
       
  1012           #else
   988           emit contextEvent(&context);
  1013           emit contextEvent(&context);
       
  1014           #endif
   989       }
  1015       }
   990   }
  1016   }
   991 void GWebContentView::handleViewScrolled(QPoint& scrollPos, QPoint& delta)
  1017 void GWebContentView::handleViewScrolled(QPoint& scrollPos, QPoint& delta)
   992 {
  1018 {
   993     if (delta.manhattanLength() && (delta.y() > 0  || scrollPos.y() + delta.y() <= 40) 
  1019     if(!currentPageIsSuperPage() && !WebPageController::getSingleton()->isPageLoading())
   994         && !currentPageIsSuperPage())
  1020         m_chrome->layout()->setViewSlide(scrollPos.y() + delta.y());
   995         m_chrome->layout()->slideView(-delta.y());
       
   996     
  1021     
   997     emit startingPanGesture(1);
  1022     emit startingPanGesture(1);
   998 }
  1023 }
   999 
  1024 
  1000 #endif
  1025 #endif
  1012          // ensure that the correct zoom factor is applied as there is a possibility
  1037          // ensure that the correct zoom factor is applied as there is a possibility
  1013          // that we might have been on another page earlier
  1038          // that we might have been on another page earlier
  1014          webWidget()->setPageZoomFactor(newPage->mainFrame()->zoomFactor());
  1039          webWidget()->setPageZoomFactor(newPage->mainFrame()->zoomFactor());
  1015       }
  1040       }
  1016 #else
  1041 #else
  1017 	 m_widget->setCurrentPageInfo(newPage->pageZoomMetaData());
  1042          m_widget->setPageDataToViewportInfo(*(newPage->pageZoomMetaData()));
  1018 #endif
  1043 #endif
  1019   }
  1044   }
  1020 
  1045 
  1021   void GWebContentView::setJSObject(const QString &objectName) {
  1046   void GWebContentView::setJSObject(const QString &objectName) {
  1022       m_jsObject = new GWebContentViewJSObject(this, m_chrome->page()->mainFrame(), objectName);
  1047       m_jsObject = new GWebContentViewJSObject(this, m_chrome->page()->mainFrame(), objectName);
  1033 
  1058 
  1034       m_enabled = value;
  1059       m_enabled = value;
  1035       widget()->setEnabled(value);
  1060       widget()->setEnabled(value);
  1036       widget()->update();
  1061       widget()->update();
  1037   }
  1062   }
       
  1063   
       
  1064   
       
  1065   bool GWebContentView::gesturesEnabled() const 
       
  1066   { 
       
  1067 #ifndef BEDROCK_TILED_BACKING_STORE
       
  1068       return m_touchNavigation->enabled(); 
       
  1069 #else   
       
  1070       return m_widget->gesturesEnabled();
       
  1071 #endif
       
  1072   }
       
  1073 
       
  1074   void GWebContentView::setGesturesEnabled(bool value) 
       
  1075   { 
       
  1076 #ifndef BEDROCK_TILED_BACKING_STORE       
       
  1077       m_touchNavigation->setEnabled(value); 
       
  1078 #else
       
  1079       m_widget->setGesturesEnabled(value);
       
  1080 #endif
       
  1081   }
       
  1082 
       
  1083 #ifndef BEDROCK_TILED_BACKING_STORE
  1038   void GWebContentView::setSavedZoomValueInView(qreal zoomValue){
  1084   void GWebContentView::setSavedZoomValueInView(qreal zoomValue){
  1039 	  m_savedZoomValueInView = zoomValue;
  1085 	  m_savedZoomValueInView = zoomValue;
  1040   }
  1086   }
  1041   
  1087   
  1042   qreal GWebContentView::getSavedZoomValueInView() const{
  1088   qreal GWebContentView::getSavedZoomValueInView() const{
  1043       return m_savedZoomValueInView;
  1089       return m_savedZoomValueInView;
  1044   }
  1090   }
       
  1091 #endif
       
  1092 
       
  1093   void GWebContentView::saveZoomDataAndRestoreAfterLoad()
       
  1094   {
       
  1095       QVariant userData = m_widget->webView()->page()->history()->currentItem().userData();
       
  1096       QVariant::Type t = userData.type();
       
  1097       int ut = userData.userType();
       
  1098 
       
  1099       if(userData.isValid() && t == QVariant::UserType &&
       
  1100          ut == QMetaTypeId<WebPageData>::qt_metatype_id())
       
  1101         m_savedZoomData = new WebPageData(userData.value<WebPageData>());
       
  1102   }
  1045 } // end of namespace GVA
  1103 } // end of namespace GVA
  1046 
  1104 
  1047 
  1105