gfx/src/nsRect.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/src/nsRect.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsRect.h"
    1.10 +#include "mozilla/gfx/Types.h"          // for NS_SIDE_BOTTOM, etc
    1.11 +#include "nsDeviceContext.h"            // for nsDeviceContext
    1.12 +#include "nsString.h"               // for nsAutoString, etc
    1.13 +#include "nsMargin.h"                   // for nsMargin
    1.14 +
    1.15 +static_assert((int(NS_SIDE_TOP) == 0) &&
    1.16 +              (int(NS_SIDE_RIGHT) == 1) &&
    1.17 +              (int(NS_SIDE_BOTTOM) == 2) &&
    1.18 +              (int(NS_SIDE_LEFT) == 3),
    1.19 +              "The mozilla::css::Side sequence must match the nsMargin nscoord sequence");
    1.20 +
    1.21 +#ifdef DEBUG
    1.22 +// Diagnostics
    1.23 +
    1.24 +FILE* operator<<(FILE* out, const nsRect& rect)
    1.25 +{
    1.26 +  nsAutoString tmp;
    1.27 +
    1.28 +  // Output the coordinates in fractional pixels so they're easier to read
    1.29 +  tmp.AppendLiteral("{");
    1.30 +  tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.x,
    1.31 +                       nsDeviceContext::AppUnitsPerCSSPixel()));
    1.32 +  tmp.AppendLiteral(", ");
    1.33 +  tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.y,
    1.34 +                       nsDeviceContext::AppUnitsPerCSSPixel()));
    1.35 +  tmp.AppendLiteral(", ");
    1.36 +  tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.width,
    1.37 +                       nsDeviceContext::AppUnitsPerCSSPixel()));
    1.38 +  tmp.AppendLiteral(", ");
    1.39 +  tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.height,
    1.40 +                       nsDeviceContext::AppUnitsPerCSSPixel()));
    1.41 +  tmp.AppendLiteral("}");
    1.42 +  fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
    1.43 +  return out;
    1.44 +}
    1.45 +
    1.46 +#endif // DEBUG

mercurial