|
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/. */ |
|
5 #ifndef nsTextBoxFrame_h___ |
|
6 #define nsTextBoxFrame_h___ |
|
7 |
|
8 #include "mozilla/Attributes.h" |
|
9 #include "nsLeafBoxFrame.h" |
|
10 |
|
11 class nsAccessKeyInfo; |
|
12 class nsAsyncAccesskeyUpdate; |
|
13 |
|
14 typedef nsLeafBoxFrame nsTextBoxFrameSuper; |
|
15 class nsTextBoxFrame : public nsTextBoxFrameSuper |
|
16 { |
|
17 public: |
|
18 NS_DECL_QUERYFRAME_TARGET(nsTextBoxFrame) |
|
19 NS_DECL_QUERYFRAME |
|
20 NS_DECL_FRAMEARENA_HELPERS |
|
21 |
|
22 virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; |
|
23 virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; |
|
24 virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; |
|
25 NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; |
|
26 virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE; |
|
27 |
|
28 enum CroppingStyle { CropNone, CropLeft, CropRight, CropCenter }; |
|
29 |
|
30 friend nsIFrame* NS_NewTextBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); |
|
31 |
|
32 virtual void Init(nsIContent* aContent, |
|
33 nsIFrame* aParent, |
|
34 nsIFrame* asPrevInFlow) MOZ_OVERRIDE; |
|
35 |
|
36 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; |
|
37 |
|
38 virtual nsresult AttributeChanged(int32_t aNameSpaceID, |
|
39 nsIAtom* aAttribute, |
|
40 int32_t aModType) MOZ_OVERRIDE; |
|
41 |
|
42 #ifdef DEBUG_FRAME_DUMP |
|
43 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; |
|
44 #endif |
|
45 |
|
46 void UpdateAttributes(nsIAtom* aAttribute, |
|
47 bool& aResize, |
|
48 bool& aRedraw); |
|
49 |
|
50 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
|
51 const nsRect& aDirtyRect, |
|
52 const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
|
53 |
|
54 virtual ~nsTextBoxFrame(); |
|
55 |
|
56 void PaintTitle(nsRenderingContext& aRenderingContext, |
|
57 const nsRect& aDirtyRect, |
|
58 nsPoint aPt, |
|
59 const nscolor* aOverrideColor); |
|
60 |
|
61 nsRect GetComponentAlphaBounds(); |
|
62 |
|
63 virtual bool ComputesOwnOverflowArea() MOZ_OVERRIDE; |
|
64 |
|
65 void GetCroppedTitle(nsString& aTitle) const { aTitle = mCroppedTitle; } |
|
66 |
|
67 protected: |
|
68 friend class nsAsyncAccesskeyUpdate; |
|
69 friend class nsDisplayXULTextBox; |
|
70 // Should be called only by nsAsyncAccesskeyUpdate. |
|
71 // Returns true if accesskey was updated. |
|
72 bool UpdateAccesskey(nsWeakFrame& aWeakThis); |
|
73 void UpdateAccessTitle(); |
|
74 void UpdateAccessIndex(); |
|
75 |
|
76 // REVIEW: SORRY! Couldn't resist devirtualizing these |
|
77 void LayoutTitle(nsPresContext* aPresContext, |
|
78 nsRenderingContext& aRenderingContext, |
|
79 const nsRect& aRect); |
|
80 |
|
81 void CalculateUnderline(nsRenderingContext& aRenderingContext); |
|
82 |
|
83 void CalcTextSize(nsBoxLayoutState& aBoxLayoutState); |
|
84 |
|
85 void CalcDrawRect(nsRenderingContext &aRenderingContext); |
|
86 |
|
87 nsTextBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext); |
|
88 |
|
89 nscoord CalculateTitleForWidth(nsPresContext* aPresContext, |
|
90 nsRenderingContext& aRenderingContext, |
|
91 nscoord aWidth); |
|
92 |
|
93 void GetTextSize(nsPresContext* aPresContext, |
|
94 nsRenderingContext& aRenderingContext, |
|
95 const nsString& aString, |
|
96 nsSize& aSize, |
|
97 nscoord& aAscent); |
|
98 |
|
99 nsresult RegUnregAccessKey(bool aDoReg); |
|
100 |
|
101 private: |
|
102 |
|
103 bool AlwaysAppendAccessKey(); |
|
104 bool InsertSeparatorBeforeAccessKey(); |
|
105 |
|
106 void DrawText(nsRenderingContext& aRenderingContext, |
|
107 const nsRect& aDirtyRect, |
|
108 const nsRect& aTextRect, |
|
109 const nscolor* aOverrideColor); |
|
110 |
|
111 nsString mTitle; |
|
112 nsString mCroppedTitle; |
|
113 nsString mAccessKey; |
|
114 nsSize mTextSize; |
|
115 nsRect mTextDrawRect; |
|
116 nsAccessKeyInfo* mAccessKeyInfo; |
|
117 |
|
118 CroppingStyle mCropType; |
|
119 nscoord mAscent; |
|
120 bool mNeedsRecalc; |
|
121 bool mNeedsReflowCallback; |
|
122 |
|
123 static bool gAlwaysAppendAccessKey; |
|
124 static bool gAccessKeyPrefInitialized; |
|
125 static bool gInsertSeparatorBeforeAccessKey; |
|
126 static bool gInsertSeparatorPrefInitialized; |
|
127 |
|
128 }; // class nsTextBoxFrame |
|
129 |
|
130 #endif /* nsTextBoxFrame_h___ */ |