Diff
Modified: trunk/LayoutTests/ChangeLog (221376 => 221377)
--- trunk/LayoutTests/ChangeLog 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/LayoutTests/ChangeLog 2017-08-30 17:20:26 UTC (rev 221377)
@@ -1,3 +1,18 @@
+2017-08-30 Said Abou-Hallawa <sabouhall...@apple.com>
+
+ The SVG fragment identifier is not respected if it is a part of an HTTP URL
+ https://bugs.webkit.org/show_bug.cgi?id=163811
+
+ Reviewed by Darin Adler.
+
+ * http/tests/svg/resources/rgb-icons-1.svg: Added.
+ * http/tests/svg/resources/rgb-icons-2.svg: Added.
+ * http/tests/svg/resources/rgb-icons-3.svg: Added.
+ * http/tests/svg/svg-fragment-background-expected.html: Added.
+ * http/tests/svg/svg-fragment-background.html: Added.
+ * http/tests/svg/svg-fragment-image-expected.html: Added.
+ * http/tests/svg/svg-fragment-image.html: Added.
+
2017-08-30 Per Arne Vollan <pvol...@apple.com>
The test imported/w3c/web-platform-tests/dom/traversal/NodeFilter-constants.html is slow on Windows.
Added: trunk/LayoutTests/http/tests/svg/resources/rgb-icons-1.svg (0 => 221377)
--- trunk/LayoutTests/http/tests/svg/resources/rgb-icons-1.svg (rev 0)
+++ trunk/LayoutTests/http/tests/svg/resources/rgb-icons-1.svg 2017-08-30 17:20:26 UTC (rev 221377)
@@ -0,0 +1,9 @@
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 32 96">
+ <view id="red-icon-view" viewBox="0 0 32 32"/>
+ <view id="green-icon-view" viewBox="0 32 32 32"/>
+ <view id="blue-icon-view" viewBox="0 64 32 32"/>
+
+ <rect fill="red" x="0" y="0" width="32" height="32"/>
+ <rect fill="green" x="0" y="32" width="32" height="32"/>
+ <rect fill="blue" x="0" y="64" width="32" height="32"/>
+</svg>
Added: trunk/LayoutTests/http/tests/svg/resources/rgb-icons-2.svg (0 => 221377)
--- trunk/LayoutTests/http/tests/svg/resources/rgb-icons-2.svg (rev 0)
+++ trunk/LayoutTests/http/tests/svg/resources/rgb-icons-2.svg 2017-08-30 17:20:26 UTC (rev 221377)
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 32 96">
+ <rect id="red-icon" fill="red" x="0" y="0" width="32" height="32"/>
+ <rect id="green-icon" fill="green" x="0" y="32" width="32" height="32"/>
+ <rect id="blue-icon" fill="blue" x="0" y="64" width="32" height="32"/>
+</svg>
Added: trunk/LayoutTests/http/tests/svg/resources/rgb-icons-3.svg (0 => 221377)
--- trunk/LayoutTests/http/tests/svg/resources/rgb-icons-3.svg (rev 0)
+++ trunk/LayoutTests/http/tests/svg/resources/rgb-icons-3.svg 2017-08-30 17:20:26 UTC (rev 221377)
@@ -0,0 +1,15 @@
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 32 32">
+ <defs>
+ <style>
+ rect {
+ display: none;
+ }
+ rect:target {
+ display: inline;
+ }
+ </style>
+ </defs>
+ <rect id="red-icon" fill="red" width="32" height="32"/>
+ <rect id="green-icon" fill="green" width="32" height="32"/>
+ <rect id="blue-icon" fill="blue" width="32" height="32"/>
+</svg>
Added: trunk/LayoutTests/http/tests/svg/svg-fragment-background-expected.html (0 => 221377)
--- trunk/LayoutTests/http/tests/svg/svg-fragment-background-expected.html (rev 0)
+++ trunk/LayoutTests/http/tests/svg/svg-fragment-background-expected.html 2017-08-30 17:20:26 UTC (rev 221377)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ span {
+ display: inline-block;
+ width: 100px;
+ height: 100px;
+ background-color: green;
+ }
+ </style>
+</head>
+<body>
+ <div>
+ <p>background-image with with hide/show embedded :target CSS</p>
+ <span></span>
+ <span></span>
+ <span></span>
+ </div>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/svg/svg-fragment-background.html (0 => 221377)
--- trunk/LayoutTests/http/tests/svg/svg-fragment-background.html (rev 0)
+++ trunk/LayoutTests/http/tests/svg/svg-fragment-background.html 2017-08-30 17:20:26 UTC (rev 221377)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ .icon {
+ display: inline-block;
+ width: 100px;
+ height: 100px;
+ }
+ .green-icon-1 {
+ background: url(resources/rgb-icons-3.svg#green-icon) no-repeat;
+ }
+ .green-icon-2 {
+ background: url(http://localhost:8000/svg/resources/rgb-icons-3.svg#green-icon) no-repeat;
+ }
+ </style>
+</head>
+<body>
+ <div id="group-1">
+ <p>background-image with with hide/show embedded :target CSS</p>
+ <span class="icon green-icon-1"></span>
+ <span class="icon green-icon-2"></span>
+ <span class="icon" id="green-icon"></span>
+ </div>
+ <script>
+ if (window.testRunner)
+ testRunner.waitUntilDone();
+
+ document.getElementById("green-icon").style.background = "" no-repeat";
+
+ setTimeout(function() {
+ if (window.testRunner)
+ testRunner.notifyDone();
+ }, 50);
+ </script>
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/http/tests/svg/svg-fragment-image-expected.html (0 => 221377)
--- trunk/LayoutTests/http/tests/svg/svg-fragment-image-expected.html (rev 0)
+++ trunk/LayoutTests/http/tests/svg/svg-fragment-image-expected.html 2017-08-30 17:20:26 UTC (rev 221377)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ span {
+ display: inline-block;
+ width: 100px;
+ height: 100px;
+ background-color: green;
+ }
+ </style>
+</head>
+<body>
+ <div>
+ <p><img> with #fragment referencing <view></p>
+ <span></span>
+ <span></span>
+ <span></span>
+ </div>
+ <div>
+ <p><img> with #svgView(viewBox())</p>
+ <span></span>
+ <span></span>
+ <span></span>
+ <div>
+ <div>
+ <p><img> with hide/show embedded :target CSS</p>
+ <span></span>
+ <span></span>
+ <span></span>
+ </div>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/svg/svg-fragment-image.html (0 => 221377)
--- trunk/LayoutTests/http/tests/svg/svg-fragment-image.html (rev 0)
+++ trunk/LayoutTests/http/tests/svg/svg-fragment-image.html 2017-08-30 17:20:26 UTC (rev 221377)
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ img {
+ width: 100px;
+ height: 100px;
+ }
+ </style>
+</head>
+<body>
+ <div id="group-1">
+ <p><img> with #fragment referencing <view></p>
+ <img src=""
+ <img src=""
+ </div>
+ <div id="group-2">
+ <p><img> with #svgView(viewBox())</p>
+ <img src=""
+ <img src=""
+ </div>
+ <div id="group-3">
+ <p><img> with hide/show embedded :target CSS</p>
+ <img src=""
+ <img src=""
+ </div>
+ <script>
+ function createAndLoadImage(parent, src, srcset) {
+ return new Promise((resolve) => {
+ var image = new Image;
+ parent.appendChild(image);
+ image._onload_ = (() => {
+ resolve(image);
+ });
+ image.src = ""
+ image.srcset = srcset;
+ });
+ }
+
+ (function() {
+ if (window.testRunner)
+ testRunner.waitUntilDone();
+
+ var imageData = [
+ {
+ "parent": document.getElementById("group-1"),
+ "src": "http://127.0.0.1:8000/svg/resources/rgb-icons-1.svg#red-icon-view",
+ "srcset": "http://127.0.0.1:8000/svg/resources/rgb-icons-1.svg#green-icon-view",
+ },
+ {
+ "parent": document.getElementById("group-2"),
+ "src": "http://127.0.0.1:8000/svg/resources/rgb-icons-2.svg#svgView(viewBox(0,0,32,32))",
+ "srcset": "http://127.0.0.1:8000/svg/resources/rgb-icons-2.svg#svgView(viewBox(0,32,32,32))"
+ },
+ {
+ "parent": document.getElementById("group-3"),
+ "src" : "http://127.0.0.1:8000/svg/resources/rgb-icons-3.svg#red-icon",
+ "srcset" : "http://127.0.0.1:8000/svg/resources/rgb-icons-3.svg#green-icon"
+ },
+ ];
+
+ var promises = [];
+ for (let datum of imageData)
+ promises.push(createAndLoadImage(datum.parent, datum.src, datum.srcset));
+
+ Promise.all(promises).then(() => {
+ if (window.testRunner)
+ testRunner.notifyDone();
+ });
+ })();
+ </script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (221376 => 221377)
--- trunk/Source/WebCore/ChangeLog 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/ChangeLog 2017-08-30 17:20:26 UTC (rev 221377)
@@ -1,3 +1,93 @@
+2017-08-30 Said Abou-Hallawa <sabouhall...@apple.com>
+
+ The SVG fragment identifier is not respected if it is a part of an HTTP URL
+ https://bugs.webkit.org/show_bug.cgi?id=163811
+
+ Reviewed by Darin Adler.
+
+ If an image is referenced more than once in a page and the URL to that
+ image is an HTTP URL, one CachedImage is created for all the renderers
+ even if the original URLs have different fragmentIdentifiers. In this
+ case the fragment will be removed from the request which is associated
+ with the shared CachedImage. This CachedImage creates an SVGImage with
+ a URL but without a fragmentIdentifier. So SVGImage::draw() does not call
+ FrameView::scrollToFragment() and therefore the viewport is not setup
+ correctly for displaying the SVG in this case.
+
+ The fix is to move the url from the SVGImage to SVGImageForContainer.
+ Because there is one SVGImageForContainer created for every renderer,
+ we can move the full URL there. The drawing of an SVGImage has to start
+ from the SVGImageForContainer::draw() because the SVGImage may not have
+ an intrinsic size and the SVGImageForContainer is the one which knows
+ the destination rectangle. So SVGImageForContainer can pass the full url
+ to SVGImage::drawForContainer() which can be used to scrollToFragment()
+ before calling SVGImage::draw().
+
+ For clarity and consistency, all setContainerSizeForRenderer() will be
+ changed to setContainerContext() and the pair SizeAndZoom will be replaced
+ by the struct ContainerContext.
+
+ Tests: http/tests/svg/svg-fragment-background.html
+ http/tests/svg/svg-fragment-image.html
+
+ * css/CSSCursorImageValue.h:
+ * css/CSSImageSetValue.cpp:
+ (WebCore::CSSImageSetValue::fillImageSet):
+ * css/CSSImageSetValue.h:
+ * loader/cache/CachedImage.cpp:
+ (WebCore::CachedImage::didRemoveClient):
+ (WebCore::CachedImage::switchClientsToRevalidatedResource):
+ (WebCore::CachedImage::allClientsRemoved):
+ (WebCore::CachedImage::setContainerContextForClient):
+ (WebCore::CachedImage::clear):
+ (WebCore::CachedImage::createImage):
+ (WebCore::CachedImage::setContainerSizeForRenderer): Deleted.
+ * loader/cache/CachedImage.h:
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry const):
+ (WebCore::RenderBoxModelObject::paintNinePieceImage):
+ * rendering/RenderImage.cpp:
+ (WebCore::RenderImage::updateInnerContentRect):
+ (WebCore::RenderImage::repaintOrMarkForLayout):
+ * rendering/RenderImageResource.cpp:
+ (WebCore::RenderImageResource::setContainerContext):
+ (WebCore::RenderImageResource::setContainerSizeForRenderer): Deleted.
+ * rendering/RenderImageResource.h:
+ * rendering/RenderImageResourceStyleImage.cpp:
+ (WebCore::RenderImageResourceStyleImage::setContainerContext):
+ (WebCore::RenderImageResourceStyleImage::setContainerSizeForRenderer): Deleted.
+ * rendering/RenderImageResourceStyleImage.h:
+ * rendering/RenderListMarker.cpp:
+ (WebCore::RenderListMarker::updateContent):
+ * rendering/shapes/ShapeOutsideInfo.cpp:
+ (WebCore::ShapeOutsideInfo::createShapeForImage const):
+ * rendering/style/StyleCachedImage.cpp:
+ (WebCore::StyleCachedImage::imageURL):
+ (WebCore::StyleCachedImage::setContainerContextForRenderer):
+ (WebCore::StyleCachedImage::setContainerSizeForRenderer): Deleted.
+ * rendering/style/StyleCachedImage.h:
+ * rendering/style/StyleGeneratedImage.h:
+ * rendering/style/StyleImage.h:
+ * rendering/svg/RenderSVGImage.cpp:
+ (WebCore::RenderSVGImage::updateImageViewport):
+ * svg/SVGImageElement.h:
+ * svg/graphics/SVGImage.cpp:
+ (WebCore::SVGImage::SVGImage):
+ (WebCore::SVGImage::drawForContainer):
+ (WebCore::SVGImage::drawPatternForContainer):
+ (WebCore::SVGImage::draw):
+ (WebCore::SVGImage::dump const): Deleted.
+ * svg/graphics/SVGImage.h:
+ * svg/graphics/SVGImageCache.cpp:
+ (WebCore::SVGImageCache::setContainerContextForClient):
+ (WebCore::SVGImageCache::setContainerSizeForRenderer): Deleted.
+ * svg/graphics/SVGImageCache.h:
+ * svg/graphics/SVGImageForContainer.cpp:
+ (WebCore::SVGImageForContainer::size const):
+ (WebCore::SVGImageForContainer::draw):
+ (WebCore::SVGImageForContainer::drawPattern):
+ * svg/graphics/SVGImageForContainer.h:
+
2017-08-29 Wenson Hsieh <wenson_hs...@apple.com>
REGRESSION(r210287) On drop, event.dataTransfer.getData("text") returns an empty string when dragging an image
Modified: trunk/Source/WebCore/css/CSSCursorImageValue.h (221376 => 221377)
--- trunk/Source/WebCore/css/CSSCursorImageValue.h 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/css/CSSCursorImageValue.h 2017-08-30 17:20:26 UTC (rev 221377)
@@ -52,6 +52,8 @@
return IntPoint(-1, -1);
}
+ const URL& imageURL() const { return m_originalURL; }
+
String customCSSText() const;
std::pair<CachedImage*, float> loadImage(CachedResourceLoader&, const ResourceLoaderOptions&);
Modified: trunk/Source/WebCore/css/CSSImageSetValue.cpp (221376 => 221377)
--- trunk/Source/WebCore/css/CSSImageSetValue.cpp 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/css/CSSImageSetValue.cpp 2017-08-30 17:20:26 UTC (rev 221377)
@@ -53,7 +53,7 @@
size_t i = 0;
while (i < length) {
CSSValue* imageValue = item(i);
- String imageURL = downcast<CSSImageValue>(*imageValue).url();
+ URL imageURL = downcast<CSSImageValue>(*imageValue).url();
++i;
ASSERT_WITH_SECURITY_IMPLICATION(i < length);
Modified: trunk/Source/WebCore/css/CSSImageSetValue.h (221376 => 221377)
--- trunk/Source/WebCore/css/CSSImageSetValue.h 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/css/CSSImageSetValue.h 2017-08-30 17:20:26 UTC (rev 221377)
@@ -50,7 +50,7 @@
String customCSSText() const;
struct ImageWithScale {
- String imageURL;
+ URL imageURL;
float scaleFactor;
};
@@ -58,6 +58,8 @@
void updateDeviceScaleFactor(const Document&);
+ URL bestImageForScaleFactorURL() { return bestImageForScaleFactor().imageURL; }
+
protected:
ImageWithScale bestImageForScaleFactor();
Modified: trunk/Source/WebCore/loader/cache/CachedImage.cpp (221376 => 221377)
--- trunk/Source/WebCore/loader/cache/CachedImage.cpp 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/loader/cache/CachedImage.cpp 2017-08-30 17:20:26 UTC (rev 221377)
@@ -129,7 +129,7 @@
{
ASSERT(client.resourceClientType() == CachedImageClient::expectedType());
- m_pendingContainerSizeRequests.remove(&static_cast<CachedImageClient&>(client));
+ m_pendingContainerContextRequests.remove(&static_cast<CachedImageClient&>(client));
m_pendingImageDrawingClients.remove(&static_cast<CachedImageClient&>(client));
if (m_svgImageCache)
@@ -163,15 +163,15 @@
{
ASSERT(is<CachedImage>(resourceToRevalidate()));
// Pending container size requests need to be transferred to the revalidated resource.
- if (!m_pendingContainerSizeRequests.isEmpty()) {
+ if (!m_pendingContainerContextRequests.isEmpty()) {
// A copy of pending size requests is needed as they are deleted during CachedResource::switchClientsToRevalidateResouce().
- ContainerSizeRequests switchContainerSizeRequests;
- for (auto& request : m_pendingContainerSizeRequests)
- switchContainerSizeRequests.set(request.key, request.value);
+ ContainerContextRequests switchContainerContextRequests;
+ for (auto& request : m_pendingContainerContextRequests)
+ switchContainerContextRequests.set(request.key, request.value);
CachedResource::switchClientsToRevalidatedResource();
CachedImage& revalidatedCachedImage = downcast<CachedImage>(*resourceToRevalidate());
- for (auto& request : switchContainerSizeRequests)
- revalidatedCachedImage.setContainerSizeForRenderer(request.key, request.value.first, request.value.second);
+ for (auto& request : switchContainerContextRequests)
+ revalidatedCachedImage.setContainerContextForClient(*request.key, request.value.containerSize, request.value.containerZoom, request.value.imageURL);
return;
}
@@ -180,7 +180,7 @@
void CachedImage::allClientsRemoved()
{
- m_pendingContainerSizeRequests.clear();
+ m_pendingContainerContextRequests.clear();
m_pendingImageDrawingClients.clear();
if (m_image && !errorOccurred())
m_image->resetAnimation();
@@ -242,14 +242,13 @@
return m_image.get();
}
-void CachedImage::setContainerSizeForRenderer(const CachedImageClient* renderer, const LayoutSize& containerSize, float containerZoom)
+void CachedImage::setContainerContextForClient(const CachedImageClient& client, const LayoutSize& containerSize, float containerZoom, const URL& imageURL)
{
if (containerSize.isEmpty())
return;
- ASSERT(renderer);
ASSERT(containerZoom);
if (!m_image) {
- m_pendingContainerSizeRequests.set(renderer, SizeAndZoom(containerSize, containerZoom));
+ m_pendingContainerContextRequests.set(&client, ContainerContext { containerSize, containerZoom, imageURL });
return;
}
@@ -258,7 +257,7 @@
return;
}
- m_svgImageCache->setContainerSizeForRenderer(renderer, containerSize, containerZoom);
+ m_svgImageCache->setContainerContextForClient(client, containerSize, containerZoom, imageURL);
}
LayoutSize CachedImage::imageSizeForRenderer(const RenderElement* renderer, float multiplier, SizeType sizeType)
@@ -313,7 +312,7 @@
{
destroyDecodedData();
clearImage();
- m_pendingContainerSizeRequests.clear();
+ m_pendingContainerContextRequests.clear();
m_pendingImageDrawingClients.clear();
setEncodedSize(0);
}
@@ -327,7 +326,7 @@
m_imageObserver = CachedImageObserver::create(*this);
if (m_response.mimeType() == "image/svg+xml") {
- auto svgImage = SVGImage::create(*m_imageObserver, url());
+ auto svgImage = SVGImage::create(*m_imageObserver);
m_svgImageCache = std::make_unique<SVGImageCache>(svgImage.ptr());
m_image = WTFMove(svgImage);
#if USE(CG) && !USE(WEBKIT_IMAGE_DECODERS)
@@ -340,10 +339,10 @@
if (m_image) {
// Send queued container size requests.
if (m_image->usesContainerSize()) {
- for (auto& request : m_pendingContainerSizeRequests)
- setContainerSizeForRenderer(request.key, request.value.first, request.value.second);
+ for (auto& request : m_pendingContainerContextRequests)
+ setContainerContextForClient(*request.key, request.value.containerSize, request.value.containerZoom, request.value.imageURL);
}
- m_pendingContainerSizeRequests.clear();
+ m_pendingContainerContextRequests.clear();
m_pendingImageDrawingClients.clear();
}
}
Modified: trunk/Source/WebCore/loader/cache/CachedImage.h (221376 => 221377)
--- trunk/Source/WebCore/loader/cache/CachedImage.h 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/loader/cache/CachedImage.h 2017-08-30 17:20:26 UTC (rev 221377)
@@ -63,7 +63,7 @@
bool canRender(const RenderElement* renderer, float multiplier) { return !errorOccurred() && !imageSizeForRenderer(renderer, multiplier).isEmpty(); }
- void setContainerSizeForRenderer(const CachedImageClient*, const LayoutSize&, float);
+ void setContainerContextForClient(const CachedImageClient&, const LayoutSize&, float, const URL&);
bool usesImageContainerSize() const { return m_image && m_image->usesContainerSize(); }
bool imageHasRelativeWidth() const { return m_image && m_image->hasRelativeWidth(); }
bool imageHasRelativeHeight() const { return m_image && m_image->hasRelativeHeight(); }
@@ -150,10 +150,15 @@
void didReplaceSharedBufferContents() override;
- typedef std::pair<LayoutSize, float> SizeAndZoom;
- typedef HashMap<const CachedImageClient*, SizeAndZoom> ContainerSizeRequests;
- ContainerSizeRequests m_pendingContainerSizeRequests;
+ struct ContainerContext {
+ LayoutSize containerSize;
+ float containerZoom;
+ URL imageURL;
+ };
+ using ContainerContextRequests = HashMap<const CachedImageClient*, ContainerContext>;
+ ContainerContextRequests m_pendingContainerContextRequests;
+
HashSet<CachedImageClient*> m_pendingImageDrawingClients;
RefPtr<CachedImageObserver> m_imageObserver;
Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (221376 => 221377)
--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2017-08-30 17:20:26 UTC (rev 221377)
@@ -1241,7 +1241,7 @@
auto clientForBackgroundImage = backgroundObject ? backgroundObject : this;
LayoutSize tileSize = calculateFillTileSize(fillLayer, positioningAreaSize);
if (StyleImage* layerImage = fillLayer.image())
- layerImage->setContainerSizeForRenderer(clientForBackgroundImage, tileSize, style().effectiveZoom());
+ layerImage->setContainerContextForRenderer(*clientForBackgroundImage, tileSize, style().effectiveZoom());
EFillRepeat backgroundRepeatX = fillLayer.repeatX();
EFillRepeat backgroundRepeatY = fillLayer.repeatY();
@@ -1363,7 +1363,7 @@
LayoutSize source = calculateImageIntrinsicDimensions(styleImage, destination.size(), DoNotScaleByEffectiveZoom);
// If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any.
- styleImage->setContainerSizeForRenderer(this, source, style.effectiveZoom());
+ styleImage->setContainerContextForRenderer(*this, source, style.effectiveZoom());
ninePieceImage.paint(graphicsContext, this, style, destination, source, deviceScaleFactor, op);
return true;
Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (221376 => 221377)
--- trunk/Source/WebCore/rendering/RenderImage.cpp 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp 2017-08-30 17:20:26 UTC (rev 221377)
@@ -285,8 +285,12 @@
{
// Propagate container size to image resource.
IntSize containerSize(replacedContentRect(intrinsicSize()).size());
- if (!containerSize.isEmpty())
- imageResource().setContainerSizeForRenderer(containerSize);
+ if (!containerSize.isEmpty()) {
+ URL imageSourceURL;
+ if (HTMLImageElement* imageElement = is<HTMLImageElement>(element()) ? downcast<HTMLImageElement>(element()) : nullptr)
+ imageSourceURL = document().completeURL(imageElement->imageSourceURL());
+ imageResource().setContainerContext(containerSize, imageSourceURL);
+ }
}
void RenderImage::repaintOrMarkForLayout(ImageSizeChangeType imageSizeChange, const IntRect* rect)
@@ -323,7 +327,7 @@
// may need values from the containing block, though, so make sure that we're not too
// early. It may be that layout hasn't even taken place once yet.
- // FIXME: we should not have to trigger another call to setContainerSizeForRenderer()
+ // FIXME: we should not have to trigger another call to setContainerContextForRenderer()
// from here, since it's already being done during layout.
updateInnerContentRect();
}
Modified: trunk/Source/WebCore/rendering/RenderImageResource.cpp (221376 => 221377)
--- trunk/Source/WebCore/rendering/RenderImageResource.cpp 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/rendering/RenderImageResource.cpp 2017-08-30 17:20:26 UTC (rev 221377)
@@ -94,12 +94,12 @@
return &Image::nullImage();
}
-void RenderImageResource::setContainerSizeForRenderer(const IntSize& imageContainerSize)
+void RenderImageResource::setContainerContext(const IntSize& imageContainerSize, const URL& imageURL)
{
if (!m_cachedImage)
return;
ASSERT(m_renderer);
- m_cachedImage->setContainerSizeForRenderer(m_renderer, imageContainerSize, m_renderer->style().effectiveZoom());
+ m_cachedImage->setContainerContextForClient(*m_renderer, imageContainerSize, m_renderer->style().effectiveZoom(), imageURL);
}
LayoutSize RenderImageResource::imageSize(float multiplier, CachedImage::SizeType type) const
Modified: trunk/Source/WebCore/rendering/RenderImageResource.h (221376 => 221377)
--- trunk/Source/WebCore/rendering/RenderImageResource.h 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/rendering/RenderImageResource.h 2017-08-30 17:20:26 UTC (rev 221377)
@@ -51,7 +51,7 @@
virtual RefPtr<Image> image(const IntSize& size = { }) const;
virtual bool errorOccurred() const { return m_cachedImage && m_cachedImage->errorOccurred(); }
- virtual void setContainerSizeForRenderer(const IntSize&);
+ virtual void setContainerContext(const IntSize&, const URL&);
virtual bool imageHasRelativeWidth() const { return m_cachedImage && m_cachedImage->imageHasRelativeWidth(); }
virtual bool imageHasRelativeHeight() const { return m_cachedImage && m_cachedImage->imageHasRelativeHeight(); }
Modified: trunk/Source/WebCore/rendering/RenderImageResourceStyleImage.cpp (221376 => 221377)
--- trunk/Source/WebCore/rendering/RenderImageResourceStyleImage.cpp 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/rendering/RenderImageResourceStyleImage.cpp 2017-08-30 17:20:26 UTC (rev 221377)
@@ -62,10 +62,10 @@
return &Image::nullImage();
}
-void RenderImageResourceStyleImage::setContainerSizeForRenderer(const IntSize& size)
+void RenderImageResourceStyleImage::setContainerContext(const IntSize& size, const URL&)
{
ASSERT(renderer());
- m_styleImage->setContainerSizeForRenderer(renderer(), size, renderer()->style().effectiveZoom());
+ m_styleImage->setContainerContextForRenderer(*renderer(), size, renderer()->style().effectiveZoom());
}
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderImageResourceStyleImage.h (221376 => 221377)
--- trunk/Source/WebCore/rendering/RenderImageResourceStyleImage.h 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/rendering/RenderImageResourceStyleImage.h 2017-08-30 17:20:26 UTC (rev 221377)
@@ -44,7 +44,7 @@
RefPtr<Image> image(const IntSize& = { }) const final;
bool errorOccurred() const final { return m_styleImage->errorOccurred(); }
- void setContainerSizeForRenderer(const IntSize&) final;
+ void setContainerContext(const IntSize&, const URL&) final;
bool imageHasRelativeWidth() const final { return m_styleImage->imageHasRelativeWidth(); }
bool imageHasRelativeHeight() const final { return m_styleImage->imageHasRelativeHeight(); }
Modified: trunk/Source/WebCore/rendering/RenderListMarker.cpp (221376 => 221377)
--- trunk/Source/WebCore/rendering/RenderListMarker.cpp 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/rendering/RenderListMarker.cpp 2017-08-30 17:20:26 UTC (rev 221377)
@@ -1443,7 +1443,7 @@
LayoutUnit bulletWidth = style().fontMetrics().ascent() / LayoutUnit(2);
LayoutSize defaultBulletSize(bulletWidth, bulletWidth);
LayoutSize imageSize = calculateImageIntrinsicDimensions(m_image.get(), defaultBulletSize, DoNotScaleByEffectiveZoom);
- m_image->setContainerSizeForRenderer(this, imageSize, style().effectiveZoom());
+ m_image->setContainerContextForRenderer(*this, imageSize, style().effectiveZoom());
return;
}
Modified: trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp (221376 => 221377)
--- trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp 2017-08-30 17:20:26 UTC (rev 221377)
@@ -147,7 +147,7 @@
std::unique_ptr<Shape> ShapeOutsideInfo::createShapeForImage(StyleImage* styleImage, float shapeImageThreshold, WritingMode writingMode, float margin) const
{
LayoutSize imageSize = m_renderer.calculateImageIntrinsicDimensions(styleImage, m_referenceBoxLogicalSize, RenderImage::ScaleByEffectiveZoom);
- styleImage->setContainerSizeForRenderer(&m_renderer, imageSize, m_renderer.style().effectiveZoom());
+ styleImage->setContainerContextForRenderer(m_renderer, imageSize, m_renderer.style().effectiveZoom());
const LayoutRect& marginRect = getShapeImageMarginRect(m_renderer, m_referenceBoxLogicalSize);
const LayoutRect& imageRect = is<RenderImage>(m_renderer)
Modified: trunk/Source/WebCore/rendering/style/StyleCachedImage.cpp (221376 => 221377)
--- trunk/Source/WebCore/rendering/style/StyleCachedImage.cpp 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/rendering/style/StyleCachedImage.cpp 2017-08-30 17:20:26 UTC (rev 221377)
@@ -68,6 +68,21 @@
return false;
}
+URL StyleCachedImage::imageURL()
+{
+ if (is<CSSImageValue>(m_cssValue))
+ return downcast<CSSImageValue>(m_cssValue.get()).url();
+
+ if (is<CSSImageSetValue>(m_cssValue))
+ return downcast<CSSImageSetValue>(m_cssValue.get()).bestImageForScaleFactorURL();
+
+ if (is<CSSCursorImageValue>(m_cssValue.get()))
+ return downcast<CSSCursorImageValue>(m_cssValue.get()).imageURL();
+
+ ASSERT_NOT_REACHED();
+ return { };
+}
+
void StyleCachedImage::load(CachedResourceLoader& loader, const ResourceLoaderOptions& options)
{
ASSERT(m_isPending);
@@ -165,11 +180,11 @@
return m_cachedImage->usesImageContainerSize();
}
-void StyleCachedImage::setContainerSizeForRenderer(const RenderElement* renderer, const FloatSize& imageContainerSize, float imageContainerZoomFactor)
+void StyleCachedImage::setContainerContextForRenderer(const RenderElement& renderer, const FloatSize& containerSize, float containerZoom)
{
if (!m_cachedImage)
return;
- m_cachedImage->setContainerSizeForRenderer(renderer, LayoutSize(imageContainerSize), imageContainerZoomFactor);
+ m_cachedImage->setContainerContextForClient(renderer, LayoutSize(containerSize), containerZoom, imageURL());
}
void StyleCachedImage::addClient(RenderElement* renderer)
Modified: trunk/Source/WebCore/rendering/style/StyleCachedImage.h (221376 => 221377)
--- trunk/Source/WebCore/rendering/style/StyleCachedImage.h 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/rendering/style/StyleCachedImage.h 2017-08-30 17:20:26 UTC (rev 221377)
@@ -38,33 +38,34 @@
static Ref<StyleCachedImage> create(CSSValue& cssValue) { return adoptRef(*new StyleCachedImage(cssValue)); }
virtual ~StyleCachedImage();
- bool operator==(const StyleImage& other) const override;
+ bool operator==(const StyleImage& other) const final;
- CachedImage* cachedImage() const override;
+ CachedImage* cachedImage() const final;
- WrappedImagePtr data() const override { return m_cachedImage.get(); }
+ WrappedImagePtr data() const final { return m_cachedImage.get(); }
- Ref<CSSValue> cssValue() const override;
+ Ref<CSSValue> cssValue() const final;
- bool canRender(const RenderElement*, float multiplier) const override;
- bool isPending() const override;
- void load(CachedResourceLoader&, const ResourceLoaderOptions&) override;
- bool isLoaded() const override;
- bool errorOccurred() const override;
- FloatSize imageSize(const RenderElement*, float multiplier) const override;
- bool imageHasRelativeWidth() const override;
- bool imageHasRelativeHeight() const override;
- void computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) override;
- bool usesImageContainerSize() const override;
- void setContainerSizeForRenderer(const RenderElement*, const FloatSize&, float) override;
- void addClient(RenderElement*) override;
- void removeClient(RenderElement*) override;
- RefPtr<Image> image(RenderElement*, const FloatSize&) const override;
- float imageScaleFactor() const override;
- bool knownToBeOpaque(const RenderElement*) const override;
+ bool canRender(const RenderElement*, float multiplier) const final;
+ bool isPending() const final;
+ void load(CachedResourceLoader&, const ResourceLoaderOptions&) final;
+ bool isLoaded() const final;
+ bool errorOccurred() const final;
+ FloatSize imageSize(const RenderElement*, float multiplier) const final;
+ bool imageHasRelativeWidth() const final;
+ bool imageHasRelativeHeight() const final;
+ void computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) final;
+ bool usesImageContainerSize() const final;
+ void setContainerContextForRenderer(const RenderElement&, const FloatSize&, float) final;
+ void addClient(RenderElement*) final;
+ void removeClient(RenderElement*) final;
+ RefPtr<Image> image(RenderElement*, const FloatSize&) const final;
+ float imageScaleFactor() const final;
+ bool knownToBeOpaque(const RenderElement*) const final;
private:
StyleCachedImage(CSSValue&);
+ URL imageURL();
Ref<CSSValue> m_cssValue;
bool m_isPending { true };
Modified: trunk/Source/WebCore/rendering/style/StyleGeneratedImage.h (221376 => 221377)
--- trunk/Source/WebCore/rendering/style/StyleGeneratedImage.h 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/rendering/style/StyleGeneratedImage.h 2017-08-30 17:20:26 UTC (rev 221377)
@@ -40,24 +40,24 @@
CSSImageGeneratorValue& imageValue() { return m_imageGeneratorValue; }
private:
- bool operator==(const StyleImage& other) const override { return data() == other.data(); }
+ bool operator==(const StyleImage& other) const final { return data() == other.data(); }
- WrappedImagePtr data() const override { return m_imageGeneratorValue.ptr(); }
+ WrappedImagePtr data() const final { return m_imageGeneratorValue.ptr(); }
- Ref<CSSValue> cssValue() const override;
+ Ref<CSSValue> cssValue() const final;
bool isPending() const override;
- void load(CachedResourceLoader&, const ResourceLoaderOptions&) override;
- FloatSize imageSize(const RenderElement*, float multiplier) const override;
- bool imageHasRelativeWidth() const override { return !m_fixedSize; }
- bool imageHasRelativeHeight() const override { return !m_fixedSize; }
- void computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) override;
- bool usesImageContainerSize() const override { return !m_fixedSize; }
- void setContainerSizeForRenderer(const RenderElement*, const FloatSize& containerSize, float) override { m_containerSize = containerSize; }
- void addClient(RenderElement*) override;
- void removeClient(RenderElement*) override;
- RefPtr<Image> image(RenderElement*, const FloatSize&) const override;
- bool knownToBeOpaque(const RenderElement*) const override;
+ void load(CachedResourceLoader&, const ResourceLoaderOptions&) final;
+ FloatSize imageSize(const RenderElement*, float multiplier) const final;
+ bool imageHasRelativeWidth() const final { return !m_fixedSize; }
+ bool imageHasRelativeHeight() const final { return !m_fixedSize; }
+ void computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) final;
+ bool usesImageContainerSize() const final { return !m_fixedSize; }
+ void setContainerContextForRenderer(const RenderElement&, const FloatSize& containerSize, float) final { m_containerSize = containerSize; }
+ void addClient(RenderElement*) final;
+ void removeClient(RenderElement*) final;
+ RefPtr<Image> image(RenderElement*, const FloatSize&) const final;
+ bool knownToBeOpaque(const RenderElement*) const final;
explicit StyleGeneratedImage(Ref<CSSImageGeneratorValue>&&);
Modified: trunk/Source/WebCore/rendering/style/StyleImage.h (221376 => 221377)
--- trunk/Source/WebCore/rendering/style/StyleImage.h 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/rendering/style/StyleImage.h 2017-08-30 17:20:26 UTC (rev 221377)
@@ -59,7 +59,7 @@
virtual bool imageHasRelativeWidth() const = 0;
virtual bool imageHasRelativeHeight() const = 0;
virtual bool usesImageContainerSize() const = 0;
- virtual void setContainerSizeForRenderer(const RenderElement*, const FloatSize&, float) = 0;
+ virtual void setContainerContextForRenderer(const RenderElement&, const FloatSize&, float) = 0;
virtual void addClient(RenderElement*) = 0;
virtual void removeClient(RenderElement*) = 0;
virtual RefPtr<Image> image(RenderElement*, const FloatSize&) const = 0;
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGImage.cpp (221376 => 221377)
--- trunk/Source/WebCore/rendering/svg/RenderSVGImage.cpp 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGImage.cpp 2017-08-30 17:20:26 UTC (rev 221377)
@@ -75,14 +75,16 @@
SVGLengthContext lengthContext(&imageElement());
m_objectBoundingBox = FloatRect(imageElement().x().value(lengthContext), imageElement().y().value(lengthContext), imageElement().width().value(lengthContext), imageElement().height().value(lengthContext));
+ URL imageSourceURL = document().completeURL(imageElement().imageSourceURL());
+
// Images with preserveAspectRatio=none should force non-uniform scaling. This can be achieved
// by setting the image's container size to its intrinsic size.
// See: http://www.w3.org/TR/SVG/single-page.html, 7.8 The ‘preserveAspectRatio’ attribute.
if (imageElement().preserveAspectRatio().align() == SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_NONE) {
if (CachedImage* cachedImage = imageResource().cachedImage()) {
- LayoutSize intrinsicSize = cachedImage->imageSizeForRenderer(0, style().effectiveZoom());
+ LayoutSize intrinsicSize = cachedImage->imageSizeForRenderer(nullptr, style().effectiveZoom());
if (intrinsicSize != imageResource().imageSize(style().effectiveZoom())) {
- imageResource().setContainerSizeForRenderer(roundedIntSize(intrinsicSize));
+ imageResource().setContainerContext(roundedIntSize(intrinsicSize), imageSourceURL);
updatedViewport = true;
}
}
@@ -90,7 +92,7 @@
if (oldBoundaries != m_objectBoundingBox) {
if (!updatedViewport)
- imageResource().setContainerSizeForRenderer(enclosingIntRect(m_objectBoundingBox).size());
+ imageResource().setContainerContext(enclosingIntRect(m_objectBoundingBox).size(), imageSourceURL);
updatedViewport = true;
m_needsBoundariesUpdate = true;
}
Modified: trunk/Source/WebCore/svg/SVGImageElement.h (221376 => 221377)
--- trunk/Source/WebCore/svg/SVGImageElement.h 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/svg/SVGImageElement.h 2017-08-30 17:20:26 UTC (rev 221377)
@@ -37,6 +37,7 @@
static Ref<SVGImageElement> create(const QualifiedName&, Document&);
bool hasSingleSecurityOrigin() const;
+ const AtomicString& imageSourceURL() const final;
private:
SVGImageElement(const QualifiedName&, Document&);
@@ -52,7 +53,6 @@
RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
- const AtomicString& imageSourceURL() const final;
void addSubresourceAttributeURLs(ListHashSet<URL>&) const final;
bool haveLoadedRequiredResources() final;
Modified: trunk/Source/WebCore/svg/graphics/SVGImage.cpp (221376 => 221377)
--- trunk/Source/WebCore/svg/graphics/SVGImage.cpp 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.cpp 2017-08-30 17:20:26 UTC (rev 221377)
@@ -66,9 +66,8 @@
namespace WebCore {
-SVGImage::SVGImage(ImageObserver& observer, const URL& url)
+SVGImage::SVGImage(ImageObserver& observer)
: Image(&observer)
- , m_url(url)
{
}
@@ -166,7 +165,7 @@
return IntSize(300, 150);
}
-ImageDrawResult SVGImage::drawForContainer(GraphicsContext& context, const FloatSize containerSize, float zoom, const FloatRect& dstRect,
+ImageDrawResult SVGImage::drawForContainer(GraphicsContext& context, const FloatSize containerSize, float containerZoom, const URL& initialFragmentURL, const FloatRect& dstRect,
const FloatRect& srcRect, CompositeOperator compositeOp, BlendMode blendMode)
{
if (!m_page)
@@ -182,7 +181,7 @@
setContainerSize(roundedContainerSize);
FloatRect scaledSrc = srcRect;
- scaledSrc.scale(1 / zoom);
+ scaledSrc.scale(1 / containerZoom);
// Compensate for the container size rounding by adjusting the source rect.
FloatSize adjustedSrcSize = scaledSrc.size();
@@ -189,6 +188,8 @@
adjustedSrcSize.scale(roundedContainerSize.width() / containerSize.width(), roundedContainerSize.height() / containerSize.height());
scaledSrc.setSize(adjustedSrcSize);
+ frameView()->scrollToFragment(initialFragmentURL);
+
ImageDrawResult result = draw(context, dstRect, scaledSrc, compositeOp, blendMode, DecodingMode::Synchronous, ImageOrientationDescription());
setImageObserver(observer);
@@ -242,11 +243,11 @@
}
#endif
-void SVGImage::drawPatternForContainer(GraphicsContext& context, const FloatSize& containerSize, float zoom, const FloatRect& srcRect,
+void SVGImage::drawPatternForContainer(GraphicsContext& context, const FloatSize& containerSize, float containerZoom, const URL& initialFragmentURL, const FloatRect& srcRect,
const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator compositeOp, const FloatRect& dstRect, BlendMode blendMode)
{
FloatRect zoomedContainerRect = FloatRect(FloatPoint(), containerSize);
- zoomedContainerRect.scale(zoom);
+ zoomedContainerRect.scale(containerZoom);
// The ImageBuffer size needs to be scaled to match the final resolution.
AffineTransform transform = context.getCTM();
@@ -260,7 +261,7 @@
std::unique_ptr<ImageBuffer> buffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(imageBufferSize.size()), 1, ColorSpaceSRGB, context);
if (!buffer) // Failed to allocate buffer.
return;
- drawForContainer(buffer->context(), containerSize, zoom, imageBufferSize, zoomedContainerRect, CompositeSourceOver, BlendModeNormal);
+ drawForContainer(buffer->context(), containerSize, containerZoom, initialFragmentURL, imageBufferSize, zoomedContainerRect, CompositeSourceOver, BlendModeNormal);
if (context.drawLuminanceMask())
buffer->convertToLuminanceMask();
@@ -309,9 +310,6 @@
view->resize(containerSize());
- if (!m_url.isEmpty())
- view->scrollToFragment(m_url);
-
if (view->needsLayout())
view->layout();
@@ -490,11 +488,4 @@
return page->chrome().client().isSVGImageChromeClient();
}
-void SVGImage::dump(TextStream& ts) const
-{
- Image::dump(ts);
- ts.dumpProperty("url", m_url.string());
}
-
-
-}
Modified: trunk/Source/WebCore/svg/graphics/SVGImage.h (221376 => 221377)
--- trunk/Source/WebCore/svg/graphics/SVGImage.h 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.h 2017-08-30 17:20:26 UTC (rev 221377)
@@ -42,10 +42,7 @@
class SVGImage final : public Image {
public:
- static Ref<SVGImage> create(ImageObserver& observer, const URL& url)
- {
- return adoptRef(*new SVGImage(observer, url));
- }
+ static Ref<SVGImage> create(ImageObserver& observer) { return adoptRef(*new SVGImage(observer)); }
RenderBox* embeddedContentBox() const;
FrameView* frameView() const;
@@ -53,8 +50,6 @@
bool isSVGImage() const final { return true; }
FloatSize size() const final { return m_intrinsicSize; }
- void setURL(const URL& url) { m_url = url; }
-
bool hasSingleSecurityOrigin() const final;
bool hasRelativeWidth() const final;
@@ -94,12 +89,10 @@
// FIXME: Implement this to be less conservative.
bool currentFrameKnownToBeOpaque() const final { return false; }
- void dump(WTF::TextStream&) const final;
-
- SVGImage(ImageObserver&, const URL&);
+ explicit SVGImage(ImageObserver&);
ImageDrawResult draw(GraphicsContext&, const FloatRect& fromRect, const FloatRect& toRect, CompositeOperator, BlendMode, DecodingMode, ImageOrientationDescription) final;
- ImageDrawResult drawForContainer(GraphicsContext&, const FloatSize, float, const FloatRect&, const FloatRect&, CompositeOperator, BlendMode);
- void drawPatternForContainer(GraphicsContext&, const FloatSize& containerSize, float zoom, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing,
+ ImageDrawResult drawForContainer(GraphicsContext&, const FloatSize containerSize, float containerZoom, const URL& initialFragmentURL, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator, BlendMode);
+ void drawPatternForContainer(GraphicsContext&, const FloatSize& containerSize, float containerZoom, const URL& initialFragmentURL, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing,
CompositeOperator, const FloatRect&, BlendMode);
SVGSVGElement* rootElement() const;
@@ -107,7 +100,6 @@
std::unique_ptr<SVGImageChromeClient> m_chromeClient;
std::unique_ptr<Page> m_page;
FloatSize m_intrinsicSize;
- URL m_url;
};
bool isInSVGImage(const Element*);
Modified: trunk/Source/WebCore/svg/graphics/SVGImageCache.cpp (221376 => 221377)
--- trunk/Source/WebCore/svg/graphics/SVGImageCache.cpp 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/svg/graphics/SVGImageCache.cpp 2017-08-30 17:20:26 UTC (rev 221377)
@@ -49,9 +49,8 @@
m_imageForContainerMap.remove(client);
}
-void SVGImageCache::setContainerSizeForRenderer(const CachedImageClient* client, const LayoutSize& containerSize, float containerZoom)
+void SVGImageCache::setContainerContextForClient(const CachedImageClient& client, const LayoutSize& containerSize, float containerZoom, const URL& imageURL)
{
- ASSERT(client);
ASSERT(!containerSize.isEmpty());
ASSERT(containerZoom);
@@ -58,7 +57,7 @@
FloatSize containerSizeWithoutZoom(containerSize);
containerSizeWithoutZoom.scale(1 / containerZoom);
- m_imageForContainerMap.set(client, SVGImageForContainer::create(m_svgImage, containerSizeWithoutZoom, containerZoom));
+ m_imageForContainerMap.set(&client, SVGImageForContainer::create(m_svgImage, containerSizeWithoutZoom, containerZoom, imageURL));
}
Image* SVGImageCache::findImageForRenderer(const RenderObject* renderer) const
Modified: trunk/Source/WebCore/svg/graphics/SVGImageCache.h (221376 => 221377)
--- trunk/Source/WebCore/svg/graphics/SVGImageCache.h 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/svg/graphics/SVGImageCache.h 2017-08-30 17:20:26 UTC (rev 221377)
@@ -33,6 +33,7 @@
class SVGImage;
class SVGImageForContainer;
class RenderObject;
+class URL;
class SVGImageCache {
WTF_MAKE_FAST_ALLOCATED;
@@ -42,7 +43,7 @@
void removeClientFromCache(const CachedImageClient*);
- void setContainerSizeForRenderer(const CachedImageClient*, const LayoutSize&, float);
+ void setContainerContextForClient(const CachedImageClient&, const LayoutSize&, float, const URL&);
FloatSize imageSizeForRenderer(const RenderObject*) const;
Image* imageForRenderer(const RenderObject*) const;
Modified: trunk/Source/WebCore/svg/graphics/SVGImageForContainer.cpp (221376 => 221377)
--- trunk/Source/WebCore/svg/graphics/SVGImageForContainer.cpp 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/svg/graphics/SVGImageForContainer.cpp 2017-08-30 17:20:26 UTC (rev 221377)
@@ -30,7 +30,7 @@
FloatSize SVGImageForContainer::size() const
{
FloatSize scaledContainerSize(m_containerSize);
- scaledContainerSize.scale(m_zoom);
+ scaledContainerSize.scale(m_containerZoom);
return FloatSize(roundedIntSize(scaledContainerSize));
}
@@ -37,13 +37,13 @@
ImageDrawResult SVGImageForContainer::draw(GraphicsContext& context, const FloatRect& dstRect,
const FloatRect& srcRect, CompositeOperator compositeOp, BlendMode blendMode, DecodingMode, ImageOrientationDescription)
{
- return m_image->drawForContainer(context, m_containerSize, m_zoom, dstRect, srcRect, compositeOp, blendMode);
+ return m_image->drawForContainer(context, m_containerSize, m_containerZoom, m_initialFragmentURL, dstRect, srcRect, compositeOp, blendMode);
}
void SVGImageForContainer::drawPattern(GraphicsContext& context, const FloatRect& dstRect, const FloatRect& srcRect, const AffineTransform& patternTransform,
const FloatPoint& phase, const FloatSize& spacing, CompositeOperator compositeOp, BlendMode blendMode)
{
- m_image->drawPatternForContainer(context, m_containerSize, m_zoom, srcRect, patternTransform, phase, spacing, compositeOp, dstRect, blendMode);
+ m_image->drawPatternForContainer(context, m_containerSize, m_containerZoom, m_initialFragmentURL, srcRect, patternTransform, phase, spacing, compositeOp, dstRect, blendMode);
}
NativeImagePtr SVGImageForContainer::nativeImageForCurrentFrame(const GraphicsContext* targetContext)
Modified: trunk/Source/WebCore/svg/graphics/SVGImageForContainer.h (221376 => 221377)
--- trunk/Source/WebCore/svg/graphics/SVGImageForContainer.h 2017-08-30 17:18:09 UTC (rev 221376)
+++ trunk/Source/WebCore/svg/graphics/SVGImageForContainer.h 2017-08-30 17:20:26 UTC (rev 221377)
@@ -36,9 +36,9 @@
class SVGImageForContainer final : public Image {
public:
- static Ref<SVGImageForContainer> create(SVGImage* image, const FloatSize& containerSize, float zoom)
+ static Ref<SVGImageForContainer> create(SVGImage* image, const FloatSize& containerSize, float containerZoom, const URL& initialFragmentURL)
{
- return adoptRef(*new SVGImageForContainer(image, containerSize, zoom));
+ return adoptRef(*new SVGImageForContainer(image, containerSize, containerZoom, initialFragmentURL));
}
bool isSVGImage() const final { return true; }
@@ -45,8 +45,6 @@
FloatSize size() const final;
- void setURL(const URL& url) { m_image->setURL(url); }
-
bool usesContainerSize() const final { return m_image->usesContainerSize(); }
bool hasRelativeWidth() const final { return m_image->hasRelativeWidth(); }
bool hasRelativeHeight() const final { return m_image->hasRelativeHeight(); }
@@ -65,10 +63,11 @@
NativeImagePtr nativeImageForCurrentFrame(const GraphicsContext* = nullptr) final;
private:
- SVGImageForContainer(SVGImage* image, const FloatSize& containerSize, float zoom)
+ SVGImageForContainer(SVGImage* image, const FloatSize& containerSize, float containerZoom, const URL& initialFragmentURL)
: m_image(image)
, m_containerSize(containerSize)
- , m_zoom(zoom)
+ , m_containerZoom(containerZoom)
+ , m_initialFragmentURL(initialFragmentURL)
{
}
@@ -76,7 +75,8 @@
SVGImage* m_image;
const FloatSize m_containerSize;
- const float m_zoom;
+ const float m_containerZoom;
+ const URL m_initialFragmentURL;
};
} // namespace WebCore