haikuwebkit/LayoutTests/svg/as-image/same-image-two-instances.html

24 lines
606 B
HTML
Raw Permalink Normal View History

2011-10-31 Nikolas Zimmermann <nzimmermann@rim.com> CSS 2.1 failure: background-intrinsic-* https://bugs.webkit.org/show_bug.cgi?id=47156 Reviewed by Antti Koivisto. Add all *intrinsic* tests from the CSS 2.1 Testsuite - we pass all of them now. All tests regarding SVG are now imported in LayoutTests, none are failing anymore. Add several new testcases covering the SVG Image size negotiation logic, as defined in CSS 2.1. * css2.1/20110323/background-intrinsic-001.htm: Added. * css2.1/20110323/background-intrinsic-002.htm: Added. * css2.1/20110323/background-intrinsic-003.htm: Added. * css2.1/20110323/background-intrinsic-004.htm: Added. * css2.1/20110323/background-intrinsic-005.htm: Added. * css2.1/20110323/background-intrinsic-006.htm: Added. * css2.1/20110323/background-intrinsic-007.htm: Added. * css2.1/20110323/background-intrinsic-008.htm: Added. * css2.1/20110323/background-intrinsic-009.htm: Added. * css2.1/20110323/resources/green-intrinsic-height-ratio.svg: Added. * css2.1/20110323/resources/green-intrinsic-height.svg: Added. * css2.1/20110323/resources/green-intrinsic-none.svg: Added. * css2.1/20110323/resources/green-intrinsic-ratio-landscape.svg: Added. * css2.1/20110323/resources/green-intrinsic-ratio-portrait.svg: Added. * css2.1/20110323/resources/green-intrinsic-width-height.svg: Added. * css2.1/20110323/resources/green-intrinsic-width-pc-height-pc.svg: Added. * css2.1/20110323/resources/green-intrinsic-width-ratio.svg: Added. * css2.1/20110323/resources/green-intrinsic-width.svg: Added. * css2.1/20110323/resources/red-intrinsic-height-ratio.svg: Added. * css2.1/20110323/resources/red-intrinsic-height.svg: Added. * css2.1/20110323/resources/red-intrinsic-none.svg: Added. * css2.1/20110323/resources/red-intrinsic-ratio-landscape.svg: Added. * css2.1/20110323/resources/red-intrinsic-ratio-portrait.svg: Added. * css2.1/20110323/resources/red-intrinsic-width-height.svg: Added. * css2.1/20110323/resources/red-intrinsic-width-pc-height-pc.svg: Added. * css2.1/20110323/resources/red-intrinsic-width-ratio.svg: Added. * css2.1/20110323/resources/red-intrinsic-width.svg: Added. * fast/backgrounds/size/contain-and-cover-zoomed.html: Added. * fast/images/percent-height-image-expected.txt: Update results, testcase is fixed now. * fast/images/percent-height-image.html: Make test async, to make it work cross-browser. With this patch we now pass this testcase. * platform/mac-snowleopard/svg/zoom/page/relative-sized-document-scrollbars-expected.png: Removed. * platform/mac-snowleopard/svg/zoom/page/zoom-foreignObject-expected.png: Removed. * platform/mac/css1/text_properties/vertical_align-expected.txt: Update for rounding differences. * platform/mac/css2.1/20110323/background-intrinsic-001-expected.png: Added. * platform/mac/css2.1/20110323/background-intrinsic-001-expected.txt: Added. * platform/mac/css2.1/20110323/background-intrinsic-002-expected.png: Added. * platform/mac/css2.1/20110323/background-intrinsic-002-expected.txt: Added. * platform/mac/css2.1/20110323/background-intrinsic-003-expected.png: Added. * platform/mac/css2.1/20110323/background-intrinsic-003-expected.txt: Added. * platform/mac/css2.1/20110323/background-intrinsic-004-expected.png: Added. * platform/mac/css2.1/20110323/background-intrinsic-004-expected.txt: Added. * platform/mac/css2.1/20110323/background-intrinsic-005-expected.png: Added. * platform/mac/css2.1/20110323/background-intrinsic-005-expected.txt: Added. * platform/mac/css2.1/20110323/background-intrinsic-006-expected.png: Added. * platform/mac/css2.1/20110323/background-intrinsic-006-expected.txt: Added. * platform/mac/css2.1/20110323/background-intrinsic-007-expected.png: Added. * platform/mac/css2.1/20110323/background-intrinsic-007-expected.txt: Added. * platform/mac/css2.1/20110323/background-intrinsic-008-expected.png: Added. * platform/mac/css2.1/20110323/background-intrinsic-008-expected.txt: Added. * platform/mac/css2.1/20110323/background-intrinsic-009-expected.png: Added. * platform/mac/css2.1/20110323/background-intrinsic-009-expected.txt: Added. * platform/mac/fast/backgrounds/size/contain-and-cover-expected.png: Updated for rounding differences. * platform/mac/fast/backgrounds/size/contain-and-cover-zoomed-expected.png: Added. * platform/mac/fast/backgrounds/size/contain-and-cover-zoomed-expected.txt: Added. * platform/mac/fast/block/float/015-expected.png: Slight changes, due 49x50 -> 50x50 size change. * platform/mac/fast/block/float/015-expected.txt: Ditto. * platform/mac/fast/block/positioning/replaced-inside-fixed-top-bottom-expected.png: Slight changes due to rounding. * platform/mac/fast/block/positioning/replaced-inside-fixed-top-bottom-expected.txt: Ditto. * platform/mac/fast/repaint/block-layout-inline-children-replaced-expected.png: Ditto. * platform/mac/fast/repaint/block-layout-inline-children-replaced-expected.txt: Ditto. * platform/mac/svg/as-background-image/background-image-preserveaspectRatio-support-expected.png: Added. * platform/mac/svg/as-background-image/background-image-preserveaspectRatio-support-expected.txt: Added. * platform/mac/svg/as-background-image/background-image-tiled-expected.png: Added. * platform/mac/svg/as-background-image/background-image-tiled-expected.txt: Added. * platform/mac/svg/as-background-image/same-image-two-instances-background-image-expected.png: Added. * platform/mac/svg/as-background-image/same-image-two-instances-background-image-expected.txt: Added. * platform/mac/svg/as-background-image/svg-as-background-4-expected.png: Adapt to preserveAspectRatio changes in hearts.svg. * platform/mac/svg/as-border-image/svg-as-border-image-expected.png: This needed a rebaseline, it was forgotten before. * platform/mac/svg/as-image/animated-svg-as-image-expected.png: Progression, now both images share the same size & ratio, as desired. * platform/mac/svg/as-image/img-preserveAspectRatio-support-1-expected.png: Added. * platform/mac/svg/as-image/img-preserveAspectRatio-support-1-expected.txt: Added. * platform/mac/svg/as-image/same-image-two-instances-expected.png: Added. * platform/mac/svg/as-image/same-image-two-instances-expected.txt: Added. * platform/mac/svg/as-image/svg-as-relative-image-expected.png: Adapt to green-relative-size-rect.svg - a circle got added to make it easier to compare. * platform/mac/svg/as-image/svg-as-relative-image-with-explicit-size-expected.png: Added. * platform/mac/svg/as-image/svg-as-relative-image-with-explicit-size-expected.txt: Added. * platform/mac/svg/as-image/svg-image-change-content-size-expected.png: Added. * platform/mac/svg/as-image/svg-image-change-content-size-expected.txt: Added. * platform/mac/svg/zoom/page/relative-sized-document-scrollbars-expected.png: Updated, scrollbars are gone - now matching Opera/FF. * platform/mac/svg/zoom/page/relative-sized-document-scrollbars-expected.txt: Ditto. * platform/mac/svg/zoom/page/zoom-background-image-tiled-expected.png: Added. * platform/mac/svg/zoom/page/zoom-background-image-tiled-expected.txt: Added. * platform/mac/svg/zoom/page/zoom-background-images-expected.png: Added. * platform/mac/svg/zoom/page/zoom-background-images-expected.txt: Added. * platform/mac/svg/zoom/page/zoom-foreignObject-expected.png: Updated, scrollbars are gone - now matching Opera/FF. * platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt: Ditto. * platform/mac/svg/zoom/page/zoom-img-preserveAspectRatio-support-1-expected.png: Added. * platform/mac/svg/zoom/page/zoom-img-preserveAspectRatio-support-1-expected.txt: Added. * platform/mac/svg/zoom/page/zoom-svg-as-background-with-relative-size-and-viewBox-expected.png: Added. * platform/mac/svg/zoom/page/zoom-svg-as-background-with-relative-size-and-viewBox-expected.txt: Added. * platform/mac/svg/zoom/page/zoom-svg-as-background-with-relative-size-expected.png: Added. * platform/mac/svg/zoom/page/zoom-svg-as-background-with-relative-size-expected.txt: Added. * platform/mac/svg/zoom/page/zoom-svg-as-image-expected.png: Added. * platform/mac/svg/zoom/page/zoom-svg-as-image-expected.txt: Added. * platform/mac/svg/zoom/page/zoom-svg-as-relative-image-expected.png: Added. * platform/mac/svg/zoom/page/zoom-svg-as-relative-image-expected.txt: Added. * svg/as-background-image/background-image-preserveaspectRatio-support.html: Added. * svg/as-background-image/background-image-tiled.html: Added. * svg/as-background-image/resources/construction-tape.svg: Added. * svg/as-background-image/resources/hearts.svg: Fix testcase, by adding pAR="none", which is now respected. Now the image looks as desired across Opera/FF and us. * svg/as-background-image/same-image-two-instances-background-image.html: Added. * svg/as-image/img-preserveAspectRatio-support-1.html: Added. * svg/as-image/resources/circle-default-meet.svg: Added. * svg/as-image/resources/circle-default-none.svg: Added. * svg/as-image/resources/circle-default-slice.svg: Added. * svg/as-image/resources/circle-nosize.svg: Added. * svg/as-image/resources/circle-viewbox-default.svg: Added. * svg/as-image/resources/circle-viewbox-meet.svg: Added. * svg/as-image/resources/circle-viewbox-none.svg: Added. * svg/as-image/resources/circle-viewbox-slice.svg: Added. * svg/as-image/resources/green-relative-size-rect.svg: Use relative units everywhere as intended. Add circle to make it easy to spot ratio changes. * svg/as-image/same-image-two-instances.html: Added. * svg/as-image/svg-as-relative-image-with-explicit-size.html: Added. * svg/as-image/svg-image-change-content-size.xhtml: Added. * svg/zoom/page/resources/relative-sized-background-with-viewBox.svg: Added. * svg/zoom/page/zoom-background-image-tiled.html: Added. * svg/zoom/page/zoom-background-images.html: Added. * svg/zoom/page/zoom-img-preserveAspectRatio-support-1.html: Added. * svg/zoom/page/zoom-svg-as-background-with-relative-size-and-viewBox.html: Added. * svg/zoom/page/zoom-svg-as-background-with-relative-size.html: Added. * svg/zoom/page/zoom-svg-as-image.html: Added. * svg/zoom/page/zoom-svg-as-relative-image.html: Added. 2011-10-31 Nikolas Zimmermann <nzimmermann@rim.com> CSS 2.1 failure: background-intrinsic-* https://bugs.webkit.org/show_bug.cgi?id=47156 SVGs do not work as tiled background images https://bugs.webkit.org/show_bug.cgi?id=16281 Apply preserveAspectRatio and synthesize viewboxes in <img> https://bugs.webkit.org/show_bug.cgi?id=34521 SVG background doesn't resize properly when dimensions are changed https://bugs.webkit.org/show_bug.cgi?id=42944 Images with percent height inside a floated div should use intrinsic height. https://bugs.webkit.org/show_bug.cgi?id=45439 SVG image in HTML changes size as the window is resized https://bugs.webkit.org/show_bug.cgi?id=52045 Reviewed by Antti Koivisto. Implement intrinsic sizing support for SVGImage (svg embedded through <html:img>/<svg:image>/background-image/border-image/...). This is demanded by CSS 2.1, and covered by new layout tests in LayoutTests/css2.1 and several new custom testcases. Tests: css2.1/20110323/background-intrinsic-001.htm css2.1/20110323/background-intrinsic-002.htm css2.1/20110323/background-intrinsic-003.htm css2.1/20110323/background-intrinsic-004.htm css2.1/20110323/background-intrinsic-005.htm css2.1/20110323/background-intrinsic-006.htm css2.1/20110323/background-intrinsic-007.htm css2.1/20110323/background-intrinsic-008.htm css2.1/20110323/background-intrinsic-009.htm svg/as-background-image/background-image-preserveaspectRatio-support.html (adapted from testcase from bug 34521) svg/as-background-image/background-image-tiled.html (reduction from bug 16281) svg/as-background-image/same-image-two-instances-background-image.html svg/as-image/img-preserveAspectRatio-support-1.html (reduction from bug 34521) svg/as-image/same-image-two-instances.html svg/as-image/svg-as-relative-image-with-explicit-size.html svg/as-image/svg-image-change-content-size.xhtml (reduction from bug 42944) svg/zoom/page/zoom-img-preserveAspectRatio-support-1.html svg/zoom/page/zoom-svg-as-image.html svg/zoom/page/zoom-svg-as-relative-image.html * css/CSSImageGeneratorValue.cpp: (WebCore::CSSImageGeneratorValue::addClient): Pass default zoom factor. (WebCore::CSSImageGeneratorValue::getImage): Ditto. * loader/cache/CachedImage.cpp: Enable SVGImage <-> IntSize cache. (WebCore::CachedImage::lookupImageForSize): Use recently introduced ImageBySizeCache, to lookup an image for a certain size. (WebCore::CachedImage::lookupOrCreateImageForRenderer): Use recently introduced ImageBySizeCache, to dynamically create copies of m_image if needed. (WebCore::CachedImage::imageForRenderer): Lookup image by renderer, which first looks up a size for a renderer, then uses lookupImageForSize(). (WebCore::CachedImage::setContainerSizeForRenderer): For SVGImages, pass on container size handling to ImageBySizeCache. (WebCore::CachedImage::imageSizeForRenderer): Figure out the image size, respecting per-renderer overrides, for a certain renderer. (WebCore::CachedImage::computeIntrinsicDimensions): Remove unnecessary RenderObject parameter. * loader/cache/CachedImage.h: * page/ChromeClient.h: (WebCore::ChromeClient::isSVGImageChromeClient): Used to identify whether a RenderSVGRoot is embedded through a SVGImage. Returns false, by default. * platform/graphics/Image.h: (WebCore::Image::setImageObserver): Add helper. * rendering/ImageBySizeCache.cpp: Cleanup code. (WebCore::ImageBySizeCache::addClient): Assert the passed renderer is valid. (WebCore::ImageBySizeCache::removeClient): Ditto. Allow removeClient() to be called w/o prio addClient() usage. (WebCore::ImageBySizeCache::getImage): Add zoom parameter. (WebCore::ImageBySizeCache::getRequestedSizeAndZoom): Add way to get requested size from cache, instead of actual cached sizes. (WebCore::ImageBySizeCache::imageForSize): Respect empty sizes, just return 0, instead of asserting. (WebCore::ImageBySizeCache::imageForRenderer): Added a helper that retrieves an image for a renderer, by lookup up its size and using imageForSize(). * rendering/ImageBySizeCache.h: Cleaup code, introduce struct that replaces the std::pair<IntSize, int>. (WebCore::SizeZoomAndCount::SizeZoomAndCount): * rendering/RenderBoxModelObject.cpp: Implement CSS 2.1 intrinsic size negotiation for images. (WebCore::resolveWidthForRatio): New inline helper function used by calculateImageIntrinsicDimensions. (WebCore::resolveHeightForRatio): Ditto. (WebCore::resolveAgainstIntrinsicWidthOrHeightAndRatio): Ditto. (WebCore::resolveAgainstIntrinsicRatio): Ditto. (WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions): New helper function, containing the main algorithm, which is a pure transcription of the spec. (WebCore::RenderBoxModelObject::calculateFillTileSize): Use new calculateImageIntrinsicDimensions() helper to figure out the intrinsic size. (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry): Propagate calculateFillTileSize() result to the image resource, via setContainerSizeForRenderer(). (WebCore::RenderBoxModelObject::paintNinePieceImage): Use new calculateImageIntrinsicDimensions() helper to figure out the intrinsic size. * rendering/RenderBoxModelObject.h: Clarify some variable names, added calculateImageIntrinsicDimensions(). * rendering/RenderImage.cpp: (WebCore::RenderImage::RenderImage): Use IntSize(), instead of IntSize(0, 0). (WebCore::RenderImage::updateIntrinsicSizeIfNeeded): Refactored from imageDimensionsChanged(). (WebCore::RenderImage::imageDimensionsChanged): Use updateIntrinsicSizeIfNeeded(). (WebCore::RenderImage::computeReplacedLogicalWidth): Use RenderReplaced::computeReplacedLogicalWidth() exclusively. For this to work, the intrinsic size must be correct. (WebCore::RenderImage::computeIntrinsicRatioInformation): Default implementation for non-SVGImages. (WebCore::RenderImage::needsPreferredWidthsRecalculation): Return true, just like RenderPart, if embeddedContentBox is not null. (WebCore::RenderImage::embeddedContentBox): Returns the RenderSVGRoot* renderer of the embedded SVG, if possible. * rendering/RenderImage.h: Remove isLogicalWidth/HeightSpecified() / computeReplacedLogicalHeight() / calcAspectRatioLogicalWidth/Height(). * rendering/RenderImageResource.cpp: (WebCore::RenderImageResource::setContainerSizeForRenderer): Pass around new "float containerZoomFactor" parameter. * rendering/RenderImageResourceStyleImage.cpp: (WebCore::RenderImageResourceStyleImage::image): embeddedContentBox() is now calling image() earlier than before. We now have to handle the case that the image is pending. (WebCore::RenderImageResourceStyleImage::setContainerSizeForRenderer): Pass zoom factor. * rendering/RenderImageResourceStyleImage.h: * rendering/RenderListMarker.cpp: (WebCore::RenderListMarker::computePreferredLogicalWidths): Pass effective zoom to setContainerSizeForRenderer(). * rendering/RenderReplaced.cpp: (WebCore::RenderReplaced::computeIntrinsicLogicalWidth): Generalized this code, as RenderImage is using it as well now. Marginal changes needed. (WebCore::RenderReplaced::computeIntrinsicLogicalHeight): Ditto. (WebCore::RenderReplaced::computeReplacedLogicalWidth): Ditto. * rendering/style/StyleCachedImage.cpp: (WebCore::StyleCachedImage::computeIntrinsicDimensions): Stop passing m_renderer to CachedImage, it's no longer needed. (WebCore::StyleCachedImage::setContainerSizeForRenderer): Add "float containerZoomFactor" parameter. * rendering/style/StyleCachedImage.h: Add "float containerZoomFactor" parameter to setContainerSizeForRenderer. * rendering/style/StyleGeneratedImage.h: (WebCore::StyleGeneratedImage::setContainerSizeForRenderer): Ditto. * rendering/style/StyleImage.h: Ditto. * rendering/style/StylePendingImage.h: (WebCore::StylePendingImage::setContainerSizeForRenderer): Ditto. * rendering/svg/RenderSVGImage.cpp: (WebCore::RenderSVGImage::layout): Always supply a container size when embedding SVGs in <svg:image>. * rendering/svg/RenderSVGRoot.cpp: Move "override container size" from SVGSVGElement into RenderSVGRoot, where it belongs. (WebCore::RenderSVGRoot::isEmbeddedThroughImageElement): Add helper method to determine whether we're loaded through SVGImage. (WebCore::RenderSVGRoot::computeReplacedLogicalWidth): If we have a valid container size, it has precendence (only supplied via external SVGImages). (WebCore::RenderSVGRoot::computeReplacedLogicalHeight): Ditto. (WebCore::RenderSVGRoot::layout): Remove calcViewport() usage, no need to track/override the viewport size anymore, all done in coputeReplacedLogical* now. (WebCore::RenderSVGRoot::paint): Use borderBoxRect() which now always matches the previously computed m_viewportSize. (WebCore::RenderSVGRoot::computeRectForRepaint): Ditto. * rendering/svg/RenderSVGRoot.h: Move "override container size" from SVGSVGElement into RenderSVGRoot, where it belongs. (WebCore::RenderSVGRoot::containerSize): (WebCore::RenderSVGRoot::setContainerSize): * svg/SVGLength.cpp: (WebCore::SVGLength::determineViewport): Resolve lengths against override container size in documents embedded through SVGImage. * svg/SVGSVGElement.cpp: Remove "override container size" handling from SVGSVGElement. (WebCore::SVGSVGElement::SVGSVGElement): Ditto. (WebCore::SVGSVGElement::currentViewBoxRect): Always synthesize a viewBox, if we're embedded through SVGImage, as demanded by SVG 1.1 2nd Edition. * svg/SVGSVGElement.h: * svg/graphics/SVGImage.cpp: (WebCore::SVGImageChromeClient::isSVGImageChromeClient): Return true, used to identify whether RenderSVGRoot is embedded through SVGImage. (WebCore::SVGImage::createWithDataAndSize): Add new helper function. (WebCore::SVGImage::setContainerZoom): Forwarded to Page::setPageZoomFactor. (WebCore::SVGImage::setContainerSize): Assert that container size is not empty. We should never receive an empty container size. (WebCore::SVGImage::usesContainerSize): Adapt to override container size changes, it now lives in RenderSVGRoot instead of SVGSVGElement. (WebCore::SVGImage::size): New algorithm to figure out the size of an embedded SVG, as demanded by the CSS/SVG specs. (WebCore::SVGImage::embeddedContentBox): Add helper which returns the RenderSVGRoot of the document. (WebCore::SVGImage::computeIntrinsicDimensions): Implement intrinsic ratio calculation. (WebCore::SVGImage::dataChanged): Force calling FrameView::setCanHaveScrollbars(false), as SVG images now always synthesize a viewBox, and thus never receive scrollbars. * svg/graphics/SVGImage.h: Canonical link: https://commits.webkit.org/87466@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@98852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2011-10-31 14:07:49 +00:00
<!DOCTYPE html>
<html>
<head>
<style>
img {
/* background-color: #EBF; */
border: 2px dashed maroon;
height: 50px;
left: 100px;
overflow: visible;
padding: 3px;
top: 20px;
width: 200px;
box-sizing: border-box;
}
</style>
</head>
<body>
<!-- None of these images must look distorted -->
<img src="resources/circle-default-default.svg" />
<img style="width: 100px; height: 100px" src="resources/circle-default-default.svg"/>
</body>
</html>