content/xul/templates/src/nsRDFConInstanceTestNode.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef nsRDFConInstanceTestNode_h__
     7 #define nsRDFConInstanceTestNode_h__
     9 #include "mozilla/Attributes.h"
    10 #include "nscore.h"
    11 #include "nsRDFTestNode.h"
    12 #include "nsIRDFResource.h"
    13 #include "nsIRDFDataSource.h"
    14 #include "nsXULTemplateQueryProcessorRDF.h"
    16 /**
    17  * Rule network node that tests if a resource is an RDF container, or
    18  * uses multi-attributes to ``contain'' other elements.
    19  */
    20 class nsRDFConInstanceTestNode : public nsRDFTestNode
    21 {
    22 public:
    23     enum Test { eFalse, eTrue, eDontCare };
    25     nsRDFConInstanceTestNode(TestNode* aParent,
    26                              nsXULTemplateQueryProcessorRDF* aProcessor,
    27                              nsIAtom* aContainerVariable,
    28                              Test aContainer,
    29                              Test aEmpty);
    31     virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations,
    32                                           bool* aCantHandleYet) const MOZ_OVERRIDE;
    34     virtual bool
    35     CanPropagate(nsIRDFResource* aSource,
    36                  nsIRDFResource* aProperty,
    37                  nsIRDFNode* aTarget,
    38                  Instantiation& aInitialBindings) const MOZ_OVERRIDE;
    40     virtual void
    41     Retract(nsIRDFResource* aSource,
    42             nsIRDFResource* aProperty,
    43             nsIRDFNode* aTarget) const MOZ_OVERRIDE;
    46     class Element : public MemoryElement {
    47     public:
    48         Element(nsIRDFResource* aContainer,
    49                 Test aContainerTest,
    50                 Test aEmptyTest)
    51             : mContainer(aContainer),
    52               mContainerTest(aContainerTest),
    53               mEmptyTest(aEmptyTest) {
    54             MOZ_COUNT_CTOR(nsRDFConInstanceTestNode::Element); }
    56         virtual ~Element() { MOZ_COUNT_DTOR(nsRDFConInstanceTestNode::Element); }
    58         virtual const char* Type() const MOZ_OVERRIDE {
    59             return "nsRDFConInstanceTestNode::Element"; }
    61         virtual PLHashNumber Hash() const MOZ_OVERRIDE {
    62             return mozilla::HashGeneric(mContainerTest, mEmptyTest, mContainer.get());
    63         }
    65         virtual bool Equals(const MemoryElement& aElement) const MOZ_OVERRIDE {
    66             if (aElement.Type() == Type()) {
    67                 const Element& element = static_cast<const Element&>(aElement);
    68                 return mContainer == element.mContainer
    69                     && mContainerTest == element.mContainerTest
    70                     && mEmptyTest == element.mEmptyTest;
    71             }
    72             return false; }
    74     protected:
    75         nsCOMPtr<nsIRDFResource> mContainer;
    76         Test mContainerTest;
    77         Test mEmptyTest;
    78     };
    80 protected:
    81     nsXULTemplateQueryProcessorRDF* mProcessor;
    82     nsCOMPtr<nsIAtom> mContainerVariable;
    83     Test mContainer;
    84     Test mEmpty;
    85 };
    87 #endif // nsRDFConInstanceTestNode_h__

mercurial