private double GetCoordinateForObjectBoundingBox(String attributeName, double defaultValue) { String attributeValue = GetAttribute(attributeName); double absoluteValue = defaultValue; if (CssUtils.IsPercentageValue(attributeValue)) { absoluteValue = CssUtils.ParseRelativeValue(attributeValue, 1); } else { if (CssUtils.IsNumericValue(attributeValue) || CssUtils.IsMetricValue(attributeValue) || CssUtils.IsRelativeValue (attributeValue)) { // if there is incorrect value metric, then we do not need to parse the value int unitsPosition = CssUtils.DeterminePositionBetweenValueAndUnit(attributeValue); if (unitsPosition > 0) { // We want to ignore the unit type. From the svg specification: // "the normal of the linear gradient is perpendicular to the gradient vector in // object bounding box space (i.e., the abstract coordinate system where (0,0) // is at the top/left of the object bounding box and (1,1) is at the bottom/right // of the object bounding box)". // Different browsers treats this differently. We chose the "Google Chrome" approach // which treats the "abstract coordinate system" in the coordinate metric measure, // i.e. for value '0.5cm' the top/left of the object bounding box would be (1cm, 1cm), // for value '0.5em' the top/left of the object bounding box would be (1em, 1em) and etc. // no null pointer should be thrown as determine absoluteValue = CssUtils.ParseDouble(attributeValue.JSubstring(0, unitsPosition)).Value; } } } // need to multiply by 0.75 as further the (top, right) coordinates of the object bbox // would be transformed into (0.75, 0.75) point instead of (1, 1). The reason described // as a comment inside the method constructing the gradient transformation return(absoluteValue * 0.75); }