2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifndef nsStyleUtil_h___
|
|
|
|
#define nsStyleUtil_h___
|
|
|
|
|
|
|
|
#include "nsCoord.h"
|
2009-10-21 14:57:57 -07:00
|
|
|
#include "nsCSSProperty.h"
|
2012-04-25 23:24:26 -07:00
|
|
|
#include "gfxFontFeatures.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsCSSValue.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
struct nsStyleBackground;
|
2010-04-10 13:10:12 -07:00
|
|
|
class nsString;
|
|
|
|
class nsStringComparator;
|
|
|
|
class nsIContent;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Style utility functions
|
|
|
|
class nsStyleUtil {
|
|
|
|
public:
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool DashMatchCompare(const nsAString& aAttributeValue,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsAString& aSelectorValue,
|
|
|
|
const nsStringComparator& aComparator);
|
|
|
|
|
2009-03-05 20:05:00 -08:00
|
|
|
// Append a quoted (with "") and escaped version of aString to aResult.
|
|
|
|
static void AppendEscapedCSSString(const nsString& aString,
|
|
|
|
nsAString& aResult);
|
2010-02-04 12:49:29 -08:00
|
|
|
// 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);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-10-21 14:57:57 -07:00
|
|
|
// Append a bitmask-valued property's value(s) (space-separated) to aResult.
|
|
|
|
static void AppendBitmaskCSSValue(nsCSSProperty aProperty,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aMaskedValue,
|
|
|
|
int32_t aFirstMask,
|
|
|
|
int32_t aLastMask,
|
2009-10-21 14:57:57 -07:00
|
|
|
nsAString& aResult);
|
|
|
|
|
2012-04-25 23:24:26 -07:00
|
|
|
static void AppendFontFeatureSettings(const nsTArray<gfxFontFeature>& aFeatures,
|
|
|
|
nsAString& aResult);
|
|
|
|
|
|
|
|
static void AppendFontFeatureSettings(const nsCSSValue& src,
|
|
|
|
nsAString& aResult);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* Convert an author-provided floating point number to an integer (0
|
|
|
|
* ... 255) appropriate for use in the alpha component of a color.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static uint8_t FloatToColorComponent(float aAlpha)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
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.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static float ColorComponentToFloat(uint8_t aAlpha);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-18 22:17:07 -08:00
|
|
|
/*
|
|
|
|
* Does this child count as significant for selector matching?
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsSignificantChild(nsIContent* aChild,
|
|
|
|
bool aTextIsSignificant,
|
|
|
|
bool aWhitespaceIsSignificant);
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* nsStyleUtil_h___ */
|