michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /** michael@0: michael@0: Author: michael@0: Eric D Vaughan michael@0: michael@0: **/ michael@0: michael@0: #ifndef nsBoxLayoutState_h___ michael@0: #define nsBoxLayoutState_h___ michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsPresContext.h" michael@0: #include "nsIPresShell.h" michael@0: michael@0: class nsRenderingContext; michael@0: class nsCalculatedBoxInfo; michael@0: struct nsHTMLReflowMetrics; michael@0: struct nsHTMLReflowState; michael@0: class nsString; michael@0: class nsHTMLReflowCommand; michael@0: michael@0: class MOZ_STACK_CLASS nsBoxLayoutState michael@0: { michael@0: public: michael@0: nsBoxLayoutState(nsPresContext* aPresContext, michael@0: nsRenderingContext* aRenderingContext = nullptr, michael@0: // see OuterReflowState() below michael@0: const nsHTMLReflowState* aOuterReflowState = nullptr, michael@0: uint16_t aReflowDepth = 0) NS_HIDDEN; michael@0: nsBoxLayoutState(const nsBoxLayoutState& aState) NS_HIDDEN; michael@0: michael@0: nsPresContext* PresContext() const { return mPresContext; } michael@0: nsIPresShell* PresShell() const { return mPresContext->PresShell(); } michael@0: michael@0: uint32_t LayoutFlags() const { return mLayoutFlags; } michael@0: void SetLayoutFlags(uint32_t aFlags) { mLayoutFlags = aFlags; } michael@0: michael@0: // if true no one under us will paint during reflow. michael@0: void SetPaintingDisabled(bool aDisable) { mPaintingDisabled = aDisable; } michael@0: bool PaintingDisabled() const { return mPaintingDisabled; } michael@0: michael@0: // The rendering context may be null for specialized uses of michael@0: // nsBoxLayoutState and should be null-checked before it is used. michael@0: // However, passing a null rendering context to the constructor when michael@0: // doing box layout or intrinsic size calculation will cause bugs. michael@0: nsRenderingContext* GetRenderingContext() const { return mRenderingContext; } michael@0: michael@0: struct AutoReflowDepth { michael@0: AutoReflowDepth(nsBoxLayoutState& aState) michael@0: : mState(aState) { ++mState.mReflowDepth; } michael@0: ~AutoReflowDepth() { --mState.mReflowDepth; } michael@0: nsBoxLayoutState& mState; michael@0: }; michael@0: michael@0: // The HTML reflow state that lives outside the box-block boundary. michael@0: // May not be set reliably yet. michael@0: const nsHTMLReflowState* OuterReflowState() { return mOuterReflowState; } michael@0: michael@0: uint16_t GetReflowDepth() { return mReflowDepth; } michael@0: michael@0: private: michael@0: nsRefPtr mPresContext; michael@0: nsRenderingContext *mRenderingContext; michael@0: const nsHTMLReflowState *mOuterReflowState; michael@0: uint32_t mLayoutFlags; michael@0: uint16_t mReflowDepth; michael@0: bool mPaintingDisabled; michael@0: }; michael@0: michael@0: #endif michael@0: