tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsBlockReflowContext.h (3516B)


      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/. */
      6 
      7 /* class that a parent frame uses to reflow a block frame */
      8 
      9 #ifndef nsBlockReflowContext_h___
     10 #define nsBlockReflowContext_h___
     11 
     12 #include "mozilla/ReflowOutput.h"
     13 
     14 class nsIFrame;
     15 class nsLineBox;
     16 class nsPresContext;
     17 class nsReflowStatus;
     18 namespace mozilla {
     19 class BlockReflowState;
     20 }  // namespace mozilla
     21 
     22 /**
     23 * An encapsulation of the state and algorithm for reflowing block frames.
     24 */
     25 class nsBlockReflowContext {
     26  using BlockReflowState = mozilla::BlockReflowState;
     27  using ReflowInput = mozilla::ReflowInput;
     28  using ReflowOutput = mozilla::ReflowOutput;
     29 
     30 public:
     31  nsBlockReflowContext(nsPresContext* aPresContext,
     32                       const ReflowInput& aParentRI);
     33  ~nsBlockReflowContext() = default;
     34 
     35  void ReflowBlock(const mozilla::LogicalRect& aSpace, bool aApplyBStartMargin,
     36                   mozilla::CollapsingMargin& aPrevMargin, nscoord aClearance,
     37                   nsLineBox* aLine, ReflowInput& aReflowInput,
     38                   nsReflowStatus& aReflowStatus, BlockReflowState& aState);
     39 
     40  bool PlaceBlock(const ReflowInput& aReflowInput, bool aForceFit,
     41                  nsLineBox* aLine,
     42                  mozilla::CollapsingMargin& aBEndMarginResult /* out */,
     43                  mozilla::OverflowAreas& aOverflowAreas,
     44                  const nsReflowStatus& aReflowStatus);
     45 
     46  mozilla::CollapsingMargin& GetCarriedOutBEndMargin() {
     47    return mMetrics.mCarriedOutBEndMargin;
     48  }
     49 
     50  const ReflowOutput& GetMetrics() const { return mMetrics; }
     51 
     52  /**
     53   * Computes the collapsed block-start margin (in the context's parent's
     54   * writing mode) for a block whose reflow input is in aRI.
     55   * The computed margin is added into aMargin, whose writing mode is the
     56   * parent's mode as found in mMetrics.GetWritingMode(); note this may not be
     57   * the block's own writing mode as found in aRI.
     58   * If aClearanceFrame is null then this is the first optimistic pass which
     59   * shall assume that no frames have clearance, and we clear the HasClearance
     60   * on all frames encountered.
     61   * If non-null, this is the second pass and the caller has decided
     62   * aClearanceFrame needs clearance (and we will therefore stop collapsing
     63   * there); also, this function is responsible for marking it with
     64   * SetHasClearance.
     65   * If in the optimistic pass any frame is encountered that might possibly
     66   * need clearance (i.e., if we really needed the optimism assumption) then
     67   * we set aMayNeedRetry to true.
     68   * We return true if we changed the clearance state of any line and marked it
     69   * dirty.
     70   */
     71  bool ComputeCollapsedBStartMargin(const ReflowInput& aRI,
     72                                    mozilla::CollapsingMargin* aMargin,
     73                                    nsIFrame* aClearanceFrame,
     74                                    bool* aMayNeedRetry,
     75                                    bool* aIsEmpty = nullptr);
     76 
     77 protected:
     78  nsPresContext* mPresContext;
     79  const ReflowInput& mOuterReflowInput;
     80 
     81  nsIFrame* mFrame;
     82  mozilla::LogicalRect mSpace;
     83 
     84  nscoord mICoord, mBCoord;
     85  nsSize mContainerSize;
     86  mozilla::WritingMode mWritingMode;
     87  ReflowOutput mMetrics;
     88  mozilla::CollapsingMargin mBStartMargin;
     89 };
     90 
     91 #endif /* nsBlockReflowContext_h___ */