void Attr::SetTextContentInternal(const nsAString& aTextContent, nsIPrincipal* aSubjectPrincipal, ErrorResult& aError) { SetNodeValueInternal(aTextContent, aError); }
void Attr::SetTextContentInternal(const nsAString& aTextContent, ErrorResult& aError) { OwnerDoc()->WarnOnceAbout(nsIDocument::eTextContent); SetNodeValueInternal(aTextContent, aError); }
nsresult nsXFormsMDGEngine::SetNodeValue(nsIDOMNode *aContextNode, const nsAString &aNodeValue, PRBool *aNodeChanged) { return SetNodeValueInternal(aContextNode, aNodeValue, PR_TRUE, PR_FALSE, aNodeChanged); }
nsresult nsXFormsMDGEngine::Recalculate(nsCOMArray<nsIDOMNode> *aChangedNodes) { NS_ENSURE_ARG(aChangedNodes); #ifdef DEBUG_XF_MDG printf("nsXFormsMDGEngine::Recalculate(aChangedNodes=|%d|)\n", aChangedNodes->Count()); #endif // XXX: There's something wrong with the marking of nodes, as we assume that // recalculate will always be called first. bug 338146 nsresult rv = HandleMarkedNodes(aChangedNodes); NS_ENSURE_SUCCESS(rv, rv); PRBool res = PR_TRUE; mFirstCalculate = mJustRebuilt; #ifdef DEBUG_XF_MDG printf("\taChangedNodes: %d\n", aChangedNodes->Count()); printf("\tmNodeToMDG: %d\n", mNodeToMDG.Count()); printf("\tmNodeStates: %d\n", mNodeStates.Count()); printf("\tGraph nodes: %d\n", mGraph.Count()); #endif // Go through all dirty nodes in the graph nsXFormsMDGNode* g; for (PRInt32 i = 0; i < mGraph.Count(); ++i) { g = static_cast<nsXFormsMDGNode*>(mGraph[i]); if (!g) { NS_WARNING("nsXFormsMDGEngine::Calculate(): Empty node in graph!!!"); continue; } NS_ASSERTION(g->mCount == 0, "nsXFormsMDGEngine::Calculate(): Graph node with mCount != 0"); #ifdef DEBUG_XF_MDG nsAutoString domNodeName; g->mContextNode->GetNodeName(domNodeName); printf("\tNode #%d: This=%p, Dirty=%d, DynFunc=%d, Type=%d, Count=%d, Suc=%d, CSize=%d, CPos=%d, Next=%p, HasExpr=%d, domnode=%s\n", i, (void*) g, g->IsDirty(), g->mDynFunc, g->mType, g->mCount, g->mSuc.Count(), g->mContextSize, g->mContextPosition, (void*) g->mNext, g->HasExpr(), NS_ConvertUTF16toUTF8(domNodeName).get()); #endif // Ignore node if it is not dirty if (!g->IsDirty()) { continue; } nsXFormsNodeState* ns = GetNCNodeState(g->mContextNode); NS_ENSURE_TRUE(ns, NS_ERROR_FAILURE); PRBool constraint = PR_TRUE; PRBool conChanged; // Find MIP-type and handle it accordingly switch (g->mType) { case eModel_calculate: if (g->HasExpr()) { nsCOMPtr<nsISupports> result; rv = g->mExpression->EvaluateWithContext(g->mContextNode, g->mContextPosition, g->mContextSize, nsIDOMXPathResult::STRING_TYPE, nsnull, getter_AddRefs(result)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIDOMXPathResult> xpath_res = do_QueryInterface(result); NS_ENSURE_STATE(xpath_res); nsAutoString nodeval; rv = xpath_res->GetStringValue(nodeval); NS_ENSURE_SUCCESS(rv, rv); rv = SetNodeValueInternal(g->mContextNode, nodeval, PR_FALSE, PR_TRUE); if (NS_SUCCEEDED(rv)) { NS_ENSURE_TRUE(aChangedNodes->AppendObject(g->mContextNode), NS_ERROR_FAILURE); } ns->Set(eFlag_DISPATCH_VALUE_CHANGED, PR_TRUE); } break; case eModel_constraint: if (g->HasExpr()) { rv = BooleanExpression(g, constraint); NS_ENSURE_SUCCESS(rv, rv); } conChanged = ns->IsConstraint() != constraint; // On the first calculate after a rebuild (mFirstCalculate) we also // add constraints to the set of changed nodes to trigger validation // of type information if present. if (conChanged || mFirstCalculate) { if (conChanged) { ns->Set(eFlag_CONSTRAINT, constraint); ns->Set(eFlag_DISPATCH_VALID_CHANGED, PR_TRUE); } NS_ENSURE_TRUE(aChangedNodes->AppendObject(g->mContextNode), NS_ERROR_FAILURE); } break; case eModel_readonly: if (g->HasExpr()) { rv = ComputeMIPWithInheritance(eFlag_READONLY, eFlag_DISPATCH_READONLY_CHANGED, eFlag_INHERITED_READONLY, g, aChangedNodes); NS_ENSURE_SUCCESS(rv, rv); } break; case eModel_relevant: if (g->HasExpr()) { rv = ComputeMIPWithInheritance(eFlag_RELEVANT, eFlag_DISPATCH_RELEVANT_CHANGED, eFlag_INHERITED_RELEVANT, g, aChangedNodes); NS_ENSURE_SUCCESS(rv, rv); } break; case eModel_required: if (g->HasExpr()) { PRBool didChange; rv = ComputeMIP(eFlag_REQUIRED, eFlag_DISPATCH_REQUIRED_CHANGED, g, didChange); NS_ENSURE_SUCCESS(rv, rv); if (didChange) { NS_ENSURE_TRUE(aChangedNodes->AppendObject(g->mContextNode), NS_ERROR_FAILURE); } } break; default: NS_ERROR("There was no expression which matched\n"); res = PR_FALSE; break; } // Mark successors dirty nsXFormsMDGNode* sucnode; for (PRInt32 j = 0; j < g->mSuc.Count(); ++j) { sucnode = static_cast<nsXFormsMDGNode*>(g->mSuc[j]); if (!sucnode) { NS_ERROR("nsXFormsMDGEngine::Calculate(): Node has NULL successor!"); return NS_ERROR_FAILURE; } sucnode->MarkDirty(); } g->MarkClean(); } nsXFormsUtils::MakeUniqueAndSort(aChangedNodes); #ifdef DEBUG_XF_MDG printf("\taChangedNodes: %d\n", aChangedNodes->Count()); printf("\tmNodeToMDG: %d\n", mNodeToMDG.Count()); printf("\tmNodeStates: %d\n", mNodeStates.Count()); printf("\tGraph nodes: %d\n", mGraph.Count()); #endif return res; }