static int32_t
BlacklistFeatureToGfxFeature(const nsAString& aFeature)
{
MOZ_ASSERT(!aFeature.IsEmpty());
if (aFeature.EqualsLiteral("DIRECT2D"))
return nsIGfxInfo::FEATURE_DIRECT2D;
else if (aFeature.EqualsLiteral("DIRECT3D_9_LAYERS"))
return nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS;
else if (aFeature.EqualsLiteral("DIRECT3D_10_LAYERS"))
return nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS;
else if (aFeature.EqualsLiteral("DIRECT3D_10_1_LAYERS"))
return nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS;
else if (aFeature.EqualsLiteral("DIRECT3D_11_LAYERS"))
return nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS;
else if (aFeature.EqualsLiteral("DIRECT3D_11_ANGLE"))
return nsIGfxInfo::FEATURE_DIRECT3D_11_ANGLE;
else if (aFeature.EqualsLiteral("HARDWARE_VIDEO_DECODING"))
return nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING;
else if (aFeature.EqualsLiteral("OPENGL_LAYERS"))
return nsIGfxInfo::FEATURE_OPENGL_LAYERS;
else if (aFeature.EqualsLiteral("WEBGL_OPENGL"))
return nsIGfxInfo::FEATURE_WEBGL_OPENGL;
else if (aFeature.EqualsLiteral("WEBGL_ANGLE"))
return nsIGfxInfo::FEATURE_WEBGL_ANGLE;
else if (aFeature.EqualsLiteral("WEBGL_MSAA"))
return nsIGfxInfo::FEATURE_WEBGL_MSAA;
else if (aFeature.EqualsLiteral("STAGEFRIGHT"))
return nsIGfxInfo::FEATURE_STAGEFRIGHT;
else if (aFeature.EqualsLiteral("WEBRTC_HW_ACCELERATION_ENCODE"))
return nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_ENCODE;
else if (aFeature.EqualsLiteral("WEBRTC_HW_ACCELERATION_DECODE"))
return nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION_DECODE;
else if (aFeature.EqualsLiteral("WEBRTC_HW_ACCELERATION"))
return nsIGfxInfo::FEATURE_WEBRTC_HW_ACCELERATION;
else if (aFeature.EqualsLiteral("CANVAS2D_ACCELERATION"))
return nsIGfxInfo::FEATURE_CANVAS2D_ACCELERATION;
// If we don't recognize the feature, it may be new, and something
// this version doesn't understand. So, nothing to do. This is
// different from feature not being specified at all, in which case
// this method should not get called and we should continue with the
// "all features" blocklisting.
return -1;
}
/* readonly attribute wstring name; */
NS_IMETHODIMP
nsSchemaBuiltinType::GetName(nsAString& aName)
{
switch (mBuiltinType) {
case BUILTIN_TYPE_ANYTYPE:
aName.AssignLiteral("anyType");
break;
case BUILTIN_TYPE_STRING:
aName.AssignLiteral("string");
break;
case BUILTIN_TYPE_NORMALIZED_STRING:
aName.AssignLiteral("normalizedString");
break;
case BUILTIN_TYPE_TOKEN:
aName.AssignLiteral("token");
break;
case BUILTIN_TYPE_BYTE:
aName.AssignLiteral("byte");
break;
case BUILTIN_TYPE_UNSIGNEDBYTE:
aName.AssignLiteral("unsignedByte");
break;
case BUILTIN_TYPE_BASE64BINARY:
aName.AssignLiteral("base64Binary");
break;
case BUILTIN_TYPE_HEXBINARY:
aName.AssignLiteral("hexBinary");
break;
case BUILTIN_TYPE_INTEGER:
aName.AssignLiteral("integer");
break;
case BUILTIN_TYPE_POSITIVEINTEGER:
aName.AssignLiteral("positiveInteger");
break;
case BUILTIN_TYPE_NEGATIVEINTEGER:
aName.AssignLiteral("negativeInteger");
break;
case BUILTIN_TYPE_NONNEGATIVEINTEGER:
aName.AssignLiteral("nonNegativeInteger");
break;
case BUILTIN_TYPE_NONPOSITIVEINTEGER:
aName.AssignLiteral("nonPositiveInteger");
break;
case BUILTIN_TYPE_INT:
aName.AssignLiteral("int");
break;
case BUILTIN_TYPE_UNSIGNEDINT:
aName.AssignLiteral("unsignedInt");
break;
case BUILTIN_TYPE_LONG:
aName.AssignLiteral("long");
break;
case BUILTIN_TYPE_UNSIGNEDLONG:
aName.AssignLiteral("unsignedLong");
break;
case BUILTIN_TYPE_SHORT:
aName.AssignLiteral("short");
break;
case BUILTIN_TYPE_UNSIGNEDSHORT:
aName.AssignLiteral("unsignedShort");
break;
case BUILTIN_TYPE_DECIMAL:
aName.AssignLiteral("decimal");
break;
case BUILTIN_TYPE_FLOAT:
aName.AssignLiteral("float");
break;
case BUILTIN_TYPE_DOUBLE:
aName.AssignLiteral("double");
break;
case BUILTIN_TYPE_BOOLEAN:
aName.AssignLiteral("boolean");
break;
case BUILTIN_TYPE_TIME:
aName.AssignLiteral("time");
break;
case BUILTIN_TYPE_DATETIME:
aName.AssignLiteral("dateTime");
break;
case BUILTIN_TYPE_DURATION:
aName.AssignLiteral("duration");
break;
case BUILTIN_TYPE_DATE:
aName.AssignLiteral("date");
break;
case BUILTIN_TYPE_GMONTH:
aName.AssignLiteral("gMonth");
break;
case BUILTIN_TYPE_GYEAR:
aName.AssignLiteral("gYear");
break;
case BUILTIN_TYPE_GYEARMONTH:
aName.AssignLiteral("gYearMonth");
break;
case BUILTIN_TYPE_GDAY:
aName.AssignLiteral("gDay");
break;
case BUILTIN_TYPE_GMONTHDAY:
aName.AssignLiteral("gMonthDay");
//.........这里部分代码省略.........
nsresult
BluetoothService::HandleSettingsChanged(const nsAString& aData)
{
MOZ_ASSERT(NS_IsMainThread());
// The string that we're interested in will be a JSON string that looks like:
// {"key":"bluetooth.enabled","value":true}
JSContext* cx = nsContentUtils::GetSafeJSContext();
if (!cx) {
return NS_OK;
}
JS::Value val;
if (!JS_ParseJSON(cx, aData.BeginReading(), aData.Length(), &val)) {
return JS_ReportPendingException(cx) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
if (!val.isObject()) {
return NS_OK;
}
JSObject& obj(val.toObject());
JS::Value key;
if (!JS_GetProperty(cx, &obj, "key", &key)) {
MOZ_ASSERT(!JS_IsExceptionPending(cx));
return NS_ERROR_OUT_OF_MEMORY;
}
if (!key.isString()) {
return NS_OK;
}
JSBool match;
if (!JS_StringEqualsAscii(cx, key.toString(), BLUETOOTH_ENABLED_SETTING,
&match)) {
MOZ_ASSERT(!JS_IsExceptionPending(cx));
return NS_ERROR_OUT_OF_MEMORY;
}
if (!match) {
return NS_OK;
}
JS::Value value;
if (!JS_GetProperty(cx, &obj, "value", &value)) {
MOZ_ASSERT(!JS_IsExceptionPending(cx));
return NS_ERROR_OUT_OF_MEMORY;
}
if (!value.isBoolean()) {
MOZ_ASSERT(false, "Expecting a boolean for 'bluetooth.enabled'!");
return NS_ERROR_UNEXPECTED;
}
if (mSettingsCheckInProgress) {
// Somehow the setting for bluetooth has been flipped before our first
// settings check completed. Flip this flag so that we ignore the result
// of that check whenever it finishes.
mSettingsCheckInProgress = false;
}
if (value.toBoolean() == IsEnabled()) {
// Nothing to do here.
return NS_OK;
}
nsresult rv;
if (IsEnabled()) {
rv = StartStopBluetooth(false);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
rv = StartStopBluetooth(true);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
NS_IMETHODIMP
nsCommandLine::ResolveFile(const nsAString& aArgument, nsIFile* *aResult)
{
NS_ENSURE_TRUE(mWorkingDir, NS_ERROR_NOT_INITIALIZED);
// This is some seriously screwed-up code. nsIFile.appendRelativeNativePath
// explicitly does not accept .. or . path parts, but that is exactly what we
// need here. So we hack around it.
nsresult rv;
#if defined(MOZ_WIDGET_COCOA)
nsCOMPtr<nsILocalFileMac> lfm (do_QueryInterface(mWorkingDir));
NS_ENSURE_TRUE(lfm, NS_ERROR_NO_INTERFACE);
nsCOMPtr<nsILocalFileMac> newfile (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
NS_ENSURE_TRUE(newfile, NS_ERROR_OUT_OF_MEMORY);
CFURLRef baseurl;
rv = lfm->GetCFURL(&baseurl);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString path;
NS_CopyUnicodeToNative(aArgument, path);
CFURLRef newurl =
CFURLCreateFromFileSystemRepresentationRelativeToBase(nullptr, (const UInt8*) path.get(),
path.Length(),
true, baseurl);
CFRelease(baseurl);
rv = newfile->InitWithCFURL(newurl);
CFRelease(newurl);
if (NS_FAILED(rv)) return rv;
newfile.forget(aResult);
return NS_OK;
#elif defined(XP_UNIX)
nsCOMPtr<nsIFile> lf (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
NS_ENSURE_TRUE(lf, NS_ERROR_OUT_OF_MEMORY);
if (aArgument.First() == '/') {
// absolute path
rv = lf->InitWithPath(aArgument);
if (NS_FAILED(rv)) return rv;
NS_ADDREF(*aResult = lf);
return NS_OK;
}
nsAutoCString nativeArg;
NS_CopyUnicodeToNative(aArgument, nativeArg);
nsAutoCString newpath;
mWorkingDir->GetNativePath(newpath);
newpath.Append('/');
newpath.Append(nativeArg);
rv = lf->InitWithNativePath(newpath);
if (NS_FAILED(rv)) return rv;
rv = lf->Normalize();
if (NS_FAILED(rv)) return rv;
lf.forget(aResult);
return NS_OK;
#elif defined(XP_WIN32)
nsCOMPtr<nsIFile> lf (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
NS_ENSURE_TRUE(lf, NS_ERROR_OUT_OF_MEMORY);
rv = lf->InitWithPath(aArgument);
if (NS_FAILED(rv)) {
// If it's a relative path, the Init is *going* to fail. We use string magic and
// win32 _fullpath. Note that paths of the form "\Relative\To\CurDrive" are
// going to fail, and I haven't figured out a way to work around this without
// the PathCombine() function, which is not available in plain win95/nt4
nsAutoString fullPath;
mWorkingDir->GetPath(fullPath);
fullPath.Append('\\');
fullPath.Append(aArgument);
WCHAR pathBuf[MAX_PATH];
if (!_wfullpath(pathBuf, fullPath.get(), MAX_PATH))
return NS_ERROR_FAILURE;
rv = lf->InitWithPath(nsDependentString(pathBuf));
if (NS_FAILED(rv)) return rv;
}
lf.forget(aResult);
return NS_OK;
#else
#error Need platform-specific logic here.
#endif
//.........这里部分代码省略.........
void
nsCSSSelector::AppendToStringWithoutCombinatorsOrNegations
(nsAString& aString, CSSStyleSheet* aSheet,
bool aIsNegated) const
{
nsAutoString temp;
bool isPseudoElement = IsPseudoElement();
// For non-pseudo-element selectors or for lone pseudo-elements, deal with
// namespace prefixes.
bool wroteNamespace = false;
if (!isPseudoElement || !mNext) {
// append the namespace prefix if needed
nsXMLNameSpaceMap *sheetNS = aSheet ? aSheet->GetNameSpaceMap() : nullptr;
// sheetNS is non-null if and only if we had an @namespace rule. If it's
// null, that means that the only namespaces we could have are the
// wildcard namespace (which can be implicit in this case) and the "none"
// namespace, which then needs to be explicitly specified.
if (!sheetNS) {
NS_ASSERTION(mNameSpace == kNameSpaceID_Unknown ||
mNameSpace == kNameSpaceID_None,
"How did we get this namespace?");
if (mNameSpace == kNameSpaceID_None) {
aString.Append(char16_t('|'));
wroteNamespace = true;
}
} else if (sheetNS->FindNameSpaceID(nullptr) == mNameSpace) {
// We have the default namespace (possibly including the wildcard
// namespace). Do nothing.
NS_ASSERTION(mNameSpace == kNameSpaceID_Unknown ||
CanBeNamespaced(aIsNegated),
"How did we end up with this namespace?");
} else if (mNameSpace == kNameSpaceID_None) {
NS_ASSERTION(CanBeNamespaced(aIsNegated),
"How did we end up with this namespace?");
aString.Append(char16_t('|'));
wroteNamespace = true;
} else if (mNameSpace != kNameSpaceID_Unknown) {
NS_ASSERTION(CanBeNamespaced(aIsNegated),
"How did we end up with this namespace?");
nsIAtom *prefixAtom = sheetNS->FindPrefix(mNameSpace);
NS_ASSERTION(prefixAtom, "how'd we get a non-default namespace "
"without a prefix?");
nsStyleUtil::AppendEscapedCSSIdent(nsDependentAtomString(prefixAtom),
aString);
aString.Append(char16_t('|'));
wroteNamespace = true;
} else {
// A selector for an element in any namespace, while the default
// namespace is something else. :not() is special in that the default
// namespace is not implied for non-type selectors, so if this is a
// negated non-type selector we don't need to output an explicit wildcard
// namespace here, since those default to a wildcard namespace.
if (CanBeNamespaced(aIsNegated)) {
aString.AppendLiteral("*|");
wroteNamespace = true;
}
}
}
if (!mLowercaseTag) {
// Universal selector: avoid writing the universal selector when we
// can avoid it, especially since we're required to avoid it for the
// inside of :not()
if (wroteNamespace ||
(!mIDList && !mClassList && !mPseudoClassList && !mAttrList &&
(aIsNegated || !mNegations))) {
aString.Append(char16_t('*'));
}
} else {
// Append the tag name
nsAutoString tag;
(isPseudoElement ? mLowercaseTag : mCasedTag)->ToString(tag);
if (isPseudoElement) {
if (!mNext) {
// Lone pseudo-element selector -- toss in a wildcard type selector
// XXXldb Why?
aString.Append(char16_t('*'));
}
// While our atoms use one colon, most pseudo-elements require two
// colons (those not in CSS level 2) and all pseudo-elements allow
// two colons. So serialize to the non-deprecated two colon syntax.
aString.Append(char16_t(':'));
// This should not be escaped since (a) the pseudo-element string
// has a ":" that can't be escaped and (b) all pseudo-elements at
// this point are known, and therefore we know they don't need
// escaping.
aString.Append(tag);
} else {
nsStyleUtil::AppendEscapedCSSIdent(tag, aString);
}
}
// Append the id, if there is one
if (mIDList) {
nsAtomList* list = mIDList;
while (list != nullptr) {
list->mAtom->ToString(temp);
aString.Append(char16_t('#'));
//.........这里部分代码省略.........
请发表评论