예제 #1
0
void V8CustomEvent::detailAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
    CustomEvent* event = V8CustomEvent::toNative(info.Holder());

    v8::Handle<v8::Value> result = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::detail(info.GetIsolate()));

    if (!result.IsEmpty()) {
        v8SetReturnValue(info, result);
        return;
    }

    if (!event->serializedDetail()) {
        // If we're in an isolated world and the event was created in the main world,
        // we need to find the 'detail' property on the main world wrapper and clone it.
        v8::Local<v8::Value> mainWorldDetail = V8HiddenValue::getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, V8HiddenValue::detail(info.GetIsolate()));
        if (!mainWorldDetail.IsEmpty())
            event->setSerializedDetail(SerializedScriptValue::createAndSwallowExceptions(mainWorldDetail, info.GetIsolate()));
    }

    if (event->serializedDetail()) {
        result = event->serializedDetail()->deserialize();
        v8SetReturnValue(info, cacheState(info.Holder(), result, info.GetIsolate()));
        return;
    }

    v8SetReturnValue(info, cacheState(info.Holder(), v8::Null(info.GetIsolate()), info.GetIsolate()));
}
예제 #2
0
JSValue jsCustomEventDetail(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSCustomEvent* castedThis = static_cast<JSCustomEvent*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    CustomEvent* imp = static_cast<CustomEvent*>(castedThis->impl());
    JSValue result = imp->detail().jsValue();;
    return result;
}
예제 #3
0
EncodedJSValue JSC_HOST_CALL jsCustomEventPrototypeFunctionInitCustomEvent(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSCustomEvent::s_info))
        return throwVMTypeError(exec);
    JSCustomEvent* castedThis = static_cast<JSCustomEvent*>(asObject(thisValue));
    CustomEvent* imp = static_cast<CustomEvent*>(castedThis->impl());
    const String& typeArg = ustringToString(exec->argument(0).toString(exec));
    bool canBubbleArg = exec->argument(1).toBoolean(exec);
    bool cancelableArg = exec->argument(2).toBoolean(exec);
    ScriptValue detailArg = exec->argument(3);

    imp->initCustomEvent(typeArg, canBubbleArg, cancelableArg, detailArg);
    return JSValue::encode(jsUndefined());
}
void V8CustomEvent::initCustomEventMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    CustomEvent* event = V8CustomEvent::toImpl(info.Holder());

    TOSTRING_VOID(V8StringResource<>, typeArg, info[0]);
    bool canBubbleArg;
    bool cancelableArg;
    if (!v8Call(info[1]->BooleanValue(info.GetIsolate()->GetCurrentContext()), canBubbleArg)
        || !v8Call(info[2]->BooleanValue(info.GetIsolate()->GetCurrentContext()), cancelableArg))
        return;
    v8::Local<v8::Value> detailsArg = info[3];

    event->initEvent(typeArg, canBubbleArg, cancelableArg);
    event->setDetail(ScriptValue(ScriptState::current(info.GetIsolate()), detailsArg));
}
예제 #5
0
bool
Coordinator::event(QEvent* event)
{
    if(event->type() != CUSTOM_EVENT_TYPE)
    {
        return QObject::event(event);
    }

    CustomEvent* customEvent = dynamic_cast<CustomEvent*>(event);
    assert(customEvent);
    Ice::DispatcherCallPtr call = customEvent->call();
    assert(call);
    try
    {
        call->run();
    }
    catch(const Ice::Exception& ex)
    {
        ostringstream error;
        error << "Ice::DispatcherCall (Ice::Exception):\n" << ex;
        setError(error.str());
    }
    catch(const exception& ex)
    {
        ostringstream error;
        error << "Ice::DispatcherCall (std::exception):\n" << ex.what();
        setError(error.str());
    }
    catch(const string& ex)
    {
        ostringstream error;
        error << "Ice::DispatcherCall (std::string):\n" << ex;
        setError(error.str());
    }
    catch(const char* ex)
    {
        ostringstream error;
        error << "Ice::DispatcherCall (const char*):\n" << ex;
        setError(error.str());
    }
    catch(...)
    {
        ostringstream error;
        error << "Ice::DispatcherCall (unknown C++ exception).";
        setError(error.str());
    }
    return true;
}
예제 #6
0
void V8CustomEvent::initCustomEventMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    CustomEvent* event = V8CustomEvent::toNative(info.Holder());
    ASSERT(!event->serializedDetail());

    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, typeArg, info[0]);
    V8TRYCATCH_VOID(bool, canBubbleArg, info[1]->BooleanValue());
    V8TRYCATCH_VOID(bool, cancelableArg, info[2]->BooleanValue());
    v8::Handle<v8::Value> detailsArg = info[3];

    event->initEvent(typeArg, canBubbleArg, cancelableArg);

    if (!detailsArg.IsEmpty()) {
        V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::detail(info.GetIsolate()), detailsArg);
        if (DOMWrapperWorld::current(info.GetIsolate())->isIsolatedWorld())
            event->setSerializedDetail(SerializedScriptValue::createAndSwallowExceptions(detailsArg, info.GetIsolate()));
    }
}
void V8CustomEvent::detailAttributeGetterCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    CustomEvent* event = V8CustomEvent::toImpl(info.Holder());

    v8::Local<v8::Value> result = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::detail(info.GetIsolate()));

    if (!result.IsEmpty()) {
        v8SetReturnValue(info, result);
        return;
    }

    // Be careful not to return a V8 value which is created in different world.
    v8::Local<v8::Value> detail;
    if (SerializedScriptValue* serializedValue = event->serializedDetail())
        detail = serializedValue->deserialize();
    else
        detail = event->detail().v8ValueFor(ScriptState::current(info.GetIsolate()));
    // |detail| should be null when it is an empty handle because its default value is null.
    if (detail.IsEmpty())
        detail = v8::Null(info.GetIsolate());
    v8SetReturnValue(info, cacheState(info.GetIsolate(), info.Holder(), detail));
}
예제 #8
0
void PraxisDlg::customEvent(QEvent *event)
{
   switch( event->type() )
   {
   case PRAXIS_SET_MAX_PAGE:
   {
       CustomEvent *e = static_cast<CustomEvent*>(event);
       _total = e->_total;
       SetMaxPage(e->_nMaxPage);
       e->accept();
       break;
   }
   case PRAXIS_UPDATE_UI:
   {
       CustomEvent *e = static_cast<CustomEvent*>(event);
       UpdateUI();
       e->accept();
       break;
   }
   default:
       QObject::event(event);
   }
}
예제 #9
0
static void GetPropertyBagFromEvent(Event* aEvent,
                                    nsIPropertyBag2** aPropertyBag) {
  *aPropertyBag = nullptr;

  CustomEvent* customEvent = aEvent->AsCustomEvent();
  if (!customEvent) return;

  AutoJSAPI jsapi;
  if (!jsapi.Init(customEvent->GetParentObject())) return;

  JSContext* cx = jsapi.cx();
  JS::Rooted<JS::Value> detail(cx);
  customEvent->GetDetail(cx, &detail);
  if (!detail.isObject()) return;

  JS::Rooted<JSObject*> detailObj(cx, &detail.toObject());

  nsresult rv;
  nsCOMPtr<nsIPropertyBag2> propBag;
  rv = UnwrapArg<nsIPropertyBag2>(cx, detailObj, getter_AddRefs(propBag));
  if (NS_FAILED(rv)) return;

  propBag.forget(aPropertyBag);
}