Changeset 98483 in webkit


Ignore:
Timestamp:
Oct 26, 2011 8:27:44 AM (12 years ago)
Author:
Nikolas Zimmermann
Message:

2011-10-26 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.
  • 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.

2011-10-26 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

  • 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::lookupImageForRenderer): Lookup image by renderer, which first looks up a size for a renderer, then uses lookupImageForSize(). (WebCore::createSVGImage): Refactored from createImage(), contains the SVGImage creation part only. (WebCore::CachedImage::lookupOrCreateImageForRenderer): Use recently introduced ImageBySizeCache, to dynamically create copies of m_image if needed. (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. (WebCore::CachedImage::addClientForRenderer): Special variant of addClient(), overriding the existing in CachedResource. (WebCore::CachedImage::removeClientForRenderer): Special variant of removeClient(), that also clears the image in the ImageBySizeCache. (WebCore::CachedImage::createImage): Refactor SVGImage creation into createSVGImage() free function, to be useable from lookupOrCreateImageForRenderer().
  • loader/cache/CachedImage.h: Expose removeClientForRenderer().
  • page/ChromeClient.h: (WebCore::ChromeClient::isSVGImageChromeClient): Used to identify whether a RenderSVGRoot is embedded through a SVGImage. Returns false, by default.
  • rendering/ImageBySizeCache.cpp: (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::setClient): New helper function, that combines the usage of addClient/removeClient, for the use in CachedImage. (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: Expose setClient() & imageForRenderer().
  • rendering/RenderBoxModelObject.cpp: Implement CSS 2.1 intrinsic size negotiation for images. (WebCore::resolveWidthForRatio): New inline helper function used bz 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. (WebCore::StyleCachedImage::addClient): Forward to new addClientForRenderer(). (WebCore::StyleCachedImage::removeClient): Call new removeClientForRenderer() instead of removeClient(), so the ImageBySizeCache is also updated.
  • 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::setObserver): Helper function. (WebCore::SVGImageChromeClient::isSVGImageChromeClient): Return true, used to identify whether RenderSVGRoot is embedded through SVGImage. (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::draw): Stop calling layout() while painting! (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:
94 added
2 deleted
49 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r98482 r98483  
     12011-10-26  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        * svg/as-background-image/background-image-preserveaspectRatio-support.html: Added.
     106        * svg/as-background-image/background-image-tiled.html: Added.
     107        * svg/as-background-image/resources/construction-tape.svg: Added.
     108        * 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.
     109        * svg/as-background-image/same-image-two-instances-background-image.html: Added.
     110        * svg/as-image/img-preserveAspectRatio-support-1.html: Added.
     111        * svg/as-image/resources/circle-default-meet.svg: Added.
     112        * svg/as-image/resources/circle-default-none.svg: Added.
     113        * svg/as-image/resources/circle-default-slice.svg: Added.
     114        * svg/as-image/resources/circle-nosize.svg: Added.
     115        * svg/as-image/resources/circle-viewbox-default.svg: Added.
     116        * svg/as-image/resources/circle-viewbox-meet.svg: Added.
     117        * svg/as-image/resources/circle-viewbox-none.svg: Added.
     118        * svg/as-image/resources/circle-viewbox-slice.svg: Added.
     119        * 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.
     120        * svg/as-image/same-image-two-instances.html: Added.
     121        * svg/as-image/svg-as-relative-image-with-explicit-size.html: Added.
     122        * svg/as-image/svg-image-change-content-size.xhtml: Added.
     123        * svg/zoom/page/resources/relative-sized-background-with-viewBox.svg: Added.
     124        * svg/zoom/page/zoom-background-image-tiled.html: Added.
     125        * svg/zoom/page/zoom-background-images.html: Added.
     126        * svg/zoom/page/zoom-img-preserveAspectRatio-support-1.html: Added.
     127        * svg/zoom/page/zoom-svg-as-background-with-relative-size-and-viewBox.html: Added.
     128        * svg/zoom/page/zoom-svg-as-background-with-relative-size.html: Added.
     129
    11302011-10-26  Yury Semikhatsky  <yurys@chromium.org>
    2131
  • trunk/LayoutTests/fast/images/percent-height-image-expected.txt

    r67075 r98483  
    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

    r67075 r98483  
    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

    r25970 r98483  
    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

    r25970 r98483  
    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

    r73385 r98483  
    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

    r67463 r98483  
    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

    r97873 r98483  
    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

    r97873 r98483  
    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

    r91633 r98483  
    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

    r87782 r98483  
    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

    r98481 r98483  
     12011-10-26  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
     44        * loader/cache/CachedImage.cpp: Enable SVGImage <-> IntSize cache.
     45        (WebCore::CachedImage::lookupImageForSize): Use recently introduced ImageBySizeCache, to lookup an image for a certain size.
     46        (WebCore::CachedImage::lookupImageForRenderer): Lookup image by renderer, which first looks up a size for a renderer, then uses lookupImageForSize().
     47        (WebCore::createSVGImage): Refactored from createImage(), contains the SVGImage creation part only.
     48        (WebCore::CachedImage::lookupOrCreateImageForRenderer): Use recently introduced ImageBySizeCache, to dynamically create copies of m_image if needed.
     49        (WebCore::CachedImage::setContainerSizeForRenderer): For SVGImages, pass on container size handling to ImageBySizeCache.
     50        (WebCore::CachedImage::imageSizeForRenderer): Figure out the image size, respecting per-renderer overrides, for a certain renderer.
     51        (WebCore::CachedImage::computeIntrinsicDimensions): Remove unnecessary RenderObject parameter.
     52        (WebCore::CachedImage::addClientForRenderer): Special variant of addClient(), overriding the existing in CachedResource.
     53        (WebCore::CachedImage::removeClientForRenderer): Special variant of removeClient(), that also clears the image in the ImageBySizeCache.
     54        (WebCore::CachedImage::createImage): Refactor SVGImage creation into createSVGImage() free function, to be useable from lookupOrCreateImageForRenderer().
     55        * loader/cache/CachedImage.h: Expose removeClientForRenderer().
     56        * page/ChromeClient.h:
     57        (WebCore::ChromeClient::isSVGImageChromeClient): Used to identify whether a RenderSVGRoot is embedded through a SVGImage. Returns false, by default.
     58        * rendering/ImageBySizeCache.cpp:
     59        (WebCore::ImageBySizeCache::addClient): Assert the passed renderer is valid.
     60        (WebCore::ImageBySizeCache::removeClient): Ditto. Allow removeClient() to be called w/o prio addClient() usage.
     61        (WebCore::ImageBySizeCache::setClient): New helper function, that combines the usage of addClient/removeClient, for the use in CachedImage.
     62        (WebCore::ImageBySizeCache::imageForSize): Respect empty sizes, just return 0, instead of asserting.
     63        (WebCore::ImageBySizeCache::imageForRenderer): Added a helper that retrieves an image for a renderer, by lookup up its size and using imageForSize().
     64        * rendering/ImageBySizeCache.h: Expose setClient() & imageForRenderer().
     65        * rendering/RenderBoxModelObject.cpp: Implement CSS 2.1 intrinsic size negotiation for images.
     66        (WebCore::resolveWidthForRatio): New inline helper function used bz calculateImageIntrinsicDimensions.
     67        (WebCore::resolveHeightForRatio): Ditto.
     68        (WebCore::resolveAgainstIntrinsicWidthOrHeightAndRatio): Ditto.
     69        (WebCore::resolveAgainstIntrinsicRatio):  Ditto.
     70        (WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions): New helper function, containing the main algorithm, which is a pure transcription of the spec.
     71        (WebCore::RenderBoxModelObject::calculateFillTileSize): Use new calculateImageIntrinsicDimensions() helper to figure out the intrinsic size.
     72        (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry): Propagate calculateFillTileSize() result to the image resource, via setContainerSizeForRenderer().
     73        (WebCore::RenderBoxModelObject::paintNinePieceImage): Use new calculateImageIntrinsicDimensions() helper to figure out the intrinsic size.
     74        * rendering/RenderBoxModelObject.h: Clarify some variable names, added calculateImageIntrinsicDimensions().
     75        * rendering/RenderImage.cpp:
     76        (WebCore::RenderImage::RenderImage): Use IntSize(), instead of IntSize(0, 0).
     77        (WebCore::RenderImage::updateIntrinsicSizeIfNeeded): Refactored from imageDimensionsChanged().
     78        (WebCore::RenderImage::imageDimensionsChanged): Use updateIntrinsicSizeIfNeeded().
     79        (WebCore::RenderImage::computeReplacedLogicalWidth): Use RenderReplaced::computeReplacedLogicalWidth() exclusively. For this to work, the intrinsic size must be correct.
     80        (WebCore::RenderImage::computeIntrinsicRatioInformation): Default implementation for non-SVGImages.
     81        (WebCore::RenderImage::needsPreferredWidthsRecalculation): Return true, just like RenderPart, if embeddedContentBox is not null.
     82        (WebCore::RenderImage::embeddedContentBox): Returns the RenderSVGRoot* renderer of the embedded SVG, if possible.
     83        * rendering/RenderImage.h: Remove isLogicalWidth/HeightSpecified() / computeReplacedLogicalHeight() / calcAspectRatioLogicalWidth/Height().
     84        * rendering/RenderImageResource.cpp:
     85        (WebCore::RenderImageResource::setContainerSizeForRenderer): Pass around new "float containerZoomFactor" parameter.
     86        * rendering/RenderImageResourceStyleImage.cpp:
     87        (WebCore::RenderImageResourceStyleImage::image): embeddedContentBox() is now calling image() earlier than before. We now have to handle the case that the image is pending.
     88        (WebCore::RenderImageResourceStyleImage::setContainerSizeForRenderer): Pass zoom factor.
     89        * rendering/RenderImageResourceStyleImage.h:
     90        * rendering/RenderListMarker.cpp:
     91        (WebCore::RenderListMarker::computePreferredLogicalWidths): Pass effective zoom to setContainerSizeForRenderer().
     92        * rendering/RenderReplaced.cpp:
     93        (WebCore::RenderReplaced::computeIntrinsicLogicalWidth): Generalized this code, as RenderImage is using it as well now. Marginal changes needed.
     94        (WebCore::RenderReplaced::computeIntrinsicLogicalHeight): Ditto.
     95        (WebCore::RenderReplaced::computeReplacedLogicalWidth): Ditto.
     96        * rendering/style/StyleCachedImage.cpp:
     97        (WebCore::StyleCachedImage::computeIntrinsicDimensions): Stop passing m_renderer to CachedImage, it's no longer needed.
     98        (WebCore::StyleCachedImage::setContainerSizeForRenderer): Add "float containerZoomFactor" parameter.
     99        (WebCore::StyleCachedImage::addClient): Forward to new addClientForRenderer().
     100        (WebCore::StyleCachedImage::removeClient): Call new removeClientForRenderer() instead of removeClient(), so the ImageBySizeCache is also updated.
     101        * rendering/style/StyleCachedImage.h: Add "float containerZoomFactor" parameter to setContainerSizeForRenderer.
     102        * rendering/style/StyleGeneratedImage.h:
     103        (WebCore::StyleGeneratedImage::setContainerSizeForRenderer): Ditto.
     104        * rendering/style/StyleImage.h: Ditto.
     105        * rendering/style/StylePendingImage.h:
     106        (WebCore::StylePendingImage::setContainerSizeForRenderer): Ditto.
     107        * rendering/svg/RenderSVGImage.cpp:
     108        (WebCore::RenderSVGImage::layout): Always supply a container size when embedding SVGs in <svg:image>.
     109        * rendering/svg/RenderSVGRoot.cpp: Move "override container size" from SVGSVGElement into RenderSVGRoot, where it belongs.
     110        (WebCore::RenderSVGRoot::isEmbeddedThroughImageElement): Add helper method to determine whether we're loaded through SVGImage.
     111        (WebCore::RenderSVGRoot::computeReplacedLogicalWidth): If we have a valid container size, it has precendence (only supplied via external SVGImages).
     112        (WebCore::RenderSVGRoot::computeReplacedLogicalHeight): Ditto.
     113        (WebCore::RenderSVGRoot::layout): Remove calcViewport() usage, no need to track/override the viewport size anymore, all done in coputeReplacedLogical* now.
     114        (WebCore::RenderSVGRoot::paint): Use borderBoxRect() which now always matches the previously computed m_viewportSize.
     115        (WebCore::RenderSVGRoot::computeRectForRepaint): Ditto.
     116        * rendering/svg/RenderSVGRoot.h: Move "override container size" from SVGSVGElement into RenderSVGRoot, where it belongs.
     117        (WebCore::RenderSVGRoot::containerSize):
     118        (WebCore::RenderSVGRoot::setContainerSize):
     119        * svg/SVGLength.cpp:
     120        (WebCore::SVGLength::determineViewport): Resolve lengths against override container size in documents embedded through SVGImage.
     121        * svg/SVGSVGElement.cpp: Remove "override container size" handling from SVGSVGElement.
     122        (WebCore::SVGSVGElement::SVGSVGElement): Ditto.
     123        (WebCore::SVGSVGElement::currentViewBoxRect): Always synthesize a viewBox, if we're embedded through SVGImage, as demanded by SVG 1.1 2nd Edition.
     124        * svg/SVGSVGElement.h:
     125        * svg/graphics/SVGImage.cpp:
     126        (WebCore::SVGImageChromeClient::setObserver): Helper function.
     127        (WebCore::SVGImageChromeClient::isSVGImageChromeClient): Return true, used to identify whether RenderSVGRoot is embedded through SVGImage.
     128        (WebCore::SVGImage::setContainerZoom): Forwarded to Page::setPageZoomFactor.
     129        (WebCore::SVGImage::setContainerSize): Assert that container size is not empty. We should never receive an empty container size.
     130        (WebCore::SVGImage::usesContainerSize): Adapt to override container size changes, it now lives in RenderSVGRoot instead of SVGSVGElement.
     131        (WebCore::SVGImage::size): New algorithm to figure out the size of an embedded SVG, as demanded by the CSS/SVG specs.
     132        (WebCore::SVGImage::draw): Stop calling layout() while painting!
     133        (WebCore::SVGImage::embeddedContentBox): Add helper which returns the RenderSVGRoot of the document.
     134        (WebCore::SVGImage::computeIntrinsicDimensions): Implement intrinsic ratio calculation.
     135        (WebCore::SVGImage::dataChanged): Force calling FrameView::setCanHaveScrollbars(false), as SVG images now always synthesize a viewBox, and thus never receive scrollbars.
     136        * svg/graphics/SVGImage.h:
     137
    11382011-10-26  Kenneth Rohde Christiansen  <kenneth@webkit.org>
    2139
  • trunk/Source/WebCore/loader/cache/CachedImage.cpp

    r97727 r98483  
    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::lookupImageForRenderer(const RenderObject* renderer) const
     147{
     148    if (!m_image)
     149        return 0;
     150    if (!m_image->isSVGImage())
     151        return m_image.get();
     152    if (Image* image = m_svgImageCache.imageForRenderer(renderer))
     153        return image;
    144154    return m_image.get();
    145155}
    146156
    147 PassRefPtr<Image> CachedImage::lookupOrCreateImageForRenderer(const RenderObject* renderer)
    148 {
    149     // FIXME: Add logic for this in webkit.org/b/47156.
    150     UNUSED_PARAM(renderer);
     157inline PassRefPtr<Image> createSVGImage(CachedImage* image, const IntSize& size, SharedBuffer* data)
     158{
     159    if (size.isEmpty() || !data)
     160        return SVGImage::create(image);
     161
     162    RefPtr<Image> newImage = SVGImage::create(image);
     163    newImage->setData(data, true);
     164    newImage->setContainerSize(size);
     165    return newImage.release();
     166}
     167
     168inline PassRefPtr<Image> CachedImage::lookupOrCreateImageForRenderer(const RenderObject* renderer)
     169{
     170    if (!m_image)
     171        return 0;
     172    if (!m_image->isSVGImage())
     173        return m_image;
     174
     175    IntSize size;
     176    if (Image* result = m_svgImageCache.imageForRenderer(renderer, &size))
     177        return result;
     178
     179    if (size.isEmpty())
     180        return m_image;
     181
     182    // Create and cache new image at desired size.
     183    RefPtr<Image> newImage = createSVGImage(this, size, m_data.get());
     184    m_svgImageCache.putImage(size, newImage);
     185    return newImage.release();
     186}
     187#else
     188inline Image* CachedImage::lookupImageForSize(const IntSize&) const
     189{
     190    return m_image.get();
     191}
     192
     193inline Image* CachedImage::lookupImageForRenderer(const RenderObject*) const
     194{
     195    return m_image.get();
     196}
     197
     198inline PassRefPtr<Image> CachedImage::lookupOrCreateImageForRenderer(const RenderObject*)
     199{
    151200    return m_image;
    152201}
     202#endif
    153203
    154204Image* CachedImage::image()
     
    186236}
    187237
    188 void CachedImage::setContainerSizeForRenderer(const RenderObject* renderer, const IntSize& containerSize)
     238void CachedImage::setContainerSizeForRenderer(const RenderObject* renderer, const IntSize& containerSize, float containerZoom)
    189239{
    190240    if (!m_image)
    191241        return;
    192 
    193     // FIXME: Add logic for this in webkit.org/b/47156.
     242#if ENABLE(SVG)
     243    if (!m_image->isSVGImage()) {
     244        m_image->setContainerSize(containerSize);
     245        return;
     246    }
     247    m_svgImageCache.setClient(renderer, containerSize);
     248
     249    Image* image = lookupOrCreateImageForRenderer(renderer).get();
     250    if (image && image != m_image) {
     251        ASSERT(image->isSVGImage());
     252        static_cast<SVGImage*>(image)->setContainerZoom(containerZoom);
     253    }
     254#else
    194255    UNUSED_PARAM(renderer);
    195256    m_image->setContainerSize(containerSize);
     257#endif
    196258}
    197259
     
    224286    ASSERT(!isPurgeable());
    225287
    226     Image* image = lookupImageForRenderer(renderer);
    227     if (!image)
     288    if (!m_image)
    228289        return IntSize();
     290#if ENABLE(SVG)
     291    // SVGImages already includes the zooming in its intrinsic size.
     292    if (m_image->isSVGImage())
     293        return lookupImageForRenderer(renderer)->size();
     294#endif
     295
    229296    if (multiplier == 1.0f)
    230297        return m_image->size();
     
    242309}
    243310
    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);
     311void CachedImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
     312{
     313    if (m_image)
     314        m_image->computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intrinsicRatio);
     315}
     316
     317void CachedImage::addClientForRenderer(RenderObject* renderer)
     318{
     319    ASSERT(renderer);
     320#if ENABLE(SVG)
     321    m_svgImageCache.addClient(renderer, IntSize());
     322#endif
     323    addClient(renderer);
     324}
     325
     326void CachedImage::removeClientForRenderer(RenderObject* renderer)
     327{
     328    ASSERT(renderer);
     329#if ENABLE(SVG)
     330    m_svgImageCache.removeClient(renderer);
     331#endif
     332    removeClient(renderer);
    248333}
    249334
     
    285370#if ENABLE(SVG)
    286371    if (m_response.mimeType() == "image/svg+xml") {
    287         m_image = SVGImage::create(this);
     372        m_image = createSVGImage(this, IntSize(), 0);
    288373        return;
    289374    }
  • trunk/Source/WebCore/loader/cache/CachedImage.h

    r97729 r98483  
    5858
    5959    bool canRender(const RenderObject* renderer, float multiplier) { return !errorOccurred() && !imageSizeForRenderer(renderer, multiplier).isEmpty(); }
     60    void addClientForRenderer(RenderObject*);
     61    void removeClientForRenderer(RenderObject*);
    6062
    61     // These are only used for SVGImage right now
    62     void setContainerSizeForRenderer(const RenderObject*, const IntSize&);
     63    void setContainerSizeForRenderer(const RenderObject*, const IntSize&, float);
    6364    bool usesImageContainerSize() const;
    6465    bool imageHasRelativeWidth() const;
     
    6768    // This method takes a zoom multiplier that can be used to increase the natural size of the image by the zoom.
    6869    IntSize imageSizeForRenderer(const RenderObject*, float multiplier); // returns the size of the complete image.
    69     void computeIntrinsicDimensions(const RenderObject*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
     70    void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
    7071
    7172    virtual void didAddClient(CachedResourceClient*);
  • trunk/Source/WebCore/page/ChromeClient.h

    r98472 r98483  
    337337        virtual void numWheelEventHandlersChanged(unsigned) = 0;
    338338       
     339        virtual bool isSVGImageChromeClient() const { return false; }
     340
    339341    protected:
    340342        virtual ~ChromeClient() { }
  • trunk/Source/WebCore/rendering/ImageBySizeCache.cpp

    r97448 r98483  
    3535void ImageBySizeCache::addClient(const RenderObject* renderer, const IntSize& size)
    3636{
     37    ASSERT(renderer);
    3738    if (!size.isEmpty())
    3839        m_sizes.add(size);
     
    4950void ImageBySizeCache::removeClient(const RenderObject* renderer)
    5051{
     52    ASSERT(renderer);
    5153    RenderObjectSizeCountMap::iterator it = m_clients.find(renderer);
    52     ASSERT(it != m_clients.end());
     54    if (it == m_clients.end())
     55        return;
    5356
    5457    SizeCountPair& sizeCount = it->second;
     
    6265    if (!--sizeCount.second)
    6366        m_clients.remove(renderer);
     67}
     68
     69void ImageBySizeCache::setClient(const RenderObject* renderer, const IntSize& size)
     70{
     71    ASSERT(renderer);
     72    RenderObjectSizeCountMap::iterator it = m_clients.find(renderer);
     73    if (it != m_clients.end()) {
     74        IntSize currentSize = it->second.first;
     75        if (currentSize == size)
     76            return;
     77        removeClient(renderer);
     78    }
     79
     80    if (!size.isEmpty())
     81        addClient(renderer, size);
    6482}
    6583
     
    98116Image* ImageBySizeCache::imageForSize(const IntSize& size) const
    99117{
     118    if (size.isEmpty())
     119        return 0;
    100120    HashMap<IntSize, RefPtr<Image> >::const_iterator it = m_images.find(size);
    101121    if (it == m_images.end())
     
    104124}
    105125
    106 IntSize ImageBySizeCache::sizeForClient(const RenderObject* renderer) const
     126Image* ImageBySizeCache::imageForRenderer(const RenderObject* renderer, IntSize* size) const
    107127{
     128    if (!renderer)
     129        return 0;
    108130    RenderObjectSizeCountMap::const_iterator it = m_clients.find(renderer);
    109131    if (it == m_clients.end())
    110         return IntSize();
    111     return it->second.first;
     132        return 0;
     133    if (size)
     134        *size = it->second.first;
     135    return imageForSize(it->second.first);
    112136}
    113137
  • trunk/Source/WebCore/rendering/ImageBySizeCache.h

    r97448 r98483  
    4141    void addClient(const RenderObject*, const IntSize&);
    4242    void removeClient(const RenderObject*);
     43    void setClient(const RenderObject*, const IntSize&);
    4344
    4445    Image* getImage(const RenderObject*, const IntSize&);
     
    4849
    4950    Image* imageForSize(const IntSize&) const;
    50     IntSize sizeForClient(const RenderObject*) const;
     51    Image* imageForRenderer(const RenderObject*, IntSize* lookedUpSize = 0) const;
    5152    const RenderObjectSizeCountMap& clients() const { return m_clients; }
    5253
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r97481 r98483  
    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    // This implements http://www.w3.org/TR/css3-background/#background-size.
     839    LayoutUnit resolvedWidth = 0;
     840    LayoutUnit resolvedHeight = 0;
     841    FloatSize intrinsicRatio;
     842
     843    // A generated image without a fixed size, will always return the container size as intrinsic size.
     844    if (image->isGeneratedImage() && image->usesImageContainerSize()) {
     845        resolvedWidth = positioningAreaSize.width();
     846        resolvedHeight = positioningAreaSize.height();
     847    } else {
     848        Length intrinsicWidth;
     849        Length intrinsicHeight;
     850        image->computeIntrinsicDimensions(this, intrinsicWidth, intrinsicHeight, intrinsicRatio);
     851
     852        // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
     853        if (intrinsicWidth.isFixed())
     854            resolvedWidth = static_cast<LayoutUnit>(ceilf(intrinsicWidth.value() * style()->effectiveZoom()));
     855        if (intrinsicHeight.isFixed())
     856            resolvedHeight = static_cast<LayoutUnit>(ceilf(intrinsicHeight.value() * style()->effectiveZoom()));
     857    }
     858
     859    // Intrinsic dimensions expressed as percentages must be resolved relative to the dimensions of the rectangle
     860    // that establishes the coordinate system for the 'background-position' property. SVG on the other hand
     861    // _explicitely_ says that percentage values for the width/height attributes do NOT define intrinsic dimensions.
     862    if (resolvedWidth > 0 && resolvedHeight > 0)
     863        return LayoutSize(resolvedWidth, resolvedHeight);
     864
     865    // If the image has one of either an intrinsic width or an intrinsic height:
     866    // * and an intrinsic aspect ratio, then the missing dimension is calculated from the given dimension and the ratio.
     867    // * and no intrinsic aspect ratio, then the missing dimension is assumed to be the size of the rectangle that
     868    //   establishes the coordinate system for the 'background-position' property.
     869    if ((resolvedWidth && !resolvedHeight) || (!resolvedWidth && resolvedHeight))
     870        return resolveAgainstIntrinsicWidthOrHeightAndRatio(positioningAreaSize, intrinsicRatio, resolvedWidth, resolvedHeight);
     871
     872    // If the image has no intrinsic dimensions and has an intrinsic ratio the dimensions must be assumed to be the
     873    // largest dimensions at that ratio such that neither dimension exceeds the dimensions of the rectangle that
     874    // establishes the coordinate system for the 'background-position' property.
     875    if (!resolvedWidth && !resolvedHeight && !intrinsicRatio.isEmpty())
     876        return resolveAgainstIntrinsicRatio(positioningAreaSize, intrinsicRatio);
     877
     878    // If the image has no intrinsic ratio either, then the dimensions must be assumed to be the rectangle that
     879    // establishes the coordinate system for the 'background-position' property.
     880    return positioningAreaSize;
     881}
     882
     883LayoutSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, const LayoutSize& positioningAreaSize) const
    786884{
    787885    StyleImage* image = fillLayer->image();
    788     image->setContainerSizeForRenderer(this, positioningAreaSize); // Use the box established by background-origin.
    789 
    790886    EFillSizeType type = fillLayer->size().type;
     887
     888    LayoutSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize);
    791889
    792890    switch (type) {
     
    811909            // scale to maintain our aspect ratio.
    812910            if (layerWidth.isAuto() && !layerHeight.isAuto()) {
    813                 LayoutSize imageIntrinsicSize = image->imageSize(this, style()->effectiveZoom());
    814911                if (imageIntrinsicSize.height())
    815912                    w = imageIntrinsicSize.width() * h / imageIntrinsicSize.height();       
    816913            } else if (!layerWidth.isAuto() && layerHeight.isAuto()) {
    817                 LayoutSize imageIntrinsicSize = image->imageSize(this, style()->effectiveZoom());
    818914                if (imageIntrinsicSize.width())
    819915                    h = imageIntrinsicSize.height() * w / imageIntrinsicSize.width();
    820916            } else if (layerWidth.isAuto() && layerHeight.isAuto()) {
    821917                // If both width and height are auto, use the image's intrinsic size.
    822                 LayoutSize imageIntrinsicSize = image->imageSize(this, style()->effectiveZoom());
    823918                w = imageIntrinsicSize.width();
    824919                h = imageIntrinsicSize.height();
     
    827922            return LayoutSize(max<LayoutUnit>(1, w), max<LayoutUnit>(1, h));
    828923        }
     924        case SizeNone: {
     925            // If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any.
     926            if (!imageIntrinsicSize.isEmpty())
     927                return imageIntrinsicSize;
     928
     929            // If the image has neither an intrinsic width nor an intrinsic height, its size is determined as for ‘contain’.
     930            type = Contain;
     931        }
    829932        case Contain:
    830933        case Cover: {
    831             LayoutSize imageIntrinsicSize = image->imageSize(this, 1);
    832934            float horizontalScaleFactor = imageIntrinsicSize.width()
    833935                ? static_cast<float>(positioningAreaSize.width()) / imageIntrinsicSize.width() : 1;
     
    836938            float scaleFactor = type == Contain ? min(horizontalScaleFactor, verticalScaleFactor) : max(horizontalScaleFactor, verticalScaleFactor);
    837939            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());
     940       }
     941    }
     942
     943    ASSERT_NOT_REACHED();
     944    return LayoutSize();
    844945}
    845946
     
    9281029    }
    9291030
    930     geometry.setTileSize(calculateFillTileSize(fillLayer, positioningAreaSize));
     1031    LayoutSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize);
     1032    fillLayer->image()->setContainerSizeForRenderer(this, fillTileSize, style()->effectiveZoom());
     1033    geometry.setTileSize(fillTileSize);
    9311034
    9321035    EFillRepeat backgroundRepeatX = fillLayer->repeatX();
     
    9881091    LayoutRect borderImageRect = LayoutRect(leftWithOutset, topWithOutset, rightWithOutset - leftWithOutset, bottomWithOutset - topWithOutset);
    9891092
    990     styleImage->setContainerSizeForRenderer(this, borderImageRect.size());
    991     LayoutSize imageSize = styleImage->imageSize(this, 1.0f);
     1093    LayoutSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size());
     1094
     1095    // If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any.
     1096    LayoutSize containerSize = imageSize.isEmpty() ? borderImageRect.size() : imageSize;
     1097    styleImage->setContainerSizeForRenderer(this, containerSize, style->effectiveZoom());
     1098
    9921099    LayoutUnit imageWidth = imageSize.width();
    9931100    LayoutUnit imageHeight = imageSize.height();
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.h

    r97318 r98483  
    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

    r97448 r98483  
    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(bool imageSizeChanged)
     178{
     179    if (m_imageResource->imageSize(style()->effectiveZoom()) == intrinsicSize() && !imageSizeChanged)
     180        return false;
     181    if (m_imageResource->errorOccurred())
     182        return imageSizeChanged;
     183    setIntrinsicSize(m_imageResource->imageSize(style()->effectiveZoom()));
     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(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()));
     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    // Propagate the containing block size to the image resource, otherwhise we can't compute our own intrinsic size, if it's relative.
     495    RenderBox* contentRenderer = embeddedContentBox();
     496    bool hasRelativeWidth = contentRenderer ? contentRenderer->style()->width().isPercent() : m_imageResource->imageHasRelativeWidth();
     497    bool hasRelativeHeight = contentRenderer ? contentRenderer->style()->height().isPercent() : m_imageResource->imageHasRelativeHeight();
     498
     499    if (hasRelativeWidth || hasRelativeHeight) {
     500        RenderObject* containingBlock = isPositioned() ? container() : this->containingBlock();
     501        if (containingBlock->isBox()) {
     502            RenderBox* box = toRenderBox(containingBlock);
     503            m_imageResource->setContainerSizeForRenderer(IntSize(box->availableWidth(), box->availableHeight())); // Already contains zooming information.
     504            const_cast<RenderImage*>(this)->updateIntrinsicSizeIfNeeded(false);
    522505        }
    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)
     506    }
     507
     508    return RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth);
     509}
     510
     511void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicRatio, bool& isPercentageIntrinsicSize) const
     512{
     513    // Assure this method is never used for SVGImages.
     514    ASSERT(!embeddedContentBox());
     515    isPercentageIntrinsicSize = false;
     516    if (m_imageResource && m_imageResource->image())
     517        intrinsicRatio = m_imageResource->image()->size();
     518}
     519
     520bool RenderImage::needsPreferredWidthsRecalculation() const
     521{
     522    if (RenderReplaced::needsPreferredWidthsRecalculation())
     523        return true;
     524    return embeddedContentBox();
     525}
     526
     527RenderBox* RenderImage::embeddedContentBox() const
     528{
     529    if (!m_imageResource)
    562530        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;
     531
     532    RefPtr<Image> image = m_imageResource->image();
     533    if (image && image->isSVGImage())
     534        return static_pointer_cast<SVGImage>(image)->embeddedContentBox();
     535
     536    return 0;
    577537}
    578538
  • trunk/Source/WebCore/rendering/RenderImage.h

    r91628 r98483  
    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(bool imageSizeChanged);
    9694
    9795    void paintAreaElementFocusRing(PaintInfo&);
  • trunk/Source/WebCore/rendering/RenderImageResource.cpp

    r97448 r98483  
    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

    r95901 r98483  
    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

    r97448 r98483  
    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

    r97448 r98483  
    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

    r96187 r98483  
    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

    r97727 r98483  
    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
    8282void StyleCachedImage::addClient(RenderObject* renderer)
    8383{
    84     m_image->addClient(renderer);
     84    m_image->addClientForRenderer(renderer);
    8585}
    8686
    8787void StyleCachedImage::removeClient(RenderObject* renderer)
    8888{
    89     m_image->removeClient(renderer);
     89    m_image->removeClientForRenderer(renderer);
    9090}
    9191
  • trunk/Source/WebCore/rendering/style/StyleCachedImage.h

    r97727 r98483  
    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

    r97727 r98483  
    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

    r97727 r98483  
    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

    r97727 r98483  
    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

    r94372 r98483  
    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

    r98263 r98483  
    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

    r93050 r98483  
    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

    r93807 r98483  
    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

    r95040 r98483  
    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

    r93440 r98483  
    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

    r97727 r98483  
    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    void setObserver(SVGImage* image) { m_image = image; }
     68    virtual bool isSVGImageChromeClient() const { return true; }
    6569    SVGImage* image() const { return m_image; }
    6670   
     
    100104}
    101105
     106void SVGImage::setContainerZoom(float containerZoom)
     107{
     108    if (!m_page)
     109        return;
     110    m_chromeClient->setObserver(0);
     111    m_page->mainFrame()->setPageZoomFactor(containerZoom);
     112    m_chromeClient->setObserver(this);
     113}
     114
    102115void SVGImage::setContainerSize(const IntSize& containerSize)
    103116{
    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);
     117    ASSERT(!containerSize.isEmpty());
     118   
     119    if (!m_page)
     120        return;
     121    Frame* frame = m_page->mainFrame();
     122    SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement();
     123    if (!rootElement)
     124        return;
     125
     126    RenderSVGRoot* renderer = toRenderSVGRoot(rootElement->renderer());
     127    if (!renderer)
     128        return;
     129    renderer->setContainerSize(containerSize);
     130
     131    frame->view()->resize(size());
     132    if (frame->view()->needsLayout())
     133        frame->view()->layout();
    115134}
    116135
     
    123142    if (!rootElement)
    124143        return false;
    125 
    126     return rootElement->hasSetContainerSize();
     144    if (RenderSVGRoot* renderer = toRenderSVGRoot(rootElement->renderer()))
     145        return !renderer->containerSize().isEmpty();
     146    return false;
    127147}
    128148
     
    135155    if (!rootElement)
    136156        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;
     157
     158    RenderSVGRoot* renderer = toRenderSVGRoot(rootElement->renderer());
     159    if (!renderer)
     160        return IntSize();
     161
     162    // If a container size is available it has precedence.
     163    IntSize containerSize = renderer->containerSize();
     164    if (!containerSize.isEmpty())
     165        return containerSize;
     166
     167    // Otherwise fallback to the viewBox size.
     168    IntSize size = enclosingIntRect(rootElement->currentViewBoxRect()).size();
     169    if (!size.isEmpty())
     170        return size;
     171
     172    // As last resort, use CSS default intrinsic size.
     173    return IntSize(300, 150);
    175174}
    176175
     
    198197    context->scale(scale);
    199198
    200     view->resize(size());
    201 
    202     if (view->needsLayout())
    203         view->layout();
    204 
    205199    view->paint(context, IntRect(0, 0, view->width(), view->height()));
    206200
     
    214208}
    215209
     210RenderBox* SVGImage::embeddedContentBox() const
     211{
     212    if (!m_page)
     213        return 0;
     214    Frame* frame = m_page->mainFrame();
     215    SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement();
     216    if (!rootElement)
     217        return 0;
     218    return toRenderBox(rootElement->renderer());
     219}
     220
    216221void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
    217222{
     
    228233    intrinsicWidth = renderer->style()->width();
    229234    intrinsicHeight = renderer->style()->height();
    230     // FIXME: Add intrinsicRatio calculation from webkit.org/b/47156.
    231     intrinsicRatio = FloatSize();
     235    if (rootElement->preserveAspectRatio().align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
     236        intrinsicRatio = rootElement->currentViewBoxRect().size();
    232237}
    233238
     
    296301        FrameLoader* loader = frame->loader();
    297302        loader->setForcedSandboxFlags(SandboxAll);
     303
     304        frame->view()->setCanHaveScrollbars(false); // SVG Images will always synthesize a viewBox, if it's not available, and thus never see scrollbars.
     305        frame->view()->setTransparent(true); // SVG Images are transparent.
     306
    298307        ASSERT(loader->activeDocumentLoader()); // DocumentLoader should have been created by frame->init().
    299308        loader->activeDocumentLoader()->writer()->setMIMEType("image/svg+xml");
     
    301310        loader->activeDocumentLoader()->writer()->addData(data()->data(), data()->size());
    302311        loader->activeDocumentLoader()->writer()->end();
    303         frame->view()->setTransparent(true); // SVG Images are transparent.
     312   
     313        frame->view()->resize(size());
     314
     315        if (frame->view()->needsLayout())
     316            frame->view()->layout();
    304317    }
    305318
  • trunk/Source/WebCore/svg/graphics/SVGImage.h

    r97727 r98483  
    3636
    3737class Page;
     38class RenderBox;
    3839class SVGImageChromeClient;
    3940
     
    4445        return adoptRef(new SVGImage(observer));
    4546    }
     47
     48    RenderBox* embeddedContentBox() const;
     49    void setContainerZoom(float);
    4650
    4751    virtual bool isSVGImage() const { return true; }
     
    5458    virtual void setContainerSize(const IntSize&);
    5559    virtual bool usesContainerSize() const;
    56     virtual bool hasRelativeWidth() const;
    57     virtual bool hasRelativeHeight() const;
    5860    virtual void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
    5961
Note: See TracChangeset for help on using the changeset viewer.