зеркало из https://github.com/mozilla/pjs.git
bug 330660, when constraining, skip underspecified items and do them later. This make certain more complex templates update properly. r+sr=bz
This commit is contained in:
Родитель
3336ccb2cb
Коммит
4a22557d1d
|
@ -79,8 +79,12 @@ nsContentTestNode::nsContentTestNode(nsXULTemplateQueryProcessorRDF* aProcessor,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsContentTestNode::FilterInstantiations(InstantiationSet& aInstantiations) const
|
||||
nsContentTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
|
||||
PRBool* aCantHandleYet) const
|
||||
|
||||
{
|
||||
if (aCantHandleYet)
|
||||
*aCantHandleYet = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,8 +58,8 @@ public:
|
|||
nsContentTestNode(nsXULTemplateQueryProcessorRDF* aProcessor,
|
||||
nsIAtom* aContentVariable);
|
||||
|
||||
virtual nsresult
|
||||
FilterInstantiations(InstantiationSet& aInstantiations) const;
|
||||
virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations,
|
||||
PRBool* aCantHandleYet) const;
|
||||
|
||||
nsresult
|
||||
Constrain(InstantiationSet& aInstantiations);
|
||||
|
|
|
@ -107,10 +107,14 @@ nsRDFConInstanceTestNode::nsRDFConInstanceTestNode(TestNode* aParent,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsRDFConInstanceTestNode::FilterInstantiations(InstantiationSet& aInstantiations) const
|
||||
nsRDFConInstanceTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
|
||||
PRBool* aCantHandleYet) const
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (aCantHandleYet)
|
||||
*aCantHandleYet = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIRDFContainerUtils> rdfc
|
||||
= do_GetService("@mozilla.org/rdf/container-utils;1");
|
||||
|
||||
|
|
|
@ -61,7 +61,8 @@ public:
|
|||
Test aContainer,
|
||||
Test aEmpty);
|
||||
|
||||
virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations) const;
|
||||
virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations,
|
||||
PRBool* aCantHandleYet) const;
|
||||
|
||||
virtual PRBool
|
||||
CanPropagate(nsIRDFResource* aSource,
|
||||
|
|
|
@ -98,11 +98,15 @@ nsRDFConMemberTestNode::nsRDFConMemberTestNode(TestNode* aParent,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsRDFConMemberTestNode::FilterInstantiations(InstantiationSet& aInstantiations) const
|
||||
nsRDFConMemberTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
|
||||
PRBool* aCantHandleYet) const
|
||||
{
|
||||
// XXX Uh, factor me, please!
|
||||
nsresult rv;
|
||||
|
||||
if (aCantHandleYet)
|
||||
*aCantHandleYet = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIRDFContainerUtils> rdfc =
|
||||
do_GetService("@mozilla.org/rdf/container-utils;1");
|
||||
|
||||
|
@ -476,8 +480,12 @@ nsRDFConMemberTestNode::FilterInstantiations(InstantiationSet& aInstantiations)
|
|||
|
||||
if (! hasContainerBinding && ! hasMemberBinding) {
|
||||
// Neither container nor member assignment!
|
||||
NS_ERROR("can't do open ended queries like that!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
if (!aCantHandleYet) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
*aCantHandleYet = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// finally, remove the "under specified" instantiation.
|
||||
|
|
|
@ -57,7 +57,8 @@ public:
|
|||
nsIAtom* aContainerVariable,
|
||||
nsIAtom* aMemberVariable);
|
||||
|
||||
virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations) const;
|
||||
virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations,
|
||||
PRBool* aCantHandleYet) const;
|
||||
|
||||
virtual PRBool
|
||||
CanPropagate(nsIRDFResource* aSource,
|
||||
|
|
|
@ -151,10 +151,14 @@ nsRDFPropertyTestNode::nsRDFPropertyTestNode(TestNode* aParent,
|
|||
|
||||
|
||||
nsresult
|
||||
nsRDFPropertyTestNode::FilterInstantiations(InstantiationSet& aInstantiations) const
|
||||
nsRDFPropertyTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
|
||||
PRBool* aCantHandleYet) const
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (aCantHandleYet)
|
||||
*aCantHandleYet = PR_FALSE;
|
||||
|
||||
nsIRDFDataSource* ds = mProcessor->GetDataSource();
|
||||
|
||||
InstantiationSet::Iterator last = aInstantiations.Last();
|
||||
|
@ -333,9 +337,13 @@ nsRDFPropertyTestNode::FilterInstantiations(InstantiationSet& aInstantiations) c
|
|||
aInstantiations.Erase(inst--);
|
||||
}
|
||||
else {
|
||||
// Neither source nor target assignment!
|
||||
NS_ERROR("can't do open ended queries like that!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
if (!aCantHandleYet) {
|
||||
// Neither source nor target assignment!
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
*aCantHandleYet = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,8 @@ public:
|
|||
nsIRDFResource* aProperty,
|
||||
nsIRDFNode* aTarget);
|
||||
|
||||
virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations) const;
|
||||
virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations,
|
||||
PRBool* aCantHandleYet) const;
|
||||
|
||||
virtual PRBool
|
||||
CanPropagate(nsIRDFResource* aSource,
|
||||
|
|
|
@ -337,7 +337,7 @@ TestNode::Propagate(InstantiationSet& aInstantiations,
|
|||
|
||||
aTakenInstantiations = PR_FALSE;
|
||||
|
||||
nsresult rv = FilterInstantiations(aInstantiations);
|
||||
nsresult rv = FilterInstantiations(aInstantiations, nsnull);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
@ -390,17 +390,27 @@ TestNode::Constrain(InstantiationSet& aInstantiations)
|
|||
PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
|
||||
("TestNode[%p]: Constrain() begin", this));
|
||||
|
||||
rv = FilterInstantiations(aInstantiations);
|
||||
// if the cantHandleYet flag is set by FilterInstantiations,
|
||||
// there isn't enough information yet available to fill in.
|
||||
// For this, continue the constrain all the way to the top
|
||||
// and then call FilterInstantiations again afterwards. This
|
||||
// should fill in any missing information.
|
||||
PRBool cantHandleYet = PR_FALSE;
|
||||
rv = FilterInstantiations(aInstantiations, &cantHandleYet);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (mParent && ! aInstantiations.Empty()) {
|
||||
// if we still have instantiations, then ride 'em on up to the
|
||||
if ((mParent && ! aInstantiations.Empty()) || cantHandleYet) {
|
||||
// if we still have instantiations, or if the instantiations
|
||||
// could not be filled in yet, then ride 'em on up to the
|
||||
// parent to narrow them.
|
||||
|
||||
PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
|
||||
("TestNode[%p]: Constrain() passing to parent %p", this, mParent));
|
||||
|
||||
rv = mParent->Constrain(aInstantiations);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && cantHandleYet)
|
||||
rv = FilterInstantiations(aInstantiations, nsnull);
|
||||
}
|
||||
else {
|
||||
PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
|
||||
|
|
|
@ -868,10 +868,14 @@ public:
|
|||
* those which do pass the test node's test.
|
||||
*
|
||||
* @param aInstantiations the set of instantiations to be
|
||||
* filtered
|
||||
* filtered
|
||||
* @param aCantHandleYet [out] true if the instantiations do not contain
|
||||
* enough information to constrain the data. May be null if this
|
||||
* isn't important to the caller.
|
||||
* @return NS_OK if no errors occurred.
|
||||
*/
|
||||
virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations) const = 0;
|
||||
virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations,
|
||||
PRBool* aCantHandleYet) const = 0;
|
||||
//XXX probably better named "ApplyConstraints" or "Discrminiate" or something
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче