} } }
} else { fullURL = baseURL; NS_IF_ADDREF(fullURL); }   NS_ENSURE_SUCCESS(aPresContext->GetContainer(getter_AddRefs(container)), NS_ERROR_FAILURE);  nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryInterface(container)); NS_ENSURE_TRUE(requestor, NS_ERROR_FAILURE);  NS_ENSURE_SUCCESS(requestor->GetInterface(NS_GET_IID(nsIPluginHost), getter_AddRefs(pluginHost)), NS_ERROR_FAILURE);  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);
nsObjectFrame::Reflow(nsPresContext*          aPresContext,                      nsHTMLReflowMetrics&     aMetrics,                      const nsHTMLReflowState& aReflowState,                      nsReflowStatus&          aStatus){  DO_GLOBAL_REFLOW_COUNT("nsObjectFrame", aReflowState.reason);  DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);  nsresult rv = NS_OK;  // If we have a child, we toss the reflow over to it.  nsIFrame * child = mFrames.FirstChild();  if (child) {    // Reflow the child; our size just depends on that of the child,    // pure and simple    return HandleChild(aPresContext, aMetrics, aReflowState, aStatus, child);  }  // Get our desired size  GetDesiredSize(aPresContext, aReflowState, aMetrics);  // delay plugin instantiation until all children have  // arrived. Otherwise there may be PARAMs or other stuff that the  // plugin needs to see that haven't arrived yet.  if (!GetContent()->IsDoneAddingChildren()) {    aStatus = NS_FRAME_COMPLETE;    return rv;  }  // if we are printing or print previewing, bail for now  if (aPresContext->Medium() == nsLayoutAtoms::print) {    aStatus = NS_FRAME_COMPLETE;    return rv;  }  // 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);    nsCOMPtr<nsISupports>     container;    nsCOMPtr<nsIPluginHost>   pluginHost;    nsCOMPtr<nsIURI> fullURL;    nsAutoString classid;    nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();    nsAutoString codeBase;    if ((NS_CONTENT_ATTR_HAS_VALUE ==         mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::codebase, codeBase)) &&        !codeBase.IsEmpty()) {      nsCOMPtr<nsIURI> codeBaseURL;      rv = MakeAbsoluteURL(getter_AddRefs(codeBaseURL), codeBase, baseURI);      if (NS_SUCCEEDED(rv)) {        baseURI = codeBaseURL;      }    }    // if we have a clsid, we're either an internal widget, an ActiveX control, or an applet    if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::classid, classid)) {      PRBool bJavaObject;      bJavaObject = !nsCRT::strncmp(classid.get(), NS_LITERAL_STRING("java:").get(), 5);      // if we find "java:" in the class id, we have a java applet      if(bJavaObject) {        if (!baseURI) {          rv = NS_ERROR_FAILURE;        }        else {          fullURL = baseURI;          // get the nsIPluginHost interface          pluginHost = do_GetService(kCPluginManagerCID, &rv);          if (pluginHost) {            mInstanceOwner->SetPluginHost(pluginHost);            rv = InstantiatePlugin(aPresContext, aMetrics, aReflowState,                                  pluginHost, "application/x-java-vm", 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.EqualsLiteral("browser")) {          rv = InstantiateWidget(aPresContext, aMetrics,                                 aReflowState, kCAppShellCID);        }        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 (!baseURI) {            rv = NS_ERROR_FAILURE;          }          else {            fullURL = baseURI;            // get the nsIPluginHost interface            pluginHost = do_GetService(kCPluginManagerCID, &rv);            if (pluginHost) {              mInstanceOwner->SetPluginHost(pluginHost);              if (NS_SUCCEEDED(pluginHost->IsPluginEnabledForType("application/x-oleobject"))) {                rv = InstantiatePlugin(aPresContext, aMetrics, aReflowState, pluginHost,                                       "application/x-oleobject", fullURL);              }              else if (NS_SUCCEEDED(pluginHost->IsPluginEnabledForType("application/oleobject"))) {                rv = InstantiatePlugin(aPresContext, aMetrics, aReflowState, pluginHost,                                       "application/oleobject", fullURL);              }              else rv = NS_ERROR_FAILURE;            }          }        }      }      // finish up      if (NS_SUCCEEDED(rv)) {        aStatus = NS_FRAME_COMPLETE;        return NS_OK;      }    }    else { // no clsid - the object is either an applet or a plugin      nsAutoString    src;      if (!baseURI) {        rv = NS_ERROR_FAILURE;      }      else {        // get the nsIPluginHost interface        pluginHost = do_GetService(kCPluginManagerCID, &rv);        if (pluginHost) {          mInstanceOwner->SetPluginHost(pluginHost);          nsIAtom *tag = mContent->Tag();          if (tag == nsHTMLAtoms::applet) {            if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::code, src)) {              // Create an absolute URL              rv = MakeAbsoluteURL(getter_AddRefs(fullURL), src, baseURI);            }            else              fullURL = baseURI;            rv = InstantiatePlugin(aPresContext, aMetrics, aReflowState,                                  pluginHost, "application/x-java-vm", fullURL);          } else { // traditional plugin            nsXPIDLCString mimeTypeStr;            nsAutoString type;            mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, type);            if (type.Length()) {              mimeTypeStr.Adopt(ToNewCString(type));            }            // Stream in the object source if there is one...            // If this is an OBJECT tag, we should look for a DATA attribute.            // If not, it's an EMBED tag, and so we should look for a SRC attribute.            if (tag == nsHTMLAtoms::object)              rv = mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, src);            else              rv = mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, src);                        if (NS_CONTENT_ATTR_HAS_VALUE == rv) {              // Create an absolute URL              rv = MakeAbsoluteURL(getter_AddRefs(fullURL), src, baseURI);              if (NS_FAILED(rv)) {                // Failed to create URI, maybe because we didn't                // reconize the protocol handler ==> treat like                // no 'src'/'data' was specified in the embed/object tag                fullURL = baseURI;              }            }            else {              // we didn't find a src or data param, so just set the url              // to the base              fullURL = baseURI;            }            // now try to instantiate a plugin instance based on a mime type            const char* mimeType = mimeTypeStr.get();            if (mimeType || !src.IsEmpty()) {              if (!mimeType) {                // we don't have a mime type, try to figure it out from extension                PRInt32 offset = src.RFindChar(PRUnichar('.'));                if (offset != kNotFound)                  pluginHost->IsPluginEnabledForExtension(NS_ConvertUTF16toUTF8(Substring(src, offset + 1, src.Length())).get(), mimeType);              }              // if we fail to get a mime type from extension we can still try to               // instantiate plugin as it can be possible to determine it later              rv = InstantiatePlugin(aPresContext, aMetrics, aReflowState,                                    pluginHost, mimeType, fullURL);            }            else // if we have neither we should not bother              rv = NS_ERROR_FAILURE;          }        }      }    }  }  else { // if (!mInstanceOwner)    rv = ReinstantiatePlugin(aPresContext, aMetrics, aReflowState);  }  // finish up  if (NS_FAILED(rv)) {    // if we got an error, we are probably going to be replaced    // for a replaced object frame, clear our vertical alignment style info, see bug 36997    nsStyleTextReset* text = NS_STATIC_CAST(nsStyleTextReset*,      mStyleContext->GetUniqueStyleData(eStyleStruct_TextReset));    text->mVerticalAlign.SetNormalValue();    //check for alternative content with CantRenderReplacedElement()    rv = aPresContext->PresShell()->CantRenderReplacedElement(this);  } else {    NotifyContentObjectWrapper();  }  aStatus = NS_FRAME_COMPLETE;  NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);  return rv;}