|
1 /* |
|
2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
|
3 * |
|
4 * Redistribution and use in source and binary forms, with or without |
|
5 * modification, are permitted provided that the following conditions |
|
6 * are met: |
|
7 * 1. Redistributions of source code must retain the above copyright |
|
8 * notice, this list of conditions and the following disclaimer. |
|
9 * 2. Redistributions in binary form must reproduce the above copyright |
|
10 * notice, this list of conditions and the following disclaimer in the |
|
11 * documentation and/or other materials provided with the distribution. |
|
12 * |
|
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
|
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
|
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
|
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|
23 * THE POSSIBILITY OF SUCH DAMAGE. |
|
24 */ |
|
25 |
|
26 #ifndef WebPage_h |
|
27 #define WebPage_h |
|
28 |
|
29 #include "DrawingArea.h" |
|
30 #include "InjectedBundlePageLoaderClient.h" |
|
31 #include "InjectedBundlePageUIClient.h" |
|
32 #include <WebCore/FrameLoaderTypes.h> |
|
33 #include <WebCore/IntRect.h> |
|
34 #include <wtf/HashMap.h> |
|
35 #include <wtf/OwnPtr.h> |
|
36 #include <wtf/PassRefPtr.h> |
|
37 #include <wtf/RefCounted.h> |
|
38 #include <wtf/RefPtr.h> |
|
39 |
|
40 namespace CoreIPC { |
|
41 class ArgumentDecoder; |
|
42 class Connection; |
|
43 class MessageID; |
|
44 } |
|
45 |
|
46 namespace WebCore { |
|
47 class GraphicsContext; |
|
48 class KeyboardEvent; |
|
49 class Page; |
|
50 class PlatformKeyboardEvent; |
|
51 class PlatformMouseEvent; |
|
52 class PlatformWheelEvent; |
|
53 class String; |
|
54 } |
|
55 |
|
56 namespace WebKit { |
|
57 |
|
58 class DrawingArea; |
|
59 class WebFrame; |
|
60 struct WebPreferencesStore; |
|
61 |
|
62 class WebPage : public RefCounted<WebPage> { |
|
63 public: |
|
64 static PassRefPtr<WebPage> create(uint64_t pageID, const WebCore::IntSize& viewSize, const WebPreferencesStore&, DrawingArea::Type); |
|
65 ~WebPage(); |
|
66 |
|
67 void close(); |
|
68 |
|
69 WebCore::Page* corePage() const { return m_page; } |
|
70 uint64_t pageID() const { return m_pageID; } |
|
71 |
|
72 WebFrame* webFrame(uint64_t) const; |
|
73 void addWebFrame(uint64_t, WebFrame*); |
|
74 void removeWebFrame(uint64_t); |
|
75 |
|
76 void setSize(const WebCore::IntSize&); |
|
77 const WebCore::IntSize& size() const { return m_viewSize; } |
|
78 |
|
79 DrawingArea* drawingArea() const { return m_drawingArea.get(); } |
|
80 |
|
81 // -- Called by the DrawingArea. |
|
82 // FIXME: We could genericize these into a DrawingArea client interface. Would that be beneficial? |
|
83 void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect&); |
|
84 void layoutIfNeeded(); |
|
85 |
|
86 // -- Called from WebCore clients. |
|
87 bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*); |
|
88 void show(); |
|
89 |
|
90 // -- Called from WebProcess. |
|
91 void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder&); |
|
92 |
|
93 // -- InjectedBundle methods |
|
94 void initializeInjectedBundleLoaderClient(WKBundlePageLoaderClient*); |
|
95 void initializeInjectedBundleUIClient(WKBundlePageUIClient*); |
|
96 |
|
97 InjectedBundlePageLoaderClient& injectedBundleLoaderClient() { return m_loaderClient; } |
|
98 InjectedBundlePageUIClient& injectedBundleUIClient() { return m_uiClient; } |
|
99 |
|
100 WebFrame* mainFrame() const { return m_mainFrame.get(); } |
|
101 WebCore::String renderTreeExternalRepresentation() const; |
|
102 |
|
103 #if USE(ACCELERATED_COMPOSITING) |
|
104 void changeAcceleratedCompositingMode(WebCore::GraphicsLayer*); |
|
105 void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*); |
|
106 void exitAcceleratedCompositingMode(); |
|
107 #endif |
|
108 |
|
109 private: |
|
110 WebPage(uint64_t pageID, const WebCore::IntSize& viewSize, const WebPreferencesStore&, DrawingArea::Type); |
|
111 |
|
112 void platformInitialize(); |
|
113 static const char* interpretKeyEvent(const WebCore::KeyboardEvent*); |
|
114 |
|
115 // Actions |
|
116 void tryClose(); |
|
117 void loadURL(const WebCore::String&); |
|
118 void stopLoading(); |
|
119 void reload(bool reloadFromOrigin); |
|
120 void goForward(uint64_t); |
|
121 void goBack(uint64_t); |
|
122 void goToBackForwardItem(uint64_t); |
|
123 void setActive(bool); |
|
124 void setFocused(bool); |
|
125 void setIsInWindow(bool); |
|
126 void mouseEvent(const WebCore::PlatformMouseEvent&); |
|
127 void wheelEvent(WebCore::PlatformWheelEvent&); |
|
128 void keyEvent(const WebCore::PlatformKeyboardEvent&); |
|
129 void runJavaScriptInMainFrame(const WebCore::String&, uint64_t callbackID); |
|
130 void getRenderTreeExternalRepresentation(uint64_t callbackID); |
|
131 void preferencesDidChange(const WebPreferencesStore&); |
|
132 void didReceivePolicyDecision(WebFrame*, uint64_t listenerID, WebCore::PolicyAction policyAction); |
|
133 |
|
134 WebCore::Page* m_page; |
|
135 RefPtr<WebFrame> m_mainFrame; |
|
136 HashMap<uint64_t, WebFrame*> m_frameMap; |
|
137 |
|
138 WebCore::IntSize m_viewSize; |
|
139 OwnPtr<DrawingArea> m_drawingArea; |
|
140 |
|
141 InjectedBundlePageLoaderClient m_loaderClient; |
|
142 InjectedBundlePageUIClient m_uiClient; |
|
143 |
|
144 uint64_t m_pageID; |
|
145 }; |
|
146 |
|
147 } // namespace WebKit |
|
148 |
|
149 #endif // WebPage_h |