layout/generic/nsBulletFrame.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/generic/nsBulletFrame.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,142 @@
     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 +/* rendering object for list-item bullets */
    1.10 +
    1.11 +#ifndef nsBulletFrame_h___
    1.12 +#define nsBulletFrame_h___
    1.13 +
    1.14 +#include "mozilla/Attributes.h"
    1.15 +#include "nsFrame.h"
    1.16 +
    1.17 +#include "imgINotificationObserver.h"
    1.18 +
    1.19 +class imgIContainer;
    1.20 +class imgRequestProxy;
    1.21 +
    1.22 +class nsBulletFrame;
    1.23 +
    1.24 +class nsBulletListener : public imgINotificationObserver
    1.25 +{
    1.26 +public:
    1.27 +  nsBulletListener();
    1.28 +  virtual ~nsBulletListener();
    1.29 +
    1.30 +  NS_DECL_ISUPPORTS
    1.31 +  NS_DECL_IMGINOTIFICATIONOBSERVER
    1.32 +
    1.33 +  void SetFrame(nsBulletFrame *frame) { mFrame = frame; }
    1.34 +
    1.35 +private:
    1.36 +  nsBulletFrame *mFrame;
    1.37 +};
    1.38 +
    1.39 +/**
    1.40 + * A simple class that manages the layout and rendering of html bullets.
    1.41 + * This class also supports the CSS list-style properties.
    1.42 + */
    1.43 +class nsBulletFrame : public nsFrame {
    1.44 +public:
    1.45 +  NS_DECL_FRAMEARENA_HELPERS
    1.46 +#ifdef DEBUG
    1.47 +  NS_DECL_QUERYFRAME_TARGET(nsBulletFrame)
    1.48 +  NS_DECL_QUERYFRAME
    1.49 +#endif
    1.50 +
    1.51 +  nsBulletFrame(nsStyleContext* aContext)
    1.52 +    : nsFrame(aContext)
    1.53 +  {
    1.54 +  }
    1.55 +  virtual ~nsBulletFrame();
    1.56 +
    1.57 +  NS_IMETHOD Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect* aData);
    1.58 +
    1.59 +  // nsIFrame
    1.60 +  virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
    1.61 +  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
    1.62 +                                const nsRect&           aDirtyRect,
    1.63 +                                const nsDisplayListSet& aLists) MOZ_OVERRIDE;
    1.64 +  virtual nsIAtom* GetType() const MOZ_OVERRIDE;
    1.65 +  virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
    1.66 +#ifdef DEBUG_FRAME_DUMP
    1.67 +  virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
    1.68 +#endif
    1.69 +
    1.70 +  // nsIHTMLReflow
    1.71 +  virtual nsresult Reflow(nsPresContext* aPresContext,
    1.72 +                          nsHTMLReflowMetrics& aMetrics,
    1.73 +                          const nsHTMLReflowState& aReflowState,
    1.74 +                          nsReflowStatus& aStatus) MOZ_OVERRIDE;
    1.75 +  virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
    1.76 +  virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
    1.77 +
    1.78 +  // nsBulletFrame
    1.79 +  int32_t SetListItemOrdinal(int32_t aNextOrdinal, bool* aChanged,
    1.80 +                             int32_t aIncrement);
    1.81 +
    1.82 +
    1.83 +  /* get list item text, without '.' */
    1.84 +  static void AppendCounterText(int32_t aListStyleType,
    1.85 +                                int32_t aOrdinal,
    1.86 +                                nsString& aResult,
    1.87 +                                bool& aIsRTL);
    1.88 +
    1.89 +  /* get suffix of list item */
    1.90 +  static void GetListItemSuffix(int32_t aListStyleType,
    1.91 +                                nsString& aResult,
    1.92 +                                bool& aSuppressPadding);
    1.93 +
    1.94 +  /* get list item text, with '.' */
    1.95 +  void GetListItemText(const nsStyleList& aStyleList, nsString& aResult);
    1.96 +                         
    1.97 +  void PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt,
    1.98 +                   const nsRect& aDirtyRect, uint32_t aFlags);
    1.99 +  
   1.100 +  virtual bool IsEmpty() MOZ_OVERRIDE;
   1.101 +  virtual bool IsSelfEmpty() MOZ_OVERRIDE;
   1.102 +  virtual nscoord GetBaseline() const MOZ_OVERRIDE;
   1.103 +
   1.104 +  float GetFontSizeInflation() const;
   1.105 +  bool HasFontSizeInflation() const {
   1.106 +    return (GetStateBits() & BULLET_FRAME_HAS_FONT_INFLATION) != 0;
   1.107 +  }
   1.108 +  void SetFontSizeInflation(float aInflation);
   1.109 +
   1.110 +  int32_t GetOrdinal() { return mOrdinal; }
   1.111 +
   1.112 +  already_AddRefed<imgIContainer> GetImage() const;
   1.113 +
   1.114 +protected:
   1.115 +  nsresult OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage);
   1.116 +
   1.117 +  void GetDesiredSize(nsPresContext* aPresContext,
   1.118 +                      nsRenderingContext *aRenderingContext,
   1.119 +                      nsHTMLReflowMetrics& aMetrics,
   1.120 +                      float aFontSizeInflation);
   1.121 +
   1.122 +  void GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGroup);
   1.123 +
   1.124 +  nsMargin mPadding;
   1.125 +  nsRefPtr<imgRequestProxy> mImageRequest;
   1.126 +  nsRefPtr<nsBulletListener> mListener;
   1.127 +
   1.128 +  nsSize mIntrinsicSize;
   1.129 +  int32_t mOrdinal;
   1.130 +  bool mTextIsRTL;
   1.131 +
   1.132 +  // If set to true, any padding of bullet defined in the UA style sheet will
   1.133 +  // be suppressed.  This is used for some CJK numbering styles where extra
   1.134 +  // space after the suffix is not desired.  Note that, any author-specified
   1.135 +  // padding overriding the default style will NOT be suppressed.
   1.136 +  bool mSuppressPadding;
   1.137 +
   1.138 +private:
   1.139 +
   1.140 +  // This is a boolean flag indicating whether or not the current image request
   1.141 +  // has been registered with the refresh driver.
   1.142 +  bool mRequestRegistered;
   1.143 +};
   1.144 +
   1.145 +#endif /* nsBulletFrame_h___ */

mercurial