dom/xslt/xpath/nsXPathResult.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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 #ifndef nsXPathResult_h__
michael@0 7 #define nsXPathResult_h__
michael@0 8
michael@0 9 #include "txExprResult.h"
michael@0 10 #include "nsIDOMXPathResult.h"
michael@0 11 #include "nsStubMutationObserver.h"
michael@0 12 #include "nsCOMPtr.h"
michael@0 13 #include "nsCOMArray.h"
michael@0 14 #include "nsWeakPtr.h"
michael@0 15 #include "nsCycleCollectionParticipant.h"
michael@0 16 #include "mozilla/Attributes.h"
michael@0 17
michael@0 18 class nsIDocument;
michael@0 19
michael@0 20 // {662f2c9a-c7cd-4cab-9349-e733df5a838c}
michael@0 21 #define NS_IXPATHRESULT_IID \
michael@0 22 { 0x662f2c9a, 0xc7cd, 0x4cab, {0x93, 0x49, 0xe7, 0x33, 0xdf, 0x5a, 0x83, 0x8c }}
michael@0 23
michael@0 24 class nsIXPathResult : public nsISupports
michael@0 25 {
michael@0 26 public:
michael@0 27 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IXPATHRESULT_IID)
michael@0 28 virtual nsresult SetExprResult(txAExprResult *aExprResult,
michael@0 29 uint16_t aResultType,
michael@0 30 nsINode* aContextNode) = 0;
michael@0 31 virtual nsresult GetExprResult(txAExprResult **aExprResult) = 0;
michael@0 32 virtual nsresult Clone(nsIXPathResult **aResult) = 0;
michael@0 33 };
michael@0 34
michael@0 35 NS_DEFINE_STATIC_IID_ACCESSOR(nsIXPathResult, NS_IXPATHRESULT_IID)
michael@0 36
michael@0 37 /**
michael@0 38 * A class for evaluating an XPath expression string
michael@0 39 */
michael@0 40 class nsXPathResult MOZ_FINAL : public nsIDOMXPathResult,
michael@0 41 public nsStubMutationObserver,
michael@0 42 public nsIXPathResult
michael@0 43 {
michael@0 44 public:
michael@0 45 nsXPathResult();
michael@0 46 nsXPathResult(const nsXPathResult &aResult);
michael@0 47 ~nsXPathResult();
michael@0 48
michael@0 49 // nsISupports interface
michael@0 50 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
michael@0 51 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsXPathResult, nsIDOMXPathResult)
michael@0 52
michael@0 53 // nsIDOMXPathResult interface
michael@0 54 NS_DECL_NSIDOMXPATHRESULT
michael@0 55
michael@0 56 // nsIMutationObserver interface
michael@0 57 NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
michael@0 58 NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
michael@0 59 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
michael@0 60 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
michael@0 61 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
michael@0 62 NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
michael@0 63
michael@0 64 // nsIXPathResult interface
michael@0 65 nsresult SetExprResult(txAExprResult *aExprResult, uint16_t aResultType,
michael@0 66 nsINode* aContextNode) MOZ_OVERRIDE;
michael@0 67 nsresult GetExprResult(txAExprResult **aExprResult) MOZ_OVERRIDE;
michael@0 68 nsresult Clone(nsIXPathResult **aResult) MOZ_OVERRIDE;
michael@0 69 void RemoveObserver();
michael@0 70 private:
michael@0 71 static bool isSnapshot(uint16_t aResultType)
michael@0 72 {
michael@0 73 return aResultType == UNORDERED_NODE_SNAPSHOT_TYPE ||
michael@0 74 aResultType == ORDERED_NODE_SNAPSHOT_TYPE;
michael@0 75 }
michael@0 76 static bool isIterator(uint16_t aResultType)
michael@0 77 {
michael@0 78 return aResultType == UNORDERED_NODE_ITERATOR_TYPE ||
michael@0 79 aResultType == ORDERED_NODE_ITERATOR_TYPE;
michael@0 80 }
michael@0 81 static bool isNode(uint16_t aResultType)
michael@0 82 {
michael@0 83 return aResultType == FIRST_ORDERED_NODE_TYPE ||
michael@0 84 aResultType == ANY_UNORDERED_NODE_TYPE;
michael@0 85 }
michael@0 86 bool isSnapshot() const
michael@0 87 {
michael@0 88 return isSnapshot(mResultType);
michael@0 89 }
michael@0 90 bool isIterator() const
michael@0 91 {
michael@0 92 return isIterator(mResultType);
michael@0 93 }
michael@0 94 bool isNode() const
michael@0 95 {
michael@0 96 return isNode(mResultType);
michael@0 97 }
michael@0 98
michael@0 99 void Invalidate(const nsIContent* aChangeRoot);
michael@0 100
michael@0 101 nsRefPtr<txAExprResult> mResult;
michael@0 102 nsCOMArray<nsIDOMNode> mResultNodes;
michael@0 103 nsCOMPtr<nsIDocument> mDocument;
michael@0 104 uint32_t mCurrentPos;
michael@0 105 uint16_t mResultType;
michael@0 106 nsWeakPtr mContextNode;
michael@0 107 bool mInvalidIteratorState;
michael@0 108 bool mBooleanResult;
michael@0 109 double mNumberResult;
michael@0 110 nsString mStringResult;
michael@0 111 };
michael@0 112
michael@0 113 #endif

mercurial