nsObjectFrame::Reflow(nsIPresContext&          aPresContext,
nsObjectFrame::Reflow(nsIPresContext*          aPresContext,
nsObjectFrame::Reflow(nsIPresContext&          aPresContext,                      nsHTMLReflowMetrics&     aMetrics,                      const nsHTMLReflowState& aReflowState,                      nsReflowStatus&          aStatus){  nsresult rv = NS_OK;  char* mimeType = nsnull;  PRUint32 buflen;  // Get our desired size  GetDesiredSize(&aPresContext, aReflowState, aMetrics);  // could be an image  nsIFrame * child = mFrames.FirstChild();  if(child != nsnull)  	return HandleImage(aPresContext, aMetrics, aReflowState, aStatus, child);  // if mInstance is null, we need to determine what kind of object we are and instantiate ourselves  if(!mInstanceOwner)  {    // XXX - do we need to create this for widgets as well?    mInstanceOwner = new nsPluginInstanceOwner();    if(!mInstanceOwner)	    return NS_ERROR_OUT_OF_MEMORY;    NS_ADDREF(mInstanceOwner);    mInstanceOwner->Init(&aPresContext, this);    nsISupports               *container = nsnull;    nsIPluginHost             *pluginHost = nsnull;    nsIContentViewerContainer *cv = nsnull;    nsIURI* baseURL = nsnull;    nsIURI* fullURL = nsnull;    nsAutoString classid;    PRInt32 nameSpaceID;    // if we have a clsid, we're either an internal widget, an ActiveX control, or an applet    mContent->GetNameSpaceID(nameSpaceID);    if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(nameSpaceID, nsHTMLAtoms::classid, classid))    {      nsCID widgetCID;		PRBool bJavaObject = PR_FALSE;	PRBool bJavaPluginClsid = PR_FALSE;	if (classid.Find("java:") != -1)	{	    classid.Cut(0, 5); // Strip off the "java:". What's left is the class file.	    bJavaObject = PR_TRUE;	}	if (classid.Find("clsid:") != -1)	{            classid.Cut(0, 6); // Strip off the "clsid:". What's left is the class ID.	    bJavaPluginClsid = (classid == JAVA_CLASS_ID);	}      // if we find "java:" in the class id, or we match the Java classid number, we have a java applet      if(bJavaObject || bJavaPluginClsid)      {        mimeType = (char *)PR_Malloc(PL_strlen("application/x-java-vm") + 1);        PL_strcpy(mimeType, "application/x-java-vm");      if((rv = GetBaseURL(baseURL)) != NS_OK)	return rv;#ifndef NECKO        nsILoadGroup* group = nsnull;        if (nsnull != baseURL)          baseURL->GetLoadGroup(&group);#endif        nsAutoString codeBase;        if(NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::codebase, codeBase) &&           !bJavaPluginClsid) 		    {          nsIURI* codeBaseURL = nsnull;#ifdef NECKO          rv = NS_NewURI(&codeBaseURL, codeBase, baseURL);#else          rv = NS_NewURL(&codeBaseURL, codeBase, baseURL, nsnull, group);#endif          if(rv == NS_OK)          {            NS_IF_RELEASE(baseURL);            baseURL = codeBaseURL;          }        }#ifndef NECKO   // unused urlxxx?        const char* urlxxx;        (void)baseURL->GetSpec(&urlxxx);#endif        // Create an absolute URL        if(bJavaPluginClsid) {#ifdef NECKO          rv = NS_NewURI(&fullURL, classid, baseURL);#else          rv = NS_NewURL(&fullURL, classid, baseURL, nsnull, group);#endif        }        else        {          fullURL = baseURL;          NS_IF_ADDREF(fullURL);        }#ifndef NECKO        NS_IF_RELEASE(group);#endif        // get the nsIPluginHost interface        if((rv = aPresContext.GetContainer(&container)) != NS_OK)	        return rv;        if((rv = container->QueryInterface(kIContentViewerContainerIID, (void **)&cv)) != NS_OK)        {		      NS_RELEASE(container);           return rv;        }	      if((rv = cv->QueryCapability(kIPluginHostIID, (void **)&pluginHost)) != NS_OK)        {		      NS_RELEASE(container);           NS_RELEASE(cv);           return rv;        }        mInstanceOwner->SetPluginHost(pluginHost);        rv = InstantiatePlugin(aPresContext, aMetrics, aReflowState, pluginHost, mimeType, fullURL);      }      else // otherwise, we're either an ActiveX control or an internal widget      {        // These are some builtin types that we know about for now.        // (Eventually this will move somewhere else.)        if (classid == "browser")        {          widgetCID = kCAppShellCID;	        rv = InstantiateWidget(aPresContext, aMetrics, aReflowState, widgetCID);        }        else        {	      // if we haven't matched to an internal type, check to see if we have an ActiveX handler	      // if not, create the default plugin	        if((rv = GetBaseURL(baseURL)) != NS_OK)	          return rv;#ifndef NECKO	        nsILoadGroup* group = nsnull;          if(nsnull != baseURL)            baseURL->GetLoadGroup(&group);#endif	        // if we have a codebase, add it to the fullURL	        nsAutoString codeBase;          if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::codebase, codeBase)) 	        {            nsIURI* codeBaseURL = nsnull;#ifdef NECKO            rv = NS_NewURI(&fullURL, codeBase, baseURL);#else            rv = NS_NewURL(&fullURL, codeBase, baseURL, nsnull, group);#endif            if(rv == NS_OK)            {              NS_IF_RELEASE(baseURL);              baseURL = codeBaseURL;            }          } else {	          fullURL = baseURL;              NS_IF_ADDREF(fullURL);	      }#ifndef NECKO	        NS_IF_RELEASE(group);#endif          // get the nsIPluginHost interface          if((rv = aPresContext.GetContainer(&container)) != NS_OK)	          return rv;          if((rv = container->QueryInterface(kIContentViewerContainerIID, (void **)&cv)) != NS_OK)          {		        NS_RELEASE(container);             return rv;          }	        if((rv = cv->QueryCapability(kIPluginHostIID, (void **)&pluginHost)) != NS_OK)          {		        NS_RELEASE(container);             NS_RELEASE(cv);             return rv;          }          mInstanceOwner->SetPluginHost(pluginHost);          if(pluginHost->IsPluginEnabledForType("application/x-oleobject") == NS_OK)	          rv = InstantiatePlugin(aPresContext, aMetrics, aReflowState, pluginHost, "application/x-oleobject", fullURL);          else if(pluginHost->IsPluginEnabledForType("application/oleobject") == NS_OK)	          rv = InstantiatePlugin(aPresContext, aMetrics, aReflowState, pluginHost, "application/oleobject", fullURL);	        else	          rv = NS_ERROR_FAILURE;        }      }	    NS_IF_RELEASE(baseURL);	    NS_IF_RELEASE(fullURL);	    NS_IF_RELEASE(pluginHost);	    NS_IF_RELEASE(cv);	    NS_IF_RELEASE(container);      // finish up      if(rv == NS_OK)      {        aStatus = NS_FRAME_COMPLETE;        return NS_OK;      }      // if we got an error, we'll check for alternative content with CantRenderReplacedElement()      nsIPresShell* presShell;      aPresContext.GetShell(&presShell);      presShell->CantRenderReplacedElement(&aPresContext, this);      NS_RELEASE(presShell);      aStatus = NS_FRAME_COMPLETE;      return NS_OK;    }	  // if we're here, the object is either an applet or a plugin    nsIAtom* atom = nsnull;    nsAutoString    src;	  if((rv = GetBaseURL(baseURL)) != NS_OK)		  return rv;    // get the nsIPluginHost interface    if((rv = aPresContext.GetContainer(&container)) != NS_OK)		  return rv;	  if((rv = container->QueryInterface(kIContentViewerContainerIID, (void **)&cv)) != NS_OK)    {		  NS_RELEASE(container);       return rv;    }    if((rv = cv->QueryCapability(kIPluginHostIID, (void **)&pluginHost)) != NS_OK)    {		  NS_RELEASE(container);       NS_RELEASE(cv);       return rv;    }    mInstanceOwner->SetPluginHost(pluginHost);    mContent->GetTag(atom);	  // check if it's an applet    if (atom == nsHTMLAtoms::applet && atom) 	  {      mimeType = (char *)PR_Malloc(PL_strlen("application/x-java-vm") + 1);      PL_strcpy(mimeType, "application/x-java-vm");      if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::code, src)) 	    {#ifndef NECKO        nsILoadGroup* group = nsnull;        if (nsnull != baseURL)          baseURL->GetLoadGroup(&group);#endif        nsAutoString codeBase;        if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::codebase, codeBase)) 		    {          nsIURI* codeBaseURL = nsnull;#ifdef NECKO          rv = NS_NewURI(&codeBaseURL, codeBase, baseURL);#else          rv = NS_NewURL(&codeBaseURL, codeBase, baseURL, nsnull, group);#endif          if(rv == NS_OK)          {            NS_IF_RELEASE(baseURL);            baseURL = codeBaseURL;          }        }        // Create an absolute URL#ifdef NECKO        rv = NS_NewURI(&fullURL, src, baseURL);#else        rv = NS_NewURL(&fullURL, src, baseURL, nsnull, group);        NS_IF_RELEASE(group);#endif      }      rv = InstantiatePlugin(aPresContext, aMetrics, aReflowState, pluginHost, mimeType, fullURL);    }    else // traditional plugin	  {	    nsAutoString type;      mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, type);      buflen = type.Length();      if (buflen > 0) 	    {        mimeType = (char *)PR_Malloc(buflen + 1);        if (nsnull != mimeType)          type.ToCString(mimeType, buflen + 1);      }      //stream in the object source if there is one...      if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::src, src)) 	    {#ifdef NECKO        // Create an absolute URL        rv = NS_NewURI(&fullURL, src, baseURL);#else        nsILoadGroup* group = nsnull;        if (nsnull != baseURL)          baseURL->GetLoadGroup(&group);        // Create an absolute URL        rv = NS_NewURL(&fullURL, src, baseURL, nsnull, group);        NS_IF_RELEASE(group);#endif	    }	    else if(NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::data, src)) 	    {#ifdef NECKO        // Create an absolute URL        rv = NS_NewURI(&fullURL, src, baseURL);#else        nsILoadGroup* group = nsnull;        if (nsnull != baseURL)          baseURL->GetLoadGroup(&group);        // Create an absolute URL        rv = NS_NewURL(&fullURL, src, baseURL, nsnull, group);        NS_IF_RELEASE(group);#endif	    } else {// we didn't find a src or data param, so just set the url to the base		  fullURL = baseURL;		  NS_IF_ADDREF(fullURL);		}	    // if we didn't find the type, but we do have a src, we can determine the mimetype	    // based on the file extension      if(!mimeType && src.GetUnicode())	    {		    char* extension;		    char* cString = src.ToNewCString();		    extension = PL_strrchr(cString, '.');		    if(extension)			    ++extension;		    pluginHost->IsPluginEnabledForExtension((const char *)extension, (const char *&)mimeType);      delete [] cString;	    }	    rv = InstantiatePlugin(aPresContext, aMetrics, aReflowState, pluginHost, mimeType, fullURL);    }	  NS_IF_RELEASE(atom);	  NS_IF_RELEASE(baseURL);	  NS_IF_RELEASE(fullURL);	  NS_IF_RELEASE(pluginHost);	  NS_IF_RELEASE(cv);	  NS_IF_RELEASE(container);  }  else    rv = ReinstantiatePlugin(aPresContext, aMetrics, aReflowState);  // finish up  if(rv == NS_OK)  {    aStatus = NS_FRAME_COMPLETE;    return NS_OK;  }  // if we got an error, we'll check for alternative content with CantRenderReplacedElement()  nsIPresShell* presShell;  aPresContext.GetShell(&presShell);  presShell->CantRenderReplacedElement(&aPresContext, this);  NS_RELEASE(presShell);  aStatus = NS_FRAME_COMPLETE;  return NS_OK;}