Add aliases for old names of border-radius properties. (Bug 451134) r=bzbarsky a2.0=blocking2.0:beta6
authorL. David Baron <dbaron@dbaron.org>
Thu, 09 Sep 2010 08:21:48 -0700
changeset 52299 8adb2f64c138
parent 52298 c954983caff1
child 52301 ce4dbcbc75a2
push id15592
push userdbaron@mozilla.com
push date2010-09-09 15:23 +0000
treeherdermozilla-central@8adb2f64c138 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs451134
milestone2.0b6pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Add aliases for old names of border-radius properties. (Bug 451134) r=bzbarsky a2.0=blocking2.0:beta6
layout/style/nsCSSProps.cpp
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -314,33 +314,68 @@ nsCSSProps::ReleaseTable(void)
     delete gFontDescTable;
     gFontDescTable = nsnull;
 
     delete [] gShorthandsContainingPool;
     gShorthandsContainingPool = nsnull;
   }
 }
 
+struct CSSPropertyAlias {
+  char name[sizeof("-moz-border-radius-bottomright")];
+  nsCSSProperty id;
+};
+
+static const CSSPropertyAlias gAliases[] = {
+  { "-moz-border-radius", eCSSProperty_border_radius },
+  { "-moz-border-radius-bottomleft", eCSSProperty_border_bottom_left_radius },
+  { "-moz-border-radius-bottomright", eCSSProperty_border_bottom_right_radius },
+  { "-moz-border-radius-topleft", eCSSProperty_border_top_left_radius },
+  { "-moz-border-radius-topright", eCSSProperty_border_top_right_radius },
+  // Don't forget to update the sizeof in CSSPropertyAlias above with the
+  // longest string when you add stuff here.
+};
+
 nsCSSProperty
 nsCSSProps::LookupProperty(const nsACString& aProperty)
 {
   NS_ABORT_IF_FALSE(gPropertyTable, "no lookup table, needs addref");
 
   nsCSSProperty res = nsCSSProperty(gPropertyTable->Lookup(aProperty));
+  if (res == eCSSProperty_UNKNOWN) {
+    for (const CSSPropertyAlias *alias = gAliases,
+                            *alias_end = gAliases + NS_ARRAY_LENGTH(gAliases);
+         alias < alias_end; ++alias) {
+      if (aProperty.LowerCaseEqualsASCII(alias->name)) {
+        res = alias->id;
+        break;
+      }
+    }
+  }
   return res;
 }
 
 nsCSSProperty
 nsCSSProps::LookupProperty(const nsAString& aProperty)
 {
   // This is faster than converting and calling
   // LookupProperty(nsACString&).  The table will do its own
   // converting and avoid a PromiseFlatCString() call.
   NS_ABORT_IF_FALSE(gPropertyTable, "no lookup table, needs addref");
   nsCSSProperty res = nsCSSProperty(gPropertyTable->Lookup(aProperty));
+  if (res == eCSSProperty_UNKNOWN) {
+    for (const CSSPropertyAlias *alias = gAliases,
+                            *alias_end = gAliases + NS_ARRAY_LENGTH(gAliases);
+         alias < alias_end; ++alias) {
+      if (aProperty.LowerCaseEqualsASCII(alias->name)) {
+        res = alias->id;
+        break;
+      }
+    }
+  }
   return res;
 }
 
 nsCSSFontDesc
 nsCSSProps::LookupFontDesc(const nsACString& aFontDesc)
 {
   NS_ABORT_IF_FALSE(gFontDescTable, "no lookup table, needs addref");
   return nsCSSFontDesc(gFontDescTable->Lookup(aFontDesc));