webengine/osswebengine/WebKitTools/DumpRenderTree/win/UIDelegate.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2  * Copyright (C) 2005, 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  *
       
     8  * 1.  Redistributions of source code must retain the above copyright
       
     9  *     notice, this list of conditions and the following disclaimer. 
       
    10  * 2.  Redistributions in binary form must reproduce the above copyright
       
    11  *     notice, this list of conditions and the following disclaimer in the
       
    12  *     documentation and/or other materials provided with the distribution. 
       
    13  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
       
    14  *     its contributors may be used to endorse or promote products derived
       
    15  *     from this software without specific prior written permission. 
       
    16  *
       
    17  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
       
    18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
    19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
       
    20  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
       
    21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
       
    22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
       
    23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
       
    24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
    25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
       
    26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    27  */
       
    28 
       
    29 #include "DumpRenderTree.h"
       
    30 #include "UIDelegate.h"
       
    31 
       
    32 #include "DraggingInfo.h"
       
    33 #include "EventSender.h"
       
    34 
       
    35 #include <WebCore/COMPtr.h>
       
    36 #include <wtf/Platform.h>
       
    37 #include <JavaScriptCore/Assertions.h>
       
    38 #include <JavaScriptCore/JavaScriptCore.h>
       
    39 #include <WebKit/IWebFramePrivate.h>
       
    40 #include <WebKit/IWebViewPrivate.h>
       
    41 #include <stdio.h>
       
    42 
       
    43 HRESULT STDMETHODCALLTYPE UIDelegate::QueryInterface(REFIID riid, void** ppvObject)
       
    44 {
       
    45     *ppvObject = 0;
       
    46     if (IsEqualGUID(riid, IID_IUnknown))
       
    47         *ppvObject = static_cast<IWebUIDelegate*>(this);
       
    48     else if (IsEqualGUID(riid, IID_IWebUIDelegate))
       
    49         *ppvObject = static_cast<IWebUIDelegate*>(this);
       
    50     else if (IsEqualGUID(riid, IID_IWebUIDelegatePrivate))
       
    51         *ppvObject = static_cast<IWebUIDelegatePrivate*>(this);
       
    52     else
       
    53         return E_NOINTERFACE;
       
    54 
       
    55     AddRef();
       
    56     return S_OK;
       
    57 }
       
    58 
       
    59 ULONG STDMETHODCALLTYPE UIDelegate::AddRef(void)
       
    60 {
       
    61     return ++m_refCount;
       
    62 }
       
    63 
       
    64 ULONG STDMETHODCALLTYPE UIDelegate::Release(void)
       
    65 {
       
    66     ULONG newRef = --m_refCount;
       
    67     if (!newRef)
       
    68         delete(this);
       
    69 
       
    70     return newRef;
       
    71 }
       
    72 
       
    73 HRESULT STDMETHODCALLTYPE UIDelegate::hasCustomMenuImplementation( 
       
    74         /* [retval][out] */ BOOL *hasCustomMenus)
       
    75 {
       
    76     *hasCustomMenus = FALSE;
       
    77 
       
    78     return S_OK;
       
    79 }
       
    80 
       
    81 HRESULT STDMETHODCALLTYPE UIDelegate::setFrame( 
       
    82         /* [in] */ IWebView* /*sender*/,
       
    83         /* [in] */ RECT* frame)
       
    84 {
       
    85     m_frame = frame;
       
    86     return S_OK;
       
    87 }
       
    88 
       
    89 HRESULT STDMETHODCALLTYPE UIDelegate::webViewFrame( 
       
    90         /* [in] */ IWebView* /*sender*/,
       
    91         /* [retval][out] */ RECT* frame)
       
    92 {
       
    93     frame = m_frame;
       
    94     return S_OK;
       
    95 }
       
    96 
       
    97 HRESULT STDMETHODCALLTYPE UIDelegate::runJavaScriptAlertPanelWithMessage( 
       
    98         /* [in] */ IWebView* /*sender*/,
       
    99         /* [in] */ BSTR message)
       
   100 {
       
   101     wprintf(L"ALERT: %s\n", message ? message : L"");
       
   102 
       
   103     return S_OK;
       
   104 }
       
   105 
       
   106 HRESULT STDMETHODCALLTYPE UIDelegate::webViewAddMessageToConsole( 
       
   107     /* [in] */ IWebView* sender,
       
   108     /* [in] */ BSTR message,
       
   109     /* [in] */ int lineNumber,
       
   110     /* [in] */ BSTR url,
       
   111     /* [in] */ BOOL isError)
       
   112 {
       
   113     wprintf(L"CONSOLE MESSAGE: line %d: %s\n", lineNumber, message ? message : L"");
       
   114 
       
   115     return S_OK;
       
   116 }
       
   117 
       
   118 HRESULT STDMETHODCALLTYPE UIDelegate::doDragDrop( 
       
   119     /* [in] */ IWebView* sender,
       
   120     /* [in] */ IDataObject* object,
       
   121     /* [in] */ IDropSource* source,
       
   122     /* [in] */ DWORD okEffect,
       
   123     /* [retval][out] */ DWORD* performedEffect)
       
   124 {
       
   125     if (!performedEffect)
       
   126         return E_POINTER;
       
   127 
       
   128     *performedEffect = 0;
       
   129 
       
   130     draggingInfo = new DraggingInfo(object, source);
       
   131 
       
   132     replaySavedEvents();
       
   133 
       
   134     return S_OK;
       
   135 }
       
   136 
       
   137 HRESULT STDMETHODCALLTYPE UIDelegate::webViewGetDlgCode( 
       
   138     /* [in] */ IWebView* /*sender*/,
       
   139     /* [in] */ UINT /*keyCode*/,
       
   140     /* [retval][out] */ LONG_PTR *code)
       
   141 {
       
   142     if (!code)
       
   143         return E_POINTER;
       
   144     *code = 0;
       
   145     return E_NOTIMPL;
       
   146 }