r=jst, sr=erik
DOM changes to implement the dir attribute (document.dir) needed for Bidi
This commit is contained in:
mkaply%us.ibm.com 2001-03-10 00:50:54 +00:00
parent cd7c184727
commit 06a62886d8
8 changed files with 81 additions and 2 deletions

View File

@ -2369,6 +2369,19 @@ nsDocument::SetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject* aBoxObject)
return NS_OK;
}
NS_IMETHODIMP
nsDocument::GetDir(nsAWritableString& aDirection)
{
aDirection.Assign(NS_LITERAL_STRING("ltr") );
return NS_OK;
}
NS_IMETHODIMP
nsDocument::SetDir(const nsAReadableString& aDirection)
{
return NS_OK;
}
//
// nsIDOMNode methods
//

View File

@ -371,6 +371,8 @@ public:
NS_IMETHOD GetPlugins(nsIDOMPluginArray** aPlugins);
NS_IMETHOD GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult);
NS_IMETHOD SetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject* aBoxObject);
NS_IMETHOD GetDir(nsAWritableString& aDirection);
NS_IMETHOD SetDir(const nsAReadableString& aDirection);
// nsIDOMNode interface
NS_DECL_IDOMNODE

View File

@ -2932,6 +2932,19 @@ nsXULDocument::GetPlugins(nsIDOMPluginArray** aPlugins)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsXULDocument::GetDir(nsAWritableString& aDirection)
{
aDirection.Assign(NS_LITERAL_STRING("ltr") );
return NS_OK;
}
NS_IMETHODIMP
nsXULDocument::SetDir(const nsAReadableString& aDirection)
{
return NS_OK;
}
//----------------------------------------------------------------------
//
// nsIDOMXULDocument interface

View File

@ -44,6 +44,9 @@ public:
NS_IMETHOD GetCharacterSet(nsAWritableString& aCharacterSet)=0;
NS_IMETHOD GetDir(nsAWritableString& aDir)=0;
NS_IMETHOD SetDir(const nsAReadableString& aDir)=0;
NS_IMETHOD GetPlugins(nsIDOMPluginArray** aPlugins)=0;
NS_IMETHOD GetLocation(jsval* aLocation)=0;
@ -61,6 +64,8 @@ public:
#define NS_DECL_IDOMNSDOCUMENT \
NS_IMETHOD GetCharacterSet(nsAWritableString& aCharacterSet); \
NS_IMETHOD GetDir(nsAWritableString& aDir); \
NS_IMETHOD SetDir(const nsAReadableString& aDir); \
NS_IMETHOD GetPlugins(nsIDOMPluginArray** aPlugins); \
NS_IMETHOD GetLocation(jsval* aLocation); \
NS_IMETHOD SetLocation(jsval aLocation); \
@ -73,6 +78,8 @@ public:
#define NS_FORWARD_IDOMNSDOCUMENT(_to) \
NS_IMETHOD GetCharacterSet(nsAWritableString& aCharacterSet) { return _to GetCharacterSet(aCharacterSet); } \
NS_IMETHOD GetDir(nsAWritableString& aDir); \
NS_IMETHOD SetDir(const nsAReadableString& aDir); \
NS_IMETHOD GetPlugins(nsIDOMPluginArray** aPlugins) { return _to GetPlugins(aPlugins); } \
NS_IMETHOD GetLocation(jsval* aLocation) { return _to GetLocation(aLocation); } \
NS_IMETHOD SetLocation(jsval aLocation) { return _to SetLocation(aLocation); } \

View File

@ -91,6 +91,7 @@ interface NSDocument {
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } */
readonly attribute DOMString characterSet;
attribute DOMString dir;
readonly attribute PluginArray plugins;
attribute jsval location;

View File

@ -768,6 +768,7 @@ enum nsDOMProp {
NS_DOM_PROP_NOTATION_SYSTEMID,
NS_DOM_PROP_NSDOCUMENT_CHARACTERSET,
NS_DOM_PROP_NSDOCUMENT_CREATERANGE,
NS_DOM_PROP_NSDOCUMENT_DIR,
NS_DOM_PROP_NSDOCUMENT_GETBOXOBJECTFOR,
NS_DOM_PROP_NSDOCUMENT_LOAD,
NS_DOM_PROP_NSDOCUMENT_LOCATION,

View File

@ -766,6 +766,7 @@
"notation.systemid", \
"nsdocument.characterset", \
"nsdocument.createrange", \
"nsdocument.dir", \
"nsdocument.getboxobjectfor", \
"nsdocument.load", \
"nsdocument.location", \

View File

@ -102,8 +102,9 @@ enum Document_slots {
DOCUMENTSTYLE_STYLESHEETS = -4,
DOCUMENTVIEW_DEFAULTVIEW = -5,
NSDOCUMENT_CHARACTERSET = -6,
NSDOCUMENT_PLUGINS = -7,
NSDOCUMENT_LOCATION = -8
NSDOCUMENT_DIR = -7,
NSDOCUMENT_PLUGINS = -8,
NSDOCUMENT_LOCATION = -9
};
/***********************************************************************/
@ -224,6 +225,25 @@ GetDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
}
break;
}
case NSDOCUMENT_DIR:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NSDOCUMENT_DIR, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
nsAutoString prop;
nsIDOMNSDocument* b;
if (NS_OK == a->QueryInterface(kINSDocumentIID, (void **)&b)) {
rv = b->GetDir(prop);
if(NS_SUCCEEDED(rv)) {
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
}
NS_RELEASE(b);
}
else {
rv = NS_ERROR_DOM_WRONG_TYPE_ERR;
}
}
break;
}
case NSDOCUMENT_PLUGINS:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NSDOCUMENT_PLUGINS, PR_FALSE);
@ -292,6 +312,26 @@ SetDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
if (!secMan)
return PR_FALSE;
switch(JSVAL_TO_INT(id)) {
case NSDOCUMENT_DIR:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NSDOCUMENT_DIR, PR_TRUE);
if (NS_SUCCEEDED(rv)) {
nsAutoString prop;
nsJSUtils::nsConvertJSValToString(prop, cx, *vp);
nsIDOMNSDocument *b;
if (NS_OK == a->QueryInterface(kINSDocumentIID, (void **)&b)) {
b->SetDir(prop);
NS_RELEASE(b);
}
else {
rv = NS_ERROR_DOM_WRONG_TYPE_ERR;
}
}
break;
}
case NSDOCUMENT_LOCATION:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NSDOCUMENT_LOCATION, PR_TRUE);
@ -337,6 +377,7 @@ static JSPropertySpec DocumentProperties[] =
{"styleSheets", DOCUMENTSTYLE_STYLESHEETS, JSPROP_ENUMERATE | JSPROP_READONLY},
{"defaultView", DOCUMENTVIEW_DEFAULTVIEW, JSPROP_ENUMERATE | JSPROP_READONLY},
{"characterSet", NSDOCUMENT_CHARACTERSET, JSPROP_ENUMERATE | JSPROP_READONLY},
{"dir", NSDOCUMENT_DIR, JSPROP_ENUMERATE},
{"plugins", NSDOCUMENT_PLUGINS, JSPROP_ENUMERATE | JSPROP_READONLY},
{"location", NSDOCUMENT_LOCATION, JSPROP_ENUMERATE},
{0}