2 * Copyright (C) 2007 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
27 #include "WebKitDLL.h"
28 #include "WebScriptDebugServer.h"
31 #include <wtf/Vector.h>
33 static Vector<IWebView*> sViews;
35 // EnumViews ------------------------------------------------------------------
37 class EnumViews : public IEnumVARIANT
40 EnumViews() : m_refCount(1), m_current(sViews.begin()) { }
42 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject)
45 if (IsEqualGUID(riid, IID_IUnknown) || IsEqualGUID(riid, IID_IEnumVARIANT))
54 virtual ULONG STDMETHODCALLTYPE AddRef(void)
59 virtual ULONG STDMETHODCALLTYPE Release(void)
61 ULONG newRef = --m_refCount;
67 virtual HRESULT STDMETHODCALLTYPE Next(ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
74 if (!celt || celt > 1)
76 if (m_current == sViews.end())
80 HRESULT hr = (*m_current++)->QueryInterface(IID_IUnknown, (void**)&unknown);
84 V_VT(rgVar) = VT_UNKNOWN;
85 V_UNKNOWN(rgVar) = unknown;
92 virtual HRESULT STDMETHODCALLTYPE Skip(ULONG celt)
95 return (m_current != sViews.end()) ? S_OK : S_FALSE;
98 virtual HRESULT STDMETHODCALLTYPE Reset(void)
100 m_current = sViews.begin();
104 virtual HRESULT STDMETHODCALLTYPE Clone(IEnumVARIANT**)
111 Vector<IWebView*>::iterator m_current;
114 // WebScriptDebugServer ------------------------------------------------------------
116 WebScriptDebugServer::WebScriptDebugServer()
122 WebScriptDebugServer::~WebScriptDebugServer()
127 WebScriptDebugServer* WebScriptDebugServer::createInstance()
129 WebScriptDebugServer* instance = new WebScriptDebugServer;
134 // IUnknown -------------------------------------------------------------------
136 HRESULT STDMETHODCALLTYPE WebScriptDebugServer::QueryInterface(REFIID riid, void** ppvObject)
139 if (IsEqualGUID(riid, IID_IUnknown))
140 *ppvObject = static_cast<WebScriptDebugServer*>(this);
141 else if (IsEqualGUID(riid, IID_IWebScriptDebugServer))
142 *ppvObject = static_cast<WebScriptDebugServer*>(this);
144 return E_NOINTERFACE;
150 ULONG STDMETHODCALLTYPE WebScriptDebugServer::AddRef(void)
155 ULONG STDMETHODCALLTYPE WebScriptDebugServer::Release(void)
157 ULONG newRef = --m_refCount;
164 void WebScriptDebugServer::viewAdded(IWebView* view)
169 void WebScriptDebugServer::viewRemoved(IWebView* view)
171 Vector<IWebView*>::iterator end = sViews.end();
173 for (Vector<IWebView*>::iterator it = sViews.begin(); it != end; ++it, ++i) {
181 // IWebScriptDebugServer -----------------------------------------------------------
183 HRESULT STDMETHODCALLTYPE WebScriptDebugServer::addListener(
184 /* [in] */ const IWebScriptDebugListener*)
189 HRESULT STDMETHODCALLTYPE WebScriptDebugServer::removeListener(
190 /* [in] */ const IWebScriptDebugListener*)
195 HRESULT STDMETHODCALLTYPE WebScriptDebugServer::step()
200 HRESULT STDMETHODCALLTYPE WebScriptDebugServer::pause()
205 HRESULT STDMETHODCALLTYPE WebScriptDebugServer::resume()
210 HRESULT STDMETHODCALLTYPE WebScriptDebugServer::isPaused(
211 /* [out, retval] */ BOOL*)