Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/xul/nsBoxLayoutState.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
9
  Author:
10
  Eric D Vaughan
11
12
**/
13
14
#ifndef nsBoxLayoutState_h___
15
#define nsBoxLayoutState_h___
16
17
#include "nsCOMPtr.h"
18
#include "nsPresContext.h"
19
#include "nsIPresShell.h"
20
21
class gfxContext;
22
namespace mozilla {
23
struct ReflowInput;
24
} // namespace mozilla
25
26
27
class MOZ_STACK_CLASS nsBoxLayoutState
28
{
29
  using ReflowInput = mozilla::ReflowInput;
30
31
public:
32
  explicit nsBoxLayoutState(nsPresContext* aPresContext,
33
                            gfxContext* aRenderingContext = nullptr,
34
                            // see OuterReflowInput() below
35
                            const ReflowInput* aOuterReflowInput = nullptr,
36
                            uint16_t aReflowDepth = 0);
37
  nsBoxLayoutState(const nsBoxLayoutState& aState);
38
39
0
  nsPresContext* PresContext() const { return mPresContext; }
40
0
  nsIPresShell* PresShell() const { return mPresContext->PresShell(); }
41
42
0
  uint32_t LayoutFlags() const { return mLayoutFlags; }
43
0
  void SetLayoutFlags(uint32_t aFlags) { mLayoutFlags = aFlags; }
44
45
  // if true no one under us will paint during reflow.
46
0
  void SetPaintingDisabled(bool aDisable) { mPaintingDisabled = aDisable; }
47
0
  bool PaintingDisabled() const { return mPaintingDisabled; }
48
49
  // The rendering context may be null for specialized uses of
50
  // nsBoxLayoutState and should be null-checked before it is used.
51
  // However, passing a null rendering context to the constructor when
52
  // doing box layout or intrinsic size calculation will cause bugs.
53
0
  gfxContext* GetRenderingContext() const { return mRenderingContext; }
54
55
  struct AutoReflowDepth {
56
    explicit AutoReflowDepth(nsBoxLayoutState& aState)
57
0
      : mState(aState) { ++mState.mReflowDepth; }
58
0
    ~AutoReflowDepth() { --mState.mReflowDepth; }
59
    nsBoxLayoutState& mState;
60
  };
61
62
  // The HTML reflow state that lives outside the box-block boundary.
63
  // May not be set reliably yet.
64
0
  const ReflowInput* OuterReflowInput() { return mOuterReflowInput; }
65
66
0
  uint16_t GetReflowDepth() { return mReflowDepth; }
67
68
private:
69
  RefPtr<nsPresContext> mPresContext;
70
  gfxContext *mRenderingContext;
71
  const ReflowInput *mOuterReflowInput;
72
  uint32_t mLayoutFlags;
73
  uint16_t mReflowDepth;
74
  bool mPaintingDisabled;
75
};
76
77
#endif
78