Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/generic/nsSplittableFrame.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
/*
8
 * base class for rendering objects that can be split across lines,
9
 * columns, or pages
10
 */
11
12
#ifndef nsSplittableFrame_h___
13
#define nsSplittableFrame_h___
14
15
#include "mozilla/Attributes.h"
16
#include "nsFrame.h"
17
18
// Derived class that allows splitting
19
class nsSplittableFrame : public nsFrame
20
{
21
public:
22
  NS_DECL_ABSTRACT_FRAME(nsSplittableFrame)
23
24
  void Init(nsIContent*       aContent,
25
            nsContainerFrame* aParent,
26
            nsIFrame*         aPrevInFlow) override;
27
28
  nsSplittableType GetSplittableType() const override;
29
30
  void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
31
32
  /*
33
   * Frame continuations can be either fluid or not:
34
   * Fluid continuations ("in-flows") are the result of line breaking,
35
   * column breaking, or page breaking.
36
   * Other (non-fluid) continuations can be the result of BiDi frame splitting.
37
   * A "flow" is a chain of fluid continuations.
38
   */
39
40
  // Get the previous/next continuation, regardless of its type (fluid or non-fluid).
41
  nsIFrame* GetPrevContinuation() const final;
42
  nsIFrame* GetNextContinuation() const final;
43
44
  // Set a previous/next non-fluid continuation.
45
  void SetPrevContinuation(nsIFrame*) final;
46
  void SetNextContinuation(nsIFrame*) final;
47
48
  // Get the first/last continuation for this frame.
49
  nsIFrame* FirstContinuation() const final;
50
  nsIFrame* LastContinuation() const final;
51
52
#ifdef DEBUG
53
  // Can aFrame2 be reached from aFrame1 by following prev/next continuations?
54
  static bool IsInPrevContinuationChain(nsIFrame* aFrame1, nsIFrame* aFrame2);
55
  static bool IsInNextContinuationChain(nsIFrame* aFrame1, nsIFrame* aFrame2);
56
#endif
57
58
  // Get the previous/next continuation, only if it is fluid (an "in-flow").
59
  nsIFrame* GetPrevInFlow() const;
60
  nsIFrame* GetNextInFlow() const;
61
62
0
  nsIFrame* GetPrevInFlowVirtual() const final { return GetPrevInFlow(); }
63
0
  nsIFrame* GetNextInFlowVirtual() const final { return GetNextInFlow(); }
64
65
  // Set a previous/next fluid continuation.
66
  void SetPrevInFlow(nsIFrame*) final;
67
  void SetNextInFlow(nsIFrame*) final;
68
69
  // Get the first/last frame in the current flow.
70
  nsIFrame* FirstInFlow() const final;
71
  nsIFrame* LastInFlow() const final;
72
73
  // Remove the frame from the flow. Connects the frame's prev-in-flow
74
  // and its next-in-flow. This should only be called in frame Destroy() methods.
75
  static void RemoveFromFlow(nsIFrame* aFrame);
76
77
protected:
78
  nsSplittableFrame(ComputedStyle* aStyle, ClassID aID)
79
    : nsFrame(aStyle, aID)
80
    , mPrevContinuation(nullptr)
81
    , mNextContinuation(nullptr)
82
0
  {}
83
84
  /**
85
   * Return the sum of the block-axis content size of our prev-in-flows.
86
   * @param aWM a writing-mode to determine the block-axis
87
   *
88
   * @note (bz) This makes laying out a splittable frame with N in-flows
89
   *       O(N^2)! So, use this function with caution and minimize the number
90
   *       of calls to this method.
91
   */
92
  nscoord ConsumedBSize(mozilla::WritingMode aWM) const;
93
94
  /**
95
   * Retrieve the effective computed block size of this frame, which is the
96
   * computed block size, minus the block size consumed by any previous in-flows.
97
   */
98
  nscoord GetEffectiveComputedBSize(const ReflowInput& aReflowInput,
99
                                    nscoord aConsumed = NS_INTRINSICSIZE) const;
100
101
  /**
102
   * @see nsIFrame::GetLogicalSkipSides()
103
   */
104
  LogicalSides GetLogicalSkipSides(const ReflowInput* aReflowInput = nullptr) const override;
105
106
  /**
107
   * A faster version of GetLogicalSkipSides() that is intended to be used
108
   * inside Reflow before it's known if |this| frame will be COMPLETE or not.
109
   * It returns a result that assumes this fragment is the last and thus
110
   * should apply the block-end border/padding etc (except for "true" overflow
111
   * containers which always skip block sides).  You're then expected to
112
   * recalculate the block-end side (as needed) when you know |this| frame's
113
   * reflow status is INCOMPLETE.
114
   * This method is intended for frames that breaks in the block axis.
115
   */
116
  LogicalSides PreReflowBlockLevelLogicalSkipSides() const;
117
118
  nsIFrame*   mPrevContinuation;
119
  nsIFrame*   mNextContinuation;
120
};
121
122
#endif /* nsSplittableFrame_h___ */