20 */ |
20 */ |
21 |
21 |
22 #include "GWebContentView.h" |
22 #include "GWebContentView.h" |
23 #include "GWebContentViewWidget.h" |
23 #include "GWebContentViewWidget.h" |
24 #include "GWebContentViewJSObject.h" |
24 #include "GWebContentViewJSObject.h" |
|
25 #include "SuperPageView.h" |
25 #include "ChromeWidget.h" |
26 #include "ChromeWidget.h" |
26 #include "WebViewEventContext.h" |
27 #include "WebViewEventContext.h" |
27 #include "browserpagefactory.h" |
28 #include "browserpagefactory.h" |
28 #include "wrtbrowsercontainer.h" |
29 #include "wrtbrowsercontainer.h" |
|
30 |
|
31 #ifdef BEDROCK_TILED_BACKING_STORE |
|
32 #include "WebContentViewWidget.h" |
|
33 #endif |
|
34 |
29 #include "webpagecontroller.h" |
35 #include "webpagecontroller.h" |
|
36 #include "Utilities.h" |
|
37 #include "GSuperWebPage.h" |
30 #ifndef NO_QSTM_GESTURE |
38 #ifndef NO_QSTM_GESTURE |
31 #include "qstmgestureevent.h" |
39 #include "qstmgestureevent.h" |
32 #endif |
40 #endif |
33 |
41 |
34 #include <QGraphicsWebView> |
42 #include <QGraphicsWebView> |
64 m_currentPageIsSuperPage(false), |
68 m_currentPageIsSuperPage(false), |
65 m_timer(NULL), |
69 m_timer(NULL), |
66 m_enabled(true) |
70 m_enabled(true) |
67 { |
71 { |
68 setObjectName(objectName); |
72 setObjectName(objectName); |
69 qDebug() << "GWebContentView::GWebContentView: this=" << this; |
|
70 WRT::WrtBrowserContainer* page = BrowserPageFactory::openBrowserPage(); |
73 WRT::WrtBrowserContainer* page = BrowserPageFactory::openBrowserPage(); |
71 |
74 |
72 setActions(); |
75 setActions(); |
|
76 |
|
77 #ifdef BEDROCK_TILED_BACKING_STORE |
|
78 m_widget = new WebContentViewWidget(parent, page); |
|
79 connect(m_widget |
|
80 , SIGNAL(updateZoomActions(bool,bool)) |
|
81 , this |
|
82 , SLOT(setZoomActions(bool, bool))); |
|
83 #else |
73 m_widget = new GWebContentViewWidget(parent, this, page); |
84 m_widget = new GWebContentViewWidget(parent, this, page); |
|
85 #endif |
|
86 |
74 #ifndef __gva_no_chrome__ |
87 #ifndef __gva_no_chrome__ |
75 setJSObject(objectName); |
88 setJSObject(objectName); |
76 #endif |
89 #endif |
77 m_networkMgr = webWidget()->page()->networkAccessManager(); |
90 m_networkMgr = webWidget()->page()->networkAccessManager(); |
78 |
91 |
79 webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); |
92 webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); |
80 webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); |
93 webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); |
81 |
94 |
|
95 #ifndef BEDROCK_TILED_BACKING_STORE |
82 #ifdef NO_QSTM_GESTURE |
96 #ifdef NO_QSTM_GESTURE |
83 m_touchNavigation = new GContentViewTouchNavigation(page, m_widget); |
97 m_touchNavigation = new GContentViewTouchNavigation(page, m_widget); |
84 m_touchNavigation->setChromeWidget(m_chrome); |
98 m_touchNavigation->setChromeWidget(m_chrome); |
85 connect(m_touchNavigation, SIGNAL(mouseEvent(QEvent::Type)) , this, SIGNAL(contentViewMouseEvent(QEvent::Type))); |
99 m_touchNavigation->setParent(m_jsObject); |
|
100 m_touchNavigation->setObjectName("touchNav"); |
|
101 safe_connect(m_touchNavigation, SIGNAL(mouseEvent(QEvent::Type)) , this, SIGNAL(contentViewMouseEvent(QEvent::Type))); |
|
102 safe_connect(m_touchNavigation, SIGNAL(longPressEvent(QPoint)), |
|
103 webWidget(), SLOT(onLongPressEvent(QPoint))); |
|
104 #endif |
86 #endif |
105 #endif |
87 WRT::WrtBrowserContainer * wrtPage = static_cast<WRT::WrtBrowserContainer *>(page); |
106 WRT::WrtBrowserContainer * wrtPage = static_cast<WRT::WrtBrowserContainer *>(page); |
88 if (wrtPage) { |
107 if (wrtPage) { |
89 wrtPage->setWebWidget(webWidget()); |
108 wrtPage->setWebWidget(webWidget()); |
90 pageCreated(wrtPage); |
109 pageCreated(wrtPage); |
94 } |
113 } |
95 |
114 |
96 GWebContentView::~GWebContentView() { |
115 GWebContentView::~GWebContentView() { |
97 disconnect(m_jsObject); |
116 disconnect(m_jsObject); |
98 disconnect(webWidget()); |
117 disconnect(webWidget()); |
|
118 #ifndef BEDROCK_TILED_BACKING_STORE |
99 delete m_touchNavigation; |
119 delete m_touchNavigation; |
|
120 #endif |
100 foreach(QAction * action, m_actions) { |
121 foreach(QAction * action, m_actions) { |
101 delete action; |
122 delete action; |
102 } |
123 } |
103 |
124 |
104 delete m_widget; |
125 delete m_widget; |
105 foreach(GWebPage *page, m_superPages) { |
126 foreach(GSuperWebPage *page, m_superPages) { |
106 delete page; |
127 delete page; |
107 } |
128 } |
108 } |
129 } |
109 |
130 |
|
131 #ifdef BEDROCK_TILED_BACKING_STORE |
|
132 void GWebContentView::zoomIn(qreal deltaPercent) |
|
133 { |
|
134 //FIX ME : Do we need deltaPercent? |
|
135 Q_UNUSED(deltaPercent); |
|
136 m_widget->setPageZoom(true); |
|
137 } |
|
138 |
|
139 void GWebContentView::zoomOut(qreal deltaPercent) |
|
140 { |
|
141 //FIX ME : Do we need deltaPercent? |
|
142 Q_UNUSED(deltaPercent); |
|
143 m_widget->setPageZoom(false); |
|
144 } |
|
145 #endif |
|
146 |
|
147 #ifndef BEDROCK_TILED_BACKING_STORE |
110 void GWebContentView::bitmapZoomStop() |
148 void GWebContentView::bitmapZoomStop() |
111 { |
149 { |
112 if (m_timer) { |
150 if (m_timer) { |
113 m_timer->stop(); |
151 m_timer->stop(); |
114 disconnect(m_timer,SIGNAL(timeout())); |
152 disconnect(m_timer,SIGNAL(timeout())); |
204 webWidget()->setZoomFactor(m_value * webWidget()->zoomFactor()); |
242 webWidget()->setZoomFactor(m_value * webWidget()->zoomFactor()); |
205 } |
243 } |
206 } |
244 } |
207 } |
245 } |
208 |
246 |
|
247 #endif |
209 void GWebContentView::connectAll() { |
248 void GWebContentView::connectAll() { |
210 //qDebug() << "GWebContentView::connectAll: " << widget(); |
249 //qDebug() << "GWebContentView::connectAll: " << widget(); |
211 |
250 |
212 #ifndef __gva_no_chrome__ |
251 #ifndef __gva_no_chrome__ |
|
252 #ifndef BEDROCK_TILED_BACKING_STORE |
213 safe_connect(widget(), SIGNAL(contextEvent(::WebViewEventContext *)), |
253 safe_connect(widget(), SIGNAL(contextEvent(::WebViewEventContext *)), |
214 m_jsObject, SLOT(onContextEvent(::WebViewEventContext *))); |
254 m_jsObject, SLOT(onContextEvent(::WebViewEventContext *))); |
|
255 #else |
|
256 safe_connect(this |
|
257 , SIGNAL(contextEvent(::WebViewEventContext*)) |
|
258 , m_jsObject |
|
259 , SLOT(onContextEvent(::WebViewEventContext*))); |
|
260 |
|
261 safe_connect(m_widget |
|
262 , SIGNAL(contextEventObject(QWebHitTestResult*)) |
|
263 , this |
|
264 , SLOT(handleContextEventObject(QWebHitTestResult*))); |
|
265 |
|
266 safe_connect(m_widget |
|
267 , SIGNAL(viewScrolled(QPoint&, QPoint&)) |
|
268 , this |
|
269 , SLOT(handleViewScrolled(QPoint&, QPoint&))); |
|
270 #endif |
215 QObject::connect(webWidget(), SIGNAL(titleChanged(const QString &)), m_jsObject, SIGNAL(titleChanged(const QString &))); |
271 QObject::connect(webWidget(), SIGNAL(titleChanged(const QString &)), m_jsObject, SIGNAL(titleChanged(const QString &))); |
216 QObject::connect(webWidget(), SIGNAL(loadStarted()), m_jsObject, SIGNAL(loadStarted())); |
272 QObject::connect(webWidget(), SIGNAL(loadStarted()), m_jsObject, SIGNAL(loadStarted())); |
217 QObject::connect(webWidget(), SIGNAL(loadProgress(int)), m_jsObject, SIGNAL(loadProgress(int))); |
273 QObject::connect(webWidget(), SIGNAL(loadProgress(int)), m_jsObject, SIGNAL(loadProgress(int))); |
218 QObject::connect(webWidget(), SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); |
274 QObject::connect(webWidget(), SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); |
219 #endif |
275 #endif |
224 QObject::connect(this, SIGNAL(urlChanged(const QString&)), m_jsObject, SIGNAL(urlChanged(const QString&))); |
280 QObject::connect(this, SIGNAL(urlChanged(const QString&)), m_jsObject, SIGNAL(urlChanged(const QString&))); |
225 QObject::connect(this, SIGNAL(backEnabled(bool)), m_jsObject, SIGNAL(backEnabled(bool))); |
281 QObject::connect(this, SIGNAL(backEnabled(bool)), m_jsObject, SIGNAL(backEnabled(bool))); |
226 QObject::connect(this, SIGNAL(forwardEnabled(bool)), m_jsObject, SIGNAL(forwardEnabled(bool))); |
282 QObject::connect(this, SIGNAL(forwardEnabled(bool)), m_jsObject, SIGNAL(forwardEnabled(bool))); |
227 QObject::connect(this, SIGNAL(loadFinished(bool)), m_jsObject, SIGNAL(loadFinished(bool))); |
283 QObject::connect(this, SIGNAL(loadFinished(bool)), m_jsObject, SIGNAL(loadFinished(bool))); |
228 QObject::connect(this, SIGNAL(secureConnection(bool)), m_jsObject, SIGNAL(secureConnection(bool))); |
284 QObject::connect(this, SIGNAL(secureConnection(bool)), m_jsObject, SIGNAL(secureConnection(bool))); |
|
285 #ifndef BEDROCK_TILED_BACKING_STORE |
229 connect(m_touchNavigation, SIGNAL(startingPanGesture(int)), m_jsObject, SIGNAL(startingPanGesture(int))); |
286 connect(m_touchNavigation, SIGNAL(startingPanGesture(int)), m_jsObject, SIGNAL(startingPanGesture(int))); |
|
287 #endif |
|
288 QObject::connect(this, SIGNAL(superPageShown(const QString&)), m_jsObject, SIGNAL(superPageShown(const QString&))); |
|
289 |
230 #endif |
290 #endif |
231 connect(WebPageController::getSingleton(), SIGNAL(pageCreated(WRT::WrtBrowserContainer*)), |
291 connect(WebPageController::getSingleton(), SIGNAL(pageCreated(WRT::WrtBrowserContainer*)), |
232 this, SLOT(pageCreated(WRT::WrtBrowserContainer*))); |
292 this, SLOT(pageCreated(WRT::WrtBrowserContainer*))); |
233 connect(WebPageController::getSingleton(), SIGNAL(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*)), |
293 connect(WebPageController::getSingleton(), SIGNAL(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*)), |
234 this, SLOT(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*))); |
294 this, SLOT(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*))); |
248 |
308 |
249 QGraphicsWidget* GWebContentView::widget() const { |
309 QGraphicsWidget* GWebContentView::widget() const { |
250 return static_cast<QGraphicsWidget*>(m_widget); |
310 return static_cast<QGraphicsWidget*>(m_widget); |
251 } |
311 } |
252 |
312 |
|
313 #ifdef BEDROCK_TILED_BACKING_STORE |
|
314 QGraphicsWebView* GWebContentView::webWidget() const { |
|
315 return m_widget->webView(); |
|
316 } |
|
317 #else |
253 GWebContentViewWidget *GWebContentView::webWidget() const { |
318 GWebContentViewWidget *GWebContentView::webWidget() const { |
254 return m_widget; |
319 return m_widget; |
255 } |
320 } |
|
321 #endif |
256 |
322 |
257 QString GWebContentView::title() const { |
323 QString GWebContentView::title() const { |
258 return webWidget()->title(); |
324 return webWidget()->title(); |
259 } |
325 } |
260 |
326 |
261 QUrl GWebContentView::url() { |
327 QUrl GWebContentView::url() { |
262 return webWidget()->url(); |
328 return webWidget()->url(); |
263 } |
329 } |
264 |
330 |
265 QWebPage* GWebContentView::wrtPage() { |
331 QWebPage* GWebContentView::wrtPage() { |
|
332 #ifdef BEDROCK_TILED_BACKING_STORE |
|
333 return m_widget->page(); |
|
334 #else |
266 return m_widget->wrtPage(); |
335 return m_widget->wrtPage(); |
|
336 #endif |
267 } |
337 } |
268 |
338 |
269 void GWebContentView::setActions(){ |
339 void GWebContentView::setActions(){ |
270 |
340 |
271 QAction* action; |
341 QAction* action; |
344 } |
414 } |
345 else { |
415 else { |
346 zoomInAction->setEnabled(true); |
416 zoomInAction->setEnabled(true); |
347 } |
417 } |
348 } |
418 } |
|
419 #endif |
349 } |
420 } |
350 |
421 |
351 void GWebContentView::setZoomFactor(qreal factor){ |
422 void GWebContentView::setZoomFactor(qreal factor){ |
352 if (webWidget()) |
423 if (webWidget()) |
|
424 #ifdef BEDROCK_TILED_BACKING_STORE |
|
425 webWidget()->setScale(factor); |
|
426 #else |
353 webWidget()->setZoomFactor(factor); |
427 webWidget()->setZoomFactor(factor); |
354 } |
428 #endif |
355 |
429 } |
|
430 |
|
431 #ifdef BEDROCK_TILED_BACKING_STORE |
|
432 QGraphicsWidget* GWebContentView::webWidgetConst() { |
|
433 return m_widget; |
|
434 } |
|
435 |
|
436 void GWebContentView::setZoomActions(bool enableZoomIn, bool enableZoomOut) |
|
437 { |
|
438 m_actions.value("zoomIn")->setEnabled(enableZoomIn); |
|
439 m_actions.value("zoomOut")->setEnabled(enableZoomOut); |
|
440 } |
|
441 qreal GWebContentView::getZoomFactor(){ |
|
442 return webWidgetConst() ? webWidgetConst()->scale() : 0.0; |
|
443 } |
|
444 |
|
445 #else |
356 qreal GWebContentView::getZoomFactor() const { |
446 qreal GWebContentView::getZoomFactor() const { |
357 return webWidgetConst() ? webWidgetConst()->zoomFactor() : 0.0; |
447 return webWidgetConst() ? webWidgetConst()->zoomFactor() : 0.0; |
358 } |
448 } |
359 |
449 #endif |
360 void GWebContentView::activate() { |
450 |
361 qDebug() << "GWebContentView::activate"; |
451 void GWebContentView::activate() { |
362 ControllableViewBase::activate(); |
452 #ifdef BEDROCK_TILED_BACKING_STORE |
|
453 WRT::WrtBrowserContainer* newPage = WebPageController::getSingleton()->currentPage(); |
|
454 changeContentViewZoomInfo(newPage); |
|
455 #endif |
|
456 ControllableViewBase::activate(); |
363 } |
457 } |
364 |
458 |
365 void GWebContentView::deactivate() { |
459 void GWebContentView::deactivate() { |
366 qDebug() << "GWebContentView::deactivate"; |
460 #ifdef BEDROCK_TILED_BACKING_STORE |
|
461 if (!currentPageIsSuperPage()) { |
|
462 WRT::WrtBrowserContainer* currentPage = WebPageController::getSingleton()->currentPage(); |
|
463 currentPage->setPageZoomMetaData(m_widget->currentPageInfo()); |
|
464 } |
|
465 #endif |
367 ControllableViewBase::deactivate(); |
466 ControllableViewBase::deactivate(); |
368 } |
467 } |
369 |
468 |
370 // static void appendAction(QWebPage* page, QList<QAction*> &list, enum QWebPage::WebAction webAction, const QString &name) { |
469 // static void appendAction(QWebPage* page, QList<QAction*> &list, enum QWebPage::WebAction webAction, const QString &name) { |
371 // QAction *action = page->action(webAction); |
470 // QAction *action = page->action(webAction); |
586 } |
684 } |
587 } |
685 } |
588 else { |
686 else { |
589 qDebug() << "GWebContentView::createPage: page already exists: " << name; |
687 qDebug() << "GWebContentView::createPage: page already exists: " << name; |
590 } |
688 } |
|
689 //Create a controllable view onto the super page so that it can be controlled by the view controller. |
|
690 m_chrome->addView(new SuperPageView(this, page, name)); |
591 return page; |
691 return page; |
592 } |
692 } |
593 |
693 |
594 void GWebContentView::destroySuperPage(const QString &name) { |
694 void GWebContentView::destroySuperPage(const QString &name) { |
595 qDebug() << "GWebContentView::destroySuperPage: " << name; |
|
596 if (!m_superPages.contains(name)) return; |
695 if (!m_superPages.contains(name)) return; |
597 |
696 |
598 GWebPage *page = m_superPages.take(name); |
697 GSuperWebPage *page = m_superPages.take(name); |
599 //This will destroy any QWebPage owned by the super page. The shared page is not |
698 //This will destroy any QWebPage owned by the super page. The shared page is not |
600 //owned by the super page and will be deleted when the GWebContentView is deleted. |
699 //owned by the super page and will be deleted when the GWebContentView is deleted. |
601 if (page){ |
700 if (page){ |
602 delete page; |
701 delete page; |
603 } |
702 } |
604 } |
703 } |
605 |
704 |
606 void GWebContentView::setCurrentSuperPage(const QString &name) { |
705 bool GWebContentView::setCurrentSuperPage(const QString &name) { |
607 PageMap::iterator it = m_superPages.find(name); |
706 PageMap::iterator it = m_superPages.find(name); |
608 if (it != m_superPages.end()) { |
707 if (it != m_superPages.end()) { |
609 m_currentSuperPage = it; |
708 m_currentSuperPage = it; |
|
709 return true; |
610 } |
710 } |
611 else { |
711 else { |
612 qDebug() << "GWebContentView::setCurrentSuperPage: not found: " << name; |
712 qDebug() << "GWebContentView::setCurrentSuperPage: not found: " << name; |
|
713 return false; |
613 } |
714 } |
614 } |
715 } |
615 |
716 |
616 bool GWebContentView::isSuperPage(const QString &name){ |
717 bool GWebContentView::isSuperPage(const QString &name){ |
617 PageMap::iterator it = m_superPages.find(name); |
718 PageMap::iterator it = m_superPages.find(name); |
618 if (it != m_superPages.end()) { |
719 if (it != m_superPages.end()) { |
619 return true; |
720 return true; |
620 } |
721 } |
621 qDebug() << "GWebContentView::superPage: not found: " << name; |
722 qDebug() << "GWebContentView::superPage: not found: " << name; |
622 return false; |
723 return false; |
623 } |
724 } |
624 |
725 |
625 |
726 |
626 GWebPage * GWebContentView::superPage(const QString &name) { |
727 GSuperWebPage * GWebContentView::superPage(const QString &name) { |
627 PageMap::iterator it = m_superPages.find(name); |
728 PageMap::iterator it = m_superPages.find(name); |
628 if (it != m_superPages.end()) { |
729 if (it != m_superPages.end()) { |
629 return it.value(); |
730 return it.value(); |
630 } |
731 } |
631 qDebug() << "GWebContentView::superPage: not found: " << name; |
732 qDebug() << "GWebContentView::superPage: not found: " << name; |
632 return 0; |
733 return 0; |
633 } |
734 } |
634 |
735 |
635 void GWebContentView::showSuperPage(const QString &name) { |
736 void GWebContentView::showSuperPage(const QString &name) { |
636 setCurrentSuperPage(name); |
737 if(isSuperPage(name)) { |
637 qDebug() << "GWebContentView::showSuperPage: " << currentSuperPage(); |
738 if(currentPageIsSuperPage()) { |
638 m_currentPageIsSuperPage = true; |
739 currentSuperPage()->onHidden(); |
639 webWidget()->setPage(currentSuperPage()->page()); |
740 } |
640 m_touchNavigation->setPage(webWidget()->page()); |
741 |
641 m_touchNavigation->setWantSlideViewCalls(false); |
742 setCurrentSuperPage(name); |
642 webWidget()->page()->setPreferredContentsSize(webWidget()->size().toSize()); |
743 m_currentPageIsSuperPage = true; |
|
744 #ifndef BEDROCK_TILED_BACKING_STORE |
|
745 webWidget()->setPage(currentSuperPage()->page()); |
|
746 m_touchNavigation->setPage(webWidget()->page()); |
|
747 m_touchNavigation->setWantSlideViewCalls(false); |
|
748 webWidget()->page()->setPreferredContentsSize(webWidget()->size().toSize()); |
|
749 #else |
|
750 WRT::WrtBrowserContainer *pg = WebPageController::getSingleton()->currentPage(); |
|
751 pg->setPageZoomMetaData(m_widget->currentPageInfo()); |
|
752 m_widget->setPage(currentSuperPage()->page()); |
|
753 m_widget->showPage(true); |
|
754 #endif |
|
755 emit superPageShown(name); |
|
756 currentSuperPage()->onShown(); |
|
757 } |
|
758 else { |
|
759 qDebug() << "GWebContentView::showSuperPage: error, not found: " << name; |
|
760 } |
643 } |
761 } |
644 |
762 |
645 void GWebContentView::showNormalPage() { |
763 void GWebContentView::showNormalPage() { |
646 if (webWidget()) { |
764 if (webWidget()) { |
|
765 #ifndef BEDROCK_TILED_BACKING_STORE |
647 webWidget()->showNormalPage(); |
766 webWidget()->showNormalPage(); |
648 webWidget()->setViewportSize(); |
767 webWidget()->setViewportSize(); |
649 m_touchNavigation->setPage(currentPage()); |
768 m_touchNavigation->setPage(currentPage()); |
650 m_touchNavigation->setWantSlideViewCalls(true); |
769 m_touchNavigation->setWantSlideViewCalls(true); |
|
770 #else |
|
771 m_widget->showPage(false); |
|
772 #endif |
651 //TODO: Further testing is needed to show if the following is a net benefit. |
773 //TODO: Further testing is needed to show if the following is a net benefit. |
652 if (m_currentPageIsSuperPage && (currentSuperPage()->page() == m_sharedPage)){ |
774 if (currentPageIsSuperPage()) { |
653 //Clear contents of shared page to free resources. This should save |
775 if(currentSuperPage()->page() == m_sharedPage){ |
654 //memory for big pages, but at the performance cost of loading an empty page. |
776 //Clear contents of shared page to free resources. This should save |
655 //An alternative is to delete the shared page every time and reallocate it when |
777 //memory for big pages, but at the performance cost of loading an empty page. |
656 //a super page is loaded. |
778 //An alternative is to delete the shared page every time and reallocate it when |
657 currentSuperPage()->page()->mainFrame()->setHtml(QString()); |
779 //a super page is loaded. |
658 } |
780 currentSuperPage()->page()->mainFrame()->setHtml(QString()); |
659 m_currentPageIsSuperPage =false; |
781 } |
|
782 |
|
783 currentSuperPage()->onHidden(); |
|
784 m_currentPageIsSuperPage =false; |
|
785 } |
660 } |
786 } |
661 } |
787 } |
662 |
788 |
663 QObjectList GWebContentView::getSuperPages() { |
789 QObjectList GWebContentView::getSuperPages() { |
664 QObjectList *result = new QObjectList; |
790 QObjectList *result = new QObjectList; |
665 foreach(GVA::GWebPage *page, m_superPages) { |
791 foreach(GVA::GSuperWebPage *page, m_superPages) { |
666 result->append(page); |
792 result->append(page); |
667 } |
793 } |
668 // TO DO: Need to add result to JS engine so it can be cleaned up. |
794 // TO DO: Need to add result to JS engine so it can be cleaned up. |
669 return *result; |
795 return *result; |
670 } |
796 } |
745 |
870 |
746 // When new windows are created from window view, as the content is empty, we should disable |
871 // When new windows are created from window view, as the content is empty, we should disable |
747 // zoom actions. Set the user-scalable to false and also init the other zoom params |
872 // zoom actions. Set the user-scalable to false and also init the other zoom params |
748 // so that even if we change to windows view again without loading a page we are safe. |
873 // so that even if we change to windows view again without loading a page we are safe. |
749 // In the code-driven window usecase, this will be overwritten when the page is loaded and setViewportSize is invoked |
874 // In the code-driven window usecase, this will be overwritten when the page is loaded and setViewportSize is invoked |
|
875 #ifndef BEDROCK_TILED_BACKING_STORE |
750 newPage->setPageZoomMetaData(webWidget()->defaultZoomData()); |
876 newPage->setPageZoomMetaData(webWidget()->defaultZoomData()); |
751 |
877 #else |
|
878 newPage->setPageZoomMetaData(m_widget->defaultZoomData()); |
|
879 #endif |
752 /* Set the new page as the current page */ |
880 /* Set the new page as the current page */ |
753 WebPageController::getSingleton()->setCurrentPage(newPage); |
881 WebPageController::getSingleton()->setCurrentPage(newPage); |
754 |
882 |
755 /* Set the web widget- this one is responsible for webnavigation etc */ |
883 /* Set the web widget- this one is responsible for webnavigation etc */ |
756 newPage->setWebWidget(webWidget()); |
884 newPage->setWebWidget(webWidget()); |
757 |
885 |
|
886 #ifndef BEDROCK_TILED_BACKING_STORE |
758 //connect new page main frame's initialLayoutCompleted with WebContentWidget' setViewportSize SLOT |
887 //connect new page main frame's initialLayoutCompleted with WebContentWidget' setViewportSize SLOT |
759 connect(newPage->mainFrame(), SIGNAL(initialLayoutCompleted()), webWidget(), SLOT(setViewportSize())); |
888 connect(newPage->mainFrame(), SIGNAL(initialLayoutCompleted()), webWidget(), SLOT(setViewportSize())); |
|
889 #endif |
760 } |
890 } |
761 |
891 |
762 void GWebContentView::updateWebPage(WRT::WrtBrowserContainer* pg) |
892 void GWebContentView::updateWebPage(WRT::WrtBrowserContainer* pg) |
763 { |
893 { |
|
894 #ifdef BEDROCK_TILED_BACKING_STORE |
|
895 QGraphicsWebView* w = webWidget(); |
|
896 #else |
764 GWebContentViewWidget* w = webWidget(); |
897 GWebContentViewWidget* w = webWidget(); |
|
898 #endif |
|
899 |
|
900 #ifndef BEDROCK_TILED_BACKING_STORE |
765 w->setPage(pg); |
901 w->setPage(pg); |
|
902 #else |
|
903 m_widget->setPage(pg); |
|
904 #endif |
766 if (pg) |
905 if (pg) |
767 { |
906 { |
768 pg->setWebWidget(w); |
907 pg->setWebWidget(w); |
769 |
908 |
|
909 #ifndef BEDROCK_TILED_BACKING_STORE |
770 // Change navigation also to the current page |
910 // Change navigation also to the current page |
771 m_touchNavigation->setPage(pg); |
911 m_touchNavigation->setPage(pg); |
772 m_touchNavigation->setWantSlideViewCalls(true); |
912 m_touchNavigation->setWantSlideViewCalls(true); |
|
913 #endif |
773 |
914 |
774 } |
915 } |
775 } |
916 } |
776 |
917 |
777 void GWebContentView::pageChanged(WRT::WrtBrowserContainer* oldPage, WRT::WrtBrowserContainer* newPage) { |
918 void GWebContentView::pageChanged(WRT::WrtBrowserContainer* oldPage, WRT::WrtBrowserContainer* newPage) { |
778 qDebug() << "GWebContentView::pageChanged"; |
|
779 Q_UNUSED(oldPage) |
919 Q_UNUSED(oldPage) |
780 updateWebPage(newPage); |
920 updateWebPage(newPage); |
781 |
921 |
|
922 #ifndef BEDROCK_TILED_BACKING_STORE |
782 // Set new page zoom info |
923 // Set new page zoom info |
783 changeContentViewZoomInfo(newPage); |
924 changeContentViewZoomInfo(newPage); |
784 } |
925 #endif |
785 |
926 } |
|
927 |
|
928 #ifdef BEDROCK_TILED_BACKING_STORE |
|
929 void GWebContentView::handleContextEventObject(QWebHitTestResult* eventTarget) |
|
930 { |
|
931 WebViewEventContext context(type(), *eventTarget); |
|
932 if (currentPageIsSuperPage()) { |
|
933 // Let the superpage handle the event. |
|
934 currentSuperPage()->onContextEvent(&context); |
|
935 } |
|
936 else { |
|
937 // Send the event directly. |
|
938 emit contextEvent(&context); |
|
939 } |
|
940 } |
|
941 void GWebContentView::handleViewScrolled(QPoint& scrollPos, QPoint& delta) |
|
942 { |
|
943 if (delta.manhattanLength() && scrollPos.y() <= 5 && !currentPageIsSuperPage()) |
|
944 m_chrome->layout()->slideView(-delta.y()); |
|
945 } |
|
946 |
|
947 #endif |
786 void GWebContentView::changeContentViewZoomInfo(WRT::WrtBrowserContainer* newPage){ |
948 void GWebContentView::changeContentViewZoomInfo(WRT::WrtBrowserContainer* newPage){ |
787 // Copy the new page zoom info into cv |
949 // Copy the new page zoom info into cv |
|
950 #ifndef BEDROCK_TILED_BACKING_STORE |
788 webWidget()->setPageZoomMetaData(newPage->pageZoomMetaData()); |
951 webWidget()->setPageZoomMetaData(newPage->pageZoomMetaData()); |
789 |
952 |
790 if (webWidget()->isUserScalable()) { |
953 if (webWidget()->isUserScalable()) { |
791 webWidget()->setZoomFactor(newPage->mainFrame()->zoomFactor()); |
954 webWidget()->setZoomFactor(newPage->mainFrame()->zoomFactor()); |
792 } |
955 } |