Changeset 248458 in webkit
- Timestamp:
- Aug 8, 2019, 10:01:21 PM (7 years ago)
- Location:
- branches/safari-608.1-branch
- Files:
-
- 2 added
- 9 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/loader/cache/CachedImage.cpp (modified) (1 diff)
-
Source/WebCore/loader/cache/CachedImage.h (modified) (1 diff)
-
Source/WebCore/rendering/RenderElement.h (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (modified) (2 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (modified) (6 diffs)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/exif-orientation-8-llo.jpg (added)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/img-with-rotated-image.html (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-608.1-branch/Source/WebCore/ChangeLog
r248428 r248458 1 2019-08-08 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r248438. rdar://problem/54093226 4 5 [iOS] Position image information should respect the image orientation 6 https://bugs.webkit.org/show_bug.cgi?id=200487 7 8 Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2019-08-08 9 Reviewed by Simon Fraser. 10 11 Source/WebCore: 12 13 Re-factor CachedImage::imageSizeForRenderer() into another overriding 14 function which does not scale the imageSize. Therefore the new function 15 returns FloatSize while the original function returns LayoutSize. 16 17 * loader/cache/CachedImage.cpp: 18 (WebCore::CachedImage::imageSizeForRenderer const): 19 * loader/cache/CachedImage.h: 20 * rendering/RenderElement.h: 21 22 Source/WebKit: 23 24 imagePositionInformation() should respect the image orientation when 25 drawing an Image to a ShareableBitmap context. 26 27 boundsPositionInformation() already takes care of the image orientation 28 because it gets RenderImage::enclosingBoundingBox(). 29 30 * WebProcess/WebPage/ios/WebPageIOS.mm: 31 (WebKit::imagePositionInformation): 32 33 Tools: 34 35 Add an API test to verify the position image information is drawn rotated 36 because of respecting its image orientation. 37 38 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 39 * TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm: 40 (TestWebKitAPI::TEST): 41 * TestWebKitAPI/Tests/WebKitCocoa/exif-orientation-8-llo.jpg: Added. 42 * TestWebKitAPI/Tests/WebKitCocoa/img-with-rotated-image.html: Added. 43 44 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248438 268f45cc-cd09-0410-ab3c-d52691b4dbfc 45 46 2019-08-08 Said Abou-Hallawa <sabouhallawa@apple.com> 47 48 [iOS] Position image information should respect the image orientation 49 https://bugs.webkit.org/show_bug.cgi?id=200487 50 51 Reviewed by Simon Fraser. 52 53 Re-factor CachedImage::imageSizeForRenderer() into another overriding 54 function which does not scale the imageSize. Therefore the new function 55 returns FloatSize while the original function returns LayoutSize. 56 57 * loader/cache/CachedImage.cpp: 58 (WebCore::CachedImage::imageSizeForRenderer const): 59 * loader/cache/CachedImage.h: 60 * rendering/RenderElement.h: 61 1 62 2019-08-08 Alan Coon <alancoon@apple.com> 2 63 -
branches/safari-608.1-branch/Source/WebCore/loader/cache/CachedImage.cpp
r240014 r248458 276 276 } 277 277 278 LayoutSize CachedImage::imageSizeForRenderer(const RenderElement* renderer, float multiplier, SizeType sizeType) 278 FloatSize CachedImage::imageSizeForRenderer(const RenderElement* renderer, SizeType sizeType) const 279 279 { 280 280 if (!m_image) 281 return LayoutSize(); 282 283 LayoutSize imageSize; 281 return { }; 284 282 285 283 if (is<BitmapImage>(*m_image) && renderer && renderer->shouldRespectImageOrientation() == RespectImageOrientation) 286 imageSize = LayoutSize(downcast<BitmapImage>(*m_image).sizeRespectingOrientation()); 287 else if (is<SVGImage>(*m_image) && sizeType == UsedSize) 288 imageSize = LayoutSize(m_svgImageCache->imageSizeForRenderer(renderer)); 289 else 290 imageSize = LayoutSize(m_image->size()); 291 292 if (multiplier == 1.0f) 284 return downcast<BitmapImage>(*m_image).sizeRespectingOrientation(); 285 286 if (is<SVGImage>(*m_image) && sizeType == UsedSize) 287 return m_svgImageCache->imageSizeForRenderer(renderer); 288 289 return m_image->size(); 290 } 291 292 LayoutSize CachedImage::imageSizeForRenderer(const RenderElement* renderer, float multiplier, SizeType sizeType) const 293 { 294 LayoutSize imageSize = LayoutSize(imageSizeForRenderer(renderer, sizeType)); 295 if (imageSize.isEmpty() || multiplier == 1.0f) 293 296 return imageSize; 294 297 295 298 // Don't let images that have a width/height >= 1 shrink below 1 when zoomed. 296 299 float widthScale = m_image->hasRelativeWidth() ? 1.0f : multiplier; -
branches/safari-608.1-branch/Source/WebCore/loader/cache/CachedImage.h
r240014 r248458 76 76 IntrinsicSize 77 77 }; 78 WEBCORE_EXPORT FloatSize imageSizeForRenderer(const RenderElement* renderer, SizeType = UsedSize) const; 78 79 // This method takes a zoom multiplier that can be used to increase the natural size of the image by the zoom. 79 LayoutSize imageSizeForRenderer(const RenderElement*, float multiplier, SizeType = UsedSize) ; // returns the size of the complete image.80 LayoutSize imageSizeForRenderer(const RenderElement*, float multiplier, SizeType = UsedSize) const; // returns the size of the complete image. 80 81 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio); 81 82 -
branches/safari-608.1-branch/Source/WebCore/rendering/RenderElement.h
r245543 r248458 205 205 RenderBlock* containingBlockForAbsolutePosition() const; 206 206 207 RespectImageOrientationEnum shouldRespectImageOrientation() const;207 WEBCORE_EXPORT RespectImageOrientationEnum shouldRespectImageOrientation() const; 208 208 209 209 void removeFromRenderFragmentedFlow(); -
branches/safari-608.1-branch/Source/WebKit/ChangeLog
r248457 r248458 1 2019-08-08 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r248438. rdar://problem/54093226 4 5 [iOS] Position image information should respect the image orientation 6 https://bugs.webkit.org/show_bug.cgi?id=200487 7 8 Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2019-08-08 9 Reviewed by Simon Fraser. 10 11 Source/WebCore: 12 13 Re-factor CachedImage::imageSizeForRenderer() into another overriding 14 function which does not scale the imageSize. Therefore the new function 15 returns FloatSize while the original function returns LayoutSize. 16 17 * loader/cache/CachedImage.cpp: 18 (WebCore::CachedImage::imageSizeForRenderer const): 19 * loader/cache/CachedImage.h: 20 * rendering/RenderElement.h: 21 22 Source/WebKit: 23 24 imagePositionInformation() should respect the image orientation when 25 drawing an Image to a ShareableBitmap context. 26 27 boundsPositionInformation() already takes care of the image orientation 28 because it gets RenderImage::enclosingBoundingBox(). 29 30 * WebProcess/WebPage/ios/WebPageIOS.mm: 31 (WebKit::imagePositionInformation): 32 33 Tools: 34 35 Add an API test to verify the position image information is drawn rotated 36 because of respecting its image orientation. 37 38 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 39 * TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm: 40 (TestWebKitAPI::TEST): 41 * TestWebKitAPI/Tests/WebKitCocoa/exif-orientation-8-llo.jpg: Added. 42 * TestWebKitAPI/Tests/WebKitCocoa/img-with-rotated-image.html: Added. 43 44 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248438 268f45cc-cd09-0410-ab3c-d52691b4dbfc 45 46 2019-08-08 Said Abou-Hallawa <sabouhallawa@apple.com> 47 48 [iOS] Position image information should respect the image orientation 49 https://bugs.webkit.org/show_bug.cgi?id=200487 50 51 Reviewed by Simon Fraser. 52 53 imagePositionInformation() should respect the image orientation when 54 drawing an Image to a ShareableBitmap context. 55 56 boundsPositionInformation() already takes care of the image orientation 57 because it gets RenderImage::enclosingBoundingBox(). 58 59 * WebProcess/WebPage/ios/WebPageIOS.mm: 60 (WebKit::imagePositionInformation): 61 1 62 2019-08-08 Kocsen Chung <kocsen_chung@apple.com> 2 63 -
branches/safari-608.1-branch/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r248352 r248458 2648 2648 2649 2649 FloatSize screenSizeInPixels = screenSize(); 2650 FloatSize imageSize = renderImage.cachedImage()->imageSizeForRenderer(&renderImage); 2651 2650 2652 screenSizeInPixels.scale(page.corePage()->deviceScaleFactor()); 2651 FloatSize scaledSize = largestRectWithAspectRatioInsideRect(image->size().width() / image->size().height(), FloatRect(0, 0, screenSizeInPixels.width(), screenSizeInPixels.height())).size(); 2652 FloatSize bitmapSize = scaledSize.width() < image->size().width() ? scaledSize : image->size(); 2653 FloatSize scaledSize = largestRectWithAspectRatioInsideRect(imageSize.width() / imageSize.height(), FloatRect(0, 0, screenSizeInPixels.width(), screenSizeInPixels.height())).size(); 2654 FloatSize bitmapSize = scaledSize.width() < imageSize.width() ? scaledSize : imageSize; 2655 2653 2656 // FIXME: Only select ExtendedColor on images known to need wide gamut 2654 2657 ShareableBitmap::Configuration bitmapConfiguration; … … 2663 2666 return; 2664 2667 2665 graphicsContext->drawImage(*image, FloatRect(0, 0, bitmapSize.width(), bitmapSize.height())); 2668 auto shouldRespectImageOrientation = renderImage.shouldRespectImageOrientation(); 2669 graphicsContext->drawImage(*image, FloatRect(0, 0, bitmapSize.width(), bitmapSize.height()), ImageOrientationDescription(shouldRespectImageOrientation)); 2666 2670 info.image = sharedBitmap; 2667 2671 } -
branches/safari-608.1-branch/Tools/ChangeLog
r248429 r248458 1 2019-08-08 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r248438. rdar://problem/54093226 4 5 [iOS] Position image information should respect the image orientation 6 https://bugs.webkit.org/show_bug.cgi?id=200487 7 8 Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2019-08-08 9 Reviewed by Simon Fraser. 10 11 Source/WebCore: 12 13 Re-factor CachedImage::imageSizeForRenderer() into another overriding 14 function which does not scale the imageSize. Therefore the new function 15 returns FloatSize while the original function returns LayoutSize. 16 17 * loader/cache/CachedImage.cpp: 18 (WebCore::CachedImage::imageSizeForRenderer const): 19 * loader/cache/CachedImage.h: 20 * rendering/RenderElement.h: 21 22 Source/WebKit: 23 24 imagePositionInformation() should respect the image orientation when 25 drawing an Image to a ShareableBitmap context. 26 27 boundsPositionInformation() already takes care of the image orientation 28 because it gets RenderImage::enclosingBoundingBox(). 29 30 * WebProcess/WebPage/ios/WebPageIOS.mm: 31 (WebKit::imagePositionInformation): 32 33 Tools: 34 35 Add an API test to verify the position image information is drawn rotated 36 because of respecting its image orientation. 37 38 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 39 * TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm: 40 (TestWebKitAPI::TEST): 41 * TestWebKitAPI/Tests/WebKitCocoa/exif-orientation-8-llo.jpg: Added. 42 * TestWebKitAPI/Tests/WebKitCocoa/img-with-rotated-image.html: Added. 43 44 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248438 268f45cc-cd09-0410-ab3c-d52691b4dbfc 45 46 2019-08-08 Said Abou-Hallawa <sabouhallawa@apple.com> 47 48 [iOS] Position image information should respect the image orientation 49 https://bugs.webkit.org/show_bug.cgi?id=200487 50 51 Reviewed by Simon Fraser. 52 53 Add an API test to verify the position image information is drawn rotated 54 because of respecting its image orientation. 55 56 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 57 * TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm: 58 (TestWebKitAPI::TEST): 59 * TestWebKitAPI/Tests/WebKitCocoa/exif-orientation-8-llo.jpg: Added. 60 * TestWebKitAPI/Tests/WebKitCocoa/img-with-rotated-image.html: Added. 61 1 62 2019-08-08 Alan Coon <alancoon@apple.com> 2 63 -
branches/safari-608.1-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r248428 r248458 392 392 6BFD294C1D5E6C1D008EC968 /* HashCountedSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */; }; 393 393 725C3EF322058A5B007C36FC /* AdditionalSupportedImageTypes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 725C3EF2220584BA007C36FC /* AdditionalSupportedImageTypes.html */; }; 394 7283A9D022FA754900B21C7D /* img-with-rotated-image.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7283A9CE22FA6BBE00B21C7D /* img-with-rotated-image.html */; }; 395 7283A9D222FB1E0600B21C7D /* exif-orientation-8-llo.jpg in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7283A9D122FB1D9700B21C7D /* exif-orientation-8-llo.jpg */; }; 394 396 751B05D61F8EAC410028A09E /* DatabaseTrackerTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 751B05D51F8EAC1A0028A09E /* DatabaseTrackerTest.mm */; }; 395 397 754CEC811F6722F200D0039A /* AutoFillAvailable.mm in Sources */ = {isa = PBXBuildFile; fileRef = 754CEC801F6722DC00D0039A /* AutoFillAvailable.mm */; }; … … 1177 1179 07492B3C1DF8B86600633DE1 /* enumerateMediaDevices.html in Copy Resources */, 1178 1180 C5E1AFFE16B221F1006CC1F2 /* execCopy.html in Copy Resources */, 1181 7283A9D222FB1E0600B21C7D /* exif-orientation-8-llo.jpg in Copy Resources */, 1179 1182 CDA29B2B20FD358400F15CED /* ExitFullscreenOnEnterPiP.html in Copy Resources */, 1180 1183 F41AB9A31EF4696B0083FA08 /* file-uploading.html in Copy Resources */, … … 1218 1221 F4DEF6ED1E9B4DB60048EF61 /* image-in-link-and-input.html in Copy Resources */, 1219 1222 F45B63FB1F197F4A009D38B9 /* image-map.html in Copy Resources */, 1223 7283A9D022FA754900B21C7D /* img-with-rotated-image.html in Copy Resources */, 1220 1224 935786CD20F6A2910000CDFC /* IndexedDB.sqlite3 in Copy Resources */, 1221 1225 935786CE20F6A2A10000CDFC /* IndexedDB.sqlite3-shm in Copy Resources */, … … 1867 1871 6B9ABE112086952F00D75DE6 /* HTTPParsers.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPParsers.cpp; sourceTree = "<group>"; }; 1868 1872 725C3EF2220584BA007C36FC /* AdditionalSupportedImageTypes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = AdditionalSupportedImageTypes.html; sourceTree = "<group>"; }; 1873 7283A9CE22FA6BBE00B21C7D /* img-with-rotated-image.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "img-with-rotated-image.html"; sourceTree = "<group>"; }; 1874 7283A9D122FB1D9700B21C7D /* exif-orientation-8-llo.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "exif-orientation-8-llo.jpg"; sourceTree = "<group>"; }; 1869 1875 751B05D51F8EAC1A0028A09E /* DatabaseTrackerTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DatabaseTrackerTest.mm; sourceTree = "<group>"; }; 1870 1876 754CEC801F6722DC00D0039A /* AutoFillAvailable.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AutoFillAvailable.mm; sourceTree = "<group>"; }; … … 3131 3137 F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */, 3132 3138 F407FE381F1D0DE60017CF25 /* enormous.svg */, 3139 7283A9D122FB1D9700B21C7D /* exif-orientation-8-llo.jpg */, 3133 3140 CDA29B2A20FD344E00F15CED /* ExitFullscreenOnEnterPiP.html */, 3134 3141 F41AB99B1EF4692C0083FA08 /* file-uploading.html */, … … 3155 3162 F4DEF6EC1E9B4D950048EF61 /* image-in-link-and-input.html */, 3156 3163 F45B63FA1F197F33009D38B9 /* image-map.html */, 3164 7283A9CE22FA6BBE00B21C7D /* img-with-rotated-image.html */, 3157 3165 934FA5C720F69FEE0040DC1B /* IndexedDB.sqlite3 */, 3158 3166 934FA5C620F69FED0040DC1B /* IndexedDB.sqlite3-shm */, -
branches/safari-608.1-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm
r247342 r248458 97 97 TestWebKitAPI::Util::run(&finished); 98 98 } 99 99 100 TEST(WebKit, RequestActivatedElementInfoForRotatedImage) 101 { 102 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 103 NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"img-with-rotated-image" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]; 104 105 [webView loadRequest:request]; 106 [webView _test_waitForDidFinishNavigation]; 107 108 __block bool finished = false; 109 [webView _requestActivatedElementAtPosition:CGPointMake(50, 50) completionBlock: ^(_WKActivatedElementInfo *elementInfo) { 110 111 auto image = elementInfo.image.CGImage; 112 auto data = adoptCF(CGDataProviderCopyData(CGImageGetDataProvider(image))); 113 auto buffer = reinterpret_cast<const unsigned*>(CFDataGetBytePtr(data.get())); 114 115 auto pixelAt = [&](unsigned x, unsigned y) { 116 unsigned i = y * elementInfo.image.size.width + x; 117 return buffer[i]; 118 }; 119 120 static const unsigned yellow = 0xFFFFFF00; 121 static const unsigned red = 0xFFF51900; 122 static const unsigned green = 0xFF278000; 123 static const unsigned blue = 0xFF0000FF; 124 125 EXPECT_TRUE(elementInfo.type == _WKActivatedElementTypeImage); 126 EXPECT_WK_STREQ(elementInfo.imageURL.lastPathComponent, "exif-orientation-8-llo.jpg"); 127 EXPECT_NOT_NULL(elementInfo.image); 128 EXPECT_EQ(elementInfo.boundingRect.size.width, 50); 129 EXPECT_EQ(elementInfo.boundingRect.size.height, 100); 130 EXPECT_EQ(elementInfo.image.size.width, 50); 131 EXPECT_EQ(elementInfo.image.size.height, 100); 132 133 EXPECT_EQ(pixelAt(0, 0), yellow); 134 EXPECT_EQ(pixelAt(elementInfo.image.size.width - 1, 0), red); 135 EXPECT_EQ(pixelAt(0, elementInfo.image.size.height - 1), green); 136 EXPECT_EQ(pixelAt(elementInfo.image.size.width - 1, elementInfo.image.size.height - 1), blue); 137 138 finished = true; 139 }]; 140 141 TestWebKitAPI::Util::run(&finished); 142 } 143 100 144 TEST(WebKit, RequestActivatedElementInfoForBlank) 101 145 {
Note:
See TracChangeset
for help on using the changeset viewer.