layout/base/nsQuoteList.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/base/nsQuoteList.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,92 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/* implementation of quotes for the CSS 'content' property */
    1.10 +
    1.11 +#ifndef nsQuoteList_h___
    1.12 +#define nsQuoteList_h___
    1.13 +
    1.14 +#include "mozilla/Attributes.h"
    1.15 +#include "nsGenConList.h"
    1.16 +
    1.17 +struct nsQuoteNode : public nsGenConNode {
    1.18 +  // open-quote, close-quote, no-open-quote, or no-close-quote
    1.19 +  const nsStyleContentType mType;
    1.20 +
    1.21 +  // Quote depth before this quote, which is always non-negative.
    1.22 +  int32_t mDepthBefore;
    1.23 +
    1.24 +  nsQuoteNode(nsStyleContentType& aType, uint32_t aContentIndex)
    1.25 +    : nsGenConNode(aContentIndex)
    1.26 +    , mType(aType)
    1.27 +    , mDepthBefore(0)
    1.28 +  {
    1.29 +    NS_ASSERTION(aType == eStyleContentType_OpenQuote ||
    1.30 +                 aType == eStyleContentType_CloseQuote ||
    1.31 +                 aType == eStyleContentType_NoOpenQuote ||
    1.32 +                 aType == eStyleContentType_NoCloseQuote,
    1.33 +                 "incorrect type");
    1.34 +    NS_ASSERTION(aContentIndex <= INT32_MAX, "out of range");
    1.35 +  }
    1.36 +
    1.37 +  virtual bool InitTextFrame(nsGenConList* aList, 
    1.38 +          nsIFrame* aPseudoFrame, nsIFrame* aTextFrame) MOZ_OVERRIDE;
    1.39 +
    1.40 +  // is this 'open-quote' or 'no-open-quote'?
    1.41 +  bool IsOpenQuote() {
    1.42 +    return mType == eStyleContentType_OpenQuote ||
    1.43 +           mType == eStyleContentType_NoOpenQuote;
    1.44 +  }
    1.45 +
    1.46 +  // is this 'close-quote' or 'no-close-quote'?
    1.47 +  bool IsCloseQuote() {
    1.48 +    return !IsOpenQuote();
    1.49 +  }
    1.50 +
    1.51 +  // is this 'open-quote' or 'close-quote'?
    1.52 +  bool IsRealQuote() {
    1.53 +    return mType == eStyleContentType_OpenQuote ||
    1.54 +           mType == eStyleContentType_CloseQuote;
    1.55 +  }
    1.56 +
    1.57 +  // Depth of the quote for *this* node.  Either non-negative or -1.
    1.58 +  // -1 means this is a closing quote that tried to decrement the
    1.59 +  // counter below zero (which means no quote should be rendered).
    1.60 +  int32_t Depth() {
    1.61 +    return IsOpenQuote() ? mDepthBefore : mDepthBefore - 1;
    1.62 +  }
    1.63 +
    1.64 +  // always non-negative
    1.65 +  int32_t DepthAfter() {
    1.66 +    return IsOpenQuote() ? mDepthBefore + 1
    1.67 +                         : (mDepthBefore == 0 ? 0 : mDepthBefore - 1);
    1.68 +  }
    1.69 +
    1.70 +  // The text that should be displayed for this quote.
    1.71 +  const nsString* Text();
    1.72 +};
    1.73 +
    1.74 +class nsQuoteList : public nsGenConList {
    1.75 +private:
    1.76 +  nsQuoteNode* FirstNode() { return static_cast<nsQuoteNode*>(mFirstNode); }
    1.77 +public:
    1.78 +  // assign the correct |mDepthBefore| value to a node that has been inserted
    1.79 +  // Should be called immediately after calling |Insert|.
    1.80 +  void Calc(nsQuoteNode* aNode);
    1.81 +
    1.82 +  nsQuoteNode* Next(nsQuoteNode* aNode) {
    1.83 +    return static_cast<nsQuoteNode*>(nsGenConList::Next(aNode));
    1.84 +  }
    1.85 +  nsQuoteNode* Prev(nsQuoteNode* aNode) {
    1.86 +    return static_cast<nsQuoteNode*>(nsGenConList::Prev(aNode));
    1.87 +  }
    1.88 +  
    1.89 +  void RecalcAll();
    1.90 +#ifdef DEBUG
    1.91 +  void PrintChain();
    1.92 +#endif
    1.93 +};
    1.94 +
    1.95 +#endif /* nsQuoteList_h___ */

mercurial