Make top-level PIs and comments respect their XML.ignore* flags (246441 cont'd).

This commit is contained in:
brendan%mozilla.org 2005-03-27 20:18:51 +00:00
Родитель de47825124
Коммит 0120c22ebc
3 изменённых файлов: 38 добавлений и 24 удалений

Просмотреть файл

@ -5176,22 +5176,19 @@ js_Interpret(JSContext *cx, jsbytecode *pc, jsval *result)
case JSOP_XMLCDATA:
atom = GET_ATOM(cx, script, pc);
str = ATOM_TO_STRING(atom);
obj = js_NewXMLSpecialObject(cx, JSXML_CLASS_TEXT, NULL, str);
if (!obj) {
ok = JS_FALSE;
ok = js_NewXMLSpecialObject(cx, JSXML_CLASS_TEXT, NULL, str, &obj);
if (!ok)
goto out;
}
PUSH_OPND(OBJECT_TO_JSVAL(obj));
break;
case JSOP_XMLCOMMENT:
atom = GET_ATOM(cx, script, pc);
str = ATOM_TO_STRING(atom);
obj = js_NewXMLSpecialObject(cx, JSXML_CLASS_COMMENT, NULL, str);
if (!obj) {
ok = JS_FALSE;
ok = js_NewXMLSpecialObject(cx, JSXML_CLASS_COMMENT, NULL, str,
&obj);
if (!ok)
goto out;
}
PUSH_OPND(OBJECT_TO_JSVAL(obj));
break;
@ -5200,13 +5197,10 @@ js_Interpret(JSContext *cx, jsbytecode *pc, jsval *result)
str = ATOM_TO_STRING(atom);
atom = GET_ATOM(cx, script, pc + ATOM_INDEX_LEN);
str2 = ATOM_TO_STRING(atom);
obj = js_NewXMLSpecialObject(cx,
JSXML_CLASS_PROCESSING_INSTRUCTION,
str, str2);
if (!obj) {
ok = JS_FALSE;
ok = js_NewXMLSpecialObject(cx, JSXML_CLASS_PROCESSING_INSTRUCTION,
str, str2, &obj);
if (!ok)
goto out;
}
PUSH_OPND(OBJECT_TO_JSVAL(obj));
break;

Просмотреть файл

@ -2530,9 +2530,11 @@ XMLToXMLString(JSContext *cx, JSXML *xml, const JSXMLArray *ancestorNSes,
bp += 2;
js_strncpy(bp, JSSTRING_CHARS(name), namelength);
bp += namelength;
*bp++ = (jschar) ' ';
js_strncpy(bp, JSSTRING_CHARS(str), length);
bp += length;
if (length != 0) {
*bp++ = (jschar) ' ';
js_strncpy(bp, JSSTRING_CHARS(str), length);
bp += length;
}
js_strncpy(bp, pi_suffix_ucNstr, 2);
bp[2] = 0;
str = js_NewString(cx, base, newlength, 0);
@ -7706,26 +7708,44 @@ js_CloneXMLObject(JSContext *cx, JSObject *obj)
return NewXMLObject(cx, xml);
}
JSObject *
JSBool
js_NewXMLSpecialObject(JSContext *cx, JSXMLClass xml_class, JSString *name,
JSString *value)
JSString *value, JSObject **objp)
{
uintN flags;
JSObject *obj;
JSXML *xml;
JSXMLQName *qn;
if (!GetXMLSettingFlags(cx, &flags))
return JS_FALSE;
*objp = NULL;
switch (xml_class) {
case JSXML_CLASS_COMMENT:
if (flags & XSF_IGNORE_COMMENTS)
return JS_TRUE;
break;
case JSXML_CLASS_PROCESSING_INSTRUCTION:
if (flags & XSF_IGNORE_PROCESSING_INSTRUCTIONS)
return JS_TRUE;
break;
default:;
}
obj = js_NewXMLObject(cx, xml_class);
if (!obj)
return NULL;
return JS_FALSE;
xml = (JSXML *) JS_GetPrivate(cx, obj);
if (name) {
qn = js_NewXMLQName(cx, cx->runtime->emptyString, NULL, name);
if (!qn)
return NULL;
return JS_FALSE;
xml->name = qn;
}
xml->xml_value = value;
return obj;
*objp = obj;
return JS_TRUE;
}
#endif /* JS_HAS_XML_SUPPORT */

Просмотреть файл

@ -305,8 +305,8 @@ js_ValueToXMLListObject(JSContext *cx, jsval v);
extern JSObject *
js_CloneXMLObject(JSContext *cx, JSObject *obj);
extern JSObject *
extern JSBool
js_NewXMLSpecialObject(JSContext *cx, JSXMLClass xml_class, JSString *name,
JSString *value);
JSString *value, JSObject **objp);
#endif /* jsxml_h___ */