michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* base class for rendering objects that do not have child lists */ michael@0: michael@0: #ifndef nsLeafFrame_h___ michael@0: #define nsLeafFrame_h___ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsFrame.h" michael@0: #include "nsDisplayList.h" michael@0: michael@0: /** michael@0: * Abstract class that provides simple fixed-size layout for leaf objects michael@0: * (e.g. images, form elements, etc.). Deriviations provide the implementation michael@0: * of the GetDesiredSize method. The rendering method knows how to render michael@0: * borders and backgrounds. michael@0: */ michael@0: class nsLeafFrame : public nsFrame { michael@0: public: michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: // nsIFrame replacements michael@0: virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, michael@0: const nsRect& aDirtyRect, michael@0: const nsDisplayListSet& aLists) MOZ_OVERRIDE { michael@0: DO_GLOBAL_REFLOW_COUNT_DSP("nsLeafFrame"); michael@0: DisplayBorderBackgroundOutline(aBuilder, aLists); michael@0: } michael@0: michael@0: /** michael@0: * Both GetMinWidth and GetPrefWidth will return whatever GetIntrinsicWidth michael@0: * returns. michael@0: */ michael@0: virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; michael@0: virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; michael@0: michael@0: /** michael@0: * Our auto size is just intrinsic width and intrinsic height. michael@0: */ michael@0: virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext, michael@0: nsSize aCBSize, nscoord aAvailableWidth, michael@0: nsSize aMargin, nsSize aBorder, michael@0: nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE; michael@0: michael@0: /** michael@0: * Reflow our frame. This will use the computed width plus borderpadding for michael@0: * the desired width, and use the return value of GetIntrinsicHeight plus michael@0: * borderpadding for the desired height. Ascent will be set to the height, michael@0: * and descent will be set to 0. michael@0: */ michael@0: virtual nsresult Reflow(nsPresContext* aPresContext, michael@0: nsHTMLReflowMetrics& aDesiredSize, michael@0: const nsHTMLReflowState& aReflowState, michael@0: nsReflowStatus& aStatus) MOZ_OVERRIDE; michael@0: michael@0: /** michael@0: * This method does most of the work that Reflow() above need done. michael@0: */ michael@0: virtual nsresult DoReflow(nsPresContext* aPresContext, michael@0: nsHTMLReflowMetrics& aDesiredSize, michael@0: const nsHTMLReflowState& aReflowState, michael@0: nsReflowStatus& aStatus); michael@0: michael@0: virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE michael@0: { michael@0: // We don't actually contain a block, but we do always want a michael@0: // computed width, so tell a little white lie here. michael@0: return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplacedContainsBlock)); michael@0: } michael@0: michael@0: protected: michael@0: nsLeafFrame(nsStyleContext* aContext) : nsFrame(aContext) {} michael@0: virtual ~nsLeafFrame(); michael@0: michael@0: /** michael@0: * Return the intrinsic width of the frame's content area. Note that this michael@0: * should not include borders or padding and should not depend on the applied michael@0: * styles. michael@0: */ michael@0: virtual nscoord GetIntrinsicWidth() = 0; michael@0: michael@0: /** michael@0: * Return the intrinsic height of the frame's content area. This should not michael@0: * include border or padding. This will only matter if the specified height michael@0: * is auto. Note that subclasses must either implement this or override michael@0: * Reflow and ComputeAutoSize; the default Reflow and ComputeAutoSize impls michael@0: * call this method. michael@0: */ michael@0: virtual nscoord GetIntrinsicHeight(); michael@0: michael@0: /** michael@0: * Subroutine to add in borders and padding michael@0: */ michael@0: void AddBordersAndPadding(const nsHTMLReflowState& aReflowState, michael@0: nsHTMLReflowMetrics& aDesiredSize); michael@0: michael@0: /** michael@0: * Set aDesiredSize to be the available size michael@0: */ michael@0: void SizeToAvailSize(const nsHTMLReflowState& aReflowState, michael@0: nsHTMLReflowMetrics& aDesiredSize); michael@0: }; michael@0: michael@0: #endif /* nsLeafFrame_h___ */