content/base/src/DocumentFragment.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  * vim: sw=2 ts=2 et :
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef mozilla_dom_DocumentFragment_h__
     8 #define mozilla_dom_DocumentFragment_h__
    10 #include "mozilla/Attributes.h"
    11 #include "mozilla/dom/FragmentOrElement.h"
    12 #include "nsIDOMDocumentFragment.h"
    14 class nsINodeInfo;
    15 class nsIAtom;
    16 class nsAString;
    17 class nsIDocument;
    18 class nsIContent;
    20 namespace mozilla {
    21 namespace dom {
    23 class Element;
    25 class DocumentFragment : public FragmentOrElement,
    26                          public nsIDOMDocumentFragment
    27 {
    28 private:
    29   void Init()
    30   {
    31     NS_ABORT_IF_FALSE(mNodeInfo->NodeType() ==
    32                       nsIDOMNode::DOCUMENT_FRAGMENT_NODE &&
    33                       mNodeInfo->Equals(nsGkAtoms::documentFragmentNodeName,
    34                                         kNameSpaceID_None),
    35                       "Bad NodeType in aNodeInfo");
    36   }
    38 public:
    39   using FragmentOrElement::GetFirstChild;
    40   using nsINode::QuerySelector;
    41   using nsINode::QuerySelectorAll;
    42   // Make sure bindings can see our superclass' protected GetElementById method.
    43   using nsINode::GetElementById;
    45   // nsISupports
    46   NS_DECL_ISUPPORTS_INHERITED
    48   // interface nsIDOMNode
    49   NS_FORWARD_NSIDOMNODE_TO_NSINODE
    51   // interface nsIDOMDocumentFragment
    52   NS_DECL_NSIDOMDOCUMENTFRAGMENT
    54   DocumentFragment(already_AddRefed<nsINodeInfo>& aNodeInfo)
    55     : FragmentOrElement(aNodeInfo), mHost(nullptr)
    56   {
    57     Init();
    58   }
    60   DocumentFragment(nsNodeInfoManager* aNodeInfoManager)
    61     : FragmentOrElement(aNodeInfoManager->GetNodeInfo(
    62                                             nsGkAtoms::documentFragmentNodeName,
    63                                             nullptr, kNameSpaceID_None,
    64                                             nsIDOMNode::DOCUMENT_FRAGMENT_NODE)),
    65       mHost(nullptr)
    66   {
    67     Init();
    68   }
    70   virtual ~DocumentFragment()
    71   {
    72   }
    74   virtual JSObject* WrapNode(JSContext *aCx) MOZ_OVERRIDE;
    76   // nsIContent
    77   nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
    78                    const nsAString& aValue, bool aNotify)
    79   {
    80     return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify);
    81   }
    82   virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
    83                            nsIAtom* aPrefix, const nsAString& aValue,
    84                            bool aNotify) MOZ_OVERRIDE
    85   {
    86     return NS_OK;
    87   }
    88   virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, 
    89                              bool aNotify) MOZ_OVERRIDE
    90   {
    91     return NS_OK;
    92   }
    93   virtual const nsAttrName* GetAttrNameAt(uint32_t aIndex) const MOZ_OVERRIDE
    94   {
    95     return nullptr;
    96   }
    97   virtual uint32_t GetAttrCount() const MOZ_OVERRIDE
    98   {
    99     return 0;
   100   }
   102   virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE;
   104   virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; }
   106   virtual nsIAtom* DoGetID() const MOZ_OVERRIDE;
   107   virtual nsIAtom *GetIDAttributeName() const MOZ_OVERRIDE;
   109   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
   110                               nsIContent* aBindingParent,
   111                               bool aCompileEventHandlers) MOZ_OVERRIDE
   112   {
   113     NS_ASSERTION(false, "Trying to bind a fragment to a tree");
   114     return NS_ERROR_NOT_IMPLEMENTED;
   115   }
   117   virtual void UnbindFromTree(bool aDeep, bool aNullParent) MOZ_OVERRIDE
   118   {
   119     NS_ASSERTION(false, "Trying to unbind a fragment from a tree");
   120     return;
   121   }
   123   virtual Element* GetNameSpaceElement()
   124   {
   125     return nullptr;
   126   }
   128   nsIContent* GetHost() const
   129   {
   130     return mHost;
   131   }
   133   void SetHost(nsIContent* aHost)
   134   {
   135     mHost = aHost;
   136   }
   138   static already_AddRefed<DocumentFragment>
   139   Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
   141 #ifdef DEBUG
   142   virtual void List(FILE* out, int32_t aIndent) const MOZ_OVERRIDE;
   143   virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const MOZ_OVERRIDE;
   144 #endif
   146 protected:
   147   nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
   148   nsIContent* mHost; // Weak
   149 };
   151 } // namespace dom
   152 } // namespace mozilla
   155 #endif // mozilla_dom_DocumentFragment_h__

mercurial