2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* implementation of quotes for the CSS 'content' property */
|
|
|
|
|
|
|
|
#ifndef nsQuoteList_h___
|
|
|
|
#define nsQuoteList_h___
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsGenConList.h"
|
|
|
|
|
|
|
|
struct nsQuoteNode : public nsGenConNode {
|
|
|
|
// 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 08:56:38 -07:00
|
|
|
int32_t mDepthBefore;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsQuoteNode(nsStyleContentType& aType, uint32_t aContentIndex)
|
2008-08-17 18:16:42 -07:00
|
|
|
: nsGenConNode(aContentIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
, mType(aType)
|
|
|
|
, mDepthBefore(0)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aType == eStyleContentType_OpenQuote ||
|
|
|
|
aType == eStyleContentType_CloseQuote ||
|
|
|
|
aType == eStyleContentType_NoOpenQuote ||
|
|
|
|
aType == eStyleContentType_NoCloseQuote,
|
|
|
|
"incorrect type");
|
2012-09-27 23:57:33 -07:00
|
|
|
NS_ASSERTION(aContentIndex <= INT32_MAX, "out of range");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool InitTextFrame(nsGenConList* aList,
|
2015-03-21 09:28:04 -07:00
|
|
|
nsIFrame* aPseudoFrame, nsIFrame* aTextFrame) override;
|
2008-08-17 18:16:42 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// is this 'open-quote' or 'no-open-quote'?
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsOpenQuote() {
|
2007-03-22 10:30:00 -07:00
|
|
|
return mType == eStyleContentType_OpenQuote ||
|
|
|
|
mType == eStyleContentType_NoOpenQuote;
|
|
|
|
}
|
|
|
|
|
|
|
|
// is this 'close-quote' or 'no-close-quote'?
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsCloseQuote() {
|
2007-03-22 10:30:00 -07:00
|
|
|
return !IsOpenQuote();
|
|
|
|
}
|
|
|
|
|
|
|
|
// is this 'open-quote' or 'close-quote'?
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsRealQuote() {
|
2007-03-22 10:30:00 -07: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 08:56:38 -07:00
|
|
|
int32_t Depth() {
|
2007-03-22 10:30:00 -07:00
|
|
|
return IsOpenQuote() ? mDepthBefore : mDepthBefore - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// always non-negative
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t DepthAfter() {
|
2007-03-22 10:30:00 -07:00
|
|
|
return IsOpenQuote() ? mDepthBefore + 1
|
|
|
|
: (mDepthBefore == 0 ? 0 : mDepthBefore - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The text that should be displayed for this quote.
|
|
|
|
const nsString* Text();
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsQuoteList : public nsGenConList {
|
|
|
|
private:
|
2007-07-08 00:08:04 -07:00
|
|
|
nsQuoteNode* FirstNode() { return static_cast<nsQuoteNode*>(mFirstNode); }
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
// 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 00:08:04 -07:00
|
|
|
return static_cast<nsQuoteNode*>(nsGenConList::Next(aNode));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
nsQuoteNode* Prev(nsQuoteNode* aNode) {
|
2007-07-08 00:08:04 -07:00
|
|
|
return static_cast<nsQuoteNode*>(nsGenConList::Prev(aNode));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void RecalcAll();
|
|
|
|
#ifdef DEBUG
|
|
|
|
void PrintChain();
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsQuoteList_h___ */
|