/src/mozilla-central/layout/generic/nsBulletFrame.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | /* rendering object for list-item bullets */ |
8 | | |
9 | | #ifndef nsBulletFrame_h___ |
10 | | #define nsBulletFrame_h___ |
11 | | |
12 | | #include "mozilla/Attributes.h" |
13 | | #include "nsFrame.h" |
14 | | |
15 | | #include "imgIContainer.h" |
16 | | #include "imgINotificationObserver.h" |
17 | | |
18 | | class imgIContainer; |
19 | | class imgRequestProxy; |
20 | | |
21 | | class nsBulletFrame; |
22 | | class BulletRenderer; |
23 | | |
24 | | class nsBulletListener final : public imgINotificationObserver |
25 | | { |
26 | | public: |
27 | | nsBulletListener(); |
28 | | |
29 | | NS_DECL_ISUPPORTS |
30 | | NS_DECL_IMGINOTIFICATIONOBSERVER |
31 | | |
32 | 0 | void SetFrame(nsBulletFrame *frame) { mFrame = frame; } |
33 | | |
34 | | private: |
35 | | virtual ~nsBulletListener(); |
36 | | |
37 | | nsBulletFrame *mFrame; |
38 | | }; |
39 | | |
40 | | /** |
41 | | * A simple class that manages the layout and rendering of html bullets. |
42 | | * This class also supports the CSS list-style properties. |
43 | | */ |
44 | | class nsBulletFrame final : public nsFrame { |
45 | | typedef mozilla::image::ImgDrawResult ImgDrawResult; |
46 | | |
47 | | public: |
48 | | NS_DECL_FRAMEARENA_HELPERS(nsBulletFrame) |
49 | | #ifdef DEBUG |
50 | | NS_DECL_QUERYFRAME |
51 | | #endif |
52 | | |
53 | | explicit nsBulletFrame(ComputedStyle* aStyle) |
54 | | : nsFrame(aStyle, kClassID) |
55 | | , mPadding(GetWritingMode()) |
56 | | , mIntrinsicSize(GetWritingMode()) |
57 | | , mOrdinal(0) |
58 | | , mRequestRegistered(false) |
59 | 0 | {} |
60 | | |
61 | | virtual ~nsBulletFrame(); |
62 | | |
63 | | NS_IMETHOD Notify(imgIRequest* aRequest, int32_t aType, const nsIntRect* aData); |
64 | | |
65 | | // nsIFrame |
66 | | virtual void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override; |
67 | | virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
68 | | const nsDisplayListSet& aLists) override; |
69 | | virtual void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override; |
70 | | #ifdef DEBUG_FRAME_DUMP |
71 | | virtual nsresult GetFrameName(nsAString& aResult) const override; |
72 | | #endif |
73 | | |
74 | | virtual void Reflow(nsPresContext* aPresContext, |
75 | | ReflowOutput& aMetrics, |
76 | | const ReflowInput& aReflowInput, |
77 | | nsReflowStatus& aStatus) override; |
78 | | virtual nscoord GetMinISize(gfxContext *aRenderingContext) override; |
79 | | virtual nscoord GetPrefISize(gfxContext *aRenderingContext) override; |
80 | | void AddInlineMinISize(gfxContext* aRenderingContext, |
81 | | nsIFrame::InlineMinISizeData* aData) override; |
82 | | void AddInlinePrefISize(gfxContext* aRenderingContext, |
83 | | nsIFrame::InlinePrefISizeData* aData) override; |
84 | | |
85 | | virtual bool IsFrameOfType(uint32_t aFlags) const override |
86 | 0 | { |
87 | 0 | if (aFlags & (eSupportsCSSTransforms | eSupportsContainLayoutAndPaint)) { |
88 | 0 | return false; |
89 | 0 | } |
90 | 0 | return nsFrame::IsFrameOfType(aFlags); |
91 | 0 | } |
92 | | |
93 | | // nsBulletFrame |
94 | | int32_t SetListItemOrdinal(int32_t aNextOrdinal, bool* aChanged, |
95 | | int32_t aIncrement); |
96 | | |
97 | | /* get list item text, with prefix & suffix */ |
98 | | void GetListItemText(nsAString& aResult); |
99 | | |
100 | | void GetSpokenText(nsAString& aText); |
101 | | |
102 | | Maybe<BulletRenderer> |
103 | | CreateBulletRenderer(gfxContext& aRenderingContext, nsPoint aPt); |
104 | | ImgDrawResult PaintBullet(gfxContext& aRenderingContext, nsPoint aPt, |
105 | | const nsRect& aDirtyRect, uint32_t aFlags, |
106 | | bool aDisableSubpixelAA); |
107 | | |
108 | | virtual bool IsEmpty() override; |
109 | | virtual bool IsSelfEmpty() override; |
110 | | virtual nscoord GetLogicalBaseline(mozilla::WritingMode aWritingMode) const override; |
111 | | |
112 | | float GetFontSizeInflation() const; |
113 | 0 | bool HasFontSizeInflation() const { |
114 | 0 | return (GetStateBits() & BULLET_FRAME_HAS_FONT_INFLATION) != 0; |
115 | 0 | } |
116 | | void SetFontSizeInflation(float aInflation); |
117 | | |
118 | 0 | int32_t GetOrdinal() { return mOrdinal; } |
119 | | |
120 | | already_AddRefed<imgIContainer> GetImage() const; |
121 | | |
122 | | protected: |
123 | | nsresult OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage); |
124 | | |
125 | | void AppendSpacingToPadding(nsFontMetrics* aFontMetrics, |
126 | | mozilla::LogicalMargin* aPadding); |
127 | | void GetDesiredSize(nsPresContext* aPresContext, |
128 | | gfxContext *aRenderingContext, |
129 | | ReflowOutput& aMetrics, |
130 | | float aFontSizeInflation, |
131 | | mozilla::LogicalMargin* aPadding); |
132 | | |
133 | | void GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGroup); |
134 | | nsIDocument* GetOurCurrentDoc() const; |
135 | | |
136 | | mozilla::LogicalMargin mPadding; |
137 | | RefPtr<imgRequestProxy> mImageRequest; |
138 | | RefPtr<nsBulletListener> mListener; |
139 | | |
140 | | mozilla::LogicalSize mIntrinsicSize; |
141 | | int32_t mOrdinal; |
142 | | |
143 | | private: |
144 | | void RegisterImageRequest(bool aKnownToBeAnimated); |
145 | | void DeregisterAndCancelImageRequest(); |
146 | | |
147 | | // This is a boolean flag indicating whether or not the current image request |
148 | | // has been registered with the refresh driver. |
149 | | bool mRequestRegistered : 1; |
150 | | }; |
151 | | |
152 | | #endif /* nsBulletFrame_h___ */ |