[Webkit-unassigned] [Bug 67652] Negative width/height values not always treated properly by 2D canvas drawImage

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Jun 30 07:51:12 PDT 2013


https://bugs.webkit.org/show_bug.cgi?id=67652





--- Comment #16 from Dirk Schulze <krit at webkit.org>  2013-06-30 07:53:07 PST ---
(From update of attachment 205773)
View in context: https://bugs.webkit.org/attachment.cgi?id=205773&action=review

> Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp:120
> +static bool clipRectangles(FloatRect& imageRect, FloatRect& normalizedSrcRect, FloatRect& normalizedDstRect)
> +{
> +    if (normalizedSrcRect.x() < imageRect.x()) {
> +        float clipRatio = (imageRect.x() - normalizedSrcRect.x()) / normalizedSrcRect.width();
> +        if (clipRatio >= 1)
> +            return false;
> +        normalizedDstRect.setX(normalizedDstRect.x() + (clipRatio * normalizedDstRect.width()));
> +        normalizedDstRect.setWidth(normalizedDstRect.width() - (clipRatio * normalizedDstRect.width()));
> +        normalizedSrcRect.setWidth(normalizedSrcRect.width() - (clipRatio * normalizedSrcRect.width()));
> +        normalizedSrcRect.setX(imageRect.x());
> +    }
> +    if ((normalizedSrcRect.x() + normalizedSrcRect.width())  > (imageRect.x() + imageRect.width())) {
> +        float clipRatio = (normalizedSrcRect.width() - (imageRect.x() + imageRect.width() - normalizedSrcRect.x())) / normalizedSrcRect.width();
> +        if (clipRatio >= 1)
> +            return false;
> +        normalizedDstRect.setWidth(normalizedDstRect.width() - (clipRatio * normalizedDstRect.width()));
> +        normalizedSrcRect.setWidth(normalizedSrcRect.width() - (clipRatio * normalizedSrcRect.width()));
> +    }
> +    if (normalizedSrcRect.y() < imageRect.y()) {
> +        float clipRatio = (imageRect.y() - normalizedSrcRect.y()) / normalizedSrcRect.height();
> +        if (clipRatio >= 1)
> +            return false;
> +        normalizedDstRect.setY(normalizedDstRect.y() + (clipRatio * normalizedDstRect.height()));
> +        normalizedDstRect.setHeight(normalizedDstRect.height() - (clipRatio * normalizedDstRect.height()));
> +        normalizedSrcRect.setHeight(normalizedSrcRect.height() - (clipRatio * normalizedSrcRect.height()));
> +        normalizedSrcRect.setY(imageRect.y());
> +    }
> +    if ((normalizedSrcRect.y() + normalizedSrcRect.height())  > (imageRect.y() + imageRect.height())) {
> +        float clipRatio = (normalizedSrcRect.height() - (imageRect.y() + imageRect.height() - normalizedSrcRect.y())) / normalizedSrcRect.height();
> +        if (clipRatio >= 1)
> +            return false;
> +        normalizedDstRect.setHeight(normalizedDstRect.height() - (clipRatio * normalizedDstRect.height()));
> +        normalizedSrcRect.setHeight(normalizedSrcRect.height() - (clipRatio * normalizedSrcRect.height()));
> +    }
> +    return true;
> +}

This looks like a lot of source code for such a short sentence :P I don't understand the intention yet. What exactly do you want to do here? Can you upload and attach an example to the bug report? I do not understand why Canvas is working correctly according to comment #1 but other sources are not. Where is the difference? Where do we do something different?

Would be great if you can attach an example and also give feedback how other browsers behave here.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list