layout/base/nsQuoteList.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /* implementation of quotes for the CSS 'content' property */
michael@0 7
michael@0 8 #ifndef nsQuoteList_h___
michael@0 9 #define nsQuoteList_h___
michael@0 10
michael@0 11 #include "mozilla/Attributes.h"
michael@0 12 #include "nsGenConList.h"
michael@0 13
michael@0 14 struct nsQuoteNode : public nsGenConNode {
michael@0 15 // open-quote, close-quote, no-open-quote, or no-close-quote
michael@0 16 const nsStyleContentType mType;
michael@0 17
michael@0 18 // Quote depth before this quote, which is always non-negative.
michael@0 19 int32_t mDepthBefore;
michael@0 20
michael@0 21 nsQuoteNode(nsStyleContentType& aType, uint32_t aContentIndex)
michael@0 22 : nsGenConNode(aContentIndex)
michael@0 23 , mType(aType)
michael@0 24 , mDepthBefore(0)
michael@0 25 {
michael@0 26 NS_ASSERTION(aType == eStyleContentType_OpenQuote ||
michael@0 27 aType == eStyleContentType_CloseQuote ||
michael@0 28 aType == eStyleContentType_NoOpenQuote ||
michael@0 29 aType == eStyleContentType_NoCloseQuote,
michael@0 30 "incorrect type");
michael@0 31 NS_ASSERTION(aContentIndex <= INT32_MAX, "out of range");
michael@0 32 }
michael@0 33
michael@0 34 virtual bool InitTextFrame(nsGenConList* aList,
michael@0 35 nsIFrame* aPseudoFrame, nsIFrame* aTextFrame) MOZ_OVERRIDE;
michael@0 36
michael@0 37 // is this 'open-quote' or 'no-open-quote'?
michael@0 38 bool IsOpenQuote() {
michael@0 39 return mType == eStyleContentType_OpenQuote ||
michael@0 40 mType == eStyleContentType_NoOpenQuote;
michael@0 41 }
michael@0 42
michael@0 43 // is this 'close-quote' or 'no-close-quote'?
michael@0 44 bool IsCloseQuote() {
michael@0 45 return !IsOpenQuote();
michael@0 46 }
michael@0 47
michael@0 48 // is this 'open-quote' or 'close-quote'?
michael@0 49 bool IsRealQuote() {
michael@0 50 return mType == eStyleContentType_OpenQuote ||
michael@0 51 mType == eStyleContentType_CloseQuote;
michael@0 52 }
michael@0 53
michael@0 54 // Depth of the quote for *this* node. Either non-negative or -1.
michael@0 55 // -1 means this is a closing quote that tried to decrement the
michael@0 56 // counter below zero (which means no quote should be rendered).
michael@0 57 int32_t Depth() {
michael@0 58 return IsOpenQuote() ? mDepthBefore : mDepthBefore - 1;
michael@0 59 }
michael@0 60
michael@0 61 // always non-negative
michael@0 62 int32_t DepthAfter() {
michael@0 63 return IsOpenQuote() ? mDepthBefore + 1
michael@0 64 : (mDepthBefore == 0 ? 0 : mDepthBefore - 1);
michael@0 65 }
michael@0 66
michael@0 67 // The text that should be displayed for this quote.
michael@0 68 const nsString* Text();
michael@0 69 };
michael@0 70
michael@0 71 class nsQuoteList : public nsGenConList {
michael@0 72 private:
michael@0 73 nsQuoteNode* FirstNode() { return static_cast<nsQuoteNode*>(mFirstNode); }
michael@0 74 public:
michael@0 75 // assign the correct |mDepthBefore| value to a node that has been inserted
michael@0 76 // Should be called immediately after calling |Insert|.
michael@0 77 void Calc(nsQuoteNode* aNode);
michael@0 78
michael@0 79 nsQuoteNode* Next(nsQuoteNode* aNode) {
michael@0 80 return static_cast<nsQuoteNode*>(nsGenConList::Next(aNode));
michael@0 81 }
michael@0 82 nsQuoteNode* Prev(nsQuoteNode* aNode) {
michael@0 83 return static_cast<nsQuoteNode*>(nsGenConList::Prev(aNode));
michael@0 84 }
michael@0 85
michael@0 86 void RecalcAll();
michael@0 87 #ifdef DEBUG
michael@0 88 void PrintChain();
michael@0 89 #endif
michael@0 90 };
michael@0 91
michael@0 92 #endif /* nsQuoteList_h___ */

mercurial