⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kjs_events.cpp

📁 konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版本源码包.
💻 CPP
📖 第 1 页 / 共 3 页
字号:
DOMEvent::DOMEvent(ExecState *exec, DOM::Event e)  : DOMObject(DOMEventProto::self(exec)), event(e) { }DOMEvent::DOMEvent(const Object &proto, DOM::Event e)  : DOMObject(proto), event(e) { }DOMEvent::~DOMEvent(){  ScriptInterpreter::forgetDOMObject(event.handle());}Value DOMEvent::tryGet(ExecState *exec, const Identifier &p) const{#ifdef KJS_VERBOSE  kdDebug() << "KJS::DOMEvent::tryGet " << p.qstring() << endl;#endif  return DOMObjectLookupGetValue<DOMEvent,DOMObject>(exec, p, &DOMEventTable, this );}Value DOMEvent::getValueProperty(ExecState *exec, int token) const{  switch (token) {  case Type:    return String(event.type());  case Target:  case SrcElement: /*MSIE extension - "the object that fired the event"*/    return getDOMNode(exec,event.target());  case CurrentTarget:    return getDOMNode(exec,event.currentTarget());  case EventPhase:    return Number((unsigned int)event.eventPhase());  case Bubbles:    return Boolean(event.bubbles());  case Cancelable:    return Boolean(event.cancelable());  case TimeStamp:    return Number((long unsigned int)event.timeStamp()); // ### long long ?  case ReturnValue: // MSIE extension    return Boolean(event.handle()->defaultPrevented());  case CancelBubble: // MSIE extension    return Boolean(event.handle()->propagationStopped());  default:    kdDebug(6070) << "WARNING: Unhandled token in DOMEvent::getValueProperty : " << token << endl;    return Value();  }}Value DOMEvent::defaultValue(ExecState *exec, KJS::Type hint) const{  if (event.handle()->id() == EventImpl::ERROR_EVENT && !event.handle()->message().isNull()) {    return String(event.handle()->message());  }  else    return DOMObject::defaultValue(exec,hint);}void DOMEvent::tryPut(ExecState *exec, const Identifier &propertyName,                      const Value& value, int attr){  DOMObjectLookupPut<DOMEvent, DOMObject>(exec, propertyName, value, attr,                                          &DOMEventTable, this);}void DOMEvent::putValueProperty(ExecState *exec, int token, const Value& value, int){  switch (token) {  case ReturnValue: // MSIE equivalent for "preventDefault" (but with a way to reset it)    // returnValue=false means "default action of the event on the source object is canceled",    // which means preventDefault(true). Hence the '!'.    event.handle()->preventDefault(!value.toBoolean(exec));    break;  case CancelBubble: // MSIE equivalent for "stopPropagation" (but with a way to reset it)    event.handle()->stopPropagation(value.toBoolean(exec));    break;  default:    break;  }}Value DOMEventProtoFunc::tryCall(ExecState *exec, Object & thisObj, const List &args){  KJS_CHECK_THIS( KJS::DOMEvent, thisObj );  DOM::Event event = static_cast<DOMEvent *>( thisObj.imp() )->toEvent();  switch (id) {    case DOMEvent::StopPropagation:      event.stopPropagation();      return Undefined();    case DOMEvent::PreventDefault:      event.preventDefault();      return Undefined();    case DOMEvent::InitEvent:      event.initEvent(args[0].toString(exec).string(),args[1].toBoolean(exec),args[2].toBoolean(exec));      return Undefined();  };  return Undefined();}Value KJS::getDOMEvent(ExecState *exec, DOM::Event e){  DOM::EventImpl *ei = e.handle();  if (!ei)    return Null();  ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->interpreter());  DOMObject *ret = interp->getDOMObject(ei);  if (!ret) {    if (ei->isTextEvent())      ret = new DOMTextEvent(exec, e);    else if (ei->isMouseEvent())      ret = new DOMMouseEvent(exec, e);    else if (ei->isUIEvent())      ret = new DOMUIEvent(exec, e);    else if (ei->isMutationEvent())      ret = new DOMMutationEvent(exec, e);    else      ret = new DOMEvent(exec, e);    interp->putDOMObject(ei, ret);  }  return Value(ret);}DOM::Event KJS::toEvent(const Value& val){  Object obj = Object::dynamicCast(val);  if (!obj.isValid() || !obj.inherits(&DOMEvent::info))    return DOM::Event();  const DOMEvent *dobj = static_cast<const DOMEvent*>(obj.imp());  return dobj->toEvent();}// -------------------------------------------------------------------------const ClassInfo EventExceptionConstructor::info = { "EventExceptionConstructor", 0, &EventExceptionConstructorTable, 0 };/*@begin EventExceptionConstructorTable 1  UNSPECIFIED_EVENT_TYPE_ERR    DOM::EventException::UNSPECIFIED_EVENT_TYPE_ERR DontDelete|ReadOnly@end*/EventExceptionConstructor::EventExceptionConstructor(ExecState *exec)  : DOMObject(exec->interpreter()->builtinObjectPrototype()){}Value EventExceptionConstructor::tryGet(ExecState *exec, const Identifier &p) const{  return DOMObjectLookupGetValue<EventExceptionConstructor, DOMObject>(exec,p,&EventExceptionConstructorTable,this);}Value EventExceptionConstructor::getValueProperty(ExecState *, int token) const{  // We use the token as the value to return directly  return Number(token);}Value KJS::getEventExceptionConstructor(ExecState *exec){  return cacheGlobalObject<EventExceptionConstructor>(exec, "[[eventException.constructor]]");}// -------------------------------------------------------------------------const ClassInfo DOMUIEvent::info = { "UIEvent", &DOMEvent::info, &DOMUIEventTable, 0 };/*@begin DOMUIEventTable 7  view		DOMUIEvent::View	DontDelete|ReadOnly  detail	DOMUIEvent::Detail	DontDelete|ReadOnly  keyCode	DOMUIEvent::KeyCode	DontDelete|ReadOnly  charCode	DOMUIEvent::CharCode	DontDelete|ReadOnly  layerX	DOMUIEvent::LayerX	DontDelete|ReadOnly  layerY	DOMUIEvent::LayerY	DontDelete|ReadOnly  pageX		DOMUIEvent::PageX	DontDelete|ReadOnly  pageY		DOMUIEvent::PageY	DontDelete|ReadOnly  which		DOMUIEvent::Which	DontDelete|ReadOnly@end@begin DOMUIEventProtoTable 1  initUIEvent	DOMUIEvent::InitUIEvent	DontDelete|Function 5@end*/DEFINE_PROTOTYPE("DOMUIEvent",DOMUIEventProto)IMPLEMENT_PROTOFUNC_DOM(DOMUIEventProtoFunc)IMPLEMENT_PROTOTYPE_WITH_PARENT(DOMUIEventProto,DOMUIEventProtoFunc,DOMEventProto)DOMUIEvent::DOMUIEvent(ExecState *exec, DOM::UIEvent ue) :  DOMEvent(DOMUIEventProto::self(exec), ue) {}DOMUIEvent::DOMUIEvent(const Object &proto, DOM::UIEvent ue) :  DOMEvent(proto, ue) {}DOMUIEvent::~DOMUIEvent(){}Value DOMUIEvent::tryGet(ExecState *exec, const Identifier &p) const{  return DOMObjectLookupGetValue<DOMUIEvent,DOMEvent>(exec,p,&DOMUIEventTable,this);}Value DOMUIEvent::getValueProperty(ExecState *exec, int token) const{  switch (token) {  case View:    return getDOMAbstractView(exec,static_cast<DOM::UIEvent>(event).view());  case Detail:    return Number(static_cast<DOM::UIEvent>(event).detail());  case KeyCode:    // IE-compatibility    return Number(static_cast<DOM::UIEvent>(event).keyCode());  case CharCode:    // IE-compatibility    return Number(static_cast<DOM::UIEvent>(event).charCode());  case LayerX:    // NS-compatibility    return Number(static_cast<DOM::UIEvent>(event).layerX());  case LayerY:    // NS-compatibility    return Number(static_cast<DOM::UIEvent>(event).layerY());  case PageX:    // NS-compatibility    return Number(static_cast<DOM::UIEvent>(event).pageX());  case PageY:    // NS-compatibility    return Number(static_cast<DOM::UIEvent>(event).pageY());  case Which:    // NS-compatibility    return Number(static_cast<DOM::UIEvent>(event).which());  default:    kdDebug(6070) << "WARNING: Unhandled token in DOMUIEvent::getValueProperty : " << token << endl;    return Undefined();  }}Value DOMUIEventProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args){  KJS_CHECK_THIS( KJS::DOMUIEvent, thisObj );  DOM::UIEvent uiEvent = static_cast<DOMUIEvent *>(thisObj.imp())->toUIEvent();  switch (id) {    case DOMUIEvent::InitUIEvent: {      DOM::AbstractView v = toAbstractView(args[3]);      static_cast<DOM::UIEvent>(uiEvent).initUIEvent(args[0].toString(exec).string(),                                                     args[1].toBoolean(exec),                                                     args[2].toBoolean(exec),                                                     v,                                                     args[4].toInteger(exec));      }      return Undefined();  }  return Undefined();}// -------------------------------------------------------------------------const ClassInfo DOMMouseEvent::info = { "MouseEvent", &DOMUIEvent::info, &DOMMouseEventTable, 0 };/*@begin DOMMouseEventTable 2  screenX	DOMMouseEvent::ScreenX	DontDelete|ReadOnly  screenY	DOMMouseEvent::ScreenY	DontDelete|ReadOnly  clientX	DOMMouseEvent::ClientX	DontDelete|ReadOnly  x		DOMMouseEvent::X	DontDelete|ReadOnly  clientY	DOMMouseEvent::ClientY	DontDelete|ReadOnly  y		DOMMouseEvent::Y	DontDelete|ReadOnly  offsetX	DOMMouseEvent::OffsetX	DontDelete|ReadOnly  offsetY	DOMMouseEvent::OffsetY	DontDelete|ReadOnly  ctrlKey	DOMMouseEvent::CtrlKey	DontDelete|ReadOnly  shiftKey	DOMMouseEvent::ShiftKey	DontDelete|ReadOnly  altKey	DOMMouseEvent::AltKey	DontDelete|ReadOnly  metaKey	DOMMouseEvent::MetaKey	DontDelete|ReadOnly  button	DOMMouseEvent::Button	DontDelete|ReadOnly  relatedTarget	DOMMouseEvent::RelatedTarget DontDelete|ReadOnly  fromElement	DOMMouseEvent::FromElement DontDelete|ReadOnly  toElement	DOMMouseEvent::ToElement	DontDelete|ReadOnly@end@begin DOMMouseEventProtoTable 1  initMouseEvent	DOMMouseEvent::InitMouseEvent	DontDelete|Function 15@end*/DEFINE_PROTOTYPE("DOMMouseEvent",DOMMouseEventProto)IMPLEMENT_PROTOFUNC_DOM(DOMMouseEventProtoFunc)IMPLEMENT_PROTOTYPE_WITH_PARENT(DOMMouseEventProto,DOMMouseEventProtoFunc,DOMUIEventProto)DOMMouseEvent::DOMMouseEvent(ExecState *exec, DOM::MouseEvent me) :  DOMUIEvent(DOMMouseEventProto::self(exec), me) {}DOMMouseEvent::~DOMMouseEvent(){}Value DOMMouseEvent::tryGet(ExecState *exec, const Identifier &p) const{#ifdef KJS_VERBOSE  kdDebug(6070) << "DOMMouseEvent::tryGet " << p.qstring() << endl;#endif  return DOMObjectLookupGetValue<DOMMouseEvent,DOMUIEvent>(exec,p,&DOMMouseEventTable,this);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -