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

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

Issue 1477433004: Use LayoutUnit for SVG container size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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: third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
diff --git a/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp b/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
index 04e8195e089bea7d5ee2afa1b9a2a414a97d1c22..18590a30c750b3b861c8ab9f912ba9df41b433ee 100644
--- a/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
+++ b/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
@@ -132,7 +132,7 @@ static SVGSVGElement* svgRootElement(Page* page)
return frame->document()->accessSVGExtensions().rootElement();
}
-void SVGImage::setContainerSize(const IntSize& size)
+void SVGImage::setContainerSize(const LayoutSize& size)
{
if (!usesContainerSize())
return;
@@ -142,7 +142,7 @@ void SVGImage::setContainerSize(const IntSize& size)
return;
FrameView* view = frameView();
- view->resize(this->containerSize());
+ view->resize(roundedIntSize(this->containerSize()));
LayoutSVGRoot* layoutObject = toLayoutSVGRoot(rootElement->layoutObject());
if (!layoutObject)
@@ -150,18 +150,18 @@ void SVGImage::setContainerSize(const IntSize& size)
layoutObject->setContainerSize(size);
}
-IntSize SVGImage::containerSize() const
+LayoutSize SVGImage::containerSize() const
{
SVGSVGElement* rootElement = svgRootElement(m_page.get());
if (!rootElement)
- return IntSize();
+ return LayoutSize();
LayoutSVGRoot* layoutObject = toLayoutSVGRoot(rootElement->layoutObject());
if (!layoutObject)
- return IntSize();
+ return LayoutSize();
// If a container size is available it has precedence.
- IntSize containerSize = layoutObject->containerSize();
+ LayoutSize containerSize = layoutObject->containerSize();
if (!containerSize.isEmpty())
return containerSize;
@@ -187,10 +187,10 @@ IntSize SVGImage::containerSize() const
intrinsicSize = rootElement->currentViewBoxRect().size();
if (!intrinsicSize.isEmpty())
- return expandedIntSize(intrinsicSize);
+ return LayoutSize(intrinsicSize);
// As last resort, use CSS replaced element fallback size.
- return IntSize(300, 150);
+ return LayoutSize(300, 150);
}
void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const FloatSize containerSize, float zoom, const FloatRect& dstRect,
@@ -202,17 +202,11 @@ void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const Fl
// Temporarily disable the image observer to prevent changeInRect() calls due re-laying out the image.
ImageObserverDisabler imageObserverDisabler(this);
- IntSize roundedContainerSize = roundedIntSize(containerSize);
- setContainerSize(roundedContainerSize);
+ setContainerSize(LayoutSize(containerSize));
FloatRect scaledSrc = srcRect;
scaledSrc.scale(1 / zoom);
- // Compensate for the container size rounding by adjusting the source rect.
- FloatSize adjustedSrcSize = scaledSrc.size();
- adjustedSrcSize.scale(roundedContainerSize.width() / containerSize.width(), roundedContainerSize.height() / containerSize.height());
- scaledSrc.setSize(adjustedSrcSize);
-
drawInternal(canvas, paint, dstRect, scaledSrc, DoNotRespectImageOrientation, ClampImageToSourceRect, url);
}
@@ -294,7 +288,7 @@ void SVGImage::drawInternal(SkCanvas* canvas, const SkPaint& paint, const FloatR
RespectImageOrientationEnum, ImageClampingMode, const KURL& url)
{
FrameView* view = frameView();
- view->resize(containerSize());
+ view->resize(roundedIntSize(containerSize()));
// Always call processUrlFragment, even if the url is empty, because
// there may have been a previous url/fragment that needs to be reset.
@@ -502,7 +496,7 @@ bool SVGImage::dataChanged(bool allDataReceived)
AtomicString("UTF-8", AtomicString::ConstructFromLiteral), KURL(), ForceSynchronousLoad)));
// Set the intrinsic size before a container size is available.
- m_intrinsicSize = containerSize();
+ m_intrinsicSize = roundedIntSize(containerSize());
}
return m_page;

Powered by Google App Engine
This is Rietveld 408576698