OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "Icon.h" | 32 #include "Icon.h" |
33 | 33 |
34 #include <windows.h> | |
35 #include <shellapi.h> | |
36 | |
37 #include "GraphicsContext.h" | 34 #include "GraphicsContext.h" |
38 #include "PlatformContextSkia.h" | |
39 #include "PlatformString.h" | 35 #include "PlatformString.h" |
40 #include "SkiaUtils.h" | |
41 | 36 |
42 namespace WebCore { | 37 namespace WebCore { |
43 | 38 |
44 Icon::Icon(const PlatformIcon& icon) | 39 Icon::Icon(PassRefPtr<PlatformIcon> icon) |
45 : m_icon(icon) | 40 : m_icon(icon) |
46 { | 41 { |
47 } | 42 } |
48 | 43 |
49 Icon::~Icon() | 44 Icon::~Icon() |
50 { | 45 { |
51 if (m_icon) | |
52 DestroyIcon(m_icon); | |
53 } | 46 } |
54 | 47 |
| 48 #if 0 |
55 PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames) | 49 PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames) |
56 { | 50 { |
57 // FIXME: We can't access icons directly from renderer processes. | 51 // It's hard to support for synchronous icon loading because of the sandbox. |
58 // http://code.google.com/p/chromium/issues/detail?id=4092 | 52 // Chrome::iconForFiles() will load icons asynchronously instead. |
59 return 0; | 53 return 0; |
60 } | 54 } |
| 55 #endif |
61 | 56 |
62 void Icon::paint(GraphicsContext* context, const IntRect& rect) | 57 void Icon::paint(GraphicsContext* context, const IntRect& rect) |
63 { | 58 { |
64 if (context->paintingDisabled()) | 59 if (context->paintingDisabled()) |
65 return; | 60 return; |
66 | 61 |
67 HDC hdc = context->platformContext()->canvas()->beginPlatformPaint(); | 62 // An Icon doesn't know the color space of the file upload control. |
68 DrawIconEx(hdc, rect.x(), rect.y(), m_icon, rect.width(), rect.height(), 0,
0, DI_NORMAL); | 63 // So use DeviceColorSpace. |
69 context->platformContext()->canvas()->endPlatformPaint(); | 64 context->drawImage(m_icon.get(), DeviceColorSpace, rect); |
70 } | 65 } |
71 | 66 |
72 } // namespace WebCore | 67 } // namespace WebCore |
OLD | NEW |