/*
 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

#ifndef DO_NO_IMPORTS
import "oaidl.idl";
import "ocidl.idl";
import "IWebUndoTarget.idl";
import "IWebURLRequest.idl";
import "IWebFrame.idl";
#endif

interface IWebFrame;
interface IWebView;
interface IWebURLRequest;
interface IWebUndoTarget;

/*!
    @enum WebMenuItemTag
    @discussion Each menu item in the default menu items array passed in
    contextMenuItemsForElement:defaultMenuItems: has its tag set to one of the WebMenuItemTags.
    When iterating through the default menu items array, use the tag to differentiate between them.
*/
typedef enum WebMenuItemTag {
    WebMenuItemTagOpenLinkInNewWindow=1,
    WebMenuItemTagDownloadLinkToDisk,
    WebMenuItemTagCopyLinkToClipboard,
    WebMenuItemTagOpenImageInNewWindow,
    WebMenuItemTagDownloadImageToDisk,
    WebMenuItemTagCopyImageToClipboard,
    WebMenuItemTagOpenFrameInNewWindow,
    WebMenuItemTagCopy,
    WebMenuItemTagGoBack,
    WebMenuItemTagGoForward,
    WebMenuItemTagStop,
    WebMenuItemTagReload,
    WebMenuItemTagCut,
    WebMenuItemTagPaste,
    WebMenuItemTagSpellingGuess,
    WebMenuItemTagNoGuessesFound,
    WebMenuItemTagIgnoreSpelling,
    WebMenuItemTagLearnSpelling,
    WebMenuItemTagOther,
    WebMenuItemTagSearchInSpotlight,
    WebMenuItemTagSearchWeb,
    WebMenuItemTagLookUpInDictionary,
    WebMenuItemTagOpenWithDefaultApplication,
    WebMenuItemPDFActualSize,
    WebMenuItemPDFZoomIn,
    WebMenuItemPDFZoomOut,
    WebMenuItemPDFAutoSize,
    WebMenuItemPDFSinglePage,
    WebMenuItemPDFFacingPages,
    WebMenuItemPDFContinuous,
    WebMenuItemPDFNextPage,
    WebMenuItemPDFPreviousPage,
    // FIXME: Review these names before release!
    WebMenuItemTagOpenLink = 2000,
    WebMenuItemTagIgnoreGrammar,
    WebtMenuItemTagSpellingMenu,
    WebMenuItemTagShowSpellingPanel,
    WebMenuItemTagCheckSpelling,
    WebMenuItemTagCheckSpellingWhileTyping,
    WebMenuItemTagCheckGrammarWithSpelling,
    WebMenuItemTagFontMenu,
    WebMenuItemTagShowFonts,
    WebMenuItemTagBold,
    WebMenuItemTagItalic,
    WebMenuItemTagUnderline,
    WebMenuItemTagOutline,
    WebMenuItemTagStyles,
    WebMenuItemTagShowColors,
    WebMenuItemTagSpeechMenu,
    WebMenuItemTagStartSpeaking,
    WebMenuItemTagStopSpeaking,
    WebMenuItemTagWritingDirectionMenu,
    WebMenuItemTagDefaultDirection,
    WebMenuItemTagLeftToRight,
    WebMenuItemTagRightToLeft,
    WebMenuItemTagPDFSinglePageScrolling,
    WebMenuItemTagPDFFacingPagesScrolling,
    WebMenuItemTagInspectElement,
    WebMenuItemBaseApplicationTag=10000
} WebMenuItemTag;

/*!
    @enum WebDragDestinationAction
    @abstract Actions that the destination of a drag can perform.
    @constant WebDragDestinationActionNone No action
    @constant WebDragDestinationActionDHTML Allows DHTML (such as JavaScript) to handle the drag
    @constant WebDragDestinationActionEdit Allows editable documents to be edited from the drag
    @constant WebDragDestinationActionLoad Allows a location change from the drag
    @constant WebDragDestinationActionAny Allows any of the above to occur
*/
typedef enum WebDragDestinationAction {
    WebDragDestinationActionNone    = 0,
    WebDragDestinationActionDHTML   = 1,
    WebDragDestinationActionEdit    = 2,
    WebDragDestinationActionLoad    = 4,
    WebDragDestinationActionAny     = (unsigned long)-1
} WebDragDestinationAction;

/*!
    @enum WebDragSourceAction
    @abstract Actions that the source of a drag can perform.
    @constant WebDragSourceActionNone No action
    @constant WebDragSourceActionDHTML Allows DHTML (such as JavaScript) to start a drag
    @constant WebDragSourceActionImage Allows an image drag to occur
    @constant WebDragSourceActionLink Allows a link drag to occur
    @constant WebDragSourceActionSelection Allows a selection drag to occur
    @constant WebDragSourceActionAny Allows any of the above to occur
*/
typedef enum WebDragSourceAction {
    WebDragSourceActionNone         = 0,
    WebDragSourceActionDHTML        = 1,
    WebDragSourceActionImage        = 2,
    WebDragSourceActionLink         = 4,
    WebDragSourceActionSelection    = 8,
    WebDragSourceActionAny          = (unsigned long)-1
} WebDragSourceAction;


/*!
    @protocol WebOpenPanelResultListener
    @discussion This protocol is used to call back with the results of
    the file open panel requested by runOpenPanelForFileButtonWithResultListener:
    @protocol WebOpenPanelResultListener <NSObject>
*/
[
    object,
    oleautomation,
    uuid(634198C7-9DFC-4aba-9E8C-90AEEA7A4144),
    pointer_default(unique)
]
interface IWebOpenPanelResultListener : IUnknown
{
    /*!
        @method chooseFilename:
        @abstract Call this method to return a filename from the file open panel.
        @param fileName
        - (void)chooseFilename:(NSString *)fileName;
    */
    HRESULT chooseFilename([out, retval] BSTR* fileName);

    /*!
        @method cancel
        @abstract Call this method to indicate that the file open panel was cancelled.
        - (void)cancel;
    */
    HRESULT cancel();
}

/*!
    @category WebUIDelegate
    @discussion A class that implements WebUIDelegate provides
    window-related methods that may be used by Javascript, plugins and
    other aspects of web pages. These methods are used to open new
    windows and control aspects of existing windows.
    @interface NSObject (WebUIDelegate)
*/
[
    object,
    oleautomation,
    uuid(042B7EE3-A5A4-4a8f-8C33-775CD9E89C7C),
    pointer_default(unique)
]
interface IWebUIDelegate : IUnknown
{
    /*!
        @method webView:createWebViewWithRequest:
        @abstract Create a new window and begin to load the specified request.
        @discussion The newly created window is hidden, and the window operations delegate on the
        new WebViews will get a webViewShow: call.
        @param sender The WebView sending the delegate method.
        @param request The request to load.
        @result The WebView for the new window.
        - (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request;
    */
    HRESULT createWebViewWithRequest([in] IWebView* sender, [in] IWebURLRequest* request, [out, retval] IWebView** newWebView);

    /*!
        @method webViewShow:
        @param sender The WebView sending the delegate method.
        @abstract Show the window that contains the top level view of the WebView,
        ordering it frontmost.
        @discussion This will only be called just after createWindowWithRequest:
        is used to create a new window.
        - (void)webViewShow:(WebView *)sender;
    */
    HRESULT webViewShow([in] IWebView* sender);

    /*!
        @method webViewClose:
        @abstract Close the current window. 
        @param sender The WebView sending the delegate method.
        @discussion Clients showing multiple views in one window may
        choose to close only the one corresponding to this
        WebView. Other clients may choose to ignore this method
        entirely.
        - (void)webViewClose:(WebView *)sender;
    */
    HRESULT webViewClose([in] IWebView* sender);

    /*!
        @method webViewFocus:
        @abstract Focus the current window (i.e. makeKeyAndOrderFront:).
        @param The WebView sending the delegate method.
        @discussion Clients showing multiple views in one window may want to
        also do something to focus the one corresponding to this WebView.
        - (void)webViewFocus:(WebView *)sender;
    */
    HRESULT webViewFocus([in] IWebView* sender);

    /*!
        @method webViewUnfocus:
        @abstract Unfocus the current window.
        @param sender The WebView sending the delegate method.
        @discussion Clients showing multiple views in one window may want to
        also do something to unfocus the one corresponding to this WebView.
        - (void)webViewUnfocus:(WebView *)sender;
    */
    HRESULT webViewUnfocus([in] IWebView* sender);

    /*!
        @method webViewFirstResponder:
        @abstract Get the first responder for this window.
        @param sender The WebView sending the delegate method.
        @discussion This method should return the focused control in the
        WebView's view, if any. If the view is out of the window
        hierarchy, this might return something than calling firstResponder
        on the real NSWindow would. It's OK to return either nil or the
        real first responder if some control not in the window has focus.
        - (NSResponder *)webViewFirstResponder:(WebView *)sender;
    */
    HRESULT webViewFirstResponder([in] IWebView* sender, [out, retval] OLE_HANDLE* responderHWnd);

    /*!
        @method webView:makeFirstResponder:
        @abstract Set the first responder for this window.
        @param sender The WebView sending the delegate method.
        @param responder The responder to make first (will always be a view)
        @discussion responder will always be a view that is in the view
        subhierarchy of the top-level web view for this WebView. If the
        WebView's top level view is currently out of the view
        hierarchy, it may be desirable to save the first responder
        elsewhere, or possibly ignore this call.
        - (void)webView:(WebView *)sender makeFirstResponder:(NSResponder *)responder;
    */
    HRESULT makeFirstResponder([in] IWebView* sender, [in] OLE_HANDLE responderHWnd);

    /*!
        @method webView:setStatusText:
        @abstract Set the window's status display, if any, to the specified string.
        @param sender The WebView sending the delegate method.
        @param text The status text to set
        - (void)webView:(WebView *)sender setStatusText:(NSString *)text;
    */
    HRESULT setStatusText([in] IWebView* sender, [in] BSTR text);

    /*!
        @method webViewStatusText:
        @abstract Get the currently displayed status text.
        @param sender The WebView sending the delegate method.
        @result The status text
        - (NSString *)webViewStatusText:(WebView *)sender;
    */
    HRESULT webViewStatusText([in] IWebView* sender, [out, retval] BSTR* text);

    /*!
        @method webViewAreToolbarsVisible:
        @abstract Determine whether the window's toolbars are currently visible
        @param sender The WebView sending the delegate method.
        @discussion This method should return YES if the window has any
        toolbars that are currently on, besides the status bar. If the app
        has more than one toolbar per window, for example a regular
        command toolbar and a favorites bar, it should return YES from
        this method if at least one is on.
        @result YES if at least one toolbar is visible, otherwise NO.
        - (BOOL)webViewAreToolbarsVisible:(WebView *)sender;
    */
    HRESULT webViewAreToolbarsVisible([in] IWebView* sender, [out, retval] BOOL* visible);

    /*!
        @method webView:setToolbarsVisible:
        @param sender The WebView sending the delegate method.
        @abstract Set whether the window's toolbars are currently visible.
        @param visible New value for toolbar visibility
        @discussion Setting this to YES should turn on all toolbars
        (except for a possible status bar). Setting it to NO should turn
        off all toolbars (with the same exception).
        - (void)webView:(WebView *)sender setToolbarsVisible:(BOOL)visible;
    */
    HRESULT setToolbarsVisible([in] IWebView* sender, [in] BOOL visible);

    /*!
        @method webViewIsStatusBarVisible:
        @abstract Determine whether the status bar is visible.
        @param sender The WebView sending the delegate method.
        @result YES if the status bar is visible, otherwise NO.
        - (BOOL)webViewIsStatusBarVisible:(WebView *)sender;
    */
    HRESULT webViewIsStatusBarVisible([in] IWebView* sender, [out, retval] BOOL* visible);

    /*!
        @method webView:setStatusBarVisible:
        @abstract Set whether the status bar is currently visible.
        @param visible The new visibility value
        @discussion Setting this to YES should show the status bar,
        setting it to NO should hide it.
        - (void)webView:(WebView *)sender setStatusBarVisible:(BOOL)visible;
    */
    HRESULT setStatusBarVisible([in] IWebView* sender, [in] BOOL visible);

    /*!
        @method webViewIsResizable:
        @abstract Determine whether the window is resizable or not.
        @param sender The WebView sending the delegate method.
        @result YES if resizable, NO if not.
        @discussion If there are multiple views in the same window, they
        have have their own separate resize controls and this may need to
        be handled specially.
        - (BOOL)webViewIsResizable:(WebView *)sender;
    */
    HRESULT webViewIsResizable([in] IWebView* sender, [out, retval] BOOL* resizable);

    /*!
        @method webView:setResizable:
        @abstract Set the window to resizable or not
        @param sender The WebView sending the delegate method.
        @param resizable YES if the window should be made resizable, NO if not.
        @discussion If there are multiple views in the same window, they
        have have their own separate resize controls and this may need to
        be handled specially.
        - (void)webView:(WebView *)sender setResizable:(BOOL)resizable;
    */
    HRESULT setResizable([in] IWebView* sender, [in] BOOL resizable);

    /*!
        @method webView:setFrame:
        @abstract Set the window's frame rect
        @param sender The WebView sending the delegate method.
        @param frame The new window frame size
        @discussion Even though a caller could set the frame directly using the NSWindow,
        this method is provided so implementors of this protocol can do special
        things on programmatic move/resize, like avoiding autosaving of the size.
        - (void)webView:(WebView *)sender setFrame:(NSRect)frame;
    */
    HRESULT setFrame([in] IWebView* sender, [in] RECT* frame);

    /*!
        @method webViewFrame:
        @param sender The WebView sending the delegate method.
        @abstract REturn the window's frame rect
        @discussion 
        - (NSRect)webViewFrame:(WebView *)sender;
    */
    HRESULT webViewFrame([in] IWebView* sender, [out, retval] RECT* frame);

    /*!
        @method webView:setContentRect:
        @abstract Set the window's content rect
        @param sender The WebView sending the delegate method.
        @param frame The new window content rect
        @discussion Even though a caller could set the content rect
        directly using the NSWindow, this method is provided so
        implementors of this protocol can do special things on
        programmatic move/resize, like avoiding autosaving of the size.
        - (void)webView:(WebView *)sender setContentRect:(NSRect)contentRect;
    */
    HRESULT setContentRect([in] IWebView* sender, [in] RECT* contentRect);

    /*!
        @method webViewContentRect:
        @abstract Return the window's content rect
        @discussion 
        - (NSRect)webViewContentRect:(WebView *)sender;
    */
    HRESULT webViewContentRect([in] IWebView* sender, [out, retval] RECT* contentRect);

    /*!
        @method webView:runJavaScriptAlertPanelWithMessage:
        @abstract Display a JavaScript alert panel
        @param sender The WebView sending the delegate method.
        @param message The message to display
        @discussion Clients should visually indicate that this panel comes
        from JavaScript. The panel should have a single OK button.
        - (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message;
    */
    HRESULT runJavaScriptAlertPanelWithMessage([in] IWebView* sender, [in] BSTR message);

    /*!
        @method webView:runJavaScriptConfirmPanelWithMessage:
        @abstract Display a JavaScript confirm panel
        @param sender The WebView sending the delegate method.
        @param message The message to display
        @result YES if the user hit OK, no if the user chose Cancel.
        @discussion Clients should visually indicate that this panel comes
        from JavaScript. The panel should have two buttons, e.g. "OK" and
        "Cancel".
        - (BOOL)webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message;
    */
    HRESULT runJavaScriptConfirmPanelWithMessage([in] IWebView* sender, [in] BSTR message, [out, retval] BOOL* result);

    /*!
        @method webView:runJavaScriptTextInputPanelWithPrompt:defaultText:
        @abstract Display a JavaScript text input panel
        @param sender The WebView sending the delegate method.
        @param message The message to display
        @param defaultText The initial text for the text entry area.
        @result The typed text if the user hit OK, otherwise nil.
        @discussion Clients should visually indicate that this panel comes
        from JavaScript. The panel should have two buttons, e.g. "OK" and
        "Cancel", and an area to type text.
        - (NSString *)webView:(WebView *)sender runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText;
    */
    HRESULT runJavaScriptTextInputPanelWithPrompt([in] IWebView* sender, [in] BSTR message, [in] BSTR defaultText, [out, retval] BSTR* result);

    /*!
        @method webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:
        @abstract Display a confirm panel by an "before unload" event handler.
        @param sender The WebView sending the delegate method.
        @param message The message to display.
        @param frame The WebFrame whose JavaScript initiated this call.
        @result YES if the user hit OK, NO if the user chose Cancel.
        @discussion Clients should include a message in addition to the one
        supplied by the web page that indicates. The panel should have 
        two buttons, e.g. "OK" and "Cancel".
        - (BOOL)webView:(WebView *)sender runBeforeUnloadConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;
    */
    HRESULT runBeforeUnloadConfirmPanelWithMessage([in] IWebView* sender, [in] BSTR message, [in] IWebFrame* initiatedByFrame, [out, retval] BOOL* result);

    /*!
        @method webView:runOpenPanelForFileButtonWithResultListener:
        @abstract Display a file open panel for a file input control.
        @param sender The WebView sending the delegate method.
        @param resultListener The object to call back with the results.
        @discussion This method is passed a callback object instead of giving a return
        value so that it can be handled with a sheet.
        - (void)webView:(WebView *)sender runOpenPanelForFileButtonWithResultListener:(id<WebOpenPanelResultListener>)resultListener;
    */
    HRESULT runOpenPanelForFileButtonWithResultListener([in] IWebView* sender, [in] IWebOpenPanelResultListener* resultListener);

    /*!
        @method webView:mouseDidMoveOverElement:modifierFlags:
        @abstract Update the window's feedback for mousing over links to reflect a new item the mouse is over
        or new modifier flags.
        @param sender The WebView sending the delegate method.
        @param elementInformation Dictionary that describes the element that the mouse is over, or nil.
        @param modifierFlags The modifier flags as in NSEvent.
        - (void)webView:(WebView *)sender mouseDidMoveOverElement:(NSDictionary *)elementInformation modifierFlags:(WebNSUInt)modifierFlags;
    */
    HRESULT mouseDidMoveOverElement([in] IWebView* sender, [in] IPropertyBag* elementInformation, [in] UINT modifierFlags);

    /*!
        @method webView:contextMenuItemsForElement:defaultMenuItems:
        @abstract Returns the menu items to display in an element's contextual menu.
        @param sender The WebView sending the delegate method.
        @param element A dictionary representation of the clicked element.
        @param defaultMenuItems An array of default NSMenuItems to include in all contextual menus.
        @result An array of NSMenuItems to include in the contextual menu.
        - (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems;
    */
    HRESULT contextMenuItemsForElement([in] IWebView* sender, [in] IPropertyBag* element, [in] OLE_HANDLE defaultItemsHMenu, [out, retval] OLE_HANDLE* resultHMenu);

    /*!
        @method webView:validateUserInterfaceItem:defaultValidation:
        @abstract Controls UI validation
        @param webView The WebView sending the delegate method
        @param item The user interface item being validated
        @pararm defaultValidation Whether or not the WebView thinks the item is valid
        @discussion This method allows the UI delegate to control WebView's validation of user interface items.
        See WebView.h to see the methods to that WebView can currently validate. See NSUserInterfaceValidations and
        NSValidatedUserInterfaceItem for information about UI validation.
        - (BOOL)webView:(WebView *)webView validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item defaultValidation:(BOOL)defaultValidation;
    */
    HRESULT validateUserInterfaceItem([in] IWebView* webView, [in] UINT itemCommandID, [in] BOOL defaultValidation, [out, retval] BOOL* isValid);

    /*!
        @method webView:shouldPerformAction:fromSender:
        @abstract Controls actions
        @param webView The WebView sending the delegate method
        @param action The action being sent
        @param sender The sender of the action
        @discussion This method allows the UI delegate to control WebView's behavior when an action is being sent.
        For example, if the action is copy:, the delegate can return YES to allow WebView to perform its default
        copy behavior or return NO and perform copy: in some other way. See WebView.h to see the actions that
        WebView can perform.
        - (BOOL)webView:(WebView *)webView shouldPerformAction:(SEL)action fromSender:(id)sender;
    */
    HRESULT shouldPerformAction([in] IWebView* webView, [in] UINT itemCommandID, [in] UINT sender);

    /*!
        @method webView:dragDestinationActionMaskForDraggingInfo:
        @abstract Controls behavior when dragging to a WebView
        @param webView The WebView sending the delegate method
        @param draggingInfo The dragging info of the drag
        @discussion This method is called periodically as something is dragged over a WebView. The UI delegate can return a mask
        indicating which drag destination actions can occur, WebDragDestinationActionAny to allow any kind of action or
        WebDragDestinationActionNone to not accept the drag.
        - (unsigned)webView:(WebView *)webView dragDestinationActionMaskForDraggingInfo:(id <NSDraggingInfo>)draggingInfo;
    */
    HRESULT dragDestinationActionMaskForDraggingInfo([in] IWebView* webView, [in] IDataObject* draggingInfo, [out, retval] WebDragDestinationAction* action);

    /*!
        @method webView:willPerformDragDestinationAction:forDraggingInfo:
        @abstract Informs that WebView will perform a drag destination action
        @param webView The WebView sending the delegate method
        @param action The drag destination action
        @param draggingInfo The dragging info of the drag
        @discussion This method is called after the last call to webView:dragDestinationActionMaskForDraggingInfo: after something is dropped on a WebView.
        This method informs the UI delegate of the drag destination action that WebView will perform.
        - (void)webView:(WebView *)webView willPerformDragDestinationAction:(WebDragDestinationAction)action forDraggingInfo:(id <NSDraggingInfo>)draggingInfo;
    */
    HRESULT willPerformDragDestinationAction([in] IWebView* webView, [in] WebDragDestinationAction action, [in] IDataObject* draggingInfo);

    /*!
        @method webView:dragSourceActionMaskForPoint:
        @abstract Controls behavior when dragging from a WebView
        @param webView The WebView sending the delegate method
        @param point The point where the drag started in the coordinates of the WebView
        @discussion This method is called after the user has begun a drag from a WebView. The UI delegate can return a mask indicating
        which drag source actions can occur, WebDragSourceActionAny to allow any kind of action or WebDragSourceActionNone to not begin a drag.
        - (unsigned)webView:(WebView *)webView dragSourceActionMaskForPoint:(NSPoint)point;
    */
    HRESULT dragSourceActionMaskForPoint([in] IWebView* webView, [in] LPPOINT point, [out, retval] WebDragSourceAction* action);

    /*!
        @method webView:willPerformDragSourceAction:fromPoint:withPasteboard:
        @abstract Informs that a drag a has begun from a WebView
        @param webView The WebView sending the delegate method
        @param action The drag source action
        @param point The point where the drag started in the coordinates of the WebView
        @param pasteboard The drag pasteboard
        @discussion This method is called after webView:dragSourceActionMaskForPoint: is called after the user has begun a drag from a WebView.
        This method informs the UI delegate of the drag source action that will be performed and gives the delegate an opportunity to modify
        the contents of the dragging pasteboard.
        - (void)webView:(WebView *)webView willPerformDragSourceAction:(WebDragSourceAction)action fromPoint:(NSPoint)point withPasteboard:(NSPasteboard *)pasteboard;
    */
    HRESULT willPerformDragSourceAction([in] IWebView* webView, [in] WebDragSourceAction action, [in] LPPOINT point, [in] IDataObject* pasteboard, [out, retval] IDataObject** newPasteboard);

    /*!
        @method webView:contextMenuItemSelected:ForElement:
        @abstract Perform the action associated with the selected item.
        @param sender The WebView sending the delegate method.
        @param item The menu item that was selected.
        @param element A dictionary representation of the clicked element.
    */
    [local] HRESULT contextMenuItemSelected([in] IWebView* sender, [in] void* item, [in] IPropertyBag* element);

    /*
        @method hasCustomMenuImplementation:
        @abstract Returns whether the application uses the following functions to create a custom menu impementation.
    */
    HRESULT hasCustomMenuImplementation([out, retval] BOOL* hasCustomMenus);
    
    /*
        @method webView:trackCutsomPopupMenu
        @abstract Adds custom draw data to the menu items and calls a custom trackPopupMenu.
        @param sender The WebView sending the delegate method.
        @param menu The menu that we want to pop up.
        @param point The point associated with the context menu event in the coordinates of the WebView
    */
    HRESULT trackCustomPopupMenu([in] IWebView* sender, [in] OLE_HANDLE hMenu, [in] LPPOINT point);

    /*
        @method webView:measureCustomMenuItem
        @abstract This is called when the WM_MEASUREITEM command is received to measure the custom menu items
        @param sender The WebView sending the delegate method.
        @param measureItem The LPMEASUREITEMSTRUCT associated with the item.
    */
    [local] HRESULT measureCustomMenuItem([in] IWebView* sender, [in] void* measureItem);

    /*
        @method webView:drawCustomMenuItem
        @abstract This is called when the WM_DRAWITEM command is received to draw the custom menu item
        @param sender The WebView sending the delegate method.
        @param drawItem The LPDRAWITEMSTRUCT associated with the item.
    */
    [local] HRESULT drawCustomMenuItem([in] IWebView* sender, [in] void* drawItem);

    /*
        @method webView:addCustomMenuDrawingData
        @abstract Add custom data to the menu that the delegate can use when asked to draw.
        @param sender The WebView sending the delegate method.
        @param menu The cutsom menu to clean up.
        @discussion This method is called for submenus as well.
    */
    HRESULT addCustomMenuDrawingData([in] IWebView* sender, [in] OLE_HANDLE hMenu);

    /*
        @method webView:cleanUpCustomMenuDrawingData
        @abstract Clean up any custom data added to the menu items
        @param sender The WebView sending the delegate method.
        @param menu The cutsom menu to clean up.
    */
    HRESULT cleanUpCustomMenuDrawingData([in] IWebView* sender, [in] OLE_HANDLE hMenu);

    /*!
        @method webView:canTakeFocus:
        @abstract Informs whether focus can be transferred out of the WebView in the specified direction
        @param sender The WebView sending the delegate method.
        @param forward Whether focus is moving forward or backward.
    */
    HRESULT canTakeFocus([in] IWebView* sender, [in] BOOL forward, [out] BOOL* result);

    /*!
        @method webView:takeFocus:
        @abstract Instructs the delegate to take focus out of the WebView
        @param sender The WebView sending the delegate method.
        @param forward Whether focus is moving forward or backward.
    */
    HRESULT takeFocus([in] IWebView* sender, [in] BOOL forward);

    /// Undo related UI delegate methods --------------------------------------------------------------------------------

    /*!
        @method registerUndoWithTarget:
        @abstract Registers an undo operation of a IWebUndoTarget on the undo/redo stack.
        @param target The target that will be called back when the action is undone
        @param actionName The name of the action - this will be passed back to the target when we need to undo the operation
        @param actionArg An object that target used to save undo information
    */
    HRESULT registerUndoWithTarget([in] IWebUndoTarget* target, [in] BSTR actionName, [in] IUnknown* actionArg);

    /*!
        @method removeAllActionsWithTarget:
        @abstract remove all the undo operations that are registered for the passed in target on the undo/redo stack.
        @param target 
    */
    HRESULT removeAllActionsWithTarget([in] IWebUndoTarget* target);

    /*!
        @method setActionTitle:
        @abstract Sets the name of the action for the current group of undo operations
        @param actionName Name of the action
    */
    HRESULT setActionTitle([in] BSTR actionTitle);

    /*!
        @method undo:
        @abstract Undo the last group of operations
    */
    HRESULT undo();

    /*!
        @method redo:
        @abstract Redo the last group of operations
    */
    HRESULT redo();

    /*!
        @method canUndo:
        @abstract Returns whether there's anything on the undo stack to be undone
    */
    HRESULT canUndo([out, retval] BOOL* result);

    /*!
        @method canRedo:
        @abstract Returns whether there's anything on the redo stack to be redone
    */
    HRESULT canRedo([out, retval] BOOL* result);

/*!
    @method webView:printFrame:
    @abstract Informs that a WebFrame needs to be printed
    @param webView The WebView sending the delegate method
    @param frame The WebFrame needing to be printed
    @discussion This method is called when a script or user requests the page to be printed.
    In this method the delegate can prepare the WebFrame to be printed.
*/
    HRESULT printFrame([in] IWebView* webView, [in] IWebFrame* frame);

/*!
    @method webView:ftpDirectoryTemplatePath
    @abstract Returns the path to the FTP directory listing template document
    @param webView The WebView sending the delegate method
    @param path The path to the template document
    @discussion This method is called when an FTP directory listing is viewed in a webView.  
    In practice, all WebViews show the same template document data that was loaded for the very
    first WebView that displayed a directory listing, so this will only be called once.
*/
    HRESULT ftpDirectoryTemplatePath([in] IWebView* webView, [out, retval] BSTR* path);

/*!
    @method webViewHeaderHeight:
    @param webView The WebView sending the delegate method
    @abstract Reserve a height for the printed page header.
    @result The height to reserve for the printed page header, return 0.0 to not reserve any space for a header.
    @discussion The height returned will be used to calculate the rect passed to webView:drawHeaderInRect:.

    - (float)webViewHeaderHeight:(WebView *)sender;
*/
    HRESULT webViewHeaderHeight([in] IWebView* webView, [out, retval] float* result);

/*!
    @method webViewFooterHeight:
    @param webView The WebView sending the delegate method
    @abstract Reserve a height for the printed page footer.
    @result The height to reserve for the printed page footer, return 0.0 to not reserve any space for a footer.
    @discussion The height returned will be used to calculate the rect passed to webView:drawFooterInRect:.

    - (float)webViewFooterHeight:(WebView *)sender;
*/
    HRESULT webViewFooterHeight([in] IWebView* webView, [out, retval] float* result);

/*!
    @method webView:drawHeaderInRect:
    @param webView The WebView sending the delegate method
    @param rect The NSRect reserved for the header of the page
    @abstract The delegate should draw a header for the sender in the supplied rect.

    - (void)webView:(WebView *)sender drawHeaderInRect:(NSRect)rect;
*/
    HRESULT drawHeaderInRect([in] IWebView* webView, [in] RECT* rect, [in] OLE_HANDLE drawingContext);

/*!
    @method webView:drawFooterInRect:
    @param webView The WebView sending the delegate method
    @param rect The NSRect reserved for the footer of the page
    @abstract The delegate should draw a footer for the sender in the supplied rect.

    - (void)webView:(WebView *)sender drawFooterInRect:(NSRect)rect;
*/
    HRESULT drawFooterInRect([in] IWebView* webView, [in] RECT* rect, [in] OLE_HANDLE drawingContext, [in] UINT pageIndex, [in] UINT pageCount);

    HRESULT webViewPrintingMarginRect([in] IWebView* webView, [out, retval] RECT* rect);

    HRESULT canRunModal([in] IWebView* webView, [out, retval] BOOL* canRunBoolean);
    HRESULT createModalDialog([in] IWebView* sender, [in] IWebURLRequest* request, [out, retval] IWebView** newWebView);
    HRESULT runModal([in] IWebView* webView);
    HRESULT isMenuBarVisible([in] IWebView* webView, [out, retval] BOOL* visible);
    HRESULT setMenuBarVisible([in] IWebView* webView, [in] BOOL visible);
    HRESULT runDatabaseSizeLimitPrompt([in] IWebView* webView, [in] BSTR displayName, [in] IWebFrame* initiatedByFrame, [out, retval] BOOL* allowed);
    HRESULT paintCustomScrollbar([in] IWebView* webView, [in] HDC hDC, [in] RECT rect, [in] WebScrollBarControlSize size, [in] WebScrollbarControlState state, 
                                 [in] WebScrollbarControlPart pressedPart, [in] BOOL vertical, [in] float value, [in] float proportion, [in] WebScrollbarControlPartMask parts);
    HRESULT paintCustomScrollCorner([in] IWebView* webView, [in] HDC hDC, [in] RECT rect);
}
