Changeset 248438 in webkit
- Timestamp:
- Aug 8, 2019, 12:13:11 PM (7 years ago)
- Location:
- trunk
- 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
-
trunk/Source/WebCore/ChangeLog
r248434 r248438 1 2019-08-08 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 [iOS] Position image information should respect the image orientation 4 https://bugs.webkit.org/show_bug.cgi?id=200487 5 6 Reviewed by Simon Fraser. 7 8 Re-factor CachedImage::imageSizeForRenderer() into another overriding 9 function which does not scale the imageSize. Therefore the new function 10 returns FloatSize while the original function returns LayoutSize. 11 12 * loader/cache/CachedImage.cpp: 13 (WebCore::CachedImage::imageSizeForRenderer const): 14 * loader/cache/CachedImage.h: 15 * rendering/RenderElement.h: 16 1 17 2019-08-08 Devin Rousso <drousso@apple.com> 2 18 -
trunk/Source/WebCore/loader/cache/CachedImage.cpp
r240014 r248438 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; -
trunk/Source/WebCore/loader/cache/CachedImage.h
r240014 r248438 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 -
trunk/Source/WebCore/rendering/RenderElement.h
r245543 r248438 205 205 RenderBlock* containingBlockForAbsolutePosition() const; 206 206 207 RespectImageOrientationEnum shouldRespectImageOrientation() const;207 WEBCORE_EXPORT RespectImageOrientationEnum shouldRespectImageOrientation() const; 208 208 209 209 void removeFromRenderFragmentedFlow(); -
trunk/Source/WebKit/ChangeLog
r248436 r248438 1 2019-08-08 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 [iOS] Position image information should respect the image orientation 4 https://bugs.webkit.org/show_bug.cgi?id=200487 5 6 Reviewed by Simon Fraser. 7 8 imagePositionInformation() should respect the image orientation when 9 drawing an Image to a ShareableBitmap context. 10 11 boundsPositionInformation() already takes care of the image orientation 12 because it gets RenderImage::enclosingBoundingBox(). 13 14 * WebProcess/WebPage/ios/WebPageIOS.mm: 15 (WebKit::imagePositionInformation): 16 1 17 2019-08-08 Timothy Hatcher <timothy@apple.com> 2 18 -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r247926 r248438 2621 2621 2622 2622 FloatSize screenSizeInPixels = screenSize(); 2623 FloatSize imageSize = renderImage.cachedImage()->imageSizeForRenderer(&renderImage); 2624 2623 2625 screenSizeInPixels.scale(page.corePage()->deviceScaleFactor()); 2624 FloatSize scaledSize = largestRectWithAspectRatioInsideRect(image->size().width() / image->size().height(), FloatRect(0, 0, screenSizeInPixels.width(), screenSizeInPixels.height())).size(); 2625 FloatSize bitmapSize = scaledSize.width() < image->size().width() ? scaledSize : image->size(); 2626 FloatSize scaledSize = largestRectWithAspectRatioInsideRect(imageSize.width() / imageSize.height(), FloatRect(0, 0, screenSizeInPixels.width(), screenSizeInPixels.height())).size(); 2627 FloatSize bitmapSize = scaledSize.width() < imageSize.width() ? scaledSize : imageSize; 2628 2626 2629 // FIXME: Only select ExtendedColor on images known to need wide gamut 2627 2630 ShareableBitmap::Configuration bitmapConfiguration; … … 2636 2639 return; 2637 2640 2638 graphicsContext->drawImage(*image, FloatRect(0, 0, bitmapSize.width(), bitmapSize.height())); 2641 auto shouldRespectImageOrientation = renderImage.shouldRespectImageOrientation(); 2642 graphicsContext->drawImage(*image, FloatRect(0, 0, bitmapSize.width(), bitmapSize.height()), ImageOrientationDescription(shouldRespectImageOrientation)); 2639 2643 info.image = sharedBitmap; 2640 2644 } -
trunk/Tools/ChangeLog
r248437 r248438 1 2019-08-08 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 [iOS] Position image information should respect the image orientation 4 https://bugs.webkit.org/show_bug.cgi?id=200487 5 6 Reviewed by Simon Fraser. 7 8 Add an API test to verify the position image information is drawn rotated 9 because of respecting its image orientation. 10 11 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 12 * TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm: 13 (TestWebKitAPI::TEST): 14 * TestWebKitAPI/Tests/WebKitCocoa/exif-orientation-8-llo.jpg: Added. 15 * TestWebKitAPI/Tests/WebKitCocoa/img-with-rotated-image.html: Added. 16 1 17 2019-08-08 Claudio Saavedra <csaavedra@igalia.com> 2 18 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r248410 r248438 407 407 6BFD294C1D5E6C1D008EC968 /* HashCountedSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */; }; 408 408 725C3EF322058A5B007C36FC /* AdditionalSupportedImageTypes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 725C3EF2220584BA007C36FC /* AdditionalSupportedImageTypes.html */; }; 409 7283A9D022FA754900B21C7D /* img-with-rotated-image.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7283A9CE22FA6BBE00B21C7D /* img-with-rotated-image.html */; }; 410 7283A9D222FB1E0600B21C7D /* exif-orientation-8-llo.jpg in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7283A9D122FB1D9700B21C7D /* exif-orientation-8-llo.jpg */; }; 409 411 751B05D61F8EAC410028A09E /* DatabaseTrackerTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 751B05D51F8EAC1A0028A09E /* DatabaseTrackerTest.mm */; }; 410 412 754CEC811F6722F200D0039A /* AutoFillAvailable.mm in Sources */ = {isa = PBXBuildFile; fileRef = 754CEC801F6722DC00D0039A /* AutoFillAvailable.mm */; }; … … 1196 1198 07492B3C1DF8B86600633DE1 /* enumerateMediaDevices.html in Copy Resources */, 1197 1199 C5E1AFFE16B221F1006CC1F2 /* execCopy.html in Copy Resources */, 1200 7283A9D222FB1E0600B21C7D /* exif-orientation-8-llo.jpg in Copy Resources */, 1198 1201 CDA29B2B20FD358400F15CED /* ExitFullscreenOnEnterPiP.html in Copy Resources */, 1199 1202 F41AB9A31EF4696B0083FA08 /* file-uploading.html in Copy Resources */, … … 1238 1241 F4DEF6ED1E9B4DB60048EF61 /* image-in-link-and-input.html in Copy Resources */, 1239 1242 F45B63FB1F197F4A009D38B9 /* image-map.html in Copy Resources */, 1243 7283A9D022FA754900B21C7D /* img-with-rotated-image.html in Copy Resources */, 1240 1244 935786CD20F6A2910000CDFC /* IndexedDB.sqlite3 in Copy Resources */, 1241 1245 935786CE20F6A2A10000CDFC /* IndexedDB.sqlite3-shm in Copy Resources */, … … 1890 1894 6B9ABE112086952F00D75DE6 /* HTTPParsers.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPParsers.cpp; sourceTree = "<group>"; }; 1891 1895 725C3EF2220584BA007C36FC /* AdditionalSupportedImageTypes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = AdditionalSupportedImageTypes.html; sourceTree = "<group>"; }; 1896 7283A9CE22FA6BBE00B21C7D /* img-with-rotated-image.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "img-with-rotated-image.html"; sourceTree = "<group>"; }; 1897 7283A9D122FB1D9700B21C7D /* exif-orientation-8-llo.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "exif-orientation-8-llo.jpg"; sourceTree = "<group>"; }; 1892 1898 751B05D51F8EAC1A0028A09E /* DatabaseTrackerTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DatabaseTrackerTest.mm; sourceTree = "<group>"; }; 1893 1899 754CEC801F6722DC00D0039A /* AutoFillAvailable.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AutoFillAvailable.mm; sourceTree = "<group>"; }; … … 3161 3167 F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */, 3162 3168 F407FE381F1D0DE60017CF25 /* enormous.svg */, 3169 7283A9D122FB1D9700B21C7D /* exif-orientation-8-llo.jpg */, 3163 3170 CDA29B2A20FD344E00F15CED /* ExitFullscreenOnEnterPiP.html */, 3164 3171 F41AB99B1EF4692C0083FA08 /* file-uploading.html */, … … 3185 3192 F4DEF6EC1E9B4D950048EF61 /* image-in-link-and-input.html */, 3186 3193 F45B63FA1F197F33009D38B9 /* image-map.html */, 3194 7283A9CE22FA6BBE00B21C7D /* img-with-rotated-image.html */, 3187 3195 934FA5C720F69FEE0040DC1B /* IndexedDB.sqlite3 */, 3188 3196 934FA5C620F69FED0040DC1B /* IndexedDB.sqlite3-shm */, -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKRequestActivatedElementInfo.mm
r247342 r248438 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.