LCOV - code coverage report
Current view: top level - layout/base - nsStyleChangeList.h (source / functions) Hit Total Coverage
Test: output.info Lines: 5 11 45.5 %
Date: 2017-07-14 16:53:18 Functions: 5 6 83.3 %
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             : /*
       7             :  * a list of the recomputation that needs to be done in response to a
       8             :  * style change
       9             :  */
      10             : 
      11             : #ifndef nsStyleChangeList_h___
      12             : #define nsStyleChangeList_h___
      13             : 
      14             : #include "mozilla/Attributes.h"
      15             : #include "mozilla/StyleBackendType.h"
      16             : 
      17             : #include "nsChangeHint.h"
      18             : #include "nsCOMPtr.h"
      19             : 
      20             : class nsIFrame;
      21             : class nsIContent;
      22             : 
      23         288 : struct nsStyleChangeData
      24             : {
      25             :   nsIFrame* mFrame; // weak
      26             :   nsCOMPtr<nsIContent> mContent;
      27             :   nsChangeHint mHint;
      28             : };
      29             : 
      30             : class nsStyleChangeList : private AutoTArray<nsStyleChangeData, 10>
      31             : {
      32             :   typedef AutoTArray<nsStyleChangeData, 10> base_type;
      33             :   nsStyleChangeList(const nsStyleChangeList&) = delete;
      34             : 
      35             : public:
      36             :   using base_type::begin;
      37             :   using base_type::end;
      38             :   using base_type::IsEmpty;
      39             :   using base_type::Clear;
      40             :   using base_type::Length;
      41             :   using base_type::operator[];
      42             : 
      43          72 :   explicit nsStyleChangeList(mozilla::StyleBackendType aType) :
      44          72 :     mType(aType) { MOZ_COUNT_CTOR(nsStyleChangeList); }
      45          72 :   ~nsStyleChangeList() { MOZ_COUNT_DTOR(nsStyleChangeList); }
      46             :   void AppendChange(nsIFrame* aFrame, nsIContent* aContent, nsChangeHint aHint);
      47             : 
      48             :   // Starting from the end of the list, removes all changes until the list is
      49             :   // empty or an element with |mContent != aContent| is found.
      50           0 :   void PopChangesForContent(nsIContent* aContent)
      51             :   {
      52           0 :     while (Length() > 0) {
      53           0 :       if (LastElement().mContent == aContent) {
      54           0 :         RemoveElementAt(Length() - 1);
      55             :       } else {
      56           0 :         break;
      57             :       }
      58             :     }
      59           0 :   }
      60             : 
      61             :   bool IsGecko() const { return mType == mozilla::StyleBackendType::Gecko; }
      62         108 :   bool IsServo() const { return mType == mozilla::StyleBackendType::Servo; }
      63             : 
      64             : private:
      65             :   mozilla::StyleBackendType mType;
      66             : };
      67             : 
      68             : #endif /* nsStyleChangeList_h___ */

Generated by: LCOV version 1.13