NS_PRECONDITION(nsnull != aPresContext, "null arg"); NS_PRECONDITION(nsnull != aContent, "null arg"); NS_PRECONDITION(nsnull != aResults, "null arg");  nsIStyledContent* styledContent; if (NS_SUCCEEDED(aContent->QueryInterface(nsIStyledContent::GetIID(), (void**)&styledContent))) { PRInt32 nameSpace; styledContent->GetNameSpaceID(nameSpace); if (kNameSpaceID_HTML == nameSpace) { nsIAtom*  tag; styledContent->GetTag(tag);  if (tag == nsHTMLAtoms::a) { if ((nsnull != mLinkRule) || (nsnull != mVisitedRule)) {  nsILinkHandler* linkHandler;  if (NS_OK == aPresContext->GetLinkHandler(&linkHandler)) { nsAutoString base, href; nsresult attrState = styledContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::href, href);  if (NS_CONTENT_ATTR_HAS_VALUE == attrState) {  if (! linkHandler) { if (nsnull != mLinkRule) { aResults->AppendElement(mLinkRule); } } else { nsIURI* docURL = nsnull;  nsIHTMLContent* htmlContent; if (NS_SUCCEEDED(styledContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent))) { htmlContent->GetBaseURL(docURL);  nsAutoString absURLSpec; nsresult rv; #ifndef NECKO rv = NS_MakeAbsoluteURL(docURL, base, href, absURLSpec); #else nsIURI *baseUri = nsnull; rv = docURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri); if (NS_FAILED(rv)) return 0;  rv = NS_MakeAbsoluteURI(href, baseUri, absURLSpec);  NS_RELEASE(baseUri); #endif NS_IF_RELEASE(docURL);  nsLinkState  state; if (NS_OK == linkHandler->GetLinkState(absURLSpec.GetUnicode(), state)) { switch (state) { case eLinkState_Unvisited: if (nsnull != mLinkRule) { aResults->AppendElement(mLinkRule); } break; case eLinkState_Visited: if (nsnull != mVisitedRule) { aResults->AppendElement(mVisitedRule); } break; default: break; } } NS_RELEASE(htmlContent); } } } } NS_IF_RELEASE(linkHandler); } if (nsnull != mActiveRule) { nsIEventStateManager* eventStateManager;  if ((NS_OK == aPresContext->GetEventStateManager(&eventStateManager)) && (nsnull != eventStateManager)) { PRInt32 state; if (NS_OK == eventStateManager->GetContentState(aContent, state)) { if (0 != (state & NS_EVENT_STATE_ACTIVE)) { aResults->AppendElement(mActiveRule); } } NS_RELEASE(eventStateManager); } } }  else if ((tag == nsHTMLAtoms::td) || (tag == nsHTMLAtoms::th) || (tag == nsHTMLAtoms::tr) || (tag == nsHTMLAtoms::thead) || (tag == nsHTMLAtoms::tbody) || (tag == nsHTMLAtoms::tfoot)) { nsCompatibility mode; aPresContext->GetCompatibilityMode(&mode); if (eCompatibility_NavQuirks == mode) { if (mDocumentColorRule) { aResults->AppendElement(mDocumentColorRule); } aResults->AppendElement(mTableBackgroundRule); } } else if (tag == nsHTMLAtoms::html) { if (mDocumentColorRule) { aResults->AppendElement(mDocumentColorRule); } } NS_IF_RELEASE(tag); }   styledContent->GetContentStyleRules(aResults);  NS_RELEASE(styledContent); }
HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,                                  nsIAtom* aMedium,                                  nsIContent* aParentContent,                                  nsIAtom* aPseudoTag,                                  nsIStyleContext* aParentContext,                                  nsISupportsArray* aResults){  // no pseudo frame style  return NS_OK;}