1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/xul/nsTextBoxFrame.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,130 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 +#ifndef nsTextBoxFrame_h___ 1.9 +#define nsTextBoxFrame_h___ 1.10 + 1.11 +#include "mozilla/Attributes.h" 1.12 +#include "nsLeafBoxFrame.h" 1.13 + 1.14 +class nsAccessKeyInfo; 1.15 +class nsAsyncAccesskeyUpdate; 1.16 + 1.17 +typedef nsLeafBoxFrame nsTextBoxFrameSuper; 1.18 +class nsTextBoxFrame : public nsTextBoxFrameSuper 1.19 +{ 1.20 +public: 1.21 + NS_DECL_QUERYFRAME_TARGET(nsTextBoxFrame) 1.22 + NS_DECL_QUERYFRAME 1.23 + NS_DECL_FRAMEARENA_HELPERS 1.24 + 1.25 + virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; 1.26 + virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; 1.27 + virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; 1.28 + NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; 1.29 + virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE; 1.30 + 1.31 + enum CroppingStyle { CropNone, CropLeft, CropRight, CropCenter }; 1.32 + 1.33 + friend nsIFrame* NS_NewTextBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); 1.34 + 1.35 + virtual void Init(nsIContent* aContent, 1.36 + nsIFrame* aParent, 1.37 + nsIFrame* asPrevInFlow) MOZ_OVERRIDE; 1.38 + 1.39 + virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; 1.40 + 1.41 + virtual nsresult AttributeChanged(int32_t aNameSpaceID, 1.42 + nsIAtom* aAttribute, 1.43 + int32_t aModType) MOZ_OVERRIDE; 1.44 + 1.45 +#ifdef DEBUG_FRAME_DUMP 1.46 + virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; 1.47 +#endif 1.48 + 1.49 + void UpdateAttributes(nsIAtom* aAttribute, 1.50 + bool& aResize, 1.51 + bool& aRedraw); 1.52 + 1.53 + virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, 1.54 + const nsRect& aDirtyRect, 1.55 + const nsDisplayListSet& aLists) MOZ_OVERRIDE; 1.56 + 1.57 + virtual ~nsTextBoxFrame(); 1.58 + 1.59 + void PaintTitle(nsRenderingContext& aRenderingContext, 1.60 + const nsRect& aDirtyRect, 1.61 + nsPoint aPt, 1.62 + const nscolor* aOverrideColor); 1.63 + 1.64 + nsRect GetComponentAlphaBounds(); 1.65 + 1.66 + virtual bool ComputesOwnOverflowArea() MOZ_OVERRIDE; 1.67 + 1.68 + void GetCroppedTitle(nsString& aTitle) const { aTitle = mCroppedTitle; } 1.69 + 1.70 +protected: 1.71 + friend class nsAsyncAccesskeyUpdate; 1.72 + friend class nsDisplayXULTextBox; 1.73 + // Should be called only by nsAsyncAccesskeyUpdate. 1.74 + // Returns true if accesskey was updated. 1.75 + bool UpdateAccesskey(nsWeakFrame& aWeakThis); 1.76 + void UpdateAccessTitle(); 1.77 + void UpdateAccessIndex(); 1.78 + 1.79 + // REVIEW: SORRY! Couldn't resist devirtualizing these 1.80 + void LayoutTitle(nsPresContext* aPresContext, 1.81 + nsRenderingContext& aRenderingContext, 1.82 + const nsRect& aRect); 1.83 + 1.84 + void CalculateUnderline(nsRenderingContext& aRenderingContext); 1.85 + 1.86 + void CalcTextSize(nsBoxLayoutState& aBoxLayoutState); 1.87 + 1.88 + void CalcDrawRect(nsRenderingContext &aRenderingContext); 1.89 + 1.90 + nsTextBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext); 1.91 + 1.92 + nscoord CalculateTitleForWidth(nsPresContext* aPresContext, 1.93 + nsRenderingContext& aRenderingContext, 1.94 + nscoord aWidth); 1.95 + 1.96 + void GetTextSize(nsPresContext* aPresContext, 1.97 + nsRenderingContext& aRenderingContext, 1.98 + const nsString& aString, 1.99 + nsSize& aSize, 1.100 + nscoord& aAscent); 1.101 + 1.102 + nsresult RegUnregAccessKey(bool aDoReg); 1.103 + 1.104 +private: 1.105 + 1.106 + bool AlwaysAppendAccessKey(); 1.107 + bool InsertSeparatorBeforeAccessKey(); 1.108 + 1.109 + void DrawText(nsRenderingContext& aRenderingContext, 1.110 + const nsRect& aDirtyRect, 1.111 + const nsRect& aTextRect, 1.112 + const nscolor* aOverrideColor); 1.113 + 1.114 + nsString mTitle; 1.115 + nsString mCroppedTitle; 1.116 + nsString mAccessKey; 1.117 + nsSize mTextSize; 1.118 + nsRect mTextDrawRect; 1.119 + nsAccessKeyInfo* mAccessKeyInfo; 1.120 + 1.121 + CroppingStyle mCropType; 1.122 + nscoord mAscent; 1.123 + bool mNeedsRecalc; 1.124 + bool mNeedsReflowCallback; 1.125 + 1.126 + static bool gAlwaysAppendAccessKey; 1.127 + static bool gAccessKeyPrefInitialized; 1.128 + static bool gInsertSeparatorBeforeAccessKey; 1.129 + static bool gInsertSeparatorPrefInitialized; 1.130 + 1.131 +}; // class nsTextBoxFrame 1.132 + 1.133 +#endif /* nsTextBoxFrame_h___ */