summaryrefslogtreecommitdiffstats
path: root/dom/xul/templates/nsXULTemplateResultStorage.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/xul/templates/nsXULTemplateResultStorage.cpp
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/xul/templates/nsXULTemplateResultStorage.cpp')
-rw-r--r--dom/xul/templates/nsXULTemplateResultStorage.cpp126
1 files changed, 126 insertions, 0 deletions
diff --git a/dom/xul/templates/nsXULTemplateResultStorage.cpp b/dom/xul/templates/nsXULTemplateResultStorage.cpp
new file mode 100644
index 000000000..b840fc2c7
--- /dev/null
+++ b/dom/xul/templates/nsXULTemplateResultStorage.cpp
@@ -0,0 +1,126 @@
+/* -*- 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 "nsIServiceManager.h"
+#include "nsRDFCID.h"
+#include "nsIRDFService.h"
+#include "nsString.h"
+#include "nsXULTemplateResultStorage.h"
+
+NS_IMPL_ISUPPORTS(nsXULTemplateResultStorage, nsIXULTemplateResult)
+
+nsXULTemplateResultStorage::nsXULTemplateResultStorage(nsXULTemplateResultSetStorage* aResultSet)
+{
+ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
+ nsCOMPtr<nsIRDFService> rdfService = do_GetService(kRDFServiceCID);
+ rdfService->GetAnonymousResource(getter_AddRefs(mNode));
+ mResultSet = aResultSet;
+ if (aResultSet) {
+ mResultSet->FillColumnValues(mValues);
+ }
+}
+
+nsXULTemplateResultStorage::~nsXULTemplateResultStorage()
+{
+}
+
+NS_IMETHODIMP
+nsXULTemplateResultStorage::GetIsContainer(bool* aIsContainer)
+{
+ *aIsContainer = false;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsXULTemplateResultStorage::GetIsEmpty(bool* aIsEmpty)
+{
+ *aIsEmpty = true;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsXULTemplateResultStorage::GetMayProcessChildren(bool* aMayProcessChildren)
+{
+ *aMayProcessChildren = false;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsXULTemplateResultStorage::GetId(nsAString& aId)
+{
+ const char* uri = nullptr;
+ mNode->GetValueConst(&uri);
+
+ aId.Assign(NS_ConvertUTF8toUTF16(uri));
+
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsXULTemplateResultStorage::GetResource(nsIRDFResource** aResource)
+{
+ *aResource = mNode;
+ NS_IF_ADDREF(*aResource);
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsXULTemplateResultStorage::GetType(nsAString& aType)
+{
+ aType.Truncate();
+ return NS_OK;
+}
+
+
+NS_IMETHODIMP
+nsXULTemplateResultStorage::GetBindingFor(nsIAtom* aVar, nsAString& aValue)
+{
+ NS_ENSURE_ARG_POINTER(aVar);
+
+ aValue.Truncate();
+ if (!mResultSet) {
+ return NS_OK;
+ }
+
+ int32_t idx = mResultSet->GetColumnIndex(aVar);
+ if (idx < 0) {
+ return NS_OK;
+ }
+
+ nsIVariant * value = mValues[idx];
+ if (value) {
+ value->GetAsAString(aValue);
+ }
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsXULTemplateResultStorage::GetBindingObjectFor(nsIAtom* aVar, nsISupports** aValue)
+{
+ NS_ENSURE_ARG_POINTER(aVar);
+
+ if (mResultSet) {
+ int32_t idx = mResultSet->GetColumnIndex(aVar);
+ if (idx >= 0) {
+ *aValue = mValues[idx];
+ NS_IF_ADDREF(*aValue);
+ return NS_OK;
+ }
+ }
+ *aValue = nullptr;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsXULTemplateResultStorage::RuleMatched(nsISupports* aQuery, nsIDOMNode* aRuleNode)
+{
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsXULTemplateResultStorage::HasBeenRemoved()
+{
+ return NS_OK;
+}