webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
WebFrame.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2007, 2011, 2013-2015 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. ``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 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 "WebKit.h"
30 #include "WebDataSource.h"
31 
32 #include "AccessibleDocument.h"
33 #include <WebCore/AdjustViewSizeOrNot.h>
34 #include <WebCore/FrameWin.h>
35 #include <WebCore/GraphicsContext.h>
36 #include <WebCore/ResourceHandleClient.h>
37 #include <WebCore/URL.h>
38 #include <sal.h>
39 #include <wtf/RefPtr.h>
40 #include <wtf/text/WTFString.h>
41 
42 namespace WebCore {
43  class AuthenticationChallenge;
44  class DocumentLoader;
45  class Element;
46  class FloatSize;
47  class Frame;
48  class GraphicsContext;
49  class HTMLFrameOwnerElement;
50  class IntRect;
51  class Page;
52  class ResourceError;
53  class SharedBuffer;
54 }
55 
56 typedef const struct OpaqueJSContext* JSContextRef;
57 typedef struct OpaqueJSValue* JSObjectRef;
58 
59 #if USE(CG)
60 typedef struct CGContext PlatformGraphicsContext;
61 #elif USE(CAIRO)
62 namespace WebCore {
63 class PlatformContextCairo;
64 }
65 typedef class WebCore::PlatformContextCairo PlatformGraphicsContext;
66 #endif
67 
68 class WebFrame;
70 class WebHistory;
71 class WebView;
72 
73 interface IWebHistoryItemPrivate;
74 
77 
78 class DECLSPEC_UUID("{A3676398-4485-4a9d-87DC-CB5A40E6351D}") WebFrame : public IWebFrame2, IWebFramePrivate, IWebDocumentText
79 {
80 public:
81  static WebFrame* createInstance();
82 protected:
83  WebFrame();
84  ~WebFrame();
85 
86 public:
87  // IUnknown
88  virtual HRESULT STDMETHODCALLTYPE QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject);
89  virtual ULONG STDMETHODCALLTYPE AddRef();
90  virtual ULONG STDMETHODCALLTYPE Release();
91 
92  //IWebFrame
93  virtual HRESULT STDMETHODCALLTYPE name(_Deref_opt_out_ BSTR* frameName);
94  virtual HRESULT STDMETHODCALLTYPE webView(_COM_Outptr_opt_ IWebView**);
95  virtual HRESULT STDMETHODCALLTYPE frameView(_COM_Outptr_opt_ IWebFrameView**);
96  virtual HRESULT STDMETHODCALLTYPE DOMDocument(_COM_Outptr_opt_ IDOMDocument**);
97  virtual HRESULT STDMETHODCALLTYPE DOMWindow(_COM_Outptr_opt_ IDOMWindow**);
98  virtual HRESULT STDMETHODCALLTYPE frameElement(_COM_Outptr_opt_ IDOMHTMLElement** frameElement);
99  virtual HRESULT STDMETHODCALLTYPE loadRequest(_In_opt_ IWebURLRequest*);
100  virtual HRESULT STDMETHODCALLTYPE loadData(_In_opt_ IStream* data, _In_ BSTR mimeType, _In_ BSTR textEncodingName, _In_ BSTR url);
101  virtual HRESULT STDMETHODCALLTYPE loadHTMLString(_In_ BSTR, _In_ BSTR baseURL);
102  virtual HRESULT STDMETHODCALLTYPE loadAlternateHTMLString(_In_ BSTR, _In_ BSTR baseURL, _In_ BSTR unreachableURL);
103  virtual HRESULT STDMETHODCALLTYPE loadArchive(_In_opt_ IWebArchive*);
104  virtual HRESULT STDMETHODCALLTYPE dataSource(_COM_Outptr_opt_ IWebDataSource**);
105  virtual HRESULT STDMETHODCALLTYPE provisionalDataSource(_COM_Outptr_opt_ IWebDataSource**);
106  virtual HRESULT STDMETHODCALLTYPE stopLoading();
107  virtual HRESULT STDMETHODCALLTYPE reload();
108  virtual HRESULT STDMETHODCALLTYPE findFrameNamed(_In_ BSTR name, _COM_Outptr_opt_ IWebFrame**);
109  virtual HRESULT STDMETHODCALLTYPE parentFrame(_COM_Outptr_opt_ IWebFrame**);
110  virtual HRESULT STDMETHODCALLTYPE childFrames(_COM_Outptr_opt_ IEnumVARIANT** enumFrames);
111  virtual HRESULT STDMETHODCALLTYPE currentForm(_COM_Outptr_opt_ IDOMElement**);
112  virtual /* [local] */ JSGlobalContextRef STDMETHODCALLTYPE globalContext();
113 
114  // IWebFramePrivate
115  virtual HRESULT STDMETHODCALLTYPE unused1() { return E_NOTIMPL; }
116  virtual HRESULT STDMETHODCALLTYPE renderTreeAsExternalRepresentation(BOOL forPrinting, _Deref_opt_out_ BSTR* result);
117  virtual HRESULT STDMETHODCALLTYPE pageNumberForElementById(_In_ BSTR id, float pageWidthInPixels, float pageHeightInPixels, _Out_ int* pageNumber);
118  virtual HRESULT STDMETHODCALLTYPE numberOfPages(float pageWidthInPixels, float pageHeightInPixels, _Out_ int* pageCount);
119  virtual HRESULT STDMETHODCALLTYPE scrollOffset(_Out_ SIZE*);
120  virtual HRESULT STDMETHODCALLTYPE layout();
121  virtual HRESULT STDMETHODCALLTYPE firstLayoutDone(_Out_ BOOL*);
122  virtual HRESULT STDMETHODCALLTYPE unused2() { return E_NOTIMPL; }
123  virtual HRESULT STDMETHODCALLTYPE pendingFrameUnloadEventCount(_Out_ UINT*);
124  virtual HRESULT STDMETHODCALLTYPE unused3() { return E_NOTIMPL; }
125  virtual HRESULT STDMETHODCALLTYPE setInPrintingMode(BOOL value, _In_ HDC printDC);
126  virtual HRESULT STDMETHODCALLTYPE getPrintedPageCount(_In_ HDC printDC, _Out_ UINT* pageCount);
127  virtual HRESULT STDMETHODCALLTYPE spoolPages(HDC printDC, UINT startPage, UINT endPage, void* ctx);
128  virtual HRESULT STDMETHODCALLTYPE isFrameSet(_Out_ BOOL*);
129  virtual HRESULT STDMETHODCALLTYPE string(_Deref_opt_out_ BSTR*);
130  virtual HRESULT STDMETHODCALLTYPE size(_Out_ SIZE*);
131  virtual HRESULT STDMETHODCALLTYPE hasScrollBars(_Out_ BOOL*);
132  virtual HRESULT STDMETHODCALLTYPE contentBounds(_Out_ RECT*);
133  virtual HRESULT STDMETHODCALLTYPE frameBounds(_Out_ RECT*);
134  virtual HRESULT STDMETHODCALLTYPE isDescendantOfFrame(_In_opt_ IWebFrame* ancestor, _Out_ BOOL* result);
135  virtual HRESULT STDMETHODCALLTYPE setAllowsScrolling(BOOL);
136  virtual HRESULT STDMETHODCALLTYPE allowsScrolling(_Out_ BOOL*);
137  virtual HRESULT STDMETHODCALLTYPE setIsDisconnected(BOOL);
138  virtual HRESULT STDMETHODCALLTYPE setExcludeFromTextSearch(BOOL);
139  virtual HRESULT STDMETHODCALLTYPE reloadFromOrigin();
140  virtual HRESULT STDMETHODCALLTYPE paintDocumentRectToContext(RECT, _In_ HDC);
141  virtual HRESULT STDMETHODCALLTYPE paintScrollViewRectToContextAtPoint(RECT, POINT, _In_ HDC);
142  virtual HRESULT STDMETHODCALLTYPE elementDoesAutoComplete(_In_opt_ IDOMElement*, _Out_ BOOL*);
143  virtual HRESULT STDMETHODCALLTYPE pauseAnimation(_In_ BSTR animationName, _In_opt_ IDOMNode*, double secondsFromNow, _Out_ BOOL* animationWasRunning);
144  virtual HRESULT STDMETHODCALLTYPE pauseTransition(_In_ BSTR propertyName, _In_opt_ IDOMNode*, double secondsFromNow, _Out_ BOOL* transitionWasRunning);
145  virtual HRESULT STDMETHODCALLTYPE numberOfActiveAnimations(_Out_ UINT*);
146  virtual HRESULT STDMETHODCALLTYPE loadPlainTextString(_In_ BSTR, _In_ BSTR url);
147  virtual HRESULT STDMETHODCALLTYPE isDisplayingStandaloneImage(_Out_ BOOL*);
148  virtual HRESULT STDMETHODCALLTYPE allowsFollowingLink(_In_ BSTR, _Out_ BOOL*);
149  virtual HRESULT STDMETHODCALLTYPE stringByEvaluatingJavaScriptInScriptWorld(IWebScriptWorld*, JSObjectRef, BSTR script, BSTR* evaluationResult);
150  virtual JSGlobalContextRef STDMETHODCALLTYPE globalContextForScriptWorld(IWebScriptWorld*);
151  virtual HRESULT STDMETHODCALLTYPE visibleContentRect(_Out_ RECT*);
152  virtual HRESULT STDMETHODCALLTYPE layerTreeAsText(_Deref_out_opt_ BSTR*);
153  virtual HRESULT STDMETHODCALLTYPE hasSpellingMarker(UINT from, UINT length, BOOL* result);
154  virtual HRESULT STDMETHODCALLTYPE clearOpener();
155  virtual HRESULT STDMETHODCALLTYPE setTextDirection(_In_ BSTR);
156  virtual HRESULT STDMETHODCALLTYPE unused4() { return E_NOTIMPL; }
157  virtual HRESULT STDMETHODCALLTYPE resumeAnimations();
158  virtual HRESULT STDMETHODCALLTYPE suspendAnimations();
159 
160  // IWebDocumentText
161  virtual HRESULT STDMETHODCALLTYPE supportsTextEncoding(_Out_ BOOL*);
162  virtual HRESULT STDMETHODCALLTYPE selectedString(_Deref_opt_out_ BSTR*);
163  virtual HRESULT STDMETHODCALLTYPE selectAll();
164  virtual HRESULT STDMETHODCALLTYPE deselectAll();
165 
166  // IWebFrame2:
167  virtual HRESULT STDMETHODCALLTYPE isMainFrame(_Out_ BOOL*);
168 
169  // FrameLoaderClient
170  virtual void frameLoaderDestroyed();
171 
172  // WebFrame
173  PassRefPtr<WebCore::Frame> createSubframeWithOwnerElement(IWebView*, WebCore::Page*, WebCore::HTMLFrameOwnerElement*);
174  void initWithWebView(IWebView*, WebCore::Page*);
175  WebCore::Frame* impl();
176  void invalidate();
177  void unmarkAllMisspellings();
178  void unmarkAllBadGrammar();
179 
180  void updateBackground();
181 
182  // WebFrame (matching WebCoreFrameBridge)
183  HRESULT inViewSourceMode(BOOL *flag);
184  HRESULT setInViewSourceMode(BOOL flag);
185  HRESULT elementWithName(BSTR name, IDOMElement* form, IDOMElement** element);
186  HRESULT formForElement(IDOMElement* element, IDOMElement** form);
187  HRESULT controlsInForm(IDOMElement* form, IDOMElement** controls, int* cControls);
188  HRESULT elementIsPassword(IDOMElement* element, bool* result);
189  HRESULT searchForLabelsBeforeElement(const BSTR* labels, unsigned cLabels, IDOMElement* beforeElement, unsigned* resultDistance, BOOL* resultIsInCellAbove, BSTR* result);
190  HRESULT matchLabelsAgainstElement(const BSTR* labels, int cLabels, IDOMElement* againstElement, BSTR* result);
191  HRESULT canProvideDocumentSource(bool* result);
192 
193  WebCore::URL url() const;
194 
195  WebView* webView() const;
196  void setWebView(WebView*);
197 
198  COMPtr<IAccessible> accessible() const;
199 
200 protected:
201  void loadHTMLString(_In_ BSTR string, _In_ BSTR baseURL, _In_ BSTR unreachableURL);
202  void loadData(PassRefPtr<WebCore::SharedBuffer>, BSTR mimeType, BSTR textEncodingName, BSTR baseURL, BSTR failingURL);
203  const Vector<WebCore::IntRect>& computePageRects(HDC printDC);
204  void setPrinting(bool printing, const WebCore::FloatSize& pageSize, const WebCore::FloatSize& originalPageSize, float maximumShrinkRatio, WebCore::AdjustViewSizeOrNot);
205  void headerAndFooterHeights(float*, float*);
206  WebCore::IntRect printerMarginRect(HDC);
207  void spoolPage (PlatformGraphicsContext* pctx, WebCore::GraphicsContext& spoolCtx, HDC printDC, IWebUIDelegate*, float headerHeight, float footerHeight, UINT page, UINT pageCount);
208  void drawHeader(PlatformGraphicsContext* pctx, IWebUIDelegate*, const WebCore::IntRect& pageRect, float headerHeight);
209  void drawFooter(PlatformGraphicsContext* pctx, IWebUIDelegate*, const WebCore::IntRect& pageRect, UINT page, UINT pageCount, float headerHeight, float footerHeight);
210 
211 protected:
212  ULONG m_refCount { 0 };
213  class WebFramePrivate;
214  WebFramePrivate* d;
215  bool m_quickRedirectComing { false };
216  WebCore::URL m_originalRequestURL;
217  bool m_inPrintingMode { false };
218 
219  Vector<WebCore::IntRect> m_pageRects;
220  int m_pageHeight { 0 }; // height of the page adjusted by margins
221  mutable COMPtr<AccessibleDocument> m_accessible;
222 };
223 
224 #endif
Definition: WebFrame.h:48
struct OpaqueJSValue * JSObjectRef
Definition: WebFrame.h:57
Definition: WebFrameLoaderClient.mm:180
WebFrame * kit(WebCore::Frame *)
Definition: WebFrame.cpp:150
Definition: IWebHistoryItemPrivate.idl:40
WEBCORE_EXPORT AuthenticationChallenge core(NSURLAuthenticationChallenge *)
Definition: AuthenticationMac.mm:214
#define WEBKIT_API
Definition: WebKitCOMAPI.h:35
const struct OpaqueJSContext * JSContextRef
Definition: WebFrame.h:56
Definition: WebView.h:127
Definition: WebHistory.h:62
This file is generated by create-http-header-name-table, do not edit.
Definition: CharsetData.cpp:6
Definition: Frame.h:113
void PlatformGraphicsContext
Definition: GraphicsContext.h:55