tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsStyleChangeList.h (1558B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      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/. */
      6 
      7 /*
      8 * a list of the recomputation that needs to be done in response to a
      9 * style change
     10 */
     11 
     12 #ifndef nsStyleChangeList_h___
     13 #define nsStyleChangeList_h___
     14 
     15 #include "nsCOMPtr.h"
     16 #include "nsChangeHint.h"
     17 #include "nsTArray.h"
     18 
     19 class nsIFrame;
     20 class nsIContent;
     21 
     22 struct nsStyleChangeData {
     23  nsIFrame* mFrame;  // weak
     24  nsCOMPtr<nsIContent> mContent;
     25  nsChangeHint mHint;
     26 };
     27 
     28 class nsStyleChangeList : private AutoTArray<nsStyleChangeData, 10> {
     29  typedef AutoTArray<nsStyleChangeData, 10> base_type;
     30  nsStyleChangeList(const nsStyleChangeList&) = delete;
     31 
     32 public:
     33  using base_type::begin;
     34  using base_type::Clear;
     35  using base_type::end;
     36  using base_type::IsEmpty;
     37  using base_type::Length;
     38  using base_type::operator[];
     39 
     40  MOZ_COUNTED_DEFAULT_CTOR(nsStyleChangeList)
     41  MOZ_COUNTED_DTOR(nsStyleChangeList)
     42  void AppendChange(nsIFrame* aFrame, nsIContent* aContent, nsChangeHint aHint);
     43 
     44  // Starting from the end of the list, removes all changes until the list is
     45  // empty or an element with |mContent != aContent| is found.
     46  void PopChangesForContent(nsIContent* aContent) {
     47    while (!IsEmpty() && LastElement().mContent == aContent) {
     48      RemoveLastElement();
     49    }
     50  }
     51 };
     52 
     53 #endif /* nsStyleChangeList_h___ */