michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsRect.h" michael@0: #include "mozilla/gfx/Types.h" // for NS_SIDE_BOTTOM, etc michael@0: #include "nsDeviceContext.h" // for nsDeviceContext michael@0: #include "nsString.h" // for nsAutoString, etc michael@0: #include "nsMargin.h" // for nsMargin michael@0: michael@0: static_assert((int(NS_SIDE_TOP) == 0) && michael@0: (int(NS_SIDE_RIGHT) == 1) && michael@0: (int(NS_SIDE_BOTTOM) == 2) && michael@0: (int(NS_SIDE_LEFT) == 3), michael@0: "The mozilla::css::Side sequence must match the nsMargin nscoord sequence"); michael@0: michael@0: #ifdef DEBUG michael@0: // Diagnostics michael@0: michael@0: FILE* operator<<(FILE* out, const nsRect& rect) michael@0: { michael@0: nsAutoString tmp; michael@0: michael@0: // Output the coordinates in fractional pixels so they're easier to read michael@0: tmp.AppendLiteral("{"); michael@0: tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.x, michael@0: nsDeviceContext::AppUnitsPerCSSPixel())); michael@0: tmp.AppendLiteral(", "); michael@0: tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.y, michael@0: nsDeviceContext::AppUnitsPerCSSPixel())); michael@0: tmp.AppendLiteral(", "); michael@0: tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.width, michael@0: nsDeviceContext::AppUnitsPerCSSPixel())); michael@0: tmp.AppendLiteral(", "); michael@0: tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.height, michael@0: nsDeviceContext::AppUnitsPerCSSPixel())); michael@0: tmp.AppendLiteral("}"); michael@0: fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out); michael@0: return out; michael@0: } michael@0: michael@0: #endif // DEBUG