• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 WebView_H
27 #define WebView_H
28 
29 #include "COMPtr.h"
30 #include "WebKit.h"
31 #include "WebFrame.h"
32 #include "WebPreferences.h"
33 
34 #include <WebCore/IntRect.h>
35 #include <WebCore/Timer.h>
36 #include <WebCore/WindowMessageListener.h>
37 #include <wtf/HashSet.h>
38 #include <wtf/OwnPtr.h>
39 
40 class WebFrame;
41 class WebBackForwardList;
42 class WebInspector;
43 class WebInspectorClient;
44 
45 WebView* kit(WebCore::Page*);
46 WebCore::Page* core(IWebView*);
47 
48 interface IDropTargetHelper;
49 
50 class WebView
51     : public IWebView
52     , public IWebViewPrivate
53     , public IWebIBActions
54     , public IWebViewCSS
55     , public IWebViewEditing
56     , public IWebViewUndoableEditing
57     , public IWebViewEditingActions
58     , public IWebNotificationObserver
59     , public IDropTarget
60     , WebCore::WindowMessageListener
61 {
62 public:
63     static WebView* createInstance();
64 protected:
65     WebView();
66     ~WebView();
67 
68 public:
69     // IUnknown
70     virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
71     virtual ULONG STDMETHODCALLTYPE AddRef(void);
72     virtual ULONG STDMETHODCALLTYPE Release(void);
73 
74     // IWebView
75 
76     virtual HRESULT STDMETHODCALLTYPE canShowMIMEType(
77         /* [in] */ BSTR mimeType,
78         /* [retval][out] */ BOOL *canShow);
79 
80     virtual HRESULT STDMETHODCALLTYPE canShowMIMETypeAsHTML(
81         /* [in] */ BSTR mimeType,
82         /* [retval][out] */ BOOL *canShow);
83 
84     virtual HRESULT STDMETHODCALLTYPE MIMETypesShownAsHTML(
85         /* [retval][out] */ IEnumVARIANT **enumVariant);
86 
87     virtual HRESULT STDMETHODCALLTYPE setMIMETypesShownAsHTML(
88         /* [size_is][in] */ BSTR *mimeTypes,
89         /* [in] */ int cMimeTypes);
90 
91     virtual HRESULT STDMETHODCALLTYPE URLFromPasteboard(
92         /* [in] */ IDataObject *pasteboard,
93         /* [retval][out] */ BSTR *url);
94 
95     virtual HRESULT STDMETHODCALLTYPE URLTitleFromPasteboard(
96         /* [in] */ IDataObject *pasteboard,
97         /* [retval][out] */ BSTR *urlTitle);
98 
99     virtual HRESULT STDMETHODCALLTYPE initWithFrame(
100         /* [in] */ RECT frame,
101         /* [in] */ BSTR frameName,
102         /* [in] */ BSTR groupName);
103 
104     virtual HRESULT STDMETHODCALLTYPE setUIDelegate(
105         /* [in] */ IWebUIDelegate *d);
106 
107     virtual HRESULT STDMETHODCALLTYPE uiDelegate(
108         /* [out][retval] */ IWebUIDelegate **d);
109 
110     virtual HRESULT STDMETHODCALLTYPE setResourceLoadDelegate(
111         /* [in] */ IWebResourceLoadDelegate *d);
112 
113     virtual HRESULT STDMETHODCALLTYPE resourceLoadDelegate(
114         /* [out][retval] */ IWebResourceLoadDelegate **d);
115 
116     virtual HRESULT STDMETHODCALLTYPE setDownloadDelegate(
117         /* [in] */ IWebDownloadDelegate *d);
118 
119     virtual HRESULT STDMETHODCALLTYPE downloadDelegate(
120         /* [out][retval] */ IWebDownloadDelegate **d);
121 
122     virtual HRESULT STDMETHODCALLTYPE setFrameLoadDelegate(
123         /* [in] */ IWebFrameLoadDelegate *d);
124 
125     virtual HRESULT STDMETHODCALLTYPE frameLoadDelegate(
126         /* [out][retval] */ IWebFrameLoadDelegate **d);
127 
128     virtual HRESULT STDMETHODCALLTYPE setPolicyDelegate(
129         /* [in] */ IWebPolicyDelegate *d);
130 
131     virtual HRESULT STDMETHODCALLTYPE policyDelegate(
132         /* [out][retval] */ IWebPolicyDelegate **d);
133 
134     virtual HRESULT STDMETHODCALLTYPE mainFrame(
135         /* [out][retval] */ IWebFrame **frame);
136 
137     virtual HRESULT STDMETHODCALLTYPE focusedFrame(
138         /* [out][retval] */ IWebFrame **frame);
139 
140     virtual HRESULT STDMETHODCALLTYPE backForwardList(
141         /* [out][retval] */ IWebBackForwardList **list);
142 
143     virtual HRESULT STDMETHODCALLTYPE setMaintainsBackForwardList(
144         /* [in] */ BOOL flag);
145 
146     virtual HRESULT STDMETHODCALLTYPE goBack(
147         /* [retval][out] */ BOOL *succeeded);
148 
149     virtual HRESULT STDMETHODCALLTYPE goForward(
150         /* [retval][out] */ BOOL *succeeded);
151 
152     virtual HRESULT STDMETHODCALLTYPE goToBackForwardItem(
153         /* [in] */ IWebHistoryItem *item,
154         /* [retval][out] */ BOOL *succeeded);
155 
156     virtual HRESULT STDMETHODCALLTYPE setTextSizeMultiplier(
157         /* [in] */ float multiplier);
158 
159     virtual HRESULT STDMETHODCALLTYPE textSizeMultiplier(
160         /* [retval][out] */ float *multiplier);
161 
162     virtual HRESULT STDMETHODCALLTYPE setApplicationNameForUserAgent(
163         /* [in] */ BSTR applicationName);
164 
165     virtual HRESULT STDMETHODCALLTYPE applicationNameForUserAgent(
166         /* [retval][out] */ BSTR *applicationName);
167 
168     virtual HRESULT STDMETHODCALLTYPE setCustomUserAgent(
169         /* [in] */ BSTR userAgentString);
170 
171     virtual HRESULT STDMETHODCALLTYPE customUserAgent(
172         /* [retval][out] */ BSTR *userAgentString);
173 
174     virtual HRESULT STDMETHODCALLTYPE userAgentForURL(
175         /* [in] */ BSTR url,
176         /* [retval][out] */ BSTR *userAgent);
177 
178     virtual HRESULT STDMETHODCALLTYPE supportsTextEncoding(
179         /* [retval][out] */ BOOL *supports);
180 
181     virtual HRESULT STDMETHODCALLTYPE setCustomTextEncodingName(
182         /* [in] */ BSTR encodingName);
183 
184     virtual HRESULT STDMETHODCALLTYPE customTextEncodingName(
185         /* [retval][out] */ BSTR *encodingName);
186 
187     virtual HRESULT STDMETHODCALLTYPE setMediaStyle(
188         /* [in] */ BSTR media);
189 
190     virtual HRESULT STDMETHODCALLTYPE mediaStyle(
191         /* [retval][out] */ BSTR *media);
192 
193     virtual HRESULT STDMETHODCALLTYPE stringByEvaluatingJavaScriptFromString(
194         /* [in] */ BSTR script,
195         /* [retval][out] */ BSTR *result);
196 
197     virtual HRESULT STDMETHODCALLTYPE windowScriptObject(
198         /* [retval][out] */ IWebScriptObject **webScriptObject);
199 
200     virtual HRESULT STDMETHODCALLTYPE setPreferences(
201         /* [in] */ IWebPreferences *prefs);
202 
203     virtual HRESULT STDMETHODCALLTYPE preferences(
204         /* [retval][out] */ IWebPreferences **prefs);
205 
206     virtual HRESULT STDMETHODCALLTYPE setPreferencesIdentifier(
207         /* [in] */ BSTR anIdentifier);
208 
209     virtual HRESULT STDMETHODCALLTYPE preferencesIdentifier(
210         /* [retval][out] */ BSTR *anIdentifier);
211 
212     virtual HRESULT STDMETHODCALLTYPE setHostWindow(
213         /* [in] */ OLE_HANDLE window);
214 
215     virtual HRESULT STDMETHODCALLTYPE hostWindow(
216         /* [retval][out] */ OLE_HANDLE *window);
217 
218     virtual HRESULT STDMETHODCALLTYPE searchFor(
219         /* [in] */ BSTR str,
220         /* [in] */ BOOL forward,
221         /* [in] */ BOOL caseFlag,
222         /* [in] */ BOOL wrapFlag,
223         /* [retval][out] */ BOOL *found);
224 
225     virtual HRESULT STDMETHODCALLTYPE registerViewClass(
226         /* [in] */ IWebDocumentView *view,
227         /* [in] */ IWebDocumentRepresentation *representation,
228         /* [in] */ BSTR forMIMEType);
229 
230     virtual HRESULT STDMETHODCALLTYPE setGroupName(
231         /* [in] */ BSTR groupName);
232 
233     virtual HRESULT STDMETHODCALLTYPE groupName(
234         /* [retval][out] */ BSTR *groupName);
235 
236     virtual HRESULT STDMETHODCALLTYPE estimatedProgress(
237         /* [retval][out] */ double *estimatedProgress);
238 
239     virtual HRESULT STDMETHODCALLTYPE isLoading(
240         /* [retval][out] */ BOOL *isLoading);
241 
242     virtual HRESULT STDMETHODCALLTYPE elementAtPoint(
243         /* [in] */ LPPOINT point,
244         /* [retval][out] */ IPropertyBag **elementDictionary);
245 
246     virtual HRESULT STDMETHODCALLTYPE pasteboardTypesForSelection(
247         /* [retval][out] */ IEnumVARIANT **enumVariant);
248 
249     virtual HRESULT STDMETHODCALLTYPE writeSelectionWithPasteboardTypes(
250         /* [size_is][in] */ BSTR *types,
251         /* [in] */ int cTypes,
252         /* [in] */ IDataObject *pasteboard);
253 
254     virtual HRESULT STDMETHODCALLTYPE pasteboardTypesForElement(
255         /* [in] */ IPropertyBag *elementDictionary,
256         /* [retval][out] */ IEnumVARIANT **enumVariant);
257 
258     virtual HRESULT STDMETHODCALLTYPE writeElement(
259         /* [in] */ IPropertyBag *elementDictionary,
260         /* [size_is][in] */ BSTR *withPasteboardTypes,
261         /* [in] */ int cWithPasteboardTypes,
262         /* [in] */ IDataObject *pasteboard);
263 
264     virtual HRESULT STDMETHODCALLTYPE selectedText(
265         /* [out, retval] */ BSTR* str);
266 
267     virtual HRESULT STDMETHODCALLTYPE centerSelectionInVisibleArea(
268         /* [in] */ IUnknown* sender);
269 
270     virtual HRESULT STDMETHODCALLTYPE moveDragCaretToPoint(
271         /* [in] */ LPPOINT point);
272 
273     virtual HRESULT STDMETHODCALLTYPE removeDragCaret( void);
274 
275     virtual HRESULT STDMETHODCALLTYPE setDrawsBackground(
276         /* [in] */ BOOL drawsBackground);
277 
278     virtual HRESULT STDMETHODCALLTYPE drawsBackground(
279         /* [retval][out] */ BOOL *drawsBackground);
280 
281     virtual HRESULT STDMETHODCALLTYPE setMainFrameURL(
282         /* [in] */ BSTR urlString);
283 
284     virtual HRESULT STDMETHODCALLTYPE mainFrameURL(
285         /* [retval][out] */ BSTR *urlString);
286 
287     virtual HRESULT STDMETHODCALLTYPE mainFrameDocument(
288         /* [retval][out] */ IDOMDocument **document);
289 
290     virtual HRESULT STDMETHODCALLTYPE mainFrameTitle(
291         /* [retval][out] */ BSTR *title);
292 
293     virtual HRESULT STDMETHODCALLTYPE mainFrameIcon(
294         /* [retval][out] */ OLE_HANDLE *hBitmap);
295 
296     virtual HRESULT STDMETHODCALLTYPE registerURLSchemeAsLocal(
297         /* [in] */ BSTR scheme);
298 
299     // IWebIBActions
300 
301     virtual HRESULT STDMETHODCALLTYPE takeStringURLFrom(
302         /* [in] */ IUnknown *sender);
303 
304     virtual HRESULT STDMETHODCALLTYPE stopLoading(
305         /* [in] */ IUnknown *sender);
306 
307     virtual HRESULT STDMETHODCALLTYPE reload(
308         /* [in] */ IUnknown *sender);
309 
310     virtual HRESULT STDMETHODCALLTYPE canGoBack(
311         /* [in] */ IUnknown *sender,
312         /* [retval][out] */ BOOL *result);
313 
314     virtual HRESULT STDMETHODCALLTYPE goBack(
315         /* [in] */ IUnknown *sender);
316 
317     virtual HRESULT STDMETHODCALLTYPE canGoForward(
318         /* [in] */ IUnknown *sender,
319         /* [retval][out] */ BOOL *result);
320 
321     virtual HRESULT STDMETHODCALLTYPE goForward(
322         /* [in] */ IUnknown *sender);
323 
324     virtual HRESULT STDMETHODCALLTYPE canMakeTextLarger(
325         /* [in] */ IUnknown *sender,
326         /* [retval][out] */ BOOL *result);
327 
328     virtual HRESULT STDMETHODCALLTYPE makeTextLarger(
329         /* [in] */ IUnknown *sender);
330 
331     virtual HRESULT STDMETHODCALLTYPE canMakeTextSmaller(
332         /* [in] */ IUnknown *sender,
333         /* [retval][out] */ BOOL *result);
334 
335     virtual HRESULT STDMETHODCALLTYPE makeTextSmaller(
336         /* [in] */ IUnknown *sender);
337 
338     virtual HRESULT STDMETHODCALLTYPE canMakeTextStandardSize(
339         /* [in] */ IUnknown *sender,
340         /* [retval][out] */ BOOL *result);
341 
342     virtual HRESULT STDMETHODCALLTYPE makeTextStandardSize(
343         /* [in] */ IUnknown *sender);
344 
345     virtual HRESULT STDMETHODCALLTYPE toggleContinuousSpellChecking(
346         /* [in] */ IUnknown *sender);
347 
348     virtual HRESULT STDMETHODCALLTYPE toggleSmartInsertDelete(
349         /* [in] */ IUnknown *sender);
350 
351     virtual HRESULT STDMETHODCALLTYPE toggleGrammarChecking(
352         /* [in] */ IUnknown *sender);
353 
354     // IWebViewCSS
355 
356     virtual HRESULT STDMETHODCALLTYPE computedStyleForElement(
357         /* [in] */ IDOMElement *element,
358         /* [in] */ BSTR pseudoElement,
359         /* [retval][out] */ IDOMCSSStyleDeclaration **style);
360 
361     // IWebViewEditing
362 
363     virtual HRESULT STDMETHODCALLTYPE editableDOMRangeForPoint(
364         /* [in] */ LPPOINT point,
365         /* [retval][out] */ IDOMRange **range);
366 
367     virtual HRESULT STDMETHODCALLTYPE setSelectedDOMRange(
368         /* [in] */ IDOMRange *range,
369         /* [in] */ WebSelectionAffinity affinity);
370 
371     virtual HRESULT STDMETHODCALLTYPE selectedDOMRange(
372         /* [retval][out] */ IDOMRange **range);
373 
374     virtual HRESULT STDMETHODCALLTYPE selectionAffinity(
375         /* [retval][out][retval][out] */ WebSelectionAffinity *affinity);
376 
377     virtual HRESULT STDMETHODCALLTYPE setEditable(
378         /* [in] */ BOOL flag);
379 
380     virtual HRESULT STDMETHODCALLTYPE isEditable(
381         /* [retval][out] */ BOOL *isEditable);
382 
383     virtual HRESULT STDMETHODCALLTYPE setTypingStyle(
384         /* [in] */ IDOMCSSStyleDeclaration *style);
385 
386     virtual HRESULT STDMETHODCALLTYPE typingStyle(
387         /* [retval][out] */ IDOMCSSStyleDeclaration **style);
388 
389     virtual HRESULT STDMETHODCALLTYPE setSmartInsertDeleteEnabled(
390         /* [in] */ BOOL flag);
391 
392     virtual HRESULT STDMETHODCALLTYPE smartInsertDeleteEnabled(
393         /* [in] */ BOOL *enabled);
394 
395     virtual HRESULT STDMETHODCALLTYPE setSelectTrailingWhitespaceEnabled(
396         /* [in] */ BOOL flag);
397 
398     virtual HRESULT STDMETHODCALLTYPE isSelectTrailingWhitespaceEnabled(
399         /* [in] */ BOOL *enabled);
400 
401     virtual HRESULT STDMETHODCALLTYPE setContinuousSpellCheckingEnabled(
402         /* [in] */ BOOL flag);
403 
404     virtual HRESULT STDMETHODCALLTYPE isContinuousSpellCheckingEnabled(
405         /* [retval][out] */ BOOL *enabled);
406 
407     virtual HRESULT STDMETHODCALLTYPE spellCheckerDocumentTag(
408         /* [retval][out] */ int *tag);
409 
410     virtual HRESULT STDMETHODCALLTYPE undoManager(
411         /* [retval][out] */ IWebUndoManager **manager);
412 
413     virtual HRESULT STDMETHODCALLTYPE setEditingDelegate(
414         /* [in] */ IWebEditingDelegate *d);
415 
416     virtual HRESULT STDMETHODCALLTYPE editingDelegate(
417         /* [retval][out] */ IWebEditingDelegate **d);
418 
419     virtual HRESULT STDMETHODCALLTYPE styleDeclarationWithText(
420         /* [in] */ BSTR text,
421         /* [retval][out] */ IDOMCSSStyleDeclaration **style);
422 
423     virtual HRESULT STDMETHODCALLTYPE hasSelectedRange(
424         /* [retval][out] */ BOOL *hasSelectedRange);
425 
426     virtual HRESULT STDMETHODCALLTYPE cutEnabled(
427         /* [retval][out] */ BOOL *enabled);
428 
429     virtual HRESULT STDMETHODCALLTYPE copyEnabled(
430         /* [retval][out] */ BOOL *enabled);
431 
432     virtual HRESULT STDMETHODCALLTYPE pasteEnabled(
433         /* [retval][out] */ BOOL *enabled);
434 
435     virtual HRESULT STDMETHODCALLTYPE deleteEnabled(
436         /* [retval][out] */ BOOL *enabled);
437 
438     virtual HRESULT STDMETHODCALLTYPE editingEnabled(
439         /* [retval][out] */ BOOL *enabled);
440 
441     virtual HRESULT STDMETHODCALLTYPE isGrammarCheckingEnabled(
442         /* [retval][out] */ BOOL *enabled);
443 
444     virtual HRESULT STDMETHODCALLTYPE setGrammarCheckingEnabled(
445         BOOL enabled);
446 
447     virtual HRESULT STDMETHODCALLTYPE setPageSizeMultiplier(
448         /* [in] */ float multiplier);
449 
450     virtual HRESULT STDMETHODCALLTYPE pageSizeMultiplier(
451         /* [retval][out] */ float *multiplier);
452 
453     virtual HRESULT STDMETHODCALLTYPE canZoomPageIn(
454         /* [in] */ IUnknown *sender,
455         /* [retval][out] */ BOOL *result);
456 
457     virtual HRESULT STDMETHODCALLTYPE zoomPageIn(
458         /* [in] */ IUnknown *sender);
459 
460     virtual HRESULT STDMETHODCALLTYPE canZoomPageOut(
461         /* [in] */ IUnknown *sender,
462         /* [retval][out] */ BOOL *result);
463 
464     virtual HRESULT STDMETHODCALLTYPE zoomPageOut(
465         /* [in] */ IUnknown *sender);
466 
467     virtual HRESULT STDMETHODCALLTYPE canResetPageZoom(
468         /* [in] */ IUnknown *sender,
469         /* [retval][out] */ BOOL *result);
470 
471     virtual HRESULT STDMETHODCALLTYPE resetPageZoom(
472         /* [in] */ IUnknown *sender);
473 
474     // IWebViewUndoableEditing
475 
476     virtual HRESULT STDMETHODCALLTYPE replaceSelectionWithNode(
477         /* [in] */ IDOMNode *node);
478 
479     virtual HRESULT STDMETHODCALLTYPE replaceSelectionWithText(
480         /* [in] */ BSTR text);
481 
482     virtual HRESULT STDMETHODCALLTYPE replaceSelectionWithMarkupString(
483         /* [in] */ BSTR markupString);
484 
485     virtual HRESULT STDMETHODCALLTYPE replaceSelectionWithArchive(
486         /* [in] */ IWebArchive *archive);
487 
488     virtual HRESULT STDMETHODCALLTYPE deleteSelection( void);
489 
490     virtual HRESULT STDMETHODCALLTYPE clearSelection(void);
491 
492     virtual HRESULT STDMETHODCALLTYPE applyStyle(
493         /* [in] */ IDOMCSSStyleDeclaration *style);
494 
495     // IWebViewEditingActions
496 
497     virtual HRESULT STDMETHODCALLTYPE copy(
498         /* [in] */ IUnknown *sender);
499 
500     virtual HRESULT STDMETHODCALLTYPE cut(
501         /* [in] */ IUnknown *sender);
502 
503     virtual HRESULT STDMETHODCALLTYPE paste(
504         /* [in] */ IUnknown *sender);
505 
506     virtual HRESULT STDMETHODCALLTYPE copyURL(
507         /* [in] */ BSTR url);
508 
509     virtual HRESULT STDMETHODCALLTYPE copyFont(
510         /* [in] */ IUnknown *sender);
511 
512     virtual HRESULT STDMETHODCALLTYPE pasteFont(
513         /* [in] */ IUnknown *sender);
514 
515     virtual HRESULT STDMETHODCALLTYPE delete_(
516         /* [in] */ IUnknown *sender);
517 
518     virtual HRESULT STDMETHODCALLTYPE pasteAsPlainText(
519         /* [in] */ IUnknown *sender);
520 
521     virtual HRESULT STDMETHODCALLTYPE pasteAsRichText(
522         /* [in] */ IUnknown *sender);
523 
524     virtual HRESULT STDMETHODCALLTYPE changeFont(
525         /* [in] */ IUnknown *sender);
526 
527     virtual HRESULT STDMETHODCALLTYPE changeAttributes(
528         /* [in] */ IUnknown *sender);
529 
530     virtual HRESULT STDMETHODCALLTYPE changeDocumentBackgroundColor(
531         /* [in] */ IUnknown *sender);
532 
533     virtual HRESULT STDMETHODCALLTYPE changeColor(
534         /* [in] */ IUnknown *sender);
535 
536     virtual HRESULT STDMETHODCALLTYPE alignCenter(
537         /* [in] */ IUnknown *sender);
538 
539     virtual HRESULT STDMETHODCALLTYPE alignJustified(
540         /* [in] */ IUnknown *sender);
541 
542     virtual HRESULT STDMETHODCALLTYPE alignLeft(
543         /* [in] */ IUnknown *sender);
544 
545     virtual HRESULT STDMETHODCALLTYPE alignRight(
546         /* [in] */ IUnknown *sender);
547 
548     virtual HRESULT STDMETHODCALLTYPE checkSpelling(
549         /* [in] */ IUnknown *sender);
550 
551     virtual HRESULT STDMETHODCALLTYPE showGuessPanel(
552         /* [in] */ IUnknown *sender);
553 
554     virtual HRESULT STDMETHODCALLTYPE performFindPanelAction(
555         /* [in] */ IUnknown *sender);
556 
557     virtual HRESULT STDMETHODCALLTYPE startSpeaking(
558         /* [in] */ IUnknown *sender);
559 
560     virtual HRESULT STDMETHODCALLTYPE stopSpeaking(
561         /* [in] */ IUnknown *sender);
562 
563     // IWebNotificationObserver
564 
565     virtual HRESULT STDMETHODCALLTYPE onNotify(
566         /* [in] */ IWebNotification *notification);
567 
568     // IWebViewPrivate
569     virtual HRESULT STDMETHODCALLTYPE setCustomDropTarget(
570         /* [in] */ IDropTarget* dt);
571 
572     virtual HRESULT STDMETHODCALLTYPE removeCustomDropTarget();
573 
574     virtual HRESULT STDMETHODCALLTYPE setInViewSourceMode(
575         /* [in] */ BOOL flag);
576 
577     virtual HRESULT STDMETHODCALLTYPE inViewSourceMode(
578         /* [retval][out] */ BOOL* flag);
579 
580     virtual HRESULT STDMETHODCALLTYPE viewWindow(
581         /* [retval][out] */ OLE_HANDLE *window);
582 
583     virtual HRESULT STDMETHODCALLTYPE setFormDelegate(
584         /* [in] */ IWebFormDelegate *formDelegate);
585 
586     virtual HRESULT STDMETHODCALLTYPE formDelegate(
587         /* [retval][out] */ IWebFormDelegate **formDelegate);
588 
589     virtual HRESULT STDMETHODCALLTYPE setFrameLoadDelegatePrivate(
590         /* [in] */ IWebFrameLoadDelegatePrivate *frameLoadDelegatePrivate);
591 
592     virtual HRESULT STDMETHODCALLTYPE frameLoadDelegatePrivate(
593         /* [retval][out] */ IWebFrameLoadDelegatePrivate **frameLoadDelegatePrivate);
594 
595     virtual HRESULT STDMETHODCALLTYPE scrollOffset(
596         /* [retval][out] */ LPPOINT offset);
597 
598     virtual HRESULT STDMETHODCALLTYPE scrollBy(
599         /* [in] */ LPPOINT offset);
600 
601     virtual HRESULT STDMETHODCALLTYPE visibleContentRect(
602         /* [retval][out] */ LPRECT rect);
603 
604     virtual HRESULT STDMETHODCALLTYPE updateFocusedAndActiveState();
605 
606     virtual HRESULT STDMETHODCALLTYPE executeCoreCommandByName(BSTR name, BSTR value);
607 
608     virtual HRESULT STDMETHODCALLTYPE clearMainFrameName();
609 
610     virtual HRESULT STDMETHODCALLTYPE markAllMatchesForText(
611         BSTR search, BOOL caseSensitive, BOOL highlight, UINT limit, UINT* matches);
612 
613     virtual HRESULT STDMETHODCALLTYPE unmarkAllTextMatches();
614 
615     virtual HRESULT STDMETHODCALLTYPE rectsForTextMatches(
616         IEnumTextMatches** pmatches);
617 
618     virtual HRESULT STDMETHODCALLTYPE generateSelectionImage(
619         BOOL forceWhiteText, OLE_HANDLE* hBitmap);
620 
621     virtual HRESULT STDMETHODCALLTYPE selectionRect(
622         RECT* rc);
623 
624     virtual HRESULT STDMETHODCALLTYPE DragEnter(
625         IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
626 
627     virtual HRESULT STDMETHODCALLTYPE DragOver(
628         DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
629 
630     virtual HRESULT STDMETHODCALLTYPE DragLeave();
631 
632     virtual HRESULT STDMETHODCALLTYPE Drop(
633         IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
634 
635     virtual HRESULT STDMETHODCALLTYPE canHandleRequest(
636         IWebURLRequest *request,
637         BOOL *result);
638 
639     virtual HRESULT STDMETHODCALLTYPE standardUserAgentWithApplicationName(
640         /* [in] */ BSTR applicationName,
641         /* [retval][out] */ BSTR *groupName);
642 
643     virtual HRESULT STDMETHODCALLTYPE clearFocusNode();
644 
645     virtual HRESULT STDMETHODCALLTYPE setInitialFocus(
646         /* [in] */ BOOL forward);
647 
648     virtual HRESULT STDMETHODCALLTYPE setTabKeyCyclesThroughElements(
649         /* [in] */ BOOL cycles);
650 
651     virtual HRESULT STDMETHODCALLTYPE tabKeyCyclesThroughElements(
652         /* [retval][out] */ BOOL *result);
653 
654     virtual HRESULT STDMETHODCALLTYPE setAllowSiteSpecificHacks(
655         /* [in] */ BOOL allows);
656 
657     virtual HRESULT STDMETHODCALLTYPE addAdditionalPluginDirectory(
658         /* [in] */ BSTR directory);
659 
660     virtual HRESULT STDMETHODCALLTYPE loadBackForwardListFromOtherView(
661         /* [in] */ IWebView *otherView);
662 
663     virtual HRESULT STDMETHODCALLTYPE inspector(
664         /* [retval][out] */ IWebInspector**);
665 
666     virtual HRESULT STDMETHODCALLTYPE clearUndoRedoOperations( void);
667     virtual HRESULT STDMETHODCALLTYPE shouldClose(
668         /* [retval][out] */ BOOL* result);
669 
670     virtual HRESULT STDMETHODCALLTYPE setProhibitsMainFrameScrolling(BOOL);
671     virtual HRESULT STDMETHODCALLTYPE setShouldApplyMacFontAscentHack(BOOL);
672 
673     virtual HRESULT STDMETHODCALLTYPE windowAncestryDidChange();
674 
675     virtual HRESULT STDMETHODCALLTYPE paintDocumentRectToContext(
676         /* [in] */ RECT rect,
677         /* [in] */ OLE_HANDLE dc);
678 
679     virtual HRESULT STDMETHODCALLTYPE setCustomHTMLTokenizerTimeDelay(
680         /* [in] */ double timeDelay);
681 
682     virtual HRESULT STDMETHODCALLTYPE setCustomHTMLTokenizerChunkSize(
683         /* [in] */ int chunkSize);
684 
685     virtual HRESULT STDMETHODCALLTYPE backingStore(
686         /* [out, retval] */ OLE_HANDLE* hBitmap);
687 
688     virtual HRESULT STDMETHODCALLTYPE setTransparent(
689         /* [in] */ BOOL transparent);
690 
691     virtual HRESULT STDMETHODCALLTYPE transparent(
692         /* [out, retval] */ BOOL* transparent);
693 
694     virtual HRESULT STDMETHODCALLTYPE setDefersCallbacks(
695         /* [in] */ BOOL defersCallbacks);
696 
697     virtual HRESULT STDMETHODCALLTYPE defersCallbacks(
698         /* [out, retval] */ BOOL* defersCallbacks);
699 
700     virtual HRESULT STDMETHODCALLTYPE globalHistoryItem(
701         /* [out, retval] */ IWebHistoryItem** item);
702 
703     virtual HRESULT STDMETHODCALLTYPE setAlwaysUsesComplexTextCodePath(
704         /* [in] */ BOOL complex);
705 
706     virtual HRESULT STDMETHODCALLTYPE alwaysUsesComplexTextCodePath(
707         /* [out, retval] */ BOOL* complex);
708 
709     virtual HRESULT STDMETHODCALLTYPE setCookieEnabled(
710         /* [in] */ BOOL enable);
711 
712     virtual HRESULT STDMETHODCALLTYPE cookieEnabled(
713         /* [out, retval] */ BOOL* enabled);
714 
715     virtual HRESULT STDMETHODCALLTYPE setMediaVolume(
716         /* [in] */ float volume);
717 
718     virtual HRESULT STDMETHODCALLTYPE mediaVolume(
719         /* [out, retval] */ float* volume);
720 
721     virtual HRESULT STDMETHODCALLTYPE registerEmbeddedViewMIMEType(
722         /* [in] */ BSTR mimeType);
723 
724     virtual HRESULT STDMETHODCALLTYPE setMemoryCacheDelegateCallsEnabled(
725         /* [in] */ BOOL enabled);
726 
727     // WebView
728     bool shouldUseEmbeddedView(const WebCore::String& mimeType) const;
729 
730     WebCore::Page* page();
731     bool handleMouseEvent(UINT, WPARAM, LPARAM);
setMouseActivated(bool flag)732     void setMouseActivated(bool flag) { m_mouseActivated = flag; }
733     bool handleContextMenuEvent(WPARAM, LPARAM);
734     bool onMeasureItem(WPARAM, LPARAM);
735     bool onDrawItem(WPARAM, LPARAM);
736     bool onInitMenuPopup(WPARAM, LPARAM);
737     bool onUninitMenuPopup(WPARAM, LPARAM);
738     void performContextMenuAction(WPARAM, LPARAM, bool byPosition);
739     bool mouseWheel(WPARAM, LPARAM, bool isHorizontal);
740     bool execCommand(WPARAM wParam, LPARAM lParam);
741     bool keyDown(WPARAM, LPARAM, bool systemKeyDown = false);
742     bool keyUp(WPARAM, LPARAM, bool systemKeyDown = false);
743     bool keyPress(WPARAM, LPARAM, bool systemKeyDown = false);
744     bool inResizer(LPARAM lParam);
745     void paint(HDC, LPARAM);
746     void paintIntoWindow(HDC bitmapDC, HDC windowDC, const WebCore::IntRect& dirtyRect);
747     bool ensureBackingStore();
748     void addToDirtyRegion(const WebCore::IntRect&);
749     void addToDirtyRegion(HRGN);
750     void scrollBackingStore(WebCore::FrameView*, int dx, int dy, const WebCore::IntRect& scrollViewRect, const WebCore::IntRect& clipRect);
751     void deleteBackingStore();
752     void repaint(const WebCore::IntRect&, bool contentChanged, bool immediate = false, bool repaintContentOnly = false);
753     void frameRect(RECT* rect);
754     void closeWindow();
755     void closeWindowSoon();
756     void close();
didClose()757     bool didClose() const { return m_didClose; }
758 
transparent()759     bool transparent() const { return m_transparent; }
760 
761     bool onIMEStartComposition();
762     bool onIMEComposition(LPARAM);
763     bool onIMEEndComposition();
764     bool onIMEChar(WPARAM, LPARAM);
765     bool onIMENotify(WPARAM, LPARAM, LRESULT*);
766     bool onIMERequest(WPARAM, LPARAM, LRESULT*);
767     bool onIMESelect(WPARAM, LPARAM);
768     bool onIMESetContext(WPARAM, LPARAM);
769     void selectionChanged();
770     void resetIME(WebCore::Frame*);
771     void setInputMethodState(bool);
772 
773     HRESULT registerDragDrop();
774     HRESULT revokeDragDrop();
775 
776     // Convenient to be able to violate the rules of COM here for easy movement to the frame.
topLevelFrame()777     WebFrame* topLevelFrame() const { return m_mainFrame; }
778     const WebCore::String& userAgentForKURL(const WebCore::KURL& url);
779 
780     static bool canHandleRequest(const WebCore::ResourceRequest&);
781 
782     static WebCore::String standardUserAgentWithApplicationName(const WebCore::String&);
783 
setIsBeingDestroyed()784     void setIsBeingDestroyed() { m_isBeingDestroyed = true; }
isBeingDestroyed()785     bool isBeingDestroyed() const { return m_isBeingDestroyed; }
786 
787     const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
788     bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*);
789 
isPainting()790     bool isPainting() const { return m_paintCount > 0; }
791 
792     void setToolTip(const WebCore::String&);
793 
794     void registerForIconNotification(bool listen);
795     void dispatchDidReceiveIconFromWebFrame(WebFrame*);
796 
797     HRESULT notifyDidAddIcon(IWebNotification*);
798     HRESULT notifyPreferencesChanged(IWebNotification*);
799 
800     static void setCacheModel(WebCacheModel);
801     static WebCacheModel cacheModel();
802     static bool didSetCacheModel();
803     static WebCacheModel maxCacheModelInAnyInstance();
804 
805     void updateActiveStateSoon() const;
806     void deleteBackingStoreSoon();
807     void cancelDeleteBackingStoreSoon();
808 
topLevelParent()809     HWND topLevelParent() const { return m_topLevelParent; }
810 
811     void updateActiveState();
812 
813     bool onGetObject(WPARAM, LPARAM, LRESULT&) const;
814     static STDMETHODIMP AccessibleObjectFromWindow(HWND, DWORD objectID, REFIID, void** ppObject);
815 
816 private:
817     void setZoomMultiplier(float multiplier, bool isTextOnly);
818     float zoomMultiplier(bool isTextOnly);
819     bool canZoomIn(bool isTextOnly);
820     HRESULT zoomIn(bool isTextOnly);
821     bool canZoomOut(bool isTextOnly);
822     HRESULT zoomOut(bool isTextOnly);
823     bool canResetZoom(bool isTextOnly);
824     HRESULT resetZoom(bool isTextOnly);
825     bool active();
826 
827     enum WindowsToPaint { PaintWebViewOnly, PaintWebViewAndChildren };
828     void paintIntoBackingStore(WebCore::FrameView*, HDC bitmapDC, const WebCore::IntRect& dirtyRect, WindowsToPaint);
829     void updateBackingStore(WebCore::FrameView*, HDC = 0, bool backingStoreCompletelyDirty = false, WindowsToPaint = PaintWebViewOnly);
830 
831 protected:
832     HIMC getIMMContext();
833     void releaseIMMContext(HIMC);
allowSiteSpecificHacks()834     static bool allowSiteSpecificHacks() { return s_allowSiteSpecificHacks; }
835     void preflightSpellChecker();
836     bool continuousCheckingAllowed();
837     void initializeToolTipWindow();
838     void closeWindowTimerFired(WebCore::Timer<WebView>*);
839     void prepareCandidateWindow(WebCore::Frame*, HIMC);
840     void updateSelectionForIME();
841     bool onIMERequestCharPosition(WebCore::Frame*, IMECHARPOSITION*, LRESULT*);
842     bool onIMERequestReconvertString(WebCore::Frame*, RECONVERTSTRING*, LRESULT*);
843     bool developerExtrasEnabled() const;
844 
845     // AllWebViewSet functions
846     void addToAllWebViewsSet();
847     void removeFromAllWebViewsSet();
848 
849     virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM);
850 
851     ULONG m_refCount;
852     HWND m_hostWindow;
853     HWND m_viewWindow;
854     WebFrame* m_mainFrame;
855     WebCore::Page* m_page;
856 
857     OwnPtr<HBITMAP> m_backingStoreBitmap;
858     SIZE m_backingStoreSize;
859     OwnPtr<HRGN> m_backingStoreDirtyRegion;
860 
861     COMPtr<IWebEditingDelegate> m_editingDelegate;
862     COMPtr<IWebFrameLoadDelegate> m_frameLoadDelegate;
863     COMPtr<IWebFrameLoadDelegatePrivate> m_frameLoadDelegatePrivate;
864     COMPtr<IWebUIDelegate> m_uiDelegate;
865     COMPtr<IWebUIDelegatePrivate> m_uiDelegatePrivate;
866     COMPtr<IWebFormDelegate> m_formDelegate;
867     COMPtr<IWebPolicyDelegate> m_policyDelegate;
868     COMPtr<IWebResourceLoadDelegate> m_resourceLoadDelegate;
869     COMPtr<IWebDownloadDelegate> m_downloadDelegate;
870     COMPtr<WebPreferences> m_preferences;
871     COMPtr<WebInspector> m_webInspector;
872 
873     bool m_userAgentOverridden;
874     bool m_useBackForwardList;
875     WebCore::String m_userAgentCustom;
876     WebCore::String m_userAgentStandard;
877     float m_zoomMultiplier;
878     WebCore::String m_overrideEncoding;
879     WebCore::String m_applicationName;
880     bool m_mouseActivated;
881     // WebCore dragging logic needs to be able to inspect the drag data
882     // this is updated in DragEnter/Leave/Drop
883     COMPtr<IDataObject> m_dragData;
884     COMPtr<IDropTargetHelper> m_dropTargetHelper;
885     UChar m_currentCharacterCode;
886     bool m_isBeingDestroyed;
887     unsigned m_paintCount;
888     bool m_hasSpellCheckerDocumentTag;
889     bool m_smartInsertDeleteEnabled;
890     bool m_selectTrailingWhitespaceEnabled;
891     bool m_didClose;
892     bool m_hasCustomDropTarget;
893     unsigned m_inIMEComposition;
894     HWND m_toolTipHwnd;
895     WebCore::String m_toolTip;
896     bool m_deleteBackingStoreTimerActive;
897 
898     bool m_transparent;
899 
900     static bool s_allowSiteSpecificHacks;
901 
902     WebCore::Timer<WebView> m_closeWindowTimer;
903     OwnPtr<TRACKMOUSEEVENT> m_mouseOutTracker;
904 
905     HWND m_topLevelParent;
906 
907     OwnPtr<HashSet<WebCore::String> > m_embeddedViewMIMETypes;
908 };
909 
910 #endif
911