layout/generic/nsLeafFrame.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /* base class for rendering objects that do not have child lists */
michael@0 7
michael@0 8 #ifndef nsLeafFrame_h___
michael@0 9 #define nsLeafFrame_h___
michael@0 10
michael@0 11 #include "mozilla/Attributes.h"
michael@0 12 #include "nsFrame.h"
michael@0 13 #include "nsDisplayList.h"
michael@0 14
michael@0 15 /**
michael@0 16 * Abstract class that provides simple fixed-size layout for leaf objects
michael@0 17 * (e.g. images, form elements, etc.). Deriviations provide the implementation
michael@0 18 * of the GetDesiredSize method. The rendering method knows how to render
michael@0 19 * borders and backgrounds.
michael@0 20 */
michael@0 21 class nsLeafFrame : public nsFrame {
michael@0 22 public:
michael@0 23 NS_DECL_FRAMEARENA_HELPERS
michael@0 24
michael@0 25 // nsIFrame replacements
michael@0 26 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
michael@0 27 const nsRect& aDirtyRect,
michael@0 28 const nsDisplayListSet& aLists) MOZ_OVERRIDE {
michael@0 29 DO_GLOBAL_REFLOW_COUNT_DSP("nsLeafFrame");
michael@0 30 DisplayBorderBackgroundOutline(aBuilder, aLists);
michael@0 31 }
michael@0 32
michael@0 33 /**
michael@0 34 * Both GetMinWidth and GetPrefWidth will return whatever GetIntrinsicWidth
michael@0 35 * returns.
michael@0 36 */
michael@0 37 virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
michael@0 38 virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
michael@0 39
michael@0 40 /**
michael@0 41 * Our auto size is just intrinsic width and intrinsic height.
michael@0 42 */
michael@0 43 virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
michael@0 44 nsSize aCBSize, nscoord aAvailableWidth,
michael@0 45 nsSize aMargin, nsSize aBorder,
michael@0 46 nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE;
michael@0 47
michael@0 48 /**
michael@0 49 * Reflow our frame. This will use the computed width plus borderpadding for
michael@0 50 * the desired width, and use the return value of GetIntrinsicHeight plus
michael@0 51 * borderpadding for the desired height. Ascent will be set to the height,
michael@0 52 * and descent will be set to 0.
michael@0 53 */
michael@0 54 virtual nsresult Reflow(nsPresContext* aPresContext,
michael@0 55 nsHTMLReflowMetrics& aDesiredSize,
michael@0 56 const nsHTMLReflowState& aReflowState,
michael@0 57 nsReflowStatus& aStatus) MOZ_OVERRIDE;
michael@0 58
michael@0 59 /**
michael@0 60 * This method does most of the work that Reflow() above need done.
michael@0 61 */
michael@0 62 virtual nsresult DoReflow(nsPresContext* aPresContext,
michael@0 63 nsHTMLReflowMetrics& aDesiredSize,
michael@0 64 const nsHTMLReflowState& aReflowState,
michael@0 65 nsReflowStatus& aStatus);
michael@0 66
michael@0 67 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
michael@0 68 {
michael@0 69 // We don't actually contain a block, but we do always want a
michael@0 70 // computed width, so tell a little white lie here.
michael@0 71 return nsFrame::IsFrameOfType(aFlags & ~(nsIFrame::eReplacedContainsBlock));
michael@0 72 }
michael@0 73
michael@0 74 protected:
michael@0 75 nsLeafFrame(nsStyleContext* aContext) : nsFrame(aContext) {}
michael@0 76 virtual ~nsLeafFrame();
michael@0 77
michael@0 78 /**
michael@0 79 * Return the intrinsic width of the frame's content area. Note that this
michael@0 80 * should not include borders or padding and should not depend on the applied
michael@0 81 * styles.
michael@0 82 */
michael@0 83 virtual nscoord GetIntrinsicWidth() = 0;
michael@0 84
michael@0 85 /**
michael@0 86 * Return the intrinsic height of the frame's content area. This should not
michael@0 87 * include border or padding. This will only matter if the specified height
michael@0 88 * is auto. Note that subclasses must either implement this or override
michael@0 89 * Reflow and ComputeAutoSize; the default Reflow and ComputeAutoSize impls
michael@0 90 * call this method.
michael@0 91 */
michael@0 92 virtual nscoord GetIntrinsicHeight();
michael@0 93
michael@0 94 /**
michael@0 95 * Subroutine to add in borders and padding
michael@0 96 */
michael@0 97 void AddBordersAndPadding(const nsHTMLReflowState& aReflowState,
michael@0 98 nsHTMLReflowMetrics& aDesiredSize);
michael@0 99
michael@0 100 /**
michael@0 101 * Set aDesiredSize to be the available size
michael@0 102 */
michael@0 103 void SizeToAvailSize(const nsHTMLReflowState& aReflowState,
michael@0 104 nsHTMLReflowMetrics& aDesiredSize);
michael@0 105 };
michael@0 106
michael@0 107 #endif /* nsLeafFrame_h___ */

mercurial