void nsStyleCoord::AppendToString(nsString& aBuffer) const { if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { aBuffer.AppendFloat(mValue.mFloat); } else if ((eStyleUnit_Coord == mUnit) || (eStyleUnit_Enumerated == mUnit) || (eStyleUnit_Integer == mUnit)) { aBuffer.AppendInt(mValue.mInt, 10); aBuffer.AppendLiteral("[0x"); aBuffer.AppendInt(mValue.mInt, 16); aBuffer.Append(PRUnichar(']')); } switch (mUnit) { case eStyleUnit_Null: aBuffer.AppendLiteral("Null"); break; case eStyleUnit_Coord: aBuffer.AppendLiteral("tw"); break; case eStyleUnit_Percent: aBuffer.AppendLiteral("%"); break; case eStyleUnit_Factor: aBuffer.AppendLiteral("f"); break; case eStyleUnit_Normal: aBuffer.AppendLiteral("Normal"); break; case eStyleUnit_Auto: aBuffer.AppendLiteral("Auto"); break; case eStyleUnit_None: aBuffer.AppendLiteral("None"); break; case eStyleUnit_Enumerated: aBuffer.AppendLiteral("enum"); break; case eStyleUnit_Integer: aBuffer.AppendLiteral("int"); break; case eStyleUnit_Chars: aBuffer.AppendLiteral("chars"); break; } aBuffer.Append(PRUnichar(' ')); }
void ProgressMeterAccessible<Max>::Value(nsString& aValue) { LeafAccessible::Value(aValue); if (!aValue.IsEmpty()) return; double maxValue = MaxValue(); if (IsNaN(maxValue) || maxValue == 0) return; double curValue = CurValue(); if (IsNaN(curValue)) return; // Treat the current value bigger than maximum as 100%. double percentValue = (curValue < maxValue) ? (curValue / maxValue) * 100 : 100; aValue.AppendFloat(percentValue); aValue.Append('%'); }
void nsCSSToken::AppendToString(nsString& aBuffer) { switch (mType) { case eCSSToken_AtKeyword: aBuffer.Append(PRUnichar('@')); // fall through intentional case eCSSToken_Ident: case eCSSToken_WhiteSpace: case eCSSToken_Function: case eCSSToken_HTMLComment: case eCSSToken_URange: aBuffer.Append(mIdent); if (mType == eCSSToken_Function) aBuffer.Append(PRUnichar('(')); break; case eCSSToken_URL: case eCSSToken_Bad_URL: aBuffer.AppendLiteral("url("); if (mSymbol != PRUnichar(0)) { aBuffer.Append(mSymbol); } aBuffer.Append(mIdent); if (mSymbol != PRUnichar(0)) { aBuffer.Append(mSymbol); } if (mType == eCSSToken_URL) { aBuffer.Append(PRUnichar(')')); } break; case eCSSToken_Number: if (mIntegerValid) { aBuffer.AppendInt(mInteger, 10); } else { aBuffer.AppendFloat(mNumber); } break; case eCSSToken_Percentage: NS_ASSERTION(!mIntegerValid, "How did a percentage token get this set?"); aBuffer.AppendFloat(mNumber * 100.0f); aBuffer.Append(PRUnichar('%')); break; case eCSSToken_Dimension: if (mIntegerValid) { aBuffer.AppendInt(mInteger, 10); } else { aBuffer.AppendFloat(mNumber); } aBuffer.Append(mIdent); break; case eCSSToken_String: aBuffer.Append(mSymbol); aBuffer.Append(mIdent); // fall through intentional case eCSSToken_Symbol: aBuffer.Append(mSymbol); break; case eCSSToken_ID: case eCSSToken_Ref: aBuffer.Append(PRUnichar('#')); aBuffer.Append(mIdent); break; case eCSSToken_Includes: aBuffer.AppendLiteral("~="); break; case eCSSToken_Dashmatch: aBuffer.AppendLiteral("|="); break; case eCSSToken_Beginsmatch: aBuffer.AppendLiteral("^="); break; case eCSSToken_Endsmatch: aBuffer.AppendLiteral("$="); break; case eCSSToken_Containsmatch: aBuffer.AppendLiteral("*="); break; case eCSSToken_Bad_String: aBuffer.Append(mSymbol); aBuffer.Append(mIdent); break; default: NS_ERROR("invalid token type"); break; } }
/** * Append the textual representation of |this| to |aBuffer|. */ void nsCSSToken::AppendToString(nsString& aBuffer) const { switch (mType) { case eCSSToken_Ident: nsStyleUtil::AppendEscapedCSSIdent(mIdent, aBuffer); break; case eCSSToken_AtKeyword: aBuffer.Append('@'); nsStyleUtil::AppendEscapedCSSIdent(mIdent, aBuffer); break; case eCSSToken_ID: case eCSSToken_Hash: aBuffer.Append('#'); nsStyleUtil::AppendEscapedCSSIdent(mIdent, aBuffer); break; case eCSSToken_Function: nsStyleUtil::AppendEscapedCSSIdent(mIdent, aBuffer); aBuffer.Append('('); break; case eCSSToken_URL: case eCSSToken_Bad_URL: aBuffer.AppendLiteral("url("); if (mSymbol != PRUnichar(0)) { nsStyleUtil::AppendEscapedCSSString(mIdent, aBuffer, mSymbol); } else { aBuffer.Append(mIdent); } if (mType == eCSSToken_URL) { aBuffer.Append(PRUnichar(')')); } break; case eCSSToken_Number: if (mIntegerValid) { aBuffer.AppendInt(mInteger, 10); } else { aBuffer.AppendFloat(mNumber); } break; case eCSSToken_Percentage: aBuffer.AppendFloat(mNumber * 100.0f); aBuffer.Append(PRUnichar('%')); break; case eCSSToken_Dimension: if (mIntegerValid) { aBuffer.AppendInt(mInteger, 10); } else { aBuffer.AppendFloat(mNumber); } nsStyleUtil::AppendEscapedCSSIdent(mIdent, aBuffer); break; case eCSSToken_Bad_String: nsStyleUtil::AppendEscapedCSSString(mIdent, aBuffer, mSymbol); // remove the trailing quote character aBuffer.Truncate(aBuffer.Length() - 1); break; case eCSSToken_String: nsStyleUtil::AppendEscapedCSSString(mIdent, aBuffer, mSymbol); break; case eCSSToken_Symbol: aBuffer.Append(mSymbol); break; case eCSSToken_Whitespace: aBuffer.Append(' '); break; case eCSSToken_HTMLComment: case eCSSToken_URange: aBuffer.Append(mIdent); break; case eCSSToken_Includes: aBuffer.AppendLiteral("~="); break; case eCSSToken_Dashmatch: aBuffer.AppendLiteral("|="); break; case eCSSToken_Beginsmatch: aBuffer.AppendLiteral("^="); break; case eCSSToken_Endsmatch: aBuffer.AppendLiteral("$="); break; case eCSSToken_Containsmatch: aBuffer.AppendLiteral("*="); break; default: NS_ERROR("invalid token type"); break; } }
void nsCSSToken::AppendToString(nsString& aBuffer) { switch (mType) { case eCSSToken_AtKeyword: aBuffer.Append(PRUnichar('@')); // fall through intentional case eCSSToken_Ident: case eCSSToken_WhiteSpace: case eCSSToken_Function: case eCSSToken_URL: case eCSSToken_InvalidURL: case eCSSToken_HTMLComment: aBuffer.Append(mIdent); break; case eCSSToken_Number: if (mIntegerValid) { aBuffer.AppendInt(mInteger, 10); } else { aBuffer.AppendFloat(mNumber); } break; case eCSSToken_Percentage: NS_ASSERTION(!mIntegerValid, "How did a percentage token get this set?"); aBuffer.AppendFloat(mNumber * 100.0f); aBuffer.Append(PRUnichar('%')); // STRING USE WARNING: technically, this should be |AppendWithConversion| break; case eCSSToken_Dimension: if (mIntegerValid) { aBuffer.AppendInt(mInteger, 10); } else { aBuffer.AppendFloat(mNumber); } aBuffer.Append(mIdent); break; case eCSSToken_String: aBuffer.Append(mSymbol); aBuffer.Append(mIdent); // fall through intentional case eCSSToken_Symbol: aBuffer.Append(mSymbol); break; case eCSSToken_ID: case eCSSToken_Ref: aBuffer.Append(PRUnichar('#')); aBuffer.Append(mIdent); break; case eCSSToken_Includes: aBuffer.AppendLiteral("~="); break; case eCSSToken_Dashmatch: aBuffer.AppendLiteral("|="); break; case eCSSToken_Error: aBuffer.Append(mSymbol); aBuffer.Append(mIdent); break; default: NS_ERROR("invalid token type"); break; } }