layout/generic/nsSplittableFrame.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/generic/nsSplittableFrame.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,109 @@
     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 + * base class for rendering objects that can be split across lines,
    1.11 + * columns, or pages
    1.12 + */
    1.13 +
    1.14 +#ifndef nsSplittableFrame_h___
    1.15 +#define nsSplittableFrame_h___
    1.16 +
    1.17 +#include "mozilla/Attributes.h"
    1.18 +#include "nsFrame.h"
    1.19 +
    1.20 +// Derived class that allows splitting
    1.21 +class nsSplittableFrame : public nsFrame
    1.22 +{
    1.23 +public:
    1.24 +  NS_DECL_FRAMEARENA_HELPERS
    1.25 +
    1.26 +  virtual void Init(nsIContent*      aContent,
    1.27 +                    nsIFrame*        aParent,
    1.28 +                    nsIFrame*        aPrevInFlow) MOZ_OVERRIDE;
    1.29 +  
    1.30 +  virtual nsSplittableType GetSplittableType() const MOZ_OVERRIDE;
    1.31 +
    1.32 +  virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
    1.33 +
    1.34 +  /*
    1.35 +   * Frame continuations can be either fluid or not:
    1.36 +   * Fluid continuations ("in-flows") are the result of line breaking, 
    1.37 +   * column breaking, or page breaking.
    1.38 +   * Other (non-fluid) continuations can be the result of BiDi frame splitting.
    1.39 +   * A "flow" is a chain of fluid continuations.
    1.40 +   */
    1.41 +  
    1.42 +  // Get the previous/next continuation, regardless of its type (fluid or non-fluid).
    1.43 +  virtual nsIFrame* GetPrevContinuation() const MOZ_OVERRIDE;
    1.44 +  virtual nsIFrame* GetNextContinuation() const MOZ_OVERRIDE;
    1.45 +
    1.46 +  // Set a previous/next non-fluid continuation.
    1.47 +  virtual void SetPrevContinuation(nsIFrame*) MOZ_OVERRIDE;
    1.48 +  virtual void SetNextContinuation(nsIFrame*) MOZ_OVERRIDE;
    1.49 +
    1.50 +  // Get the first/last continuation for this frame.
    1.51 +  virtual nsIFrame* FirstContinuation() const MOZ_OVERRIDE;
    1.52 +  virtual nsIFrame* LastContinuation() const MOZ_OVERRIDE;
    1.53 +
    1.54 +#ifdef DEBUG
    1.55 +  // Can aFrame2 be reached from aFrame1 by following prev/next continuations?
    1.56 +  static bool IsInPrevContinuationChain(nsIFrame* aFrame1, nsIFrame* aFrame2);
    1.57 +  static bool IsInNextContinuationChain(nsIFrame* aFrame1, nsIFrame* aFrame2);
    1.58 +#endif
    1.59 +  
    1.60 +  // Get the previous/next continuation, only if it is fluid (an "in-flow").
    1.61 +  nsIFrame* GetPrevInFlow() const;
    1.62 +  nsIFrame* GetNextInFlow() const;
    1.63 +
    1.64 +  virtual nsIFrame* GetPrevInFlowVirtual() const MOZ_OVERRIDE { return GetPrevInFlow(); }
    1.65 +  virtual nsIFrame* GetNextInFlowVirtual() const MOZ_OVERRIDE { return GetNextInFlow(); }
    1.66 +  
    1.67 +  // Set a previous/next fluid continuation.
    1.68 +  virtual void SetPrevInFlow(nsIFrame*) MOZ_OVERRIDE;
    1.69 +  virtual void SetNextInFlow(nsIFrame*) MOZ_OVERRIDE;
    1.70 +
    1.71 +  // Get the first/last frame in the current flow.
    1.72 +  virtual nsIFrame* FirstInFlow() const MOZ_OVERRIDE;
    1.73 +  virtual nsIFrame* LastInFlow() const MOZ_OVERRIDE;
    1.74 +
    1.75 +  // Remove the frame from the flow. Connects the frame's prev-in-flow
    1.76 +  // and its next-in-flow. This should only be called in frame Destroy() methods.
    1.77 +  static void RemoveFromFlow(nsIFrame* aFrame);
    1.78 +
    1.79 +protected:
    1.80 +  nsSplittableFrame(nsStyleContext* aContext) : nsFrame(aContext) {}
    1.81 +
    1.82 +  /**
    1.83 +   * Determine the height consumed by our previous-in-flows.
    1.84 +   *
    1.85 +   * @note (bz) This makes laying out a splittable frame with N in-flows
    1.86 +   *       O(N^2)! So, use this function with caution and minimize the number
    1.87 +   *       of calls to this method.
    1.88 +   */
    1.89 +  nscoord GetConsumedHeight() const;
    1.90 +
    1.91 +  /**
    1.92 +   * Retrieve the effective computed height of this frame, which is the computed
    1.93 +   * height, minus the height consumed by any previous in-flows.
    1.94 +   */
    1.95 +  nscoord GetEffectiveComputedHeight(const nsHTMLReflowState& aReflowState,
    1.96 +                                     nscoord aConsumed = NS_INTRINSICSIZE) const;
    1.97 +
    1.98 +  /**
    1.99 +   * @see nsIFrame::GetLogicalSkipSides()
   1.100 +   * @see nsIFrame::ApplyLogicalSkipSides()
   1.101 +   */
   1.102 +  virtual int GetLogicalSkipSides(const nsHTMLReflowState* aReflowState = nullptr) const MOZ_OVERRIDE;
   1.103 +
   1.104 +#ifdef DEBUG
   1.105 +  virtual void DumpBaseRegressionData(nsPresContext* aPresContext, FILE* out, int32_t aIndent) MOZ_OVERRIDE;
   1.106 +#endif
   1.107 +
   1.108 +  nsIFrame*   mPrevContinuation;
   1.109 +  nsIFrame*   mNextContinuation;
   1.110 +};
   1.111 +
   1.112 +#endif /* nsSplittableFrame_h___ */

mercurial