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 "mozilla/Attributes.h" 16 #include "mozilla/StyleBackendType.h" 17 18 #include "nsChangeHint.h" 19 #include "nsCOMPtr.h" 20 21 class nsIFrame; 22 class nsIContent; 23 24 struct nsStyleChangeData { 25 nsIFrame* mFrame; // weak 26 nsCOMPtr<nsIContent> mContent; 27 nsChangeHint mHint; 28 }; 29 30 class nsStyleChangeList : private AutoTArray<nsStyleChangeData, 10> { 31 typedef AutoTArray<nsStyleChangeData, 10> base_type; 32 nsStyleChangeList(const nsStyleChangeList&) = delete; 33 34 public: 35 using base_type::Clear; 36 using base_type::IsEmpty; 37 using base_type::Length; 38 using base_type::begin; 39 using base_type::end; 40 using base_type::operator[]; 41 nsStyleChangeList(mozilla::StyleBackendType aType)42 explicit nsStyleChangeList(mozilla::StyleBackendType aType) : mType(aType) { 43 MOZ_COUNT_CTOR(nsStyleChangeList); 44 } ~nsStyleChangeList()45 ~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. PopChangesForContent(nsIContent * aContent)50 void PopChangesForContent(nsIContent* aContent) { 51 while (!IsEmpty() && LastElement().mContent == aContent) { 52 RemoveElementAt(Length() - 1); 53 } 54 } 55 IsGecko()56 bool IsGecko() const { return mType == mozilla::StyleBackendType::Gecko; } IsServo()57 bool IsServo() const { return mType == mozilla::StyleBackendType::Servo; } 58 59 private: 60 mozilla::StyleBackendType mType; 61 }; 62 63 #endif /* nsStyleChangeList_h___ */ 64