Chromium Code Reviews| Index: third_party/WebKit/Source/core/style/StyleImage.cpp |
| diff --git a/third_party/WebKit/Source/core/style/StyleImage.cpp b/third_party/WebKit/Source/core/style/StyleImage.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b56d90dd4e7f7f313c6ea71a5ecf8396d637c4bd |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/style/StyleImage.cpp |
| @@ -0,0 +1,37 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "core/style/StyleImage.h" |
| + |
| +#include "core/svg/graphics/SVGImage.h" |
| +#include "core/svg/graphics/SVGImageForContainer.h" |
| + |
| +namespace blink { |
| + |
| +LayoutSize StyleImage::applyZoom(const LayoutSize& size, float multiplier) |
| +{ |
| + if (multiplier == 1.0f) |
| + return size; |
| + |
| + LayoutUnit width(size.width() * multiplier); |
| + LayoutUnit height(size.height() * multiplier); |
| + |
| + // Don't let images that have a width/height >= 1 shrink below 1 when zoomed. |
|
Yoav Weiss
2016/03/07 11:16:07
Do we have tests for this?
davve
2016/03/07 13:07:38
That's a good questions. I'm assuming the reason f
|
| + if (size.width() > LayoutUnit()) |
| + width = std::max(LayoutUnit(1), width); |
| + |
| + if (size.height() > LayoutUnit()) |
| + height = std::max(LayoutUnit(1), height); |
| + |
| + return LayoutSize(width, height); |
| +} |
| + |
| +LayoutSize StyleImage::imageSizeForSVGImage(SVGImage* svgImage, float multiplier, const LayoutSize& defaultObjectSize) const |
| +{ |
| + FloatSize unzoomedDefaultObjectSize(defaultObjectSize); |
| + unzoomedDefaultObjectSize.scale(1 / multiplier); |
| + return applyZoom(LayoutSize(svgImage->concreteObjectSize(svgImage->concreteObjectSize(unzoomedDefaultObjectSize))), multiplier); |
| +} |
| + |
| +} // namespace blink |