зеркало из https://github.com/mozilla/pjs.git
Bug 277135 - addressing svg style sr comments. r=scooter, sr=dbaron
This commit is contained in:
Родитель
9fa0fe53d1
Коммит
83911584c1
|
@ -643,16 +643,14 @@
|
|||
#define NS_STYLE_DOMINANT_BASELINE_USE_SCRIPT 1
|
||||
#define NS_STYLE_DOMINANT_BASELINE_NO_CHANGE 2
|
||||
#define NS_STYLE_DOMINANT_BASELINE_RESET_SIZE 3
|
||||
#define NS_STYLE_DOMINANT_BASELINE_ALPHABETIC 4
|
||||
#define NS_STYLE_DOMINANT_BASELINE_HANGING 5
|
||||
#define NS_STYLE_DOMINANT_BASELINE_IDEOGRAPHIC 6
|
||||
#define NS_STYLE_DOMINANT_BASELINE_IDEOGRAPHIC 4
|
||||
#define NS_STYLE_DOMINANT_BASELINE_ALPHABETIC 5
|
||||
#define NS_STYLE_DOMINANT_BASELINE_HANGING 6
|
||||
#define NS_STYLE_DOMINANT_BASELINE_MATHEMATICAL 7
|
||||
#define NS_STYLE_DOMINANT_BASELINE_CENTRAL 8
|
||||
#define NS_STYLE_DOMINANT_BASELINE_MIDDLE 9
|
||||
#define NS_STYLE_DOMINANT_BASELINE_TEXT_AFTER_EDGE 10
|
||||
#define NS_STYLE_DOMINANT_BASELINE_TEXT_BEFORE_EDGE 11
|
||||
#define NS_STYLE_DOMINANT_BASELINE_TEXT_TOP 12
|
||||
#define NS_STYLE_DOMINANT_BASELINE_TEXT_BOTTOM 13
|
||||
|
||||
// fill-rule
|
||||
#define NS_STYLE_FILL_RULE_NONZERO 0 /* == nsISVGGeometrySource::FILL_RULE_NONZERO */
|
||||
|
|
|
@ -551,8 +551,6 @@ CSS_KEY(reset-size, reset_size)
|
|||
CSS_KEY(round, round)
|
||||
//CSS_KEY(square, square)
|
||||
//CSS_KEY(start, start)
|
||||
CSS_KEY(stop-color, stop_color)
|
||||
CSS_KEY(stop-opacity, stop_opacity)
|
||||
CSS_KEY(stroke, stroke)
|
||||
CSS_KEY(text-after-edge, text_after_edge)
|
||||
CSS_KEY(text-before-edge, text_before_edge)
|
||||
|
|
|
@ -4303,7 +4303,7 @@ PRBool CSSParserImpl::ParseSingleValueProperty(nsresult& aErrorCode,
|
|||
case eCSSProperty_marker_start:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_HUO, nsnull);
|
||||
case eCSSProperty_pointer_events:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_HK,
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_HOK,
|
||||
nsCSSProps::kPointerEventsKTable);
|
||||
case eCSSProperty_shape_rendering:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_AHK,
|
||||
|
@ -4328,7 +4328,7 @@ PRBool CSSParserImpl::ParseSingleValueProperty(nsresult& aErrorCode,
|
|||
nsCSSProps::kStrokeLinejoinKTable);
|
||||
case eCSSProperty_stroke_miterlimit:
|
||||
return ParsePositiveVariant(aErrorCode, aValue, VARIANT_HN,
|
||||
nsnull); // XXX value > 1
|
||||
nsnull);
|
||||
case eCSSProperty_stroke_opacity:
|
||||
return ParseVariant(aErrorCode, aValue, VARIANT_HN,
|
||||
nsnull);
|
||||
|
@ -5796,7 +5796,7 @@ PRBool CSSParserImpl::ParseDasharray(nsresult& aErrorCode)
|
|||
|
||||
list->mValue = value;
|
||||
|
||||
while (list) {
|
||||
for (;;) {
|
||||
if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
|
||||
mTempData.SetPropertyBit(eCSSProperty_stroke_dasharray);
|
||||
mTempData.mSVG.mStrokeDasharray = listHead;
|
||||
|
@ -5805,23 +5805,24 @@ PRBool CSSParserImpl::ParseDasharray(nsresult& aErrorCode)
|
|||
}
|
||||
|
||||
if (eCSSUnit_Inherit == value.GetUnit() ||
|
||||
eCSSUnit_Initial == value.GetUnit()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
eCSSUnit_Initial == value.GetUnit() ||
|
||||
eCSSUnit_None == value.GetUnit())
|
||||
break;
|
||||
|
||||
if (!ExpectSymbol(aErrorCode, ',', PR_TRUE))
|
||||
break;
|
||||
|
||||
if (ParseVariant(aErrorCode, value,
|
||||
VARIANT_LENGTH | VARIANT_PERCENT | VARIANT_NUMBER,
|
||||
nsnull)) {
|
||||
list->mNext = new nsCSSValueList;
|
||||
list = list->mNext;
|
||||
if (list)
|
||||
list->mValue = value;
|
||||
else
|
||||
aErrorCode = NS_ERROR_OUT_OF_MEMORY;
|
||||
} else {
|
||||
if (!ParseVariant(aErrorCode, value,
|
||||
VARIANT_LENGTH | VARIANT_PERCENT | VARIANT_NUMBER,
|
||||
nsnull))
|
||||
break;
|
||||
|
||||
list->mNext = new nsCSSValueList;
|
||||
list = list->mNext;
|
||||
if (list)
|
||||
list->mValue = value;
|
||||
else {
|
||||
aErrorCode = NS_ERROR_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,10 +127,8 @@
|
|||
#define CSS_PROP_OUTLINE(name_, id_, method_, datastruct_, member_, type_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, kwtable_)
|
||||
#define CSS_PROP_XUL(name_, id_, method_, datastruct_, member_, type_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, kwtable_)
|
||||
#define CSS_PROP_COLUMN(name_, id_, method_, datastruct_, member_, type_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, kwtable_)
|
||||
#ifdef MOZ_SVG
|
||||
#define CSS_PROP_SVG(name_, id_, method_, datastruct_, member_, type_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, kwtable_)
|
||||
#define CSS_PROP_SVGRESET(name_, id_, method_, datastruct_, member_, type_, kwtable_) CSS_PROP(name_, id_, method_, datastruct_, member_, type_, kwtable_)
|
||||
#endif
|
||||
|
||||
// For properties that are stored in the CSS backend but are not
|
||||
// computed. An includer may define this in addition to CSS_PROP, but
|
||||
|
@ -230,7 +228,6 @@
|
|||
#define CSS_PROP_COLUMN(name_, id_, method_, datastruct_, member_, type_, kwtable_) /* nothing */
|
||||
#define DEFINED_CSS_PROP_COLUMN
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
#ifndef CSS_PROP_SVG
|
||||
#define CSS_PROP_SVG(name_, id_, method_, datastruct_, member_, type_, kwtable_) /* nothing */
|
||||
#define DEFINED_CSS_PROP_SVG
|
||||
|
@ -239,7 +236,6 @@
|
|||
#define CSS_PROP_SVGRESET(name_, id_, method_, datastruct_, member_, type_, kwtable_) /* nothing */
|
||||
#define DEFINED_CSS_PROP_SVGRESET
|
||||
#endif
|
||||
#endif /* defined(MOZ_SVG) */
|
||||
|
||||
#ifndef CSS_PROP_BACKENDONLY
|
||||
#define CSS_PROP_BACKENDONLY(name_, id_, method_, datastruct_, member_, type_, kwtable_) /* nothing */
|
||||
|
@ -480,10 +476,10 @@ CSS_PROP_SVG(marker-mid, marker_mid, MarkerMid, SVG, mMarkerMid, eCSSType_Value,
|
|||
CSS_PROP_SVG(marker-start, marker_start, MarkerStart, SVG, mMarkerStart, eCSSType_Value, nsnull)
|
||||
CSS_PROP_SVG(pointer-events, pointer_events, PointerEvents, SVG, mPointerEvents, eCSSType_Value, kPointerEventsKTable)
|
||||
CSS_PROP_SVG(shape-rendering, shape_rendering, ShapeRendering, SVG, mShapeRendering, eCSSType_Value, kShapeRenderingKTable)
|
||||
CSS_PROP_SVG(stop-color, stop_color, StopColor, SVG, mStopColor, eCSSType_Value, nsnull)
|
||||
CSS_PROP_SVG(stop-opacity, stop_opacity, StopOpacity, SVG, mStopOpacity, eCSSType_Value, nsnull)
|
||||
CSS_PROP_SVGRESET(stop-color, stop_color, StopColor, SVG, mStopColor, eCSSType_Value, nsnull)
|
||||
CSS_PROP_SVGRESET(stop-opacity, stop_opacity, StopOpacity, SVG, mStopOpacity, eCSSType_Value, nsnull)
|
||||
CSS_PROP_SVG(stroke, stroke, Stroke, SVG, mStroke, eCSSType_Value, nsnull)
|
||||
CSS_PROP_SVG(stroke-dasharray, stroke_dasharray, StrokeDasharray, SVG, mStrokeDasharray, eCSSType_Value, nsnull)
|
||||
CSS_PROP_SVG(stroke-dasharray, stroke_dasharray, StrokeDasharray, SVG, mStrokeDasharray, eCSSType_ValueList, nsnull)
|
||||
CSS_PROP_SVG(stroke-dashoffset, stroke_dashoffset, StrokeDashoffset, SVG, mStrokeDashoffset, eCSSType_Value, nsnull)
|
||||
CSS_PROP_SVG(stroke-linecap, stroke_linecap, StrokeLinecap, SVG, mStrokeLinecap, eCSSType_Value, kStrokeLinecapKTable)
|
||||
CSS_PROP_SVG(stroke-linejoin, stroke_linejoin, StrokeLinejoin, SVG, mStrokeLinejoin, eCSSType_Value, kStrokeLinejoinKTable)
|
||||
|
@ -533,10 +529,8 @@ CSS_PROP_TABLE(X, X, X, Table, mSpan, eCSSType_Value, nsnull)
|
|||
#undef CSS_PROP_OUTLINE
|
||||
#undef CSS_PROP_XUL
|
||||
#undef CSS_PROP_COLUMN
|
||||
#ifdef MOZ_SVG
|
||||
#undef CSS_PROP_SVG
|
||||
#undef CSS_PROP_SVGRESET
|
||||
#endif
|
||||
#ifdef DEFINED_CSS_PROP_BACKENDONLY
|
||||
#undef CSS_PROP_BACKENDONLY
|
||||
#undef DEFINED_CSS_PROP_BACKENDONLY
|
||||
|
@ -628,7 +622,6 @@ CSS_PROP_TABLE(X, X, X, Table, mSpan, eCSSType_Value, nsnull)
|
|||
#undef CSS_PROP_COLUMN
|
||||
#undef DEFINED_CSS_PROP_COLUMN
|
||||
#endif
|
||||
#ifdef MOZ_SVG
|
||||
#ifdef DEFINED_CSS_PROP_SVG
|
||||
#undef CSS_PROP_SVG
|
||||
#undef DEFINED_CSS_PROP_SVG
|
||||
|
@ -637,7 +630,6 @@ CSS_PROP_TABLE(X, X, X, Table, mSpan, eCSSType_Value, nsnull)
|
|||
#undef CSS_PROP_SVGRESET
|
||||
#undef DEFINED_CSS_PROP_SVGRESET
|
||||
#endif
|
||||
#endif /* defined(MOZ_SVG) */
|
||||
#ifdef DEFINED_CSS_PROP_BACKENDONLY
|
||||
#undef CSS_PROP_BACKENDONLY
|
||||
#undef DEFINED_CSS_PROP_BACKENDONLY
|
||||
|
|
|
@ -992,7 +992,6 @@ const PRInt32 nsCSSProps::kPointerEventsKTable[] = {
|
|||
eCSSKeyword_fill, NS_STYLE_POINTER_EVENTS_FILL,
|
||||
eCSSKeyword_stroke, NS_STYLE_POINTER_EVENTS_STROKE,
|
||||
eCSSKeyword_all, NS_STYLE_POINTER_EVENTS_ALL,
|
||||
eCSSKeyword_none, NS_STYLE_POINTER_EVENTS_NONE,
|
||||
eCSSKeyword_UNKNOWN, -1
|
||||
};
|
||||
|
||||
|
@ -1143,10 +1142,8 @@ const nsStyleStructID nsCSSProps::kSIDTable[eCSSProperty_COUNT_no_shorthands] =
|
|||
#define CSS_PROP_BORDER(name_, id_, method_, datastruct_, member_, type_, kwtable_) eStyleStruct_Border,
|
||||
#define CSS_PROP_OUTLINE(name_, id_, method_, datastruct_, member_, type_, kwtable_) eStyleStruct_Outline,
|
||||
#define CSS_PROP_XUL(name_, id_, method_, datastruct_, member_, type_, kwtable_) eStyleStruct_XUL,
|
||||
#ifdef MOZ_SVG
|
||||
#define CSS_PROP_SVG(name_, id_, method_, datastruct_, member_, type_, kwtable_) eStyleStruct_SVG,
|
||||
#define CSS_PROP_SVGRESET(name_, id_, method_, datastruct_, member_, type_, kwtable_) eStyleStruct_SVGReset,
|
||||
#endif /* defined(MOZ_SVG) */
|
||||
#define CSS_PROP_COLUMN(name_, id_, method_, datastruct_, member_, type_, kwtable_) eStyleStruct_Column,
|
||||
// This shouldn't matter, but we need something to go here.
|
||||
#define CSS_PROP_BACKENDONLY(name_, id_, method_, datastruct_, member_, type_, kwtable_) nsStyleStructID(-1),
|
||||
|
@ -1173,10 +1170,8 @@ const nsStyleStructID nsCSSProps::kSIDTable[eCSSProperty_COUNT_no_shorthands] =
|
|||
#undef CSS_PROP_BORDER
|
||||
#undef CSS_PROP_OUTLINE
|
||||
#undef CSS_PROP_XUL
|
||||
#ifdef MOZ_SVG
|
||||
#undef CSS_PROP_SVG
|
||||
#undef CSS_PROP_SVGRESET
|
||||
#endif /* undefd(MOZ_SVG) */
|
||||
#undef CSS_PROP_COLUMN
|
||||
#undef CSS_PROP_BACKENDONLY
|
||||
};
|
||||
|
|
|
@ -1261,6 +1261,7 @@ void nsCSSSVG::List(FILE* out, PRInt32 aIndent) const
|
|||
mStopOpacity.AppendToString(buffer, eCSSProperty_stop_opacity);
|
||||
mStroke.AppendToString(buffer, eCSSProperty_stroke);
|
||||
|
||||
// XXX This prints the property name many times, but nobody cares.
|
||||
nsCSSValueList *value = mStrokeDasharray;
|
||||
while (value) {
|
||||
value->mValue.AppendToString(buffer, eCSSProperty_stroke_dasharray);
|
||||
|
|
|
@ -4614,9 +4614,6 @@ SetSVGPaint(const nsCSSValue& aValue, const nsStyleSVGPaint& parentPaint,
|
|||
NS_IF_ADDREF(aResult.mPaint.mPaintServer);
|
||||
} else if (SetColor(aValue, parentPaint.mPaint.mColor, aPresContext, aContext, aResult.mPaint.mColor, aInherited)) {
|
||||
aResult.mType = eStyleSVGPaintType_Color;
|
||||
} else {
|
||||
// XXX Check for "currentColor"
|
||||
// XXX Set it to the default color
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4629,35 +4626,11 @@ SetSVGOpacity(const nsCSSValue& aValue, float parentOpacity, float& opacity, PRB
|
|||
}
|
||||
else if (aValue.GetUnit() == eCSSUnit_Number) {
|
||||
opacity = aValue.GetFloatValue();
|
||||
opacity = PR_MAX(opacity, 0.0f);
|
||||
opacity = PR_MIN(opacity, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SetSVGLength(const nsCSSValue& aValue, float parentLength, float& length,
|
||||
nsStyleContext* aContext, nsPresContext* aPresContext, PRBool& aInherited)
|
||||
{
|
||||
nsStyleCoord coord;
|
||||
PRBool dummy;
|
||||
if (SetCoord(aValue, coord, coord,
|
||||
SETCOORD_LP | SETCOORD_FACTOR,
|
||||
aContext, aPresContext, dummy)) {
|
||||
if (coord.GetUnit() == eStyleUnit_Factor) { // user units
|
||||
length = (float) coord.GetFactorValue();
|
||||
}
|
||||
else {
|
||||
length = (float) coord.GetCoordValue();
|
||||
float twipsPerPix = aPresContext->ScaledPixelsToTwips();
|
||||
if (twipsPerPix == 0.0f)
|
||||
twipsPerPix = 1e-20f;
|
||||
length /= twipsPerPix;
|
||||
}
|
||||
}
|
||||
else if (aValue.GetUnit() == eCSSUnit_Inherit) {
|
||||
length = parentLength;
|
||||
aInherited = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
const nsStyleStruct*
|
||||
nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct,
|
||||
const nsRuleDataStruct& aData,
|
||||
|
@ -4752,17 +4725,12 @@ nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct,
|
|||
svg->mMarkerStart = parentSVG->mMarkerStart;
|
||||
}
|
||||
|
||||
// stop-color:
|
||||
SetSVGPaint(SVGData.mStopColor, parentSVG->mStopColor, mPresContext, aContext, svg->mStopColor, inherited);
|
||||
|
||||
// stop-opacity:
|
||||
SetSVGOpacity(SVGData.mStopOpacity, parentSVG->mStopOpacity, svg->mStopOpacity, inherited);
|
||||
|
||||
// pointer-events: enum, inherit
|
||||
if (eCSSUnit_Enumerated == SVGData.mPointerEvents.GetUnit()) {
|
||||
svg->mPointerEvents = SVGData.mPointerEvents.GetIntValue();
|
||||
}
|
||||
else if (eCSSUnit_Inherit == SVGData.mPointerEvents.GetUnit()) {
|
||||
} else if (eCSSUnit_None == SVGData.mMarkerMid.GetUnit()) {
|
||||
svg->mPointerEvents = NS_STYLE_POINTER_EVENTS_NONE;
|
||||
} else if (eCSSUnit_Inherit == SVGData.mPointerEvents.GetUnit()) {
|
||||
inherited = PR_TRUE;
|
||||
svg->mPointerEvents = parentSVG->mPointerEvents;
|
||||
}
|
||||
|
@ -4791,7 +4759,7 @@ nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct,
|
|||
inherited = PR_TRUE;
|
||||
svg->mStrokeDasharrayLength = parentSVG->mStrokeDasharrayLength;
|
||||
if (svg->mStrokeDasharrayLength) {
|
||||
svg->mStrokeDasharray = new float[svg->mStrokeDasharrayLength];
|
||||
svg->mStrokeDasharray = new nsStyleCoord[svg->mStrokeDasharrayLength];
|
||||
if (svg->mStrokeDasharray)
|
||||
memcpy(svg->mStrokeDasharray,
|
||||
parentSVG->mStrokeDasharray,
|
||||
|
@ -4810,20 +4778,22 @@ nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct,
|
|||
// count number of values
|
||||
nsCSSValueList *value = SVGData.mStrokeDasharray;
|
||||
while (nsnull != value) {
|
||||
svg->mStrokeDasharrayLength++;
|
||||
++svg->mStrokeDasharrayLength;
|
||||
value = value->mNext;
|
||||
}
|
||||
|
||||
NS_ASSERTION(svg->mStrokeDasharrayLength != 0, "no dasharray items");
|
||||
|
||||
svg->mStrokeDasharray = new float[svg->mStrokeDasharrayLength];
|
||||
svg->mStrokeDasharray = new nsStyleCoord[svg->mStrokeDasharrayLength];
|
||||
|
||||
if (svg->mStrokeDasharray) {
|
||||
value = SVGData.mStrokeDasharray;
|
||||
PRUint32 i = 0;
|
||||
while (nsnull != value) {
|
||||
SetSVGLength(value->mValue, 0, svg->mStrokeDasharray[i++],
|
||||
aContext, mPresContext, inherited);
|
||||
SetCoord(value->mValue,
|
||||
svg->mStrokeDasharray[i++], nsnull,
|
||||
SETCOORD_LP | SETCOORD_FACTOR,
|
||||
aContext, mPresContext, inherited);
|
||||
value = value->mNext;
|
||||
}
|
||||
} else
|
||||
|
@ -4833,9 +4803,11 @@ nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct,
|
|||
}
|
||||
|
||||
// stroke-dashoffset: <dashoffset>, inherit
|
||||
SetSVGLength(SVGData.mStrokeDashoffset, parentSVG->mStrokeDashoffset,
|
||||
svg->mStrokeDashoffset, aContext, mPresContext, inherited);
|
||||
|
||||
SetCoord(SVGData.mStrokeDashoffset,
|
||||
svg->mStrokeDashoffset, parentSVG->mStrokeDashoffset,
|
||||
SETCOORD_LPH | SETCOORD_FACTOR,
|
||||
aContext, mPresContext, inherited);
|
||||
|
||||
// stroke-linecap: enum, inherit
|
||||
if (eCSSUnit_Enumerated == SVGData.mStrokeLinecap.GetUnit()) {
|
||||
svg->mStrokeLinecap = SVGData.mStrokeLinecap.GetIntValue();
|
||||
|
@ -4856,10 +4828,7 @@ nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct,
|
|||
|
||||
// stroke-miterlimit: <miterlimit>, inherit
|
||||
if (eCSSUnit_Number == SVGData.mStrokeMiterlimit.GetUnit()) {
|
||||
float value = SVGData.mStrokeMiterlimit.GetFloatValue();
|
||||
if (value >= 1.0f) { // XXX this check should probably be in nsCSSParser
|
||||
svg->mStrokeMiterlimit = value;
|
||||
}
|
||||
svg->mStrokeMiterlimit = SVGData.mStrokeMiterlimit.GetFloatValue();
|
||||
}
|
||||
else if (eCSSUnit_Inherit == SVGData.mStrokeMiterlimit.GetUnit()) {
|
||||
svg->mStrokeMiterlimit = parentSVG->mStrokeMiterlimit;
|
||||
|
@ -4870,8 +4839,10 @@ nsRuleNode::ComputeSVGData(nsStyleStruct* aStartStruct,
|
|||
SetSVGOpacity(SVGData.mStrokeOpacity, parentSVG->mStrokeOpacity, svg->mStrokeOpacity, inherited);
|
||||
|
||||
// stroke-width:
|
||||
SetSVGLength(SVGData.mStrokeWidth, parentSVG->mStrokeWidth,
|
||||
svg->mStrokeWidth, aContext, mPresContext, inherited);
|
||||
SetCoord(SVGData.mStrokeWidth,
|
||||
svg->mStrokeWidth, parentSVG->mStrokeWidth,
|
||||
SETCOORD_LPH | SETCOORD_FACTOR,
|
||||
aContext, mPresContext, inherited);
|
||||
|
||||
// text-anchor: enum, inherit
|
||||
if (eCSSUnit_Enumerated == SVGData.mTextAnchor.GetUnit()) {
|
||||
|
@ -4925,7 +4896,7 @@ nsRuleNode::ComputeSVGResetData(nsStyleStruct* aStartStruct,
|
|||
nsStyleContext* parentContext = aContext->GetParent();
|
||||
|
||||
const nsRuleDataSVG& SVGData = NS_STATIC_CAST(const nsRuleDataSVG&, aData);
|
||||
nsStyleSVGReset* svgReset = nsnull;
|
||||
nsStyleSVGReset* svgReset;
|
||||
|
||||
if (aStartStruct)
|
||||
// We only need to compute the delta between this computed data and our
|
||||
|
@ -4947,6 +4918,10 @@ nsRuleNode::ComputeSVGResetData(nsStyleStruct* aStartStruct,
|
|||
|
||||
PRBool inherited = aInherited;
|
||||
|
||||
// stop-color:
|
||||
SetSVGPaint(SVGData.mStopColor, parentSVGReset->mStopColor,
|
||||
mPresContext, aContext, svgReset->mStopColor, inherited);
|
||||
|
||||
// clip-path: url, none, inherit
|
||||
if (eCSSUnit_URL == SVGData.mClipPath.GetUnit()) {
|
||||
svgReset->mClipPath = SVGData.mClipPath.GetURLValue();
|
||||
|
@ -4957,6 +4932,10 @@ nsRuleNode::ComputeSVGResetData(nsStyleStruct* aStartStruct,
|
|||
svgReset->mClipPath = parentSVGReset->mClipPath;
|
||||
}
|
||||
|
||||
// stop-opacity:
|
||||
SetSVGOpacity(SVGData.mStopOpacity, parentSVGReset->mStopOpacity,
|
||||
svgReset->mStopOpacity, inherited);
|
||||
|
||||
// dominant-baseline: enum, auto, inherit
|
||||
if (eCSSUnit_Enumerated == SVGData.mDominantBaseline.GetUnit()) {
|
||||
svgReset->mDominantBaseline = SVGData.mDominantBaseline.GetIntValue();
|
||||
|
|
|
@ -474,9 +474,6 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther)
|
|||
DO_STRUCT_DIFFERENCE(Table);
|
||||
DO_STRUCT_DIFFERENCE(Background);
|
||||
DO_STRUCT_DIFFERENCE(UIReset);
|
||||
#ifdef MOZ_SVG
|
||||
DO_STRUCT_DIFFERENCE(SVG);
|
||||
#endif
|
||||
// If the quotes implementation is ever going to change we might not need
|
||||
// a framechange here and a reflow should be sufficient. See bug 35768.
|
||||
DO_STRUCT_DIFFERENCE(Quotes);
|
||||
|
@ -504,6 +501,9 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther)
|
|||
// The following structs cause (as their maximal difference) a
|
||||
// re-render to occur. VISUAL Structs: Color
|
||||
DO_STRUCT_DIFFERENCE(Color);
|
||||
#ifdef MOZ_SVG
|
||||
DO_STRUCT_DIFFERENCE(SVG);
|
||||
#endif
|
||||
|
||||
#undef DO_STRUCT_DIFFERENCE
|
||||
|
||||
|
@ -853,19 +853,13 @@ void nsStyleContext::DumpRegressionData(nsPresContext* aPresContext, FILE* out,
|
|||
else
|
||||
fprintf(out, "%ld ", (long)svg->mFill.mPaint.mColor);
|
||||
|
||||
fprintf(out, "%d ", (int)svg->mStopColor.mType);
|
||||
if (svg->mStopColor.mType == eStyleSVGPaintType_Server)
|
||||
fprintf(out, "%s ", URICString(svg->mStopColor.mPaint.mPaintServer).get());
|
||||
else
|
||||
fprintf(out, "%ld ", (long)svg->mStopColor.mPaint.mColor);
|
||||
|
||||
fprintf(out, "%d ", (int)svg->mStroke.mType);
|
||||
if (svg->mStroke.mType == eStyleSVGPaintType_Server)
|
||||
fprintf(out, "%s ", URICString(svg->mStroke.mPaint.mPaintServer).get());
|
||||
else
|
||||
fprintf(out, "%ld ", (long)svg->mStroke.mPaint.mColor);
|
||||
|
||||
fprintf(out, "%s %s ",
|
||||
fprintf(out, "%s %s %s ",
|
||||
URICString(svg->mMarkerEnd).get(),
|
||||
URICString(svg->mMarkerMid).get(),
|
||||
URICString(svg->mMarkerStart).get());
|
||||
|
@ -876,9 +870,8 @@ void nsStyleContext::DumpRegressionData(nsPresContext* aPresContext, FILE* out,
|
|||
svg->mStrokeDasharray[i],
|
||||
(i == svg->mStrokeDasharrayLength) ? ' ' : ',');
|
||||
|
||||
fprintf(out, "%f %f %f %f %f %f %d %d %d %d %d %d %d %d %d\" />\n",
|
||||
fprintf(out, "%f %f %f %f %f %d %d %d %d %d %d %d %d %d\" />\n",
|
||||
svg->mFillOpacity,
|
||||
svg->mStopOpacity,
|
||||
svg->mStrokeDashoffset,
|
||||
svg->mStrokeMiterlimit,
|
||||
svg->mStrokeOpacity,
|
||||
|
@ -896,8 +889,17 @@ void nsStyleContext::DumpRegressionData(nsPresContext* aPresContext, FILE* out,
|
|||
// SVGReset
|
||||
IndentBy(out,aIndent);
|
||||
const nsStyleSVGReset* svgReset = GetStyleSVGReset();
|
||||
fprintf(out, "<svgreset data=\"%s %d\" />\n",
|
||||
|
||||
fprintf(out, "<svgreset data=\"%d ", (int)svgReset->mStopColor.mType);
|
||||
if (svgReset->mStopColor.mType == eStyleSVGPaintType_Server)
|
||||
fprintf(out, "%s ",
|
||||
URICString(svgReset->mStopColor.mPaint.mPaintServer).get());
|
||||
else
|
||||
fprintf(out, "%ld ", (long)svgReset->mStopColor.mPaint.mColor);
|
||||
|
||||
fprintf(out, "%s %f %d\" />\n",
|
||||
URICString(svgReset->mClipPath).get(),
|
||||
svgReset->mStopOpacity,
|
||||
(int)svgReset->mDominantBaseline);
|
||||
#endif
|
||||
//#insert new style structs here#
|
||||
|
|
|
@ -820,18 +820,16 @@ nsStyleSVG::nsStyleSVG()
|
|||
{
|
||||
mFill.mType = eStyleSVGPaintType_Color;
|
||||
mFill.mPaint.mColor = NS_RGB(0,0,0);
|
||||
mStopColor.mType = eStyleSVGPaintType_Color;
|
||||
mStopColor.mPaint.mColor = NS_RGB(0,0,0);
|
||||
mStroke.mType = eStyleSVGPaintType_None;
|
||||
mStroke.mPaint.mColor = NS_RGB(0,0,0);
|
||||
mStrokeDasharray = nsnull;
|
||||
|
||||
mStrokeDashoffset.SetFactorValue(0.0f);
|
||||
mStrokeWidth.SetFactorValue(1.0f);
|
||||
|
||||
mFillOpacity = 1.0f;
|
||||
mStopOpacity = 1.0f;
|
||||
mStrokeDashoffset = 0.0f;
|
||||
mStrokeMiterlimit = 4.0f;
|
||||
mStrokeOpacity = 1.0f;
|
||||
mStrokeWidth = 1.0f;
|
||||
|
||||
mStrokeDasharrayLength = 0;
|
||||
mClipRule = NS_STYLE_FILL_RULE_NONZERO;
|
||||
|
@ -854,7 +852,6 @@ nsStyleSVG::nsStyleSVG(const nsStyleSVG& aSource)
|
|||
//memcpy((nsStyleSVG*)this, &aSource, sizeof(nsStyleSVG));
|
||||
|
||||
mFill = aSource.mFill;
|
||||
mStopColor = aSource.mStopColor;
|
||||
mStroke = aSource.mStroke;
|
||||
|
||||
mMarkerEnd = aSource.mMarkerEnd;
|
||||
|
@ -863,23 +860,23 @@ nsStyleSVG::nsStyleSVG(const nsStyleSVG& aSource)
|
|||
|
||||
mStrokeDasharrayLength = aSource.mStrokeDasharrayLength;
|
||||
if (aSource.mStrokeDasharray) {
|
||||
mStrokeDasharray = new float[mStrokeDasharrayLength];
|
||||
mStrokeDasharray = new nsStyleCoord[mStrokeDasharrayLength];
|
||||
if (mStrokeDasharray)
|
||||
memcpy(mStrokeDasharray,
|
||||
aSource.mStrokeDasharray,
|
||||
mStrokeDasharrayLength * sizeof(float));
|
||||
mStrokeDasharrayLength * sizeof(nsStyleCoord));
|
||||
else
|
||||
mStrokeDasharrayLength = 0;
|
||||
} else {
|
||||
mStrokeDasharray = nsnull;
|
||||
}
|
||||
|
||||
mFillOpacity = aSource.mFillOpacity;
|
||||
mStopOpacity = aSource.mStopOpacity;
|
||||
mStrokeDashoffset = aSource.mStrokeDashoffset;
|
||||
mStrokeWidth = aSource.mStrokeWidth;
|
||||
|
||||
mFillOpacity = aSource.mFillOpacity;
|
||||
mStrokeMiterlimit = aSource.mStrokeMiterlimit;
|
||||
mStrokeOpacity = aSource.mStrokeOpacity;
|
||||
mStrokeWidth = aSource.mStrokeWidth;
|
||||
|
||||
mClipRule = aSource.mClipRule;
|
||||
mFillRule = aSource.mFillRule;
|
||||
|
@ -894,18 +891,18 @@ nsStyleSVG::nsStyleSVG(const nsStyleSVG& aSource)
|
|||
nsChangeHint nsStyleSVG::CalcDifference(const nsStyleSVG& aOther) const
|
||||
{
|
||||
if ( mFill != aOther.mFill ||
|
||||
mStopColor != aOther.mStopColor ||
|
||||
|
||||
mStroke != aOther.mStroke ||
|
||||
!EqualURIs(mMarkerEnd, aOther.mMarkerEnd) ||
|
||||
!EqualURIs(mMarkerMid, aOther.mMarkerMid) ||
|
||||
!EqualURIs(mMarkerStart, aOther.mMarkerStart) ||
|
||||
|
||||
mFillOpacity != aOther.mFillOpacity ||
|
||||
mStopOpacity != aOther.mStopOpacity ||
|
||||
mStrokeDashoffset != aOther.mStrokeDashoffset ||
|
||||
mStrokeWidth != aOther.mStrokeWidth ||
|
||||
|
||||
mFillOpacity != aOther.mFillOpacity ||
|
||||
mStrokeMiterlimit != aOther.mStrokeMiterlimit ||
|
||||
mStrokeOpacity != aOther.mStrokeOpacity ||
|
||||
mStrokeWidth != aOther.mStrokeWidth ||
|
||||
|
||||
mClipRule != aOther.mClipRule ||
|
||||
mFillRule != aOther.mFillRule ||
|
||||
|
@ -918,6 +915,7 @@ nsChangeHint nsStyleSVG::CalcDifference(const nsStyleSVG& aOther) const
|
|||
mTextRendering != aOther.mTextRendering)
|
||||
return NS_STYLE_HINT_VISUAL;
|
||||
|
||||
// length of stroke dasharrays are the same (tested above) - check entries
|
||||
for (PRUint32 i=0; i<mStrokeDasharrayLength; i++)
|
||||
if (mStrokeDasharray[i] != aOther.mStrokeDasharray[i])
|
||||
return NS_STYLE_HINT_VISUAL;
|
||||
|
@ -938,8 +936,11 @@ nsChangeHint nsStyleSVG::MaxDifference()
|
|||
//
|
||||
nsStyleSVGReset::nsStyleSVGReset()
|
||||
{
|
||||
mClipPath = nsnull;
|
||||
mDominantBaseline = NS_STYLE_DOMINANT_BASELINE_AUTO;
|
||||
mStopColor.mType = eStyleSVGPaintType_Color;
|
||||
mStopColor.mPaint.mColor = NS_RGB(0,0,0);
|
||||
mClipPath = nsnull;
|
||||
mStopOpacity = 1.0f;
|
||||
mDominantBaseline = NS_STYLE_DOMINANT_BASELINE_AUTO;
|
||||
}
|
||||
|
||||
nsStyleSVGReset::~nsStyleSVGReset()
|
||||
|
@ -948,13 +949,17 @@ nsStyleSVGReset::~nsStyleSVGReset()
|
|||
|
||||
nsStyleSVGReset::nsStyleSVGReset(const nsStyleSVGReset& aSource)
|
||||
{
|
||||
mStopColor = aSource.mStopColor;
|
||||
mClipPath = aSource.mClipPath;
|
||||
mStopOpacity = aSource.mStopOpacity;
|
||||
mDominantBaseline = aSource.mDominantBaseline;
|
||||
}
|
||||
|
||||
nsChangeHint nsStyleSVGReset::CalcDifference(const nsStyleSVGReset& aOther) const
|
||||
{
|
||||
if (!EqualURIs(mClipPath, aOther.mClipPath) ||
|
||||
if (mStopColor != aOther.mStopColor ||
|
||||
!EqualURIs(mClipPath, aOther.mClipPath) ||
|
||||
mStopOpacity != aOther.mStopOpacity ||
|
||||
mDominantBaseline != aOther.mDominantBaseline)
|
||||
return NS_STYLE_HINT_VISUAL;
|
||||
|
||||
|
@ -992,9 +997,10 @@ PRBool nsStyleSVGPaint::operator==(const nsStyleSVGPaint& aOther) const
|
|||
{
|
||||
if (mType != aOther.mType)
|
||||
return PR_FALSE;
|
||||
if (mType == eStyleSVGPaintType_Server) {
|
||||
if (mType == eStyleSVGPaintType_Server)
|
||||
return EqualURIs(mPaint.mPaintServer, aOther.mPaint.mPaintServer);
|
||||
}
|
||||
if (mType == eStyleSVGPaintType_None)
|
||||
return PR_TRUE;
|
||||
return mPaint.mColor == aOther.mPaint.mColor;
|
||||
}
|
||||
|
||||
|
|
|
@ -1245,19 +1245,18 @@ struct nsStyleSVG : public nsStyleStruct {
|
|||
#endif
|
||||
|
||||
nsStyleSVGPaint mFill; // [inherited]
|
||||
nsStyleSVGPaint mStopColor; // [inherited]
|
||||
nsStyleSVGPaint mStroke; // [inherited]
|
||||
nsCOMPtr<nsIURI> mMarkerEnd; // [inherited]
|
||||
nsCOMPtr<nsIURI> mMarkerMid; // [inherited]
|
||||
nsCOMPtr<nsIURI> mMarkerStart; // [inherited]
|
||||
float *mStrokeDasharray; // [inherited]
|
||||
nsStyleCoord *mStrokeDasharray; // [inherited]
|
||||
|
||||
nsStyleCoord mStrokeDashoffset; // [inherited]
|
||||
nsStyleCoord mStrokeWidth; // [inherited]
|
||||
|
||||
float mFillOpacity; // [inherited]
|
||||
float mStopOpacity; // [inherited]
|
||||
float mStrokeDashoffset; // [inherited]
|
||||
float mStrokeMiterlimit; // [inherited]
|
||||
float mStrokeOpacity; // [inherited]
|
||||
float mStrokeWidth; // [inherited] in pixels
|
||||
|
||||
PRUint32 mStrokeDasharrayLength;
|
||||
PRUint8 mClipRule; // [inherited]
|
||||
|
@ -1290,7 +1289,9 @@ struct nsStyleSVGReset : public nsStyleStruct {
|
|||
static nsChangeHint MaxDifference();
|
||||
#endif
|
||||
|
||||
nsStyleSVGPaint mStopColor; // [reset]
|
||||
nsCOMPtr<nsIURI> mClipPath; // [reset]
|
||||
float mStopOpacity; // [reset]
|
||||
PRUint8 mDominantBaseline; // [reset] see nsStyleConsts.h
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -89,6 +89,7 @@ CPPSRCS = \
|
|||
nsSVGTSpanFrame.cpp \
|
||||
nsSVGTextFrame.cpp \
|
||||
nsSVGUseFrame.cpp \
|
||||
nsSVGUtils.cpp \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#include "nsINameSpaceManager.h"
|
||||
#include "nsContainerFrame.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsSVGUtils.h"
|
||||
|
||||
typedef nsFrame nsSVGGlyphFrameBase;
|
||||
|
||||
|
@ -645,7 +646,9 @@ nsSVGGlyphFrame::GetStrokeOpacity(float *aStrokeOpacity)
|
|||
NS_IMETHODIMP
|
||||
nsSVGGlyphFrame::GetStrokeWidth(float *aStrokeWidth)
|
||||
{
|
||||
*aStrokeWidth = GetStyleSVG()->mStrokeWidth;
|
||||
*aStrokeWidth =
|
||||
nsSVGUtils::CoordToFloat(nsSVGGlyphFrameBase::GetPresContext(),
|
||||
mContent, GetStyleSVG()->mStrokeWidth);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -653,15 +656,17 @@ nsSVGGlyphFrame::GetStrokeWidth(float *aStrokeWidth)
|
|||
NS_IMETHODIMP
|
||||
nsSVGGlyphFrame::GetStrokeDashArray(float **arr, PRUint32 *count)
|
||||
{
|
||||
const nsStyleSVG *svg = GetStyleSVG();
|
||||
const nsStyleCoord *dasharray = GetStyleSVG()->mStrokeDasharray;
|
||||
nsPresContext *presContext = nsSVGGlyphFrameBase::GetPresContext();
|
||||
|
||||
*count = svg->mStrokeDasharrayLength;
|
||||
*count = GetStyleSVG()->mStrokeDasharrayLength;
|
||||
|
||||
if (*count) {
|
||||
*arr = (float *) nsMemory::Alloc(*count * sizeof(float));
|
||||
if (*arr)
|
||||
memcpy(*arr, svg->mStrokeDasharray, *count * sizeof(float));
|
||||
else {
|
||||
if (*arr) {
|
||||
for (PRUint32 i = 0; i < *count; i++)
|
||||
(*arr)[i] = nsSVGUtils::CoordToFloat(presContext, mContent, dasharray[i]);
|
||||
} else {
|
||||
*count = 0;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -674,7 +679,9 @@ nsSVGGlyphFrame::GetStrokeDashArray(float **arr, PRUint32 *count)
|
|||
NS_IMETHODIMP
|
||||
nsSVGGlyphFrame::GetStrokeDashoffset(float *aStrokeDashoffset)
|
||||
{
|
||||
*aStrokeDashoffset = GetStyleSVG()->mStrokeDashoffset;
|
||||
*aStrokeDashoffset =
|
||||
nsSVGUtils::CoordToFloat(nsSVGGlyphFrameBase::GetPresContext(),
|
||||
mContent, GetStyleSVG()->mStrokeDashoffset);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -388,7 +388,7 @@ nsSVGGradientFrame::GetStopColorType(PRInt32 aIndex, PRUint16 *aStopColorType)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aStopColorType = stopFrame->GetStyleSVG()->mStopColor.mType;
|
||||
*aStopColorType = stopFrame->GetStyleSVGReset()->mStopColor.mType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ nsSVGGradientFrame::GetStopColor(PRInt32 aIndex, nscolor *aStopColor)
|
|||
*aStopColor = 0;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
*aStopColor = stopFrame->GetStyleSVG()->mStopColor.mPaint.mColor;
|
||||
*aStopColor = stopFrame->GetStyleSVGReset()->mStopColor.mPaint.mColor;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,7 @@ nsSVGGradientFrame::GetStopOpacity(PRInt32 aIndex, float *aStopOpacity)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aStopOpacity = stopFrame->GetStyleSVG()->mStopOpacity;
|
||||
*aStopOpacity = stopFrame->GetStyleSVGReset()->mStopOpacity;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "nsISVGRendererCanvas.h"
|
||||
#include "nsSVGAtoms.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsSVGUtils.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsSVGPathGeometryFrame
|
||||
|
@ -523,7 +524,9 @@ nsSVGPathGeometryFrame::GetStrokeOpacity(float *aStrokeOpacity)
|
|||
NS_IMETHODIMP
|
||||
nsSVGPathGeometryFrame::GetStrokeWidth(float *aStrokeWidth)
|
||||
{
|
||||
*aStrokeWidth = GetStyleSVG()->mStrokeWidth;
|
||||
*aStrokeWidth =
|
||||
nsSVGUtils::CoordToFloat(nsSVGPathGeometryFrameBase::GetPresContext(),
|
||||
mContent, GetStyleSVG()->mStrokeWidth);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -531,15 +534,17 @@ nsSVGPathGeometryFrame::GetStrokeWidth(float *aStrokeWidth)
|
|||
NS_IMETHODIMP
|
||||
nsSVGPathGeometryFrame::GetStrokeDashArray(float **arr, PRUint32 *count)
|
||||
{
|
||||
const nsStyleSVG *svg = GetStyleSVG();
|
||||
const nsStyleCoord *dasharray = GetStyleSVG()->mStrokeDasharray;
|
||||
nsPresContext *presContext = nsSVGPathGeometryFrameBase::GetPresContext();
|
||||
|
||||
*count = svg->mStrokeDasharrayLength;
|
||||
*count = GetStyleSVG()->mStrokeDasharrayLength;
|
||||
|
||||
if (*count) {
|
||||
*arr = (float *) nsMemory::Alloc(*count * sizeof(float));
|
||||
if (*arr)
|
||||
memcpy(*arr, svg->mStrokeDasharray, *count * sizeof(float));
|
||||
else {
|
||||
if (*arr) {
|
||||
for (PRUint32 i = 0; i < *count; i++)
|
||||
(*arr)[i] = nsSVGUtils::CoordToFloat(presContext, mContent, dasharray[i]);
|
||||
} else {
|
||||
*count = 0;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -552,7 +557,9 @@ nsSVGPathGeometryFrame::GetStrokeDashArray(float **arr, PRUint32 *count)
|
|||
NS_IMETHODIMP
|
||||
nsSVGPathGeometryFrame::GetStrokeDashoffset(float *aStrokeDashoffset)
|
||||
{
|
||||
*aStrokeDashoffset = GetStyleSVG()->mStrokeDashoffset;
|
||||
*aStrokeDashoffset =
|
||||
nsSVGUtils::CoordToFloat(nsSVGPathGeometryFrameBase::GetPresContext(),
|
||||
mContent, GetStyleSVG()->mStrokeDashoffset);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSVGLength.h"
|
||||
#include "nsIDOMSVGElement.h"
|
||||
#include "nsIDOMSVGSVGElement.h"
|
||||
#include "nsStyleCoord.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsSVGCoordCtxProvider.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsSVGUtils.h"
|
||||
|
||||
float
|
||||
nsSVGUtils::CoordToFloat(nsPresContext *aPresContext, nsIContent *aContent,
|
||||
const nsStyleCoord &aCoord)
|
||||
{
|
||||
float val = 0.0f;
|
||||
|
||||
switch (aCoord.GetUnit()) {
|
||||
case eStyleUnit_Factor:
|
||||
// user units
|
||||
val = aCoord.GetFactorValue();
|
||||
break;
|
||||
|
||||
case eStyleUnit_Coord:
|
||||
val = aCoord.GetCoordValue() / aPresContext->ScaledPixelsToTwips();
|
||||
break;
|
||||
|
||||
case eStyleUnit_Percent: {
|
||||
nsCOMPtr<nsIDOMSVGElement> element = do_QueryInterface(aContent);
|
||||
nsCOMPtr<nsIDOMSVGSVGElement> owner;
|
||||
element->GetOwnerSVGElement(getter_AddRefs(owner));
|
||||
nsCOMPtr<nsSVGCoordCtxProvider> ctx = do_QueryInterface(owner);
|
||||
|
||||
nsCOMPtr<nsISVGLength> length;
|
||||
NS_NewSVGLength(getter_AddRefs(length), aCoord.GetPercentValue() * 100.0f,
|
||||
nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE);
|
||||
|
||||
if (!ctx || !length)
|
||||
break;
|
||||
|
||||
length->SetContext(nsRefPtr<nsSVGCoordCtx>(ctx->GetContextUnspecified()));
|
||||
length->GetValue(&val);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla SVG project.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef NS_SVGUTILS_H
|
||||
#define NS_SVGUTILS_H
|
||||
|
||||
class nsPresContext;
|
||||
class nsIContent;
|
||||
class nsStyleCoord;
|
||||
|
||||
class nsSVGUtils
|
||||
{
|
||||
public:
|
||||
/*
|
||||
* Converts a nsStyleCoord into a userspace value. Handles units
|
||||
* Factor (straight userspace), Coord (dimensioned), and Percent (of
|
||||
* the current SVG viewport)
|
||||
*/
|
||||
static float CoordToFloat(nsPresContext *aPresContext, nsIContent *aContent,
|
||||
const nsStyleCoord &aCoord);
|
||||
};
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче