haikuwebkit/LayoutTests/fast/hidpi/image-srcset-change-dynamic...

5 lines
312 B
Plaintext
Raw Permalink Normal View History

Use srcset's pixel density to determine intrinsic size https://bugs.webkit.org/show_bug.cgi?id=123832 Patch by Yoav Weiss <yoav@yoav.ws> on 2014-02-04 Reviewed by Dean Jackson. The patch is a port of a similar Blink patch: https://codereview.chromium.org/25105004 According to the spec "When an img element has a current pixel density that is not 1.0, the element's image data must be treated as if its resolution, in device pixels per CSS pixels, was the current pixel density." Source/WebCore: I've added that support using the following changes: - bestFitSourceForImageAttributes now returns the image candidate to HTMLImageElement. - HTMLImageElement passes the devicePixelRatio data to RenderImage, which stores it. - Bitmap images are scaled using the devicePixelRatio at RenderImageResource's intrinsicSize() and imageSize(). - SVG images are scaled using the devicePixelRatio at RenderReplaced::computeAspectRatioInformationForRenderBox. - Canvas support added at CanvasRenderingContext2D::size. Tests: fast/hidpi/image-srcset-intrinsic-size.html fast/hidpi/image-srcset-png-canvas.html fast/hidpi/image-srcset-png.html fast/hidpi/image-srcset-relative-svg-canvas-2x.html fast/hidpi/image-srcset-relative-svg.html fast/hidpi/image-srcset-space-left-nomodifier.html fast/hidpi/image-srcset-svg-canvas-2x.html fast/hidpi/image-srcset-svg-canvas.html fast/hidpi/image-srcset-svg.html fast/hidpi/image-srcset-svg2.html * html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::HTMLImageElement): (WebCore::HTMLImageElement::parseAttribute): (WebCore::HTMLImageElement::createRenderer): * html/HTMLImageElement.h: * html/canvas/CanvasRenderingContext2D.cpp: (WebCore::size): (WebCore::CanvasRenderingContext2D::drawImage): * html/parser/HTMLParserIdioms.cpp: (WebCore::compareByScaleFactor): (WebCore::parseImagesWithScaleFromSrcsetAttribute): (WebCore::bestFitSourceForImageAttributes): * html/parser/HTMLParserIdioms.h: (WebCore::ImageWithScale::ImageWithScale): (WebCore::ImageWithScale::imageURL): (WebCore::ImageWithScale::scaleFactor): * html/parser/HTMLPreloadScanner.cpp: (WebCore::TokenPreloadScanner::StartTagScanner::processAttributes): * rendering/RenderImage.cpp: (WebCore::RenderImage::RenderImage): * rendering/RenderImage.h: (WebCore::RenderImage::setImageDevicePixelRatio): (WebCore::RenderImage::imageDevicePixelRatio): * rendering/RenderImageResource.cpp: (WebCore::RenderImageResource::imageSize): (WebCore::RenderImageResource::intrinsicSize): (WebCore::RenderImageResource::getImageSize): * rendering/RenderImageResource.h: * rendering/RenderReplaced.cpp: (WebCore::RenderReplaced::computeAspectRatioInformationForRenderBox): LayoutTests: Layout test changes include modifications of existing tests to accomodate the new image dimensions, as well as new tests for this specific functionality. * fast/hidpi/image-srcset-change-dynamically-from-js-2x-expected.txt: * fast/hidpi/image-srcset-change-dynamically-from-js-2x.html: * fast/hidpi/image-srcset-data-escaped-srcset-expected.txt: * fast/hidpi/image-srcset-data-escaped-srcset.html: * fast/hidpi/image-srcset-data-src.html: * fast/hidpi/image-srcset-data-srcset.html: * fast/hidpi/image-srcset-fraction.html: * fast/hidpi/image-srcset-intrinsic-size-expected.txt: Added. * fast/hidpi/image-srcset-intrinsic-size.html: Added. * fast/hidpi/image-srcset-invalid-inputs-correct-src-expected.txt: * fast/hidpi/image-srcset-invalid-inputs-correct-src.html: * fast/hidpi/image-srcset-invalid-inputs.html: * fast/hidpi/image-srcset-invalid-inputs-expected.txt: Added. * fast/hidpi/image-srcset-only-src-attribute-expected.txt: Added. * fast/hidpi/image-srcset-only-src-attribute.html: * fast/hidpi/image-srcset-png-canvas-expected.html: Added. * fast/hidpi/image-srcset-png-canvas.html: Added. * fast/hidpi/image-srcset-png-expected.html: Added. * fast/hidpi/image-srcset-png.html: Added. * fast/hidpi/image-srcset-relative-svg-expected.html: Added. * fast/hidpi/image-srcset-relative-svg.html: Added. * fast/hidpi/image-srcset-remove-dynamically-from-js.html: * fast/hidpi/image-srcset-simple-2x-expected.txt: * fast/hidpi/image-srcset-simple-2x.html: * fast/hidpi/image-srcset-space-left-nomodifier-expected.txt: Added. * fast/hidpi/image-srcset-space-left-nomodifier.html: Copied from LayoutTests/fast/hidpi/image-srcset-data-srcset.html. * fast/hidpi/image-srcset-svg-expected.html: Added. * fast/hidpi/image-srcset-svg.html: Added. * fast/hidpi/image-srcset-svg2-expected.html: Added. * fast/hidpi/image-srcset-svg2.html: Added. * fast/hidpi/resources/green-400-px-square.png: Added. * fast/hidpi/resources/relativesrcset.svg: Added. * fast/hidpi/resources/srcset-helper.js: (runTest): * fast/hidpi/resources/srcset.png: Added. * fast/hidpi/resources/srcset.svg: Added. * fast/hidpi/resources/srcset_100px.svg: Added. * fast/hidpi/resources/svg_canvas_helper.js: Added. (drawCanvas): * fast/hidpi/resources/svg_tests.css: Added. (.test): (.test img, .test canvas): (.test .stats): (.expected, .actual): * platform/mac/fast/hidpi/image-srcset-only-src-attribute-expected.png: Removed. * platform/mac/fast/hidpi/image-srcset-only-src-attribute-expected.txt: Removed. The following tests were added, but skipped, since they reveal an unrelated SVG on canvas rendering issue: * fast/hidpi/image-srcset-svg-canvas-2x-expected.html: Added. * fast/hidpi/image-srcset-svg-canvas-2x.html: Added. * fast/hidpi/image-srcset-svg-canvas-expected.html: Added. * fast/hidpi/image-srcset-svg-canvas.html: Added. * fast/hidpi/image-srcset-relative-svg-canvas-2x-expected.html: Added. * fast/hidpi/image-srcset-relative-svg-canvas-2x.html: Added. * fast/hidpi/image-srcset-relative-svg-canvas-expected.html: Added. * fast/hidpi/image-srcset-relative-svg-canvas.html: Added. Canonical link: https://commits.webkit.org/146218@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@163415 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-02-05 00:09:15 +00:00
green-400-px-square.png has MIME type image/png
Improve srcset's layout tests https://bugs.webkit.org/show_bug.cgi?id=120274 Moved srcset's tests to use js-test-pre, and output text with clear PASS/FAILED statements. Added expected.txt files to the test directory, since there shouldn't be any platform variance in the results. For some of the tests, added an equivalent 1x/2x test, to make sure the feature behaves on both DPRs. Added preload tests on the "change-dynamically" tests, to make sure the 'src' resource is not loaded when it shouldn't. Patch by Yoav Weiss <yoav@yoav.ws> on 2013-08-25 Reviewed by Andreas Kling. * fast/hidpi/image-srcset-change-dynamically-from-js-1x-expected.txt: Added. * fast/hidpi/image-srcset-change-dynamically-from-js-1x.html: Added. * fast/hidpi/image-srcset-change-dynamically-from-js-2x-expected.txt: Added. * fast/hidpi/image-srcset-change-dynamically-from-js-2x.html: Added. * fast/hidpi/image-srcset-change-dynamically-from-js.html: Removed. * fast/hidpi/image-srcset-data-src-expected.txt: Added. * fast/hidpi/image-srcset-data-src.html: * fast/hidpi/image-srcset-data-srcset-expected.txt: Added. * fast/hidpi/image-srcset-data-srcset.html: * fast/hidpi/image-srcset-invalid-inputs-correct-src-expected.txt: Added. * fast/hidpi/image-srcset-invalid-inputs-correct-src.html: * fast/hidpi/image-srcset-invalid-inputs-except-one-expected.txt: Added. * fast/hidpi/image-srcset-invalid-inputs-except-one.html: * fast/hidpi/image-srcset-remove-dynamically-from-js-expected.txt: Added. * fast/hidpi/image-srcset-remove-dynamically-from-js.html: * fast/hidpi/image-srcset-same-alternative-for-both-attributes-expected.txt: Added. * fast/hidpi/image-srcset-same-alternative-for-both-attributes.html: * fast/hidpi/image-srcset-simple-1x-expected.txt: Added. * fast/hidpi/image-srcset-simple-1x.html: Added. * fast/hidpi/image-srcset-simple-2x-expected.txt: Added. * fast/hidpi/image-srcset-simple-2x.html: Added. * fast/hidpi/image-srcset-simple.html: Removed. * fast/hidpi/image-srcset-src-selection-1x-expected.txt: Added. * fast/hidpi/image-srcset-src-selection-1x.html: Added. * fast/hidpi/image-srcset-src-selection-2x-expected.txt: Added. * fast/hidpi/image-srcset-src-selection-2x.html: Added. * fast/hidpi/image-srcset-src-selection.html: Removed. * fast/hidpi/image-srcset-viewport-modifiers-expected.txt: Added. * fast/hidpi/image-srcset-viewport-modifiers.html: * platform/mac/fast/hidpi/image-srcset-change-dynamically-from-js-expected.txt: Removed. * platform/mac/fast/hidpi/image-srcset-data-src-expected.txt: Removed. * platform/mac/fast/hidpi/image-srcset-data-srcset-expected.txt: Removed. * platform/mac/fast/hidpi/image-srcset-invalid-inputs-correct-src-expected.txt: Removed. * platform/mac/fast/hidpi/image-srcset-invalid-inputs-except-one-expected.txt: Removed. * platform/mac/fast/hidpi/image-srcset-remove-dynamically-from-js-expected.txt: Removed. * platform/mac/fast/hidpi/image-srcset-same-alternative-for-both-attributes-expected.txt: Removed. * platform/mac/fast/hidpi/image-srcset-simple-expected.txt: Removed. * platform/mac/fast/hidpi/image-srcset-src-selection-expected.txt: Removed. * platform/mac/fast/hidpi/image-srcset-viewport-modifiers-expected.txt: Removed. Canonical link: https://commits.webkit.org/138236@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154582 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-08-25 21:43:39 +00:00
PASS document.getElementById("foo").clientWidth==200 is true
This test passes if this img tag below is a green square when the scale factor is 2. It ensures that attributes can be changed dynamically from javascript, and that only the correct resource is loaded.