bool eventListenerHandlerLocation(Document* document, EventListener* eventListener, String& sourceName, int& lineNumber)
{
    const JSEventListener* jsListener = JSEventListener::cast(eventListener);
    if (!jsListener)
        return false;
    JSC::JSObject* jsObject = jsListener->jsFunction(document);
    if (!jsObject)
        return false;
    JSC::JSFunction* jsFunction = static_cast<JSFunction*>(jsObject);
    if (!jsFunction || jsFunction->isHostFunction())
        return false;
    JSC::FunctionExecutable* funcExecutable = jsFunction->jsExecutable();
    if (!funcExecutable)
        return false;
    lineNumber = funcExecutable->lineNo();
    sourceName = ustringToString(funcExecutable->sourceURL());
    return true;
}
예제 #2
0
bool eventListenerHandlerLocation(Document* document, EventListener* eventListener, String& sourceName, String& scriptId, int& lineNumber)
{
    const JSEventListener* jsListener = JSEventListener::cast(eventListener);
    ASSERT(jsListener);
    if (!jsListener)
        return false;
    JSLockHolder lock(jsListener->isolatedWorld()->globalData());
    JSC::JSObject* jsObject = jsListener->jsFunction(document);
    if (!jsObject)
        return false;
    JSC::JSFunction* jsFunction = jsDynamicCast<JSFunction*>(jsObject);
    if (!jsFunction || jsFunction->isHostFunction())
        return false;
    JSC::FunctionExecutable* funcExecutable = jsFunction->jsExecutable();
    if (!funcExecutable)
        return false;
    lineNumber = funcExecutable->lineNo() - 1;
    intptr_t funcSourceId = funcExecutable->sourceID();
    scriptId = funcSourceId == SourceProvider::nullID ? "" : String::number(funcSourceId);
    sourceName = funcExecutable->sourceURL();
    return true;
}