if (0 == bit) {
if (BG_CENTER == bit) {
PRBool CSSParserImpl::ParseBackgroundPosition(PRInt32& aErrorCode,                                              nsICSSDeclaration* aDeclaration){  // First try a number or a length value  nsCSSValue  xValue;  if (ParseVariant(aErrorCode, xValue, VARIANT_HLP, nsnull)) {    if (eCSSUnit_Inherit == xValue.GetUnit()) {  // both are inherited      if (ExpectEndProperty(aErrorCode, PR_TRUE)) {        aDeclaration->AppendValue(PROP_BACKGROUND_X_POSITION, xValue);        aDeclaration->AppendValue(PROP_BACKGROUND_Y_POSITION, xValue);        return PR_TRUE;      }      return PR_FALSE;    }    // We have one number/length. Get the optional second number/length.    nsCSSValue yValue;    if (ParseVariant(aErrorCode, yValue, VARIANT_LP, nsnull)) {      // We have two numbers      if (ExpectEndProperty(aErrorCode, PR_TRUE)) {        aDeclaration->AppendValue(PROP_BACKGROUND_X_POSITION, xValue);        aDeclaration->AppendValue(PROP_BACKGROUND_Y_POSITION, yValue);        return PR_TRUE;      }      return PR_FALSE;    }    // We have one number which is the x position. Create an value for    // the vertical position which is of value 50%    if (ExpectEndProperty(aErrorCode, PR_TRUE)) {      aDeclaration->AppendValue(PROP_BACKGROUND_X_POSITION, xValue);      aDeclaration->AppendValue(PROP_BACKGROUND_Y_POSITION, nsCSSValue(0.5f, eCSSUnit_Percent));      return PR_TRUE;    }    return PR_FALSE;  }  // Now try keywords. We do this manually to allow for the first  // appearance of "center" to apply to the either the x or y  // position (it's ambiguous so we have to disambiguate). Each  // allowed keyword value is assigned it's own bit. We don't allow  // any duplicate keywords other than center. We try to get two  // keywords but it's okay if there is only one.  PRInt32 mask = 0;  PRInt32 centerBit = BG_CENTER1;  for (PRInt32 i = 0; i < 2; i++) {    if (PR_FALSE == ParseEnum(aErrorCode, xValue, kBackgroundXYPositionKTable)) {      break;    }    PRInt32 bit = xValue.GetIntValue();    if (0 == bit) {      // Special hack for center bits: We can have two of them      mask |= centerBit;      centerBit <<= 1;      continue;    } else if ((mask & bit) != 0) {      // no duplicate values allowed (other than center)      return PR_FALSE;    }    mask |= bit;  }  // Check for bad input. Bad input consists of no matching keywords,  // or pairs of x keywords or pairs of y keywords.  if ((mask == 0) || (mask == (BG_TOP | BG_BOTTOM)) ||      (mask == (BG_LEFT | BG_RIGHT))) {    return PR_FALSE;  }  // Map good input  PRInt32 xEnumValue = 50;  if ((mask & (BG_LEFT | BG_RIGHT)) != 0) {    // We have an x value    xEnumValue = ((mask & BG_LEFT) != 0) ? 0 : 100;  }  PRInt32 yEnumValue = 50;  if ((mask & (BG_TOP | BG_BOTTOM)) != 0) {    // We have a y value    yEnumValue = ((mask & BG_TOP) != 0) ? 0 : 100;  }  if (ExpectEndProperty(aErrorCode, PR_TRUE)) {    // Create style values    aDeclaration->AppendValue(PROP_BACKGROUND_X_POSITION, nsCSSValue(xEnumValue, eCSSUnit_Enumerated));    aDeclaration->AppendValue(PROP_BACKGROUND_Y_POSITION, nsCSSValue(yEnumValue, eCSSUnit_Enumerated));    return PR_TRUE;  }  return PR_FALSE;}