layout/xul/nsBoxLayoutState.h

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing 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/. */
     6 /**
     8   Author:
     9   Eric D Vaughan
    11 **/
    13 #ifndef nsBoxLayoutState_h___
    14 #define nsBoxLayoutState_h___
    16 #include "nsCOMPtr.h"
    17 #include "nsPresContext.h"
    18 #include "nsIPresShell.h"
    20 class nsRenderingContext;
    21 class nsCalculatedBoxInfo;
    22 struct nsHTMLReflowMetrics;
    23 struct nsHTMLReflowState;
    24 class nsString;
    25 class nsHTMLReflowCommand;
    27 class MOZ_STACK_CLASS nsBoxLayoutState
    28 {
    29 public:
    30   nsBoxLayoutState(nsPresContext* aPresContext,
    31                    nsRenderingContext* aRenderingContext = nullptr,
    32                    // see OuterReflowState() below
    33                    const nsHTMLReflowState* aOuterReflowState = nullptr,
    34                    uint16_t aReflowDepth = 0) NS_HIDDEN;
    35   nsBoxLayoutState(const nsBoxLayoutState& aState) NS_HIDDEN;
    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   nsRenderingContext* GetRenderingContext() const { return mRenderingContext; }
    53   struct AutoReflowDepth {
    54     AutoReflowDepth(nsBoxLayoutState& aState)
    55       : mState(aState) { ++mState.mReflowDepth; }
    56     ~AutoReflowDepth() { --mState.mReflowDepth; }
    57     nsBoxLayoutState& mState;
    58   };
    60   // The HTML reflow state that lives outside the box-block boundary.
    61   // May not be set reliably yet.
    62   const nsHTMLReflowState* OuterReflowState() { return mOuterReflowState; }
    64   uint16_t GetReflowDepth() { return mReflowDepth; }
    66 private:
    67   nsRefPtr<nsPresContext> mPresContext;
    68   nsRenderingContext *mRenderingContext;
    69   const nsHTMLReflowState *mOuterReflowState;
    70   uint32_t mLayoutFlags;
    71   uint16_t mReflowDepth; 
    72   bool mPaintingDisabled;
    73 };
    75 #endif

mercurial