WebCore:
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Mar 2008 03:08:48 +0000 (03:08 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Mar 2008 03:08:48 +0000 (03:08 +0000)
commitcaea3f8ffd689ddb0b5506cc2ffd1061cf085f0f
tree449452a986f7e14b99b316104ab7d8711122fec1
parent434a91a224be01989bf8f7ceb877cf572fbe16c4
WebCore:

        Reviewed by Oliver Hunt.

        Fix for http://bugs.webkit.org/show_bug.cgi?id=16673
        <canvas> lacks toDataURL()

        Tests: fast/canvas/toDataURL-noData.html
               fast/canvas/toDataURL-supportedTypes.html

        * html/CanvasRenderingContext2D.cpp:
        (WebCore::CanvasRenderingContext2D::printSecurityExceptionMessage): Make message non-global.
        * html/HTMLCanvasElement.cpp:
        (WebCore::HTMLCanvasElement::printSecurityExceptionMessage): Log error message indicating that toDataURL has
        been called on a tainted canvas.
        (WebCore::HTMLCanvasElement::toDataURL): This does the tainted canvas check, ensures that the canvas has pixel
        data, checks to see if the MIME type is supported.  Unsupported MIME types and the null string (which is made
        by passing no argument/null/undefined in JavaScript) are treated as being PNG, as per the spec.  The actual
        toDataURL logic is actually done in the ImageBuffer class.
        * html/HTMLCanvasElement.h: Add function declarations.
        * html/HTMLCanvasElement.idl: Add function declaration.

        * platform/MIMETypeRegistry.cpp:
        (WebCore::initializeSupportedImageMIMETypes):
        (WebCore::initializeSupportedImageMIMETypesForEncoding):
        (WebCore::initializeSupportedJavaScriptMIMETypes):
        (WebCore::initializeSupportedNonImageMimeTypes):
        (WebCore::initializeSupportedMediaMIMETypes):
        (WebCore::initializeMIMETypeRegistry):
        (WebCore::MIMETypeRegistry::getMIMETypeForPath):
        (WebCore::MIMETypeRegistry::isSupportedImageMIMEType):
        (WebCore::MIMETypeRegistry::isSupportedImageResourceMIMEType):
        (WebCore::MIMETypeRegistry::isSupportedImageMIMETypeForEncoding):
        (WebCore::MIMETypeRegistry::isSupportedJavaScriptMIMEType):
        (WebCore::MIMETypeRegistry::isSupportedNonImageMIMEType):
        (WebCore::MIMETypeRegistry::isSupportedMediaMIMEType):
        (WebCore::MIMETypeRegistry::isJavaAppletMIMEType):
        (WebCore::MIMETypeRegistry::getSupportedImageMIMETypes):
        (WebCore::MIMETypeRegistry::getSupportedImageResourceMIMETypes):
        (WebCore::MIMETypeRegistry::getSupportedImageMIMETypesForEncoding):
        (WebCore::MIMETypeRegistry::getSupportedNonImageMIMETypes):
        (WebCore::MIMETypeRegistry::getSupportedMediaMIMETypes):
        * platform/MIMETypeRegistry.h:
        Clean up and add new supportedImageMIMETypesForEncoding set which contains the set of
        MIME types the platform knows how to encode. Currently only implemented for CG and Qt.

        * platform/graphics/ImageBuffer.h: Add toDataURL method.
        * platform/graphics/cairo/ImageBufferCairo.cpp:
        (WebCore::ImageBuffer::toDataURL): Add stub.
        * platform/graphics/cg/ImageBufferCG.cpp:
        (WebCore::ImageBuffer::create):
        (WebCore::ImageBuffer::getImageData):
        (WebCore::ImageBuffer::putImageData):
        (WebCore::ImageBuffer::toDataURL):
        Converts the current context to a data: url of the specified MIME type.  This method
        unfortunately has to flip the context, resulting in less than optimal code.

        * platform/graphics/qt/ImageBufferQt.cpp:
        (WebCore::ImageBuffer::toDataURL): Add stub.
        * platform/graphics/wx/ImageBufferWx.cpp:
        (WebCore::ImageBuffer::toDataURL): Add stub.

LayoutTests:

        Reviewed by Oliver Hunt.

        Tests for http://bugs.webkit.org/show_bug.cgi?id=16673
        <canvas> lacks toDataURL()

        * fast/canvas/toDataURL-noData-expected.txt: Added.
        * fast/canvas/toDataURL-noData.html: Added.
        * fast/canvas/toDataURL-supportedTypes-expected.txt: Added.
        * fast/canvas/toDataURL-supportedTypes.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@30888 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/canvas/toDataURL-noData-expected.txt [new file with mode: 0644]
LayoutTests/fast/canvas/toDataURL-noData.html [new file with mode: 0644]
LayoutTests/fast/canvas/toDataURL-supportedTypes-expected.txt [new file with mode: 0644]
LayoutTests/fast/canvas/toDataURL-supportedTypes.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/CanvasRenderingContext2D.cpp
WebCore/html/HTMLCanvasElement.cpp
WebCore/html/HTMLCanvasElement.h
WebCore/html/HTMLCanvasElement.idl
WebCore/platform/MIMETypeRegistry.cpp
WebCore/platform/MIMETypeRegistry.h
WebCore/platform/graphics/ImageBuffer.h
WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
WebCore/platform/graphics/cg/ImageBufferCG.cpp
WebCore/platform/graphics/qt/ImageBufferQt.cpp
WebCore/platform/graphics/wx/ImageBufferWx.cpp