static CustomElementLifecycleCallbacks::CallbackType flagSet(v8::MaybeLocal<v8::Function> attached, v8::MaybeLocal<v8::Function> detached, v8::MaybeLocal<v8::Function> attributeChanged)
{
    // V8 Custom Elements always run created to swizzle prototypes.
    int flags = CustomElementLifecycleCallbacks::CreatedCallback;

    if (!attached.IsEmpty())
        flags |= CustomElementLifecycleCallbacks::AttachedCallback;

    if (!detached.IsEmpty())
        flags |= CustomElementLifecycleCallbacks::DetachedCallback;

    if (!attributeChanged.IsEmpty())
        flags |= CustomElementLifecycleCallbacks::AttributeChangedCallback;

    return CustomElementLifecycleCallbacks::CallbackType(flags);
}
Exemple #2
0
void InjectedScript::wrapEvaluateResult(ErrorString* errorString, v8::MaybeLocal<v8::Value> maybeResultValue, const v8::TryCatch& tryCatch, const String16& objectGroup, bool returnByValue, bool generatePreview, std::unique_ptr<protocol::Runtime::RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails)
{
    v8::Local<v8::Value> resultValue;
    if (!tryCatch.HasCaught()) {
        if (hasInternalError(errorString, !maybeResultValue.ToLocal(&resultValue)))
            return;
        std::unique_ptr<RemoteObject> remoteObject = wrapObject(errorString, resultValue, objectGroup, returnByValue, generatePreview);
        if (!remoteObject)
            return;
        if (objectGroup == "console")
            m_lastEvaluationResult.Reset(m_context->isolate(), resultValue);
        *result = std::move(remoteObject);
        if (wasThrown)
            *wasThrown = false;
    } else {
        v8::Local<v8::Value> exception = tryCatch.Exception();
        std::unique_ptr<RemoteObject> remoteObject = wrapObject(errorString, exception, objectGroup, false, generatePreview && !exception->IsNativeError());
        if (!remoteObject)
            return;
        *result = std::move(remoteObject);
        if (exceptionDetails)
            *exceptionDetails = createExceptionDetails(tryCatch.Message());
        if (wasThrown)
            *wasThrown = true;
    }
}
inline void v8SetReturnValue(const CallbackInfo& info, v8::MaybeLocal<S> maybe)
{
    if (LIKELY(!maybe.IsEmpty()))
        info.GetReturnValue().Set(maybe.ToLocalChecked());
}