LCOV - code coverage report
Current view: top level - dom/xul/templates - nsTemplateMap.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 23 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/. */
       5             : 
       6             : #ifndef nsTemplateMap_h__
       7             : #define nsTemplateMap_h__
       8             : 
       9             : #include "PLDHashTable.h"
      10             : #include "nsXULElement.h"
      11             : 
      12             : class nsTemplateMap {
      13             : protected:
      14             :     struct Entry : public PLDHashEntryHdr {
      15             :         nsIContent*     mContent;
      16             :         nsIContent*     mTemplate;
      17             :     };
      18             : 
      19             :     PLDHashTable mTable;
      20             : 
      21             : public:
      22           0 :     nsTemplateMap() : mTable(PLDHashTable::StubOps(), sizeof(Entry)) { }
      23             : 
      24           0 :     ~nsTemplateMap() { }
      25             : 
      26             :     void
      27           0 :     Put(nsIContent* aContent, nsIContent* aTemplate) {
      28           0 :         NS_ASSERTION(!mTable.Search(aContent), "aContent already in map");
      29             : 
      30           0 :         auto entry = static_cast<Entry*>(mTable.Add(aContent, mozilla::fallible));
      31             : 
      32           0 :         if (entry) {
      33           0 :             entry->mContent = aContent;
      34           0 :             entry->mTemplate = aTemplate;
      35             :         }
      36           0 :     }
      37             : 
      38             :     void
      39           0 :     Remove(nsIContent* aContent) {
      40           0 :         mTable.Remove(aContent);
      41             : 
      42           0 :         for (nsIContent* child = aContent->GetFirstChild();
      43           0 :              child;
      44           0 :              child = child->GetNextSibling()) {
      45           0 :             Remove(child);
      46             :         }
      47           0 :     }
      48             : 
      49             : 
      50             :     void
      51           0 :     GetTemplateFor(nsIContent* aContent, nsIContent** aResult) {
      52           0 :         auto entry = static_cast<Entry*>(mTable.Search(aContent));
      53           0 :         if (entry)
      54           0 :             NS_IF_ADDREF(*aResult = entry->mTemplate);
      55             :         else
      56           0 :             *aResult = nullptr;
      57           0 :     }
      58             : 
      59             :     void
      60           0 :     Clear() { mTable.Clear(); }
      61             : };
      62             : 
      63             : #endif // nsTemplateMap_h__
      64             : 

Generated by: LCOV version 1.13