already_AddRefed<nsISupports> BoxObject::GetPropertyAsSupports(const nsAString& propertyName) { nsCOMPtr<nsISupports> ret; GetPropertyAsSupports(PromiseFlatString(propertyName).get(), getter_AddRefs(ret)); return ret.forget(); }
void BoxObject::GetProperty(const nsAString& propertyName, nsString& aRetVal, ErrorResult& aRv) { nsCOMPtr<nsISupports> data(GetPropertyAsSupports(propertyName)); if (!data) { return; } nsCOMPtr<nsISupportsString> supportsStr(do_QueryInterface(data)); if (!supportsStr) { aRv.Throw(NS_ERROR_FAILURE); return; } supportsStr->GetData(aRetVal); }
NS_IMETHODIMP nsBoxObject::GetProperty(const PRUnichar* aPropertyName, PRUnichar** aResult) { nsCOMPtr<nsISupports> data; nsresult rv = GetPropertyAsSupports(aPropertyName,getter_AddRefs(data)); NS_ENSURE_SUCCESS(rv, rv); if (!data) { *aResult = nsnull; return NS_OK; } nsCOMPtr<nsISupportsString> supportsStr = do_QueryInterface(data); if (!supportsStr) return NS_ERROR_FAILURE; return supportsStr->ToString(aResult); }
NS_IMETHODIMP nsTreeBoxObject::SetDocument(nsIDocument* aDocument) { // this should only be called with a null document, which indicates // that we're being torn down. NS_ASSERTION(aDocument == nsnull, "SetDocument called with non-null document"); // Drop the view's ref to us. nsCOMPtr<nsISupports> suppView; GetPropertyAsSupports(NS_LITERAL_STRING("view").get(), getter_AddRefs(suppView)); nsCOMPtr<nsITreeView> treeView(do_QueryInterface(suppView)); if (treeView) { nsCOMPtr<nsITreeSelection> sel; treeView->GetSelection(getter_AddRefs(sel)); if (sel) sel->SetTree(nsnull); treeView->SetTree(nsnull); // Break the circular ref between the view and us. } return nsBoxObject::SetDocument(aDocument); }