qwkpage_p.h revision 2fc2651226baac27029e38c9d6ef883fa32084db
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#ifndef qwkpage_p_h 22#define qwkpage_p_h 23 24#include "DrawingAreaProxy.h" 25#include "LayerTreeContext.h" 26#include "PageClient.h" 27#include "qwkpage.h" 28#include "qgraphicswkview.h" 29#include "WebPageProxy.h" 30#include <wtf/PassOwnPtr.h> 31#include <wtf/RefPtr.h> 32#include <QBasicTimer> 33#include <QGraphicsView> 34#include <QKeyEvent> 35 36class QGraphicsWKView; 37class QWKPreferences; 38 39using namespace WebKit; 40 41class QWKPagePrivate : WebKit::PageClient { 42public: 43 QWKPagePrivate(QWKPage*, QWKContext*); 44 ~QWKPagePrivate(); 45 46 static QWKPagePrivate* get(QWKPage* page) { return page->d; } 47 48 void init(QGraphicsItem*, QGraphicsWKView::BackingStoreType); 49 50 // PageClient 51 virtual PassOwnPtr<WebKit::DrawingAreaProxy> createDrawingAreaProxy(); 52 virtual void setViewNeedsDisplay(const WebCore::IntRect&); 53 virtual void displayView(); 54 virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); 55 56 virtual WebCore::IntSize viewSize(); 57 virtual bool isViewWindowActive(); 58 virtual bool isViewFocused(); 59 virtual bool isViewVisible(); 60 virtual bool isViewInWindow(); 61 62#if USE(ACCELERATED_COMPOSITING) 63 virtual void enterAcceleratedCompositingMode(const LayerTreeContext&); 64 virtual void exitAcceleratedCompositingMode(); 65 void pageDidEnterAcceleratedCompositing() { } 66 void pageDidLeaveAcceleratedCompositing() { } 67#endif // USE(ACCELERATED_COMPOSITING) 68 virtual void pageDidRequestScroll(const WebCore::IntSize&); 69 virtual void processDidCrash(); 70 virtual void pageClosed() { } 71 virtual void didRelaunchProcess(); 72 virtual void didChangeContentsSize(const WebCore::IntSize&); 73 virtual void didFindZoomableArea(const WebCore::IntRect&); 74 virtual void setCursor(const WebCore::Cursor&); 75 virtual void setViewportArguments(const WebCore::ViewportArguments&); 76 virtual void takeFocus(bool direction); 77 virtual void toolTipChanged(const WTF::String&, const WTF::String&); 78 virtual void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo); 79 virtual void clearAllEditCommands(); 80 virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&); 81 virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&); 82 virtual void doneWithKeyEvent(const WebKit::NativeWebKeyboardEvent&, bool wasEventHandled); 83 virtual void selectionChanged(bool, bool, bool, bool); 84 virtual PassRefPtr<WebKit::WebPopupMenuProxy> createPopupMenuProxy(WebKit::WebPageProxy*); 85 virtual PassRefPtr<WebKit::WebContextMenuProxy> createContextMenuProxy(WebKit::WebPageProxy*); 86 87 virtual void setFindIndicator(PassRefPtr<WebKit::FindIndicator>, bool fadeOut); 88 89 virtual void didCommitLoadForMainFrame(bool useCustomRepresentation); 90 virtual void didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&); 91 virtual double customRepresentationZoomFactor() { return 1; } 92 virtual void setCustomRepresentationZoomFactor(double) { } 93 virtual void didChangeScrollbarsForMainFrame() const { } 94 95 void paint(QPainter* painter, QRect); 96 97 void keyPressEvent(QKeyEvent*); 98 void keyReleaseEvent(QKeyEvent*); 99 void mouseMoveEvent(QGraphicsSceneMouseEvent*); 100 void mousePressEvent(QGraphicsSceneMouseEvent*); 101 void mouseReleaseEvent(QGraphicsSceneMouseEvent*); 102 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*); 103 void wheelEvent(QGraphicsSceneWheelEvent*); 104 105 void updateAction(QWKPage::WebAction action); 106 void updateNavigationActions(); 107 void updateEditorActions(); 108 void setEditCommandState(const WTF::String&, bool, int); 109 110 void _q_webActionTriggered(bool checked); 111 112 void touchEvent(QTouchEvent*); 113 114 QWKPage* q; 115 116 QGraphicsItem* view; 117 QWKContext* context; 118 QWKHistory* history; 119 120 QAction* actions[QWKPage::WebActionCount]; 121 QWKPreferences* preferences; 122 123 RefPtr<WebKit::WebPageProxy> page; 124 125 WebCore::ViewportArguments viewportArguments; 126 127 QWKPage::CreateNewPageFn createNewPageFn; 128 129 QPoint tripleClick; 130 QBasicTimer tripleClickTimer; 131 QGraphicsWKView::BackingStoreType backingStoreType; 132 133 bool isConnectedToEngine; 134}; 135 136class QtViewportAttributesPrivate : public QSharedData { 137public: 138 QtViewportAttributesPrivate(QWKPage::ViewportAttributes* qq) 139 : q(qq) 140 { } 141 142 QWKPage::ViewportAttributes* q; 143}; 144 145 146#endif /* qkpage_p_h */ 147