Exemple #1
0
JSValue *toJS(ExecState *exec, Event *e)
{
  if (!e)
    return jsNull();
  ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());

  JSLock lock;

  DOMObject *ret = interp->getDOMObject(e);
  if (!ret) {
    if (e->isKeyboardEvent())
      ret = new JSKeyboardEvent(exec, static_cast<KeyboardEvent *>(e));
    else if (e->isMouseEvent())
      ret = new JSMouseEvent(exec, static_cast<MouseEvent *>(e));
    else if (e->isWheelEvent())
      ret = new JSWheelEvent(exec, static_cast<WheelEvent *>(e));
    else if (e->isUIEvent())
      ret = new JSUIEvent(exec, static_cast<UIEvent *>(e));
    else if (e->isMutationEvent())
      ret = new JSMutationEvent(exec, static_cast<MutationEvent *>(e));
    else if (e->isOverflowEvent())
      ret = new JSOverflowEvent(exec, static_cast<OverflowEvent*>(e));
    else
      ret = new JSEvent(exec, e);

    interp->putDOMObject(e, ret);
  }

  return ret;
}
Exemple #2
0
JSValue *KJS::getDOMEvent(ExecState *exec, DOM::EventImpl* ei)
{
  if (!ei)
    return jsNull();
  ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter());
  DOMObject *ret = interp->getDOMObject(ei);
  if (!ret) {
    if (ei->isTextInputEvent())
      ret = new DOMTextEvent(exec, static_cast<DOM::TextEventImpl*>(ei));
    else if (ei->isKeyboardEvent())
      ret = new DOMKeyboardEvent(exec, static_cast<DOM::KeyboardEventImpl*>(ei));
    else if (ei->isMouseEvent())
      ret = new DOMMouseEvent(exec, static_cast<DOM::MouseEventImpl*>(ei));
    else if (ei->isUIEvent())
      ret = new DOMUIEvent(exec, static_cast<DOM::UIEventImpl*>(ei));
    else if (ei->isMutationEvent())
      ret = new DOMMutationEvent(exec, static_cast<DOM::MutationEventImpl*>(ei));
    else if (ei->isMessageEvent())
      ret = new DOMMessageEvent(exec, static_cast<DOM::MessageEventImpl*>(ei));
    else if (ei->isHashChangeEvent())
      ret = new DOMHashChangeEvent(exec, static_cast<DOM::HashChangeEventImpl*>(ei));
    else
      ret = new DOMEvent(exec, ei);

    interp->putDOMObject(ei, ret);
  }

  return ret;
}
Exemple #3
0
Value getDOMStyleSheetList(ExecState *exec, const DOM::StyleSheetList& ssl, const DOM::Document& doc)
{
  // Can't use the cacheDOMObject macro because of the doc argument
  DOMObject *ret;
  if (ssl.isNull())
    return Null();
  ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->interpreter());
  if ((ret = interp->getDOMObject(ssl.handle())))
    return Value(ret);
  else {
    ret = new DOMStyleSheetList(exec, ssl, doc);
    interp->putDOMObject(ssl.handle(),ret);
    return Value(ret);
  }
}
Exemple #4
0
Value getDOMCSSValue(ExecState *exec, const DOM::CSSValue& v)
{
  DOMObject *ret;
  if (v.isNull())
    return Null();
  ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->interpreter());
  if ((ret = interp->getDOMObject(v.handle())))
    return Value(ret);
  else {
    if (v.isCSSValueList())
      ret = new DOMCSSValueList(exec,v);
    else if (v.isCSSPrimitiveValue())
      ret = new DOMCSSPrimitiveValue(exec,v);
    else
      ret = new DOMCSSValue(exec,v);
    interp->putDOMObject(v.handle(),ret);
    return Value(ret);
  }
}
Exemple #5
0
Value getDOMStyleSheet(ExecState *exec, const DOM::StyleSheet& ss)
{
  DOMObject *ret;
  if (ss.isNull())
    return Null();
  ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->interpreter());
  if ((ret = interp->getDOMObject(ss.handle())))
    return Value(ret);
  else {
    if (ss.isCSSStyleSheet()) {
      DOM::CSSStyleSheet cs;
      cs = ss;
      ret = new DOMCSSStyleSheet(exec,cs);
    }
    else
      ret = new DOMStyleSheet(exec,ss);
    interp->putDOMObject(ss.handle(),ret);
    return Value(ret);
  }
}