diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 8f9c3a3a9ef..b8ec2af0446 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -2870,6 +2870,509 @@ nsComputedDOMStyle::GetFrameBorderRectWidth(nscoord& aWidth) return PR_TRUE; } +#ifdef MOZ_SVG + +nsresult +nsComputedDOMStyle::GetSVGPaintFor(PRBool aFill, + nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleSVG* svg = GetStyleSVG(); + const nsStyleSVGPaint* paint = nsnull; + + if (aFill) + paint = &svg->mFill; + else + paint = &svg->mStroke; + + nsAutoString paintString; + + switch (paint->mType) { + case eStyleSVGPaintType_None: + { + val->SetIdent(nsGkAtoms::none); + break; + } + case eStyleSVGPaintType_Color: + { + nsresult rv = SetToRGBAColor(val, paint->mPaint.mColor); + if (NS_FAILED(rv)) { + delete val; + return rv; + } + break; + } + case eStyleSVGPaintType_Server: + { + nsDOMCSSValueList *valueList = GetROCSSValueList(PR_FALSE); + NS_ENSURE_TRUE(valueList, NS_ERROR_OUT_OF_MEMORY); + + if (!valueList->AppendCSSValue(val)) { + delete valueList; + delete val; + return NS_ERROR_OUT_OF_MEMORY; + } + + nsROCSSPrimitiveValue* fallback = GetROCSSPrimitiveValue(); + if (!fallback || !valueList->AppendCSSValue(fallback)) { + delete valueList; + delete fallback; + return NS_ERROR_OUT_OF_MEMORY; + } + + val->SetURI(paint->mPaint.mPaintServer); + nsresult rv = SetToRGBAColor(fallback, paint->mFallbackColor); + if (NS_FAILED(rv)) { + delete valueList; + return rv; + } + + return CallQueryInterface(valueList, aValue); + } + } + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetFill(nsIDOMCSSValue** aValue) +{ + return GetSVGPaintFor(PR_TRUE, aValue); +} + +nsresult +nsComputedDOMStyle::GetStroke(nsIDOMCSSValue** aValue) +{ + return GetSVGPaintFor(PR_FALSE, aValue); +} + +nsresult +nsComputedDOMStyle::GetMarkerEnd(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleSVG* svg = GetStyleSVG(); + + if (svg->mMarkerEnd) + val->SetURI(svg->mMarkerEnd); + else + val->SetIdent(nsGkAtoms::none); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetMarkerMid(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleSVG* svg = GetStyleSVG(); + + if (svg->mMarkerMid) + val->SetURI(svg->mMarkerMid); + else + val->SetIdent(nsGkAtoms::none); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetMarkerStart(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleSVG* svg = GetStyleSVG(); + + if (svg->mMarkerStart) + val->SetURI(svg->mMarkerStart); + else + val->SetIdent(nsGkAtoms::none); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetStrokeDasharray(nsIDOMCSSValue** aValue) +{ + const nsStyleSVG* svg = GetStyleSVG(); + + if (!svg->mStrokeDasharrayLength || !svg->mStrokeDasharray) { + nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + val->SetIdent(nsGkAtoms::none); + return CallQueryInterface(val, aValue); + } + + nsDOMCSSValueList *valueList = GetROCSSValueList(PR_TRUE); + NS_ENSURE_TRUE(valueList, NS_ERROR_OUT_OF_MEMORY); + + for (PRUint32 i = 0; i < svg->mStrokeDasharrayLength; i++) { + nsROCSSPrimitiveValue* dash = GetROCSSPrimitiveValue(); + if (!dash || !valueList->AppendCSSValue(dash)) { + delete valueList; + delete dash; + return NS_ERROR_OUT_OF_MEMORY; + } + + SetValueToCoord(dash, svg->mStrokeDasharray[i]); + } + + return CallQueryInterface(valueList, aValue); +} + +nsresult +nsComputedDOMStyle::GetStrokeDashoffset(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + SetValueToCoord(val, GetStyleSVG()->mStrokeDashoffset); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetStrokeWidth(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + SetValueToCoord(val, GetStyleSVG()->mStrokeWidth); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetFillOpacity(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + val->SetNumber(GetStyleSVG()->mFillOpacity); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetFloodOpacity(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + val->SetNumber(GetStyleSVGReset()->mFloodOpacity); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetStopOpacity(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + val->SetNumber(GetStyleSVGReset()->mStopOpacity); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetStrokeMiterlimit(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + val->SetNumber(GetStyleSVG()->mStrokeMiterlimit); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetStrokeOpacity(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + val->SetNumber(GetStyleSVG()->mStrokeOpacity); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetClipRule(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsAFlatCString& keyword = + nsCSSProps::ValueToKeyword(GetStyleSVG()->mClipRule, + nsCSSProps::kFillRuleKTable); + val->SetIdent(keyword); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetFillRule(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsAFlatCString& keyword = + nsCSSProps::ValueToKeyword(GetStyleSVG()->mFillRule, + nsCSSProps::kFillRuleKTable); + val->SetIdent(keyword); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetStrokeLinecap(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsAFlatCString& keyword = + nsCSSProps::ValueToKeyword(GetStyleSVG()->mStrokeLinecap, + nsCSSProps::kStrokeLinecapKTable); + val->SetIdent(keyword); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetStrokeLinejoin(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsAFlatCString& keyword = + nsCSSProps::ValueToKeyword(GetStyleSVG()->mStrokeLinejoin, + nsCSSProps::kStrokeLinejoinKTable); + val->SetIdent(keyword); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetTextAnchor(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsAFlatCString& keyword = + nsCSSProps::ValueToKeyword(GetStyleSVG()->mTextAnchor, + nsCSSProps::kTextAnchorKTable); + val->SetIdent(keyword); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetColorInterpolation(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleSVG* svg = GetStyleSVG(); + + if (svg->mColorInterpolation != NS_STYLE_COLOR_INTERPOLATION_AUTO) { + const nsAFlatCString& keyword = + nsCSSProps::ValueToKeyword(svg->mColorInterpolation, + nsCSSProps::kColorInterpolationKTable); + val->SetIdent(keyword); + } else { + val->SetIdent(nsGkAtoms::_auto); + } + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetColorInterpolationFilters(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleSVG* svg = GetStyleSVG(); + + if (svg->mColorInterpolationFilters != NS_STYLE_COLOR_INTERPOLATION_AUTO) { + const nsAFlatCString& keyword = + nsCSSProps::ValueToKeyword(svg->mColorInterpolationFilters, + nsCSSProps::kColorInterpolationKTable); + val->SetIdent(keyword); + } else { + val->SetIdent(nsGkAtoms::_auto); + } + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetDominantBaseline(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleSVGReset* svg = GetStyleSVGReset(); + + if (svg->mDominantBaseline != NS_STYLE_DOMINANT_BASELINE_AUTO) { + const nsAFlatCString& keyword = + nsCSSProps::ValueToKeyword(svg->mDominantBaseline, + nsCSSProps::kDominantBaselineKTable); + val->SetIdent(keyword); + } else { + val->SetIdent(nsGkAtoms::_auto); + } + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetPointerEvents(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleSVG* svg = GetStyleSVG(); + + if (svg->mPointerEvents != NS_STYLE_POINTER_EVENTS_NONE) { + const nsAFlatCString& keyword = + nsCSSProps::ValueToKeyword(svg->mPointerEvents, + nsCSSProps::kPointerEventsKTable); + val->SetIdent(keyword); + } else { + val->SetIdent(nsGkAtoms::none); + } + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetShapeRendering(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleSVG* svg = GetStyleSVG(); + + if (svg->mShapeRendering != NS_STYLE_SHAPE_RENDERING_AUTO) { + const nsAFlatCString& keyword = + nsCSSProps::ValueToKeyword(svg->mShapeRendering, + nsCSSProps::kShapeRenderingKTable); + val->SetIdent(keyword); + } else { + val->SetIdent(nsGkAtoms::_auto); + } + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetTextRendering(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleSVG* svg = GetStyleSVG(); + + if (svg->mTextRendering != NS_STYLE_TEXT_RENDERING_AUTO) { + const nsAFlatCString& keyword = + nsCSSProps::ValueToKeyword(svg->mTextRendering, + nsCSSProps::kTextRenderingKTable); + val->SetIdent(keyword); + } else { + val->SetIdent(nsGkAtoms::_auto); + } + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetStopColor(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + nsresult rv = SetToRGBAColor(val, GetStyleSVGReset()->mStopColor); + if (NS_FAILED(rv)) { + delete val; + return rv; + } + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetFloodColor(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + nsresult rv = SetToRGBAColor(val, GetStyleSVGReset()->mFloodColor); + if (NS_FAILED(rv)) { + delete val; + return rv; + } + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetClipPath(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleSVGReset* svg = GetStyleSVGReset(); + + if (svg->mClipPath) + val->SetURI(svg->mClipPath); + else + val->SetIdent(nsGkAtoms::none); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetFilter(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleSVGReset* svg = GetStyleSVGReset(); + + if (svg->mFilter) + val->SetURI(svg->mFilter); + else + val->SetIdent(nsGkAtoms::none); + + return CallQueryInterface(val, aValue); +} + +nsresult +nsComputedDOMStyle::GetMask(nsIDOMCSSValue** aValue) +{ + nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue(); + NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); + + const nsStyleSVGReset* svg = GetStyleSVGReset(); + + if (svg->mMask) + val->SetURI(svg->mMask); + else + val->SetIdent(nsGkAtoms::none); + + return CallQueryInterface(val, aValue); +} + +#endif // MOZ_SVG + + #define COMPUTED_STYLE_MAP_ENTRY(_prop, _method) \ { eCSSProperty_##_prop, &nsComputedDOMStyle::Get##_method } @@ -3058,6 +3561,40 @@ nsComputedDOMStyle::GetQueryablePropertyMap(PRUint32* aLength) COMPUTED_STYLE_MAP_ENTRY(user_input, UserInput), COMPUTED_STYLE_MAP_ENTRY(user_modify, UserModify), COMPUTED_STYLE_MAP_ENTRY(user_select, UserSelect) + +#ifdef MOZ_SVG + , + COMPUTED_STYLE_MAP_ENTRY(clip_path, ClipPath), + COMPUTED_STYLE_MAP_ENTRY(clip_rule, ClipRule), + COMPUTED_STYLE_MAP_ENTRY(color_interpolation, ColorInterpolation), + COMPUTED_STYLE_MAP_ENTRY(color_interpolation_filters, ColorInterpolationFilters), + COMPUTED_STYLE_MAP_ENTRY(dominant_baseline, DominantBaseline), + COMPUTED_STYLE_MAP_ENTRY(fill, Fill), + COMPUTED_STYLE_MAP_ENTRY(fill_opacity, FillOpacity), + COMPUTED_STYLE_MAP_ENTRY(fill_rule, FillRule), + COMPUTED_STYLE_MAP_ENTRY(filter, Filter), + COMPUTED_STYLE_MAP_ENTRY(flood_color, FloodColor), + COMPUTED_STYLE_MAP_ENTRY(flood_opacity, FloodOpacity), + COMPUTED_STYLE_MAP_ENTRY(mask, Mask), + COMPUTED_STYLE_MAP_ENTRY(marker_end, MarkerEnd), + COMPUTED_STYLE_MAP_ENTRY(marker_mid, MarkerMid), + COMPUTED_STYLE_MAP_ENTRY(marker_start, MarkerStart), + COMPUTED_STYLE_MAP_ENTRY(pointer_events, PointerEvents), + COMPUTED_STYLE_MAP_ENTRY(shape_rendering, ShapeRendering), + COMPUTED_STYLE_MAP_ENTRY(stop_color, StopColor), + COMPUTED_STYLE_MAP_ENTRY(stop_opacity, StopOpacity), + COMPUTED_STYLE_MAP_ENTRY(stroke, Stroke), + COMPUTED_STYLE_MAP_ENTRY(stroke_dasharray, StrokeDasharray), + COMPUTED_STYLE_MAP_ENTRY(stroke_dashoffset, StrokeDashoffset), + COMPUTED_STYLE_MAP_ENTRY(stroke_linecap, StrokeLinecap), + COMPUTED_STYLE_MAP_ENTRY(stroke_linejoin, StrokeLinejoin), + COMPUTED_STYLE_MAP_ENTRY(stroke_miterlimit, StrokeMiterlimit), + COMPUTED_STYLE_MAP_ENTRY(stroke_opacity, StrokeOpacity), + COMPUTED_STYLE_MAP_ENTRY(stroke_width, StrokeWidth), + COMPUTED_STYLE_MAP_ENTRY(text_anchor, TextAnchor), + COMPUTED_STYLE_MAP_ENTRY(text_rendering, TextRendering) +#endif + }; *aLength = NS_ARRAY_LENGTH(map); diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h index 4156ff2574b..c3de2e92255 100644 --- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -266,6 +266,47 @@ private: nsresult GetColumnWidth(nsIDOMCSSValue** aValue); nsresult GetColumnGap(nsIDOMCSSValue** aValue); +#ifdef MOZ_SVG + /* SVG properties */ + nsresult GetSVGPaintFor(PRBool aFill, nsIDOMCSSValue** aValue); + + nsresult GetFill(nsIDOMCSSValue** aValue); + nsresult GetStroke(nsIDOMCSSValue** aValue); + nsresult GetMarkerEnd(nsIDOMCSSValue** aValue); + nsresult GetMarkerMid(nsIDOMCSSValue** aValue); + nsresult GetMarkerStart(nsIDOMCSSValue** aValue); + nsresult GetStrokeDasharray(nsIDOMCSSValue** aValue); + + nsresult GetStrokeDashoffset(nsIDOMCSSValue** aValue); + nsresult GetStrokeWidth(nsIDOMCSSValue** aValue); + + nsresult GetFillOpacity(nsIDOMCSSValue** aValue); + nsresult GetFloodOpacity(nsIDOMCSSValue** aValue); + nsresult GetStopOpacity(nsIDOMCSSValue** aValue); + nsresult GetStrokeMiterlimit(nsIDOMCSSValue** aValue); + nsresult GetStrokeOpacity(nsIDOMCSSValue** aValue); + + nsresult GetClipRule(nsIDOMCSSValue** aValue); + nsresult GetFillRule(nsIDOMCSSValue** aValue); + nsresult GetStrokeLinecap(nsIDOMCSSValue** aValue); + nsresult GetStrokeLinejoin(nsIDOMCSSValue** aValue); + nsresult GetTextAnchor(nsIDOMCSSValue** aValue); + + nsresult GetColorInterpolation(nsIDOMCSSValue** aValue); + nsresult GetColorInterpolationFilters(nsIDOMCSSValue** aValue); + nsresult GetDominantBaseline(nsIDOMCSSValue** aValue); + nsresult GetPointerEvents(nsIDOMCSSValue** aValue); + nsresult GetShapeRendering(nsIDOMCSSValue** aValue); + nsresult GetTextRendering(nsIDOMCSSValue** aValue); + + nsresult GetStopColor(nsIDOMCSSValue** aValue); + nsresult GetFloodColor(nsIDOMCSSValue** aValue); + + nsresult GetClipPath(nsIDOMCSSValue** aValue); + nsresult GetFilter(nsIDOMCSSValue** aValue); + nsresult GetMask(nsIDOMCSSValue** aValue); +#endif // MOZ_SVG + nsROCSSPrimitiveValue* GetROCSSPrimitiveValue(); nsDOMCSSValueList* GetROCSSValueList(PRBool aCommaDelimited); nsresult SetToRGBAColor(nsROCSSPrimitiveValue* aValue, nscolor aColor); diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index ad537c693e3..b60f8780046 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -4248,8 +4248,8 @@ nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct, inherited = PR_TRUE; svg->mColorInterpolationFilters = parentSVG->mColorInterpolationFilters; } - else if (eCSSUnit_Initial == SVGData.mColorInterpolation.GetUnit()) { - svg->mColorInterpolation = NS_STYLE_COLOR_INTERPOLATION_LINEARRGB; + else if (eCSSUnit_Initial == SVGData.mColorInterpolationFilters.GetUnit()) { + svg->mColorInterpolationFilters = NS_STYLE_COLOR_INTERPOLATION_LINEARRGB; } // fill: @@ -4347,7 +4347,7 @@ nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct, if (svg->mStrokeDasharray) memcpy(svg->mStrokeDasharray, parentSVG->mStrokeDasharray, - svg->mStrokeDasharrayLength * sizeof(float)); + svg->mStrokeDasharrayLength * sizeof(nsStyleCoord)); else svg->mStrokeDasharrayLength = 0; } @@ -4387,10 +4387,14 @@ nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct, } // stroke-dashoffset: , inherit - SetCoord(SVGData.mStrokeDashoffset, - svg->mStrokeDashoffset, parentSVG->mStrokeDashoffset, - SETCOORD_LPH | SETCOORD_FACTOR, - aContext, mPresContext, inherited); + if (eCSSUnit_Initial == SVGData.mStrokeDashoffset.GetUnit()) { + svg->mStrokeDashoffset.SetCoordValue(0); + } else { + SetCoord(SVGData.mStrokeDashoffset, + svg->mStrokeDashoffset, parentSVG->mStrokeDashoffset, + SETCOORD_LPH | SETCOORD_FACTOR, + aContext, mPresContext, inherited); + } // stroke-linecap: enum, inherit if (eCSSUnit_Enumerated == SVGData.mStrokeLinecap.GetUnit()) { @@ -4433,10 +4437,14 @@ nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct, svg->mStrokeOpacity, inherited); // stroke-width: - SetCoord(SVGData.mStrokeWidth, - svg->mStrokeWidth, parentSVG->mStrokeWidth, - SETCOORD_LPH | SETCOORD_FACTOR, - aContext, mPresContext, inherited); + if (eCSSUnit_Initial == SVGData.mStrokeWidth.GetUnit()) { + svg->mStrokeWidth.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(1)); + } else { + SetCoord(SVGData.mStrokeWidth, + svg->mStrokeWidth, parentSVG->mStrokeWidth, + SETCOORD_LPH | SETCOORD_FACTOR, + aContext, mPresContext, inherited); + } // text-anchor: enum, inherit if (eCSSUnit_Enumerated == SVGData.mTextAnchor.GetUnit()) { @@ -4476,12 +4484,20 @@ nsRuleNode::ComputeSVGResetData(nsStyleStruct* aStartStruct, COMPUTE_START_RESET(SVGReset, (), svgReset, parentSVGReset, SVG, SVGData) // stop-color: - SetColor(SVGData.mStopColor, parentSVGReset->mStopColor, - mPresContext, aContext, svgReset->mStopColor, inherited); + if (eCSSUnit_Initial == SVGData.mStopColor.GetUnit()) { + svgReset->mStopColor = NS_RGB(0, 0, 0); + } else { + SetColor(SVGData.mStopColor, parentSVGReset->mStopColor, + mPresContext, aContext, svgReset->mStopColor, inherited); + } // flood-color: - SetColor(SVGData.mFloodColor, parentSVGReset->mFloodColor, - mPresContext, aContext, svgReset->mFloodColor, inherited); + if (eCSSUnit_Initial == SVGData.mFloodColor.GetUnit()) { + svgReset->mFloodColor = NS_RGB(0, 0, 0); + } else { + SetColor(SVGData.mFloodColor, parentSVGReset->mFloodColor, + mPresContext, aContext, svgReset->mFloodColor, inherited); + } // clip-path: url, none, inherit if (eCSSUnit_URL == SVGData.mClipPath.GetUnit()) { diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 4e0f8e58f71..f6596dfad1e 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -652,8 +652,8 @@ nsStyleSVG::nsStyleSVG() mStroke.mFallbackColor = NS_RGB(0,0,0); mStrokeDasharray = nsnull; - mStrokeDashoffset.SetFactorValue(0.0f); - mStrokeWidth.SetFactorValue(1.0f); + mStrokeDashoffset.SetCoordValue(0); + mStrokeWidth.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(1)); mFillOpacity = 1.0f; mStrokeMiterlimit = 4.0f; @@ -686,7 +686,7 @@ nsStyleSVG::nsStyleSVG(const nsStyleSVG& aSource) mMarkerEnd = aSource.mMarkerEnd; mMarkerMid = aSource.mMarkerMid; - mMarkerEnd = aSource.mMarkerStart; + mMarkerStart = aSource.mMarkerStart; mStrokeDasharrayLength = aSource.mStrokeDasharrayLength; if (aSource.mStrokeDasharray) { diff --git a/layout/style/test/test_compute_data_with_start_struct.html b/layout/style/test/test_compute_data_with_start_struct.html index f4eb4c714ff..2463e43ca67 100644 --- a/layout/style/test/test_compute_data_with_start_struct.html +++ b/layout/style/test/test_compute_data_with_start_struct.html @@ -39,36 +39,6 @@ var gNoComputedStyle = { "page-break-after": true, "page-break-before": true, "quotes": true, - "clip-path": true, - "clip-rule": true, - "color-interpolation": true, - "color-interpolation-filters": true, - "dominant-baseline": true, - "fill": true, - "fill-opacity": true, - "fill-rule": true, - "filter": true, - "flood-color": true, - "flood-opacity": true, - "marker": true, // NB: shorthand - "marker-end": true, - "marker-mid": true, - "marker-start": true, - "mask": true, - "pointer-events": true, - "shape-rendering": true, - "stop-color": true, - "stop-opacity": true, - "stroke": true, - "stroke-dasharray": true, - "stroke-dashoffset": true, - "stroke-linecap": true, - "stroke-linejoin": true, - "stroke-miterlimit": true, - "stroke-opacity": true, - "stroke-width": true, - "text-anchor": true, - "text-rendering": true, }; var gXFailComputed = { diff --git a/layout/style/test/test_inherit_computation.html b/layout/style/test/test_inherit_computation.html index 09fd8264557..49218ccd435 100644 --- a/layout/style/test/test_inherit_computation.html +++ b/layout/style/test/test_inherit_computation.html @@ -41,36 +41,6 @@ var gNoComputedStyle = { "page-break-after": true, "page-break-before": true, "quotes": true, - "clip-path": true, - "clip-rule": true, - "color-interpolation": true, - "color-interpolation-filters": true, - "dominant-baseline": true, - "fill": true, - "fill-opacity": true, - "fill-rule": true, - "filter": true, - "flood-color": true, - "flood-opacity": true, - "marker": true, // NB: shorthand - "marker-end": true, - "marker-mid": true, - "marker-start": true, - "mask": true, - "pointer-events": true, - "shape-rendering": true, - "stop-color": true, - "stop-opacity": true, - "stroke": true, - "stroke-dasharray": true, - "stroke-dashoffset": true, - "stroke-linecap": true, - "stroke-linejoin": true, - "stroke-miterlimit": true, - "stroke-opacity": true, - "stroke-width": true, - "text-anchor": true, - "text-rendering": true, }; function xfail_diffcomputed(property) { diff --git a/layout/style/test/test_initial_computation.html b/layout/style/test/test_initial_computation.html index c6bc6ced4d1..b906ec9c1e2 100644 --- a/layout/style/test/test_initial_computation.html +++ b/layout/style/test/test_initial_computation.html @@ -54,36 +54,6 @@ var gNoComputedStyle = { "page-break-after": true, "page-break-before": true, "quotes": true, - "clip-path": true, - "clip-rule": true, - "color-interpolation": true, - "color-interpolation-filters": true, - "dominant-baseline": true, - "fill": true, - "fill-opacity": true, - "fill-rule": true, - "filter": true, - "flood-color": true, - "flood-opacity": true, - "marker": true, // NB: shorthand - "marker-end": true, - "marker-mid": true, - "marker-start": true, - "mask": true, - "pointer-events": true, - "shape-rendering": true, - "stop-color": true, - "stop-opacity": true, - "stroke": true, - "stroke-dasharray": true, - "stroke-dashoffset": true, - "stroke-linecap": true, - "stroke-linejoin": true, - "stroke-miterlimit": true, - "stroke-opacity": true, - "stroke-width": true, - "text-anchor": true, - "text-rendering": true, }; function xfail_diffcomputed(property) { diff --git a/layout/style/test/test_value_computation.html b/layout/style/test/test_value_computation.html index fc7f43ce531..3b2d24a8c87 100644 --- a/layout/style/test/test_value_computation.html +++ b/layout/style/test/test_value_computation.html @@ -54,36 +54,6 @@ var gNoComputedStyle = { "page-break-after": true, "page-break-before": true, "quotes": true, - "clip-path": true, - "clip-rule": true, - "color-interpolation": true, - "color-interpolation-filters": true, - "dominant-baseline": true, - "fill": true, - "fill-opacity": true, - "fill-rule": true, - "filter": true, - "flood-color": true, - "flood-opacity": true, - "marker": true, // NB: shorthand - "marker-end": true, - "marker-mid": true, - "marker-start": true, - "mask": true, - "pointer-events": true, - "shape-rendering": true, - "stop-color": true, - "stop-opacity": true, - "stroke": true, - "stroke-dasharray": true, - "stroke-dashoffset": true, - "stroke-linecap": true, - "stroke-linejoin": true, - "stroke-miterlimit": true, - "stroke-opacity": true, - "stroke-width": true, - "text-anchor": true, - "text-rendering": true, }; function xfail_diffcomputed(property) {