Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsIServiceManager.h" |
michael@0 | 7 | #include "nsRDFCID.h" |
michael@0 | 8 | #include "nsIRDFService.h" |
michael@0 | 9 | #include "nsString.h" |
michael@0 | 10 | #include "nsXULTemplateResultStorage.h" |
michael@0 | 11 | |
michael@0 | 12 | NS_IMPL_ISUPPORTS(nsXULTemplateResultStorage, nsIXULTemplateResult) |
michael@0 | 13 | |
michael@0 | 14 | nsXULTemplateResultStorage::nsXULTemplateResultStorage(nsXULTemplateResultSetStorage* aResultSet) |
michael@0 | 15 | { |
michael@0 | 16 | static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); |
michael@0 | 17 | nsCOMPtr<nsIRDFService> rdfService = do_GetService(kRDFServiceCID); |
michael@0 | 18 | rdfService->GetAnonymousResource(getter_AddRefs(mNode)); |
michael@0 | 19 | mResultSet = aResultSet; |
michael@0 | 20 | if (aResultSet) { |
michael@0 | 21 | mResultSet->FillColumnValues(mValues); |
michael@0 | 22 | } |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | NS_IMETHODIMP |
michael@0 | 26 | nsXULTemplateResultStorage::GetIsContainer(bool* aIsContainer) |
michael@0 | 27 | { |
michael@0 | 28 | *aIsContainer = false; |
michael@0 | 29 | return NS_OK; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | NS_IMETHODIMP |
michael@0 | 33 | nsXULTemplateResultStorage::GetIsEmpty(bool* aIsEmpty) |
michael@0 | 34 | { |
michael@0 | 35 | *aIsEmpty = true; |
michael@0 | 36 | return NS_OK; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | NS_IMETHODIMP |
michael@0 | 40 | nsXULTemplateResultStorage::GetMayProcessChildren(bool* aMayProcessChildren) |
michael@0 | 41 | { |
michael@0 | 42 | *aMayProcessChildren = false; |
michael@0 | 43 | return NS_OK; |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | NS_IMETHODIMP |
michael@0 | 47 | nsXULTemplateResultStorage::GetId(nsAString& aId) |
michael@0 | 48 | { |
michael@0 | 49 | const char* uri = nullptr; |
michael@0 | 50 | mNode->GetValueConst(&uri); |
michael@0 | 51 | |
michael@0 | 52 | aId.Assign(NS_ConvertUTF8toUTF16(uri)); |
michael@0 | 53 | |
michael@0 | 54 | return NS_OK; |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | NS_IMETHODIMP |
michael@0 | 58 | nsXULTemplateResultStorage::GetResource(nsIRDFResource** aResource) |
michael@0 | 59 | { |
michael@0 | 60 | *aResource = mNode; |
michael@0 | 61 | NS_IF_ADDREF(*aResource); |
michael@0 | 62 | return NS_OK; |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | NS_IMETHODIMP |
michael@0 | 66 | nsXULTemplateResultStorage::GetType(nsAString& aType) |
michael@0 | 67 | { |
michael@0 | 68 | aType.Truncate(); |
michael@0 | 69 | return NS_OK; |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | |
michael@0 | 73 | NS_IMETHODIMP |
michael@0 | 74 | nsXULTemplateResultStorage::GetBindingFor(nsIAtom* aVar, nsAString& aValue) |
michael@0 | 75 | { |
michael@0 | 76 | NS_ENSURE_ARG_POINTER(aVar); |
michael@0 | 77 | |
michael@0 | 78 | aValue.Truncate(); |
michael@0 | 79 | if (!mResultSet) { |
michael@0 | 80 | return NS_OK; |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | int32_t idx = mResultSet->GetColumnIndex(aVar); |
michael@0 | 84 | if (idx < 0) { |
michael@0 | 85 | return NS_OK; |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | nsIVariant * value = mValues[idx]; |
michael@0 | 89 | if (value) { |
michael@0 | 90 | value->GetAsAString(aValue); |
michael@0 | 91 | } |
michael@0 | 92 | return NS_OK; |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | NS_IMETHODIMP |
michael@0 | 96 | nsXULTemplateResultStorage::GetBindingObjectFor(nsIAtom* aVar, nsISupports** aValue) |
michael@0 | 97 | { |
michael@0 | 98 | NS_ENSURE_ARG_POINTER(aVar); |
michael@0 | 99 | |
michael@0 | 100 | if (mResultSet) { |
michael@0 | 101 | int32_t idx = mResultSet->GetColumnIndex(aVar); |
michael@0 | 102 | if (idx >= 0) { |
michael@0 | 103 | *aValue = mValues[idx]; |
michael@0 | 104 | NS_IF_ADDREF(*aValue); |
michael@0 | 105 | return NS_OK; |
michael@0 | 106 | } |
michael@0 | 107 | } |
michael@0 | 108 | *aValue = nullptr; |
michael@0 | 109 | return NS_OK; |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | NS_IMETHODIMP |
michael@0 | 113 | nsXULTemplateResultStorage::RuleMatched(nsISupports* aQuery, nsIDOMNode* aRuleNode) |
michael@0 | 114 | { |
michael@0 | 115 | return NS_OK; |
michael@0 | 116 | } |
michael@0 | 117 | |
michael@0 | 118 | NS_IMETHODIMP |
michael@0 | 119 | nsXULTemplateResultStorage::HasBeenRemoved() |
michael@0 | 120 | { |
michael@0 | 121 | return NS_OK; |
michael@0 | 122 | } |