📄 mgjs_htmlparagraphelement.cpp
字号:
#include "mgjs_main.h"#include <../misc/htmlattrs.h> #include <html_formimpl.h>#include <html_blockimpl.h>static JSBool GetHTMLParagraphElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);static JSBool SetHTMLParagraphElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);enum HTMLParagraphElement_slots { HTMLPARAGRAPHELEMENT_ALIGN,};static JSBool GetHTMLParagraphElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp){ myJSParagraphPrivate *mParagraphPrivate=(myJSParagraphPrivate *)JS_GetPrivate(cx,obj); HTMLParagraphElementImpl *impl; DOMString dsReturn=(const char*)""; impl=(HTMLParagraphElementImpl *)mParagraphPrivate->CurNode; if(!impl)return JS_FALSE; if (JSVAL_IS_INT(id)) { switch (JSVAL_TO_INT(id)) { case HTMLPARAGRAPHELEMENT_ALIGN: dsReturn=((HTMLParagraphElementImpl *)impl)->getAttribute(ATTR_ALIGN); *vp=STRING_TO_JSVAL (JS_NewStringCopyZ (cx,dsReturn.string())); break; } } return JS_TRUE;}static JSBool SetHTMLParagraphElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp){ myJSParagraphPrivate *mParagraphPrivate=(myJSParagraphPrivate *)JS_GetPrivate(cx,obj); HTMLParagraphElementImpl *impl; DOMString dsValue; impl=(HTMLParagraphElementImpl *)mParagraphPrivate->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 HTMLPARAGRAPHELEMENT_ALIGN: ((HTMLParagraphElementImpl *)impl)->setAttribute(ATTR_ALIGN,dsValue); break; } } return JS_TRUE;}static JSPropertySpec HTMLParagraphElementProperties[] ={ {"align", HTMLPARAGRAPHELEMENT_ALIGN, JSPROP_ENUMERATE}, {0}};JSClass HTMLParagraphElementClass = { "HTMLParagraphElement", JSCLASS_HAS_PRIVATE , JS_PropertyStub, JS_PropertyStub, GetHTMLParagraphElementProperty, SetHTMLParagraphElementProperty, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub };static JSFunctionSpec HTMLParagraphElementMethods[] = { {0}};JSObject* InitHTMLParagraphElementClass(JSContext *cx,JSObject *globalObj,JSObject *proto){ JSObject *obj; obj = JS_DefineObject (cx,globalObj, "HtmlParagraphElement", &HTMLParagraphElementClass,proto,JSPROP_ENUMERATE); JS_DefineProperties (cx,obj,HTMLParagraphElementProperties); JS_DefineFunctions (cx,obj,HTMLParagraphElementMethods); return obj;}JSObject* NewScriptHTMLParagraphElement(JSContext *cx,JSObject *proto,JSObject *parent,ElementImpl *eImpl){ JSObject *obj; JSObject *global = JS_GetGlobalObject(cx); jsval vp; if ((JS_TRUE == JS_LookupProperty(cx, global, "HtmlParagraphElement", &vp) && JSVAL_IS_OBJECT(vp))) obj=JS_NewObject(cx,&HTMLParagraphElementClass,JSVAL_TO_OBJECT(vp),NULL); else obj=InitHTMLParagraphElementClass(cx,JS_GetParent(cx,proto),proto); myJSParagraphPrivate *mParagraphPrivate=new myJSParagraphPrivate; mParagraphPrivate->CurNode=(ElementImpl*)eImpl; JS_SetPrivate(cx,obj,(void*)mParagraphPrivate); return obj;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -