From 3fe1792b186a97902ab9d00daad713d48fc04368 Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Wed, 23 Nov 2016 19:27:27 -0500 Subject: [PATCH] Bug 1321412 - Add Min() and Max() functions to BaseSize. r=kats MozReview-Commit-ID: 6GTzkpwwDNu --HG-- extra : rebase_source : 1d8e888649c10f8f044f475095cb592538992946 --- gfx/2d/BaseSize.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gfx/2d/BaseSize.h b/gfx/2d/BaseSize.h index 7bcccc629913..f9f3fa461572 100644 --- a/gfx/2d/BaseSize.h +++ b/gfx/2d/BaseSize.h @@ -6,6 +6,7 @@ #ifndef MOZILLA_GFX_BASESIZE_H_ #define MOZILLA_GFX_BASESIZE_H_ +#include #include "mozilla/Attributes.h" namespace mozilla { @@ -92,6 +93,16 @@ struct BaseSize { Sub operator/(const Sub& aSize) const { return Sub(width / aSize.width, height / aSize.height); } + + friend Sub Min(const Sub& aA, const Sub& aB) { + return Sub(std::min(aA.width, aB.width), + std::min(aA.height, aB.height)); + } + + friend Sub Max(const Sub& aA, const Sub& aB) { + return Sub(std::max(aA.width, aB.width), + std::max(aA.height, aB.height)); + } }; } // namespace gfx