layout/generic/nsLeafFrame.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/generic/nsLeafFrame.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,107 @@
     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 +/* base class for rendering objects that do not have child lists */
    1.10 +
    1.11 +#ifndef nsLeafFrame_h___
    1.12 +#define nsLeafFrame_h___
    1.13 +
    1.14 +#include "mozilla/Attributes.h"
    1.15 +#include "nsFrame.h"
    1.16 +#include "nsDisplayList.h"
    1.17 +
    1.18 +/**
    1.19 + * Abstract class that provides simple fixed-size layout for leaf objects
    1.20 + * (e.g. images, form elements, etc.). Deriviations provide the implementation
    1.21 + * of the GetDesiredSize method. The rendering method knows how to render
    1.22 + * borders and backgrounds.
    1.23 + */
    1.24 +class nsLeafFrame : public nsFrame {
    1.25 +public:
    1.26 +  NS_DECL_FRAMEARENA_HELPERS
    1.27 +
    1.28 +  // nsIFrame replacements
    1.29 +  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
    1.30 +                                const nsRect&           aDirtyRect,
    1.31 +                                const nsDisplayListSet& aLists) MOZ_OVERRIDE {
    1.32 +    DO_GLOBAL_REFLOW_COUNT_DSP("nsLeafFrame");
    1.33 +    DisplayBorderBackgroundOutline(aBuilder, aLists);
    1.34 +  }
    1.35 +
    1.36 +  /**
    1.37 +   * Both GetMinWidth and GetPrefWidth will return whatever GetIntrinsicWidth
    1.38 +   * returns.
    1.39 +   */
    1.40 +  virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
    1.41 +  virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
    1.42 +
    1.43 +  /**
    1.44 +   * Our auto size is just intrinsic width and intrinsic height.
    1.45 +   */
    1.46 +  virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
    1.47 +                                 nsSize aCBSize, nscoord aAvailableWidth,
    1.48 +                                 nsSize aMargin, nsSize aBorder,
    1.49 +                                 nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE;
    1.50 +
    1.51 +  /**
    1.52 +   * Reflow our frame.  This will use the computed width plus borderpadding for
    1.53 +   * the desired width, and use the return value of GetIntrinsicHeight plus
    1.54 +   * borderpadding for the desired height.  Ascent will be set to the height,
    1.55 +   * and descent will be set to 0.
    1.56 +   */
    1.57 +  virtual nsresult Reflow(nsPresContext*      aPresContext,
    1.58 +                          nsHTMLReflowMetrics& aDesiredSize,
    1.59 +                          const nsHTMLReflowState& aReflowState,
    1.60 +                          nsReflowStatus&      aStatus) MOZ_OVERRIDE;
    1.61 +  
    1.62 +  /**
    1.63 +   * This method does most of the work that Reflow() above need done.
    1.64 +   */
    1.65 +  virtual nsresult DoReflow(nsPresContext*      aPresContext,
    1.66 +                            nsHTMLReflowMetrics& aDesiredSize,
    1.67 +                            const nsHTMLReflowState& aReflowState,
    1.68 +                            nsReflowStatus&      aStatus);
    1.69 +
    1.70 +  virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
    1.71 +  {
    1.72 +    // We don't actually contain a block, but we do always want a
    1.73 +    // computed width, so tell a little white lie here.
    1.74 +    return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplacedContainsBlock));
    1.75 +  }
    1.76 +
    1.77 +protected:
    1.78 +  nsLeafFrame(nsStyleContext* aContext) : nsFrame(aContext) {}
    1.79 +  virtual ~nsLeafFrame();
    1.80 +
    1.81 +  /**
    1.82 +   * Return the intrinsic width of the frame's content area. Note that this
    1.83 +   * should not include borders or padding and should not depend on the applied
    1.84 +   * styles.
    1.85 +   */
    1.86 +  virtual nscoord GetIntrinsicWidth() = 0;
    1.87 +
    1.88 +  /**
    1.89 +   * Return the intrinsic height of the frame's content area.  This should not
    1.90 +   * include border or padding.  This will only matter if the specified height
    1.91 +   * is auto.  Note that subclasses must either implement this or override
    1.92 +   * Reflow and ComputeAutoSize; the default Reflow and ComputeAutoSize impls
    1.93 +   * call this method.
    1.94 +   */
    1.95 +  virtual nscoord GetIntrinsicHeight();
    1.96 +
    1.97 +  /**
    1.98 +   * Subroutine to add in borders and padding
    1.99 +   */
   1.100 +  void AddBordersAndPadding(const nsHTMLReflowState& aReflowState,
   1.101 +                            nsHTMLReflowMetrics& aDesiredSize);
   1.102 +
   1.103 +  /**
   1.104 +   * Set aDesiredSize to be the available size
   1.105 +   */
   1.106 +  void SizeToAvailSize(const nsHTMLReflowState& aReflowState,
   1.107 +                       nsHTMLReflowMetrics& aDesiredSize);
   1.108 +};
   1.109 +
   1.110 +#endif /* nsLeafFrame_h___ */

mercurial