void inDOMView::AppendKidsToArray(nsINodeList* aKids, nsCOMArray<nsIDOMNode>& aArray) { for (uint32_t i = 0, len = aKids->Length(); i < len; ++i) { nsIContent* kid = aKids->Item(i); uint16_t nodeType = kid->NodeType(); NS_ASSERTION(nodeType && nodeType <= nsINode::NOTATION_NODE, "Unknown node type. " "Were new types added to the spec?"); // As of DOM Level 2 Core and Traversal, each NodeFilter constant // is defined as the lower nth bit in the NodeFilter bitmask, // where n is the numeric constant of the nodeType it represents. // If this invariant ever changes, we will need to update the // following line. uint32_t filterForNodeType = 1 << (nodeType - 1); if (mWhatToShow & filterForNodeType) { if ((nodeType == nsINode::TEXT_NODE || nodeType == nsINode::COMMENT_NODE) && !mShowWhitespaceNodes) { nsCOMPtr<nsIContent> content = do_QueryInterface(kid); auto data = static_cast<nsGenericDOMDataNode*>(content.get()); NS_ASSERTION(data, "Does not implement nsIDOMCharacterData!"); if (InspectorUtils::IsIgnorableWhitespace(*data)) { continue; } } nsCOMPtr<nsIDOMNode> node = do_QueryInterface(kid); aArray.AppendElement(node.forget()); } } }
bool nsPerformanceSnapshot::IterPerformanceStatsCallbackInternal(JSContext* cx, const js::PerformanceData& stats, const uint64_t uid) { nsCOMPtr<nsIPerformanceStats> result = ImportStats(cx, stats, uid); if (result) { mComponentsData.AppendElement(result); } return true; }
nsresult inDOMView::AppendAttrsToArray(nsDOMAttributeMap* aAttributes, nsCOMArray<nsIDOMNode>& aArray) { uint32_t l = aAttributes->Length(); for (uint32_t i = 0; i < l; ++i) { aArray.AppendElement(aAttributes->Item(i)); } return NS_OK; }
bool nsPerformanceSnapshot::IterPerformanceStatsCallbackInternal(JSContext* cx, const js::PerformanceData& stats, const uint64_t id, const uint64_t* parentId) { nsCOMPtr<nsIPerformanceStats> parent = parentId ? mCachedStats.Get(*parentId) : nullptr; nsCOMPtr<nsIPerformanceStats> result = ImportStats(cx, stats, id, parent); if (result) { mComponentsData.AppendElement(result); mCachedStats.Put(id, result); } return true; }
void XPTInterfaceInfoManager::GetScriptableInterfaces(nsCOMArray<nsIInterfaceInfo>& aInterfaces) { // I didn't want to incur the size overhead of using nsHashtable just to // make building an enumerator easier. So, this code makes a snapshot of // the table using an nsISupportsArray and builds an enumerator for that. // We can afford this transient cost. ReentrantMonitorAutoEnter monitor(mWorkingSet.mTableReentrantMonitor); aInterfaces.SetCapacity(mWorkingSet.mNameTable.Count()); for (auto iter = mWorkingSet.mNameTable.Iter(); !iter.Done(); iter.Next()) { xptiInterfaceEntry* entry = iter.UserData(); if (entry->GetScriptableFlag()) { nsCOMPtr<nsIInterfaceInfo> ii = entry->InterfaceInfo(); aInterfaces.AppendElement(ii); } } }
void nsPerformanceSnapshot::AppendComponentsStats(nsIPerformanceStats* stats) { mComponentsData.AppendElement(stats); }