2004-04-12 21:53:22 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-03-30 05:56:38 +00:00
|
|
|
|
|
|
|
/* implementation of quotes for the CSS 'content' property */
|
|
|
|
|
2004-04-12 21:53:22 +00:00
|
|
|
#ifndef nsQuoteList_h___
|
|
|
|
#define nsQuoteList_h___
|
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2005-04-01 23:07:00 +00:00
|
|
|
#include "nsGenConList.h"
|
2004-04-12 21:53:22 +00:00
|
|
|
|
2005-04-01 23:07:00 +00:00
|
|
|
struct nsQuoteNode : public nsGenConNode {
|
2004-04-12 21:53:22 +00:00
|
|
|
// open-quote, close-quote, no-open-quote, or no-close-quote
|
|
|
|
const nsStyleContentType mType;
|
|
|
|
|
|
|
|
// Quote depth before this quote, which is always non-negative.
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mDepthBefore;
|
2004-04-12 21:53:22 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsQuoteNode(nsStyleContentType& aType, uint32_t aContentIndex)
|
2008-08-18 01:16:42 +00:00
|
|
|
: nsGenConNode(aContentIndex)
|
2005-04-01 23:07:00 +00:00
|
|
|
, mType(aType)
|
2004-04-12 21:53:22 +00:00
|
|
|
, mDepthBefore(0)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType == eStyleContentType_OpenQuote ||
|
|
|
|
aType == eStyleContentType_CloseQuote ||
|
|
|
|
aType == eStyleContentType_NoOpenQuote ||
|
|
|
|
aType == eStyleContentType_NoCloseQuote,
|
|
|
|
"incorrect type");
|
2012-09-28 06:57:33 +00:00
|
|
|
NS_ASSERTION(aContentIndex <= INT32_MAX, "out of range");
|
2004-04-12 21:53:22 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool InitTextFrame(nsGenConList* aList,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsIFrame* aPseudoFrame, nsIFrame* aTextFrame) override;
|
2008-08-18 01:16:42 +00:00
|
|
|
|
2004-04-12 21:53:22 +00:00
|
|
|
// is this 'open-quote' or 'no-open-quote'?
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsOpenQuote() {
|
2004-04-12 21:53:22 +00:00
|
|
|
return mType == eStyleContentType_OpenQuote ||
|
|
|
|
mType == eStyleContentType_NoOpenQuote;
|
|
|
|
}
|
|
|
|
|
|
|
|
// is this 'close-quote' or 'no-close-quote'?
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsCloseQuote() {
|
2004-04-12 21:53:22 +00:00
|
|
|
return !IsOpenQuote();
|
|
|
|
}
|
|
|
|
|
|
|
|
// is this 'open-quote' or 'close-quote'?
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsRealQuote() {
|
2004-04-12 21:53:22 +00:00
|
|
|
return mType == eStyleContentType_OpenQuote ||
|
|
|
|
mType == eStyleContentType_CloseQuote;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Depth of the quote for *this* node. Either non-negative or -1.
|
|
|
|
// -1 means this is a closing quote that tried to decrement the
|
|
|
|
// counter below zero (which means no quote should be rendered).
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t Depth() {
|
2004-04-12 21:53:22 +00:00
|
|
|
return IsOpenQuote() ? mDepthBefore : mDepthBefore - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// always non-negative
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t DepthAfter() {
|
2004-04-12 21:53:22 +00:00
|
|
|
return IsOpenQuote() ? mDepthBefore + 1
|
|
|
|
: (mDepthBefore == 0 ? 0 : mDepthBefore - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The text that should be displayed for this quote.
|
|
|
|
const nsString* Text();
|
|
|
|
};
|
|
|
|
|
2005-04-01 23:07:00 +00:00
|
|
|
class nsQuoteList : public nsGenConList {
|
2004-04-12 21:53:22 +00:00
|
|
|
private:
|
2007-07-08 07:08:04 +00:00
|
|
|
nsQuoteNode* FirstNode() { return static_cast<nsQuoteNode*>(mFirstNode); }
|
2004-04-12 21:53:22 +00:00
|
|
|
public:
|
2005-04-01 23:07:00 +00:00
|
|
|
// assign the correct |mDepthBefore| value to a node that has been inserted
|
|
|
|
// Should be called immediately after calling |Insert|.
|
|
|
|
void Calc(nsQuoteNode* aNode);
|
|
|
|
|
|
|
|
nsQuoteNode* Next(nsQuoteNode* aNode) {
|
2007-07-08 07:08:04 +00:00
|
|
|
return static_cast<nsQuoteNode*>(nsGenConList::Next(aNode));
|
2004-04-12 21:53:22 +00:00
|
|
|
}
|
2005-04-01 23:07:00 +00:00
|
|
|
nsQuoteNode* Prev(nsQuoteNode* aNode) {
|
2007-07-08 07:08:04 +00:00
|
|
|
return static_cast<nsQuoteNode*>(nsGenConList::Prev(aNode));
|
2004-04-12 21:53:22 +00:00
|
|
|
}
|
2005-04-01 23:07:00 +00:00
|
|
|
|
2004-04-12 21:53:22 +00:00
|
|
|
void RecalcAll();
|
|
|
|
#ifdef DEBUG
|
|
|
|
void PrintChain();
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsQuoteList_h___ */
|