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