Bug 1700051: part 33) Move `AdjustSoftBeginAndBuildSoftText` to `SoftText`. r=smaug
[gecko.git] / layout / base / nsQuoteList.h
blobb7b74e077f68da27f0d51e84f15ec1ff73b11793
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* implementation of quotes for the CSS 'content' property */
9 #ifndef nsQuoteList_h___
10 #define nsQuoteList_h___
12 #include "mozilla/Attributes.h"
13 #include "nsGenConList.h"
15 struct nsQuoteNode : public nsGenConNode {
16 // open-quote, close-quote, no-open-quote, or no-close-quote
17 const StyleContentType mType;
19 // Quote depth before this quote, which is always non-negative.
20 int32_t mDepthBefore;
22 nsQuoteNode(StyleContentType aType, uint32_t aContentIndex)
23 : nsGenConNode(aContentIndex), mType(aType), mDepthBefore(0) {
24 NS_ASSERTION(aType == StyleContentType::OpenQuote ||
25 aType == StyleContentType::CloseQuote ||
26 aType == StyleContentType::NoOpenQuote ||
27 aType == StyleContentType::NoCloseQuote,
28 "incorrect type");
29 NS_ASSERTION(aContentIndex <= INT32_MAX, "out of range");
32 virtual bool InitTextFrame(nsGenConList* aList, nsIFrame* aPseudoFrame,
33 nsIFrame* aTextFrame) override;
35 // is this 'open-quote' or 'no-open-quote'?
36 bool IsOpenQuote() {
37 return mType == StyleContentType::OpenQuote ||
38 mType == StyleContentType::NoOpenQuote;
41 // is this 'close-quote' or 'no-close-quote'?
42 bool IsCloseQuote() { return !IsOpenQuote(); }
44 // is this 'open-quote' or 'close-quote'?
45 bool IsRealQuote() {
46 return mType == StyleContentType::OpenQuote ||
47 mType == StyleContentType::CloseQuote;
50 // Depth of the quote for *this* node. Either non-negative or -1.
51 // -1 means this is a closing quote that tried to decrement the
52 // counter below zero (which means no quote should be rendered).
53 int32_t Depth() { return IsOpenQuote() ? mDepthBefore : mDepthBefore - 1; }
55 // always non-negative
56 int32_t DepthAfter() {
57 return IsOpenQuote() ? mDepthBefore + 1
58 : (mDepthBefore == 0 ? 0 : mDepthBefore - 1);
61 // The text that should be displayed for this quote.
62 nsString Text();
65 class nsQuoteList : public nsGenConList {
66 private:
67 nsQuoteNode* FirstNode() {
68 return static_cast<nsQuoteNode*>(mList.getFirst());
71 public:
72 // assign the correct |mDepthBefore| value to a node that has been inserted
73 // Should be called immediately after calling |Insert|.
74 void Calc(nsQuoteNode* aNode);
76 nsQuoteNode* Next(nsQuoteNode* aNode) {
77 return static_cast<nsQuoteNode*>(nsGenConList::Next(aNode));
79 nsQuoteNode* Prev(nsQuoteNode* aNode) {
80 return static_cast<nsQuoteNode*>(nsGenConList::Prev(aNode));
83 void RecalcAll();
84 #ifdef DEBUG
85 void PrintChain();
86 #endif
89 #endif /* nsQuoteList_h___ */