Separate previously-copied font constants into their own file and have them in one place rather than three. (
Bug 3512) r=vlad
--- a/gfx/public/nsFont.h
+++ b/gfx/public/nsFont.h
@@ -36,16 +36,17 @@
* ***** END LICENSE BLOCK ***** */
#ifndef nsFont_h___
#define nsFont_h___
#include "gfxCore.h"
#include "nsCoord.h"
#include "nsStringGlue.h"
+#include "gfxFontConstants.h"
// XXX we need a method to enumerate all of the possible fonts on the
// system across family, weight, style, size, etc. But not here!
// Enumerator callback function. Return PR_FALSE to stop
typedef PRBool (*nsFontFamilyEnumFunc)(const nsString& aFamily, PRBool aGeneric, void *aData);
// IDs for generic fonts
@@ -129,24 +130,17 @@ struct NS_GFX nsFont {
// enclosing quotes will be removed, and whitespace compressed (as needed)
PRBool EnumerateFamilies(nsFontFamilyEnumFunc aFunc, void* aData) const;
void GetFirstFamily(nsString& aFamily) const;
// Utility method to return the ID of a generic font
static void GetGenericID(const nsString& aGeneric, PRUint8* aID);
};
-#define NS_FONT_STYLE_NORMAL 0
-#define NS_FONT_STYLE_ITALIC 1
-#define NS_FONT_STYLE_OBLIQUE 2
-
#define NS_FONT_VARIANT_NORMAL 0
#define NS_FONT_VARIANT_SMALL_CAPS 1
#define NS_FONT_DECORATION_NONE 0x0
#define NS_FONT_DECORATION_UNDERLINE 0x1
#define NS_FONT_DECORATION_OVERLINE 0x2
#define NS_FONT_DECORATION_LINE_THROUGH 0x4
-#define NS_FONT_WEIGHT_NORMAL 400
-#define NS_FONT_WEIGHT_BOLD 700
-
#endif /* nsFont_h___ */
--- a/gfx/thebes/public/Makefile.in
+++ b/gfx/thebes/public/Makefile.in
@@ -13,16 +13,17 @@ REQUIRES = cairo \
$(NULL)
EXPORTS = gfxASurface.h \
gfxAlphaRecovery.h \
gfxBlur.h \
gfxColor.h \
gfxContext.h \
gfxFont.h \
+ gfxFontConstants.h \
gfxFontUtils.h \
gfxImageSurface.h \
gfxMatrix.h \
gfxPath.h \
gfxPattern.h \
gfxPlatform.h \
gfxPoint.h \
gfxRect.h \
--- a/gfx/thebes/public/gfxFont.h
+++ b/gfx/thebes/public/gfxFont.h
@@ -46,35 +46,38 @@
#include "gfxPoint.h"
#include "gfxFontUtils.h"
#include "nsTArray.h"
#include "nsTHashtable.h"
#include "nsHashKeys.h"
#include "gfxSkipChars.h"
#include "gfxRect.h"
#include "nsExpirationTracker.h"
+#include "gfxFontConstants.h"
#ifdef DEBUG
#include <stdio.h>
#endif
class gfxContext;
class gfxTextRun;
class nsIAtom;
class gfxFont;
class gfxFontGroup;
class gfxUserFontSet;
class gfxUserFontData;
-#define FONT_STYLE_NORMAL 0
-#define FONT_STYLE_ITALIC 1
-#define FONT_STYLE_OBLIQUE 2
+// We should eliminate these synonyms when it won't cause many merge conflicts.
+#define FONT_STYLE_NORMAL NS_FONT_STYLE_NORMAL
+#define FONT_STYLE_ITALIC NS_FONT_STYLE_ITALIC
+#define FONT_STYLE_OBLIQUE NS_FONT_STYLE_OBLIQUE
-#define FONT_WEIGHT_NORMAL 400
-#define FONT_WEIGHT_BOLD 700
+// We should eliminate these synonyms when it won't cause many merge conflicts.
+#define FONT_WEIGHT_NORMAL NS_FONT_WEIGHT_NORMAL
+#define FONT_WEIGHT_BOLD NS_FONT_WEIGHT_BOLD
#define FONT_MAX_SIZE 2000.0
struct THEBES_API gfxFontStyle {
gfxFontStyle();
gfxFontStyle(PRUint8 aStyle, PRUint16 aWeight, gfxFloat aSize,
const nsACString& aLangGroup,
float aSizeAdjust, PRPackedBool aSystemFont,
new file mode 100644
--- /dev/null
+++ b/gfx/thebes/public/gfxFontConstants.h
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Foundation code.
+ *
+ * The Initial Developer of the Original Code is Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/* font constants shared by both thebes and layout */
+
+#ifndef GFX_FONT_CONSTANTS_H
+#define GFX_FONT_CONSTANTS_H
+
+/*
+ * This file is separate from gfxFont.h so that layout can include it
+ * without bringing in gfxFont.h and everything it includes.
+ */
+
+#define NS_FONT_STYLE_NORMAL 0
+#define NS_FONT_STYLE_ITALIC 1
+#define NS_FONT_STYLE_OBLIQUE 2
+
+#define NS_FONT_WEIGHT_NORMAL 400
+#define NS_FONT_WEIGHT_BOLD 700
+#define NS_FONT_WEIGHT_BOLDER 1
+#define NS_FONT_WEIGHT_LIGHTER -1
+
+#endif
--- a/gfx/thebes/public/gfxUserFontSet.h
+++ b/gfx/thebes/public/gfxUserFontSet.h
@@ -170,17 +170,17 @@ public:
STATUS_FORMAT_NOT_SUPPORTED,
STATUS_ERROR,
STATUS_END_OF_LIST
};
// add in a font face
// weight, stretch - 0 == unknown, [1, 9] otherwise
- // italic style = constants in gfxFont.h (e.g. FONT_STYLE_NORMAL)
+ // italic style = constants in gfxFontConstants.h, e.g. NS_FONT_STYLE_NORMAL
// TODO: support for unicode ranges not yet implemented
void AddFontFace(const nsAString& aFamilyName,
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
PRUint32 aWeight = 0,
PRUint32 aStretch = 0,
PRUint32 aItalicStyle = 0,
gfxSparseBitSet *aUnicodeRanges = nsnull);
--- a/layout/base/nsStyleConsts.h
+++ b/layout/base/nsStyleConsts.h
@@ -403,29 +403,32 @@
#define NS_STYLE_DISPLAY_GROUPBOX 28
// See nsStyleDisplay
#define NS_STYLE_FLOAT_NONE 0
#define NS_STYLE_FLOAT_LEFT 1
#define NS_STYLE_FLOAT_RIGHT 2
// See nsStyleFont
-#define NS_STYLE_FONT_STYLE_NORMAL 0
-#define NS_STYLE_FONT_STYLE_ITALIC 1
-#define NS_STYLE_FONT_STYLE_OBLIQUE 2
+// We should eventually stop using the NS_STYLE_* variants here.
+#define NS_STYLE_FONT_STYLE_NORMAL NS_FONT_STYLE_NORMAL
+#define NS_STYLE_FONT_STYLE_ITALIC NS_FONT_STYLE_ITALIC
+#define NS_STYLE_FONT_STYLE_OBLIQUE NS_FONT_STYLE_OBLIQUE
// See nsStyleFont
-#define NS_STYLE_FONT_VARIANT_NORMAL 0
-#define NS_STYLE_FONT_VARIANT_SMALL_CAPS 1
+// We should eventually stop using the NS_STYLE_* variants here.
+#define NS_STYLE_FONT_VARIANT_NORMAL NS_FONT_VARIANT_NORMAL
+#define NS_STYLE_FONT_VARIANT_SMALL_CAPS NS_FONT_VARIANT_SMALL_CAPS
// See nsStyleFont
-#define NS_STYLE_FONT_WEIGHT_NORMAL 400
-#define NS_STYLE_FONT_WEIGHT_BOLD 700
-#define NS_STYLE_FONT_WEIGHT_BOLDER 1
-#define NS_STYLE_FONT_WEIGHT_LIGHTER -1
+// We should eventually stop using the NS_STYLE_* variants here.
+#define NS_STYLE_FONT_WEIGHT_NORMAL NS_FONT_WEIGHT_NORMAL
+#define NS_STYLE_FONT_WEIGHT_BOLD NS_FONT_WEIGHT_BOLD
+#define NS_STYLE_FONT_WEIGHT_BOLDER NS_FONT_WEIGHT_BOLDER
+#define NS_STYLE_FONT_WEIGHT_LIGHTER NS_FONT_WEIGHT_LIGHTER
// See nsStyleFont
#define NS_STYLE_FONT_SIZE_XXSMALL 0
#define NS_STYLE_FONT_SIZE_XSMALL 1
#define NS_STYLE_FONT_SIZE_SMALL 2
#define NS_STYLE_FONT_SIZE_MEDIUM 3
#define NS_STYLE_FONT_SIZE_LARGE 4
#define NS_STYLE_FONT_SIZE_XLARGE 5