OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 return nil; | 1746 return nil; |
1747 } | 1747 } |
1748 | 1748 |
1749 static NSFileWrapper *fileWrapperForElement(Element* element) | 1749 static NSFileWrapper *fileWrapperForElement(Element* element) |
1750 { | 1750 { |
1751 NSFileWrapper *wrapper = nil; | 1751 NSFileWrapper *wrapper = nil; |
1752 | 1752 |
1753 const AtomicString& attr = element->getAttribute(srcAttr); | 1753 const AtomicString& attr = element->getAttribute(srcAttr); |
1754 if (!attr.isEmpty()) { | 1754 if (!attr.isEmpty()) { |
1755 NSURL *URL = element->document()->completeURL(attr); | 1755 NSURL *URL = element->document()->completeURL(attr); |
1756 wrapper = fileWrapperForURL(element->document()->loader(), URL); | 1756 if (DocumentLoader* loader = element->document()->loader()) |
| 1757 wrapper = fileWrapperForURL(loader, URL); |
1757 } | 1758 } |
1758 if (!wrapper) { | 1759 if (!wrapper) { |
1759 RenderImage* renderer = toRenderImage(element->renderer()); | 1760 RenderImage* renderer = toRenderImage(element->renderer()); |
1760 if (renderer->cachedImage() && !renderer->cachedImage()->errorOccurred()
) { | 1761 if (renderer->cachedImage() && !renderer->cachedImage()->errorOccurred()
) { |
1761 wrapper = [[NSFileWrapper alloc] initRegularFileWithContents:(NSData
*)(renderer->cachedImage()->image()->getTIFFRepresentation())]; | 1762 wrapper = [[NSFileWrapper alloc] initRegularFileWithContents:(NSData
*)(renderer->cachedImage()->image()->getTIFFRepresentation())]; |
1762 [wrapper setPreferredFilename:@"image.tiff"]; | 1763 [wrapper setPreferredFilename:@"image.tiff"]; |
1763 [wrapper autorelease]; | 1764 [wrapper autorelease]; |
1764 } | 1765 } |
1765 } | 1766 } |
1766 | 1767 |
1767 return wrapper; | 1768 return wrapper; |
1768 } | 1769 } |
OLD | NEW |