Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : /**
7 :
8 : Author:
9 : Eric D Vaughan
10 :
11 : **/
12 :
13 : #ifndef nsBoxLayoutState_h___
14 : #define nsBoxLayoutState_h___
15 :
16 : #include "nsCOMPtr.h"
17 : #include "nsPresContext.h"
18 : #include "nsIPresShell.h"
19 :
20 : class gfxContext;
21 : namespace mozilla {
22 : struct ReflowInput;
23 : } // namespace mozilla
24 :
25 :
26 1787 : class MOZ_STACK_CLASS nsBoxLayoutState
27 : {
28 : using ReflowInput = mozilla::ReflowInput;
29 :
30 : public:
31 : explicit nsBoxLayoutState(nsPresContext* aPresContext,
32 : gfxContext* aRenderingContext = nullptr,
33 : // see OuterReflowInput() below
34 : const ReflowInput* aOuterReflowInput = nullptr,
35 : uint16_t aReflowDepth = 0);
36 : nsBoxLayoutState(const nsBoxLayoutState& aState);
37 :
38 1543 : nsPresContext* PresContext() const { return mPresContext; }
39 0 : nsIPresShell* PresShell() const { return mPresContext->PresShell(); }
40 :
41 3732 : uint32_t LayoutFlags() const { return mLayoutFlags; }
42 1362 : void SetLayoutFlags(uint32_t aFlags) { mLayoutFlags = aFlags; }
43 :
44 : // if true no one under us will paint during reflow.
45 0 : void SetPaintingDisabled(bool aDisable) { mPaintingDisabled = aDisable; }
46 437 : bool PaintingDisabled() const { return mPaintingDisabled; }
47 :
48 : // The rendering context may be null for specialized uses of
49 : // nsBoxLayoutState and should be null-checked before it is used.
50 : // However, passing a null rendering context to the constructor when
51 : // doing box layout or intrinsic size calculation will cause bugs.
52 8490 : gfxContext* GetRenderingContext() const { return mRenderingContext; }
53 :
54 : struct AutoReflowDepth {
55 438 : explicit AutoReflowDepth(nsBoxLayoutState& aState)
56 438 : : mState(aState) { ++mState.mReflowDepth; }
57 438 : ~AutoReflowDepth() { --mState.mReflowDepth; }
58 : nsBoxLayoutState& mState;
59 : };
60 :
61 : // The HTML reflow state that lives outside the box-block boundary.
62 : // May not be set reliably yet.
63 378 : const ReflowInput* OuterReflowInput() { return mOuterReflowInput; }
64 :
65 126 : uint16_t GetReflowDepth() { return mReflowDepth; }
66 :
67 : private:
68 : RefPtr<nsPresContext> mPresContext;
69 : gfxContext *mRenderingContext;
70 : const ReflowInput *mOuterReflowInput;
71 : uint32_t mLayoutFlags;
72 : uint16_t mReflowDepth;
73 : bool mPaintingDisabled;
74 : };
75 :
76 : #endif
77 :
|