7b45224e5507d3e9082fcbc9eacef60c152c1ed1
[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         WKPageSetPagePolicyClient(toAPI(m_webPageProxy.get()), &policyClient);
160     }
161 }
162
163 QtWebPageProxy::~QtWebPageProxy()
164 {
165     m_webPageProxy->close();
166     // The context is the default one and we're deleting the last QtWebPageProxy.
167     if (m_context == s_defaultContext) {
168         ASSERT(s_defaultPageProxyCount > 0);
169         s_defaultPageProxyCount--;
170         if (!s_defaultPageProxyCount)
171             s_defaultContext.clear();
172     }
173     delete m_history;
174 }
175
176 bool QtWebPageProxy::handleEvent(QEvent* ev)
177 {
178     switch (ev->type()) {
179     case QEvent::KeyPress:
180         return handleKeyPressEvent(reinterpret_cast<QKeyEvent*>(ev));
181     case QEvent::KeyRelease:
182         return handleKeyReleaseEvent(reinterpret_cast<QKeyEvent*>(ev));
183     case QEvent::FocusIn:
184         return handleFocusInEvent(reinterpret_cast<QFocusEvent*>(ev));
185     case QEvent::FocusOut:
186         return handleFocusOutEvent(reinterpret_cast<QFocusEvent*>(ev));
187     }
188
189     // FIXME: Move all common event handling here.
190     return false;
191 }
192
193 bool QtWebPageProxy::handleKeyPressEvent(QKeyEvent* ev)
194 {
195     m_webPageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(ev));
196     return true;
197 }
198
199 bool QtWebPageProxy::handleKeyReleaseEvent(QKeyEvent* ev)
200 {
201     m_webPageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(ev));
202     return true;
203 }
204
205 bool QtWebPageProxy::handleFocusInEvent(QFocusEvent*)
206 {
207     m_webPageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
208     return true;
209 }
210
211 bool QtWebPageProxy::handleFocusOutEvent(QFocusEvent*)
212 {
213     m_webPageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
214     return true;
215 }
216
217 void QtWebPageProxy::setCursor(const WebCore::Cursor& cursor)
218 {
219     m_viewInterface->didChangeCursor(*cursor.platformCursor());
220 }
221
222 void QtWebPageProxy::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
223 {
224     notImplemented();
225 }
226
227 void QtWebPageProxy::setViewNeedsDisplay(const WebCore::IntRect& rect)
228 {
229     m_viewInterface->setViewNeedsDisplay(QRect(rect));
230 }
231
232 void QtWebPageProxy::displayView()
233 {
234     // FIXME: Implement.
235 }
236
237 void QtWebPageProxy::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset)
238 {
239     // FIXME: Implement.
240 }
241
242 WebCore::IntSize QtWebPageProxy::viewSize()
243 {
244     return WebCore::IntSize(m_viewInterface->drawingAreaSize());
245 }
246
247 bool QtWebPageProxy::isViewWindowActive()
248 {
249     return m_viewInterface->isActive();
250 }
251
252 bool QtWebPageProxy::isViewFocused()
253 {
254     return m_viewInterface->hasFocus();
255 }
256
257 bool QtWebPageProxy::isViewVisible()
258 {
259     return m_viewInterface->isVisible();
260 }
261
262 bool QtWebPageProxy::isViewInWindow()
263 {
264     // FIXME: Implement.
265     return true;
266 }
267
268 void QtWebPageProxy::enterAcceleratedCompositingMode(const LayerTreeContext&)
269 {
270     // FIXME: Implement.
271 }
272
273 void QtWebPageProxy::exitAcceleratedCompositingMode()
274 {
275     // FIXME: Implement.
276 }
277
278 void QtWebPageProxy::pageDidRequestScroll(const IntPoint& point)
279 {
280     emit scrollRequested(point.x(), point.y());
281 }
282
283 void QtWebPageProxy::didChangeContentsSize(const IntSize& newSize)
284 {
285     m_viewInterface->contentSizeChanged(QSize(newSize));
286 }
287
288 void QtWebPageProxy::toolTipChanged(const String&, const String& newTooltip)
289 {
290     m_viewInterface->didChangeToolTip(QString(newTooltip));
291 }
292
293 void QtWebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
294 {
295     if (undoOrRedo == WebPageProxy::Undo) {
296         const WebUndoCommandQt* webUndoCommand = static_cast<const WebUndoCommandQt*>(m_undoStack->command(m_undoStack->index()));
297         if (webUndoCommand && webUndoCommand->inUndoRedo())
298             return;
299         m_undoStack->push(new WebUndoCommandQt(command));
300     }
301 }
302
303 void QtWebPageProxy::clearAllEditCommands()
304 {
305     m_undoStack->clear();
306 }
307
308 bool QtWebPageProxy::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
309 {
310     if (undoOrRedo == WebPageProxy::Undo)
311         return m_undoStack->canUndo();
312     return m_undoStack->canRedo();
313 }
314
315 void QtWebPageProxy::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
316 {
317     if (undoOrRedo == WebPageProxy::Undo)
318         m_undoStack->undo();
319     else
320         m_undoStack->redo();
321 }
322
323 FloatRect QtWebPageProxy::convertToDeviceSpace(const FloatRect& rect)
324 {
325     return rect;
326 }
327
328 IntPoint QtWebPageProxy::screenToWindow(const IntPoint& point)
329 {
330     return point;
331 }
332
333 IntRect QtWebPageProxy::windowToScreen(const IntRect& rect)
334 {
335     return rect;
336 }
337
338 FloatRect QtWebPageProxy::convertToUserSpace(const FloatRect& rect)
339 {
340     return rect;
341 }
342
343 void QtWebPageProxy::selectionChanged(bool, bool, bool, bool)
344 {
345 }
346
347 void QtWebPageProxy::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
348 {
349 }
350
351 PassRefPtr<WebPopupMenuProxy> QtWebPageProxy::createPopupMenuProxy(WebPageProxy*)
352 {
353     return WebPopupMenuProxyQt::create();
354 }
355
356 PassRefPtr<WebContextMenuProxy> QtWebPageProxy::createContextMenuProxy(WebPageProxy*)
357 {
358     return WebContextMenuProxyQt::create(m_webPageProxy.get(), m_viewInterface);
359 }
360
361 void QtWebPageProxy::setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut)
362 {
363 }
364
365 void QtWebPageProxy::didCommitLoadForMainFrame(bool useCustomRepresentation)
366 {
367 }
368
369 void QtWebPageProxy::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&)
370 {
371 }
372
373 void QtWebPageProxy::flashBackingStoreUpdates(const Vector<IntRect>&)
374 {
375     notImplemented();
376 }
377
378 WKPageRef QtWebPageProxy::pageRef() const
379 {
380     return toAPI(m_webPageProxy.get());;
381 }
382
383 void QtWebPageProxy::didFindZoomableArea(const IntPoint& target, const IntRect& area)
384 {
385     m_viewInterface->didFindZoomableArea(QPoint(target), QRect(area));
386 }
387
388 void QtWebPageProxy::didChangeUrl(const QUrl& url)
389 {
390     m_viewInterface->didChangeUrl(url);
391 }
392
393 void QtWebPageProxy::didChangeTitle(const QString& newTitle)
394 {
395     m_viewInterface->didChangeTitle(newTitle);
396 }
397
398 void QtWebPageProxy::loadDidBegin()
399 {
400     m_viewInterface->loadDidBegin();
401 }
402
403 void QtWebPageProxy::loadDidCommit()
404 {
405     m_viewInterface->loadDidCommit();
406 }
407
408 void QtWebPageProxy::loadDidSucceed()
409 {
410     m_viewInterface->loadDidSucceed();
411 }
412
413 void QtWebPageProxy::loadDidFail(const QWebError& error)
414 {
415     m_viewInterface->loadDidFail(error);
416 }
417
418 void QtWebPageProxy::didChangeLoadProgress(int newLoadProgress)
419 {
420     m_loadProgress = newLoadProgress;
421     m_viewInterface->didChangeLoadProgress(newLoadProgress);
422 }
423
424 void QtWebPageProxy::paint(QPainter* painter, const QRect& area)
425 {
426     if (m_webPageProxy->isValid())
427         paintContent(painter, area);
428     else
429         painter->fillRect(area, Qt::white);
430 }
431
432 void QtWebPageProxy::updateAction(QtWebPageProxy::WebAction action)
433 {
434     QAction* a = m_actions[action];
435     if (!a)
436         return;
437
438     RefPtr<WebKit::WebFrameProxy> mainFrame = m_webPageProxy->mainFrame();
439
440     bool enabled = a->isEnabled();
441
442     switch (action) {
443     case QtWebPageProxy::Back:
444         enabled = m_webPageProxy->canGoBack();
445         break;
446     case QtWebPageProxy::Forward:
447         enabled = m_webPageProxy->canGoForward();
448         break;
449     case QtWebPageProxy::Stop:
450         enabled = mainFrame && !(WebFrameProxy::LoadStateFinished == mainFrame->loadState());
451         break;
452     case QtWebPageProxy::Reload:
453         if (mainFrame)
454             enabled = (WebFrameProxy::LoadStateFinished == mainFrame->loadState());
455         else
456             enabled = m_webPageProxy->backForwardList()->currentItem();
457         break;
458     default:
459         ASSERT_NOT_REACHED();
460     }
461
462     a->setEnabled(enabled);
463 }
464
465 void QtWebPageProxy::updateNavigationActions()
466 {
467     updateAction(QtWebPageProxy::Back);
468     updateAction(QtWebPageProxy::Forward);
469     updateAction(QtWebPageProxy::Stop);
470     updateAction(QtWebPageProxy::Reload);
471 }
472
473 void QtWebPageProxy::webActionTriggered(bool checked)
474 {
475     QAction* a = qobject_cast<QAction*>(sender());
476     if (!a)
477         return;
478     QtWebPageProxy::WebAction action = static_cast<QtWebPageProxy::WebAction>(a->data().toInt());
479     triggerAction(action, checked);
480 }
481
482 void QtWebPageProxy::didRelaunchProcess()
483 {
484     updateNavigationActions();
485     m_viewInterface->didRelaunchProcess();
486     setDrawingAreaSize(m_viewInterface->drawingAreaSize());
487 }
488
489 void QtWebPageProxy::processDidCrash()
490 {
491     updateNavigationActions();
492     m_viewInterface->processDidCrash();
493 }
494
495 QWKPreferences* QtWebPageProxy::preferences() const
496 {
497     if (!m_preferences) {
498         WKPageGroupRef pageGroupRef = WKPageGetPageGroup(pageRef());
499         m_preferences = QWKPreferencesPrivate::createPreferences(pageGroupRef);
500     }
501
502     return m_preferences;
503 }
504
505 void QtWebPageProxy::setCustomUserAgent(const QString& userAgent)
506 {
507     WKRetainPtr<WKStringRef> wkUserAgent(WKStringCreateWithQString(userAgent));
508     WKPageSetCustomUserAgent(pageRef(), wkUserAgent.get());
509 }
510
511 QString QtWebPageProxy::customUserAgent() const
512 {
513     return WKStringCopyQString(WKPageCopyCustomUserAgent(pageRef()));
514 }
515
516 void QtWebPageProxy::load(const QUrl& url)
517 {
518     WKRetainPtr<WKURLRef> wkurl(WKURLCreateWithQUrl(url));
519     WKPageLoadURL(pageRef(), wkurl.get());
520 }
521
522 QUrl QtWebPageProxy::url() const
523 {
524     WKRetainPtr<WKFrameRef> frame = WKPageGetMainFrame(pageRef());
525     if (!frame)
526         return QUrl();
527     return WKURLCopyQUrl(WKFrameCopyURL(frame.get()));
528 }
529
530 QString QtWebPageProxy::title() const
531 {
532     return WKStringCopyQString(WKPageCopyTitle(toAPI(m_webPageProxy.get())));
533 }
534
535 void QtWebPageProxy::setDrawingAreaSize(const QSize& size)
536 {
537     if (!m_webPageProxy->drawingArea())
538         return;
539     m_webPageProxy->drawingArea()->setSize(IntSize(size), IntSize());
540 }
541
542 qreal QtWebPageProxy::textZoomFactor() const
543 {
544     return WKPageGetTextZoomFactor(pageRef());
545 }
546
547 void QtWebPageProxy::setTextZoomFactor(qreal zoomFactor)
548 {
549     WKPageSetTextZoomFactor(pageRef(), zoomFactor);
550 }
551
552 qreal QtWebPageProxy::pageZoomFactor() const
553 {
554     return WKPageGetPageZoomFactor(pageRef());
555 }
556
557 void QtWebPageProxy::setPageZoomFactor(qreal zoomFactor)
558 {
559     WKPageSetPageZoomFactor(pageRef(), zoomFactor);
560 }
561
562 void QtWebPageProxy::setPageAndTextZoomFactors(qreal pageZoomFactor, qreal textZoomFactor)
563 {
564     WKPageSetPageAndTextZoomFactors(pageRef(), pageZoomFactor, textZoomFactor);
565 }
566
567 QWKHistory* QtWebPageProxy::history() const
568 {
569     return m_history;
570 }
571
572 void QtWebPageProxy::triggerAction(WebAction webAction, bool)
573 {
574     switch (webAction) {
575     case Back:
576         m_webPageProxy->goBack();
577         return;
578     case Forward:
579         m_webPageProxy->goForward();
580         return;
581     case Stop:
582         m_webPageProxy->stopLoading();
583         return;
584     case Reload:
585         m_webPageProxy->reload(/* reloadFromOrigin */ true);
586         return;
587     default:
588         ASSERT_NOT_REACHED();
589     }
590 }
591
592 QAction* QtWebPageProxy::navigationAction(QtWebKit::NavigationAction which) const
593 {
594     switch (which) {
595     case QtWebKit::Back:
596         return action(QtWebPageProxy::Back);
597     case QtWebKit::Forward:
598         return action(QtWebPageProxy::Forward);
599     case QtWebKit::Reload:
600         return action(QtWebPageProxy::Reload);
601     case QtWebKit::Stop:
602         return action(QtWebPageProxy::Stop);
603     }
604
605     return 0;
606 }
607
608 QAction* QtWebPageProxy::action(WebAction action) const
609 {
610     if (action == QtWebPageProxy::NoWebAction || action >= WebActionCount)
611         return 0;
612
613     if (m_actions[action])
614         return m_actions[action];
615
616     QString text;
617     QIcon icon;
618     QStyle* style = qobject_cast<QApplication*>(QCoreApplication::instance())->style();
619     bool checkable = false;
620     QtWebPageProxy* mutableSelf = const_cast<QtWebPageProxy*>(this);
621
622     switch (action) {
623     case Back:
624         text = contextMenuItemTagGoBack();
625         icon = style->standardIcon(QStyle::SP_ArrowBack);
626         break;
627     case Forward:
628         text = contextMenuItemTagGoForward();
629         icon = style->standardIcon(QStyle::SP_ArrowForward);
630         break;
631     case Stop:
632         text = contextMenuItemTagStop();
633         icon = style->standardIcon(QStyle::SP_BrowserStop);
634         break;
635     case Reload:
636         text = contextMenuItemTagReload();
637         icon = style->standardIcon(QStyle::SP_BrowserReload);
638         break;
639     case Undo: {
640         QAction* undoAction = m_undoStack->createUndoAction(mutableSelf);
641         m_actions[action] = undoAction;
642         return undoAction;
643     }
644     case Redo: {
645         QAction* redoAction = m_undoStack->createRedoAction(mutableSelf);
646         m_actions[action] = redoAction;
647         return redoAction;
648     }
649     default:
650         ASSERT_NOT_REACHED();
651         break;
652     }
653
654     if (text.isEmpty())
655         return 0;
656
657     QAction* a = new QAction(mutableSelf);
658     a->setText(text);
659     a->setData(action);
660     a->setCheckable(checkable);
661     a->setIcon(icon);
662
663     connect(a, SIGNAL(triggered(bool)), this, SLOT(webActionTriggered(bool)));
664
665     m_actions[action] = a;
666     mutableSelf->updateAction(action);
667     return a;
668 }
669
670 void QtWebPageProxy::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
671 {
672     QImage dragQImage;
673     if (dragImage)
674         dragQImage = dragImage->createQImage();
675     else if (dragData.platformData() && dragData.platformData()->hasImage())
676         dragQImage = qvariant_cast<QImage>(dragData.platformData()->imageData());
677
678
679     DragOperation dragOperationMask = dragData.draggingSourceOperationMask();
680     QMimeData* mimeData = const_cast<QMimeData*>(dragData.platformData());
681     Qt::DropActions supportedDropActions = dragOperationToDropActions(dragOperationMask);
682
683     QPoint clientPosition;
684     QPoint globalPosition;
685     Qt::DropAction actualDropAction;
686
687     m_viewInterface->startDrag(supportedDropActions, dragQImage, mimeData,
688                                &clientPosition, &globalPosition, &actualDropAction);
689
690     m_webPageProxy->dragEnded(clientPosition, globalPosition, dropActionToDragOperation(actualDropAction));
691 }
692
693 void QtWebPageProxy::setViewportArguments(const WebCore::ViewportArguments& args)
694 {
695     m_viewInterface->didReceiveViewportArguments(args);
696 }
697
698 void QtWebPageProxy::setPageIsVisible(bool isVisible)
699 {
700     m_webPageProxy->drawingArea()->setPageIsVisible(isVisible);
701 }
702
703 #include "moc_QtWebPageProxy.cpp"