WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 178502
[CG] PostScript images should be supported if they are sub-resource images
https://bugs.webkit.org/show_bug.cgi?id=178502
Summary
[CG] PostScript images should be supported if they are sub-resource images
Said Abou-Hallawa
Reported
2017-10-18 19:28:14 PDT
1. Open the attached EPS image green-100x100.esp Result: A 100x100 green rectangle is displayed. 2. Open the attached HTML page green-100x100.html Result: A broken image is displayed. The PostScript images are detected and converted to images PDF when they are the main resources. When they are sub-resources, WebKit tries to decode them as if they were binary images.
Attachments
green-100x100.eps
(65.07 KB, application/postscript)
2017-10-18 19:29 PDT
,
Said Abou-Hallawa
no flags
Details
green-100x100.html
(79 bytes, text/html)
2017-10-18 19:32 PDT
,
Said Abou-Hallawa
no flags
Details
Patch
(84.48 KB, patch)
2017-10-18 19:43 PDT
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(18.65 KB, patch)
2017-10-19 13:33 PDT
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(19.22 KB, patch)
2017-10-19 17:55 PDT
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews123 for ios-simulator-wk2
(1015.56 KB, application/zip)
2017-10-19 19:36 PDT
,
Build Bot
no flags
Details
Patch
(20.45 KB, patch)
2017-10-20 12:44 PDT
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews123 for ios-simulator-wk2
(21.04 MB, application/zip)
2017-10-20 14:34 PDT
,
Build Bot
no flags
Details
Patch
(20.52 KB, patch)
2017-10-20 15:04 PDT
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(21.05 KB, patch)
2017-10-20 17:19 PDT
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews121 for ios-simulator-wk2
(16.07 MB, application/zip)
2017-10-20 18:50 PDT
,
Build Bot
no flags
Details
Patch
(18.41 KB, patch)
2017-10-25 15:43 PDT
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(18.58 KB, patch)
2017-10-27 11:59 PDT
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(18.63 KB, patch)
2017-10-27 12:10 PDT
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(18.65 KB, patch)
2017-10-27 12:55 PDT
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(21.46 KB, patch)
2017-10-31 15:21 PDT
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(21.10 KB, patch)
2017-11-28 11:54 PST
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(21.12 KB, patch)
2017-11-28 12:46 PST
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Show Obsolete
(15)
View All
Add attachment
proposed patch, testcase, etc.
Said Abou-Hallawa
Comment 1
2017-10-18 19:29:42 PDT
Created
attachment 324198
[details]
green-100x100.eps
Said Abou-Hallawa
Comment 2
2017-10-18 19:32:05 PDT
Created
attachment 324199
[details]
green-100x100.html
Said Abou-Hallawa
Comment 3
2017-10-18 19:43:47 PDT
Created
attachment 324201
[details]
Patch
Said Abou-Hallawa
Comment 4
2017-10-18 19:44:58 PDT
<
rdar://problem/35000589
>
Sam Weinig
Comment 5
2017-10-19 05:59:25 PDT
Comment on
attachment 324201
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=324201&action=review
> Source/WebCore/ChangeLog:10 > + Let PDFDocumentImage replaces the PostScript data with the equivalent PDF > + data and use it when creating the PDFDocument.
Why are we doing this conversion? Is it because ImageIO doesn't support PostScript directly?
> Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:374 > + CGPSConverterCallbacks callbacks = { 0, 0, 0, 0, 0, 0, 0, 0 }; > + RetainPtr<CGPSConverterRef> converter = adoptCF(CGPSConverterCreate(0, &callbacks, 0)); > + RetainPtr<CGDataProviderRef> provider = adoptCF(CGDataProviderCreateWithCFData(postScriptData.get())); > + RetainPtr<CFMutableDataRef> pdfData = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, 0)); > + RetainPtr<CGDataConsumerRef> consumer = adoptCF(CGDataConsumerCreateWithCFData(pdfData.get()));
Thes should use auto.
> Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:376 > + CGPSConverterConvert(converter.get(), provider.get(), consumer.get(), 0);
Is this operation expensive? Should we be doing it on a background thread, asynchronously? What happens with a really big PostScript file?
> Source/WebCore/platform/graphics/cg/PDFDocumentImage.h:51 > + static Ref<PDFDocumentImage> create(ImageObserver* observer, bool isPostScript = false)
I think this would be clearer as an enum: enum class Type { PDF, PostScript };
Tim Horton
Comment 6
2017-10-19 10:37:30 PDT
Comment on
attachment 324201
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=324201&action=review
> LayoutTests/fast/images/resources/green-100x100.eps:1 > +%!PS-Adobe-3.0 EPSF-3.0
This is an insanely overcomplicated EPS, I emailed you a better (<200byte) one.
Said Abou-Hallawa
Comment 7
2017-10-19 13:33:14 PDT
Created
attachment 324276
[details]
Patch
Build Bot
Comment 8
2017-10-19 13:35:06 PDT
Attachment 324276
[details]
did not pass style-queue: ERROR: Source/WebCore/platform/graphics/cg/PDFDocumentImage.h:52: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] Total errors found: 1 in 14 files If any of these errors are false positives, please file a bug against check-webkit-style.
Said Abou-Hallawa
Comment 9
2017-10-19 13:40:25 PDT
Comment on
attachment 324201
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=324201&action=review
>> Source/WebCore/ChangeLog:10 >> + data and use it when creating the PDFDocument. > > Why are we doing this conversion? Is it because ImageIO doesn't support PostScript directly?
Yes ImageIO handles only the bitmap images. SVG is handled completely by WebKit. PDF is handled by the PDFKit. So the easiest way to have PostScript handled was to convert it to PDF and let PDFKit render it.
>> Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:374 >> + RetainPtr<CGDataConsumerRef> consumer = adoptCF(CGDataConsumerCreateWithCFData(pdfData.get())); > > Thes should use auto.
Done.
>> Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:376 >> + CGPSConverterConvert(converter.get(), provider.get(), consumer.get(), 0); > > Is this operation expensive? Should we be doing it on a background thread, asynchronously? What happens with a really big PostScript file?
Yes I think so. At least it will as slow as decoding the data uri images which is decoded asynchronously. So I will log a separate bug to convert the sub-resource PostScript to a PDF asynchronously.
>> Source/WebCore/platform/graphics/cg/PDFDocumentImage.h:51 >> + static Ref<PDFDocumentImage> create(ImageObserver* observer, bool isPostScript = false) > > I think this would be clearer as an enum: > > enum class Type { > PDF, > PostScript > };
Done.
>> LayoutTests/fast/images/resources/green-100x100.eps:1 >> +%!PS-Adobe-3.0 EPSF-3.0 > > This is an insanely overcomplicated EPS, I emailed you a better (<200byte) one.
Thanks. This was very helpful. But I had to tweak it a little to get the green rectangle without anti-aliasing at the borders.
Said Abou-Hallawa
Comment 10
2017-10-19 17:55:41 PDT
Created
attachment 324325
[details]
Patch
Build Bot
Comment 11
2017-10-19 17:57:45 PDT
Attachment 324325
[details]
did not pass style-queue: ERROR: Source/WebCore/platform/graphics/cg/PDFDocumentImage.h:52: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] Total errors found: 1 in 15 files If any of these errors are false positives, please file a bug against check-webkit-style.
Build Bot
Comment 12
2017-10-19 19:36:14 PDT
Comment on
attachment 324325
[details]
Patch
Attachment 324325
[details]
did not pass ios-sim-ews (ios-simulator-wk2): Output:
http://webkit-queues.webkit.org/results/4926892
New failing tests: fast/images/eps-support-sub-resource.html
Build Bot
Comment 13
2017-10-19 19:36:15 PDT
Created
attachment 324335
[details]
Archive of layout-test-results from ews123 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews123 Port: ios-simulator-wk2 Platform: Mac OS X 10.12.6
Said Abou-Hallawa
Comment 14
2017-10-20 12:44:18 PDT
Created
attachment 324431
[details]
Patch
Build Bot
Comment 15
2017-10-20 12:45:31 PDT
Attachment 324431
[details]
did not pass style-queue: ERROR: Source/WebCore/platform/graphics/cg/PDFDocumentImage.h:52: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] Total errors found: 1 in 17 files If any of these errors are false positives, please file a bug against check-webkit-style.
Build Bot
Comment 16
2017-10-20 14:34:00 PDT
Comment on
attachment 324431
[details]
Patch
Attachment 324431
[details]
did not pass ios-sim-ews (ios-simulator-wk2): Output:
http://webkit-queues.webkit.org/results/4936524
New failing tests: webrtc/video-replace-muted-track.html
Build Bot
Comment 17
2017-10-20 14:34:02 PDT
Created
attachment 324447
[details]
Archive of layout-test-results from ews123 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews123 Port: ios-simulator-wk2 Platform: Mac OS X 10.12.6
Said Abou-Hallawa
Comment 18
2017-10-20 14:58:11 PDT
<
rdar://problem/35102988
>
Said Abou-Hallawa
Comment 19
2017-10-20 15:04:18 PDT
Created
attachment 324449
[details]
Patch
Build Bot
Comment 20
2017-10-20 15:05:49 PDT
Attachment 324449
[details]
did not pass style-queue: ERROR: Source/WebCore/platform/graphics/cg/PDFDocumentImage.h:52: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] Total errors found: 1 in 17 files If any of these errors are false positives, please file a bug against check-webkit-style.
Tim Horton
Comment 21
2017-10-20 16:38:11 PDT
Comment on
attachment 324449
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=324449&action=review
> Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:92 > +#if ENABLE(PDFKIT_PLUGIN)
Why is this in ENABLE(PDFKIT_PLUGIN)?
> Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:366 > +#if ENABLE(PDFKIT_PLUGIN)
Why is this in ENABLE(PDFKIT_PLUGIN)?
Said Abou-Hallawa
Comment 22
2017-10-20 17:19:13 PDT
Created
attachment 324476
[details]
Patch
Build Bot
Comment 23
2017-10-20 17:20:21 PDT
Attachment 324476
[details]
did not pass style-queue: ERROR: Source/WebCore/platform/graphics/cg/PDFDocumentImage.h:52: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] Total errors found: 1 in 17 files If any of these errors are false positives, please file a bug against check-webkit-style.
Said Abou-Hallawa
Comment 24
2017-10-20 18:00:08 PDT
Comment on
attachment 324449
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=324449&action=review
>> Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:92 >> +#if ENABLE(PDFKIT_PLUGIN) > > Why is this in ENABLE(PDFKIT_PLUGIN)?
I replaced it by #if PLATFORM(MAC). And I made sure that we do not create a PDFDocumentImage unless the data is for a PDF image or the data is for an EPS image and the platform is Mac.
Build Bot
Comment 25
2017-10-20 18:50:52 PDT
Comment on
attachment 324476
[details]
Patch
Attachment 324476
[details]
did not pass ios-sim-ews (ios-simulator-wk2): Output:
http://webkit-queues.webkit.org/results/4938954
New failing tests: webrtc/video-replace-muted-track.html
Build Bot
Comment 26
2017-10-20 18:50:54 PDT
Created
attachment 324479
[details]
Archive of layout-test-results from ews121 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews121 Port: ios-simulator-wk2 Platform: Mac OS X 10.12.6
Tim Horton
Comment 27
2017-10-20 19:12:10 PDT
(In reply to Said Abou-Hallawa from
comment #24
)
> Comment on
attachment 324449
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=324449&action=review
> > >> Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:92 > >> +#if ENABLE(PDFKIT_PLUGIN) > > > > Why is this in ENABLE(PDFKIT_PLUGIN)? > > I replaced it by #if PLATFORM(MAC). And I made sure that we do not create a > PDFDocumentImage unless the data is for a PDF image or the data is for an > EPS image and the platform is Mac.
I don't understand why we wouldn't want this on iOS as well.
Said Abou-Hallawa
Comment 28
2017-10-25 15:43:30 PDT
Created
attachment 324909
[details]
Patch
Build Bot
Comment 29
2017-10-25 15:45:39 PDT
Attachment 324909
[details]
did not pass style-queue: ERROR: Source/WebCore/platform/graphics/cg/PDFDocumentImage.h:52: enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums. [readability/enum_casing] [4] Total errors found: 1 in 17 files If any of these errors are false positives, please file a bug against check-webkit-style.
Said Abou-Hallawa
Comment 30
2017-10-25 15:48:24 PDT
(In reply to Tim Horton from
comment #27
)
> (In reply to Said Abou-Hallawa from
comment #24
) > > Comment on
attachment 324449
[details]
> > Patch > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=324449&action=review
> > > > >> Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:92 > > >> +#if ENABLE(PDFKIT_PLUGIN) > > > > > > Why is this in ENABLE(PDFKIT_PLUGIN)? > > > > I replaced it by #if PLATFORM(MAC). And I made sure that we do not create a > > PDFDocumentImage unless the data is for a PDF image or the data is for an > > EPS image and the platform is Mac. > > I don't understand why we wouldn't want this on iOS as well.
Because the header file CGPSConverter.h exists only in the Mac CoreGraphics framework. This header file contains all the definitions of the structures and APIs we use in PDFDocumentImage::convertPostScriptDataToPDF().
Said Abou-Hallawa
Comment 31
2017-10-27 11:59:34 PDT
Created
attachment 325182
[details]
Patch
Said Abou-Hallawa
Comment 32
2017-10-27 12:10:49 PDT
Created
attachment 325183
[details]
Patch
Said Abou-Hallawa
Comment 33
2017-10-27 12:55:19 PDT
Created
attachment 325185
[details]
Patch
Said Abou-Hallawa
Comment 34
2017-10-31 15:21:07 PDT
Created
attachment 325506
[details]
Patch
Tim Horton
Comment 35
2017-11-01 10:54:24 PDT
Comment on
attachment 325506
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=325506&action=review
> Source/WebCore/loader/cache/CachedImage.cpp:315 > + return url().path().endsWith(".pdf", false);
This random extension checking seems weird, do we have any prior examples?
Said Abou-Hallawa
Comment 36
2017-11-28 11:54:06 PST
Created
attachment 327768
[details]
Patch
Said Abou-Hallawa
Comment 37
2017-11-28 11:55:32 PST
Comment on
attachment 325506
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=325506&action=review
>> Source/WebCore/loader/cache/CachedImage.cpp:315 >> + return url().path().endsWith(".pdf", false); > > This random extension checking seems weird, do we have any prior examples?
In WebPage::createPlugin() we have the following if-statment: if (shouldUsePDFPlugin() && (MIMETypeRegistry::isPDFOrPostScriptMIMEType(parameters.mimeType) || (parameters.mimeType.isEmpty() && (path.endsWithIgnoringASCIICase(".pdf") || path.endsWithIgnoringASCIICase(".ps")))))
Simon Fraser (smfr)
Comment 38
2017-11-28 12:01:52 PST
Comment on
attachment 327768
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=327768&action=review
> Source/WebCore/loader/cache/CachedImage.h:98 > + bool isPDFRequest() const; > + bool isPostScriptRequest() const;
It's odd to ask whether an image is a "request". Maybe isPDFResource()/isPostScriptResource()?
> Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:363 > + CGPSConverterCallbacks callbacks = { 0, 0, 0, 0, 0, 0, 0, 0 };
Could be CGPSConverterCallbacks callbacks = { };
> Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:369 > + CGPSConverterConvert(converter.get(), provider.get(), consumer.get(), 0);
How expensive is this? Can it happen off the main thread?
> Source/WebCore/platform/graphics/cg/PDFDocumentImage.h:58 > + WEBCORE_EXPORT static RetainPtr<CFMutableDataRef> convertPostScriptDataToPDF(RetainPtr<CFDataRef> postScriptData);
This should return a CFDataRef, right? The caller doesn't need mutability. Can the argument be a RetainPtr<CFDataRef>&& ?
Said Abou-Hallawa
Comment 39
2017-11-28 12:46:58 PST
Created
attachment 327778
[details]
Patch
Said Abou-Hallawa
Comment 40
2017-11-28 13:32:05 PST
Comment on
attachment 327768
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=327768&action=review
>> Source/WebCore/loader/cache/CachedImage.h:98 >> + bool isPostScriptRequest() const; > > It's odd to ask whether an image is a "request". Maybe isPDFResource()/isPostScriptResource()?
Functions were renamed.
>> Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:363 >> + CGPSConverterCallbacks callbacks = { 0, 0, 0, 0, 0, 0, 0, 0 }; > > Could be CGPSConverterCallbacks callbacks = { };
Done.
>> Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:369 >> + CGPSConverterConvert(converter.get(), provider.get(), consumer.get(), 0); > > How expensive is this? Can it happen off the main thread?
It is expensive operation for sure. I logged
https://bugs.webkit.org/show_bug.cgi?id=180104
to track this issue.
>> Source/WebCore/platform/graphics/cg/PDFDocumentImage.h:58 >> + WEBCORE_EXPORT static RetainPtr<CFMutableDataRef> convertPostScriptDataToPDF(RetainPtr<CFDataRef> postScriptData); > > This should return a CFDataRef, right? The caller doesn't need mutability. > > Can the argument be a RetainPtr<CFDataRef>&& ?
Yes the argument can be RetainPtr<CFDataRef>&&. But I could not change the return value because we assign the value of convertPostScriptDataToPDF() to PDFPlugin::m_data which is of type RetainPtr<CFMutableDataRef>. I can't change its type because PDFPlugin CFDataAppendBytes to the m_data at some point.
WebKit Commit Bot
Comment 41
2017-11-28 15:09:46 PST
Comment on
attachment 327778
[details]
Patch Clearing flags on attachment: 327778 Committed
r225241
: <
https://trac.webkit.org/changeset/225241
>
WebKit Commit Bot
Comment 42
2017-11-28 15:09:48 PST
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug