Backed out changeset b242594427fd (bug 1112014) for failing on b2g
authorWes Kocher <wkocher@mozilla.com>
Fri, 01 May 2015 11:26:24 -0700
changeset 273468 19ae19cbe5beaac37f0c2ab4d458f851d1d8cb23
parent 273467 304554a697fe7497de04903df63895a5931eb514
child 273469 b7d29990d64510692ad42aa6d14974d347bc46ff
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1112014
milestone40.0a1
backs outb242594427fd4d353440287b7fdb00f4b847775a
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
Backed out changeset b242594427fd (bug 1112014) for failing on b2g IGNORE IDL
layout/inspector/inDOMUtils.cpp
layout/inspector/inIDOMUtils.idl
layout/style/nsCSSParser.cpp
layout/style/test/mochitest.ini
layout/style/test/test_bug1112014.html
--- a/layout/inspector/inDOMUtils.cpp
+++ b/layout/inspector/inDOMUtils.cpp
@@ -648,150 +648,26 @@ inDOMUtils::CssPropertyIsShorthand(const
   if (propertyID == eCSSProperty_UNKNOWN) {
     return NS_ERROR_FAILURE;
   }
 
   *_retval = nsCSSProps::IsShorthand(propertyID);
   return NS_OK;
 }
 
-// A helper function that determines whether the given property
-// supports the given type.
-static bool
-PropertySupportsVariant(nsCSSProperty aPropertyID, uint32_t aVariant)
-{
-  if (nsCSSProps::IsShorthand(aPropertyID)) {
-    // We need a special case for border here, because while it resets
-    // border-image, it can't actually parse an image.
-    if (aPropertyID == eCSSProperty_border) {
-      return (aVariant & (VARIANT_COLOR | VARIANT_LENGTH)) != 0;
-    }
-
-    for (const nsCSSProperty* props = nsCSSProps::SubpropertyEntryFor(aPropertyID);
-         *props != eCSSProperty_UNKNOWN; ++props) {
-      if (PropertySupportsVariant(*props, aVariant)) {
-        return true;
-      }
-    }
-    return false;
-  }
-
-  // Properties that are parsed by functions must have their
-  // attributes hand-maintained here.
-  if (nsCSSProps::PropHasFlags(aPropertyID, CSS_PROPERTY_VALUE_PARSER_FUNCTION) ||
-      nsCSSProps::PropertyParseType(aPropertyID) == CSS_PROPERTY_PARSE_FUNCTION) {
-    // These must all be special-cased.
-    uint32_t supported;
-    switch (aPropertyID) {
-      case eCSSProperty_border_image_slice:
-      case eCSSProperty_grid_template:
-      case eCSSProperty_grid:
-        supported = VARIANT_PN;
-        break;
-
-      case eCSSProperty_border_image_outset:
-        supported = VARIANT_LN;
-        break;
-
-      case eCSSProperty_border_image_width:
-      case eCSSProperty_stroke_dasharray:
-        supported = VARIANT_LPN;
-        break;
-
-      case eCSSProperty_border_top_left_radius:
-      case eCSSProperty_border_top_right_radius:
-      case eCSSProperty_border_bottom_left_radius:
-      case eCSSProperty_border_bottom_right_radius:
-      case eCSSProperty_background_position:
-      case eCSSProperty_background_size:
-      case eCSSProperty_grid_auto_columns:
-      case eCSSProperty_grid_auto_rows:
-      case eCSSProperty_grid_template_columns:
-      case eCSSProperty_grid_template_rows:
-      case eCSSProperty_object_position:
-      case eCSSProperty_scroll_snap_coordinate:
-      case eCSSProperty_scroll_snap_destination:
-      case eCSSProperty_transform_origin:
-      case eCSSProperty_perspective_origin:
-      case eCSSProperty__moz_outline_radius_topLeft:
-      case eCSSProperty__moz_outline_radius_topRight:
-      case eCSSProperty__moz_outline_radius_bottomLeft:
-      case eCSSProperty__moz_outline_radius_bottomRight:
-        supported = VARIANT_LP;
-        break;
-
-      case eCSSProperty_border_bottom_colors:
-      case eCSSProperty_border_left_colors:
-      case eCSSProperty_border_right_colors:
-      case eCSSProperty_border_top_colors:
-        supported = VARIANT_COLOR;
-        break;
-
-      case eCSSProperty_text_shadow:
-      case eCSSProperty_box_shadow:
-        supported = VARIANT_LENGTH | VARIANT_COLOR;
-        break;
-
-      case eCSSProperty_border_spacing:
-        supported = VARIANT_LENGTH;
-        break;
-
-      case eCSSProperty_content:
-      case eCSSProperty_cursor:
-      case eCSSProperty_clip_path:
-        supported = VARIANT_URL;
-        break;
-
-      case eCSSProperty_fill:
-      case eCSSProperty_stroke:
-        supported = VARIANT_COLOR | VARIANT_URL;
-        break;
-
-      case eCSSProperty_image_orientation:
-        supported = VARIANT_ANGLE;
-        break;
-
-      case eCSSProperty_filter:
-        supported = VARIANT_URL;
-        break;
-
-      case eCSSProperty_grid_column_start:
-      case eCSSProperty_grid_column_end:
-      case eCSSProperty_grid_row_start:
-      case eCSSProperty_grid_row_end:
-      case eCSSProperty_font_weight:
-        supported = VARIANT_NUMBER;
-        break;
-
-      default:
-        supported = 0;
-        break;
-    }
-
-    return (supported & aVariant) != 0;
-  }
-
-  return (nsCSSProps::ParserVariant(aPropertyID) & aVariant) != 0;
-}
-
 NS_IMETHODIMP
 inDOMUtils::CssPropertySupportsType(const nsAString& aProperty, uint32_t aType,
                                     bool *_retval)
 {
   nsCSSProperty propertyID =
     nsCSSProps::LookupProperty(aProperty, nsCSSProps::eEnabledForAllContent);
   if (propertyID == eCSSProperty_UNKNOWN) {
     return NS_ERROR_FAILURE;
   }
 
-  if (propertyID >= eCSSProperty_COUNT) {
-    *_retval = false;
-    return NS_OK;
-  }
-
   uint32_t variant;
   switch (aType) {
   case TYPE_LENGTH:
     variant = VARIANT_LENGTH;
     break;
   case TYPE_PERCENTAGE:
     variant = VARIANT_PERCENT;
     break;
@@ -823,17 +699,30 @@ inDOMUtils::CssPropertySupportsType(cons
     // Include integers under "number"?
     variant = VARIANT_NUMBER | VARIANT_INTEGER;
     break;
   default:
     // Unknown type
     return NS_ERROR_NOT_AVAILABLE;
   }
 
-  *_retval = PropertySupportsVariant(propertyID, variant);
+  if (!nsCSSProps::IsShorthand(propertyID)) {
+    *_retval = nsCSSProps::ParserVariant(propertyID) & variant;
+    return NS_OK;
+  }
+
+  for (const nsCSSProperty* props = nsCSSProps::SubpropertyEntryFor(propertyID);
+       *props != eCSSProperty_UNKNOWN; ++props) {
+    if (nsCSSProps::ParserVariant(*props) & variant) {
+      *_retval = true;
+      return NS_OK;
+    }
+  }
+
+  *_retval = false;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 inDOMUtils::GetCSSValuesForProperty(const nsAString& aProperty,
                                     uint32_t* aLength,
                                     char16_t*** aValues)
 {
--- a/layout/inspector/inIDOMUtils.idl
+++ b/layout/inspector/inIDOMUtils.idl
@@ -98,16 +98,19 @@ interface inIDOMUtils : nsISupports
   // Check whether a given CSS property is a shorthand.  Throws on unsupported
   // property names.
   bool cssPropertyIsShorthand(in AString aProperty);
 
   // Check whether values of the given type are valid values for the property.
   // For shorthands, checks whether there's a corresponding longhand property
   // that accepts values of this type.  Throws on unsupported properties or
   // unknown types.
+  //
+  // This function may incorrectly return false for properties that use custom
+  // parsing functions instead of table-driven parsing.
   const unsigned long TYPE_LENGTH = 0;
   const unsigned long TYPE_PERCENTAGE = 1;
   const unsigned long TYPE_COLOR = 2;
   const unsigned long TYPE_URL = 3;
   const unsigned long TYPE_ANGLE = 4;
   const unsigned long TYPE_FREQUENCY = 5;
   const unsigned long TYPE_TIME = 6;
   const unsigned long TYPE_GRADIENT = 7;
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -1207,24 +1207,26 @@ protected:
   bool mSuppressErrors : 1;
 
   // True if we've parsed "display: -webkit-box" as "display: flex" in an
   // earlier declaration within the current block of declarations, as part of
   // emulating support for certain -webkit-prefixed properties on certain
   // sites.
   bool mDidUnprefixWebkitBoxInEarlierDecl; // not :1 so we can use AutoRestore
 
+#ifdef DEBUG
   // True if any parsing of URL values requires a sheet principal to have
   // been passed in the nsCSSScanner constructor.  This is usually the case.
   // It can be set to false, for example, when we create an nsCSSParser solely
   // to parse a property value to test it for syntactic correctness.  When
   // false, an assertion that mSheetPrincipal is non-null is skipped.  Should
   // not be set to false if any nsCSSValues created during parsing can escape
   // out of the parser.
   bool mSheetPrincipalRequired;
+#endif
 
   // Stack of rule groups; used for @media and such.
   InfallibleTArray<nsRefPtr<css::GroupRule> > mGroupStack;
 
   // During the parsing of a property (which may be a shorthand), the data
   // are stored in |mTempData|.  (It is needed to ensure that parser
   // errors cause the data to be ignored, and to ensure that a
   // non-'!important' declaration does not override an '!important'
@@ -1293,17 +1295,19 @@ CSSParserImpl::CSSParserImpl()
     mIsChromeOrCertifiedApp(false),
     mViewportUnitsEnabled(true),
     mHTMLMediaMode(false),
     mParsingCompoundProperty(false),
     mInSupportsCondition(false),
     mInFailingSupportsRule(false),
     mSuppressErrors(false),
     mDidUnprefixWebkitBoxInEarlierDecl(false),
+#ifdef DEBUG
     mSheetPrincipalRequired(true),
+#endif
     mNextFree(nullptr)
 {
 }
 
 CSSParserImpl::~CSSParserImpl()
 {
   mData.AssertInitialState();
   mTempData.AssertInitialState();
@@ -7602,23 +7606,19 @@ CSSParserImpl::ParseSymbols(nsCSSValue& 
   SkipUntil(')');
   return false;
 }
 
 bool
 CSSParserImpl::SetValueToURL(nsCSSValue& aValue, const nsString& aURL)
 {
   if (!mSheetPrincipal) {
-    if (!mSheetPrincipalRequired) {
-      /* Pretend to succeed.  */
-      return true;
-    }
-
-    NS_NOTREACHED("Codepaths that expect to parse URLs MUST pass in an "
-                  "origin principal");
+    NS_ASSERTION(!mSheetPrincipalRequired,
+                 "Codepaths that expect to parse URLs MUST pass in an "
+                 "origin principal");
     return false;
   }
 
   nsRefPtr<nsStringBuffer> buffer(nsCSSValue::BufferFromString(aURL));
 
   // Note: urlVal retains its own reference to |buffer|.
   mozilla::css::URLValue *urlVal =
     new mozilla::css::URLValue(buffer, mBaseURI, mSheetURI, mSheetPrincipal);
@@ -15374,24 +15374,26 @@ CSSParserImpl::IsValueValidForProperty(c
 {
   mData.AssertInitialState();
   mTempData.AssertInitialState();
 
   nsCSSScanner scanner(aPropValue, 0);
   css::ErrorReporter reporter(scanner, mSheet, mChildLoader, nullptr);
   InitScanner(scanner, reporter, nullptr, nullptr, nullptr);
 
+#ifdef DEBUG
   // We normally would need to pass in a sheet principal to InitScanner,
   // because we might parse a URL value.  However, we will never use the
   // parsed nsCSSValue (and so whether we have a sheet principal or not
   // doesn't really matter), so to avoid failing the assertion in
   // SetValueToURL, we set mSheetPrincipalRequired to false to declare
   // that it's safe to skip the assertion.
   AutoRestore<bool> autoRestore(mSheetPrincipalRequired);
   mSheetPrincipalRequired = false;
+#endif
 
   nsAutoSuppressErrors suppressErrors(this);
 
   mSection = eCSSSection_General;
   scanner.SetSVGMode(false);
 
   // Check for unknown properties
   if (eCSSProperty_UNKNOWN == aPropID) {
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -105,17 +105,16 @@ support-files = file_bug645998-1.css fil
 [test_bug874919.html]
 support-files = file_bug829816.css
 [test_bug887741_at-rules_in_declaration_lists.html]
 [test_bug892929.html]
 [test_bug1055933.html]
 support-files = file_bug1055933_circle-xxl.png
 [test_bug1089417.html]
 support-files = file_bug1089417_iframe.html
-[test_bug1112014.html]
 [test_cascade.html]
 [test_ch_ex_no_infloops.html]
 [test_compute_data_with_start_struct.html]
 skip-if = toolkit == 'android'
 [test_computed_style.html]
 [test_computed_style_no_pseudo.html]
 [test_computed_style_prefs.html]
 [test_condition_text.html]
deleted file mode 100644
--- a/layout/style/test/test_bug1112014.html
+++ /dev/null
@@ -1,121 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=1112014
--->
-<head>
-  <meta charset="utf-8">
-  <title>Test for Bug 1112014</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script src="property_database.js"></script>
-  <script type="application/javascript;version=1.7">
-
-  let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
-    .getService(SpecialPowers.Ci.inIDOMUtils);
-
-  // This holds a canonical test value for each TYPE_ constant.
-  let testValues = {
-    TYPE_LENGTH: "10px",
-    TYPE_PERCENTAGE: "50%",
-    TYPE_COLOR: "rgb(3,3,3)",
-    TYPE_URL: "url(mozilla.org)",
-    TYPE_ANGLE: "90deg",
-    TYPE_FREQUENCY: "10kHz",
-    TYPE_TIME: "1000ms",
-    TYPE_GRADIENT: "linear-gradient( 45deg, blue, red )",
-    TYPE_TIMING_FUNCTION: "cubic-bezier(0.1, 0.7, 1.0, 0.1)",
-    TYPE_IMAGE_RECT: "-moz-image-rect(url(firefox.jpg), 5%, 5%, 10%, 10%)",
-    TYPE_NUMBER: "42"
-  };
-
-  // The canonical test values don't work for all properties, in
-  // particular some shorthand properties.  For these cases we have
-  // override values.
-  let overrideValues = {
-    "font": {
-      TYPE_LENGTH: "10px san-serif",
-      TYPE_PERCENTAGE: "50% san-serif",
-      TYPE_NUMBER: "24px/1.5 san-serif"
-    },
-    "border-image": {
-      TYPE_LENGTH: "url(/somewhere) 30% / 30px stretch",
-      TYPE_IMAGE_RECT: testValues.TYPE_IMAGE_RECT + " 30 30 stretch"
-    },
-    "-moz-border-image": {
-      TYPE_LENGTH: "url(/somewhere) 30% / 30px stretch",
-      TYPE_IMAGE_RECT: testValues.TYPE_IMAGE_RECT + " 30 30 stretch"
-    },
-    "box-shadow": {
-      TYPE_LENGTH: "2px 2px",
-      TYPE_COLOR: testValues.TYPE_COLOR + " 2px 2px"
-    },
-    "text-shadow": {
-      TYPE_LENGTH: "2px 2px",
-      TYPE_COLOR: testValues.TYPE_COLOR + " 2px 2px"
-    },
-    "font-weight": {
-      TYPE_NUMBER: "400"
-    },
-    "grid-template": {
-      TYPE_LENGTH: "'something' 23px",
-      TYPE_PERCENTAGE: "'something' 23%"
-    },
-    "grid": {
-      TYPE_LENGTH: "'something' 23px",
-      TYPE_PERCENTAGE: "'something' 23%"
-    },
-  };
-
-
-  // Ensure that all the TYPE_ constants have a representative
-  // test value, to try to ensure that this test is updated
-  // whenever a new type is added.
-  let reps = [];
-  for (let tc in utils) {
-    if (/TYPE_/.test(tc)) {
-      if (!(tc in testValues)) {
-	reps.push(tc);
-      }
-    }
-  }
-  is(reps.join(","), "", "all types have representative test value");
-
-  for (let propertyName in gCSSProperties) {
-    let prop = gCSSProperties[propertyName];
-    if (prop.backend_only) {
-      // These aren't interesting to us.
-      continue;
-    }
-
-    for (let iter in testValues) {
-      let testValue = testValues[iter];
-      if (propertyName in overrideValues &&
-	  iter in overrideValues[propertyName]) {
-	testValue = overrideValues[propertyName][iter];
-      }
-
-      let supported =
-        utils.cssPropertySupportsType(propertyName, utils[iter]);
-      let parsed = utils.cssPropertyIsValid(propertyName, testValue);
-      is(supported, parsed, propertyName + " supports " + iter);
-    }
-  }
-
-  // Regression test for an assertion failure in an earlier version of
-  // the code.  Note that cssPropertySupportsType returns false for
-  // all types for a variable.
-  ok(!utils.cssPropertySupportsType("--variable", utils.TYPE_COLOR),
-     "cssPropertySupportsType returns false for variable");
-
-  </script>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1112014">Mozilla Bug 1112014</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-
-</div>
-<pre id="test">
-</pre>
-</body>
-</html>