本文整理汇总了C++中nsAString::EqualsLiteral方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAString::EqualsLiteral方法的具体用法?C++ nsAString::EqualsLiteral怎么用?C++ nsAString::EqualsLiteral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAString
的用法示例。
在下文中一共展示了nsAString::EqualsLiteral方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
PhoneType
BluetoothHfpManager::GetPhoneType(const nsAString& aType)
{
// FIXME: Query phone type from RIL after RIL implements new API (bug 912019)
if (aType.EqualsLiteral("gsm") || aType.EqualsLiteral("gprs") ||
aType.EqualsLiteral("edge") || aType.EqualsLiteral("umts") ||
aType.EqualsLiteral("hspa") || aType.EqualsLiteral("hsdpa") ||
aType.EqualsLiteral("hsupa") || aType.EqualsLiteral("hspa+")) {
return PhoneType::GSM;
} else if (aType.EqualsLiteral("is95a") || aType.EqualsLiteral("is95b") ||
aType.EqualsLiteral("1xrtt") || aType.EqualsLiteral("evdo0") ||
aType.EqualsLiteral("evdoa") || aType.EqualsLiteral("evdob")) {
return PhoneType::CDMA;
}
return PhoneType::NONE;
}
示例2:
bool
UIEvent::GetModifierStateInternal(const nsAString& aKey)
{
WidgetInputEvent* inputEvent = mEvent->AsInputEvent();
MOZ_ASSERT(inputEvent, "mEvent must be WidgetInputEvent or derived class");
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_SHIFT)) {
return inputEvent->IsShift();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_CONTROL)) {
return inputEvent->IsControl();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_META)) {
return inputEvent->IsMeta();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_ALT)) {
return inputEvent->IsAlt();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_ALTGRAPH)) {
return inputEvent->IsAltGraph();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_OS)) {
return inputEvent->IsOS();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_CAPSLOCK)) {
return inputEvent->IsCapsLocked();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_NUMLOCK)) {
return inputEvent->IsNumLocked();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_FN)) {
return inputEvent->IsFn();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_SCROLLLOCK)) {
return inputEvent->IsScrollLocked();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_SYMBOLLOCK)) {
return inputEvent->IsSymbolLocked();
}
return false;
}
示例3: while
void
BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex,
uint16_t aCallState,
const nsAString& aError,
const nsAString& aNumber,
const bool aIsOutgoing,
const bool aIsConference,
bool aSend)
{
// aCallIndex can be UINT32_MAX for the pending outgoing call state update.
// aCallIndex will be updated again after real call state changes. See Bug
// 990467.
if (aCallIndex == UINT32_MAX) {
return;
}
// Update call state only
while (aCallIndex >= mCurrentCallArray.Length()) {
Call call;
mCurrentCallArray.AppendElement(call);
}
mCurrentCallArray[aCallIndex].mState = aCallState;
// Return if SLC is disconnected
if (!IsConnected()) {
return;
}
// Update call information besides call state
mCurrentCallArray[aCallIndex].Set(aNumber, aIsOutgoing);
// Notify bluedroid of phone state change if this
// call state change is not during transition state
if (!IsTransitionState(aCallState, aIsConference)) {
UpdatePhoneCIND(aCallIndex);
}
switch (aCallState) {
case nsITelephonyService::CALL_STATE_DIALING:
// We've send Dialer a dialing request and this is the response.
if (!mDialingRequestProcessed) {
SendResponse(HFP_AT_RESPONSE_OK);
mDialingRequestProcessed = true;
}
break;
case nsITelephonyService::CALL_STATE_DISCONNECTED:
// -1 is necessary because call 0 is an invalid (padding) call object.
if (mCurrentCallArray.Length() - 1 ==
GetNumberOfCalls(nsITelephonyService::CALL_STATE_DISCONNECTED)) {
// In order to let user hear busy tone via connected Bluetooth headset,
// we postpone the timing of dropping SCO.
if (aError.EqualsLiteral("BusyError")) {
// FIXME: UpdatePhoneCIND later since it causes SCO close but
// Dialer is still playing busy tone via HF.
NS_DispatchToMainThread(new CloseScoRunnable());
}
ResetCallArray();
}
break;
default:
break;
}
}
示例4: GetDOMTiming
DOMHighResTimeStamp
nsPerformance::GetPerformanceTimingFromString(const nsAString& aProperty)
{
if (!IsPerformanceTimingAttribute(aProperty)) {
return 0;
}
if (aProperty.EqualsLiteral("navigationStart")) {
// DOMHighResTimeStamp is in relation to navigationStart, so this will be
// zero.
return GetDOMTiming()->GetNavigationStart();
}
if (aProperty.EqualsLiteral("unloadEventStart")) {
return GetDOMTiming()->GetUnloadEventStart();
}
if (aProperty.EqualsLiteral("unloadEventEnd")) {
return GetDOMTiming()->GetUnloadEventEnd();
}
if (aProperty.EqualsLiteral("redirectStart")) {
return Timing()->RedirectStart();
}
if (aProperty.EqualsLiteral("redirectEnd")) {
return Timing()->RedirectEnd();
}
if (aProperty.EqualsLiteral("fetchStart")) {
return Timing()->FetchStart();
}
if (aProperty.EqualsLiteral("domainLookupStart")) {
return Timing()->DomainLookupStart();
}
if (aProperty.EqualsLiteral("domainLookupEnd")) {
return Timing()->DomainLookupEnd();
}
if (aProperty.EqualsLiteral("connectStart")) {
return Timing()->ConnectStart();
}
if (aProperty.EqualsLiteral("connectEnd")) {
return Timing()->ConnectEnd();
}
if (aProperty.EqualsLiteral("requestStart")) {
return Timing()->RequestStart();
}
if (aProperty.EqualsLiteral("responseStart")) {
return Timing()->ResponseStart();
}
if (aProperty.EqualsLiteral("responseEnd")) {
return Timing()->ResponseEnd();
}
if (aProperty.EqualsLiteral("domLoading")) {
return GetDOMTiming()->GetDomLoading();
}
if (aProperty.EqualsLiteral("domInteractive")) {
return GetDOMTiming()->GetDomInteractive();
}
if (aProperty.EqualsLiteral("domContentLoadedEventStart")) {
return GetDOMTiming()->GetDomContentLoadedEventStart();
}
if (aProperty.EqualsLiteral("domContentLoadedEventEnd")) {
return GetDOMTiming()->GetDomContentLoadedEventEnd();
}
if (aProperty.EqualsLiteral("domComplete")) {
return GetDOMTiming()->GetDomComplete();
}
if (aProperty.EqualsLiteral("loadEventStart")) {
return GetDOMTiming()->GetLoadEventStart();
}
if (aProperty.EqualsLiteral("loadEventEnd")) {
return GetDOMTiming()->GetLoadEventEnd();
}
MOZ_CRASH("IsPerformanceTimingAttribute and GetPerformanceTimingFromString are out of sync");
return 0;
}
示例5: ConfirmPrefix
PRBool
nsXMLContentSerializer::ConfirmPrefix(nsAString& aPrefix,
const nsAString& aURI,
nsIDOMElement* aElement,
PRBool aIsAttribute)
{
if (aPrefix.EqualsLiteral(kXMLNS)) {
return PR_FALSE;
}
if (aURI.EqualsLiteral("http://www.w3.org/XML/1998/namespace")) {
// The prefix must be xml for this namespace. We don't need to declare it,
// so always just set the prefix to xml.
aPrefix.AssignLiteral("xml");
return PR_FALSE;
}
PRBool mustHavePrefix;
if (aIsAttribute) {
if (aURI.IsEmpty()) {
// Attribute in the null namespace. This just shouldn't have a prefix.
// And there's no need to push any namespace decls
aPrefix.Truncate();
return PR_FALSE;
}
// Attribute not in the null namespace -- must have a prefix
mustHavePrefix = PR_TRUE;
} else {
// Not an attribute, so doesn't _have_ to have a prefix
mustHavePrefix = PR_FALSE;
}
// Keep track of the closest prefix that's bound to aURI and whether we've
// found such a thing. closestURIMatch holds the prefix, and uriMatch
// indicates whether we actually have one.
nsAutoString closestURIMatch;
PRBool uriMatch = PR_FALSE;
// Also keep track of whether we've seen aPrefix already. If we have, that
// means that it's already bound to a URI different from aURI, so even if we
// later (so in a more outer scope) see it bound to aURI we can't reuse it.
PRBool haveSeenOurPrefix = PR_FALSE;
PRInt32 count = mNameSpaceStack.Count();
PRInt32 index = count - 1;
while (index >= 0) {
NameSpaceDecl* decl = (NameSpaceDecl*)mNameSpaceStack.ElementAt(index);
// Check if we've found a prefix match
if (aPrefix.Equals(decl->mPrefix)) {
// If the URIs match and aPrefix is not bound to any other URI, we can
// use aPrefix
if (!haveSeenOurPrefix && aURI.Equals(decl->mURI)) {
// Just use our uriMatch stuff. That will deal with an empty aPrefix
// the right way. We can break out of the loop now, though.
uriMatch = PR_TRUE;
closestURIMatch = aPrefix;
break;
}
haveSeenOurPrefix = PR_TRUE;
// If they don't, and either:
// 1) We have a prefix (so we'd be redeclaring this prefix to point to a
// different namespace) or
// 2) We're looking at an existing default namespace decl on aElement (so
// we can't create a new default namespace decl for this URI)
// then generate a new prefix. Note that we do NOT generate new prefixes
// if we happen to have aPrefix == decl->mPrefix == "" and mismatching
// URIs when |decl| doesn't have aElement as its owner. In that case we
// can simply push the new namespace URI as the default namespace for
// aElement.
if (!aPrefix.IsEmpty() || decl->mOwner == aElement) {
NS_ASSERTION(!aURI.IsEmpty(),
"Not allowed to add a xmlns attribute with an empty "
"namespace name unless it declares the default "
"namespace.");
GenerateNewPrefix(aPrefix);
// Now we need to validate our new prefix/uri combination; check it
// against the full namespace stack again. Note that just restarting
// the while loop is ok, since we haven't changed aURI, so the
// closestURIMatch and uriMatch state is not affected.
index = count - 1;
haveSeenOurPrefix = PR_FALSE;
continue;
}
}
// If we've found a URI match, then record the first one
if (!uriMatch && aURI.Equals(decl->mURI)) {
// Need to check that decl->mPrefix is not declared anywhere closer to
// us. If it is, we can't use it.
PRBool prefixOK = PR_TRUE;
PRInt32 index2;
for (index2 = count-1; index2 > index && prefixOK; --index2) {
NameSpaceDecl* decl2 =
(NameSpaceDecl*)mNameSpaceStack.ElementAt(index2);
//.........这里部分代码省略.........
示例6: if
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;
// 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;
}
示例7: sort
nsresult
XULSortServiceImpl::InitializeSortState(nsIContent* aRootElement,
nsIContent* aContainer,
const nsAString& aSortKey,
const nsAString& aSortDirection,
nsSortState* aSortState)
{
// used as an optimization for the content builder
if (aContainer != aSortState->lastContainer.get()) {
aSortState->lastContainer = aContainer;
aSortState->lastWasFirst = PR_FALSE;
aSortState->lastWasLast = PR_FALSE;
}
// The attributes allowed are either:
// sort="key1 key2 ..."
// or sortResource="key1" sortResource2="key2"
// The latter is for backwards compatibility, and is equivalent to concatenating
// both values in the sort attribute
nsAutoString sort(aSortKey);
aSortState->sortKeys.Clear();
if (sort.IsEmpty()) {
nsAutoString sortResource, sortResource2;
aRootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::sortResource, sortResource);
if (!sortResource.IsEmpty()) {
nsCOMPtr<nsIAtom> sortkeyatom = do_GetAtom(sortResource);
aSortState->sortKeys.AppendObject(sortkeyatom);
sort.Append(sortResource);
aRootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::sortResource2, sortResource2);
if (!sortResource2.IsEmpty()) {
nsCOMPtr<nsIAtom> sortkeyatom2 = do_GetAtom(sortResource2);
aSortState->sortKeys.AppendObject(sortkeyatom2);
sort.AppendLiteral(" ");
sort.Append(sortResource2);
}
}
}
else {
PRInt32 start = 0, end = 0;
while ((end = sort.FindChar(' ',start)) >= 0) {
if (end > start) {
nsCOMPtr<nsIAtom> keyatom = do_GetAtom(Substring(sort, start, end - start));
if (!keyatom)
return NS_ERROR_OUT_OF_MEMORY;
aSortState->sortKeys.AppendObject(keyatom);
}
start = end + 1;
}
if (start < (PRInt32)sort.Length()) {
nsCOMPtr<nsIAtom> keyatom = do_GetAtom(Substring(sort, start));
if (!keyatom)
return NS_ERROR_OUT_OF_MEMORY;
aSortState->sortKeys.AppendObject(keyatom);
}
}
aSortState->sort.Assign(sort);
// set up sort order info
if (aSortDirection.EqualsLiteral("descending"))
aSortState->direction = nsSortState_descending;
else if (aSortDirection.EqualsLiteral("ascending"))
aSortState->direction = nsSortState_ascending;
else
aSortState->direction = nsSortState_natural;
aSortState->invertSort = PR_FALSE;
nsAutoString existingsort;
aRootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::sort, existingsort);
nsAutoString existingsortDirection;
aRootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::sortDirection, existingsortDirection);
// if just switching direction, set the invertSort flag
if (sort.Equals(existingsort)) {
if (aSortState->direction == nsSortState_descending) {
if (existingsortDirection.EqualsLiteral("ascending"))
aSortState->invertSort = PR_TRUE;
}
else if (aSortState->direction == nsSortState_ascending &&
existingsortDirection.EqualsLiteral("descending")) {
aSortState->invertSort = PR_TRUE;
}
}
// sort items between separatore independently
aSortState->inbetweenSeparatorSort =
aRootElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::sortSeparators,
nsGkAtoms::_true, eCaseMatters);
// sort static content (non template generated nodes) after generated content
aSortState->sortStaticsLast = aRootElement->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::sortStaticsLast,
nsGkAtoms::_true, eCaseMatters);
aSortState->initialized = PR_TRUE;
//.........这里部分代码省略.........
示例8: LOGD
nsresult
GeckoMediaPluginServiceParent::GetNodeId(const nsAString& aOrigin,
const nsAString& aTopLevelOrigin,
bool aInPrivateBrowsing,
const nsACString& aVersion,
nsACString& aOutId)
{
MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
LOGD(("%s::%s: (%s, %s), %s", __CLASS__, __FUNCTION__,
NS_ConvertUTF16toUTF8(aOrigin).get(),
NS_ConvertUTF16toUTF8(aTopLevelOrigin).get(),
(aInPrivateBrowsing ? "PrivateBrowsing" : "NonPrivateBrowsing")));
nsresult rv;
if (aOrigin.EqualsLiteral("null") ||
aOrigin.IsEmpty() ||
aTopLevelOrigin.EqualsLiteral("null") ||
aTopLevelOrigin.IsEmpty()) {
// At least one of the (origin, topLevelOrigin) is null or empty;
// probably a local file. Generate a random node id, and don't store
// it so that the GMP's storage is temporary and not shared.
nsAutoCString salt;
rv = GenerateRandomPathName(salt, NodeIdSaltLength);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
aOutId = salt;
mPersistentStorageAllowed.Put(salt, false);
return NS_OK;
}
const uint32_t hash = AddToHash(HashString(aOrigin),
HashString(aTopLevelOrigin),
HashString(aVersion));
if (aInPrivateBrowsing) {
// For PB mode, we store the node id, indexed by the origin pair,
// so that if the same origin pair is opened in this session, it gets
// the same node id.
nsCString* salt = nullptr;
if (!(salt = mTempNodeIds.Get(hash))) {
// No salt stored, generate and temporarily store some for this id.
nsAutoCString newSalt;
rv = GenerateRandomPathName(newSalt, NodeIdSaltLength);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
salt = new nsCString(newSalt);
mTempNodeIds.Put(hash, salt);
mPersistentStorageAllowed.Put(*salt, false);
}
aOutId = *salt;
return NS_OK;
}
// Otherwise, try to see if we've previously generated and stored salt
// for this origin pair.
nsCOMPtr<nsIFile> path; // $profileDir/gmp/
rv = GetStorageDir(getter_AddRefs(path));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = path->AppendNative(NS_LITERAL_CSTRING("id"));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
// $profileDir/gmp/id/
rv = path->Create(nsIFile::DIRECTORY_TYPE, 0700);
if (rv != NS_ERROR_FILE_ALREADY_EXISTS && NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
nsAutoCString hashStr;
hashStr.AppendInt((int64_t)hash);
// $profileDir/gmp/id/$hash
rv = path->AppendNative(hashStr);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = path->Create(nsIFile::DIRECTORY_TYPE, 0700);
if (rv != NS_ERROR_FILE_ALREADY_EXISTS && NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
nsCOMPtr<nsIFile> saltFile;
rv = path->Clone(getter_AddRefs(saltFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = saltFile->AppendNative(NS_LITERAL_CSTRING("salt"));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
//.........这里部分代码省略.........
示例9: htmlValueString
nsresult
nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode *aNode,
nsIAtom *aHTMLProperty,
const nsAString *aHTMLAttribute,
bool& aIsSet,
nsAString& valueString,
StyleType aStyleType)
{
NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
nsAutoString htmlValueString(valueString);
aIsSet = false;
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
do {
valueString.Assign(htmlValueString);
// get the value of the CSS equivalent styles
nsresult res = GetCSSEquivalentToHTMLInlineStyleSet(node, aHTMLProperty, aHTMLAttribute,
valueString, aStyleType);
NS_ENSURE_SUCCESS(res, res);
// early way out if we can
if (valueString.IsEmpty()) {
return NS_OK;
}
if (nsGkAtoms::b == aHTMLProperty) {
if (valueString.EqualsLiteral("bold")) {
aIsSet = true;
} else if (valueString.EqualsLiteral("normal")) {
aIsSet = false;
} else if (valueString.EqualsLiteral("bolder")) {
aIsSet = true;
valueString.AssignLiteral("bold");
} else {
int32_t weight = 0;
nsresult errorCode;
nsAutoString value(valueString);
weight = value.ToInteger(&errorCode);
if (400 < weight) {
aIsSet = true;
valueString.AssignLiteral("bold");
} else {
aIsSet = false;
valueString.AssignLiteral("normal");
}
}
} else if (nsGkAtoms::i == aHTMLProperty) {
if (valueString.EqualsLiteral("italic") ||
valueString.EqualsLiteral("oblique")) {
aIsSet = true;
}
} else if (nsGkAtoms::u == aHTMLProperty) {
nsAutoString val;
val.AssignLiteral("underline");
aIsSet = ChangeStyleTxn::ValueIncludes(valueString, val);
} else if (nsGkAtoms::strike == aHTMLProperty) {
nsAutoString val;
val.AssignLiteral("line-through");
aIsSet = ChangeStyleTxn::ValueIncludes(valueString, val);
} else if (aHTMLAttribute &&
((nsGkAtoms::font == aHTMLProperty &&
aHTMLAttribute->EqualsLiteral("color")) ||
aHTMLAttribute->EqualsLiteral("bgcolor"))) {
if (htmlValueString.IsEmpty()) {
aIsSet = true;
} else {
nscolor rgba;
nsAutoString subStr;
htmlValueString.Right(subStr, htmlValueString.Length() - 1);
if (NS_ColorNameToRGB(htmlValueString, &rgba) ||
NS_HexToRGB(subStr, &rgba)) {
nsAutoString htmlColor, tmpStr;
if (NS_GET_A(rgba) != 255) {
// This should only be hit by the "transparent" keyword, which
// currently serializes to "transparent" (not "rgba(0, 0, 0, 0)").
MOZ_ASSERT(NS_GET_R(rgba) == 0 && NS_GET_G(rgba) == 0 &&
NS_GET_B(rgba) == 0 && NS_GET_A(rgba) == 0);
htmlColor.AppendLiteral("transparent");
} else {
htmlColor.AppendLiteral("rgb(");
NS_NAMED_LITERAL_STRING(comma, ", ");
tmpStr.AppendInt(NS_GET_R(rgba), 10);
htmlColor.Append(tmpStr + comma);
tmpStr.Truncate();
tmpStr.AppendInt(NS_GET_G(rgba), 10);
htmlColor.Append(tmpStr + comma);
tmpStr.Truncate();
tmpStr.AppendInt(NS_GET_B(rgba), 10);
htmlColor.Append(tmpStr);
htmlColor.Append(char16_t(')'));
}
aIsSet = htmlColor.Equals(valueString,
nsCaseInsensitiveStringComparator());
//.........这里部分代码省略.........
示例10:
bool
nsDOMUIEvent::GetModifierStateInternal(const nsAString& aKey)
{
nsInputEvent* inputEvent = static_cast<nsInputEvent*>(mEvent);
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_SHIFT)) {
return inputEvent->IsShift();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_CONTROL)) {
return inputEvent->IsControl();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_META)) {
return inputEvent->IsMeta();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_ALT)) {
return inputEvent->IsAlt();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_ALTGRAPH)) {
return inputEvent->IsAltGraph();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_OS)) {
return inputEvent->IsOS();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_CAPSLOCK)) {
return inputEvent->IsCapsLocked();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_NUMLOCK)) {
return inputEvent->IsNumLocked();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_FN)) {
return inputEvent->IsFn();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_SCROLLLOCK)) {
return inputEvent->IsScrollLocked();
}
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_SYMBOLLOCK)) {
return inputEvent->IsSymbolLocked();
}
return false;
}
示例11: defined
static bool
GetSupportedConfig(mozIGeckoMediaPluginService* aGMPService,
const nsAString& aKeySystem,
const MediaKeySystemConfiguration& aCandidate,
MediaKeySystemConfiguration& aOutConfig,
DecoderDoctorDiagnostics* aDiagnostics)
{
MediaKeySystemConfiguration config;
config.mLabel = aCandidate.mLabel;
if (aCandidate.mInitDataTypes.WasPassed()) {
nsTArray<nsString> initDataTypes;
for (const nsString& candidate : aCandidate.mInitDataTypes.Value()) {
if (IsSupportedInitDataType(candidate, aKeySystem)) {
initDataTypes.AppendElement(candidate);
}
}
if (initDataTypes.IsEmpty()) {
return false;
}
config.mInitDataTypes.Construct();
config.mInitDataTypes.Value().Assign(initDataTypes);
}
if (aCandidate.mAudioCapabilities.WasPassed()) {
nsTArray<MediaKeySystemMediaCapability> caps;
for (const MediaKeySystemMediaCapability& cap : aCandidate.mAudioCapabilities.Value()) {
if (IsSupportedAudio(aGMPService, aKeySystem, cap.mContentType, aDiagnostics)) {
caps.AppendElement(cap);
}
}
if (caps.IsEmpty()) {
return false;
}
config.mAudioCapabilities.Construct();
config.mAudioCapabilities.Value().Assign(caps);
}
if (aCandidate.mVideoCapabilities.WasPassed()) {
nsTArray<MediaKeySystemMediaCapability> caps;
for (const MediaKeySystemMediaCapability& cap : aCandidate.mVideoCapabilities.Value()) {
if (IsSupportedVideo(aGMPService, aKeySystem, cap.mContentType, aDiagnostics)) {
caps.AppendElement(cap);
}
}
if (caps.IsEmpty()) {
return false;
}
config.mVideoCapabilities.Construct();
config.mVideoCapabilities.Value().Assign(caps);
}
#if defined(MOZ_WIDEVINE_EME) && defined(XP_WIN)
// Widevine CDM doesn't include an AAC decoder. So if WMF can't decode AAC,
// and a codec wasn't specified, be conservative and reject the MediaKeys request.
if (aKeySystem.EqualsLiteral("com.widevine.alpha") &&
(!aCandidate.mAudioCapabilities.WasPassed() ||
!aCandidate.mVideoCapabilities.WasPassed()) &&
!WMFDecoderModule::HasAAC()) {
if (aDiagnostics) {
aDiagnostics->SetKeySystemIssue(
DecoderDoctorDiagnostics::eWidevineWithNoWMF);
}
return false;
}
#endif
aOutConfig = config;
return true;
}
示例12: EnsureMinCDMVersion
/* static */
MediaKeySystemStatus
MediaKeySystemAccess::GetKeySystemStatus(const nsAString& aKeySystem,
int32_t aMinCdmVersion,
nsACString& aOutMessage,
nsACString& aOutCdmVersion)
{
MOZ_ASSERT(MediaPrefs::EMEEnabled());
nsCOMPtr<mozIGeckoMediaPluginService> mps =
do_GetService("@mozilla.org/gecko-media-plugin-service;1");
if (NS_WARN_IF(!mps)) {
aOutMessage = NS_LITERAL_CSTRING("Failed to get GMP service");
return MediaKeySystemStatus::Error;
}
if (aKeySystem.EqualsLiteral("org.w3.clearkey")) {
if (!Preferences::GetBool("media.eme.clearkey.enabled", true)) {
aOutMessage = NS_LITERAL_CSTRING("ClearKey was disabled");
return MediaKeySystemStatus::Cdm_disabled;
}
return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
}
#ifdef MOZ_ADOBE_EME
if (aKeySystem.EqualsLiteral("com.adobe.primetime")) {
if (!Preferences::GetBool("media.gmp-eme-adobe.enabled", false)) {
aOutMessage = NS_LITERAL_CSTRING("Adobe EME disabled");
return MediaKeySystemStatus::Cdm_disabled;
}
#ifdef XP_WIN
// Win Vista and later only.
if (!IsVistaOrLater()) {
aOutMessage = NS_LITERAL_CSTRING("Minimum Windows version (Vista) not met for Adobe EME");
return MediaKeySystemStatus::Cdm_not_supported;
}
#endif
#ifdef XP_MACOSX
if (!nsCocoaFeatures::OnLionOrLater()) {
aOutMessage = NS_LITERAL_CSTRING("Minimum MacOSX version (10.7) not met for Adobe EME");
return MediaKeySystemStatus::Cdm_not_supported;
}
#endif
return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
}
#endif
#ifdef MOZ_WIDEVINE_EME
if (aKeySystem.EqualsLiteral("com.widevine.alpha")) {
#ifdef XP_WIN
// Win Vista and later only.
if (!IsVistaOrLater()) {
aOutMessage = NS_LITERAL_CSTRING("Minimum Windows version (Vista) not met for Widevine EME");
return MediaKeySystemStatus::Cdm_not_supported;
}
#endif
#ifdef XP_MACOSX
if (!nsCocoaFeatures::OnLionOrLater()) {
aOutMessage = NS_LITERAL_CSTRING("Minimum MacOSX version (10.7) not met for Widevine EME");
return MediaKeySystemStatus::Cdm_not_supported;
}
#endif
if (!Preferences::GetBool("media.gmp-widevinecdm.enabled", false)) {
aOutMessage = NS_LITERAL_CSTRING("Widevine EME disabled");
return MediaKeySystemStatus::Cdm_disabled;
}
return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
}
#endif
return MediaKeySystemStatus::Cdm_not_supported;
}
示例13: if
static OperatingSystem
BlacklistOSToOperatingSystem(const nsAString& os)
{
if (os.EqualsLiteral("WINNT 5.1"))
return OperatingSystem::WindowsXP;
else if (os.EqualsLiteral("WINNT 5.2"))
return OperatingSystem::WindowsServer2003;
else if (os.EqualsLiteral("WINNT 6.0"))
return OperatingSystem::WindowsVista;
else if (os.EqualsLiteral("WINNT 6.1"))
return OperatingSystem::Windows7;
else if (os.EqualsLiteral("WINNT 6.2"))
return OperatingSystem::Windows8;
else if (os.EqualsLiteral("WINNT 6.3"))
return OperatingSystem::Windows8_1;
else if (os.EqualsLiteral("WINNT 10.0"))
return OperatingSystem::Windows10;
else if (os.EqualsLiteral("Linux"))
return OperatingSystem::Linux;
else if (os.EqualsLiteral("Darwin 9"))
return OperatingSystem::OSX10_5;
else if (os.EqualsLiteral("Darwin 10"))
return OperatingSystem::OSX10_6;
else if (os.EqualsLiteral("Darwin 11"))
return OperatingSystem::OSX10_7;
else if (os.EqualsLiteral("Darwin 12"))
return OperatingSystem::OSX10_8;
else if (os.EqualsLiteral("Darwin 13"))
return OperatingSystem::OSX10_9;
else if (os.EqualsLiteral("Darwin 14"))
return OperatingSystem::OSX10_10;
else if (os.EqualsLiteral("Darwin 15"))
return OperatingSystem::OSX10_11;
else if (os.EqualsLiteral("Darwin 16"))
return OperatingSystem::OSX10_12;
else if (os.EqualsLiteral("Android"))
return OperatingSystem::Android;
// For historical reasons, "All" in blocklist means "All Windows"
else if (os.EqualsLiteral("All"))
return OperatingSystem::Windows;
return OperatingSystem::Unknown;
}
示例14: fontname
nsresult
gfxFontconfigUtils::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName)
{
aFamilyName.Truncate();
// The fontconfig has generic family names in the font list.
if (aFontName.EqualsLiteral("serif") ||
aFontName.EqualsLiteral("sans-serif") ||
aFontName.EqualsLiteral("monospace")) {
aFamilyName.Assign(aFontName);
return NS_OK;
}
nsresult rv = UpdateFontListInternal();
if (NS_FAILED(rv))
return rv;
NS_ConvertUTF16toUTF8 fontname(aFontName);
// return empty string if no such family exists
if (!IsExistingFamily(fontname))
return NS_OK;
FcPattern *pat = NULL;
FcObjectSet *os = NULL;
FcFontSet *givenFS = NULL;
nsTArray<nsCString> candidates;
FcFontSet *candidateFS = NULL;
rv = NS_ERROR_FAILURE;
pat = FcPatternCreate();
if (!pat)
goto end;
FcPatternAddString(pat, FC_FAMILY, (FcChar8 *)fontname.get());
os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, NULL);
if (!os)
goto end;
givenFS = FcFontList(NULL, pat, os);
if (!givenFS)
goto end;
// The first value associated with a FC_FAMILY property is the family
// returned by GetFontList(), so use this value if appropriate.
// See if there is a font face with first family equal to the given family.
for (int i = 0; i < givenFS->nfont; ++i) {
char *firstFamily;
if (FcPatternGetString(givenFS->fonts[i], FC_FAMILY, 0,
(FcChar8 **) &firstFamily) != FcResultMatch)
continue;
nsDependentCString first(firstFamily);
if (!candidates.Contains(first)) {
candidates.AppendElement(first);
if (fontname.Equals(first)) {
aFamilyName.Assign(aFontName);
rv = NS_OK;
goto end;
}
}
}
// See if any of the first family names represent the same set of font
// faces as the given family.
for (PRUint32 j = 0; j < candidates.Length(); ++j) {
FcPatternDel(pat, FC_FAMILY);
FcPatternAddString(pat, FC_FAMILY, (FcChar8 *)candidates[j].get());
candidateFS = FcFontList(NULL, pat, os);
if (!candidateFS)
goto end;
if (candidateFS->nfont != givenFS->nfont)
continue;
bool equal = true;
for (int i = 0; i < givenFS->nfont; ++i) {
if (!FcPatternEqual(candidateFS->fonts[i], givenFS->fonts[i])) {
equal = false;
break;
}
}
if (equal) {
AppendUTF8toUTF16(candidates[j], aFamilyName);
rv = NS_OK;
goto end;
}
}
// No match found; return empty string.
rv = NS_OK;
end:
if (pat)
FcPatternDestroy(pat);
if (os)
//.........这里部分代码省略.........
示例15: ctxId
nsresult
HTMLCanvasElement::GetContextHelper(const nsAString& aContextId,
nsICanvasRenderingContextInternal **aContext)
{
NS_ENSURE_ARG(aContext);
if (aContextId.EqualsLiteral("2d")) {
Telemetry::Accumulate(Telemetry::CANVAS_2D_USED, 1);
nsRefPtr<CanvasRenderingContext2D> ctx =
new CanvasRenderingContext2D();
ctx->SetCanvasElement(this);
ctx.forget(aContext);
return NS_OK;
}
#ifdef MOZ_WEBGL
if (WebGL2Context::IsSupported() &&
aContextId.EqualsLiteral("experimental-webgl2"))
{
Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_USED, 1);
nsRefPtr<WebGL2Context> ctx = WebGL2Context::Create();
if (ctx == nullptr) {
return NS_ERROR_NOT_IMPLEMENTED;
}
ctx->SetCanvasElement(this);
ctx.forget(aContext);
return NS_OK;
}
#endif
NS_ConvertUTF16toUTF8 ctxId(aContextId);
// check that ctxId is clamped to A-Za-z0-9_-
for (uint32_t i = 0; i < ctxId.Length(); i++) {
if ((ctxId[i] < 'A' || ctxId[i] > 'Z') &&
(ctxId[i] < 'a' || ctxId[i] > 'z') &&
(ctxId[i] < '0' || ctxId[i] > '9') &&
(ctxId[i] != '-') &&
(ctxId[i] != '_'))
{
// XXX ERRMSG we need to report an error to developers here! (bug 329026)
return NS_OK;
}
}
nsCString ctxString("@mozilla.org/content/canvas-rendering-context;1?id=");
ctxString.Append(ctxId);
nsresult rv;
nsCOMPtr<nsICanvasRenderingContextInternal> ctx =
do_CreateInstance(ctxString.get(), &rv);
if (rv == NS_ERROR_OUT_OF_MEMORY) {
*aContext = nullptr;
return NS_ERROR_OUT_OF_MEMORY;
}
if (NS_FAILED(rv)) {
*aContext = nullptr;
// XXX ERRMSG we need to report an error to developers here! (bug 329026)
return NS_OK;
}
ctx->SetCanvasElement(this);
ctx.forget(aContext);
return NS_OK;
}