Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/xul/nsTextBoxFrame.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
#ifndef nsTextBoxFrame_h___
7
#define nsTextBoxFrame_h___
8
9
#include "mozilla/Attributes.h"
10
#include "nsLeafBoxFrame.h"
11
12
class nsAccessKeyInfo;
13
class nsAsyncAccesskeyUpdate;
14
class nsFontMetrics;
15
16
class nsTextBoxFrame final : public nsLeafBoxFrame
17
{
18
public:
19
  NS_DECL_QUERYFRAME
20
  NS_DECL_FRAMEARENA_HELPERS(nsTextBoxFrame)
21
22
  virtual nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
23
  virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override;
24
  virtual nscoord GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) override;
25
  NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState) override;
26
  virtual void MarkIntrinsicISizesDirty() override;
27
28
  enum CroppingStyle { CropNone, CropLeft, CropRight, CropCenter, CropAuto };
29
30
  friend nsIFrame* NS_NewTextBoxFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle);
31
32
  virtual void Init(nsIContent*       aContent,
33
                    nsContainerFrame* aParent,
34
                    nsIFrame*         asPrevInFlow) override;
35
36
  virtual void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
37
38
  virtual nsresult AttributeChanged(int32_t         aNameSpaceID,
39
                                    nsAtom*        aAttribute,
40
                                    int32_t         aModType) override;
41
42
#ifdef DEBUG_FRAME_DUMP
43
  virtual nsresult GetFrameName(nsAString& aResult) const override;
44
#endif
45
46
  void UpdateAttributes(nsAtom*         aAttribute,
47
                        bool&          aResize,
48
                        bool&          aRedraw);
49
50
  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
51
                                const nsDisplayListSet& aLists) override;
52
53
  virtual ~nsTextBoxFrame();
54
55
  void PaintTitle(gfxContext&          aRenderingContext,
56
                  const nsRect&        aDirtyRect,
57
                  nsPoint              aPt,
58
                  const nscolor*       aOverrideColor);
59
60
  nsRect GetComponentAlphaBounds() const;
61
62
  virtual bool ComputesOwnOverflowArea() override;
63
64
0
  void GetCroppedTitle(nsString& aTitle) const { aTitle = mCroppedTitle; }
65
66
  virtual void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override;
67
68
protected:
69
  friend class nsAsyncAccesskeyUpdate;
70
  friend class nsDisplayXULTextBox;
71
  // Should be called only by nsAsyncAccesskeyUpdate.
72
  // Returns true if accesskey was updated.
73
  bool UpdateAccesskey(WeakFrame& aWeakThis);
74
  void UpdateAccessTitle();
75
  void UpdateAccessIndex();
76
77
  // Recompute our title, ignoring the access key but taking into
78
  // account text-transform.
79
  void RecomputeTitle();
80
81
  // REVIEW: SORRY! Couldn't resist devirtualizing these
82
  void LayoutTitle(nsPresContext*      aPresContext,
83
                   gfxContext&          aRenderingContext,
84
                   const nsRect&        aRect);
85
86
  void CalculateUnderline(DrawTarget* aDrawTarget, nsFontMetrics& aFontMetrics);
87
88
  void CalcTextSize(nsBoxLayoutState& aBoxLayoutState);
89
90
  void CalcDrawRect(gfxContext &aRenderingContext);
91
92
  explicit nsTextBoxFrame(ComputedStyle* aStyle);
93
94
  nscoord CalculateTitleForWidth(gfxContext&          aRenderingContext,
95
                                 nscoord              aWidth);
96
97
  void GetTextSize(gfxContext&          aRenderingContext,
98
                   const nsString&      aString,
99
                   nsSize&              aSize,
100
                   nscoord&             aAscent);
101
102
  nsresult RegUnregAccessKey(bool aDoReg);
103
104
private:
105
106
  bool AlwaysAppendAccessKey();
107
  bool InsertSeparatorBeforeAccessKey();
108
109
  void DrawText(gfxContext&         aRenderingContext,
110
                const nsRect&       aDirtyRect,
111
                const nsRect&       aTextRect,
112
                const nscolor*      aOverrideColor);
113
114
  nsString mTitle;
115
  nsString mCroppedTitle;
116
  nsString mAccessKey;
117
  nsSize mTextSize;
118
  nsRect mTextDrawRect;
119
  nsAccessKeyInfo* mAccessKeyInfo;
120
121
  CroppingStyle mCropType;
122
  nscoord mAscent;
123
  bool mNeedsRecalc;
124
  bool mNeedsReflowCallback;
125
126
  static bool gAlwaysAppendAccessKey;
127
  static bool gAccessKeyPrefInitialized;
128
  static bool gInsertSeparatorBeforeAccessKey;
129
  static bool gInsertSeparatorPrefInitialized;
130
131
}; // class nsTextBoxFrame
132
133
#endif /* nsTextBoxFrame_h___ */