2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2000-03-31 07:02:06 +00:00
|
|
|
#ifndef nsTextBoxFrame_h___
|
|
|
|
#define nsTextBoxFrame_h___
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2013-05-29 19:37:49 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2000-03-31 07:02:06 +00:00
|
|
|
#include "nsLeafBoxFrame.h"
|
2000-02-16 23:00:52 +00:00
|
|
|
|
|
|
|
class nsAccessKeyInfo;
|
2007-08-10 07:06:13 +00:00
|
|
|
class nsAsyncAccesskeyUpdate;
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2002-02-21 13:39:39 +00:00
|
|
|
typedef nsLeafBoxFrame nsTextBoxFrameSuper;
|
|
|
|
class nsTextBoxFrame : public nsTextBoxFrameSuper
|
2000-02-16 23:00:52 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-03-01 04:06:16 +00:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsTextBoxFrame)
|
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2013-05-29 19:37:49 +00:00
|
|
|
virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
|
|
|
|
virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
|
|
|
|
virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
|
|
|
|
virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE;
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
enum CroppingStyle { CropNone, CropLeft, CropRight, CropCenter };
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
friend nsIFrame* NS_NewTextBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2013-03-20 01:47:48 +00:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* asPrevInFlow) MOZ_OVERRIDE;
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2013-05-29 19:37:49 +00:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
|
2002-02-21 13:39:39 +00:00
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2014-02-18 08:36:33 +00:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType) MOZ_OVERRIDE;
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
|
2001-09-15 00:45:54 +00:00
|
|
|
#endif
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2006-04-10 00:16:29 +00:00
|
|
|
void UpdateAttributes(nsIAtom* aAttribute,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool& aResize,
|
|
|
|
bool& aRedraw);
|
2000-10-08 05:56:55 +00:00
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
2000-10-08 05:56:55 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
virtual ~nsTextBoxFrame();
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2011-04-08 01:04:40 +00:00
|
|
|
void PaintTitle(nsRenderingContext& aRenderingContext,
|
2006-01-26 02:29:17 +00:00
|
|
|
const nsRect& aDirtyRect,
|
2011-07-01 08:21:46 +00:00
|
|
|
nsPoint aPt,
|
|
|
|
const nscolor* aOverrideColor);
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2011-01-03 01:48:09 +00:00
|
|
|
nsRect GetComponentAlphaBounds();
|
|
|
|
|
2013-05-29 19:37:49 +00:00
|
|
|
virtual bool ComputesOwnOverflowArea() MOZ_OVERRIDE;
|
2008-11-25 22:59:06 +00:00
|
|
|
|
2013-03-01 04:06:16 +00:00
|
|
|
void GetCroppedTitle(nsString& aTitle) const { aTitle = mCroppedTitle; }
|
|
|
|
|
2000-02-16 23:00:52 +00:00
|
|
|
protected:
|
2007-08-10 07:06:13 +00:00
|
|
|
friend class nsAsyncAccesskeyUpdate;
|
2011-07-01 06:43:11 +00:00
|
|
|
friend class nsDisplayXULTextBox;
|
2007-08-10 07:06:13 +00:00
|
|
|
// Should be called only by nsAsyncAccesskeyUpdate.
|
2011-10-17 14:59:28 +00:00
|
|
|
// Returns true if accesskey was updated.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool UpdateAccesskey(nsWeakFrame& aWeakThis);
|
2000-10-08 05:56:55 +00:00
|
|
|
void UpdateAccessTitle();
|
|
|
|
void UpdateAccessIndex();
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
// REVIEW: SORRY! Couldn't resist devirtualizing these
|
|
|
|
void LayoutTitle(nsPresContext* aPresContext,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext& aRenderingContext,
|
2006-01-26 02:29:17 +00:00
|
|
|
const nsRect& aRect);
|
2000-10-08 05:56:55 +00:00
|
|
|
|
2011-04-08 01:04:40 +00:00
|
|
|
void CalculateUnderline(nsRenderingContext& aRenderingContext);
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
void CalcTextSize(nsBoxLayoutState& aBoxLayoutState);
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2011-04-08 01:04:40 +00:00
|
|
|
void CalcDrawRect(nsRenderingContext &aRenderingContext);
|
2008-10-01 00:57:51 +00:00
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsTextBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext);
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2011-01-03 01:48:09 +00:00
|
|
|
nscoord CalculateTitleForWidth(nsPresContext* aPresContext,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext& aRenderingContext,
|
2011-01-03 01:48:09 +00:00
|
|
|
nscoord aWidth);
|
2000-10-08 05:56:55 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
void GetTextSize(nsPresContext* aPresContext,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext& aRenderingContext,
|
2006-01-26 02:29:17 +00:00
|
|
|
const nsString& aString,
|
|
|
|
nsSize& aSize,
|
|
|
|
nscoord& aAscent);
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult RegUnregAccessKey(bool aDoReg);
|
2002-02-21 13:39:39 +00:00
|
|
|
|
2000-02-16 23:00:52 +00:00
|
|
|
private:
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool AlwaysAppendAccessKey();
|
|
|
|
bool InsertSeparatorBeforeAccessKey();
|
2001-10-19 20:56:29 +00:00
|
|
|
|
2011-04-08 01:04:40 +00:00
|
|
|
void DrawText(nsRenderingContext& aRenderingContext,
|
2011-09-16 19:23:29 +00:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsRect& aTextRect,
|
|
|
|
const nscolor* aOverrideColor);
|
2008-10-01 00:57:51 +00:00
|
|
|
|
2000-02-16 23:00:52 +00:00
|
|
|
nsString mTitle;
|
|
|
|
nsString mCroppedTitle;
|
2000-10-08 05:56:55 +00:00
|
|
|
nsString mAccessKey;
|
2009-05-12 10:13:09 +00:00
|
|
|
nsSize mTextSize;
|
2011-01-03 01:48:09 +00:00
|
|
|
nsRect mTextDrawRect;
|
2000-02-16 23:00:52 +00:00
|
|
|
nsAccessKeyInfo* mAccessKeyInfo;
|
2009-05-12 10:13:09 +00:00
|
|
|
|
|
|
|
CroppingStyle mCropType;
|
|
|
|
nscoord mAscent;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mNeedsRecalc;
|
|
|
|
bool mNeedsReflowCallback;
|
2002-02-21 13:39:39 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool gAlwaysAppendAccessKey;
|
|
|
|
static bool gAccessKeyPrefInitialized;
|
|
|
|
static bool gInsertSeparatorBeforeAccessKey;
|
|
|
|
static bool gInsertSeparatorPrefInitialized;
|
2002-02-21 13:39:39 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
}; // class nsTextBoxFrame
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
#endif /* nsTextBoxFrame_h___ */
|