2017-10-27 17:33:53 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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;
|
2014-10-24 15:28:14 +00:00
|
|
|
class nsFontMetrics;
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2017-05-02 01:50:16 +00:00
|
|
|
class nsTextBoxFrame final : public nsLeafBoxFrame
|
2000-02-16 23:00:52 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-03-01 04:06:16 +00:00
|
|
|
NS_DECL_QUERYFRAME
|
2017-05-26 10:11:11 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsTextBoxFrame)
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2016-04-21 04:28:31 +00:00
|
|
|
virtual nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
|
2016-04-21 04:28:31 +00:00
|
|
|
virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override;
|
2016-04-21 04:28:32 +00:00
|
|
|
virtual nscoord GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) override;
|
2016-04-21 04:28:35 +00:00
|
|
|
NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState) override;
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void MarkIntrinsicISizesDirty() override;
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2016-02-11 04:12:00 +00:00
|
|
|
enum CroppingStyle { CropNone, CropLeft, CropRight, CropCenter, CropAuto };
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2018-03-22 18:20:41 +00:00
|
|
|
friend nsIFrame* NS_NewTextBoxFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle);
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2014-05-24 22:20:40 +00:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsIFrame* asPrevInFlow) override;
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2017-11-07 00:20:33 +00:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
|
2002-02-21 13:39:39 +00:00
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2017-10-02 22:05:19 +00:00
|
|
|
nsAtom* aAttribute,
|
2015-03-21 16:28:04 +00:00
|
|
|
int32_t aModType) override;
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override;
|
2001-09-15 00:45:54 +00:00
|
|
|
#endif
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2017-10-02 22:05:19 +00:00
|
|
|
void UpdateAttributes(nsAtom* 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,
|
2015-03-21 16:28:04 +00:00
|
|
|
const nsDisplayListSet& aLists) 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
|
|
|
|
2017-06-09 19:14:53 +00:00
|
|
|
void PaintTitle(gfxContext& 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
|
|
|
|
2017-08-24 15:09:44 +00:00
|
|
|
nsRect GetComponentAlphaBounds() const;
|
2011-01-03 01:48:09 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool ComputesOwnOverflowArea() override;
|
2008-11-25 22:59:06 +00:00
|
|
|
|
2013-03-01 04:06:16 +00:00
|
|
|
void GetCroppedTitle(nsString& aTitle) const { aTitle = mCroppedTitle; }
|
|
|
|
|
2018-03-22 18:20:41 +00:00
|
|
|
virtual void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override;
|
2014-05-23 21:32:37 +00:00
|
|
|
|
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.
|
2017-03-01 17:03:14 +00:00
|
|
|
bool UpdateAccesskey(WeakFrame& aWeakThis);
|
2000-10-08 05:56:55 +00:00
|
|
|
void UpdateAccessTitle();
|
|
|
|
void UpdateAccessIndex();
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2014-05-23 21:32:37 +00:00
|
|
|
// Recompute our title, ignoring the access key but taking into
|
|
|
|
// account text-transform.
|
|
|
|
void RecomputeTitle();
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
// REVIEW: SORRY! Couldn't resist devirtualizing these
|
|
|
|
void LayoutTitle(nsPresContext* aPresContext,
|
2017-06-09 19:14:53 +00:00
|
|
|
gfxContext& aRenderingContext,
|
2006-01-26 02:29:17 +00:00
|
|
|
const nsRect& aRect);
|
2000-10-08 05:56:55 +00:00
|
|
|
|
2015-12-15 21:56:41 +00:00
|
|
|
void CalculateUnderline(DrawTarget* aDrawTarget, nsFontMetrics& aFontMetrics);
|
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
|
|
|
|
2017-06-09 19:14:53 +00:00
|
|
|
void CalcDrawRect(gfxContext &aRenderingContext);
|
2008-10-01 00:57:51 +00:00
|
|
|
|
2018-03-22 18:20:41 +00:00
|
|
|
explicit nsTextBoxFrame(ComputedStyle* aStyle);
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2017-06-09 19:14:53 +00:00
|
|
|
nscoord CalculateTitleForWidth(gfxContext& aRenderingContext,
|
2011-01-03 01:48:09 +00:00
|
|
|
nscoord aWidth);
|
2000-10-08 05:56:55 +00:00
|
|
|
|
2017-06-09 19:14:53 +00:00
|
|
|
void GetTextSize(gfxContext& 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
|
|
|
|
2017-06-09 19:14:53 +00:00
|
|
|
void DrawText(gfxContext& 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___ */
|