Bug 712299 - don't require manual syncing of font data; r=bz
authorNathan Froyd <froydnj@mozilla.com>
Tue, 20 Dec 2011 11:49:16 -0500
changeset 84977 e4fe4d48518fd965c7fcd48142c54ace1d396d0e
parent 84976 ae7a421e7fdbd6d70e6de9314c72f56f4a5c993b
child 84978 ebe9f8508d67567f5bd6f1df664b8738421a8d0c
push idunknown
push userunknown
push dateunknown
reviewersbz
bugs712299
milestone12.0a1
Bug 712299 - don't require manual syncing of font data; r=bz
layout/style/Makefile.in
layout/style/nsCSSFontDescList.h
layout/style/nsCSSProperty.h
layout/style/nsCSSProps.cpp
layout/style/nsCSSRules.cpp
layout/style/nsCSSRules.h
--- a/layout/style/Makefile.in
+++ b/layout/style/Makefile.in
@@ -51,16 +51,17 @@ MODULE		= layout
 LIBRARY_NAME	= gkstyle_s
 LIBXUL_LIBRARY	= 1
 
 EXPORTS_NAMESPACES = mozilla/css
 
 EXPORTS		= \
 		nsCSSAnonBoxList.h \
 		nsCSSAnonBoxes.h \
+		nsCSSFontDescList.h \
 		nsCSSKeywordList.h \
 		nsCSSKeywords.h \
 		nsCSSParser.h \
 		nsCSSPropList.h \
 		nsCSSProperty.h \
 		nsCSSProps.h \
 		nsCSSPseudoClassList.h \
 		nsCSSPseudoClasses.h \
new file mode 100644
--- /dev/null
+++ b/layout/style/nsCSSFontDescList.h
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** 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.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of 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 ***** */
+
+CSS_FONT_DESC(font-family, Family)
+CSS_FONT_DESC(font-style, Style)
+CSS_FONT_DESC(font-weight, Weight)
+CSS_FONT_DESC(font-stretch, Stretch)
+CSS_FONT_DESC(src, Src)
+CSS_FONT_DESC(unicode-range, UnicodeRange)
+CSS_FONT_DESC(-moz-font-feature-settings, FontFeatureSettings)
+CSS_FONT_DESC(-moz-font-language-override, FontLanguageOverride)
--- a/layout/style/nsCSSProperty.h
+++ b/layout/style/nsCSSProperty.h
@@ -77,24 +77,17 @@ enum nsCSSProperty {
 
   // Extra dummy values for nsCSSParser internal use.
   eCSSPropertyExtra_x_none_value,
   eCSSPropertyExtra_x_auto_value
 };
 
 // The "descriptors" that can appear in a @font-face rule.
 // They have the syntax of properties but different value rules.
-// Keep in sync with kCSSRawFontDescs in nsCSSProps.cpp and
-// nsCSSFontFaceStyleDecl::Fields in nsCSSRules.cpp.
 enum nsCSSFontDesc {
   eCSSFontDesc_UNKNOWN = -1,
-  eCSSFontDesc_Family,
-  eCSSFontDesc_Style,
-  eCSSFontDesc_Weight,
-  eCSSFontDesc_Stretch,
-  eCSSFontDesc_Src,
-  eCSSFontDesc_UnicodeRange,
-  eCSSFontDesc_FontFeatureSettings,
-  eCSSFontDesc_FontLanguageOverride,
+#define CSS_FONT_DESC(name_, method_) eCSSFontDesc_##method_,
+#include "nsCSSFontDescList.h"
+#undef CSS_FONT_DESC
   eCSSFontDesc_COUNT
 };
 
 #endif /* nsCSSProperty_h___ */
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -79,26 +79,20 @@ using namespace mozilla;
 static PRInt32 gTableRefCount;
 static nsStaticCaseInsensitiveNameTable* gPropertyTable;
 static nsStaticCaseInsensitiveNameTable* gFontDescTable;
 
 /* static */ nsCSSProperty *
   nsCSSProps::gShorthandsContainingTable[eCSSProperty_COUNT_no_shorthands];
 /* static */ nsCSSProperty* nsCSSProps::gShorthandsContainingPool = nsnull;
 
-// Keep in sync with enum nsCSSFontDesc in nsCSSProperty.h.
 static const char* const kCSSRawFontDescs[] = {
-  "font-family",
-  "font-style",
-  "font-weight",
-  "font-stretch",
-  "src",
-  "unicode-range",
-  "-moz-font-feature-settings",
-  "-moz-font-language-override"
+#define CSS_FONT_DESC(name_, method_) #name_,
+#include "nsCSSFontDescList.h"
+#undef CSS_FONT_DESC
 };
 
 struct PropertyAndCount {
   nsCSSProperty property;
   PRUint32 count;
 };
 
 static int
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -1304,27 +1304,21 @@ AppendSerializedUnicodeRange(nsCSSValue 
     }
     buf.AppendLiteral(", ");
   }
   buf.Truncate(buf.Length() - 2); // remove the last comma-space
   CopyASCIItoUTF16(buf, aResult);
 }
 
 // Mapping from nsCSSFontDesc codes to nsCSSFontFaceStyleDecl fields.
-// Keep this in sync with enum nsCSSFontDesc in nsCSSProperty.h.
 nsCSSValue nsCSSFontFaceStyleDecl::* const
 nsCSSFontFaceStyleDecl::Fields[] = {
-    &nsCSSFontFaceStyleDecl::mFamily,
-    &nsCSSFontFaceStyleDecl::mStyle,
-    &nsCSSFontFaceStyleDecl::mWeight,
-    &nsCSSFontFaceStyleDecl::mStretch,
-    &nsCSSFontFaceStyleDecl::mSrc,
-    &nsCSSFontFaceStyleDecl::mUnicodeRange,
-    &nsCSSFontFaceStyleDecl::mFontFeatureSettings,
-    &nsCSSFontFaceStyleDecl::mFontLanguageOverride
+#define CSS_FONT_DESC(name_, method_) &nsCSSFontFaceStyleDecl::m##method_,
+#include "nsCSSFontDescList.h"
+#undef CSS_FONT_DESC
 };
 
 DOMCI_DATA(CSSFontFaceStyleDecl, nsCSSFontFaceStyleDecl)
 
 // QueryInterface implementation for nsCSSFontFaceStyleDecl
 NS_INTERFACE_MAP_BEGIN(nsCSSFontFaceStyleDecl)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -189,24 +189,19 @@ public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMCSSSTYLEDECLARATION
 
   nsresult GetPropertyValue(nsCSSFontDesc aFontDescID,
                             nsAString & aResult NS_OUTPARAM) const;
 
 protected:
   friend class nsCSSFontFaceRule;
-  nsCSSValue mFamily;
-  nsCSSValue mStyle;
-  nsCSSValue mWeight;
-  nsCSSValue mStretch;
-  nsCSSValue mSrc;
-  nsCSSValue mUnicodeRange;
-  nsCSSValue mFontFeatureSettings;
-  nsCSSValue mFontLanguageOverride;
+#define CSS_FONT_DESC(name_, method_) nsCSSValue m##method_;
+#include "nsCSSFontDescList.h"
+#undef CSS_FONT_DESC
 
   static nsCSSValue nsCSSFontFaceStyleDecl::* const Fields[];  
   inline nsCSSFontFaceRule* ContainingRule();
   inline const nsCSSFontFaceRule* ContainingRule() const;
 
 private:
   // NOT TO BE IMPLEMENTED
   // This object cannot be allocated on its own, only as part of