Example #1
0
void V8DevToolsHost::showContextMenuAtPointMethodCustom(
    const v8::FunctionCallbackInfo<v8::Value>& info) {
  if (info.Length() < 3)
    return;

  ExceptionState exceptionState(ExceptionState::ExecutionContext,
                                "showContextMenuAtPoint", "DevToolsHost",
                                info.Holder(), info.GetIsolate());
  v8::Isolate* isolate = info.GetIsolate();

  float x = toRestrictedFloat(isolate, info[0], exceptionState);
  if (exceptionState.hadException())
    return;
  float y = toRestrictedFloat(isolate, info[1], exceptionState);
  if (exceptionState.hadException())
    return;

  v8::Local<v8::Value> array = v8::Local<v8::Value>::Cast(info[2]);
  if (!array->IsArray())
    return;
  ContextMenu menu;
  if (!populateContextMenuItems(isolate, v8::Local<v8::Array>::Cast(array),
                                menu))
    return;

  Document* document = nullptr;
  if (info.Length() >= 4 && v8::Local<v8::Value>::Cast(info[3])->IsObject()) {
    v8::Local<v8::Object> documentWrapper =
        v8::Local<v8::Object>::Cast(info[3]);
    if (!V8HTMLDocument::wrapperTypeInfo.equals(
            toWrapperTypeInfo(documentWrapper)))
      return;
    document = V8HTMLDocument::toImpl(documentWrapper);
  } else {
    v8::Local<v8::Object> windowWrapper =
        V8Window::findInstanceInPrototypeChain(
            isolate->GetEnteredContext()->Global(), isolate);
    if (windowWrapper.IsEmpty())
      return;
    DOMWindow* window = V8Window::toImpl(windowWrapper);
    document = window ? toLocalDOMWindow(window)->document() : nullptr;
  }
  if (!document || !document->frame())
    return;

  DevToolsHost* devtoolsHost = V8DevToolsHost::toImpl(info.Holder());
  Vector<ContextMenuItem> items = menu.items();
  devtoolsHost->showContextMenu(document->frame(), x, y, items);
}
static void voidMethodFloatArgStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodFloatArgStringArg", "TestTypedefs", info.Holder(), info.GetIsolate());
    if (UNLIKELY(info.Length() < 2)) {
        setMinimumArityTypeError(exceptionState, 2, info.Length());
        exceptionState.throwIfNeeded();
        return;
    }
    TestTypedefs* impl = V8TestTypedefs::toImpl(info.Holder());
    float floatArg;
    V8StringResource<> stringArg;
    {
        floatArg = toRestrictedFloat(info.GetIsolate(), info[0], exceptionState);
        if (exceptionState.throwIfNeeded())
            return;
        stringArg = info[1];
        if (!stringArg.prepare())
            return;
    }
    impl->voidMethodFloatArgStringArg(floatArg, stringArg);
}
Example #3
0
static void voidMethodDoubleArgFloatArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
  ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionContext, "TestInterfaceOriginTrialEnabled", "voidMethodDoubleArgFloatArg");

  TestInterfaceOriginTrialEnabled* impl = V8TestInterfaceOriginTrialEnabled::toImpl(info.Holder());

  if (UNLIKELY(info.Length() < 2)) {
    exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length()));
    return;
  }

  double doubleArg;
  float floatArg;
  doubleArg = toRestrictedDouble(info.GetIsolate(), info[0], exceptionState);
  if (exceptionState.hadException())
    return;

  floatArg = toRestrictedFloat(info.GetIsolate(), info[1], exceptionState);
  if (exceptionState.hadException())
    return;

  impl->voidMethodDoubleArgFloatArg(doubleArg, floatArg);
}