Wed, 31 Dec 2014 06:09:35 +0100
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 /* rendering object for list-item bullets */
8 #ifndef nsBulletFrame_h___
9 #define nsBulletFrame_h___
11 #include "mozilla/Attributes.h"
12 #include "nsFrame.h"
14 #include "imgINotificationObserver.h"
16 class imgIContainer;
17 class imgRequestProxy;
19 class nsBulletFrame;
21 class nsBulletListener : public imgINotificationObserver
22 {
23 public:
24 nsBulletListener();
25 virtual ~nsBulletListener();
27 NS_DECL_ISUPPORTS
28 NS_DECL_IMGINOTIFICATIONOBSERVER
30 void SetFrame(nsBulletFrame *frame) { mFrame = frame; }
32 private:
33 nsBulletFrame *mFrame;
34 };
36 /**
37 * A simple class that manages the layout and rendering of html bullets.
38 * This class also supports the CSS list-style properties.
39 */
40 class nsBulletFrame : public nsFrame {
41 public:
42 NS_DECL_FRAMEARENA_HELPERS
43 #ifdef DEBUG
44 NS_DECL_QUERYFRAME_TARGET(nsBulletFrame)
45 NS_DECL_QUERYFRAME
46 #endif
48 nsBulletFrame(nsStyleContext* aContext)
49 : nsFrame(aContext)
50 {
51 }
52 virtual ~nsBulletFrame();
54 NS_IMETHOD Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect* aData);
56 // nsIFrame
57 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
58 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
59 const nsRect& aDirtyRect,
60 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
61 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
62 virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
63 #ifdef DEBUG_FRAME_DUMP
64 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
65 #endif
67 // nsIHTMLReflow
68 virtual nsresult Reflow(nsPresContext* aPresContext,
69 nsHTMLReflowMetrics& aMetrics,
70 const nsHTMLReflowState& aReflowState,
71 nsReflowStatus& aStatus) MOZ_OVERRIDE;
72 virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
73 virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
75 // nsBulletFrame
76 int32_t SetListItemOrdinal(int32_t aNextOrdinal, bool* aChanged,
77 int32_t aIncrement);
80 /* get list item text, without '.' */
81 static void AppendCounterText(int32_t aListStyleType,
82 int32_t aOrdinal,
83 nsString& aResult,
84 bool& aIsRTL);
86 /* get suffix of list item */
87 static void GetListItemSuffix(int32_t aListStyleType,
88 nsString& aResult,
89 bool& aSuppressPadding);
91 /* get list item text, with '.' */
92 void GetListItemText(const nsStyleList& aStyleList, nsString& aResult);
94 void PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt,
95 const nsRect& aDirtyRect, uint32_t aFlags);
97 virtual bool IsEmpty() MOZ_OVERRIDE;
98 virtual bool IsSelfEmpty() MOZ_OVERRIDE;
99 virtual nscoord GetBaseline() const MOZ_OVERRIDE;
101 float GetFontSizeInflation() const;
102 bool HasFontSizeInflation() const {
103 return (GetStateBits() & BULLET_FRAME_HAS_FONT_INFLATION) != 0;
104 }
105 void SetFontSizeInflation(float aInflation);
107 int32_t GetOrdinal() { return mOrdinal; }
109 already_AddRefed<imgIContainer> GetImage() const;
111 protected:
112 nsresult OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage);
114 void GetDesiredSize(nsPresContext* aPresContext,
115 nsRenderingContext *aRenderingContext,
116 nsHTMLReflowMetrics& aMetrics,
117 float aFontSizeInflation);
119 void GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGroup);
121 nsMargin mPadding;
122 nsRefPtr<imgRequestProxy> mImageRequest;
123 nsRefPtr<nsBulletListener> mListener;
125 nsSize mIntrinsicSize;
126 int32_t mOrdinal;
127 bool mTextIsRTL;
129 // If set to true, any padding of bullet defined in the UA style sheet will
130 // be suppressed. This is used for some CJK numbering styles where extra
131 // space after the suffix is not desired. Note that, any author-specified
132 // padding overriding the default style will NOT be suppressed.
133 bool mSuppressPadding;
135 private:
137 // This is a boolean flag indicating whether or not the current image request
138 // has been registered with the refresh driver.
139 bool mRequestRegistered;
140 };
142 #endif /* nsBulletFrame_h___ */