Changeset 98852 in webkit


Ignore:
Timestamp:
Oct 31, 2011 7:07:49 AM (13 years ago)
Author:
Nikolas Zimmermann
Message:

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:
Location:
trunk
Files:
100 added
2 deleted
54 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r98849 r98852  
     12011-10-31  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        CSS 2.1 failure: background-intrinsic-*
     4        https://bugs.webkit.org/show_bug.cgi?id=47156
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Add all *intrinsic* tests from the CSS 2.1 Testsuite - we pass all of them now.
     9        All tests regarding SVG are now imported in LayoutTests, none are failing anymore.
     10
     11        Add several new testcases covering the SVG Image size negotiation logic, as defined in CSS 2.1.
     12
     13        * css2.1/20110323/background-intrinsic-001.htm: Added.
     14        * css2.1/20110323/background-intrinsic-002.htm: Added.
     15        * css2.1/20110323/background-intrinsic-003.htm: Added.
     16        * css2.1/20110323/background-intrinsic-004.htm: Added.
     17        * css2.1/20110323/background-intrinsic-005.htm: Added.
     18        * css2.1/20110323/background-intrinsic-006.htm: Added.
     19        * css2.1/20110323/background-intrinsic-007.htm: Added.
     20        * css2.1/20110323/background-intrinsic-008.htm: Added.
     21        * css2.1/20110323/background-intrinsic-009.htm: Added.
     22        * css2.1/20110323/resources/green-intrinsic-height-ratio.svg: Added.
     23        * css2.1/20110323/resources/green-intrinsic-height.svg: Added.
     24        * css2.1/20110323/resources/green-intrinsic-none.svg: Added.
     25        * css2.1/20110323/resources/green-intrinsic-ratio-landscape.svg: Added.
     26        * css2.1/20110323/resources/green-intrinsic-ratio-portrait.svg: Added.
     27        * css2.1/20110323/resources/green-intrinsic-width-height.svg: Added.
     28        * css2.1/20110323/resources/green-intrinsic-width-pc-height-pc.svg: Added.
     29        * css2.1/20110323/resources/green-intrinsic-width-ratio.svg: Added.
     30        * css2.1/20110323/resources/green-intrinsic-width.svg: Added.
     31        * css2.1/20110323/resources/red-intrinsic-height-ratio.svg: Added.
     32        * css2.1/20110323/resources/red-intrinsic-height.svg: Added.
     33        * css2.1/20110323/resources/red-intrinsic-none.svg: Added.
     34        * css2.1/20110323/resources/red-intrinsic-ratio-landscape.svg: Added.
     35        * css2.1/20110323/resources/red-intrinsic-ratio-portrait.svg: Added.
     36        * css2.1/20110323/resources/red-intrinsic-width-height.svg: Added.
     37        * css2.1/20110323/resources/red-intrinsic-width-pc-height-pc.svg: Added.
     38        * css2.1/20110323/resources/red-intrinsic-width-ratio.svg: Added.
     39        * css2.1/20110323/resources/red-intrinsic-width.svg: Added.
     40        * fast/backgrounds/size/contain-and-cover-zoomed.html: Added.
     41        * fast/images/percent-height-image-expected.txt: Update results, testcase is fixed now.
     42        * fast/images/percent-height-image.html: Make test async, to make it work cross-browser. With this patch we now pass this testcase.
     43        * platform/mac-snowleopard/svg/zoom/page/relative-sized-document-scrollbars-expected.png: Removed.
     44        * platform/mac-snowleopard/svg/zoom/page/zoom-foreignObject-expected.png: Removed.
     45        * platform/mac/css1/text_properties/vertical_align-expected.txt: Update for rounding differences.
     46        * platform/mac/css2.1/20110323/background-intrinsic-001-expected.png: Added.
     47        * platform/mac/css2.1/20110323/background-intrinsic-001-expected.txt: Added.
     48        * platform/mac/css2.1/20110323/background-intrinsic-002-expected.png: Added.
     49        * platform/mac/css2.1/20110323/background-intrinsic-002-expected.txt: Added.
     50        * platform/mac/css2.1/20110323/background-intrinsic-003-expected.png: Added.
     51        * platform/mac/css2.1/20110323/background-intrinsic-003-expected.txt: Added.
     52        * platform/mac/css2.1/20110323/background-intrinsic-004-expected.png: Added.
     53        * platform/mac/css2.1/20110323/background-intrinsic-004-expected.txt: Added.
     54        * platform/mac/css2.1/20110323/background-intrinsic-005-expected.png: Added.
     55        * platform/mac/css2.1/20110323/background-intrinsic-005-expected.txt: Added.
     56        * platform/mac/css2.1/20110323/background-intrinsic-006-expected.png: Added.
     57        * platform/mac/css2.1/20110323/background-intrinsic-006-expected.txt: Added.
     58        * platform/mac/css2.1/20110323/background-intrinsic-007-expected.png: Added.
     59        * platform/mac/css2.1/20110323/background-intrinsic-007-expected.txt: Added.
     60        * platform/mac/css2.1/20110323/background-intrinsic-008-expected.png: Added.
     61        * platform/mac/css2.1/20110323/background-intrinsic-008-expected.txt: Added.
     62        * platform/mac/css2.1/20110323/background-intrinsic-009-expected.png: Added.
     63        * platform/mac/css2.1/20110323/background-intrinsic-009-expected.txt: Added.
     64        * platform/mac/fast/backgrounds/size/contain-and-cover-expected.png: Updated for rounding differences.
     65        * platform/mac/fast/backgrounds/size/contain-and-cover-zoomed-expected.png: Added.
     66        * platform/mac/fast/backgrounds/size/contain-and-cover-zoomed-expected.txt: Added.
     67        * platform/mac/fast/block/float/015-expected.png: Slight changes, due 49x50 -> 50x50 size change.
     68        * platform/mac/fast/block/float/015-expected.txt: Ditto.
     69        * platform/mac/fast/block/positioning/replaced-inside-fixed-top-bottom-expected.png: Slight changes due to rounding.
     70        * platform/mac/fast/block/positioning/replaced-inside-fixed-top-bottom-expected.txt: Ditto.
     71        * platform/mac/fast/repaint/block-layout-inline-children-replaced-expected.png: Ditto.
     72        * platform/mac/fast/repaint/block-layout-inline-children-replaced-expected.txt: Ditto.
     73        * platform/mac/svg/as-background-image/background-image-preserveaspectRatio-support-expected.png: Added.
     74        * platform/mac/svg/as-background-image/background-image-preserveaspectRatio-support-expected.txt: Added.
     75        * platform/mac/svg/as-background-image/background-image-tiled-expected.png: Added.
     76        * platform/mac/svg/as-background-image/background-image-tiled-expected.txt: Added.
     77        * platform/mac/svg/as-background-image/same-image-two-instances-background-image-expected.png: Added.
     78        * platform/mac/svg/as-background-image/same-image-two-instances-background-image-expected.txt: Added.
     79        * platform/mac/svg/as-background-image/svg-as-background-4-expected.png: Adapt to preserveAspectRatio changes in hearts.svg.
     80        * platform/mac/svg/as-border-image/svg-as-border-image-expected.png: This needed a rebaseline, it was forgotten before.
     81        * platform/mac/svg/as-image/animated-svg-as-image-expected.png: Progression, now both images share the same size & ratio, as desired.
     82        * platform/mac/svg/as-image/img-preserveAspectRatio-support-1-expected.png: Added.
     83        * platform/mac/svg/as-image/img-preserveAspectRatio-support-1-expected.txt: Added.
     84        * platform/mac/svg/as-image/same-image-two-instances-expected.png: Added.
     85        * platform/mac/svg/as-image/same-image-two-instances-expected.txt: Added.
     86        * 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.
     87        * platform/mac/svg/as-image/svg-as-relative-image-with-explicit-size-expected.png: Added.
     88        * platform/mac/svg/as-image/svg-as-relative-image-with-explicit-size-expected.txt: Added.
     89        * platform/mac/svg/as-image/svg-image-change-content-size-expected.png: Added.
     90        * platform/mac/svg/as-image/svg-image-change-content-size-expected.txt: Added.
     91        * platform/mac/svg/zoom/page/relative-sized-document-scrollbars-expected.png: Updated, scrollbars are gone - now matching Opera/FF.
     92        * platform/mac/svg/zoom/page/relative-sized-document-scrollbars-expected.txt: Ditto.
     93        * platform/mac/svg/zoom/page/zoom-background-image-tiled-expected.png: Added.
     94        * platform/mac/svg/zoom/page/zoom-background-image-tiled-expected.txt: Added.
     95        * platform/mac/svg/zoom/page/zoom-background-images-expected.png: Added.
     96        * platform/mac/svg/zoom/page/zoom-background-images-expected.txt: Added.
     97        * platform/mac/svg/zoom/page/zoom-foreignObject-expected.png: Updated, scrollbars are gone - now matching Opera/FF.
     98        * platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt: Ditto.
     99        * platform/mac/svg/zoom/page/zoom-img-preserveAspectRatio-support-1-expected.png: Added.
     100        * platform/mac/svg/zoom/page/zoom-img-preserveAspectRatio-support-1-expected.txt: Added.
     101        * platform/mac/svg/zoom/page/zoom-svg-as-background-with-relative-size-and-viewBox-expected.png: Added.
     102        * platform/mac/svg/zoom/page/zoom-svg-as-background-with-relative-size-and-viewBox-expected.txt: Added.
     103        * platform/mac/svg/zoom/page/zoom-svg-as-background-with-relative-size-expected.png: Added.
     104        * platform/mac/svg/zoom/page/zoom-svg-as-background-with-relative-size-expected.txt: Added.
     105        * platform/mac/svg/zoom/page/zoom-svg-as-image-expected.png: Added.
     106        * platform/mac/svg/zoom/page/zoom-svg-as-image-expected.txt: Added.
     107        * platform/mac/svg/zoom/page/zoom-svg-as-relative-image-expected.png: Added.
     108        * platform/mac/svg/zoom/page/zoom-svg-as-relative-image-expected.txt: Added.
     109        * svg/as-background-image/background-image-preserveaspectRatio-support.html: Added.
     110        * svg/as-background-image/background-image-tiled.html: Added.
     111        * svg/as-background-image/resources/construction-tape.svg: Added.
     112        * 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.
     113        * svg/as-background-image/same-image-two-instances-background-image.html: Added.
     114        * svg/as-image/img-preserveAspectRatio-support-1.html: Added.
     115        * svg/as-image/resources/circle-default-meet.svg: Added.
     116        * svg/as-image/resources/circle-default-none.svg: Added.
     117        * svg/as-image/resources/circle-default-slice.svg: Added.
     118        * svg/as-image/resources/circle-nosize.svg: Added.
     119        * svg/as-image/resources/circle-viewbox-default.svg: Added.
     120        * svg/as-image/resources/circle-viewbox-meet.svg: Added.
     121        * svg/as-image/resources/circle-viewbox-none.svg: Added.
     122        * svg/as-image/resources/circle-viewbox-slice.svg: Added.
     123        * 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.
     124        * svg/as-image/same-image-two-instances.html: Added.
     125        * svg/as-image/svg-as-relative-image-with-explicit-size.html: Added.
     126        * svg/as-image/svg-image-change-content-size.xhtml: Added.
     127        * svg/zoom/page/resources/relative-sized-background-with-viewBox.svg: Added.
     128        * svg/zoom/page/zoom-background-image-tiled.html: Added.
     129        * svg/zoom/page/zoom-background-images.html: Added.
     130        * svg/zoom/page/zoom-img-preserveAspectRatio-support-1.html: Added.
     131        * svg/zoom/page/zoom-svg-as-background-with-relative-size-and-viewBox.html: Added.
     132        * svg/zoom/page/zoom-svg-as-background-with-relative-size.html: Added.
     133        * svg/zoom/page/zoom-svg-as-image.html: Added.
     134        * svg/zoom/page/zoom-svg-as-relative-image.html: Added.
     135
    11362011-10-31  Vsevolod Vlasov  <vsevik@chromium.org>
    2137
  • trunk/LayoutTests/fast/images/percent-height-image-expected.txt

    r98508 r98852  
    22See Bug: http://bugs.webkit.org/show_bug.cgi?id=45439
    33
    4 FAIL: image height was 600 expected 20
     4PASS
  • trunk/LayoutTests/fast/images/percent-height-image.html

    r98508 r98852  
    55<div style="float: left;">
    66    <!-- src is a 20 x 20 PNG -->
    7     <img style="height: 100%; width: 100%;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAMAUExURQ//W/8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPzdRA4AAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjLX7mlDAAAAaUlEQVQoU23QQQ4AIQgDQPD/j5ZSCkYlxsPoSlnzT5mvu8yBjoPcULaAYG60RFxrDHsQVshvY6URsw8WjY2isnuZ3lTfudn5NEVFYmbN0BjWcYWVpU44kbKc2Hbg2KBMMyC85ph/HfipDQwyAn26rjFKAAAAAElFTkSuQmCC"/>
     7    <img style="height: 100%; width: 100%;" onload="check()" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAMAUExURQ//W/8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPzdRA4AAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjLX7mlDAAAAaUlEQVQoU23QQQ4AIQgDQPD/j5ZSCkYlxsPoSlnzT5mvu8yBjoPcULaAYG60RFxrDHsQVshvY6URsw8WjY2isnuZ3lTfudn5NEVFYmbN0BjWcYWVpU44kbKc2Hbg2KBMMyC85ph/HfipDQwyAn26rjFKAAAAAElFTkSuQmCC"/>
    88</div>
    99<pre></pre>
    1010<script>
    11     if (window.layoutTestController)
     11    if (window.layoutTestController) {
     12        layoutTestController.waitUntilDone();
    1213        layoutTestController.dumpAsText();
     14    }
    1315
    14     var expected = 20;
    15     var actual = document.querySelector("img").offsetHeight;
    16     var out = document.querySelector("pre");
    17     if (actual == expected)
    18         out.textContent = "PASS";
    19     else
    20         out.textContent = "FAIL: image height was " + actual + " expected " + expected;
     16    function check() {
     17        var expected = 20;
     18        var actual = document.querySelector("img").offsetHeight;
     19        var out = document.querySelector("pre");
     20        if (actual == expected)
     21            out.textContent = "PASS";
     22        else
     23            out.textContent = "FAIL: image height was " + actual + " expected " + expected;
     24        layoutTestController.notifyDone();
     25    }
    2126</script>
  • trunk/LayoutTests/platform/mac/css1/text_properties/vertical_align-expected.txt

    r98508 r98852  
    173173        RenderText {#text} at (80,122) size 101x22
    174174          text run at (80,122) width 101: " all of which "
    175         RenderImage {IMG} at (181,122) size 19x65
    176         RenderText {#text} at (200,122) size 5x22
    177           text run at (200,122) width 5: " "
     175        RenderImage {IMG} at (181,122) size 20x65
     176        RenderText {#text} at (201,122) size 5x22
     177          text run at (201,122) width 5: " "
    178178        RenderInline {SPAN} at (0,0) size 262x43
    179           RenderText {#text} at (205,105) size 262x43
    180             text run at (205,105) width 262: "should be aligned"
    181         RenderText {#text} at (467,122) size 5x22
    182           text run at (467,122) width 5: " "
    183         RenderImage {IMG} at (472,122) size 10x35
    184         RenderText {#text} at (482,122) size 123x22
    185           text run at (482,122) width 123: " with the top of "
    186         RenderImage {IMG} at (605,122) size 9x30
    187         RenderText {#text} at (614,122) size 5x22
    188           text run at (614,122) width 5: " "
    189         RenderInline {SPAN} at (0,0) size 731x144
    190           RenderText {#text} at (619,114) size 19x32
    191             text run at (619,114) width 19: "a "
    192           RenderInline {SPAN} at (0,0) size 731x194
    193             RenderText {#text} at (638,75) size 731x194
    194               text run at (638,75) width 93: "14-"
     179          RenderText {#text} at (206,105) size 262x43
     180            text run at (206,105) width 262: "should be aligned"
     181        RenderText {#text} at (468,122) size 5x22
     182          text run at (468,122) width 5: " "
     183        RenderImage {IMG} at (473,122) size 11x35
     184        RenderText {#text} at (484,122) size 123x22
     185          text run at (484,122) width 123: " with the top of "
     186        RenderImage {IMG} at (607,122) size 9x30
     187        RenderText {#text} at (616,122) size 5x22
     188          text run at (616,122) width 5: " "
     189        RenderInline {SPAN} at (0,0) size 733x144
     190          RenderText {#text} at (621,114) size 19x32
     191            text run at (621,114) width 19: "a "
     192          RenderInline {SPAN} at (0,0) size 733x194
     193            RenderText {#text} at (640,75) size 733x194
     194              text run at (640,75) width 93: "14-"
    195195              text run at (0,187) width 143: "point"
    196196          RenderText {#text} at (143,226) size 144x32
     
    206206        RenderText {#text} at (501,234) size 5x22
    207207          text run at (501,234) width 5: " "
    208         RenderImage {IMG} at (506,234) size 4x15
    209         RenderText {#text} at (510,234) size 5x22
    210           text run at (510,234) width 5: " "
     208        RenderImage {IMG} at (506,234) size 5x15
     209        RenderText {#text} at (511,234) size 5x22
     210          text run at (511,234) width 5: " "
    211211        RenderInline {BIG} at (0,0) size 156x24
    212           RenderText {#text} at (515,232) size 156x24
    213             text run at (515,232) width 156: "the images appear."
    214         RenderText {#text} at (671,234) size 5x22
    215           text run at (671,234) width 5: " "
    216         RenderImage {IMG} at (676,234) size 27x90
     212          RenderText {#text} at (516,232) size 156x24
     213            text run at (516,232) width 156: "the images appear."
     214        RenderText {#text} at (672,234) size 5x22
     215          text run at (672,234) width 5: " "
     216        RenderImage {IMG} at (677,234) size 27x90
    217217        RenderText {#text} at (0,0) size 0x0
    218218      RenderBlock {P} at (0,1784) size 769x36
     
    246246          text run at (696,22) width 36: " all of"
    247247          text run at (0,98) width 43: "which "
    248         RenderImage {IMG} at (43,77) size 19x65
    249         RenderText {#text} at (62,98) size 119x18
    250           text run at (62,98) width 119: " should be aligned "
    251         RenderImage {IMG} at (181,92) size 10x35
    252         RenderText {#text} at (191,98) size 4x18
    253           text run at (191,98) width 4: " "
     248        RenderImage {IMG} at (43,77) size 20x65
     249        RenderText {#text} at (63,98) size 119x18
     250          text run at (63,98) width 119: " should be aligned "
     251        RenderImage {IMG} at (182,92) size 11x35
     252        RenderText {#text} at (193,98) size 4x18
     253          text run at (193,98) width 4: " "
    254254        RenderInline {SPAN} at (0,0) size 236x37
    255           RenderText {#text} at (195,83) size 236x37
    256             text run at (195,83) width 236: "with the middle of"
    257         RenderText {#text} at (431,98) size 4x18
    258           text run at (431,98) width 4: " "
    259         RenderImage {IMG} at (435,84) size 15x50
    260         RenderText {#text} at (450,98) size 4x18
    261           text run at (450,98) width 4: " "
    262         RenderInline {SPAN} at (0,0) size 718x106
    263           RenderText {#text} at (454,90) size 17x28
    264             text run at (454,90) width 17: "a "
     255          RenderText {#text} at (197,83) size 236x37
     256            text run at (197,83) width 236: "with the middle of"
     257        RenderText {#text} at (433,98) size 4x18
     258          text run at (433,98) width 4: " "
     259        RenderImage {IMG} at (437,84) size 15x50
     260        RenderText {#text} at (452,98) size 4x18
     261          text run at (452,98) width 4: " "
     262        RenderInline {SPAN} at (0,0) size 720x106
     263          RenderText {#text} at (456,90) size 17x28
     264            text run at (456,90) width 17: "a "
    265265          RenderInline {SPAN} at (0,0) size 204x69
    266             RenderText {#text} at (471,58) size 204x69
    267               text run at (471,58) width 204: "14-point"
    268           RenderText {#text} at (675,90) size 718x106
    269             text run at (675,90) width 43: " text"
     266            RenderText {#text} at (473,58) size 204x69
     267              text run at (473,58) width 204: "14-point"
     268          RenderText {#text} at (677,90) size 720x106
     269            text run at (677,90) width 43: " text"
    270270            text run at (0,168) width 78: "element"
    271271        RenderText {#text} at (78,176) size 4x18
     
    279279        RenderText {#text} at (290,176) size 4x18
    280280          text run at (290,176) width 4: " "
    281         RenderImage {IMG} at (294,180) size 4x15
    282         RenderText {#text} at (298,176) size 4x18
    283           text run at (298,176) width 4: " "
     281        RenderImage {IMG} at (294,180) size 5x15
     282        RenderText {#text} at (299,176) size 4x18
     283          text run at (299,176) width 4: " "
    284284        RenderInline {BIG} at (0,0) size 156x24
    285           RenderText {#text} at (302,171) size 156x24
    286             text run at (302,171) width 156: "the images appear."
    287         RenderText {#text} at (458,176) size 4x18
    288           text run at (458,176) width 4: " "
    289         RenderImage {IMG} at (462,142) size 27x90
     285          RenderText {#text} at (303,171) size 156x24
     286            text run at (303,171) width 156: "the images appear."
     287        RenderText {#text} at (459,176) size 4x18
     288          text run at (459,176) width 4: " "
     289        RenderImage {IMG} at (463,142) size 27x90
    290290        RenderText {#text} at (0,0) size 0x0
    291291      RenderBlock {P} at (0,2084) size 769x36
     
    341341        RenderText {#text} at (146,46) size 4x18
    342342          text run at (146,46) width 4: " "
    343         RenderImage {IMG} at (150,46) size 19x65
    344         RenderText {#text} at (169,46) size 4x18
    345           text run at (169,46) width 4: " "
     343        RenderImage {IMG} at (150,46) size 20x65
     344        RenderText {#text} at (170,46) size 4x18
     345          text run at (170,46) width 4: " "
    346346        RenderInline {SPAN} at (0,0) size 111x18
    347           RenderText {#text} at (173,46) size 111x18
    348             text run at (173,46) width 111: "should be aligned"
    349         RenderText {#text} at (284,46) size 4x18
    350           text run at (284,46) width 4: " "
    351         RenderImage {IMG} at (288,46) size 10x35
    352         RenderText {#text} at (298,46) size 4x18
    353           text run at (298,46) width 4: " "
     347          RenderText {#text} at (174,46) size 111x18
     348            text run at (174,46) width 111: "should be aligned"
     349        RenderText {#text} at (285,46) size 4x18
     350          text run at (285,46) width 4: " "
     351        RenderImage {IMG} at (289,46) size 11x35
     352        RenderText {#text} at (300,46) size 4x18
     353          text run at (300,46) width 4: " "
    354354        RenderInline {SPAN} at (0,0) size 188x37
    355           RenderText {#text} at (302,46) size 188x37
    356             text run at (302,46) width 188: "with the top of"
    357         RenderText {#text} at (490,46) size 4x18
    358           text run at (490,46) width 4: " "
    359         RenderImage {IMG} at (494,46) size 15x50
    360         RenderText {#text} at (509,46) size 4x18
    361           text run at (509,46) width 4: " "
     355          RenderText {#text} at (304,46) size 188x37
     356            text run at (304,46) width 188: "with the top of"
     357        RenderText {#text} at (492,46) size 4x18
     358          text run at (492,46) width 4: " "
     359        RenderImage {IMG} at (496,46) size 15x50
     360        RenderText {#text} at (511,46) size 4x18
     361          text run at (511,46) width 4: " "
    362362        RenderInline {SPAN} at (0,0) size 128x18
    363           RenderText {#text} at (513,46) size 128x18
    364             text run at (513,46) width 128: "the tallest element in"
    365         RenderText {#text} at (641,46) size 4x18
    366           text run at (641,46) width 4: " "
    367         RenderImage {IMG} at (645,46) size 4x15
    368         RenderText {#text} at (649,46) size 4x18
    369           text run at (649,46) width 4: " "
    370         RenderInline {BIG} at (0,0) size 741x89
    371           RenderText {#text} at (653,46) size 741x89
    372             text run at (653,46) width 88: "whichever"
     363          RenderText {#text} at (515,46) size 128x18
     364            text run at (515,46) width 128: "the tallest element in"
     365        RenderText {#text} at (643,46) size 4x18
     366          text run at (643,46) width 4: " "
     367        RenderImage {IMG} at (647,46) size 5x15
     368        RenderText {#text} at (652,46) size 4x18
     369          text run at (652,46) width 4: " "
     370        RenderInline {BIG} at (0,0) size 744x89
     371          RenderText {#text} at (656,46) size 744x89
     372            text run at (656,46) width 88: "whichever"
    373373            text run at (0,111) width 208: "line the elements appear."
    374374        RenderText {#text} at (208,111) size 4x18
     
    517517                RenderText {#text} at (80,122) size 101x22
    518518                  text run at (80,122) width 101: " all of which "
    519                 RenderImage {IMG} at (181,122) size 19x65
    520                 RenderText {#text} at (200,122) size 5x22
    521                   text run at (200,122) width 5: " "
     519                RenderImage {IMG} at (181,122) size 20x65
     520                RenderText {#text} at (201,122) size 5x22
     521                  text run at (201,122) width 5: " "
    522522                RenderInline {SPAN} at (0,0) size 262x43
    523                   RenderText {#text} at (205,105) size 262x43
    524                     text run at (205,105) width 262: "should be aligned"
    525                 RenderText {#text} at (467,122) size 5x22
    526                   text run at (467,122) width 5: " "
    527                 RenderImage {IMG} at (472,122) size 10x35
    528                 RenderText {#text} at (482,122) size 123x22
    529                   text run at (482,122) width 123: " with the top of "
    530                 RenderImage {IMG} at (605,122) size 9x30
    531                 RenderText {#text} at (614,122) size 5x22
    532                   text run at (614,122) width 5: " "
    533                 RenderInline {SPAN} at (0,0) size 731x144
    534                   RenderText {#text} at (619,114) size 19x32
    535                     text run at (619,114) width 19: "a "
    536                   RenderInline {SPAN} at (0,0) size 731x194
    537                     RenderText {#text} at (638,75) size 731x194
    538                       text run at (638,75) width 93: "14-"
     523                  RenderText {#text} at (206,105) size 262x43
     524                    text run at (206,105) width 262: "should be aligned"
     525                RenderText {#text} at (468,122) size 5x22
     526                  text run at (468,122) width 5: " "
     527                RenderImage {IMG} at (473,122) size 11x35
     528                RenderText {#text} at (484,122) size 123x22
     529                  text run at (484,122) width 123: " with the top of "
     530                RenderImage {IMG} at (607,122) size 9x30
     531                RenderText {#text} at (616,122) size 5x22
     532                  text run at (616,122) width 5: " "
     533                RenderInline {SPAN} at (0,0) size 733x144
     534                  RenderText {#text} at (621,114) size 19x32
     535                    text run at (621,114) width 19: "a "
     536                  RenderInline {SPAN} at (0,0) size 733x194
     537                    RenderText {#text} at (640,75) size 733x194
     538                      text run at (640,75) width 93: "14-"
    539539                      text run at (0,187) width 143: "point"
    540540                  RenderText {#text} at (143,226) size 144x32
     
    550550                RenderText {#text} at (501,234) size 5x22
    551551                  text run at (501,234) width 5: " "
    552                 RenderImage {IMG} at (506,234) size 4x15
    553                 RenderText {#text} at (510,234) size 5x22
    554                   text run at (510,234) width 5: " "
     552                RenderImage {IMG} at (506,234) size 5x15
     553                RenderText {#text} at (511,234) size 5x22
     554                  text run at (511,234) width 5: " "
    555555                RenderInline {BIG} at (0,0) size 156x24
    556                   RenderText {#text} at (515,232) size 156x24
    557                     text run at (515,232) width 156: "the images appear."
    558                 RenderText {#text} at (671,234) size 5x22
    559                   text run at (671,234) width 5: " "
    560                 RenderImage {IMG} at (676,234) size 27x90
     556                  RenderText {#text} at (516,232) size 156x24
     557                    text run at (516,232) width 156: "the images appear."
     558                RenderText {#text} at (672,234) size 5x22
     559                  text run at (672,234) width 5: " "
     560                RenderImage {IMG} at (677,234) size 27x90
    561561                RenderText {#text} at (0,0) size 0x0
    562562              RenderBlock {P} at (4,1453) size 747x36
     
    590590                  text run at (696,22) width 36: " all of"
    591591                  text run at (0,98) width 43: "which "
    592                 RenderImage {IMG} at (43,77) size 19x65
    593                 RenderText {#text} at (62,98) size 119x18
    594                   text run at (62,98) width 119: " should be aligned "
    595                 RenderImage {IMG} at (181,92) size 10x35
    596                 RenderText {#text} at (191,98) size 4x18
    597                   text run at (191,98) width 4: " "
     592                RenderImage {IMG} at (43,77) size 20x65
     593                RenderText {#text} at (63,98) size 119x18
     594                  text run at (63,98) width 119: " should be aligned "
     595                RenderImage {IMG} at (182,92) size 11x35
     596                RenderText {#text} at (193,98) size 4x18
     597                  text run at (193,98) width 4: " "
    598598                RenderInline {SPAN} at (0,0) size 236x37
    599                   RenderText {#text} at (195,83) size 236x37
    600                     text run at (195,83) width 236: "with the middle of"
    601                 RenderText {#text} at (431,98) size 4x18
    602                   text run at (431,98) width 4: " "
    603                 RenderImage {IMG} at (435,84) size 15x50
    604                 RenderText {#text} at (450,98) size 4x18
    605                   text run at (450,98) width 4: " "
    606                 RenderInline {SPAN} at (0,0) size 718x106
    607                   RenderText {#text} at (454,90) size 17x28
    608                     text run at (454,90) width 17: "a "
     599                  RenderText {#text} at (197,83) size 236x37
     600                    text run at (197,83) width 236: "with the middle of"
     601                RenderText {#text} at (433,98) size 4x18
     602                  text run at (433,98) width 4: " "
     603                RenderImage {IMG} at (437,84) size 15x50
     604                RenderText {#text} at (452,98) size 4x18
     605                  text run at (452,98) width 4: " "
     606                RenderInline {SPAN} at (0,0) size 720x106
     607                  RenderText {#text} at (456,90) size 17x28
     608                    text run at (456,90) width 17: "a "
    609609                  RenderInline {SPAN} at (0,0) size 204x69
    610                     RenderText {#text} at (471,58) size 204x69
    611                       text run at (471,58) width 204: "14-point"
    612                   RenderText {#text} at (675,90) size 718x106
    613                     text run at (675,90) width 43: " text"
     610                    RenderText {#text} at (473,58) size 204x69
     611                      text run at (473,58) width 204: "14-point"
     612                  RenderText {#text} at (677,90) size 720x106
     613                    text run at (677,90) width 43: " text"
    614614                    text run at (0,168) width 78: "element"
    615615                RenderText {#text} at (78,176) size 4x18
     
    623623                RenderText {#text} at (290,176) size 4x18
    624624                  text run at (290,176) width 4: " "
    625                 RenderImage {IMG} at (294,180) size 4x15
    626                 RenderText {#text} at (298,176) size 4x18
    627                   text run at (298,176) width 4: " "
     625                RenderImage {IMG} at (294,180) size 5x15
     626                RenderText {#text} at (299,176) size 4x18
     627                  text run at (299,176) width 4: " "
    628628                RenderInline {BIG} at (0,0) size 156x24
    629                   RenderText {#text} at (302,171) size 156x24
    630                     text run at (302,171) width 156: "the images appear."
    631                 RenderText {#text} at (458,176) size 4x18
    632                   text run at (458,176) width 4: " "
    633                 RenderImage {IMG} at (462,142) size 27x90
     629                  RenderText {#text} at (303,171) size 156x24
     630                    text run at (303,171) width 156: "the images appear."
     631                RenderText {#text} at (459,176) size 4x18
     632                  text run at (459,176) width 4: " "
     633                RenderImage {IMG} at (463,142) size 27x90
    634634                RenderText {#text} at (0,0) size 0x0
    635635              RenderBlock {P} at (4,1753) size 747x36
     
    685685                RenderText {#text} at (146,46) size 4x18
    686686                  text run at (146,46) width 4: " "
    687                 RenderImage {IMG} at (150,46) size 19x65
    688                 RenderText {#text} at (169,46) size 4x18
    689                   text run at (169,46) width 4: " "
     687                RenderImage {IMG} at (150,46) size 20x65
     688                RenderText {#text} at (170,46) size 4x18
     689                  text run at (170,46) width 4: " "
    690690                RenderInline {SPAN} at (0,0) size 111x18
    691                   RenderText {#text} at (173,46) size 111x18
    692                     text run at (173,46) width 111: "should be aligned"
    693                 RenderText {#text} at (284,46) size 4x18
    694                   text run at (284,46) width 4: " "
    695                 RenderImage {IMG} at (288,46) size 10x35
    696                 RenderText {#text} at (298,46) size 4x18
    697                   text run at (298,46) width 4: " "
     691                  RenderText {#text} at (174,46) size 111x18
     692                    text run at (174,46) width 111: "should be aligned"
     693                RenderText {#text} at (285,46) size 4x18
     694                  text run at (285,46) width 4: " "
     695                RenderImage {IMG} at (289,46) size 11x35
     696                RenderText {#text} at (300,46) size 4x18
     697                  text run at (300,46) width 4: " "
    698698                RenderInline {SPAN} at (0,0) size 188x37
    699                   RenderText {#text} at (302,46) size 188x37
    700                     text run at (302,46) width 188: "with the top of"
    701                 RenderText {#text} at (490,46) size 4x18
    702                   text run at (490,46) width 4: " "
    703                 RenderImage {IMG} at (494,46) size 15x50
    704                 RenderText {#text} at (509,46) size 4x18
    705                   text run at (509,46) width 4: " "
     699                  RenderText {#text} at (304,46) size 188x37
     700                    text run at (304,46) width 188: "with the top of"
     701                RenderText {#text} at (492,46) size 4x18
     702                  text run at (492,46) width 4: " "
     703                RenderImage {IMG} at (496,46) size 15x50
     704                RenderText {#text} at (511,46) size 4x18
     705                  text run at (511,46) width 4: " "
    706706                RenderInline {SPAN} at (0,0) size 128x18
    707                   RenderText {#text} at (513,46) size 128x18
    708                     text run at (513,46) width 128: "the tallest element in"
    709                 RenderText {#text} at (641,46) size 4x18
    710                   text run at (641,46) width 4: " "
    711                 RenderImage {IMG} at (645,46) size 4x15
    712                 RenderText {#text} at (649,46) size 4x18
    713                   text run at (649,46) width 4: " "
    714                 RenderInline {BIG} at (0,0) size 741x89
    715                   RenderText {#text} at (653,46) size 741x89
    716                     text run at (653,46) width 88: "whichever"
     707                  RenderText {#text} at (515,46) size 128x18
     708                    text run at (515,46) width 128: "the tallest element in"
     709                RenderText {#text} at (643,46) size 4x18
     710                  text run at (643,46) width 4: " "
     711                RenderImage {IMG} at (647,46) size 5x15
     712                RenderText {#text} at (652,46) size 4x18
     713                  text run at (652,46) width 4: " "
     714                RenderInline {BIG} at (0,0) size 744x89
     715                  RenderText {#text} at (656,46) size 744x89
     716                    text run at (656,46) width 88: "whichever"
    717717                    text run at (0,111) width 208: "line the elements appear."
    718718                RenderText {#text} at (208,111) size 4x18
  • trunk/LayoutTests/platform/mac/fast/block/float/015-expected.txt

    r98508 r98852  
    1111                text run at (4,4) width 4: " "
    1212            RenderTableCell {TD} at (12,0) size 657x128 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]
    13               RenderImage {IMG} at (4,4) size 49x50 [bgcolor=#FFA500]
     13              RenderImage {IMG} at (4,4) size 50x50 [bgcolor=#FFA500]
    1414              RenderBlock {P} at (4,4) size 649x18
    15                 RenderText {#text} at (52,0) size 595x18
    16                   text run at (52,0) width 595: "This text should be flowing past a tall orange rectangle on the left side of the browser window."
     15                RenderText {#text} at (53,0) size 595x18
     16                  text run at (53,0) width 595: "This text should be flowing past a tall orange rectangle on the left side of the browser window."
    1717              RenderBlock {DIV} at (4,38) size 649x18 [bgcolor=#008000]
    18                 RenderBR {BR} at (52,0) size 0x18
    19               RenderImage {IMG} at (4,56) size 49x50 [bgcolor=#FFA500]
     18                RenderBR {BR} at (53,0) size 0x18
     19              RenderImage {IMG} at (4,56) size 50x50 [bgcolor=#FFA500]
    2020              RenderBlock {DIV} at (4,106) size 649x18
    2121                RenderText {#text} at (0,0) size 649x18
  • trunk/LayoutTests/platform/mac/fast/block/positioning/replaced-inside-fixed-top-bottom-expected.txt

    r98508 r98852  
    88layer at (51,140) size 560x320
    99  RenderBlock (positioned) {DIV} at (1,40) size 560x320 [border: (1px solid #FF0000)]
    10     RenderImage {IMG} at (1,1) size 392x318
     10    RenderImage {IMG} at (1,1) size 393x318
    1111    RenderText {#text} at (0,0) size 0x0
    1212    RenderText {#text} at (0,0) size 0x0
  • trunk/LayoutTests/platform/mac/fast/repaint/block-layout-inline-children-replaced-expected.txt

    r98508 r98852  
    1212      RenderBlock {DIV} at (0,34) size 800x152
    1313        RenderBlock {DIV} at (0,0) size 402x152 [border: (1px solid #DDDDDD)]
    14           RenderImage {IMG} at (155,1) size 92x100
     14          RenderImage {IMG} at (155,1) size 93x100
  • trunk/LayoutTests/platform/mac/svg/zoom/page/relative-sized-document-scrollbars-expected.txt

    r98508 r98852  
    1 layer at (0,0) size 1357x1011
    2   RenderView at (0,0) size 785x585
    3 layer at (0,0) size 1357x1011
    4   RenderSVGRoot {svg} at (12,8) size 1333x995
    5     RenderSVGPath {rect} at (12,8) size 1333x995 [stroke={[type=SOLID] [color=#000000]}] [x=7.85] [y=5.85] [width=769.30] [height=573.30]
     1layer at (0,0) size 800x600
     2  RenderView at (0,0) size 800x600
     3layer at (0,0) size 800x600
     4  RenderSVGRoot {svg} at (6,3) size 788x594
     5    RenderSVGPath {rect} at (6,3) size 788x594 [stroke={[type=SOLID] [color=#000000]}] [x=4.63] [y=3.47] [width=453.70] [height=340.28]
    66    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
  • trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt

    r98508 r98852  
    1 layer at (0,0) size 1131x843
    2   RenderView at (0,0) size 785x585
    3 layer at (0,0) size 1131x843
    4   RenderSVGRoot {svg} at (12,12) size 1119x831
     1layer at (0,0) size 800x600
     2  RenderView at (0,0) size 800x600
     3layer at (0,0) size 800x600
     4  RenderSVGRoot {svg} at (12,12) size 788x588
    55    RenderSVGForeignObject {foreignObject} at (10,10) size 580x380
    66      RenderBlock {xhtml:div} at (0,0) size 580x18
     
    1212            text run at (0,0) width 66: "and a link."
    1313        RenderBR {xhtml:br} at (66,0) size 0x18
    14     RenderSVGPath {rect} at (12,12) size 840x552 [stroke={[type=SOLID] [color=#008000]}] [x=10.00] [y=10.00] [width=580.00] [height=380.00]
     14    RenderSVGPath {rect} at (12,12) size 788x552 [stroke={[type=SOLID] [color=#008000]}] [x=10.00] [y=10.00] [width=580.00] [height=380.00]
    1515    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
  • trunk/LayoutTests/svg/as-background-image/resources/hearts.svg

    r98508 r98852  
    1 <svg width="100%" height="100%" viewBox="0 200 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
     1<svg width="100%" height="100%" preserveAspectRatio="none" viewBox="0 200 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
    22<title>Suzanne's Hearts V1.0</title><desc>Author: http://richard.warburton.it - Licence: http://creativecommons.org/licenses/publicdomain</desc>
    33<rect x="-200" y="0" width="600" height="600" fill="black" />
  • trunk/LayoutTests/svg/as-image/resources/green-relative-size-rect.svg

    r98508 r98852  
    11<svg xmlns="http://www.w3.org/2000/svg" width='100%' height='100%'>
    2     <rect fill='green' width='100px' height='100px' />
     2    <rect fill='green' width='100%' height='100%' />
     3    <circle cx="50%" cy="50%" r="10%" fill="navy"/>
    34</svg>
  • trunk/Source/WebCore/ChangeLog

    r98850 r98852  
     12011-10-31  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        CSS 2.1 failure: background-intrinsic-*
     4        https://bugs.webkit.org/show_bug.cgi?id=47156
     5
     6        SVGs do not work as tiled background images
     7        https://bugs.webkit.org/show_bug.cgi?id=16281
     8
     9        Apply preserveAspectRatio and synthesize viewboxes in <img>
     10        https://bugs.webkit.org/show_bug.cgi?id=34521
     11
     12        SVG background doesn't resize properly when dimensions are changed
     13        https://bugs.webkit.org/show_bug.cgi?id=42944
     14
     15        Images with percent height inside a floated div should use intrinsic height.
     16        https://bugs.webkit.org/show_bug.cgi?id=45439
     17
     18        SVG image in HTML changes size as the window is resized
     19        https://bugs.webkit.org/show_bug.cgi?id=52045
     20
     21        Reviewed by Antti Koivisto.
     22
     23        Implement intrinsic sizing support for SVGImage (svg embedded through <html:img>/<svg:image>/background-image/border-image/...).
     24        This is demanded by CSS 2.1, and covered by new layout tests in LayoutTests/css2.1 and several new custom testcases.
     25
     26        Tests: css2.1/20110323/background-intrinsic-001.htm
     27               css2.1/20110323/background-intrinsic-002.htm
     28               css2.1/20110323/background-intrinsic-003.htm
     29               css2.1/20110323/background-intrinsic-004.htm
     30               css2.1/20110323/background-intrinsic-005.htm
     31               css2.1/20110323/background-intrinsic-006.htm
     32               css2.1/20110323/background-intrinsic-007.htm
     33               css2.1/20110323/background-intrinsic-008.htm
     34               css2.1/20110323/background-intrinsic-009.htm
     35               svg/as-background-image/background-image-preserveaspectRatio-support.html (adapted from testcase from bug 34521)
     36               svg/as-background-image/background-image-tiled.html (reduction from bug 16281)
     37               svg/as-background-image/same-image-two-instances-background-image.html
     38               svg/as-image/img-preserveAspectRatio-support-1.html (reduction from bug 34521)
     39               svg/as-image/same-image-two-instances.html
     40               svg/as-image/svg-as-relative-image-with-explicit-size.html
     41               svg/as-image/svg-image-change-content-size.xhtml (reduction from bug 42944)
     42               svg/zoom/page/zoom-img-preserveAspectRatio-support-1.html
     43               svg/zoom/page/zoom-svg-as-image.html
     44               svg/zoom/page/zoom-svg-as-relative-image.html
     45
     46        * css/CSSImageGeneratorValue.cpp:
     47        (WebCore::CSSImageGeneratorValue::addClient): Pass default zoom factor.
     48        (WebCore::CSSImageGeneratorValue::getImage): Ditto.
     49        * loader/cache/CachedImage.cpp: Enable SVGImage <-> IntSize cache.
     50        (WebCore::CachedImage::lookupImageForSize): Use recently introduced ImageBySizeCache, to lookup an image for a certain size.
     51        (WebCore::CachedImage::lookupOrCreateImageForRenderer): Use recently introduced ImageBySizeCache, to dynamically create copies of m_image if needed.
     52        (WebCore::CachedImage::imageForRenderer): Lookup image by renderer, which first looks up a size for a renderer, then uses lookupImageForSize().
     53        (WebCore::CachedImage::setContainerSizeForRenderer): For SVGImages, pass on container size handling to ImageBySizeCache.
     54        (WebCore::CachedImage::imageSizeForRenderer): Figure out the image size, respecting per-renderer overrides, for a certain renderer.
     55        (WebCore::CachedImage::computeIntrinsicDimensions): Remove unnecessary RenderObject parameter.
     56        * loader/cache/CachedImage.h:
     57        * page/ChromeClient.h:
     58        (WebCore::ChromeClient::isSVGImageChromeClient): Used to identify whether a RenderSVGRoot is embedded through a SVGImage. Returns false, by default.
     59        * platform/graphics/Image.h:
     60        (WebCore::Image::setImageObserver): Add helper.
     61        * rendering/ImageBySizeCache.cpp: Cleanup code.
     62        (WebCore::ImageBySizeCache::addClient): Assert the passed renderer is valid.
     63        (WebCore::ImageBySizeCache::removeClient): Ditto. Allow removeClient() to be called w/o prio addClient() usage.
     64        (WebCore::ImageBySizeCache::getImage): Add zoom parameter.
     65        (WebCore::ImageBySizeCache::getRequestedSizeAndZoom): Add way to get requested size from cache, instead of actual cached sizes.
     66        (WebCore::ImageBySizeCache::imageForSize): Respect empty sizes, just return 0, instead of asserting.
     67        (WebCore::ImageBySizeCache::imageForRenderer): Added a helper that retrieves an image for a renderer, by lookup up its size and using imageForSize().
     68        * rendering/ImageBySizeCache.h: Cleaup code, introduce struct that replaces the std::pair<IntSize, int>.
     69        (WebCore::SizeZoomAndCount::SizeZoomAndCount):
     70        * rendering/RenderBoxModelObject.cpp: Implement CSS 2.1 intrinsic size negotiation for images.
     71        (WebCore::resolveWidthForRatio): New inline helper function used by calculateImageIntrinsicDimensions.
     72        (WebCore::resolveHeightForRatio): Ditto.
     73        (WebCore::resolveAgainstIntrinsicWidthOrHeightAndRatio): Ditto.
     74        (WebCore::resolveAgainstIntrinsicRatio):  Ditto.
     75        (WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions): New helper function, containing the main algorithm, which is a pure transcription of the spec.
     76        (WebCore::RenderBoxModelObject::calculateFillTileSize): Use new calculateImageIntrinsicDimensions() helper to figure out the intrinsic size.
     77        (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry): Propagate calculateFillTileSize() result to the image resource, via setContainerSizeForRenderer().
     78        (WebCore::RenderBoxModelObject::paintNinePieceImage): Use new calculateImageIntrinsicDimensions() helper to figure out the intrinsic size.
     79        * rendering/RenderBoxModelObject.h: Clarify some variable names, added calculateImageIntrinsicDimensions().
     80        * rendering/RenderImage.cpp:
     81        (WebCore::RenderImage::RenderImage): Use IntSize(), instead of IntSize(0, 0).
     82        (WebCore::RenderImage::updateIntrinsicSizeIfNeeded): Refactored from imageDimensionsChanged().
     83        (WebCore::RenderImage::imageDimensionsChanged): Use updateIntrinsicSizeIfNeeded().
     84        (WebCore::RenderImage::computeReplacedLogicalWidth): Use RenderReplaced::computeReplacedLogicalWidth() exclusively. For this to work, the intrinsic size must be correct.
     85        (WebCore::RenderImage::computeIntrinsicRatioInformation): Default implementation for non-SVGImages.
     86        (WebCore::RenderImage::needsPreferredWidthsRecalculation): Return true, just like RenderPart, if embeddedContentBox is not null.
     87        (WebCore::RenderImage::embeddedContentBox): Returns the RenderSVGRoot* renderer of the embedded SVG, if possible.
     88        * rendering/RenderImage.h: Remove isLogicalWidth/HeightSpecified() / computeReplacedLogicalHeight() / calcAspectRatioLogicalWidth/Height().
     89        * rendering/RenderImageResource.cpp:
     90        (WebCore::RenderImageResource::setContainerSizeForRenderer): Pass around new "float containerZoomFactor" parameter.
     91        * rendering/RenderImageResourceStyleImage.cpp:
     92        (WebCore::RenderImageResourceStyleImage::image): embeddedContentBox() is now calling image() earlier than before. We now have to handle the case that the image is pending.
     93        (WebCore::RenderImageResourceStyleImage::setContainerSizeForRenderer): Pass zoom factor.
     94        * rendering/RenderImageResourceStyleImage.h:
     95        * rendering/RenderListMarker.cpp:
     96        (WebCore::RenderListMarker::computePreferredLogicalWidths): Pass effective zoom to setContainerSizeForRenderer().
     97        * rendering/RenderReplaced.cpp:
     98        (WebCore::RenderReplaced::computeIntrinsicLogicalWidth): Generalized this code, as RenderImage is using it as well now. Marginal changes needed.
     99        (WebCore::RenderReplaced::computeIntrinsicLogicalHeight): Ditto.
     100        (WebCore::RenderReplaced::computeReplacedLogicalWidth): Ditto.
     101        * rendering/style/StyleCachedImage.cpp:
     102        (WebCore::StyleCachedImage::computeIntrinsicDimensions): Stop passing m_renderer to CachedImage, it's no longer needed.
     103        (WebCore::StyleCachedImage::setContainerSizeForRenderer): Add "float containerZoomFactor" parameter.
     104        * rendering/style/StyleCachedImage.h: Add "float containerZoomFactor" parameter to setContainerSizeForRenderer.
     105        * rendering/style/StyleGeneratedImage.h:
     106        (WebCore::StyleGeneratedImage::setContainerSizeForRenderer): Ditto.
     107        * rendering/style/StyleImage.h: Ditto.
     108        * rendering/style/StylePendingImage.h:
     109        (WebCore::StylePendingImage::setContainerSizeForRenderer): Ditto.
     110        * rendering/svg/RenderSVGImage.cpp:
     111        (WebCore::RenderSVGImage::layout): Always supply a container size when embedding SVGs in <svg:image>.
     112        * rendering/svg/RenderSVGRoot.cpp: Move "override container size" from SVGSVGElement into RenderSVGRoot, where it belongs.
     113        (WebCore::RenderSVGRoot::isEmbeddedThroughImageElement): Add helper method to determine whether we're loaded through SVGImage.
     114        (WebCore::RenderSVGRoot::computeReplacedLogicalWidth): If we have a valid container size, it has precendence (only supplied via external SVGImages).
     115        (WebCore::RenderSVGRoot::computeReplacedLogicalHeight): Ditto.
     116        (WebCore::RenderSVGRoot::layout): Remove calcViewport() usage, no need to track/override the viewport size anymore, all done in coputeReplacedLogical* now.
     117        (WebCore::RenderSVGRoot::paint): Use borderBoxRect() which now always matches the previously computed m_viewportSize.
     118        (WebCore::RenderSVGRoot::computeRectForRepaint): Ditto.
     119        * rendering/svg/RenderSVGRoot.h: Move "override container size" from SVGSVGElement into RenderSVGRoot, where it belongs.
     120        (WebCore::RenderSVGRoot::containerSize):
     121        (WebCore::RenderSVGRoot::setContainerSize):
     122        * svg/SVGLength.cpp:
     123        (WebCore::SVGLength::determineViewport): Resolve lengths against override container size in documents embedded through SVGImage.
     124        * svg/SVGSVGElement.cpp: Remove "override container size" handling from SVGSVGElement.
     125        (WebCore::SVGSVGElement::SVGSVGElement): Ditto.
     126        (WebCore::SVGSVGElement::currentViewBoxRect): Always synthesize a viewBox, if we're embedded through SVGImage, as demanded by SVG 1.1 2nd Edition.
     127        * svg/SVGSVGElement.h:
     128        * svg/graphics/SVGImage.cpp:
     129        (WebCore::SVGImageChromeClient::isSVGImageChromeClient): Return true, used to identify whether RenderSVGRoot is embedded through SVGImage.
     130        (WebCore::SVGImage::createWithDataAndSize): Add new helper function.
     131        (WebCore::SVGImage::setContainerZoom): Forwarded to Page::setPageZoomFactor.
     132        (WebCore::SVGImage::setContainerSize): Assert that container size is not empty. We should never receive an empty container size.
     133        (WebCore::SVGImage::usesContainerSize): Adapt to override container size changes, it now lives in RenderSVGRoot instead of SVGSVGElement.
     134        (WebCore::SVGImage::size): New algorithm to figure out the size of an embedded SVG, as demanded by the CSS/SVG specs.
     135        (WebCore::SVGImage::embeddedContentBox): Add helper which returns the RenderSVGRoot of the document.
     136        (WebCore::SVGImage::computeIntrinsicDimensions): Implement intrinsic ratio calculation.
     137        (WebCore::SVGImage::dataChanged): Force calling FrameView::setCanHaveScrollbars(false), as SVG images now always synthesize a viewBox, and thus never receive scrollbars.
     138        * svg/graphics/SVGImage.h:
     139
    11402011-10-31  Yury Semikhatsky  <yurys@chromium.org>
    2141
  • trunk/Source/WebCore/css/CSSImageGeneratorValue.cpp

    r97854 r98852  
    4848{
    4949    ref();
    50     m_imageCache.addClient(renderer, size);
     50    m_imageCache.addClient(renderer, size, 1);
    5151}
    5252
     
    6161    // If renderer is the only client, make sure we don't delete this, if the size changes (as this will result in addClient/removeClient calls).
    6262    RefPtr<CSSImageGeneratorValue> protect(this);
    63     return m_imageCache.getImage(renderer, size);
     63    return m_imageCache.getImage(renderer, size, 1);
    6464}
    6565
  • trunk/Source/WebCore/loader/cache/CachedImage.cpp

    r98508 r98852  
    3535#include "FrameLoaderTypes.h"
    3636#include "FrameView.h"
     37#include "RenderObject.h"
    3738#include "Settings.h"
    3839#include "SharedBuffer.h"
     
    131132}
    132133
    133 Image* CachedImage::lookupImageForSize(const IntSize& size) const
    134 {
    135     // FIXME: Add logic for this in webkit.org/b/47156.
    136     UNUSED_PARAM(size);
     134#if ENABLE(SVG)
     135inline Image* CachedImage::lookupImageForSize(const IntSize& size) const
     136{
     137    if (!m_image)
     138        return 0;
     139    if (!m_image->isSVGImage())
     140        return m_image.get();
     141    if (Image* image = m_svgImageCache.imageForSize(size))
     142        return image;
    137143    return m_image.get();
    138144}
    139145
    140 Image* CachedImage::lookupImageForRenderer(const RenderObject* renderer) const
    141 {
    142     // FIXME: Add logic for this in webkit.org/b/47156.
    143     UNUSED_PARAM(renderer);
     146inline Image* CachedImage::lookupOrCreateImageForRenderer(const RenderObject* renderer)
     147{
     148    if (!m_image)
     149        return 0;
     150    if (!m_image->isSVGImage())
     151        return m_image.get();
     152
     153    // Request requested size/zoom for this renderer from the cache.
     154    IntSize size;
     155    float zoom = 1;
     156    m_svgImageCache.getRequestedSizeAndZoom(renderer, size, zoom);
     157    if (size.isEmpty())
     158        return m_image.get();
     159
     160    if (Image* image = m_svgImageCache.getImage(renderer, size, zoom))
     161        return image;
     162
     163    // Create and cache new image at requested size.
     164    RefPtr<Image> newImage = SVGImage::createWithDataAndSize(this, m_data.get(), size, zoom);
     165    Image* newImagePtr = newImage.get();
     166    m_svgImageCache.addClient(renderer, size, zoom);
     167    m_svgImageCache.putImage(size, newImage.release());
     168    return newImagePtr;
     169}
     170
     171#else
     172inline Image* CachedImage::lookupImageForSize(const IntSize&) const
     173{
    144174    return m_image.get();
    145175}
    146176
    147 PassRefPtr<Image> CachedImage::lookupOrCreateImageForRenderer(const RenderObject* renderer)
    148 {
    149     // FIXME: Add logic for this in webkit.org/b/47156.
    150     UNUSED_PARAM(renderer);
    151     return m_image;
    152 }
     177inline Image* CachedImage::lookupOrCreateImageForRenderer(const RenderObject*)
     178{
     179    return m_image.get();
     180}
     181#endif
    153182
    154183Image* CachedImage::image()
     
    181210
    182211    if (m_image)
    183         return lookupOrCreateImageForRenderer(renderer).get();
     212        return lookupOrCreateImageForRenderer(renderer);
    184213
    185214    return Image::nullImage();
    186215}
    187216
    188 void CachedImage::setContainerSizeForRenderer(const RenderObject* renderer, const IntSize& containerSize)
    189 {
    190     if (!m_image)
    191         return;
    192 
    193     // FIXME: Add logic for this in webkit.org/b/47156.
     217void CachedImage::setContainerSizeForRenderer(const RenderObject* renderer, const IntSize& containerSize, float containerZoom)
     218{
     219    if (!m_image || containerSize.isEmpty())
     220        return;
     221#if ENABLE(SVG)
     222    if (!m_image->isSVGImage()) {
     223        m_image->setContainerSize(containerSize);
     224        return;
     225    }
     226    m_svgImageCache.addClient(renderer, containerSize, containerZoom);
     227#else
    194228    UNUSED_PARAM(renderer);
    195229    m_image->setContainerSize(containerSize);
     230#endif
    196231}
    197232
     
    224259    ASSERT(!isPurgeable());
    225260
    226     Image* image = lookupImageForRenderer(renderer);
    227     if (!image)
     261    if (!m_image)
    228262        return IntSize();
     263#if ENABLE(SVG)
     264    if (m_image->isSVGImage()) {
     265        // SVGImages already includes the zooming in its intrinsic size.
     266        IntSize size;
     267        float zoom = 1;
     268        m_svgImageCache.getRequestedSizeAndZoom(renderer, size, zoom);
     269        if (!size.isEmpty())
     270            return size;
     271        return m_image->size();
     272    }
     273#endif
     274
    229275    if (multiplier == 1.0f)
    230276        return m_image->size();
     
    242288}
    243289
    244 void CachedImage::computeIntrinsicDimensions(const RenderObject* renderer, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
    245 {
    246     if (Image* image = lookupImageForRenderer(renderer))
    247         image->computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intrinsicRatio);
     290void CachedImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
     291{
     292    if (m_image)
     293        m_image->computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intrinsicRatio);
    248294}
    249295
  • trunk/Source/WebCore/loader/cache/CachedImage.h

    r98508 r98852  
    5959    bool canRender(const RenderObject* renderer, float multiplier) { return !errorOccurred() && !imageSizeForRenderer(renderer, multiplier).isEmpty(); }
    6060
    61     // These are only used for SVGImage right now
    62     void setContainerSizeForRenderer(const RenderObject*, const IntSize&);
     61    void setContainerSizeForRenderer(const RenderObject*, const IntSize&, float);
    6362    bool usesImageContainerSize() const;
    6463    bool imageHasRelativeWidth() const;
     
    6766    // This method takes a zoom multiplier that can be used to increase the natural size of the image by the zoom.
    6867    IntSize imageSizeForRenderer(const RenderObject*, float multiplier); // returns the size of the complete image.
    69     void computeIntrinsicDimensions(const RenderObject*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
     68    void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
    7069
    7170    virtual void didAddClient(CachedResourceClient*);
     
    9796private:
    9897    Image* lookupImageForSize(const IntSize&) const;
    99     Image* lookupImageForRenderer(const RenderObject*) const;
    100     PassRefPtr<Image> lookupOrCreateImageForRenderer(const RenderObject*);
     98    Image* lookupOrCreateImageForRenderer(const RenderObject*);
    10199
    102100    void createImage();
  • trunk/Source/WebCore/page/ChromeClient.h

    r98508 r98852  
    337337        virtual void numWheelEventHandlersChanged(unsigned) = 0;
    338338       
     339        virtual bool isSVGImageChromeClient() const { return false; }
     340
    339341    protected:
    340342        virtual ~ChromeClient() { }
  • trunk/Source/WebCore/platform/graphics/Image.h

    r97729 r98852  
    130130    // Typically the CachedImage that owns us.
    131131    ImageObserver* imageObserver() const { return m_imageObserver; }
     132    void setImageObserver(ImageObserver* observer) { m_imageObserver = observer; }
    132133
    133134    enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile };
  • trunk/Source/WebCore/rendering/ImageBySizeCache.cpp

    r98508 r98852  
    3333}
    3434
    35 void ImageBySizeCache::addClient(const RenderObject* renderer, const IntSize& size)
     35void ImageBySizeCache::addClient(const RenderObject* renderer, const IntSize& size, float zoom)
    3636{
     37    ASSERT(renderer);
    3738    if (!size.isEmpty())
    3839        m_sizes.add(size);
     
    4041    RenderObjectSizeCountMap::iterator it = m_clients.find(renderer);
    4142    if (it == m_clients.end())
    42         m_clients.add(renderer, SizeCountPair(size, 1));
     43        m_clients.add(renderer, SizeZoomAndCount(size, zoom, 1));
    4344    else {
    44         SizeCountPair& sizeCount = it->second;
    45         ++sizeCount.second;
     45        SizeZoomAndCount& sizeCount = it->second;
     46        sizeCount.requestedSize = size;
     47        sizeCount.requestedZoom = zoom;
     48        ++sizeCount.count;
    4649    }
    4750}
     
    4952void ImageBySizeCache::removeClient(const RenderObject* renderer)
    5053{
     54    ASSERT(renderer);
    5155    RenderObjectSizeCountMap::iterator it = m_clients.find(renderer);
    5256    ASSERT(it != m_clients.end());
    5357
    54     SizeCountPair& sizeCount = it->second;
    55     IntSize size = sizeCount.first;
     58    SizeZoomAndCount& sizeCount = it->second;
     59    IntSize size = sizeCount.actualSize;
    5660    if (!size.isEmpty()) {
    5761        m_sizes.remove(size);
     
    6064    }
    6165   
    62     if (!--sizeCount.second)
     66    if (!--sizeCount.count)
    6367        m_clients.remove(renderer);
    6468}
    6569
    66 Image* ImageBySizeCache::getImage(const RenderObject* renderer, const IntSize& size)
     70Image* ImageBySizeCache::getImage(const RenderObject* renderer, const IntSize& size, float zoom)
    6771{
    6872    RenderObjectSizeCountMap::iterator it = m_clients.find(renderer);
    69     ASSERT(it != m_clients.end());
    70 
    71     SizeCountPair& sizeCount = it->second;
    72     IntSize oldSize = sizeCount.first;
    73     if (oldSize != size) {
    74         removeClient(renderer);
    75         addClient(renderer, size);
     73    if (it != m_clients.end()) {
     74        SizeZoomAndCount& sizeCount = it->second;
     75        IntSize oldSize = sizeCount.actualSize;
     76        if (oldSize != size) {
     77            removeClient(renderer);
     78            addClient(renderer, size, zoom);
     79        }
    7680    }
    7781
     
    8286    // Look up the image in our cache.
    8387    return m_images.get(size).get();
     88}
     89
     90void ImageBySizeCache::getRequestedSizeAndZoom(const RenderObject* renderer, IntSize& size, float& zoom)
     91{
     92    RenderObjectSizeCountMap::iterator it = m_clients.find(renderer);
     93    if (it == m_clients.end())
     94        return;
     95    SizeZoomAndCount& sizeCount = it->second;
     96    size = sizeCount.requestedSize;
     97    zoom = sizeCount.requestedZoom;
    8498}
    8599
     
    98112Image* ImageBySizeCache::imageForSize(const IntSize& size) const
    99113{
     114    if (size.isEmpty())
     115        return 0;
    100116    HashMap<IntSize, RefPtr<Image> >::const_iterator it = m_images.find(size);
    101117    if (it == m_images.end())
     
    104120}
    105121
    106 IntSize ImageBySizeCache::sizeForClient(const RenderObject* renderer) const
     122Image* ImageBySizeCache::imageForRenderer(const RenderObject* renderer) const
    107123{
     124    if (!renderer)
     125        return 0;
    108126    RenderObjectSizeCountMap::const_iterator it = m_clients.find(renderer);
    109127    if (it == m_clients.end())
    110         return IntSize();
    111     return it->second.first;
     128        return 0;
     129    return imageForSize(it->second.actualSize);
    112130}
    113131
  • trunk/Source/WebCore/rendering/ImageBySizeCache.h

    r98508 r98852  
    3232class RenderObject;
    3333
    34 typedef pair<IntSize, int> SizeCountPair;
    35 typedef HashMap<const RenderObject*, SizeCountPair> RenderObjectSizeCountMap;
     34struct SizeZoomAndCount {
     35    SizeZoomAndCount(IntSize newSize = IntSize(), float newZoom = 0, int newCount = 0)
     36        : actualSize(newSize)
     37        , requestedSize(newSize)
     38        , actualZoom(newZoom)
     39        , requestedZoom(newZoom)
     40        , count(newCount)
     41    {
     42    }
     43
     44    IntSize actualSize;
     45    IntSize requestedSize;
     46    float actualZoom;
     47    float requestedZoom;
     48    int count;
     49};
     50
     51typedef HashMap<const RenderObject*, SizeZoomAndCount> RenderObjectSizeCountMap;
    3652
    3753class ImageBySizeCache {
     
    3955    ImageBySizeCache();
    4056
    41     void addClient(const RenderObject*, const IntSize&);
     57    void addClient(const RenderObject*, const IntSize&, float zoom);
    4258    void removeClient(const RenderObject*);
    4359
    44     Image* getImage(const RenderObject*, const IntSize&);
     60    Image* getImage(const RenderObject*, const IntSize&, float zoom);
     61    void getRequestedSizeAndZoom(const RenderObject*, IntSize&, float& zoom);
     62
    4563    void putImage(const IntSize&, PassRefPtr<Image>);
    4664
     
    4866
    4967    Image* imageForSize(const IntSize&) const;
    50     IntSize sizeForClient(const RenderObject*) const;
     68    Image* imageForRenderer(const RenderObject*) const;
    5169    const RenderObjectSizeCountMap& clients() const { return m_clients; }
    5270
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r98508 r98852  
    783783}
    784784
    785 LayoutSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, LayoutSize positioningAreaSize) const
     785static inline LayoutUnit resolveWidthForRatio(LayoutUnit height, const FloatSize& intrinsicRatio)
     786{
     787    // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
     788    return static_cast<LayoutUnit>(ceilf(height * intrinsicRatio.width() / intrinsicRatio.height()));
     789}
     790
     791static inline LayoutUnit resolveHeightForRatio(LayoutUnit width, const FloatSize& intrinsicRatio)
     792{
     793    // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
     794    return static_cast<LayoutUnit>(ceilf(width * intrinsicRatio.height() / intrinsicRatio.width()));
     795}
     796
     797static inline LayoutSize resolveAgainstIntrinsicWidthOrHeightAndRatio(const LayoutSize& size, const FloatSize& intrinsicRatio, LayoutUnit useWidth, LayoutUnit useHeight)
     798{
     799    if (intrinsicRatio.isEmpty()) {
     800        if (useWidth)
     801            return LayoutSize(useWidth, size.height());
     802        return LayoutSize(size.width(), useHeight);
     803    }
     804
     805    if (useWidth)
     806        return LayoutSize(useWidth, resolveHeightForRatio(useWidth, intrinsicRatio));
     807    return LayoutSize(resolveWidthForRatio(useHeight, intrinsicRatio), useHeight);
     808}
     809
     810static inline LayoutSize resolveAgainstIntrinsicRatio(const LayoutSize& size, const FloatSize& intrinsicRatio)
     811{
     812    // Two possible solutions: (size.width(), solutionHeight) or (solutionWidth, size.height())
     813    // "... must be assumed to be the largest dimensions..." = easiest answer: the rect with the largest surface area.
     814
     815    LayoutUnit solutionWidth = resolveWidthForRatio(size.height(), intrinsicRatio);
     816    LayoutUnit solutionHeight = resolveHeightForRatio(size.width(), intrinsicRatio);
     817    if (solutionWidth <= size.width()) {
     818        if (solutionHeight <= size.height()) {
     819            // If both solutions fit, choose the one covering the larger area.
     820            LayoutUnit areaOne = solutionWidth * size.height();
     821            LayoutUnit areaTwo = size.width() * solutionHeight;
     822            if (areaOne < areaTwo)
     823                return LayoutSize(size.width(), solutionHeight);
     824            return LayoutSize(solutionWidth, size.height());
     825        }
     826
     827        // Only the first solution fits.
     828        return LayoutSize(solutionWidth, size.height());
     829    }
     830
     831    // Only the second solution fits, assert that.
     832    ASSERT(solutionHeight <= size.height());
     833    return LayoutSize(size.width(), solutionHeight);
     834}
     835
     836LayoutSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const LayoutSize& positioningAreaSize) const
     837{
     838    LayoutUnit resolvedWidth = 0;
     839    LayoutUnit resolvedHeight = 0;
     840    FloatSize intrinsicRatio;
     841
     842    // A generated image without a fixed size, will always return the container size as intrinsic size.
     843    if (image->isGeneratedImage() && image->usesImageContainerSize()) {
     844        resolvedWidth = positioningAreaSize.width();
     845        resolvedHeight = positioningAreaSize.height();
     846    } else {
     847        Length intrinsicWidth;
     848        Length intrinsicHeight;
     849        image->computeIntrinsicDimensions(this, intrinsicWidth, intrinsicHeight, intrinsicRatio);
     850
     851        // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
     852        if (intrinsicWidth.isFixed())
     853            resolvedWidth = static_cast<LayoutUnit>(ceilf(intrinsicWidth.value() * style()->effectiveZoom()));
     854        if (intrinsicHeight.isFixed())
     855            resolvedHeight = static_cast<LayoutUnit>(ceilf(intrinsicHeight.value() * style()->effectiveZoom()));
     856    }
     857
     858    // Intrinsic dimensions expressed as percentages must be resolved relative to the dimensions of the rectangle
     859    // that establishes the coordinate system for the 'background-position' property. SVG on the other hand
     860    // _explicitely_ says that percentage values for the width/height attributes do NOT define intrinsic dimensions.
     861    if (resolvedWidth > 0 && resolvedHeight > 0)
     862        return LayoutSize(resolvedWidth, resolvedHeight);
     863
     864    // If the image has one of either an intrinsic width or an intrinsic height:
     865    // * and an intrinsic aspect ratio, then the missing dimension is calculated from the given dimension and the ratio.
     866    // * and no intrinsic aspect ratio, then the missing dimension is assumed to be the size of the rectangle that
     867    //   establishes the coordinate system for the 'background-position' property.
     868    if ((resolvedWidth && !resolvedHeight) || (!resolvedWidth && resolvedHeight))
     869        return resolveAgainstIntrinsicWidthOrHeightAndRatio(positioningAreaSize, intrinsicRatio, resolvedWidth, resolvedHeight);
     870
     871    // If the image has no intrinsic dimensions and has an intrinsic ratio the dimensions must be assumed to be the
     872    // largest dimensions at that ratio such that neither dimension exceeds the dimensions of the rectangle that
     873    // establishes the coordinate system for the 'background-position' property.
     874    if (!resolvedWidth && !resolvedHeight && !intrinsicRatio.isEmpty())
     875        return resolveAgainstIntrinsicRatio(positioningAreaSize, intrinsicRatio);
     876
     877    // If the image has no intrinsic ratio either, then the dimensions must be assumed to be the rectangle that
     878    // establishes the coordinate system for the 'background-position' property.
     879    return positioningAreaSize;
     880}
     881
     882LayoutSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, const LayoutSize& positioningAreaSize) const
    786883{
    787884    StyleImage* image = fillLayer->image();
    788     image->setContainerSizeForRenderer(this, positioningAreaSize); // Use the box established by background-origin.
    789 
    790885    EFillSizeType type = fillLayer->size().type;
     886
     887    LayoutSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize);
    791888
    792889    switch (type) {
     
    811908            // scale to maintain our aspect ratio.
    812909            if (layerWidth.isAuto() && !layerHeight.isAuto()) {
    813                 LayoutSize imageIntrinsicSize = image->imageSize(this, style()->effectiveZoom());
    814910                if (imageIntrinsicSize.height())
    815911                    w = imageIntrinsicSize.width() * h / imageIntrinsicSize.height();       
    816912            } else if (!layerWidth.isAuto() && layerHeight.isAuto()) {
    817                 LayoutSize imageIntrinsicSize = image->imageSize(this, style()->effectiveZoom());
    818913                if (imageIntrinsicSize.width())
    819914                    h = imageIntrinsicSize.height() * w / imageIntrinsicSize.width();
    820915            } else if (layerWidth.isAuto() && layerHeight.isAuto()) {
    821916                // If both width and height are auto, use the image's intrinsic size.
    822                 LayoutSize imageIntrinsicSize = image->imageSize(this, style()->effectiveZoom());
    823917                w = imageIntrinsicSize.width();
    824918                h = imageIntrinsicSize.height();
     
    827921            return LayoutSize(max<LayoutUnit>(1, w), max<LayoutUnit>(1, h));
    828922        }
     923        case SizeNone: {
     924            // If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any.
     925            if (!imageIntrinsicSize.isEmpty())
     926                return imageIntrinsicSize;
     927
     928            // If the image has neither an intrinsic width nor an intrinsic height, its size is determined as for ‘contain’.
     929            type = Contain;
     930        }
    829931        case Contain:
    830932        case Cover: {
    831             LayoutSize imageIntrinsicSize = image->imageSize(this, 1);
    832933            float horizontalScaleFactor = imageIntrinsicSize.width()
    833934                ? static_cast<float>(positioningAreaSize.width()) / imageIntrinsicSize.width() : 1;
     
    836937            float scaleFactor = type == Contain ? min(horizontalScaleFactor, verticalScaleFactor) : max(horizontalScaleFactor, verticalScaleFactor);
    837938            return LayoutSize(max<LayoutUnit>(1, imageIntrinsicSize.width() * scaleFactor), max<LayoutUnit>(1, imageIntrinsicSize.height() * scaleFactor));
    838         }
    839         case SizeNone:
    840             break;
    841     }
    842 
    843     return image->imageSize(this, style()->effectiveZoom());
     939       }
     940    }
     941
     942    ASSERT_NOT_REACHED();
     943    return LayoutSize();
    844944}
    845945
     
    9281028    }
    9291029
    930     geometry.setTileSize(calculateFillTileSize(fillLayer, positioningAreaSize));
     1030    LayoutSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize);
     1031    fillLayer->image()->setContainerSizeForRenderer(this, fillTileSize, style()->effectiveZoom());
     1032    geometry.setTileSize(fillTileSize);
    9311033
    9321034    EFillRepeat backgroundRepeatX = fillLayer->repeatX();
     
    9881090    LayoutRect borderImageRect = LayoutRect(leftWithOutset, topWithOutset, rightWithOutset - leftWithOutset, bottomWithOutset - topWithOutset);
    9891091
    990     styleImage->setContainerSizeForRenderer(this, borderImageRect.size());
    991     LayoutSize imageSize = styleImage->imageSize(this, 1.0f);
     1092    LayoutSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size());
     1093
     1094    // If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any.
     1095    LayoutSize containerSize = imageSize.isEmpty() ? borderImageRect.size() : imageSize;
     1096    styleImage->setContainerSizeForRenderer(this, containerSize, style->effectiveZoom());
     1097
    9921098    LayoutUnit imageWidth = imageSize.width();
    9931099    LayoutUnit imageHeight = imageSize.height();
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.h

    r98508 r98852  
    196196    virtual bool isBoxModelObject() const { return true; }
    197197
    198     LayoutSize calculateFillTileSize(const FillLayer*, LayoutSize scaledSize) const;
     198    LayoutSize calculateFillTileSize(const FillLayer*, const LayoutSize& scaledPositioningAreaSize) const;
     199    LayoutSize calculateImageIntrinsicDimensions(StyleImage*, const LayoutSize& scaledPositioningAreaSize) const;
    199200
    200201    RoundedRect getBackgroundRoundedRect(const LayoutRect&, InlineFlowBox*, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight,
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r98508 r98852  
    4242#include "RenderLayer.h"
    4343#include "RenderView.h"
     44#include "SVGImage.h"
    4445#include <wtf/UnusedParam.h>
    4546
     
    5152
    5253RenderImage::RenderImage(Node* node)
    53     : RenderReplaced(node, IntSize(0, 0))
     54    : RenderReplaced(node, IntSize())
    5455    , m_needsToSetSizeForAltText(false)
    5556    , m_didIncrementVisuallyNonEmptyPixelCount(false)
     
    174175}
    175176
     177bool RenderImage::updateIntrinsicSizeIfNeeded(const LayoutSize& newSize, bool imageSizeChanged)
     178{
     179    if (newSize == intrinsicSize() && !imageSizeChanged)
     180        return false;
     181    if (m_imageResource->errorOccurred())
     182        return imageSizeChanged;
     183    setIntrinsicSize(newSize);
     184    return true;
     185}
     186
    176187void RenderImage::imageDimensionsChanged(bool imageSizeChanged, const IntRect* rect)
    177188{
    178189    bool shouldRepaint = true;
    179 
    180     if (m_imageResource->imageSize(style()->effectiveZoom()) != intrinsicSize() || imageSizeChanged) {
    181         if (!m_imageResource->errorOccurred())
    182             setIntrinsicSize(m_imageResource->imageSize(style()->effectiveZoom()));
    183 
     190    if (updateIntrinsicSizeIfNeeded(m_imageResource->imageSize(style()->effectiveZoom()), imageSizeChanged)) {
    184191        // In the case of generated image content using :before/:after, we might not be in the
    185192        // render tree yet.  In that case, we don't need to worry about check for layout, since we'll get a
     
    476483}
    477484
    478 bool RenderImage::isLogicalWidthSpecified() const
    479 {
    480     switch (style()->logicalWidth().type()) {
    481         case Fixed:
    482         case Percent:
    483             return true;
    484         case Auto:
    485         case Relative: // FIXME: Shouldn't this case return true?
    486         case Intrinsic:
    487         case MinIntrinsic:
    488             return false;
    489         case Undefined:
    490             ASSERT_NOT_REACHED();
    491             return false;
    492     }
    493     ASSERT_NOT_REACHED();
    494     return false;
    495 }
    496 
    497 bool RenderImage::isLogicalHeightSpecified() const
    498 {
    499     switch (style()->logicalHeight().type()) {
    500         case Fixed:
    501         case Percent:
    502             return true;
    503         case Auto:
    504         case Relative: // FIXME: Shouldn't this case return true?
    505         case Intrinsic:
    506         case MinIntrinsic:
    507             return false;
    508         case Undefined:
    509             ASSERT_NOT_REACHED();
    510             return false;
    511     }
    512     ASSERT_NOT_REACHED();
    513     return false;
    514 }
    515 
    516485LayoutUnit RenderImage::computeReplacedLogicalWidth(bool includeMaxWidth) const
    517486{
    518     if (m_imageResource->imageHasRelativeWidth())
    519         if (RenderObject* cb = isPositioned() ? container() : containingBlock()) {
    520             if (cb->isBox())
    521                 m_imageResource->setContainerSizeForRenderer(LayoutSize(toRenderBox(cb)->availableWidth(), toRenderBox(cb)->availableHeight()));
    522         }
    523 
    524     LayoutUnit logicalWidth;
    525     if (isLogicalWidthSpecified())
    526         logicalWidth = computeReplacedLogicalWidthUsing(style()->logicalWidth());
    527     else if (m_imageResource->usesImageContainerSize()) {
    528         LayoutSize size = m_imageResource->imageSize(style()->effectiveZoom());
    529         logicalWidth = style()->isHorizontalWritingMode() ? size.width() : size.height();
    530     } else if (m_imageResource->imageHasRelativeWidth())
    531         logicalWidth = 0; // If the image is relatively-sized, set the width to 0 until there is a set container size.
    532     else
    533         logicalWidth = calcAspectRatioLogicalWidth();
    534 
    535     return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth, includeMaxWidth);
    536 }
    537 
    538 LayoutUnit RenderImage::computeReplacedLogicalHeight() const
    539 {
    540     // FIXME: This function should use RenderReplaced::computeReplacedLogicalHeight()
    541     LayoutUnit logicalHeight;
    542     if (logicalHeightIsAuto() && !style()->logicalWidth().isAuto() && intrinsicLogicalWidth() && intrinsicLogicalHeight())
    543         logicalHeight = static_cast<LayoutUnit>(availableLogicalWidth() * intrinsicLogicalHeight() / intrinsicLogicalWidth());
    544     else if (isLogicalHeightSpecified())
    545         logicalHeight = computeReplacedLogicalHeightUsing(style()->logicalHeight());
    546     else if (m_imageResource->usesImageContainerSize()) {
    547         LayoutSize size = m_imageResource->imageSize(style()->effectiveZoom());
    548         logicalHeight = style()->isHorizontalWritingMode() ? size.height() : size.width();
    549     } else if (m_imageResource->imageHasRelativeHeight())
    550         logicalHeight = 0; // If the image is relatively-sized, set the height to 0 until there is a set container size.
    551     else
    552         logicalHeight = calcAspectRatioLogicalHeight();
    553 
    554     return computeReplacedLogicalHeightRespectingMinMaxHeight(logicalHeight);
    555 }
    556 
    557 int RenderImage::calcAspectRatioLogicalWidth() const
    558 {
    559     int intrinsicWidth = intrinsicLogicalWidth();
    560     int intrinsicHeight = intrinsicLogicalHeight();
    561     if (!intrinsicHeight)
     487    // If we've got an explicit width/height assigned, propagate it to the image resource.   
     488    if (style()->logicalWidth().isFixed() && style()->logicalHeight().isFixed()) {
     489        LayoutUnit width = RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth);
     490        m_imageResource->setContainerSizeForRenderer(IntSize(width, computeReplacedLogicalHeight()));
     491        return width;
     492    }
     493
     494    RenderBox* contentRenderer = embeddedContentBox();
     495    bool hasRelativeWidth = contentRenderer ? contentRenderer->style()->width().isPercent() : m_imageResource->imageHasRelativeWidth();
     496    bool hasRelativeHeight = contentRenderer ? contentRenderer->style()->height().isPercent() : m_imageResource->imageHasRelativeHeight();
     497
     498    LayoutSize containerSize;
     499    if (hasRelativeWidth || hasRelativeHeight) {
     500        // Propagate the containing block size to the image resource, otherwhise we can't compute our own intrinsic size, if it's relative.
     501        RenderObject* containingBlock = isPositioned() ? container() : this->containingBlock();
     502        if (containingBlock->isBox()) {
     503            RenderBox* box = toRenderBox(containingBlock);
     504            containerSize = LayoutSize(box->availableWidth(), box->availableHeight()); // Already contains zooming information.
     505        }
     506    } else {
     507        // Propagate the current zoomed image size to the image resource, otherwhise the image size will remain the same on-screen.
     508        CachedImage* cachedImage = m_imageResource->cachedImage();
     509        if (cachedImage && cachedImage->image()) {
     510            containerSize = cachedImage->image()->size();
     511            // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
     512            containerSize.setWidth(static_cast<LayoutUnit>(containerSize.width() * style()->effectiveZoom()));
     513            containerSize.setHeight(static_cast<LayoutUnit>(containerSize.height() * style()->effectiveZoom()));
     514        }
     515    }
     516
     517    if (!containerSize.isEmpty()) {
     518        m_imageResource->setContainerSizeForRenderer(containerSize);
     519        const_cast<RenderImage*>(this)->updateIntrinsicSizeIfNeeded(containerSize, false);
     520    }
     521
     522    return RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth);
     523}
     524
     525void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicRatio, bool& isPercentageIntrinsicSize) const
     526{
     527    // Assure this method is never used for SVGImages.
     528    ASSERT(!embeddedContentBox());
     529    isPercentageIntrinsicSize = false;
     530    CachedImage* cachedImage = m_imageResource ? m_imageResource->cachedImage() : 0;
     531    if (cachedImage && cachedImage->image())
     532        intrinsicRatio = cachedImage->image()->size();
     533}
     534
     535bool RenderImage::needsPreferredWidthsRecalculation() const
     536{
     537    if (RenderReplaced::needsPreferredWidthsRecalculation())
     538        return true;
     539    return embeddedContentBox();
     540}
     541
     542RenderBox* RenderImage::embeddedContentBox() const
     543{
     544    if (!m_imageResource)
    562545        return 0;
    563     if (!m_imageResource->hasImage() || m_imageResource->errorOccurred())
    564         return intrinsicWidth; // Don't bother scaling.
    565     return RenderBox::computeReplacedLogicalHeight() * intrinsicWidth / intrinsicHeight;
    566 }
    567 
    568 int RenderImage::calcAspectRatioLogicalHeight() const
    569 {
    570     int intrinsicWidth = intrinsicLogicalWidth();
    571     int intrinsicHeight = intrinsicLogicalHeight();
    572     if (!intrinsicWidth)
    573         return 0;
    574     if (!m_imageResource->hasImage() || m_imageResource->errorOccurred())
    575         return intrinsicHeight; // Don't bother scaling.
    576     return RenderBox::computeReplacedLogicalWidth() * intrinsicHeight / intrinsicWidth;
     546
     547    RefPtr<Image> image = m_imageResource->image();
     548    if (image && image->isSVGImage())
     549        return static_pointer_cast<SVGImage>(image)->embeddedContentBox();
     550
     551    return 0;
    577552}
    578553
  • trunk/Source/WebCore/rendering/RenderImage.h

    r98508 r98852  
    5555
    5656protected:
     57    virtual bool needsPreferredWidthsRecalculation() const;
     58    virtual RenderBox* embeddedContentBox() const;
     59    virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
     60
    5761    virtual void styleDidChange(StyleDifference, const RenderStyle*);
    5862
     
    6165    virtual void paintIntoRect(GraphicsContext*, const IntRect&);
    6266    virtual void paint(PaintInfo&, const LayoutPoint&);
    63 
    64     bool isLogicalWidthSpecified() const;
    65     bool isLogicalHeightSpecified() const;
    6667
    6768    virtual void intrinsicSizeChanged()
     
    8788
    8889    virtual LayoutUnit computeReplacedLogicalWidth(bool includeMaxWidth = true) const;
    89     virtual LayoutUnit computeReplacedLogicalHeight() const;
    9090
    9191    IntSize imageSizeForError(CachedImage*) const;
    9292    void imageDimensionsChanged(bool imageSizeChanged, const IntRect* = 0);
    93 
    94     int calcAspectRatioLogicalWidth() const;
    95     int calcAspectRatioLogicalHeight() const;
     93    bool updateIntrinsicSizeIfNeeded(const LayoutSize&, bool imageSizeChanged);
    9694
    9795    void paintAreaElementFocusRing(PaintInfo&);
  • trunk/Source/WebCore/rendering/RenderImageResource.cpp

    r98508 r98852  
    9494    ASSERT(m_renderer);
    9595    if (m_cachedImage)
    96         m_cachedImage->setContainerSizeForRenderer(m_renderer, imageContainerSize);
     96        m_cachedImage->setContainerSizeForRenderer(m_renderer, imageContainerSize, m_renderer->style()->effectiveZoom());
    9797}
    9898
  • trunk/Source/WebCore/rendering/RenderImageResourceStyleImage.cpp

    r98508 r98852  
    6161}
    6262
     63PassRefPtr<Image> RenderImageResourceStyleImage::image(int width, int height) const
     64{
     65    // Generated content may trigger calls to image() while we're still pending, don't assert but gracefully exit.
     66    if (m_styleImage->isPendingImage())
     67        return 0;
     68    return m_styleImage->image(m_renderer, IntSize(width, height));
     69}
     70
     71void RenderImageResourceStyleImage::setContainerSizeForRenderer(const IntSize& size)
     72{
     73    ASSERT(m_renderer);
     74    m_styleImage->setContainerSizeForRenderer(m_renderer, size, m_renderer->style()->effectiveZoom());
     75}
     76
    6377} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderImageResourceStyleImage.h

    r98508 r98852  
    4747
    4848    virtual bool hasImage() const { return true; }
    49     virtual PassRefPtr<Image> image(int width = 0, int height = 0) const { return m_styleImage->image(m_renderer, IntSize(width, height)); }
     49    virtual PassRefPtr<Image> image(int width = 0, int height = 0) const;
    5050    virtual bool errorOccurred() const { return m_styleImage->errorOccurred(); }
    5151
    52     virtual void setContainerSizeForRenderer(const IntSize& size) { m_styleImage->setContainerSizeForRenderer(m_renderer, size); }
     52    virtual void setContainerSizeForRenderer(const IntSize&);
    5353    virtual bool usesImageContainerSize() const { return m_styleImage->usesImageContainerSize(); }
    5454    virtual bool imageHasRelativeWidth() const { return m_styleImage->imageHasRelativeWidth(); }
  • trunk/Source/WebCore/rendering/RenderListMarker.cpp

    r98508 r98852  
    13511351        // until we support the CSS3 marker pseudoclass to allow control over the width and height of the marker box.
    13521352        LayoutUnit bulletWidth = fontMetrics.ascent() / 2;
    1353         m_image->setContainerSizeForRenderer(this, LayoutSize(bulletWidth, bulletWidth));
     1353        m_image->setContainerSizeForRenderer(this, LayoutSize(bulletWidth, bulletWidth), style()->effectiveZoom());
    13541354        LayoutSize imageSize = m_image->imageSize(this, style()->effectiveZoom());
    13551355        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = style()->isHorizontalWritingMode() ? imageSize.width() : imageSize.height();
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r98767 r98852  
    202202{
    203203    if (m_hasIntrinsicSize) {
    204         ASSERT(!contentRenderer);
    205         return computeReplacedLogicalWidthRespectingMinMaxWidth(calcAspectRatioLogicalWidth(), includeMaxWidth);
     204        if (!contentRenderer || !contentRenderer->style()->logicalWidth().isFixed())
     205            return computeReplacedLogicalWidthRespectingMinMaxWidth(calcAspectRatioLogicalWidth(), includeMaxWidth);
    206206    }
    207207    ASSERT(contentRenderer);
     
    213213{
    214214    if (m_hasIntrinsicSize) {
    215         ASSERT(!contentRenderer);
    216         return computeReplacedLogicalHeightRespectingMinMaxHeight(calcAspectRatioLogicalHeight());
     215        if (!contentRenderer || !contentRenderer->style()->logicalHeight().isFixed())
     216            return computeReplacedLogicalHeightRespectingMinMaxHeight(calcAspectRatioLogicalHeight());
    217217    }
    218218    ASSERT(contentRenderer);
     
    236236        contentRenderStyle = contentRenderer->style();
    237237        ASSERT(contentRenderStyle);
    238     }
     238    } else
     239        computeIntrinsicRatioInformation(intrinsicRatio, isPercentageIntrinsicSize);
    239240
    240241    if (style()->logicalWidth().isAuto()) {
  • trunk/Source/WebCore/rendering/style/StyleCachedImage.cpp

    r98508 r98852  
    6565}
    6666
    67 void StyleCachedImage::computeIntrinsicDimensions(const RenderObject* renderer, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
     67void StyleCachedImage::computeIntrinsicDimensions(const RenderObject*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
    6868{
    69     m_image->computeIntrinsicDimensions(renderer, intrinsicWidth, intrinsicHeight, intrinsicRatio);
     69    m_image->computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intrinsicRatio);
    7070}
    7171
     
    7575}
    7676
    77 void StyleCachedImage::setContainerSizeForRenderer(const RenderObject* renderer, const IntSize& imageContainerSize)
     77void StyleCachedImage::setContainerSizeForRenderer(const RenderObject* renderer, const IntSize& imageContainerSize, float imageContainerZoomFactor)
    7878{
    79     m_image->setContainerSizeForRenderer(renderer, imageContainerSize);
     79    m_image->setContainerSizeForRenderer(renderer, imageContainerSize, imageContainerZoomFactor);
    8080}
    8181
  • trunk/Source/WebCore/rendering/style/StyleCachedImage.h

    r98508 r98852  
    4949    virtual void computeIntrinsicDimensions(const RenderObject*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
    5050    virtual bool usesImageContainerSize() const;
    51     virtual void setContainerSizeForRenderer(const RenderObject*, const IntSize&);
     51    virtual void setContainerSizeForRenderer(const RenderObject*, const IntSize&, float);
    5252    virtual void addClient(RenderObject*);
    5353    virtual void removeClient(RenderObject*);
  • trunk/Source/WebCore/rendering/style/StyleGeneratedImage.h

    r98508 r98852  
    4848    virtual void computeIntrinsicDimensions(const RenderObject*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
    4949    virtual bool usesImageContainerSize() const { return !m_fixedSize; }
    50     virtual void setContainerSizeForRenderer(const RenderObject*, const IntSize& containerSize) { m_containerSize = containerSize; }
     50    virtual void setContainerSizeForRenderer(const RenderObject*, const IntSize& containerSize, float) { m_containerSize = containerSize; }
    5151    virtual void addClient(RenderObject*);
    5252    virtual void removeClient(RenderObject*);
  • trunk/Source/WebCore/rendering/style/StyleImage.h

    r98508 r98852  
    5858    virtual bool imageHasRelativeHeight() const = 0;
    5959    virtual bool usesImageContainerSize() const = 0;
    60     virtual void setContainerSizeForRenderer(const RenderObject*, const IntSize&) = 0;
     60    virtual void setContainerSizeForRenderer(const RenderObject*, const IntSize&, float) = 0;
    6161    virtual void addClient(RenderObject*) = 0;
    6262    virtual void removeClient(RenderObject*) = 0;
  • trunk/Source/WebCore/rendering/style/StylePendingImage.h

    r98508 r98852  
    5050    virtual void computeIntrinsicDimensions(const RenderObject*, Length& /* intrinsicWidth */ , Length& /* intrinsicHeight */, FloatSize& /* intrinsicRatio */) { }
    5151    virtual bool usesImageContainerSize() const { return false; }
    52     virtual void setContainerSizeForRenderer(const RenderObject*, const IntSize&) { }
     52    virtual void setContainerSizeForRenderer(const RenderObject*, const IntSize&, float) { }
    5353    virtual void addClient(RenderObject*) { }
    5454    virtual void removeClient(RenderObject*) { }
  • trunk/Source/WebCore/rendering/svg/RenderSVGImage.cpp

    r98508 r98852  
    6767    LayoutRepainter repainter(*this, checkForRepaintDuringLayout() && selfNeedsLayout());
    6868    SVGImageElement* image = static_cast<SVGImageElement*>(node());
     69    m_imageResource->setContainerSizeForRenderer(enclosingIntRect(m_objectBoundingBox).size());
    6970
    7071    bool transformOrBoundariesUpdate = m_needsTransformUpdate || m_updateCachedRepaintRect;
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp

    r98508 r98852  
    2727#include "RenderSVGRoot.h"
    2828
     29#include "Chrome.h"
     30#include "ChromeClient.h"
    2931#include "Frame.h"
    3032#include "GraphicsContext.h"
    3133#include "HitTestResult.h"
    3234#include "LayoutRepainter.h"
     35#include "Page.h"
    3336#include "RenderPart.h"
    3437#include "RenderSVGContainer.h"
     
    115118}
    116119
    117 LayoutUnit RenderSVGRoot::computeIntrinsicWidth(LayoutUnit replacedWidth) const
    118 {
    119     if (!style()->width().isPercent())
    120         return replacedWidth;
    121     // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    122     return static_cast<int>(ceilf(replacedWidth * style()->effectiveZoom()));
    123 }
    124 
    125 LayoutUnit RenderSVGRoot::computeIntrinsicHeight(LayoutUnit replacedHeight) const
    126 {
    127     if (!style()->height().isPercent())
    128         return replacedHeight;
    129     // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    130     return static_cast<int>(ceilf(replacedHeight * style()->effectiveZoom()));
     120bool RenderSVGRoot::isEmbeddedThroughImageElement() const
     121{
     122    if (!node())
     123        return false;
     124
     125    Frame* frame = node()->document()->frame();
     126    if (!frame)
     127        return false;
     128
     129    // Test whether we're embedded through an img.
     130    if (!frame->page() || !frame->page()->chrome())
     131        return false;
     132
     133    ChromeClient* chromeClient = frame->page()->chrome()->client();
     134    if (!chromeClient || !chromeClient->isSVGImageChromeClient())
     135        return false;
     136
     137    return true;
    131138}
    132139
     
    142149LayoutUnit RenderSVGRoot::computeReplacedLogicalWidth(bool includeMaxWidth) const
    143150{
    144     LayoutUnit replacedWidth = RenderBox::computeReplacedLogicalWidth(includeMaxWidth);
     151    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
     152    LayoutUnit replacedWidth = m_containerSize.width();
     153    if (replacedWidth > 0)
     154        return replacedWidth;
     155
     156    replacedWidth = RenderBox::computeReplacedLogicalWidth(includeMaxWidth);
    145157    Frame* frame = node() && node()->document() ? node()->document()->frame() : 0;
    146158    if (!frame)
    147         return computeIntrinsicWidth(replacedWidth);
     159        return replacedWidth;
    148160
    149161    if (isEmbeddedThroughFrameContainingSVGDocument(frame))
    150         return computeIntrinsicWidth(replacedWidth);
     162        return replacedWidth;
    151163
    152164    RenderPart* ownerRenderer = frame->ownerRenderer();
     
    182194LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight() const
    183195{
    184     LayoutUnit replacedHeight = RenderBox::computeReplacedLogicalHeight();
    185 
     196    // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
     197    LayoutUnit replacedHeight = m_containerSize.height();
     198    if (replacedHeight > 0)
     199        return replacedHeight;
     200
     201    replacedHeight = RenderBox::computeReplacedLogicalHeight();
    186202    Frame* frame = node() && node()->document() ? node()->document()->frame() : 0;
    187203    if (!frame)
    188         return computeIntrinsicHeight(replacedHeight);
     204        return replacedHeight;
    189205
    190206    if (isEmbeddedThroughFrameContainingSVGDocument(frame))
    191         return computeIntrinsicHeight(replacedHeight);
     207        return replacedHeight;
    192208
    193209    RenderPart* ownerRenderer = frame->ownerRenderer();
     
    221237    computeLogicalWidth();
    222238    computeLogicalHeight();
    223     calcViewport();
    224239
    225240    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
    226     m_isLayoutSizeChanged = svg->hasRelativeLengths() && oldSize != size();
    227  
     241    m_isLayoutSizeChanged = needsLayout || (svg->hasRelativeLengths() && oldSize != size());
     242
    228243    if (view() && view()->frameView() && view()->frameView()->embeddedContentBox()) {
    229244        if (!m_needsSizeNegotiationWithHostDocument)
     
    271286        return;
    272287
    273     // An empty viewport disables rendering.  FIXME: Should we still render filters?
    274     if (m_viewportSize.isEmpty())
     288    // An empty viewport disables rendering.
     289    if (borderBoxRect().isEmpty())
    275290        return;
    276291
     
    329344    RenderBox::updateFromElement();
    330345    SVGResourcesCache::clientUpdatedFromElement(this, style());
    331 }
    332 
    333 void RenderSVGRoot::calcViewport()
    334 {
    335     SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
    336 
    337     if (!svg->hasSetContainerSize()) {
    338         // In the normal case of <svg> being stand-alone or in a CSSBoxModel object we use
    339         // RenderBox::width()/height() (which pulls data from RenderStyle)
    340         m_viewportSize = FloatSize(width(), height());
    341         return;
    342     }
    343 
    344     // In the SVGImage case grab the SVGLength values off of SVGSVGElement and use
    345     // the special relativeWidthValue accessors which respect the specified containerSize
    346     // FIXME: Check how SVGImage + zooming is supposed to be handled?
    347     SVGLength width = svg->width();
    348     SVGLength height = svg->height();
    349     m_viewportSize = FloatSize(width.unitType() == LengthTypePercentage ? svg->relativeWidthValue() : width.value(svg),
    350                                height.unitType() == LengthTypePercentage ? svg->relativeHeightValue() : height.value(svg));
    351346}
    352347
     
    399394
    400395    // Apply initial viewport clip - not affected by overflow settings   
    401     repaintRect.intersect(enclosingLayoutRect(FloatRect(FloatPoint(), m_viewportSize)));
     396    repaintRect.intersect(borderBoxRect());
    402397
    403398    const SVGRenderStyle* svgStyle = style()->svgStyle();
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h

    r98508 r98852  
    3232namespace WebCore {
    3333
     34class AffineTransform;
    3435class SVGStyledElement;
    35 class AffineTransform;
    3636
    3737class RenderSVGRoot : public RenderBox {
     
    3939    explicit RenderSVGRoot(SVGStyledElement*);
    4040    virtual ~RenderSVGRoot();
     41
     42    bool isEmbeddedThroughImageElement() const;
    4143
    4244    virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
     
    5658    virtual void setNeedsTransformUpdate() { m_needsBoundariesOrTransformUpdate = true; }
    5759
     60    IntSize containerSize() const { return m_containerSize; }
     61    void setContainerSize(const IntSize& containerSize) { m_containerSize = containerSize; }
     62
    5863private:
    59     LayoutUnit computeIntrinsicWidth(LayoutUnit replacedWidth) const;
    60     LayoutUnit computeIntrinsicHeight(LayoutUnit replacedHeight) const;
    61 
    6264    virtual RenderObjectChildList* virtualChildren() { return children(); }
    6365    virtual const RenderObjectChildList* virtualChildren() const { return children(); }
     
    9395    virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&, bool* wasFixed = 0) const;
    9496
    95     void calcViewport();
    96 
    9797    bool selfWillPaint();
    9898    void updateCachedBoundaries();
     
    104104
    105105    RenderObjectChildList m_children;
    106     FloatSize m_viewportSize;
     106    IntSize m_containerSize;
    107107    FloatRect m_objectBoundingBox;
    108108    FloatRect m_strokeBoundingBox;
  • trunk/Source/WebCore/svg/SVGLength.cpp

    r98508 r98852  
    2929#include "Frame.h"
    3030#include "FrameView.h"
    31 #include "RenderObject.h"
    3231#include "RenderPart.h"
     32#include "RenderSVGRoot.h"
    3333#include "RenderView.h"
    3434#include "SVGException.h"
     
    361361                return false;
    362362
     363            // SVGs embedded through <object> resolve percentage values against the owner renderer in the host document.
    363364            if (RenderPart* ownerRenderer = frame->ownerRenderer()) {
    364365                width = ownerRenderer->width();
     
    372373            return false;
    373374
     375        // Always resolve percentages against the unscaled viewport, as agreed across browsers.
     376        float zoom = view->style()->effectiveZoom();
    374377        width = view->viewWidth();
    375378        height = view->viewHeight();
     379        if (zoom != 1) {
     380            width /= zoom;
     381            height /= zoom;
     382        }
    376383        return true;
    377384    }
     
    381388    if (viewportElement && viewportElement->isSVG()) {
    382389        const SVGSVGElement* svg = static_cast<const SVGSVGElement*>(viewportElement);
    383         if (svg->hasAttribute(SVGNames::viewBoxAttr)) {
    384             width = svg->viewBox().width();
    385             height = svg->viewBox().height();
    386         } else {
     390        FloatRect viewBox = svg->currentViewBoxRect();
     391        if (viewBox.isEmpty()) {
    387392            width = svg->width().value(svg);
    388393            height = svg->height().value(svg);
     394        } else {
     395            width = viewBox.width();
     396            height = viewBox.height();
    389397        }
    390398
  • trunk/Source/WebCore/svg/SVGSVGElement.cpp

    r98508 r98852  
    8888    , m_useCurrentView(false)
    8989    , m_timeContainer(SMILTimeContainer::create(this))
    90     , m_containerSize(300, 150)
    91     , m_hasSetContainerSize(false)
    9290{
    9391    ASSERT(hasTagName(SVGNames::svgTag));
     
    153151    viewRectangle.setSize(FloatSize(width().value(this), height().value(this)));   
    154152    return viewBoxToViewTransform(viewRectangle.width(), viewRectangle.height()).mapRect(viewRectangle);
    155 }
    156 
    157 int SVGSVGElement::relativeWidthValue() const
    158 {
    159     SVGLength w = width();
    160     if (w.unitType() != LengthTypePercentage)
    161         return 0;
    162 
    163     return static_cast<int>(w.valueAsPercentage() * m_containerSize.width());
    164 }
    165 
    166 int SVGSVGElement::relativeHeightValue() const
    167 {
    168     SVGLength h = height();
    169     if (h.unitType() != LengthTypePercentage)
    170         return 0;
    171 
    172     return static_cast<int>(h.valueAsPercentage() * m_containerSize.height());
    173153}
    174154
     
    580560    }
    581561
    582     return viewBox();
     562    // Synthesize a viewBox if we're embedded through a <img> element, if none is present.
     563    FloatRect useViewBox = viewBox();
     564    if (useViewBox.isEmpty() && width().unitType() != LengthTypePercentage && height().unitType() != LengthTypePercentage) {
     565        if (RenderObject* renderer = this->renderer()) {
     566            if (renderer->isSVGRoot() && toRenderSVGRoot(renderer)->isEmbeddedThroughImageElement())
     567                useViewBox = FloatRect(0, 0, width().value(this), height().value(this));
     568        }
     569    }
     570
     571    return useViewBox;
    583572}
    584573
  • trunk/Source/WebCore/svg/SVGSVGElement.h

    r98508 r98852  
    6363
    6464    FloatRect viewport() const;
    65 
    66     void setContainerSize(const LayoutSize& containerSize) { m_containerSize = containerSize; m_hasSetContainerSize = true; }
    67     LayoutSize containerSize() const { return m_containerSize; }
    68     bool hasSetContainerSize() const { return m_hasSetContainerSize; }
    69     int relativeWidthValue() const;
    70     int relativeHeightValue() const;
    7165
    7266    float pixelUnitToMillimeterX() const;
     
    182176    FloatPoint m_translation;
    183177    mutable OwnPtr<SVGViewSpec> m_viewSpec;
    184     LayoutSize m_containerSize;
    185     bool m_hasSetContainerSize;
    186178};
    187179
  • trunk/Source/WebCore/svg/graphics/SVGImage.cpp

    r98730 r98852  
    4444#include "ImageBuffer.h"
    4545#include "ImageObserver.h"
     46#include "Length.h"
    4647#include "Page.h"
     48#include "RenderSVGRoot.h"
    4749#include "RenderView.h"
    4850#include "ResourceError.h"
     
    6365    }
    6466
     67    virtual bool isSVGImageChromeClient() const { return true; }
    6568    SVGImage* image() const { return m_image; }
    66    
     69
    6770private:
    6871    virtual void chromeDestroyed()
     
    100103}
    101104
     105PassRefPtr<SVGImage> SVGImage::createWithDataAndSize(ImageObserver* observer, SharedBuffer* data, const IntSize& size, float zoom)
     106{
     107    ASSERT(!size.isEmpty());
     108
     109    RefPtr<SVGImage> image = adoptRef(new SVGImage(0));
     110    image->setData(data, true);
     111    image->setContainerSize(size);
     112    image->setContainerZoom(zoom);
     113    image->setImageObserver(observer);
     114    return image.release();
     115}
     116
     117void SVGImage::setContainerZoom(float containerZoom)
     118{
     119    if (!m_page)
     120        return;
     121    Frame* frame = m_page->mainFrame();
     122    frame->setPageZoomFactor(containerZoom);
     123}
     124
    102125void SVGImage::setContainerSize(const IntSize& containerSize)
    103126{
    104     if (containerSize.isEmpty())
    105         return;
    106 
    107     if (!m_page)
    108         return;
    109     Frame* frame = m_page->mainFrame();
    110     SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement();
    111     if (!rootElement)
    112         return;
    113 
    114     rootElement->setContainerSize(containerSize);
     127    ASSERT(!containerSize.isEmpty());
     128    ASSERT(!imageObserver());
     129   
     130    if (!m_page)
     131        return;
     132    Frame* frame = m_page->mainFrame();
     133    SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement();
     134    if (!rootElement)
     135        return;
     136
     137    RenderSVGRoot* renderer = toRenderSVGRoot(rootElement->renderer());
     138    if (!renderer)
     139        return;
     140    renderer->setContainerSize(containerSize);
     141    frame->view()->resize(size());
    115142}
    116143
     
    123150    if (!rootElement)
    124151        return false;
    125 
    126     return rootElement->hasSetContainerSize();
     152    if (RenderSVGRoot* renderer = toRenderSVGRoot(rootElement->renderer()))
     153        return !renderer->containerSize().isEmpty();
     154    return false;
    127155}
    128156
     
    135163    if (!rootElement)
    136164        return IntSize();
    137    
    138     SVGLength width = rootElement->width();
    139     SVGLength height = rootElement->height();
    140    
    141     IntSize svgSize;
    142     if (width.unitType() == LengthTypePercentage)
    143         svgSize.setWidth(rootElement->relativeWidthValue());
    144     else
    145         svgSize.setWidth(static_cast<int>(width.value(rootElement)));
    146 
    147     if (height.unitType() == LengthTypePercentage)
    148         svgSize.setHeight(rootElement->relativeHeightValue());
    149     else
    150         svgSize.setHeight(static_cast<int>(height.value(rootElement)));
    151 
    152     return svgSize;
    153 }
    154 
    155 bool SVGImage::hasRelativeWidth() const
    156 {
    157     if (!m_page)
    158         return false;
    159     SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_page->mainFrame()->document())->rootElement();
    160     if (!rootElement)
    161         return false;
    162 
    163     return rootElement->width().unitType() == LengthTypePercentage;
    164 }
    165 
    166 bool SVGImage::hasRelativeHeight() const
    167 {
    168     if (!m_page)
    169         return false;
    170     SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_page->mainFrame()->document())->rootElement();
    171     if (!rootElement)
    172         return false;
    173 
    174     return rootElement->height().unitType() == LengthTypePercentage;
     165
     166    RenderSVGRoot* renderer = toRenderSVGRoot(rootElement->renderer());
     167    if (!renderer)
     168        return IntSize();
     169
     170    // If a container size is available it has precedence.
     171    IntSize containerSize = renderer->containerSize();
     172    if (!containerSize.isEmpty())
     173        return containerSize;
     174
     175    // Assure that a container size is always given for a non-identity zoom level.
     176    ASSERT(renderer->style()->effectiveZoom() == 1);
     177    IntSize size = enclosingIntRect(rootElement->currentViewBoxRect()).size();
     178    if (!size.isEmpty())
     179        return size;
     180
     181    // As last resort, use CSS default intrinsic size.
     182    return IntSize(300, 150);
    175183}
    176184
     
    214222}
    215223
     224RenderBox* SVGImage::embeddedContentBox() const
     225{
     226    if (!m_page)
     227        return 0;
     228    Frame* frame = m_page->mainFrame();
     229    SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement();
     230    if (!rootElement)
     231        return 0;
     232    return toRenderBox(rootElement->renderer());
     233}
     234
    216235void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
    217236{
     
    228247    intrinsicWidth = renderer->style()->width();
    229248    intrinsicHeight = renderer->style()->height();
    230     // FIXME: Add intrinsicRatio calculation from webkit.org/b/47156.
    231     intrinsicRatio = FloatSize();
     249    if (rootElement->preserveAspectRatio().align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
     250        intrinsicRatio = rootElement->currentViewBoxRect().size();
    232251}
    233252
     
    296315        FrameLoader* loader = frame->loader();
    297316        loader->setForcedSandboxFlags(SandboxAll);
     317
     318        frame->view()->setCanHaveScrollbars(false); // SVG Images will always synthesize a viewBox, if it's not available, and thus never see scrollbars.
     319        frame->view()->setTransparent(true); // SVG Images are transparent.
     320
    298321        ASSERT(loader->activeDocumentLoader()); // DocumentLoader should have been created by frame->init().
    299322        loader->activeDocumentLoader()->writer()->setMIMEType("image/svg+xml");
     
    301324        loader->activeDocumentLoader()->writer()->addData(data()->data(), data()->size());
    302325        loader->activeDocumentLoader()->writer()->end();
    303         frame->view()->setTransparent(true); // SVG Images are transparent.
    304326    }
    305327
  • trunk/Source/WebCore/svg/graphics/SVGImage.h

    r98508 r98852  
    3636
    3737class Page;
     38class RenderBox;
    3839class SVGImageChromeClient;
    3940
     
    4445        return adoptRef(new SVGImage(observer));
    4546    }
     47
     48    static PassRefPtr<SVGImage> createWithDataAndSize(ImageObserver*, SharedBuffer*, const IntSize&, float zoom);
     49
     50    void setContainerZoom(float);
     51    RenderBox* embeddedContentBox() const;
    4652
    4753    virtual bool isSVGImage() const { return true; }
     
    5460    virtual void setContainerSize(const IntSize&);
    5561    virtual bool usesContainerSize() const;
    56     virtual bool hasRelativeWidth() const;
    57     virtual bool hasRelativeHeight() const;
    5862    virtual void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
    5963
Note: See TracChangeset for help on using the changeset viewer.