LCOV - code coverage report
Current view: top level - layout/style - nsCSSAnonBoxes.h (source / functions) Hit Total Coverage
Test: output.info Lines: 8 8 100.0 %
Date: 2017-07-14 16:53:18 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       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             : /* atom list for CSS anonymous boxes */
       7             : 
       8             : #ifndef nsCSSAnonBoxes_h___
       9             : #define nsCSSAnonBoxes_h___
      10             : 
      11             : #include "nsIAtom.h"
      12             : 
      13             : // Empty class derived from nsIAtom so that function signatures can
      14             : // require an atom from this atom list.
      15             : class nsICSSAnonBoxPseudo : public nsIAtom {};
      16             : 
      17             : class nsCSSAnonBoxes {
      18             : public:
      19             : 
      20             :   static void AddRefAtoms();
      21             : 
      22             :   static bool IsAnonBox(nsIAtom *aAtom);
      23             : #ifdef MOZ_XUL
      24             :   static bool IsTreePseudoElement(nsIAtom* aPseudo);
      25             : #endif
      26        4109 :   static bool IsNonElement(nsIAtom* aPseudo)
      27             :   {
      28        7609 :     return aPseudo == mozText || aPseudo == oofPlaceholder ||
      29        7609 :            aPseudo == firstLetterContinuation;
      30             :   }
      31             : 
      32             : #define CSS_ANON_BOX(_name, _value, _skips_fixup) static nsICSSAnonBoxPseudo* _name;
      33             : #include "nsCSSAnonBoxList.h"
      34             : #undef CSS_ANON_BOX
      35             : 
      36             :   typedef uint8_t NonInheritingBase;
      37             :   enum class NonInheriting : NonInheritingBase {
      38             : #define CSS_ANON_BOX(_name, _value, _skips_fixup) /* nothing */
      39             : #define CSS_NON_INHERITING_ANON_BOX(_name, _value) _name,
      40             : #include "nsCSSAnonBoxList.h"
      41             : #undef CSS_NON_INHERITING_ANON_BOX
      42             : #undef CSS_ANON_BOX
      43             :     _Count
      44             :   };
      45             : 
      46             :   // Be careful using this: if we have a lot of non-inheriting anon box types it
      47             :   // might not be very fast.  We may want to think of ways to handle that
      48             :   // (e.g. by moving to an enum instead of an atom, like we did for
      49             :   // pseudo-elements, or by adding a new value of the pseudo-element enum for
      50             :   // non-inheriting anon boxes or something).
      51        1442 :   static bool IsNonInheritingAnonBox(nsIAtom* aPseudo)
      52             :   {
      53             :     return
      54             : #define CSS_ANON_BOX(_name, _value, _skips_fixup) /* nothing */
      55             : #define CSS_NON_INHERITING_ANON_BOX(_name, _value) _name == aPseudo ||
      56             : #include "nsCSSAnonBoxList.h"
      57             : #undef CSS_NON_INHERITING_ANON_BOX
      58             : #undef CSS_ANON_BOX
      59        1442 :       false;
      60             :   }
      61             : 
      62             :   // Returns whether the given anonymous box skips parent display-based style
      63             :   // fixups.  Must only be called with an inheriting anonymous box.  (All
      64             :   // non-inheriting anonymous boxes skip this fixup, since it doesn't make
      65             :   // sense to perform the fixup with no inherited styles.)
      66         229 :   static bool AnonBoxSkipsParentDisplayBasedStyleFixup(nsIAtom* aPseudo)
      67             :   {
      68         229 :     MOZ_ASSERT(!IsNonInheritingAnonBox(aPseudo),
      69             :                "only call this for inheriting anonymous boxes");
      70             :     return
      71             : #define CSS_ANON_BOX(name_, value_, skips_fixup_) \
      72             :       (skips_fixup_ && name_ == aPseudo) ||
      73             : #define CSS_NON_INHERITING_ANON_BOX(_name, _value) /* nothing */
      74             : #include "nsCSSAnonBoxList.h"
      75             : #undef CSS_NON_INHERITING_ANON_BOX
      76             : #undef CSS_ANON_BOX
      77         229 :       false;
      78             :   }
      79             : 
      80             :   // Get the NonInheriting type for a given pseudo tag.  The pseudo tag must
      81             :   // test true for IsNonInheritingAnonBox.
      82             :   static NonInheriting NonInheritingTypeForPseudoTag(nsIAtom* aPseudo);
      83             : 
      84             :   // Get the atom for a given non-inheriting anon box type.  aBoxType must be <
      85             :   // NonInheriting::_Count.
      86             :   static nsIAtom* GetNonInheritingPseudoAtom(NonInheriting aBoxType);
      87             : };
      88             : 
      89             : #endif /* nsCSSAnonBoxes_h___ */

Generated by: LCOV version 1.13