gecko/layout/style/nsStyleUtil.h
Ehsan Akhgari 0fd9123eac Bug 579517 - Part 1: Automated conversion of NSPR numeric types to stdint types in Gecko; r=bsmedberg
This patch was generated by a script.  Here's the source of the script for
future reference:

function convert() {
echo "Converting $1 to $2..."
find . ! -wholename "*nsprpub*" \
       ! -wholename "*security/nss*" \
       ! -wholename "*/.hg*" \
       ! -wholename "obj-ff-dbg*" \
       ! -name nsXPCOMCID.h \
       ! -name prtypes.h \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.c" \
         -o -iname "*.cc" \
         -o -iname "*.idl" \
         -o -iname "*.ipdl" \
         -o -iname "*.ipdlh" \
         -o -iname "*.mm" \) | \
    xargs -n 1 sed -i -e "s/\b$1\b/$2/g"
}

convert PRInt8 int8_t
convert PRUint8 uint8_t
convert PRInt16 int16_t
convert PRUint16 uint16_t
convert PRInt32 int32_t
convert PRUint32 uint32_t
convert PRInt64 int64_t
convert PRUint64 uint64_t

convert PRIntn int
convert PRUintn unsigned

convert PRSize size_t

convert PROffset32 int32_t
convert PROffset64 int64_t

convert PRPtrdiff ptrdiff_t

convert PRFloat64 double
2012-08-22 11:56:38 -04:00

80 lines
2.8 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsStyleUtil_h___
#define nsStyleUtil_h___
#include "nsCoord.h"
#include "nsCSSProperty.h"
#include "gfxFontFeatures.h"
#include "nsTArray.h"
#include "nsCSSValue.h"
struct nsStyleBackground;
class nsString;
class nsStringComparator;
class nsIContent;
// Style utility functions
class nsStyleUtil {
public:
static bool DashMatchCompare(const nsAString& aAttributeValue,
const nsAString& aSelectorValue,
const nsStringComparator& aComparator);
// Append a quoted (with "") and escaped version of aString to aResult.
static void AppendEscapedCSSString(const nsString& aString,
nsAString& aResult);
// Append the identifier given by |aIdent| to |aResult|, with
// appropriate escaping so that it can be reparsed to the same
// identifier.
static void AppendEscapedCSSIdent(const nsString& aIdent,
nsAString& aResult);
// Append a bitmask-valued property's value(s) (space-separated) to aResult.
static void AppendBitmaskCSSValue(nsCSSProperty aProperty,
int32_t aMaskedValue,
int32_t aFirstMask,
int32_t aLastMask,
nsAString& aResult);
static void AppendFontFeatureSettings(const nsTArray<gfxFontFeature>& aFeatures,
nsAString& aResult);
static void AppendFontFeatureSettings(const nsCSSValue& src,
nsAString& aResult);
/*
* Convert an author-provided floating point number to an integer (0
* ... 255) appropriate for use in the alpha component of a color.
*/
static uint8_t FloatToColorComponent(float aAlpha)
{
NS_ASSERTION(0.0 <= aAlpha && aAlpha <= 1.0, "out of range");
return NSToIntRound(aAlpha * 255);
}
/*
* Convert the alpha component of an nscolor (0 ... 255) to the
* floating point number with the least accurate *decimal*
* representation that is converted to that color.
*
* Should be used only by serialization code.
*/
static float ColorComponentToFloat(uint8_t aAlpha);
/*
* Does this child count as significant for selector matching?
*/
static bool IsSignificantChild(nsIContent* aChild,
bool aTextIsSignificant,
bool aWhitespaceIsSignificant);
};
#endif /* nsStyleUtil_h___ */