Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/generic/nsInlineFrame.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
7
/* rendering object for CSS display:inline objects */
8
9
#ifndef nsInlineFrame_h___
10
#define nsInlineFrame_h___
11
12
#include "mozilla/Attributes.h"
13
#include "nsContainerFrame.h"
14
15
class nsLineLayout;
16
17
/**
18
 * Inline frame class.
19
 *
20
 * This class manages a list of child frames that are inline frames. Working with
21
 * nsLineLayout, the class will reflow and place inline frames on a line.
22
 */
23
class nsInlineFrame : public nsContainerFrame
24
{
25
public:
26
  NS_DECL_QUERYFRAME
27
  NS_DECL_FRAMEARENA_HELPERS(nsInlineFrame)
28
29
  friend nsInlineFrame* NS_NewInlineFrame(nsIPresShell* aPresShell,
30
                                          ComputedStyle* aStyle);
31
32
  // nsIFrame overrides
33
  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
34
                                const nsDisplayListSet& aLists) override;
35
36
#ifdef ACCESSIBILITY
37
  virtual mozilla::a11y::AccType AccessibleType() override;
38
#endif
39
40
#ifdef DEBUG_FRAME_DUMP
41
  virtual nsresult GetFrameName(nsAString& aResult) const override;
42
#endif
43
44
  virtual bool IsFrameOfType(uint32_t aFlags) const override
45
0
  {
46
0
    if (aFlags & (eSupportsCSSTransforms | eSupportsContainLayoutAndPaint)) {
47
0
      return false;
48
0
    }
49
0
    return nsContainerFrame::IsFrameOfType(aFlags &
50
0
      ~(nsIFrame::eBidiInlineContainer | nsIFrame::eLineParticipant));
51
0
  }
52
53
  virtual void InvalidateFrame(uint32_t aDisplayItemKey = 0, bool aRebuildDisplayItems = true) override;
54
  virtual void InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey = 0, bool aRebuildDisplayItems = true) override;
55
56
  virtual bool IsEmpty() override;
57
  virtual bool IsSelfEmpty() override;
58
59
  virtual FrameSearchResult
60
  PeekOffsetCharacter(bool aForward, int32_t* aOffset,
61
                      PeekOffsetCharacterOptions aOptions =
62
                        PeekOffsetCharacterOptions()) override;
63
64
  virtual void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
65
  virtual nsresult StealFrame(nsIFrame* aChild) override;
66
67
  // nsIHTMLReflow overrides
68
  virtual void AddInlineMinISize(gfxContext *aRenderingContext,
69
                                 InlineMinISizeData *aData) override;
70
  virtual void AddInlinePrefISize(gfxContext *aRenderingContext,
71
                                  InlinePrefISizeData *aData) override;
72
  virtual mozilla::LogicalSize
73
  ComputeSize(gfxContext *aRenderingContext,
74
              mozilla::WritingMode aWritingMode,
75
              const mozilla::LogicalSize& aCBSize,
76
              nscoord aAvailableISize,
77
              const mozilla::LogicalSize& aMargin,
78
              const mozilla::LogicalSize& aBorder,
79
              const mozilla::LogicalSize& aPadding,
80
              ComputeSizeFlags aFlags) override;
81
  virtual nsRect ComputeTightBounds(DrawTarget* aDrawTarget) const override;
82
  virtual void Reflow(nsPresContext* aPresContext,
83
                      ReflowOutput& aDesiredSize,
84
                      const ReflowInput& aReflowInput,
85
                      nsReflowStatus& aStatus) override;
86
87
  virtual nsresult AttributeChanged(int32_t aNameSpaceID,
88
                                    nsAtom* aAttribute,
89
                                    int32_t aModType) override;
90
91
  virtual bool CanContinueTextRun() const override;
92
93
  virtual void PullOverflowsFromPrevInFlow() override;
94
  virtual nscoord GetLogicalBaseline(mozilla::WritingMode aWritingMode) const override;
95
  virtual bool DrainSelfOverflowList() override;
96
97
  /**
98
   * Return true if the frame is first visual frame or first continuation
99
   */
100
0
  bool IsFirst() const {
101
0
    // If the frame's bidi visual state is set, return is-first state
102
0
    // else return true if it's the first continuation.
103
0
    return (GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET)
104
0
             ? !!(GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_IS_FIRST)
105
0
             : (!GetPrevInFlow());
106
0
  }
107
108
  /**
109
   * Return true if the frame is last visual frame or last continuation.
110
   */
111
0
  bool IsLast() const {
112
0
    // If the frame's bidi visual state is set, return is-last state
113
0
    // else return true if it's the last continuation.
114
0
    return (GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET)
115
0
             ? !!(GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_IS_LAST)
116
0
             : (!GetNextInFlow());
117
0
  }
118
119
  // Restyles the block wrappers around our non-inline-outside kids.
120
  // This will only be called when such wrappers in fact exist.
121
  void UpdateStyleOfOwnedAnonBoxesForIBSplit(
122
    mozilla::ServoRestyleState& aRestyleState);
123
124
protected:
125
  // Additional reflow state used during our reflow methods
126
  struct InlineReflowInput {
127
    nsIFrame* mPrevFrame;
128
    nsInlineFrame* mNextInFlow;
129
    nsIFrame*      mLineContainer;
130
    nsLineLayout*  mLineLayout;
131
    bool mSetParentPointer;  // when reflowing child frame first set its
132
                                     // parent frame pointer
133
134
0
    InlineReflowInput()  {
135
0
      mPrevFrame = nullptr;
136
0
      mNextInFlow = nullptr;
137
0
      mLineContainer = nullptr;
138
0
      mLineLayout = nullptr;
139
0
      mSetParentPointer = false;
140
0
    }
141
  };
142
143
  nsInlineFrame(ComputedStyle* aStyle, ClassID aID)
144
    : nsContainerFrame(aStyle, aID)
145
    , mBaseline(NS_INTRINSIC_WIDTH_UNKNOWN)
146
0
  {}
147
148
  virtual LogicalSides GetLogicalSkipSides(const ReflowInput* aReflowInput = nullptr) const override;
149
150
  void ReflowFrames(nsPresContext* aPresContext,
151
                    const ReflowInput& aReflowInput,
152
                    InlineReflowInput& rs,
153
                    ReflowOutput& aMetrics,
154
                    nsReflowStatus& aStatus);
155
156
  void ReflowInlineFrame(nsPresContext* aPresContext,
157
                         const ReflowInput& aReflowInput,
158
                         InlineReflowInput& rs,
159
                         nsIFrame* aFrame,
160
                         nsReflowStatus& aStatus);
161
162
  // Returns whether there's any frame that PullOneFrame would pull from
163
  // aNextInFlow or any of aNextInFlow's next-in-flows.
164
  static bool HasFramesToPull(nsInlineFrame* aNextInFlow);
165
166
  virtual nsIFrame* PullOneFrame(nsPresContext*, InlineReflowInput&);
167
168
  virtual void PushFrames(nsPresContext* aPresContext,
169
                          nsIFrame* aFromChild,
170
                          nsIFrame* aPrevSibling,
171
                          InlineReflowInput& aState);
172
173
private:
174
  explicit nsInlineFrame(ComputedStyle* aStyle)
175
    : nsInlineFrame(aStyle, kClassID)
176
0
  {}
177
178
  /**
179
   * Move any frames on our overflow list to the end of our principal list.
180
   * @param aInFirstLine whether we're in a first-line frame.
181
   * @return true if there were any overflow frames
182
   */
183
  bool DrainSelfOverflowListInternal(bool aInFirstLine);
184
protected:
185
  nscoord mBaseline;
186
};
187
188
//----------------------------------------------------------------------
189
190
/**
191
 * Variation on inline-frame used to manage lines for line layout in
192
 * special situations (:first-line style in particular).
193
 */
194
class nsFirstLineFrame final : public nsInlineFrame {
195
public:
196
  NS_DECL_FRAMEARENA_HELPERS(nsFirstLineFrame)
197
198
  friend nsFirstLineFrame* NS_NewFirstLineFrame(nsIPresShell* aPresShell,
199
                                                ComputedStyle* aStyle);
200
201
#ifdef DEBUG_FRAME_DUMP
202
  virtual nsresult GetFrameName(nsAString& aResult) const override;
203
#endif
204
  virtual void Reflow(nsPresContext* aPresContext,
205
                      ReflowOutput& aDesiredSize,
206
                      const ReflowInput& aReflowInput,
207
                      nsReflowStatus& aStatus) override;
208
209
  virtual void Init(nsIContent*       aContent,
210
                    nsContainerFrame* aParent,
211
                    nsIFrame*         aPrevInFlow) override;
212
  virtual void PullOverflowsFromPrevInFlow() override;
213
  virtual bool DrainSelfOverflowList() override;
214
215
protected:
216
  explicit nsFirstLineFrame(ComputedStyle* aStyle)
217
    : nsInlineFrame(aStyle, kClassID)
218
0
  {}
219
220
  nsIFrame* PullOneFrame(nsPresContext*, InlineReflowInput&) override;
221
};
222
223
#endif /* nsInlineFrame_h___ */