Merge mozilla-central and tracemonkey. (a=blockers)
[mozilla-central.git] / layout / base / nsQuoteList.h
blob6d147357d489fa4d562f3e683d55509fb5fef7ca
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Esben Mose Hansen.
20 * Contributor(s):
21 * Esben Mose Hansen <esben@oek.dk> (original author)
22 * L. David Baron <dbaron@dbaron.org>
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 /* implementation of quotes for the CSS 'content' property */
40 #ifndef nsQuoteList_h___
41 #define nsQuoteList_h___
43 #include "nsGenConList.h"
45 struct nsQuoteNode : public nsGenConNode {
46 // open-quote, close-quote, no-open-quote, or no-close-quote
47 const nsStyleContentType mType;
49 // Quote depth before this quote, which is always non-negative.
50 PRInt32 mDepthBefore;
52 nsQuoteNode(nsStyleContentType& aType, PRUint32 aContentIndex)
53 : nsGenConNode(aContentIndex)
54 , mType(aType)
55 , mDepthBefore(0)
57 NS_ASSERTION(aType == eStyleContentType_OpenQuote ||
58 aType == eStyleContentType_CloseQuote ||
59 aType == eStyleContentType_NoOpenQuote ||
60 aType == eStyleContentType_NoCloseQuote,
61 "incorrect type");
62 NS_ASSERTION(aContentIndex <= PR_INT32_MAX, "out of range");
65 virtual PRBool InitTextFrame(nsGenConList* aList,
66 nsIFrame* aPseudoFrame, nsIFrame* aTextFrame);
68 // is this 'open-quote' or 'no-open-quote'?
69 PRBool IsOpenQuote() {
70 return mType == eStyleContentType_OpenQuote ||
71 mType == eStyleContentType_NoOpenQuote;
74 // is this 'close-quote' or 'no-close-quote'?
75 PRBool IsCloseQuote() {
76 return !IsOpenQuote();
79 // is this 'open-quote' or 'close-quote'?
80 PRBool IsRealQuote() {
81 return mType == eStyleContentType_OpenQuote ||
82 mType == eStyleContentType_CloseQuote;
85 // Depth of the quote for *this* node. Either non-negative or -1.
86 // -1 means this is a closing quote that tried to decrement the
87 // counter below zero (which means no quote should be rendered).
88 PRInt32 Depth() {
89 return IsOpenQuote() ? mDepthBefore : mDepthBefore - 1;
92 // always non-negative
93 PRInt32 DepthAfter() {
94 return IsOpenQuote() ? mDepthBefore + 1
95 : (mDepthBefore == 0 ? 0 : mDepthBefore - 1);
98 // The text that should be displayed for this quote.
99 const nsString* Text();
102 class nsQuoteList : public nsGenConList {
103 private:
104 nsQuoteNode* FirstNode() { return static_cast<nsQuoteNode*>(mFirstNode); }
105 public:
106 // assign the correct |mDepthBefore| value to a node that has been inserted
107 // Should be called immediately after calling |Insert|.
108 void Calc(nsQuoteNode* aNode);
110 nsQuoteNode* Next(nsQuoteNode* aNode) {
111 return static_cast<nsQuoteNode*>(nsGenConList::Next(aNode));
113 nsQuoteNode* Prev(nsQuoteNode* aNode) {
114 return static_cast<nsQuoteNode*>(nsGenConList::Prev(aNode));
117 void RecalcAll();
118 #ifdef DEBUG
119 void PrintChain();
120 #endif
123 #endif /* nsQuoteList_h___ */