qwkpage_p.h revision 2bde8e466a4451c7319e3a072d118917957d6554
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#endif // USE(ACCELERATED_COMPOSITING) 66 virtual void pageDidRequestScroll(const WebCore::IntPoint&); 67 virtual void processDidCrash(); 68 virtual void pageClosed() { } 69 virtual void didRelaunchProcess(); 70 virtual void didChangeContentsSize(const WebCore::IntSize&); 71 virtual void didFindZoomableArea(const WebCore::IntRect&); 72 virtual void setCursor(const WebCore::Cursor&); 73 virtual void setViewportArguments(const WebCore::ViewportArguments&); 74 virtual void takeFocus(bool direction); 75 virtual void setFocus(bool focused) { } 76 virtual void toolTipChanged(const WTF::String&, const WTF::String&); 77 virtual void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo); 78 virtual void clearAllEditCommands(); 79 virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&); 80 virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&); 81 virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&); 82 83 virtual void doneWithKeyEvent(const WebKit::NativeWebKeyboardEvent&, bool wasEventHandled); 84 virtual void selectionChanged(bool, bool, bool, bool); 85 virtual PassRefPtr<WebKit::WebPopupMenuProxy> createPopupMenuProxy(WebKit::WebPageProxy*); 86 virtual PassRefPtr<WebKit::WebContextMenuProxy> createContextMenuProxy(WebKit::WebPageProxy*); 87 88 virtual void setFindIndicator(PassRefPtr<WebKit::FindIndicator>, bool fadeOut); 89 90 virtual void didCommitLoadForMainFrame(bool useCustomRepresentation); 91 virtual void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&); 92 virtual double customRepresentationZoomFactor() { return 1; } 93 virtual void setCustomRepresentationZoomFactor(double) { } 94 virtual void didChangeScrollbarsForMainFrame() const { } 95 96 virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects); 97 98 virtual float userSpaceScaleFactor() const { return 1; } 99 100 void paint(QPainter* painter, QRect); 101 102 void keyPressEvent(QKeyEvent*); 103 void keyReleaseEvent(QKeyEvent*); 104 void mouseMoveEvent(QGraphicsSceneMouseEvent*); 105 void mousePressEvent(QGraphicsSceneMouseEvent*); 106 void mouseReleaseEvent(QGraphicsSceneMouseEvent*); 107 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*); 108 void wheelEvent(QGraphicsSceneWheelEvent*); 109 110 void updateAction(QWKPage::WebAction action); 111 void updateNavigationActions(); 112 void updateEditorActions(); 113 114 void _q_webActionTriggered(bool checked); 115 116 void touchEvent(QTouchEvent*); 117 118 QWKPage* q; 119 120 QGraphicsItem* view; 121 QWKContext* context; 122 QWKHistory* history; 123 124 QAction* actions[QWKPage::WebActionCount]; 125 QWKPreferences* preferences; 126 127 RefPtr<WebKit::WebPageProxy> page; 128 129 WebCore::ViewportArguments viewportArguments; 130 131 QWKPage::CreateNewPageFn createNewPageFn; 132 133 QPoint tripleClick; 134 QBasicTimer tripleClickTimer; 135 QGraphicsWKView::BackingStoreType backingStoreType; 136 137 bool isConnectedToEngine; 138}; 139 140class QtViewportAttributesPrivate : public QSharedData { 141public: 142 QtViewportAttributesPrivate(QWKPage::ViewportAttributes* qq) 143 : q(qq) 144 { } 145 146 QWKPage::ViewportAttributes* q; 147}; 148 149 150#endif /* qkpage_p_h */ 151