Bug 1104435 part 2 - Make AnimationPlayer derive from nsISupports; r=smaug
[gecko.git] / layout / base / nsQuoteList.h
blobb8e5b883511b3167e139f1f0948c643c6208cd57
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/. */
6 /* implementation of quotes for the CSS 'content' property */
8 #ifndef nsQuoteList_h___
9 #define nsQuoteList_h___
11 #include "mozilla/Attributes.h"
12 #include "nsGenConList.h"
14 struct nsQuoteNode : public nsGenConNode {
15 // open-quote, close-quote, no-open-quote, or no-close-quote
16 const nsStyleContentType mType;
18 // Quote depth before this quote, which is always non-negative.
19 int32_t mDepthBefore;
21 nsQuoteNode(nsStyleContentType& aType, uint32_t aContentIndex)
22 : nsGenConNode(aContentIndex)
23 , mType(aType)
24 , mDepthBefore(0)
26 NS_ASSERTION(aType == eStyleContentType_OpenQuote ||
27 aType == eStyleContentType_CloseQuote ||
28 aType == eStyleContentType_NoOpenQuote ||
29 aType == eStyleContentType_NoCloseQuote,
30 "incorrect type");
31 NS_ASSERTION(aContentIndex <= INT32_MAX, "out of range");
34 virtual bool InitTextFrame(nsGenConList* aList,
35 nsIFrame* aPseudoFrame, nsIFrame* aTextFrame) MOZ_OVERRIDE;
37 // is this 'open-quote' or 'no-open-quote'?
38 bool IsOpenQuote() {
39 return mType == eStyleContentType_OpenQuote ||
40 mType == eStyleContentType_NoOpenQuote;
43 // is this 'close-quote' or 'no-close-quote'?
44 bool IsCloseQuote() {
45 return !IsOpenQuote();
48 // is this 'open-quote' or 'close-quote'?
49 bool IsRealQuote() {
50 return mType == eStyleContentType_OpenQuote ||
51 mType == eStyleContentType_CloseQuote;
54 // Depth of the quote for *this* node. Either non-negative or -1.
55 // -1 means this is a closing quote that tried to decrement the
56 // counter below zero (which means no quote should be rendered).
57 int32_t Depth() {
58 return IsOpenQuote() ? mDepthBefore : mDepthBefore - 1;
61 // always non-negative
62 int32_t DepthAfter() {
63 return IsOpenQuote() ? mDepthBefore + 1
64 : (mDepthBefore == 0 ? 0 : mDepthBefore - 1);
67 // The text that should be displayed for this quote.
68 const nsString* Text();
71 class nsQuoteList : public nsGenConList {
72 private:
73 nsQuoteNode* FirstNode() { return static_cast<nsQuoteNode*>(mFirstNode); }
74 public:
75 // assign the correct |mDepthBefore| value to a node that has been inserted
76 // Should be called immediately after calling |Insert|.
77 void Calc(nsQuoteNode* aNode);
79 nsQuoteNode* Next(nsQuoteNode* aNode) {
80 return static_cast<nsQuoteNode*>(nsGenConList::Next(aNode));
82 nsQuoteNode* Prev(nsQuoteNode* aNode) {
83 return static_cast<nsQuoteNode*>(nsGenConList::Prev(aNode));
86 void RecalcAll();
87 #ifdef DEBUG
88 void PrintChain();
89 #endif
92 #endif /* nsQuoteList_h___ */