Fixed regex LIR to be x64 compliant (bug 514548, r=lw).
[mozilla-central.git] / layout / generic / nsLeafFrame.cpp
blob7eceafe4092992c7a88a8ad4e9dc525e75605844
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 /* base class for rendering objects that do not have child lists */
40 #include "nsCOMPtr.h"
41 #include "nsLeafFrame.h"
42 #include "nsHTMLContainerFrame.h"
43 #include "nsHTMLParts.h"
44 #include "nsIPresShell.h"
45 #include "nsPresContext.h"
47 nsLeafFrame::~nsLeafFrame()
51 /* virtual */ nscoord
52 nsLeafFrame::GetMinWidth(nsIRenderingContext *aRenderingContext)
54 nscoord result;
55 DISPLAY_MIN_WIDTH(this, result);
57 result = GetIntrinsicWidth();
58 return result;
61 /* virtual */ nscoord
62 nsLeafFrame::GetPrefWidth(nsIRenderingContext *aRenderingContext)
64 nscoord result;
65 DISPLAY_PREF_WIDTH(this, result);
66 result = GetIntrinsicWidth();
67 return result;
70 /* virtual */ nsSize
71 nsLeafFrame::ComputeAutoSize(nsIRenderingContext *aRenderingContext,
72 nsSize aCBSize, nscoord aAvailableWidth,
73 nsSize aMargin, nsSize aBorder,
74 nsSize aPadding, PRBool aShrinkWrap)
76 return nsSize(GetIntrinsicWidth(), GetIntrinsicHeight());
79 NS_IMETHODIMP
80 nsLeafFrame::Reflow(nsPresContext* aPresContext,
81 nsHTMLReflowMetrics& aMetrics,
82 const nsHTMLReflowState& aReflowState,
83 nsReflowStatus& aStatus)
85 DO_GLOBAL_REFLOW_COUNT("nsLeafFrame");
86 NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
87 ("enter nsLeafFrame::Reflow: aMaxSize=%d,%d",
88 aReflowState.availableWidth, aReflowState.availableHeight));
90 NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
92 DoReflow(aPresContext, aMetrics, aReflowState, aStatus);
94 FinishAndStoreOverflow(&aMetrics);
95 return NS_OK;
98 NS_IMETHODIMP
99 nsLeafFrame::DoReflow(nsPresContext* aPresContext,
100 nsHTMLReflowMetrics& aMetrics,
101 const nsHTMLReflowState& aReflowState,
102 nsReflowStatus& aStatus)
104 NS_ASSERTION(aReflowState.ComputedWidth() != NS_UNCONSTRAINEDSIZE,
105 "Shouldn't have unconstrained stuff here "
106 "Thanks to the rules of reflow");
107 NS_ASSERTION(NS_INTRINSICSIZE != aReflowState.ComputedHeight(),
108 "Shouldn't have unconstrained stuff here "
109 "thanks to ComputeAutoSize");
111 aMetrics.width = aReflowState.ComputedWidth();
112 aMetrics.height = aReflowState.ComputedHeight();
114 AddBordersAndPadding(aReflowState, aMetrics);
115 aStatus = NS_FRAME_COMPLETE;
117 NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
118 ("exit nsLeafFrame::DoReflow: size=%d,%d",
119 aMetrics.width, aMetrics.height));
120 NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
122 aMetrics.mOverflowArea =
123 nsRect(0, 0, aMetrics.width, aMetrics.height);
125 return NS_OK;
128 nscoord
129 nsLeafFrame::GetIntrinsicHeight()
131 NS_NOTREACHED("Someone didn't override Reflow or ComputeAutoSize");
132 return 0;
135 // XXX how should border&padding effect baseline alignment?
136 // => descent = borderPadding.bottom for example
137 void
138 nsLeafFrame::AddBordersAndPadding(const nsHTMLReflowState& aReflowState,
139 nsHTMLReflowMetrics& aMetrics)
141 aMetrics.width += aReflowState.mComputedBorderPadding.LeftRight();
142 aMetrics.height += aReflowState.mComputedBorderPadding.TopBottom();
145 void
146 nsLeafFrame::SizeToAvailSize(const nsHTMLReflowState& aReflowState,
147 nsHTMLReflowMetrics& aDesiredSize)
149 aDesiredSize.width = aReflowState.availableWidth; // FRAME
150 aDesiredSize.height = aReflowState.availableHeight;
151 aDesiredSize.mOverflowArea =
152 nsRect(0, 0, aDesiredSize.width, aDesiredSize.height);
153 FinishAndStoreOverflow(&aDesiredSize);