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: #ifndef nsTextBoxFrame_h___ michael@0: #define nsTextBoxFrame_h___ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsLeafBoxFrame.h" michael@0: michael@0: class nsAccessKeyInfo; michael@0: class nsAsyncAccesskeyUpdate; michael@0: michael@0: typedef nsLeafBoxFrame nsTextBoxFrameSuper; michael@0: class nsTextBoxFrame : public nsTextBoxFrameSuper michael@0: { michael@0: public: michael@0: NS_DECL_QUERYFRAME_TARGET(nsTextBoxFrame) michael@0: NS_DECL_QUERYFRAME michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; michael@0: virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; michael@0: virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; michael@0: NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; michael@0: virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE; michael@0: michael@0: enum CroppingStyle { CropNone, CropLeft, CropRight, CropCenter }; michael@0: michael@0: friend nsIFrame* NS_NewTextBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); michael@0: michael@0: virtual void Init(nsIContent* aContent, michael@0: nsIFrame* aParent, michael@0: nsIFrame* asPrevInFlow) MOZ_OVERRIDE; michael@0: michael@0: virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult AttributeChanged(int32_t aNameSpaceID, michael@0: nsIAtom* aAttribute, michael@0: int32_t aModType) MOZ_OVERRIDE; michael@0: michael@0: #ifdef DEBUG_FRAME_DUMP michael@0: virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: void UpdateAttributes(nsIAtom* aAttribute, michael@0: bool& aResize, michael@0: bool& aRedraw); michael@0: michael@0: virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, michael@0: const nsRect& aDirtyRect, michael@0: const nsDisplayListSet& aLists) MOZ_OVERRIDE; michael@0: michael@0: virtual ~nsTextBoxFrame(); michael@0: michael@0: void PaintTitle(nsRenderingContext& aRenderingContext, michael@0: const nsRect& aDirtyRect, michael@0: nsPoint aPt, michael@0: const nscolor* aOverrideColor); michael@0: michael@0: nsRect GetComponentAlphaBounds(); michael@0: michael@0: virtual bool ComputesOwnOverflowArea() MOZ_OVERRIDE; michael@0: michael@0: void GetCroppedTitle(nsString& aTitle) const { aTitle = mCroppedTitle; } michael@0: michael@0: protected: michael@0: friend class nsAsyncAccesskeyUpdate; michael@0: friend class nsDisplayXULTextBox; michael@0: // Should be called only by nsAsyncAccesskeyUpdate. michael@0: // Returns true if accesskey was updated. michael@0: bool UpdateAccesskey(nsWeakFrame& aWeakThis); michael@0: void UpdateAccessTitle(); michael@0: void UpdateAccessIndex(); michael@0: michael@0: // REVIEW: SORRY! Couldn't resist devirtualizing these michael@0: void LayoutTitle(nsPresContext* aPresContext, michael@0: nsRenderingContext& aRenderingContext, michael@0: const nsRect& aRect); michael@0: michael@0: void CalculateUnderline(nsRenderingContext& aRenderingContext); michael@0: michael@0: void CalcTextSize(nsBoxLayoutState& aBoxLayoutState); michael@0: michael@0: void CalcDrawRect(nsRenderingContext &aRenderingContext); michael@0: michael@0: nsTextBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext); michael@0: michael@0: nscoord CalculateTitleForWidth(nsPresContext* aPresContext, michael@0: nsRenderingContext& aRenderingContext, michael@0: nscoord aWidth); michael@0: michael@0: void GetTextSize(nsPresContext* aPresContext, michael@0: nsRenderingContext& aRenderingContext, michael@0: const nsString& aString, michael@0: nsSize& aSize, michael@0: nscoord& aAscent); michael@0: michael@0: nsresult RegUnregAccessKey(bool aDoReg); michael@0: michael@0: private: michael@0: michael@0: bool AlwaysAppendAccessKey(); michael@0: bool InsertSeparatorBeforeAccessKey(); michael@0: michael@0: void DrawText(nsRenderingContext& aRenderingContext, michael@0: const nsRect& aDirtyRect, michael@0: const nsRect& aTextRect, michael@0: const nscolor* aOverrideColor); michael@0: michael@0: nsString mTitle; michael@0: nsString mCroppedTitle; michael@0: nsString mAccessKey; michael@0: nsSize mTextSize; michael@0: nsRect mTextDrawRect; michael@0: nsAccessKeyInfo* mAccessKeyInfo; michael@0: michael@0: CroppingStyle mCropType; michael@0: nscoord mAscent; michael@0: bool mNeedsRecalc; michael@0: bool mNeedsReflowCallback; michael@0: michael@0: static bool gAlwaysAppendAccessKey; michael@0: static bool gAccessKeyPrefInitialized; michael@0: static bool gInsertSeparatorBeforeAccessKey; michael@0: static bool gInsertSeparatorPrefInitialized; michael@0: michael@0: }; // class nsTextBoxFrame michael@0: michael@0: #endif /* nsTextBoxFrame_h___ */