mgjs_htmldirectoryelement.cpp
来自「monqueror一个很具有参考价值的源玛」· C++ 代码 · 共 99 行
CPP
99 行
#include "mgjs_main.h"#include <../misc/htmlattrs.h> #include <html_formimpl.h>#include "html_listimpl.h"static JSBool GetHTMLDirectoryElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);static JSBool SetHTMLDirectoryElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);enum HTMLDirectoryElement_slots { HTMLDIRECTORYELEMENT_COMPACT,};static JSBool GetHTMLDirectoryElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp){ myJSDirectoryPrivate *mDirectoryPrivate=(myJSDirectoryPrivate *)JS_GetPrivate(cx,obj); HTMLDirectoryElementImpl *impl; // HTMLElementImpl *eImpl; DOMString dsReturn=(const char*)""; bool bReturn; impl=(HTMLDirectoryElementImpl *)mDirectoryPrivate->CurNode; if(!impl)return JS_FALSE; if (JSVAL_IS_INT(id)) { switch (JSVAL_TO_INT(id)) { case HTMLDIRECTORYELEMENT_COMPACT: bReturn=!((ElementImpl *)impl)->getAttribute(ATTR_COMPACT).isNull(); *vp=INT_TO_JSVAL(bReturn);#if DEBUG_BY_XHTANG *vp=STRING_TO_JSVAL (JS_NewStringCopyZ (cx,QString::number(bReturn)));#endif break; } } return JS_TRUE;}static JSBool SetHTMLDirectoryElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp){ myJSDirectoryPrivate *mDirectoryPrivate=(myJSDirectoryPrivate *)JS_GetPrivate(cx,obj); HTMLDirectoryElementImpl *impl; DOMString dsValue; bool bValue; impl=(HTMLDirectoryElementImpl *)mDirectoryPrivate->CurNode; if(!impl)return JS_FALSE; JSString *jss; if (!(jss = JS_ValueToString (cx,*vp)))return JS_FALSE; dsValue = (const char*)JS_GetStringBytes (jss); if (JSVAL_IS_INT(id)) { switch (JSVAL_TO_INT(id)) { case HTMLDIRECTORYELEMENT_COMPACT: bValue=JSVAL_TO_INT(*vp); ((ElementImpl *)impl)->setAttribute(ATTR_COMPACT,bValue?"":0); break; } } return JS_TRUE;}static JSPropertySpec HTMLDirectoryElementProperties[] ={ {"compact", HTMLDIRECTORYELEMENT_COMPACT, JSPROP_ENUMERATE}, {0}};JSClass HTMLDirectoryElementClass = { "HTMLDirectoryElement", JSCLASS_HAS_PRIVATE , JS_PropertyStub, JS_PropertyStub, GetHTMLDirectoryElementProperty, SetHTMLDirectoryElementProperty, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub };static JSFunctionSpec HTMLDirectoryElementMethods[] = { {0}};JSObject* InitHTMLDirectoryElementClass(JSContext *cx,JSObject *globalObj,JSObject *proto){ JSObject *obj; obj = JS_DefineObject (cx,globalObj, "HtmlDirectoryElement", &HTMLDirectoryElementClass,proto,JSPROP_ENUMERATE); JS_DefineProperties (cx,obj,HTMLDirectoryElementProperties); JS_DefineFunctions (cx,obj,HTMLDirectoryElementMethods); return obj;}JSObject* NewScriptHTMLDirectoryElement(JSContext *cx,JSObject *proto,JSObject *parent,ElementImpl *eImpl){ JSObject *obj; JSObject *global = JS_GetGlobalObject(cx); jsval vp; if ((JS_TRUE == JS_LookupProperty(cx, global, "HtmlDirectoryElement", &vp) && JSVAL_IS_OBJECT(vp))) obj=JS_NewObject(cx,&HTMLDirectoryElementClass,JSVAL_TO_OBJECT(vp),NULL); else obj=InitHTMLDirectoryElementClass(cx,JS_GetParent(cx,proto),proto); myJSDirectoryPrivate *mDirectoryPrivate=new myJSDirectoryPrivate; mDirectoryPrivate->CurNode=(ElementImpl*)eImpl; JS_SetPrivate(cx,obj,(void*)mDirectoryPrivate); return obj;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?