Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
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___
8 #include "mozilla/Attributes.h"
9 #include "nsLeafBoxFrame.h"
11 class nsAccessKeyInfo;
12 class nsAsyncAccesskeyUpdate;
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
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;
28 enum CroppingStyle { CropNone, CropLeft, CropRight, CropCenter };
30 friend nsIFrame* NS_NewTextBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
32 virtual void Init(nsIContent* aContent,
33 nsIFrame* aParent,
34 nsIFrame* asPrevInFlow) MOZ_OVERRIDE;
36 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
38 virtual nsresult AttributeChanged(int32_t aNameSpaceID,
39 nsIAtom* aAttribute,
40 int32_t aModType) MOZ_OVERRIDE;
42 #ifdef DEBUG_FRAME_DUMP
43 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
44 #endif
46 void UpdateAttributes(nsIAtom* aAttribute,
47 bool& aResize,
48 bool& aRedraw);
50 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
51 const nsRect& aDirtyRect,
52 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
54 virtual ~nsTextBoxFrame();
56 void PaintTitle(nsRenderingContext& aRenderingContext,
57 const nsRect& aDirtyRect,
58 nsPoint aPt,
59 const nscolor* aOverrideColor);
61 nsRect GetComponentAlphaBounds();
63 virtual bool ComputesOwnOverflowArea() MOZ_OVERRIDE;
65 void GetCroppedTitle(nsString& aTitle) const { aTitle = mCroppedTitle; }
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();
76 // REVIEW: SORRY! Couldn't resist devirtualizing these
77 void LayoutTitle(nsPresContext* aPresContext,
78 nsRenderingContext& aRenderingContext,
79 const nsRect& aRect);
81 void CalculateUnderline(nsRenderingContext& aRenderingContext);
83 void CalcTextSize(nsBoxLayoutState& aBoxLayoutState);
85 void CalcDrawRect(nsRenderingContext &aRenderingContext);
87 nsTextBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext);
89 nscoord CalculateTitleForWidth(nsPresContext* aPresContext,
90 nsRenderingContext& aRenderingContext,
91 nscoord aWidth);
93 void GetTextSize(nsPresContext* aPresContext,
94 nsRenderingContext& aRenderingContext,
95 const nsString& aString,
96 nsSize& aSize,
97 nscoord& aAscent);
99 nsresult RegUnregAccessKey(bool aDoReg);
101 private:
103 bool AlwaysAppendAccessKey();
104 bool InsertSeparatorBeforeAccessKey();
106 void DrawText(nsRenderingContext& aRenderingContext,
107 const nsRect& aDirtyRect,
108 const nsRect& aTextRect,
109 const nscolor* aOverrideColor);
111 nsString mTitle;
112 nsString mCroppedTitle;
113 nsString mAccessKey;
114 nsSize mTextSize;
115 nsRect mTextDrawRect;
116 nsAccessKeyInfo* mAccessKeyInfo;
118 CroppingStyle mCropType;
119 nscoord mAscent;
120 bool mNeedsRecalc;
121 bool mNeedsReflowCallback;
123 static bool gAlwaysAppendAccessKey;
124 static bool gAccessKeyPrefInitialized;
125 static bool gInsertSeparatorBeforeAccessKey;
126 static bool gInsertSeparatorPrefInitialized;
128 }; // class nsTextBoxFrame
130 #endif /* nsTextBoxFrame_h___ */