Files
palemoon27/dom/xul/templates/nsContentTestNode.cpp
T
roytam1 21cd830e68 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 586587 - support kHTMLMime in the Windows clipboard as CF_HTML. r=jimm (6af5a0d7fa)
- Bug 1159604: Use a fallible allocation in nsClipboard::GetGlobalData. r=bbondy (c9645301a4)
- Bug 1048624 - Cleanup and refactor the media crashtest manifests and re-enable some disabled tests that now pass. (d712e08056)
- crashtest for bug 1020370 r=padenot (c0900de1df)
- crashtest for bug 1206362 r=padenot (07ace6a42f)
- Bug 1207546 - Integrate WebRTC with audio channels, r=roc (0ecafba529)
- Bug 1219478: Replace PRLogModuleInfo usage with LazyLogModule in dom folders except media.r=amerchesini (2e67bd7308)
- Bug 1198422 - CSP: Allow nonce to load if default-src is not specified in second policy (r=dveditz) (8a8bca1eb3)
- Bug 1187152 (part 1) - Replace nsBaseHashtable::Enumerate() calls in modules/ with iterators. r=mwu. (85cea6dce7)
- Bug 1187152 (part 2) - Replace nsBaseHashtable::Enumerate() calls in modules/ with iterators. r=froydnj. (e909442934)
- Bug 1187152 (part 3) - Replace nsBaseHashtable::Enumerate() calls in modules/ with iterators. r=froydnj. (48c78d75e6)
2023-03-23 10:03:31 +08:00

91 lines
2.7 KiB
C++

/* -*- 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 "nsIAtom.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,
nsIAtom* 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;
}