Changeset 213378 in webkit
- Timestamp:
- Mar 3, 2017 1:15:28 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r213345 r213378 1 2017-03-03 Ryan Haddad <ryanhaddad@apple.com> 2 3 Unreviewed, rolling out r213344. 4 5 This changed caused LayoutTest crashes under GuardMalloc. 6 7 Reverted changeset: 8 9 "Add support for canvas.toBlob" 10 https://bugs.webkit.org/show_bug.cgi?id=148878 11 http://trac.webkit.org/changeset/213344 12 1 13 2017-03-02 Jiewen Tan <jiewen_tan@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/toBlob.jpeg-expected.txt
r213344 r213378 1 1 2 PASS toBlob with image/jpeg returns a JPEG Blob 2 FAIL toBlob with image/jpeg returns a JPEG Blob canvas.toBlob is not a function. (In 'canvas.toBlob(this.step_func_done(function(data) { 3 assert_equals(data.type, "image/jpeg"); 4 }), 'image/jpeg')', 'canvas.toBlob' is undefined) 3 5 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/toBlob.png-expected.txt
r213344 r213378 1 1 2 PASS toBlob with image/png returns a PNG Blob 2 FAIL toBlob with image/png returns a PNG Blob canvas.toBlob is not a function. (In 'canvas.toBlob(this.step_func_done(function(data) { 3 assert_equals(data.type, "image/png"); 4 }), 'image/png')', 'canvas.toBlob' is undefined) 3 5 -
trunk/Source/WebCore/CMakeLists.txt
r213355 r213378 476 476 477 477 fileapi/Blob.idl 478 fileapi/BlobCallback.idl479 478 fileapi/BlobLineEndings.idl 480 479 fileapi/BlobPropertyBag.idl … … 1607 1606 fileapi/Blob.cpp 1608 1607 fileapi/BlobBuilder.cpp 1609 fileapi/BlobCallback.cpp1610 1608 fileapi/BlobURL.cpp 1611 1609 fileapi/File.cpp -
trunk/Source/WebCore/ChangeLog
r213375 r213378 1 2017-03-03 Ryan Haddad <ryanhaddad@apple.com> 2 3 Unreviewed, rolling out r213344. 4 5 This changed caused LayoutTest crashes under GuardMalloc. 6 7 Reverted changeset: 8 9 "Add support for canvas.toBlob" 10 https://bugs.webkit.org/show_bug.cgi?id=148878 11 http://trac.webkit.org/changeset/213344 12 1 13 2017-03-03 Konstantin Tokarev <annulen@yandex.ru> 2 14 -
trunk/Source/WebCore/DerivedSources.make
r213345 r213378 405 405 $(WebCore)/dom/XMLDocument.idl \ 406 406 $(WebCore)/fileapi/Blob.idl \ 407 $(WebCore)/fileapi/BlobCallback.idl \408 407 $(WebCore)/fileapi/BlobLineEndings.idl \ 409 408 $(WebCore)/fileapi/BlobPropertyBag.idl \ -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r213355 r213378 4034 4034 A149786F1ABAF33800CEF7E4 /* ContentFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = A149786D1ABAF33800CEF7E4 /* ContentFilter.h */; }; 4035 4035 A14978711ABAF3A500CEF7E4 /* PlatformContentFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = A14978701ABAF3A500CEF7E4 /* PlatformContentFilter.h */; }; 4036 A15D75151E68F7C400A35FBC /* BlobCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A15D75121E68F7B100A35FBC /* BlobCallback.cpp */; };4037 A15D75161E68F7C800A35FBC /* BlobCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = A15D75131E68F7B100A35FBC /* BlobCallback.h */; };4038 A15D751A1E68F89E00A35FBC /* JSBlobCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A15D75171E68F83600A35FBC /* JSBlobCallback.cpp */; };4039 A15D751B1E68F8A300A35FBC /* JSBlobCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = A15D75181E68F83600A35FBC /* JSBlobCallback.h */; };4040 4036 A15E31F31E0CB0B2004B371C /* QuickLook.mm in Sources */ = {isa = PBXBuildFile; fileRef = A15E31F21E0CB0AA004B371C /* QuickLook.mm */; }; 4041 4037 A15E31F41E0CB0B5004B371C /* QuickLook.h in Headers */ = {isa = PBXBuildFile; fileRef = A15E31F11E0CB0AA004B371C /* QuickLook.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 11901 11897 A149786D1ABAF33800CEF7E4 /* ContentFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentFilter.h; sourceTree = "<group>"; }; 11902 11898 A14978701ABAF3A500CEF7E4 /* PlatformContentFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformContentFilter.h; sourceTree = "<group>"; }; 11903 A15D75121E68F7B100A35FBC /* BlobCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BlobCallback.cpp; sourceTree = "<group>"; };11904 A15D75131E68F7B100A35FBC /* BlobCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlobCallback.h; sourceTree = "<group>"; };11905 A15D75141E68F7B100A35FBC /* BlobCallback.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = BlobCallback.idl; sourceTree = "<group>"; };11906 A15D75171E68F83600A35FBC /* JSBlobCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBlobCallback.cpp; sourceTree = "<group>"; };11907 A15D75181E68F83600A35FBC /* JSBlobCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBlobCallback.h; sourceTree = "<group>"; };11908 11899 A15E31F11E0CB0AA004B371C /* QuickLook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuickLook.h; sourceTree = "<group>"; }; 11909 11900 A15E31F21E0CB0AA004B371C /* QuickLook.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QuickLook.mm; sourceTree = "<group>"; }; … … 18961 18952 2E2D99CB10E2BBDA00496337 /* JSBlob.cpp */, 18962 18953 2E2D99CC10E2BBDA00496337 /* JSBlob.h */, 18963 A15D75171E68F83600A35FBC /* JSBlobCallback.cpp */,18964 A15D75181E68F83600A35FBC /* JSBlobCallback.h */,18965 18954 7C77C3D91DEF86D700A50BFA /* JSBlobLineEndings.cpp */, 18966 18955 7C77C3DA1DEF86D700A50BFA /* JSBlobLineEndings.h */, … … 19897 19886 976D6C5C122B8A3D001FD1F7 /* BlobBuilder.cpp */, 19898 19887 976D6C5D122B8A3D001FD1F7 /* BlobBuilder.h */, 19899 A15D75121E68F7B100A35FBC /* BlobCallback.cpp */,19900 A15D75131E68F7B100A35FBC /* BlobCallback.h */,19901 A15D75141E68F7B100A35FBC /* BlobCallback.idl */,19902 19888 7C77C3D61DEF850A00A50BFA /* BlobLineEndings.h */, 19903 19889 7C77C3D81DEF854000A50BFA /* BlobLineEndings.idl */, … … 26933 26919 A4226E5C1163D695008B8397 /* JSHTMLProgressElement.h in Headers */, 26934 26920 1AE2AEC80A1D297B00B42B25 /* JSHTMLQuoteElement.h in Headers */, 26935 A15D751B1E68F8A300A35FBC /* JSBlobCallback.h in Headers */,26936 26921 1AE2ABAD0A1CE90500B42B25 /* JSHTMLScriptElement.h in Headers */, 26937 26922 E1E6EEA80B628DB3005F2F70 /* JSHTMLSelectElement.h in Headers */, … … 28329 28314 97BC6A521505F081001B74AC /* SQLTransactionCallback.h in Headers */, 28330 28315 97BC6A571505F081001B74AC /* SQLTransactionCoordinator.h in Headers */, 28331 A15D75161E68F7C800A35FBC /* BlobCallback.h in Headers */,28332 28316 97BC6A581505F081001B74AC /* SQLTransactionErrorCallback.h in Headers */, 28333 28317 FE36FD1816C7826500F887C1 /* SQLTransactionState.h in Headers */, … … 31112 31096 B2FA3E0A0AB75A6F000E5AC4 /* JSSVGTransform.cpp in Sources */, 31113 31097 B2FA3E0C0AB75A6F000E5AC4 /* JSSVGTransformList.cpp in Sources */, 31114 A15D75151E68F7C400A35FBC /* BlobCallback.cpp in Sources */,31115 31098 B2FA3E0E0AB75A6F000E5AC4 /* JSSVGTRefElement.cpp in Sources */, 31116 31099 B2FA3E100AB75A6F000E5AC4 /* JSSVGTSpanElement.cpp in Sources */, … … 32464 32447 93F19B0708245E59001E9ABC /* WebCoreView.m in Sources */, 32465 32448 A5E616731894581F009ADF50 /* WebDebuggerAgent.cpp in Sources */, 32466 A15D751A1E68F89E00A35FBC /* JSBlobCallback.cpp in Sources */,32467 32449 FE0D84EB1048436E001A179E /* WebEvent.mm in Sources */, 32468 32450 225A16B60D5C11E900090295 /* WebEventRegion.mm in Sources */, -
trunk/Source/WebCore/html/HTMLCanvasElement.cpp
r213344 r213378 29 29 #include "HTMLCanvasElement.h" 30 30 31 #include "Blob.h"32 #include "BlobCallback.h"33 31 #include "CanvasGradient.h" 34 32 #include "CanvasPattern.h" … … 488 486 } 489 487 490 ExceptionOr<void> HTMLCanvasElement::toBlob(ScriptExecutionContext& context, Ref<BlobCallback>&& callback, const String& mimeType, JSC::JSValue qualityValue)491 {492 if (!m_originClean)493 return Exception { SECURITY_ERR };494 495 if (m_size.isEmpty() || !buffer()) {496 callback->scheduleCallback(context, nullptr);497 return { };498 }499 500 String encodingMIMEType = toEncodingMimeType(mimeType);501 std::optional<double> quality;502 if (qualityValue.isNumber())503 quality = qualityValue.toNumber(context.execState());504 505 #if USE(CG)506 if (auto imageData = getImageData()) {507 Vector<uint8_t> blobData = data(*imageData, encodingMIMEType, quality);508 callback->scheduleCallback(context, Blob::create(WTFMove(blobData), encodingMIMEType));509 return { };510 }511 #endif512 513 makeRenderingResultsAvailable();514 515 Vector<uint8_t> blobData = buffer()->toData(encodingMIMEType, quality);516 callback->scheduleCallback(context, Blob::create(WTFMove(blobData), encodingMIMEType));517 return { };518 }519 520 488 RefPtr<ImageData> HTMLCanvasElement::getImageData() 521 489 { -
trunk/Source/WebCore/html/HTMLCanvasElement.h
r213344 r213378 40 40 namespace WebCore { 41 41 42 class BlobCallback;43 42 class CanvasRenderingContext; 44 43 class GraphicsContext; … … 103 102 WEBCORE_EXPORT ExceptionOr<String> toDataURL(const String& mimeType, std::optional<double> quality); 104 103 ExceptionOr<String> toDataURL(const String& mimeType) { return toDataURL(mimeType, std::nullopt); } 105 ExceptionOr<void> toBlob(ScriptExecutionContext&, Ref<BlobCallback>&&, const String& mimeType, JSC::JSValue qualityValue);106 104 107 105 // Used for rendering -
trunk/Source/WebCore/html/HTMLCanvasElement.idl
r213344 r213378 38 38 39 39 [Custom, MayThrowException] DOMString toDataURL(optional DOMString? type); 40 [CallWith=ScriptExecutionContext, MayThrowException] void toBlob(BlobCallback callback, optional DOMString type, optional any quality);41 40 }; -
trunk/Source/WebCore/platform/graphics/ImageBuffer.h
r213344 r213378 113 113 114 114 String toDataURL(const String& mimeType, std::optional<double> quality = std::nullopt, CoordinateSystem = LogicalCoordinateSystem) const; 115 Vector<uint8_t> toData(const String& mimeType, std::optional<double> quality = std::nullopt) const;116 115 #if !USE(CG) 117 116 AffineTransform baseTransform() const { return AffineTransform(); } … … 176 175 #if USE(CG) 177 176 ImageBuffer(const FloatSize&, float resolutionScale, CGColorSpaceRef, RenderingMode, bool& success); 178 RetainPtr<CGImageRef> toCGImage(const String& mimeType) const;179 177 #elif USE(DIRECT2D) 180 178 ImageBuffer(const FloatSize&, float resolutionScale, ColorSpace, RenderingMode, const GraphicsContext*, bool& success); … … 184 182 #if USE(CG) 185 183 String dataURL(const ImageData&, const String& mimeType, std::optional<double> quality); 186 Vector<uint8_t> data(const ImageData&, const String& mimeType, std::optional<double> quality);187 184 #endif 188 185 -
trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
r213344 r213378 540 540 static cairo_status_t writeFunction(void* output, const unsigned char* data, unsigned int length) 541 541 { 542 if (!reinterpret_cast<Vector<u int8_t>*>(output)->tryAppend(data, length))542 if (!reinterpret_cast<Vector<unsigned char>*>(output)->tryAppend(data, length)) 543 543 return CAIRO_STATUS_WRITE_ERROR; 544 544 return CAIRO_STATUS_SUCCESS; 545 545 } 546 546 547 static bool encodeImage(cairo_surface_t* image, const String& mimeType, Vector< uint8_t>* output)547 static bool encodeImage(cairo_surface_t* image, const String& mimeType, Vector<char>* output) 548 548 { 549 549 ASSERT_UNUSED(mimeType, mimeType == "image/png"); // Only PNG output is supported for now. … … 554 554 String ImageBuffer::toDataURL(const String& mimeType, std::optional<double>, CoordinateSystem) const 555 555 { 556 Vector<uint8_t> encodedImage = toData(mimeType, quality); 557 if (encodedImage.isEmpty()) 556 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); 557 558 cairo_surface_t* image = cairo_get_target(context().platformContext()->cr()); 559 560 Vector<char> encodedImage; 561 if (!image || !encodeImage(image, mimeType, &encodedImage)) 558 562 return "data:,"; 559 563 560 564 Vector<char> base64Data; 561 base64Encode(encodedImage .data(), encodedImage.size(), base64Data);565 base64Encode(encodedImage, base64Data); 562 566 563 567 return "data:" + mimeType + ";base64," + base64Data; 564 568 } 565 566 Vector<uint8_t> ImageBuffer::toData(const String& mimeType, std::optional<double> quality) const567 {568 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));569 570 cairo_surface_t* image = cairo_get_target(context().platformContext()->cr());571 572 Vector<uint8_t> encodedImage;573 if (!image || !encodeImage(image, mimeType, &encodedImage))574 return { };575 576 return encodedImage;577 }578 579 569 #endif 580 570 -
trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
r213344 r213378 499 499 } 500 500 501 static Vector<uint8_t> data(CGImageRef image, const String& mimeType, std::optional<double> quality)502 {503 auto uti = utiFromMIMEType(mimeType);504 ASSERT(uti);505 506 auto cfData = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, 0));507 if (!encodeImage(image, uti.get(), quality, cfData.get()))508 return { };509 510 Vector<uint8_t> data;511 data.append(CFDataGetBytePtr(cfData.get()), CFDataGetLength(cfData.get()));512 return data;513 }514 515 501 String ImageBuffer::toDataURL(const String& mimeType, std::optional<double> quality, CoordinateSystem) const 516 {517 if (auto image = toCGImage(mimeType))518 return dataURL(image.get(), mimeType, quality);519 return ASCIILiteral("data:,");520 }521 522 Vector<uint8_t> ImageBuffer::toData(const String& mimeType, std::optional<double> quality) const523 {524 if (auto image = toCGImage(mimeType))525 return data(image.get(), mimeType, quality);526 return { };527 }528 529 RetainPtr<CGImageRef> ImageBuffer::toCGImage(const String& mimeType) const530 502 { 531 503 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); … … 544 516 premultipliedData = getPremultipliedImageData(IntRect(IntPoint(0, 0), logicalSize())); 545 517 if (!premultipliedData) 546 return nullptr;518 return ASCIILiteral("data:,"); 547 519 548 520 auto dataProvider = adoptCF(CGDataProviderCreateWithData(0, premultipliedData->data(), 4 * logicalSize().width() * logicalSize().height(), 0)); 549 521 if (!dataProvider) 550 return nullptr; 551 552 image = adoptCF(CGImageCreate(logicalSize().width(), logicalSize().height(), 8, 32, 4 * logicalSize().width(), sRGBColorSpaceRef(), kCGBitmapByteOrderDefault | kCGImageAlphaNoneSkipLast, dataProvider.get(), 0, false, kCGRenderingIntentDefault)); 522 return ASCIILiteral("data:,"); 523 524 image = adoptCF(CGImageCreate(logicalSize().width(), logicalSize().height(), 8, 32, 4 * logicalSize().width(), 525 sRGBColorSpaceRef(), kCGBitmapByteOrderDefault | kCGImageAlphaNoneSkipLast, dataProvider.get(), 0, false, kCGRenderingIntentDefault)); 553 526 } else if (m_resolutionScale == 1) { 554 527 image = copyNativeImage(CopyBackingStore); … … 564 537 } 565 538 566 return image;567 } 568 569 static RetainPtr<CGImageRef> cgImage(const ImageData& source, const String& mimeType)539 return dataURL(image.get(), mimeType, quality); 540 } 541 542 String dataURL(const ImageData& source, const String& mimeType, std::optional<double> quality) 570 543 { 571 544 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); … … 582 555 size_t size = 4 * source.width() * source.height(); 583 556 if (!premultipliedData.tryReserveCapacity(size)) 584 return nullptr;557 return ASCIILiteral("data:,"); 585 558 586 559 premultipliedData.resize(size); … … 605 578 auto dataProvider = adoptCF(CGDataProviderCreateWithData(0, data, 4 * source.width() * source.height(), 0)); 606 579 if (!dataProvider) 607 return nullptr; 608 609 auto image = adoptCF(CGImageCreate(source.width(), source.height(), 8, 32, 4 * source.width(), sRGBColorSpaceRef(), kCGBitmapByteOrderDefault | dataAlphaInfo, dataProvider.get(), 0, false, kCGRenderingIntentDefault)); 610 return image; 611 } 612 613 String dataURL(const ImageData& source, const String& mimeType, std::optional<double> quality) 614 { 615 if (auto image = cgImage(source, mimeType)) 616 return dataURL(image.get(), mimeType, quality); 617 return ASCIILiteral("data:,"); 618 } 619 620 Vector<uint8_t> data(const ImageData& source, const String& mimeType, std::optional<double> quality) 621 { 622 if (auto image = cgImage(source, mimeType)) 623 return data(image.get(), mimeType, quality); 624 return { }; 580 return ASCIILiteral("data:,"); 581 582 auto image = adoptCF(CGImageCreate(source.width(), source.height(), 8, 32, 4 * source.width(), 583 sRGBColorSpaceRef(), kCGBitmapByteOrderDefault | dataAlphaInfo, dataProvider.get(), 0, false, kCGRenderingIntentDefault)); 584 return dataURL(image.get(), mimeType, quality); 625 585 } 626 586 -
trunk/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp
r213344 r213378 78 78 String ImageBuffer::toDataURL(const String& mimeType, std::optional<double> quality, CoordinateSystem) const 79 79 { 80 Vector<uint8_t> imageData = toData(mimeType, quality);81 if (imageData.isEmpty())82 return "data:,";83 84 Vector<char> base64Data;85 base64Encode(imageData.data(), imageData.size(), base64Data);86 87 return "data:" + mimeType + ";base64," + base64Data;88 }89 90 Vector<uint8_t> ImageBuffer::toData(const String& mimeType, std::optional<double> quality) const91 {92 80 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); 93 81 … … 95 83 gsize bufferSize; 96 84 if (!encodeImage(m_data.m_surface.get(), mimeType, quality, buffer, bufferSize)) 97 return { };85 return "data:,"; 98 86 99 Vector<uint8_t> imageData; 100 imageData.append(buffer.get(), bufferSize); 101 return imageData; 87 Vector<char> base64Data; 88 base64Encode(buffer.get(), bufferSize, base64Data); 89 90 return "data:" + mimeType + ";base64," + base64Data; 102 91 } 103 92 -
trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp
r213344 r213378 261 261 } 262 262 263 Vector<uint8_t> ImageBuffer::toData(const String& mimeType, std::optional<double> quality) const264 {265 notImplemented();266 return { };267 }268 269 263 String ImageDataToDataURL(const ImageData& source, const String& mimeType, const double* quality) 270 264 {
Note: See TracChangeset
for help on using the changeset viewer.