Bug 1425356 - remove XUL template support, r=bz
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 19 Dec 2017 14:11:06 +0000
changeset 397696 ca915358876060cbaab7cc2eac1c93847dd9ea0e
parent 397695 490e100ac2e55214f41728c5e5d3dbb8ba7eb4f5
child 397697 886d3489da20955f3549085bf35aa9e573e6778a
push id33189
push usernerli@mozilla.com
push dateThu, 04 Jan 2018 09:45:12 +0000
treeherdermozilla-central@f78a83244fbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1425356
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1425356 - remove XUL template support, r=bz MozReview-Commit-ID: HdBoQ15DFOu
browser/installer/package-manifest.in
dom/tests/mochitest/general/test_interfaces.js
dom/webidl/LegacyQueryInterface.webidl
dom/webidl/XULElement.webidl
dom/webidl/XULTemplateBuilder.webidl
dom/webidl/moz.build
dom/xul/XULDocument.cpp
dom/xul/XULDocument.h
dom/xul/moz.build
dom/xul/nsIXULDocument.h
dom/xul/nsIXULSortService.idl
dom/xul/nsXULContentUtils.cpp
dom/xul/nsXULContentUtils.h
dom/xul/nsXULElement.cpp
dom/xul/nsXULElement.h
dom/xul/nsXULSortService.cpp
dom/xul/nsXULSortService.h
dom/xul/templates/crashtests/257752-1-recursion.rdf
dom/xul/templates/crashtests/257752-1-recursion.xul
dom/xul/templates/crashtests/329884-1.xul
dom/xul/templates/crashtests/330012-1.rdf
dom/xul/templates/crashtests/330012-1.xul
dom/xul/templates/crashtests/404346-1.xul
dom/xul/templates/crashtests/415019-1.xul
dom/xul/templates/crashtests/417840-1.xul
dom/xul/templates/crashtests/424418-1.xul
dom/xul/templates/crashtests/crashtests.list
dom/xul/templates/moz.build
dom/xul/templates/nsContentSupportMap.cpp
dom/xul/templates/nsContentSupportMap.h
dom/xul/templates/nsContentTestNode.cpp
dom/xul/templates/nsContentTestNode.h
dom/xul/templates/nsIXULBuilderListener.idl
dom/xul/templates/nsIXULSortService.idl
dom/xul/templates/nsIXULTemplateBuilder.idl
dom/xul/templates/nsIXULTemplateQueryProcessor.idl
dom/xul/templates/nsIXULTemplateResult.idl
dom/xul/templates/nsIXULTemplateRuleFilter.idl
dom/xul/templates/nsInstantiationNode.cpp
dom/xul/templates/nsInstantiationNode.h
dom/xul/templates/nsRDFBinding.cpp
dom/xul/templates/nsRDFBinding.h
dom/xul/templates/nsRDFConInstanceTestNode.cpp
dom/xul/templates/nsRDFConInstanceTestNode.h
dom/xul/templates/nsRDFConMemberTestNode.cpp
dom/xul/templates/nsRDFConMemberTestNode.h
dom/xul/templates/nsRDFPropertyTestNode.cpp
dom/xul/templates/nsRDFPropertyTestNode.h
dom/xul/templates/nsRDFQuery.cpp
dom/xul/templates/nsRDFQuery.h
dom/xul/templates/nsRDFTestNode.h
dom/xul/templates/nsResourceSet.cpp
dom/xul/templates/nsResourceSet.h
dom/xul/templates/nsRuleNetwork.cpp
dom/xul/templates/nsRuleNetwork.h
dom/xul/templates/nsTemplateMap.h
dom/xul/templates/nsTemplateMatch.cpp
dom/xul/templates/nsTemplateMatch.h
dom/xul/templates/nsTemplateRule.cpp
dom/xul/templates/nsTemplateRule.h
dom/xul/templates/nsTreeRows.cpp
dom/xul/templates/nsTreeRows.h
dom/xul/templates/nsXMLBinding.cpp
dom/xul/templates/nsXMLBinding.h
dom/xul/templates/nsXULContentBuilder.cpp
dom/xul/templates/nsXULContentUtils.cpp
dom/xul/templates/nsXULContentUtils.h
dom/xul/templates/nsXULResourceList.h
dom/xul/templates/nsXULSortService.cpp
dom/xul/templates/nsXULSortService.h
dom/xul/templates/nsXULTemplateBuilder.cpp
dom/xul/templates/nsXULTemplateBuilder.h
dom/xul/templates/nsXULTemplateQueryProcessorRDF.cpp
dom/xul/templates/nsXULTemplateQueryProcessorRDF.h
dom/xul/templates/nsXULTemplateQueryProcessorStorage.cpp
dom/xul/templates/nsXULTemplateQueryProcessorStorage.h
dom/xul/templates/nsXULTemplateQueryProcessorXML.cpp
dom/xul/templates/nsXULTemplateQueryProcessorXML.h
dom/xul/templates/nsXULTemplateResultRDF.cpp
dom/xul/templates/nsXULTemplateResultRDF.h
dom/xul/templates/nsXULTemplateResultSetRDF.cpp
dom/xul/templates/nsXULTemplateResultSetRDF.h
dom/xul/templates/nsXULTemplateResultStorage.cpp
dom/xul/templates/nsXULTemplateResultStorage.h
dom/xul/templates/nsXULTemplateResultXML.cpp
dom/xul/templates/nsXULTemplateResultXML.h
dom/xul/templates/nsXULTreeBuilder.cpp
dom/xul/templates/nsXULTreeBuilder.h
dom/xul/templates/tests/chrome/animals.rdf
dom/xul/templates/tests/chrome/animals.sqlite
dom/xul/templates/tests/chrome/animals.xml
dom/xul/templates/tests/chrome/bug441785-1.rdf
dom/xul/templates/tests/chrome/bug441785-2.rdf
dom/xul/templates/tests/chrome/chrome.ini
dom/xul/templates/tests/chrome/file_bug330010.rdf
dom/xul/templates/tests/chrome/templates_shared.js
dom/xul/templates/tests/chrome/test_bug329335.xul
dom/xul/templates/tests/chrome/test_bug330010.xul
dom/xul/templates/tests/chrome/test_bug397148.xul
dom/xul/templates/tests/chrome/test_bug441785.xul
dom/xul/templates/tests/chrome/test_bug476634.xul
dom/xul/templates/tests/chrome/test_sortservice.xul
dom/xul/templates/tests/chrome/test_tmpl_bindingsextendedsyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_bindingsmultiple.xul
dom/xul/templates/tests/chrome/test_tmpl_bindingsquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_bindingsreversed.xul
dom/xul/templates/tests/chrome/test_tmpl_bindingssameastriple.xul
dom/xul/templates/tests/chrome/test_tmpl_containerandmembervariablechanged.xul
dom/xul/templates/tests/chrome/test_tmpl_containervariablechanged.xul
dom/xul/templates/tests/chrome/test_tmpl_containmentattribute.xul
dom/xul/templates/tests/chrome/test_tmpl_defaultcontainervariableisuri.xul
dom/xul/templates/tests/chrome/test_tmpl_errors.xul
dom/xul/templates/tests/chrome/test_tmpl_extendedsyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxemptyconditions.xul
dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxotherrefvariable.xul
dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxremoveunmatched.xul
dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxsimplevariablesubstitution.xul
dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxtworulesrecurse.xul
dom/xul/templates/tests/chrome/test_tmpl_extendedsyntaxusinganinterveningcontainer.xul
dom/xul/templates/tests/chrome/test_tmpl_extendedvariablesubstitution.xul
dom/xul/templates/tests/chrome/test_tmpl_gridelement.xul
dom/xul/templates/tests/chrome/test_tmpl_htmlelementextendedsyntaxwithbinding.xul
dom/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxrecursive.xul
dom/xul/templates/tests/chrome/test_tmpl_htmlelementquerysyntaxwithmultiplerules.xul
dom/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_htmlelementsimplesyntaxusingatextnode.xul
dom/xul/templates/tests/chrome/test_tmpl_invalidqp.xul
dom/xul/templates/tests/chrome/test_tmpl_listboxelement.xul
dom/xul/templates/tests/chrome/test_tmpl_literalasmember.xul
dom/xul/templates/tests/chrome/test_tmpl_membervariablechanged.xul
dom/xul/templates/tests/chrome/test_tmpl_membervariablesubstitution.xul
dom/xul/templates/tests/chrome/test_tmpl_menuelement.xul
dom/xul/templates/tests/chrome/test_tmpl_menuelementrecursive.xul
dom/xul/templates/tests/chrome/test_tmpl_menulistelement.xul
dom/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainer.xul
dom/xul/templates/tests/chrome/test_tmpl_mixedsyntaxiscontainerisempty.xul
dom/xul/templates/tests/chrome/test_tmpl_mixedsyntaxisempty.xul
dom/xul/templates/tests/chrome/test_tmpl_noaction.xul
dom/xul/templates/tests/chrome/test_tmpl_noactionuriattribute.xul
dom/xul/templates/tests/chrome/test_tmpl_parentconditions.xul
dom/xul/templates/tests/chrome/test_tmpl_parentcontenttag.xul
dom/xul/templates/tests/chrome/test_tmpl_parentsimplesyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_query3triples.xul
dom/xul/templates/tests/chrome/test_tmpl_query3tripleswherecontains.xul
dom/xul/templates/tests/chrome/test_tmpl_querymember3tripleswhereequals.xul
dom/xul/templates/tests/chrome/test_tmpl_querymemberandtwotriples.xul
dom/xul/templates/tests/chrome/test_tmpl_querymembertriplemembertriple.xul
dom/xul/templates/tests/chrome/test_tmpl_queryresourcematch.xul
dom/xul/templates/tests/chrome/test_tmpl_queryreversetriple.xul
dom/xul/templates/tests/chrome/test_tmpl_queryselfwithtriple.xul
dom/xul/templates/tests/chrome/test_tmpl_querysetone.xul
dom/xul/templates/tests/chrome/test_tmpl_querysettwo.xul
dom/xul/templates/tests/chrome/test_tmpl_querysettwowithcondition.xul
dom/xul/templates/tests/chrome/test_tmpl_querysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerules.xul
dom/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulesfirstconditionall.xul
dom/xul/templates/tests/chrome/test_tmpl_querysyntaxmultiplerulestwoconditions.xul
dom/xul/templates/tests/chrome/test_tmpl_querytripleandmembermerge.xul
dom/xul/templates/tests/chrome/test_tmpl_querytripleobjecttosubject.xul
dom/xul/templates/tests/chrome/test_tmpl_querytwomembers.xul
dom/xul/templates/tests/chrome/test_tmpl_querytwomembersfiltered.xul
dom/xul/templates/tests/chrome/test_tmpl_querytwotriples.xul
dom/xul/templates/tests/chrome/test_tmpl_queryupwardsmember.xul
dom/xul/templates/tests/chrome/test_tmpl_queryupwardsmembertripleandfilteringtriple.xul
dom/xul/templates/tests/chrome/test_tmpl_querywithemptyconditions.xul
dom/xul/templates/tests/chrome/test_tmpl_referenceasmember.xul
dom/xul/templates/tests/chrome/test_tmpl_regenerate.xul
dom/xul/templates/tests/chrome/test_tmpl_selfgenerationextendedsyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_selfgenerationsimplesyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainer.xul
dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxenclosedinacontainerwitharule.xul
dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilter.xul
dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithmultiplerules.xul
dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxfilterwithrule.xul
dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxiteratingoverasinglevalue.xul
dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusinganinterveningcontainer.xul
dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingatextnode.xul
dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingcontainerasthegenerationelement.xul
dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingdontrecurse.xul
dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegeneration.xul
dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxusingrecursivegenerationagain.xul
dom/xul/templates/tests/chrome/test_tmpl_simplesyntaxwithtwovariablesused.xul
dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsatbeginningandend.xul
dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutioncaretsubstitution.xul
dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionnovariable.xul
dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarkaspartofvariable.xul
dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionquestionmarksubstitution.xul
dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutiontextandvariable.xul
dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariableandtextconcatenated.xul
dom/xul/templates/tests/chrome/test_tmpl_simplevariablesubstitutionvariablesconcatenated.xul
dom/xul/templates/tests/chrome/test_tmpl_sortascendinginteger.xul
dom/xul/templates/tests/chrome/test_tmpl_sortascendingquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sortascendingtworulesquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithcontainerquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sortascendingtworuleswithdifferentcontainerquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sortdescendingquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sortquerymemberandtwotriples.xul
dom/xul/templates/tests/chrome/test_tmpl_sortresource2descendingsimplesyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicateascendingquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sortresource2settopredicatedescendingquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sortresourceascendingquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sortresourcedescendingquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicateascendingquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sortresourcesettopredicatedescendingquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sorttworesourcesasstringsettopredicatedescendingquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sorttworesourcessettopredicateascendingquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sorttwovariablesascendingsimplesyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sorttwovariablesdescendingquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_sortunknownascendingquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_2.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_bad_parameters_3.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_baddatasource.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_badquery.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_dynamicparameters.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_listbox.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_multiqueries.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_parameters.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_rule.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_simple.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_sortintegerasc.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_sortintegerdesc.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_sortstringasc.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_sortstringdesc.xul
dom/xul/templates/tests/chrome/test_tmpl_storage_tree.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntax.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxnotrecursive.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxnotrecursivetreebuilder.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursive.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivemultiplerules.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivemultiplerulestreebuilder.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxrecursivetreebuilder.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementquerysyntaxtreebuilder.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxnotrecursive.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxnotrecursivetreebuilder.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxrecursive.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementsimplesyntaxrecursivetreebuilder.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecell.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecellsortascending.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecellsortascendingtreebuilder.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementtreecelltreebuilder.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementtreeitemonly.xul
dom/xul/templates/tests/chrome/test_tmpl_treeelementtreeitemsortascending.xul
dom/xul/templates/tests/chrome/test_tmpl_twogenerationnodes.xul
dom/xul/templates/tests/chrome/test_tmpl_whereafterignorecase.xul
dom/xul/templates/tests/chrome/test_tmpl_whereafterlowercase.xul
dom/xul/templates/tests/chrome/test_tmpl_whereafternegation.xul
dom/xul/templates/tests/chrome/test_tmpl_whereafteruppercase.xul
dom/xul/templates/tests/chrome/test_tmpl_wherebeforeignorecase.xul
dom/xul/templates/tests/chrome/test_tmpl_wherebeforelowercase.xul
dom/xul/templates/tests/chrome/test_tmpl_wherebeforenegation.xul
dom/xul/templates/tests/chrome/test_tmpl_wherebeforeuppercase.xul
dom/xul/templates/tests/chrome/test_tmpl_wherecontains.xul
dom/xul/templates/tests/chrome/test_tmpl_wherecontainsignorecase.xul
dom/xul/templates/tests/chrome/test_tmpl_wherecontainsnegation.xul
dom/xul/templates/tests/chrome/test_tmpl_wherecontainsnumber.xul
dom/xul/templates/tests/chrome/test_tmpl_wherecontainsnumberstring.xul
dom/xul/templates/tests/chrome/test_tmpl_wherecontainsresource.xul
dom/xul/templates/tests/chrome/test_tmpl_wherecontainstwo.xul
dom/xul/templates/tests/chrome/test_tmpl_whereendswith.xul
dom/xul/templates/tests/chrome/test_tmpl_whereendswithignorecase.xul
dom/xul/templates/tests/chrome/test_tmpl_whereendswithnegation.xul
dom/xul/templates/tests/chrome/test_tmpl_whereequals.xul
dom/xul/templates/tests/chrome/test_tmpl_whereequalsignorecase.xul
dom/xul/templates/tests/chrome/test_tmpl_whereequalsmultiple.xul
dom/xul/templates/tests/chrome/test_tmpl_whereequalsmultiplenegation.xul
dom/xul/templates/tests/chrome/test_tmpl_whereequalsmultiplenegationignorecase.xul
dom/xul/templates/tests/chrome/test_tmpl_whereequalsnegation.xul
dom/xul/templates/tests/chrome/test_tmpl_whereequalsnegationignorecase.xul
dom/xul/templates/tests/chrome/test_tmpl_whereequalsnegationwrongcase.xul
dom/xul/templates/tests/chrome/test_tmpl_whereequalsnumber.xul
dom/xul/templates/tests/chrome/test_tmpl_whereequalsothervariable.xul
dom/xul/templates/tests/chrome/test_tmpl_whereequalsresource.xul
dom/xul/templates/tests/chrome/test_tmpl_whereequalssamevariable.xul
dom/xul/templates/tests/chrome/test_tmpl_whereequalswrongcase.xul
dom/xul/templates/tests/chrome/test_tmpl_wheregreater.xul
dom/xul/templates/tests/chrome/test_tmpl_wheregreaternegation.xul
dom/xul/templates/tests/chrome/test_tmpl_wheregreaternegationstring.xul
dom/xul/templates/tests/chrome/test_tmpl_wheregreaterstring.xul
dom/xul/templates/tests/chrome/test_tmpl_whereless.xul
dom/xul/templates/tests/chrome/test_tmpl_wherelessnegation.xul
dom/xul/templates/tests/chrome/test_tmpl_wherelessnegationstring.xul
dom/xul/templates/tests/chrome/test_tmpl_wherelessstring.xul
dom/xul/templates/tests/chrome/test_tmpl_wherenorel.xul
dom/xul/templates/tests/chrome/test_tmpl_wherenosubject.xul
dom/xul/templates/tests/chrome/test_tmpl_wherenovalue.xul
dom/xul/templates/tests/chrome/test_tmpl_wherestartswith.xul
dom/xul/templates/tests/chrome/test_tmpl_wherestartswithignorecase.xul
dom/xul/templates/tests/chrome/test_tmpl_wherestartswithmultiple.xul
dom/xul/templates/tests/chrome/test_tmpl_wherestartswithnegation.xul
dom/xul/templates/tests/chrome/test_tmpl_wherestartswithunknownvariable.xul
dom/xul/templates/tests/chrome/test_tmpl_wherestartswithvariable.xul
dom/xul/templates/tests/chrome/test_tmpl_wheresubjectequalsvariable.xul
dom/xul/templates/tests/chrome/test_tmpl_wheresubjectstartswithvariable.xul
dom/xul/templates/tests/chrome/test_tmpl_xmlquerysimple.xul
dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithassign.xul
dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithassignmentandcondition.xul
dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithassignmentandconditiondontrecurse.xul
dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithbindinginbindings.xul
dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithbindinginrule.xul
dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithdifferentmember.xul
dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithinlinedata.xul
dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithinlinedatawithmultiplequeries.xul
dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithmultiplequeries.xul
dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithothertypes.xul
dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithsort.xul
dom/xul/templates/tests/chrome/test_tmpl_xmlquerywithsortotherfield.xul
layout/build/moz.build
layout/xul/nsXULPopupManager.cpp
layout/xul/tree/TreeBoxObject.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
mobile/android/installer/package-manifest.in
testing/crashtest/crashtests.list
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -335,17 +335,16 @@
 @RESPATH@/components/xpcom_components.xpt
 @RESPATH@/components/xpcom_ds.xpt
 @RESPATH@/components/xpcom_io.xpt
 @RESPATH@/components/xpcom_threads.xpt
 @RESPATH@/components/xpcom_xpti.xpt
 @RESPATH@/components/xpconnect.xpt
 @RESPATH@/components/xulapp.xpt
 @RESPATH@/components/xul.xpt
-@RESPATH@/components/xultmpl.xpt
 @RESPATH@/components/zipwriter.xpt
 @RESPATH@/components/telemetry.xpt
 
 ; JavaScript components
 @RESPATH@/components/ConsoleAPI.manifest
 @RESPATH@/components/ConsoleAPIStorage.js
 @RESPATH@/components/BrowserElementParent.manifest
 @RESPATH@/components/BrowserElementParent.js
--- a/dom/tests/mochitest/general/test_interfaces.js
+++ b/dom/tests/mochitest/general/test_interfaces.js
@@ -1270,22 +1270,16 @@ var interfaceNamesInGlobalScope =
     {name: "XULControlElement", xbl: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "XULDocument", xbl: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "XULElement", xbl: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "XULLabeledControlElement", xbl: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "XULTemplateBuilder", xbl: true},
-// IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "XULTreeBuilder", xbl: true},
-// IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "XULTreeBuilderObserver", xbl: true},
-// IMPORTANT: Do not change this list without review from a DOM peer!
   ];
 // IMPORTANT: Do not change the list above without review from a DOM peer!
 
 function createInterfaceMap(isXBLScope) {
   var version = SpecialPowers.Cc["@mozilla.org/xre/app-info;1"].getService(SpecialPowers.Ci.nsIXULAppInfo).version;
   var isNightly = version.endsWith("a1");
   var isRelease = !version.includes("a");
   var isDesktop = !/Mobile|Tablet/.test(navigator.userAgent);
--- a/dom/webidl/LegacyQueryInterface.webidl
+++ b/dom/webidl/LegacyQueryInterface.webidl
@@ -87,9 +87,8 @@ TreeContentView implements LegacyQueryIn
 TreeWalker implements LegacyQueryInterface;
 ValidityState implements LegacyQueryInterface;
 WebSocket implements LegacyQueryInterface;
 Window implements LegacyQueryInterface;
 XMLHttpRequest implements LegacyQueryInterface;
 XMLHttpRequestUpload implements LegacyQueryInterface;
 XMLSerializer implements LegacyQueryInterface;
 XPathEvaluator implements LegacyQueryInterface;
-XULTemplateBuilder implements LegacyQueryInterface;
--- a/dom/webidl/XULElement.webidl
+++ b/dom/webidl/XULElement.webidl
@@ -1,17 +1,15 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 interface XULControllers;
-interface MozRDFCompositeDataSource;
-interface MozRDFResource;
 
 [HTMLConstructor, Func="IsChromeOrXBL"]
 interface XULElement : Element {
   // Layout properties
   [SetterThrows]
   attribute DOMString align;
   [SetterThrows]
   attribute DOMString dir;
@@ -63,38 +61,28 @@ interface XULElement : Element {
   // Position properties for
   // * popups - these are screen coordinates
   // * other elements - these are client coordinates relative to parent stack.
   [SetterThrows]
   attribute DOMString left;
   [SetterThrows]
   attribute DOMString top;
 
-  // XUL Template Builder
-  [SetterThrows]
-  attribute DOMString datasources;
-  [SetterThrows]
-  attribute DOMString ref;
-
   // Tooltip and status info
   [SetterThrows]
   attribute DOMString tooltipText;
   [SetterThrows]
   attribute DOMString statusText;
 
   // Properties for images
   [SetterThrows]
   attribute DOMString src;
 
   attribute boolean allowEvents;
 
-  readonly attribute MozRDFCompositeDataSource? database;
-  readonly attribute XULTemplateBuilder?        builder;
-  [Throws]
-  readonly attribute MozRDFResource?            resource;
   [Throws, ChromeOnly]
   readonly attribute XULControllers             controllers;
   [Throws]
   readonly attribute BoxObject?                 boxObject;
 
   [Throws]
   void                      focus();
   [Throws]
deleted file mode 100644
--- a/dom/webidl/XULTemplateBuilder.webidl
+++ /dev/null
@@ -1,398 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-interface MozRDFCompositeDataSource;
-interface MozRDFResource;
-interface nsISupports;
-interface XULTemplateResult;
-interface XULTemplateRuleFilter;
-
-callback interface XULBuilderListener
-{
-    void willRebuild(XULTemplateBuilder aBuilder);
-    void didRebuild(XULTemplateBuilder aBuilder);
-};
-
-/**
- * A template builder, given an input source of data, a template, and a
- * reference point, generates a list of results from the input, and copies
- * part of the template for each result. Templates may generate content
- * recursively, using the same template, but with the previous iteration's
- * results as the reference point. As an example, for an XML datasource the
- * initial reference point would be a specific node in the DOM tree and a
- * template might generate a list of all child nodes. For the next iteration,
- * those children would be used to generate output for their child nodes and
- * so forth.
- *
- * A template builder is attached to a single DOM node; this node is called
- * the root node and is expected to contain a XUL template element as a direct
- * child. Different template builders may be specialized in the manner in
- * which they generate and display the resulting content from the template.
- *
- * The structure of a template is as follows:
- *
- * <rootnode datasources="" ref="">
- *   <template>
- *     <queryset>
- *       <query>
- *       </query>
- *       <rule>
- *         <conditions>...</conditions>
- *         <bindings>...</bindings>
- *         <action>...</action>
- *       </rule>
- *     </queryset>
- *   </template>
- * </rootnode>
- *
- * The datasources attribute on the root node is used to identify the source
- * of data to be used. The ref attribute is used to specify the reference
- * point for the query. Currently, the datasource will either be an
- * nsIRDFDataSource or a DOM node. In the future, other datasource types may
- * be used.
- *
- * The <queryset> element contains a single query and one or more <rule>
- * elements. There may be more than one <queryset> if multiple queries are
- * desired, and this element is optional if only one query is needed -- in
- * that case the <query> and <rule>s are allowed to be children of the
- * <template> node
- *
- * The contents of the query are processed by a separate component called a
- * query processor. This query processor is expected to use this query to
- * generate results when asked by the template builder. The template builder
- * then generates output for each result based on the <rule> elements.
- *
- * This allows the query processor to be specific to a particular kind of
- * input data or query syntax, while the template builder remains independent
- * of the kind of data being used. Due to this, the query processor will be
- * supplied with the datasource and query which the template builder handles
- * in an opaque way, while the query processor handles these more
- * specifically.
- *
- * Results implement the nsIXULTemplateResult interface and may be identified
- * by an id which must be unique within a given set of query results.
- *
- * Each query may be accompanied by one or more <rule> elements. These rules
- * are evaluated by the template builder for each result produced by the
- * query. A rule consists of conditions that cause a rule to be either
- * accepted or rejected. The condition syntax allows for common conditional
- * handling; additional filtering may be applied by adding a custom filter
- * to a rule with the builder's addRuleFilter method.
- *
- * If a result passes a rule's conditions, this is considered a match, and the
- * content within the rule's <action> body is inserted as a sibling of the
- * <template>, assuming the template builder creates real DOM content. Only
- * one rule will match a result. For a tree builder, for example, the content
- * within the action body is used to create the tree rows instead. A matching
- * result must have its ruleMatched method called. When a result no longer
- * matches, the result's hasBeenRemoved method must be called.
- *
- * Optionally, the rule may have a <bindings> section which may be used to
- * define additional variables to be used within an action body. Each of these
- * declared bindings must be supplied to the query processor via its
- * addBinding method. The bindings are evaluated after a rule has matched.
- *
- * Templates may generate content recursively, using the previous iteration's
- * results as reference point to invoke the same queries. Since the reference
- * point is different, different output will typically be generated.
- *
- * The reference point nsIXULTemplateResult object for the first iteration is
- * determined by calling the query processor's translateRef method using the
- * value of the root node's ref attribute. This object may be retrieved later
- * via the builder's rootResult property.
- *
- * For convenience, each reference point as well as all results implement the
- * nsIXULTemplateResult interface, allowing the result objects from each
- * iteration to be used directly as the reference points for the next
- * iteration.
- *
- * When using multiple queries, each may generate results with the same id.
- * More than one of these results may match one of the rules in their
- * respective queries, however only the result for the earliest matching query
- * in the template becomes the active match and generates output. The
- * addResult, removeResult, replaceResult and resultBindingChanged methods may
- * be called by the query processor to indicate that the set of valid results
- * has changed, such that a different query may match. If a different match
- * would become active, the content for the existing match is removed and the
- * content for the new match is generated. A query processor is not required
- * to provide any support for updating results after they have been generated.
- *
- * See http://wiki.mozilla.org/XUL:Templates_Plan for details about templates.
- */
-[Func="IsChromeOrXBL"]
-interface XULTemplateBuilder
-{
-    /**
-     * The root node in the DOM to which this builder is attached.
-     */
-    readonly attribute Element? root;
-
-    /**
-     * The opaque datasource object that is used for the template. This object
-     * is created by the getDataSource method of the query processor. May be
-     * null if the datasource has not been loaded yet. Set this attribute to
-     * use a different datasource and rebuild the template.
-     *
-     * For an RDF datasource, this will be the same as the database. For XML
-     * this will be the nsIDOMNode for the datasource document or node for
-     * an inline reference (such as #name). Other query processors may use
-     * other types for the datasource.
-     */
-    [SetterThrows]
-    attribute nsISupports? datasource;
-
-    /**
-     * The composite datasource that the template builder observes
-     * and uses to create content. This is used only for RDF queries and is
-     * maintained for backwards compatibility. It will be the same object as
-     * the datasource property. For non-RDF queries, it will always be null.
-     */
-    readonly attribute MozRDFCompositeDataSource? database;
-
-    /**
-     * The virtual result representing the starting reference point,
-     * determined by calling the query processor's translateRef method
-     * with the root node's ref attribute as an argument.
-     */
-    readonly attribute XULTemplateResult? rootResult;
-
-    /**
-     * Force the template builder to rebuild its content. All existing content
-     * will be removed first. The query processor's done() method will be
-     * invoked during cleanup, followed by its initializeForBuilding method
-     * when the content is to be regenerated.
-     * 
-     */
-    [Throws]
-    void rebuild();
-
-    /**
-     * Reload any of our RDF datasources that support nsIRDFRemoteDatasource. 
-     *
-     * @note This is a temporary hack so that remote-XUL authors can
-     *       reload remote datasources. When RDF becomes remote-scriptable,
-     *       this will no longer be necessary.
-     */
-    [Throws]
-    void refresh();
-
-    /**
-     * Inform the template builder that a new result is available. The builder
-     * will add this result to the set of results. The query node that the
-     * new result applies to must be specified using the aQueryNode parameter.
-     *
-     * The builder will apply the rules associated with the query to the new
-     * result, unless a result with the same id from an earlier query
-     * supersedes it, and the result's RuleMatched method will be called if it
-     * matches.
-     *
-     * @param aResult the result to add
-     * @param aQueryNode the query that the result applies to
-     */
-    [Throws]
-    void addResult(XULTemplateResult aResult, Node aQueryNode);
-
-    /**
-     * Inform the template builder that a result no longer applies. The builder
-     * will call the remove content generated for the result, if any. If a
-     * different query would then match instead, it will become the active
-     * match. This method will have no effect if the result isn't known to the
-     * builder.
-     *
-     * @param aResult the result to remove
-     *
-     * @throws NS_ERROR_NULL_POINTER if aResult is null
-     */
-    [Throws]
-    void removeResult(XULTemplateResult aResult);
-
-    /**
-     * Inform the template builder that one result should be replaced with
-     * another. Both the old result (aOldResult) and the new result
-     * (aNewResult) must have the same id. The query node that the new result
-     * applies to must be specified using the aQueryNode parameter.
-     *
-     * This method is expected to have the same effect as calling both
-     * removeResult for the old result and addResult for the new result.
-     *
-     * @param aOldResult the old result
-     * @param aNewResult the new result
-     * @param aQueryNode the query that the new result applies to
-     *
-     * @throws NS_ERROR_NULL_POINTER if either argument is null, or
-     *         NS_ERROR_INVALID_ARG if the ids don't match
-     */
-    [Throws]
-    void replaceResult(XULTemplateResult aOldResult,
-                       XULTemplateResult aNewResult,
-                       Node aQueryNode);
-
-    /**
-     * Inform the template builder that one or more of the optional bindings
-     * for a result has changed. In this case, the rules are not reapplied as
-     * it is expected that the same rule will still apply. The builder will
-     * resynchronize any variables that are referenced in the action body.
-     *
-     * @param aResult the result to change
-     *
-     * @throws NS_ERROR_NULL_POINTER if aResult is null
-     */
-    [Throws]
-    void resultBindingChanged(XULTemplateResult aResult);
-
-    /**
-     * Return the result for a given id. Only one such result is returned and
-     * is always the result with that id associated with the active match.
-     * This method will return null is there is no result for the id.
-     *
-     * @param aId the id to return the result for
-     */
-    [Throws]
-    XULTemplateResult? getResultForId(DOMString aId);
-
-    /**
-     * Retrieve the result corresponding to a generated element, or null is
-     * there isn't one.
-     *
-     * @param aContent element to result the result of
-     */
-    XULTemplateResult? getResultForContent(Element aElement);
-
-    /**
-     * Returns true if the node has content generated for it. This method is
-     * intended to be called only by the RDF query processor. If aTag is set,
-     * the content must have a tag name that matches aTag. aTag may be ignored
-     * for builders that don't generate real DOM content.
-     *
-     * @param aNode node to check
-     * @param aTag tag that must match
-     */
-    [Throws]
-    boolean hasGeneratedContent(MozRDFResource aNode, DOMString? aTag);
-
-    /**
-     * Adds a rule filter for a given rule, which may be used for specialized
-     * rule filtering. Any existing filter on the rule is removed. The default
-     * conditions specified inside the <rule> tag are applied before the
-     * rule filter is applied, meaning that the filter may be used to further
-     * filter out results but not reaccept results that have already been
-     * rejected.
-     *
-     * @param aRule the rule to apply the filter to
-     * @param aFilter the filter to add
-     */
-    [Throws]
-    void addRuleFilter(Node aRule, XULTemplateRuleFilter aFilter);
-
-    /**
-     * Add a listener to this template builder. The template builder
-     * holds a strong reference to the listener.
-     */
-    void addListener(XULBuilderListener aListener);
-
-    /**
-     * Remove a listener from this template builder.
-     */
-    void removeListener(XULBuilderListener aListener);
-};
-
-/**
- *  XULTreeBuilderObserver
- *  This interface allows clients of the XULTreeBuilder to define domain 
- *  specific handling of specific nsITreeView methods that 
- *  XULTreeBuilder does not implement.
- */
-[Func="IsChromeOrXBL"]
-callback interface XULTreeBuilderObserver
-{
-    const long DROP_BEFORE = -1;
-    const long DROP_ON = 0;
-    const long DROP_AFTER = 1;
-    /**
-     * Methods used by the drag feedback code to determine if a drag is
-     * allowable at the current location. To get the behavior where drops are
-     * only allowed on items, such as the mailNews folder pane, always return
-     * false when the orientation is not DROP_ON.
-     */
-    boolean canDrop(long index, long orientation, DataTransfer? dataTransfer);
-
-    /**
-     * Called when the user drops something on this view. The |orientation|
-     * param specifies before/on/after the given |row|.
-     */
-    void onDrop(long row, long orientation, DataTransfer? dataTransfer);
- 
-    /** 
-     * Called when an item is opened or closed. 
-     */
-    void onToggleOpenState(long index);
-
-    /** 
-	 * Called when a header is clicked.
-     */
-    void onCycleHeader(DOMString colID, Element? elt);
-
-    /**
-     * Called when a cell in a non-selectable cycling column (e.g. 
-     * unread/flag/etc.) is clicked.
-     */
-    void onCycleCell(long row, DOMString colID);
-
-    /** 
-     * Called when selection in the tree changes
-     */
-    void onSelectionChanged();
-
-    /**
-     * A command API that can be used to invoke commands on the selection.  
-     * The tree will automatically invoke this method when certain keys 
-     * are pressed.  For example, when the DEL key is pressed, performAction 
-     * will be called with the "delete" string. 
-     */
-    void onPerformAction(DOMString action);
-
-    /**
-     * A command API that can be used to invoke commands on a specific row.
-     */
-    void onPerformActionOnRow(DOMString action, long row);
-
-    /**
-     * A command API that can be used to invoke commands on a specific cell.
-     */
-    void onPerformActionOnCell(DOMString action, long row, DOMString colID);
-};
-
-[Func="IsChromeOrXBL"]
-interface XULTreeBuilder : XULTemplateBuilder
-{
-    /**
-     * Retrieve the RDF resource associated with the specified row.
-     */
-    [Throws]
-    MozRDFResource? getResourceAtIndex(long aRowIndex);
-
-    /**
-     * Retrieve the index associated with specified RDF resource.
-     */
-    [Throws]
-    long getIndexOfResource(MozRDFResource resource);
-
-    /** 
-     * Add a Tree Builder Observer to handle Tree View 
-     * methods that the base builder does not implement. 
-     */
-    void addObserver(XULTreeBuilderObserver aObserver);
-
-    /** 
-     * Remove an Tree Builder Observer.
-     */
-    void removeObserver(XULTreeBuilderObserver aObserver);
-
-    /** 
-     * Sort the contents of the tree using the specified column.
-     */
-    void sort(Element aColumnElement);
-};
-XULTreeBuilder implements TreeView;
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -966,17 +966,16 @@ WEBIDL_FILES = [
     'XPathEvaluator.webidl',
     'XPathExpression.webidl',
     'XPathNSResolver.webidl',
     'XPathResult.webidl',
     'XSLTProcessor.webidl',
     'XULCommandEvent.webidl',
     'XULDocument.webidl',
     'XULElement.webidl',
-    'XULTemplateBuilder.webidl',
 ]
 
 if CONFIG['MOZ_WEBRTC']:
     WEBIDL_FILES += [
         'DataChannel.webidl',
         'PeerConnectionImpl.webidl',
         'PeerConnectionImplEnums.webidl',
         'PeerConnectionObserver.webidl',
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -46,24 +46,24 @@
 #include "nsPIBoxObject.h"
 #include "mozilla/dom/BoxObject.h"
 #include "nsString.h"
 #include "nsPIDOMWindow.h"
 #include "nsPIWindowRoot.h"
 #include "nsXULCommandDispatcher.h"
 #include "nsXULElement.h"
 #include "mozilla/Logging.h"
-#include "rdf.h"
 #include "nsIFrame.h"
 #include "nsXBLService.h"
 #include "nsCExternalHandlerService.h"
 #include "nsMimeTypes.h"
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 #include "nsContentList.h"
+#include "nsISimpleEnumerator.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsNodeInfoManager.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsContentUtils.h"
 #include "nsIParser.h"
 #include "nsCharsetSource.h"
 #include "mozilla/StyleSheetInlines.h"
@@ -90,18 +90,16 @@
 #include "nsTextNode.h"
 #include "nsJSUtils.h"
 #include "mozilla/dom/URL.h"
 #include "nsIContentPolicy.h"
 #include "mozAutoDocUpdate.h"
 #include "xpcpublic.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInlines.h"
-#include "nsXULTemplateBuilder.h"
-#include "nsXULTreeBuilder.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 //----------------------------------------------------------------------
 //
 // CIDs
 //
@@ -192,17 +190,16 @@ namespace dom {
 XULDocument::XULDocument(void)
     : XMLDocument("application/vnd.mozilla.xul+xml"),
       mNextSrcLoadWaiter(nullptr),
       mApplyingPersistedAttrs(false),
       mIsWritingFastLoad(false),
       mDocumentLoaded(false),
       mStillWalking(false),
       mRestrictPersistence(false),
-      mTemplateBuilderTable(nullptr),
       mPendingSheets(0),
       mDocLWTheme(Doc_Theme_Uninitialized),
       mState(eState_Master),
       mCurrentScriptProto(nullptr),
       mOffThreadCompiling(false),
       mOffThreadCompileStringBuf(nullptr),
       mOffThreadCompileStringLength(0),
       mResolutionPhase(nsForwardReference::eStart),
@@ -232,18 +229,16 @@ XULDocument::~XULDocument()
     mForwardReferences.Clear();
     // Likewise for any references we have to IDs where we might
     // look for persisted data:
     mPersistenceIds.Clear();
 
     // Destroy our broadcaster map.
     delete mBroadcasterMap;
 
-    delete mTemplateBuilderTable;
-
     Preferences::UnregisterCallback(XULDocument::DirectionChanged,
                                     "intl.uidirection", this);
 
     if (mOffThreadCompileStringBuf) {
       js_free(mOffThreadCompileStringBuf);
     }
 }
 
@@ -280,29 +275,16 @@ namespace dom {
 NS_IMPL_CYCLE_COLLECTION_CLASS(XULDocument)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(XULDocument, XMLDocument)
     NS_ASSERTION(!nsCCUncollectableMarker::InGeneration(cb, tmp->GetMarkedCCGeneration()),
                  "Shouldn't traverse XULDocument!");
     // XXX tmp->mForwardReferences?
     // XXX tmp->mContextStack?
 
-    // An element will only have a template builder as long as it's in the
-    // document, so we'll traverse the table here instead of from the element.
-    if (tmp->mTemplateBuilderTable) {
-        for (auto iter = tmp->mTemplateBuilderTable->Iter();
-             !iter.Done();
-             iter.Next()) {
-            NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mTemplateBuilderTable key");
-            cb.NoteXPCOMChild(iter.Key());
-            NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mTemplateBuilderTable value");
-            cb.NoteXPCOMChild(iter.UserData());
-        }
-    }
-
     NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCurrentPrototype)
     NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMasterPrototype)
     NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCommandDispatcher)
     NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPrototypes)
     NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLocalStore)
 
     if (tmp->mOverlayLoadObservers) {
         for (auto iter = tmp->mOverlayLoadObservers->Iter();
@@ -318,19 +300,16 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
              iter.Next()) {
             NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mPendingOverlayLoadNotifications value");
             cb.NoteXPCOMChild(iter.Data());
         }
     }
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(XULDocument, XMLDocument)
-    delete tmp->mTemplateBuilderTable;
-    tmp->mTemplateBuilderTable = nullptr;
-
     NS_IMPL_CYCLE_COLLECTION_UNLINK(mCommandDispatcher)
     NS_IMPL_CYCLE_COLLECTION_UNLINK(mLocalStore)
     //XXX We should probably unlink all the objects we traverse.
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(XULDocument,
                                              XMLDocument,
                                              nsIXULDocument,
@@ -1662,36 +1641,16 @@ XULDocument::AddElementToDocumentPost(El
     }
 
     // We need to pay special attention to the keyset tag to set up a listener
     if (aElement->NodeInfo()->Equals(nsGkAtoms::keyset, kNameSpaceID_XUL)) {
         // Create our XUL key listener and hook it up.
         nsXBLService::AttachGlobalKeyHandler(aElement);
     }
 
-    // See if we need to attach a XUL template to this node
-    bool needsHookup;
-    nsresult rv = CheckTemplateBuilderHookup(aElement, &needsHookup);
-    if (NS_FAILED(rv))
-        return rv;
-
-    if (needsHookup) {
-        if (mResolutionPhase == nsForwardReference::eDone) {
-            rv = CreateTemplateBuilder(aElement);
-            if (NS_FAILED(rv))
-                return rv;
-        }
-        else {
-            TemplateBuilderHookup* hookup = new TemplateBuilderHookup(aElement);
-            rv = AddForwardReference(hookup);
-            if (NS_FAILED(rv))
-                return rv;
-        }
-    }
-
     return NS_OK;
 }
 
 NS_IMETHODIMP
 XULDocument::AddSubtreeToDocument(nsIContent* aContent)
 {
     NS_ASSERTION(aContent->GetUncomposedDoc() == this, "Element not in doc!");
     // From here on we only care about elements.
@@ -1779,50 +1738,16 @@ XULDocument::RemoveSubtreeFromDocument(n
                          broadcasterID, attribute, getter_AddRefs(broadcaster));
     if (rv == NS_FINDBROADCASTER_FOUND) {
         RemoveBroadcastListenerFor(*broadcaster, *listener, attribute);
     }
 
     return NS_OK;
 }
 
-NS_IMETHODIMP
-XULDocument::SetTemplateBuilderFor(nsIContent* aContent,
-                                   nsIXULTemplateBuilder* aBuilder)
-{
-    if (! mTemplateBuilderTable) {
-        if (!aBuilder) {
-            return NS_OK;
-        }
-        mTemplateBuilderTable = new BuilderTable;
-    }
-
-    if (aBuilder) {
-        mTemplateBuilderTable->Put(aContent, aBuilder);
-    }
-    else {
-        mTemplateBuilderTable->Remove(aContent);
-    }
-
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-XULDocument::GetTemplateBuilderFor(nsIContent* aContent,
-                                   nsIXULTemplateBuilder** aResult)
-{
-    if (mTemplateBuilderTable) {
-        mTemplateBuilderTable->Get(aContent, aResult);
-    }
-    else
-        *aResult = nullptr;
-
-    return NS_OK;
-}
-
 static void
 GetRefMapAttribute(Element* aElement, nsAutoString* aValue)
 {
     aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::ref, *aValue);
 }
 
 nsresult
 XULDocument::AddElementToRefMap(Element* aElement)
@@ -3626,105 +3551,16 @@ XULDocument::AddAttributes(nsXULPrototyp
         if (NS_FAILED(rv)) return rv;
     }
 
     return NS_OK;
 }
 
 
 nsresult
-XULDocument::CheckTemplateBuilderHookup(Element* aElement,
-                                        bool* aNeedsHookup)
-{
-    // See if the element already has a `database' attribute. If it
-    // does, then the template builder has already been created.
-    //
-    // XXX This approach will crash and burn (well, maybe not _that_
-    // bad) if aElement is not a XUL element.
-    //
-    // XXXvarga Do we still want to support non XUL content?
-    RefPtr<nsXULElement> xulElement = nsXULElement::FromContent(aElement);
-    if (xulElement) {
-        nsCOMPtr<nsIRDFCompositeDataSource> ds = xulElement->GetDatabase();
-        if (ds) {
-            *aNeedsHookup = false;
-            return NS_OK;
-        }
-    }
-
-    // Check aElement for a 'datasources' attribute, if it has
-    // one a XUL template builder needs to be hooked up.
-    *aNeedsHookup = aElement->HasAttr(kNameSpaceID_None,
-                                      nsGkAtoms::datasources);
-    return NS_OK;
-}
-
-/* static */ nsresult
-XULDocument::CreateTemplateBuilder(Element* aElement)
-{
-    // Check if need to construct a tree builder or content builder.
-    bool isTreeBuilder = false;
-
-    // return successful if the element is not is a document, as an inline
-    // script could have removed it
-    nsIDocument* document = aElement->GetUncomposedDoc();
-    NS_ENSURE_TRUE(document, NS_OK);
-
-    int32_t nameSpaceID;
-    nsAtom* baseTag = document->BindingManager()->
-      ResolveTag(aElement, &nameSpaceID);
-
-    if ((nameSpaceID == kNameSpaceID_XUL) && (baseTag == nsGkAtoms::tree)) {
-        // By default, we build content for a tree and then we attach
-        // the tree content view. However, if the `dont-build-content'
-        // flag is set, then we we'll attach a tree builder which
-        // directly implements the tree view.
-
-        nsAutoString flags;
-        aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::flags, flags);
-        if (flags.Find(NS_LITERAL_STRING("dont-build-content")) >= 0) {
-            isTreeBuilder = true;
-        }
-    }
-
-    if (isTreeBuilder) {
-        // Create and initialize a tree builder.
-        RefPtr<nsXULTreeBuilder> builder = new nsXULTreeBuilder(aElement);
-        nsresult rv = builder->Init();
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        // Create a <treechildren> if one isn't there already.
-        // XXXvarga what about attributes?
-        RefPtr<Element> bodyContent;
-        nsXULContentUtils::FindChildByTag(aElement, kNameSpaceID_XUL,
-                                          nsGkAtoms::treechildren,
-                                          getter_AddRefs(bodyContent));
-
-        if (!bodyContent) {
-            bodyContent =
-                document->CreateElem(nsDependentAtomString(nsGkAtoms::treechildren),
-                                     nullptr, kNameSpaceID_XUL);
-
-            aElement->AppendChildTo(bodyContent, false);
-        }
-    }
-    else {
-        // Create and initialize a content builder.
-        nsCOMPtr<nsIXULTemplateBuilder> builder;
-        nsresult rv = NS_NewXULContentBuilder(aElement, getter_AddRefs(builder));
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        builder->CreateContents(aElement, false);
-    }
-
-    return NS_OK;
-}
-
-
-nsresult
 XULDocument::AddPrototypeSheets()
 {
     nsresult rv;
 
     const nsCOMArray<nsIURI>& sheets = mCurrentPrototype->GetStyleSheetReferences();
 
     for (int32_t i = 0; i < sheets.Count(); i++) {
         nsCOMPtr<nsIURI> uri = sheets[i];
@@ -4029,40 +3865,16 @@ XULDocument::BroadcasterHookup::~Broadca
         MOZ_LOG(gXULLog, LogLevel::Warning,
                ("xul: broadcaster hookup failed <%s attribute='%s'> to %s",
                 nsAtomCString(mObservesElement->NodeInfo()->NameAtom()).get(),
                 attributeC.get(),
                 broadcasteridC.get()));
     }
 }
 
-
-//----------------------------------------------------------------------
-//
-// XULDocument::TemplateBuilderHookup
-//
-
-nsForwardReference::Result
-XULDocument::TemplateBuilderHookup::Resolve()
-{
-    bool needsHookup;
-    nsresult rv = CheckTemplateBuilderHookup(mElement, &needsHookup);
-    if (NS_FAILED(rv))
-        return eResolve_Error;
-
-    if (needsHookup) {
-        rv = CreateTemplateBuilder(mElement);
-        if (NS_FAILED(rv))
-            return eResolve_Error;
-    }
-
-    return eResolve_Succeeded;
-}
-
-
 //----------------------------------------------------------------------
 
 nsresult
 XULDocument::BroadcastAttributeChangeFromOverlay(nsIContent* aNode,
                                                  int32_t aNameSpaceID,
                                                  nsAtom* aAttribute,
                                                  nsAtom* aPrefix,
                                                  const nsAString& aValue)
--- a/dom/xul/XULDocument.h
+++ b/dom/xul/XULDocument.h
@@ -125,20 +125,16 @@ public:
     NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTEWILLCHANGE
 
     // nsIXULDocument interface
     virtual void GetElementsForID(const nsAString& aID,
                                   nsCOMArray<mozilla::dom::Element>& aElements) override;
 
     NS_IMETHOD AddSubtreeToDocument(nsIContent* aContent) override;
     NS_IMETHOD RemoveSubtreeFromDocument(nsIContent* aContent) override;
-    NS_IMETHOD SetTemplateBuilderFor(nsIContent* aContent,
-                                     nsIXULTemplateBuilder* aBuilder) override;
-    NS_IMETHOD GetTemplateBuilderFor(nsIContent* aContent,
-                                     nsIXULTemplateBuilder** aResult) override;
     NS_IMETHOD OnPrototypeLoadDone(bool aResumeWalk) override;
     bool OnDocumentParserError() override;
 
     // nsINode interface overrides
     virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
                            bool aPreallocateChildren) const override;
 
     // nsIDOMNode interface
@@ -347,22 +343,16 @@ protected:
     /**
      * An array of style sheets, that will be added (preserving order) to the
      * document after all of them are loaded (in DoneWalking).
      */
     nsTArray<RefPtr<StyleSheet>> mOverlaySheets;
 
     nsCOMPtr<nsIDOMXULCommandDispatcher>     mCommandDispatcher; // [OWNER] of the focus tracker
 
-    // Maintains the template builders that have been attached to
-    // content elements
-    typedef nsInterfaceHashtable<nsISupportsHashKey, nsIXULTemplateBuilder>
-        BuilderTable;
-    BuilderTable* mTemplateBuilderTable;
-
     uint32_t mPendingSheets;
 
     /**
      * document lightweight theme for use with :-moz-lwtheme, :-moz-lwtheme-brighttext
      * and :-moz-lwtheme-darktext
      */
     DocumentTheme                         mDocLWTheme;
 
@@ -464,28 +454,16 @@ protected:
     /**
      * If the current transcluded script is being compiled off thread, the
      * source for that script.
      */
     char16_t* mOffThreadCompileStringBuf;
     size_t mOffThreadCompileStringLength;
 
     /**
-     * Check if a XUL template builder has already been hooked up.
-     */
-    static nsresult
-    CheckTemplateBuilderHookup(mozilla::dom::Element* aElement, bool* aNeedsHookup);
-
-    /**
-     * Create a XUL template builder on the specified node.
-     */
-    static nsresult
-    CreateTemplateBuilder(Element* aElement);
-
-    /**
      * Add the current prototype's style sheets (currently it's just
      * style overlays from the chrome registry) to the document.
      */
     nsresult AddPrototypeSheets();
 
 
 protected:
     /* Declarations related to forward references.
@@ -562,31 +540,16 @@ protected:
         virtual ~OverlayForwardReference();
 
         virtual Phase GetPhase() override { return eConstruction; }
         virtual Result Resolve() override;
     };
 
     friend class OverlayForwardReference;
 
-    class TemplateBuilderHookup : public nsForwardReference
-    {
-    protected:
-        nsCOMPtr<Element> mElement; // [OWNER]
-
-    public:
-        explicit TemplateBuilderHookup(Element* aElement)
-            : mElement(aElement) {}
-
-        virtual Phase GetPhase() override { return eHookup; }
-        virtual Result Resolve() override;
-    };
-
-    friend class TemplateBuilderHookup;
-
     // The out params of FindBroadcaster only have values that make sense when
     // the method returns NS_FINDBROADCASTER_FOUND.  In all other cases, the
     // values of the out params should not be relied on (though *aListener and
     // *aBroadcaster do need to be released if non-null, of course).
     nsresult
     FindBroadcaster(Element* aElement,
                     Element** aListener,
                     nsString& aBroadcasterID,
--- a/dom/xul/moz.build
+++ b/dom/xul/moz.build
@@ -7,55 +7,55 @@
 with Files("**"):
     BUG_COMPONENT = ("Core", "XUL")
 
 MOCHITEST_MANIFESTS += ['test/mochitest.ini']
 
 MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
 
 if CONFIG['MOZ_XUL']:
-    DIRS += ['templates']
-
     XPIDL_SOURCES += [
         'nsIXULOverlayProvider.idl',
     ]
 
     EXPORTS += [
         'nsIXULDocument.h',
         'nsXULElement.h',
     ]
 
     UNIFIED_SOURCES += [
         'nsXULCommandDispatcher.cpp',
         'nsXULContentSink.cpp',
+        'nsXULContentUtils.cpp',
         'nsXULElement.cpp',
         'nsXULPopupListener.cpp',
         'nsXULPrototypeCache.cpp',
         'nsXULPrototypeDocument.cpp',
+        'nsXULSortService.cpp',
         'XULDocument.cpp',
     ]
 
 XPIDL_SOURCES += [
     'nsIController.idl',
     'nsIControllers.idl',
+    'nsIXULSortService.idl',
 ]
 
 XPIDL_MODULE = 'xul'
 
 UNIFIED_SOURCES += [
     'nsXULControllers.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '/docshell/base',
     '/dom/base',
     '/dom/html',
     '/dom/xbl',
     '/dom/xml',
-    '/dom/xul/templates',
     '/layout/base',
     '/layout/generic',
     '/layout/style',
     '/layout/xul',
 ]
 
 FINAL_LIBRARY = 'xul'
 
--- a/dom/xul/nsIXULDocument.h
+++ b/dom/xul/nsIXULDocument.h
@@ -49,29 +49,16 @@ public:
   NS_IMETHOD AddSubtreeToDocument(nsIContent* aElement) = 0;
 
   /**
    * Notify the XUL document that a subtree has been removed
    */
   NS_IMETHOD RemoveSubtreeFromDocument(nsIContent* aElement) = 0;
 
   /**
-   * Attach a XUL template builder to the specified content node.
-   * @param aBuilder the template builder to attach, or null if
-   *   the builder is to be removed.
-   */
-  NS_IMETHOD SetTemplateBuilderFor(nsIContent* aContent, nsIXULTemplateBuilder* aBuilder) = 0;
-
-  /**
-   * Retrieve the XUL template builder that's attached to a content
-   * node.
-   */
-  NS_IMETHOD GetTemplateBuilderFor(nsIContent* aContent, nsIXULTemplateBuilder** aResult) = 0;
-
-  /**
    * This is invoked whenever the prototype for this document is loaded
    * and should be walked, regardless of whether the XUL cache is
    * disabled, whether the protototype was loaded, whether the
    * prototype was loaded from the cache or created by parsing the
    * actual XUL source, etc.
    *
    * @param aResumeWalk whether this should also call ResumeWalk().
    * Sometimes the caller of OnPrototypeLoadDone resumes the walk itself
rename from dom/xul/templates/nsIXULSortService.idl
rename to dom/xul/nsIXULSortService.idl
rename from dom/xul/templates/nsXULContentUtils.cpp
rename to dom/xul/nsXULContentUtils.cpp
--- a/dom/xul/templates/nsXULContentUtils.cpp
+++ b/dom/xul/nsXULContentUtils.cpp
@@ -8,101 +8,60 @@
 /*
 
   A package of routines shared by the XUL content code.
 
  */
 
 #include "mozilla/ArrayUtils.h"
 
-#include "DateTimeFormat.h"
+#include "nsCollationCID.h"
 #include "nsCOMPtr.h"
 #include "nsIContent.h"
+#include "nsICollation.h"
 #include "nsIDocument.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMXULCommandDispatcher.h"
 #include "nsIDOMXULDocument.h"
-#include "nsIRDFNode.h"
 #include "nsIRDFService.h"
 #include "nsIServiceManager.h"
-#include "nsIURL.h"
 #include "nsXULContentUtils.h"
 #include "nsLayoutCID.h"
-#include "nsNameSpaceManager.h"
 #include "nsRDFCID.h"
 #include "nsString.h"
 #include "nsGkAtoms.h"
-#include "mozilla/Logging.h"
-#include "prtime.h"
-#include "rdf.h"
-#include "nsContentUtils.h"
-#include "nsICollation.h"
-#include "nsCollationCID.h"
-#include "nsIConsoleService.h"
-#include "nsEscape.h"
 
 using namespace mozilla;
 
 //------------------------------------------------------------------------
 
 nsIRDFService* nsXULContentUtils::gRDF;
 nsICollation *nsXULContentUtils::gCollation;
 
-extern LazyLogModule gXULTemplateLog;
-
-#define XUL_RESOURCE(ident, uri) nsIRDFResource* nsXULContentUtils::ident
-#define XUL_LITERAL(ident, val) nsIRDFLiteral* nsXULContentUtils::ident
-#include "nsXULResourceList.h"
-#undef XUL_RESOURCE
-#undef XUL_LITERAL
-
 //------------------------------------------------------------------------
 // Constructors n' stuff
 //
 
 nsresult
 nsXULContentUtils::Init()
 {
     static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
     nsresult rv = CallGetService(kRDFServiceCID, &gRDF);
     if (NS_FAILED(rv)) {
         return rv;
     }
 
-#define XUL_RESOURCE(ident, uri)                              \
-  PR_BEGIN_MACRO                                              \
-   rv = gRDF->GetResource(NS_LITERAL_CSTRING(uri), &(ident)); \
-   if (NS_FAILED(rv)) return rv;                              \
-  PR_END_MACRO
-
-#define XUL_LITERAL(ident, val)                                   \
-  PR_BEGIN_MACRO                                                  \
-   rv = gRDF->GetLiteral(val, &(ident));                          \
-   if (NS_FAILED(rv)) return rv;                                  \
-  PR_END_MACRO
-
-#include "nsXULResourceList.h"
-#undef XUL_RESOURCE
-#undef XUL_LITERAL
-
     return NS_OK;
 }
 
 
 nsresult
 nsXULContentUtils::Finish()
 {
     NS_IF_RELEASE(gRDF);
-
-#define XUL_RESOURCE(ident, uri) NS_IF_RELEASE(ident)
-#define XUL_LITERAL(ident, val) NS_IF_RELEASE(ident)
-#include "nsXULResourceList.h"
-#undef XUL_RESOURCE
-#undef XUL_LITERAL
-
     NS_IF_RELEASE(gCollation);
 
     return NS_OK;
 }
 
 nsICollation*
 nsXULContentUtils::GetCollation()
 {
@@ -115,17 +74,19 @@ nsXULContentUtils::GetCollation()
                          "couldn't create collation instance");
         } else
             NS_ERROR("couldn't create instance of collation factory");
     }
 
     return gCollation;
 }
 
+
 //------------------------------------------------------------------------
+//
 
 nsresult
 nsXULContentUtils::FindChildByTag(nsIContent* aElement,
                                   int32_t aNameSpaceID,
                                   nsAtom* aTag,
                                   Element** aResult)
 {
     for (nsIContent* child = aElement->GetFirstChild();
@@ -138,133 +99,16 @@ nsXULContentUtils::FindChildByTag(nsICon
             return NS_OK;
         }
     }
 
     *aResult = nullptr;
     return NS_RDF_NO_VALUE; // not found
 }
 
-
-/*
-	Note: this routine is similar, yet distinctly different from, nsBookmarksService::GetTextForNode
-*/
-
-nsresult
-nsXULContentUtils::GetTextForNode(nsIRDFNode* aNode, nsAString& aResult)
-{
-    if (! aNode) {
-        aResult.Truncate();
-        return NS_OK;
-    }
-
-    nsresult rv;
-
-    // Literals are the most common, so try these first.
-    nsCOMPtr<nsIRDFLiteral> literal = do_QueryInterface(aNode);
-    if (literal) {
-        const char16_t* p;
-        rv = literal->GetValueConst(&p);
-        if (NS_FAILED(rv)) return rv;
-
-        aResult = p;
-        return NS_OK;
-    }
-
-    nsCOMPtr<nsIRDFDate> dateLiteral = do_QueryInterface(aNode);
-    if (dateLiteral) {
-        PRTime value;
-        rv = dateLiteral->GetValue(&value);
-        if (NS_FAILED(rv)) return rv;
-
-        nsAutoString str;
-        rv = DateTimeFormat::FormatPRTime(kDateFormatShort,
-                                          kTimeFormatSeconds,
-                                          value,
-                                          str);
-
-        aResult.Assign(str);
-
-        if (NS_FAILED(rv)) return rv;
-
-        return NS_OK;
-    }
-
-    nsCOMPtr<nsIRDFInt> intLiteral = do_QueryInterface(aNode);
-    if (intLiteral) {
-        int32_t	value;
-        rv = intLiteral->GetValue(&value);
-        if (NS_FAILED(rv)) return rv;
-
-        aResult.Truncate();
-        nsAutoString intStr;
-        intStr.AppendInt(value, 10);
-        aResult.Append(intStr);
-        return NS_OK;
-    }
-
-
-    nsCOMPtr<nsIRDFResource> resource = do_QueryInterface(aNode);
-    if (resource) {
-        const char* p;
-        rv = resource->GetValueConst(&p);
-        if (NS_FAILED(rv)) return rv;
-        CopyUTF8toUTF16(p, aResult);
-        return NS_OK;
-    }
-
-    NS_ERROR("not a resource or a literal");
-    return NS_ERROR_UNEXPECTED;
-}
-
-nsresult
-nsXULContentUtils::GetResource(int32_t aNameSpaceID, nsAtom* aAttribute, nsIRDFResource** aResult)
-{
-    // construct a fully-qualified URI from the namespace/tag pair.
-    NS_PRECONDITION(aAttribute != nullptr, "null ptr");
-    if (! aAttribute)
-        return NS_ERROR_NULL_POINTER;
-
-    return GetResource(aNameSpaceID, nsDependentAtomString(aAttribute),
-                       aResult);
-}
-
-
-nsresult
-nsXULContentUtils::GetResource(int32_t aNameSpaceID, const nsAString& aAttribute, nsIRDFResource** aResult)
-{
-    // construct a fully-qualified URI from the namespace/tag pair.
-
-    // XXX should we allow nodes with no namespace???
-    //NS_PRECONDITION(aNameSpaceID != kNameSpaceID_Unknown, "no namespace");
-    //if (aNameSpaceID == kNameSpaceID_Unknown)
-    //    return NS_ERROR_UNEXPECTED;
-
-    nsresult rv;
-
-    nsAutoStringN<256> uri;
-    if (aNameSpaceID != kNameSpaceID_Unknown && aNameSpaceID != kNameSpaceID_None) {
-        rv = nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNameSpaceID, uri);
-        // XXX ignore failure; treat as "no namespace"
-    }
-
-    // XXX check to see if we need to insert a '/' or a '#'. Oy.
-    if (!uri.IsEmpty()  && uri.Last() != '#' && uri.Last() != '/' && aAttribute.First() != '#')
-        uri.Append(char16_t('#'));
-
-    uri.Append(aAttribute);
-
-    rv = gRDF->GetUnicodeResource(uri, aResult);
-    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource");
-    if (NS_FAILED(rv)) return rv;
-
-    return NS_OK;
-}
-
-
 nsresult
 nsXULContentUtils::SetCommandUpdater(nsIDocument* aDocument, Element* aElement)
 {
     // Deal with setting up a 'commandupdater'. Pulls the 'events' and
     // 'targets' attributes off of aElement, and adds it to the
     // document's command dispatcher.
     NS_PRECONDITION(aDocument != nullptr, "null ptr");
     if (! aDocument)
@@ -307,21 +151,8 @@ nsXULContentUtils::SetCommandUpdater(nsI
         return NS_ERROR_UNEXPECTED;
 
     rv = dispatcher->AddCommandUpdater(domelement, events, targets);
     if (NS_FAILED(rv)) return rv;
 
     return NS_OK;
 }
 
-void
-nsXULContentUtils::LogTemplateError(const char* aStr)
-{
-  nsAutoString message;
-  message.AssignLiteral("Error parsing template: ");
-  message.Append(NS_ConvertUTF8toUTF16(aStr).get());
-
-  nsCOMPtr<nsIConsoleService> cs = do_GetService(NS_CONSOLESERVICE_CONTRACTID);
-  if (cs) {
-    cs->LogStringMessage(message.get());
-    MOZ_LOG(gXULTemplateLog, LogLevel::Info, ("Error parsing template: %s", aStr));
-  }
-}
rename from dom/xul/templates/nsXULContentUtils.h
rename to dom/xul/nsXULContentUtils.h
--- a/dom/xul/templates/nsXULContentUtils.h
+++ b/dom/xul/nsXULContentUtils.h
@@ -10,88 +10,27 @@
  */
 
 #ifndef nsXULContentUtils_h__
 #define nsXULContentUtils_h__
 
 #include "nsISupports.h"
 
 class nsAtom;
+class nsICollation;
 class nsIContent;
 class nsIDocument;
-class nsIRDFNode;
-class nsIRDFResource;
-class nsIRDFLiteral;
 class nsIRDFService;
-class nsICollation;
 
 namespace mozilla {
 namespace dom {
 class Element;
 }
 }
 
-// errors to pass to LogTemplateError
-#define ERROR_TEMPLATE_INVALID_QUERYPROCESSOR                           \
-        "querytype attribute doesn't specify a valid query processor"
-#define ERROR_TEMPLATE_INVALID_QUERYSET                                 \
-        "unexpected <queryset> element"
-#define ERROR_TEMPLATE_NO_MEMBERVAR                                     \
-        "no member variable found. Action body should have an element with uri attribute"
-#define ERROR_TEMPLATE_WHERE_NO_SUBJECT                                 \
-        "<where> element is missing a subject attribute"
-#define ERROR_TEMPLATE_WHERE_NO_RELATION                                \
-        "<where> element is missing a rel attribute"
-#define ERROR_TEMPLATE_WHERE_NO_VALUE                                   \
-        "<where> element is missing a value attribute"
-#define ERROR_TEMPLATE_WHERE_NO_VAR                                     \
-        "<where> element must have at least one variable as a subject or value"
-#define ERROR_TEMPLATE_BINDING_BAD_SUBJECT                              \
-        "<binding> requires a variable for its subject attribute"
-#define ERROR_TEMPLATE_BINDING_BAD_PREDICATE                            \
-        "<binding> element is missing a predicate attribute"
-#define ERROR_TEMPLATE_BINDING_BAD_OBJECT                               \
-        "<binding> requires a variable for its object attribute"
-#define ERROR_TEMPLATE_CONTENT_NOT_FIRST                                \
-        "expected <content> to be first"
-#define ERROR_TEMPLATE_MEMBER_NOCONTAINERVAR                            \
-        "<member> requires a variable for its container attribute"
-#define ERROR_TEMPLATE_MEMBER_NOCHILDVAR                                \
-        "<member> requires a variable for its child attribute"
-#define ERROR_TEMPLATE_TRIPLE_NO_VAR                                    \
-        "<triple> should have at least one variable as a subject or object"
-#define ERROR_TEMPLATE_TRIPLE_BAD_SUBJECT                               \
-        "<triple> requires a variable for its subject attribute"
-#define ERROR_TEMPLATE_TRIPLE_BAD_PREDICATE                             \
-        "<triple> should have a non-variable value as a predicate"
-#define ERROR_TEMPLATE_TRIPLE_BAD_OBJECT                                \
-        "<triple> requires a variable for its object attribute"
-#define ERROR_TEMPLATE_MEMBER_UNBOUND                                   \
-        "neither container or child variables of <member> has a value"
-#define ERROR_TEMPLATE_TRIPLE_UNBOUND                                   \
-        "neither subject or object variables of <triple> has a value"
-#define ERROR_TEMPLATE_BAD_XPATH                                        \
-        "XPath expression in query could not be parsed"
-#define ERROR_TEMPLATE_BAD_ASSIGN_XPATH                                 \
-        "XPath expression in <assign> could not be parsed"
-#define ERROR_TEMPLATE_BAD_BINDING_XPATH                                \
-        "XPath expression in <binding> could not be parsed"
-#define ERROR_TEMPLATE_STORAGE_BAD_URI                                  \
-        "only profile: or file URI are allowed"
-#define ERROR_TEMPLATE_STORAGE_CANNOT_OPEN_DATABASE                     \
-        "cannot open given database"
-#define ERROR_TEMPLATE_STORAGE_BAD_QUERY                                \
-        "syntax error in the SQL query"
-#define ERROR_TEMPLATE_STORAGE_UNKNOWN_QUERY_PARAMETER                   \
-        "the given named parameter is unknown in the SQL query"
-#define ERROR_TEMPLATE_STORAGE_WRONG_TYPE_QUERY_PARAMETER               \
-        "the type of a query parameter is wrong"
-#define ERROR_TEMPLATE_STORAGE_QUERY_PARAMETER_NOT_BOUND                \
-        "a query parameter cannot be bound to the SQL query"
-
 class nsXULContentUtils
 {
 protected:
     static nsIRDFService* gRDF;
     static nsICollation *gCollation;
 
     static bool gDisableXULCache;
 
@@ -107,47 +46,21 @@ public:
 
     static nsresult
     FindChildByTag(nsIContent *aElement,
                    int32_t aNameSpaceID,
                    nsAtom* aTag,
                    mozilla::dom::Element** aResult);
 
     static nsresult
-    FindChildByResource(nsIContent* aElement,
-                        nsIRDFResource* aResource,
-                        nsIContent** aResult);
-
-    static nsresult
-    GetTextForNode(nsIRDFNode* aNode, nsAString& aResult);
-
-    static nsresult
-    GetResource(int32_t aNameSpaceID, nsAtom* aAttribute, nsIRDFResource** aResult);
-
-    static nsresult
-    GetResource(int32_t aNameSpaceID, const nsAString& aAttribute, nsIRDFResource** aResult);
-
-    static nsresult
     SetCommandUpdater(nsIDocument* aDocument, mozilla::dom::Element* aElement);
 
-    /**
-     * Log a message to the error console
-     */
-    static void
-    LogTemplateError(const char* aMsg);
-
     static nsIRDFService*
     RDFService()
     {
         return gRDF;
     }
 
     static nsICollation*
     GetCollation();
-
-#define XUL_RESOURCE(ident, uri) static nsIRDFResource* ident
-#define XUL_LITERAL(ident, val)  static nsIRDFLiteral*  ident
-#include "nsXULResourceList.h"
-#undef XUL_RESOURCE
-#undef XUL_LITERAL
 };
 
 #endif // nsXULContentUtils_h__
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -28,33 +28,28 @@
 #include "mozilla/DeclarationBlockInlines.h"
 #include "nsFocusManager.h"
 #include "nsHTMLStyleSheet.h"
 #include "nsNameSpaceManager.h"
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 #include "nsIPresShell.h"
 #include "nsIPrincipal.h"
-#include "nsIRDFCompositeDataSource.h"
-#include "nsIRDFNode.h"
-#include "nsIRDFService.h"
 #include "nsIScriptContext.h"
 #include "nsIScriptError.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIServiceManager.h"
 #include "mozilla/css/StyleRule.h"
 #include "nsIURL.h"
 #include "nsViewManager.h"
 #include "nsIWidget.h"
 #include "nsIXULDocument.h"
-#include "nsIXULTemplateBuilder.h"
 #include "nsLayoutCID.h"
 #include "nsContentCID.h"
 #include "mozilla/dom/Event.h"
-#include "nsRDFCID.h"
 #include "nsStyleConsts.h"
 #include "nsString.h"
 #include "nsXULControllers.h"
 #include "nsIBoxObject.h"
 #include "nsPIBoxObject.h"
 #include "XULDocument.h"
 #include "nsXULPopupListener.h"
 #include "nsRuleWalker.h"
@@ -65,21 +60,19 @@
 #include "nsContentList.h"
 #include "mozilla/InternalMutationEvent.h"
 #include "mozilla/MouseEvents.h"
 #include "nsIDOMMutationEvent.h"
 #include "nsPIDOMWindow.h"
 #include "nsJSPrincipals.h"
 #include "nsDOMAttributeMap.h"
 #include "nsGkAtoms.h"
-#include "nsXULContentUtils.h"
 #include "nsNodeUtils.h"
 #include "nsFrameLoader.h"
 #include "mozilla/Logging.h"
-#include "rdf.h"
 #include "nsIControllers.h"
 #include "nsAttrValueOrString.h"
 #include "nsAttrValueInlines.h"
 #include "mozilla/Attributes.h"
 #include "nsIController.h"
 #include "nsQueryObject.h"
 #include <algorithm>
 #include "nsIDOMChromeWindow.h"
@@ -327,21 +320,16 @@ nsXULElement::Clone(mozilla::dom::NodeIn
 
     RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
     RefPtr<nsXULElement> element = new nsXULElement(ni.forget());
 
     nsresult rv = element->mAttrsAndChildren.EnsureCapacityToClone(mAttrsAndChildren,
                                                                    aPreallocateChildren);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    // XXX TODO: set up RDF generic builder n' stuff if there is a
-    // 'datasources' attribute? This is really kind of tricky,
-    // because then we'd need to -selectively- copy children that
-    // -weren't- generated from RDF. Ugh. Forget it.
-
     // Note that we're _not_ copying mControllers.
 
     uint32_t count = mAttrsAndChildren.AttrCount();
     rv = NS_OK;
     for (uint32_t i = 0; i < count; ++i) {
         const nsAttrName* originalName = mAttrsAndChildren.AttrNameAt(i);
         const nsAttrValue* originalValue = mAttrsAndChildren.AttrAt(i);
         nsAttrValue attrValue;
@@ -1331,64 +1319,16 @@ nsXULElement::PreHandleEvent(EventChainV
         nsAutoString command;
         GetAttr(kNameSpaceID_None, nsGkAtoms::command, command);
         MOZ_ASSERT(!command.IsEmpty());
         return DispatchXULCommand(aVisitor, command);
     }
     return nsStyledElement::PreHandleEvent(aVisitor);
 }
 
-// XXX This _should_ be an implementation method, _not_ publicly exposed :-(
-already_AddRefed<nsIRDFResource>
-nsXULElement::GetResource(ErrorResult& rv)
-{
-    nsAutoString id;
-    GetAttr(kNameSpaceID_None, nsGkAtoms::ref, id);
-    if (id.IsEmpty()) {
-        GetAttr(kNameSpaceID_None, nsGkAtoms::id, id);
-    }
-
-    if (id.IsEmpty()) {
-        return nullptr;
-    }
-
-    nsCOMPtr<nsIRDFResource> resource;
-    rv = nsXULContentUtils::RDFService()->
-        GetUnicodeResource(id, getter_AddRefs(resource));
-    return resource.forget();
-}
-
-already_AddRefed<nsIRDFCompositeDataSource>
-nsXULElement::GetDatabase()
-{
-    nsCOMPtr<nsIXULTemplateBuilder> builder = GetBuilder();
-    if (!builder) {
-        return nullptr;
-    }
-
-    nsCOMPtr<nsIRDFCompositeDataSource> database;
-    builder->GetDatabase(getter_AddRefs(database));
-    return database.forget();
-}
-
-
-already_AddRefed<nsIXULTemplateBuilder>
-nsXULElement::GetBuilder()
-{
-    // XXX sXBL/XBL2 issue! Owner or current document?
-    nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(GetUncomposedDoc());
-    if (!xuldoc) {
-        return nullptr;
-    }
-
-    nsCOMPtr<nsIXULTemplateBuilder> builder;
-    xuldoc->GetTemplateBuilderFor(this, getter_AddRefs(builder));
-    return builder.forget();
-}
-
 //----------------------------------------------------------------------
 // Implementation methods
 
 NS_IMETHODIMP
 nsXULElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
 {
     return NS_OK;
 }
--- a/dom/xul/nsXULElement.h
+++ b/dom/xul/nsXULElement.h
@@ -17,20 +17,17 @@
 #include "nsIDOMEvent.h"
 #include "nsIServiceManager.h"
 #include "nsAtom.h"
 #include "mozilla/dom/NodeInfo.h"
 #include "nsIControllers.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMXULElement.h"
 #include "nsIDOMXULMultSelectCntrlEl.h"
-#include "nsIRDFCompositeDataSource.h"
-#include "nsIRDFResource.h"
 #include "nsIURI.h"
-#include "nsIXULTemplateBuilder.h"
 #include "nsLayoutCID.h"
 #include "nsAttrAndChildArray.h"
 #include "nsGkAtoms.h"
 #include "nsStringFwd.h"
 #include "nsStyledElement.h"
 #include "nsIFrameLoader.h"
 #include "nsFrameLoader.h" // Needed because we return an
                            // already_AddRefed<nsFrameLoader> where bindings
@@ -328,22 +325,21 @@ public:
   The XUL element.
 
  */
 
 #define XUL_ELEMENT_FLAG_BIT(n_) NODE_FLAG_BIT(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET + (n_))
 
 // XUL element specific bits
 enum {
-  XUL_ELEMENT_TEMPLATE_GENERATED =        XUL_ELEMENT_FLAG_BIT(0),
-  XUL_ELEMENT_HAS_CONTENTMENU_LISTENER =  XUL_ELEMENT_FLAG_BIT(1),
-  XUL_ELEMENT_HAS_POPUP_LISTENER =        XUL_ELEMENT_FLAG_BIT(2)
+  XUL_ELEMENT_HAS_CONTENTMENU_LISTENER =  XUL_ELEMENT_FLAG_BIT(0),
+  XUL_ELEMENT_HAS_POPUP_LISTENER =        XUL_ELEMENT_FLAG_BIT(1)
 };
 
-ASSERT_NODE_FLAGS_SPACE(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET + 3);
+ASSERT_NODE_FLAGS_SPACE(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET + 2);
 
 #undef XUL_ELEMENT_FLAG_BIT
 
 class nsXULElement final : public nsStyledElement,
                            public nsIDOMXULElement
 {
 public:
     using Element::Blur;
@@ -392,25 +388,16 @@ public:
     virtual bool IsNodeOfType(uint32_t aFlags) const override;
     virtual bool IsFocusableInternal(int32_t* aTabIndex, bool aWithMouse) override;
 
     NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) override;
     virtual nsChangeHint GetAttributeChangeHint(const nsAtom* aAttribute,
                                                 int32_t aModType) const override;
     NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
 
-    // XUL element methods
-    /**
-     * The template-generated flag is used to indicate that a
-     * template-generated element has already had its children generated.
-     */
-    void SetTemplateGenerated() { SetFlags(XUL_ELEMENT_TEMPLATE_GENERATED); }
-    void ClearTemplateGenerated() { UnsetFlags(XUL_ELEMENT_TEMPLATE_GENERATED); }
-    bool GetTemplateGenerated() { return HasFlag(XUL_ELEMENT_TEMPLATE_GENERATED); }
-
     // nsIDOMNode
     NS_FORWARD_NSIDOMNODE_TO_NSINODE
     // And since that shadowed GetParentElement with the XPCOM
     // signature, pull in the one we care about.
     using nsStyledElement::GetParentElement;
 
     // nsIDOMElement
     NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
@@ -631,24 +618,16 @@ public:
     void GetTop(DOMString& aValue) const
     {
         GetXULAttr(nsGkAtoms::top, aValue);
     }
     void SetTop(const nsAString& aValue, mozilla::ErrorResult& rv)
     {
         SetXULAttr(nsGkAtoms::top, aValue, rv);
     }
-    void GetDatasources(DOMString& aValue) const
-    {
-        GetXULAttr(nsGkAtoms::datasources, aValue);
-    }
-    void SetDatasources(const nsAString& aValue, mozilla::ErrorResult& rv)
-    {
-        SetXULAttr(nsGkAtoms::datasources, aValue, rv);
-    }
     void GetRef(DOMString& aValue) const
     {
         GetXULAttr(nsGkAtoms::ref, aValue);
     }
     void SetRef(const nsAString& aValue, mozilla::ErrorResult& rv)
     {
         SetXULAttr(nsGkAtoms::ref, aValue, rv);
     }
@@ -679,19 +658,16 @@ public:
     bool AllowEvents() const
     {
         return BoolAttrIsTrue(nsGkAtoms::allowevents);
     }
     void SetAllowEvents(bool aAllowEvents)
     {
         SetXULBoolAttr(nsGkAtoms::allowevents, aAllowEvents);
     }
-    already_AddRefed<nsIRDFCompositeDataSource> GetDatabase();
-    already_AddRefed<nsIXULTemplateBuilder> GetBuilder();
-    already_AddRefed<nsIRDFResource> GetResource(mozilla::ErrorResult& rv);
     nsIControllers* GetControllers(mozilla::ErrorResult& rv);
     // Note: this can only fail if the do_CreateInstance for the boxobject
     // contact fails for some reason.
     already_AddRefed<mozilla::dom::BoxObject> GetBoxObject(mozilla::ErrorResult& rv);
     void Click(mozilla::dom::CallerType aCallerType);
     void DoCommand();
     already_AddRefed<nsINodeList>
       GetElementsByAttribute(const nsAString& aAttribute,
rename from dom/xul/templates/nsXULSortService.cpp
rename to dom/xul/nsXULSortService.cpp
--- a/dom/xul/templates/nsXULSortService.cpp
+++ b/dom/xul/nsXULSortService.cpp
@@ -15,18 +15,16 @@
 #include "nsGkAtoms.h"
 #include "nsNameSpaceManager.h"
 #include "nsXULContentUtils.h"
 #include "nsString.h"
 #include "nsQuickSort.h"
 #include "nsWhitespaceTokenizer.h"
 #include "nsXULSortService.h"
 #include "nsXULElement.h"
-#include "nsIXULTemplateBuilder.h"
-#include "nsTemplateMatch.h"
 #include "nsICollation.h"
 #include "nsUnicharUtils.h"
 
 NS_IMPL_ISUPPORTS(XULSortServiceImpl, nsIXULSortService)
 
 void
 XULSortServiceImpl::SetSortHints(Element* aElement, nsSortState* aSortState)
 {
@@ -88,33 +86,18 @@ XULSortServiceImpl::SetSortColumnHints(n
   }
 }
 
 nsresult
 XULSortServiceImpl::GetItemsToSort(nsIContent *aContainer,
                                    nsSortState* aSortState,
                                    nsTArray<contentSortInfo>& aSortItems)
 {
-  // if there is a template attached to the sort node, use the builder to get
-  // the items to be sorted
-  RefPtr<nsXULElement> element = nsXULElement::FromContent(aContainer);
-  if (element) {
-    nsCOMPtr<nsIXULTemplateBuilder> builder = element->GetBuilder();
-
-    if (builder) {
-      nsresult rv = builder->GetQueryProcessor(getter_AddRefs(aSortState->processor));
-      if (NS_FAILED(rv) || !aSortState->processor)
-        return rv;
-
-      return GetTemplateItemsToSort(aContainer, builder, aSortState, aSortItems);
-    }
-  }
-
-  // if there is no template builder, just get the children. For trees,
-  // get the treechildren element as use that as the parent
+  // Get the children. For trees, get the treechildren element and
+  // use that as the parent
   RefPtr<Element> treechildren;
   if (aContainer->NodeInfo()->Equals(nsGkAtoms::tree, kNameSpaceID_XUL)) {
     nsXULContentUtils::FindChildByTag(aContainer,
                                       kNameSpaceID_XUL,
                                       nsGkAtoms::treechildren,
                                       getter_AddRefs(treechildren));
     if (!treechildren)
       return NS_OK;
@@ -131,90 +114,41 @@ XULSortServiceImpl::GetItemsToSort(nsICo
 
     cinfo->content = child;
   }
 
   return NS_OK;
 }
 
 
-nsresult
-XULSortServiceImpl::GetTemplateItemsToSort(nsIContent* aContainer,
-                                           nsIXULTemplateBuilder* aBuilder,
-                                           nsSortState* aSortState,
-                                           nsTArray<contentSortInfo>& aSortItems)
-{
-  for (nsIContent* child = aContainer->GetFirstChild();
-       child;
-       child = child->GetNextSibling()) {
-
-    nsCOMPtr<nsIDOMElement> childnode = do_QueryInterface(child);
-
-    nsCOMPtr<nsIXULTemplateResult> result;
-    nsresult rv = aBuilder->GetResultForContent(childnode, getter_AddRefs(result));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    if (result) {
-      contentSortInfo* cinfo = aSortItems.AppendElement();
-      if (!cinfo)
-        return NS_ERROR_OUT_OF_MEMORY;
-
-      cinfo->content = child;
-      cinfo->result = result;
-    }
-    else if (!aContainer->IsXULElement(nsGkAtoms::_template)) {
-      rv = GetTemplateItemsToSort(child, aBuilder, aSortState, aSortItems);
-      NS_ENSURE_SUCCESS(rv, rv);
-    }
-  }
-
-  return NS_OK;
-}
-
 int
 testSortCallback(const void *data1, const void *data2, void *privateData)
 {
   /// Note: testSortCallback is a small C callback stub for NS_QuickSort
   contentSortInfo *left = (contentSortInfo *)data1;
   contentSortInfo *right = (contentSortInfo *)data2;
   nsSortState* sortState = (nsSortState *)privateData;
 
   int32_t sortOrder = 0;
 
-  if (sortState->direction == nsSortState_natural && sortState->processor) {
-    // sort in natural order
-    sortState->processor->CompareResults(left->result, right->result,
-                                         nullptr, sortState->sortHints, &sortOrder);
-  }
-  else {
-    int32_t length = sortState->sortKeys.Length();
-    for (int32_t t = 0; t < length; t++) {
-      // for templates, use the query processor to do sorting
-      if (sortState->processor) {
-        sortState->processor->CompareResults(left->result, right->result,
-                                             sortState->sortKeys[t],
-                                             sortState->sortHints, &sortOrder);
-        if (sortOrder)
-          break;
-      } else {
-        // no template, so just compare attributes. Ignore namespaces for now.
-        nsAutoString leftstr, rightstr;
-        if (left->content->IsElement()) {
-          left->content->AsElement()->GetAttr(kNameSpaceID_None,
-                                              sortState->sortKeys[t],
-                                              leftstr);
-        }
-        if (right->content->IsElement()) {
-          right->content->AsElement()->GetAttr(kNameSpaceID_None,
-                                               sortState->sortKeys[t], rightstr);
-        }
+  int32_t length = sortState->sortKeys.Length();
+  for (int32_t t = 0; t < length; t++) {
+    // compare attributes. Ignore namespaces for now.
+    nsAutoString leftstr, rightstr;
+    if (left->content->IsElement()) {
+      left->content->AsElement()->GetAttr(kNameSpaceID_None,
+                                          sortState->sortKeys[t],
+                                          leftstr);
+    }
+    if (right->content->IsElement()) {
+      right->content->AsElement()->GetAttr(kNameSpaceID_None,
+                                           sortState->sortKeys[t], rightstr);
+    }
 
-        sortOrder = XULSortServiceImpl::CompareValues(leftstr, rightstr, sortState->sortHints);
-      }
-    }
+    sortOrder = XULSortServiceImpl::CompareValues(leftstr, rightstr, sortState->sortHints);
   }
 
   if (sortState->direction == nsSortState_descending)
     sortOrder = -sortOrder;
 
   return sortOrder;
 }
 
@@ -484,17 +418,16 @@ XULSortServiceImpl::Sort(nsIDOMNode* aNo
   nsresult rv = InitializeSortState(sortNode, sortNode,
                                     aSortKey, aSortHints, &sortState);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // store sort info in attributes on content
   SetSortHints(sortNode, &sortState);
   rv = SortContainer(sortNode, &sortState);
 
-  sortState.processor = nullptr; // don't hang on to this reference
   return rv;
 }
 
 nsresult
 NS_NewXULSortService(nsIXULSortService** sortService)
 {
   *sortService = new XULSortServiceImpl();
   NS_ADDREF(*sortService);
rename from dom/xul/templates/nsXULSortService.h
rename to dom/xul/nsXULSortService.h
--- a/dom/xul/templates/nsXULSortService.h
+++ b/dom/xul/nsXULSortService.h
@@ -1,77 +1,69 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
-  This sort service is used to sort template built content or content by attribute.
+  This sort service is used to sort content by attribute.
  */
 
-#ifndef nsXULTemplateResultSetRDF_h
-#define nsXULTemplateResultSetRDF_h
+#ifndef nsXULSortService_h
+#define nsXULSortService_h
 
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
 #include "nsTArray.h"
 #include "nsIContent.h"
-#include "nsIXULTemplateResult.h"
-#include "nsIXULTemplateQueryProcessor.h"
 #include "nsIXULSortService.h"
 #include "nsCycleCollectionParticipant.h"
 
 enum nsSortState_direction {
   nsSortState_descending,
   nsSortState_ascending,
   nsSortState_natural
 };
 
 // the sort state holds info about the current sort
 struct nsSortState
 {
   bool initialized;
   MOZ_INIT_OUTSIDE_CTOR bool invertSort;
   MOZ_INIT_OUTSIDE_CTOR bool inbetweenSeparatorSort;
   MOZ_INIT_OUTSIDE_CTOR bool sortStaticsLast;
-  MOZ_INIT_OUTSIDE_CTOR bool isContainerRDFSeq;
 
   uint32_t sortHints;
 
   MOZ_INIT_OUTSIDE_CTOR nsSortState_direction direction;
   nsAutoString sort;
   nsTArray<RefPtr<nsAtom>> sortKeys;
 
-  nsCOMPtr<nsIXULTemplateQueryProcessor> processor;
   nsCOMPtr<nsIContent> lastContainer;
   MOZ_INIT_OUTSIDE_CTOR bool lastWasFirst, lastWasLast;
 
   nsSortState()
     : initialized(false),
-      isContainerRDFSeq(false),
       sortHints(0)
   {
   }
   void Traverse(nsCycleCollectionTraversalCallback &cb) const
   {
-    cb.NoteXPCOMChild(processor);
     cb.NoteXPCOMChild(lastContainer);
   }
 };
 
 // information about a particular item to be sorted
 struct contentSortInfo {
   nsCOMPtr<nsIContent> content;
   nsCOMPtr<nsIContent> parent;
-  nsCOMPtr<nsIXULTemplateResult> result;
   void swap(contentSortInfo& other)
   {
     content.swap(other.content);
     parent.swap(other.parent);
-    result.swap(other.result);
   }
 };
 
 ////////////////////////////////////////////////////////////////////////
 // ServiceImpl
 //
 //   This is the sort service.
 //
@@ -118,25 +110,16 @@ public:
    *   - otherwise, get the direct children
    */
   nsresult
   GetItemsToSort(nsIContent *aContainer,
                  nsSortState* aSortState,
                  nsTArray<contentSortInfo>& aSortItems);
 
   /**
-   * Get the list of items to sort for template built content
-   */
-  nsresult
-  GetTemplateItemsToSort(nsIContent* aContainer,
-                         nsIXULTemplateBuilder* aBuilder,
-                         nsSortState* aSortState,
-                         nsTArray<contentSortInfo>& aSortItems);
-
-  /**
    * Sort a container using the supplied sort state details.
    */
   nsresult
   SortContainer(nsIContent *aContainer, nsSortState* aSortState);
 
   /**
    * Given a list of sortable items, reverse the list. This is done
    * when simply changing the sort direction for the same key.
@@ -166,9 +149,9 @@ public:
    * Compares aLeft and aRight and returns < 0, 0, or > 0. The sort
    * hints are checked for case matching and integer sorting.
    */
   static int32_t CompareValues(const nsAString& aLeft,
                                const nsAString& aRight,
                                uint32_t aSortHints);
 };
 
-#endif
+#endif // nsXULSortService_h
deleted file mode 100644
--- a/dom/xul/templates/crashtests/257752-1-recursion.rdf
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0"?>
-<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-     xmlns:m="urn:foo#">
-   <rdf:Seq about="urn:x-rec:1">
-     <rdf:li rdf:resource="urn:x-rec:2"/>
-   </rdf:Seq>
-   <rdf:Seq about="urn:x-rec:2">
-     <rdf:li rdf:resource="urn:x-rec:3"/>
-   </rdf:Seq>
-   <rdf:Seq about="urn:x-rec:3">
-     <rdf:li rdf:resource="urn:x-rec:1"/>
-   </rdf:Seq>
-</rdf:RDF>
deleted file mode 100644
--- a/dom/xul/templates/crashtests/257752-1-recursion.xul
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-
-<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
-
-<window id="child-iterate-recurse"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
-<vbox flex="1" style="overflow: auto;">
-
-<vbox datasources="257752-1-recursion.rdf" ref="urn:x-rec:1">
-  <template>
-    <rule>
-      <conditions>
-          <content uri="?uri"/>
-          <member container="?uri" child="?child"/>
-      </conditions>
-      <action>
-        <vbox uri="?child" style="border: 1px solid grey; margin: 1em;">
-          <label value="hi"/>
-        </vbox>
-      </action>
-    </rule>
-  </template>
-</vbox>
-
-</vbox>
-
-</window>
deleted file mode 100644
--- a/dom/xul/templates/crashtests/329884-1.xul
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-        
-<script>
-
-function rM(q1) { q1.parentNode.removeChild(q1); }
-
-function init2()
-{ 
-  rM(document.getElementById("t"));
-}
-
-window.addEventListener("load", init2, false);
-
-</script>
-
-<foo id="t" datasources="1.rdf" />
-
-</window>
deleted file mode 100644
--- a/dom/xul/templates/crashtests/330012-1.rdf
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0"?>
-<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-         xmlns:s="urn:squarefree:a1:">
-  <rdf:Description about="urn:root">
-    <s:grapes>
-      <rdf:Bag>
-        <rdf:li>
-          <rdf:Description/>
-        </rdf:li>
-      </rdf:Bag>
-    </s:grapes>
- </rdf:Description>
-</rdf:RDF>
deleted file mode 100644
--- a/dom/xul/templates/crashtests/330012-1.xul
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
-  <foo id="foo" datasources="330012-1.rdf" ref="urn:root">
-    <template>
-      <rule>
-        <conditions>
-          <content uri="?root"/>
-          <triple subject="?root"
-                  predicate="urn:squarefree:a1:grapes"
-                  object="?lalala"/>
-          <member container="?grapes" child="?grape"/>
-        </conditions>
-        <action>
-          <bar uri="?grape"/>
-       </action>
-     </rule>
-   </template>
- </foo>
-
-</window>
deleted file mode 100644
--- a/dom/xul/templates/crashtests/404346-1.xul
+++ /dev/null
@@ -1,7 +0,0 @@
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-<box id="b">
-<box id="a" template="b"/>
-<triple/>
-</box>
-<box datasources="" observes="a" ref="bbb"/>
-</window>
\ No newline at end of file
deleted file mode 100644
--- a/dom/xul/templates/crashtests/415019-1.xul
+++ /dev/null
@@ -1,14 +0,0 @@
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-  <hbox datasources="nosuch.rdf" ref="urn:root">
-    <template>
-      <rule>
-        <conditions>
-          <triple subject="?a"/>
-        </conditions>
-        <action>
-          <vbox uri="?b"/>
-        </action>
-      </rule>
-    </template>
-  </hbox>
-</window>
deleted file mode 100644
--- a/dom/xul/templates/crashtests/417840-1.xul
+++ /dev/null
@@ -1,1 +0,0 @@
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="document.getElementById('foo').removeAttribute('ref');"><foo id="foo" datasources="nosuch.rdf" ref="urn:root"><template/></foo></window>
deleted file mode 100644
--- a/dom/xul/templates/crashtests/424418-1.xul
+++ /dev/null
@@ -1,1 +0,0 @@
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"><hbox datasources="u"/></window>
deleted file mode 100644
--- a/dom/xul/templates/crashtests/crashtests.list
+++ /dev/null
@@ -1,7 +0,0 @@
-load 257752-1-recursion.xul
-load 329884-1.xul
-skip-if(winWidget) load 330012-1.xul # bug 742455
-load 404346-1.xul
-load 415019-1.xul
-load 417840-1.xul
-load 424418-1.xul
deleted file mode 100644
--- a/dom/xul/templates/moz.build
+++ /dev/null
@@ -1,64 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-MOCHITEST_CHROME_MANIFESTS += ['tests/chrome/chrome.ini']
-
-XPIDL_SOURCES += [
-    'nsIXULBuilderListener.idl',
-    'nsIXULSortService.idl',
-    'nsIXULTemplateBuilder.idl',
-    'nsIXULTemplateQueryProcessor.idl',
-    'nsIXULTemplateResult.idl',
-    'nsIXULTemplateRuleFilter.idl',
-]
-
-XPIDL_MODULE = 'xultmpl'
-
-EXPORTS += [
-    'nsTreeRows.h',
-    'nsXULTemplateBuilder.h',
-    'nsXULTreeBuilder.h',
-]
-
-UNIFIED_SOURCES += [
-    'nsContentSupportMap.cpp',
-    'nsContentTestNode.cpp',
-    'nsInstantiationNode.cpp',
-    'nsRDFBinding.cpp',
-    'nsRDFConInstanceTestNode.cpp',
-    'nsRDFConMemberTestNode.cpp',
-    'nsRDFPropertyTestNode.cpp',
-    'nsRDFQuery.cpp',
-    'nsResourceSet.cpp',
-    'nsRuleNetwork.cpp',
-    'nsTemplateMatch.cpp',
-    'nsTemplateRule.cpp',
-    'nsTreeRows.cpp',
-    'nsXMLBinding.cpp',
-    'nsXULContentBuilder.cpp',
-    'nsXULContentUtils.cpp',
-    'nsXULSortService.cpp',
-    'nsXULTemplateBuilder.cpp',
-    'nsXULTemplateQueryProcessorRDF.cpp',
-    'nsXULTemplateQueryProcessorStorage.cpp',
-    'nsXULTemplateQueryProcessorXML.cpp',
-    'nsXULTemplateResultRDF.cpp',
-    'nsXULTemplateResultSetRDF.cpp',
-    'nsXULTemplateResultStorage.cpp',
-    'nsXULTemplateResultXML.cpp',
-    'nsXULTreeBuilder.cpp',
-]
-
-LOCAL_INCLUDES += [
-    '/dom/base',
-    '/dom/xul',
-    '/layout/xul/tree/',
-]
-
-FINAL_LIBRARY = 'xul'
-
-if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
-    CXXFLAGS += ['-Wno-error=shadow']
deleted file mode 100644
--- a/dom/xul/templates/nsContentSupportMap.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsContentSupportMap.h"
-#include "nsXULElement.h"
-
-void
-nsContentSupportMap::Remove(nsIContent* aElement)
-{
-    nsIContent* child = aElement;
-    do {
-        mMap.Remove(child);
-        child = child->GetNextNode(aElement);
-    } while(child);
-}
-
deleted file mode 100644
--- a/dom/xul/templates/nsContentSupportMap.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsContentSupportMap_h__
-#define nsContentSupportMap_h__
-
-#include "PLDHashTable.h"
-#include "nsTemplateMatch.h"
-
-/**
- * The nsContentSupportMap maintains a mapping from a "resource element"
- * in the content tree to the nsTemplateMatch that was used to instantiate it. This
- * is necessary to allow the XUL content to be built lazily. Specifically,
- * when building "resumes" on a partially-built content element, the builder
- * will walk upwards in the content tree to find the first element with an
- * 'id' attribute. This element is assumed to be the "resource element",
- * and allows the content builder to access the nsTemplateMatch (variable assignments
- * and rule information).
- */
-class nsContentSupportMap {
-public:
-    nsContentSupportMap() : mMap(PLDHashTable::StubOps(), sizeof(Entry)) { }
-    ~nsContentSupportMap() { }
-
-    nsresult Put(nsIContent* aElement, nsTemplateMatch* aMatch) {
-        PLDHashEntryHdr* hdr = mMap.Add(aElement, mozilla::fallible);
-        if (!hdr)
-            return NS_ERROR_OUT_OF_MEMORY;
-
-        Entry* entry = static_cast<Entry*>(hdr);
-        NS_ASSERTION(entry->mMatch == nullptr, "over-writing entry");
-        entry->mContent = aElement;
-        entry->mMatch   = aMatch;
-        return NS_OK;
-    }
-
-    bool Get(nsIContent* aElement, nsTemplateMatch** aMatch) {
-        PLDHashEntryHdr* hdr = mMap.Search(aElement);
-        if (!hdr)
-            return false;
-
-        Entry* entry = static_cast<Entry*>(hdr);
-        *aMatch = entry->mMatch;
-        return true;
-    }
-
-    void Remove(nsIContent* aElement);
-
-    void Clear() { mMap.Clear(); }
-
-protected:
-    PLDHashTable mMap;
-
-    struct Entry : public PLDHashEntryHdr {
-        nsIContent*      mContent;
-        nsTemplateMatch* mMatch;
-    };
-};
-
-#endif
deleted file mode 100644
--- a/dom/xul/templates/nsContentTestNode.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsContentTestNode.h"
-#include "nsIRDFResource.h"
-#include "nsAtom.h"
-#include "nsIDOMElement.h"
-#include "nsXULContentUtils.h"
-#include "nsIXULTemplateResult.h"
-#include "nsIXULTemplateBuilder.h"
-#include "nsXULTemplateQueryProcessorRDF.h"
-
-#include "mozilla/Logging.h"
-
-using mozilla::LogLevel;
-
-extern mozilla::LazyLogModule gXULTemplateLog;
-
-nsContentTestNode::nsContentTestNode(nsXULTemplateQueryProcessorRDF* aProcessor,
-                                     nsAtom* aRefVariable)
-    : TestNode(nullptr),
-      mProcessor(aProcessor),
-      mDocument(nullptr),
-      mRefVariable(aRefVariable),
-      mTag(nullptr)
-{
-    if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-        nsAutoString tag(NS_LITERAL_STRING("(none)"));
-        if (mTag)
-            mTag->ToString(tag);
-
-        nsAutoString refvar(NS_LITERAL_STRING("(none)"));
-        if (aRefVariable)
-            aRefVariable->ToString(refvar);
-
-        MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-               ("nsContentTestNode[%p]: ref-var=%s tag=%s",
-                this, NS_ConvertUTF16toUTF8(refvar).get(),
-                NS_ConvertUTF16toUTF8(tag).get()));
-    }
-}
-
-nsresult
-nsContentTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
-                                        bool* aCantHandleYet) const
-
-{
-    if (aCantHandleYet)
-        *aCantHandleYet = false;
-    return NS_OK;
-}
-
-nsresult
-nsContentTestNode::Constrain(InstantiationSet& aInstantiations)
-{
-    // contrain the matches to those that have matched in the template builder
-
-    nsIXULTemplateBuilder* builder = mProcessor->GetBuilder();
-    if (!builder) {
-        aInstantiations.Clear();
-        return NS_OK;
-    }
-
-    nsresult rv;
-
-    InstantiationSet::Iterator last = aInstantiations.Last();
-    for (InstantiationSet::Iterator inst = aInstantiations.First(); inst != last; ++inst) {
-
-        nsCOMPtr<nsIRDFNode> refValue;
-        bool hasRefBinding = inst->mAssignments.GetAssignmentFor(mRefVariable,
-                                                                   getter_AddRefs(refValue));
-        if (hasRefBinding) {
-            nsCOMPtr<nsIRDFResource> refResource = do_QueryInterface(refValue);
-            if (refResource) {
-                bool generated;
-                rv = builder->HasGeneratedContent(refResource, mTag, &generated);
-                if (NS_FAILED(rv)) return rv;
-
-                if (generated)
-                    continue;
-            }
-        }
-
-        aInstantiations.Erase(inst--);
-    }
-
-    return NS_OK;
-}
deleted file mode 100644
--- a/dom/xul/templates/nsContentTestNode.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsContentTestNode_h__
-#define nsContentTestNode_h__
-
-#include "mozilla/Attributes.h"
-#include "nscore.h"
-#include "nsRuleNetwork.h"
-#include "nsAtom.h"
-#include "nsIDOMDocument.h"
-
-class nsXULTemplateQueryProcessorRDF;
-
-/**
- * The nsContentTestNode is always the top node in a query's rule network. It
- * exists so that Constrain can filter out resources that aren't part of a
- * result.
- */
-class nsContentTestNode : public TestNode
-{
-public:
-    nsContentTestNode(nsXULTemplateQueryProcessorRDF* aProcessor,
-                      nsAtom* aContentVariable);
-
-    virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations,
-                                          bool* aCantHandleYet) const override;
-
-    nsresult
-    Constrain(InstantiationSet& aInstantiations) override;
-
-    void SetTag(nsAtom* aTag, nsIDOMDocument* aDocument)
-    {
-        mTag = aTag;
-        mDocument = aDocument;
-    }
-
-protected:
-    nsXULTemplateQueryProcessorRDF *mProcessor;
-    nsIDOMDocument* mDocument;
-    RefPtr<nsAtom> mRefVariable;
-    RefPtr<nsAtom> mTag;
-};
-
-#endif // nsContentTestNode_h__
-
deleted file mode 100644
--- a/dom/xul/templates/nsIXULBuilderListener.idl
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -*- Mode: idl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-
-#include "nsISupports.idl"
-
-interface nsIXULTemplateBuilder;
-
-// An nsIXULBuilderListener object is a listener that will be notified
-// when a template builder rebuilds its content.
-[scriptable, uuid(ac46be8f-c863-4c23-84a2-d0fcc8dfa9f4)]
-interface nsIXULBuilderListener: nsISupports {
-
-  /**
-   * Called before a template builder rebuilds its content.
-   * @param aBuilder the template builder that rebuilds the content.
-   */
-  void willRebuild(in nsIXULTemplateBuilder aBuilder);
-
-  /**
-   * Called after a template builder has rebuilt its content.
-   * @param aBuilder the template builder that has rebuilt the content.
-   */
-  void didRebuild(in nsIXULTemplateBuilder aBuilder);
-
-};
deleted file mode 100644
--- a/dom/xul/templates/nsIXULTemplateBuilder.idl
+++ /dev/null
@@ -1,407 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "domstubs.idl"
-
-interface nsIContent;
-interface nsIXULBuilderListener;
-interface nsIXULTemplateResult;
-interface nsIXULTemplateRuleFilter;
-interface nsIXULTemplateQueryProcessor;
-interface nsIRDFResource;
-interface nsIRDFCompositeDataSource;
-interface nsIDOMDataTransfer;
-
-%{C++
-class nsAtom;
-%}
-[ptr] native nsAtomPtr(nsAtom);
-[ptr] native Element (mozilla::dom::Element);
-
-/**
- * A template builder, given an input source of data, a template, and a
- * reference point, generates a list of results from the input, and copies
- * part of the template for each result. Templates may generate content
- * recursively, using the same template, but with the previous iteration's
- * results as the reference point. As an example, for an XML datasource the
- * initial reference point would be a specific node in the DOM tree and a
- * template might generate a list of all child nodes. For the next iteration,
- * those children would be used to generate output for their child nodes and
- * so forth.
- *
- * A template builder is attached to a single DOM node; this node is called
- * the root node and is expected to contain a XUL template element as a direct
- * child. Different template builders may be specialized in the manner in
- * which they generate and display the resulting content from the template.
- *
- * The structure of a template is as follows:
- *
- * <rootnode datasources="" ref="">
- *   <template>
- *     <queryset>
- *       <query>
- *       </query>
- *       <rule>
- *         <conditions>...</conditions>
- *         <bindings>...</bindings>
- *         <action>...</action>
- *       </rule>
- *     </queryset>
- *   </template>
- * </rootnode>
- *
- * The datasources attribute on the root node is used to identify the source
- * of data to be used. The ref attribute is used to specify the reference
- * point for the query. Currently, the datasource will either be an
- * nsIRDFDataSource or a DOM node. In the future, other datasource types may
- * be used.
- *
- * The <queryset> element contains a single query and one or more <rule>
- * elements. There may be more than one <queryset> if multiple queries are
- * desired, and this element is optional if only one query is needed -- in
- * that case the <query> and <rule>s are allowed to be children of the
- * <template> node
- *
- * The contents of the query are processed by a separate component called a
- * query processor. This query processor is expected to use this query to
- * generate results when asked by the template builder. The template builder
- * then generates output for each result based on the <rule> elements.
- *
- * This allows the query processor to be specific to a particular kind of
- * input data or query syntax, while the template builder remains independent
- * of the kind of data being used. Due to this, the query processor will be
- * supplied with the datasource and query which the template builder handles
- * in an opaque way, while the query processor handles these more
- * specifically.
- *
- * Results implement the nsIXULTemplateResult interface and may be identified
- * by an id which must be unique within a given set of query results.
- *
- * Each query may be accompanied by one or more <rule> elements. These rules
- * are evaluated by the template builder for each result produced by the
- * query. A rule consists of conditions that cause a rule to be either
- * accepted or rejected. The condition syntax allows for common conditional
- * handling; additional filtering may be applied by adding a custom filter
- * to a rule with the builder's addRuleFilter method.
- *
- * If a result passes a rule's conditions, this is considered a match, and the
- * content within the rule's <action> body is inserted as a sibling of the
- * <template>, assuming the template builder creates real DOM content. Only
- * one rule will match a result. For a tree builder, for example, the content
- * within the action body is used to create the tree rows instead. A matching
- * result must have its ruleMatched method called. When a result no longer
- * matches, the result's hasBeenRemoved method must be called.
- *
- * Optionally, the rule may have a <bindings> section which may be used to
- * define additional variables to be used within an action body. Each of these
- * declared bindings must be supplied to the query processor via its
- * addBinding method. The bindings are evaluated after a rule has matched.
- *
- * Templates may generate content recursively, using the previous iteration's
- * results as reference point to invoke the same queries. Since the reference
- * point is different, different output will typically be generated.
- *
- * The reference point nsIXULTemplateResult object for the first iteration is
- * determined by calling the query processor's translateRef method using the
- * value of the root node's ref attribute. This object may be retrieved later
- * via the builder's rootResult property.
- *
- * For convenience, each reference point as well as all results implement the
- * nsIXULTemplateResult interface, allowing the result objects from each
- * iteration to be used directly as the reference points for the next
- * iteration.
- *
- * When using multiple queries, each may generate results with the same id.
- * More than one of these results may match one of the rules in their
- * respective queries, however only the result for the earliest matching query
- * in the template becomes the active match and generates output. The
- * addResult, removeResult, replaceResult and resultBindingChanged methods may
- * be called by the query processor to indicate that the set of valid results
- * has changed, such that a different query may match. If a different match
- * would become active, the content for the existing match is removed and the
- * content for the new match is generated. A query processor is not required
- * to provide any support for updating results after they have been generated.
- *
- * See http://wiki.mozilla.org/XUL:Templates_Plan for details about templates.
- */
-[scriptable, uuid(A583B676-5B02-4F9C-A0C9-CB850CB99818)]
-interface nsIXULTemplateBuilder : nsISupports
-{
-    /**
-     * The root node in the DOM to which this builder is attached.
-     */
-    readonly attribute nsIDOMElement root;
-
-    /**
-     * The opaque datasource object that is used for the template. This object
-     * is created by the getDataSource method of the query processor. May be
-     * null if the datasource has not been loaded yet. Set this attribute to
-     * use a different datasource and rebuild the template.
-     *
-     * For an RDF datasource, this will be the same as the database. For XML
-     * this will be the nsIDOMNode for the datasource document or node for
-     * an inline reference (such as #name). Other query processors may use
-     * other types for the datasource.
-     */
-    attribute nsISupports datasource;
-
-    /**
-     * The composite datasource that the template builder observes
-     * and uses to create content. This is used only for RDF queries and is
-     * maintained for backwards compatibility. It will be the same object as
-     * the datasource property. For non-RDF queries, it will always be null.
-     */
-    readonly attribute nsIRDFCompositeDataSource database;
-
-    /**
-     * The virtual result representing the starting reference point,
-     * determined by calling the query processor's translateRef method
-     * with the root node's ref attribute as an argument.
-     */
-    readonly attribute nsIXULTemplateResult rootResult;
-
-    /**
-     * The query processor used to generate results.
-     */
-    [noscript] readonly attribute nsIXULTemplateQueryProcessor queryProcessor;
-
-    /**
-     * Force the template builder to rebuild its content. All existing content
-     * will be removed first. The query processor's done() method will be
-     * invoked during cleanup, followed by its initializeForBuilding method
-     * when the content is to be regenerated.
-     * 
-     */
-    void rebuild();
-
-    /**
-     * Reload any of our RDF datasources that support nsIRDFRemoteDatasource. 
-     *
-     * @note This is a temporary hack so that remote-XUL authors can
-     *       reload remote datasources. When RDF becomes remote-scriptable,
-     *       this will no longer be necessary.
-     */
-    void refresh();
-
-    /**
-     * Inform the template builder that a new result is available. The builder
-     * will add this result to the set of results. The query node that the
-     * new result applies to must be specified using the aQueryNode parameter.
-     *
-     * The builder will apply the rules associated with the query to the new
-     * result, unless a result with the same id from an earlier query
-     * supersedes it, and the result's RuleMatched method will be called if it
-     * matches.
-     *
-     * @param aResult the result to add
-     * @param aQueryNode the query that the result applies to
-     *
-     * @throws NS_ERROR_NULL_POINTER if aResult or aQueryNode are null
-     */
-    void addResult(in nsIXULTemplateResult aResult, in nsIDOMNode aQueryNode);
-
-    /**
-     * Inform the template builder that a result no longer applies. The builder
-     * will call the remove content generated for the result, if any. If a different
-     * query would then match instead, it will become the active match. This
-     * method will have no effect if the result isn't known to the builder.
-     *
-     * @param aResult the result to remove
-     *
-     * @throws NS_ERROR_NULL_POINTER if aResult is null
-     */
-    void removeResult(in nsIXULTemplateResult aResult);
-
-    /**
-     * Inform the template builder that one result should be replaced with
-     * another. Both the old result (aOldResult) and the new result
-     * (aNewResult) must have the same id. The query node that the new result
-     * applies to must be specified using the aQueryNode parameter.
-     *
-     * This method is expected to have the same effect as calling both
-     * removeResult for the old result and addResult for the new result.
-     *
-     * @param aOldResult the old result
-     * @param aNewResult the new result
-     * @param aQueryNode the query that the new result applies to
-     *
-     * @throws NS_ERROR_NULL_POINTER if either argument is null, or
-     *         NS_ERROR_INVALID_ARG if the ids don't match
-     */
-    void replaceResult(in nsIXULTemplateResult aOldResult,
-                       in nsIXULTemplateResult aNewResult,
-                       in nsIDOMNode aQueryNode);
-
-    /**
-     * Inform the template builder that one or more of the optional bindings
-     * for a result has changed. In this case, the rules are not reapplied as
-     * it is expected that the same rule will still apply. The builder will
-     * resynchronize any variables that are referenced in the action body.
-     *
-     * @param aResult the result to change
-     *
-     * @throws NS_ERROR_NULL_POINTER if aResult is null
-     */
-    void resultBindingChanged(in nsIXULTemplateResult aResult);
-
-    /**
-     * Return the result for a given id. Only one such result is returned and
-     * is always the result with that id associated with the active match.
-     * This method will return null is there is no result for the id.
-     *
-     * @param aId the id to return the result for
-     */
-    nsIXULTemplateResult getResultForId(in AString aId);
-
-    /**
-     * Retrieve the result corresponding to a generated element, or null is
-     * there isn't one.
-     *
-     * @param aContent element to result the result of
-     */
-    nsIXULTemplateResult getResultForContent(in nsIDOMElement aElement);
-
-    /**
-     * Returns true if the node has content generated for it. This method is
-     * intended to be called only by the RDF query processor. If aTag is set,
-     * the content must have a tag name that matches aTag. aTag may be ignored
-     * for builders that don't generate real DOM content.
-     *
-     * @param aNode node to check
-     * @param aTag tag that must match
-     */
-    [noscript] boolean hasGeneratedContent(in nsIRDFResource aNode,
-                                           in nsAtomPtr aTag);
-
-    /**
-     * Adds a rule filter for a given rule, which may be used for specialized
-     * rule filtering. Any existing filter on the rule is removed. The default
-     * conditions specified inside the <rule> tag are applied before the
-     * rule filter is applied, meaning that the filter may be used to further
-     * filter out results but not reaccept results that have already been
-     * rejected.
-     *
-     * @param aRule the rule to apply the filter to
-     * @param aFilter the filter to add
-     */
-    void addRuleFilter(in nsIDOMNode aRule, in nsIXULTemplateRuleFilter aFilter);
-
-    /**
-     * Invoked lazily by a XUL element that needs its child content built.
-     * If aForceCreation is true, then the contents of an element will be
-     * generated even if it is closed. If false, the element will only
-     * generate its contents if it is open. This behaviour is used with menus.
-     */
-    [noscript] void createContents(in Element aElement,
-                                   in boolean aForceCreation);
-
-    /**
-     * Add a listener to this template builder. The template builder
-     * holds a strong reference to the listener.
-     */
-    void addListener(in nsIXULBuilderListener aListener);
-
-    /**
-     * Remove a listener from this template builder.
-     */
-    void removeListener(in nsIXULBuilderListener aListener);
-};
-
-/**
- * nsIXULTreeBuilderObserver
- *  This interface allows clients of the XULTreeBuilder to define domain 
- *  specific handling of specific nsITreeView methods that 
- *  XULTreeBuilder does not implement.
- */
-[scriptable, uuid(57CED9A7-EC0B-4A0E-8AEB-5DA32EBE951C)]
-interface nsIXULTreeBuilderObserver : nsISupports
-{
-    const long DROP_BEFORE = -1;
-    const long DROP_ON = 0;
-    const long DROP_AFTER = 1;
-    /**
-     * Methods used by the drag feedback code to determine if a drag is allowable at
-     * the current location. To get the behavior where drops are only allowed on
-     * items, such as the mailNews folder pane, always return false whe
-     * the orientation is not DROP_ON.
-     */
-    boolean canDrop(in long index, in long orientation, in nsIDOMDataTransfer dataTransfer);
-
-    /**
-     * Called when the user drops something on this view. The |orientation| param
-     * specifies before/on/after the given |row|.
-     */
-    void onDrop(in long row, in long orientation, in nsIDOMDataTransfer dataTransfer);
- 
-    /** 
-     * Called when an item is opened or closed. 
-     */
-    void onToggleOpenState (in long index);
-
-    /** 
-	 * Called when a header is clicked.
-     */
-    void onCycleHeader(in wstring colID, in nsIDOMElement elt);
-
-    /**
-     * Called when a cell in a non-selectable cycling column (e.g. 
-     * unread/flag/etc.) is clicked.
-     */
-    void onCycleCell(in long row, in wstring colID);
-
-    /** 
-     * Called when selection in the tree changes
-     */
-    void onSelectionChanged();
-
-    /**
-     * A command API that can be used to invoke commands on the selection.  
-     * The tree will automatically invoke this method when certain keys 
-     * are pressed.  For example, when the DEL key is pressed, performAction 
-     * will be called with the "delete" string. 
-     */
-    void onPerformAction(in wstring action);
-
-    /**
-     * A command API that can be used to invoke commands on a specific row.
-     */
-    void onPerformActionOnRow(in wstring action, in long row);
-
-    /**
-     * A command API that can be used to invoke commands on a specific cell.
-     */
-    void onPerformActionOnCell(in wstring action, in long row, in wstring colID);
-};
-
-[scriptable, uuid(06b31b15-ebf5-4e74-a0e2-6bc0a18a3969)]
-interface nsIXULTreeBuilder : nsISupports
-{
-    /**
-     * Retrieve the RDF resource associated with the specified row.
-     */
-    nsIRDFResource getResourceAtIndex(in long aRowIndex);
-
-    /**
-     * Retrieve the index associated with specified RDF resource.
-     */
-    long getIndexOfResource(in nsIRDFResource resource);
-
-    /** 
-     * Add a Tree Builder Observer to handle Tree View 
-     * methods that the base builder does not implement. 
-     */
-    void addObserver(in nsIXULTreeBuilderObserver aObserver);
-
-    /** 
-     * Remove an Tree Builder Observer.
-     */
-    void removeObserver(in nsIXULTreeBuilderObserver aObserver);
-
-    /** 
-     * Sort the contents of the tree using the specified column.
-     */
-    void sort(in nsIDOMElement aColumnElement);
-};
-
deleted file mode 100644
--- a/dom/xul/templates/nsIXULTemplateQueryProcessor.idl
+++ /dev/null
@@ -1,280 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "domstubs.idl"
-
-interface nsIArray;
-interface nsISimpleEnumerator;
-interface nsIXULTemplateResult;
-interface nsIXULTemplateRuleFilter;
-interface nsIXULTemplateBuilder;
-
-%{C++
-class nsAtom;
-%}
-[ptr] native nsAtomPtr(nsAtom);
-
-/**
- * A query processor takes a template query and generates results for it given
- * a datasource and a reference point. There is a one-to-one relationship
- * between a template builder and a query processor. The template builder
- * creates the query processor, and there is no other means to retrieve it.
- *
- * A template query is the contents inside a <query> element within the
- * template. The actual syntax is opaque to the template builder and defined
- * by a query processor. The query is expected to consist of either text or
- * DOM nodes that, when executed by a call to the generateResults method, will
- * allow the generation of a list of results.
- *
- * The template builder will supply two variables, the reference variable and
- * the member variable to further indicate what part of the datasource is to
- * be examined in addition to the query itself. The reference is always
- * a placeholder for the starting point and the member is always a placeholder
- * for the end points (the results).
- *
- * The reference point is important when generating output recursively, as
- * the query will be the same for each iteration, however, the reference point
- * will differ.
- *
- * For instance, when examining an XML source, an XML query processor might
- * begin at the node referred by the reference variable and end at a list of
- * that node's children.
- *
- * Some queries may not need the reference variable if the syntax or the form
- * of the data implies the value. For instance, a datasource that holds a
- * table that can only produce one set of results.
- *
- * The reference variable may be specified in a template by setting the
- * "container" attribute on the <template> element to the variable to use. The
- * member variable may be specified in a similar way using the "member"
- * attribute, or it may be specified in the first <action> body in the
- * template as the value of a uri attribute on an element. A breadth-first
- * search of the first action is performed to find this element.
- *
- * If unspecified, the default value of the reference variable is ?uri.
- *
- * For example, a query might have the following syntax:
- *
- * (?id, ?name, ?url) from Bookmarks where parentfolder = ?start
- *
- * This query might generate a result for each bookmark within a given folder.
- * The variable ?start would be the reference variable, while the variable ?id
- * would be the member variable, since it is the unique value that identifies
- * a result. Each result will have the four variables referred to defined for
- * it and the values may be retrieved using the result's getBindingFor and
- * getBindingObjectFor methods.
- *
- * The template builder must call initializeForBuilding before the other
- * methods, except for translateRef. The builder will then call compileQuery
- * for each query in the template to compile the queries. When results need
- * to be generated, the builder will call generateResults. The
- * initializeForBuilding, compileQuery and addBinding methods may not be
- * called after generateResults has been called until the builder indicates
- * that the generated output is being removed by calling the done method.
- *
- * Currently, the datasource supplied to the methods will always be an
- * nsIRDFDataSource or a DOM node, and will always be the same one in between
- * calls to initializeForBuilding and done.
- */
-[scriptable, uuid(C257573F-444F-468A-BA27-DE979DC55FE4)]
-interface nsIXULTemplateQueryProcessor : nsISupports
-{
-  /**
-   * Retrieve the datasource to use for the query processor. The list of
-   * datasources in a template is specified using the datasources attribute as
-   * a space separated list of URIs. This list is processed by the builder and
-   * supplied to the query processor in the aDataSources array as a list of
-   * nsIURI objects or nsIDOMNode objects. This method may return an object
-   * corresponding to these URIs and the builder will supply this object to
-   * other query processor methods. For example, for an XML source, the
-   * datasource might be an nsIDOMNode.
-   *
-   * All of these URIs are checked by the builder so it is safe to use them,
-   * however note that a URI that redirects may still needs to be checked to
-   * ensure that the document containing aRootNode may access it. This is the
-   * responsibility of the query processor if it needs to load the content of
-   * the URI.
-   *
-   * If the query processor needs to load the datasource asynchronously, it
-   * may set the aShouldDelayBuilding returned parameter to true to delay
-   * building the template content, and call the builder's Rebuild method when
-   * the data is available.
-   *
-   * @param aDataSources  the list of nsIURI objects and/or nsIDOMNode objects
-   * @param aRootNode     the root node the builder is attached to
-   * @param aIsTrusted    true if the template is in a trusted document
-   * @param aBuilder      the template builder
-   * @param aShouldDelayBuilding [out] whether the builder should wait to
-   *                                   build the content or not
-   * @returns a datasource object
-   */
-  nsISupports getDatasource(in nsIArray aDataSources,
-                            in nsIDOMNode aRootNode,
-                            in boolean aIsTrusted,
-                            in nsIXULTemplateBuilder aBuilder,
-                            out boolean aShouldDelayBuilding);
-
-  /**
-   * Initialize for query generation. This will be called before the rules are
-   * processed and whenever the template is rebuilt. This method must be
-   * called once before any of the other query processor methods except for
-   * translateRef.
-   *
-   * @param aDatasource datasource for the data
-   * @param aBuilder the template builder
-   * @param aRootNode the root node the builder is attached to
-   *
-   * @throws NS_ERROR_INVALID_ARG if the datasource is not supported or
-   *         NS_ERROR_UNEXPECTED if generateResults has already been called.
-   */
-  void initializeForBuilding(in nsISupports aDatasource,
-                             in nsIXULTemplateBuilder aBuilder,
-                             in nsIDOMNode aRootNode);
-
-  /**
-   * Called when the template builder is being destroyed so that the query
-   * processor can clean up any state. The query processor should remove as
-   * much state as possible, such as results or references to the builder.
-   * This method will also be called when the template is going to be rebuilt.
-   */
-  void done();
-
-  /**
-   * Compile a query from a node. The result of this function will later be
-   * passed to generateResults for result generation. If null is returned,
-   * the query will be ignored.
-   *
-   * The template builder will call this method once for each query within
-   * the template, before any results can be generated using generateResults,
-   * but after initializeForBuilding has been called. This method should not
-   * be called again for the same query unless the template is rebuilt.
-   *
-   * The reference variable may be used by the query processor as a
-   * placeholder for the reference point, or starting point in the query.
-   *
-   * The member variable is determined from the member attribute on the
-   * template, or from the uri in the first action's rule if that attribute is
-   * not present. A rule processor may use the member variable as a hint to
-   * indicate what variable is expected to contain the results.
-   *
-   * @param aBuilder the template builder
-   * @param aQuery <query> node to compile
-   * @param aRefVariable the reference variable
-   * @param aMemberVariable the member variable
-   *
-   * @returns a compiled query object
-   */
-  [noscript] nsISupports compileQuery(in nsIXULTemplateBuilder aBuilder,
-                                      in nsIDOMNode aQuery,
-                                      in nsAtomPtr aRefVariable,
-                                      in nsAtomPtr aMemberVariable);
-
-  /**
-   * Generate the results of a query and return them in an enumerator. The
-   * enumerator must contain nsIXULTemplateResult objects. If there are no
-   * results, an empty enumerator must be returned.
-   *
-   * The datasource will be the same as the one passed to the earlier
-   * initializeForBuilding method. The context reference (aRef) is a reference
-   * point used when calculating results.
-   *
-   * The value of aQuery must be the result of a previous call to compileQuery
-   * from this query processor. This method may be called multiple times,
-   * typically with different values for aRef.
-   *
-   * @param aDatasource datasource for the data
-   * @param aRef context reference value used as a starting point
-   * @param aQuery the compiled query returned from query compilation
-   *
-   * @returns an enumerator of nsIXULTemplateResult objects as the results
-   *
-   * @throws NS_ERROR_INVALID_ARG if aQuery is invalid
-   */
-  nsISimpleEnumerator generateResults(in nsISupports aDatasource,
-                                      in nsIXULTemplateResult aRef,
-                                      in nsISupports aQuery);
-
-  /**
-   * Add a variable binding for a particular rule. A binding allows an
-   * additional variable to be set for a result, outside of those defined
-   * within the query. These bindings are always optional, in that they will
-   * never affect the results generated.
-   *
-   * This function will never be called after generateResults. Any bindings
-   * that were added should be applied to each result when the result's
-   * ruleMatched method is called, since the bindings are different for each
-   * rule.
-   *
-   * The reference aRef may be used to determine the reference when
-   * calculating the value for the binding, for example when a value should
-   * depend on the value of another variable.
-   *
-   * The syntax of the expression aExpr is defined by the query processor. If
-   * the syntax is invalid, the binding should be ignored. Only fatal errors
-   * should be thrown, or NS_ERROR_UNEXPECTED if generateResults has already
-   * been called.
-   *
-   * As an example, if the reference aRef is the variable '?count' which
-   * holds the value 5, and the expression aExpr is the string '+2', the value
-   * of the variable aVar would be 7, assuming the query processor considers
-   * the syntax '+2' to mean add two to the reference.
-   *
-   * @param aRuleNode rule to add the binding to
-   * @param aVar variable that will be bound
-   * @param aRef variable that holds reference value
-   * @param aExpr expression used to compute the value to assign
-   */
-  [noscript] void addBinding(in nsIDOMNode aRuleNode,
-                             in nsAtomPtr aVar,
-                             in nsAtomPtr aRef,
-                             in AString aExpr);
-
-  /**
-   * Translate a ref attribute string into a result. This is used as the
-   * reference point by the template builder when generating the first level
-   * of content. For recursive generation, the result from the parent
-   * generation phase will be used directly as the reference so a translation
-   * is not needed. This allows all levels to be generated using objects that
-   * all implement the nsIXULTemplateResult interface.
-   *
-   * This method may be called before initializeForBuilding, so the
-   * implementation may use the supplied datasource if it is needed to
-   * translate the reference.
-   *
-   * @param aDatasource datasource for the data
-   * @param aRefString the ref attribute string
-   *
-   * @return the translated ref
-   */
-  nsIXULTemplateResult translateRef(in nsISupports aDatasource,
-                                    in AString aRefString);
-
-  /**
-   * Compare two results to determine their order, used when sorting results.
-   * This method should return -1 when the left result is less than the right,
-   * 0 if both are equivalent, and 1 if the left is greater than the right.
-   * The comparison should only consider the values for the specified
-   * variable.
-   *
-   * If the comparison variable is null, the results may be
-   * sorted in a natural order, for instance, based on the order the data in
-   * stored in the datasource.
-   *
-   * The sort hints are the flags in nsIXULSortService.
-   *
-   * This method must only be called with results that were created by this
-   * query processor.
-   *
-   * @param aLeft the left result to compare
-   * @param aRight the right result to compare
-   * @param aVar variable to compare
-   *
-   * @param returns -1 if less, 0 if equal, or 1 if greater
-   */
-   [noscript] int32_t compareResults(in nsIXULTemplateResult aLeft,
-                                     in nsIXULTemplateResult aRight,
-                                     in nsAtomPtr aVar,
-                                     in unsigned long aSortHints);
-};
deleted file mode 100644
--- a/dom/xul/templates/nsIXULTemplateResult.idl
+++ /dev/null
@@ -1,120 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsISupports.idl"
-
-interface nsIDOMNode;
-interface nsIRDFResource;
-
-%{C++
-class nsAtom;
-%}
-[ptr] native nsAtomPtr(nsAtom);
-
-/**
- * A single result generated from a template query. Each result is identified
- * by an id, which must be unique within the set of results produced from a
- * query. The result may optionally be identified by an RDF resource.
- *
- * Generally, the result and its id will be able to uniquely identify a node
- * in the source data, such as an RDF or XML node. In other contexts, such as
- * a database query, a result would represent a particular record.
- *
- * A result is expected to only be created by a query processor.
- *
- * Each result also contains a set of variable bindings. The value for a
- * particular variable may be retrieved using the getBindingFor and
- * getBindingObjectFor methods.
- */
-[scriptable, uuid(ebea0230-36fa-41b7-8e31-760806057965)]
-interface nsIXULTemplateResult : nsISupports
-{
-  /**
-   * True if the result represents a container.
-   */
-  readonly attribute boolean isContainer;
-
-  /**
-   * True if the result represents an empty container.
-   */
-  readonly attribute boolean isEmpty;
-
-  /**
-   * True if the template builder may use this result as the reference point
-   * for additional recursive processing of the template. The template builder
-   * will reprocess the template using this result as the reference point and
-   * generate output content that is expected to be inserted as children of the
-   * output generated for this result. If false, child content is not
-   * processed. This property identifies only the default handling and may be
-   * overriden by syntax used in the template.
-   */
-  readonly attribute boolean mayProcessChildren;
-
-  /**
-   * ID of the result. The DOM element created for this result, if any, will
-   * have its id attribute set to this value. The id must be unique for a
-   * query.
-   */
-  readonly attribute AString id;
-
-  /**
-   * Resource for the result, which may be null. If set, the resource uri
-   * must be the same as the ID property.
-   */
-  readonly attribute nsIRDFResource resource;
-
-  /**
-   * The type of the object. The predefined value 'separator' may be used
-   * for separators. Other values may be used for application specific
-   * purposes.
-   */
-  readonly attribute AString type;
-
-  /**
-   * Get the string representation of the value of a variable for this
-   * result. This string will be used in the action body from a template as
-   * the replacement text. For instance, if the text ?name appears in an
-   * attribute within the action body, it will be replaced with the result
-   * of this method. The question mark is considered part of the variable
-   * name, thus aVar should be ?name and not simply name.
-   *
-   * @param aVar the variable to look up
-   *
-   * @return the value for the variable or a null string if it has no value
-   */
-  [noscript] AString getBindingFor(in nsAtomPtr aVar);
-
-  /**
-   * Get an object value for a variable such as ?name for this result. 
-   *
-   * This method may return null for a variable, even if getBindingFor returns
-   * a non-null value for the same variable. This method is provided as a
-   * convenience when sorting results.
-   *
-   * @param aVar the variable to look up
-   *
-   * @return the value for the variable or null if it has no value
-   */
-  [noscript] nsISupports getBindingObjectFor(in nsAtomPtr aVar);
-
-  /**
-   * Indicate that a particular rule of a query has matched and that output
-   * will be generated for it. Both the query as compiled by the query
-   * processor's compileQuery method and the XUL <rule> element are supplied.
-   * The query must always be one that was compiled by the query processor
-   * that created this result. The <rule> element must always be a child of
-   * the <query> element that was used to compile the query.
-   *
-   * @param aQuery the query that matched
-   * @param aRuleNode the rule node that matched
-   */
-  void ruleMatched(in nsISupports aQuery, in nsIDOMNode aRuleNode);
-
-  /**
-   * Indicate that the output for a result has beeen removed and that the
-   * result is no longer being used by the builder.
-   */
-  void hasBeenRemoved();
-};
deleted file mode 100644
--- a/dom/xul/templates/nsIXULTemplateRuleFilter.idl
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "domstubs.idl"
-
-interface nsISupports;
-interface nsIXULTemplateResult;
-
-/**
- * A rule filter may be used to add additional filtering of results to a rule.
- * The filter is used to further reject results from matching the template's
- * rules, beyond what the template syntax can do itself, thus allowing for
- * more complex result filtering. The rule filter is applied after the rule
- * syntax within the template.
- *
- * Only one filter may apply to each rule within the template and may be
- * assigned using the template builder's addRuleFilter method.
- */
-[scriptable, uuid(819cd1ed-8010-42e1-a8b9-778b726a1ff3)]
-interface nsIXULTemplateRuleFilter : nsISupports
-{
-  /**
-   * Evaluate a result and return true if the result is accepted by this
-   * filter, or false if it is rejected. Accepted results will have output
-   * generated for them for the rule. Rejected results will not, but they
-   * may still match another rule.
-   *
-   * @param aRef the result to examine
-   * @param aRule the rule node
-   *
-   * @return true if the rule matches
-   */
-  boolean match(in nsIXULTemplateResult aRef, in nsIDOMNode aRule);
-};
deleted file mode 100644
--- a/dom/xul/templates/nsInstantiationNode.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsInstantiationNode.h"
-#include "nsTemplateRule.h"
-#include "nsXULTemplateQueryProcessorRDF.h"
-
-#include "mozilla/Logging.h"
-extern mozilla::LazyLogModule gXULTemplateLog;
-
-nsInstantiationNode::nsInstantiationNode(nsXULTemplateQueryProcessorRDF* aProcessor,
-                                         nsRDFQuery* aQuery)
-        : mProcessor(aProcessor),
-          mQuery(aQuery)
-{
-    MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-           ("nsInstantiationNode[%p] query=%p", this, aQuery));
-
-    MOZ_COUNT_CTOR(nsInstantiationNode);
-}
-
-
-nsInstantiationNode::~nsInstantiationNode()
-{
-    MOZ_COUNT_DTOR(nsInstantiationNode);
-}
-
-nsresult
-nsInstantiationNode::Propagate(InstantiationSet& aInstantiations,
-                               bool aIsUpdate, bool& aTakenInstantiations)
-{
-    // In update mode, iterate through the results and call the template
-    // builder to update them. In non-update mode, cache them in the processor
-    // to be used during processing. The results are cached in the processor
-    // so that the simple rules are only computed once. In this situation, all
-    // data for all queries are calculated at once.
-    nsresult rv = NS_OK;
-
-    aTakenInstantiations = false;
-
-    if (aIsUpdate) {
-        // Iterate through newly added keys to determine which rules fired.
-        //
-        // XXXwaterson Unfortunately, this could also lead to retractions;
-        // e.g., (container ?a ^empty false) could become "unmatched". How
-        // to track those?
-        nsCOMPtr<nsIDOMNode> querynode;
-        mQuery->GetQueryNode(getter_AddRefs(querynode));
-
-        InstantiationSet::ConstIterator last = aInstantiations.Last();
-        for (InstantiationSet::ConstIterator inst = aInstantiations.First(); inst != last; ++inst) {
-            nsAssignmentSet assignments = inst->mAssignments;
-
-            nsCOMPtr<nsIRDFNode> node;
-            assignments.GetAssignmentFor(mQuery->mMemberVariable,
-                                         getter_AddRefs(node));
-            if (node) {
-                nsCOMPtr<nsIRDFResource> resource = do_QueryInterface(node);
-                if (resource) {
-                    RefPtr<nsXULTemplateResultRDF> nextresult =
-                        new nsXULTemplateResultRDF(mQuery, *inst, resource);
-                    if (! nextresult)
-                        return NS_ERROR_OUT_OF_MEMORY;
-
-                    rv = mProcessor->AddMemoryElements(*inst, nextresult);
-                    if (NS_FAILED(rv))
-                        return rv;
-
-                    mProcessor->GetBuilder()->AddResult(nextresult, querynode);
-                }
-            }
-        }
-    }
-    else {
-        nsresult rv = mQuery->SetCachedResults(mProcessor, aInstantiations);
-        if (NS_SUCCEEDED(rv))
-            aTakenInstantiations = true;
-    }
-
-    return rv;
-}
deleted file mode 100644
--- a/dom/xul/templates/nsInstantiationNode.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsInstantiationNode_h__
-#define nsInstantiationNode_h__
-
-#include "mozilla/Attributes.h"
-#include "nsRuleNetwork.h"
-#include "nsRDFQuery.h"
-
-class nsXULTemplateQueryProcessorRDF;
-
-/**
- * A leaf-level node in the rule network. If any instantiations
- * propagate to this node, then we know we've matched a rule.
- */
-class nsInstantiationNode : public ReteNode
-{
-public:
-    nsInstantiationNode(nsXULTemplateQueryProcessorRDF* aProcessor,
-                        nsRDFQuery* aRule);
-
-    ~nsInstantiationNode();
-
-    // "downward" propagations
-    virtual nsresult Propagate(InstantiationSet& aInstantiations,
-                               bool aIsUpdate, bool& aMatched) override;
-
-protected:
-
-    nsXULTemplateQueryProcessorRDF* mProcessor;
-    nsRDFQuery* mQuery;
-};
-
-#endif // nsInstantiationNode_h__
deleted file mode 100644
--- a/dom/xul/templates/nsRDFBinding.cpp
+++ /dev/null
@@ -1,265 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsXULTemplateQueryProcessorRDF.h"
-#include "nsXULTemplateResultRDF.h"
-#include "nsRDFBinding.h"
-
-#ifdef DEBUG
-#include "nsXULContentUtils.h"
-#endif
-
-RDFBindingSet::~RDFBindingSet()
-{
-    while (mFirst) {
-        RDFBinding* doomed = mFirst;
-        mFirst = mFirst->mNext;
-        delete doomed;
-    }
-
-    MOZ_COUNT_DTOR(RDFBindingSet);
-}
-
-nsresult
-RDFBindingSet::AddBinding(nsAtom* aVar, nsAtom* aRef, nsIRDFResource* aPredicate)
-{
-    RDFBinding* newbinding = new RDFBinding(aRef, aPredicate, aVar);
-    if (mFirst) {
-        RDFBinding* binding = mFirst;
-
-        while (binding) {
-            // the binding is dependant on the calculation of a previous binding
-            if (binding->mSubjectVariable == aVar)
-                newbinding->mHasDependency = true;
-
-            // if the target variable is already used in a binding, ignore it
-            // since it won't be useful for anything
-            if (binding->mTargetVariable == aVar) {
-                delete newbinding;
-                return NS_OK;
-            }
-
-            // add the binding at the end of the list
-            if (! binding->mNext) {
-                binding->mNext = newbinding;
-                break;
-            }
-
-            binding = binding->mNext;
-        }
-    }
-    else {
-        mFirst = newbinding;
-    }
-
-    mCount++;
-
-    return NS_OK;
-}
-
-bool
-RDFBindingSet::SyncAssignments(nsIRDFResource* aSubject,
-                               nsIRDFResource* aPredicate,
-                               nsIRDFNode* aTarget,
-                               nsAtom* aMemberVariable,
-                               nsXULTemplateResultRDF* aResult,
-                               nsBindingValues& aBindingValues)
-{
-    NS_ASSERTION(aBindingValues.GetBindingSet() == this,
-                 "nsBindingValues not for this RDFBindingSet");
-    NS_PRECONDITION(aResult, "Must have result");
-
-    bool needSync = false;
-    nsCOMPtr<nsIRDFNode>* valuesArray = aBindingValues.ValuesArray();
-    if (!valuesArray)
-        return false;
-
-    RDFBinding* binding = mFirst;
-    int32_t count = 0;
-
-    // QI for proper comparisons just to be safe
-    nsCOMPtr<nsIRDFNode> subjectnode = do_QueryInterface(aSubject);
-
-    // iterate through the bindings looking for ones that would match the RDF
-    // nodes that were involved in a change
-    nsCOMPtr<nsIRDFNode> value;
-    while (binding) {
-        if (aPredicate == binding->mPredicate) {
-            // if the source of the binding is the member variable, optimize
-            if (binding->mSubjectVariable == aMemberVariable) {
-                valuesArray[count] = aTarget;
-                needSync = true;
-            }
-            else {
-                aResult->GetAssignment(binding->mSubjectVariable, getter_AddRefs(value));
-                if (value == subjectnode) {
-                    valuesArray[count] = aTarget;
-                    needSync = true;
-                }
-            }
-        }
-
-        binding = binding->mNext;
-        count++;
-    }
-
-    return needSync;
-}
-
-void
-RDFBindingSet::AddDependencies(nsIRDFResource* aSubject,
-                               nsXULTemplateResultRDF* aResult)
-{
-    NS_PRECONDITION(aResult, "Must have result");
-
-    // iterate through the bindings and add binding dependencies to the
-    // processor
-
-    nsXULTemplateQueryProcessorRDF* processor = aResult->GetProcessor();
-    if (! processor)
-        return;
-
-    nsCOMPtr<nsIRDFNode> value;
-
-    RDFBinding* binding = mFirst;
-    while (binding) {
-        aResult->GetAssignment(binding->mSubjectVariable, getter_AddRefs(value));
-
-        nsCOMPtr<nsIRDFResource> valueres = do_QueryInterface(value);
-        if (valueres)
-            processor->AddBindingDependency(aResult, valueres);
-
-        binding = binding->mNext;
-    }
-}
-
-void
-RDFBindingSet::RemoveDependencies(nsIRDFResource* aSubject,
-                                  nsXULTemplateResultRDF* aResult)
-{
-    NS_PRECONDITION(aResult, "Must have result");
-
-    // iterate through the bindings and remove binding dependencies from the
-    // processor
-
-    nsXULTemplateQueryProcessorRDF* processor = aResult->GetProcessor();
-    if (! processor)
-        return;
-
-    nsCOMPtr<nsIRDFNode> value;
-
-    RDFBinding* binding = mFirst;
-    while (binding) {
-        aResult->GetAssignment(binding->mSubjectVariable, getter_AddRefs(value));
-
-        nsCOMPtr<nsIRDFResource> valueres = do_QueryInterface(value);
-        if (valueres)
-            processor->RemoveBindingDependency(aResult, valueres);
-
-        binding = binding->mNext;
-    }
-}
-
-int32_t
-RDFBindingSet::LookupTargetIndex(nsAtom* aTargetVariable, RDFBinding** aBinding)
-{
-    int32_t idx = 0;
-    RDFBinding* binding = mFirst;
-
-    while (binding) {
-        if (binding->mTargetVariable == aTargetVariable) {
-            *aBinding = binding;
-            return idx;
-        }
-        idx++;
-        binding = binding->mNext;
-    }
-
-    return -1;
-}
-
-nsBindingValues::~nsBindingValues()
-{
-    ClearBindingSet();
-    MOZ_COUNT_DTOR(nsBindingValues);
-}
-
-void
-nsBindingValues::ClearBindingSet()
-{
-    if (mBindings && mValues) {
-        delete [] mValues;
-        mValues = nullptr;
-    }
-
-    mBindings = nullptr;
-}
-
-nsresult
-nsBindingValues::SetBindingSet(RDFBindingSet* aBindings)
-{
-    ClearBindingSet();
-
-    int32_t count = aBindings->Count();
-    if (count) {
-        mValues = new nsCOMPtr<nsIRDFNode>[count];
-        mBindings = aBindings;
-    }
-    else {
-        mValues = nullptr;
-    }
-
-    return NS_OK;
-}
-
-void
-nsBindingValues::GetAssignmentFor(nsXULTemplateResultRDF* aResult,
-                                  nsAtom* aVar,
-                                  nsIRDFNode** aValue)
-{
-    *aValue = nullptr;
-
-    // assignments are calculated lazily when asked for. The only issue is
-    // when a binding has no value in the RDF graph, it will be checked again
-    // every time.
-
-    if (mBindings && mValues) {
-        RDFBinding* binding;
-        int32_t idx = mBindings->LookupTargetIndex(aVar, &binding);
-        if (idx >= 0) {
-            *aValue = mValues[idx];
-            if (*aValue) {
-                NS_ADDREF(*aValue);
-            }
-            else {
-                nsXULTemplateQueryProcessorRDF* processor = aResult->GetProcessor();
-                if (! processor)
-                    return;
-
-                nsIRDFDataSource* ds = processor->GetDataSource();
-                if (! ds)
-                    return;
-
-                nsCOMPtr<nsIRDFNode> subjectValue;
-                aResult->GetAssignment(binding->mSubjectVariable,
-                                       getter_AddRefs(subjectValue));
-                if (subjectValue) {
-                    nsCOMPtr<nsIRDFResource> subject = do_QueryInterface(subjectValue);
-                    ds->GetTarget(subject, binding->mPredicate, true, aValue);
-                    if (*aValue)
-                        mValues[idx] = *aValue;
-                }
-            }
-        }
-    }
-}
-
-void
-nsBindingValues::RemoveDependencies(nsIRDFResource* aSubject,
-                                    nsXULTemplateResultRDF* aResult)
-{
-    if (mBindings)
-        mBindings->RemoveDependencies(aSubject, aResult);
-}
deleted file mode 100644
--- a/dom/xul/templates/nsRDFBinding.h
+++ /dev/null
@@ -1,216 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsRDFBinding_h__
-#define nsRDFBinding_h__
-
-#include "nsAtom.h"
-#include "nsIRDFResource.h"
-#include "nsISupportsImpl.h"
-
-class nsXULTemplateResultRDF;
-class nsBindingValues;
-
-/*
- * Classes related to storing bindings for RDF handling.
- */
-
-/*
- * a  <binding> descriptors
- */
-class RDFBinding {
-
-public:
-
-    RefPtr<nsAtom>        mSubjectVariable;
-    nsCOMPtr<nsIRDFResource> mPredicate;
-    RefPtr<nsAtom>        mTargetVariable;
-
-    // indicates whether a binding is dependant on the result from a
-    // previous binding
-    bool                     mHasDependency;
-
-    RDFBinding*              mNext;
-
-private:
-
-    friend class RDFBindingSet;
-
-    RDFBinding(nsAtom* aSubjectVariable,
-               nsIRDFResource* aPredicate,
-               nsAtom* aTargetVariable)
-      : mSubjectVariable(aSubjectVariable),
-        mPredicate(aPredicate),
-        mTargetVariable(aTargetVariable),
-        mHasDependency(false),
-        mNext(nullptr)
-    {
-        MOZ_COUNT_CTOR(RDFBinding);
-    }
-
-    ~RDFBinding()
-    {
-        MOZ_COUNT_DTOR(RDFBinding);
-    }
-};
-
-/*
- * a collection of <binding> descriptors. This object is refcounted by
- * nsBindingValues objects and the query processor.
- */
-class RDFBindingSet final
-{
-private:
-    // Private destructor, to discourage deletion outside of Release():
-    ~RDFBindingSet();
-
-    // the number of bindings
-    int32_t mCount;
-
-    // pointer to the first binding in a linked list
-    RDFBinding* mFirst;
-
-public:
-
-    RDFBindingSet()
-        : mCount(0),
-          mFirst(nullptr)
-    {
-        MOZ_COUNT_CTOR(RDFBindingSet);
-    }
-
-    NS_INLINE_DECL_REFCOUNTING(RDFBindingSet)
-
-    int32_t Count() const { return mCount; }
-
-    /*
-     * Add a binding (aRef -> aPredicate -> aVar) to the set
-     */
-    nsresult
-    AddBinding(nsAtom* aVar, nsAtom* aRef, nsIRDFResource* aPredicate);
-
-    /*
-     * Return true if the binding set contains a binding which would cause
-     * the result to need resynchronizing for an RDF triple. The member
-     * variable may be supplied as an optimization since bindings most
-     * commonly use the member variable as the subject. If aMemberVariable
-     * is set, aSubject must be the value of the member variable for the
-     * result. The supplied binding values aBindingValues must be values
-     * using this binding set (that is aBindingValues->GetBindingSet() == this)
-     *
-     * @param aSubject subject of the RDF triple
-     * @param aPredicate predicate of the RDF triple
-     * @param aTarget target of the RDF triple
-     * @param aMemberVariable member variable for the query for the binding
-     * @param aResult result to synchronize
-     * @param aBindingValues the values for the bindings for the result
-     */
-    bool
-    SyncAssignments(nsIRDFResource* aSubject,
-                    nsIRDFResource* aPredicate,
-                    nsIRDFNode* aTarget,
-                    nsAtom* aMemberVariable,
-                    nsXULTemplateResultRDF* aResult,
-                    nsBindingValues& aBindingValues);
-
-    /*
-     * The query processor maintains a map of subjects to an array of results.
-     * This is used such that when a new assertion is added to the RDF graph,
-     * the results associated with the subject of that triple may be checked
-     * to see if their bindings have changed. The AddDependencies method adds
-     * these subject dependencies to the map.
-     */
-    void
-    AddDependencies(nsIRDFResource* aSubject,
-                    nsXULTemplateResultRDF* aResult);
-
-    /*
-     * Remove the results from the dependencies map when results are deleted.
-     */
-    void
-    RemoveDependencies(nsIRDFResource* aSubject,
-                       nsXULTemplateResultRDF* aResult);
-
-    /*
-     * The nsBindingValues classes stores an array of values, one for each
-     * target symbol that could be set by the bindings in the set.
-     * LookupTargetIndex determines the index into the array for a given
-     * target symbol.
-     */
-    int32_t
-    LookupTargetIndex(nsAtom* aTargetVariable, RDFBinding** aBinding);
-};
-
-/*
- * A set of values of bindings. This object is used once per result.
- * This stores a reference to the binding set and an array of node values.
- * Since the binding set is used once per query and the values are
- * used once per result, we reduce size by only storing the value array's
- * length in the binding set. This is possible since the array is always
- * a fixed length for a particular binding set.
- *
- * XXX ndeakin We may want to revisit this later since it makes the code
- *             more complicated.
- */
-class nsBindingValues
-{
-protected:
-
-    // the binding set
-    RefPtr<RDFBindingSet> mBindings;
-
-    /*
-     * A set of values for variable bindings. To look up a binding value,
-     * scan through the binding set in mBindings for the right target atom.
-     * Its index will correspond to the index in this array. The size of this
-     * array is determined by the RDFBindingSet's Count().
-     */
-    nsCOMPtr<nsIRDFNode>* mValues;
-
-public:
-
-    nsBindingValues()
-      : mBindings(nullptr),
-        mValues(nullptr)
-    {
-        MOZ_COUNT_CTOR(nsBindingValues);
-    }
-
-    ~nsBindingValues();
-
-
-    /**
-     * Clear the binding set, to be called when the nsBindingValues is deleted
-     * or a new binding set is being set.
-     */
-    void ClearBindingSet();
-
-    RDFBindingSet* GetBindingSet() { return mBindings; }
-
-    /**
-     * Set the binding set to use. This needs to be called once a rule matches
-     * since it is then known which bindings will apply.
-     */
-    nsresult SetBindingSet(RDFBindingSet* aBindings);
-
-    nsCOMPtr<nsIRDFNode>* ValuesArray() { return mValues; }
-
-    /*
-     * Retrieve the assignment for a particular variable
-     */
-    void
-    GetAssignmentFor(nsXULTemplateResultRDF* aResult,
-                     nsAtom* aVar,
-                     nsIRDFNode** aValue);
-
-    /*
-     * Remove depenedencies the bindings have on particular resources
-     */
-    void
-    RemoveDependencies(nsIRDFResource* aSubject,
-                       nsXULTemplateResultRDF* aResult);
-};
-
-#endif // nsRDFBinding_h__
deleted file mode 100644
--- a/dom/xul/templates/nsRDFConInstanceTestNode.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsIComponentManager.h"
-#include "nsIRDFContainer.h"
-#include "nsIRDFContainerUtils.h"
-#include "nsIServiceManager.h"
-#include "nsRDFCID.h"
-#include "nsRDFConInstanceTestNode.h"
-#include "nsResourceSet.h"
-
-#include "mozilla/Logging.h"
-#include "nsXULContentUtils.h"
-
-using mozilla::LogLevel;
-
-extern mozilla::LazyLogModule gXULTemplateLog;
-
-static const char*
-TestToString(nsRDFConInstanceTestNode::Test aTest) {
-    switch (aTest) {
-    case nsRDFConInstanceTestNode::eFalse:    return "false";
-    case nsRDFConInstanceTestNode::eTrue:     return "true";
-    case nsRDFConInstanceTestNode::eDontCare: return "dontcare";
-    }
-    return "?";
-}
-
-nsRDFConInstanceTestNode::nsRDFConInstanceTestNode(TestNode* aParent,
-                                                   nsXULTemplateQueryProcessorRDF* aProcessor,
-                                                   nsAtom* aContainerVariable,
-                                                   Test aContainer,
-                                                   Test aEmpty)
-    : nsRDFTestNode(aParent),
-      mProcessor(aProcessor),
-      mContainerVariable(aContainerVariable),
-      mContainer(aContainer),
-      mEmpty(aEmpty)
-{
-    if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-        nsAutoCString props;
-
-        nsResourceSet& containmentProps = aProcessor->ContainmentProperties();
-        nsResourceSet::ConstIterator last = containmentProps.Last();
-        nsResourceSet::ConstIterator first = containmentProps.First();
-        nsResourceSet::ConstIterator iter;
-
-        for (iter = first; iter != last; ++iter) {
-            if (iter != first)
-                props += " ";
-
-            const char* str;
-            iter->GetValueConst(&str);
-
-            props += str;
-        }
-
-        nsAutoString cvar(NS_LITERAL_STRING("(none)"));
-        if (mContainerVariable)
-            mContainerVariable->ToString(cvar);
-
-        MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-               ("nsRDFConInstanceTestNode[%p]: parent=%p member-props=(%s) container-var=%s container=%s empty=%s",
-                this,
-                aParent,
-                props.get(),
-                NS_ConvertUTF16toUTF8(cvar).get(),
-                TestToString(aContainer),
-                TestToString(aEmpty)));
-    }
-}
-
-nsresult
-nsRDFConInstanceTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
-                                               bool* aCantHandleYet) const
-{
-    nsresult rv;
-
-    if (aCantHandleYet)
-        *aCantHandleYet = false;
-
-    nsCOMPtr<nsIRDFContainerUtils> rdfc
-        = do_GetService("@mozilla.org/rdf/container-utils;1");
-
-    if (! rdfc)
-        return NS_ERROR_FAILURE;
-
-    nsIRDFDataSource* ds = mProcessor->GetDataSource();
-
-    InstantiationSet::Iterator last = aInstantiations.Last();
-    for (InstantiationSet::Iterator inst = aInstantiations.First(); inst != last; ++inst) {
-        nsCOMPtr<nsIRDFNode> value;
-        if (! inst->mAssignments.GetAssignmentFor(mContainerVariable, getter_AddRefs(value))) {
-            NS_ERROR("can't do unbounded container testing");
-            return NS_ERROR_UNEXPECTED;
-        }
-
-        nsCOMPtr<nsIRDFResource> valueres = do_QueryInterface(value);
-        if (! valueres) {
-            aInstantiations.Erase(inst--);
-            continue;
-        }
-
-        if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-            const char* container = "(unbound)";
-            valueres->GetValueConst(&container);
-
-            MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-                   ("nsRDFConInstanceTestNode[%p]::FilterInstantiations() container=[%s]",
-                    this, container));
-        }
-
-        nsCOMPtr<nsIRDFContainer> rdfcontainer;
-
-        bool isRDFContainer;
-        rv = rdfc->IsContainer(ds, valueres, &isRDFContainer);
-        if (NS_FAILED(rv)) return rv;
-
-        if (mEmpty != eDontCare || mContainer != eDontCare) {
-            Test empty = eDontCare;
-            Test container = eDontCare;
-
-            if (isRDFContainer) {
-                // It's an RDF container. Use the container utilities
-                // to deduce what's in it.
-                container = eTrue;
-
-                // XXX should cache the factory
-                rdfcontainer = do_CreateInstance("@mozilla.org/rdf/container;1", &rv);
-                if (NS_FAILED(rv)) return rv;
-
-                rv = rdfcontainer->Init(ds, valueres);
-                if (NS_FAILED(rv)) return rv;
-
-                int32_t count;
-                rv = rdfcontainer->GetCount(&count);
-                if (NS_FAILED(rv)) return rv;
-
-                empty = (count == 0) ? eTrue : eFalse;
-            } else {
-                empty = eTrue;
-                container = eFalse;
-
-                // First do the simple check of finding some outward
-                // arcs; there should be only a few containment arcs, so this can
-                // save us time from dealing with an iterator later on
-                nsResourceSet& containmentProps = mProcessor->ContainmentProperties();
-                for (nsResourceSet::ConstIterator property = containmentProps.First();
-                     property != containmentProps.Last();
-                     ++property) {
-                    nsCOMPtr<nsIRDFNode> target;
-                    rv = ds->GetTarget(valueres, *property, true, getter_AddRefs(target));
-                    if (NS_FAILED(rv)) return rv;
-
-                    if (target != nullptr) {
-                        // bingo. we found one.
-                        empty = eFalse;
-                        container = eTrue;
-                        break;
-                    }
-                }
-
-                // if we still don't think its a container, but we
-                // want to know for sure whether it is or not, we need
-                // to check ArcLabelsOut for potential container arcs.
-                if (container == eFalse && mContainer != eDontCare) {
-                    nsCOMPtr<nsISimpleEnumerator> arcsout;
-                    rv = ds->ArcLabelsOut(valueres, getter_AddRefs(arcsout));
-                    if (NS_FAILED(rv)) return rv;
-
-                    while (1) {
-                        bool hasmore;
-                        rv = arcsout->HasMoreElements(&hasmore);
-                        if (NS_FAILED(rv)) return rv;
-
-                        if (! hasmore)
-                            break;
-
-                        nsCOMPtr<nsISupports> isupports;
-                        rv = arcsout->GetNext(getter_AddRefs(isupports));
-                        if (NS_FAILED(rv)) return rv;
-
-                        nsCOMPtr<nsIRDFResource> property = do_QueryInterface(isupports);
-                        NS_ASSERTION(property != nullptr, "not a property");
-                        if (! property)
-                            return NS_ERROR_UNEXPECTED;
-
-                        if (mProcessor->ContainmentProperties().Contains(property)) {
-                            container = eTrue;
-                            break;
-                        }
-                    }
-                }
-            }
-
-            MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-                   ("    empty => %s",
-                    (empty == mEmpty) ? "consistent" : "inconsistent"));
-
-            MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-                   ("    container => %s",
-                    (container == mContainer) ? "consistent" : "inconsistent"));
-
-            if (((mEmpty == empty) && (mContainer == container)) ||
-                ((mEmpty == eDontCare) && (mContainer == container)) ||
-                ((mContainer == eDontCare) && (mEmpty == empty)))
-            {
-                Element* element =
-                    new nsRDFConInstanceTestNode::Element(valueres, container, empty);
-                inst->AddSupportingElement(element);
-            }
-            else {
-                aInstantiations.Erase(inst--);
-            }
-        }
-    }
-
-    return NS_OK;
-}
-
-bool
-nsRDFConInstanceTestNode::CanPropagate(nsIRDFResource* aSource,
-                                       nsIRDFResource* aProperty,
-                                       nsIRDFNode* aTarget,
-                                       Instantiation& aInitialBindings) const
-{
-    nsresult rv;
-
-    bool canpropagate = false;
-
-    nsCOMPtr<nsIRDFContainerUtils> rdfc
-        = do_GetService("@mozilla.org/rdf/container-utils;1");
-
-    if (! rdfc)
-        return false;
-
-    // We can certainly propagate ordinal properties
-    rv = rdfc->IsOrdinalProperty(aProperty, &canpropagate);
-    if (NS_FAILED(rv)) return false;
-
-    if (! canpropagate) {
-        canpropagate = mProcessor->ContainmentProperties().Contains(aProperty);
-    }
-
-    if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-        const char* source;
-        aSource->GetValueConst(&source);
-
-        const char* property;
-        aProperty->GetValueConst(&property);
-
-        nsAutoString target;
-        nsXULContentUtils::GetTextForNode(aTarget, target);
-
-        MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-               ("nsRDFConInstanceTestNode[%p]: CanPropagate([%s]==[%s]=>[%s]) => %s",
-                this, source, property, NS_ConvertUTF16toUTF8(target).get(),
-                canpropagate ? "true" : "false"));
-    }
-
-    if (canpropagate) {
-        aInitialBindings.AddAssignment(mContainerVariable, aSource);
-        return true;
-    }
-
-    return false;
-}
-
-void
-nsRDFConInstanceTestNode::Retract(nsIRDFResource* aSource,
-                                  nsIRDFResource* aProperty,
-                                  nsIRDFNode* aTarget) const
-{
-    // XXXwaterson oof. complicated. figure this out.
-    if (0) {
-        mProcessor->RetractElement(Element(aSource, mContainer, mEmpty));
-    }
-}
-
deleted file mode 100644
--- a/dom/xul/templates/nsRDFConInstanceTestNode.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsRDFConInstanceTestNode_h__
-#define nsRDFConInstanceTestNode_h__
-
-#include "mozilla/Attributes.h"
-#include "nscore.h"
-#include "nsRDFTestNode.h"
-#include "nsIRDFResource.h"
-#include "nsIRDFDataSource.h"
-#include "nsXULTemplateQueryProcessorRDF.h"
-
-/**
- * Rule network node that tests if a resource is an RDF container, or
- * uses multi-attributes to ``contain'' other elements.
- */
-class nsRDFConInstanceTestNode : public nsRDFTestNode
-{
-public:
-    enum Test { eFalse, eTrue, eDontCare };
-
-    nsRDFConInstanceTestNode(TestNode* aParent,
-                             nsXULTemplateQueryProcessorRDF* aProcessor,
-                             nsAtom* aContainerVariable,
-                             Test aContainer,
-                             Test aEmpty);
-
-    virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations,
-                                          bool* aCantHandleYet) const override;
-
-    virtual bool
-    CanPropagate(nsIRDFResource* aSource,
-                 nsIRDFResource* aProperty,
-                 nsIRDFNode* aTarget,
-                 Instantiation& aInitialBindings) const override;
-
-    virtual void
-    Retract(nsIRDFResource* aSource,
-            nsIRDFResource* aProperty,
-            nsIRDFNode* aTarget) const override;
-
-
-    class Element : public MemoryElement {
-    public:
-        Element(nsIRDFResource* aContainer,
-                Test aContainerTest,
-                Test aEmptyTest)
-            : mContainer(aContainer),
-              mContainerTest(aContainerTest),
-              mEmptyTest(aEmptyTest) {
-            MOZ_COUNT_CTOR(nsRDFConInstanceTestNode::Element); }
-
-        virtual ~Element() { MOZ_COUNT_DTOR(nsRDFConInstanceTestNode::Element); }
-
-        virtual const char* Type() const override {
-            return "nsRDFConInstanceTestNode::Element"; }
-
-        virtual PLHashNumber Hash() const override {
-            return mozilla::HashGeneric(mContainerTest, mEmptyTest, mContainer.get());
-        }
-
-        virtual bool Equals(const MemoryElement& aElement) const override {
-            if (aElement.Type() == Type()) {
-                const Element& element = static_cast<const Element&>(aElement);
-                return mContainer == element.mContainer
-                    && mContainerTest == element.mContainerTest
-                    && mEmptyTest == element.mEmptyTest;
-            }
-            return false; }
-
-    protected:
-        nsCOMPtr<nsIRDFResource> mContainer;
-        Test mContainerTest;
-        Test mEmptyTest;
-    };
-
-protected:
-    nsXULTemplateQueryProcessorRDF* mProcessor;
-    RefPtr<nsAtom> mContainerVariable;
-    Test mContainer;
-    Test mEmpty;
-};
-
-#endif // nsRDFConInstanceTestNode_h__
-
deleted file mode 100644
--- a/dom/xul/templates/nsRDFConMemberTestNode.cpp
+++ /dev/null
@@ -1,510 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsRDFConMemberTestNode.h"
-#include "nsIRDFContainer.h"
-#include "nsIRDFContainerUtils.h"
-#include "nsRDFCID.h"
-#include "nsIServiceManager.h"
-#include "nsResourceSet.h"
-#include "nsString.h"
-#include "nsXULContentUtils.h"
-
-#include "mozilla/Logging.h"
-
-using mozilla::LogLevel;
-
-extern mozilla::LazyLogModule gXULTemplateLog;
-
-nsRDFConMemberTestNode::nsRDFConMemberTestNode(TestNode* aParent,
-                                               nsXULTemplateQueryProcessorRDF* aProcessor,
-                                               nsAtom *aContainerVariable,
-                                               nsAtom *aMemberVariable)
-    : nsRDFTestNode(aParent),
-      mProcessor(aProcessor),
-      mContainerVariable(aContainerVariable),
-      mMemberVariable(aMemberVariable)
-{
-    if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-        nsAutoCString props;
-
-        nsResourceSet& containmentProps = aProcessor->ContainmentProperties();
-        nsResourceSet::ConstIterator last = containmentProps.Last();
-        nsResourceSet::ConstIterator first = containmentProps.First();
-        nsResourceSet::ConstIterator iter;
-
-        for (iter = first; iter != last; ++iter) {
-            if (iter != first)
-                props += " ";
-
-            const char* str;
-            iter->GetValueConst(&str);
-
-            props += str;
-        }
-
-        nsAutoString cvar(NS_LITERAL_STRING("(none)"));
-        if (mContainerVariable)
-            mContainerVariable->ToString(cvar);
-
-        nsAutoString mvar(NS_LITERAL_STRING("(none)"));
-        if (mMemberVariable)
-            mMemberVariable->ToString(mvar);
-
-        MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-               ("nsRDFConMemberTestNode[%p]: parent=%p member-props=(%s) container-var=%s member-var=%s",
-                this,
-                aParent,
-                props.get(),
-                NS_ConvertUTF16toUTF8(cvar).get(),
-                NS_ConvertUTF16toUTF8(mvar).get()));
-    }
-}
-
-nsresult
-nsRDFConMemberTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
-                                             bool* aCantHandleYet) const
-{
-    // XXX Uh, factor me, please!
-    nsresult rv;
-
-    if (aCantHandleYet)
-        *aCantHandleYet = false;
-
-    nsCOMPtr<nsIRDFContainerUtils> rdfc =
-        do_GetService("@mozilla.org/rdf/container-utils;1");
-
-    if (! rdfc)
-        return NS_ERROR_FAILURE;
-
-    nsIRDFDataSource* ds = mProcessor->GetDataSource();
-
-    InstantiationSet::Iterator last = aInstantiations.Last();
-    for (InstantiationSet::Iterator inst = aInstantiations.First(); inst != last; ++inst) {
-        bool hasContainerBinding;
-        nsCOMPtr<nsIRDFNode> containerValue;
-        hasContainerBinding = inst->mAssignments.GetAssignmentFor(mContainerVariable,
-                                                                  getter_AddRefs(containerValue));
-
-        nsCOMPtr<nsIRDFResource> containerRes = do_QueryInterface(containerValue);
-
-        nsCOMPtr<nsIRDFContainer> rdfcontainer;
-
-        if (hasContainerBinding && containerRes) {
-            // If we have a container assignment, then see if the
-            // container is an RDF container (bag, seq, alt), and if
-            // so, wrap it.
-            bool isRDFContainer;
-            rv = rdfc->IsContainer(ds, containerRes, &isRDFContainer);
-            if (NS_FAILED(rv)) return rv;
-
-            if (isRDFContainer) {
-                rdfcontainer = do_CreateInstance("@mozilla.org/rdf/container;1", &rv);
-                if (NS_FAILED(rv)) return rv;
-
-                rv = rdfcontainer->Init(ds, containerRes);
-                if (NS_FAILED(rv)) return rv;
-            }
-        }
-
-        bool hasMemberBinding;
-        nsCOMPtr<nsIRDFNode> memberValue;
-        hasMemberBinding = inst->mAssignments.GetAssignmentFor(mMemberVariable,
-                                                               getter_AddRefs(memberValue));
-
-        if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-            const char* container = "(unbound)";
-            if (hasContainerBinding)
-                containerRes->GetValueConst(&container);
-
-            nsAutoString member(NS_LITERAL_STRING("(unbound)"));
-            if (hasMemberBinding)
-                nsXULContentUtils::GetTextForNode(memberValue, member);
-
-            MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-                   ("nsRDFConMemberTestNode[%p]: FilterInstantiations() container=[%s] member=[%s]",
-                    this, container, NS_ConvertUTF16toUTF8(member).get()));
-        }
-
-        if (hasContainerBinding && hasMemberBinding) {
-            // it's a consistency check. see if we have a assignment that is consistent
-            bool isconsistent = false;
-
-            if (rdfcontainer) {
-                // RDF containers are easy. Just use the container API.
-                int32_t index;
-                rv = rdfcontainer->IndexOf(memberValue, &index);
-                if (NS_FAILED(rv)) return rv;
-
-                if (index >= 0)
-                    isconsistent = true;
-            }
-
-            // XXXwaterson oof. if we *are* an RDF container, why do
-            // we still need to grovel through all the containment
-            // properties if the thing we're looking for wasn't there?
-
-            if (! isconsistent) {
-                // Othewise, we'll need to grovel through the
-                // membership properties to see if we have an
-                // assertion that indicates membership.
-                nsResourceSet& containmentProps = mProcessor->ContainmentProperties();
-                for (nsResourceSet::ConstIterator property = containmentProps.First();
-                     property != containmentProps.Last();
-                     ++property) {
-                    bool hasAssertion;
-                    rv = ds->HasAssertion(containerRes,
-                                          *property,
-                                          memberValue,
-                                          true,
-                                          &hasAssertion);
-                    if (NS_FAILED(rv)) return rv;
-
-                    if (hasAssertion) {
-                        // it's consistent. leave it in the set and we'll
-                        // run it up to our parent.
-                        isconsistent = true;
-                        break;
-                    }
-                }
-            }
-
-            MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-                   ("    consistency check => %s", isconsistent ? "passed" : "failed"));
-
-            if (isconsistent) {
-                // Add a memory element to our set-of-support.
-                Element* element =
-                    new nsRDFConMemberTestNode::Element(containerRes,
-                                                        memberValue);
-                inst->AddSupportingElement(element);
-            }
-            else {
-                // it's inconsistent. remove it.
-                aInstantiations.Erase(inst--);
-            }
-
-            // We're done, go on to the next instantiation
-            continue;
-        }
-
-        if (hasContainerBinding && rdfcontainer) {
-            // We've got a container assignment, and the container is
-            // bound to an RDF container. Add each member as a new
-            // instantiation.
-            nsCOMPtr<nsISimpleEnumerator> elements;
-            rv = rdfcontainer->GetElements(getter_AddRefs(elements));
-            if (NS_FAILED(rv)) return rv;
-
-            while (1) {
-                bool hasmore;
-                rv = elements->HasMoreElements(&hasmore);
-                if (NS_FAILED(rv)) return rv;
-
-                if (! hasmore)
-                    break;
-
-                nsCOMPtr<nsISupports> isupports;
-                rv = elements->GetNext(getter_AddRefs(isupports));
-                if (NS_FAILED(rv)) return rv;
-
-                nsCOMPtr<nsIRDFNode> node = do_QueryInterface(isupports);
-                if (! node)
-                    return NS_ERROR_UNEXPECTED;
-
-                if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-                    nsAutoString member;
-                    nsXULContentUtils::GetTextForNode(node, member);
-
-                    MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-                           ("    member => %s", NS_ConvertUTF16toUTF8(member).get()));
-                }
-
-                Instantiation newinst = *inst;
-                newinst.AddAssignment(mMemberVariable, node);
-
-                Element* element =
-                    new nsRDFConMemberTestNode::Element(containerRes, node);
-                newinst.AddSupportingElement(element);
-                aInstantiations.Insert(inst, newinst);
-            }
-        }
-
-        if (hasMemberBinding) {
-            // Oh, this is so nasty. If we have a member assignment, then
-            // grovel through each one of our inbound arcs to see if
-            // any of them are ordinal properties (like an RDF
-            // container might have). If so, walk it backwards to get
-            // the container we're in.
-            nsCOMPtr<nsISimpleEnumerator> arcsin;
-            rv = ds->ArcLabelsIn(memberValue, getter_AddRefs(arcsin));
-            if (NS_FAILED(rv)) return rv;
-
-            while (1) {
-                nsCOMPtr<nsIRDFResource> property;
-
-                {
-                    bool hasmore;
-                    rv = arcsin->HasMoreElements(&hasmore);
-                    if (NS_FAILED(rv)) return rv;
-
-                    if (! hasmore)
-                        break;
-
-                    nsCOMPtr<nsISupports> isupports;
-                    rv = arcsin->GetNext(getter_AddRefs(isupports));
-                    if (NS_FAILED(rv)) return rv;
-
-                    property = do_QueryInterface(isupports);
-                    if (! property)
-                        return NS_ERROR_UNEXPECTED;
-                }
-
-                // Ordinal properties automagically indicate container
-                // membership as far as we're concerned. Note that
-                // we're *only* concerned with ordinal properties
-                // here: the next block will worry about the other
-                // membership properties.
-                bool isordinal;
-                rv = rdfc->IsOrdinalProperty(property, &isordinal);
-                if (NS_FAILED(rv)) return rv;
-
-                if (isordinal) {
-                    // If we get here, we've found a property that
-                    // indicates container membership leading *into* a
-                    // member node. Find all the people that point to
-                    // it, and call them containers.
-                    nsCOMPtr<nsISimpleEnumerator> sources;
-                    rv = ds->GetSources(property, memberValue, true,
-                                        getter_AddRefs(sources));
-                    if (NS_FAILED(rv)) return rv;
-
-                    while (1) {
-                        bool hasmore;
-                        rv = sources->HasMoreElements(&hasmore);
-                        if (NS_FAILED(rv)) return rv;
-
-                        if (! hasmore)
-                            break;
-
-                        nsCOMPtr<nsISupports> isupports;
-                        rv = sources->GetNext(getter_AddRefs(isupports));
-                        if (NS_FAILED(rv)) return rv;
-
-                        nsCOMPtr<nsIRDFResource> source = do_QueryInterface(isupports);
-                        if (! source)
-                            return NS_ERROR_UNEXPECTED;
-
-                        if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-                            const char* container;
-                            source->GetValueConst(&container);
-
-                            MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-                                   ("    container => %s", container));
-                        }
-
-                        // Add a new instantiation
-                        Instantiation newinst = *inst;
-                        newinst.AddAssignment(mContainerVariable, source);
-
-                        Element* element =
-                            new nsRDFConMemberTestNode::Element(source,
-                                                                memberValue);
-                        newinst.AddSupportingElement(element);
-
-                        aInstantiations.Insert(inst, newinst);
-                    }
-                }
-            }
-        }
-
-        if ((hasContainerBinding && ! hasMemberBinding) ||
-            (! hasContainerBinding && hasMemberBinding)) {
-            // it's an open ended query on the container or member. go
-            // through our containment properties to see if anything
-            // applies.
-            nsResourceSet& containmentProps = mProcessor->ContainmentProperties();
-            for (nsResourceSet::ConstIterator property = containmentProps.First();
-                 property != containmentProps.Last();
-                 ++property) {
-                nsCOMPtr<nsISimpleEnumerator> results;
-                if (hasContainerBinding) {
-                    rv = ds->GetTargets(containerRes, *property, true,
-                                        getter_AddRefs(results));
-                }
-                else {
-                    rv = ds->GetSources(*property, memberValue, true,
-                                        getter_AddRefs(results));
-                }
-                if (NS_FAILED(rv)) return rv;
-
-                while (1) {
-                    bool hasmore;
-                    rv = results->HasMoreElements(&hasmore);
-                    if (NS_FAILED(rv)) return rv;
-
-                    if (! hasmore)
-                        break;
-
-                    nsCOMPtr<nsISupports> isupports;
-                    rv = results->GetNext(getter_AddRefs(isupports));
-                    if (NS_FAILED(rv)) return rv;
-
-                    nsAtom* variable;
-                    nsCOMPtr<nsIRDFNode> value;
-                    nsCOMPtr<nsIRDFResource> valueRes;
-
-                    if (hasContainerBinding) {
-                        variable = mMemberVariable;
-
-                        value = do_QueryInterface(isupports);
-                        NS_ASSERTION(value != nullptr, "member is not an nsIRDFNode");
-                        if (! value) continue;
-
-                        if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-                            nsAutoString s;
-                            nsXULContentUtils::GetTextForNode(value, s);
-
-                            MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-                                   ("    member => %s", NS_ConvertUTF16toUTF8(s).get()));
-                        }
-                    }
-                    else {
-                        variable = mContainerVariable;
-
-                        valueRes = do_QueryInterface(isupports);
-                        NS_ASSERTION(valueRes != nullptr, "container is not an nsIRDFResource");
-                        if (! valueRes) continue;
-
-                        value = valueRes;
-
-                        if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-                            const char* s;
-                            valueRes->GetValueConst(&s);
-
-                            MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-                                   ("    container => %s", s));
-                        }
-                    }
-
-                    // Copy the original instantiation, and add it to the
-                    // instantiation set with the new assignment that we've
-                    // introduced. Ownership will be transferred to the
-                    Instantiation newinst = *inst;
-                    newinst.AddAssignment(variable, value);
-
-                    Element* element;
-                    if (hasContainerBinding) {
-                        element =
-                            new nsRDFConMemberTestNode::Element(containerRes, value);
-                    }
-                    else {
-                        element =
-                            new nsRDFConMemberTestNode::Element(valueRes, memberValue);
-                    }
-
-                    if (! element)
-                        return NS_ERROR_OUT_OF_MEMORY;
-
-                    newinst.AddSupportingElement(element);
-
-                    aInstantiations.Insert(inst, newinst);
-                }
-            }
-        }
-
-        if (! hasContainerBinding && ! hasMemberBinding) {
-            // Neither container nor member assignment!
-            if (!aCantHandleYet) {
-                nsXULContentUtils::LogTemplateError(ERROR_TEMPLATE_MEMBER_UNBOUND);
-                return NS_ERROR_UNEXPECTED;
-            }
-
-            *aCantHandleYet = true;
-            return NS_OK;
-        }
-
-        // finally, remove the "under specified" instantiation.
-        aInstantiations.Erase(inst--);
-    }
-
-    return NS_OK;
-}
-
-bool
-nsRDFConMemberTestNode::CanPropagate(nsIRDFResource* aSource,
-                                     nsIRDFResource* aProperty,
-                                     nsIRDFNode* aTarget,
-                                     Instantiation& aInitialBindings) const
-{
-    nsresult rv;
-
-    bool canpropagate = false;
-
-    nsCOMPtr<nsIRDFContainerUtils> rdfc =
-        do_GetService("@mozilla.org/rdf/container-utils;1");
-
-    if (! rdfc)
-        return false;
-
-    // We can certainly propagate ordinal properties
-    rv = rdfc->IsOrdinalProperty(aProperty, &canpropagate);
-    if (NS_FAILED(rv)) return false;
-
-    if (! canpropagate) {
-        canpropagate = mProcessor->ContainmentProperties().Contains(aProperty);
-    }
-
-    if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-        const char* source;
-        aSource->GetValueConst(&source);
-
-        const char* property;
-        aProperty->GetValueConst(&property);
-
-        nsAutoString target;
-        nsXULContentUtils::GetTextForNode(aTarget, target);
-
-        MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-               ("nsRDFConMemberTestNode[%p]: CanPropagate([%s]==[%s]=>[%s]) => %s",
-                this, source, property, NS_ConvertUTF16toUTF8(target).get(),
-                canpropagate ? "true" : "false"));
-    }
-
-    if (canpropagate) {
-        aInitialBindings.AddAssignment(mContainerVariable, aSource);
-        aInitialBindings.AddAssignment(mMemberVariable, aTarget);
-        return true;
-    }
-
-    return false;
-}
-
-void
-nsRDFConMemberTestNode::Retract(nsIRDFResource* aSource,
-                                nsIRDFResource* aProperty,
-                                nsIRDFNode* aTarget) const
-{
-    bool canretract = false;
-
-    nsCOMPtr<nsIRDFContainerUtils> rdfc =
-        do_GetService("@mozilla.org/rdf/container-utils;1");
-
-    if (! rdfc)
-        return;
-
-    // We can certainly retract ordinal properties
-    nsresult rv;
-    rv = rdfc->IsOrdinalProperty(aProperty, &canretract);
-    if (NS_FAILED(rv)) return;
-
-    if (! canretract) {
-        canretract = mProcessor->ContainmentProperties().Contains(aProperty);
-    }
-
-    if (canretract) {
-        mProcessor->RetractElement(Element(aSource, aTarget));
-    }
-}
deleted file mode 100644
--- a/dom/xul/templates/nsRDFConMemberTestNode.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsRDFConMemberTestNode_h__
-#define nsRDFConMemberTestNode_h__
-
-#include "mozilla/Attributes.h"
-#include "nscore.h"
-#include "nsRDFTestNode.h"
-#include "nsIRDFDataSource.h"
-#include "nsXULTemplateQueryProcessorRDF.h"
-
-/**
- * Rule network node that test if a resource is a member of an RDF
- * container, or is ``contained'' by another resource that refers to
- * it using a ``containment'' attribute.
- */
-class nsRDFConMemberTestNode : public nsRDFTestNode
-{
-public:
-    nsRDFConMemberTestNode(TestNode* aParent,
-                           nsXULTemplateQueryProcessorRDF* aProcessor,
-                           nsAtom* aContainerVariable,
-                           nsAtom* aMemberVariable);
-
-    virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations,
-                                          bool* aCantHandleYet) const override;
-
-    virtual bool
-    CanPropagate(nsIRDFResource* aSource,
-                 nsIRDFResource* aProperty,
-                 nsIRDFNode* aTarget,
-                 Instantiation& aInitialBindings) const override;
-
-    virtual void
-    Retract(nsIRDFResource* aSource,
-            nsIRDFResource* aProperty,
-            nsIRDFNode* aTarget) const override;
-
-    class Element : public MemoryElement {
-    public:
-        Element(nsIRDFResource* aContainer,
-                nsIRDFNode* aMember)
-            : mContainer(aContainer),
-              mMember(aMember) {
-            MOZ_COUNT_CTOR(nsRDFConMemberTestNode::Element); }
-
-        virtual ~Element() { MOZ_COUNT_DTOR(nsRDFConMemberTestNode::Element); }
-
-        virtual const char* Type() const override {
-            return "nsRDFConMemberTestNode::Element"; }
-
-        virtual PLHashNumber Hash() const override {
-            return PLHashNumber(NS_PTR_TO_INT32(mContainer.get())) ^
-                (PLHashNumber(NS_PTR_TO_INT32(mMember.get())) >> 12); }
-
-        virtual bool Equals(const MemoryElement& aElement) const override {
-            if (aElement.Type() == Type()) {
-                const Element& element = static_cast<const Element&>(aElement);
-                return mContainer == element.mContainer && mMember == element.mMember;
-            }
-            return false; }
-
-    protected:
-        nsCOMPtr<nsIRDFResource> mContainer;
-        nsCOMPtr<nsIRDFNode> mMember;
-    };
-
-protected:
-    nsXULTemplateQueryProcessorRDF* mProcessor;
-    RefPtr<nsAtom> mContainerVariable;
-    RefPtr<nsAtom> mMemberVariable;
-};
-
-#endif // nsRDFConMemberTestNode_h__
deleted file mode 100644
--- a/dom/xul/templates/nsRDFPropertyTestNode.cpp
+++ /dev/null
@@ -1,362 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsRDFPropertyTestNode.h"
-#include "nsString.h"
-#include "nsXULContentUtils.h"
-
-#include "mozilla/Logging.h"
-
-using mozilla::LogLevel;
-
-extern mozilla::LazyLogModule gXULTemplateLog;
-#include "nsIRDFLiteral.h"
-
-nsRDFPropertyTestNode::nsRDFPropertyTestNode(TestNode* aParent,
-                                             nsXULTemplateQueryProcessorRDF* aProcessor,
-                                             nsAtom* aSourceVariable,
-                                             nsIRDFResource* aProperty,
-                                             nsAtom* aTargetVariable)
-    : nsRDFTestNode(aParent),
-      mProcessor(aProcessor),
-      mSourceVariable(aSourceVariable),
-      mSource(nullptr),
-      mProperty(aProperty),
-      mTargetVariable(aTargetVariable),
-      mTarget(nullptr)
-{
-    if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-        const char* prop = "(null)";
-        if (aProperty)
-            aProperty->GetValueConst(&prop);
-
-        nsAutoString svar(NS_LITERAL_STRING("(none)"));
-        if (mSourceVariable)
-            mSourceVariable->ToString(svar);
-
-        nsAutoString tvar(NS_LITERAL_STRING("(none)"));
-        if (mTargetVariable)
-            mTargetVariable->ToString(tvar);
-
-        MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-               ("nsRDFPropertyTestNode[%p]: parent=%p source=%s property=%s target=%s",
-                this, aParent, NS_ConvertUTF16toUTF8(svar).get(), prop, NS_ConvertUTF16toUTF8(tvar).get()));
-    }
-}
-
-
-nsRDFPropertyTestNode::nsRDFPropertyTestNode(TestNode* aParent,
-                                             nsXULTemplateQueryProcessorRDF* aProcessor,
-                                             nsIRDFResource* aSource,
-                                             nsIRDFResource* aProperty,
-                                             nsAtom* aTargetVariable)
-    : nsRDFTestNode(aParent),
-      mProcessor(aProcessor),
-      mSourceVariable(nullptr),
-      mSource(aSource),
-      mProperty(aProperty),
-      mTargetVariable(aTargetVariable),
-      mTarget(nullptr)
-{
-    if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-        const char* source = "(null)";
-        if (aSource)
-            aSource->GetValueConst(&source);
-
-        const char* prop = "(null)";
-        if (aProperty)
-            aProperty->GetValueConst(&prop);
-
-        nsAutoString tvar(NS_LITERAL_STRING("(none)"));
-        if (mTargetVariable)
-            mTargetVariable->ToString(tvar);
-
-        MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-               ("nsRDFPropertyTestNode[%p]: parent=%p source=%s property=%s target=%s",
-                this, aParent, source, prop, NS_ConvertUTF16toUTF8(tvar).get()));
-    }
-}
-
-
-nsRDFPropertyTestNode::nsRDFPropertyTestNode(TestNode* aParent,
-                                             nsXULTemplateQueryProcessorRDF* aProcessor,
-                                             nsAtom* aSourceVariable,
-                                             nsIRDFResource* aProperty,
-                                             nsIRDFNode* aTarget)
-    : nsRDFTestNode(aParent),
-      mProcessor(aProcessor),
-      mSourceVariable(aSourceVariable),
-      mSource(nullptr),
-      mProperty(aProperty),
-      mTargetVariable(nullptr),
-      mTarget(aTarget)
-{
-    if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-        nsAutoString svar(NS_LITERAL_STRING("(none)"));
-        if (mSourceVariable)
-            mSourceVariable->ToString(svar);
-
-        const char* prop = "(null)";
-        if (aProperty)
-            aProperty->GetValueConst(&prop);
-
-        nsAutoString target;
-        nsXULContentUtils::GetTextForNode(aTarget, target);
-
-        MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-               ("nsRDFPropertyTestNode[%p]: parent=%p source=%s property=%s target=%s",
-                this, aParent, NS_ConvertUTF16toUTF8(svar).get(), prop, NS_ConvertUTF16toUTF8(target).get()));
-    }
-}
-
-
-nsresult
-nsRDFPropertyTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
-                                            bool* aCantHandleYet) const
-{
-    nsresult rv;
-
-    if (aCantHandleYet)
-        *aCantHandleYet = false;
-
-    nsIRDFDataSource* ds = mProcessor->GetDataSource();
-
-    InstantiationSet::Iterator last = aInstantiations.Last();
-    for (InstantiationSet::Iterator inst = aInstantiations.First(); inst != last; ++inst) {
-        bool hasSourceBinding;
-        nsCOMPtr<nsIRDFResource> sourceRes;
-
-        if (mSource) {
-            hasSourceBinding = true;
-            sourceRes = mSource;
-        }
-        else {
-            nsCOMPtr<nsIRDFNode> sourceValue;
-            hasSourceBinding = inst->mAssignments.GetAssignmentFor(mSourceVariable,
-                                                                   getter_AddRefs(sourceValue));
-            sourceRes = do_QueryInterface(sourceValue);
-        }
-
-        bool hasTargetBinding;
-        nsCOMPtr<nsIRDFNode> targetValue;
-
-        if (mTarget) {
-            hasTargetBinding = true;
-            targetValue = mTarget;
-        }
-        else {
-            hasTargetBinding = inst->mAssignments.GetAssignmentFor(mTargetVariable,
-                                                                   getter_AddRefs(targetValue));
-        }
-
-        if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-            const char* source = "(unbound)";
-            if (hasSourceBinding)
-                sourceRes->GetValueConst(&source);
-
-            nsAutoString target(NS_LITERAL_STRING("(unbound)"));
-            if (hasTargetBinding)
-                nsXULContentUtils::GetTextForNode(targetValue, target);
-
-            MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-                   ("nsRDFPropertyTestNode[%p]: FilterInstantiations() source=[%s] target=[%s]",
-                    this, source, NS_ConvertUTF16toUTF8(target).get()));
-        }
-
-        if (hasSourceBinding && hasTargetBinding) {
-            // it's a consistency check. see if we have a assignment that is consistent
-            bool hasAssertion;
-            rv = ds->HasAssertion(sourceRes, mProperty, targetValue,
-                                  true, &hasAssertion);
-            if (NS_FAILED(rv)) return rv;
-
-            MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-                   ("    consistency check => %s", hasAssertion ? "passed" : "failed"));
-
-            if (hasAssertion) {
-                // it's consistent.
-                Element* element =
-                    new nsRDFPropertyTestNode::Element(sourceRes, mProperty,
-                                                       targetValue);
-                inst->AddSupportingElement(element);
-            }
-            else {
-                // it's inconsistent. remove it.
-                aInstantiations.Erase(inst--);
-            }
-        }
-        else if ((hasSourceBinding && ! hasTargetBinding) ||
-                 (! hasSourceBinding && hasTargetBinding)) {
-            // it's an open ended query on the source or
-            // target. figure out what matches and add as a
-            // cross-product.
-            nsCOMPtr<nsISimpleEnumerator> results;
-            if (hasSourceBinding) {
-                rv = ds->GetTargets(sourceRes,
-                                    mProperty,
-                                    true,
-                                    getter_AddRefs(results));
-            }
-            else {
-                rv = ds->GetSources(mProperty,
-                                    targetValue,
-                                    true,
-                                    getter_AddRefs(results));
-                if (NS_FAILED(rv)) return rv;
-            }
-
-            while (1) {
-                bool hasMore;
-                rv = results->HasMoreElements(&hasMore);
-                if (NS_FAILED(rv)) return rv;
-
-                if (! hasMore)
-                    break;
-
-                nsCOMPtr<nsISupports> isupports;
-                rv = results->GetNext(getter_AddRefs(isupports));
-                if (NS_FAILED(rv)) return rv;
-
-                nsAtom* variable;
-                nsCOMPtr<nsIRDFNode> value;
-
-                if (hasSourceBinding) {
-                    variable = mTargetVariable;
-
-                    value = do_QueryInterface(isupports);
-                    NS_ASSERTION(value != nullptr, "target is not an nsIRDFNode");
-
-                    if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-                        nsAutoString s(NS_LITERAL_STRING("(none found)"));
-                        if (value)
-                            nsXULContentUtils::GetTextForNode(value, s);
-
-                        MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-                               ("    target => %s", NS_ConvertUTF16toUTF8(s).get()));
-                    }
-
-                    if (! value) continue;
-
-                    targetValue = value;
-                }
-                else {
-                    variable = mSourceVariable;
-
-                    nsCOMPtr<nsIRDFResource> source = do_QueryInterface(isupports);
-                    NS_ASSERTION(source != nullptr, "source is not an nsIRDFResource");
-
-                    if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-                        const char* s = "(none found)";
-                        if (source)
-                            source->GetValueConst(&s);
-
-                        MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-                               ("    source => %s", s));
-                    }
-
-                    if (! source) continue;
-
-                    value = sourceRes = source;
-                }
-
-                // Copy the original instantiation, and add it to the
-                // instantiation set with the new assignment that we've
-                // introduced. Ownership will be transferred to the
-                Instantiation newinst = *inst;
-                newinst.AddAssignment(variable, value);
-
-                Element* element =
-                    new nsRDFPropertyTestNode::Element(sourceRes, mProperty,
-                                                       targetValue);
-                newinst.AddSupportingElement(element);
-
-                aInstantiations.Insert(inst, newinst);
-            }
-
-            // finally, remove the "under specified" instantiation.
-            aInstantiations.Erase(inst--);
-        }
-        else {
-            if (!aCantHandleYet) {
-                nsXULContentUtils::LogTemplateError(ERROR_TEMPLATE_TRIPLE_UNBOUND);
-                // Neither source nor target assignment!
-                return NS_ERROR_UNEXPECTED;
-            }
-
-            *aCantHandleYet = true;
-            return NS_OK;
-        }
-    }
-
-    return NS_OK;
-}
-
-bool
-nsRDFPropertyTestNode::CanPropagate(nsIRDFResource* aSource,
-                                    nsIRDFResource* aProperty,
-                                    nsIRDFNode* aTarget,
-                                    Instantiation& aInitialBindings) const
-{
-    bool result;
-
-    if ((mProperty.get() != aProperty) ||
-        (mSource && mSource.get() != aSource) ||
-        (mTarget && mTarget.get() != aTarget)) {
-        result = false;
-    }
-    else {
-        if (mSourceVariable)
-            aInitialBindings.AddAssignment(mSourceVariable, aSource);
-
-        if (mTargetVariable)
-            aInitialBindings.AddAssignment(mTargetVariable, aTarget);
-
-        result = true;
-    }
-
-    if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-        const char* source;
-        aSource->GetValueConst(&source);
-
-        const char* property;
-        aProperty->GetValueConst(&property);
-
-        nsAutoString target;
-        nsXULContentUtils::GetTextForNode(aTarget, target);
-
-        MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-               ("nsRDFPropertyTestNode[%p]: CanPropagate([%s]==[%s]=>[%s]) => %s",
-                this, source, property, NS_ConvertUTF16toUTF8(target).get(),
-                result ? "true" : "false"));
-    }
-
-    return result;
-}
-
-void
-nsRDFPropertyTestNode::Retract(nsIRDFResource* aSource,
-                               nsIRDFResource* aProperty,
-                               nsIRDFNode* aTarget) const
-{
-    if (aProperty == mProperty.get()) {
-        if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Debug)) {
-            const char* source;
-            aSource->GetValueConst(&source);
-
-            const char* property;
-            aProperty->GetValueConst(&property);
-
-            nsAutoString target;
-            nsXULContentUtils::GetTextForNode(aTarget, target);
-
-            MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-                   ("nsRDFPropertyTestNode[%p]: Retract([%s]==[%s]=>[%s])",
-                    this, source, property, NS_ConvertUTF16toUTF8(target).get()));
-        }
-
-        mProcessor->RetractElement(Element(aSource, aProperty, aTarget));
-    }
-}
-
deleted file mode 100644
--- a/dom/xul/templates/nsRDFPropertyTestNode.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsRDFPropertyTestNode_h__
-#define nsRDFPropertyTestNode_h__
-
-#include "mozilla/Attributes.h"
-#include "nscore.h"
-#include "nsRDFTestNode.h"
-#include "nsIRDFDataSource.h"
-#include "nsIRDFResource.h"
-#include "nsXULTemplateQueryProcessorRDF.h"
-
-class nsRDFPropertyTestNode : public nsRDFTestNode
-{
-public:
-    /**
-     * Both source and target unbound (?source ^property ?target)
-     */
-    nsRDFPropertyTestNode(TestNode* aParent,
-                          nsXULTemplateQueryProcessorRDF* aProcessor,
-                          nsAtom* aSourceVariable,
-                          nsIRDFResource* aProperty,
-                          nsAtom* aTargetVariable);
-
-    /**
-     * Source bound, target unbound (source ^property ?target)
-     */
-    nsRDFPropertyTestNode(TestNode* aParent,
-                          nsXULTemplateQueryProcessorRDF* aProcessor,
-                          nsIRDFResource* aSource,
-                          nsIRDFResource* aProperty,
-                          nsAtom* aTargetVariable);
-
-    /**
-     * Source unbound, target bound (?source ^property target)
-     */
-    nsRDFPropertyTestNode(TestNode* aParent,
-                          nsXULTemplateQueryProcessorRDF* aProcessor,
-                          nsAtom* aSourceVariable,
-                          nsIRDFResource* aProperty,
-                          nsIRDFNode* aTarget);
-
-    virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations,
-                                          bool* aCantHandleYet) const override;
-
-    virtual bool
-    CanPropagate(nsIRDFResource* aSource,
-                 nsIRDFResource* aProperty,
-                 nsIRDFNode* aTarget,
-                 Instantiation& aInitialBindings) const override;
-
-    virtual void
-    Retract(nsIRDFResource* aSource,
-            nsIRDFResource* aProperty,
-            nsIRDFNode* aTarget) const override;
-
-
-    class Element : public MemoryElement {
-    public:
-        Element(nsIRDFResource* aSource,
-                nsIRDFResource* aProperty,
-                nsIRDFNode* aTarget)
-            : mSource(aSource),
-              mProperty(aProperty),
-              mTarget(aTarget) {
-            MOZ_COUNT_CTOR(nsRDFPropertyTestNode::Element); }
-
-        virtual ~Element() { MOZ_COUNT_DTOR(nsRDFPropertyTestNode::Element); }
-
-        virtual const char* Type() const override {
-            return "nsRDFPropertyTestNode::Element"; }
-
-        virtual PLHashNumber Hash() const override {
-            return mozilla::HashGeneric(mSource.get(), mProperty.get(), mTarget.get());
-        }
-
-        virtual bool Equals(const MemoryElement& aElement) const override {
-            if (aElement.Type() == Type()) {
-                const Element& element = static_cast<const Element&>(aElement);
-                return mSource == element.mSource
-                    && mProperty == element.mProperty
-                    && mTarget == element.mTarget;
-            }
-            return false; }
-
-    protected:
-        nsCOMPtr<nsIRDFResource> mSource;
-        nsCOMPtr<nsIRDFResource> mProperty;
-        nsCOMPtr<nsIRDFNode> mTarget;
-    };
-
-protected:
-    nsXULTemplateQueryProcessorRDF* mProcessor;
-    RefPtr<nsAtom>        mSourceVariable;
-    nsCOMPtr<nsIRDFResource> mSource;
-    nsCOMPtr<nsIRDFResource> mProperty;
-    RefPtr<nsAtom>        mTargetVariable;
-    nsCOMPtr<nsIRDFNode>     mTarget;
-};
-
-#endif // nsRDFPropertyTestNode_h__
deleted file mode 100644
--- a/dom/xul/templates/nsRDFQuery.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nscore.h"
-#include "nsCOMPtr.h"
-
-#include "nsXULTemplateQueryProcessorRDF.h"
-#include "nsRDFQuery.h"
-
-NS_IMPL_CYCLE_COLLECTION(nsRDFQuery, mQueryNode)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsRDFQuery)
-  NS_INTERFACE_MAP_ENTRY(nsITemplateRDFQuery)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsRDFQuery)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsRDFQuery)
-
-void
-nsRDFQuery::Finish()
-{
-    // the template builder is going away and the query processor likely as
-    // well. Clear the reference to avoid calling it.
-    mProcessor = nullptr;
-    mCachedResults = nullptr;
-}
-
-nsresult
-nsRDFQuery::SetCachedResults(nsXULTemplateQueryProcessorRDF* aProcessor,
-                             const InstantiationSet& aInstantiations)
-{
-    mCachedResults = new nsXULTemplateResultSetRDF(aProcessor, this, &aInstantiations);
-    return NS_OK;
-}
-
-
-void
-nsRDFQuery::UseCachedResults(nsISimpleEnumerator** aResults)
-{
-    *aResults = mCachedResults;
-    NS_IF_ADDREF(*aResults);
-
-    mCachedResults = nullptr;
-}
deleted file mode 100644
--- a/dom/xul/templates/nsRDFQuery.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsRDFQuery_h__
-#define nsRDFQuery_h__
-
-#include "nsISimpleEnumerator.h"
-#include "nsCycleCollectionParticipant.h"
-#include "mozilla/Attributes.h"
-
-#define NS_ITEMPLATERDFQUERY_IID \
-  {0x8929ff60, 0x1c9c, 0x4d87, \
-    { 0xac, 0x02, 0x09, 0x14, 0x15, 0x3b, 0x48, 0xc4 }}
-
-class nsXULTemplateQueryProcessorRDF;
-
-/**
- * A compiled query in the RDF query processor. This interface should not be
- * used directly outside of the RDF query processor.
- */
-class nsITemplateRDFQuery : public nsISupports
-{
-public:
-    NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITEMPLATERDFQUERY_IID)
-
-    // return the processor the query was created from
-    virtual nsXULTemplateQueryProcessorRDF* Processor() = 0;  // not addrefed
-
-    // return the member variable for the query
-    virtual nsAtom* GetMemberVariable() = 0; // not addrefed
-
-    // return the <query> node the query was compiled from
-    virtual void GetQueryNode(nsIDOMNode** aQueryNode) = 0;
-
-    // remove any results that are cached by the query
-    virtual void ClearCachedResults() = 0;
-};
-
-class nsRDFQuery final : public nsITemplateRDFQuery
-{
-    ~nsRDFQuery() { Finish(); }
-
-public:
-
-    explicit nsRDFQuery(nsXULTemplateQueryProcessorRDF* aProcessor)
-      : mProcessor(aProcessor),
-        mSimple(false),
-        mRoot(nullptr),
-        mCachedResults(nullptr)
-    { }
-
-    NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-    NS_DECL_CYCLE_COLLECTION_CLASS(nsRDFQuery)
-
-    /**
-     * Retrieve the root node in the rule network
-     * @return the root node in the rule network
-     */
-    TestNode* GetRoot() { return mRoot; }
-
-    void SetRoot(TestNode* aRoot) { mRoot = aRoot; }
-
-    void GetQueryNode(nsIDOMNode** aQueryNode) override
-    {
-       *aQueryNode = mQueryNode;
-       NS_IF_ADDREF(*aQueryNode);
-    }
-
-    void SetQueryNode(nsIDOMNode* aQueryNode)
-    {
-       mQueryNode = aQueryNode;
-    }
-
-    // an optimization is used when several queries all use the simple query
-    // syntax. Since simple queries can only generate one possible set of
-    // results, they only need to be calculated once and reused for every
-    // simple query. The results may be cached in the query for this purpose.
-    // If successful, this method takes ownership of aInstantiations.
-    nsresult SetCachedResults(nsXULTemplateQueryProcessorRDF* aProcessor,
-                              const InstantiationSet& aInstantiations);
-
-    // grab the cached results, if any, causing the caller to take ownership
-    // of them. This also has the effect of setting the cached results in this
-    // nsRDFQuery to null.
-    void UseCachedResults(nsISimpleEnumerator** aResults);
-
-    // clear the cached results
-    void ClearCachedResults() override
-    {
-        mCachedResults = nullptr;
-    }
-
-    nsXULTemplateQueryProcessorRDF* Processor() override { return mProcessor; }
-
-    nsAtom* GetMemberVariable() override { return mMemberVariable; }
-
-    bool IsSimple() { return mSimple; }
-
-    void SetSimple() { mSimple = true; }
-
-    // the reference and member variables for the query
-    RefPtr<nsAtom> mRefVariable;
-    RefPtr<nsAtom> mMemberVariable;
-
-protected:
-
-    nsXULTemplateQueryProcessorRDF* mProcessor;
-
-    // true if the query is a simple rule (one with a default query)
-    bool mSimple;
-
-    /**
-     * The root node in the network for this query
-     */
-    TestNode *mRoot;
-
-    // the <query> node
-    nsCOMPtr<nsIDOMNode> mQueryNode;
-
-    // used for simple rules since their results are all determined in one step
-    nsCOMPtr<nsISimpleEnumerator> mCachedResults;
-
-    void Finish();
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsITemplateRDFQuery, NS_ITEMPLATERDFQUERY_IID)
-
-#endif // nsRDFQuery_h__
deleted file mode 100644
--- a/dom/xul/templates/nsRDFTestNode.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsRDFTestNode_h__
-#define nsRDFTestNode_h__
-
-#include "nsRuleNetwork.h"
-
-class nsIRDFResource;
-class nsIRDFNode;
-
-/**
- * An abstract base class for all of the RDF-related tests. This interface
- * allows us to iterate over all of the RDF tests to find the one in the
- * network that is apropos for a newly-added assertion.
- */
-class nsRDFTestNode : public TestNode
-{
-public:
-    explicit nsRDFTestNode(TestNode* aParent)
-        : TestNode(aParent) {}
-
-    /**
-     * Determine whether the node can propagate an assertion
-     * with the specified source, property, and target. If the
-     * assertion can be propagated, aInitialBindings will be
-     * initialized with appropriate variable-to-value assignments
-     * to allow the rule network to start a constrain and propagate
-     * search from this node in the network.
-     *
-     * @return true if the node can propagate the specified
-     * assertion.
-     */
-    virtual bool CanPropagate(nsIRDFResource* aSource,
-                                nsIRDFResource* aProperty,
-                                nsIRDFNode* aTarget,
-                                Instantiation& aInitialBindings) const = 0;
-
-    /**
-     *
-     */
-    virtual void Retract(nsIRDFResource* aSource,
-                         nsIRDFResource* aProperty,
-                         nsIRDFNode* aTarget) const = 0;
-};
-
-#endif // nsRDFTestNode_h__
deleted file mode 100644
--- a/dom/xul/templates/nsResourceSet.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsResourceSet.h"
-
-nsResourceSet::nsResourceSet(const nsResourceSet& aResourceSet)
-    : mResources(nullptr),
-      mCount(0),
-      mCapacity(0)
-{
-    ConstIterator last = aResourceSet.Last();
-    for (ConstIterator resource = aResourceSet.First(); resource != last; ++resource)
-        Add(*resource);
-}
-
-
-nsResourceSet&
-nsResourceSet::operator=(const nsResourceSet& aResourceSet)
-{
-    Clear();
-    ConstIterator last = aResourceSet.Last();
-    for (ConstIterator resource = aResourceSet.First(); resource != last; ++resource)
-        Add(*resource);
-    return *this;
-}
-
-nsResourceSet::~nsResourceSet()
-{
-    MOZ_COUNT_DTOR(nsResourceSet);
-    Clear();
-    delete[] mResources;
-}
-
-nsresult
-nsResourceSet::Clear()
-{
-    while (--mCount >= 0) {
-        NS_RELEASE(mResources[mCount]);
-    }
-    mCount = 0;
-    return NS_OK;
-}
-
-nsresult
-nsResourceSet::Add(nsIRDFResource* aResource)
-{
-    NS_PRECONDITION(aResource != nullptr, "null ptr");
-    if (! aResource)
-        return NS_ERROR_NULL_POINTER;
-
-    if (Contains(aResource))
-        return NS_OK;
-
-    if (mCount >= mCapacity) {
-        int32_t capacity = mCapacity + 4;
-        nsIRDFResource** resources = new nsIRDFResource*[capacity];
-        for (int32_t i = mCount - 1; i >= 0; --i)
-            resources[i] = mResources[i];
-
-        delete[] mResources;
-
-        mResources = resources;
-        mCapacity = capacity;
-    }
-
-    mResources[mCount++] = aResource;
-    NS_ADDREF(aResource);
-    return NS_OK;
-}
-
-void
-nsResourceSet::Remove(nsIRDFResource* aProperty)
-{
-    bool found = false;
-
-    nsIRDFResource** res = mResources;
-    nsIRDFResource** limit = mResources + mCount;
-    while (res < limit) {
-        if (found) {
-            *(res - 1) = *res;
-        }
-        else if (*res == aProperty) {
-            NS_RELEASE(*res);
-            found = true;
-        }
-        ++res;
-    }
-
-    if (found)
-        --mCount;
-}
-
-bool
-nsResourceSet::Contains(nsIRDFResource* aResource) const
-{
-    for (int32_t i = mCount - 1; i >= 0; --i) {
-        if (mResources[i] == aResource)
-            return true;
-    }
-
-    return false;
-}
-
deleted file mode 100644
--- a/dom/xul/templates/nsResourceSet.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#ifndef nsResourceSet_h__
-#define nsResourceSet_h__
-
-#include "nsIRDFResource.h"
-
-class nsResourceSet
-{
-public:
-    nsResourceSet()
-        : mResources(nullptr),
-          mCount(0),
-          mCapacity(0) {
-        MOZ_COUNT_CTOR(nsResourceSet); }
-
-    nsResourceSet(const nsResourceSet& aResourceSet);
-
-    nsResourceSet& operator=(const nsResourceSet& aResourceSet);
-
-    ~nsResourceSet();
-
-    nsresult Clear();
-    nsresult Add(nsIRDFResource* aProperty);
-    void Remove(nsIRDFResource* aProperty);
-
-    bool Contains(nsIRDFResource* aProperty) const;
-
-protected:
-    nsIRDFResource** mResources;
-    int32_t mCount;
-    int32_t mCapacity;
-
-public:
-    class ConstIterator {
-    protected:
-        nsIRDFResource** mCurrent;
-
-    public:
-        ConstIterator() : mCurrent(nullptr) {}
-
-        ConstIterator(const ConstIterator& aConstIterator)
-            : mCurrent(aConstIterator.mCurrent) {}
-
-        ConstIterator& operator=(const ConstIterator& aConstIterator) {
-            mCurrent = aConstIterator.mCurrent;
-            return *this; }
-
-        ConstIterator& operator++() {
-            ++mCurrent;
-            return *this; }
-
-        ConstIterator operator++(int) {
-            ConstIterator result(*this);
-            ++mCurrent;
-            return result; }
-
-        /*const*/ nsIRDFResource* operator*() const {
-            return *mCurrent; }
-
-        /*const*/ nsIRDFResource* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN {
-            return *mCurrent; }
-
-        bool operator==(const ConstIterator& aConstIterator) const {
-            return mCurrent == aConstIterator.mCurrent; }
-
-        bool operator!=(const ConstIterator& aConstIterator) const {
-            return mCurrent != aConstIterator.mCurrent; }
-
-    protected:
-        explicit ConstIterator(nsIRDFResource** aProperty) : mCurrent(aProperty) {}
-        friend class nsResourceSet;
-    };
-
-    ConstIterator First() const { return ConstIterator(mResources); }
-    ConstIterator Last() const { return ConstIterator(mResources + mCount); }
-};
-
-#endif // nsResourceSet_h__
-
deleted file mode 100644
--- a/dom/xul/templates/nsRuleNetwork.cpp
+++ /dev/null
@@ -1,428 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
-
-  Implementations for the rule network classes.
-
-  To Do.
-
-  - Constrain() & Propagate() still feel like they are poorly named.
-  - As do Instantiation and InstantiationSet.
-  - Make InstantiationSet share and do copy-on-write.
-  - Make things iterative, instead of recursive.
-
- */
-
-#include "nscore.h"
-#include "nsCOMPtr.h"
-#include "plhash.h"
-
-#include "mozilla/Logging.h"
-
-#include "nsString.h"
-#include "nsUnicharUtils.h"
-#include "nsXULContentUtils.h"
-
-#include "nsRuleNetwork.h"
-#include "nsXULTemplateResultSetRDF.h"
-#include "nsRDFConMemberTestNode.h"
-#include "nsRDFPropertyTestNode.h"
-
-using namespace mozilla;
-extern LazyLogModule gXULTemplateLog;
-
-//----------------------------------------------------------------------
-//
-// nsRuleNetwork
-//
-
-nsresult
-MemoryElementSet::Add(MemoryElement* aElement)
-{
-    for (ConstIterator element = First(); element != Last(); ++element) {
-        if (*element == *aElement) {
-            // We've already got this element covered. Since Add()
-            // assumes ownership, and we aren't going to need this,
-            // just nuke it.
-            delete aElement;
-            return NS_OK;
-        }
-    }
-
-    List* list = new List;
-    list->mElement = aElement;
-    list->mRefCnt  = 1;
-    list->mNext    = mElements;
-
-    mElements = list;
-
-    return NS_OK;
-}
-
-
-//----------------------------------------------------------------------
-
-nsresult
-nsAssignmentSet::Add(const nsAssignment& aAssignment)
-{
-    NS_PRECONDITION(! HasAssignmentFor(aAssignment.mVariable), "variable already bound");
-
-    // XXXndeakin should this just silently fail?
-    if (HasAssignmentFor(aAssignment.mVariable))
-        return NS_ERROR_UNEXPECTED;
-
-    List* list = new List(aAssignment);
-    list->mRefCnt     = 1;
-    list->mNext       = mAssignments;
-
-    mAssignments = list;
-
-    return NS_OK;
-}
-
-int32_t
-nsAssignmentSet::Count() const
-{
-    int32_t count = 0;
-    for (ConstIterator assignment = First(); assignment != Last(); ++assignment)
-        ++count;
-
-    return count;
-}
-
-bool
-nsAssignmentSet::HasAssignment(nsAtom* aVariable, nsIRDFNode* aValue) const
-{
-    for (ConstIterator assignment = First(); assignment != Last(); ++assignment) {
-        if (assignment->mVariable == aVariable && assignment->mValue == aValue)
-            return true;
-    }
-
-    return false;
-}
-
-bool
-nsAssignmentSet::HasAssignmentFor(nsAtom* aVariable) const
-{
-    for (ConstIterator assignment = First(); assignment != Last(); ++assignment) {
-        if (assignment->mVariable == aVariable)
-            return true;
-    }
-
-    return false;
-}
-
-bool
-nsAssignmentSet::GetAssignmentFor(nsAtom* aVariable, nsIRDFNode** aValue) const
-{
-    for (ConstIterator assignment = First(); assignment != Last(); ++assignment) {
-        if (assignment->mVariable == aVariable) {
-            *aValue = assignment->mValue;
-            NS_IF_ADDREF(*aValue);
-            return true;
-        }
-    }
-
-    *aValue = nullptr;
-    return false;
-}
-
-bool
-nsAssignmentSet::Equals(const nsAssignmentSet& aSet) const
-{
-    if (aSet.mAssignments == mAssignments)
-        return true;
-
-    // If they have a different number of assignments, then they're different.
-    if (Count() != aSet.Count())
-        return false;
-
-    // XXX O(n^2)! Ugh!
-    nsCOMPtr<nsIRDFNode> value;
-    for (ConstIterator assignment = First(); assignment != Last(); ++assignment) {
-        if (! aSet.GetAssignmentFor(assignment->mVariable, getter_AddRefs(value)))
-            return false;
-
-        if (assignment->mValue != value)
-            return false;
-    }
-
-    return true;
-}
-
-//----------------------------------------------------------------------
-
-PLHashNumber
-Instantiation::Hash(const void* aKey)
-{
-    const Instantiation* inst = static_cast<const Instantiation*>(aKey);
-
-    PLHashNumber result = 0;
-
-    nsAssignmentSet::ConstIterator last = inst->mAssignments.Last();
-    for (nsAssignmentSet::ConstIterator assignment = inst->mAssignments.First();
-         assignment != last; ++assignment)
-        result ^= assignment->Hash();
-
-    return result;
-}
-
-
-int
-Instantiation::Compare(const void* aLeft, const void* aRight)
-{
-    const Instantiation* left  = static_cast<const Instantiation*>(aLeft);
-    const Instantiation* right = static_cast<const Instantiation*>(aRight);
-
-    return *left == *right;
-}
-
-
-//----------------------------------------------------------------------
-//
-// InstantiationSet
-//
-
-InstantiationSet::InstantiationSet()
-{
-    mHead.mPrev = mHead.mNext = &mHead;
-    MOZ_COUNT_CTOR(InstantiationSet);
-}
-
-
-InstantiationSet::InstantiationSet(const InstantiationSet& aInstantiationSet)
-{
-    mHead.mPrev = mHead.mNext = &mHead;
-
-    // XXX replace with copy-on-write foo
-    ConstIterator last = aInstantiationSet.Last();
-    for (ConstIterator inst = aInstantiationSet.First(); inst != last; ++inst)
-        Append(*inst);
-
-    MOZ_COUNT_CTOR(InstantiationSet);
-}
-
-InstantiationSet&
-InstantiationSet::operator=(const InstantiationSet& aInstantiationSet)
-{
-    // XXX replace with copy-on-write foo
-    Clear();
-
-    ConstIterator last = aInstantiationSet.Last();
-    for (ConstIterator inst = aInstantiationSet.First(); inst != last; ++inst)
-        Append(*inst);
-
-    return *this;
-}
-
-
-void
-InstantiationSet::Clear()
-{
-    Iterator inst = First();
-    while (inst != Last())
-        Erase(inst++);
-}
-
-
-InstantiationSet::Iterator
-InstantiationSet::Insert(Iterator aIterator, const Instantiation& aInstantiation)
-{
-    List* newelement = new List();
-    if (newelement) {
-        newelement->mInstantiation = aInstantiation;
-
-        aIterator.mCurrent->mPrev->mNext = newelement;
-
-        newelement->mNext = aIterator.mCurrent;
-        newelement->mPrev = aIterator.mCurrent->mPrev;
-
-        aIterator.mCurrent->mPrev = newelement;
-    }
-    return aIterator;
-}
-
-InstantiationSet::Iterator
-InstantiationSet::Erase(Iterator aIterator)
-{
-    Iterator result = aIterator;
-    ++result;
-    aIterator.mCurrent->mNext->mPrev = aIterator.mCurrent->mPrev;
-    aIterator.mCurrent->mPrev->mNext = aIterator.mCurrent->mNext;
-    delete aIterator.mCurrent;
-    return result;
-}
-
-
-bool
-InstantiationSet::HasAssignmentFor(nsAtom* aVariable) const
-{
-    return !Empty() ? First()->mAssignments.HasAssignmentFor(aVariable) : false;
-}
-
-//----------------------------------------------------------------------
-//
-// ReteNode
-//
-//   The basic node in the network.
-//
-
-//----------------------------------------------------------------------
-//
-// TestNode
-//
-//   to do:
-//     - FilterInstantiations() is poorly named
-//
-
-
-TestNode::TestNode(TestNode* aParent)
-    : mParent(aParent)
-{
-}
-
-nsresult
-TestNode::Propagate(InstantiationSet& aInstantiations,
-                    bool aIsUpdate, bool& aTakenInstantiations)
-{
-    MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-           ("TestNode[%p]: Propagate() begin", this));
-
-    aTakenInstantiations = false;
-
-    nsresult rv = FilterInstantiations(aInstantiations, nullptr);
-    if (NS_FAILED(rv))
-        return rv;
-
-    // if there is more than one child, each will need to be supplied with the
-    // original set of instantiations from this node, so create a copy in this
-    // case. If there is only one child, optimize and just pass the
-    // instantiations along to the child without copying
-    bool shouldCopy = (mKids.Count() > 1);
-
-    // See the header file for details about how instantiation ownership works.
-    if (! aInstantiations.Empty()) {
-        ReteNodeSet::Iterator last = mKids.Last();
-        for (ReteNodeSet::Iterator kid = mKids.First(); kid != last; ++kid) {
-            MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-                   ("TestNode[%p]: Propagate() passing to child %p", this, kid.operator->()));
-
-            // create a copy of the instantiations
-            if (shouldCopy) {
-                bool owned = false;
-                InstantiationSet* instantiations =
-                    new InstantiationSet(aInstantiations);
-                rv = kid->Propagate(*instantiations, aIsUpdate, owned);
-                if (!owned)
-                    delete instantiations;
-                if (NS_FAILED(rv))
-                    return rv;
-            }
-            else {
-                rv = kid->Propagate(aInstantiations, aIsUpdate, aTakenInstantiations);
-                if (NS_FAILED(rv))
-                    return rv;
-            }
-        }
-    }
-
-    MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-           ("TestNode[%p]: Propagate() end", this));
-
-    return NS_OK;
-}
-
-
-nsresult
-TestNode::Constrain(InstantiationSet& aInstantiations)
-{
-    nsresult rv;
-
-    MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-           ("TestNode[%p]: Constrain() begin", this));
-
-    // 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.
-    bool cantHandleYet = false;
-    rv = FilterInstantiations(aInstantiations, &cantHandleYet);
-    if (NS_FAILED(rv)) return rv;
-
-    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.
-
-        MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-               ("TestNode[%p]: Constrain() passing to parent %p", this, mParent));
-
-        rv = mParent->Constrain(aInstantiations);
-
-        if (NS_SUCCEEDED(rv) && cantHandleYet)
-            rv = FilterInstantiations(aInstantiations, nullptr);
-    }
-    else {
-        MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-               ("TestNode[%p]: Constrain() failed", this));
-
-        rv = NS_OK;
-    }
-
-    MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
-           ("TestNode[%p]: Constrain() end", this));
-
-    return rv;
-}
-
-
-//----------------------------------------------------------------------
-
-ReteNodeSet::ReteNodeSet()
-    : mNodes(nullptr), mCount(0), mCapacity(0)
-{
-}
-
-ReteNodeSet::~ReteNodeSet()
-{
-    Clear();
-}
-
-nsresult
-ReteNodeSet::Add(ReteNode* aNode)
-{
-    NS_PRECONDITION(aNode != nullptr, "null ptr");
-    if (! aNode)
-        return NS_ERROR_NULL_POINTER;
-
-    if (mCount >= mCapacity) {
-        int32_t capacity = mCapacity + 4;
-        ReteNode** nodes = new ReteNode*[capacity];
-        if (! nodes)
-            return NS_ERROR_OUT_OF_MEMORY;
-
-        for (int32_t i = mCount - 1; i >= 0; --i)
-            nodes[i] = mNodes[i];
-
-        delete[] mNodes;
-
-        mNodes = nodes;
-        mCapacity = capacity;
-    }
-
-    mNodes[mCount++] = aNode;
-    return NS_OK;
-}
-
-nsresult
-ReteNodeSet::Clear()
-{
-    delete[] mNodes;
-    mNodes = nullptr;
-    mCount = mCapacity = 0;
-    return NS_OK;
-}
deleted file mode 100644
--- a/dom/xul/templates/nsRuleNetwork.h
+++ /dev/null
@@ -1,861 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
-
-  A rule discrimination network implementation based on ideas from
-  RETE and TREAT.
-
-  RETE is described in Charles Forgy, "Rete: A Fast Algorithm for the
-  Many Patterns/Many Objects Match Problem", Artificial Intelligence
-  19(1): pp. 17-37, 1982.
-
-  TREAT is described in Daniel P. Miranker, "TREAT: A Better Match
-  Algorithm for AI Production System Matching", AAAI 1987: pp. 42-47.
-
-  --
-
-  TO DO:
-
-  . nsAssignmentSet::List objects are allocated by the gallon. We
-    should make it so that these are always allocated from a pool,
-    maybe owned by the nsRuleNetwork?
-
- */
-
-#ifndef nsRuleNetwork_h__
-#define nsRuleNetwork_h__
-
-#include "mozilla/Attributes.h"
-#include "mozilla/HashFunctions.h"
-#include "nsCOMPtr.h"
-#include "nsCOMArray.h"
-#include "nsAtom.h"
-#include "nsIDOMNode.h"
-#include "plhash.h"
-#include "PLDHashTable.h"
-#include "nsIRDFNode.h"
-
-class nsXULTemplateResultSetRDF;
-
-//----------------------------------------------------------------------
-
-/**
- * A memory element that supports an instantiation. A memory element holds a
- * set of nodes involved in an RDF test such as <member> or <triple> test. A
- * memory element is created when a specific test matches. The query processor
- * maintains a map between the memory elements and the results they eventually
- * matched. When an assertion is removed from the graph, this map is consulted
- * to determine which results will no longer match.
- */
-class MemoryElement {
-protected:
-    MemoryElement() { MOZ_COUNT_CTOR(MemoryElement); }
-
-public:
-    virtual ~MemoryElement() { MOZ_COUNT_DTOR(MemoryElement); }
-
-    virtual const char* Type() const = 0;
-    virtual PLHashNumber Hash() const = 0;
-    virtual bool Equals(const MemoryElement& aElement) const = 0;
-
-    bool operator==(const MemoryElement& aMemoryElement) const {
-        return Equals(aMemoryElement);
-    }
-
-    bool operator!=(const MemoryElement& aMemoryElement) const {
-        return !Equals(aMemoryElement);
-    }
-};
-
-//----------------------------------------------------------------------
-
-/**
- * A collection of memory elements
- */
-class MemoryElementSet {
-public:
-    class ConstIterator;
-    friend class ConstIterator;
-
-protected:
-    class List {
-    public:
-        List() { MOZ_COUNT_CTOR(MemoryElementSet::List); }
-
-    protected:
-        ~List() {
-            MOZ_COUNT_DTOR(MemoryElementSet::List);
-            delete mElement;
-            NS_IF_RELEASE(mNext); }
-
-    public:
-        int32_t AddRef() { return ++mRefCnt; }
-
-        int32_t Release() {
-            int32_t refcnt = --mRefCnt;
-            if (refcnt == 0) delete this;
-            return refcnt; }
-
-        MemoryElement* mElement;
-        int32_t        mRefCnt;
-        List*          mNext;
-    };
-
-    List* mElements;
-
-public:
-    MemoryElementSet() : mElements(nullptr) {
-        MOZ_COUNT_CTOR(MemoryElementSet); }
-
-    MemoryElementSet(const MemoryElementSet& aSet) : mElements(aSet.mElements) {
-        MOZ_COUNT_CTOR(MemoryElementSet);
-        NS_IF_ADDREF(mElements); }
-
-    MemoryElementSet& operator=(const MemoryElementSet& aSet) {
-        NS_IF_RELEASE(mElements);
-        mElements = aSet.mElements;
-        NS_IF_ADDREF(mElements);
-        return *this; }
-
-    ~MemoryElementSet() {
-        MOZ_COUNT_DTOR(MemoryElementSet);
-        NS_IF_RELEASE(mElements); }
-
-public:
-    class ConstIterator {
-    public:
-        explicit ConstIterator(List* aElementList) : mCurrent(aElementList) {
-            NS_IF_ADDREF(mCurrent); }
-
-        ConstIterator(const ConstIterator& aConstIterator)
-            : mCurrent(aConstIterator.mCurrent) {
-            NS_IF_ADDREF(mCurrent); }
-
-        ConstIterator& operator=(const ConstIterator& aConstIterator) {
-            NS_IF_RELEASE(mCurrent);
-            mCurrent = aConstIterator.mCurrent;
-            NS_IF_ADDREF(mCurrent);
-            return *this; }
-
-        ~ConstIterator() { NS_IF_RELEASE(mCurrent); }
-
-        ConstIterator& operator++() {
-            List* next = mCurrent->mNext;
-            NS_RELEASE(mCurrent);
-            mCurrent = next;
-            NS_IF_ADDREF(mCurrent);
-            return *this; }
-
-        ConstIterator operator++(int) {
-            ConstIterator result(*this);
-            List* next = mCurrent->mNext;
-            NS_RELEASE(mCurrent);
-            mCurrent = next;
-            NS_IF_ADDREF(mCurrent);
-            return result; }
-
-        const MemoryElement& operator*() const {
-            return *mCurrent->mElement; }
-
-        const MemoryElement* operator->() const {
-            return mCurrent->mElement; }
-
-        bool operator==(const ConstIterator& aConstIterator) const {
-            return mCurrent == aConstIterator.mCurrent; }
-
-        bool operator!=(const ConstIterator& aConstIterator) const {
-            return mCurrent != aConstIterator.mCurrent; }
-
-    protected:
-        List* mCurrent;
-    };
-
-    ConstIterator First() const { return ConstIterator(mElements); }
-    ConstIterator Last() const { return ConstIterator(nullptr); }
-
-    // N.B. that the set assumes ownership of the element
-    nsresult Add(MemoryElement* aElement);
-};
-
-//----------------------------------------------------------------------
-
-/**
- * An assignment of a value to a variable
- */
-class nsAssignment {
-public:
-    const RefPtr<nsAtom> mVariable;
-    nsCOMPtr<nsIRDFNode> mValue;
-
-    nsAssignment(nsAtom* aVariable, nsIRDFNode* aValue)
-        : mVariable(aVariable),
-          mValue(aValue)
-        { MOZ_COUNT_CTOR(nsAssignment); }
-
-    nsAssignment(const nsAssignment& aAssignment)
-        : mVariable(aAssignment.mVariable),
-          mValue(aAssignment.mValue)
-        { MOZ_COUNT_CTOR(nsAssignment); }
-
-    ~nsAssignment() { MOZ_COUNT_DTOR(nsAssignment); }
-
-    bool operator==(const nsAssignment& aAssignment) const {
-        return mVariable == aAssignment.mVariable && mValue == aAssignment.mValue; }
-
-    bool operator!=(const nsAssignment& aAssignment) const {
-        return mVariable != aAssignment.mVariable || mValue != aAssignment.mValue; }
-
-    PLHashNumber Hash() const {
-        using mozilla::HashGeneric;
-        return HashGeneric(mVariable.get()) ^ HashGeneric(mValue.get()); }
-};
-
-
-//----------------------------------------------------------------------
-
-/**
- * A collection of value-to-variable assignments that minimizes
- * copying by sharing subsets when possible.
- */
-class nsAssignmentSet {
-public:
-    class ConstIterator;
-    friend class ConstIterator;
-
-protected:
-    class List {
-    public:
-        explicit List(const nsAssignment& aAssignment) : mAssignment(aAssignment) {
-            MOZ_COUNT_CTOR(nsAssignmentSet::List); }
-
-    protected:
-        ~List() {
-            MOZ_COUNT_DTOR(nsAssignmentSet::List);
-            NS_IF_RELEASE(mNext); }
-
-    public:
-
-        int32_t AddRef() { return ++mRefCnt; }
-
-        int32_t Release() {
-            int32_t refcnt = --mRefCnt;
-            if (refcnt == 0) delete this;
-            return refcnt; }
-
-        nsAssignment mAssignment;
-        int32_t mRefCnt;
-        List*   mNext;
-    };
-
-    List* mAssignments;
-
-public:
-    nsAssignmentSet()
-        : mAssignments(nullptr)
-        { MOZ_COUNT_CTOR(nsAssignmentSet); }
-
-    nsAssignmentSet(const nsAssignmentSet& aSet)
-        : mAssignments(aSet.mAssignments) {
-        MOZ_COUNT_CTOR(nsAssignmentSet);
-        NS_IF_ADDREF(mAssignments); }
-
-    nsAssignmentSet& operator=(const nsAssignmentSet& aSet) {
-        NS_IF_RELEASE(mAssignments);
-        mAssignments = aSet.mAssignments;
-        NS_IF_ADDREF(mAssignments);
-        return *this; }
-
-    ~nsAssignmentSet() {
-        MOZ_COUNT_DTOR(nsAssignmentSet);
-        NS_IF_RELEASE(mAssignments); }
-
-public:
-    class ConstIterator {
-    public:
-        explicit ConstIterator(List* aAssignmentList) : mCurrent(aAssignmentList) {
-            NS_IF_ADDREF(mCurrent); }
-
-        ConstIterator(const ConstIterator& aConstIterator)
-            : mCurrent(aConstIterator.mCurrent) {
-            NS_IF_ADDREF(mCurrent); }
-
-        ConstIterator& operator=(const ConstIterator& aConstIterator) {
-            NS_IF_RELEASE(mCurrent);
-            mCurrent = aConstIterator.mCurrent;
-            NS_IF_ADDREF(mCurrent);
-            return *this; }
-
-        ~ConstIterator() { NS_IF_RELEASE(mCurrent); }
-
-        ConstIterator& operator++() {
-            List* next = mCurrent->mNext;
-            NS_RELEASE(mCurrent);
-            mCurrent = next;
-            NS_IF_ADDREF(mCurrent);
-            return *this; }
-
-        ConstIterator operator++(int) {
-            ConstIterator result(*this);
-            List* next = mCurrent->mNext;
-            NS_RELEASE(mCurrent);
-            mCurrent = next;
-            NS_IF_ADDREF(mCurrent);
-            return result; }
-
-        const nsAssignment& operator*() const {
-            return mCurrent->mAssignment; }
-
-        const nsAssignment* operator->() const {
-            return &mCurrent->mAssignment; }
-
-        bool operator==(const ConstIterator& aConstIterator) const {
-            return mCurrent == aConstIterator.mCurrent; }
-
-        bool operator!=(const ConstIterator& aConstIterator) const {
-            return mCurrent != aConstIterator.mCurrent; }
-
-    protected:
-        List* mCurrent;
-    };
-
-    ConstIterator First() const { return ConstIterator(mAssignments); }
-    ConstIterator Last() const { return ConstIterator(nullptr); }
-
-public:
-    /**
-     * Add an assignment to the set
-     * @param aElement the assigment to add
-     * @return NS_OK if all is well, NS_ERROR_OUT_OF_MEMORY if memory
-     *   could not be allocated for the addition.
-     */
-    nsresult Add(const nsAssignment& aElement);
-
-    /**
-     * Determine if the assignment set contains the specified variable
-     * to value assignment.
-     * @param aVariable the variable for which to lookup the binding
-     * @param aValue the value to query
-     * @return true if aVariable is bound to aValue; false otherwise.
-     */
-    bool HasAssignment(nsAtom* aVariable, nsIRDFNode* aValue) const;
-
-    /**
-     * Determine if the assignment set contains the specified assignment
-     * @param aAssignment the assignment to search for
-     * @return true if the set contains the assignment, false otherwise.
-     */
-    bool HasAssignment(const nsAssignment& aAssignment) const {
-        return HasAssignment(aAssignment.mVariable, aAssignment.mValue); }
-
-    /**
-     * Determine whether the assignment set has an assignment for the
-     * specified variable.
-     * @param aVariable the variable to query
-     * @return true if the assignment set has an assignment for the variable,
-     *   false otherwise.
-     */
-    bool HasAssignmentFor(nsAtom* aVariable) const;
-
-    /**
-     * Retrieve the assignment for the specified variable
-     * @param aVariable the variable to query
-     * @param aValue an out parameter that will receive the value assigned
-     *   to the variable, if any.
-     * @return true if the variable has an assignment, false
-     *   if there was no assignment for the variable.
-     */
-    bool GetAssignmentFor(nsAtom* aVariable, nsIRDFNode** aValue) const;
-
-    /**
-     * Count the number of assignments in the set
-     * @return the number of assignments in the set
-     */
-    int32_t Count() const;
-
-    /**
-     * Determine if the set is empty
-     * @return true if the assignment set is empty, false otherwise.
-     */
-    bool IsEmpty() const { return mAssignments == nullptr; }
-
-    bool Equals(const nsAssignmentSet& aSet) const;
-    bool operator==(const nsAssignmentSet& aSet) const { return Equals(aSet); }
-    bool operator!=(const nsAssignmentSet& aSet) const { return !Equals(aSet); }
-};
-
-
-//----------------------------------------------------------------------
-
-/**
- * A collection of variable-to-value bindings, with the memory elements
- * that support those bindings. Essentially, an instantiation is the
- * collection of variables and values assigned to those variables for a single
- * result. For each RDF rule in the rule network, each instantiation is
- * examined and either extended with additional bindings specified by the RDF
- * rule, or removed if the rule doesn't apply (for instance if a node has no
- * children). When an instantiation gets to the last node of the rule network,
- * which is always an nsInstantiationNode, a result is created for it.
- *
- * An instantiation object is typically created by "extending" another
- * instantiation object. That is, using the copy constructor, and
- * adding bindings and support to the instantiation.
- */
-class Instantiation
-{
-public:
-    /**
-     * The variable-to-value bindings
-     */
-    nsAssignmentSet  mAssignments;
-
-    /**
-     * The memory elements that support the bindings.
-     */
-    MemoryElementSet mSupport;
-
-    Instantiation() { MOZ_COUNT_CTOR(Instantiation); }
-
-    Instantiation(const Instantiation& aInstantiation)
-        : mAssignments(aInstantiation.mAssignments),
-          mSupport(aInstantiation.mSupport) {
-        MOZ_COUNT_CTOR(Instantiation); }
-
-    Instantiation& operator=(const Instantiation& aInstantiation) {
-        mAssignments = aInstantiation.mAssignments;
-        mSupport  = aInstantiation.mSupport;
-        return *this; }
-
-    ~Instantiation() { MOZ_COUNT_DTOR(Instantiation); }
-
-    /**
-     * Add the specified variable-to-value assignment to the instantiation's
-     * set of assignments.
-     * @param aVariable the variable to which is being assigned
-     * @param aValue the value that is being assigned
-     * @return NS_OK if no errors, NS_ERROR_OUT_OF_MEMORY if there
-     *   is not enough memory to perform the operation
-     */
-    nsresult AddAssignment(nsAtom* aVariable, nsIRDFNode* aValue) {
-        mAssignments.Add(nsAssignment(aVariable, aValue));
-        return NS_OK; }
-
-    /**
-     * Add a memory element to the set of memory elements that are
-     * supporting the instantiation
-     * @param aMemoryElement the memory element to add to the
-     *   instantiation's set of support
-     * @return NS_OK if no errors occurred, NS_ERROR_OUT_OF_MEMORY
-     *   if there is not enough memory to perform the operation.
-     */
-    nsresult AddSupportingElement(MemoryElement* aMemoryElement) {
-        mSupport.Add(aMemoryElement);
-        return NS_OK; }
-
-    bool Equals(const Instantiation& aInstantiation) const {
-        return mAssignments == aInstantiation.mAssignments; }
-
-    bool operator==(const Instantiation& aInstantiation) const {
-        return Equals(aInstantiation); }
-
-    bool operator!=(const Instantiation& aInstantiation) const {
-        return !Equals(aInstantiation); }
-
-    static PLHashNumber Hash(const void* aKey);
-    static int Compare(const void* aLeft, const void* aRight);
-};
-
-
-//----------------------------------------------------------------------
-
-/**
- * A collection of intantiations
- */
-class InstantiationSet
-{
-public:
-    InstantiationSet();
-    InstantiationSet(const InstantiationSet& aInstantiationSet);
-    InstantiationSet& operator=(const InstantiationSet& aInstantiationSet);
-
-    ~InstantiationSet() {
-        MOZ_COUNT_DTOR(InstantiationSet);
-        Clear(); }
-
-    class ConstIterator;
-    friend class ConstIterator;
-
-    class Iterator;
-    friend class Iterator;
-
-    friend class nsXULTemplateResultSetRDF; // so it can get to the List
-
-protected:
-    class List {
-    public:
-        Instantiation mInstantiation;
-        List*         mNext;
-        List*         mPrev;
-
-        List() { MOZ_COUNT_CTOR(InstantiationSet::List); }
-        ~List() { MOZ_COUNT_DTOR(InstantiationSet::List); }
-    };
-
-    List mHead;
-
-public:
-    class ConstIterator {
-    protected:
-        friend class Iterator; // XXXwaterson so broken.
-        List* mCurrent;
-
-    public:
-        explicit ConstIterator(List* aList) : mCurrent(aList) {}
-
-        ConstIterator(const ConstIterator& aConstIterator)
-            : mCurrent(aConstIterator.mCurrent) {}
-
-        ConstIterator& operator=(const ConstIterator& aConstIterator) {
-            mCurrent = aConstIterator.mCurrent;
-            return *this; }
-
-        ConstIterator& operator++() {
-            mCurrent = mCurrent->mNext;
-            return *this; }
-
-        ConstIterator operator++(int) {
-            ConstIterator result(*this);
-            mCurrent = mCurrent->mNext;
-            return result; }
-
-        ConstIterator& operator--() {
-            mCurrent = mCurrent->mPrev;
-            return *this; }
-
-        ConstIterator operator--(int) {
-            ConstIterator result(*this);
-            mCurrent = mCurrent->mPrev;
-            return result; }
-
-        const Instantiation& operator*() const {
-            return mCurrent->mInstantiation; }
-
-        const Instantiation* operator->() const {
-            return &mCurrent->mInstantiation; }
-
-        bool operator==(const ConstIterator& aConstIterator) const {
-            return mCurrent == aConstIterator.mCurrent; }
-
-        bool operator!=(const ConstIterator& aConstIterator) const {
-            return mCurrent != aConstIterator.mCurrent; }
-    };
-
-    ConstIterator First() const { return ConstIterator(mHead.mNext); }
-    ConstIterator Last() const { return ConstIterator(const_cast<List*>(&mHead)); }
-
-    class Iterator : public ConstIterator {
-    public:
-        explicit Iterator(List* aList) : ConstIterator(aList) {}
-
-        Iterator& operator++() {
-            mCurrent = mCurrent->mNext;
-            return *this; }
-
-        Iterator operator++(int) {
-            Iterator result(*this);
-            mCurrent = mCurrent->mNext;
-            return result; }
-
-        Iterator& operator--() {
-            mCurrent = mCurrent->mPrev;
-            return *this; }
-
-        Iterator operator--(int) {
-            Iterator result(*this);
-            mCurrent = mCurrent->mPrev;
-            return result; }
-
-        Instantiation& operator*() const {
-            return mCurrent->mInstantiation; }
-
-        Instantiation* operator->() const {
-            return &mCurrent->mInstantiation; }
-
-        bool operator==(const ConstIterator& aConstIterator) const {
-            return mCurrent == aConstIterator.mCurrent; }
-
-        bool operator!=(const ConstIterator& aConstIterator) const {
-            return mCurrent != aConstIterator.mCurrent; }
-
-        friend class InstantiationSet;
-    };
-
-    Iterator First() { return Iterator(mHead.mNext); }
-    Iterator Last() { return Iterator(&mHead); }
-
-    bool Empty() const { return First() == Last(); }
-
-    Iterator Append(const Instantiation& aInstantiation) {
-        return Insert(Last(), aInstantiation); }
-
-    Iterator Insert(Iterator aBefore, const Instantiation& aInstantiation);
-
-    Iterator Erase(Iterator aElement);
-
-    void Clear();
-
-    bool HasAssignmentFor(nsAtom* aVariable) const;
-};
-
-//----------------------------------------------------------------------
-
-/**
- * A abstract base class for all nodes in the rule network
- */
-class ReteNode
-{
-public:
-    ReteNode() {}
-    virtual ~ReteNode() {}
-
-    /**
-     * Propagate a set of instantiations "down" through the
-     * network. Each instantiation is a partial set of
-     * variable-to-value assignments, along with the memory elements
-     * that support it.
-     *
-     * The node must evaluate each instantiation, and either 1)
-     * extend it with additional assignments and memory-element
-     * support, or 2) remove it from the set because it is
-     * inconsistent with the constraints that this node applies.
-     *
-     * The node must then pass the resulting instantiation set along
-     * to any of its children in the network. (In other words, the
-     * node must recursively call Propagate() on its children. We
-     * should fix this to make the algorithm interruptable.)
-     *
-     * See TestNode::Propagate for details about instantiation set ownership
-     *
-     * @param aInstantiations the set of instantiations to propagate
-     *   down through the network.
-     * @param aIsUpdate true if updating, false for first generation
-     * @param aTakenInstantiations true if the ownership over aInstantiations
-     *                             has been taken from the caller. If false,
-     *                             the caller owns it.
-     * @return NS_OK if no errors occurred.
-     */
-    virtual nsresult Propagate(InstantiationSet& aInstantiations,
-                               bool aIsUpdate, bool& aTakenInstantiations) = 0;
-};
-
-//----------------------------------------------------------------------
-
-/**
- * A collection of nodes in the rule network
- */
-class ReteNodeSet
-{
-public:
-    ReteNodeSet();
-    ~ReteNodeSet();
-
-    nsresult Add(ReteNode* aNode);
-    nsresult Clear();
-
-    class Iterator;
-
-    class ConstIterator {
-    public:
-        explicit ConstIterator(ReteNode** aNode) : mCurrent(aNode) {}
-
-        ConstIterator(const ConstIterator& aConstIterator)
-            : mCurrent(aConstIterator.mCurrent) {}
-
-        ConstIterator& operator=(const ConstIterator& aConstIterator) {
-            mCurrent = aConstIterator.mCurrent;
-            return *this; }
-
-        ConstIterator& operator++() {
-            ++mCurrent;
-            return *this; }
-
-        ConstIterator operator++(int) {
-            ConstIterator result(*this);
-            ++mCurrent;
-            return result; }
-
-        const ReteNode* operator*() const {
-            return *mCurrent; }
-
-        const ReteNode* operator->() const {
-            return *mCurrent; }
-
-        bool operator==(const ConstIterator& aConstIterator) const {
-            return mCurrent == aConstIterator.mCurrent; }
-
-        bool operator!=(const ConstIterator& aConstIterator) const {
-            return mCurrent != aConstIterator.mCurrent; }
-
-    protected:
-        friend class Iterator; // XXXwaterson this is so wrong!
-        ReteNode** mCurrent;
-    };
-
-    ConstIterator First() const { return ConstIterator(mNodes); }
-    ConstIterator Last() const { return ConstIterator(mNodes + mCount); }
-
-    class Iterator : public ConstIterator {
-    public:
-        explicit Iterator(ReteNode** aNode) : ConstIterator(aNode) {}
-
-        Iterator& operator++() {
-            ++mCurrent;
-            return *this; }
-
-        Iterator operator++(int) {
-            Iterator result(*this);
-            ++mCurrent;
-            return result; }
-
-        ReteNode* operator*() const {
-            return *mCurrent; }
-
-        ReteNode* operator->() const {
-            return *mCurrent; }
-
-        bool operator==(const ConstIterator& aConstIterator) const {
-            return mCurrent == aConstIterator.mCurrent; }
-
-        bool operator!=(const ConstIterator& aConstIterator) const {
-            return mCurrent != aConstIterator.mCurrent; }
-    };
-
-    Iterator First() { return Iterator(mNodes); }
-    Iterator Last() { return Iterator(mNodes + mCount); }
-
-    int32_t Count() const { return mCount; }
-
-protected:
-    ReteNode** mNodes;
-    int32_t mCount;
-    int32_t mCapacity;
-};
-
-//----------------------------------------------------------------------
-
-/**
- * A node that applies a test condition to a set of instantiations.
- *
- * This class provides implementations of Propagate() and Constrain()
- * in terms of one simple operation, FilterInstantiations(). A node
- * that is a "simple test node" in a rule network should derive from
- * this class, and need only implement FilterInstantiations().
- */
-class TestNode : public ReteNode
-{
-public:
-    explicit TestNode(TestNode* aParent);
-
-    /**
-     * Retrieve the test node's parent
-     * @return the test node's parent
-     */
-    TestNode* GetParent() const { return mParent; }
-
-    /**
-     * Calls FilterInstantiations() on the instantiation set, and if
-     * the resulting set isn't empty, propagates the new set down to
-     * each of the test node's children.
-     *
-     * Note that the caller of Propagate is responsible for deleting
-     * aInstantiations if necessary as described below.
-     *
-     * Propagate may be called in update or non-update mode as indicated
-     * by the aIsUpdate argument. Non-update mode is used when initially
-     * generating results, whereas update mode is used when the datasource
-     * changes and new results might be available.
-     *
-     * The last node in a chain of TestNodes is always an nsInstantiationNode.
-     * In non-update mode, this nsInstantiationNode will cache the results
-     * in the query using the SetCachedResults method. The query processor
-     * takes these cached results and creates a nsXULTemplateResultSetRDF
-     * which is the enumeration returned to the template builder. This
-     * nsXULTemplateResultSetRDF owns the instantiations and they will be
-     * deleted when the nsXULTemplateResultSetRDF goes away.
-     *
-     * In update mode, the nsInstantiationNode node will iterate over the
-     * instantiations itself and callback to the builder to update any matches
-     * and generated content. If no instantiations match, then the builder
-     * will never be called.
-     *
-     * Thus, the difference between update and non-update modes is that in
-     * update mode, the results and instantiations have been already handled
-     * whereas in non-update mode they are expected to be returned in an
-     * nsXULTemplateResultSetRDF for further processing by the builder.
-     *
-     * Regardless, aTakenInstantiations will be set to true if the
-     * ownership over aInstantiations has been transferred to a result set.
-     * If set to false, the caller is still responsible for aInstantiations.
-     * aTakenInstantiations will be set properly even if an error occurs.
-     */
-    virtual nsresult Propagate(InstantiationSet& aInstantiations,
-                               bool aIsUpdate, bool& aTakenInstantiations) override;
-
-    /**
-     * This is called by a child node on its parent to allow the
-     * parent's constraints to apply to the set of instantiations.
-     *
-     * A node must iterate through the set of instantiations, and for
-     * each instantiation, either 1) extend the instantiation by
-     * adding variable-to-value assignments and memory element support
-     * for those assignments, or 2) remove the instantiation because
-     * it is inconsistent.
-     *
-     * The node must then pass the resulting set of instantiations up
-     * to its parent (by recursive call; we should make this iterative
-     * & interruptable at some point.)
-     *
-     * @param aInstantiations the set of instantiations that must
-     *   be constrained
-     * @return NS_OK if no errors occurred
-     */
-    virtual nsresult Constrain(InstantiationSet& aInstantiations);
-
-    /**
-     * Given a set of instantiations, filter out any that are
-     * inconsistent with the test node's test, and append
-     * variable-to-value assignments and memory element support for
-     * those which do pass the test node's test.
-     *
-     * @param aInstantiations the set of instantiations to be
-     *        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,
-                                          bool* aCantHandleYet) const = 0;
-    //XXX probably better named "ApplyConstraints" or "Discrminiate" or something
-
-    /**
-     * Add another node as a child of this node.
-     * @param aNode the node to add.
-     * @return NS_OK if no errors occur.
-     */
-    nsresult AddChild(ReteNode* aNode) { return mKids.Add(aNode); }
-
-    /**
-     * Remove all the children of this node
-     * @return NS_OK if no errors occur.
-     */
-    nsresult RemoveAllChildren() { return mKids.Clear(); }
-
-protected:
-    TestNode* mParent;
-    ReteNodeSet mKids;
-};
-
-#endif // nsRuleNetwork_h__
deleted file mode 100644
--- a/dom/xul/templates/nsTemplateMap.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsTemplateMap_h__
-#define nsTemplateMap_h__
-
-#include "PLDHashTable.h"
-#include "nsXULElement.h"
-
-class nsTemplateMap {
-protected:
-    struct Entry : public PLDHashEntryHdr {
-        nsIContent*     mContent;
-        nsIContent*     mTemplate;
-    };
-
-    PLDHashTable mTable;
-
-public:
-    nsTemplateMap() : mTable(PLDHashTable::StubOps(), sizeof(Entry)) { }
-
-    ~nsTemplateMap() { }
-
-    void
-    Put(nsIContent* aContent, nsIContent* aTemplate) {
-        NS_ASSERTION(!mTable.Search(aContent), "aContent already in map");
-
-        auto entry = static_cast<Entry*>(mTable.Add(aContent, mozilla::fallible));
-
-        if (entry) {
-            entry->mContent = aContent;
-            entry->mTemplate = aTemplate;
-        }
-    }
-
-    void
-    Remove(nsIContent* aContent) {
-        mTable.Remove(aContent);
-
-        for (nsIContent* child = aContent->GetFirstChild();
-             child;
-             child = child->GetNextSibling()) {
-            Remove(child);
-        }
-    }
-
-
-    void
-    GetTemplateFor(nsIContent* aContent, nsIContent** aResult) {
-        auto entry = static_cast<Entry*>(mTable.Search(aContent));
-        if (entry)
-            NS_IF_ADDREF(*aResult = entry->mTemplate);
-        else
-            *aResult = nullptr;
-    }
-
-    void
-    Clear() { mTable.Clear(); }
-};
-
-#endif // nsTemplateMap_h__
-
deleted file mode 100644
--- a/dom/xul/templates/nsTemplateMatch.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsTemplateMatch.h"
-#include "nsTemplateRule.h"
-
-// static
-void
-nsTemplateMatch::Destroy(nsTemplateMatch*& aMatch, bool aRemoveResult)
-{
-    if (aRemoveResult && aMatch->mResult)
-        aMatch->mResult->HasBeenRemoved();
-    ::delete aMatch;
-    aMatch = nullptr;
-}
-
-nsresult
-nsTemplateMatch::RuleMatched(nsTemplateQuerySet* aQuerySet,
-                             nsTemplateRule* aRule,
-                             int16_t aRuleIndex,
-                             nsIXULTemplateResult* aResult)
-{
-    // assign the rule index, used to indicate that a match is active, and
-    // so the tree builder can get the right action body to generate
-    mRuleIndex = aRuleIndex;
-
-    nsCOMPtr<nsIDOMNode> rulenode;
-    aRule->GetRuleNode(getter_AddRefs(rulenode));
-    if (rulenode)
-        return aResult->RuleMatched(aQuerySet->mCompiledQuery, rulenode);
-
-    return NS_OK;
-}
deleted file mode 100644
--- a/dom/xul/templates/nsTemplateMatch.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsTemplateMatch_h__
-#define nsTemplateMatch_h__
-
-#include "mozilla/Attributes.h"
-#include "nsIContent.h"
-#include "nsIXULTemplateQueryProcessor.h"
-#include "nsIXULTemplateResult.h"
-#include "nsRuleNetwork.h"
-
-/**
- * A match object, where each match object is associated with one result.
- * There will be one match list for each unique id generated. However, since
- * there are multiple querysets and each may generate results with the same
- * id, they are all chained together in a linked list, ordered in the same
- * order as the respective <queryset> elements they were generated from.
- * A match can be identified by the container and id. The id is retrievable
- * from the result.
- *
- * Only one match per container and id pair is active at a time, but which
- * match is active may change as new results are added or removed. When a
- * match is active, content is generated for that match.
- *
- * Matches are stored and owned by the mMatchToMap hash in the template
- * builder.
- */
-
-class nsTemplateRule;
-class nsTemplateQuerySet;
-
-class nsTemplateMatch {
-private:
-    // Hide so that only Create() and Destroy() can be used to
-    // allocate and deallocate from the heap
-    void* operator new(size_t) CPP_THROW_NEW { MOZ_ASSERT(0); return nullptr; }
-    void operator delete(void*, size_t) { MOZ_ASSERT(0); }
-
-public:
-    nsTemplateMatch(uint16_t aQuerySetPriority,
-                    nsIXULTemplateResult* aResult,
-                    nsIContent* aContainer)
-        : mRuleIndex(-1),
-          mQuerySetPriority(aQuerySetPriority),
-          mContainer(aContainer),
-          mResult(aResult),
-          mNext(nullptr)
-    {
-      MOZ_COUNT_CTOR(nsTemplateMatch);
-    }
-
-    ~nsTemplateMatch()
-    {
-      MOZ_COUNT_DTOR(nsTemplateMatch);
-    }
-
-    static nsTemplateMatch*
-    Create(uint16_t aQuerySetPriority,
-           nsIXULTemplateResult* aResult,
-           nsIContent* aContainer) {
-        return ::new nsTemplateMatch(aQuerySetPriority, aResult, aContainer);
-    }
-
-    static void Destroy(nsTemplateMatch*& aMatch, bool aRemoveResult);
-
-    // return true if the the match is active, and has generated output
-    bool IsActive() {
-        return mRuleIndex >= 0;
-    }
-
-    // indicate that a rule is no longer active, used when a query with a
-    // lower priority has overriden the match
-    void SetInactive() {
-        mRuleIndex = -1;
-    }
-
-    // return matching rule index
-    int16_t RuleIndex() {
-        return mRuleIndex;
-    }
-
-    // return priority of query set
-    uint16_t QuerySetPriority() {
-        return mQuerySetPriority;
-    }
-
-    // return container, not addrefed. May be null.
-    nsIContent* GetContainer() {
-        return mContainer;
-    }
-
-    nsresult RuleMatched(nsTemplateQuerySet* aQuerySet,
-                         nsTemplateRule* aRule,
-                         int16_t aRuleIndex,
-                         nsIXULTemplateResult* aResult);
-
-private:
-
-    /**
-     * The index of the rule that matched, or -1 if the match is not active.
-     */
-    int16_t mRuleIndex;
-
-    /**
-     * The priority of the queryset for this rule
-     */
-    uint16_t mQuerySetPriority;
-
-    /**
-     * The container the content generated for the match is inside.
-     */
-    nsCOMPtr<nsIContent> mContainer;
-
-public:
-
-    /**
-     * The result associated with this match
-     */
-    nsCOMPtr<nsIXULTemplateResult> mResult;
-
-    /**
-     * Matches are stored in a linked list, in priority order. This first
-     * match that has a rule set (mRule) is the active match and generates
-     * content. The next match is owned by the builder, which will delete
-     * template matches when needed.
-     */
-    nsTemplateMatch *mNext;
-
-private:
-
-    nsTemplateMatch(const nsTemplateMatch& aMatch) = delete;
-    void operator=(const nsTemplateMatch& aMatch) = delete;
-};
-
-#endif // nsTemplateMatch_h__
-
deleted file mode 100644
--- a/dom/xul/templates/nsTemplateRule.cpp
+++ /dev/null
@@ -1,422 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsTemplateRule.h"
-#include "nsTemplateMatch.h"
-#include "nsXULContentUtils.h"
-#include "nsUnicharUtils.h"
-#include "nsReadableUtils.h"
-#include "nsICollation.h"
-
-nsTemplateCondition::nsTemplateCondition(nsAtom* aSourceVariable,
-                                         const nsAString& aRelation,
-                                         nsAtom* aTargetVariable,
-                                         bool aIgnoreCase,
-                                         bool aNegate)
-    : mSourceVariable(aSourceVariable),
-      mTargetVariable(aTargetVariable),
-      mIgnoreCase(aIgnoreCase),
-      mNegate(aNegate),
-      mNext(nullptr)
-{
-    SetRelation(aRelation);
-
-    MOZ_COUNT_CTOR(nsTemplateCondition);
-}
-
-nsTemplateCondition::nsTemplateCondition(nsAtom* aSourceVariable,
-                                         const nsAString& aRelation,
-                                         const nsAString& aTargets,
-                                         bool aIgnoreCase,
-                                         bool aNegate,
-                                         bool aIsMultiple)
-    : mSourceVariable(aSourceVariable),
-      mIgnoreCase(aIgnoreCase),
-      mNegate(aNegate),
-      mNext(nullptr)
-{
-    SetRelation(aRelation);
-
-    if (aIsMultiple) {
-        int32_t start = 0, end = 0;
-        while ((end = aTargets.FindChar(',',start)) >= 0) {
-            if (end > start) {
-                mTargetList.AppendElement(Substring(aTargets, start, end - start));
-            }
-            start = end + 1;
-        }
-        if (start < int32_t(aTargets.Length())) {
-            mTargetList.AppendElement(Substring(aTargets, start));
-        }
-    }
-    else {
-        mTargetList.AppendElement(aTargets);
-    }
-
-    MOZ_COUNT_CTOR(nsTemplateCondition);
-}
-
-nsTemplateCondition::nsTemplateCondition(const nsAString& aSource,
-                                         const nsAString& aRelation,
-                                         nsAtom* aTargetVariable,
-                                         bool aIgnoreCase,
-                                         bool aNegate)
-    : mSource(aSource),
-      mTargetVariable(aTargetVariable),
-      mIgnoreCase(aIgnoreCase),
-      mNegate(aNegate),
-      mNext(nullptr)
-{
-    SetRelation(aRelation);
-
-    MOZ_COUNT_CTOR(nsTemplateCondition);
-}
-
-void
-nsTemplateCondition::SetRelation(const nsAString& aRelation)
-{
-    if (aRelation.EqualsLiteral("equals") || aRelation.IsEmpty())
-        mRelation = eEquals;
-    else if (aRelation.EqualsLiteral("less"))
-        mRelation = eLess;
-    else if (aRelation.EqualsLiteral("greater"))
-        mRelation = eGreater;
-    else if (aRelation.EqualsLiteral("before"))
-        mRelation = eBefore;
-    else if (aRelation.EqualsLiteral("after"))
-        mRelation = eAfter;
-    else if (aRelation.EqualsLiteral("startswith"))
-        mRelation = eStartswith;
-    else if (aRelation.EqualsLiteral("endswith"))
-        mRelation = eEndswith;
-    else if (aRelation.EqualsLiteral("contains"))
-        mRelation = eContains;
-    else
-        mRelation = eUnknown;
-}
-
-bool
-nsTemplateCondition::CheckMatch(nsIXULTemplateResult* aResult)
-{
-    bool match = false;
-
-    nsAutoString leftString;
-    if (mSourceVariable)
-      aResult->GetBindingFor(mSourceVariable, leftString);
-    else
-      leftString.Assign(mSource);
-
-    if (mTargetVariable) {
-        nsAutoString rightString;
-        aResult->GetBindingFor(mTargetVariable, rightString);
-
-        match = CheckMatchStrings(leftString, rightString);
-    }
-    else {
-        // iterate over the strings in the target and determine
-        // whether there is a match.
-        uint32_t length = mTargetList.Length();
-        for (uint32_t t = 0; t < length; t++) {
-            match = CheckMatchStrings(leftString, mTargetList[t]);
-
-            // stop once a match is found. In negate mode, stop once a
-            // target does not match.
-            if (match != mNegate) break;
-        }
-    }
-
-    return match;
-}
-
-
-bool
-nsTemplateCondition::CheckMatchStrings(const nsAString& aLeftString,
-                                       const nsAString& aRightString)
-{
-    bool match = false;
-
-    if (aRightString.IsEmpty()) {
-        if ((mRelation == eEquals) && aLeftString.IsEmpty())
-            match = true;
-    }
-    else {
-        switch (mRelation) {
-            case eEquals:
-                if (mIgnoreCase)
-                    match = aLeftString.Equals(aRightString,
-                                               nsCaseInsensitiveStringComparator());
-                else
-                    match = aLeftString.Equals(aRightString);
-                break;
-
-            case eLess:
-            case eGreater:
-            {
-                // non-numbers always compare false
-                nsresult err;
-                int32_t leftint = PromiseFlatString(aLeftString).ToInteger(&err);
-                if (NS_SUCCEEDED(err)) {
-                    int32_t rightint = PromiseFlatString(aRightString).ToInteger(&err);
-                    if (NS_SUCCEEDED(err)) {
-                        match = (mRelation == eLess) ? (leftint < rightint) :
-                                                       (leftint > rightint);
-                    }
-                }
-
-                break;
-            }
-
-            case eBefore:
-            {
-                nsICollation* collation = nsXULContentUtils::GetCollation();
-                if (collation) {
-                    int32_t sortOrder;
-                    collation->CompareString((mIgnoreCase ?
-                                              static_cast<int32_t>(nsICollation::kCollationCaseInSensitive) :
-                                              static_cast<int32_t>(nsICollation::kCollationCaseSensitive)),
-                                              aLeftString,
-                                              aRightString,
-                                              &sortOrder);
-                    match = (sortOrder < 0);
-                }
-                else if (mIgnoreCase) {
-                    match = (Compare(aLeftString, aRightString,
-                                     nsCaseInsensitiveStringComparator()) < 0);
-                }
-                else {
-                    match = (Compare(aLeftString, aRightString) < 0);
-                }
-                break;
-            }
-
-            case eAfter:
-            {
-                nsICollation* collation = nsXULContentUtils::GetCollation();
-                if (collation) {
-                    int32_t sortOrder;
-                    collation->CompareString((mIgnoreCase ?
-                                              static_cast<int32_t>(nsICollation::kCollationCaseInSensitive) :
-                                              static_cast<int32_t>(nsICollation::kCollationCaseSensitive)),
-                                              aLeftString,
-                                              aRightString,
-                                              &sortOrder);
-                    match = (sortOrder > 0);
-                }
-                else if (mIgnoreCase) {
-                    match = (Compare(aLeftString, aRightString,
-                                     nsCaseInsensitiveStringComparator()) > 0);
-                }
-                else {
-                    match = (Compare(aLeftString, aRightString) > 0);
-                }
-                break;
-            }
-
-            case eStartswith:
-                if (mIgnoreCase)
-                    match = (StringBeginsWith(aLeftString, aRightString,
-                                              nsCaseInsensitive