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