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