Bug 677079 - Part g: Expose VersionSetXML in jsfriendapi.h; r=bhackett

This commit is contained in:
Ms2ger 2012-01-15 09:13:08 +01:00
Родитель d69f8b329c
Коммит d8739c7ff6
5 изменённых файлов: 19 добавлений и 17 удалений

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

@ -41,7 +41,8 @@
* A class that handles loading and evaluation of <script> elements.
*/
#include "jscntxt.h"
#include "jsapi.h"
#include "jsfriendapi.h"
#include "nsScriptLoader.h"
#include "nsParserUtils.h"
#include "nsICharsetConverterManager.h"
@ -498,7 +499,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
// We re-use our knowledge of the implementation to reuse
// JSVERSION_HAS_XML as a safe version flag.
// If version has JSVERSION_UNKNOWN (-1), then this is still OK.
version |= js::VersionFlags::HAS_XML;
version = js::VersionSetXML(JSVersion(version), true);
}
}
} else {

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

@ -47,7 +47,8 @@
* see http://developer.mozilla.org/en/docs/XUL
*/
#include "jscntxt.h" // for JSVERSION_HAS_XML
#include "jsapi.h"
#include "jsfriendapi.h"
#include "nsXULContentSink.h"
#include "nsCOMPtr.h"
#include "nsForwardReference.h"
@ -1060,7 +1061,7 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
// our implementation knowledge to reuse JSVERSION_HAS_XML as a
// safe version flag. This is still OK if version is
// JSVERSION_UNKNOWN (-1),
version |= js::VersionFlags::HAS_XML;
version = js::VersionSetXML(JSVersion(version), true);
nsAutoString value;
rv = parser.GetParameter("e4x", value);
@ -1069,7 +1070,7 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
return rv;
} else {
if (value.Length() == 1 && value[0] == '0')
version &= ~js::VersionFlags::HAS_XML;
version = js::VersionSetXML(JSVersion(version), false);
}
}
}
@ -1083,7 +1084,7 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
// Even when JS version < 1.6 is specified, E4X is
// turned on in XUL.
version |= js::VersionFlags::HAS_XML;
version = js::VersionSetXML(JSVersion(version), true);
}
}
aAttributes += 2;

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

@ -846,15 +846,6 @@ VersionShouldParseXML(JSVersion version)
return VersionHasXML(version) || VersionNumber(version) >= JSVERSION_1_6;
}
static inline void
VersionSetXML(JSVersion *version, bool enable)
{
if (enable)
*version = JSVersion(uint32_t(*version) | VersionFlags::HAS_XML);
else
*version = JSVersion(uint32_t(*version) & ~VersionFlags::HAS_XML);
}
static inline JSVersion
VersionExtractFlags(JSVersion version)
{
@ -884,8 +875,7 @@ VersionFlagsToOptions(JSVersion version)
static inline JSVersion
OptionFlagsToVersion(uintN options, JSVersion version)
{
VersionSetXML(&version, OptionsHasXML(options));
return version;
return VersionSetXML(version, OptionsHasXML(options));
}
static inline bool

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

@ -498,6 +498,13 @@ GetContextStructuredCloneCallbacks(JSContext *cx)
return cx->runtime->structuredCloneCallbacks;
}
JS_FRIEND_API(JSVersion)
VersionSetXML(JSVersion version, bool enable)
{
return enable ? JSVersion(uint32_t(version) | VersionFlags::HAS_XML)
: JSVersion(uint32_t(version) & ~VersionFlags::HAS_XML);
}
#ifdef JS_THREADSAFE
JSThread *
GetContextThread(const JSContext *cx)

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

@ -489,6 +489,9 @@ class JS_FRIEND_API(AutoLockGC)
extern JS_FRIEND_API(const JSStructuredCloneCallbacks *)
GetContextStructuredCloneCallbacks(JSContext *cx);
extern JS_FRIEND_API(JSVersion)
VersionSetXML(JSVersion version, bool enable);
} /* namespace js */
/*