Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
CSSParserImpl Class Reference
Inheritance diagram for CSSParserImpl:
Inheritance graph
[legend]
Collaboration diagram for CSSParserImpl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CSSParserImpl ()
virtual ~CSSParserImpl ()
NS_DECL_ISUPPORTS NS_IMETHOD SetStyleSheet (nsICSSStyleSheet *aSheet)
NS_IMETHOD SetCaseSensitive (PRBool aCaseSensitive)
NS_IMETHOD SetQuirkMode (PRBool aQuirkMode)
NS_IMETHOD SetChildLoader (nsICSSLoader *aChildLoader)
NS_IMETHOD Parse (nsIUnicharInputStream *aInput, nsIURI *aSheetURI, nsIURI *aBaseURI, PRUint32 aLineNumber, PRBool aAllowUnsafeRules, nsICSSStyleSheet *&aResult)
NS_IMETHOD Parse (nsIUnicharInputStream *aInput, nsIURI *aSheetURI, nsIURI *aBaseURI, PRUint32 aLineNumber, nsICSSStyleSheet *&aResult)
NS_IMETHOD ParseStyleAttribute (const nsAString &aAttributeValue, nsIURI *aDocURL, nsIURI *aBaseURL, nsICSSStyleRule **aResult)
NS_IMETHOD ParseAndAppendDeclaration (const nsAString &aBuffer, nsIURI *aSheetURL, nsIURI *aBaseURL, nsCSSDeclaration *aDeclaration, PRBool aParseOnlyOneDecl, PRBool *aChanged, PRBool aClearOldDecl)
NS_IMETHOD ParseRule (const nsAString &aRule, nsIURI *aSheetURL, nsIURI *aBaseURL, nsISupportsArray **aResult)
NS_IMETHOD ParseProperty (const nsCSSProperty aPropID, const nsAString &aPropValue, nsIURI *aSheetURL, nsIURI *aBaseURL, nsCSSDeclaration *aDeclaration, PRBool *aChanged)
 important" as the aPropValue. It will parse the "foo" and set it
NS_IMETHOD ParseMediaList (const nsSubstring &aBuffer, nsIURI *aURL, PRUint32 aLineNumber, nsMediaList *aMediaList, PRBool aHTMLMode)
 Parse aBuffer into a media list |aMediaList|, which must be non-null, replacing its current contents.
NS_IMETHOD ParseColorString (const nsSubstring &aBuffer, nsIURI *aURL, PRUint32 aLineNumber, PRBool aHandleAlphaColors, nscolor *aColor)
 Parse aBuffer into a nscolor |aColor|.
void AppendRule (nsICSSRule *aRule)

Protected Types

enum  nsSelectorParsingStatus { eSelectorParsingStatus_Done, eSelectorParsingStatus_Continue, eSelectorParsingStatus_Empty, eSelectorParsingStatus_Error }
enum  nsCSSSection { eCSSSection_Charset, eCSSSection_Import, eCSSSection_NameSpace, eCSSSection_General }

Protected Member Functions

nsresult InitScanner (nsIUnicharInputStream *aInput, nsIURI *aSheetURI, PRUint32 aLineNumber, nsIURI *aBaseURI)
nsresult InitScanner (const nsAString &aBuffer, nsIURI *aSheetURI, PRUint32 aLineNumber, nsIURI *aBaseURI)
nsresult ReleaseScanner (void)
nsresult DoParseMediaList (const nsSubstring &aBuffer, nsIURI *aURL, PRUint32 aLineNumber, nsMediaList *aMediaList)
PRBool GetToken (nsresult &aErrorCode, PRBool aSkipWS)
PRBool GetURLToken (nsresult &aErrorCode, PRBool aSkipWS)
void UngetToken ()
PRBool ExpectSymbol (nsresult &aErrorCode, PRUnichar aSymbol, PRBool aSkipWS)
PRBool ExpectEndProperty (nsresult &aErrorCode, PRBool aSkipWS)
nsStringNextIdent (nsresult &aErrorCode)
void SkipUntil (nsresult &aErrorCode, PRUnichar aStopSymbol)
void SkipRuleSet (nsresult &aErrorCode)
PRBool SkipAtRule (nsresult &aErrorCode)
PRBool SkipDeclaration (nsresult &aErrorCode, PRBool aCheckForBraces)
PRBool GetNonCloseParenToken (nsresult &aErrorCode, PRBool aSkipWS)
PRBool PushGroup (nsICSSGroupRule *aRule)
void PopGroup (void)
PRBool ParseRuleSet (nsresult &aErrorCode, RuleAppendFunc aAppendFunc, void *aProcessData)
PRBool ParseAtRule (nsresult &aErrorCode, RuleAppendFunc aAppendFunc, void *aProcessData)
PRBool ParseCharsetRule (nsresult &aErrorCode, RuleAppendFunc aAppendFunc, void *aProcessData)
PRBool ParseImportRule (nsresult &aErrorCode, RuleAppendFunc aAppendFunc, void *aProcessData)
PRBool GatherURL (nsresult &aErrorCode, nsString &aURL)
PRBool GatherMedia (nsresult &aErrorCode, nsMediaList *aMedia, PRUnichar aStopSymbol)
PRBool ProcessImport (nsresult &aErrorCode, const nsString &aURLSpec, nsMediaList *aMedia, RuleAppendFunc aAppendFunc, void *aProcessData)
PRBool ParseGroupRule (nsresult &aErrorCode, nsICSSGroupRule *aRule, RuleAppendFunc aAppendFunc, void *aProcessData)
PRBool ParseMediaRule (nsresult &aErrorCode, RuleAppendFunc aAppendFunc, void *aProcessData)
PRBool ParseMozDocumentRule (nsresult &aErrorCode, RuleAppendFunc aAppendFunc, void *aProcessData)
PRBool ParseNameSpaceRule (nsresult &aErrorCode, RuleAppendFunc aAppendFunc, void *aProcessData)
PRBool ProcessNameSpace (nsresult &aErrorCode, const nsString &aPrefix, const nsString &aURLSpec, RuleAppendFunc aAppendFunc, void *aProcessData)
PRBool ParseFontFaceRule (nsresult &aErrorCode, RuleAppendFunc aAppendFunc, void *aProcessData)
PRBool ParsePageRule (nsresult &aErrorCode, RuleAppendFunc aAppendFunc, void *aProcessData)
nsSelectorParsingStatus ParseIDSelector (PRInt32 &aDataMask, nsCSSSelector &aSelector, nsresult &aErrorCode)
nsSelectorParsingStatus ParseClassSelector (PRInt32 &aDataMask, nsCSSSelector &aSelector, nsresult &aErrorCode)
nsSelectorParsingStatus ParsePseudoSelector (PRInt32 &aDataMask, nsCSSSelector &aSelector, nsresult &aErrorCode, PRBool aIsNegated)
nsSelectorParsingStatus ParseAttributeSelector (PRInt32 &aDataMask, nsCSSSelector &aSelector, nsresult &aErrorCode)
nsSelectorParsingStatus ParseTypeOrUniversalSelector (PRInt32 &aDataMask, nsCSSSelector &aSelector, nsresult &aErrorCode, PRBool aIsNegated)
nsSelectorParsingStatus ParseLangSelector (nsCSSSelector &aSelector, nsresult &aErrorCode)
nsSelectorParsingStatus ParseNegatedSimpleSelector (PRInt32 &aDataMask, nsCSSSelector &aSelector, nsresult &aErrorCode)
nsSelectorParsingStatus ParseSelector (nsresult &aErrorCode, nsCSSSelector &aSelectorResult)
 This is the format for selectors: operator? [[namespace |]? element_name]? [ ID | class | attrib | pseudo ]*.
PRBool ParseSelectorList (nsresult &aErrorCode, nsCSSSelectorList *&aListHead)
PRBool ParseSelectorGroup (nsresult &aErrorCode, nsCSSSelectorList *&aListHead)
nsCSSDeclarationParseDeclarationBlock (nsresult &aErrorCode, PRBool aCheckForBraces)
PRBool ParseDeclaration (nsresult &aErrorCode, nsCSSDeclaration *aDeclaration, PRBool aCheckForBraces, PRBool aMustCallValueAppended, PRBool *aChanged)
void ClearTempData (nsCSSProperty aPropID)
void TransferTempData (nsCSSDeclaration *aDeclaration, nsCSSProperty aPropID, PRBool aIsImportant, PRBool aMustCallValueAppended, PRBool *aChanged)
void DoTransferTempData (nsCSSDeclaration *aDeclaration, nsCSSProperty aPropID, PRBool aIsImportant, PRBool aMustCallValueAppended, PRBool *aChanged)
PRBool ParseProperty (nsresult &aErrorCode, nsCSSProperty aPropID)
PRBool ParseSingleValueProperty (nsresult &aErrorCode, nsCSSValue &aValue, nsCSSProperty aPropID)
PRBool ParseAzimuth (nsresult &aErrorCode, nsCSSValue &aValue)
PRBool ParseBackground (nsresult &aErrorCode)
PRBool ParseBackgroundPosition (nsresult &aErrorCode)
PRBool ParseBorderColor (nsresult &aErrorCode)
PRBool ParseBorderColors (nsresult &aErrorCode, nsCSSValueList **aResult, nsCSSProperty aProperty)
PRBool ParseBorderSpacing (nsresult &aErrorCode)
PRBool ParseBorderSide (nsresult &aErrorCode, const nsCSSProperty aPropIDs[], PRBool aSetAllSides)
PRBool ParseBorderStyle (nsresult &aErrorCode)
PRBool ParseBorderWidth (nsresult &aErrorCode)
PRBool ParseBorderRadius (nsresult &aErrorCode)
PRBool ParseOutlineRadius (nsresult &aErrorCode)
PRBool ParseRect (nsCSSRect &aRect, nsresult &aErrorCode, nsCSSProperty aPropID)
PRBool DoParseRect (nsCSSRect &aRect, nsresult &aErrorCode)
PRBool ParseContent (nsresult &aErrorCode)
PRBool ParseCounterData (nsresult &aErrorCode, nsCSSCounterData **aResult, nsCSSProperty aPropID)
PRBool ParseCue (nsresult &aErrorCode)
PRBool ParseCursor (nsresult &aErrorCode)
PRBool ParseFont (nsresult &aErrorCode)
PRBool ParseFontWeight (nsresult &aErrorCode, nsCSSValue &aValue)
PRBool ParseFamily (nsresult &aErrorCode, nsCSSValue &aValue)
PRBool ParseListStyle (nsresult &aErrorCode)
PRBool ParseMargin (nsresult &aErrorCode)
PRBool ParseMarks (nsresult &aErrorCode, nsCSSValue &aValue)
PRBool ParseOutline (nsresult &aErrorCode)
PRBool ParseOverflow (nsresult &aErrorCode)
PRBool ParsePadding (nsresult &aErrorCode)
PRBool ParsePause (nsresult &aErrorCode)
PRBool ParseQuotes (nsresult &aErrorCode)
PRBool ParseSize (nsresult &aErrorCode)
PRBool ParseTextDecoration (nsresult &aErrorCode, nsCSSValue &aValue)
PRBool ParseTextShadow (nsresult &aErrorCode)
void AppendValue (nsCSSProperty aPropID, const nsCSSValue &aValue)
PRBool ParseBoxProperties (nsresult &aErrorCode, nsCSSRect &aResult, const nsCSSProperty aPropIDs[])
 Parse a "box" property.
PRBool ParseDirectionalBoxProperty (nsresult &aErrorCode, nsCSSProperty aProperty, PRInt32 aSourceType)
PRInt32 ParseChoice (nsresult &aErrorCode, nsCSSValue aValues[], const nsCSSProperty aPropIDs[], PRInt32 aNumIDs)
PRBool ParseColor (nsresult &aErrorCode, nsCSSValue &aValue)
PRBool ParseColorComponent (nsresult &aErrorCode, PRUint8 &aComponent, PRInt32 &aType, char aStop)
PRBool ParseHSLColor (nsresult &aErrorCode, nscolor &aColor, char aStop)
PRBool ParseColorOpacity (nsresult &aErrorCode, PRUint8 &aOpacity)
PRBool ParseEnum (nsresult &aErrorCode, nsCSSValue &aValue, const PRInt32 aKeywordTable[])
PRBool ParseVariant (nsresult &aErrorCode, nsCSSValue &aValue, PRInt32 aVariantMask, const PRInt32 aKeywordTable[])
PRBool ParsePositiveVariant (nsresult &aErrorCode, nsCSSValue &aValue, PRInt32 aVariantMask, const PRInt32 aKeywordTable[])
PRBool ParseCounter (nsresult &aErrorCode, nsCSSValue &aValue)
PRBool ParseAttr (nsresult &aErrorCode, nsCSSValue &aValue)
PRBool ParseURL (nsresult &aErrorCode, nsCSSValue &aValue)
PRBool TranslateDimension (nsresult &aErrorCode, nsCSSValue &aValue, PRInt32 aVariantMask, float aNumber, const nsString &aUnit)
void SetParsingCompoundProperty (PRBool aBool)
PRBool IsParsingCompoundProperty (void)

Protected Attributes

nsCSSToken mToken
nsCSSScanner mScanner
nsCOMPtr< nsIURImBaseURL
nsCOMPtr< nsIURImSheetURL
nsCOMPtr< nsICSSStyleSheetmSheet
nsICSSLoadermChildLoader
nsCSSSection mSection
nsXMLNameSpaceMapmNameSpaceMap
PRPackedBool mHavePushBack: 1
PRPackedBool mNavQuirkMode: 1
PRPackedBool mUnsafeRulesEnabled: 1
PRPackedBool mHTMLMediaMode: 1
PRPackedBool mHandleAlphaColors: 1
PRPackedBool mCaseSensitive: 1
PRPackedBool mParsingCompoundProperty: 1
nsCOMArray< nsICSSGroupRulemGroupStack
nsCSSExpandedDataBlock mTempData
nsCSSExpandedDataBlock mData

Detailed Description

Definition at line 86 of file nsCSSParser.cpp.


Member Enumeration Documentation

enum CSSParserImpl::nsCSSSection [protected]
Enumerator:
eCSSSection_Charset 
eCSSSection_Import 
eCSSSection_NameSpace 
eCSSSection_General 

Definition at line 391 of file nsCSSParser.cpp.

Enumerator:
eSelectorParsingStatus_Done 
eSelectorParsingStatus_Continue 
eSelectorParsingStatus_Empty 
eSelectorParsingStatus_Error 

Definition at line 210 of file nsCSSParser.cpp.

                               {
    // we have parsed a selector and we saw a token that cannot be part of a selector:
    eSelectorParsingStatus_Done,
    // we should continue parsing the selector:
    eSelectorParsingStatus_Continue,
    // same as "Done" but we did not find a selector:
    eSelectorParsingStatus_Empty,
    // we saw an unexpected token or token value,
    // or we saw end-of-file with an unfinished selector:
    eSelectorParsingStatus_Error 
  };

Constructor & Destructor Documentation


Member Function Documentation

Definition at line 1732 of file nsCSSParser.cpp.

{
  PRInt32 count = mGroupStack.Count();
  if (0 < count) {
    mGroupStack[count - 1]->AppendStyleRule(aRule);
  }
  else {
    mSheet->AppendStyleRule(aRule);
  }
}

Here is the call graph for this function:

void CSSParserImpl::AppendValue ( nsCSSProperty  aPropID,
const nsCSSValue aValue 
) [protected]

Definition at line 3998 of file nsCSSParser.cpp.

{
  NS_ASSERTION(0 <= aPropID && aPropID < eCSSProperty_COUNT_no_shorthands,
               "property out of range");
  NS_ASSERTION(nsCSSProps::kTypeTable[aPropID] == eCSSType_Value,
               nsPrintfCString(64, "type error (property=\'%s\')",
                             nsCSSProps::GetStringValue(aPropID).get()).get());
  nsCSSValue& storage =
      *NS_STATIC_CAST(nsCSSValue*, mTempData.PropertyAt(aPropID));
  storage = aValue;
  mTempData.SetPropertyBit(aPropID);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3272 of file nsCSSParser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult CSSParserImpl::DoParseMediaList ( const nsSubstring aBuffer,
nsIURI aURL,
PRUint32  aLineNumber,
nsMediaList aMediaList 
) [protected]

Definition at line 1003 of file nsCSSParser.cpp.

{
  // fake base URL since media lists don't have URLs in them
  nsresult rv = InitScanner(aBuffer, aURL, aLineNumber, aURL);
  if (NS_FAILED(rv)) {
    return rv;
  }

  if (!GatherMedia(rv, aMediaList, PRUnichar(0)) && !mHTMLMediaMode) {
    OUTPUT_ERROR();
  }
  CLEAR_ERROR();
  ReleaseScanner();
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::DoParseRect ( nsCSSRect aRect,
nsresult aErrorCode 
) [protected]

Definition at line 5149 of file nsCSSParser.cpp.

{
  if (! GetToken(aErrorCode, PR_TRUE)) {
    return PR_FALSE;
  }
  if (eCSSToken_Ident == mToken.mType) {
    nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(mToken.mIdent);
    switch (keyword) {
      case eCSSKeyword_auto:
        if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
          aRect.SetAllSidesTo(nsCSSValue(eCSSUnit_Auto));
          return PR_TRUE;
        }
        break;
      case eCSSKeyword_inherit:
        if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
          aRect.SetAllSidesTo(nsCSSValue(eCSSUnit_Inherit));
          return PR_TRUE;
        }
        break;
      case eCSSKeyword__moz_initial:
        if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
          aRect.SetAllSidesTo(nsCSSValue(eCSSUnit_Initial));
          return PR_TRUE;
        }
        break;
      default:
        UngetToken();
        break;
    }
  } else if ((eCSSToken_Function == mToken.mType) && 
             mToken.mIdent.LowerCaseEqualsLiteral("rect")) {
    if (!ExpectSymbol(aErrorCode, '(', PR_TRUE)) {
      return PR_FALSE;
    }
    NS_FOR_CSS_SIDES(side) {
      if (! ParseVariant(aErrorCode, aRect.*(nsCSSRect::sides[side]),
                         VARIANT_AL, nsnull)) {
        return PR_FALSE;
      }
      if (3 != side) {
        // skip optional commas between elements
        ExpectSymbol(aErrorCode, ',', PR_TRUE);
      }
    }
    if (!ExpectSymbol(aErrorCode, ')', PR_TRUE)) {
      return PR_FALSE;
    }
    if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
      return PR_TRUE;
    }
  } else {
    UngetToken();
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CSSParserImpl::DoTransferTempData ( nsCSSDeclaration aDeclaration,
nsCSSProperty  aPropID,
PRBool  aIsImportant,
PRBool  aMustCallValueAppended,
PRBool aChanged 
) [protected]

Definition at line 3306 of file nsCSSParser.cpp.

{
  NS_ASSERTION(mTempData.HasPropertyBit(aPropID), "oops");
  if (aIsImportant) {
    if (!mData.HasImportantBit(aPropID))
      *aChanged = PR_TRUE;
    mData.SetImportantBit(aPropID);
  } else {
    if (mData.HasImportantBit(aPropID)) {
      mTempData.ClearProperty(aPropID);
      return;
    }
  }

  if (aMustCallValueAppended || !mData.HasPropertyBit(aPropID)) {
    aDeclaration->ValueAppended(aPropID);
  }

  mData.SetPropertyBit(aPropID);
  mTempData.ClearPropertyBit(aPropID);

  /*
   * Save needless copying and allocation by calling the destructor in
   * the destination, copying memory directly, and then using placement
   * new.
   */
  void *v_source = mTempData.PropertyAt(aPropID);
  void *v_dest = mData.PropertyAt(aPropID);
  switch (nsCSSProps::kTypeTable[aPropID]) {
    case eCSSType_Value: {
      nsCSSValue *source = NS_STATIC_CAST(nsCSSValue*, v_source);
      nsCSSValue *dest = NS_STATIC_CAST(nsCSSValue*, v_dest);
      if (*source != *dest)
        *aChanged = PR_TRUE;
      dest->~nsCSSValue();
      memcpy(dest, source, sizeof(nsCSSValue));
      new (source) nsCSSValue();
      if (dest->GetUnit() == eCSSUnit_Null) {
        // Some of our property parsers actually want to _clear_ properties in
        // mData (eg the "font" shorthand parser does for system fonts).  We've
        // cleared the data; now clear the bit too.
        mData.ClearPropertyBit(aPropID);
      }
    } break;

    case eCSSType_Rect: {
      nsCSSRect *source = NS_STATIC_CAST(nsCSSRect*, v_source);
      nsCSSRect *dest = NS_STATIC_CAST(nsCSSRect*, v_dest);
      if (*source != *dest)
        *aChanged = PR_TRUE;
      dest->~nsCSSRect();
      memcpy(dest, source, sizeof(nsCSSRect));
      new (source) nsCSSRect();
    } break;

    case eCSSType_ValuePair: {
      nsCSSValuePair *source = NS_STATIC_CAST(nsCSSValuePair*, v_source);
      nsCSSValuePair *dest = NS_STATIC_CAST(nsCSSValuePair*, v_dest);
      if (*source != *dest)
        *aChanged = PR_TRUE;
      dest->~nsCSSValuePair();
      memcpy(dest, source, sizeof(nsCSSValuePair));
      new (source) nsCSSValuePair();
    } break;

    case eCSSType_ValueList: {
      nsCSSValueList **source = NS_STATIC_CAST(nsCSSValueList**, v_source);
      nsCSSValueList **dest = NS_STATIC_CAST(nsCSSValueList**, v_dest);
      if (!nsCSSValueList::Equal(*source, *dest))
        *aChanged = PR_TRUE;
      delete *dest;
      *dest = *source;
      *source = nsnull;
    } break;

    case eCSSType_CounterData: {
      nsCSSCounterData **source = NS_STATIC_CAST(nsCSSCounterData**, v_source);
      nsCSSCounterData **dest = NS_STATIC_CAST(nsCSSCounterData**, v_dest);
      if (!nsCSSCounterData::Equal(*source, *dest))
        *aChanged = PR_TRUE;
      delete *dest;
      *dest = *source;
      *source = nsnull;
    } break;

    case eCSSType_Quotes: {
      nsCSSQuotes **source = NS_STATIC_CAST(nsCSSQuotes**, v_source);
      nsCSSQuotes **dest = NS_STATIC_CAST(nsCSSQuotes**, v_dest);
      if (!nsCSSQuotes::Equal(*source, *dest))
        *aChanged = PR_TRUE;
      delete *dest;
      *dest = *source;
      *source = nsnull;
    } break;

    case eCSSType_Shadow: {
      nsCSSShadow **source = NS_STATIC_CAST(nsCSSShadow**, v_source);
      nsCSSShadow **dest = NS_STATIC_CAST(nsCSSShadow**, v_dest);
      if (!nsCSSShadow::Equal(*source, *dest))
        *aChanged = PR_TRUE;
      delete *dest;
      *dest = *source;
      *source = nsnull;
    } break;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ExpectEndProperty ( nsresult aErrorCode,
PRBool  aSkipWS 
) [protected]

Definition at line 1139 of file nsCSSParser.cpp.

{
  if (!GetToken(aErrorCode, aSkipWS)) {
    return PR_TRUE; // properties may end with eof
  }
  if ((eCSSToken_Symbol == mToken.mType) &&
      ((';' == mToken.mSymbol) || ('!' == mToken.mSymbol) || ('}' == mToken.mSymbol))) {
    // XXX need to verify that ! is only followed by "important [;|}]
    // XXX this requires a multi-token pushback buffer
    UngetToken();
    return PR_TRUE;
  }
  REPORT_UNEXPECTED_TOKEN(PEExpectEndProperty);
  UngetToken();
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ExpectSymbol ( nsresult aErrorCode,
PRUnichar  aSymbol,
PRBool  aSkipWS 
) [protected]

Definition at line 1125 of file nsCSSParser.cpp.

{
  if (!GetToken(aErrorCode, aSkipWS)) {
    return PR_FALSE;
  }
  if (mToken.IsSymbol(aSymbol)) {
    return PR_TRUE;
  }
  UngetToken();
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::GatherMedia ( nsresult aErrorCode,
nsMediaList aMedia,
PRUnichar  aStopSymbol 
) [protected]

Definition at line 1302 of file nsCSSParser.cpp.

{
  for (;;) {
    if (!GetToken(aErrorCode, PR_TRUE)) {
      REPORT_UNEXPECTED_EOF(PEGatherMediaEOF);
      break;
    }
    if (eCSSToken_Ident != mToken.mType) {
      REPORT_UNEXPECTED_TOKEN(PEGatherMediaNotIdent);
      UngetToken();
      break;
    }
    ToLowerCase(mToken.mIdent);  // case insensitive from CSS - must be lower cased
    nsCOMPtr<nsIAtom> medium = do_GetAtom(mToken.mIdent);
    aMedia->AppendAtom(medium);

    if (!GetToken(aErrorCode, PR_TRUE)) {
      if (aStopSymbol == PRUnichar(0))
        return PR_TRUE;
      REPORT_UNEXPECTED_EOF(PEGatherMediaEOF);
      break;
    }

    if (eCSSToken_Symbol == mToken.mType &&
        mToken.mSymbol == aStopSymbol) {
      UngetToken();
      return PR_TRUE;
    } else if (eCSSToken_Symbol != mToken.mType ||
               mToken.mSymbol != ',') {
      REPORT_UNEXPECTED_TOKEN(PEGatherMediaNotComma);
      UngetToken();
      break;
    }
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::GatherURL ( nsresult aErrorCode,
nsString aURL 
) [protected]

Definition at line 1279 of file nsCSSParser.cpp.

{
  if (!GetToken(aErrorCode, PR_TRUE)) {
    return PR_FALSE;
  }
  if (eCSSToken_String == mToken.mType) {
    aURL = mToken.mIdent;
    return PR_TRUE;
  }
  else if (eCSSToken_Function == mToken.mType && 
           mToken.mIdent.LowerCaseEqualsLiteral("url") &&
           ExpectSymbol(aErrorCode, '(', PR_FALSE) &&
           GetURLToken(aErrorCode, PR_TRUE) &&
           (eCSSToken_String == mToken.mType ||
            eCSSToken_URL == mToken.mType)) {
    aURL = mToken.mIdent;
    if (ExpectSymbol(aErrorCode, ')', PR_TRUE)) {
      return PR_TRUE;
    }
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::GetNonCloseParenToken ( nsresult aErrorCode,
PRBool  aSkipWS 
) [protected]

Definition at line 1648 of file nsCSSParser.cpp.

{
  if (!GetToken(aErrorCode, aSkipWS))
    return PR_FALSE;
  if (mToken.mType == eCSSToken_Symbol && mToken.mSymbol == ')') {
    UngetToken();
    return PR_FALSE;
  }
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::GetToken ( nsresult aErrorCode,
PRBool  aSkipWS 
) [protected]

Definition at line 1084 of file nsCSSParser.cpp.

{
  for (;;) {
    if (!mHavePushBack) {
      if (!mScanner.Next(aErrorCode, mToken)) {
        break;
      }
    }
    mHavePushBack = PR_FALSE;
    if (aSkipWS && (eCSSToken_WhiteSpace == mToken.mType)) {
      continue;
    }
    return PR_TRUE;
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::GetURLToken ( nsresult aErrorCode,
PRBool  aSkipWS 
) [protected]

Definition at line 1101 of file nsCSSParser.cpp.

{
  for (;;) {
    // XXXldb This pushback code doesn't make sense.
    if (! mHavePushBack) {
      if (! mScanner.NextURL(aErrorCode, mToken)) {
        break;
      }
    }
    mHavePushBack = PR_FALSE;
    if (aSkipWS && (eCSSToken_WhiteSpace == mToken.mType)) {
      continue;
    }
    return PR_TRUE;
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult CSSParserImpl::InitScanner ( nsIUnicharInputStream aInput,
nsIURI aSheetURI,
PRUint32  aLineNumber,
nsIURI aBaseURI 
) [protected]

Definition at line 592 of file nsCSSParser.cpp.

{
  NS_ASSERTION(! mScannerInited, "already have scanner");

  mScanner.Init(aInput, aSheetURI, aLineNumber);
#ifdef DEBUG
  mScannerInited = PR_TRUE;
#endif
  mBaseURL = aBaseURI;
  mSheetURL = aSheetURI;

  mHavePushBack = PR_FALSE;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult CSSParserImpl::InitScanner ( const nsAString &  aBuffer,
nsIURI aSheetURI,
PRUint32  aLineNumber,
nsIURI aBaseURI 
) [protected]

Definition at line 610 of file nsCSSParser.cpp.

{
  // Having it not own the string is OK since the caller will hold on to
  // the stream until we're done parsing.
  nsCOMPtr<nsIUnicharInputStream> input;
  nsresult rv = NS_NewStringUnicharInputStream(getter_AddRefs(input),
                                               &aBuffer, PR_FALSE);
  if (NS_FAILED(rv)) {
    return rv;
  }

  return InitScanner(input, aSheetURI, aLineNumber, aBaseURI);
}

Here is the call graph for this function:

Definition at line 366 of file nsCSSParser.cpp.

Here is the caller graph for this function:

nsString * CSSParserImpl::NextIdent ( nsresult aErrorCode) [protected]

Definition at line 1157 of file nsCSSParser.cpp.

{
  // XXX Error reporting?
  if (!GetToken(aErrorCode, PR_TRUE)) {
    return nsnull;
  }
  if (eCSSToken_Ident != mToken.mType) {
    UngetToken();
    return nsnull;
  }
  return &mToken.mIdent;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP CSSParserImpl::Parse ( nsIUnicharInputStream aInput,
nsIURI aSheetURL,
nsIURI aBaseURI,
PRUint32  aLineNumber,
PRBool  aAllowUnsafeRules,
nsICSSStyleSheet *&  aResult 
) [virtual]
Parameters:
aAllowUnsafeRulessee aEnableUnsafeRules in nsICSSLoader::LoadSheetSync

Implements nsICSSParser_MOZILLA_1_8_BRANCH.

Definition at line 649 of file nsCSSParser.cpp.

{
  NS_ASSERTION(nsnull != aBaseURI, "need base URL");
  NS_ASSERTION(nsnull != aSheetURI, "need sheet URL");

  if (! mSheet) {
    NS_NewCSSStyleSheet(getter_AddRefs(mSheet));
    NS_ENSURE_TRUE(mSheet, NS_ERROR_OUT_OF_MEMORY);

    nsCOMPtr<nsICSSStyleSheet_MOZILLA_1_8_BRANCH> sheet =
      do_QueryInterface(mSheet);
    sheet->SetURIs18(aSheetURI, aSheetURI, aBaseURI);
    mNameSpaceMap = nsnull;
  }
#ifdef DEBUG
  else {
    nsCOMPtr<nsIURI> uri;
    mSheet->GetSheetURI(getter_AddRefs(uri));
    PRBool equal;
    aSheetURI->Equals(uri, &equal);
    NS_ASSERTION(equal, "Sheet URI does not match passed URI");
  }
#endif
  
  nsresult errorCode = NS_OK;

  nsresult result = InitScanner(aInput, aSheetURI, aLineNumber, aBaseURI);
  if (! NS_SUCCEEDED(result)) {
    return result;
  }

  PRInt32 ruleCount = 0;
  mSheet->StyleRuleCount(ruleCount);
  if (0 < ruleCount) {
    nsICSSRule* lastRule = nsnull;
    mSheet->GetStyleRuleAt(ruleCount - 1, lastRule);
    if (lastRule) {
      PRInt32 type;
      lastRule->GetType(type);
      switch (type) {
        case nsICSSRule::CHARSET_RULE:
        case nsICSSRule::IMPORT_RULE:     
          mSection = eCSSSection_Import;    
          break;
        case nsICSSRule::NAMESPACE_RULE:  
          mSection = eCSSSection_NameSpace; 
          break;
        default:  
          mSection = eCSSSection_General; 
          break;
      }
      NS_RELEASE(lastRule);
    }
  }
  else {
    mSection = eCSSSection_Charset; // sheet is empty, any rules are fair
  }

  mUnsafeRulesEnabled = aAllowUnsafeRules;

  nsCSSToken* tk = &mToken;
  for (;;) {
    // Get next non-whitespace token
    if (!GetToken(errorCode, PR_TRUE)) {
      OUTPUT_ERROR();
      break;
    }
    if (eCSSToken_HTMLComment == tk->mType) {
      continue; // legal here only
    }
    if (eCSSToken_AtKeyword == tk->mType) {
      ParseAtRule(errorCode, AppendRuleToSheet, this);
      continue;
    }
    UngetToken();
    if (ParseRuleSet(errorCode, AppendRuleToSheet, this)) {
      mSection = eCSSSection_General;
    }
  }
  ReleaseScanner();

  mUnsafeRulesEnabled = PR_FALSE;

  aResult = mSheet;
  NS_ADDREF(aResult);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP CSSParserImpl::Parse ( nsIUnicharInputStream aInput,
nsIURI aSheetURI,
nsIURI aBaseURI,
PRUint32  aLineNumber,
nsICSSStyleSheet *&  aResult 
) [virtual]

Implements nsICSSParser.

Definition at line 639 of file nsCSSParser.cpp.

{
  return Parse(aInput, aSheetURI, aBaseURI, aLineNumber, PR_FALSE, aResult);
}

Here is the call graph for this function:

NS_IMETHODIMP CSSParserImpl::ParseAndAppendDeclaration ( const nsAString &  aBuffer,
nsIURI aSheetURL,
nsIURI aBaseURL,
nsCSSDeclaration aDeclaration,
PRBool  aParseOnlyOneDecl,
PRBool aChanged,
PRBool  aClearOldDecl 
) [virtual]

Implements nsICSSParser.

Definition at line 795 of file nsCSSParser.cpp.

{
//  NS_ASSERTION(nsnull != aBaseURL, "need base URL");
  *aChanged = PR_FALSE;

  nsresult rv = InitScanner(aBuffer, aSheetURL, 0, aBaseURL);
  if (! NS_SUCCEEDED(rv)) {
    return rv;
  }

  mSection = eCSSSection_General;
  nsresult errorCode = NS_OK;

  if (aClearOldDecl) {
    mData.AssertInitialState();
    aDeclaration->ClearData();
    // We could check if it was already empty, but...
    *aChanged = PR_TRUE;
  } else {
    aDeclaration->ExpandTo(&mData);
  }

  do {
    // If we cleared the old decl, then we want to be calling
    // ValueAppended as we parse.
    if (!ParseDeclaration(errorCode, aDeclaration, PR_FALSE,
                          aClearOldDecl, aChanged)) {
      NS_ASSERTION(errorCode != nsresult(-1), "-1 is no longer used for EOF");
      rv = errorCode;

      if (NS_FAILED(errorCode))
        break;

      if (!SkipDeclaration(errorCode, PR_FALSE)) {
        NS_ASSERTION(errorCode != nsresult(-1), "-1 is no longer used for EOF");
        rv = errorCode;
        break;
      }
    }
  } while (!aParseOnlyOneDecl);
  aDeclaration->CompressFrom(&mData);

  ReleaseScanner();
  return rv;
}

Here is the call graph for this function:

PRBool CSSParserImpl::ParseAtRule ( nsresult aErrorCode,
RuleAppendFunc  aAppendFunc,
void aProcessData 
) [protected]

Definition at line 1195 of file nsCSSParser.cpp.

{
  if ((mSection <= eCSSSection_Charset) && 
      (mToken.mIdent.LowerCaseEqualsLiteral("charset"))) {
    if (ParseCharsetRule(aErrorCode, aAppendFunc, aData)) {
      mSection = eCSSSection_Import;  // only one charset allowed
      return PR_TRUE;
    }
  }
  if ((mSection <= eCSSSection_Import) && 
      mToken.mIdent.LowerCaseEqualsLiteral("import")) {
    if (ParseImportRule(aErrorCode, aAppendFunc, aData)) {
      mSection = eCSSSection_Import;
      return PR_TRUE;
    }
  }
  if ((mSection <= eCSSSection_NameSpace) && 
      mToken.mIdent.LowerCaseEqualsLiteral("namespace")) {
    if (ParseNameSpaceRule(aErrorCode, aAppendFunc, aData)) {
      mSection = eCSSSection_NameSpace;
      return PR_TRUE;
    }
  }
  if (mToken.mIdent.LowerCaseEqualsLiteral("media")) {
    if (ParseMediaRule(aErrorCode, aAppendFunc, aData)) {
      mSection = eCSSSection_General;
      return PR_TRUE;
    }
  }
  if (mToken.mIdent.LowerCaseEqualsLiteral("-moz-document")) {
    if (ParseMozDocumentRule(aErrorCode, aAppendFunc, aData)) {
      mSection = eCSSSection_General;
      return PR_TRUE;
    }
  }
  if (mToken.mIdent.LowerCaseEqualsLiteral("font-face")) {
    if (ParseFontFaceRule(aErrorCode, aAppendFunc, aData)) {
      mSection = eCSSSection_General;
      return PR_TRUE;
    }
  }
  if (mToken.mIdent.LowerCaseEqualsLiteral("page")) {
    if (ParsePageRule(aErrorCode, aAppendFunc, aData)) {
      mSection = eCSSSection_General;
      return PR_TRUE;
    }
  }
  REPORT_UNEXPECTED_TOKEN(PEUnknownAtRule);
  OUTPUT_ERROR();

  // Skip over unsupported at rule, don't advance section
  return SkipAtRule(aErrorCode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseAttr ( nsresult aErrorCode,
nsCSSValue aValue 
) [protected]

Definition at line 3821 of file nsCSSParser.cpp.

{
  if (ExpectSymbol(aErrorCode, '(', PR_FALSE)) {
    if (GetToken(aErrorCode, PR_TRUE)) {
      nsAutoString attr;
      if (eCSSToken_Ident == mToken.mType) {  // attr name or namespace
        nsAutoString  holdIdent(mToken.mIdent);
        if (ExpectSymbol(aErrorCode, '|', PR_FALSE)) {  // namespace
          PRInt32 nameSpaceID = kNameSpaceID_Unknown;
          if (mNameSpaceMap) {
            ToLowerCase(holdIdent); // always case insensitive, since stays within CSS
            nsCOMPtr<nsIAtom> prefix = do_GetAtom(holdIdent);
            nameSpaceID = mNameSpaceMap->FindNameSpaceID(prefix);
          } // else, no declared namespaces
          if (kNameSpaceID_Unknown == nameSpaceID) {  // unknown prefix, dump it
            const PRUnichar *params[] = {
              holdIdent.get()
            };
            REPORT_UNEXPECTED_P(PEUnknownNamespacePrefix, params);
            return PR_FALSE;
          }
          attr.AppendInt(nameSpaceID, 10);
          attr.Append(PRUnichar('|'));
          if (! GetToken(aErrorCode, PR_FALSE)) {
            REPORT_UNEXPECTED_EOF(PEAttributeNameEOF);
            return PR_FALSE;
          }
          if (eCSSToken_Ident == mToken.mType) {
            if (mCaseSensitive) {
              attr.Append(mToken.mIdent);
            } else {
              nsAutoString buffer;
              ToLowerCase(mToken.mIdent, buffer);
              attr.Append(buffer);
            }
          }
          else {
            REPORT_UNEXPECTED_TOKEN(PEAttributeNameExpected);
            UngetToken();
            return PR_FALSE;
          }
        }
        else {  // no namespace
          if (mCaseSensitive) {
            attr = holdIdent;
          }
          else {
            ToLowerCase(holdIdent, attr);
          }
        }
      }
      else if (mToken.IsSymbol('*')) {  // namespace wildcard
        // Wildcard namespace makes no sense here and is not allowed
        REPORT_UNEXPECTED_TOKEN(PEAttributeNameExpected);
        UngetToken();
        return PR_FALSE;
      }
      else if (mToken.IsSymbol('|')) {  // explicit NO namespace
        if (! GetToken(aErrorCode, PR_FALSE)) {
          REPORT_UNEXPECTED_EOF(PEAttributeNameEOF);
          return PR_FALSE;
        }
        if (eCSSToken_Ident == mToken.mType) {
          if (mCaseSensitive) {
            attr.Append(mToken.mIdent);
          } else {
            nsAutoString buffer;
            ToLowerCase(mToken.mIdent, buffer);
            attr.Append(buffer);
          }
        }
        else {
          REPORT_UNEXPECTED_TOKEN(PEAttributeNameExpected);
          UngetToken();
          return PR_FALSE;
        }
      }
      else {
        REPORT_UNEXPECTED_TOKEN(PEAttributeNameOrNamespaceExpected);
        UngetToken();
        return PR_FALSE;
      }
      if (ExpectSymbol(aErrorCode, ')', PR_TRUE)) {
        aValue.SetStringValue(attr, eCSSUnit_Attr);
        return PR_TRUE;
      }
    }
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

CSSParserImpl::nsSelectorParsingStatus CSSParserImpl::ParseAttributeSelector ( PRInt32 aDataMask,
nsCSSSelector aSelector,
nsresult aErrorCode 
) [protected]

Definition at line 2211 of file nsCSSParser.cpp.

{
  if (! GetToken(aErrorCode, PR_TRUE)) { // premature EOF
    REPORT_UNEXPECTED_EOF(PEAttributeNameEOF);
    return eSelectorParsingStatus_Error;
  }

  PRInt32 nameSpaceID = kNameSpaceID_None;
  nsAutoString  attr;
  if (mToken.IsSymbol('*')) { // wildcard namespace
    nameSpaceID = kNameSpaceID_Unknown;
    if (ExpectSymbol(aErrorCode, '|', PR_FALSE)) {
      if (! GetToken(aErrorCode, PR_FALSE)) { // premature EOF
        REPORT_UNEXPECTED_EOF(PEAttributeNameEOF);
        return eSelectorParsingStatus_Error;
      }
      if (eCSSToken_Ident == mToken.mType) { // attr name
        attr = mToken.mIdent;
      }
      else {
        REPORT_UNEXPECTED_TOKEN(PEAttributeNameExpected);
        UngetToken();
        return eSelectorParsingStatus_Error;
       }
    }
    else {
      REPORT_UNEXPECTED_TOKEN(PEAttSelNoBar);
      return eSelectorParsingStatus_Error;
    }
  }
  else if (mToken.IsSymbol('|')) { // NO namespace
    if (! GetToken(aErrorCode, PR_FALSE)) { // premature EOF
      REPORT_UNEXPECTED_EOF(PEAttributeNameEOF);
      return eSelectorParsingStatus_Error;
    }
    if (eCSSToken_Ident == mToken.mType) { // attr name
      attr = mToken.mIdent;
    }
    else {
      REPORT_UNEXPECTED_TOKEN(PEAttributeNameExpected);
      UngetToken();
      return eSelectorParsingStatus_Error;
    }
  }
  else if (eCSSToken_Ident == mToken.mType) { // attr name or namespace
    attr = mToken.mIdent; // hang on to it
    if (ExpectSymbol(aErrorCode, '|', PR_FALSE)) {  // was a namespace
      nameSpaceID = kNameSpaceID_Unknown;
      if (mNameSpaceMap) {
        ToLowerCase(attr); // always case insensitive, since stays within CSS
        nsCOMPtr<nsIAtom> prefix = do_GetAtom(attr);
        nameSpaceID = mNameSpaceMap->FindNameSpaceID(prefix);
      } // else, no declared namespaces
      if (kNameSpaceID_Unknown == nameSpaceID) {  // unknown prefix, dump it
        const PRUnichar *params[] = {
          attr.get()
        };
        REPORT_UNEXPECTED_P(PEUnknownNamespacePrefix, params);
        return eSelectorParsingStatus_Error;
      }
      if (! GetToken(aErrorCode, PR_FALSE)) { // premature EOF
        REPORT_UNEXPECTED_EOF(PEAttributeNameEOF);
        return eSelectorParsingStatus_Error;
      }
      if (eCSSToken_Ident == mToken.mType) { // attr name
        attr = mToken.mIdent;
      }
      else {
        REPORT_UNEXPECTED_TOKEN(PEAttributeNameExpected);
        UngetToken();
        return eSelectorParsingStatus_Error;
      }
    }
  }
  else {  // malformed
    REPORT_UNEXPECTED_TOKEN(PEAttributeNameOrNamespaceExpected);
    UngetToken();
    return eSelectorParsingStatus_Error;
  }

  if (! mCaseSensitive) {
    ToLowerCase(attr);
  }
  if (! GetToken(aErrorCode, PR_TRUE)) { // premature EOF
    REPORT_UNEXPECTED_EOF(PEAttSelInnerEOF);
    return eSelectorParsingStatus_Error;
  }
  if ((eCSSToken_Symbol == mToken.mType) ||
      (eCSSToken_Includes == mToken.mType) ||
      (eCSSToken_Dashmatch == mToken.mType) ||
      (eCSSToken_Beginsmatch == mToken.mType) ||
      (eCSSToken_Endsmatch == mToken.mType) ||
      (eCSSToken_Containsmatch == mToken.mType)) {
    PRUint8 func;
    if (eCSSToken_Includes == mToken.mType) {
      func = NS_ATTR_FUNC_INCLUDES;
    }
    else if (eCSSToken_Dashmatch == mToken.mType) {
      func = NS_ATTR_FUNC_DASHMATCH;
    }
    else if (eCSSToken_Beginsmatch == mToken.mType) {
      func = NS_ATTR_FUNC_BEGINSMATCH;
    }
    else if (eCSSToken_Endsmatch == mToken.mType) {
      func = NS_ATTR_FUNC_ENDSMATCH;
    }
    else if (eCSSToken_Containsmatch == mToken.mType) {
      func = NS_ATTR_FUNC_CONTAINSMATCH;
    }
    else if (']' == mToken.mSymbol) {
      aDataMask |= SEL_MASK_ATTRIB;
      aSelector.AddAttribute(nameSpaceID, attr);
      func = NS_ATTR_FUNC_SET;
    }
    else if ('=' == mToken.mSymbol) {
      func = NS_ATTR_FUNC_EQUALS;
    }
    else {
      REPORT_UNEXPECTED_TOKEN(PEAttSelUnexpected);
      UngetToken(); // bad function
      return eSelectorParsingStatus_Error;
    }
    if (NS_ATTR_FUNC_SET != func) { // get value
      if (! GetToken(aErrorCode, PR_TRUE)) { // premature EOF
        REPORT_UNEXPECTED_EOF(PEAttSelValueEOF);
        return eSelectorParsingStatus_Error;
      }
      if ((eCSSToken_Ident == mToken.mType) || (eCSSToken_String == mToken.mType)) {
        nsAutoString  value(mToken.mIdent);
        if (! GetToken(aErrorCode, PR_TRUE)) { // premature EOF
          REPORT_UNEXPECTED_EOF(PEAttSelCloseEOF);
          return eSelectorParsingStatus_Error;
        }
        if (mToken.IsSymbol(']')) {
          PRBool isCaseSensitive = mCaseSensitive;
          if (nameSpaceID == kNameSpaceID_None ||
              nameSpaceID == kNameSpaceID_XHTML) {
            static const char* caseSensitiveHTMLAttribute[] = {
              // list based on http://www.w3.org/TR/REC-html40/index/attributes.html
              "abbr",          "alt",        "label",
              "prompt",        "standby",    "summary",
              "title",         "class",      "archive",
              "cite",          "datetime",   "href",
              "name",          nsnull
            };
            short i = 0;
            const char* htmlAttr;
            while ((htmlAttr = caseSensitiveHTMLAttribute[i++])) {
              if (attr.EqualsIgnoreCase(htmlAttr)) {
                isCaseSensitive = PR_TRUE;
                break;
              }
            }
          }
          aDataMask |= SEL_MASK_ATTRIB;
          aSelector.AddAttribute(nameSpaceID, attr, func, value, isCaseSensitive);
        }
        else {
          REPORT_UNEXPECTED_TOKEN(PEAttSelNoClose);
          UngetToken();
          return eSelectorParsingStatus_Error;
        }
      }
      else {
        REPORT_UNEXPECTED_TOKEN(PEAttSelBadValue);
        UngetToken();
        return eSelectorParsingStatus_Error;
      }
    }
  }
  else {
    REPORT_UNEXPECTED_TOKEN(PEAttSelUnexpected);
    UngetToken(); // bad dog, no biscut!
    return eSelectorParsingStatus_Error;
   }
   return eSelectorParsingStatus_Continue;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseAzimuth ( nsresult aErrorCode,
nsCSSValue aValue 
) [protected]

Definition at line 4690 of file nsCSSParser.cpp.

{
  if (ParseVariant(aErrorCode, aValue, VARIANT_HK | VARIANT_ANGLE, 
                   nsCSSProps::kAzimuthKTable)) {
    if (eCSSUnit_Enumerated == aValue.GetUnit()) {
      PRInt32 intValue = aValue.GetIntValue();
      if ((NS_STYLE_AZIMUTH_LEFT_SIDE <= intValue) && 
          (intValue <= NS_STYLE_AZIMUTH_BEHIND)) {  // look for optional modifier
        nsCSSValue  modifier;
        if (ParseEnum(aErrorCode, modifier, nsCSSProps::kAzimuthKTable)) {
          PRInt32 enumValue = modifier.GetIntValue();
          if (((intValue == NS_STYLE_AZIMUTH_BEHIND) && 
               (NS_STYLE_AZIMUTH_LEFT_SIDE <= enumValue) && (enumValue <= NS_STYLE_AZIMUTH_RIGHT_SIDE)) ||
              ((enumValue == NS_STYLE_AZIMUTH_BEHIND) && 
               (NS_STYLE_AZIMUTH_LEFT_SIDE <= intValue) && (intValue <= NS_STYLE_AZIMUTH_RIGHT_SIDE))) {
            aValue.SetIntValue(intValue | enumValue, eCSSUnit_Enumerated);
            return PR_TRUE;
          }
          // Put the unknown identifier back and return
          UngetToken();
          return PR_FALSE;
        }
      }
    }
    return PR_TRUE;
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseBackground ( nsresult aErrorCode) [protected]

Definition at line 4743 of file nsCSSParser.cpp.

{
  const PRInt32 numProps = 6;
  static const nsCSSProperty kBackgroundIDs[numProps] = {
    eCSSProperty_background_color,
    eCSSProperty_background_image,
    eCSSProperty_background_repeat,
    eCSSProperty_background_attachment,
    eCSSProperty_background_x_position,
    eCSSProperty_background_y_position
  };

  nsCSSValue  values[numProps];
  PRInt32 found = ParseChoice(aErrorCode, values, kBackgroundIDs, numProps);
  if ((found < 1) || (PR_FALSE == ExpectEndProperty(aErrorCode, PR_TRUE))) {
    return PR_FALSE;
  }

  if (0 != (found & 0x30)) {  // found one or more position values, validate them
    if (0 == (found & 0x20)) {
      if (eCSSUnit_Enumerated == values[4].GetUnit()) {
        PRInt32 mask = values[4].GetIntValue();
        values[4] = BackgroundPositionMaskToCSSValue(mask, PR_TRUE);
        values[5] = BackgroundPositionMaskToCSSValue(mask, PR_FALSE);
      }
      else {
        values[5].SetPercentValue(0.5f);
      }
    }
    else { // both x & y values
      nsCSSUnit xUnit = values[4].GetUnit();
      nsCSSUnit yUnit = values[5].GetUnit();
      if (eCSSUnit_Enumerated == xUnit) {
        PRInt32 xValue = values[4].GetIntValue();
        if (eCSSUnit_Enumerated == yUnit) {
          PRInt32 yValue = values[5].GetIntValue();
          if (0 != (xValue & (BG_LEFT | BG_RIGHT)) &&  // x is really an x value
              0 != (yValue & (BG_LEFT | BG_RIGHT))) {  // y is also an x value
            return PR_FALSE;
          }
          if (0 != (xValue & (BG_TOP | BG_BOTTOM)) &&  // x is really an y value
              0 != (yValue & (BG_TOP | BG_BOTTOM))) {  // y is also an y value
            return PR_FALSE;
          }
          if (0 != (xValue & (BG_TOP | BG_BOTTOM)) ||  // x is really a y value
              0 != (yValue & (BG_LEFT | BG_RIGHT))) {  // or y is really an x value
            PRInt32 holdXValue = xValue;
            xValue = yValue;
            yValue = holdXValue;
          }
          NS_ASSERTION(xValue & BG_CLR, "bad x value");
          NS_ASSERTION(yValue & BG_CTB, "bad y value");
          values[4] = BackgroundPositionMaskToCSSValue(xValue, PR_TRUE);
          values[5] = BackgroundPositionMaskToCSSValue(yValue, PR_FALSE);
        }
        else {
          if (!(xValue & BG_CLR)) {
            // The first keyword can only be 'center', 'left', or 'right'
            return PR_FALSE;
          }
          values[4] = BackgroundPositionMaskToCSSValue(xValue, PR_TRUE);
        }
      }
      else {
        if (eCSSUnit_Enumerated == yUnit) {
          PRInt32 yValue = values[5].GetIntValue();
          if (!(yValue & BG_CTB)) {
            // The second keyword can only be 'center', 'top', or 'bottom'
            return PR_FALSE;
          }
          values[5] = BackgroundPositionMaskToCSSValue(yValue, PR_FALSE);
        }
      }
    }
  }

  // Provide missing values
  if ((found & 0x01) == 0) {
    values[0].SetIntValue(NS_STYLE_BG_COLOR_TRANSPARENT, eCSSUnit_Enumerated);
  }
  if ((found & 0x02) == 0) {
    values[1].SetNoneValue();
  }
  if ((found & 0x04) == 0) {
    values[2].SetIntValue(NS_STYLE_BG_REPEAT_XY, eCSSUnit_Enumerated);
  }
  if ((found & 0x08) == 0) {
    values[3].SetIntValue(NS_STYLE_BG_ATTACHMENT_SCROLL, eCSSUnit_Enumerated);
  }
  if ((found & 0x30) == 0) {
    values[4].SetPercentValue(0.0f);
    values[5].SetPercentValue(0.0f);
  }

  PRInt32 index;
  for (index = 0; index < numProps; ++index) {
    AppendValue(kBackgroundIDs[index], values[index]);
  }

  // Background properties not settable from the shorthand get reset to their initial value
  static const PRInt32 numResetProps = 3;
  static const nsCSSProperty kBackgroundResetIDs[numResetProps] = {
    eCSSProperty__moz_background_clip,
    eCSSProperty__moz_background_inline_policy,
    eCSSProperty__moz_background_origin
  };

  nsCSSValue initial;
  initial.SetInitialValue();
  for (index = 0; index < numResetProps; ++index) {
    AppendValue(kBackgroundResetIDs[index], initial);
  }

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4859 of file nsCSSParser.cpp.

{
  // First try a percentage or a length value
  nsCSSValue xValue, yValue;
  if (ParseVariant(aErrorCode, xValue, VARIANT_HLP, nsnull)) {
    if (eCSSUnit_Inherit == xValue.GetUnit() ||
        eCSSUnit_Initial == xValue.GetUnit()) {  // both are inherited or both are set to initial
      if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
        AppendValue(eCSSProperty_background_x_position, xValue);
        AppendValue(eCSSProperty_background_y_position, xValue);
        return PR_TRUE;
      }
      return PR_FALSE;
    }
    // We have one percentage/length. Get the optional second
    // percentage/length/keyword.
    if (ParseVariant(aErrorCode, yValue, VARIANT_LP, nsnull)) {
      // We have two numbers
      if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
        AppendValue(eCSSProperty_background_x_position, xValue);
        AppendValue(eCSSProperty_background_y_position, yValue);
        return PR_TRUE;
      }
      return PR_FALSE;
    }

    if (ParseEnum(aErrorCode, yValue, kBackgroundXYPositionKTable)) {
      PRInt32 yVal = yValue.GetIntValue();
      if (!(yVal & BG_CTB)) {
        // The second keyword can only be 'center', 'top', or 'bottom'
        return PR_FALSE;
      }
      if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
        yValue = BackgroundPositionMaskToCSSValue(yVal, PR_FALSE);
        AppendValue(eCSSProperty_background_x_position, xValue);
        AppendValue(eCSSProperty_background_y_position, yValue);
        return PR_TRUE;
      }
      return PR_FALSE;
    }

    // If only one percentage or length value is given, it sets the
    // horizontal position only, and the vertical position will be 50%.
    if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
      AppendValue(eCSSProperty_background_x_position, xValue);
      AppendValue(eCSSProperty_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;
  if (ParseEnum(aErrorCode, xValue, kBackgroundXYPositionKTable)) {
    PRInt32 bit = xValue.GetIntValue();
    mask |= bit;
    if (ParseEnum(aErrorCode, xValue, kBackgroundXYPositionKTable)) {
      bit = xValue.GetIntValue();
      if (mask & (bit & ~BG_CENTER)) {
        // Only the 'center' keyword can be duplicated.
        return PR_FALSE;
      }
      mask |= bit;
    }
    else {
      // Only one keyword.  See if we have a length or percentage.
      if (ParseVariant(aErrorCode, yValue, VARIANT_LP, nsnull)) {
        if (!(mask & BG_CLR)) {
          // The first keyword can only be 'center', 'left', or 'right'
          return PR_FALSE;
        }

        if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
          xValue = BackgroundPositionMaskToCSSValue(mask, PR_TRUE);
          AppendValue(eCSSProperty_background_x_position, xValue);
          AppendValue(eCSSProperty_background_y_position, yValue);
          return PR_TRUE;
        }
        return PR_FALSE;
      }
    }
  }

  // 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;
  }

  if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
    // Create style values
    xValue = BackgroundPositionMaskToCSSValue(mask, PR_TRUE);
    yValue = BackgroundPositionMaskToCSSValue(mask, PR_FALSE);
    AppendValue(eCSSProperty_background_x_position, xValue);
    AppendValue(eCSSProperty_background_y_position, yValue);
    return PR_TRUE;
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseBorderColor ( nsresult aErrorCode) [protected]

Definition at line 4997 of file nsCSSParser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseBorderColors ( nsresult aErrorCode,
nsCSSValueList **  aResult,
nsCSSProperty  aProperty 
) [protected]

Definition at line 5097 of file nsCSSParser.cpp.

{
  nsCSSValue value;
  if (ParseVariant(aErrorCode, value, VARIANT_HCK|VARIANT_NONE, nsCSSProps::kBorderColorKTable)) {
    nsCSSValueList* listHead = new nsCSSValueList();
    nsCSSValueList* list = listHead;
    if (!list) {
      aErrorCode = NS_ERROR_OUT_OF_MEMORY;
      return PR_FALSE;
    }
    list->mValue = value;

    while (list) {
      if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
        mTempData.SetPropertyBit(aProperty);
        *aResult = listHead;
        aErrorCode = NS_OK;
        return PR_TRUE;
      }
      if (ParseVariant(aErrorCode, value, VARIANT_HCK|VARIANT_NONE, nsCSSProps::kBorderColorKTable)) {
        list->mNext = new nsCSSValueList();
        list = list->mNext;
        if (list)
          list->mValue = value;
        else
          aErrorCode = NS_ERROR_OUT_OF_MEMORY;
      }
      else
        break;
    }
    delete listHead;
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseBorderRadius ( nsresult aErrorCode) [protected]

Definition at line 5085 of file nsCSSParser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseBorderSide ( nsresult aErrorCode,
const nsCSSProperty  aPropIDs[],
PRBool  aSetAllSides 
) [protected]

Definition at line 5033 of file nsCSSParser.cpp.

{
  const PRInt32 numProps = 3;
  nsCSSValue  values[numProps];

  PRInt32 found = ParseChoice(aErrorCode, values, aPropIDs, numProps);
  if ((found < 1) || (PR_FALSE == ExpectEndProperty(aErrorCode, PR_TRUE))) {
    return PR_FALSE;
  }

  if ((found & 1) == 0) { // Provide default border-width
    values[0].SetIntValue(NS_STYLE_BORDER_WIDTH_MEDIUM, eCSSUnit_Enumerated);
  }
  if ((found & 2) == 0) { // Provide default border-style
    values[1].SetNoneValue();
  }
  if ((found & 4) == 0) { // text color will be used
    values[2].SetIntValue(NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR, eCSSUnit_Enumerated);
  }

  if (aSetAllSides) {
    // Parsing "border" shorthand; set all four sides to the same thing
    for (PRInt32 index = 0; index < 4; index++) {
      NS_ASSERTION(numProps == 3, "This code needs updating");
      AppendValue(kBorderWidthIDs[index], values[0]);
      AppendValue(kBorderStyleIDs[index], values[1]);
      AppendValue(kBorderColorIDs[index], values[2]);
    }   
  }
  else {
    // Just set our one side
    for (PRInt32 index = 0; index < numProps; index++) {
      AppendValue(aPropIDs[index], values[index]);
    }
  }
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseBorderSpacing ( nsresult aErrorCode) [protected]

Definition at line 5003 of file nsCSSParser.cpp.

{
  nsCSSValue  xValue;
  if (ParsePositiveVariant(aErrorCode, xValue, VARIANT_HL, nsnull)) {
    if (xValue.IsLengthUnit()) {
      // We have one length. Get the optional second length.
      nsCSSValue yValue;
      if (ParsePositiveVariant(aErrorCode, yValue, VARIANT_LENGTH, nsnull)) {
        // We have two numbers
        if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
          mTempData.mTable.mBorderSpacing.mXValue = xValue;
          mTempData.mTable.mBorderSpacing.mYValue = yValue;
          mTempData.SetPropertyBit(eCSSProperty_border_spacing);
          return PR_TRUE;
        }
        return PR_FALSE;
      }
    }

    // We have one length which is the horizontal spacing. Create a value for
    // the vertical spacing which is equal
    if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
      mTempData.mTable.mBorderSpacing.SetBothValuesTo(xValue);
      mTempData.SetPropertyBit(eCSSProperty_border_spacing);
      return PR_TRUE;
    }
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseBorderStyle ( nsresult aErrorCode) [protected]

Definition at line 5073 of file nsCSSParser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseBorderWidth ( nsresult aErrorCode) [protected]

Definition at line 5079 of file nsCSSParser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseBoxProperties ( nsresult aErrorCode,
nsCSSRect aResult,
const nsCSSProperty  aPropIDs[] 
) [protected]

Parse a "box" property.

Box properties have 1 to 4 values. When less than 4 values are provided a standard mapping is used to replicate existing values.

Definition at line 4017 of file nsCSSParser.cpp.

{
  // Get up to four values for the property
  PRInt32 count = 0;
  PRInt32 index;
  nsCSSRect result;
  for (index = 0; index < 4; index++) {
    if (! ParseSingleValueProperty(aErrorCode,
                                   result.*(nsCSSRect::sides[index]),
                                   aPropIDs[index])) {
      break;
    }
    count++;
  }
  if ((count == 0) || (PR_FALSE == ExpectEndProperty(aErrorCode, PR_TRUE))) {
    return PR_FALSE;
  }

  if (1 < count) { // verify no more than single inherit or initial
    for (index = 0; index < 4; index++) {
      nsCSSUnit unit = (result.*(nsCSSRect::sides[index])).GetUnit();
      if (eCSSUnit_Inherit == unit || eCSSUnit_Initial == unit) {
        return PR_FALSE;
      }
    }
  }

  // Provide missing values by replicating some of the values found
  switch (count) {
    case 1: // Make right == top
      result.mRight = result.mTop;
    case 2: // Make bottom == top
      result.mBottom = result.mTop;
    case 3: // Make left == right
      result.mLeft = result.mRight;
  }

  for (index = 0; index < 4; index++) {
    mTempData.SetPropertyBit(aPropIDs[index]);
  }
  aResult = result;
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseCharsetRule ( nsresult aErrorCode,
RuleAppendFunc  aAppendFunc,
void aProcessData 
) [protected]

Definition at line 1250 of file nsCSSParser.cpp.

{
  if (!GetToken(aErrorCode, PR_TRUE)) {
    REPORT_UNEXPECTED_EOF(PECharsetRuleEOF);
    return PR_FALSE;
  }

  if (eCSSToken_String != mToken.mType) {
    REPORT_UNEXPECTED_TOKEN(PECharsetRuleNotString);
    return PR_FALSE;
  }

  nsAutoString charset = mToken.mIdent;
  
  if (!ExpectSymbol(aErrorCode, ';', PR_TRUE)) {
    return PR_FALSE;
  }

  nsCOMPtr<nsICSSRule> rule;
  NS_NewCSSCharsetRule(getter_AddRefs(rule), charset);

  if (rule) {
    (*aAppendFunc)(rule, aData);
  }

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 CSSParserImpl::ParseChoice ( nsresult aErrorCode,
nsCSSValue  aValues[],
const nsCSSProperty  aPropIDs[],
PRInt32  aNumIDs 
) [protected]

Definition at line 3942 of file nsCSSParser.cpp.

{
  PRInt32 found = 0;
  SetParsingCompoundProperty(PR_TRUE);

  PRInt32 loop;
  for (loop = 0; loop < aNumIDs; loop++) {
    // Try each property parser in order
    PRInt32 hadFound = found;
    PRInt32 index;
    for (index = 0; index < aNumIDs; index++) {
      PRInt32 bit = 1 << index;
      if ((found & bit) == 0) {
        if (ParseSingleValueProperty(aErrorCode, aValues[index], aPropIDs[index])) {
          found |= bit;
        }
      }
    }
    if (found == hadFound) {  // found nothing new
      break;
    }
  }
  if (0 < found) {
    if (1 == found) { // only first property
      if (eCSSUnit_Inherit == aValues[0].GetUnit()) { // one inherit, all inherit
        for (loop = 1; loop < aNumIDs; loop++) {
          aValues[loop].SetInheritValue();
        }
        found = ((1 << aNumIDs) - 1);
      }
      else if (eCSSUnit_Initial == aValues[0].GetUnit()) { // one initial, all initial
        for (loop = 1; loop < aNumIDs; loop++) {
          aValues[loop].SetInitialValue();
        }
        found = ((1 << aNumIDs) - 1);
      }
    }
    else {  // more than one value, verify no inherits or initials
      for (loop = 0; loop < aNumIDs; loop++) {
        if (eCSSUnit_Inherit == aValues[loop].GetUnit()) {
          found = -1;
          break;
        }
        else if (eCSSUnit_Initial == aValues[loop].GetUnit()) {
          found = -1;
          break;
        }
      }
    }
  }
  SetParsingCompoundProperty(PR_FALSE);
  return found;
}

Here is the call graph for this function:

Here is the caller graph for this function:

CSSParserImpl::nsSelectorParsingStatus CSSParserImpl::ParseClassSelector ( PRInt32 aDataMask,
nsCSSSelector aSelector,
nsresult aErrorCode 
) [protected]

Definition at line 2015 of file nsCSSParser.cpp.

{
  if (! GetToken(aErrorCode, PR_FALSE)) { // get ident
    REPORT_UNEXPECTED_EOF(PEClassSelEOF);
    return eSelectorParsingStatus_Error;
  }
  if (eCSSToken_Ident != mToken.mType) {  // malformed selector
    REPORT_UNEXPECTED_TOKEN(PEClassSelNotIdent);
    UngetToken();
    return eSelectorParsingStatus_Error;
  }
  aDataMask |= SEL_MASK_CLASS;

  aSelector.AddClass(mToken.mIdent);

  return eSelectorParsingStatus_Continue;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseColor ( nsresult aErrorCode,
nsCSSValue aValue 
) [protected]

Definition at line 2760 of file nsCSSParser.cpp.

{
  if (!GetToken(aErrorCode, PR_TRUE)) {
    REPORT_UNEXPECTED_EOF(PEColorEOF);
    return PR_FALSE;
  }

  nsCSSToken* tk = &mToken;
  nscolor rgba;
  switch (tk->mType) {
    case eCSSToken_ID:
    case eCSSToken_Ref:
      // #xxyyzz
      if (NS_HexToRGB(tk->mIdent, &rgba)) {
        aValue.SetColorValue(rgba);
        return PR_TRUE;
      }
      break;

    case eCSSToken_Ident:
      if (NS_ColorNameToRGB(tk->mIdent, &rgba)) {
        aValue.SetStringValue(tk->mIdent, eCSSUnit_String);
        return PR_TRUE;
      }
      else {
        nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(tk->mIdent);
        if (eCSSKeyword_UNKNOWN < keyword) { // known keyword
          PRInt32 value;
          if (nsCSSProps::FindKeyword(keyword, nsCSSProps::kColorKTable, value)) {
            aValue.SetIntValue(value, eCSSUnit_Integer);
            return PR_TRUE;
          }
        }
      }
      break;
    case eCSSToken_Function:
      if (mToken.mIdent.LowerCaseEqualsLiteral("rgb")) {
        // rgb ( component , component , component )
        PRUint8 r, g, b;
        PRInt32 type = COLOR_TYPE_UNKNOWN;
        if (ExpectSymbol(aErrorCode, '(', PR_FALSE) && // this won't fail
            ParseColorComponent(aErrorCode, r, type, ',') &&
            ParseColorComponent(aErrorCode, g, type, ',') &&
            ParseColorComponent(aErrorCode, b, type, ')')) {
          aValue.SetColorValue(NS_RGB(r,g,b));
          return PR_TRUE;
        }
        return PR_FALSE;  // already pushed back
      }
      else if (mToken.mIdent.LowerCaseEqualsLiteral("-moz-rgba") ||
               (mHandleAlphaColors && mToken.mIdent.LowerCaseEqualsLiteral("rgba"))) {
        // rgba ( component , component , component , opacity )
        PRUint8 r, g, b, a;
        PRInt32 type = COLOR_TYPE_UNKNOWN;
        if (ExpectSymbol(aErrorCode, '(', PR_FALSE) && // this won't fail
            ParseColorComponent(aErrorCode, r, type, ',') &&
            ParseColorComponent(aErrorCode, g, type, ',') &&
            ParseColorComponent(aErrorCode, b, type, ',') &&
            ParseColorOpacity(aErrorCode, a)) {
          aValue.SetColorValue(NS_RGBA(r, g, b, a));
          return PR_TRUE;
        }
        return PR_FALSE;  // already pushed back
      }
      else if (mToken.mIdent.LowerCaseEqualsLiteral("hsl")) {
        // hsl ( hue , saturation , lightness )
        // "hue" is a number, "saturation" and "lightness" are percentages.
        if (ParseHSLColor(aErrorCode, rgba, ')')) {
          aValue.SetColorValue(rgba);
          return PR_TRUE;
        }
        return PR_FALSE;
      }
      else if (mToken.mIdent.LowerCaseEqualsLiteral("-moz-hsla") ||
               (mHandleAlphaColors && mToken.mIdent.LowerCaseEqualsLiteral("hsla"))) {
        // hsla ( hue , saturation , lightness , opacity )
        // "hue" is a number, "saturation" and "lightness" are percentages,
        // "opacity" is a number.
        PRUint8 a;
        if (ParseHSLColor(aErrorCode, rgba, ',') &&
            ParseColorOpacity(aErrorCode, a)) {
          aValue.SetColorValue(NS_RGBA(NS_GET_R(rgba), NS_GET_G(rgba),
                                       NS_GET_B(rgba), a));
          return PR_TRUE;
        }
        return PR_FALSE;
      }
      break;
    default:
      break;
  }

  // try 'xxyyzz' without '#' prefix for compatibility with IE and Nav4x (bug 23236 and 45804)
  if (mNavQuirkMode && !IsParsingCompoundProperty()) {
    // - If the string starts with 'a-f', the nsCSSScanner builds the
    //   token as a eCSSToken_Ident and we can parse the string as a
    //   'xxyyzz' RGB color.
    // - If it only contains '0-9' digits, the token is a
    //   eCSSToken_Number and it must be converted back to a 6
    //   characters string to be parsed as a RGB color.
    // - If it starts with '0-9' and contains any 'a-f', the token is a
    //   eCSSToken_Dimension, the mNumber part must be converted back to
    //   a string and the mIdent part must be appended to that string so
    //   that the resulting string has 6 characters.
    // Note: This is a hack for Nav compatibility.  Do not attempt to
    // simplify it by hacking into the ncCSSScanner.  This would be very
    // bad.
    nsAutoString str;
    char buffer[20];
    switch (tk->mType) {
      case eCSSToken_Ident:
        str.Assign(tk->mIdent);
        break;

      case eCSSToken_Number:
        if (tk->mIntegerValid) {
          PR_snprintf(buffer, sizeof(buffer), "%06d", tk->mInteger);
          str.AssignWithConversion(buffer);
        }
        break;

      case eCSSToken_Dimension:
        if (tk->mIdent.Length() <= 6) {
          PR_snprintf(buffer, sizeof(buffer), "%06.0f", tk->mNumber);
          nsAutoString temp;
          temp.AssignWithConversion(buffer);
          temp.Right(str, 6 - tk->mIdent.Length());
          str.Append(tk->mIdent);
        }
        break;
      default:
        // There is a whole bunch of cases that are
        // not handled by this switch.  Ignore them.
        break;
    }
    if (NS_HexToRGB(str, &rgba)) {
      aValue.SetColorValue(rgba);
      return PR_TRUE;
    }
  }

  // It's not a color
  REPORT_UNEXPECTED_TOKEN(PEColorNotColor);
  UngetToken();
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseColorComponent ( nsresult aErrorCode,
PRUint8 aComponent,
PRInt32 aType,
char  aStop 
) [protected]

Definition at line 2909 of file nsCSSParser.cpp.

{
  if (!GetToken(aErrorCode, PR_TRUE)) {
    REPORT_UNEXPECTED_EOF(PEColorComponentEOF);
    return PR_FALSE;
  }
  float value;
  nsCSSToken* tk = &mToken;
  switch (tk->mType) {
  case eCSSToken_Number:
    switch (aType) {
      case COLOR_TYPE_UNKNOWN:
        aType = COLOR_TYPE_INTEGERS;
        break;
      case COLOR_TYPE_INTEGERS:
        break;
      case COLOR_TYPE_PERCENTAGES:
        REPORT_UNEXPECTED_TOKEN(PEExpectedPercent);
        UngetToken();
        return PR_FALSE;
      default:
        NS_NOTREACHED("Someone forgot to add the new color component type in here");
    }

    if (!mToken.mIntegerValid) {
      REPORT_UNEXPECTED_TOKEN(PEExpectedInt);
      UngetToken();
      return PR_FALSE;
    }
    value = tk->mNumber;
    break;
  case eCSSToken_Percentage:
    switch (aType) {
      case COLOR_TYPE_UNKNOWN:
        aType = COLOR_TYPE_PERCENTAGES;
        break;
      case COLOR_TYPE_INTEGERS:
        REPORT_UNEXPECTED_TOKEN(PEExpectedInt);
        UngetToken();
        return PR_FALSE;
      case COLOR_TYPE_PERCENTAGES:
        break;
      default:
        NS_NOTREACHED("Someone forgot to add the new color component type in here");
    }
    value = tk->mNumber * 255.0f;
    break;
  default:
    REPORT_UNEXPECTED_TOKEN(PEColorBadRGBContents);
    UngetToken();
    return PR_FALSE;
  }
  if (ExpectSymbol(aErrorCode, aStop, PR_TRUE)) {
    if (value < 0.0f) value = 0.0f;
    if (value > 255.0f) value = 255.0f;
    aComponent = (PRUint8) value;
    return PR_TRUE;
  }
  const PRUnichar stopString[] = { PRUnichar(aStop), PRUnichar(0) };
  const PRUnichar *params[] = {
    nsnull,
    stopString
  };
  REPORT_UNEXPECTED_TOKEN_P(PEColorComponentBadTerm, params);
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseColorOpacity ( nsresult aErrorCode,
PRUint8 aOpacity 
) [protected]

Definition at line 3057 of file nsCSSParser.cpp.

{
  if (!GetToken(aErrorCode, PR_TRUE)) {
    REPORT_UNEXPECTED_EOF(PEColorOpacityEOF);
    return PR_FALSE;
  }

  if (mToken.mType != eCSSToken_Number) {
    REPORT_UNEXPECTED_TOKEN(PEExpectedNumber);
    UngetToken();
    return PR_FALSE;
  }

  PRInt32 value = NSToIntRound(mToken.mNumber*255);

  if (!ExpectSymbol(aErrorCode, ')', PR_TRUE)) {
    REPORT_UNEXPECTED_TOKEN(PEExpectedCloseParen);
    return PR_FALSE;
  }
  
  if (value < 0) value = 0;
  if (value > 255) value = 255;
  aOpacity = (PRUint8)value;

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP CSSParserImpl::ParseColorString ( const nsSubstring aBuffer,
nsIURI aURL,
PRUint32  aLineNumber,
PRBool  aHandleAlphaColors,
nscolor aColor 
) [virtual]

Parse aBuffer into a nscolor |aColor|.

If aHandleAlphaColors is set, handle rgba()/hsla(). Will return NS_ERROR_FAILURE if aBuffer is not a valid CSS color specification.

Will also currently return NS_ERROR_FAILURE if it is not self-contained (i.e. doesn't reference any external style state, such as "initial" or "inherit").

Implements nsICSSParser.

Definition at line 1023 of file nsCSSParser.cpp.

{
  NS_ASSERTION(aHandleAlphaColors == PR_TRUE || aHandleAlphaColors == PR_FALSE, "bad PRBool value");

  nsresult rv = NS_ERROR_FAILURE;

  rv = InitScanner(aBuffer, aURL, aLineNumber, aURL);
  if (NS_FAILED(rv))
    return rv;

  mHandleAlphaColors = aHandleAlphaColors;

  nsCSSValue value;
  PRBool colorParsed = ParseColor(rv, value);

  CLEAR_ERROR();
  ReleaseScanner();

  mHandleAlphaColors = PR_FALSE;

  if (!colorParsed) {
    return NS_ERROR_FAILURE;
  }

  if (value.GetUnit() == eCSSUnit_String) {
    nsAutoString s;
    nscolor rgba;
    if (NS_ColorNameToRGB(value.GetStringValue(s), &rgba)) {
      (*aColor) = rgba;
      rv = NS_OK;
    }
  } else if (value.GetUnit() == eCSSUnit_Color) {
    (*aColor) = value.GetColorValue();
    rv = NS_OK;
  } else if (value.GetUnit() == eCSSUnit_Integer) {
    PRInt32 intValue = value.GetIntValue();
    if (intValue >= 0) {
      nsCOMPtr<nsILookAndFeel> lfSvc = do_GetService("@mozilla.org/widget/lookandfeel;1");
      if (lfSvc) {
        nscolor rgba;
        rv = lfSvc->GetColor((nsILookAndFeel::nsColorID) value.GetIntValue(), rgba);
        if (NS_SUCCEEDED(rv))
          (*aColor) = rgba;
      }
    } else {
      // XXX - this is NS_COLOR_CURRENTCOLOR, NS_COLOR_MOZ_HYPERLINKTEXT, etc.
      // which we don't handle as per the ParseColorString definition.  Should
      // remove this limitation at some point.
      rv = NS_ERROR_FAILURE;
    }
  }

  return rv;
}

Here is the call graph for this function:

PRBool CSSParserImpl::ParseContent ( nsresult aErrorCode) [protected]

Definition at line 5208 of file nsCSSParser.cpp.

{
  // XXX Rewrite to make it look more like ParseCursor or ParseCounterData?
  nsCSSValue  value;
  if (ParseVariant(aErrorCode, value,
                   VARIANT_CONTENT | VARIANT_INHERIT | VARIANT_NORMAL, 
                   nsCSSProps::kContentKTable)) {
    nsCSSValueList* listHead = new nsCSSValueList();
    nsCSSValueList* list = listHead;
    if (nsnull == list) {
      aErrorCode = NS_ERROR_OUT_OF_MEMORY;
      return PR_FALSE;
    }
    list->mValue = value;

    while (nsnull != list) {
      if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
        mTempData.SetPropertyBit(eCSSProperty_content);
        mTempData.mContent.mContent = listHead;
        aErrorCode = NS_OK;
        return PR_TRUE;
      }
      if (eCSSUnit_Inherit == value.GetUnit() ||
          eCSSUnit_Initial == value.GetUnit() ||
          eCSSUnit_Normal == value.GetUnit()) {
        // This only matters the first time through the loop.
        return PR_FALSE;
      }
      if (ParseVariant(aErrorCode, value, VARIANT_CONTENT, nsCSSProps::kContentKTable)) {
        list->mNext = new nsCSSValueList();
        list = list->mNext;
        if (nsnull != list) {
          list->mValue = value;
        }
        else {
          aErrorCode = NS_ERROR_OUT_OF_MEMORY;
        }
      }
      else {
        break;
      }
    }
    delete listHead;
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseCounter ( nsresult aErrorCode,
nsCSSValue aValue 
) [protected]

Definition at line 3754 of file nsCSSParser.cpp.

{
  nsCSSUnit unit = (mToken.mIdent.LowerCaseEqualsLiteral("counter") ? 
                    eCSSUnit_Counter : eCSSUnit_Counters);

  if (!ExpectSymbol(aErrorCode, '(', PR_FALSE))
    return PR_FALSE;

  if (!GetNonCloseParenToken(aErrorCode, PR_TRUE) ||
      eCSSToken_Ident != mToken.mType) {
    SkipUntil(aErrorCode, ')');
    return PR_FALSE;
  }

  nsRefPtr<nsCSSValue::Array> val =
    nsCSSValue::Array::Create(unit == eCSSUnit_Counter ? 2 : 3);
  if (!val) {
    aErrorCode = NS_ERROR_OUT_OF_MEMORY;
    return PR_FALSE;
  }

  val->Item(0).SetStringValue(mToken.mIdent, eCSSUnit_String);

  if (eCSSUnit_Counters == unit) {
    // get mandatory separator string
    if (!ExpectSymbol(aErrorCode, ',', PR_TRUE) ||
        !(GetNonCloseParenToken(aErrorCode, PR_TRUE) &&
          eCSSToken_String == mToken.mType)) {
      SkipUntil(aErrorCode, ')');
      return PR_FALSE;
    }
    val->Item(1).SetStringValue(mToken.mIdent, eCSSUnit_String);
  }

  // get optional type
  PRInt32 type = NS_STYLE_LIST_STYLE_DECIMAL;
  if (ExpectSymbol(aErrorCode, ',', PR_TRUE)) {
    nsCSSKeyword keyword;
    PRBool success = GetNonCloseParenToken(aErrorCode, PR_TRUE) &&
                     eCSSToken_Ident == mToken.mType &&
                     (keyword = nsCSSKeywords::LookupKeyword(mToken.mIdent)) !=
                      eCSSKeyword_UNKNOWN;
    if (success) {
      if (keyword == eCSSKeyword_none) {
        type = NS_STYLE_LIST_STYLE_NONE;
      } else {
        success = nsCSSProps::FindKeyword(keyword,
                                          nsCSSProps::kListStyleKTable, type);
      }
    }
    if (!success) {
      SkipUntil(aErrorCode, ')');
      return PR_FALSE;
    }
  }
  PRInt32 typeItem = eCSSUnit_Counters == unit ? 2 : 1;
  val->Item(typeItem).SetIntValue(type, eCSSUnit_Enumerated);

  if (!ExpectSymbol(aErrorCode, ')', PR_TRUE)) {
    SkipUntil(aErrorCode, ')');
    return PR_FALSE;
  }

  aValue.SetArrayValue(val, unit);
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseCounterData ( nsresult aErrorCode,
nsCSSCounterData **  aResult,
nsCSSProperty  aPropID 
) [protected]

Definition at line 5260 of file nsCSSParser.cpp.

{
  nsString* ident = NextIdent(aErrorCode);
  if (nsnull == ident) {
    return PR_FALSE;
  }
  static const SingleCounterPropValue singleValues[] = {
    { "none", eCSSUnit_None },
    { "inherit", eCSSUnit_Inherit },
    { "-moz-initial", eCSSUnit_Initial }
  };
  for (const SingleCounterPropValue *sv = singleValues,
           *sv_end = singleValues + NS_ARRAY_LENGTH(singleValues);
       sv != sv_end; ++sv) {
    if (ident->LowerCaseEqualsLiteral(sv->str)) {
      if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
        nsCSSCounterData* dataHead = new nsCSSCounterData();
        if (!dataHead) {
          aErrorCode = NS_ERROR_OUT_OF_MEMORY;
          return PR_FALSE;
        }
        dataHead->mCounter = nsCSSValue(sv->unit);
        *aResult = dataHead;
        mTempData.SetPropertyBit(aPropID);
        return PR_TRUE;
      }
      return PR_FALSE;
    }
  }
  UngetToken(); // undo NextIdent

  nsCSSCounterData* dataHead = nsnull;
  nsCSSCounterData **next = &dataHead;
  for (;;) {
    if (!GetToken(aErrorCode, PR_TRUE) || mToken.mType != eCSSToken_Ident) {
      break;
    }
    nsCSSCounterData *data = *next = new nsCSSCounterData();
    if (!data) {
      aErrorCode = NS_ERROR_OUT_OF_MEMORY;
      break;
    }
    next = &data->mNext;
    data->mCounter.SetStringValue(mToken.mIdent, eCSSUnit_String);
    if (GetToken(aErrorCode, PR_TRUE)) {
      if (eCSSToken_Number == mToken.mType && mToken.mIntegerValid) {
        data->mValue.SetIntValue(mToken.mInteger, eCSSUnit_Integer);
      } else {
        UngetToken();
      }
    }
    if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
      mTempData.SetPropertyBit(aPropID);
      *aResult = dataHead;
      aErrorCode = NS_OK;
      return PR_TRUE;
    }
  }
  delete dataHead;
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseCue ( nsresult aErrorCode) [protected]

Definition at line 5324 of file nsCSSParser.cpp.

{
  nsCSSValue before;
  if (ParseSingleValueProperty(aErrorCode, before, eCSSProperty_cue_before)) {
    if (eCSSUnit_URL == before.GetUnit()) {
      nsCSSValue after;
      if (ParseSingleValueProperty(aErrorCode, after, eCSSProperty_cue_after)) {
        if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
          AppendValue(eCSSProperty_cue_before, before);
          AppendValue(eCSSProperty_cue_after, after);
          return PR_TRUE;
        }
        return PR_FALSE;
      }
    }
    if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
      AppendValue(eCSSProperty_cue_before, before);
      AppendValue(eCSSProperty_cue_after, before);
      return PR_TRUE;
    }
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseCursor ( nsresult aErrorCode) [protected]

Definition at line 5348 of file nsCSSParser.cpp.

{
  nsCSSValueList *list = nsnull;
  for (nsCSSValueList **curp = &list, *cur; ; curp = &cur->mNext) {
    cur = *curp = new nsCSSValueList();
    if (!cur) {
      aErrorCode = NS_ERROR_OUT_OF_MEMORY;
      break;
    }
    if (!ParseVariant(aErrorCode, cur->mValue,
                      (cur == list) ? VARIANT_AHUK : VARIANT_AUK,
                      nsCSSProps::kCursorKTable)) {
      break;
    }
    if (cur->mValue.GetUnit() != eCSSUnit_URL) {
      if (!ExpectEndProperty(aErrorCode, PR_TRUE)) {
        break;
      }
      // Only success case here, since having the failure case at the
      // end allows more sharing of code.
      mTempData.SetPropertyBit(eCSSProperty_cursor);
      mTempData.mUserInterface.mCursor = list;
      aErrorCode = NS_OK;
      return PR_TRUE;
    } 
    // We have a URL, so make a value array with three values.
    nsRefPtr<nsCSSValue::Array> val = nsCSSValue::Array::Create(3);
    if (!val) {
      aErrorCode = NS_ERROR_OUT_OF_MEMORY;
      break;
    }
    val->Item(0) = cur->mValue;
    cur->mValue.SetArrayValue(val, eCSSUnit_Array);

    // Parse optional x and y position of cursor hotspot (css3-ui).
    if (ParseVariant(aErrorCode, val->Item(1), VARIANT_NUMBER, nsnull)) {
      // If we have one number, we must have two.
      if (!ParseVariant(aErrorCode, val->Item(2), VARIANT_NUMBER, nsnull)) {
        break;
      }
    }

    if (!ExpectSymbol(aErrorCode, ',', PR_TRUE)) {
      break;
    }
  }
  // Have failure case at the end so we can |break| to get to it.
  delete list;
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseDeclaration ( nsresult aErrorCode,
nsCSSDeclaration aDeclaration,
PRBool  aCheckForBraces,
PRBool  aMustCallValueAppended,
PRBool aChanged 
) [protected]

Definition at line 3112 of file nsCSSParser.cpp.

{
  mTempData.AssertInitialState();

  // Get property name
  nsCSSToken* tk = &mToken;
  nsAutoString propertyName;
  for (;;) {
    if (!GetToken(aErrorCode, PR_TRUE)) {
      if (aCheckForBraces) {
        REPORT_UNEXPECTED_EOF(PEDeclEndEOF);
      }
      return PR_FALSE;
    }
    if (eCSSToken_Ident == tk->mType) {
      propertyName = tk->mIdent;
      // grab the ident before the ExpectSymbol trashes the token
      if (!ExpectSymbol(aErrorCode, ':', PR_TRUE)) {
        REPORT_UNEXPECTED_TOKEN(PEParseDeclarationNoColon);
        REPORT_UNEXPECTED(PEDeclDropped);
        OUTPUT_ERROR();
        return PR_FALSE;
      }
      break;
    }
    if (tk->IsSymbol(';')) {
      // dangling semicolons are skipped
      continue;
    }

    if (!tk->IsSymbol('}')) {
      REPORT_UNEXPECTED_TOKEN(PEParseDeclarationDeclExpected);
      REPORT_UNEXPECTED(PEDeclSkipped);
      OUTPUT_ERROR();
    }
    // Not a declaration...
    UngetToken();
    return PR_FALSE;
  }

  // Map property name to it's ID and then parse the property
  nsCSSProperty propID = nsCSSProps::LookupProperty(propertyName);
  if (eCSSProperty_UNKNOWN == propID) { // unknown property
    const PRUnichar *params[] = {
      propertyName.get()
    };
    REPORT_UNEXPECTED_P(PEUnknownProperty, params);
    REPORT_UNEXPECTED(PEDeclDropped);
    OUTPUT_ERROR();
    return PR_FALSE;
  }
  if (! ParseProperty(aErrorCode, propID)) {
    // XXX Much better to put stuff in the value parsers instead...
    const PRUnichar *params[] = {
      propertyName.get()
    };
    REPORT_UNEXPECTED_P(PEPropertyParsingError, params);
    REPORT_UNEXPECTED(PEDeclDropped);
    OUTPUT_ERROR();
    ClearTempData(propID);
    return PR_FALSE;
  }
  CLEAR_ERROR();

  // See if the declaration is followed by a "!important" declaration
  PRBool isImportant = PR_FALSE;
  if (!GetToken(aErrorCode, PR_TRUE)) {
    if (aCheckForBraces) {
      // Premature eof is not ok when proper termination is mandated
      REPORT_UNEXPECTED_EOF(PEEndOfDeclEOF);
      ClearTempData(propID);
      return PR_FALSE;
    }
    TransferTempData(aDeclaration, propID, isImportant,
                     aMustCallValueAppended, aChanged);
    return PR_TRUE;
  }
  else {
    if (eCSSToken_Symbol == tk->mType) {
      if ('!' == tk->mSymbol) {
        // Look for important ident
        if (!GetToken(aErrorCode, PR_TRUE)) {
          // Premature eof is not ok
          REPORT_UNEXPECTED_EOF(PEImportantEOF);
          ClearTempData(propID);
          return PR_FALSE;
        }
        if ((eCSSToken_Ident != tk->mType) ||
            !tk->mIdent.LowerCaseEqualsLiteral("important")) {
          REPORT_UNEXPECTED_TOKEN(PEExpectedImportant);
          OUTPUT_ERROR();
          UngetToken();
          ClearTempData(propID);
          return PR_FALSE;
        }
        isImportant = PR_TRUE;
      }
      else {
        // Not a !important declaration
        UngetToken();
      }
    }
    else {
      // Not a !important declaration
      UngetToken();
    }
  }

  // Make sure valid property declaration is terminated with either a
  // semicolon or a right-curly-brace (when aCheckForBraces is true).
  // When aCheckForBraces is false, proper termination is either
  // semicolon or EOF.
  if (!GetToken(aErrorCode, PR_TRUE)) {
    if (aCheckForBraces) {
      // Premature eof is not ok
      REPORT_UNEXPECTED_EOF(PEDeclEndEOF);
      ClearTempData(propID);
      return PR_FALSE;
    }
    TransferTempData(aDeclaration, propID, isImportant,
                     aMustCallValueAppended, aChanged);
    return PR_TRUE;
  } 
  if (eCSSToken_Symbol == tk->mType) {
    if (';' == tk->mSymbol) {
      TransferTempData(aDeclaration, propID, isImportant,
                       aMustCallValueAppended, aChanged);
      return PR_TRUE;
    }
    if (!aCheckForBraces) {
      // If we didn't hit eof and we didn't see a semicolon then the
      // declaration is not properly terminated.
      REPORT_UNEXPECTED_TOKEN(PEBadDeclEnd);
      REPORT_UNEXPECTED(PEDeclDropped);
      OUTPUT_ERROR();
      ClearTempData(propID);
      return PR_FALSE;
    }
    if ('}' == tk->mSymbol) {
      UngetToken();
      TransferTempData(aDeclaration, propID, isImportant,
                       aMustCallValueAppended, aChanged);
      return PR_TRUE;
    }
  }
  if (aCheckForBraces)
    REPORT_UNEXPECTED_TOKEN(PEBadDeclOrRuleEnd);
  else
    REPORT_UNEXPECTED_TOKEN(PEBadDeclEnd);
  REPORT_UNEXPECTED(PEDeclDropped);
  OUTPUT_ERROR();
  ClearTempData(propID);
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsCSSDeclaration * CSSParserImpl::ParseDeclarationBlock ( nsresult aErrorCode,
PRBool  aCheckForBraces 
) [protected]

Definition at line 2720 of file nsCSSParser.cpp.

{
  if (aCheckForBraces) {
    if (!ExpectSymbol(aErrorCode, '{', PR_TRUE)) {
      REPORT_UNEXPECTED_TOKEN(PEBadDeclBlockStart);
      OUTPUT_ERROR();
      return nsnull;
    }
  }
  nsCSSDeclaration* declaration = new nsCSSDeclaration();
  mData.AssertInitialState();
  if (declaration) {
    for (;;) {
      PRBool changed;
      if (!ParseDeclaration(aErrorCode, declaration, aCheckForBraces,
                            PR_TRUE, &changed)) {
        if (!SkipDeclaration(aErrorCode, aCheckForBraces)) {
          break;
        }
        if (aCheckForBraces) {
          if (ExpectSymbol(aErrorCode, '}', PR_TRUE)) {
            break;
          }
        }
        // Since the skipped declaration didn't end the block we parse
        // the next declaration.
      }
    }
    declaration->CompressFrom(&mData);
  }
  return declaration;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseDirectionalBoxProperty ( nsresult aErrorCode,
nsCSSProperty  aProperty,
PRInt32  aSourceType 
) [protected]

Definition at line 4063 of file nsCSSParser.cpp.

{
  const nsCSSProperty* subprops = nsCSSProps::SubpropertyEntryFor(aProperty);
  NS_ASSERTION(subprops[3] == eCSSProperty_UNKNOWN,
               "not box property with physical vs. logical cascading");
  nsCSSValue value;
  if (!ParseSingleValueProperty(aErrorCode, value, subprops[0]) ||
      !ExpectEndProperty(aErrorCode, PR_TRUE))
    return PR_FALSE;

  AppendValue(subprops[0], value);
  nsCSSValue typeVal(aSourceType, eCSSUnit_Enumerated);
  AppendValue(subprops[1], typeVal);
  AppendValue(subprops[2], typeVal);
  aErrorCode = NS_OK;
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseEnum ( nsresult aErrorCode,
nsCSSValue aValue,
const PRInt32  aKeywordTable[] 
) [protected]

Definition at line 3490 of file nsCSSParser.cpp.

{
  nsString* ident = NextIdent(aErrorCode);
  if (nsnull == ident) {
    return PR_FALSE;
  }
  nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(*ident);
  if (eCSSKeyword_UNKNOWN < keyword) {
    PRInt32 value;
    if (nsCSSProps::FindKeyword(keyword, aKeywordTable, value)) {
      aValue.SetIntValue(value, eCSSUnit_Enumerated);
      return PR_TRUE;
    }
  }

  // Put the unknown identifier back and return
  UngetToken();
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseFamily ( nsresult aErrorCode,
nsCSSValue aValue 
) [protected]

Definition at line 5521 of file nsCSSParser.cpp.

{
  nsCSSToken* tk = &mToken;
  nsAutoString family;
  PRBool firstOne = PR_TRUE;
  for (;;) {
    if (!GetToken(aErrorCode, PR_TRUE)) {
      break;
    }
    if (eCSSToken_Ident == tk->mType) {
      if (firstOne) {
        nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(tk->mIdent);
        if (keyword == eCSSKeyword_inherit) {
          aValue.SetInheritValue();
          return PR_TRUE;
        }
        else if (keyword == eCSSKeyword__moz_initial) {
          aValue.SetInitialValue();
          return PR_TRUE;
        }
      }
      else {
        family.Append(PRUnichar(','));
      }
      family.Append(tk->mIdent);
      for (;;) {
        if (!GetToken(aErrorCode, PR_FALSE)) {
          break;
        }
        if (eCSSToken_Ident == tk->mType) {
          family.Append(tk->mIdent);
        } else if (eCSSToken_WhiteSpace == tk->mType) {
          // Lookahead one token and drop whitespace if we ending the
          // font name.
          if (!GetToken(aErrorCode, PR_TRUE)) {
            break;
          }
          if (eCSSToken_Ident != tk->mType) {
            UngetToken();
            break;
          }
          UngetToken();
          family.Append(PRUnichar(' '));
        } else {
          UngetToken();
          break;
        }
      }
      firstOne = PR_FALSE;
    } else if (eCSSToken_String == tk->mType) {
      if (!firstOne) {
        family.Append(PRUnichar(','));
      }
      family.Append(tk->mSymbol); // replace the quotes
      family.Append(tk->mIdent); // XXX What if it had escaped quotes?
      family.Append(tk->mSymbol);
      firstOne = PR_FALSE;
    } else if (eCSSToken_Symbol == tk->mType) {
      if (',' != tk->mSymbol) {
        UngetToken();
        break;
      }
    } else {
      UngetToken();
      break;
    }
  }
  if (family.IsEmpty()) {
    return PR_FALSE;
  }
  aValue.SetStringValue(family, eCSSUnit_String);
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseFont ( nsresult aErrorCode) [protected]

Definition at line 5400 of file nsCSSParser.cpp.

{
  static const nsCSSProperty fontIDs[] = {
    eCSSProperty_font_style,
    eCSSProperty_font_variant,
    eCSSProperty_font_weight
  };

  nsCSSValue  family;
  if (ParseVariant(aErrorCode, family, VARIANT_HK, nsCSSProps::kFontKTable)) {
    if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
      if (eCSSUnit_Inherit == family.GetUnit()) {
        AppendValue(eCSSProperty_font_family, family);
        AppendValue(eCSSProperty_font_style, family);
        AppendValue(eCSSProperty_font_variant, family);
        AppendValue(eCSSProperty_font_weight, family);
        AppendValue(eCSSProperty_font_size, family);
        AppendValue(eCSSProperty_line_height, family);
        AppendValue(eCSSProperty_font_stretch, family);
        AppendValue(eCSSProperty_font_size_adjust, family);
      }
      else {
        AppendValue(eCSSProperty_font_family, family);  // keyword value overrides everything else
        nsCSSValue empty;
        // XXXbz this is actually _clearing_ the values for the following
        // properties in mTempData, but setting the bit for them.  We need that
        // because we want to clear out the values in mData when all is said
        // and done.  See the code in TransferTempData that handles this.  The
        // end result is that mData always has its property bits set like it
        // should, but mTempData can, in fact, have bits set for properties
        // that are not set...
        AppendValue(eCSSProperty_font_style, empty);
        AppendValue(eCSSProperty_font_variant, empty);
        AppendValue(eCSSProperty_font_weight, empty);
        AppendValue(eCSSProperty_font_size, empty);
        AppendValue(eCSSProperty_line_height, empty);
        AppendValue(eCSSProperty_font_stretch, empty);
        AppendValue(eCSSProperty_font_size_adjust, empty);
      }
      return PR_TRUE;
    }
    return PR_FALSE;
  }

  // Get optional font-style, font-variant and font-weight (in any order)
  const PRInt32 numProps = 3;
  nsCSSValue  values[numProps];
  PRInt32 found = ParseChoice(aErrorCode, values, fontIDs, numProps);
  if ((found < 0) || (eCSSUnit_Inherit == values[0].GetUnit()) || 
      (eCSSUnit_Initial == values[0].GetUnit())) { // illegal data
    return PR_FALSE;
  }
  if ((found & 1) == 0) {
    // Provide default font-style
    values[0].SetNormalValue();
  }
  if ((found & 2) == 0) {
    // Provide default font-variant
    values[1].SetNormalValue();
  }
  if ((found & 4) == 0) {
    // Provide default font-weight
    values[2].SetNormalValue();
  }

  // Get mandatory font-size
  nsCSSValue  size;
  if (! ParseVariant(aErrorCode, size, VARIANT_KEYWORD | VARIANT_LP, nsCSSProps::kFontSizeKTable)) {
    return PR_FALSE;
  }

  // Get optional "/" line-height
  nsCSSValue  lineHeight;
  if (ExpectSymbol(aErrorCode, '/', PR_TRUE)) {
    if (! ParsePositiveVariant(aErrorCode, lineHeight,
                               VARIANT_NUMBER | VARIANT_LP | VARIANT_NORMAL,
                               nsnull)) {
      return PR_FALSE;
    }
  }
  else {
    lineHeight.SetNormalValue();
  }

  // Get final mandatory font-family
  if (ParseFamily(aErrorCode, family)) {
    if ((eCSSUnit_Inherit != family.GetUnit()) && (eCSSUnit_Initial != family.GetUnit()) &&
        ExpectEndProperty(aErrorCode, PR_TRUE)) {
      AppendValue(eCSSProperty_font_family, family);
      AppendValue(eCSSProperty_font_style, values[0]);
      AppendValue(eCSSProperty_font_variant, values[1]);
      AppendValue(eCSSProperty_font_weight, values[2]);
      AppendValue(eCSSProperty_font_size, size);
      AppendValue(eCSSProperty_line_height, lineHeight);
      AppendValue(eCSSProperty_font_stretch, nsCSSValue(eCSSUnit_Normal));
      AppendValue(eCSSProperty_font_size_adjust, nsCSSValue(eCSSUnit_None));
      return PR_TRUE;
    }
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseFontFaceRule ( nsresult aErrorCode,
RuleAppendFunc  aAppendFunc,
void aProcessData 
) [protected]

Definition at line 1614 of file nsCSSParser.cpp.

{
  // XXX not yet implemented
  return PR_FALSE;
}

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseFontWeight ( nsresult aErrorCode,
nsCSSValue aValue 
) [protected]

Definition at line 5502 of file nsCSSParser.cpp.

{
  if (ParseVariant(aErrorCode, aValue, VARIANT_HMKI, nsCSSProps::kFontWeightKTable)) {
    if (eCSSUnit_Integer == aValue.GetUnit()) { // ensure unit value
      PRInt32 intValue = aValue.GetIntValue();
      if ((100 <= intValue) &&
          (intValue <= 900) &&
          (0 == (intValue % 100))) {
        return PR_TRUE;
      } else {
        UngetToken();
        return PR_FALSE;
      }
    }
    return PR_TRUE;
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseGroupRule ( nsresult aErrorCode,
nsICSSGroupRule aRule,
RuleAppendFunc  aAppendFunc,
void aProcessData 
) [protected]

Definition at line 1402 of file nsCSSParser.cpp.

{
  // XXXbz this could use better error reporting throughout the method
  if (!ExpectSymbol(aErrorCode, '{', PR_TRUE)) {
    return PR_FALSE;
  }

  // push rule on stack, loop over children
  if (!PushGroup(aRule)) {
    aErrorCode = NS_ERROR_OUT_OF_MEMORY;
    return PR_FALSE;
  }
  nsCSSSection holdSection = mSection;
  mSection = eCSSSection_General;

  for (;;) {
    // Get next non-whitespace token
    if (! GetToken(aErrorCode, PR_TRUE)) {
      REPORT_UNEXPECTED_EOF(PEGroupRuleEOF);
      break;
    }
    if (mToken.IsSymbol('}')) { // done!
      UngetToken();
      break;
    }
    if (eCSSToken_AtKeyword == mToken.mType) {
      SkipAtRule(aErrorCode); // group rules cannot contain @rules
      continue;
    }
    UngetToken();
    ParseRuleSet(aErrorCode, AppendRuleToSheet, this);
  }
  PopGroup();

  if (!ExpectSymbol(aErrorCode, '}', PR_TRUE)) {
    mSection = holdSection;
    return PR_FALSE;
  }
  (*aAppendFunc)(aRule, aData);
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseHSLColor ( nsresult aErrorCode,
nscolor aColor,
char  aStop 
) [protected]

Definition at line 2980 of file nsCSSParser.cpp.

{
  float h, s, l;
  if (!ExpectSymbol(aErrorCode, '(', PR_FALSE)) {
    NS_ERROR("How did this get to be a function token?");
    return PR_FALSE;
  }

  // Get the hue
  if (!GetToken(aErrorCode, PR_TRUE)) {
    REPORT_UNEXPECTED_EOF(PEColorHueEOF);
    return PR_FALSE;
  }
  if (mToken.mType != eCSSToken_Number) {
    REPORT_UNEXPECTED_TOKEN(PEExpectedNumber);
    UngetToken();
    return PR_FALSE;
  }
  h = mToken.mNumber;
  h /= 360.0f;
  // hue values are wraparound
  h = h - floor(h);
  
  if (!ExpectSymbol(aErrorCode, ',', PR_TRUE)) {
    REPORT_UNEXPECTED_TOKEN(PEExpectedComma);
    return PR_FALSE;
  }
  
  // Get the saturation
  if (!GetToken(aErrorCode, PR_TRUE)) {
    REPORT_UNEXPECTED_EOF(PEColorSaturationEOF);
    return PR_FALSE;
  }
  if (mToken.mType != eCSSToken_Percentage) {
    REPORT_UNEXPECTED_TOKEN(PEExpectedPercent);
    UngetToken();
    return PR_FALSE;
  }
  s = mToken.mNumber;
  if (s < 0.0f) s = 0.0f;
  if (s > 1.0f) s = 1.0f;
  
  if (!ExpectSymbol(aErrorCode, ',', PR_TRUE)) {
    REPORT_UNEXPECTED_TOKEN(PEExpectedComma);
    return PR_FALSE;
  }

  // Get the lightness
  if (!GetToken(aErrorCode, PR_TRUE)) {
    REPORT_UNEXPECTED_EOF(PEColorLightnessEOF);
    return PR_FALSE;
  }
  if (mToken.mType != eCSSToken_Percentage) {
    REPORT_UNEXPECTED_TOKEN(PEExpectedPercent);
    UngetToken();
    return PR_FALSE;
  }
  l = mToken.mNumber;
  if (l < 0.0f) l = 0.0f;
  if (l > 1.0f) l = 1.0f;
        
  if (ExpectSymbol(aErrorCode, aStop, PR_TRUE)) {
    aColor = NS_HSL2RGB(h, s, l);
    return PR_TRUE;
  }
  
  const PRUnichar stopString[] = { PRUnichar(aStop), PRUnichar(0) };
  const PRUnichar *params[] = {
    nsnull,
    stopString
  };
  REPORT_UNEXPECTED_TOKEN_P(PEColorComponentBadTerm, params);
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

CSSParserImpl::nsSelectorParsingStatus CSSParserImpl::ParseIDSelector ( PRInt32 aDataMask,
nsCSSSelector aSelector,
nsresult aErrorCode 
) [protected]

Definition at line 2000 of file nsCSSParser.cpp.

{
  NS_ASSERTION(!mToken.mIdent.IsEmpty(),
               "Empty mIdent in eCSSToken_ID token?");
  aDataMask |= SEL_MASK_ID;
  aSelector.AddID(mToken.mIdent);
  return eSelectorParsingStatus_Continue;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseImportRule ( nsresult aErrorCode,
RuleAppendFunc  aAppendFunc,
void aProcessData 
) [protected]

Definition at line 1342 of file nsCSSParser.cpp.

{
  nsCOMPtr<nsMediaList> media = new nsMediaList();
  if (!media) {
    aErrorCode = NS_ERROR_OUT_OF_MEMORY;
    return PR_FALSE;
  }

  nsAutoString url;
  if (!GatherURL(aErrorCode, url)) {
    REPORT_UNEXPECTED_TOKEN(PEImportNotURI);
    return PR_FALSE;
  }
  
  if (!ExpectSymbol(aErrorCode, ';', PR_TRUE)) {
    if (!GatherMedia(aErrorCode, media, ';') ||
        !ExpectSymbol(aErrorCode, ';', PR_TRUE)) {
      REPORT_UNEXPECTED_TOKEN(PEImportUnexpected);
      // don't advance section, simply ignore invalid @import
      return PR_FALSE;
    }
    NS_ASSERTION(media->Count() != 0, "media list must be nonempty");
  }

  ProcessImport(aErrorCode, url, media, aAppendFunc, aData);
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2639 of file nsCSSParser.cpp.

{
  // Check if we have the first parenthesis
  if (!ExpectSymbol(aErrorCode, '(', PR_FALSE)) {
    REPORT_UNEXPECTED_TOKEN(PELangNoArg);
    return eSelectorParsingStatus_Error;
  }

  if (! GetToken(aErrorCode, PR_TRUE)) { // premature eof
    REPORT_UNEXPECTED_EOF(PELangArgEOF);
    return eSelectorParsingStatus_Error;
  }
  // We expect an identifier with a language abbreviation
  if (eCSSToken_Ident != mToken.mType) {
    REPORT_UNEXPECTED_TOKEN(PELangArgNotIdent);
    UngetToken();
    return eSelectorParsingStatus_Error;
  }

  // Add the pseudo with the language parameter
  aSelector.AddPseudoClass(nsCSSPseudoClasses::lang, mToken.mIdent.get());

  // close the parenthesis
  if (!ExpectSymbol(aErrorCode, ')', PR_TRUE)) {
    REPORT_UNEXPECTED_TOKEN(PELangNoClose);
    return eSelectorParsingStatus_Error;
  }

  return eSelectorParsingStatus_Continue;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseListStyle ( nsresult aErrorCode) [protected]

Definition at line 5595 of file nsCSSParser.cpp.

{
  const PRInt32 numProps = 3;
  static const nsCSSProperty listStyleIDs[] = {
    eCSSProperty_list_style_type,
    eCSSProperty_list_style_position,
    eCSSProperty_list_style_image
  };

  nsCSSValue  values[numProps];
  PRInt32 index;
  PRInt32 found = ParseChoice(aErrorCode, values, listStyleIDs, numProps);
  if ((found < 1) || (PR_FALSE == ExpectEndProperty(aErrorCode, PR_TRUE))) {
    return PR_FALSE;
  }

  // Provide default values
  if ((found & 1) == 0) {
    values[0].SetIntValue(NS_STYLE_LIST_STYLE_DISC, eCSSUnit_Enumerated);
  }
  if ((found & 2) == 0) {
    values[1].SetIntValue(NS_STYLE_LIST_STYLE_POSITION_OUTSIDE, eCSSUnit_Enumerated);
  }
  if ((found & 4) == 0) {
    values[2].SetNoneValue();
  }

  for (index = 0; index < numProps; index++) {
    AppendValue(listStyleIDs[index], values[index]);
  }
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseMargin ( nsresult aErrorCode) [protected]

Definition at line 5628 of file nsCSSParser.cpp.

{
  static const nsCSSProperty kMarginSideIDs[] = {
    eCSSProperty_margin_top,
    eCSSProperty_margin_right_value,
    eCSSProperty_margin_bottom,
    eCSSProperty_margin_left_value
  };
  // do this now, in case 4 values weren't specified
  mTempData.SetPropertyBit(eCSSProperty_margin_left_ltr_source);
  mTempData.SetPropertyBit(eCSSProperty_margin_left_rtl_source);
  mTempData.SetPropertyBit(eCSSProperty_margin_right_ltr_source);
  mTempData.SetPropertyBit(eCSSProperty_margin_right_rtl_source);
  mTempData.mMargin.mMarginLeftLTRSource.SetIntValue(NS_BOXPROP_SOURCE_PHYSICAL, eCSSUnit_Enumerated);
  mTempData.mMargin.mMarginLeftRTLSource.SetIntValue(NS_BOXPROP_SOURCE_PHYSICAL, eCSSUnit_Enumerated);
  mTempData.mMargin.mMarginRightLTRSource.SetIntValue(NS_BOXPROP_SOURCE_PHYSICAL, eCSSUnit_Enumerated);
  mTempData.mMargin.mMarginRightRTLSource.SetIntValue(NS_BOXPROP_SOURCE_PHYSICAL, eCSSUnit_Enumerated);
  return ParseBoxProperties(aErrorCode, mTempData.mMargin.mMargin,
                            kMarginSideIDs);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseMarks ( nsresult aErrorCode,
nsCSSValue aValue 
) [protected]

Definition at line 5649 of file nsCSSParser.cpp.

{
  if (ParseVariant(aErrorCode, aValue, VARIANT_HOK, nsCSSProps::kPageMarksKTable)) {
    if (eCSSUnit_Enumerated == aValue.GetUnit()) {
      if (PR_FALSE == ExpectEndProperty(aErrorCode, PR_TRUE)) {
        nsCSSValue  second;
        if (ParseEnum(aErrorCode, second, nsCSSProps::kPageMarksKTable)) {
          aValue.SetIntValue(aValue.GetIntValue() | second.GetIntValue(), eCSSUnit_Enumerated);
          return PR_TRUE;
        }
        return PR_FALSE;
      }
    }
    return PR_TRUE;
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP CSSParserImpl::ParseMediaList ( const nsSubstring aBuffer,
nsIURI aURL,
PRUint32  aLineNumber,
nsMediaList aMediaList,
PRBool  aHTMLMode 
) [virtual]

Parse aBuffer into a media list |aMediaList|, which must be non-null, replacing its current contents.

If aHTMLMode is true, parse according to HTML rules, with commas as the most important delimiter. Otherwise, parse according to CSS rules, with parentheses and strings more important than commas.

Implements nsICSSParser.

Definition at line 950 of file nsCSSParser.cpp.

{
  aMediaList->Clear();
  nsresult rv = NS_OK;

  if (aHTMLMode) {
    mHTMLMediaMode = PR_TRUE;

    // XXXldb We need to make the scanner not skip CSS comments!  (Or
    // should we?)

    // Follow the parsing rules in 
    // http://www.w3.org/TR/1999/REC-html401-19991224/types.html#type-media-descriptors

    for (PRUint32 sub = 0, sub_end; sub < aBuffer.Length(); sub = sub_end + 1) {
      sub_end = aBuffer.FindChar(PRUnichar(','), sub);
      if (sub_end == PRUint32(kNotFound))
        sub_end = aBuffer.Length();

      PRUint32 parse_start, parse_end;
      for (parse_start = sub;
           parse_start < sub_end && nsCRT::IsAsciiSpace(aBuffer[parse_start]);
           ++parse_start)
        ;

      for (parse_end = parse_start;
           parse_end < sub_end &&
           (nsCRT::IsAsciiAlpha(aBuffer[parse_end]) ||
            nsCRT::IsAsciiDigit(aBuffer[parse_end]) ||
            aBuffer[parse_end] == PRUnichar('-'));
           ++parse_end)
        ;

      DoParseMediaList(Substring(aBuffer, parse_start, parse_end - parse_start),
                       aURL, aLineNumber, aMediaList);
    }

    mHTMLMediaMode = PR_FALSE;
  } else {
    rv = DoParseMediaList(aBuffer, aURL, aLineNumber, aMediaList);
  }

  return rv;
}

Here is the call graph for this function:

PRBool CSSParserImpl::ParseMediaRule ( nsresult aErrorCode,
RuleAppendFunc  aAppendFunc,
void aProcessData 
) [protected]

Definition at line 1448 of file nsCSSParser.cpp.

{
  nsCOMPtr<nsMediaList> media = new nsMediaList();
  if (!media) {
    aErrorCode = NS_ERROR_OUT_OF_MEMORY;
    return PR_FALSE;
  }

  if (GatherMedia(aErrorCode, media, '{')) {
    NS_ASSERTION(media->Count() != 0, "media list must be nonempty");
    // XXXbz this could use better error reporting throughout the method
    nsRefPtr<nsCSSMediaRule> rule(new nsCSSMediaRule());
    // Append first, so when we do SetMedia() the rule
    // knows what its stylesheet is.
    if (rule && ParseGroupRule(aErrorCode, rule, aAppendFunc, aData)) {
      rule->SetMedia(media);
      return PR_TRUE;
    }
  }

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseMozDocumentRule ( nsresult aErrorCode,
RuleAppendFunc  aAppendFunc,
void aProcessData 
) [protected]

Definition at line 1476 of file nsCSSParser.cpp.

{
  nsCSSDocumentRule::URL *urls = nsnull;
  nsCSSDocumentRule::URL **next = &urls;
  do {
    if (!GetToken(aErrorCode, PR_TRUE) ||
        eCSSToken_Function != mToken.mType ||
        !(mToken.mIdent.LowerCaseEqualsLiteral("url") ||
          mToken.mIdent.LowerCaseEqualsLiteral("url-prefix") ||
          mToken.mIdent.LowerCaseEqualsLiteral("domain"))) {
      REPORT_UNEXPECTED_TOKEN(PEMozDocRuleBadFunc);
      delete urls;
      return PR_FALSE;
    }
    nsCSSDocumentRule::URL *cur = *next = new nsCSSDocumentRule::URL;
    if (!cur) {
      aErrorCode = NS_ERROR_OUT_OF_MEMORY;
      delete urls;
      return PR_FALSE;
    }
    next = &cur->next;
    if (mToken.mIdent.LowerCaseEqualsLiteral("url")) {
      cur->func = nsCSSDocumentRule::eURL;
    } else if (mToken.mIdent.LowerCaseEqualsLiteral("url-prefix")) {
      cur->func = nsCSSDocumentRule::eURLPrefix;
    } else if (mToken.mIdent.LowerCaseEqualsLiteral("domain")) {
      cur->func = nsCSSDocumentRule::eDomain;
    }

    if (!ExpectSymbol(aErrorCode, '(', PR_FALSE) ||
        !GetURLToken(aErrorCode, PR_TRUE) ||
        (eCSSToken_String != mToken.mType &&
         eCSSToken_URL != mToken.mType)) {
      REPORT_UNEXPECTED_TOKEN(PEMozDocRuleNotURI);
      delete urls;
      return PR_FALSE;
    }
    if (!ExpectSymbol(aErrorCode, ')', PR_TRUE)) {
      delete urls;
      return PR_FALSE;
    }

    // We could try to make the URL (as long as it's not domain())
    // canonical and absolute with NS_NewURI and GetSpec, but I'm
    // inclined to think we shouldn't.
    CopyUTF16toUTF8(mToken.mIdent, cur->url);
  } while (ExpectSymbol(aErrorCode, ',', PR_TRUE));

  nsRefPtr<nsCSSDocumentRule> rule(new nsCSSDocumentRule());
  if (!rule) {
    aErrorCode = NS_ERROR_OUT_OF_MEMORY;
    delete urls;
    return PR_FALSE;
  }
  rule->SetURLs(urls);

  return ParseGroupRule(aErrorCode, rule, aAppendFunc, aData);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseNameSpaceRule ( nsresult aErrorCode,
RuleAppendFunc  aAppendFunc,
void aProcessData 
) [protected]

Definition at line 1538 of file nsCSSParser.cpp.

{
  if (!GetToken(aErrorCode, PR_TRUE)) {
    REPORT_UNEXPECTED_EOF(PEAtNSPrefixEOF);
    return PR_FALSE;
  }

  nsAutoString  prefix;
  nsAutoString  url;

  if (eCSSToken_Ident == mToken.mType) {
    prefix = mToken.mIdent;
    ToLowerCase(prefix); // always case insensitive, since stays within CSS
    if (! GetToken(aErrorCode, PR_TRUE)) {
      REPORT_UNEXPECTED_EOF(PEAtNSURIEOF);
      return PR_FALSE;
    }
  }

  if (eCSSToken_String == mToken.mType) {
    url = mToken.mIdent;
    if (ExpectSymbol(aErrorCode, ';', PR_TRUE)) {
      ProcessNameSpace(aErrorCode, prefix, url, aAppendFunc, aData);
      return PR_TRUE;
    }
  }
  else if ((eCSSToken_Function == mToken.mType) && 
           (mToken.mIdent.LowerCaseEqualsLiteral("url"))) {
    if (ExpectSymbol(aErrorCode, '(', PR_FALSE)) {
      if (GetURLToken(aErrorCode, PR_TRUE)) {
        if ((eCSSToken_String == mToken.mType) || (eCSSToken_URL == mToken.mType)) {
          url = mToken.mIdent;
          if (ExpectSymbol(aErrorCode, ')', PR_TRUE)) {
            if (ExpectSymbol(aErrorCode, ';', PR_TRUE)) {
              ProcessNameSpace(aErrorCode, prefix, url, aAppendFunc, aData);
              return PR_TRUE;
            }
          }
        }
      }
    }
  }
  REPORT_UNEXPECTED_TOKEN(PEAtNSUnexpected);

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2570 of file nsCSSParser.cpp.

{
  // Check if we have the first parenthesis
  if (!ExpectSymbol(aErrorCode, '(', PR_FALSE)) {
    REPORT_UNEXPECTED_TOKEN(PENegationBadArg);
    return eSelectorParsingStatus_Error;
  }

  if (! GetToken(aErrorCode, PR_TRUE)) { // premature eof
    REPORT_UNEXPECTED_EOF(PENegationEOF);
    return eSelectorParsingStatus_Error;
  }
  if (!aSelector.mNegations) {
    aSelector.mNegations = new nsCSSSelector();
    if (!aSelector.mNegations) {
      aErrorCode = NS_ERROR_OUT_OF_MEMORY;
      return eSelectorParsingStatus_Error;
    }
  }
  // ID, class and attribute selectors and pseudo-classes are stored in
  // the first mNegations attached to a selector
  nsSelectorParsingStatus parsingStatus;
  if (eCSSToken_ID == mToken.mType) { // #id
    parsingStatus = ParseIDSelector(aDataMask, *aSelector.mNegations, aErrorCode);
  }
  else if (mToken.IsSymbol('.')) {    // .class
    parsingStatus = ParseClassSelector(aDataMask, *aSelector.mNegations, aErrorCode);
  }
  else if (mToken.IsSymbol(':')) {    // :pseudo
    parsingStatus = ParsePseudoSelector(aDataMask, *aSelector.mNegations, aErrorCode, PR_TRUE);
  }
  else if (mToken.IsSymbol('[')) {    // [attribute
    parsingStatus = ParseAttributeSelector(aDataMask, *aSelector.mNegations, aErrorCode);
  }
  else {
    // then it should be a type element or universal selector
    nsCSSSelector *newSel = new nsCSSSelector();
    if (!newSel) {
      aErrorCode = NS_ERROR_OUT_OF_MEMORY;
      return eSelectorParsingStatus_Error;
    }
    nsCSSSelector* negations = aSelector.mNegations;
    while (nsnull != negations->mNegations) {
      negations = negations->mNegations;
    }
    // negated type element selectors and universal selectors are stored after the first
    // mNegations containing only negated IDs, classes, attributes and pseudo-classes
    negations->mNegations = newSel;
    parsingStatus = ParseTypeOrUniversalSelector(aDataMask, *newSel, aErrorCode, PR_TRUE);
  }
  if (eSelectorParsingStatus_Error == parsingStatus) {
    REPORT_UNEXPECTED_TOKEN(PENegationBadInner);
    return parsingStatus;
  }
  // close the parenthesis
  if (!ExpectSymbol(aErrorCode, ')', PR_TRUE)) {
    REPORT_UNEXPECTED_TOKEN(PENegationNoClose);
    return eSelectorParsingStatus_Error;
  }

  return eSelectorParsingStatus_Continue;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseOutline ( nsresult aErrorCode) [protected]

Definition at line 5667 of file nsCSSParser.cpp.

{
  const PRInt32 numProps = 3;
  static const nsCSSProperty kOutlineIDs[] = {
    eCSSProperty_outline_color,
    eCSSProperty_outline_style,
    eCSSProperty_outline_width
  };

  nsCSSValue  values[numProps];
  PRInt32 found = ParseChoice(aErrorCode, values, kOutlineIDs, numProps);
  if ((found < 1) || (PR_FALSE == ExpectEndProperty(aErrorCode, PR_TRUE))) {
    return PR_FALSE;
  }

  // Provide default values
  if ((found & 1) == 0) {
    values[0].SetIntValue(NS_STYLE_COLOR_INVERT, eCSSUnit_Enumerated);
  }
  if ((found & 2) == 0) {
    values[1].SetNoneValue();
  }
  if ((found & 4) == 0) {
    values[2].SetIntValue(NS_STYLE_BORDER_WIDTH_MEDIUM, eCSSUnit_Enumerated);
  }

  PRInt32 index;
  for (index = 0; index < numProps; index++) {
    AppendValue(kOutlineIDs[index], values[index]);
  }
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseOutlineRadius ( nsresult aErrorCode) [protected]

Definition at line 5091 of file nsCSSParser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseOverflow ( nsresult aErrorCode) [protected]

Definition at line 5700 of file nsCSSParser.cpp.

{
  nsCSSValue overflow;
  if (!ParseVariant(aErrorCode, overflow, VARIANT_AHK,
                   nsCSSProps::kOverflowKTable) ||
      !ExpectEndProperty(aErrorCode, PR_TRUE))
    return PR_FALSE;

  nsCSSValue overflowX(overflow);
  nsCSSValue overflowY(overflow);
  if (eCSSUnit_Enumerated == overflow.GetUnit())
    switch(overflow.GetIntValue()) {
      case NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL:
        overflowX.SetIntValue(NS_STYLE_OVERFLOW_SCROLL, eCSSUnit_Enumerated);
        overflowY.SetIntValue(NS_STYLE_OVERFLOW_HIDDEN, eCSSUnit_Enumerated);
        break;
      case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL:
        overflowX.SetIntValue(NS_STYLE_OVERFLOW_HIDDEN, eCSSUnit_Enumerated);
        overflowY.SetIntValue(NS_STYLE_OVERFLOW_SCROLL, eCSSUnit_Enumerated);
        break;
    }
  AppendValue(eCSSProperty_overflow_x, overflowX);
  AppendValue(eCSSProperty_overflow_y, overflowY);
  aErrorCode = NS_OK;
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParsePadding ( nsresult aErrorCode) [protected]

Definition at line 5727 of file nsCSSParser.cpp.

{
  static const nsCSSProperty kPaddingSideIDs[] = {
    eCSSProperty_padding_top,
    eCSSProperty_padding_right_value,
    eCSSProperty_padding_bottom,
    eCSSProperty_padding_left_value
  };
  // do this now, in case 4 values weren't specified
  mTempData.SetPropertyBit(eCSSProperty_padding_left_ltr_source);
  mTempData.SetPropertyBit(eCSSProperty_padding_left_rtl_source);
  mTempData.SetPropertyBit(eCSSProperty_padding_right_ltr_source);
  mTempData.SetPropertyBit(eCSSProperty_padding_right_rtl_source);
  mTempData.mMargin.mPaddingLeftLTRSource.SetIntValue(NS_BOXPROP_SOURCE_PHYSICAL, eCSSUnit_Enumerated);
  mTempData.mMargin.mPaddingLeftRTLSource.SetIntValue(NS_BOXPROP_SOURCE_PHYSICAL, eCSSUnit_Enumerated);
  mTempData.mMargin.mPaddingRightLTRSource.SetIntValue(NS_BOXPROP_SOURCE_PHYSICAL, eCSSUnit_Enumerated);
  mTempData.mMargin.mPaddingRightRTLSource.SetIntValue(NS_BOXPROP_SOURCE_PHYSICAL, eCSSUnit_Enumerated);
  return ParseBoxProperties(aErrorCode, mTempData.mMargin.mPadding,
                            kPaddingSideIDs);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParsePageRule ( nsresult aErrorCode,
RuleAppendFunc  aAppendFunc,
void aProcessData 
) [protected]

Definition at line 1620 of file nsCSSParser.cpp.

{
  // XXX not yet implemented
  return PR_FALSE;
}

Here is the caller graph for this function:

PRBool CSSParserImpl::ParsePause ( nsresult aErrorCode) [protected]

Definition at line 5748 of file nsCSSParser.cpp.

{
  nsCSSValue  before;
  if (ParseSingleValueProperty(aErrorCode, before, eCSSProperty_pause_before)) {
    if (eCSSUnit_Inherit != before.GetUnit() && eCSSUnit_Initial != before.GetUnit()) {
      nsCSSValue after;
      if (ParseSingleValueProperty(aErrorCode, after, eCSSProperty_pause_after)) {
        if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
          AppendValue(eCSSProperty_pause_before, before);
          AppendValue(eCSSProperty_pause_after, after);
          return PR_TRUE;
        }
        return PR_FALSE;
      }
    }
    if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
      AppendValue(eCSSProperty_pause_before, before);
      AppendValue(eCSSProperty_pause_after, before);
      return PR_TRUE;
    }
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParsePositiveVariant ( nsresult aErrorCode,
nsCSSValue aValue,
PRInt32  aVariantMask,
const PRInt32  aKeywordTable[] 
) [protected]

Definition at line 3576 of file nsCSSParser.cpp.

{ 
  if (ParseVariant(aErrorCode, aValue, aVariantMask, aKeywordTable)) { 
    if (eCSSUnit_Number == aValue.GetUnit() || 
        aValue.IsLengthUnit()){ 
      if (aValue.GetFloatValue() < 0) { 
        UngetToken();
        return PR_FALSE; 
      } 
    } 
    else if(aValue.GetUnit() == eCSSUnit_Percent) { 
      if (aValue.GetPercentValue() < 0) { 
        UngetToken();
        return PR_FALSE; 
      } 
    } 
    return PR_TRUE; 
  } 
  return PR_FALSE; 
} 

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP CSSParserImpl::ParseProperty ( const nsCSSProperty  aPropID,
const nsAString &  aPropValue,
nsIURI aSheetURL,
nsIURI aBaseURL,
nsCSSDeclaration aDeclaration,
PRBool aChanged 
) [virtual]

important" as the aPropValue. It will parse the "foo" and set it

Implements nsICSSParser.

Definition at line 892 of file nsCSSParser.cpp.

{
  NS_ASSERTION(nsnull != aBaseURL, "need base URL");
  NS_ASSERTION(nsnull != aDeclaration, "Need declaration to parse into!");
  *aChanged = PR_FALSE;

  nsresult rv = InitScanner(aPropValue, aSheetURL, 0, aBaseURL);
  if (NS_FAILED(rv)) {
    return rv;
  }

  mSection = eCSSSection_General;
  nsresult errorCode = NS_OK;

  if (eCSSProperty_UNKNOWN == aPropID) { // unknown property
    NS_ConvertASCIItoUTF16 propName(nsCSSProps::GetStringValue(aPropID));
    const PRUnichar *params[] = {
      propName.get()
    };
    REPORT_UNEXPECTED_P(PEUnknownProperty, params);
    REPORT_UNEXPECTED(PEDeclDropped);
    OUTPUT_ERROR();
    ReleaseScanner();
    return NS_OK;
  }
  
  mData.AssertInitialState();
  mTempData.AssertInitialState();
  aDeclaration->ExpandTo(&mData);
  nsresult result = NS_OK;
  if (ParseProperty(errorCode, aPropID)) {
    TransferTempData(aDeclaration, aPropID, PR_FALSE, PR_FALSE, aChanged);
  } else {
    NS_ConvertASCIItoUTF16 propName(nsCSSProps::GetStringValue(aPropID));
    const PRUnichar *params[] = {
      propName.get()
    };
    REPORT_UNEXPECTED_P(PEPropertyParsingError, params);
    REPORT_UNEXPECTED(PEDeclDropped);
    OUTPUT_ERROR();
    ClearTempData(aPropID);
    NS_ASSERTION(errorCode != nsresult(-1), "-1 is no longer used for EOF");
    result = errorCode;
  }
  CLEAR_ERROR();
  
  aDeclaration->CompressFrom(&mData);
  
  ReleaseScanner();
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseProperty ( nsresult aErrorCode,
nsCSSProperty  aPropID 
) [protected]

Definition at line 4083 of file nsCSSParser.cpp.

{
  switch (aPropID) {  // handle shorthand or multiple properties
  case eCSSProperty_background:
    return ParseBackground(aErrorCode);
  case eCSSProperty_background_position:
    return ParseBackgroundPosition(aErrorCode);
  case eCSSProperty_border:
    return ParseBorderSide(aErrorCode, kBorderTopIDs, PR_TRUE);
  case eCSSProperty_border_color:
    return ParseBorderColor(aErrorCode);
  case eCSSProperty_border_spacing:
    return ParseBorderSpacing(aErrorCode);
  case eCSSProperty_border_style:
    return ParseBorderStyle(aErrorCode);
  case eCSSProperty_border_bottom:
    return ParseBorderSide(aErrorCode, kBorderBottomIDs, PR_FALSE);
  case eCSSProperty_border_left:
    return ParseBorderSide(aErrorCode, kBorderLeftIDs, PR_FALSE);
  case eCSSProperty_border_right:
    return ParseBorderSide(aErrorCode, kBorderRightIDs, PR_FALSE);
  case eCSSProperty_border_top:
    return ParseBorderSide(aErrorCode, kBorderTopIDs, PR_FALSE);
  case eCSSProperty_border_bottom_colors:
    return ParseBorderColors(aErrorCode,
                             &mTempData.mMargin.mBorderColors.mBottom,
                             aPropID);
  case eCSSProperty_border_left_colors:
    return ParseBorderColors(aErrorCode,
                             &mTempData.mMargin.mBorderColors.mLeft,
                             aPropID);
  case eCSSProperty_border_right_colors:
    return ParseBorderColors(aErrorCode,
                             &mTempData.mMargin.mBorderColors.mRight,
                             aPropID);
  case eCSSProperty_border_top_colors:
    return ParseBorderColors(aErrorCode,
                             &mTempData.mMargin.mBorderColors.mTop,
                             aPropID);
  case eCSSProperty_border_width:
    return ParseBorderWidth(aErrorCode);
  case eCSSProperty__moz_border_radius:
    return ParseBorderRadius(aErrorCode);
  case eCSSProperty__moz_outline_radius:
    return ParseOutlineRadius(aErrorCode);
  case eCSSProperty_clip:
    return ParseRect(mTempData.mDisplay.mClip, aErrorCode,
                     eCSSProperty_clip);
  case eCSSProperty_content:
    return ParseContent(aErrorCode);
  case eCSSProperty_counter_increment:
    return ParseCounterData(aErrorCode, &mTempData.mContent.mCounterIncrement,
                            aPropID);
  case eCSSProperty_counter_reset:
    return ParseCounterData(aErrorCode, &mTempData.mContent.mCounterReset,
                            aPropID);
  case eCSSProperty_cue:
    return ParseCue(aErrorCode);
  case eCSSProperty_cursor:
    return ParseCursor(aErrorCode);
  case eCSSProperty_font:
    return ParseFont(aErrorCode);
  case eCSSProperty_image_region:
    return ParseRect(mTempData.mList.mImageRegion, aErrorCode,
                     eCSSProperty_image_region);
  case eCSSProperty_list_style:
    return ParseListStyle(aErrorCode);
  case eCSSProperty_margin:
    return ParseMargin(aErrorCode);
  case eCSSProperty_margin_end:
    return ParseDirectionalBoxProperty(aErrorCode, eCSSProperty_margin_end,
                                       NS_BOXPROP_SOURCE_LOGICAL);
  case eCSSProperty_margin_left:
    return ParseDirectionalBoxProperty(aErrorCode, eCSSProperty_margin_left,
                                       NS_BOXPROP_SOURCE_PHYSICAL);
  case eCSSProperty_margin_right:
    return ParseDirectionalBoxProperty(aErrorCode, eCSSProperty_margin_right,
                                       NS_BOXPROP_SOURCE_PHYSICAL);
  case eCSSProperty_margin_start:
    return ParseDirectionalBoxProperty(aErrorCode, eCSSProperty_margin_start,
                                       NS_BOXPROP_SOURCE_LOGICAL);
  case eCSSProperty_outline:
    return ParseOutline(aErrorCode);
  case eCSSProperty_overflow:
    return ParseOverflow(aErrorCode);
  case eCSSProperty_padding:
    return ParsePadding(aErrorCode);
  case eCSSProperty_padding_end:
    return ParseDirectionalBoxProperty(aErrorCode, eCSSProperty_padding_end,
                                       NS_BOXPROP_SOURCE_LOGICAL);
  case eCSSProperty_padding_left:
    return ParseDirectionalBoxProperty(aErrorCode, eCSSProperty_padding_left,
                                       NS_BOXPROP_SOURCE_PHYSICAL);
  case eCSSProperty_padding_right:
    return ParseDirectionalBoxProperty(aErrorCode, eCSSProperty_padding_right,
                                       NS_BOXPROP_SOURCE_PHYSICAL);
  case eCSSProperty_padding_start:
    return ParseDirectionalBoxProperty(aErrorCode, eCSSProperty_padding_start,
                                       NS_BOXPROP_SOURCE_LOGICAL);
  case eCSSProperty_pause:
    return ParsePause(aErrorCode);
  case eCSSProperty_quotes:
    return ParseQuotes(aErrorCode);
  case eCSSProperty_size:
    return ParseSize(aErrorCode);
  case eCSSProperty_text_shadow:
    return ParseTextShadow(aErrorCode);

#ifdef MOZ_SVG
  case eCSSProperty_stroke_dasharray:
    return ParseDasharray(aErrorCode);
  case eCSSProperty_marker:
    return ParseMarker(aErrorCode);
#endif

  // Strip out properties we use internally. These properties are used
  // by compound property parsing routines (e.g. "background-position").
  case eCSSProperty_background_x_position:
  case eCSSProperty_background_y_position:
  case eCSSProperty_margin_end_value:
  case eCSSProperty_margin_left_value:
  case eCSSProperty_margin_right_value:
  case eCSSProperty_margin_start_value:
  case eCSSProperty_margin_left_ltr_source:
  case eCSSProperty_margin_left_rtl_source:
  case eCSSProperty_margin_right_ltr_source:
  case eCSSProperty_margin_right_rtl_source:
  case eCSSProperty_padding_end_value:
  case eCSSProperty_padding_left_value:
  case eCSSProperty_padding_right_value:
  case eCSSProperty_padding_start_value:
  case eCSSProperty_padding_left_ltr_source:
  case eCSSProperty_padding_left_rtl_source:
  case eCSSProperty_padding_right_ltr_source:
  case eCSSProperty_padding_right_rtl_source:
    // The user can't use these
    REPORT_UNEXPECTED(PEInaccessibleProperty);
    return PR_FALSE;

  default:  // must be single property
    {
      nsCSSValue value;
      if (ParseSingleValueProperty(aErrorCode, value, aPropID)) {
        if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
          AppendValue(aPropID, value);
          aErrorCode = NS_OK;
          return PR_TRUE;
        }
        // XXX Report errors?
      }
      // XXX Report errors?
    }
  }
  return PR_FALSE;
}

Here is the call graph for this function:

CSSParserImpl::nsSelectorParsingStatus CSSParserImpl::ParsePseudoSelector ( PRInt32 aDataMask,
nsCSSSelector aSelector,
nsresult aErrorCode,
PRBool  aIsNegated 
) [protected]

Definition at line 2395 of file nsCSSParser.cpp.

{
  if (! GetToken(aErrorCode, PR_FALSE)) { // premature eof
    REPORT_UNEXPECTED_EOF(PEPseudoSelEOF);
    return eSelectorParsingStatus_Error;
  }

  // First, find out whether we are parsing a CSS3 pseudo-element
  PRBool parsingPseudoElement = PR_FALSE;
  if (mToken.IsSymbol(':')) {
    parsingPseudoElement = PR_TRUE;
    if (! GetToken(aErrorCode, PR_FALSE)) { // premature eof
      REPORT_UNEXPECTED_EOF(PEPseudoSelEOF);
      return eSelectorParsingStatus_Error;
    }
  }

  // Do some sanity-checking on the token
  if (eCSSToken_Ident != mToken.mType && eCSSToken_Function != mToken.mType) {
    // malformed selector
    REPORT_UNEXPECTED_TOKEN(PEPseudoSelBadName);
    UngetToken();
    return eSelectorParsingStatus_Error;
  }

  // OK, now we know we have an mIdent.  Atomize it.  All the atoms, for
  // pseudo-classes as well as pseudo-elements, start with a single ':'.
  nsAutoString buffer;
  buffer.Append(PRUnichar(':'));
  buffer.Append(mToken.mIdent);
  ToLowerCase(buffer);
  nsCOMPtr<nsIAtom> pseudo = do_GetAtom(buffer);

  // stash away some info about this pseudo so we only have to get it once.
  PRBool isTreePseudo = PR_FALSE;
#ifdef MOZ_XUL
  isTreePseudo = IsTreePseudoElement(pseudo);
  // If a tree pseudo-element is using the function syntax, it will
  // get isTree set here and will pass the check below that only
  // allows functions if they are in our list of things allowed to be
  // functions.  If it is _not_ using the function syntax, isTree will
  // be false, and it will still pass that check.  So the tree
  // pseudo-elements are allowed to be either functions or not, as
  // desired.
  PRBool isTree = (eCSSToken_Function == mToken.mType) &&
                  IsTreePseudoElement(pseudo);
#endif
  PRBool isPseudoElement = nsCSSPseudoElements::IsPseudoElement(pseudo);
  // anonymous boxes are only allowed if they're the tree boxes or we have
  // enabled unsafe rules
  PRBool isAnonBox = nsCSSAnonBoxes::IsAnonBox(pseudo) &&
    (mUnsafeRulesEnabled || isTreePseudo);

  // If it's a function token, it better be on our "ok" list, and if the name
  // is that of a function pseudo it better be a function token
  if ((eCSSToken_Function == mToken.mType) !=
      (
#ifdef MOZ_XUL
       isTree ||
#endif
       nsCSSPseudoClasses::notPseudo == pseudo ||
       nsCSSPseudoClasses::lang == pseudo)) { // There are no other function pseudos
    REPORT_UNEXPECTED_TOKEN(PEPseudoSelNonFunc);
    UngetToken();
    return eSelectorParsingStatus_Error;
  }
  
  // If it starts with "::", it better be a pseudo-element
  if (parsingPseudoElement &&
      !isPseudoElement &&
      !isAnonBox) {
    REPORT_UNEXPECTED_TOKEN(PEPseudoSelNotPE);
    UngetToken();
    return eSelectorParsingStatus_Error;
  }

  if (nsCSSPseudoClasses::notPseudo == pseudo) {
    if (aIsNegated) { // :not() can't be itself negated
      REPORT_UNEXPECTED_TOKEN(PEPseudoSelDoubleNot);
      UngetToken();
      return eSelectorParsingStatus_Error;
    }
    // CSS 3 Negation pseudo-class takes one simple selector as argument
    nsSelectorParsingStatus parsingStatus =
      ParseNegatedSimpleSelector(aDataMask, aSelector, aErrorCode);
    if (eSelectorParsingStatus_Continue != parsingStatus) {
      return parsingStatus;
    }
  }    
  else if (!parsingPseudoElement &&
           nsCSSPseudoClasses::IsPseudoClass(pseudo)) {
    aDataMask |= SEL_MASK_PCLASS;
    if (nsCSSPseudoClasses::lang == pseudo) {
      nsSelectorParsingStatus parsingStatus = ParseLangSelector(aSelector, aErrorCode);
      if (eSelectorParsingStatus_Continue != parsingStatus) {
        return parsingStatus;
      }
    }
    // XXX are there more pseudo classes which accept arguments ?
    else {
      aSelector.AddPseudoClass(pseudo);
    }
  }
  else if (isPseudoElement || isAnonBox) {
    // Pseudo-element.  Make some more sanity checks.
    
    if (aIsNegated) { // pseudo-elements can't be negated
      REPORT_UNEXPECTED_TOKEN(PEPseudoSelPEInNot);
      UngetToken();
      return eSelectorParsingStatus_Error;
    }
    // CSS2 pseudo-elements and -moz-tree-* pseudo-elements are allowed
    // to have a single ':' on them.  Others (CSS3+ pseudo-elements and
    // various -moz-* pseudo-elements) must have |parsingPseudoElement|
    // set.
    if (!parsingPseudoElement &&
        !nsCSSPseudoElements::IsCSS2PseudoElement(pseudo)
#ifdef MOZ_XUL
        && !isTreePseudo
#endif
        ) {
      REPORT_UNEXPECTED_TOKEN(PEPseudoSelNewStyleOnly);
      UngetToken();
      return eSelectorParsingStatus_Error;
    }

    if (0 == (aDataMask & SEL_MASK_PELEM)) {
      aDataMask |= SEL_MASK_PELEM;
      aSelector.AddPseudoClass(pseudo); // store it here, it gets pulled later

#ifdef MOZ_XUL
      if (isTree) {
        // We have encountered a pseudoelement of the form
        // -moz-tree-xxxx(a,b,c).  We parse (a,b,c) and add each
        // item in the list to the pseudoclass list.  They will be pulled
        // from the list later along with the pseudo-element.
        if (!ParseTreePseudoElement(aErrorCode, aSelector)) {
          return eSelectorParsingStatus_Error;
        }
      }
#endif

      // ensure selector ends here, must be followed by EOF, space, '{' or ','
      if (GetToken(aErrorCode, PR_FALSE)) { // premature eof is ok (here!)
        if ((eCSSToken_WhiteSpace == mToken.mType) || 
            (mToken.IsSymbol('{') || mToken.IsSymbol(','))) {
          UngetToken();
          return eSelectorParsingStatus_Done;
        }
        REPORT_UNEXPECTED_TOKEN(PEPseudoSelTrailing);
        UngetToken();
        return eSelectorParsingStatus_Error;
      }
    }
    else {  // multiple pseudo elements, not legal
      REPORT_UNEXPECTED_TOKEN(PEPseudoSelMultiplePE);
      UngetToken();
      return eSelectorParsingStatus_Error;
    }
  } else {
    // Not a pseudo-class, not a pseudo-element.... forget it
    REPORT_UNEXPECTED_TOKEN(PEPseudoSelUnknown);
    UngetToken();
    return eSelectorParsingStatus_Error;
  }
  return eSelectorParsingStatus_Continue;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseQuotes ( nsresult aErrorCode) [protected]

Definition at line 5772 of file nsCSSParser.cpp.

{
  nsCSSValue  open;
  if (ParseVariant(aErrorCode, open, VARIANT_HOS, nsnull)) {
    if (eCSSUnit_String == open.GetUnit()) {
      nsCSSQuotes* quotesHead = new nsCSSQuotes();
      nsCSSQuotes* quotes = quotesHead;
      if (nsnull == quotes) {
        aErrorCode = NS_ERROR_OUT_OF_MEMORY;
        return PR_FALSE;
      }
      quotes->mOpen = open;
      while (nsnull != quotes) {
        // get mandatory close
        if (ParseVariant(aErrorCode, quotes->mClose, VARIANT_STRING, nsnull)) {
          if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
            mTempData.SetPropertyBit(eCSSProperty_quotes);
            mTempData.mContent.mQuotes = quotesHead;
            aErrorCode = NS_OK;
            return PR_TRUE;
          }
          // look for another open
          if (ParseVariant(aErrorCode, open, VARIANT_STRING, nsnull)) {
            quotes->mNext = new nsCSSQuotes();
            quotes = quotes->mNext;
            if (nsnull != quotes) {
              quotes->mOpen = open;
              continue;
            }
            aErrorCode = NS_ERROR_OUT_OF_MEMORY;
          }
        }
        break;
      }
      delete quotesHead;
      return PR_FALSE;
    }
    if (ExpectEndProperty(aErrorCode, PR_TRUE)) {
      nsCSSQuotes* quotesHead = new nsCSSQuotes();
      quotesHead->mOpen = open;
      mTempData.mContent.mQuotes = quotesHead;
      mTempData.SetPropertyBit(eCSSProperty_quotes);
      return PR_TRUE;
    }
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CSSParserImpl::ParseRect ( nsCSSRect aRect,
nsresult aErrorCode,
nsCSSProperty  aPropID 
) [protected]

Definition at line 5135 of file nsCSSParser.cpp.

{
  nsCSSRect rect;
  PRBool result;
  if ((result = DoParseRect(rect, aErrorCode)) &&
      rect != aRect) {
    aRect = rect;
    mTempData.SetPropertyBit(aPropID);
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP CSSParserImpl::ParseRule ( const nsAString &  aRule,
nsIURI aSheetURL,
nsIURI aBaseURL,
nsISupportsArray **  aResult 
) [virtual]

Implements nsICSSParser.

Definition at line 848 of file nsCSSParser.cpp.

{
  NS_ASSERTION(nsnull != aBaseURL, "need base URL");
  NS_ENSURE_ARG_POINTER(aResult);

  nsresult rv = InitScanner(aRule, aSheetURL, 0, aBaseURL);
  if (NS_FAILED(rv)) {
    return rv;
  }

  rv = NS_NewISupportsArray(aResult);
  if (NS_FAILED(rv)) {
    ReleaseScanner();
    return rv;
  }
  
  mSection = eCSSSection_Charset; // callers are responsible for rejecting invalid rules.
  nsresult errorCode = NS_OK;

  nsCSSToken* tk = &mToken;
  // Get first non-whitespace token
  if (!GetToken(errorCode, PR_TRUE)) {
    REPORT_UNEXPECTED(PEParseRuleWSOnly);
    OUTPUT_ERROR();
  } else if (eCSSToken_AtKeyword == tk->mType) {
    ParseAtRule(errorCode, AppendRuleToArray, *aResult);    
  }
  else {
    UngetToken();
    ParseRuleSet(errorCode, AppendRuleToArray, *aResult);
  }
  OUTPUT_ERROR();
  ReleaseScanner();
  return NS_OK;
}

Here is the call graph for this function: