/* * This function maps attribute id and returns corresponding values */ static void ConvertAttributeString(BluetoothAvrcpMediaAttribute aAttrId, nsAString& aAttrStr) { BluetoothA2dpManager* a2dp = BluetoothA2dpManager::Get(); NS_ENSURE_TRUE_VOID(a2dp); switch (aAttrId) { case AVRCP_MEDIA_ATTRIBUTE_TITLE: a2dp->GetTitle(aAttrStr); break; case AVRCP_MEDIA_ATTRIBUTE_ARTIST: a2dp->GetArtist(aAttrStr); break; case AVRCP_MEDIA_ATTRIBUTE_ALBUM: a2dp->GetAlbum(aAttrStr); break; case AVRCP_MEDIA_ATTRIBUTE_TRACK_NUM: aAttrStr.AppendInt(a2dp->GetMediaNumber()); break; case AVRCP_MEDIA_ATTRIBUTE_NUM_TRACKS: aAttrStr.AppendInt(a2dp->GetTotalMediaNumber()); break; case AVRCP_MEDIA_ATTRIBUTE_GENRE: // TODO: we currently don't support genre from music player aAttrStr.Truncate(); break; case AVRCP_MEDIA_ATTRIBUTE_PLAYING_TIME: aAttrStr.AppendInt(a2dp->GetDuration()); break; } }
void nsSVGIntegerPair::GetBaseValueString(nsAString &aValueAsString) const { aValueAsString.Truncate(); aValueAsString.AppendInt(mBaseVal[0]); if (mBaseVal[0] != mBaseVal[1]) { aValueAsString.AppendLiteral(", "); aValueAsString.AppendInt(mBaseVal[1]); } }
nsresult GonkCameraParameters::MapIsoFromGonk(const char* aIso, nsAString& aIsoOut) { if (!aIso) { return NS_ERROR_NOT_AVAILABLE; } if (strcmp(aIso, "ISO_HJR") == 0) { aIsoOut.AssignASCII("hjr"); } else if (strcmp(aIso, "auto") == 0) { aIsoOut.AssignASCII("auto"); } else { unsigned int iso; char ignored; // Some camera libraries return ISO modes as "ISO100", others as "100". if (sscanf(aIso, "ISO%u%c", &iso, &ignored) != 1 && sscanf(aIso, "%u%c", &iso, &ignored) != 1) { return NS_ERROR_INVALID_ARG; } aIsoOut.Truncate(0); aIsoOut.AppendInt(iso); } return NS_OK; }
/* * This function maps attribute id and returns corresponding values */ static void ConvertAttributeString(BluetoothAvrcpMediaAttribute aAttrId, nsAString& aAttrStr) { BluetoothAvrcpManager* avrcp = BluetoothAvrcpManager::Get(); NS_ENSURE_TRUE_VOID(avrcp); switch (aAttrId) { case AVRCP_MEDIA_ATTRIBUTE_TITLE: avrcp->GetTitle(aAttrStr); /* * bluedroid can only send string length AVRC_MAX_ATTR_STR_LEN - 1 */ if (aAttrStr.Length() >= AVRC_MAX_ATTR_STR_LEN) { aAttrStr.Truncate(AVRC_MAX_ATTR_STR_LEN - 1); BT_WARNING("Truncate media item attribute title, length is over 255"); } break; case AVRCP_MEDIA_ATTRIBUTE_ARTIST: avrcp->GetArtist(aAttrStr); if (aAttrStr.Length() >= AVRC_MAX_ATTR_STR_LEN) { aAttrStr.Truncate(AVRC_MAX_ATTR_STR_LEN - 1); BT_WARNING("Truncate media item attribute artist, length is over 255"); } break; case AVRCP_MEDIA_ATTRIBUTE_ALBUM: avrcp->GetAlbum(aAttrStr); if (aAttrStr.Length() >= AVRC_MAX_ATTR_STR_LEN) { aAttrStr.Truncate(AVRC_MAX_ATTR_STR_LEN - 1); BT_WARNING("Truncate media item attribute album, length is over 255"); } break; case AVRCP_MEDIA_ATTRIBUTE_TRACK_NUM: aAttrStr.AppendInt(avrcp->GetMediaNumber()); break; case AVRCP_MEDIA_ATTRIBUTE_NUM_TRACKS: aAttrStr.AppendInt(avrcp->GetTotalMediaNumber()); break; case AVRCP_MEDIA_ATTRIBUTE_GENRE: // TODO: we currently don't support genre from music player aAttrStr.Truncate(); break; case AVRCP_MEDIA_ATTRIBUTE_PLAYING_TIME: aAttrStr.AppendInt(avrcp->GetDuration()); break; } }
void GeneratePathFromGattId(const BluetoothGattId& aId, nsAString& aPath, nsAString& aUuidStr) { ReversedUuidToString(aId.mUuid, aUuidStr); aPath.Assign(aUuidStr); aPath.AppendLiteral("_"); aPath.AppendInt(aId.mInstanceId); }
void GeneratePathFromGattId(const BluetoothGattId& aId, nsAString& aPath) { nsString uuidStr; UuidToString(aId.mUuid, uuidStr); aPath.Assign(uuidStr); aPath.AppendLiteral("_"); aPath.AppendInt(aId.mInstanceId); }
NS_IMETHODIMP sbStatusPropertyInfo::GetCellValue(const nsAString& aValue, nsAString& retval) { sbStatusPropertyValue value(aValue); retval.Truncate(); if (value.GetMode() == sbStatusPropertyValue::eRipping) { retval.AppendInt(value.GetCurrent()); } return NS_OK; }
static void EnsureNonEmptyIdentifier(nsAString& aIdentifier) { if (!aIdentifier.IsEmpty()) { return; } // If the identifier is empty, set it to the number of whole seconds since the // epoch. This identifier will appear in the files that this process // generates and also the files generated by this process's children, allowing // us to identify which files are from the same memory report request. aIdentifier.AppendInt(static_cast<int64_t>(PR_Now()) / 1000000); }
NS_IMETHODIMP sbSQLBuilderCriterionIn::ToString(nsAString& _retval) { AppendTableColumnTo(_retval); _retval.AppendLiteral(" in ("); PRUint32 len = mInItems.Length(); for (PRUint32 i = 0; i < len; i++) { const sbInItem& ii = mInItems[i]; switch(ii.type) { case eIsNull: /* not implemented */ break; case eString: { nsAutoString escapedValue(ii.stringValue); SB_EscapeSQL(escapedValue); _retval.AppendLiteral("'"); _retval.Append(escapedValue); _retval.AppendLiteral("'"); break; } case eInteger32: _retval.AppendInt(ii.int32Value); break; case eSubquery: { nsresult rv; nsAutoString sql; rv = ii.subquery->ToString(sql); NS_ENSURE_SUCCESS(rv, rv); _retval.Append(sql); break; } } if (i + 1 < len) { _retval.AppendLiteral(", "); } } _retval.AppendLiteral(")"); return NS_OK; }
nsresult GonkCameraParameters::MapIsoFromGonk(const char* aIso, nsAString& aIsoOut) { if (strcmp(aIso, "ISO_HJR") == 0) { aIsoOut.AssignASCII("hjr"); } else if (strcmp(aIso, "auto") == 0) { aIsoOut.AssignASCII("auto"); } else { unsigned int iso; if (sscanf(aIso, "ISO%u", &iso) != 1) { return NS_ERROR_INVALID_ARG; } aIsoOut.AppendInt(iso); } return NS_OK; }
static bool AppendStandardNamespacePrefixToString(nsAString& aString, int32_t aNameSpace) { if (aNameSpace == kNameSpaceID_Unknown) { // Wildcard namespace; no prefix to write. return false; } switch (aNameSpace) { case kNameSpaceID_None: break; case kNameSpaceID_XML: aString.AppendLiteral("xml"); break; case kNameSpaceID_XHTML: aString.AppendLiteral("html"); break; case kNameSpaceID_XLink: aString.AppendLiteral("xlink"); break; case kNameSpaceID_XSLT: aString.AppendLiteral("xsl"); break; case kNameSpaceID_XBL: aString.AppendLiteral("xbl"); break; case kNameSpaceID_MathML: aString.AppendLiteral("math"); break; case kNameSpaceID_RDF: aString.AppendLiteral("rdf"); break; case kNameSpaceID_XUL: aString.AppendLiteral("xul"); break; case kNameSpaceID_SVG: aString.AppendLiteral("svg"); break; default: aString.AppendLiteral("ns"); aString.AppendInt(aNameSpace); break; } return true; }
nsresult HTMLCanvasElement::ParseParams(JSContext* aCx, const nsAString& aType, const JS::Value& aEncoderOptions, nsAString& aParams, bool* usingCustomParseOptions) { // Quality parameter is only valid for the image/jpeg MIME type if (aType.EqualsLiteral("image/jpeg")) { if (aEncoderOptions.isNumber()) { double quality = aEncoderOptions.toNumber(); // Quality must be between 0.0 and 1.0, inclusive if (quality >= 0.0 && quality <= 1.0) { aParams.AppendLiteral("quality="); aParams.AppendInt(NS_lround(quality * 100.0)); } } } // If we haven't parsed the aParams check for proprietary options. // The proprietary option -moz-parse-options will take a image lib encoder // parse options string as is and pass it to the encoder. *usingCustomParseOptions = false; if (aParams.Length() == 0 && aEncoderOptions.isString()) { NS_NAMED_LITERAL_STRING(mozParseOptions, "-moz-parse-options:"); nsAutoJSString paramString; if (!paramString.init(aCx, aEncoderOptions.toString())) { return NS_ERROR_FAILURE; } if (StringBeginsWith(paramString, mozParseOptions)) { nsDependentSubstring parseOptions = Substring(paramString, mozParseOptions.Length(), paramString.Length() - mozParseOptions.Length()); aParams.Append(parseOptions); *usingCustomParseOptions = true; } } return NS_OK; }
NS_IMETHODIMP sbDownloadButtonPropertyInfo::GetCellValue(const nsAString& aValue, nsAString& _retval) { sbDownloadButtonPropertyValue value(aValue); switch(value.GetMode()) { case sbDownloadButtonPropertyValue::eDownloading: case sbDownloadButtonPropertyValue::ePaused: if (value.GetTotal() > 0) { PRFloat64 progress = ((PRFloat64) value.GetCurrent() / (PRFloat64) value.GetTotal()) * 100; _retval.AppendInt((PRUint32) progress); } break; default: _retval.Truncate(); } return NS_OK; }
/* readonly attribute DOMString DisplayRAM; */ NS_IMETHODIMP nsSystemInfo::GetDisplayRAM(nsAString & aDisplayRAM) { aDisplayRAM.AppendInt(vram); return NS_OK; }
void nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult) const { // eCSSProperty_UNKNOWN gets used for some recursive calls below. NS_ABORT_IF_FALSE((0 <= aProperty && aProperty <= eCSSProperty_COUNT_no_shorthands) || aProperty == eCSSProperty_UNKNOWN, "property ID out of range"); nsCSSUnit unit = GetUnit(); if (unit == eCSSUnit_Null) { return; } if (eCSSUnit_String <= unit && unit <= eCSSUnit_Attr) { if (unit == eCSSUnit_Attr) { aResult.AppendLiteral("attr("); } nsAutoString buffer; GetStringValue(buffer); if (unit == eCSSUnit_String) { nsStyleUtil::AppendEscapedCSSString(buffer, aResult); } else if (unit == eCSSUnit_Families) { // XXX We really need to do *some* escaping. aResult.Append(buffer); } else { nsStyleUtil::AppendEscapedCSSIdent(buffer, aResult); } } else if (eCSSUnit_Array <= unit && unit <= eCSSUnit_Steps) { switch (unit) { case eCSSUnit_Counter: aResult.AppendLiteral("counter("); break; case eCSSUnit_Counters: aResult.AppendLiteral("counters("); break; case eCSSUnit_Cubic_Bezier: aResult.AppendLiteral("cubic-bezier("); break; case eCSSUnit_Steps: aResult.AppendLiteral("steps("); break; default: break; } nsCSSValue::Array *array = GetArrayValue(); bool mark = false; for (size_t i = 0, i_end = array->Count(); i < i_end; ++i) { if (mark && array->Item(i).GetUnit() != eCSSUnit_Null) { if (unit == eCSSUnit_Array && eCSSProperty_transition_timing_function != aProperty) aResult.AppendLiteral(" "); else aResult.AppendLiteral(", "); } if (unit == eCSSUnit_Steps && i == 1) { NS_ABORT_IF_FALSE(array->Item(i).GetUnit() == eCSSUnit_Enumerated && (array->Item(i).GetIntValue() == NS_STYLE_TRANSITION_TIMING_FUNCTION_STEP_START || array->Item(i).GetIntValue() == NS_STYLE_TRANSITION_TIMING_FUNCTION_STEP_END), "unexpected value"); if (array->Item(i).GetIntValue() == NS_STYLE_TRANSITION_TIMING_FUNCTION_STEP_START) { aResult.AppendLiteral("start"); } else { aResult.AppendLiteral("end"); } continue; } nsCSSProperty prop = ((eCSSUnit_Counter <= unit && unit <= eCSSUnit_Counters) && i == array->Count() - 1) ? eCSSProperty_list_style_type : aProperty; if (array->Item(i).GetUnit() != eCSSUnit_Null) { array->Item(i).AppendToString(prop, aResult); mark = true; } } if (eCSSUnit_Array == unit && aProperty == eCSSProperty_transition_timing_function) { aResult.AppendLiteral(")"); } } /* Although Function is backed by an Array, we'll handle it separately * because it's a bit quirky. */ else if (eCSSUnit_Function == unit) { const nsCSSValue::Array* array = GetArrayValue(); NS_ABORT_IF_FALSE(array->Count() >= 1, "Functions must have at least one element for the name."); /* Append the function name. */ const nsCSSValue& functionName = array->Item(0); if (functionName.GetUnit() == eCSSUnit_Enumerated) { // We assume that the first argument is always of nsCSSKeyword type. const nsCSSKeyword functionId = static_cast<nsCSSKeyword>(functionName.GetIntValue()); nsStyleUtil::AppendEscapedCSSIdent( NS_ConvertASCIItoUTF16(nsCSSKeywords::GetStringValue(functionId)), aResult); } else { functionName.AppendToString(aProperty, aResult); } aResult.AppendLiteral("("); /* Now, step through the function contents, writing each of them as we go. */ for (size_t index = 1; index < array->Count(); ++index) { array->Item(index).AppendToString(aProperty, aResult); /* If we're not at the final element, append a comma. */ if (index + 1 != array->Count()) aResult.AppendLiteral(", "); } /* Finally, append the closing parenthesis. */ aResult.AppendLiteral(")"); } else if (IsCalcUnit()) { NS_ABORT_IF_FALSE(GetUnit() == eCSSUnit_Calc, "unexpected unit"); CSSValueSerializeCalcOps ops(aProperty, aResult); css::SerializeCalc(*this, ops); } else if (eCSSUnit_Integer == unit) { aResult.AppendInt(GetIntValue(), 10); } else if (eCSSUnit_Enumerated == unit) { if (eCSSProperty_text_decoration_line == aProperty) { PRInt32 intValue = GetIntValue(); if (NS_STYLE_TEXT_DECORATION_LINE_NONE == intValue) { AppendASCIItoUTF16(nsCSSProps::LookupPropertyValue(aProperty, intValue), aResult); } else { // Ignore the "override all" internal value. // (It doesn't have a string representation.) intValue &= ~NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL; nsStyleUtil::AppendBitmaskCSSValue( aProperty, intValue, NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE, NS_STYLE_TEXT_DECORATION_LINE_PREF_ANCHORS, aResult); } } else if (eCSSProperty_marks == aProperty) { PRInt32 intValue = GetIntValue(); if (intValue == NS_STYLE_PAGE_MARKS_NONE) { AppendASCIItoUTF16(nsCSSProps::LookupPropertyValue(aProperty, intValue), aResult); } else { nsStyleUtil::AppendBitmaskCSSValue(aProperty, intValue, NS_STYLE_PAGE_MARKS_CROP, NS_STYLE_PAGE_MARKS_REGISTER, aResult); } } else if (eCSSProperty_unicode_bidi == aProperty) { PR_STATIC_ASSERT(NS_STYLE_UNICODE_BIDI_NORMAL == 0); PRInt32 intValue = GetIntValue(); if (NS_STYLE_UNICODE_BIDI_NORMAL == intValue) { AppendASCIItoUTF16(nsCSSProps::LookupPropertyValue(aProperty, intValue), aResult); } else { nsStyleUtil::AppendBitmaskCSSValue( aProperty, intValue, NS_STYLE_UNICODE_BIDI_EMBED, NS_STYLE_UNICODE_BIDI_PLAINTEXT, aResult); } } else { const nsAFlatCString& name = nsCSSProps::LookupPropertyValue(aProperty, GetIntValue()); AppendASCIItoUTF16(name, aResult); } } else if (eCSSUnit_EnumColor == unit) { // we can lookup the property in the ColorTable and then // get a string mapping the name nsCAutoString str; if (nsCSSProps::GetColorName(GetIntValue(), str)){ AppendASCIItoUTF16(str, aResult); } else { NS_ABORT_IF_FALSE(false, "bad color value"); } } else if (eCSSUnit_Color == unit) { nscolor color = GetColorValue(); if (color == NS_RGBA(0, 0, 0, 0)) { // Use the strictest match for 'transparent' so we do correct // round-tripping of all other rgba() values. aResult.AppendLiteral("transparent"); } else { PRUint8 a = NS_GET_A(color); if (a < 255) { aResult.AppendLiteral("rgba("); } else { aResult.AppendLiteral("rgb("); } NS_NAMED_LITERAL_STRING(comma, ", "); aResult.AppendInt(NS_GET_R(color), 10); aResult.Append(comma); aResult.AppendInt(NS_GET_G(color), 10); aResult.Append(comma); aResult.AppendInt(NS_GET_B(color), 10); if (a < 255) { aResult.Append(comma); aResult.AppendFloat(nsStyleUtil::ColorComponentToFloat(a)); } aResult.Append(PRUnichar(')')); } } else if (eCSSUnit_URL == unit || eCSSUnit_Image == unit) { aResult.Append(NS_LITERAL_STRING("url(")); nsStyleUtil::AppendEscapedCSSString( nsDependentString(GetOriginalURLValue()), aResult); aResult.Append(NS_LITERAL_STRING(")")); } else if (eCSSUnit_Element == unit) { aResult.Append(NS_LITERAL_STRING("-moz-element(#")); nsAutoString tmpStr; GetStringValue(tmpStr); nsStyleUtil::AppendEscapedCSSIdent(tmpStr, aResult); aResult.Append(NS_LITERAL_STRING(")")); } else if (eCSSUnit_Percent == unit) { aResult.AppendFloat(GetPercentValue() * 100.0f); } else if (eCSSUnit_Percent < unit) { // length unit aResult.AppendFloat(GetFloatValue()); } else if (eCSSUnit_Gradient == unit) { nsCSSValueGradient* gradient = GetGradientValue(); if (gradient->mIsRepeating) { if (gradient->mIsRadial) aResult.AppendLiteral("-moz-repeating-radial-gradient("); else aResult.AppendLiteral("-moz-repeating-linear-gradient("); } else { if (gradient->mIsRadial) aResult.AppendLiteral("-moz-radial-gradient("); else aResult.AppendLiteral("-moz-linear-gradient("); } if (gradient->mIsToCorner) { aResult.AppendLiteral("to"); NS_ABORT_IF_FALSE(gradient->mBgPos.mXValue.GetUnit() == eCSSUnit_Enumerated && gradient->mBgPos.mYValue.GetUnit() == eCSSUnit_Enumerated, "unexpected unit"); if (!(gradient->mBgPos.mXValue.GetIntValue() & NS_STYLE_BG_POSITION_CENTER)) { aResult.AppendLiteral(" "); gradient->mBgPos.mXValue.AppendToString(eCSSProperty_background_position, aResult); } if (!(gradient->mBgPos.mYValue.GetIntValue() & NS_STYLE_BG_POSITION_CENTER)) { aResult.AppendLiteral(" "); gradient->mBgPos.mYValue.AppendToString(eCSSProperty_background_position, aResult); } aResult.AppendLiteral(", "); } else if (gradient->mBgPos.mXValue.GetUnit() != eCSSUnit_None || gradient->mBgPos.mYValue.GetUnit() != eCSSUnit_None || gradient->mAngle.GetUnit() != eCSSUnit_None) { if (gradient->mBgPos.mXValue.GetUnit() != eCSSUnit_None) { gradient->mBgPos.mXValue.AppendToString(eCSSProperty_background_position, aResult); aResult.AppendLiteral(" "); } if (gradient->mBgPos.mXValue.GetUnit() != eCSSUnit_None) { gradient->mBgPos.mYValue.AppendToString(eCSSProperty_background_position, aResult); aResult.AppendLiteral(" "); } if (gradient->mAngle.GetUnit() != eCSSUnit_None) { gradient->mAngle.AppendToString(aProperty, aResult); } aResult.AppendLiteral(", "); } if (gradient->mIsRadial && (gradient->mRadialShape.GetUnit() != eCSSUnit_None || gradient->mRadialSize.GetUnit() != eCSSUnit_None)) { if (gradient->mRadialShape.GetUnit() != eCSSUnit_None) { NS_ABORT_IF_FALSE(gradient->mRadialShape.GetUnit() == eCSSUnit_Enumerated, "bad unit for radial gradient shape"); PRInt32 intValue = gradient->mRadialShape.GetIntValue(); NS_ABORT_IF_FALSE(intValue != NS_STYLE_GRADIENT_SHAPE_LINEAR, "radial gradient with linear shape?!"); AppendASCIItoUTF16(nsCSSProps::ValueToKeyword(intValue, nsCSSProps::kRadialGradientShapeKTable), aResult); aResult.AppendLiteral(" "); } if (gradient->mRadialSize.GetUnit() != eCSSUnit_None) { NS_ABORT_IF_FALSE(gradient->mRadialSize.GetUnit() == eCSSUnit_Enumerated, "bad unit for radial gradient size"); PRInt32 intValue = gradient->mRadialSize.GetIntValue(); AppendASCIItoUTF16(nsCSSProps::ValueToKeyword(intValue, nsCSSProps::kRadialGradientSizeKTable), aResult); } aResult.AppendLiteral(", "); } for (PRUint32 i = 0 ;;) { gradient->mStops[i].mColor.AppendToString(aProperty, aResult); if (gradient->mStops[i].mLocation.GetUnit() != eCSSUnit_None) { aResult.AppendLiteral(" "); gradient->mStops[i].mLocation.AppendToString(aProperty, aResult); } if (++i == gradient->mStops.Length()) { break; } aResult.AppendLiteral(", "); } aResult.AppendLiteral(")"); } else if (eCSSUnit_Pair == unit) { GetPairValue().AppendToString(aProperty, aResult); } else if (eCSSUnit_Triplet == unit) { GetTripletValue().AppendToString(aProperty, aResult); } else if (eCSSUnit_Rect == unit) { GetRectValue().AppendToString(aProperty, aResult); } else if (eCSSUnit_List == unit || eCSSUnit_ListDep == unit) { GetListValue()->AppendToString(aProperty, aResult); } else if (eCSSUnit_PairList == unit || eCSSUnit_PairListDep == unit) { GetPairListValue()->AppendToString(aProperty, aResult); } switch (unit) { case eCSSUnit_Null: break; case eCSSUnit_Auto: aResult.AppendLiteral("auto"); break; case eCSSUnit_Inherit: aResult.AppendLiteral("inherit"); break; case eCSSUnit_Initial: aResult.AppendLiteral("-moz-initial"); break; case eCSSUnit_None: aResult.AppendLiteral("none"); break; case eCSSUnit_Normal: aResult.AppendLiteral("normal"); break; case eCSSUnit_System_Font: aResult.AppendLiteral("-moz-use-system-font"); break; case eCSSUnit_All: aResult.AppendLiteral("all"); break; case eCSSUnit_Dummy: case eCSSUnit_DummyInherit: NS_ABORT_IF_FALSE(false, "should never serialize"); break; case eCSSUnit_String: break; case eCSSUnit_Ident: break; case eCSSUnit_Families: break; case eCSSUnit_URL: break; case eCSSUnit_Image: break; case eCSSUnit_Element: break; case eCSSUnit_Array: break; case eCSSUnit_Attr: case eCSSUnit_Cubic_Bezier: case eCSSUnit_Steps: case eCSSUnit_Counter: case eCSSUnit_Counters: aResult.Append(PRUnichar(')')); break; case eCSSUnit_Local_Font: break; case eCSSUnit_Font_Format: break; case eCSSUnit_Function: break; case eCSSUnit_Calc: break; case eCSSUnit_Calc_Plus: break; case eCSSUnit_Calc_Minus: break; case eCSSUnit_Calc_Times_L: break; case eCSSUnit_Calc_Times_R: break; case eCSSUnit_Calc_Divided: break; case eCSSUnit_Integer: break; case eCSSUnit_Enumerated: break; case eCSSUnit_EnumColor: break; case eCSSUnit_Color: break; case eCSSUnit_Percent: aResult.Append(PRUnichar('%')); break; case eCSSUnit_Number: break; case eCSSUnit_Gradient: break; case eCSSUnit_Pair: break; case eCSSUnit_Triplet: break; case eCSSUnit_Rect: break; case eCSSUnit_List: break; case eCSSUnit_ListDep: break; case eCSSUnit_PairList: break; case eCSSUnit_PairListDep: break; case eCSSUnit_Inch: aResult.AppendLiteral("in"); break; case eCSSUnit_Millimeter: aResult.AppendLiteral("mm"); break; case eCSSUnit_PhysicalMillimeter: aResult.AppendLiteral("mozmm"); break; case eCSSUnit_Centimeter: aResult.AppendLiteral("cm"); break; case eCSSUnit_Point: aResult.AppendLiteral("pt"); break; case eCSSUnit_Pica: aResult.AppendLiteral("pc"); break; case eCSSUnit_EM: aResult.AppendLiteral("em"); break; case eCSSUnit_XHeight: aResult.AppendLiteral("ex"); break; case eCSSUnit_Char: aResult.AppendLiteral("ch"); break; case eCSSUnit_RootEM: aResult.AppendLiteral("rem"); break; case eCSSUnit_Pixel: aResult.AppendLiteral("px"); break; case eCSSUnit_Degree: aResult.AppendLiteral("deg"); break; case eCSSUnit_Grad: aResult.AppendLiteral("grad"); break; case eCSSUnit_Radian: aResult.AppendLiteral("rad"); break; case eCSSUnit_Hertz: aResult.AppendLiteral("Hz"); break; case eCSSUnit_Kilohertz: aResult.AppendLiteral("kHz"); break; case eCSSUnit_Seconds: aResult.Append(PRUnichar('s')); break; case eCSSUnit_Milliseconds: aResult.AppendLiteral("ms"); break; } }
void nsSVGInteger::GetBaseValueString(nsAString & aValueAsString) { aValueAsString.Truncate(); aValueAsString.AppendInt(mBaseVal); }
/* readonly attribute DOMString DisplayHeight; */ NS_IMETHODIMP nsSystemInfo::GetDisplayHeight(nsAString & aDisplayHeight) { aDisplayHeight.AppendInt(mHeight); return NS_OK; }
static nsresult GetKeyValue(const WCHAR* keyLocation, const WCHAR* keyName, nsAString& destString, int type) { HKEY key; DWORD dwcbData; DWORD dValue; DWORD resultType; LONG result; nsresult retval = NS_OK; result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyLocation, 0, KEY_QUERY_VALUE, &key); if (result != ERROR_SUCCESS) { return NS_ERROR_FAILURE; } switch (type) { case REG_DWORD: { // We only use this for vram size dwcbData = sizeof(dValue); result = RegQueryValueExW(key, keyName, NULL, &resultType, (LPBYTE)&dValue, &dwcbData); if (result == ERROR_SUCCESS && resultType == REG_DWORD) { dValue = dValue / 1024 / 1024; destString.AppendInt(PRInt32(dValue)); } else { retval = NS_ERROR_FAILURE; } break; } case REG_MULTI_SZ: { // A chain of null-separated strings; we convert the nulls to spaces WCHAR wCharValue[1024]; dwcbData = sizeof(wCharValue); result = RegQueryValueExW(key, keyName, NULL, &resultType, (LPBYTE)wCharValue, &dwcbData); if (result == ERROR_SUCCESS && resultType == REG_MULTI_SZ) { // This bit here could probably be cleaner. bool isValid = false; DWORD strLen = dwcbData/sizeof(wCharValue[0]); for (DWORD i = 0; i < strLen; i++) { if (wCharValue[i] == '\0') { if (i < strLen - 1 && wCharValue[i + 1] == '\0') { isValid = true; break; } else { wCharValue[i] = ' '; } } } // ensure wCharValue is null terminated wCharValue[strLen-1] = '\0'; if (isValid) destString = wCharValue; } else { retval = NS_ERROR_FAILURE; } break; } } RegCloseKey(key); return retval; }
/* readonly attribute DOMString DisplayWidth; */ NS_IMETHODIMP nsSystemInfo::GetDisplayWidth(nsAString & aDisplayWidth) { aDisplayWidth.AppendInt(mPixelWidth); return NS_OK; }
/* readonly attribute DOMString DisplayColorDepth; */ NS_IMETHODIMP nsSystemInfo::GetDisplayColorDepth(nsAString & aDisplayColorDepth) { aDisplayColorDepth.AppendInt(mDepth); return NS_OK; }
NS_IMETHODIMP nsMsgGroupView::CellTextForColumn(int32_t aRow, const char16_t *aColumnName, nsAString &aValue) { if (!IsValidIndex(aRow)) return NS_MSG_INVALID_DBVIEW_INDEX; if (m_flags[aRow] & MSG_VIEW_FLAG_DUMMY && aColumnName[0] != 'u') { nsCOMPtr <nsIMsgDBHdr> msgHdr; nsresult rv = GetMsgHdrForViewIndex(aRow, getter_AddRefs(msgHdr)); NS_ENSURE_SUCCESS(rv, rv); nsString hashKey; rv = HashHdr(msgHdr, hashKey); if (NS_FAILED(rv)) return NS_OK; nsCOMPtr<nsIMsgThread> msgThread; m_groupsTable.Get(hashKey, getter_AddRefs(msgThread)); nsMsgGroupThread * groupThread = static_cast<nsMsgGroupThread *>(msgThread.get()); if (aColumnName[0] == 's' && aColumnName[1] == 'u' ) { uint32_t flags; bool rcvDate = false; msgHdr->GetFlags(&flags); aValue.Truncate(); nsString tmp_str; switch (m_sortType) { case nsMsgViewSortType::byReceived: rcvDate = true; case nsMsgViewSortType::byDate: { uint32_t ageBucket = 0; GetAgeBucketValue(msgHdr, &ageBucket, rcvDate); switch (ageBucket) { case 1: if (m_kTodayString.IsEmpty()) m_kTodayString.Adopt(GetString(u"today")); aValue.Assign(m_kTodayString); break; case 2: if (m_kYesterdayString.IsEmpty()) m_kYesterdayString.Adopt(GetString(u"yesterday")); aValue.Assign(m_kYesterdayString); break; case 3: if (m_kLastWeekString.IsEmpty()) m_kLastWeekString.Adopt(GetString(u"lastWeek")); aValue.Assign(m_kLastWeekString); break; case 4: if (m_kTwoWeeksAgoString.IsEmpty()) m_kTwoWeeksAgoString.Adopt(GetString(u"twoWeeksAgo")); aValue.Assign(m_kTwoWeeksAgoString); break; case 5: if (m_kOldMailString.IsEmpty()) m_kOldMailString.Adopt(GetString(u"older")); aValue.Assign(m_kOldMailString); break; default: // Future date, error/spoofed. if (m_kFutureDateString.IsEmpty()) m_kFutureDateString.Adopt(GetString(u"futureDate")); aValue.Assign(m_kFutureDateString); break; } break; } case nsMsgViewSortType::bySubject: FetchSubject(msgHdr, m_flags[aRow], aValue); break; case nsMsgViewSortType::byAuthor: FetchAuthor(msgHdr, aValue); break; case nsMsgViewSortType::byStatus: rv = FetchStatus(m_flags[aRow], aValue); if (aValue.IsEmpty()) { tmp_str.Adopt(GetString(u"messagesWithNoStatus")); aValue.Assign(tmp_str); } break; case nsMsgViewSortType::byTags: rv = FetchTags(msgHdr, aValue); if (aValue.IsEmpty()) { tmp_str.Adopt(GetString(u"untaggedMessages")); aValue.Assign(tmp_str); } break; case nsMsgViewSortType::byPriority: FetchPriority(msgHdr, aValue); if (aValue.IsEmpty()) { tmp_str.Adopt(GetString(u"noPriority")); aValue.Assign(tmp_str); } break; case nsMsgViewSortType::byAccount: FetchAccount(msgHdr, aValue); break; case nsMsgViewSortType::byRecipient: FetchRecipients(msgHdr, aValue); break; case nsMsgViewSortType::byAttachments: tmp_str.Adopt(GetString(flags & nsMsgMessageFlags::Attachment ? u"attachments" : u"noAttachments")); aValue.Assign(tmp_str); break; case nsMsgViewSortType::byFlagged: tmp_str.Adopt(GetString(flags & nsMsgMessageFlags::Marked ? u"groupFlagged" : u"notFlagged")); aValue.Assign(tmp_str); break; // byLocation is a special case; we don't want to have duplicate // all this logic in nsMsgSearchDBView, and its hash key is what we // want anyways, so just copy it across. case nsMsgViewSortType::byLocation: case nsMsgViewSortType::byCorrespondent: aValue = hashKey; break; case nsMsgViewSortType::byCustom: { nsIMsgCustomColumnHandler* colHandler = GetCurColumnHandler(); if (colHandler) { bool isString; colHandler->IsString(&isString); if (isString) rv = colHandler->GetSortStringForRow(msgHdr.get(), aValue); else { uint32_t intKey; rv = colHandler->GetSortLongForRow(msgHdr.get(), &intKey); aValue.AppendInt(intKey); } } if (aValue.IsEmpty()) aValue.AssignLiteral("*"); break; } default: NS_ASSERTION(false, "we don't sort by group for this type"); break; } if (groupThread) { // Get number of messages in group nsAutoString formattedCountMsg; uint32_t numMsg = groupThread->NumRealChildren(); formattedCountMsg.AppendInt(numMsg); // Get number of unread messages nsAutoString formattedCountUnrMsg; uint32_t numUnrMsg = 0; groupThread->GetNumUnreadChildren(&numUnrMsg); formattedCountUnrMsg.AppendInt(numUnrMsg); // Add text to header aValue.Append(NS_LITERAL_STRING(" (")); if (numUnrMsg) { aValue.Append(formattedCountUnrMsg); aValue.Append(NS_LITERAL_STRING("/")); } aValue.Append(formattedCountMsg); aValue.Append(NS_LITERAL_STRING(")")); } } else if (aColumnName[0] == 't' && aColumnName[1] == 'o') { nsAutoString formattedCountString; uint32_t numChildren = (groupThread) ? groupThread->NumRealChildren() : 0; formattedCountString.AppendInt(numChildren); aValue.Assign(formattedCountString); } return NS_OK; } return nsMsgDBView::CellTextForColumn(aRow, aColumnName, aValue); }