[Qt][WK2] Implement decidePolicyForResponse in our PolicyClient
[WebKit.git] / Source / WebKit2 / UIProcess / qt / QtWebPageProxy.cpp
1 /*
2  * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
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 GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this program; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  *
19  */
20
21 #include "config.h"
22 #include "QtWebPageProxy.h"
23
24 #include "qweberror.h"
25 #include "qwkpreferences_p.h"
26
27 #include "ClientImpl.h"
28 #include "qwkhistory.h"
29 #include "qwkhistory_p.h"
30 #include "FindIndicator.h"
31 #include "LocalizedStrings.h"
32 #include "NativeWebKeyboardEvent.h"
33 #include "NotImplemented.h"
34 #include "PolicyInterface.h"
35 #include "ViewInterface.h"
36 #include "WebBackForwardList.h"
37 #include "WebContext.h"
38 #include "WebContextMenuProxyQt.h"
39 #include "WebEditCommandProxy.h"
40 #include "WebEventFactoryQt.h"
41 #include "WebPopupMenuProxyQt.h"
42 #include "WebUndoCommandQt.h"
43 #include "WKStringQt.h"
44 #include "WKURLQt.h"
45 #include <QAction>
46 #include <QApplication>
47 #include <QGraphicsSceneMouseEvent>
48 #include <QJSEngine>
49 #include <QMimeData>
50 #include <QStyle>
51 #include <QTouchEvent>
52 #include <QUndoStack>
53 #include <QtDebug>
54 #include <WebCore/Cursor.h>
55 #include <WebCore/DragData.h>
56 #include <WebCore/FloatRect.h>
57 #include <WebCore/NotImplemented.h>
58 #include <WebKit2/WKFrame.h>
59 #include <WebKit2/WKPageGroup.h>
60 #include <WebKit2/WKRetainPtr.h>
61
62 using namespace WebKit;
63 using namespace WebCore;
64
65
66 RefPtr<WebContext> QtWebPageProxy::s_defaultContext;
67
68 unsigned QtWebPageProxy::s_defaultPageProxyCount = 0;
69
70 PassRefPtr<WebContext> QtWebPageProxy::defaultWKContext()
71 {
72     if (!s_defaultContext)
73         s_defaultContext = WebContext::create(String());
74     return s_defaultContext;
75 }
76
77 static inline Qt::DropActions dragOperationToDropActions(unsigned dragOperations)
78 {
79     Qt::DropActions result = Qt::IgnoreAction;
80     if (dragOperations & DragOperationCopy)
81         result |= Qt::CopyAction;
82     if (dragOperations & DragOperationMove)
83         result |= Qt::MoveAction;
84     if (dragOperations & DragOperationGeneric)
85         result |= Qt::MoveAction;
86     if (dragOperations & DragOperationLink)
87         result |= Qt::LinkAction;
88     return result;
89 }
90
91 WebCore::DragOperation dropActionToDragOperation(Qt::DropActions actions)
92 {
93     unsigned result = 0;
94     if (actions & Qt::CopyAction)
95         result |= DragOperationCopy;
96     if (actions & Qt::MoveAction)
97         result |= (DragOperationMove | DragOperationGeneric);
98     if (actions & Qt::LinkAction)
99         result |= DragOperationLink;
100     if (result == (DragOperationCopy | DragOperationMove | DragOperationGeneric | DragOperationLink))
101         result = DragOperationEvery;
102     return (DragOperation)result;
103 }
104
105 QtWebPageProxy::QtWebPageProxy(ViewInterface* viewInterface, PolicyInterface* policyInterface, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
106     : m_viewInterface(viewInterface)
107     , m_policyInterface(policyInterface)
108     , m_context(contextRef ? toImpl(contextRef) : defaultWKContext())
109     , m_preferences(0)
110     , m_undoStack(adoptPtr(new QUndoStack(this)))
111     , m_loadProgress(0)
112 {
113     ASSERT(viewInterface);
114     memset(m_actions, 0, sizeof(m_actions));
115     m_webPageProxy = m_context->createWebPage(this, toImpl(pageGroupRef));
116     m_history = QWKHistoryPrivate::createHistory(this, m_webPageProxy->backForwardList());
117     if (!contextRef)
118         s_defaultPageProxyCount++;
119 }
120
121 void QtWebPageProxy::init()
122 {
123     m_webPageProxy->initializeWebPage();
124
125     WKPageLoaderClient loadClient;
126     memset(&loadClient, 0, sizeof(WKPageLoaderClient));
127     loadClient.version = kWKPageLoaderClientCurrentVersion;
128     loadClient.clientInfo = this;
129     loadClient.didStartProvisionalLoadForFrame = qt_wk_didStartProvisionalLoadForFrame;
130     loadClient.didFailProvisionalLoadWithErrorForFrame = qt_wk_didFailProvisionalLoadWithErrorForFrame;
131     loadClient.didCommitLoadForFrame = qt_wk_didCommitLoadForFrame;
132     loadClient.didFinishLoadForFrame = qt_wk_didFinishLoadForFrame;
133     loadClient.didFailLoadWithErrorForFrame = qt_wk_didFailLoadWithErrorForFrame;
134     loadClient.didSameDocumentNavigationForFrame = qt_wk_didSameDocumentNavigationForFrame;
135     loadClient.didReceiveTitleForFrame = qt_wk_didReceiveTitleForFrame;
136     loadClient.didStartProgress = qt_wk_didStartProgress;
137     loadClient.didChangeProgress = qt_wk_didChangeProgress;
138     loadClient.didFinishProgress = qt_wk_didFinishProgress;
139     WKPageSetPageLoaderClient(pageRef(), &loadClient);
140
141     WKPageUIClient uiClient;
142     memset(&uiClient, 0, sizeof(WKPageUIClient));
143     uiClient.version = kWKPageUIClientCurrentVersion;
144     uiClient.clientInfo = m_viewInterface;
145     uiClient.runJavaScriptAlert = qt_wk_runJavaScriptAlert;
146     uiClient.runJavaScriptConfirm = qt_wk_runJavaScriptConfirm;
147     uiClient.runJavaScriptPrompt = qt_wk_runJavaScriptPrompt;
148     uiClient.setStatusText = qt_wk_setStatusText;
149     uiClient.runOpenPanel = qt_wk_runOpenPanel;
150     uiClient.mouseDidMoveOverElement = qt_wk_mouseDidMoveOverElement;
151     WKPageSetPageUIClient(toAPI(m_webPageProxy.get()), &uiClient);
152
153     if (m_policyInterface) {
154         WKPagePolicyClient policyClient;
155         memset(&policyClient, 0, sizeof(WKPagePolicyClient));
156         policyClient.version = kWKPagePolicyClientCurrentVersion;
157         policyClient.clientInfo = m_policyInterface;
158         policyClient.decidePolicyForNavigationAction = qt_wk_decidePolicyForNavigationAction;
159         policyClient.decidePolicyForResponse = qt_wk_decidePolicyForResponse;
160         WKPageSetPagePolicyClient(toAPI(m_webPageProxy.get()), &policyClient);
161     }
162 }
163
164 QtWebPageProxy::~QtWebPageProxy()
165 {
166     m_webPageProxy->close();
167     // The context is the default one and we're deleting the last QtWebPageProxy.
168     if (m_context == s_defaultContext) {
169         ASSERT(s_defaultPageProxyCount > 0);
170         s_defaultPageProxyCount--;
171         if (!s_defaultPageProxyCount)
172             s_defaultContext.clear();
173     }
174     delete m_history;
175 }
176
177 bool QtWebPageProxy::handleEvent(QEvent* ev)
178 {
179     switch (ev->type()) {
180     case QEvent::KeyPress:
181         return handleKeyPressEvent(reinterpret_cast<QKeyEvent*>(ev));
182     case QEvent::KeyRelease:
183         return handleKeyReleaseEvent(reinterpret_cast<QKeyEvent*>(ev));
184     case QEvent::FocusIn:
185         return handleFocusInEvent(reinterpret_cast<QFocusEvent*>(ev));
186     case QEvent::FocusOut:
187         return handleFocusOutEvent(reinterpret_cast<QFocusEvent*>(ev));
188     }
189
190     // FIXME: Move all common event handling here.
191     return false;
192 }
193
194 bool QtWebPageProxy::handleKeyPressEvent(QKeyEvent* ev)
195 {
196     m_webPageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(ev));
197     return true;
198 }
199
200 bool QtWebPageProxy::handleKeyReleaseEvent(QKeyEvent* ev)
201 {
202     m_webPageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(ev));
203     return true;
204 }
205
206 bool QtWebPageProxy::handleFocusInEvent(QFocusEvent*)
207 {
208     m_webPageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
209     return true;
210 }
211
212 bool QtWebPageProxy::handleFocusOutEvent(QFocusEvent*)
213 {
214     m_webPageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
215     return true;
216 }
217
218 void QtWebPageProxy::setCursor(const WebCore::Cursor& cursor)
219 {
220     m_viewInterface->didChangeCursor(*cursor.platformCursor());
221 }
222
223 void QtWebPageProxy::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
224 {
225     notImplemented();
226 }
227
228 void QtWebPageProxy::setViewNeedsDisplay(const WebCore::IntRect& rect)
229 {
230     m_viewInterface->setViewNeedsDisplay(QRect(rect));
231 }
232
233 void QtWebPageProxy::displayView()
234 {
235     // FIXME: Implement.
236 }
237
238 void QtWebPageProxy::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset)
239 {
240     // FIXME: Implement.
241 }
242
243 WebCore::IntSize QtWebPageProxy::viewSize()
244 {
245     return WebCore::IntSize(m_viewInterface->drawingAreaSize());
246 }
247
248 bool QtWebPageProxy::isViewWindowActive()
249 {
250     return m_viewInterface->isActive();
251 }
252
253 bool QtWebPageProxy::isViewFocused()
254 {
255     return m_viewInterface->hasFocus();
256 }
257
258 bool QtWebPageProxy::isViewVisible()
259 {
260     return m_viewInterface->isVisible();
261 }
262
263 bool QtWebPageProxy::isViewInWindow()
264 {
265     // FIXME: Implement.
266     return true;
267 }
268
269 void QtWebPageProxy::enterAcceleratedCompositingMode(const LayerTreeContext&)
270 {
271     // FIXME: Implement.
272 }
273
274 void QtWebPageProxy::exitAcceleratedCompositingMode()
275 {
276     // FIXME: Implement.
277 }
278
279 void QtWebPageProxy::pageDidRequestScroll(const IntPoint& point)
280 {
281     emit scrollRequested(point.x(), point.y());
282 }
283
284 void QtWebPageProxy::didChangeContentsSize(const IntSize& newSize)
285 {
286     m_viewInterface->contentSizeChanged(QSize(newSize));
287 }
288
289 void QtWebPageProxy::toolTipChanged(const String&, const String& newTooltip)
290 {
291     m_viewInterface->didChangeToolTip(QString(newTooltip));
292 }
293
294 void QtWebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
295 {
296     if (undoOrRedo == WebPageProxy::Undo) {
297         const WebUndoCommandQt* webUndoCommand = static_cast<const WebUndoCommandQt*>(m_undoStack->command(m_undoStack->index()));
298         if (webUndoCommand && webUndoCommand->inUndoRedo())
299             return;
300         m_undoStack->push(new WebUndoCommandQt(command));
301     }
302 }
303
304 void QtWebPageProxy::clearAllEditCommands()
305 {
306     m_undoStack->clear();
307 }
308
309 bool QtWebPageProxy::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
310 {
311     if (undoOrRedo == WebPageProxy::Undo)
312         return m_undoStack->canUndo();
313     return m_undoStack->canRedo();
314 }
315
316 void QtWebPageProxy::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
317 {
318     if (undoOrRedo == WebPageProxy::Undo)
319         m_undoStack->undo();
320     else
321         m_undoStack->redo();
322 }
323
324 FloatRect QtWebPageProxy::convertToDeviceSpace(const FloatRect& rect)
325 {
326     return rect;
327 }
328
329 IntPoint QtWebPageProxy::screenToWindow(const IntPoint& point)
330 {
331     return point;
332 }
333
334 IntRect QtWebPageProxy::windowToScreen(const IntRect& rect)
335 {
336     return rect;
337 }
338
339 FloatRect QtWebPageProxy::convertToUserSpace(const FloatRect& rect)
340 {
341     return rect;
342 }
343
344 void QtWebPageProxy::selectionChanged(bool, bool, bool, bool)
345 {
346 }
347
348 void QtWebPageProxy::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
349 {
350 }
351
352 PassRefPtr<WebPopupMenuProxy> QtWebPageProxy::createPopupMenuProxy(WebPageProxy*)
353 {
354     return WebPopupMenuProxyQt::create();
355 }
356
357 PassRefPtr<WebContextMenuProxy> QtWebPageProxy::createContextMenuProxy(WebPageProxy*)
358 {
359     return WebContextMenuProxyQt::create(m_webPageProxy.get(), m_viewInterface);
360 }
361
362 void QtWebPageProxy::setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut)
363 {
364 }
365
366 void QtWebPageProxy::didCommitLoadForMainFrame(bool useCustomRepresentation)
367 {
368 }
369
370 void QtWebPageProxy::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&)
371 {
372 }
373
374 void QtWebPageProxy::flashBackingStoreUpdates(const Vector<IntRect>&)
375 {
376     notImplemented();
377 }
378
379 WKPageRef QtWebPageProxy::pageRef() const
380 {
381     return toAPI(m_webPageProxy.get());;
382 }
383
384 void QtWebPageProxy::didFindZoomableArea(const IntPoint& target, const IntRect& area)
385 {
386     m_viewInterface->didFindZoomableArea(QPoint(target), QRect(area));
387 }
388
389 void QtWebPageProxy::didChangeUrl(const QUrl& url)
390 {
391     m_viewInterface->didChangeUrl(url);
392 }
393
394 void QtWebPageProxy::didChangeTitle(const QString& newTitle)
395 {
396     m_viewInterface->didChangeTitle(newTitle);
397 }
398
399 void QtWebPageProxy::loadDidBegin()
400 {
401     m_viewInterface->loadDidBegin();
402 }
403
404 void QtWebPageProxy::loadDidCommit()
405 {
406     m_viewInterface->loadDidCommit();
407 }
408
409 void QtWebPageProxy::loadDidSucceed()
410 {
411     m_viewInterface->loadDidSucceed();
412 }
413
414 void QtWebPageProxy::loadDidFail(const QWebError& error)
415 {
416     m_viewInterface->loadDidFail(error);
417 }
418
419 void QtWebPageProxy::didChangeLoadProgress(int newLoadProgress)
420 {
421     m_loadProgress = newLoadProgress;
422     m_viewInterface->didChangeLoadProgress(newLoadProgress);
423 }
424
425 void QtWebPageProxy::paint(QPainter* painter, const QRect& area)
426 {
427     if (m_webPageProxy->isValid())
428         paintContent(painter, area);
429     else
430         painter->fillRect(area, Qt::white);
431 }
432
433 void QtWebPageProxy::updateAction(QtWebPageProxy::WebAction action)
434 {
435     QAction* a = m_actions[action];
436     if (!a)
437         return;
438
439     RefPtr<WebKit::WebFrameProxy> mainFrame = m_webPageProxy->mainFrame();
440
441     bool enabled = a->isEnabled();
442
443     switch (action) {
444     case QtWebPageProxy::Back:
445         enabled = m_webPageProxy->canGoBack();
446         break;
447     case QtWebPageProxy::Forward:
448         enabled = m_webPageProxy->canGoForward();
449         break;
450     case QtWebPageProxy::Stop:
451         enabled = mainFrame && !(WebFrameProxy::LoadStateFinished == mainFrame->loadState());
452         break;
453     case QtWebPageProxy::Reload:
454         if (mainFrame)
455             enabled = (WebFrameProxy::LoadStateFinished == mainFrame->loadState());
456         else
457             enabled = m_webPageProxy->backForwardList()->currentItem();
458         break;
459     default:
460         ASSERT_NOT_REACHED();
461     }
462
463     a->setEnabled(enabled);
464 }
465
466 void QtWebPageProxy::updateNavigationActions()
467 {
468     updateAction(QtWebPageProxy::Back);
469     updateAction(QtWebPageProxy::Forward);
470     updateAction(QtWebPageProxy::Stop);
471     updateAction(QtWebPageProxy::Reload);
472 }
473
474 void QtWebPageProxy::webActionTriggered(bool checked)
475 {
476     QAction* a = qobject_cast<QAction*>(sender());
477     if (!a)
478         return;
479     QtWebPageProxy::WebAction action = static_cast<QtWebPageProxy::WebAction>(a->data().toInt());
480     triggerAction(action, checked);
481 }
482
483 void QtWebPageProxy::didRelaunchProcess()
484 {
485     updateNavigationActions();
486     m_viewInterface->didRelaunchProcess();
487     setDrawingAreaSize(m_viewInterface->drawingAreaSize());
488 }
489
490 void QtWebPageProxy::processDidCrash()
491 {
492     updateNavigationActions();
493     m_viewInterface->processDidCrash();
494 }
495
496 QWKPreferences* QtWebPageProxy::preferences() const
497 {
498     if (!m_preferences) {
499         WKPageGroupRef pageGroupRef = WKPageGetPageGroup(pageRef());
500         m_preferences = QWKPreferencesPrivate::createPreferences(pageGroupRef);
501     }
502
503     return m_preferences;
504 }
505
506 void QtWebPageProxy::setCustomUserAgent(const QString& userAgent)
507 {
508     WKRetainPtr<WKStringRef> wkUserAgent(WKStringCreateWithQString(userAgent));
509     WKPageSetCustomUserAgent(pageRef(), wkUserAgent.get());
510 }
511
512 QString QtWebPageProxy::customUserAgent() const
513 {
514     return WKStringCopyQString(WKPageCopyCustomUserAgent(pageRef()));
515 }
516
517 void QtWebPageProxy::load(const QUrl& url)
518 {
519     WKRetainPtr<WKURLRef> wkurl(WKURLCreateWithQUrl(url));
520     WKPageLoadURL(pageRef(), wkurl.get());
521 }
522
523 QUrl QtWebPageProxy::url() const
524 {
525     WKRetainPtr<WKFrameRef> frame = WKPageGetMainFrame(pageRef());
526     if (!frame)
527         return QUrl();
528     return WKURLCopyQUrl(WKFrameCopyURL(frame.get()));
529 }
530
531 QString QtWebPageProxy::title() const
532 {
533     return WKStringCopyQString(WKPageCopyTitle(toAPI(m_webPageProxy.get())));
534 }
535
536 void QtWebPageProxy::setDrawingAreaSize(const QSize& size)
537 {
538     if (!m_webPageProxy->drawingArea())
539         return;
540     m_webPageProxy->drawingArea()->setSize(IntSize(size), IntSize());
541 }
542
543 qreal QtWebPageProxy::textZoomFactor() const
544 {
545     return WKPageGetTextZoomFactor(pageRef());
546 }
547
548 void QtWebPageProxy::setTextZoomFactor(qreal zoomFactor)
549 {
550     WKPageSetTextZoomFactor(pageRef(), zoomFactor);
551 }
552
553 qreal QtWebPageProxy::pageZoomFactor() const
554 {
555     return WKPageGetPageZoomFactor(pageRef());
556 }
557
558 void QtWebPageProxy::setPageZoomFactor(qreal zoomFactor)
559 {
560     WKPageSetPageZoomFactor(pageRef(), zoomFactor);
561 }
562
563 void QtWebPageProxy::setPageAndTextZoomFactors(qreal pageZoomFactor, qreal textZoomFactor)
564 {
565     WKPageSetPageAndTextZoomFactors(pageRef(), pageZoomFactor, textZoomFactor);
566 }
567
568 QWKHistory* QtWebPageProxy::history() const
569 {
570     return m_history;
571 }
572
573 void QtWebPageProxy::triggerAction(WebAction webAction, bool)
574 {
575     switch (webAction) {
576     case Back:
577         m_webPageProxy->goBack();
578         return;
579     case Forward:
580         m_webPageProxy->goForward();
581         return;
582     case Stop:
583         m_webPageProxy->stopLoading();
584         return;
585     case Reload:
586         m_webPageProxy->reload(/* reloadFromOrigin */ true);
587         return;
588     default:
589         ASSERT_NOT_REACHED();
590     }
591 }
592
593 QAction* QtWebPageProxy::navigationAction(QtWebKit::NavigationAction which) const
594 {
595     switch (which) {
596     case QtWebKit::Back:
597         return action(QtWebPageProxy::Back);
598     case QtWebKit::Forward:
599         return action(QtWebPageProxy::Forward);
600     case QtWebKit::Reload:
601         return action(QtWebPageProxy::Reload);
602     case QtWebKit::Stop:
603         return action(QtWebPageProxy::Stop);
604     }
605
606     return 0;
607 }
608
609 QAction* QtWebPageProxy::action(WebAction action) const
610 {
611     if (action == QtWebPageProxy::NoWebAction || action >= WebActionCount)
612         return 0;
613
614     if (m_actions[action])
615         return m_actions[action];
616
617     QString text;
618     QIcon icon;
619     QStyle* style = qobject_cast<QApplication*>(QCoreApplication::instance())->style();
620     bool checkable = false;
621     QtWebPageProxy* mutableSelf = const_cast<QtWebPageProxy*>(this);
622
623     switch (action) {
624     case Back:
625         text = contextMenuItemTagGoBack();
626         icon = style->standardIcon(QStyle::SP_ArrowBack);
627         break;
628     case Forward:
629         text = contextMenuItemTagGoForward();
630         icon = style->standardIcon(QStyle::SP_ArrowForward);
631         break;
632     case Stop:
633         text = contextMenuItemTagStop();
634         icon = style->standardIcon(QStyle::SP_BrowserStop);
635         break;
636     case Reload:
637         text = contextMenuItemTagReload();
638         icon = style->standardIcon(QStyle::SP_BrowserReload);
639         break;
640     case Undo: {
641         QAction* undoAction = m_undoStack->createUndoAction(mutableSelf);
642         m_actions[action] = undoAction;
643         return undoAction;
644     }
645     case Redo: {
646         QAction* redoAction = m_undoStack->createRedoAction(mutableSelf);
647         m_actions[action] = redoAction;
648         return redoAction;
649     }
650     default:
651         ASSERT_NOT_REACHED();
652         break;
653     }
654
655     if (text.isEmpty())
656         return 0;
657
658     QAction* a = new QAction(mutableSelf);
659     a->setText(text);
660     a->setData(action);
661     a->setCheckable(checkable);
662     a->setIcon(icon);
663
664     connect(a, SIGNAL(triggered(bool)), this, SLOT(webActionTriggered(bool)));
665
666     m_actions[action] = a;
667     mutableSelf->updateAction(action);
668     return a;
669 }
670
671 void QtWebPageProxy::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
672 {
673     QImage dragQImage;
674     if (dragImage)
675         dragQImage = dragImage->createQImage();
676     else if (dragData.platformData() && dragData.platformData()->hasImage())
677         dragQImage = qvariant_cast<QImage>(dragData.platformData()->imageData());
678
679
680     DragOperation dragOperationMask = dragData.draggingSourceOperationMask();
681     QMimeData* mimeData = const_cast<QMimeData*>(dragData.platformData());
682     Qt::DropActions supportedDropActions = dragOperationToDropActions(dragOperationMask);
683
684     QPoint clientPosition;
685     QPoint globalPosition;
686     Qt::DropAction actualDropAction;
687
688     m_viewInterface->startDrag(supportedDropActions, dragQImage, mimeData,
689                                &clientPosition, &globalPosition, &actualDropAction);
690
691     m_webPageProxy->dragEnded(clientPosition, globalPosition, dropActionToDragOperation(actualDropAction));
692 }
693
694 void QtWebPageProxy::setViewportArguments(const WebCore::ViewportArguments& args)
695 {
696     m_viewInterface->didReceiveViewportArguments(args);
697 }
698
699 void QtWebPageProxy::setPageIsVisible(bool isVisible)
700 {
701     m_webPageProxy->drawingArea()->setPageIsVisible(isVisible);
702 }
703
704 #include "moc_QtWebPageProxy.cpp"