|
1 /* |
|
2 * Copyright (C) 2006, 2007 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 COMPUTER, INC. ``AS IS'' AND ANY |
|
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
|
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
24 */ |
|
25 |
|
26 #ifndef WebFrame_H |
|
27 #define WebFrame_H |
|
28 |
|
29 #include "DOMCore.h" |
|
30 #include "IWebFormDelegate.h" |
|
31 #include "IWebFrame.h" |
|
32 #include "IWebFramePrivate.h" |
|
33 #include "WebDataSource.h" |
|
34 |
|
35 #pragma warning(push, 0) |
|
36 #include <WebCore/FrameLoaderClient.h> |
|
37 #include <WebCore/FrameWin.h> |
|
38 #include <WebCore/KURL.h> |
|
39 #include <WebCore/PlatformString.h> |
|
40 #include <WebCore/ResourceHandleClient.h> |
|
41 #pragma warning(pop) |
|
42 |
|
43 #include <WTF/RefPtr.h> |
|
44 #include <WTF/HashMap.h> |
|
45 |
|
46 namespace WebCore { |
|
47 class AuthenticationChallenge; |
|
48 class DocumentLoader; |
|
49 class Element; |
|
50 class Frame; |
|
51 class HTMLFrameOwnerElement; |
|
52 class IntRect; |
|
53 class Page; |
|
54 class ResourceError; |
|
55 class SharedBuffer; |
|
56 } |
|
57 |
|
58 typedef const struct OpaqueJSContext* JSContextRef; |
|
59 typedef struct OpaqueJSValue* JSObjectRef; |
|
60 |
|
61 class WebFrame; |
|
62 class WebFramePolicyListener; |
|
63 class WebHistory; |
|
64 class WebView; |
|
65 |
|
66 interface IWebHistoryItemPrivate; |
|
67 |
|
68 WebFrame* kit(WebCore::Frame*); |
|
69 WebCore::Frame* core(WebFrame*); |
|
70 |
|
71 extern const GUID IID_WebFrame; |
|
72 |
|
73 class WebFrame : public IWebFrame, IWebFramePrivate |
|
74 , public WebCore::FrameLoaderClient |
|
75 { |
|
76 public: |
|
77 static WebFrame* createInstance(); |
|
78 protected: |
|
79 WebFrame(); |
|
80 ~WebFrame(); |
|
81 |
|
82 public: |
|
83 // IUnknown |
|
84 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); |
|
85 virtual ULONG STDMETHODCALLTYPE AddRef(void); |
|
86 virtual ULONG STDMETHODCALLTYPE Release(void); |
|
87 |
|
88 //IWebFrame |
|
89 virtual HRESULT STDMETHODCALLTYPE name( |
|
90 /* [retval][out] */ BSTR *frameName); |
|
91 |
|
92 virtual HRESULT STDMETHODCALLTYPE webView( |
|
93 /* [retval][out] */ IWebView **view); |
|
94 |
|
95 virtual HRESULT STDMETHODCALLTYPE frameView( |
|
96 /* [retval][out] */ IWebFrameView **view); |
|
97 |
|
98 virtual HRESULT STDMETHODCALLTYPE DOMDocument( |
|
99 /* [retval][out] */ IDOMDocument** document); |
|
100 |
|
101 virtual HRESULT STDMETHODCALLTYPE frameElement( |
|
102 /* [retval][out] */ IDOMHTMLElement **frameElement); |
|
103 |
|
104 virtual HRESULT STDMETHODCALLTYPE loadRequest( |
|
105 /* [in] */ IWebURLRequest *request); |
|
106 |
|
107 virtual HRESULT STDMETHODCALLTYPE loadData( |
|
108 /* [in] */ IStream *data, |
|
109 /* [in] */ BSTR mimeType, |
|
110 /* [in] */ BSTR textEncodingName, |
|
111 /* [in] */ BSTR url); |
|
112 |
|
113 virtual HRESULT STDMETHODCALLTYPE loadHTMLString( |
|
114 /* [in] */ BSTR string, |
|
115 /* [in] */ BSTR baseURL); |
|
116 |
|
117 virtual HRESULT STDMETHODCALLTYPE loadAlternateHTMLString( |
|
118 /* [in] */ BSTR str, |
|
119 /* [in] */ BSTR baseURL, |
|
120 /* [in] */ BSTR unreachableURL); |
|
121 |
|
122 virtual HRESULT STDMETHODCALLTYPE loadArchive( |
|
123 /* [in] */ IWebArchive *archive); |
|
124 |
|
125 virtual HRESULT STDMETHODCALLTYPE dataSource( |
|
126 /* [retval][out] */ IWebDataSource **source); |
|
127 |
|
128 virtual HRESULT STDMETHODCALLTYPE provisionalDataSource( |
|
129 /* [retval][out] */ IWebDataSource **source); |
|
130 |
|
131 virtual HRESULT STDMETHODCALLTYPE stopLoading( void); |
|
132 |
|
133 virtual HRESULT STDMETHODCALLTYPE reload( void); |
|
134 |
|
135 virtual HRESULT STDMETHODCALLTYPE findFrameNamed( |
|
136 /* [in] */ BSTR name, |
|
137 /* [retval][out] */ IWebFrame **frame); |
|
138 |
|
139 virtual HRESULT STDMETHODCALLTYPE parentFrame( |
|
140 /* [retval][out] */ IWebFrame **frame); |
|
141 |
|
142 virtual HRESULT STDMETHODCALLTYPE childFrames( |
|
143 /* [retval][out] */ IEnumVARIANT **enumFrames); |
|
144 |
|
145 virtual HRESULT STDMETHODCALLTYPE currentForm( |
|
146 /* [retval][out] */ IDOMElement **formElement); |
|
147 |
|
148 // IWebFramePrivate |
|
149 virtual HRESULT STDMETHODCALLTYPE renderTreeAsExternalRepresentation( |
|
150 /* [retval][out] */ BSTR *result); |
|
151 |
|
152 virtual HRESULT STDMETHODCALLTYPE scrollOffset( |
|
153 /* [retval][out] */ SIZE* offset); |
|
154 |
|
155 virtual HRESULT STDMETHODCALLTYPE layout(); |
|
156 |
|
157 virtual HRESULT STDMETHODCALLTYPE firstLayoutDone( |
|
158 /* [retval][out] */ BOOL* result); |
|
159 |
|
160 virtual HRESULT STDMETHODCALLTYPE loadType( |
|
161 /* [retval][out] */ WebFrameLoadType* type); |
|
162 |
|
163 virtual HRESULT STDMETHODCALLTYPE setInPrintingMode( |
|
164 /* [in] */ BOOL value, |
|
165 /* [in] */ HDC printDC); |
|
166 |
|
167 virtual HRESULT STDMETHODCALLTYPE getPrintedPageCount( |
|
168 /* [in] */ HDC printDC, |
|
169 /* [retval][out] */ UINT *pageCount); |
|
170 |
|
171 virtual HRESULT STDMETHODCALLTYPE spoolPages( |
|
172 /* [in] */ HDC printDC, |
|
173 /* [in] */ UINT startPage, |
|
174 /* [in] */ UINT endPage, |
|
175 /* [retval][out] */ void* ctx); |
|
176 |
|
177 virtual HRESULT STDMETHODCALLTYPE isFrameSet( |
|
178 /* [retval][out] */ BOOL* result); |
|
179 |
|
180 virtual HRESULT STDMETHODCALLTYPE string( |
|
181 /* [retval][out] */ BSTR* result); |
|
182 |
|
183 virtual HRESULT STDMETHODCALLTYPE size( |
|
184 /* [retval][out] */ SIZE *size); |
|
185 |
|
186 virtual HRESULT STDMETHODCALLTYPE hasScrollBars( |
|
187 /* [retval][out] */ BOOL *result); |
|
188 |
|
189 virtual HRESULT STDMETHODCALLTYPE contentBounds( |
|
190 /* [retval][out] */ RECT *result); |
|
191 |
|
192 virtual HRESULT STDMETHODCALLTYPE frameBounds( |
|
193 /* [retval][out] */ RECT *result); |
|
194 |
|
195 virtual HRESULT STDMETHODCALLTYPE isDescendantOfFrame( |
|
196 /* [in] */ IWebFrame *ancestor, |
|
197 /* [retval][out] */ BOOL *result); |
|
198 |
|
199 virtual HRESULT STDMETHODCALLTYPE setAllowsScrolling( |
|
200 /* [in] */ BOOL flag); |
|
201 |
|
202 virtual HRESULT STDMETHODCALLTYPE allowsScrolling( |
|
203 /* [retval][out] */ BOOL *flag); |
|
204 |
|
205 |
|
206 // FrameWinClient |
|
207 virtual void ref(); |
|
208 virtual void deref(); |
|
209 |
|
210 virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL&, const WebCore::String& name, WebCore::HTMLFrameOwnerElement*, const WebCore::String& referrer); |
|
211 virtual void openURL(const WebCore::String& URL, const WebCore::Event* triggeringEvent, bool newWindow, bool lockHistory); |
|
212 virtual void windowScriptObjectAvailable(JSContextRef context, JSObjectRef windowObject); |
|
213 |
|
214 // FrameLoaderClient |
|
215 virtual void frameLoaderDestroyed(); |
|
216 virtual bool hasWebView() const; |
|
217 virtual bool hasFrameView() const; |
|
218 virtual bool privateBrowsingEnabled() const; |
|
219 virtual void makeDocumentView(); |
|
220 virtual void makeRepresentation(WebCore::DocumentLoader*); |
|
221 virtual void forceLayout(); |
|
222 virtual void forceLayoutForNonHTML(); |
|
223 virtual void setCopiesOnScroll(); |
|
224 virtual void detachedFromParent1(); |
|
225 virtual void detachedFromParent2(); |
|
226 virtual void detachedFromParent3(); |
|
227 virtual void detachedFromParent4(); |
|
228 virtual void loadedFromCachedPage(); |
|
229 virtual void dispatchDidHandleOnloadEvents(); |
|
230 virtual void dispatchDidReceiveServerRedirectForProvisionalLoad(); |
|
231 virtual void dispatchDidCancelClientRedirect(); |
|
232 virtual void dispatchWillPerformClientRedirect(const WebCore::KURL&, double interval, double fireDate); |
|
233 virtual void dispatchDidChangeLocationWithinPage(); |
|
234 virtual void dispatchWillClose(); |
|
235 virtual void dispatchDidReceiveIcon(); |
|
236 virtual void dispatchDidStartProvisionalLoad(); |
|
237 virtual void dispatchDidReceiveTitle(const WebCore::String& title); |
|
238 virtual void dispatchDidCommitLoad(); |
|
239 virtual void dispatchDidFinishDocumentLoad(); |
|
240 virtual void dispatchDidFinishLoad(); |
|
241 virtual void dispatchDidFirstLayout(); |
|
242 virtual void dispatchShow(); |
|
243 virtual void cancelPolicyCheck(); |
|
244 virtual void dispatchWillSubmitForm(WebCore::FramePolicyFunction, PassRefPtr<WebCore::FormState>); |
|
245 virtual void dispatchDidLoadMainResource(WebCore::DocumentLoader*); |
|
246 virtual void revertToProvisionalState(WebCore::DocumentLoader*); |
|
247 virtual void clearUnarchivingState(WebCore::DocumentLoader*); |
|
248 virtual void setMainFrameDocumentReady(bool); |
|
249 virtual void willChangeTitle(WebCore::DocumentLoader*); |
|
250 virtual void didChangeTitle(WebCore::DocumentLoader*); |
|
251 virtual void finishedLoading(WebCore::DocumentLoader*); |
|
252 virtual void finalSetupForReplace(WebCore::DocumentLoader*); |
|
253 virtual void setDefersLoading(bool); |
|
254 virtual bool isArchiveLoadPending(WebCore::ResourceLoader*) const; |
|
255 virtual void cancelPendingArchiveLoad(WebCore::ResourceLoader*); |
|
256 virtual void clearArchivedResources(); |
|
257 virtual bool canHandleRequest(const WebCore::ResourceRequest&) const; |
|
258 virtual bool canShowMIMEType(const WebCore::String& MIMEType) const; |
|
259 virtual bool representationExistsForURLScheme(const WebCore::String& URLScheme) const; |
|
260 virtual WebCore::String generatedMIMETypeForURLScheme(const WebCore::String& URLScheme) const; |
|
261 virtual void frameLoadCompleted(); |
|
262 virtual void restoreViewState(); |
|
263 virtual void provisionalLoadStarted(); |
|
264 virtual bool shouldTreatURLAsSameAsCurrent(const WebCore::KURL&) const; |
|
265 virtual void addHistoryItemForFragmentScroll(); |
|
266 virtual void didFinishLoad(); |
|
267 virtual void prepareForDataSourceReplacement(); |
|
268 virtual void setTitle(const WebCore::String& title, const WebCore::KURL&); |
|
269 virtual WebCore::String userAgent(const WebCore::KURL&); |
|
270 virtual void setDocumentViewFromCachedPage(WebCore::CachedPage *); |
|
271 virtual void updateGlobalHistoryForStandardLoad(const WebCore::KURL &); |
|
272 virtual void updateGlobalHistoryForReload(const WebCore::KURL &); |
|
273 virtual bool shouldGoToHistoryItem(WebCore::HistoryItem *) const; |
|
274 virtual void saveViewStateToItem(WebCore::HistoryItem *); |
|
275 virtual void saveDocumentViewToCachedPage(WebCore::CachedPage *); |
|
276 virtual bool canCachePage(void) const; |
|
277 virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&); |
|
278 virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&); |
|
279 virtual WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&); |
|
280 virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&); |
|
281 virtual WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&); |
|
282 virtual WebCore::ResourceError interruptForPolicyChangeError(const WebCore::ResourceRequest&); |
|
283 virtual WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&); |
|
284 virtual WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&); |
|
285 virtual bool shouldFallBack(const WebCore::ResourceError&); |
|
286 virtual void committedLoad(WebCore::DocumentLoader*, const char*, int); |
|
287 virtual void dispatchDecidePolicyForMIMEType(WebCore::FramePolicyFunction, const WebCore::String& MIMEType, const WebCore::ResourceRequest&); |
|
288 virtual void dispatchDecidePolicyForNewWindowAction(WebCore::FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, const WebCore::String& frameName); |
|
289 virtual void dispatchDecidePolicyForNavigationAction(WebCore::FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&); |
|
290 virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&); |
|
291 virtual bool willUseArchive(WebCore::ResourceLoader*, const WebCore::ResourceRequest&, const WebCore::KURL& originalURL) const; |
|
292 virtual void download(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&); |
|
293 |
|
294 virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&); |
|
295 virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse); |
|
296 virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&); |
|
297 virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int lengthReceived); |
|
298 virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier); |
|
299 virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&); |
|
300 virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length); |
|
301 virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&); |
|
302 virtual void dispatchDidFailLoad(const WebCore::ResourceError&); |
|
303 virtual WebCore::Frame* dispatchCreatePage(); |
|
304 virtual void startDownload(const WebCore::ResourceRequest&); |
|
305 virtual void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); |
|
306 virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); |
|
307 |
|
308 virtual void postProgressStartedNotification(); |
|
309 virtual void postProgressEstimateChangedNotification(); |
|
310 virtual void postProgressFinishedNotification(); |
|
311 |
|
312 virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL& url, const WebCore::String& name, WebCore::HTMLFrameOwnerElement* ownerElement, |
|
313 const WebCore::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight); |
|
314 virtual WebCore::Widget* createPlugin(const WebCore::IntSize&, WebCore::Element*, const WebCore::KURL&, const Vector<WebCore::String>&, const Vector<WebCore::String>&, const WebCore::String&, bool loadManually); |
|
315 virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget); |
|
316 |
|
317 virtual WebCore::Widget* createJavaAppletWidget(const WebCore::IntSize&, WebCore::Element*, const WebCore::KURL& baseURL, const Vector<WebCore::String>& paramNames, const Vector<WebCore::String>& paramValues); |
|
318 |
|
319 virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL& url, const WebCore::String& mimeType); |
|
320 virtual WebCore::String overrideMediaType() const; |
|
321 |
|
322 virtual void windowObjectCleared() const; |
|
323 virtual void didPerformFirstNavigation() const; |
|
324 |
|
325 virtual void registerForIconNotification(bool listen); |
|
326 |
|
327 // WebFrame |
|
328 void initWithWebFrameView(IWebFrameView*, IWebView*, WebCore::Page*, WebCore::HTMLFrameOwnerElement*); |
|
329 WebCore::Frame* impl(); |
|
330 void invalidate(); |
|
331 void receivedData(const char*, int, const WebCore::String&); |
|
332 void unmarkAllMisspellings(); |
|
333 void unmarkAllBadGrammar(); |
|
334 |
|
335 // WebFrame (matching WebCoreFrameBridge) |
|
336 void setTextSizeMultiplier(float multiplier); |
|
337 HRESULT inViewSourceMode(BOOL *flag); |
|
338 HRESULT setInViewSourceMode(BOOL flag); |
|
339 HRESULT elementWithName(BSTR name, IDOMElement* form, IDOMElement** element); |
|
340 HRESULT formForElement(IDOMElement* element, IDOMElement** form); |
|
341 HRESULT elementDoesAutoComplete(IDOMElement* element, bool* result); |
|
342 HRESULT controlsInForm(IDOMElement* form, IDOMElement** controls, int* cControls); |
|
343 HRESULT elementIsPassword(IDOMElement* element, bool* result); |
|
344 HRESULT searchForLabelsBeforeElement(const BSTR* labels, int cLabels, IDOMElement* beforeElement, BSTR* result); |
|
345 HRESULT matchLabelsAgainstElement(const BSTR* labels, int cLabels, IDOMElement* againstElement, BSTR* result); |
|
346 HRESULT canProvideDocumentSource(bool* result); |
|
347 WebHistory* webHistory(); |
|
348 |
|
349 COMPtr<WebFramePolicyListener> setUpPolicyListener(WebCore::FramePolicyFunction function); |
|
350 void receivedPolicyDecision(WebCore::PolicyAction); |
|
351 |
|
352 WebCore::KURL url() const; |
|
353 protected: |
|
354 void loadHTMLString(BSTR string, BSTR baseURL, BSTR unreachableURL); |
|
355 void loadData(PassRefPtr<WebCore::SharedBuffer>, BSTR mimeType, BSTR textEncodingName, BSTR baseURL, BSTR failingURL); |
|
356 void loadURLIntoChild(const WebCore::KURL&, const WebCore::String& referrer, WebFrame* childFrame); |
|
357 const Vector<WebCore::IntRect>& computePageRects(HDC printDC); |
|
358 void setPrinting(bool printing, float minPageWidth, float maxPageWidth, bool adjustViewSize); |
|
359 void headerAndFooterHeights(float*, float*); |
|
360 WebCore::IntRect printerMarginRect(HDC); |
|
361 |
|
362 protected: |
|
363 ULONG m_refCount; |
|
364 class WebFramePrivate; |
|
365 WebFramePrivate* d; |
|
366 bool m_quickRedirectComing; |
|
367 WebCore::KURL m_originalRequestURL; |
|
368 bool m_inPrintingMode; |
|
369 Vector<WebCore::IntRect> m_pageRects; |
|
370 int m_pageHeight; // height of the page adjusted by margins |
|
371 }; |
|
372 |
|
373 #endif |