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.

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

mercurial