mParentContext = aParentContext;
SelectorMatchesData::SelectorMatchesData(nsIPresContext* aPresContext, nsIContent* aContent,                 nsIStyleContext* aParentContext, nsISupportsArray* aResults,                nsCompatibility* aCompat /*= nsnull*/){  mPresContext = aPresContext;  mContent = aContent;  mParentContent = nsnull;  mParentContext = aParentContext;  mResults = aResults;  mContentTag = nsnull;  mContentID = nsnull;  mStyledContent = nsnull;  mIsHTMLContent = PR_FALSE;  mIsHTMLLink = PR_FALSE;  mIsSimpleXLink = PR_FALSE;  mLinkState = eLinkState_Unknown;  mEventState = NS_EVENT_STATE_UNSPECIFIED;  mNameSpaceID = kNameSpaceID_Unknown;  if(!aCompat) {    // get the compat. mode (unless it is provided)    nsCompatibility quirkMode = eCompatibility_Standard;    mPresContext->GetCompatibilityMode(&quirkMode);    mIsQuirkMode = eCompatibility_Standard == quirkMode ? PR_FALSE : PR_TRUE;  } else {    mIsQuirkMode = eCompatibility_Standard == *aCompat ? PR_FALSE : PR_TRUE;  }  if(aContent){    // we hold no ref to the content...    mContent = aContent;    // get the namespace    aContent->GetNameSpaceID(mNameSpaceID);    // get the tag and parent    aContent->GetTag(mContentTag);    aContent->GetParent(mParentContent);    // get the event state    nsIEventStateManager* eventStateManager = nsnull;    mPresContext->GetEventStateManager(&eventStateManager);    if(eventStateManager) {      eventStateManager->GetContentState(aContent, mEventState);      NS_RELEASE(eventStateManager);    }    // get the styledcontent interface and the ID    if (NS_SUCCEEDED(aContent->QueryInterface(NS_GET_IID(nsIStyledContent), (void**)&mStyledContent))) {      NS_ASSERTION(mStyledContent, "Succeeded but returned null");      mStyledContent->GetID(mContentID);    }    // see if there are attributes for the content    PRInt32 attrCount = 0;    aContent->GetAttributeCount(attrCount);    mHasAttributes = PRBool(attrCount > 0);    PRBool isXUL = PR_FALSE;    // check for HTMLContent and Link status    //#ifdef MOZ_XUL#ifndef DONT_OPTIMIZE_ISHTMLCONTENT_FOR_XUL    // check for HTML content    // NOTE: optimization to first check for XULContent since asking a XUL element to     //       QI for HTMLContent is very slow    nsIXULContent *xc;    if (NS_SUCCEEDED(aContent->QueryInterface(NS_GET_IID(nsIXULContent), (void**)&xc))) {      NS_RELEASE(xc);      isXUL = PR_TRUE;    }#endif#endif    nsIHTMLContent* hc;    if (PR_FALSE == isXUL &&        NS_SUCCEEDED(aContent->QueryInterface(NS_GET_IID(nsIHTMLContent), (void**)&hc))) {      mIsHTMLContent = PR_TRUE;      NS_RELEASE(hc);    }     // if HTML content and it has some attributes, check for an HTML link    // NOTE: optimization: cannot be a link if no attributes (since it needs an href)    if (PR_TRUE == mIsHTMLContent && mHasAttributes) {      // check if it is an HTML Link      if(nsStyleUtil::IsHTMLLink(aContent, mContentTag, mPresContext, &mLinkState)) {        mIsHTMLLink = PR_TRUE;      }    }     // if not an HTML link, check for a simple xlink (cannot be both HTML link and xlink)    // NOTE: optimization: cannot be an XLink if no attributes (since it needs an     if(PR_FALSE == mIsHTMLLink &&       mHasAttributes &&       nsStyleUtil::IsSimpleXlink(aContent, mPresContext, &mLinkState)) {      mIsSimpleXLink = PR_TRUE;    }   }}