michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* rendering object for list-item bullets */ michael@0: michael@0: #ifndef nsBulletFrame_h___ michael@0: #define nsBulletFrame_h___ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsFrame.h" michael@0: michael@0: #include "imgINotificationObserver.h" michael@0: michael@0: class imgIContainer; michael@0: class imgRequestProxy; michael@0: michael@0: class nsBulletFrame; michael@0: michael@0: class nsBulletListener : public imgINotificationObserver michael@0: { michael@0: public: michael@0: nsBulletListener(); michael@0: virtual ~nsBulletListener(); michael@0: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_IMGINOTIFICATIONOBSERVER michael@0: michael@0: void SetFrame(nsBulletFrame *frame) { mFrame = frame; } michael@0: michael@0: private: michael@0: nsBulletFrame *mFrame; michael@0: }; michael@0: michael@0: /** michael@0: * A simple class that manages the layout and rendering of html bullets. michael@0: * This class also supports the CSS list-style properties. michael@0: */ michael@0: class nsBulletFrame : public nsFrame { michael@0: public: michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: #ifdef DEBUG michael@0: NS_DECL_QUERYFRAME_TARGET(nsBulletFrame) michael@0: NS_DECL_QUERYFRAME michael@0: #endif michael@0: michael@0: nsBulletFrame(nsStyleContext* aContext) michael@0: : nsFrame(aContext) michael@0: { michael@0: } michael@0: virtual ~nsBulletFrame(); michael@0: michael@0: NS_IMETHOD Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect* aData); michael@0: michael@0: // nsIFrame michael@0: virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; michael@0: virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, michael@0: const nsRect& aDirtyRect, michael@0: const nsDisplayListSet& aLists) MOZ_OVERRIDE; michael@0: virtual nsIAtom* GetType() const MOZ_OVERRIDE; michael@0: virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE; michael@0: #ifdef DEBUG_FRAME_DUMP michael@0: virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: // nsIHTMLReflow michael@0: virtual nsresult Reflow(nsPresContext* aPresContext, michael@0: nsHTMLReflowMetrics& aMetrics, michael@0: const nsHTMLReflowState& aReflowState, michael@0: nsReflowStatus& aStatus) MOZ_OVERRIDE; michael@0: virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; michael@0: virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; michael@0: michael@0: // nsBulletFrame michael@0: int32_t SetListItemOrdinal(int32_t aNextOrdinal, bool* aChanged, michael@0: int32_t aIncrement); michael@0: michael@0: michael@0: /* get list item text, without '.' */ michael@0: static void AppendCounterText(int32_t aListStyleType, michael@0: int32_t aOrdinal, michael@0: nsString& aResult, michael@0: bool& aIsRTL); michael@0: michael@0: /* get suffix of list item */ michael@0: static void GetListItemSuffix(int32_t aListStyleType, michael@0: nsString& aResult, michael@0: bool& aSuppressPadding); michael@0: michael@0: /* get list item text, with '.' */ michael@0: void GetListItemText(const nsStyleList& aStyleList, nsString& aResult); michael@0: michael@0: void PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt, michael@0: const nsRect& aDirtyRect, uint32_t aFlags); michael@0: michael@0: virtual bool IsEmpty() MOZ_OVERRIDE; michael@0: virtual bool IsSelfEmpty() MOZ_OVERRIDE; michael@0: virtual nscoord GetBaseline() const MOZ_OVERRIDE; michael@0: michael@0: float GetFontSizeInflation() const; michael@0: bool HasFontSizeInflation() const { michael@0: return (GetStateBits() & BULLET_FRAME_HAS_FONT_INFLATION) != 0; michael@0: } michael@0: void SetFontSizeInflation(float aInflation); michael@0: michael@0: int32_t GetOrdinal() { return mOrdinal; } michael@0: michael@0: already_AddRefed GetImage() const; michael@0: michael@0: protected: michael@0: nsresult OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage); michael@0: michael@0: void GetDesiredSize(nsPresContext* aPresContext, michael@0: nsRenderingContext *aRenderingContext, michael@0: nsHTMLReflowMetrics& aMetrics, michael@0: float aFontSizeInflation); michael@0: michael@0: void GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGroup); michael@0: michael@0: nsMargin mPadding; michael@0: nsRefPtr mImageRequest; michael@0: nsRefPtr mListener; michael@0: michael@0: nsSize mIntrinsicSize; michael@0: int32_t mOrdinal; michael@0: bool mTextIsRTL; michael@0: michael@0: // If set to true, any padding of bullet defined in the UA style sheet will michael@0: // be suppressed. This is used for some CJK numbering styles where extra michael@0: // space after the suffix is not desired. Note that, any author-specified michael@0: // padding overriding the default style will NOT be suppressed. michael@0: bool mSuppressPadding; michael@0: michael@0: private: michael@0: michael@0: // This is a boolean flag indicating whether or not the current image request michael@0: // has been registered with the refresh driver. michael@0: bool mRequestRegistered; michael@0: }; michael@0: michael@0: #endif /* nsBulletFrame_h___ */