|
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 "WebFrameLoaderClient.h" |
|
30 |
|
31 #include "WebKit.h" |
|
32 #include "WebDataSource.h" |
|
33 |
|
34 #include "AccessibleDocument.h" |
|
35 |
|
36 #pragma warning(push, 0) |
|
37 #include <WebCore/FrameWin.h> |
|
38 #include <WebCore/GraphicsContext.h> |
|
39 #include <WebCore/KURL.h> |
|
40 #include <WebCore/PlatformString.h> |
|
41 #include <WebCore/ResourceHandleClient.h> |
|
42 #pragma warning(pop) |
|
43 |
|
44 #include <WTF/RefPtr.h> |
|
45 #include <WTF/HashMap.h> |
|
46 #include <WTF/OwnPtr.h> |
|
47 |
|
48 namespace WebCore { |
|
49 class AuthenticationChallenge; |
|
50 class DocumentLoader; |
|
51 class Element; |
|
52 class Frame; |
|
53 class GraphicsContext; |
|
54 class HTMLFrameOwnerElement; |
|
55 class IntRect; |
|
56 class Page; |
|
57 class ResourceError; |
|
58 class SharedBuffer; |
|
59 } |
|
60 |
|
61 typedef const struct OpaqueJSContext* JSContextRef; |
|
62 typedef struct OpaqueJSValue* JSObjectRef; |
|
63 |
|
64 #if PLATFORM(CG) |
|
65 typedef struct CGContext PlatformGraphicsContext; |
|
66 #elif PLATFORM(CAIRO) |
|
67 typedef struct _cairo PlatformGraphicsContext; |
|
68 #endif |
|
69 |
|
70 class WebFrame; |
|
71 class WebFramePolicyListener; |
|
72 class WebHistory; |
|
73 class WebView; |
|
74 |
|
75 interface IWebHistoryItemPrivate; |
|
76 |
|
77 WebFrame* kit(WebCore::Frame*); |
|
78 WebCore::Frame* core(WebFrame*); |
|
79 |
|
80 class DECLSPEC_UUID("{A3676398-4485-4a9d-87DC-CB5A40E6351D}") WebFrame : public IWebFrame, IWebFramePrivate, IWebDocumentText |
|
81 , public WebFrameLoaderClient |
|
82 { |
|
83 public: |
|
84 static WebFrame* createInstance(); |
|
85 protected: |
|
86 WebFrame(); |
|
87 ~WebFrame(); |
|
88 |
|
89 public: |
|
90 // IUnknown |
|
91 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); |
|
92 virtual ULONG STDMETHODCALLTYPE AddRef(void); |
|
93 virtual ULONG STDMETHODCALLTYPE Release(void); |
|
94 |
|
95 //IWebFrame |
|
96 virtual HRESULT STDMETHODCALLTYPE name( |
|
97 /* [retval][out] */ BSTR *frameName); |
|
98 |
|
99 virtual HRESULT STDMETHODCALLTYPE webView( |
|
100 /* [retval][out] */ IWebView **view); |
|
101 |
|
102 virtual HRESULT STDMETHODCALLTYPE frameView( |
|
103 /* [retval][out] */ IWebFrameView **view); |
|
104 |
|
105 virtual HRESULT STDMETHODCALLTYPE DOMDocument( |
|
106 /* [retval][out] */ IDOMDocument** document); |
|
107 |
|
108 virtual HRESULT STDMETHODCALLTYPE frameElement( |
|
109 /* [retval][out] */ IDOMHTMLElement **frameElement); |
|
110 |
|
111 virtual HRESULT STDMETHODCALLTYPE loadRequest( |
|
112 /* [in] */ IWebURLRequest *request); |
|
113 |
|
114 virtual HRESULT STDMETHODCALLTYPE loadData( |
|
115 /* [in] */ IStream *data, |
|
116 /* [in] */ BSTR mimeType, |
|
117 /* [in] */ BSTR textEncodingName, |
|
118 /* [in] */ BSTR url); |
|
119 |
|
120 virtual HRESULT STDMETHODCALLTYPE loadHTMLString( |
|
121 /* [in] */ BSTR string, |
|
122 /* [in] */ BSTR baseURL); |
|
123 |
|
124 virtual HRESULT STDMETHODCALLTYPE loadAlternateHTMLString( |
|
125 /* [in] */ BSTR str, |
|
126 /* [in] */ BSTR baseURL, |
|
127 /* [in] */ BSTR unreachableURL); |
|
128 |
|
129 virtual HRESULT STDMETHODCALLTYPE loadArchive( |
|
130 /* [in] */ IWebArchive *archive); |
|
131 |
|
132 virtual HRESULT STDMETHODCALLTYPE dataSource( |
|
133 /* [retval][out] */ IWebDataSource **source); |
|
134 |
|
135 virtual HRESULT STDMETHODCALLTYPE provisionalDataSource( |
|
136 /* [retval][out] */ IWebDataSource **source); |
|
137 |
|
138 virtual HRESULT STDMETHODCALLTYPE stopLoading( void); |
|
139 |
|
140 virtual HRESULT STDMETHODCALLTYPE reload( void); |
|
141 |
|
142 virtual HRESULT STDMETHODCALLTYPE findFrameNamed( |
|
143 /* [in] */ BSTR name, |
|
144 /* [retval][out] */ IWebFrame **frame); |
|
145 |
|
146 virtual HRESULT STDMETHODCALLTYPE parentFrame( |
|
147 /* [retval][out] */ IWebFrame **frame); |
|
148 |
|
149 virtual HRESULT STDMETHODCALLTYPE childFrames( |
|
150 /* [retval][out] */ IEnumVARIANT **enumFrames); |
|
151 |
|
152 virtual HRESULT STDMETHODCALLTYPE currentForm( |
|
153 /* [retval][out] */ IDOMElement **formElement); |
|
154 |
|
155 virtual /* [local] */ JSGlobalContextRef STDMETHODCALLTYPE globalContext(); |
|
156 |
|
157 // IWebFramePrivate |
|
158 virtual HRESULT STDMETHODCALLTYPE unused1(BSTR*) { return E_NOTIMPL; } |
|
159 virtual HRESULT STDMETHODCALLTYPE renderTreeAsExternalRepresentation(BOOL forPrinting, BSTR *result); |
|
160 |
|
161 virtual HRESULT STDMETHODCALLTYPE counterValueForElementById( |
|
162 /* [in] */ BSTR id, |
|
163 /* [retval][out] */ BSTR *result); |
|
164 |
|
165 virtual HRESULT STDMETHODCALLTYPE pageNumberForElementById( |
|
166 /* [in] */ BSTR id, |
|
167 /* [in] */ float pageWidthInPixels, |
|
168 /* [in] */ float pageHeightInPixels, |
|
169 /* [retval][out] */ int* result); |
|
170 |
|
171 virtual HRESULT STDMETHODCALLTYPE numberOfPages( |
|
172 /* [in] */ float pageWidthInPixels, |
|
173 /* [in] */ float pageHeightInPixels, |
|
174 /* [retval][out] */ int* result); |
|
175 |
|
176 virtual HRESULT STDMETHODCALLTYPE scrollOffset( |
|
177 /* [retval][out] */ SIZE* offset); |
|
178 |
|
179 virtual HRESULT STDMETHODCALLTYPE layout(); |
|
180 |
|
181 virtual HRESULT STDMETHODCALLTYPE firstLayoutDone( |
|
182 /* [retval][out] */ BOOL* result); |
|
183 |
|
184 virtual HRESULT STDMETHODCALLTYPE loadType( |
|
185 /* [retval][out] */ WebFrameLoadType* type); |
|
186 |
|
187 virtual HRESULT STDMETHODCALLTYPE pendingFrameUnloadEventCount( |
|
188 /* [retval][out] */ UINT* result); |
|
189 |
|
190 virtual HRESULT STDMETHODCALLTYPE fetchApplicationIcon( |
|
191 /* [in] */ IWebIconFetcherDelegate *delegate, |
|
192 /* [retval][out] */ IWebIconFetcher **result); |
|
193 |
|
194 virtual HRESULT STDMETHODCALLTYPE setInPrintingMode( |
|
195 /* [in] */ BOOL value, |
|
196 /* [in] */ HDC printDC); |
|
197 |
|
198 virtual HRESULT STDMETHODCALLTYPE getPrintedPageCount( |
|
199 /* [in] */ HDC printDC, |
|
200 /* [retval][out] */ UINT *pageCount); |
|
201 |
|
202 virtual HRESULT STDMETHODCALLTYPE spoolPages( |
|
203 /* [in] */ HDC printDC, |
|
204 /* [in] */ UINT startPage, |
|
205 /* [in] */ UINT endPage, |
|
206 /* [retval][out] */ void* ctx); |
|
207 |
|
208 virtual HRESULT STDMETHODCALLTYPE isFrameSet( |
|
209 /* [retval][out] */ BOOL* result); |
|
210 |
|
211 virtual HRESULT STDMETHODCALLTYPE string( |
|
212 /* [retval][out] */ BSTR* result); |
|
213 |
|
214 virtual HRESULT STDMETHODCALLTYPE size( |
|
215 /* [retval][out] */ SIZE *size); |
|
216 |
|
217 virtual HRESULT STDMETHODCALLTYPE hasScrollBars( |
|
218 /* [retval][out] */ BOOL *result); |
|
219 |
|
220 virtual HRESULT STDMETHODCALLTYPE contentBounds( |
|
221 /* [retval][out] */ RECT *result); |
|
222 |
|
223 virtual HRESULT STDMETHODCALLTYPE frameBounds( |
|
224 /* [retval][out] */ RECT *result); |
|
225 |
|
226 virtual HRESULT STDMETHODCALLTYPE isDescendantOfFrame( |
|
227 /* [in] */ IWebFrame *ancestor, |
|
228 /* [retval][out] */ BOOL *result); |
|
229 |
|
230 virtual HRESULT STDMETHODCALLTYPE setAllowsScrolling( |
|
231 /* [in] */ BOOL flag); |
|
232 |
|
233 virtual HRESULT STDMETHODCALLTYPE allowsScrolling( |
|
234 /* [retval][out] */ BOOL *flag); |
|
235 |
|
236 virtual HRESULT STDMETHODCALLTYPE setIsDisconnected( |
|
237 /* [in] */ BOOL flag); |
|
238 |
|
239 virtual HRESULT STDMETHODCALLTYPE setExcludeFromTextSearch( |
|
240 /* [in] */ BOOL flag); |
|
241 |
|
242 virtual HRESULT STDMETHODCALLTYPE reloadFromOrigin(); |
|
243 |
|
244 virtual HRESULT STDMETHODCALLTYPE paintDocumentRectToContext( |
|
245 /* [in] */ RECT rect, |
|
246 /* [in] */ OLE_HANDLE deviceContext); |
|
247 |
|
248 virtual HRESULT STDMETHODCALLTYPE paintScrollViewRectToContextAtPoint( |
|
249 /* [in] */ RECT rect, |
|
250 /* [in] */ POINT pt, |
|
251 /* [in] */ OLE_HANDLE deviceContext); |
|
252 |
|
253 virtual HRESULT STDMETHODCALLTYPE elementDoesAutoComplete( |
|
254 /* [in] */ IDOMElement* element, |
|
255 /* [retval][out] */ BOOL* result); |
|
256 |
|
257 virtual HRESULT STDMETHODCALLTYPE pauseAnimation(BSTR animationName, IDOMNode*, double secondsFromNow, BOOL* animationWasRunning); |
|
258 virtual HRESULT STDMETHODCALLTYPE pauseTransition(BSTR propertyName, IDOMNode*, double secondsFromNow, BOOL* transitionWasRunning); |
|
259 virtual HRESULT STDMETHODCALLTYPE pauseSVGAnimation(BSTR elementId, IDOMNode*, double secondsFromNow, BOOL* animationWasRunning); |
|
260 virtual HRESULT STDMETHODCALLTYPE numberOfActiveAnimations(UINT*); |
|
261 |
|
262 virtual HRESULT STDMETHODCALLTYPE isDisplayingStandaloneImage(BOOL*); |
|
263 |
|
264 virtual HRESULT STDMETHODCALLTYPE allowsFollowingLink( |
|
265 /* [in] */ BSTR url, |
|
266 /* [retval][out] */ BOOL* result); |
|
267 |
|
268 virtual HRESULT STDMETHODCALLTYPE stringByEvaluatingJavaScriptInScriptWorld(IWebScriptWorld*, JSObjectRef globalObjectRef, BSTR script, BSTR* evaluationResult); |
|
269 virtual JSGlobalContextRef STDMETHODCALLTYPE globalContextForScriptWorld(IWebScriptWorld*); |
|
270 |
|
271 virtual HRESULT STDMETHODCALLTYPE visibleContentRect(RECT*); |
|
272 |
|
273 virtual HRESULT STDMETHODCALLTYPE layerTreeAsText(BSTR*); |
|
274 |
|
275 // IWebDocumentText |
|
276 virtual HRESULT STDMETHODCALLTYPE supportsTextEncoding( |
|
277 /* [retval][out] */ BOOL* result); |
|
278 |
|
279 virtual HRESULT STDMETHODCALLTYPE selectedString( |
|
280 /* [retval][out] */ BSTR* result); |
|
281 |
|
282 virtual HRESULT STDMETHODCALLTYPE selectAll(); |
|
283 |
|
284 virtual HRESULT STDMETHODCALLTYPE deselectAll(); |
|
285 |
|
286 // FrameLoaderClient |
|
287 virtual void frameLoaderDestroyed(); |
|
288 virtual void makeRepresentation(WebCore::DocumentLoader*); |
|
289 virtual void forceLayoutForNonHTML(); |
|
290 virtual void setCopiesOnScroll(); |
|
291 virtual void detachedFromParent2(); |
|
292 virtual void detachedFromParent3(); |
|
293 virtual void cancelPolicyCheck(); |
|
294 virtual void dispatchWillSendSubmitEvent(WebCore::HTMLFormElement*) { } |
|
295 virtual void dispatchWillSubmitForm(WebCore::FramePolicyFunction, PassRefPtr<WebCore::FormState>); |
|
296 virtual void revertToProvisionalState(WebCore::DocumentLoader*); |
|
297 virtual void setMainFrameDocumentReady(bool); |
|
298 virtual void willChangeTitle(WebCore::DocumentLoader*); |
|
299 virtual void didChangeTitle(WebCore::DocumentLoader*); |
|
300 virtual void didChangeIcons(WebCore::DocumentLoader*); |
|
301 virtual bool canHandleRequest(const WebCore::ResourceRequest&) const; |
|
302 virtual bool canShowMIMEType(const WebCore::String& MIMEType) const; |
|
303 virtual bool representationExistsForURLScheme(const WebCore::String& URLScheme) const; |
|
304 virtual WebCore::String generatedMIMETypeForURLScheme(const WebCore::String& URLScheme) const; |
|
305 virtual void frameLoadCompleted(); |
|
306 virtual void restoreViewState(); |
|
307 virtual void provisionalLoadStarted(); |
|
308 virtual bool shouldTreatURLAsSameAsCurrent(const WebCore::KURL&) const; |
|
309 virtual void addHistoryItemForFragmentScroll(); |
|
310 virtual void didFinishLoad(); |
|
311 virtual void prepareForDataSourceReplacement(); |
|
312 virtual WebCore::String userAgent(const WebCore::KURL&); |
|
313 virtual void saveViewStateToItem(WebCore::HistoryItem *); |
|
314 virtual WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&); |
|
315 virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&); |
|
316 virtual WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&); |
|
317 virtual WebCore::ResourceError interruptForPolicyChangeError(const WebCore::ResourceRequest&); |
|
318 virtual WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&); |
|
319 virtual WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&); |
|
320 virtual WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&); |
|
321 virtual bool shouldFallBack(const WebCore::ResourceError&); |
|
322 virtual void dispatchDecidePolicyForMIMEType(WebCore::FramePolicyFunction, const WebCore::String& MIMEType, const WebCore::ResourceRequest&); |
|
323 virtual void dispatchDecidePolicyForNewWindowAction(WebCore::FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>, const WebCore::String& frameName); |
|
324 virtual void dispatchDecidePolicyForNavigationAction(WebCore::FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>); |
|
325 virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&); |
|
326 virtual void download(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&); |
|
327 |
|
328 virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length); |
|
329 virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&); |
|
330 virtual void dispatchDidFailLoad(const WebCore::ResourceError&); |
|
331 virtual void startDownload(const WebCore::ResourceRequest&); |
|
332 |
|
333 virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL, const Vector<WebCore::String>& paramNames, const Vector<WebCore::String>& paramValues); |
|
334 |
|
335 virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL& url, const WebCore::String& mimeType); |
|
336 virtual WebCore::String overrideMediaType() const; |
|
337 |
|
338 virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*); |
|
339 virtual void documentElementAvailable(); |
|
340 virtual void didPerformFirstNavigation() const; |
|
341 |
|
342 virtual void registerForIconNotification(bool listen); |
|
343 |
|
344 // WebFrame |
|
345 PassRefPtr<WebCore::Frame> init(IWebView*, WebCore::Page*, WebCore::HTMLFrameOwnerElement*); |
|
346 WebCore::Frame* impl(); |
|
347 void invalidate(); |
|
348 void unmarkAllMisspellings(); |
|
349 void unmarkAllBadGrammar(); |
|
350 |
|
351 void updateBackground(); |
|
352 |
|
353 // WebFrame (matching WebCoreFrameBridge) |
|
354 void setTextSizeMultiplier(float multiplier); |
|
355 HRESULT inViewSourceMode(BOOL *flag); |
|
356 HRESULT setInViewSourceMode(BOOL flag); |
|
357 HRESULT elementWithName(BSTR name, IDOMElement* form, IDOMElement** element); |
|
358 HRESULT formForElement(IDOMElement* element, IDOMElement** form); |
|
359 HRESULT controlsInForm(IDOMElement* form, IDOMElement** controls, int* cControls); |
|
360 HRESULT elementIsPassword(IDOMElement* element, bool* result); |
|
361 HRESULT searchForLabelsBeforeElement(const BSTR* labels, unsigned cLabels, IDOMElement* beforeElement, unsigned* resultDistance, BOOL* resultIsInCellAbove, BSTR* result); |
|
362 HRESULT matchLabelsAgainstElement(const BSTR* labels, int cLabels, IDOMElement* againstElement, BSTR* result); |
|
363 HRESULT canProvideDocumentSource(bool* result); |
|
364 |
|
365 COMPtr<WebFramePolicyListener> setUpPolicyListener(WebCore::FramePolicyFunction function); |
|
366 void receivedPolicyDecision(WebCore::PolicyAction); |
|
367 |
|
368 WebCore::KURL url() const; |
|
369 |
|
370 WebView* webView() const; |
|
371 |
|
372 COMPtr<IAccessible> accessible() const; |
|
373 |
|
374 protected: |
|
375 void loadHTMLString(BSTR string, BSTR baseURL, BSTR unreachableURL); |
|
376 void loadData(PassRefPtr<WebCore::SharedBuffer>, BSTR mimeType, BSTR textEncodingName, BSTR baseURL, BSTR failingURL); |
|
377 const Vector<WebCore::IntRect>& computePageRects(HDC printDC); |
|
378 void setPrinting(bool printing, float minPageWidth, float maxPageWidth, bool adjustViewSize); |
|
379 void headerAndFooterHeights(float*, float*); |
|
380 WebCore::IntRect printerMarginRect(HDC); |
|
381 void spoolPage (PlatformGraphicsContext* pctx, WebCore::GraphicsContext* spoolCtx, HDC printDC, IWebUIDelegate*, float headerHeight, float footerHeight, UINT page, UINT pageCount); |
|
382 void drawHeader(PlatformGraphicsContext* pctx, IWebUIDelegate*, const WebCore::IntRect& pageRect, float headerHeight); |
|
383 void drawFooter(PlatformGraphicsContext* pctx, IWebUIDelegate*, const WebCore::IntRect& pageRect, UINT page, UINT pageCount, float headerHeight, float footerHeight); |
|
384 |
|
385 protected: |
|
386 ULONG m_refCount; |
|
387 class WebFramePrivate; |
|
388 WebFramePrivate* d; |
|
389 bool m_quickRedirectComing; |
|
390 WebCore::KURL m_originalRequestURL; |
|
391 bool m_inPrintingMode; |
|
392 Vector<WebCore::IntRect> m_pageRects; |
|
393 int m_pageHeight; // height of the page adjusted by margins |
|
394 mutable COMPtr<AccessibleDocument> m_accessible; |
|
395 }; |
|
396 |
|
397 #endif |