Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1548)

Unified Diff: Source/core/svg/graphics/SVGImage.cpp

Issue 1314793010: Support fragment URLs for all kinds of SVG images (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update DEPS to match Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/svg/graphics/SVGImage.cpp
diff --git a/Source/core/svg/graphics/SVGImage.cpp b/Source/core/svg/graphics/SVGImage.cpp
index ca2cc3f6bb3804707b77e8066bb8aa936231ba70..42b25dc39265948183beeff60adc2235b2f1916b 100644
--- a/Source/core/svg/graphics/SVGImage.cpp
+++ b/Source/core/svg/graphics/SVGImage.cpp
@@ -193,7 +193,7 @@ IntSize SVGImage::containerSize() const
}
void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const FloatSize containerSize, float zoom, const FloatRect& dstRect,
- const FloatRect& srcRect)
+ const FloatRect& srcRect, const KURL& urlWithFragment)
{
if (!m_page)
return;
@@ -212,7 +212,9 @@ void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const Fl
adjustedSrcSize.scale(roundedContainerSize.width() / containerSize.width(), roundedContainerSize.height() / containerSize.height());
scaledSrc.setSize(adjustedSrcSize);
- draw(canvas, paint, dstRect, scaledSrc, DoNotRespectImageOrientation, ClampImageToSourceRect);
+ frameView()->processUrlFragment(urlWithFragment);
+
+ drawInternal(canvas, paint, dstRect, scaledSrc, DoNotRespectImageOrientation, ClampImageToSourceRect);
}
PassRefPtr<SkImage> SVGImage::imageForCurrentFrame()
@@ -222,7 +224,7 @@ PassRefPtr<SkImage> SVGImage::imageForCurrentFrame()
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(width(), height());
- drawForContainer(canvas, SkPaint(), size(), 1, rect(), rect());
+ drawForContainer(canvas, SkPaint(), size(), 1, rect(), rect(), KURL());
RefPtr<SkPicture> picture = adoptRef(recorder.endRecording());
return adoptRef(
@@ -232,7 +234,7 @@ PassRefPtr<SkImage> SVGImage::imageForCurrentFrame()
void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize,
float zoom, const FloatRect& srcRect, const FloatSize& tileScale, const FloatPoint& phase,
SkXfermode::Mode compositeOp, const FloatRect& dstRect,
- const IntSize& repeatSpacing)
+ const IntSize& repeatSpacing, const KURL& urlWithFragment)
{
// Tile adjusted for scaling/stretch.
FloatRect tile(srcRect);
@@ -249,7 +251,7 @@ void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize
if (tile != spacedTile)
patternPicture.context().clip(tile);
SkPaint paint;
- drawForContainer(patternPicture.context().canvas(), paint, containerSize, zoom, tile, srcRect);
+ drawForContainer(patternPicture.context().canvas(), paint, containerSize, zoom, tile, srcRect, urlWithFragment);
}
RefPtr<const SkPicture> tilePicture = patternPicture.endRecording();
@@ -280,18 +282,24 @@ static bool drawNeedsLayer(const SkPaint& paint)
return false;
}
-void SVGImage::draw(SkCanvas* canvas, const SkPaint& paint, const FloatRect& dstRect, const FloatRect& srcRect, RespectImageOrientationEnum, ImageClampingMode)
+void SVGImage::draw(SkCanvas* canvas, const SkPaint& paint, const FloatRect& dstRect, const FloatRect& srcRect,
+ RespectImageOrientationEnum shouldRespectImageOrientation, ImageClampingMode clampMode)
{
if (!m_page)
return;
+ // Reset any previous URL fragment identifier.
+ frameView()->processUrlFragment(KURL());
+
+ drawInternal(canvas, paint, dstRect, srcRect, shouldRespectImageOrientation, clampMode);
+}
+
+void SVGImage::drawInternal(SkCanvas* canvas, const SkPaint& paint, const FloatRect& dstRect, const FloatRect& srcRect,
+ RespectImageOrientationEnum, ImageClampingMode)
+{
FrameView* view = frameView();
view->resize(containerSize());
- // Always call processUrlFragment, even if the url is empty, because
- // there may have been a previous url/fragment that needs to be reset.
- view->processUrlFragment(m_url);
-
SkPictureBuilder imagePicture(dstRect);
{
ClipRecorder clipRecorder(imagePicture.context(), *this, DisplayItem::ClipNodeImage, LayoutRect(enclosingIntRect(dstRect)));

Powered by Google App Engine
This is Rietveld 408576698