layout/xul/nsBoxLayoutState.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/xul/nsBoxLayoutState.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/**
    1.10 + 
    1.11 +  Author:
    1.12 +  Eric D Vaughan
    1.13 +
    1.14 +**/
    1.15 +
    1.16 +#ifndef nsBoxLayoutState_h___
    1.17 +#define nsBoxLayoutState_h___
    1.18 +
    1.19 +#include "nsCOMPtr.h"
    1.20 +#include "nsPresContext.h"
    1.21 +#include "nsIPresShell.h"
    1.22 +
    1.23 +class nsRenderingContext;
    1.24 +class nsCalculatedBoxInfo;
    1.25 +struct nsHTMLReflowMetrics;
    1.26 +struct nsHTMLReflowState;
    1.27 +class nsString;
    1.28 +class nsHTMLReflowCommand;
    1.29 +
    1.30 +class MOZ_STACK_CLASS nsBoxLayoutState
    1.31 +{
    1.32 +public:
    1.33 +  nsBoxLayoutState(nsPresContext* aPresContext,
    1.34 +                   nsRenderingContext* aRenderingContext = nullptr,
    1.35 +                   // see OuterReflowState() below
    1.36 +                   const nsHTMLReflowState* aOuterReflowState = nullptr,
    1.37 +                   uint16_t aReflowDepth = 0) NS_HIDDEN;
    1.38 +  nsBoxLayoutState(const nsBoxLayoutState& aState) NS_HIDDEN;
    1.39 +
    1.40 +  nsPresContext* PresContext() const { return mPresContext; }
    1.41 +  nsIPresShell* PresShell() const { return mPresContext->PresShell(); }
    1.42 +
    1.43 +  uint32_t LayoutFlags() const { return mLayoutFlags; }
    1.44 +  void SetLayoutFlags(uint32_t aFlags) { mLayoutFlags = aFlags; }
    1.45 +
    1.46 +  // if true no one under us will paint during reflow.
    1.47 +  void SetPaintingDisabled(bool aDisable) { mPaintingDisabled = aDisable; }
    1.48 +  bool PaintingDisabled() const { return mPaintingDisabled; }
    1.49 +
    1.50 +  // The rendering context may be null for specialized uses of
    1.51 +  // nsBoxLayoutState and should be null-checked before it is used.
    1.52 +  // However, passing a null rendering context to the constructor when
    1.53 +  // doing box layout or intrinsic size calculation will cause bugs.
    1.54 +  nsRenderingContext* GetRenderingContext() const { return mRenderingContext; }
    1.55 +
    1.56 +  struct AutoReflowDepth {
    1.57 +    AutoReflowDepth(nsBoxLayoutState& aState)
    1.58 +      : mState(aState) { ++mState.mReflowDepth; }
    1.59 +    ~AutoReflowDepth() { --mState.mReflowDepth; }
    1.60 +    nsBoxLayoutState& mState;
    1.61 +  };
    1.62 +
    1.63 +  // The HTML reflow state that lives outside the box-block boundary.
    1.64 +  // May not be set reliably yet.
    1.65 +  const nsHTMLReflowState* OuterReflowState() { return mOuterReflowState; }
    1.66 +
    1.67 +  uint16_t GetReflowDepth() { return mReflowDepth; }
    1.68 +  
    1.69 +private:
    1.70 +  nsRefPtr<nsPresContext> mPresContext;
    1.71 +  nsRenderingContext *mRenderingContext;
    1.72 +  const nsHTMLReflowState *mOuterReflowState;
    1.73 +  uint32_t mLayoutFlags;
    1.74 +  uint16_t mReflowDepth; 
    1.75 +  bool mPaintingDisabled;
    1.76 +};
    1.77 +
    1.78 +#endif
    1.79 +

mercurial