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