Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
inCSSValueSearch Class Reference

#include <inCSSValueSearch.h>

Inheritance diagram for inCSSValueSearch:
Inheritance graph
[legend]
Collaboration diagram for inCSSValueSearch:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_INISEARCHPROCESS
NS_DECL_INICSSVALUESEARCH 
inCSSValueSearch ()
virtual ~inCSSValueSearch ()
void addPropertyCriteria (in wstring aPropName)
void searchSync ()
void searchAsync (in inISearchObserver aObserver)
void searchStop ()
boolean searchStep ()
AString getStringResultAt (in long aIndex)
long getIntResultAt (in long aIndex)
unsigned long getUIntResultAt (in long aIndex)

Public Attributes

attribute nsIDOMDocument document
attribute wstring baseURL
attribute boolean returnRelativeURLs
attribute boolean normalizeChromeURLs
attribute wstring textCriteria
readonly attribute boolean isActive
readonly attribute long resultCount
attribute boolean holdResults

Protected Member Functions

nsresult InitSearch ()
nsresult KillSearch (PRInt16 aResult)
nsresult SearchStyleSheet (nsIDOMCSSStyleSheet *aStyleSheet, nsIURI *aBaseURI)
nsresult SearchRuleList (nsIDOMCSSRuleList *aRuleList, nsIURI *aBaseURI)
nsresult SearchStyleRule (nsIDOMCSSStyleRule *aStyleRule, nsIURI *aBaseURI)
nsresult SearchStyleValue (const nsAFlatString &aValue, nsIURI *aBaseURI)
nsresult EqualizeURL (nsAutoString *aURL)

Protected Attributes

nsCOMPtr< inISearchObservermObserver
nsCOMPtr< nsIInspectorCSSUtilsmCSSUtils
nsCOMPtr< nsIDOMDocumentmDocument
nsVoidArraymResults
nsCSSPropertymProperties
nsString mLastResult
nsString mBaseURL
nsString mTextCriteria
PRInt32 mResultCount
PRUint32 mPropertyCount
PRBool mIsActive
PRBool mHoldResults
PRBool mReturnRelativeURLs
PRBool mNormalizeChromeURLs

Detailed Description

Definition at line 55 of file inCSSValueSearch.h.


Constructor & Destructor Documentation

Definition at line 59 of file inCSSValueSearch.cpp.

Here is the call graph for this function:

Definition at line 73 of file inCSSValueSearch.cpp.

{
  delete[] mProperties;
  delete mResults;
}

Member Function Documentation

void inICSSValueSearch::addPropertyCriteria ( in wstring  aPropName) [inherited]

Definition at line 406 of file inCSSValueSearch.cpp.

{
  if (mNormalizeChromeURLs) {
    if (aURL->Find("chrome://", PR_FALSE, 0, 1) >= 0) {
      PRUint32 len = aURL->Length();
      char* result = new char[len-8];
      const PRUnichar* src = aURL->get();
      PRUint32 i = 9;
      PRUint32 milestone = 0;
      PRUint32 s = 0;
      while (i < len) {
        if (src[i] == '/') {
          milestone += 1;
        } 
        if (milestone != 1) {
          result[i-9-s] = src[i];
        } else {
          s++;
        }
        i++;
      }
      result[i-9-s] = 0;

      aURL->AssignWithConversion(result);
      delete [] result;
    }
  } else {
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long inISearchProcess::getIntResultAt ( in long  aIndex) [inherited]
AString inISearchProcess::getStringResultAt ( in long  aIndex) [inherited]
unsigned long inISearchProcess::getUIntResultAt ( in long  aIndex) [inherited]

Definition at line 288 of file inCSSValueSearch.cpp.

{
  if (mHoldResults) {
    mResults = new nsVoidArray();
  }
  
  mResultCount = 0;

  return NS_OK;
}

Here is the call graph for this function:

nsresult inCSSValueSearch::KillSearch ( PRInt16  aResult) [protected]

Definition at line 300 of file inCSSValueSearch.cpp.

{
  mIsActive = PR_TRUE;
  mObserver->OnSearchEnd(this, aResult);

  return NS_OK;
}
nsresult inCSSValueSearch::SearchRuleList ( nsIDOMCSSRuleList aRuleList,
nsIURI aBaseURI 
) [protected]

Definition at line 327 of file inCSSValueSearch.cpp.

{
  PRUint32 length;
  aRuleList->GetLength(&length);
  for (PRUint32 i = 0; i < length; ++i) {
    nsCOMPtr<nsIDOMCSSRule> rule;
    aRuleList->Item(i, getter_AddRefs(rule));
    PRUint16 type;
    rule->GetType(&type);
    switch (type) {
      case nsIDOMCSSRule::STYLE_RULE: {
        nsCOMPtr<nsIDOMCSSStyleRule> styleRule = do_QueryInterface(rule);
        SearchStyleRule(styleRule, aBaseURL);
      } break;
      case nsIDOMCSSRule::IMPORT_RULE: {
        nsCOMPtr<nsIDOMCSSImportRule> importRule = do_QueryInterface(rule);
        nsCOMPtr<nsIDOMCSSStyleSheet> childSheet;
        importRule->GetStyleSheet(getter_AddRefs(childSheet));
        if (childSheet)
          SearchStyleSheet(childSheet, aBaseURL);
      } break;
      case nsIDOMCSSRule::MEDIA_RULE: {
        nsCOMPtr<nsIDOMCSSMediaRule> mediaRule = do_QueryInterface(rule);
        nsCOMPtr<nsIDOMCSSRuleList> childRules;
        mediaRule->GetCssRules(getter_AddRefs(childRules));
        SearchRuleList(childRules, aBaseURL);
      } break;
      default:
        // XXX handle nsIDOMCSSRule::PAGE_RULE if we ever support it
        break;
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult inCSSValueSearch::SearchStyleRule ( nsIDOMCSSStyleRule aStyleRule,
nsIURI aBaseURI 
) [protected]

Definition at line 363 of file inCSSValueSearch.cpp.

{
  nsCOMPtr<nsIDOMCSSStyleDeclaration> decl;
  nsresult rv = aStyleRule->GetStyle(getter_AddRefs(decl));
  NS_ENSURE_SUCCESS(rv, rv);
  
  PRUint32 length;
  decl->GetLength(&length);
  nsAutoString property, value;
  for (PRUint32 i = 0; i < length; ++i) {
    decl->Item(i, property);
    // XXX This probably ought to use GetPropertyCSSValue if it were
    // implemented.
    decl->GetPropertyValue(property, value);
    SearchStyleValue(value, aBaseURL);
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult inCSSValueSearch::SearchStyleSheet ( nsIDOMCSSStyleSheet aStyleSheet,
nsIURI aBaseURI 
) [protected]

Definition at line 309 of file inCSSValueSearch.cpp.

{
  nsCOMPtr<nsIURI> baseURL;
  nsAutoString href;
  aStyleSheet->GetHref(href);
  if (href.IsEmpty())
    baseURL = aBaseURL;
  else
    NS_NewURI(getter_AddRefs(baseURL), href, nsnull, aBaseURL);

  nsCOMPtr<nsIDOMCSSRuleList> rules;
  nsresult rv = aStyleSheet->GetCssRules(getter_AddRefs(rules));
  NS_ENSURE_SUCCESS(rv, rv);

  return SearchRuleList(rules, baseURL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult inCSSValueSearch::SearchStyleValue ( const nsAFlatString aValue,
nsIURI aBaseURI 
) [protected]

Definition at line 383 of file inCSSValueSearch.cpp.

{
  if (StringBeginsWith(aValue, NS_LITERAL_STRING("url(")) &&
      StringEndsWith(aValue, NS_LITERAL_STRING(")"))) {
    const nsASingleFragmentString &url =
      Substring(aValue, 4, aValue.Length() - 5);
    // XXXldb Need to do more with |mReturnRelativeURLs|, perhaps?
    nsCOMPtr<nsIURI> uri;
    nsresult rv = NS_NewURI(getter_AddRefs(uri), url, nsnull, aBaseURL);
    NS_ENSURE_SUCCESS(rv, rv);
    nsCAutoString spec;
    uri->GetSpec(spec);
    nsAutoString *result = new NS_ConvertUTF8toUTF16(spec);
    if (mReturnRelativeURLs)
      EqualizeURL(result);
    mResults->AppendElement(result);
    ++mResultCount;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 48 of file inICSSValueSearch.idl.

Definition at line 45 of file inICSSValueSearch.idl.

Definition at line 59 of file inISearchProcess.idl.

Definition at line 49 of file inISearchProcess.idl.

Definition at line 72 of file inCSSValueSearch.h.

Definition at line 67 of file inCSSValueSearch.h.

Definition at line 68 of file inCSSValueSearch.h.

Definition at line 77 of file inCSSValueSearch.h.

Definition at line 76 of file inCSSValueSearch.h.

Definition at line 71 of file inCSSValueSearch.h.

Definition at line 79 of file inCSSValueSearch.h.

Definition at line 66 of file inCSSValueSearch.h.

Definition at line 70 of file inCSSValueSearch.h.

Definition at line 75 of file inCSSValueSearch.h.

Definition at line 74 of file inCSSValueSearch.h.

Definition at line 69 of file inCSSValueSearch.h.

Definition at line 78 of file inCSSValueSearch.h.

Definition at line 73 of file inCSSValueSearch.h.

Definition at line 54 of file inICSSValueSearch.idl.

Definition at line 52 of file inISearchProcess.idl.

Definition at line 51 of file inICSSValueSearch.idl.

Definition at line 60 of file inICSSValueSearch.idl.


The documentation for this class was generated from the following files: