2 * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies)
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.
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.
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.
21 #ifndef QtWebPageProxy_h
22 #define QtWebPageProxy_h
24 #include "LayerTreeContext.h"
25 #include "PageClient.h"
26 #include "QtPolicyInterface.h"
27 #include "QtViewInterface.h"
28 #include "ShareableBitmap.h"
29 #include "ViewportArguments.h"
30 #include "WebContext.h"
31 #include "WebPageProxy.h"
32 #include <wtf/RefPtr.h>
33 #include <QBasicTimer>
34 #include <QGraphicsView>
37 #include <QSharedPointer>
44 class QWebPreferences;
47 using namespace WebKit;
49 WebCore::DragOperation dropActionToDragOperation(Qt::DropActions actions);
51 // FIXME: needs focus in/out, window activation, support through viewStateDidChange().
52 class QtWebPageProxy : public QObject, WebKit::PageClient {
70 QtWebPageProxy(WebKit::QtViewInterface*, WebKit::QtPolicyInterface* = 0, WKContextRef = 0, WKPageGroupRef = 0);
73 virtual bool handleEvent(QEvent*);
76 virtual void setViewNeedsDisplay(const WebCore::IntRect&);
77 virtual void displayView();
78 virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
80 virtual WebCore::IntSize viewSize();
81 virtual bool isViewWindowActive();
82 virtual bool isViewFocused();
83 virtual bool isViewVisible();
84 virtual bool isViewInWindow();
86 #if USE(ACCELERATED_COMPOSITING)
87 virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
88 virtual void exitAcceleratedCompositingMode();
89 #endif // USE(ACCELERATED_COMPOSITING)
90 virtual void pageDidRequestScroll(const WebCore::IntPoint&);
91 virtual void processDidCrash();
92 virtual void pageClosed() { }
93 virtual void didRelaunchProcess();
94 virtual void didChangeContentsSize(const WebCore::IntSize&);
96 virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
97 virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
98 virtual void setCursor(const WebCore::Cursor&);
99 virtual void setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves);
100 virtual void toolTipChanged(const WTF::String&, const WTF::String&);
101 virtual void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo);
102 virtual void clearAllEditCommands();
103 virtual bool canUndoRedo(WebPageProxy::UndoOrRedo);
104 virtual void executeUndoRedo(WebPageProxy::UndoOrRedo);
105 virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
106 virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
107 virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&);
108 virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&);
110 virtual void doneWithKeyEvent(const WebKit::NativeWebKeyboardEvent&, bool wasEventHandled);
111 virtual void selectionChanged(bool, bool, bool, bool);
112 virtual PassRefPtr<WebKit::WebPopupMenuProxy> createPopupMenuProxy(WebKit::WebPageProxy*);
113 virtual PassRefPtr<WebKit::WebContextMenuProxy> createContextMenuProxy(WebKit::WebPageProxy*);
115 virtual void setFindIndicator(PassRefPtr<WebKit::FindIndicator>, bool fadeOut);
117 virtual void didCommitLoadForMainFrame(bool useCustomRepresentation);
118 virtual void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&);
119 virtual double customRepresentationZoomFactor() { return 1; }
120 virtual void setCustomRepresentationZoomFactor(double) { }
121 virtual void didChangeScrollbarsForMainFrame() const { }
123 virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);
124 virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) { }
125 virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) { }
127 virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&);
129 void didChangeUrl(const QUrl&);
130 void didChangeTitle(const QString&);
133 void loadDidCommit();
134 void loadDidSucceed();
135 void loadDidFail(const QtWebError&);
136 void didChangeLoadProgress(int);
137 int loadProgress() const { return m_loadProgress; }
139 void paint(QPainter*, const QRect&);
141 bool canGoBack() const;
143 bool canGoForward() const;
145 bool canStop() const;
147 bool canReload() const;
150 void updateEditorActions();
152 WKPageRef pageRef() const;
154 void load(const QUrl& url);
157 void setDrawingAreaSize(const QSize&);
159 QWebPreferences* preferences() const;
161 QString title() const;
163 void setCustomUserAgent(const QString&);
164 QString customUserAgent() const;
166 qreal textZoomFactor() const;
167 qreal pageZoomFactor() const;
168 void setTextZoomFactor(qreal zoomFactor);
169 void setPageZoomFactor(qreal zoomFactor);
170 void setPageAndTextZoomFactors(qreal pageZoomFactor, qreal textZoomFactor);
172 QWKHistory* history() const;
175 void navigationStateChanged();
178 Q_SIGNAL void scrollRequested(int dx, int dy);
179 Q_SIGNAL void zoomableAreaFound(const QRect&);
180 Q_SIGNAL void updateNavigationState();
185 virtual void paintContent(QPainter* painter, const QRect& area) = 0;
186 RefPtr<WebKit::WebPageProxy> m_webPageProxy;
187 WebKit::QtViewInterface* const m_viewInterface;
188 WebKit::QtPolicyInterface* const m_policyInterface;
191 bool handleKeyPressEvent(QKeyEvent*);
192 bool handleKeyReleaseEvent(QKeyEvent*);
193 bool handleFocusInEvent(QFocusEvent*);
194 bool handleFocusOutEvent(QFocusEvent*);
196 static PassRefPtr<WebContext> defaultWKContext();
197 static RefPtr<WebContext> s_defaultContext;
198 static unsigned s_defaultPageProxyCount;
200 RefPtr<WebContext> m_context;
201 QWKHistory* m_history;
203 mutable QWebPreferences* m_preferences;
205 OwnPtr<QUndoStack> m_undoStack;
209 #endif /* QtWebPageProxy_h */