2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* base class for rendering objects that do not have child lists */
|
|
|
|
|
|
|
|
#ifndef nsLeafFrame_h___
|
|
|
|
#define nsLeafFrame_h___
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsFrame.h"
|
|
|
|
#include "nsDisplayList.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Abstract class that provides simple fixed-size layout for leaf objects
|
|
|
|
* (e.g. images, form elements, etc.). Deriviations provide the implementation
|
|
|
|
* of the GetDesiredSize method. The rendering method knows how to render
|
|
|
|
* borders and backgrounds.
|
|
|
|
*/
|
|
|
|
class nsLeafFrame : public nsFrame {
|
|
|
|
public:
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsIFrame replacements
|
2013-02-14 03:12:27 -08:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE {
|
2007-03-22 10:30:00 -07:00
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP("nsLeafFrame");
|
2013-02-14 03:08:08 -08:00
|
|
|
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-07-24 10:03:26 -07:00
|
|
|
* Both GetMinISize and GetPrefISize will return whatever GetIntrinsicISize
|
2007-03-22 10:30:00 -07:00
|
|
|
* returns.
|
|
|
|
*/
|
2014-07-24 10:03:25 -07:00
|
|
|
virtual nscoord GetMinISize(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
|
|
|
virtual nscoord GetPrefISize(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-27 12:24:06 -08:00
|
|
|
/**
|
|
|
|
* Our auto size is just intrinsic width and intrinsic height.
|
|
|
|
*/
|
2014-08-24 07:34:51 -07:00
|
|
|
virtual mozilla::LogicalSize
|
|
|
|
ComputeAutoSize(nsRenderingContext *aRenderingContext,
|
|
|
|
mozilla::WritingMode aWritingMode,
|
|
|
|
const mozilla::LogicalSize& aCBSize,
|
|
|
|
nscoord aAvailableISize,
|
|
|
|
const mozilla::LogicalSize& aMargin,
|
|
|
|
const mozilla::LogicalSize& aBorder,
|
|
|
|
const mozilla::LogicalSize& aPadding,
|
|
|
|
bool aShrinkWrap) MOZ_OVERRIDE;
|
2008-01-27 12:24:06 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Reflow our frame. This will use the computed width plus borderpadding for
|
2014-07-24 10:03:26 -07:00
|
|
|
* the desired width, and use the return value of GetIntrinsicBSize plus
|
2007-03-22 10:30:00 -07:00
|
|
|
* borderpadding for the desired height. Ascent will be set to the height,
|
|
|
|
* and descent will be set to 0.
|
|
|
|
*/
|
2014-05-12 17:47:52 -07:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus) MOZ_OVERRIDE;
|
2008-01-20 18:03:08 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method does most of the work that Reflow() above need done.
|
|
|
|
*/
|
2014-05-12 17:47:53 -07:00
|
|
|
virtual void DoReflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// We don't actually contain a block, but we do always want a
|
|
|
|
// computed width, so tell a little white lie here.
|
|
|
|
return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplacedContainsBlock));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2014-08-07 16:48:38 -07:00
|
|
|
explicit nsLeafFrame(nsStyleContext* aContext) : nsFrame(aContext) {}
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual ~nsLeafFrame();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the intrinsic width of the frame's content area. Note that this
|
|
|
|
* should not include borders or padding and should not depend on the applied
|
|
|
|
* styles.
|
|
|
|
*/
|
2014-07-24 10:03:26 -07:00
|
|
|
virtual nscoord GetIntrinsicISize() = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the intrinsic height of the frame's content area. This should not
|
2008-01-27 12:24:06 -08:00
|
|
|
* include border or padding. This will only matter if the specified height
|
|
|
|
* is auto. Note that subclasses must either implement this or override
|
|
|
|
* Reflow and ComputeAutoSize; the default Reflow and ComputeAutoSize impls
|
|
|
|
* call this method.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2014-07-24 10:03:26 -07:00
|
|
|
virtual nscoord GetIntrinsicBSize();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Subroutine to add in borders and padding
|
|
|
|
*/
|
|
|
|
void AddBordersAndPadding(const nsHTMLReflowState& aReflowState,
|
2014-07-24 01:30:07 -07:00
|
|
|
mozilla::LogicalSize& aDesiredSize);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set aDesiredSize to be the available size
|
|
|
|
*/
|
|
|
|
void SizeToAvailSize(const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsLeafFrame_h___ */
|