OSDN Git Service

Merge WebKit at r78450: Initial merge by git.
[android-x86/external-webkit.git] / Source / WebKit2 / UIProcess / API / qt / qwkpage.cpp
1 /*
2  * Copyright (C) 2010 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 "qwkpage.h"
23 #include "qwkpage_p.h"
24
25 #include "qwkpreferences_p.h"
26
27 #include "ChunkedUpdateDrawingAreaProxy.h"
28 #include "ClientImpl.h"
29 #include "qgraphicswkview.h"
30 #include "qwkcontext.h"
31 #include "qwkcontext_p.h"
32 #include "qwkhistory.h"
33 #include "qwkhistory_p.h"
34 #include "FindIndicator.h"
35 #include "LocalizedStrings.h"
36 #include "NativeWebKeyboardEvent.h"
37 #include "TiledDrawingAreaProxy.h"
38 #include "WebContext.h"
39 #include "WebContextMenuProxyQt.h"
40 #include "WebEventFactoryQt.h"
41 #include "WebPopupMenuProxyQt.h"
42 #include "WKStringQt.h"
43 #include "WKURLQt.h"
44 #include "ViewportArguments.h"
45 #include <QAction>
46 #include <QApplication>
47 #include <QGraphicsSceneMouseEvent>
48 #include <QStyle>
49 #include <QTouchEvent>
50 #include <QtDebug>
51 #include <WebCore/Cursor.h>
52 #include <WebCore/FloatRect.h>
53 #include <WebKit2/WKFrame.h>
54 #include <WebKit2/WKPageGroup.h>
55 #include <WebKit2/WKRetainPtr.h>
56
57 using namespace WebKit;
58 using namespace WebCore;
59
60 static WebCore::ContextMenuAction contextMenuActionForWebAction(QWKPage::WebAction action)
61 {
62     switch (action) {
63     case QWKPage::OpenLink:
64         return WebCore::ContextMenuItemTagOpenLink;
65     case QWKPage::OpenLinkInNewWindow:
66         return WebCore::ContextMenuItemTagOpenLinkInNewWindow;
67     case QWKPage::CopyLinkToClipboard:
68         return WebCore::ContextMenuItemTagCopyLinkToClipboard;
69     case QWKPage::OpenImageInNewWindow:
70         return WebCore::ContextMenuItemTagOpenImageInNewWindow;
71     case QWKPage::Cut:
72         return WebCore::ContextMenuItemTagCut;
73     case QWKPage::Copy:
74         return WebCore::ContextMenuItemTagCopy;
75     case QWKPage::Paste:
76         return WebCore::ContextMenuItemTagPaste;
77     case QWKPage::SelectAll:
78         return WebCore::ContextMenuItemTagSelectAll;
79     default:
80         ASSERT(false);
81         break;
82     }
83     return WebCore::ContextMenuItemTagNoAction;
84 }
85
86 QWKPagePrivate::QWKPagePrivate(QWKPage* qq, QWKContext* c)
87     : q(qq)
88     , view(0)
89     , context(c)
90     , preferences(0)
91     , createNewPageFn(0)
92     , backingStoreType(QGraphicsWKView::Simple)
93     , isConnectedToEngine(true)
94 {
95     memset(actions, 0, sizeof(actions));
96     page = context->d->context->createWebPage(this, 0);
97     history = QWKHistoryPrivate::createHistory(page->backForwardList());
98 }
99
100 QWKPagePrivate::~QWKPagePrivate()
101 {
102     page->close();
103     delete history;
104 }
105
106 void QWKPagePrivate::init(QGraphicsItem* view, QGraphicsWKView::BackingStoreType backingStoreType)
107 {
108     this->view = view;
109     this->backingStoreType = backingStoreType;
110     page->initializeWebPage();
111 }
112
113 void QWKPagePrivate::setCursor(const WebCore::Cursor& cursor)
114 {
115 #ifndef QT_NO_CURSOR
116     emit q->cursorChanged(*cursor.platformCursor());
117 #endif
118 }
119
120 void QWKPagePrivate::setViewportArguments(const ViewportArguments& args)
121 {
122     viewportArguments = args;
123     emit q->viewportChangeRequested();
124 }
125
126 void QWKPagePrivate::takeFocus(bool direction)
127 {
128     emit q->focusNextPrevChild(direction);
129 }
130
131 PassOwnPtr<DrawingAreaProxy> QWKPagePrivate::createDrawingAreaProxy()
132 {
133     // FIXME: We should avoid this cast by decoupling the view from the page.
134     QGraphicsWKView* wkView = static_cast<QGraphicsWKView*>(view);
135
136 #if ENABLE(TILED_BACKING_STORE)
137     if (backingStoreType == QGraphicsWKView::Tiled)
138         return TiledDrawingAreaProxy::create(wkView, page.get());
139 #endif
140     return ChunkedUpdateDrawingAreaProxy::create(wkView, page.get());
141 }
142
143 void QWKPagePrivate::setViewNeedsDisplay(const WebCore::IntRect& rect)
144 {
145     view->update(QRect(rect));
146 }
147
148 void QWKPagePrivate::displayView()
149 {
150     // FIXME: Implement.
151 }
152
153 void QWKPagePrivate::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset)
154 {
155     // FIXME: Implement.
156 }
157
158 WebCore::IntSize QWKPagePrivate::viewSize()
159 {
160     // FIXME: Implement.
161     return WebCore::IntSize();
162 }
163
164 bool QWKPagePrivate::isViewWindowActive()
165 {
166     // FIXME: Implement.
167     return true;
168 }
169
170 bool QWKPagePrivate::isViewFocused()
171 {
172     // FIXME: Implement.
173     return true;
174 }
175
176 bool QWKPagePrivate::isViewVisible()
177 {
178     // FIXME: Implement.
179     return true;
180 }
181
182 bool QWKPagePrivate::isViewInWindow()
183 {
184     // FIXME: Implement.
185     return true;
186 }
187
188 void QWKPagePrivate::enterAcceleratedCompositingMode(const LayerTreeContext&)
189 {
190     // FIXME: Implement.
191 }
192
193 void QWKPagePrivate::exitAcceleratedCompositingMode()
194 {
195     // FIXME: Implement.
196 }
197
198 void QWKPagePrivate::pageDidRequestScroll(const IntSize& delta)
199 {
200     emit q->scrollRequested(delta.width(), delta.height());
201 }
202
203 void QWKPagePrivate::didChangeContentsSize(const IntSize& newSize)
204 {
205     emit q->contentsSizeChanged(QSize(newSize));
206 }
207
208 void QWKPagePrivate::toolTipChanged(const String&, const String& newTooltip)
209 {
210     emit q->statusBarMessage(QString(newTooltip));
211 }
212
213 void QWKPagePrivate::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
214 {
215 }
216
217 void QWKPagePrivate::clearAllEditCommands()
218 {
219 }
220
221 FloatRect QWKPagePrivate::convertToDeviceSpace(const FloatRect& rect)
222 {
223     return rect;
224 }
225
226 FloatRect QWKPagePrivate::convertToUserSpace(const FloatRect& rect)
227 {
228     return rect;
229 }
230
231 void QWKPagePrivate::selectionChanged(bool, bool, bool, bool)
232 {
233 }
234
235 void QWKPagePrivate::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
236 {
237 }
238
239 PassRefPtr<WebPopupMenuProxy> QWKPagePrivate::createPopupMenuProxy(WebPageProxy*)
240 {
241     return WebPopupMenuProxyQt::create();
242 }
243
244 PassRefPtr<WebContextMenuProxy> QWKPagePrivate::createContextMenuProxy(WebPageProxy*)
245 {
246     return WebContextMenuProxyQt::create(q);
247 }
248
249 void QWKPagePrivate::setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut)
250 {
251 }
252
253 void QWKPagePrivate::didCommitLoadForMainFrame(bool useCustomRepresentation)
254 {
255 }
256
257 void QWKPagePrivate::didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&)
258 {
259 }
260
261 void QWKPagePrivate::paint(QPainter* painter, QRect area)
262 {
263     if (page->isValid() && page->drawingArea())
264         page->drawingArea()->paint(IntRect(area), painter);
265     else
266         painter->fillRect(area, Qt::white);
267 }
268
269 void QWKPagePrivate::keyPressEvent(QKeyEvent* ev)
270 {
271     page->handleKeyboardEvent(NativeWebKeyboardEvent(ev));
272 }
273
274 void QWKPagePrivate::keyReleaseEvent(QKeyEvent* ev)
275 {
276     page->handleKeyboardEvent(NativeWebKeyboardEvent(ev));
277 }
278
279 void QWKPagePrivate::mouseMoveEvent(QGraphicsSceneMouseEvent* ev)
280 {
281     // For some reason mouse press results in mouse hover (which is
282     // converted to mouse move for WebKit). We ignore these hover
283     // events by comparing lastPos with newPos.
284     // NOTE: lastPos from the event always comes empty, so we work
285     // around that here.
286     static QPointF lastPos = QPointF();
287     if (lastPos == ev->pos())
288         return;
289     lastPos = ev->pos();
290
291     WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 0);
292     page->handleMouseEvent(mouseEvent);
293 }
294
295 void QWKPagePrivate::mousePressEvent(QGraphicsSceneMouseEvent* ev)
296 {
297     if (tripleClickTimer.isActive() && (ev->pos() - tripleClick).manhattanLength() < QApplication::startDragDistance()) {
298         WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 3);
299         page->handleMouseEvent(mouseEvent);
300         return;
301     }
302
303     WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 1);
304     page->handleMouseEvent(mouseEvent);
305 }
306
307 void QWKPagePrivate::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev)
308 {
309     WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 0);
310     page->handleMouseEvent(mouseEvent);
311 }
312
313 void QWKPagePrivate::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev)
314 {
315     WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 2);
316     page->handleMouseEvent(mouseEvent);
317
318     tripleClickTimer.start(QApplication::doubleClickInterval(), q);
319     tripleClick = ev->pos().toPoint();
320 }
321
322 void QWKPagePrivate::wheelEvent(QGraphicsSceneWheelEvent* ev)
323 {
324     WebWheelEvent wheelEvent = WebEventFactory::createWebWheelEvent(ev);
325     page->handleWheelEvent(wheelEvent);
326 }
327
328 void QWKPagePrivate::setEditCommandState(const WTF::String&, bool, int)
329 {
330 }
331
332 void QWKPagePrivate::updateAction(QWKPage::WebAction action)
333 {
334 #ifdef QT_NO_ACTION
335     Q_UNUSED(action)
336 #else
337     QAction* a = actions[action];
338     if (!a)
339         return;
340
341     RefPtr<WebKit::WebFrameProxy> mainFrame = page->mainFrame();
342     if (!mainFrame)
343         return;
344
345     bool enabled = a->isEnabled();
346     bool checked = a->isChecked();
347
348     switch (action) {
349     case QWKPage::Back:
350         enabled = page->canGoBack();
351         break;
352     case QWKPage::Forward:
353         enabled = page->canGoForward();
354         break;
355     case QWKPage::Stop:
356         enabled = !(WebFrameProxy::LoadStateFinished == mainFrame->loadState());
357         break;
358     case QWKPage::Reload:
359         enabled = (WebFrameProxy::LoadStateFinished == mainFrame->loadState());
360         break;
361     default:
362         break;
363     }
364
365     a->setEnabled(enabled);
366
367     if (a->isCheckable())
368         a->setChecked(checked);
369 #endif // QT_NO_ACTION
370 }
371
372 void QWKPagePrivate::updateNavigationActions()
373 {
374     updateAction(QWKPage::Back);
375     updateAction(QWKPage::Forward);
376     updateAction(QWKPage::Stop);
377     updateAction(QWKPage::Reload);
378 }
379
380 #ifndef QT_NO_ACTION
381 void QWKPagePrivate::_q_webActionTriggered(bool checked)
382 {
383     QAction* a = qobject_cast<QAction*>(q->sender());
384     if (!a)
385         return;
386     QWKPage::WebAction action = static_cast<QWKPage::WebAction>(a->data().toInt());
387     q->triggerAction(action, checked);
388 }
389 #endif // QT_NO_ACTION
390
391 void QWKPagePrivate::touchEvent(QTouchEvent* event)
392 {
393 #if ENABLE(TOUCH_EVENTS)
394     WebTouchEvent touchEvent = WebEventFactory::createWebTouchEvent(event);
395     page->handleTouchEvent(touchEvent);
396 #else
397     event->ignore();
398 #endif
399 }
400
401 void QWKPagePrivate::didRelaunchProcess()
402 {
403     QGraphicsWKView* wkView = static_cast<QGraphicsWKView*>(view);
404     if (wkView)
405         q->setViewportSize(wkView->size().toSize());
406
407     isConnectedToEngine = true;
408     emit q->engineConnectionChanged(true);
409 }
410
411 void QWKPagePrivate::processDidCrash()
412 {
413     isConnectedToEngine = false;
414     emit q->engineConnectionChanged(false);
415 }
416
417 QWKPage::QWKPage(QWKContext* context)
418     : d(new QWKPagePrivate(this, context))
419 {
420     WKPageLoaderClient loadClient = {
421         0,      /* version */
422         this,   /* clientInfo */
423         qt_wk_didStartProvisionalLoadForFrame,
424         qt_wk_didReceiveServerRedirectForProvisionalLoadForFrame,
425         qt_wk_didFailProvisionalLoadWithErrorForFrame,
426         qt_wk_didCommitLoadForFrame,
427         qt_wk_didFinishDocumentLoadForFrame,
428         qt_wk_didFinishLoadForFrame,
429         qt_wk_didFailLoadWithErrorForFrame,
430         0, /* didSameDocumentNavigationForFrame */
431         qt_wk_didReceiveTitleForFrame,
432         qt_wk_didFirstLayoutForFrame,
433         qt_wk_didFirstVisuallyNonEmptyLayoutForFrame,
434         qt_wk_didRemoveFrameFromHierarchy,
435         0, /* didDisplayInsecureContentForFrame */
436         0, /* didRunInsecureContentForFrame */
437         0, /* canAuthenticateAgainstProtectionSpaceInFrame */
438         0, /* didReceiveAuthenticationChallengeInFrame */
439         qt_wk_didStartProgress,
440         qt_wk_didChangeProgress,
441         qt_wk_didFinishProgress,
442         qt_wk_didBecomeUnresponsive,
443         qt_wk_didBecomeResponsive,
444         0,  /* processDidCrash */
445         0   /* didChangeBackForwardList */
446     };
447     WKPageSetPageLoaderClient(pageRef(), &loadClient);
448
449     WKPageUIClient uiClient = {
450         0,      /* version */
451         this,   /* clientInfo */
452         qt_wk_createNewPage,
453         qt_wk_showPage,
454         qt_wk_close,
455         qt_wk_runJavaScriptAlert,
456         0,  /* runJavaScriptConfirm */
457         0,  /* runJavaScriptPrompt */
458         0,  /* setStatusText */
459         0,  /* mouseDidMoveOverElement */
460         0,  /* missingPluginButtonClicked */
461         0,  /* didNotHandleKeyEvent */
462         0,  /* toolbarsAreVisible */
463         0,  /* setToolbarsAreVisible */
464         0,  /* menuBarIsVisible */
465         0,  /* setMenuBarIsVisible */
466         0,  /* statusBarIsVisible */
467         0,  /* setStatusBarIsVisible */
468         0,  /* isResizable */
469         0,  /* setIsResizable */
470         0,  /* getWindowFrame */
471         0,  /* setWindowFrame */
472         0,  /* runBeforeUnloadConfirmPanel */
473         0,  /* didDraw */
474         0,  /* pageDidScroll */
475         0,  /* exceededDatabaseQuota */
476         0,  /* runOpenPanel */
477         0,  /* decidePolicyForGeolocationPermissionRequest */
478         0,  /* headerHeight */
479         0,  /* footerHeight */
480         0,  /* drawHeader */
481         0,  /* drawFooter */
482         0,  /* printFrame */
483         0,  /* runModal */
484         0   /* didCompleteRubberBandForMainFrame */
485     };
486     WKPageSetPageUIClient(pageRef(), &uiClient);
487 }
488
489 QWKPage::~QWKPage()
490 {
491     delete d;
492 }
493
494 QWKPage::ViewportAttributes::ViewportAttributes()
495     : d(0)
496     , m_initialScaleFactor(-1.0)
497     , m_minimumScaleFactor(-1.0)
498     , m_maximumScaleFactor(-1.0)
499     , m_devicePixelRatio(-1.0)
500     , m_isUserScalable(true)
501     , m_isValid(false)
502 {
503
504 }
505
506 QWKPage::ViewportAttributes::ViewportAttributes(const QWKPage::ViewportAttributes& other)
507     : d(other.d)
508     , m_initialScaleFactor(other.m_initialScaleFactor)
509     , m_minimumScaleFactor(other.m_minimumScaleFactor)
510     , m_maximumScaleFactor(other.m_maximumScaleFactor)
511     , m_devicePixelRatio(other.m_devicePixelRatio)
512     , m_isUserScalable(other.m_isUserScalable)
513     , m_isValid(other.m_isValid)
514     , m_size(other.m_size)
515 {
516
517 }
518
519 QWKPage::ViewportAttributes::~ViewportAttributes()
520 {
521
522 }
523
524 QWKPage::ViewportAttributes& QWKPage::ViewportAttributes::operator=(const QWKPage::ViewportAttributes& other)
525 {
526     if (this != &other) {
527         d = other.d;
528         m_initialScaleFactor = other.m_initialScaleFactor;
529         m_minimumScaleFactor = other.m_minimumScaleFactor;
530         m_maximumScaleFactor = other.m_maximumScaleFactor;
531         m_devicePixelRatio = other.m_devicePixelRatio;
532         m_isUserScalable = other.m_isUserScalable;
533         m_isValid = other.m_isValid;
534         m_size = other.m_size;
535     }
536
537     return *this;
538 }
539
540 QWKPage::ViewportAttributes QWKPage::viewportAttributesForSize(const QSize& availableSize) const
541 {
542     static int desktopWidth = 980;
543     static int deviceDPI = 160;
544
545     ViewportAttributes result;
546
547      if (availableSize.isEmpty())
548          return result; // Returns an invalid instance.
549
550     // FIXME: Add a way to get these data via the platform plugin and fall back
551     // to the size of the view.
552     int deviceWidth = 480;
553     int deviceHeight = 864;
554
555     WebCore::ViewportAttributes conf = WebCore::computeViewportAttributes(d->viewportArguments, desktopWidth, deviceWidth, deviceHeight, deviceDPI, availableSize);
556
557     result.m_isValid = true;
558     result.m_size = conf.layoutSize;
559     result.m_initialScaleFactor = conf.initialScale;
560     result.m_minimumScaleFactor = conf.minimumScale;
561     result.m_maximumScaleFactor = conf.maximumScale;
562     result.m_devicePixelRatio = conf.devicePixelRatio;
563     result.m_isUserScalable = conf.userScalable;
564
565     return result;
566 }
567
568 void QWKPage::setActualVisibleContentsRect(const QRect& rect) const
569 {
570 #if ENABLE(TILED_BACKING_STORE)
571     d->page->setActualVisibleContentRect(rect);
572 #endif
573 }
574
575 void QWKPage::timerEvent(QTimerEvent* ev)
576 {
577     int timerId = ev->timerId();
578     if (timerId == d->tripleClickTimer.timerId())
579         d->tripleClickTimer.stop();
580     else
581         QObject::timerEvent(ev);
582 }
583
584 WKPageRef QWKPage::pageRef() const
585 {
586     return toAPI(d->page.get());
587 }
588
589 QWKContext* QWKPage::context() const
590 {
591     return d->context;
592 }
593
594 QWKPreferences* QWKPage::preferences() const
595 {
596     if (!d->preferences) {
597         WKPageGroupRef pageGroupRef = WKPageGetPageGroup(pageRef());
598         d->preferences = QWKPreferencesPrivate::createPreferences(pageGroupRef);
599     }
600
601     return d->preferences;
602 }
603
604 void QWKPage::setCreateNewPageFunction(CreateNewPageFn function)
605 {
606     d->createNewPageFn = function;
607 }
608
609 void QWKPage::setCustomUserAgent(const QString& userAgent)
610 {
611     WKRetainPtr<WKStringRef> wkUserAgent(WKStringCreateWithQString(userAgent));
612     WKPageSetCustomUserAgent(pageRef(), wkUserAgent.get());
613 }
614
615 QString QWKPage::customUserAgent() const
616 {
617     return WKStringCopyQString(WKPageCopyCustomUserAgent(pageRef()));
618 }
619
620 void QWKPage::load(const QUrl& url)
621 {
622     WKRetainPtr<WKURLRef> wkurl(WKURLCreateWithQUrl(url));
623     WKPageLoadURL(pageRef(), wkurl.get());
624 }
625
626 void QWKPage::setUrl(const QUrl& url)
627 {
628     load(url);
629 }
630
631 QUrl QWKPage::url() const
632 {
633     WKRetainPtr<WKFrameRef> frame = WKPageGetMainFrame(pageRef());
634     if (!frame)
635         return QUrl();
636     return WKURLCopyQUrl(WKFrameCopyURL(frame.get()));
637 }
638
639 QString QWKPage::title() const
640 {
641     return WKStringCopyQString(WKPageCopyTitle(pageRef()));
642 }
643
644 void QWKPage::setViewportSize(const QSize& size)
645 {
646     if (d->page->drawingArea())
647         d->page->drawingArea()->setSize(IntSize(size), IntSize());
648 }
649
650 qreal QWKPage::textZoomFactor() const
651 {
652     return WKPageGetTextZoomFactor(pageRef());
653 }
654
655 void QWKPage::setTextZoomFactor(qreal zoomFactor)
656 {
657     WKPageSetTextZoomFactor(pageRef(), zoomFactor);
658 }
659
660 qreal QWKPage::pageZoomFactor() const
661 {
662     return WKPageGetPageZoomFactor(pageRef());
663 }
664
665 void QWKPage::setPageZoomFactor(qreal zoomFactor)
666 {
667     WKPageSetPageZoomFactor(pageRef(), zoomFactor);
668 }
669
670 void QWKPage::setPageAndTextZoomFactors(qreal pageZoomFactor, qreal textZoomFactor)
671 {
672     WKPageSetPageAndTextZoomFactors(pageRef(), pageZoomFactor, textZoomFactor);
673 }
674
675 QWKHistory* QWKPage::history() const
676 {
677     return d->history;
678 }
679
680 void QWKPage::setResizesToContentsUsingLayoutSize(const QSize& targetLayoutSize)
681 {
682 #if ENABLE(TILED_BACKING_STORE)
683     d->page->setResizesToContentsUsingLayoutSize(targetLayoutSize);
684 #endif
685 }
686
687 #ifndef QT_NO_ACTION
688 void QWKPage::triggerAction(WebAction webAction, bool)
689 {
690     switch (webAction) {
691     case Back:
692         d->page->goBack();
693         return;
694     case Forward:
695         d->page->goForward();
696         return;
697     case Stop:
698         d->page->stopLoading();
699         return;
700     case Reload:
701         d->page->reload(/* reloadFromOrigin */ true);
702         return;
703     default:
704         break;
705     }
706
707     QAction* qtAction = action(webAction);
708     WebKit::WebContextMenuItemData menuItemData(ActionType, contextMenuActionForWebAction(webAction), qtAction->text(), qtAction->isEnabled(), qtAction->isChecked());
709     d->page->contextMenuItemSelected(menuItemData);
710 }
711 #endif // QT_NO_ACTION
712
713 #ifndef QT_NO_ACTION
714 QAction* QWKPage::action(WebAction action) const
715 {
716     if (action == QWKPage::NoWebAction || action >= WebActionCount)
717         return 0;
718
719     if (d->actions[action])
720         return d->actions[action];
721
722     QString text;
723     QIcon icon;
724     QStyle* style = qobject_cast<QApplication*>(QCoreApplication::instance())->style();
725     bool checkable = false;
726
727     switch (action) {
728     case OpenLink:
729         text = contextMenuItemTagOpenLink();
730         break;
731     case OpenLinkInNewWindow:
732         text = contextMenuItemTagOpenLinkInNewWindow();
733         break;
734     case CopyLinkToClipboard:
735         text = contextMenuItemTagCopyLinkToClipboard();
736         break;
737     case OpenImageInNewWindow:
738         text = contextMenuItemTagOpenImageInNewWindow();
739         break;
740     case Back:
741         text = contextMenuItemTagGoBack();
742         icon = style->standardIcon(QStyle::SP_ArrowBack);
743         break;
744     case Forward:
745         text = contextMenuItemTagGoForward();
746         icon = style->standardIcon(QStyle::SP_ArrowForward);
747         break;
748     case Stop:
749         text = contextMenuItemTagStop();
750         icon = style->standardIcon(QStyle::SP_BrowserStop);
751         break;
752     case Reload:
753         text = contextMenuItemTagReload();
754         icon = style->standardIcon(QStyle::SP_BrowserReload);
755         break;
756     case Cut:
757         text = contextMenuItemTagCut();
758         break;
759     case Copy:
760         text = contextMenuItemTagCopy();
761         break;
762     case Paste:
763         text = contextMenuItemTagPaste();
764         break;
765     case SelectAll:
766         text = contextMenuItemTagSelectAll();
767         break;
768     default:
769         return 0;
770         break;
771     }
772
773     if (text.isEmpty())
774         return 0;
775
776     QAction* a = new QAction(d->q);
777     a->setText(text);
778     a->setData(action);
779     a->setCheckable(checkable);
780     a->setIcon(icon);
781
782     connect(a, SIGNAL(triggered(bool)), this, SLOT(_q_webActionTriggered(bool)));
783
784     d->actions[action] = a;
785     d->updateAction(action);
786     return a;
787 }
788 #endif // QT_NO_ACTION
789
790 void QWKPage::findZoomableAreaForPoint(const QPoint& point)
791 {
792     d->page->findZoomableAreaForPoint(point);
793 }
794
795 void QWKPagePrivate::didFindZoomableArea(const IntRect& area)
796 {
797     emit q->zoomableAreaFound(QRect(area));
798 }
799
800 bool QWKPage::isConnectedToEngine() const
801 {
802     return d->isConnectedToEngine;
803 }
804
805 #include "moc_qwkpage.cpp"