Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/base/nsQuoteList.h
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
/* implementation of quotes for the CSS 'content' property */
8
9
#ifndef nsQuoteList_h___
10
#define nsQuoteList_h___
11
12
#include "mozilla/Attributes.h"
13
#include "nsGenConList.h"
14
15
struct nsQuoteNode : public nsGenConNode {
16
  // open-quote, close-quote, no-open-quote, or no-close-quote
17
  const StyleContentType mType;
18
19
  // Quote depth before this quote, which is always non-negative.
20
  int32_t mDepthBefore;
21
22
  nsQuoteNode(StyleContentType aType, uint32_t aContentIndex)
23
    : nsGenConNode(aContentIndex)
24
    , mType(aType)
25
    , mDepthBefore(0)
26
0
  {
27
0
    NS_ASSERTION(aType == StyleContentType::OpenQuote ||
28
0
                 aType == StyleContentType::CloseQuote ||
29
0
                 aType == StyleContentType::NoOpenQuote ||
30
0
                 aType == StyleContentType::NoCloseQuote,
31
0
                 "incorrect type");
32
0
    NS_ASSERTION(aContentIndex <= INT32_MAX, "out of range");
33
0
  }
34
35
  virtual bool InitTextFrame(nsGenConList* aList,
36
          nsIFrame* aPseudoFrame, nsIFrame* aTextFrame) override;
37
38
  // is this 'open-quote' or 'no-open-quote'?
39
0
  bool IsOpenQuote() {
40
0
    return mType == StyleContentType::OpenQuote ||
41
0
           mType == StyleContentType::NoOpenQuote;
42
0
  }
43
44
  // is this 'close-quote' or 'no-close-quote'?
45
0
  bool IsCloseQuote() {
46
0
    return !IsOpenQuote();
47
0
  }
48
49
  // is this 'open-quote' or 'close-quote'?
50
0
  bool IsRealQuote() {
51
0
    return mType == StyleContentType::OpenQuote ||
52
0
           mType == StyleContentType::CloseQuote;
53
0
  }
54
55
  // Depth of the quote for *this* node.  Either non-negative or -1.
56
  // -1 means this is a closing quote that tried to decrement the
57
  // counter below zero (which means no quote should be rendered).
58
0
  int32_t Depth() {
59
0
    return IsOpenQuote() ? mDepthBefore : mDepthBefore - 1;
60
0
  }
61
62
  // always non-negative
63
0
  int32_t DepthAfter() {
64
0
    return IsOpenQuote() ? mDepthBefore + 1
65
0
                         : (mDepthBefore == 0 ? 0 : mDepthBefore - 1);
66
0
  }
67
68
  // The text that should be displayed for this quote.
69
  const nsString* Text();
70
};
71
72
class nsQuoteList : public nsGenConList {
73
private:
74
0
  nsQuoteNode* FirstNode() { return static_cast<nsQuoteNode*>(mList.getFirst()); }
75
public:
76
  // assign the correct |mDepthBefore| value to a node that has been inserted
77
  // Should be called immediately after calling |Insert|.
78
  void Calc(nsQuoteNode* aNode);
79
80
0
  nsQuoteNode* Next(nsQuoteNode* aNode) {
81
0
    return static_cast<nsQuoteNode*>(nsGenConList::Next(aNode));
82
0
  }
83
0
  nsQuoteNode* Prev(nsQuoteNode* aNode) {
84
0
    return static_cast<nsQuoteNode*>(nsGenConList::Prev(aNode));
85
0
  }
86
87
  void RecalcAll();
88
#ifdef DEBUG
89
  void PrintChain();
90
#endif
91
};
92
93
#endif /* nsQuoteList_h___ */