REGRESSION (r203378): [iOS] The PDF image is rendered stretched if a sub image of...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Aug 2016 19:18:29 +0000 (19:18 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Aug 2016 19:18:29 +0000 (19:18 +0000)
commit3095943c770b33159f73cb69a2184f7a31376f9a
tree96e29c9928839fa91b78e92869a9755b4c68c6ee
parent8aa3538c453fb9450328c8b860409711fb7ad84f
REGRESSION (r203378): [iOS] The PDF image is rendered stretched if a sub image of it is cached first
https://bugs.webkit.org/show_bug.cgi?id=160617

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2016-08-25
Reviewed by Tim Horton.

Source/WebCore:

When caching only a sub-image of the PDF ensure the source rectangle starts
at the top-left of the cached sub-image rectangle. When drawing the cached
sub-image to the destination context ensure the destination rectangle is the
sub-image rectangle so no stretching or shrinking happens.

Test: fast/images/cached-clipped-pdf.html

* page/Settings.cpp:
(WebCore::Settings::Settings):
(WebCore::Settings::setCachedPDFImageEnabled): Deleted.
* page/Settings.h:
(WebCore::Settings::isCachedPDFImageEnabled): Deleted.
* page/Settings.in:
Change the boolean setting CachedPDFImageEnabled to be enum property and
rename it PDFImageCachingPolicy. Allow the "PDFImageCachingBelowMemoryLimit"
option to be available on a;; platforms. The "PDFImageCachingClipBoundsOnly"
option is added for testing purpose. If forces recaching the PDF with each
draw and it sets the cached image rectangle to the clipping rectangle.

* platform/graphics/cg/PDFDocumentImage.cpp:
(WebCore::PDFDocumentImage::setPdfImageCachingPolicy): Take an enum instead of boolean.
(WebCore::cachedImageRect):
(WebCore::PDFDocumentImage::decodedSizeChanged): Enable PDFImageCachingBelowMemoryLimit
on all platforms.
(WebCore::PDFDocumentImage::updateCachedImageIfNeeded): Fix the source rectangle
when caching a sub-image of the PDF.
(WebCore::PDFDocumentImage::draw): Fix the destination rectangle when drawing
a sub-image to the destination context.
(WebCore::PDFDocumentImage::setCachedPDFImageEnabled): Deleted.
* platform/graphics/cg/PDFDocumentImage.h:

* rendering/RenderImage.cpp:
(WebCore::RenderImage::paintIntoRect):

* testing/InternalSettings.cpp:
(WebCore::InternalSettings::Backup::Backup):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setPDFImageCachingPolicy):
(WebCore::InternalSettings::setCachedPDFImageEnabled): Deleted.
* testing/InternalSettings.h:
* testing/InternalSettings.idl:
Change the internal setting CachedPDFImageEnabled to PDFImageCachingPolicy.

LayoutTests:

* fast/images/cached-clipped-pdf-expected.html: Added.
* fast/images/cached-clipped-pdf.html: Added.
* fast/images/displaced-non-cached-pdf.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/images/cached-clipped-pdf-expected.html [new file with mode: 0644]
LayoutTests/fast/images/cached-clipped-pdf.html [new file with mode: 0644]
LayoutTests/fast/images/displaced-non-cached-pdf.html
Source/WebCore/ChangeLog
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.h
Source/WebCore/page/Settings.in
Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp
Source/WebCore/platform/graphics/cg/PDFDocumentImage.h
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/testing/InternalSettings.cpp
Source/WebCore/testing/InternalSettings.h
Source/WebCore/testing/InternalSettings.idl