Changeset 60458 in webkit
- Timestamp:
- May 31, 2010 6:23:52 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 11 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r60453 r60458 1 2010-05-31 Leo Yang <leo.yang@torchmobile.com.cn> 2 3 Reviewed by George Staikos. 4 5 Fix canvas.toDataURL(type, quality, ...) to let it support quality parameter. 6 And implement it in Qt port. 7 https://bugs.webkit.org/show_bug.cgi?id=37304 8 9 * platform/qt/fast/canvas/toDataURL-jpeg-alpha-expected.txt: Added. 10 * platform/qt/fast/canvas/toDataURL-jpeg-alpha.html: Added. 11 * platform/qt/fast/canvas/toDataURL-jpeg-primarycolors-expected.txt: Added. 12 * platform/qt/fast/canvas/toDataURL-jpeg-primarycolors.html: Added. 13 * platform/qt/fast/canvas/toDataURL-jpeg-quality-basic-expected.txt: Added. 14 * platform/qt/fast/canvas/toDataURL-jpeg-quality-basic.html: Added. 15 * platform/qt/fast/canvas/toDataURL-jpeg-quality-notnumber-expected.txt: Added. 16 * platform/qt/fast/canvas/toDataURL-jpeg-quality-notnumber.html: Added. 17 * platform/qt/fast/canvas/toDataURL-jpeg-quality-outsiderange-expected.txt: Added. 18 * platform/qt/fast/canvas/toDataURL-jpeg-quality-outsiderange.html: Added. 19 * platform/qt/fast/canvas/toDataURL-jpeg.js: Added. 20 1 21 2010-05-31 Stephen White <senorblanco@chromium.org> 2 22 -
trunk/WebCore/ChangeLog
r60454 r60458 1 2010-05-31 Leo Yang <leo.yang@torchmobile.com.cn> 2 3 Reviewed by George Staikos. 4 5 Fix canvas.toDataURL(type, quality, ...) to let it support quality parameter. 6 And implement it in Qt port. 7 https://bugs.webkit.org/show_bug.cgi?id=37304 8 9 Tests: platform/qt/fast/canvas/toDataURL-jpeg-alpha.html 10 platform/qt/fast/canvas/toDataURL-jpeg-primarycolors.html 11 platform/qt/fast/canvas/toDataURL-jpeg-quality-basic.html 12 platform/qt/fast/canvas/toDataURL-jpeg-quality-notnumber.html 13 platform/qt/fast/canvas/toDataURL-jpeg-quality-outsiderange.html 14 15 * bindings/js/JSHTMLCanvasElementCustom.cpp: 16 (WebCore::JSHTMLCanvasElement::toDataURL): 17 * bindings/v8/custom/V8HTMLCanvasElementCustom.cpp: 18 (WebCore::V8HTMLCanvasElement::toDataURLCallback): 19 * dom/CanvasSurface.cpp: 20 (WebCore::CanvasSurface::toDataURL): 21 * dom/CanvasSurface.h: 22 (WebCore::CanvasSurface::toDataURL): 23 * html/HTMLCanvasElement.idl: 24 * platform/graphics/ImageBuffer.h: 25 * platform/graphics/cairo/ImageBufferCairo.cpp: 26 (WebCore::ImageBuffer::toDataURL): 27 * platform/graphics/cg/ImageBufferCG.cpp: 28 (WebCore::ImageBuffer::toDataURL): 29 * platform/graphics/haiku/ImageBufferHaiku.cpp: 30 (WebCore::ImageBuffer::toDataURL): 31 * platform/graphics/qt/ImageBufferQt.cpp: 32 (WebCore::ImageBuffer::toDataURL): 33 * platform/graphics/skia/ImageBufferSkia.cpp: 34 (WebCore::ImageBuffer::toDataURL): 35 * platform/graphics/wince/ImageBufferWince.cpp: 36 (WebCore::ImageBuffer::toDataURL): 37 * platform/graphics/wx/ImageBufferWx.cpp: 38 (WebCore::ImageBuffer::toDataURL): 39 1 40 2010-05-31 Lucas De Marchi <lucas.demarchi@profusion.mobi> 2 41 -
trunk/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp
r60392 r60458 1 1 /* 2 2 * Copyright (C) 2007 Apple Inc. All rights reserved. 3 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 85 86 } 86 87 88 JSValue JSHTMLCanvasElement::toDataURL(ExecState* exec) 89 { 90 const String& type = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)); 91 double quality = 1.0; 92 if (exec->argumentCount() > 1) { 93 JSValue v = exec->argument(1); 94 if (v.isNumber()) 95 quality = v.toNumber(exec); 96 if (!(0.0 <= quality && quality <= 1.0)) 97 quality = 1.0; 98 } 99 HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(impl()); 100 ExceptionCode ec = 0; 101 JSC::JSValue result = jsString(exec, canvas->toDataURL(type, quality, ec)); 102 setDOMException(exec, ec); 103 return result; 104 } 105 87 106 } // namespace WebCore -
trunk/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
r59569 r60458 1 1 /* 2 2 * Copyright (C) 2007-2009 Google Inc. All rights reserved. 3 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 35 36 #include "CanvasRenderingContext.h" 36 37 #include "HTMLCanvasElement.h" 38 #include "PlatformString.h" 37 39 #include "WebGLContextAttributes.h" 38 40 #include "V8Binding.h" … … 43 45 #include "V8WebGLRenderingContext.h" 44 46 #endif 47 #include <wtf/MathExtras.h> 45 48 46 49 namespace WebCore { … … 90 93 } 91 94 95 v8::Handle<v8::Value> V8HTMLCanvasElement::toDataURLCallback(const v8::Arguments& args) 96 { 97 double quality = 1.0; 98 if (args.Length() > 1) { 99 if (args[1]->IsNumber()) 100 quality = args[1]->NumberValue(); 101 if (!(0.0 <= quality && quality <= 1.0)) 102 quality = 1.0; 103 } 104 v8::Handle<v8::Object> holder = args.Holder(); 105 HTMLCanvasElement* canvas = V8HTMLCanvasElement::toNative(holder); 106 String type = toWebCoreString(args[0]); 107 ExceptionCode ec = 0; 108 String result = canvas->toDataURL(type, quality, ec); 109 V8Proxy::setDOMException(ec); 110 return v8StringOrUndefined(result); 111 } 112 92 113 } // namespace WebCore -
trunk/WebCore/dom/CanvasSurface.cpp
r59581 r60458 1 1 /* 2 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 65 66 } 66 67 67 String CanvasSurface::toDataURL(const String& mimeType, ExceptionCode& ec)68 String CanvasSurface::toDataURL(const String& mimeType, double quality, ExceptionCode& ec) 68 69 { 69 70 if (!m_originClean) { … … 81 82 return buffer()->toDataURL("image/png"); 82 83 83 return buffer()->toDataURL(lowercaseMimeType );84 return buffer()->toDataURL(lowercaseMimeType, quality); 84 85 } 85 86 -
trunk/WebCore/dom/CanvasSurface.h
r57020 r60458 1 1 /* 2 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 29 30 #include "AffineTransform.h" 30 31 #include "IntSize.h" 32 #include "PlatformString.h" 31 33 32 34 #include <wtf/OwnPtr.h> … … 42 44 class ImageBuffer; 43 45 class IntPoint; 44 class String;45 46 46 47 class CSSStyleSelector; … … 59 60 int height() const { return m_size.height(); } 60 61 61 String toDataURL(const String& mimeType, ExceptionCode&); 62 String toDataURL(const String& mimeType, double quality, ExceptionCode&); 63 64 String toDataURL(const String& mimeType, ExceptionCode& ec) { return toDataURL(mimeType, 1.0, ec); } 62 65 63 66 const IntSize& size() const { return m_size; } -
trunk/WebCore/html/HTMLCanvasElement.idl
r53238 r60458 1 1 /* 2 2 * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 33 34 attribute long height; 34 35 35 DOMString toDataURL(in [ConvertUndefinedOrNullToNullString] DOMString type)36 [Custom] DOMString toDataURL(in [ConvertUndefinedOrNullToNullString] DOMString type) 36 37 raises(DOMException); 37 38 -
trunk/WebCore/platform/graphics/ImageBuffer.h
r54503 r60458 2 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 3 3 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 5 * 5 6 * Redistribution and use in source and binary forms, with or without … … 83 84 void putPremultipliedImageData(ImageData*, const IntRect& sourceRect, const IntPoint& destPoint); 84 85 85 String toDataURL(const String& mimeType ) const;86 String toDataURL(const String& mimeType, double quality = 1.0) const; 86 87 #if !PLATFORM(CG) 87 88 AffineTransform baseTransform() const { return AffineTransform(); } -
trunk/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
r52049 r60458 3 3 * Copyright (C) 2007 Holger Hans Peter Freyther <zecke@selfish.org> 4 4 * Copyright (C) 2008, 2009 Dirk Schulze <krit@webkit.org> 5 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 5 6 * 6 7 * Redistribution and use in source and binary forms, with or without … … 284 285 } 285 286 286 String ImageBuffer::toDataURL(const String& mimeType ) const287 String ImageBuffer::toDataURL(const String& mimeType, double) const 287 288 { 288 289 cairo_surface_t* image = cairo_get_target(context()->platformContext()); -
trunk/WebCore/platform/graphics/cg/ImageBufferCG.cpp
r56825 r60458 2 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 3 3 * Copyright (C) 2008 Apple Inc. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 5 * 5 6 * Redistribution and use in source and binary forms, with or without … … 276 277 } 277 278 278 String ImageBuffer::toDataURL(const String& mimeType ) const279 String ImageBuffer::toDataURL(const String& mimeType, double) const 279 280 { 280 281 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); -
trunk/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp
r58078 r60458 1 1 /* 2 2 * Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de> 3 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 310 311 } 311 312 312 String ImageBuffer::toDataURL(const String& mimeType ) const313 String ImageBuffer::toDataURL(const String& mimeType, double) const 313 314 { 314 315 if (!MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)) -
trunk/WebCore/platform/graphics/qt/ImageBufferQt.cpp
r59713 r60458 3 3 * Copyright (C) 2008 Holger Hans Peter Freyther 4 4 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 5 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 5 6 * 6 7 * Redistribution and use in source and binary forms, with or without … … 276 277 // only formats (png, gif, jpeg..., xpm). So assume we get image/ as image 277 278 // mimetypes and then remove the image/ to get the Qt format. 278 String ImageBuffer::toDataURL(const String& mimeType ) const279 String ImageBuffer::toDataURL(const String& mimeType, double quality) const 279 280 { 280 281 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); 282 ASSERT(0.0 <= quality && quality <= 1.0); 281 283 282 284 if (!mimeType.startsWith("image/")) … … 288 290 buffer.open(QBuffer::WriteOnly); 289 291 290 if (!m_data.m_pixmap.save(&buffer, mimeType.substring(sizeof "image").utf8().data())) 292 if (!m_data.m_pixmap.save(&buffer, mimeType.substring(sizeof "image").utf8().data(), quality * 100 + 0.5)) { 293 buffer.close(); 291 294 return "data:,"; 295 } 292 296 293 297 buffer.close(); -
trunk/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
r52791 r60458 2 2 * Copyright (c) 2008, Google Inc. All rights reserved. 3 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 5 * 5 6 * Redistribution and use in source and binary forms, with or without … … 261 262 } 262 263 263 String ImageBuffer::toDataURL(const String& ) const264 String ImageBuffer::toDataURL(const String&, double) const 264 265 { 265 266 // Encode the image into a vector. -
trunk/WebCore/platform/graphics/wince/ImageBufferWince.cpp
r57273 r60458 1 1 /* 2 2 * Copyright (C) 2009 Torch Mobile, Inc. All rights reserved. 3 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 3 4 * 4 5 * This library is free software; you can redistribute it and/or … … 216 217 } 217 218 218 String ImageBuffer::toDataURL(const String& mimeType ) const219 String ImageBuffer::toDataURL(const String& mimeType, double) const 219 220 { 220 221 if (!m_data.m_bitmap->bytes()) -
trunk/WebCore/platform/graphics/wx/ImageBufferWx.cpp
r57404 r60458 1 1 /* 2 2 * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> 3 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 76 77 } 77 78 78 String ImageBuffer::toDataURL(const String& ) const79 String ImageBuffer::toDataURL(const String&, double) const 79 80 { 80 81 notImplemented();
Note: See TracChangeset
for help on using the changeset viewer.