if (IsInDoc()) { nsIPresShell *presShell = GetOwnerDoc()->GetShellAt(0);
nsIDocument* doc = GetCurrentDoc(); if (doc) { nsIPresShell *presShell = doc->GetShellAt(0);
nsSVGScriptElement::ScriptAvailable(nsresult aResult,                                    nsIScriptElement *aElement,                                    PRBool aIsInline,                                    PRBool aWasPending,                                    nsIURI *aURI,                                    PRInt32 aLineNo,                                    const nsAString& aScript){  if (!aIsInline && NS_FAILED(aResult)) {    nsCOMPtr<nsPresContext> presContext;    if (IsInDoc()) {      nsIPresShell *presShell = GetOwnerDoc()->GetShellAt(0);      if (presShell)        presContext = presShell->GetPresContext();    }    nsEventStatus status = nsEventStatus_eIgnore;    nsScriptErrorEvent event(NS_SCRIPT_ERROR);    event.lineNr = aLineNo;    NS_NAMED_LITERAL_STRING(errorString, "Error loading script");    event.errorMsg = errorString.get();    nsCAutoString spec;    aURI->GetSpec(spec);    NS_ConvertUTF8toUCS2 fileName(spec);    event.fileName = fileName.get();    HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT,                   &status);  }  return NS_OK;}