void MapPainterSVG::DrawPath(const Projection& projection, const MapParameter& parameter, const Color& color, double width, const std::vector<double>& dash, LineStyle::CapStyle startCap, LineStyle::CapStyle endCap, size_t transStart, size_t transEnd) { stream << " <polyline"; stream << " fill=\"none\""; stream << " stroke=\"" << GetColorValue(color) << "\""; if (!color.IsSolid()) { stream << " stroke-opacity=\"" << color.GetA() << "\""; } stream << " stroke-width=\"" << width << "\""; stream << std::endl; stream << " points=\""; for (size_t i=transStart; i<=transEnd; i++) { if (i!=transStart) { stream << " "; } stream << coordBuffer->buffer[i].GetX() << "," << coordBuffer->buffer[i].GetY(); } stream << "\" />" << std::endl; }
void MapPainterSVG::DrawGround(const Projection& projection, const MapParameter& parameter, const FillStyle& style) { stream << " <rect x=\"" << 0 << "\" y=\"" << 0 << "\" width=\"" << projection.GetWidth() << "\" height=\"" << projection.GetHeight() << "\"" << std::endl; stream << " fill=\"" << GetColorValue(style.GetFillColor()) << "\"" << "/>" << std::endl; }
bool CCheckGridCell::LoadCheckBitmap() { if (m_hBitmapCheck != 0) { return true; } HINSTANCE hInst = AfxGetInstanceHandle(); m_hBitmapCheck = LoadResourceBitmap(hInst, MAKEINTRESOURCE(m_nBitmapResourceId)); if (m_hBitmapCheck == 0) { return false; } HANDLE hBitmap = m_hBitmapCheck; LPSTR lpDIB = (LPSTR)GlobalLock(hBitmap); DWORD dwColors = GetNumDIBColorEntries((LPBITMAPINFO)lpDIB); for (DWORD i = 0; i < dwColors; i++) { RGBQUAD* pColor = &((LPBITMAPINFO)lpDIB)->bmiColors[i]; COLORREF rgbOld = RGB(pColor->rgbRed, pColor->rgbGreen, pColor->rgbBlue); COLORREF rgbNew = GetColorValue(rgbOld); // replace color if (rgbOld != rgbNew) { pColor->rgbGreen = GetGValue(rgbNew); pColor->rgbBlue = GetBValue(rgbNew); pColor->rgbRed = GetRValue(rgbNew); } } GlobalUnlock(hBitmap); return true; }
int do_color_keyword (int keyword, int colormode, char *s) { switch (keyword) { case kwc_DefaultForeground: GetColor (colormode, &Scr->DefaultC.fore, s); return 1; case kwc_DefaultBackground: GetColor (colormode, &Scr->DefaultC.back, s); return 1; case kwc_MenuForeground: GetColor (colormode, &Scr->MenuC.fore, s); return 1; case kwc_MenuBackground: GetColor (colormode, &Scr->MenuC.back, s); return 1; case kwc_MenuBorderColor: GetColor (colormode, &Scr->MenuBorderColor, s); return 1; case kwc_MenuTitleForeground: GetColor (colormode, &Scr->MenuTitleC.fore, s); return 1; case kwc_MenuTitleBackground: GetColor (colormode, &Scr->MenuTitleC.back, s); return 1; case kwc_MenuShadowColor: GetColor (colormode, &Scr->MenuShadowColor, s); return 1; case kwc_PointerForeground: GetColorValue (colormode, &Scr->PointerForeground, s); return 1; case kwc_PointerBackground: GetColorValue (colormode, &Scr->PointerBackground, s); return 1; } return 0; }
COLORREF Attribute::GetColorValue() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); bool bTransparent; COLORREF value = GetColorValue(bTransparent); return value; }
COLORREF SgmlElement::GetColorValue(LPCTSTR szName) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); bool bTransparent; COLORREF clrValue = GetColorValue(szName, bTransparent); return clrValue; }
bool nsCSSValue::IsNonTransparentColor() const { // We have the value in the form it was specified in at this point, so we // have to look for both the keyword 'transparent' and its equivalent in // rgba notation. nsDependentString buf; return (mUnit == eCSSUnit_Color && NS_GET_A(GetColorValue()) > 0) || (mUnit == eCSSUnit_Ident && !nsGkAtoms::transparent->Equals(GetStringValue(buf))) || (mUnit == eCSSUnit_EnumColor); }
void FReplaceVectorWithLinearColorBuilder::CreateColorPicker(const TSharedPtr<IPropertyHandle>& StructHandle) { OldColorValue = GetColorValue(StructHandle); FColorPickerArgs PickerArgs; PickerArgs.bUseAlpha = false; PickerArgs.bOnlyRefreshOnMouseUp = false; PickerArgs.bOnlyRefreshOnOk = false; PickerArgs.DisplayGamma = TAttribute<float>::Create(TAttribute<float>::FGetter::CreateUObject(GEngine, &UEngine::GetDisplayGamma)); PickerArgs.OnColorCommitted = FOnLinearColorValueChanged::CreateSP(this, &FReplaceVectorWithLinearColorBuilder::OnSetColorFromColorPicker, StructHandle); PickerArgs.OnColorPickerCancelled = FOnColorPickerCancelled::CreateSP(this, &FReplaceVectorWithLinearColorBuilder::OnColorPickerCancelled, StructHandle); PickerArgs.OnInteractivePickBegin = FSimpleDelegate::CreateSP(this, &FReplaceVectorWithLinearColorBuilder::OnColorPickerInteractiveBegin); PickerArgs.OnInteractivePickEnd = FSimpleDelegate::CreateSP(this, &FReplaceVectorWithLinearColorBuilder::OnColorPickerInteractiveEnd); PickerArgs.InitialColorOverride = OldColorValue; PickerArgs.ParentWidget = ColorPickerParentWidget; OpenColorPicker(PickerArgs); }
void MapPainterSVG::DrawLabel(const Projection& projection, const MapParameter& parameter, const LabelData& label) { if (dynamic_cast<const TextStyle*>(label.style.get())!=NULL) { const TextStyle* style=dynamic_cast<const TextStyle*>(label.style.get()); #if defined(OSMSCOUT_MAP_SVG_HAVE_LIB_PANGO) PangoFontDescription* font=GetFont(projection, parameter, label.fontSize); #endif // TODO: This is not the exact placement, we cannot just move vertical by fontSize, but we must move the actual // text height. For this we need the text bounding box in LabelData. stream << " <text"; stream << " x=\"" << label.x << "\""; stream << " y=\"" << label.y+projection.ConvertWidthToPixel(label.fontSize*parameter.GetFontSize()) << "\""; stream << " font-family=\"" << parameter.GetFontName() << "\""; stream << " font-size=\"" << projection.ConvertWidthToPixel(label.fontSize*parameter.GetFontSize()) << "\""; stream << " fill=\"" << GetColorValue(style->GetTextColor()) << "\""; if (label.alpha!=1.0) { stream << " fill-opacity=\"" << label.alpha << "\""; } stream << ">"; stream << label.text; stream << "</text>" << std::endl; /* stream << "<rect x=\"" << label.bx1 << "\"" << " y=\"" << label.by1 << "\"" <<" width=\"" << label.bx2-label.bx1 << "\"" << " height=\"" << label.by2-label.by1 << "\"" << " fill=\"none\" stroke=\"blue\"/>" << std::endl;*/ } else if (dynamic_cast<const ShieldStyle*>(label.style.get())!=NULL) { const ShieldStyle* style=dynamic_cast<const ShieldStyle*>(label.style.get()); #if defined(OSMSCOUT_MAP_SVG_HAVE_LIB_PANGO) PangoFontDescription* font=GetFont(projection, parameter, label.fontSize); #endif // Shield background stream << " <rect"; stream << " x=\"" << label.bx1 << "\""; stream << " y=\"" << label.by1 << "\""; stream << " width=\"" << label.bx2-label.bx1+1 << "\""; stream << " height=\"" << label.by2-label.by1+1 << "\""; stream << " fill=\"" << GetColorValue(style->GetBgColor()) << "\""; stream << " stroke=\"none\""; stream << "/>" << std::endl; // Shield inner border stream << " <rect"; stream << " x=\"" << label.bx1+2 << "\""; stream << " y=\"" << label.by1+2 << "\""; stream << " width=\"" << label.bx2-label.bx1+1-4 << "\""; stream << " height=\"" << label.by2-label.by1+1-4 << "\""; stream << " fill=\"none\""; stream << " stroke=\"" << GetColorValue(style->GetBorderColor()) << "\""; stream << " stroke-width=\"1\""; stream << "/>" << std::endl; // TODO: This is not the exact placement, we cannot just move vertical by fontSize, but we must move the actual // text height. For this we need the text bounding box in LabelData. stream << " <text"; stream << " x=\"" << label.x << "\""; stream << " y=\"" << label.y+projection.ConvertWidthToPixel(label.fontSize*parameter.GetFontSize()) << "\""; stream << " font-family=\"" << parameter.GetFontName() << "\""; stream << " font-size=\"" << projection.ConvertWidthToPixel(label.fontSize*parameter.GetFontSize()) << "\""; stream << " fill=\"" << GetColorValue(style->GetTextColor()) << "\""; if (label.alpha!=1.0) { stream << " fill-opacity=\"" << label.alpha << "\""; } stream << ">"; stream << label.text; stream << "</text>" << std::endl; } }
void MapPainterSVG::AfterPreprocessing(const StyleConfig& styleConfig, const Projection& projection, const MapParameter& parameter, const MapData& data) { stream << " <defs>" << std::endl; stream << " <style type=\"text/css\">" << std::endl; stream << " <![CDATA[" << std::endl; size_t nextAreaId=0; for (const auto& area: GetAreaData()) { std::map<FillStyle,std::string>::const_iterator entry=fillStyleNameMap.find(*area.fillStyle); if (entry==fillStyleNameMap.end()) { std::string name="area_"+NumberToString(nextAreaId); fillStyleNameMap.insert(std::make_pair(*area.fillStyle,name)); nextAreaId++; stream << " ." << name << " {"; stream << "fill:" << GetColorValue(area.fillStyle->GetFillColor()); if (!area.fillStyle->GetFillColor().IsSolid()) { stream << ";fill-opacity:" << area.fillStyle->GetFillColor().GetA(); } stream << ";fillRule:nonzero"; double borderWidth=projection.ConvertWidthToPixel(area.fillStyle->GetBorderWidth()); if (borderWidth>0.0) { stream << ";stroke:" << GetColorValue(area.fillStyle->GetBorderColor()); if (!area.fillStyle->GetBorderColor().IsSolid()) { stream << ";stroke-opacity:" << area.fillStyle->GetBorderColor().GetA(); } stream << ";stroke-width:" << borderWidth; if (area.fillStyle->HasBorderDashes()) { stream << ";stroke-dasharray:"; for (size_t i=0; i<area.fillStyle->GetBorderDash().size(); i++) { if (i>0) { stream << ","; } stream << area.fillStyle->GetBorderDash()[i]*borderWidth; } } } stream << "}" << std::endl; } } stream << std::endl; size_t nextWayId=0; for (const auto& way : GetWayData()) { std::map<LineStyle,std::string>::const_iterator entry=lineStyleNameMap.find(*way.lineStyle); if (entry==lineStyleNameMap.end()) { std::string name="way_"+NumberToString(nextWayId); lineStyleNameMap.insert(std::make_pair(*way.lineStyle,name)); nextWayId++; double lineWidth; if (way.lineStyle->GetWidth()==0) { lineWidth=projection.ConvertWidthToPixel(way.lineStyle->GetDisplayWidth()); } else { lineWidth=GetProjectedWidth(projection, projection.ConvertWidthToPixel(way.lineStyle->GetDisplayWidth()), way.lineStyle->GetWidth()); } stream << " ." << name << " {"; stream << "fill:none;"; stream << "stroke:" << GetColorValue(way.lineStyle->GetLineColor()); if (!way.lineStyle->GetLineColor().IsSolid()) { stream << ";stroke-opacity:" << way.lineStyle->GetLineColor().GetA(); } if (way.lineStyle->HasDashes()) { stream << ";stroke-dasharray:"; for (size_t i=0; i<way.lineStyle->GetDash().size(); i++) { if (i>0) { stream << " "; } stream << way.lineStyle->GetDash()[i]*lineWidth; } } stream << "}" << std::endl; } } stream << std::endl; stream << " ]]>" << std::endl; stream << " </style>" << std::endl; stream << " </defs>" << std::endl; stream << std::endl; }
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 nsAttrValue::ToString(nsAString& aResult) const { switch(Type()) { case eString: { nsStringBuffer* str = static_cast<nsStringBuffer*>(GetPtr()); if (str) { str->ToString(str->StorageSize()/sizeof(PRUnichar) - 1, aResult); } else { aResult.Truncate(); } break; } case eAtom: { nsIAtom *atom = static_cast<nsIAtom*>(GetPtr()); atom->ToString(aResult); break; } case eInteger: { nsAutoString intStr; intStr.AppendInt(GetIntInternal()); aResult = intStr; break; } case eColor: { nscolor v; GetColorValue(v); NS_RGBToHex(v, aResult); break; } case eEnum: { PRInt16 val = GetEnumValue(); const EnumTable* table = sEnumTableArray-> ElementAt(GetIntInternal() & NS_ATTRVALUE_ENUMTABLEINDEX_MASK); while (table->tag) { if (table->value == val) { aResult.AssignASCII(table->tag); return; } table++; } NS_NOTREACHED("couldn't find value in EnumTable"); break; } case ePercent: { nsAutoString intStr; intStr.AppendInt(GetIntInternal()); aResult = intStr + NS_LITERAL_STRING("%"); break; } case eCSSStyleRule: { aResult.Truncate(); MiscContainer *container = GetMiscContainer(); nsCSSDeclaration* decl = container->mCSSStyleRule->GetDeclaration(); if (decl) { decl->ToString(aResult); } break; } case eAtomArray: { MiscContainer* cont = GetMiscContainer(); PRInt32 count = cont->mAtomArray->Count(); if (count) { cont->mAtomArray->ObjectAt(0)->ToString(aResult); nsAutoString tmp; PRInt32 i; for (i = 1; i < count; ++i) { cont->mAtomArray->ObjectAt(i)->ToString(tmp); aResult.Append(NS_LITERAL_STRING(" ") + tmp); } } else { aResult.Truncate(); } break; } #ifdef MOZ_SVG case eSVGValue: { GetMiscContainer()->mSVGValue->GetValueString(aResult); } #endif } }
FLinearColor FReplaceVectorWithLinearColorBuilder::OnGetColorForColorBlock(TSharedPtr<IPropertyHandle> StructHandle) const { return GetColorValue(StructHandle); }