+2006-12-26 Eric Seidel <eric@webkit.org>
+
+ Reviewed by rwlbuis.
+
+ Updated tests (and test results) after fixing:
+ WebKit does not respect boundingbox percentages larger than 100%
+ http://bugs.webkit.org/show_bug.cgi?id=11973
+
+ * svg/custom/js-late-gradient-and-object-creation-expected.checksum:
+ * svg/custom/js-late-gradient-and-object-creation-expected.png:
+ * svg/custom/js-late-gradient-and-object-creation-expected.txt:
+ * svg/custom/js-late-gradient-and-object-creation.svg:
+ * svg/custom/js-late-gradient-creation-expected.checksum:
+ * svg/custom/js-late-gradient-creation-expected.png:
+ * svg/custom/js-late-gradient-creation-expected.txt:
+ * svg/custom/js-late-gradient-creation.svg:
+ * svg/custom/large-bounding-box-percents-expected.checksum: Added.
+ * svg/custom/large-bounding-box-percents-expected.png: Added.
+ * svg/custom/large-bounding-box-percents-expected.txt: Added.
+ * svg/custom/large-bounding-box-percents.svg: Added.
+
2006-12-26 Nikolas Zimmermann <zimmermann@kde.org>
Reviewed by Oliver.
-1d6f00f06bf2678713807225983e4ce2
\ No newline at end of file
+d48e9aada5dbc9b9a4a2d5a27c1de4b7
\ No newline at end of file
-KRenderingPaintServer {id="fillLinearGradient" [type=LINEAR-GRADIENT] [stops=[(0.00,#0000FF), (1.00,#FF0000)]] [start=(10,10)] [end=(440,0)]}
-KRenderingPaintServer {id="strokeLinearGradient" [type=LINEAR-GRADIENT] [stops=[(1.00,#008000)]] [start=(10,10)] [end=(440,0)]}
+KRenderingPaintServer {id="fillLinearGradient" [type=LINEAR-GRADIENT] [stops=[(0.00,#0000FF), (1.00,#FF0000)]] [start=(0,0)] [end=(100,0)]}
+KRenderingPaintServer {id="strokeLinearGradient" [type=LINEAR-GRADIENT] [stops=[(1.00,#008000)]] [start=(0,0)] [end=(100,0)]}
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
RenderSVGContainer {svg} at (-250,15) size 1008.33x363.33
// Setup "fillLinearGradient"
var gradient1 = document.createElement("linearGradient");
gradient1.setAttribute("id", "fillLinearGradient");
- gradient1.setAttribute("x1", "10");
- gradient1.setAttribute("y1", "10");
- gradient1.setAttribute("x2", "440");
- gradient1.setAttribute("xy", "10");
+ gradient1.setAttribute("x1", "0");
+ gradient1.setAttribute("x2", "1");
var stop11 = document.createElement("stop");
stop11.setAttribute("stop-color", "blue");
// Setup "strokeLinearGradient"
var gradient2 = document.createElement("linearGradient");
gradient2.setAttribute("id", "strokeLinearGradient");
- gradient2.setAttribute("x1", "10");
- gradient2.setAttribute("y1", "10");
- gradient2.setAttribute("x2", "440");
- gradient2.setAttribute("xy", "10");
+ gradient2.setAttribute("x1", "0");
+ gradient2.setAttribute("x2", "1");
var stop22 = document.createElement("stop");
stop22.setAttribute("stop-color", "yellow");
-ce98110035a3e810643a85660f989bf6
\ No newline at end of file
+23d2f1db55637003a57f111d6e057472
\ No newline at end of file
-KRenderingPaintServer {id="dynGrad" [type=LINEAR-GRADIENT] [stops=[(0.00,#0000FF), (1.00,#FF0000)]] [start=(10,10)] [end=(440,0)]}
+KRenderingPaintServer {id="dynGrad" [type=LINEAR-GRADIENT] [stops=[(0.00,#0000FF), (1.00,#FF0000)]] [start=(0,0)] [end=(100,0)]}
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
RenderSVGContainer {svg} at (33.33,22.50) size 700x195
{
var gradient = document.createElement("linearGradient");
gradient.setAttribute("id", "dynGrad");
- gradient.setAttribute("x1", "10");
- gradient.setAttribute("y1", "10");
- gradient.setAttribute("x2", "440");
- gradient.setAttribute("xy", "10");
+ gradient.setAttribute("x1", "0");
+ gradient.setAttribute("x2", "1");
var stop1 = document.createElement("stop");
stop1.setAttribute("stop-color", "blue");
--- /dev/null
+ab26223b261bf32598417729f5423581
\ No newline at end of file
--- /dev/null
+KRenderingPaintServer {id="myradial" [type=RADIAL-GRADIENT] [stops=[(0.00,#008000), (1.00,#FF0000)]] [center=(50,50)] [focal=(50,50)] [radius=500.00]}
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+ RenderSVGContainer {svg} at (0,0) size 100x100
+ RenderPath {rect} at (0,0) size 100x100 [fill={[type=RADIAL-GRADIENT] [stops=[(0.00,#008000), (1.00,#FF0000)]] [center=(50,50)] [focal=(50,50)] [radius=500.00]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"]
--- /dev/null
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <radialGradient id="myradial" r="5">
+ <stop offset="0" style="stop-color: green"/>
+ <stop offset="1" style="stop-color: red"/>
+ </radialGradient>
+ <rect x='0' y='0' width='100' height='100' style="fill:url(#myradial)"/>
+</svg>
+2006-12-26 Eric Seidel <eric@webkit.org>
+
+ Reviewed by rwlbuis.
+
+ Replace bogus SVGLength::isFraction() method with valueAsPercentage() to fix:
+ http://bugs.webkit.org/show_bug.cgi?id=11973
+
+ * ksvg2/svg/SVGLength.cpp:
+ (WebCore::SVGLength::valueInSpecifiedUnits): remove extra spaces
+ (WebCore::SVGLength::valueAsPercentage): new method
+ * ksvg2/svg/SVGLength.h:
+ * ksvg2/svg/SVGLinearGradientElement.cpp:
+ (WebCore::SVGLinearGradientElement::buildGradient): use valueAsPercentage()
+ * ksvg2/svg/SVGPatternElement.cpp:
+ (WebCore::SVGPatternElement::drawPatternContentIntoTile): return if malloc fails
+ * ksvg2/svg/SVGRadialGradientElement.cpp:
+ (WebCore::SVGRadialGradientElement::buildGradient): use valueAsPercentage()
+ * platform/graphics/cg/GraphicsContextCG.cpp:
+ (WebCore::GraphicsContext::createImageBuffer): return 0 if malloc fails
+ * platform/graphics/svg/cg/SVGPaintServerGradientCg.cpp:
+ (WebCore::SVGPaintServerGradient::setup): return if malloc fails
+ * platform/graphics/svg/cg/SVGResourceMaskerCg.mm:
+ (WebCore::SVGResourceMasker::applyMask): add comment about possible crash
+
2006-12-26 Nikolas Zimmermann <zimmermann@kde.org>
Reviewed by Oliver.
float SVGLength::valueInSpecifiedUnits() const
{
return m_valueInSpecifiedUnits;
-}
+}
+
+float SVGLength::valueAsPercentage() const
+{
+ // 100% = 100.0 instead of 1.0 for historical reasons, this could eventually be changed
+ if (extractType(m_unit) == LengthTypePercentage)
+ return valueInSpecifiedUnits();
+ return valueInSpecifiedUnits() * 100.f;
+}
void SVGLength::setValueAsString(const String& s)
{
setValue(valueInUserUnits);
}
-bool SVGLength::isFraction(const SVGLength& length)
-{
- return (length.unitType() == LengthTypeNumber && length.value() >= 0 && length.value() <= 1);
-}
-
double SVGLength::dpi() const
{
/* FIXME: DPI detection
float valueInSpecifiedUnits() const;
void setValueInSpecifiedUnits(float);
+
+ float valueAsPercentage() const;
String valueAsString() const;
void setValueAsString(const String&);
void convertToSpecifiedUnits(unsigned short);
// Helper functions
- static bool isFraction(const SVGLength&);
static float PercentageOfViewport(float value, const SVGStyledElement*, SVGLengthMode);
private:
float _x1, _y1, _x2, _y2;
if (bbox) {
- _x1 = x1().valueInSpecifiedUnits();
- if (SVGLength::isFraction(x1()))
- _x1 *= 100.0;
-
- _y1 = y1().valueInSpecifiedUnits();
- if (SVGLength::isFraction(y1()))
- _y1 *= 100.0;
-
- _x2 = x2().valueInSpecifiedUnits();
- if (SVGLength::isFraction(x2()))
- _x2 *= 100.0;
-
- _y2 = y2().valueInSpecifiedUnits();
- if (SVGLength::isFraction(y2()))
- _y2 *= 100.0;
+ _x1 = x1().valueAsPercentage();
+ _y1 = y1().valueAsPercentage();
+ _x2 = x2().valueAsPercentage();
+ _y2 = y2().valueAsPercentage();
} else {
_x1 = x1().value();
_y1 = y1().value();
if (gradientTransform()->numberOfItems() > 0)
mat = gradientTransform()->consolidate()->matrix();
- DeprecatedString ref = href().deprecatedString();
- RefPtr<SVGPaintServer> pserver = getPaintServerById(document(), ref.mid(1));
+ RefPtr<SVGPaintServer> pserver = getPaintServerById(document(), href().substring(1));
if (pserver && (pserver->type() == RadialGradientPaintServer || pserver->type() == LinearGradientPaintServer)) {
bool isLinear = pserver->type() == LinearGradientPaintServer;
float _x, _y, w, h;
if (bbox) {
- _x = x().valueInSpecifiedUnits();
- if (SVGLength::isFraction(x()))
- _x *= 100.0;
-
- _y = y().valueInSpecifiedUnits();
- if (SVGLength::isFraction(y()))
- _y *= 100.0;
-
- w = width().valueInSpecifiedUnits();
- if (SVGLength::isFraction(width()))
- w *= 100.0;
-
- h = height().valueInSpecifiedUnits();
- if (SVGLength::isFraction(height()))
- h *= 100.0;
+ _x = x().valueAsPercentage();
+ _y = y().valueAsPercentage();
+ w = width().valueAsPercentage();
+ h = height().valueAsPercentage();
} else {
_x = x().value();
_y = y().value();
h = height().value();
}
- ImageBuffer* patternImage(GraphicsContext::createImageBuffer(IntSize(lroundf(w), lroundf(h)), false));
+ ImageBuffer* patternImage = GraphicsContext::createImageBuffer(IntSize(lroundf(w), lroundf(h)), false);
if (!patternImage)
return;
float _cx, _cy, _r, _fx, _fy;
if (bbox) {
- _cx = cx().valueInSpecifiedUnits();
- if (SVGLength::isFraction(cx()))
- _cx *= 100.0;
-
- _cy = cy().valueInSpecifiedUnits();
- if (SVGLength::isFraction(cy()))
- _cy *= 100.0;
-
- _r = r().valueInSpecifiedUnits();
- if (SVGLength::isFraction(r()))
- _r *= 100.0;
-
- if (fxSet) {
- _fx = fx().valueInSpecifiedUnits();
- if (SVGLength::isFraction(fx()))
- _fx *= 100.0;
- } else
- _fx = _cx;
-
- if (fySet) {
- _fy = fy().valueInSpecifiedUnits();
- if (SVGLength::isFraction(fy()))
- _fy *= 100.0;
- } else
- _fy = _cy;
+ _cx = cx().valueAsPercentage();
+ _cy = cy().valueAsPercentage();
+ _r = r().valueAsPercentage();
+ _fx = fxSet ? (fx().valueAsPercentage()) : _cx;
+ _fy = fySet ? (fy().valueAsPercentage()) : _cy;
} else {
_cx = cx().value();
_cy = cy().value();
if (gradientTransform()->numberOfItems() > 0)
mat = gradientTransform()->consolidate()->matrix();
- DeprecatedString ref = href().deprecatedString();
- RefPtr<SVGPaintServer> pserver = getPaintServerById(document(), ref.mid(1));
+ RefPtr<SVGPaintServer> pserver = getPaintServerById(document(), href().substring(1));
if (pserver && (pserver->type() == RadialGradientPaintServer || pserver->type() == LinearGradientPaintServer)) {
bool isRadial = pserver->type() == RadialGradientPaintServer;
bytesPerRow *= 4;
void* imageBuffer = fastMalloc(bytesPerRow * size.height());
+ if (!imageBuffer)
+ return 0;
memset(imageBuffer, 0, bytesPerRow * size.height());
CGColorSpaceRef colorSpace = grayScale ? CGColorSpaceCreateDeviceGray() : CGColorSpaceCreateDeviceRGB();
IntRect maskRect = const_cast<RenderObject*>(object)->absoluteBoundingBoxRect();
maskRect = object->absoluteTransform().inverse().mapRect(maskRect);
- ImageBuffer* maskImage(GraphicsContext::createImageBuffer(IntSize(maskRect.width(), maskRect.height()), false));
+ ImageBuffer* maskImage = GraphicsContext::createImageBuffer(IntSize(maskRect.width(), maskRect.height()), false);
+ // FIXME: maskImage could be NULL
GraphicsContext* maskImageContext = maskImage->context();
maskImageContext->save();
// Create new graphics context in gray scale mode for image rendering
OwnPtr<ImageBuffer> grayScaleImage(GraphicsContext::createImageBuffer(maskSize, true));
+ if (!grayScaleImage)
+ return;
CGContextRef grayScaleContext = grayScaleImage->context()->platformContext();
// Wrap CG context in CI context