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