Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/generic/nsBlockReflowContext.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
/* class that a parent frame uses to reflow a block frame */
8
9
#ifndef nsBlockReflowContext_h___
10
#define nsBlockReflowContext_h___
11
12
#include "nsIFrame.h"
13
#include "mozilla/ReflowOutput.h"
14
15
class nsLineBox;
16
class nsPresContext;
17
namespace mozilla {
18
class BlockReflowInput;
19
} // namespace mozilla
20
21
/**
22
 * An encapsulation of the state and algorithm for reflowing block frames.
23
 */
24
class nsBlockReflowContext {
25
  using BlockReflowInput = mozilla::BlockReflowInput;
26
  using ReflowInput = mozilla::ReflowInput;
27
  using ReflowOutput = mozilla::ReflowOutput;
28
29
public:
30
  nsBlockReflowContext(nsPresContext* aPresContext,
31
                       const ReflowInput& aParentRI);
32
0
  ~nsBlockReflowContext() { }
33
34
  void ReflowBlock(const mozilla::LogicalRect& aSpace,
35
                   bool                        aApplyBStartMargin,
36
                   nsCollapsingMargin&         aPrevMargin,
37
                   nscoord                     aClearance,
38
                   bool                        aIsAdjacentWithBStart,
39
                   nsLineBox*                  aLine,
40
                   ReflowInput&          aReflowInput,
41
                   nsReflowStatus&             aReflowStatus,
42
                   BlockReflowInput&         aState);
43
44
  bool PlaceBlock(const ReflowInput& aReflowInput,
45
                  bool aForceFit,
46
                  nsLineBox* aLine,
47
                  nsCollapsingMargin& aBEndMarginResult /* out */,
48
                  nsOverflowAreas& aOverflowAreas,
49
                  const nsReflowStatus& aReflowStatus);
50
51
0
  nsCollapsingMargin& GetCarriedOutBEndMargin() {
52
0
    return mMetrics.mCarriedOutBEndMargin;
53
0
  }
54
55
0
  const ReflowOutput& GetMetrics() const {
56
0
    return mMetrics;
57
0
  }
58
59
  /**
60
   * Computes the collapsed block-start margin (in the context's parent's
61
   * writing mode) for a block whose reflow state is in aRI.
62
   * The computed margin is added into aMargin, whose writing mode is the
63
   * parent's mode as found in mMetrics.GetWritingMode(); note this may not be
64
   * the block's own writing mode as found in aRI.
65
   * If aClearanceFrame is null then this is the first optimistic pass which
66
   * shall assume that no frames have clearance, and we clear the HasClearance
67
   * on all frames encountered.
68
   * If non-null, this is the second pass and the caller has decided
69
   * aClearanceFrame needs clearance (and we will therefore stop collapsing
70
   * there); also, this function is responsible for marking it with
71
   * SetHasClearance.
72
   * If in the optimistic pass any frame is encountered that might possibly
73
   * need clearance (i.e., if we really needed the optimism assumption) then
74
   * we set aMayNeedRetry to true.
75
   * We return true if we changed the clearance state of any line and marked it
76
   * dirty.
77
   */
78
  bool ComputeCollapsedBStartMargin(const ReflowInput& aRI,
79
                                    nsCollapsingMargin* aMargin,
80
                                    nsIFrame* aClearanceFrame,
81
                                    bool* aMayNeedRetry,
82
                                    bool* aIsEmpty = nullptr);
83
84
protected:
85
  nsPresContext* mPresContext;
86
  const ReflowInput& mOuterReflowInput;
87
88
  nsIFrame* mFrame;
89
  mozilla::LogicalRect mSpace;
90
91
  nscoord mICoord, mBCoord;
92
  nsSize mContainerSize;
93
  mozilla::WritingMode mWritingMode;
94
  ReflowOutput mMetrics;
95
  nsCollapsingMargin mBStartMargin;
96
};
97
98
#endif /* nsBlockReflowContext_h___ */