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