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

Unified Diff: third_party/WebKit/Source/core/style/StyleImage.cpp

Issue 1756763004: Merge image sizing algorithms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Break out common code to StyleImage and fold constant into call Created 4 years, 10 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: 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..1eb077d970f790b71b89b016229ae3c89a0df795
--- /dev/null
+++ b/third_party/WebKit/Source/core/style/StyleImage.cpp
@@ -0,0 +1,26 @@
+// 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::imageSizeForSVGImage(SVGImage* svgImage, float multiplier, const LayoutSize& defaultObjectSize) const
+{
+ FloatSize unzoomedDefaultObjectSize(defaultObjectSize);
+ unzoomedDefaultObjectSize.scale(1 / multiplier);
+ LayoutSize concreteObjectSize(svgImage->calculateConcreteObjectSize(unzoomedDefaultObjectSize));
+
+ // Don't let images that have a width/height >= 1 shrink below 1 when zoomed.
+ LayoutSize minimumSize(concreteObjectSize.width() > LayoutUnit() ? LayoutUnit(1) : LayoutUnit(),
+ concreteObjectSize.height() > LayoutUnit() ? LayoutUnit(1) : LayoutUnit());
+ concreteObjectSize.scale(multiplier);
+ concreteObjectSize.clampToMinimumSize(minimumSize);
+ return concreteObjectSize;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698