1 /* |
1 /* |
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
4 * |
9 * Initial Contributors: |
5 * This program is free software: you can redistribute it and/or modify |
10 * Nokia Corporation - initial contribution. |
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
11 * |
8 * |
12 * Contributors: |
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
13 * |
13 * |
14 * Description: |
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
15 * |
19 * |
16 */ |
20 */ |
17 |
|
18 |
21 |
19 #include "GWebContentView.h" |
22 #include "GWebContentView.h" |
20 #include "GWebContentViewWidget.h" |
23 #include "GWebContentViewWidget.h" |
21 #include "GWebContentViewJSObject.h" |
24 #include "GWebContentViewJSObject.h" |
|
25 #include "SuperPageView.h" |
22 #include "ChromeWidget.h" |
26 #include "ChromeWidget.h" |
23 #include "WebViewEventContext.h" |
27 #include "WebViewEventContext.h" |
24 #include "browserpagefactory.h" |
28 #include "browserpagefactory.h" |
25 #include "wrtbrowsercontainer.h" |
29 #include "wrtbrowsercontainer.h" |
|
30 |
|
31 #ifdef BEDROCK_TILED_BACKING_STORE |
|
32 #include "WebContentViewWidget.h" |
|
33 #endif |
|
34 |
26 #include "webpagecontroller.h" |
35 #include "webpagecontroller.h" |
|
36 #include "Utilities.h" |
|
37 #include "GSuperWebPage.h" |
27 #ifndef NO_QSTM_GESTURE |
38 #ifndef NO_QSTM_GESTURE |
28 #include "qstmgestureevent.h" |
39 #include "qstmgestureevent.h" |
29 #endif |
40 #endif |
30 |
41 |
31 #include <QGraphicsWebView> |
42 #include <QGraphicsWebView> |
32 #include <QWebHistory> |
43 #include <QWebHistory> |
33 #include <QWebPage> |
44 #include <QWebPage> |
34 #include <QWebFrame> |
45 #include <QWebFrame> |
35 #include <QTimeLine> |
46 #include <QTimeLine> |
36 #include <QDebug> |
47 #include <QDebug> |
37 |
48 #include <QtGui> |
38 |
|
39 #define safe_connect(src, srcSig, target, targetSlot) \ |
|
40 { int res = connect(src, srcSig, target, targetSlot); assert(res); } |
|
41 |
49 |
42 namespace GVA { |
50 namespace GVA { |
43 |
51 |
44 |
52 |
45 // ---------------------------------------------------------- |
53 // ---------------------------------------------------------- |
46 |
54 |
47 const qreal KZoomInStep = 1.05; |
55 const qreal KZoomInStep = 1.05; |
48 const qreal KZoomOutStep = 0.95238; |
56 const qreal KZoomOutStep = 0.95238; |
49 |
57 |
50 GWebContentView::GWebContentView(ChromeWidget *chrome, QObject * parent, const QString &objectName) |
58 GWebContentView::GWebContentView(ChromeWidget *chrome, QObject * parent, const QString &objectName) |
51 : ControllableViewBase(parent), |
59 : ControllableViewBase(parent), |
52 m_networkMgr(0), |
60 m_networkMgr(0), |
53 m_chrome(chrome), |
61 m_chrome(chrome), |
54 m_timeLine(0), |
62 m_timeLine(0), |
55 m_zoomIn(false), |
63 m_zoomIn(false), |
56 m_backEnabled(false), |
64 m_backEnabled(false), |
57 m_forwardEnabled(false), |
65 m_forwardEnabled(false), |
|
66 m_sharedPage(0), |
58 m_currentSuperPage(m_superPages.begin()), |
67 m_currentSuperPage(m_superPages.begin()), |
59 m_currentPageIsSuperPage(false), |
68 m_currentPageIsSuperPage(false), |
60 m_timer(NULL) |
69 m_timer(NULL), |
|
70 m_enabled(true) |
61 { |
71 { |
62 setObjectName(objectName); |
72 setObjectName(objectName); |
63 qDebug() << "GWebContentView::GWebContentView: this=" << this; |
73 WRT::WrtBrowserContainer* page = BrowserPageFactory::openBrowserPage(); |
64 QWebPage* page = BrowserPageFactory::openBrowserPage(); |
74 |
65 |
75 setActions(); |
66 setZoomActions(); |
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 |
67 m_widget = new GWebContentViewWidget(parent, this, page); |
84 m_widget = new GWebContentViewWidget(parent, this, page); |
|
85 #endif |
|
86 |
68 #ifndef __gva_no_chrome__ |
87 #ifndef __gva_no_chrome__ |
69 m_jsObject = new GWebContentViewJSObject(this, m_chrome->page()->mainFrame(), objectName); |
88 setJSObject(objectName); |
70 #endif |
89 #endif |
71 m_networkMgr = webWidget()->page()->networkAccessManager(); |
90 m_networkMgr = webWidget()->page()->networkAccessManager(); |
72 |
91 |
73 webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); |
92 webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); |
74 webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); |
93 webWidget()->page()->currentFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); |
75 |
94 |
|
95 #ifndef BEDROCK_TILED_BACKING_STORE |
76 #ifdef NO_QSTM_GESTURE |
96 #ifdef NO_QSTM_GESTURE |
77 m_touchNavigation = new GWebTouchNavigation(page, m_widget); |
97 m_touchNavigation = new GContentViewTouchNavigation(page, m_widget); |
78 m_touchNavigation->setChromeWidget(m_chrome); |
98 m_touchNavigation->setChromeWidget(m_chrome); |
79 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 |
80 #endif |
105 #endif |
81 WRT::WrtBrowserContainer * wrtPage = static_cast<WRT::WrtBrowserContainer *>(page); |
106 WRT::WrtBrowserContainer * wrtPage = static_cast<WRT::WrtBrowserContainer *>(page); |
82 if(wrtPage) { |
107 if (wrtPage) { |
83 wrtPage->setWebWidget(webWidget()); |
108 wrtPage->setWebWidget(webWidget()); |
84 pageCreated(wrtPage); |
109 pageCreated(wrtPage); |
85 } |
110 } |
86 |
111 |
87 connectAll(); |
112 connectAll(); |
88 } |
113 } |
89 |
114 |
90 GWebContentView::~GWebContentView() { |
115 GWebContentView::~GWebContentView() { |
91 disconnect(m_jsObject); |
116 disconnect(m_jsObject); |
92 disconnect(webWidget()); |
117 disconnect(webWidget()); |
|
118 #ifndef BEDROCK_TILED_BACKING_STORE |
93 delete m_touchNavigation; |
119 delete m_touchNavigation; |
94 delete m_actionZoomIn; |
120 #endif |
95 delete m_actionZoomOut; |
121 foreach(QAction * action, m_actions) { |
|
122 delete action; |
|
123 } |
|
124 |
96 delete m_widget; |
125 delete m_widget; |
97 foreach(GWebPage *page, m_superPages) { |
126 foreach(GSuperWebPage *page, m_superPages) { |
98 delete page; |
127 delete page; |
99 } |
128 } |
100 } |
129 } |
101 |
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 |
102 void GWebContentView::bitmapZoomStop() |
148 void GWebContentView::bitmapZoomStop() |
103 { |
149 { |
104 if (m_timer) { |
150 if (m_timer) { |
105 m_timer->stop(); |
151 m_timer->stop(); |
106 disconnect(m_timer,SIGNAL(timeout())); |
152 disconnect(m_timer,SIGNAL(timeout())); |
107 delete m_timer; |
153 delete m_timer; |
108 m_timer = NULL; |
154 m_timer = NULL; |
109 } |
155 } |
110 qreal zoomFactor = m_value * webWidget()->zoomFactor(); |
156 qreal zoomFactor = m_value * webWidget()->zoomFactor(); |
111 ((zoomFactor+0.001) >= webWidget()->maximumScale() )? webWidget()->setZoomFactor(webWidget()->maximumScale()):webWidget()->setZoomFactor(zoomFactor); |
157 ((zoomFactor+0.001) >= webWidget()->maximumScale() )? webWidget()->setZoomFactor(webWidget()->maximumScale()):webWidget()->setZoomFactor(zoomFactor); |
112 webWidget()->bitmapZoomCleanup(); |
158 webWidget()->bitmapZoomCleanup(); |
113 } |
159 } |
129 |
175 |
130 void GWebContentView::zoomN() |
176 void GWebContentView::zoomN() |
131 { |
177 { |
132 if ((m_value * webWidget()->zoomFactor()) < webWidget()->minimumScale()){ |
178 if ((m_value * webWidget()->zoomFactor()) < webWidget()->minimumScale()){ |
133 if (m_timer && m_timer->isActive()) |
179 if (m_timer && m_timer->isActive()) |
134 bitmapZoomStop(); |
180 bitmapZoomStop(); |
135 }else { |
181 }else { |
136 if (m_timer->isSingleShot()) { |
182 if (m_timer->isSingleShot()) { |
137 m_timer->setSingleShot(false); |
183 m_timer->setSingleShot(false); |
138 m_timer->start(1); |
184 m_timer->start(1); |
139 } |
185 } |
140 webWidget()->setBitmapZoom(m_value * webWidget()->zoomFactor()); |
186 webWidget()->setBitmapZoom(m_value * webWidget()->zoomFactor()); |
141 m_value *= KZoomOutStep; |
187 m_value *= KZoomOutStep; |
142 } |
188 } |
143 } |
189 } |
144 |
190 |
145 void GWebContentView::zoomIn(qreal deltaPercent) |
191 void GWebContentView::zoomIn(qreal deltaPercent) |
146 { |
192 { |
147 Q_UNUSED(deltaPercent) |
193 Q_UNUSED(deltaPercent) |
148 if (webWidget() && webWidget()->isUserScalable()) { |
194 if (webWidget() && webWidget()->isUserScalable()) { |
149 if (m_timer && m_timer->isActive()) { |
195 if (m_timer && m_timer->isActive()) { |
150 if (!m_timer->isSingleShot()) |
196 if (!m_timer->isSingleShot()) |
151 m_value /= KZoomInStep; |
197 m_value /= KZoomInStep; |
152 bitmapZoomStop(); |
198 bitmapZoomStop(); |
153 return; |
199 return; |
154 }else if (!m_timer) |
200 }else if (!m_timer) |
155 m_timer = new QTimer(this); |
201 m_timer = new QTimer(this); |
156 |
202 |
157 m_value = KZoomInStep; |
203 m_value = KZoomInStep; |
158 |
204 |
159 if ((m_value * webWidget()->zoomFactor()) < webWidget()->maximumScale()) { |
205 if ((m_value * webWidget()->zoomFactor()) < webWidget()->maximumScale()) { |
160 webWidget()->createPageSnapShot(); |
206 webWidget()->createPageSnapShot(); |
161 connect(m_timer,SIGNAL(timeout()),this,SLOT(zoomP())); |
207 connect(m_timer,SIGNAL(timeout()),this,SLOT(zoomP())); |
162 zoomP(); |
208 zoomP(); |
163 m_timer->setSingleShot(true); |
209 m_timer->setSingleShot(true); |
196 webWidget()->setZoomFactor(m_value * webWidget()->zoomFactor()); |
242 webWidget()->setZoomFactor(m_value * webWidget()->zoomFactor()); |
197 } |
243 } |
198 } |
244 } |
199 } |
245 } |
200 |
246 |
|
247 #endif |
201 void GWebContentView::connectAll() { |
248 void GWebContentView::connectAll() { |
202 //qDebug() << "GWebContentView::connectAll: " << widget(); |
249 //qDebug() << "GWebContentView::connectAll: " << widget(); |
203 |
250 |
204 #ifndef __gva_no_chrome__ |
251 #ifndef __gva_no_chrome__ |
|
252 #ifndef BEDROCK_TILED_BACKING_STORE |
205 safe_connect(widget(), SIGNAL(contextEvent(::WebViewEventContext *)), |
253 safe_connect(widget(), SIGNAL(contextEvent(::WebViewEventContext *)), |
206 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 |
207 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 &))); |
208 QObject::connect(webWidget(), SIGNAL(loadStarted()), m_jsObject, SIGNAL(loadStarted())); |
272 QObject::connect(webWidget(), SIGNAL(loadStarted()), m_jsObject, SIGNAL(loadStarted())); |
209 QObject::connect(webWidget(), SIGNAL(loadProgress(int)), m_jsObject, SIGNAL(loadProgress(int))); |
273 QObject::connect(webWidget(), SIGNAL(loadProgress(int)), m_jsObject, SIGNAL(loadProgress(int))); |
|
274 QObject::connect(webWidget(), SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); |
210 #endif |
275 #endif |
211 QObject::connect(webWidget(), SIGNAL(loadStarted()), this, SLOT(onLoadStarted())); |
276 QObject::connect(webWidget(), SIGNAL(loadStarted()), this, SLOT(onLoadStarted())); |
212 QObject::connect(webWidget(), SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool))); |
277 QObject::connect(webWidget(), SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool))); |
213 QObject::connect(webWidget(), SIGNAL(urlChanged(const QUrl&)), this, SLOT(onUrlChanged(const QUrl&))); |
278 QObject::connect(webWidget(), SIGNAL(urlChanged(const QUrl&)), this, SLOT(onUrlChanged(const QUrl&))); |
214 #ifndef __gva_no_chrome__ |
279 #ifndef __gva_no_chrome__ |
215 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&))); |
216 QObject::connect(this, SIGNAL(backEnabled(bool)), m_jsObject, SIGNAL(backEnabled(bool))); |
281 QObject::connect(this, SIGNAL(backEnabled(bool)), m_jsObject, SIGNAL(backEnabled(bool))); |
217 QObject::connect(this, SIGNAL(forwardEnabled(bool)), m_jsObject, SIGNAL(forwardEnabled(bool))); |
282 QObject::connect(this, SIGNAL(forwardEnabled(bool)), m_jsObject, SIGNAL(forwardEnabled(bool))); |
218 QObject::connect(this, SIGNAL(loadFinished(bool)), m_jsObject, SIGNAL(loadFinished(bool))); |
283 QObject::connect(this, SIGNAL(loadFinished(bool)), m_jsObject, SIGNAL(loadFinished(bool))); |
219 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 |
220 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 |
221 #endif |
290 #endif |
222 connect(WebPageController::getSingleton(), SIGNAL(pageCreated(WRT::WrtBrowserContainer*)), |
291 connect(WebPageController::getSingleton(), SIGNAL(pageCreated(WRT::WrtBrowserContainer*)), |
223 this, SLOT(pageCreated(WRT::WrtBrowserContainer*))); |
292 this, SLOT(pageCreated(WRT::WrtBrowserContainer*))); |
224 connect(WebPageController::getSingleton(), SIGNAL(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*)), |
293 connect(WebPageController::getSingleton(), SIGNAL(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*)), |
225 this, SLOT(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*))); |
294 this, SLOT(pageChanged(WRT::WrtBrowserContainer*, WRT::WrtBrowserContainer*))); |
|
295 connect(WebPageController::getSingleton(), SIGNAL(showMessageBox(WRT::MessageBoxProxy*)), |
|
296 this, SLOT(showMessageBox(WRT::MessageBoxProxy*))); |
226 } |
297 } |
227 |
298 |
228 QVariant GWebContentView::getContentWindowObject() { |
299 QVariant GWebContentView::getContentWindowObject() { |
229 try { |
300 try { |
230 return webWidget()->page()->mainFrame()->evaluateJavaScript("window"); |
301 return webWidget()->page()->mainFrame()->evaluateJavaScript("window"); |
237 |
308 |
238 QGraphicsWidget* GWebContentView::widget() const { |
309 QGraphicsWidget* GWebContentView::widget() const { |
239 return static_cast<QGraphicsWidget*>(m_widget); |
310 return static_cast<QGraphicsWidget*>(m_widget); |
240 } |
311 } |
241 |
312 |
|
313 #ifdef BEDROCK_TILED_BACKING_STORE |
|
314 QGraphicsWebView* GWebContentView::webWidget() const { |
|
315 return m_widget->webView(); |
|
316 } |
|
317 #else |
242 GWebContentViewWidget *GWebContentView::webWidget() const { |
318 GWebContentViewWidget *GWebContentView::webWidget() const { |
243 return m_widget; |
319 return m_widget; |
244 } |
320 } |
|
321 #endif |
245 |
322 |
246 QString GWebContentView::title() const { |
323 QString GWebContentView::title() const { |
247 return webWidget()->title(); |
324 return webWidget()->title(); |
248 } |
325 } |
249 |
326 |
250 QUrl GWebContentView::url() { |
327 QUrl GWebContentView::url() { |
251 return webWidget()->url(); |
328 return webWidget()->url(); |
252 } |
329 } |
253 |
330 |
254 QWebPage* GWebContentView::wrtPage() { |
331 QWebPage* GWebContentView::wrtPage() { |
|
332 #ifdef BEDROCK_TILED_BACKING_STORE |
|
333 return m_widget->page(); |
|
334 #else |
255 return m_widget->wrtPage(); |
335 return m_widget->wrtPage(); |
256 } |
336 #endif |
257 |
337 } |
258 void GWebContentView::setZoomActions(){ |
338 |
259 |
339 void GWebContentView::setActions(){ |
260 // Create zoomIn and zoomOut actions */ |
340 |
261 m_actionZoomIn = new QAction("zoomIn", this); |
341 QAction* action; |
262 m_actionZoomIn->setObjectName("zoomIn"); |
342 action = m_actions["zoomIn"] = new QAction("zoomIn", this); |
263 |
343 action->setObjectName("zoomIn"); |
264 m_actionZoomOut = new QAction("zoomOut", this); |
344 connect(action, SIGNAL(triggered()), this, SLOT(zoomIn())); |
265 m_actionZoomOut->setObjectName("zoomOut"); |
345 |
|
346 action = m_actions["zoomOut"] = new QAction("zoomOut", this); |
|
347 action->setObjectName("zoomOut"); |
266 /* Disable zoomOut action initially as we are the the minimum scale */ |
348 /* Disable zoomOut action initially as we are the the minimum scale */ |
267 /* Revisit this to determine whether we can use the change signal to |
349 /* Revisit this to determine whether we can use the change signal to |
268 * set the zoomOut button image initially as well |
350 * set the zoomOut button image initially as well |
269 */ |
351 */ |
270 m_actionZoomOut->setEnabled(false); |
352 action->setEnabled(false); |
271 |
353 connect(action, SIGNAL(triggered()), this, SLOT(zoomOut())); |
272 connect(m_actionZoomIn, SIGNAL(triggered()), this, SLOT(zoomIn())); |
354 |
273 connect(m_actionZoomOut, SIGNAL(triggered()), this, SLOT(zoomOut())); |
355 action = m_actions["zoom"] = new QAction("zoom", this); |
|
356 action->setObjectName("zoom"); |
|
357 |
|
358 |
|
359 action = m_actions["winview"]= new QAction("winview", this); |
|
360 action->setObjectName("winview"); |
|
361 |
|
362 |
|
363 action = m_actions["menu"] = new QAction("menu", this); |
|
364 action->setObjectName("menu"); |
|
365 |
|
366 action = m_actions["mostvisited"] = new QAction("mostvisited", this); |
|
367 action->setObjectName("mostvisited"); |
|
368 |
|
369 action = m_actions["toggletb"] = new QAction("toggletb", this); |
|
370 action->setObjectName("toggletb"); |
|
371 |
274 } |
372 } |
275 |
373 |
276 void GWebContentView::triggerAction(const QString & action) |
374 void GWebContentView::triggerAction(const QString & action) |
277 { |
375 { |
278 qDebug() << "GWebContentView::triggerAction: " << action; |
|
279 QWebPage::WebAction webAction; |
376 QWebPage::WebAction webAction; |
280 if(action=="Stop") |
377 if (action=="Stop") |
281 webAction = QWebPage::Stop; |
378 webAction = QWebPage::Stop; |
282 else if (action=="Back") |
379 else if (action=="Back") |
283 webAction = QWebPage::Back; |
380 webAction = QWebPage::Back; |
284 else if(action=="Reload") |
381 else if (action=="Reload") |
285 webAction = QWebPage::Reload; |
382 webAction = QWebPage::Reload; |
286 else if (action=="Forward") |
383 else if (action=="Forward") |
287 webAction = QWebPage::Forward; |
384 webAction = QWebPage::Forward; |
288 else |
385 else |
289 return; |
386 return; |
290 webWidget()->triggerPageAction(webAction); |
387 webWidget()->triggerPageAction(webAction); |
291 } |
388 } |
292 |
389 |
293 void GWebContentView::deactivateZoomActions() |
390 void GWebContentView::deactivateZoomActions() |
294 { |
391 { |
295 m_actionZoomOut->setEnabled(false); |
392 m_actions.value("zoomIn")->setEnabled(false); |
296 m_actionZoomIn->setEnabled(false); |
393 m_actions.value("zoomOut")->setEnabled(false); |
297 } |
394 } |
298 |
395 |
299 void GWebContentView::changeZoomAction(qreal zoom){ |
396 void GWebContentView::changeZoomAction(qreal zoom){ |
300 if(!webWidget()) return; |
397 #ifndef BEDROCK_TILED_BACKING_STORE |
301 if(!(webWidget()->isUserScalable() ) ){ |
398 if (!webWidget()) return; |
|
399 if (!(webWidget()->isUserScalable() ) ){ |
302 deactivateZoomActions(); |
400 deactivateZoomActions(); |
303 } |
401 } |
304 else { |
402 else { |
|
403 QAction * zoomOutAction = m_actions.value("zoomOut"); |
|
404 QAction * zoomInAction = m_actions.value("zoomIn"); |
305 if (zoom <= webWidget()->minimumScale() ) { |
405 if (zoom <= webWidget()->minimumScale() ) { |
306 m_actionZoomOut->setEnabled(false); |
406 zoomOutAction->setEnabled(false); |
307 } |
407 } |
308 else { |
408 else { |
309 m_actionZoomOut->setEnabled(true); |
409 zoomOutAction->setEnabled(true); |
310 } |
410 } |
311 |
411 |
312 if (zoom >= webWidget()->maximumScale() ){ |
412 if (zoom >= webWidget()->maximumScale() ){ |
313 m_actionZoomIn->setEnabled(false); |
413 zoomInAction->setEnabled(false); |
314 } |
414 } |
315 else { |
415 else { |
316 m_actionZoomIn->setEnabled(true); |
416 zoomInAction->setEnabled(true); |
317 } |
417 } |
318 } |
418 } |
|
419 #endif |
319 } |
420 } |
320 |
421 |
321 void GWebContentView::setZoomFactor(qreal factor){ |
422 void GWebContentView::setZoomFactor(qreal factor){ |
322 if(webWidget()) |
423 if (webWidget()) |
|
424 #ifdef BEDROCK_TILED_BACKING_STORE |
|
425 webWidget()->setScale(factor); |
|
426 #else |
323 webWidget()->setZoomFactor(factor); |
427 webWidget()->setZoomFactor(factor); |
324 } |
428 #endif |
325 |
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 |
326 qreal GWebContentView::getZoomFactor() const { |
446 qreal GWebContentView::getZoomFactor() const { |
327 return webWidgetConst() ? webWidgetConst()->zoomFactor() : 0.0; |
447 return webWidgetConst() ? webWidgetConst()->zoomFactor() : 0.0; |
328 } |
448 } |
329 |
449 #endif |
330 void GWebContentView::activate() { |
450 |
331 qDebug() << "GWebContentView::activate"; |
451 void GWebContentView::activate() { |
332 ControllableViewBase::activate(); |
452 #ifdef BEDROCK_TILED_BACKING_STORE |
|
453 WRT::WrtBrowserContainer* newPage = WebPageController::getSingleton()->currentPage(); |
|
454 changeContentViewZoomInfo(newPage); |
|
455 #endif |
|
456 ControllableViewBase::activate(); |
333 } |
457 } |
334 |
458 |
335 void GWebContentView::deactivate() { |
459 void GWebContentView::deactivate() { |
336 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 |
337 ControllableViewBase::deactivate(); |
466 ControllableViewBase::deactivate(); |
338 } |
467 } |
339 |
468 |
340 // 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) { |
341 // QAction *action = page->action(webAction); |
470 // QAction *action = page->action(webAction); |
342 // if(action) { |
471 // if (action) { |
343 // action->setObjectName(name); |
472 // action->setObjectName(name); |
344 // list.append(action); |
473 // list.append(action); |
345 // } |
474 // } |
346 // } |
475 // } |
347 |
476 |
353 { |
482 { |
354 // Get some of the actions from the page (there are many more available) and build a list |
483 // Get some of the actions from the page (there are many more available) and build a list |
355 // list of them. |
484 // list of them. |
356 |
485 |
357 QList<QAction*> actions; |
486 QList<QAction*> actions; |
|
487 QAction * action = m_actions.value("zoomIn"); |
|
488 |
358 |
489 |
359 /* Add zoomIn and zoomOut actions created earlier*/ |
490 /* Add zoomIn and zoomOut actions created earlier*/ |
360 if(m_actionZoomIn) actions.append(m_actionZoomIn); |
491 if (action) actions.append(action); |
361 if(m_actionZoomOut) actions.append(m_actionZoomOut); |
492 |
|
493 action = m_actions.value("zoomOut"); |
|
494 if (action) actions.append(action); |
362 |
495 |
363 return actions; |
496 return actions; |
364 } |
497 } |
365 |
498 |
366 |
499 |
367 QAction * GWebContentView::getAction(const QString & action) |
500 QAction * GWebContentView::getAction(const QString & action) |
368 { |
501 { |
369 if(action == "zoomIn") |
502 QAction * act = NULL; |
370 return m_actionZoomIn; |
503 if (m_actions.contains(action) ) |
371 if(action == "zoomOut") |
504 act = m_actions.value(action); |
372 return m_actionZoomOut; |
505 |
373 QWebPage::WebAction webAction; |
506 if (!act ) { |
374 if(action == "Back") |
507 WebPageController * pageController = WebPageController::getSingleton(); |
375 webAction = QWebPage::Back; |
508 if (action == "Back") |
376 else if(action == "Forward") |
509 act = pageController->getActionBack(); |
377 webAction = QWebPage::Forward; |
510 else if (action == "Forward") |
378 else if(action == "Stop") |
511 act = pageController->getActionForward(); |
379 webAction = QWebPage::Stop; |
512 else if (action == "Stop") |
380 else if(action == "Reload") |
513 act = pageController->getActionStop(); |
381 webAction = QWebPage::Reload; |
514 else if (action == "Reload") |
382 else return 0; |
515 act = pageController->getActionReload(); |
383 return webWidget()->pageAction(webAction); |
516 |
|
517 } |
|
518 return act; |
384 } |
519 } |
385 |
520 |
386 void GWebContentView::scrollViewBy(int dx, int dy) |
521 void GWebContentView::scrollViewBy(int dx, int dy) |
387 { |
522 { |
388 wrtPage()->mainFrame()->scroll(dx, dy); |
523 wrtPage()->mainFrame()->scroll(dx, dy); |
488 m_timeLine->stop(); |
622 m_timeLine->stop(); |
489 } |
623 } |
490 |
624 |
491 void GWebContentView::updateZoom(qreal delta){ |
625 void GWebContentView::updateZoom(qreal delta){ |
492 Q_UNUSED(delta) |
626 Q_UNUSED(delta) |
493 if(m_zoomIn) |
627 #ifndef BEDROCK_TILED_BACKING_STORE |
|
628 if (m_zoomIn) |
494 zoomBy(0.1); |
629 zoomBy(0.1); |
495 else |
630 else |
496 zoomBy(-0.1); |
631 zoomBy(-0.1); |
|
632 #endif |
497 } |
633 } |
498 |
634 |
499 void GWebContentView::onUrlChanged(const QUrl& url) |
635 void GWebContentView::onUrlChanged(const QUrl& url) |
500 { |
636 { |
501 emit urlChanged(url.toString()); |
637 emit urlChanged(url.toString()); |
502 //NB: Brief hack |
638 //NB: Brief hack |
503 if(url.scheme()=="https") |
639 if (url.scheme()=="https") |
504 emit secureConnection(true); |
640 emit secureConnection(true); |
505 else |
641 else |
506 emit secureConnection(false); |
642 emit secureConnection(false); |
507 } |
643 } |
508 |
644 |
509 GWebPage *GWebContentView::createSuperPage(const QString &name) { |
645 GSuperWebPage *GWebContentView::createSuperPage(const QString &name, bool persist) { |
510 qDebug() << "GWebContentView::createSuperPage: " << name; |
646 GSuperWebPage *page = 0; |
511 GWebPage *page = 0; |
|
512 PageMap::iterator it = m_superPages.find(name); |
647 PageMap::iterator it = m_superPages.find(name); |
513 if(it == m_superPages.end()) { |
648 // If page doesn't exist create a new one. |
514 // Doesn't exist. Create a new one. |
649 if (it == m_superPages.end()) { |
515 page = new GSuperWebPage(0, chrome()); |
650 |
|
651 if (persist || !m_sharedPage){ |
|
652 if (persist) |
|
653 //Implicitly creates a new QWebPage that is owned by the superpage object |
|
654 page = new GSuperWebPage(0, chrome()); |
|
655 |
|
656 else { |
|
657 //Create a shared QWebPage that is owned by this view |
|
658 m_sharedPage = new WebPageWrapper(this, "Superpage javascript error"); |
|
659 page = new GSuperWebPage(m_sharedPage, chrome()); |
|
660 } |
|
661 //No scroll bars |
|
662 page->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); |
|
663 page->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); |
|
664 //No history for super pages |
|
665 page->page()->history()->setMaximumItemCount(0); |
|
666 //Limit page cache usage by super pages |
|
667 |
|
668 //NB: needed? |
|
669 QPalette viewPalette = widget()->palette(); |
|
670 viewPalette.setBrush(QPalette::Base, Qt::white); |
|
671 page->page()->setPalette(viewPalette); |
|
672 } else { |
|
673 //Reuse the shared QWebPage |
|
674 page = new GSuperWebPage(m_sharedPage, chrome()); |
|
675 } |
|
676 //Export the superpage to JS |
516 page->setParent(jsObject()); |
677 page->setParent(jsObject()); |
517 page->setObjectName(name); |
678 page->setObjectName(name); |
518 |
|
519 // Add it to the superpage list. |
679 // Add it to the superpage list. |
520 m_superPages[name] = page; |
680 m_superPages[name] = page; |
521 if(m_superPages.count() == 1) { |
681 if (m_superPages.count() == 1) { |
522 // This is the only superpage, make it current. |
682 // This is the only superpage, make it current. |
523 m_currentSuperPage = m_superPages.find(name); |
683 m_currentSuperPage = m_superPages.find(name); |
524 } |
684 } |
525 |
|
526 //NB: Here's how to set default webview backgound color |
|
527 page->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); |
|
528 page->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); |
|
529 QPalette viewPalette = widget()->palette(); |
|
530 viewPalette.setBrush(QPalette::Base, Qt::white); |
|
531 //viewPalette.setColor(QPalette::Window, Qt::transparent); |
|
532 page->page()->setPalette(viewPalette); |
|
533 //m_view->setPalette(viewPalette); |
|
534 } |
685 } |
535 else { |
686 else { |
536 qDebug() << "GWebContentView::createPage: page already exists: " << name; |
687 qDebug() << "GWebContentView::createPage: page already exists: " << name; |
537 } |
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)); |
538 return page; |
691 return page; |
539 } |
692 } |
540 |
693 |
541 void GWebContentView::destroySuperPage(const QString &name) { |
694 void GWebContentView::destroySuperPage(const QString &name) { |
542 qDebug() << "GWebContentView::destroySuperPage: " << name; |
695 if (!m_superPages.contains(name)) return; |
543 if(!m_superPages.contains(name)) return; |
696 |
544 |
697 GSuperWebPage *page = m_superPages.take(name); |
545 GWebPage *page = m_superPages.take(name); |
698 //This will destroy any QWebPage owned by the super page. The shared page is not |
546 if(page) { |
699 //owned by the super page and will be deleted when the GWebContentView is deleted. |
547 delete page; |
700 if (page){ |
548 } |
701 delete page; |
549 } |
702 } |
550 |
703 } |
551 void GWebContentView::setCurrentSuperPage(const QString &name) { |
704 |
|
705 bool GWebContentView::setCurrentSuperPage(const QString &name) { |
552 PageMap::iterator it = m_superPages.find(name); |
706 PageMap::iterator it = m_superPages.find(name); |
553 if(it != m_superPages.end()) { |
707 if (it != m_superPages.end()) { |
554 m_currentSuperPage = it; |
708 m_currentSuperPage = it; |
|
709 return true; |
555 } |
710 } |
556 else { |
711 else { |
557 qDebug() << "GWebContentView::setCurrentSuperPage: not found: " << name; |
712 qDebug() << "GWebContentView::setCurrentSuperPage: not found: " << name; |
558 } |
713 return false; |
559 } |
714 } |
560 |
715 } |
|
716 |
561 bool GWebContentView::isSuperPage(const QString &name){ |
717 bool GWebContentView::isSuperPage(const QString &name){ |
562 PageMap::iterator it = m_superPages.find(name); |
718 PageMap::iterator it = m_superPages.find(name); |
563 if(it != m_superPages.end()) { |
719 if (it != m_superPages.end()) { |
564 return true; |
720 return true; |
565 } |
721 } |
566 qDebug() << "GWebContentView::superPage: not found: " << name; |
722 qDebug() << "GWebContentView::superPage: not found: " << name; |
567 return false; |
723 return false; |
568 } |
724 } |
569 |
725 |
570 |
726 |
571 GWebPage * GWebContentView::superPage(const QString &name) { |
727 GSuperWebPage * GWebContentView::superPage(const QString &name) { |
572 PageMap::iterator it = m_superPages.find(name); |
728 PageMap::iterator it = m_superPages.find(name); |
573 if(it != m_superPages.end()) { |
729 if (it != m_superPages.end()) { |
574 return it.value(); |
730 return it.value(); |
575 } |
731 } |
576 qDebug() << "GWebContentView::superPage: not found: " << name; |
732 qDebug() << "GWebContentView::superPage: not found: " << name; |
577 return 0; |
733 return 0; |
578 } |
734 } |
579 |
735 |
580 void GWebContentView::showSuperPage(const QString &name) { |
736 void GWebContentView::showSuperPage(const QString &name) { |
581 setCurrentSuperPage(name); |
737 if(isSuperPage(name)) { |
582 qDebug() << "GWebContentView::showSuperPage: " << currentSuperPage(); |
738 if(currentPageIsSuperPage()) { |
583 m_currentPageIsSuperPage = true; |
739 currentSuperPage()->onHidden(); |
584 webWidget()->setPage(currentSuperPage()->page()); |
740 } |
585 m_touchNavigation->setPage(webWidget()->page()); |
741 |
586 webWidget()->page()->setPreferredContentsSize(webWidget()->size().toSize()); |
742 setCurrentSuperPage(name); |
|
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 } |
587 } |
761 } |
588 |
762 |
589 void GWebContentView::showNormalPage() { |
763 void GWebContentView::showNormalPage() { |
590 if(webWidget()) { |
764 if (webWidget()) { |
|
765 #ifndef BEDROCK_TILED_BACKING_STORE |
591 webWidget()->showNormalPage(); |
766 webWidget()->showNormalPage(); |
592 webWidget()->setViewportSize(); |
767 webWidget()->setViewportSize(); |
593 m_touchNavigation->setPage(currentPage()); |
768 m_touchNavigation->setPage(currentPage()); |
594 m_currentPageIsSuperPage =false; |
769 m_touchNavigation->setWantSlideViewCalls(true); |
595 } |
770 #else |
596 } |
771 m_widget->showPage(false); |
597 |
772 #endif |
|
773 //TODO: Further testing is needed to show if the following is a net benefit. |
|
774 if (currentPageIsSuperPage()) { |
|
775 if(currentSuperPage()->page() == m_sharedPage){ |
|
776 //Clear contents of shared page to free resources. This should save |
|
777 //memory for big pages, but at the performance cost of loading an empty page. |
|
778 //An alternative is to delete the shared page every time and reallocate it when |
|
779 //a super page is loaded. |
|
780 currentSuperPage()->page()->mainFrame()->setHtml(QString()); |
|
781 } |
|
782 |
|
783 currentSuperPage()->onHidden(); |
|
784 m_currentPageIsSuperPage =false; |
|
785 } |
|
786 } |
|
787 } |
|
788 |
598 QObjectList GWebContentView::getSuperPages() { |
789 QObjectList GWebContentView::getSuperPages() { |
599 QObjectList *result = new QObjectList; |
790 QObjectList *result = new QObjectList; |
600 foreach(GVA::GWebPage *page, m_superPages) { |
791 foreach(GVA::GSuperWebPage *page, m_superPages) { |
601 result->append(page); |
792 result->append(page); |
602 } |
793 } |
603 // 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. |
604 return *result; |
795 return *result; |
605 } |
796 } |
610 } |
801 } |
611 |
802 |
612 void GWebContentView::onLoadStarted() |
803 void GWebContentView::onLoadStarted() |
613 { |
804 { |
614 //qDebug() << "GWebContentView::onLoadStarted: " << QTime::currentTime(); |
805 //qDebug() << "GWebContentView::onLoadStarted: " << QTime::currentTime(); |
615 #if defined(__gva_no_chrome__) || defined(NO_RESIZE_ON_LOAD) |
806 #if defined(__gva_no_chrome__) || defined(NO_RESIZE_ON_LOAD) |
616 m_widget->onLoadStarted(); |
807 m_widget->onLoadStarted(); |
617 #endif |
808 #endif |
618 emit loadStarted(); |
809 emit loadStarted(); |
619 } |
810 } |
620 |
811 |
621 void GWebContentView::onLoadFinished(bool ok) |
812 void GWebContentView::onLoadFinished(bool ok) |
622 { |
813 { |
623 //qDebug() << "GWebContentView::onLoadFinished: " << QTime::currentTime(); |
814 //qDebug() << "GWebContentView::onLoadFinished: " << QTime::currentTime(); |
624 emit loadFinished(ok); |
815 emit loadFinished(ok); |
625 //NB: page manager functions really |
816 //NB: page manager functions really |
626 if(!m_backEnabled && currentPage()->history()->canGoBack()){ |
817 if (!m_backEnabled && currentPage()->history()->canGoBack()){ |
627 m_backEnabled = true; |
818 m_backEnabled = true; |
628 emit backEnabled(true); |
819 emit backEnabled(true); |
629 } |
820 } |
630 else if (m_backEnabled && !currentPage()->history()->canGoBack()){ |
821 else if (m_backEnabled && !currentPage()->history()->canGoBack()){ |
631 m_backEnabled = false; |
822 m_backEnabled = false; |
632 emit backEnabled(false); |
823 emit backEnabled(false); |
633 } |
824 } |
634 if(!m_forwardEnabled && currentPage()->history()->canGoForward()){ |
825 if (!m_forwardEnabled && currentPage()->history()->canGoForward()){ |
635 m_forwardEnabled = true; |
826 m_forwardEnabled = true; |
636 emit forwardEnabled(true); |
827 emit forwardEnabled(true); |
637 } |
828 } |
638 else if (m_forwardEnabled && !currentPage()->history()->canGoForward()){ |
829 else if (m_forwardEnabled && !currentPage()->history()->canGoForward()){ |
639 m_forwardEnabled = false; |
830 m_forwardEnabled = false; |
640 emit forwardEnabled(false); |
831 emit forwardEnabled(false); |
641 } |
832 } |
642 |
833 |
643 // Set focus to the Web View so that text boxes have the focus (BR-994) |
834 // Set focus to the Web View so that text boxes have the focus (BR-994) |
644 m_widget->setFocus(); |
835 m_widget->setFocus(); |
645 |
836 |
646 #if defined(__gva_no_chrome__) || defined(NO_RESIZE_ON_LOAD) |
837 #if defined(__gva_no_chrome__) || defined(NO_RESIZE_ON_LOAD) |
647 m_widget->onLoadFinished(); |
838 m_widget->onLoadFinished(); |
668 // } |
859 // } |
669 |
860 |
670 |
861 |
671 void GWebContentView::pageCreated(WRT::WrtBrowserContainer* newPage) { |
862 void GWebContentView::pageCreated(WRT::WrtBrowserContainer* newPage) { |
672 |
863 |
673 qDebug() << "GWebContentView::pageCreated"; |
|
674 /* save the page snapshot before changing the current page to the new page*/ |
864 /* save the page snapshot before changing the current page to the new page*/ |
675 WRT::WrtBrowserContainer * currPage = WebPageController::getSingleton()->currentPage(); |
865 WRT::WrtBrowserContainer * currPage = WebPageController::getSingleton()->currentPage(); |
676 if(currPage) { |
866 if (currPage) { |
677 QWebHistoryItem item = currPage->history()->currentItem(); |
867 QWebHistoryItem item = currPage->history()->currentItem(); |
678 currPage->savePageDataToHistoryItem(currPage->mainFrame(), &item); |
868 currPage->savePageDataToHistoryItem(currPage->mainFrame(), &item); |
679 } |
869 } |
680 |
870 |
681 // 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 |
682 // 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 |
683 // 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. |
684 // 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 |
685 newPage->setPageZoomMetaData(webWidget()->defaultZoomData()); |
876 newPage->setPageZoomMetaData(webWidget()->defaultZoomData()); |
686 |
877 #else |
|
878 newPage->setPageZoomMetaData(m_widget->defaultZoomData()); |
|
879 #endif |
687 /* Set the new page as the current page */ |
880 /* Set the new page as the current page */ |
688 WebPageController::getSingleton()->setCurrentPage(newPage); |
881 WebPageController::getSingleton()->setCurrentPage(newPage); |
689 |
882 |
690 /* Set the web widget- this one is responsible for webnavigation etc */ |
883 /* Set the web widget- this one is responsible for webnavigation etc */ |
691 newPage->setWebWidget(webWidget()); |
884 newPage->setWebWidget(webWidget()); |
692 |
885 |
|
886 #ifndef BEDROCK_TILED_BACKING_STORE |
693 //connect new page main frame's initialLayoutCompleted with WebContentWidget' setViewportSize SLOT |
887 //connect new page main frame's initialLayoutCompleted with WebContentWidget' setViewportSize SLOT |
694 connect(newPage->mainFrame(), SIGNAL(initialLayoutCompleted()), webWidget(), SLOT(setViewportSize())); |
888 connect(newPage->mainFrame(), SIGNAL(initialLayoutCompleted()), webWidget(), SLOT(setViewportSize())); |
|
889 #endif |
695 } |
890 } |
696 |
891 |
697 void GWebContentView::updateWebPage(WRT::WrtBrowserContainer* pg) |
892 void GWebContentView::updateWebPage(WRT::WrtBrowserContainer* pg) |
698 { |
893 { |
|
894 #ifdef BEDROCK_TILED_BACKING_STORE |
|
895 QGraphicsWebView* w = webWidget(); |
|
896 #else |
699 GWebContentViewWidget* w = webWidget(); |
897 GWebContentViewWidget* w = webWidget(); |
|
898 #endif |
|
899 |
|
900 #ifndef BEDROCK_TILED_BACKING_STORE |
700 w->setPage(pg); |
901 w->setPage(pg); |
701 if(pg) |
902 #else |
|
903 m_widget->setPage(pg); |
|
904 #endif |
|
905 if (pg) |
702 { |
906 { |
703 pg->setWebWidget(w); |
907 pg->setWebWidget(w); |
704 |
908 |
|
909 #ifndef BEDROCK_TILED_BACKING_STORE |
705 // Change navigation also to the current page |
910 // Change navigation also to the current page |
706 m_touchNavigation->setPage(pg); |
911 m_touchNavigation->setPage(pg); |
|
912 m_touchNavigation->setWantSlideViewCalls(true); |
|
913 #endif |
707 |
914 |
708 } |
915 } |
709 } |
916 } |
710 |
917 |
711 void GWebContentView::pageChanged(WRT::WrtBrowserContainer* oldPage, WRT::WrtBrowserContainer* newPage) { |
918 void GWebContentView::pageChanged(WRT::WrtBrowserContainer* oldPage, WRT::WrtBrowserContainer* newPage) { |
712 qDebug() << "GWebContentView::pageChanged"; |
|
713 Q_UNUSED(oldPage) |
919 Q_UNUSED(oldPage) |
714 updateWebPage(newPage); |
920 updateWebPage(newPage); |
715 |
921 |
|
922 #ifndef BEDROCK_TILED_BACKING_STORE |
716 // Set new page zoom info |
923 // Set new page zoom info |
717 changeContentViewZoomInfo(newPage); |
924 changeContentViewZoomInfo(newPage); |
718 } |
925 #endif |
719 |
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 |
720 void GWebContentView::changeContentViewZoomInfo(WRT::WrtBrowserContainer* newPage){ |
948 void GWebContentView::changeContentViewZoomInfo(WRT::WrtBrowserContainer* newPage){ |
721 // Copy the new page zoom info into cv |
949 // Copy the new page zoom info into cv |
|
950 #ifndef BEDROCK_TILED_BACKING_STORE |
722 webWidget()->setPageZoomMetaData(newPage->pageZoomMetaData()); |
951 webWidget()->setPageZoomMetaData(newPage->pageZoomMetaData()); |
723 |
952 |
724 if (webWidget()->isUserScalable()) { |
953 if (webWidget()->isUserScalable()) { |
725 webWidget()->setZoomFactor(newPage->mainFrame()->zoomFactor()); |
954 webWidget()->setZoomFactor(newPage->mainFrame()->zoomFactor()); |
726 } |
955 } |