Logo Search packages:      
Sourcecode: xulrunner version File versions

nsresult nsScriptElement::MaybeProcessScript (  )  [protected, virtual]

Processes the script if it's in the document-tree and links to or contains a script. Once it has been evaluated there is no way to make it reevaluate the script, you'll have to create a new element. This also means that when adding a src attribute to an element that already contains an inline script, the script referenced by the src attribute will not be loaded.

In order to be able to use multiple childNodes, or to use the fallback mechanism of using both inline script and linked script you have to add all attributes and childNodes before adding the element to the document-tree.

Definition at line 171 of file nsScriptElement.cpp.

References HasScriptContent().

  nsCOMPtr<nsIContent> cont =
    do_QueryInterface((nsIScriptElement*) this);

               "You forgot to add self as observer");

  if (mIsEvaluated || !mDoneAddingChildren || !cont->IsInDoc() ||
      mMalformed || !HasScriptContent()) {
    return NS_OK;

  if (InNonScriptingContainer(cont)) {
    // Make sure to flag ourselves as evaluated
    mIsEvaluated = PR_TRUE;
    return NS_OK;

  nsresult scriptresult = NS_OK;
  nsRefPtr<nsScriptLoader> loader = cont->GetOwnerDoc()->ScriptLoader();
  mIsEvaluated = PR_TRUE;
  scriptresult = loader->ProcessScriptElement(this);

  // The only error we don't ignore is NS_ERROR_HTMLPARSER_BLOCK
  // However we don't want to override other success values
  if (NS_FAILED(scriptresult) &&
      scriptresult != NS_ERROR_HTMLPARSER_BLOCK) {
    scriptresult = NS_OK;

  return scriptresult;

Generated by  Doxygen 1.6.0   Back to index