2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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 09:56:38 +04:00
|
|
|
|
|
|
|
/* implementation of quotes for the CSS 'content' property */
|
|
|
|
|
2004-04-13 01:53:22 +04:00
|
|
|
#ifndef nsQuoteList_h___
|
|
|
|
#define nsQuoteList_h___
|
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2005-04-02 03:07:00 +04:00
|
|
|
#include "nsGenConList.h"
|
2004-04-13 01:53:22 +04:00
|
|
|
|
2005-04-02 03:07:00 +04:00
|
|
|
struct nsQuoteNode : public nsGenConNode {
|
2004-04-13 01:53:22 +04:00
|
|
|
// open-quote, close-quote, no-open-quote, or no-close-quote
|
2018-06-30 16:05:15 +03:00
|
|
|
const StyleContentType mType;
|
2004-04-13 01:53:22 +04:00
|
|
|
|
|
|
|
// Quote depth before this quote, which is always non-negative.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mDepthBefore;
|
2004-04-13 01:53:22 +04:00
|
|
|
|
2018-06-30 16:05:15 +03:00
|
|
|
nsQuoteNode(StyleContentType aType, uint32_t aContentIndex)
|
2008-08-18 05:16:42 +04:00
|
|
|
: nsGenConNode(aContentIndex), mType(aType), mDepthBefore(0) {
|
2018-06-30 16:05:15 +03:00
|
|
|
NS_ASSERTION(aType == StyleContentType::OpenQuote ||
|
|
|
|
aType == StyleContentType::CloseQuote ||
|
|
|
|
aType == StyleContentType::NoOpenQuote ||
|
|
|
|
aType == StyleContentType::NoCloseQuote,
|
2004-04-13 01:53:22 +04:00
|
|
|
"incorrect type");
|
2012-09-28 10:57:33 +04:00
|
|
|
NS_ASSERTION(aContentIndex <= INT32_MAX, "out of range");
|
2004-04-13 01:53:22 +04:00
|
|
|
}
|
|
|
|
|
2016-10-27 13:07:52 +03:00
|
|
|
virtual bool InitTextFrame(nsGenConList* aList, nsIFrame* aPseudoFrame,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* aTextFrame) override;
|
2008-08-18 05:16:42 +04:00
|
|
|
|
2004-04-13 01:53:22 +04:00
|
|
|
// is this 'open-quote' or 'no-open-quote'?
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsOpenQuote() {
|
2018-06-30 16:05:15 +03:00
|
|
|
return mType == StyleContentType::OpenQuote ||
|
|
|
|
mType == StyleContentType::NoOpenQuote;
|
2004-04-13 01:53:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// is this 'close-quote' or 'no-close-quote'?
|
|
|
|
bool IsCloseQuote() { return !IsOpenQuote(); }
|
|
|
|
|
|
|
|
// is this 'open-quote' or 'close-quote'?
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsRealQuote() {
|
2018-06-30 16:05:15 +03:00
|
|
|
return mType == StyleContentType::OpenQuote ||
|
|
|
|
mType == StyleContentType::CloseQuote;
|
2004-04-13 01:53:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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).
|
|
|
|
int32_t Depth() { return IsOpenQuote() ? mDepthBefore : mDepthBefore - 1; }
|
|
|
|
|
|
|
|
// always non-negative
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t DepthAfter() {
|
2004-04-13 01:53:22 +04:00
|
|
|
return IsOpenQuote() ? mDepthBefore + 1
|
|
|
|
: (mDepthBefore == 0 ? 0 : mDepthBefore - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The text that should be displayed for this quote.
|
2018-11-07 02:03:24 +03:00
|
|
|
nsString Text();
|
2004-04-13 01:53:22 +04:00
|
|
|
};
|
|
|
|
|
2005-04-02 03:07:00 +04:00
|
|
|
class nsQuoteList : public nsGenConList {
|
2004-04-13 01:53:22 +04:00
|
|
|
private:
|
2016-10-27 13:07:52 +03:00
|
|
|
nsQuoteNode* FirstNode() {
|
|
|
|
return static_cast<nsQuoteNode*>(mList.getFirst());
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2004-04-13 01:53:22 +04:00
|
|
|
public:
|
2005-04-02 03:07:00 +04: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 11:08:04 +04:00
|
|
|
return static_cast<nsQuoteNode*>(nsGenConList::Next(aNode));
|
2004-04-13 01:53:22 +04:00
|
|
|
}
|
2005-04-02 03:07:00 +04:00
|
|
|
nsQuoteNode* Prev(nsQuoteNode* aNode) {
|
2007-07-08 11:08:04 +04:00
|
|
|
return static_cast<nsQuoteNode*>(nsGenConList::Prev(aNode));
|
2004-04-13 01:53:22 +04:00
|
|
|
}
|
2016-10-27 13:07:52 +03:00
|
|
|
|
2004-04-13 01:53:22 +04:00
|
|
|
void RecalcAll();
|
|
|
|
#ifdef DEBUG
|
|
|
|
void PrintChain();
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsQuoteList_h___ */
|