nsresult nsDocElementBoxFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements) { nsIDocument* doc = mContent->GetDocument(); if (!doc) { // The page is currently being torn down. Why bother. return NS_ERROR_FAILURE; } nsNodeInfoManager *nodeInfoManager = doc->NodeInfoManager(); // create the top-secret popupgroup node. shhhhh! nsCOMPtr<nsINodeInfo> nodeInfo; nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::popupgroup, nsnull, kNameSpaceID_XUL, nsIDOMNode::ELEMENT_NODE); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY); nsresult rv = NS_NewXULElement(getter_AddRefs(mPopupgroupContent), nodeInfo.forget()); NS_ENSURE_SUCCESS(rv, rv); if (!aElements.AppendElement(mPopupgroupContent)) return NS_ERROR_OUT_OF_MEMORY; // create the top-secret default tooltip node. shhhhh! nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::tooltip, nsnull, kNameSpaceID_XUL, nsIDOMNode::ELEMENT_NODE); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY); rv = NS_NewXULElement(getter_AddRefs(mTooltipContent), nodeInfo.forget()); NS_ENSURE_SUCCESS(rv, rv); mTooltipContent->SetAttr(nsnull, nsGkAtoms::_default, NS_LITERAL_STRING("true"), false); if (!aElements.AppendElement(mTooltipContent)) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; }
nsresult XULTooltipElement::Init() { // Create the default child label node that will contain the text of the // tooltip. RefPtr<mozilla::dom::NodeInfo> nodeInfo; nodeInfo = mNodeInfo->NodeInfoManager()->GetNodeInfo( nsGkAtoms::description, nullptr, kNameSpaceID_XUL, nsINode::ELEMENT_NODE); nsCOMPtr<Element> description; nsresult rv = NS_NewXULElement(getter_AddRefs(description), nodeInfo.forget(), dom::NOT_FROM_PARSER); NS_ENSURE_SUCCESS(rv, rv); description->SetAttr(kNameSpaceID_None, nsGkAtoms::_class, NS_LITERAL_STRING("tooltip-label"), false); description->SetAttr(kNameSpaceID_None, nsGkAtoms::flex, NS_LITERAL_STRING("true"), false); ErrorResult error; AppendChild(*description, error); return error.StealNSResult(); }
nsresult NS_NewElement(nsIContent** aResult, PRInt32 aElementType, already_AddRefed<nsINodeInfo> aNodeInfo, PRUint32 aFromParser) { if (aElementType == kNameSpaceID_XHTML) { return NS_NewHTMLElement(aResult, aNodeInfo, aFromParser); } #ifdef MOZ_XUL if (aElementType == kNameSpaceID_XUL) { return NS_NewXULElement(aResult, aNodeInfo); } #endif #ifdef MOZ_MATHML if (aElementType == kNameSpaceID_MathML) { return NS_NewMathMLElement(aResult, aNodeInfo); } #endif #ifdef MOZ_SVG if (aElementType == kNameSpaceID_SVG && NS_SVGEnabled()) { return NS_NewSVGElement(aResult, aNodeInfo, aFromParser); } #endif if (aElementType == kNameSpaceID_XMLEvents) { return NS_NewXMLEventsElement(aResult, aNodeInfo); } #ifdef MOZ_XTF if (aElementType > kNameSpaceID_LastBuiltin) { nsIXTFService* xtfService = nsContentUtils::GetXTFService(); NS_ASSERTION(xtfService, "could not get xtf service"); if (xtfService && NS_SUCCEEDED(xtfService->CreateElement(aResult, aNodeInfo))) return NS_OK; } #endif return NS_NewXMLElement(aResult, aNodeInfo); }