2
* The contents of this file are subject to the Mozilla Public
3
* License Version 1.1 (the "License"); you may not use this file
4
* except in compliance with the License. You may obtain a copy of
5
* the License at http://www.mozilla.org/MPL/
7
* Software distributed under the License is distributed on an "AS
8
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9
* implied. See the License for the specific language governing
10
* rights and limitations under the License.
12
* The Original Code is Mozilla MathML Project.
14
* The Initial Developer of the Original Code is The University Of
15
* Queensland. Portions created by The University Of Queensland are
16
* Copyright (C) 1999 The University Of Queensland. All Rights Reserved.
19
* Roger B. Sidje <rbs@maths.uq.edu.au>
23
// a helper frame class to wrap non-MathML frames so that foreign elements
24
// (e.g., html:img) can mix better with other surrounding MathML markups
28
#include "nsHTMLParts.h"
30
#include "nsAreaFrame.h"
31
#include "nsLineLayout.h"
32
#include "nsIPresContext.h"
33
#include "nsHTMLAtoms.h"
34
#include "nsUnitConversion.h"
35
#include "nsStyleContext.h"
36
#include "nsStyleConsts.h"
37
#include "nsIRenderingContext.h"
38
#include "nsIFontMetrics.h"
40
#include "nsMathMLForeignFrameWrapper.h"
42
NS_IMPL_ADDREF_INHERITED(nsMathMLForeignFrameWrapper, nsMathMLFrame)
43
NS_IMPL_RELEASE_INHERITED(nsMathMLForeignFrameWrapper, nsMathMLFrame)
44
NS_IMPL_QUERY_INTERFACE_INHERITED1(nsMathMLForeignFrameWrapper, nsBlockFrame, nsMathMLFrame)
47
NS_NewMathMLForeignFrameWrapper(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
49
NS_PRECONDITION(aNewFrame, "null OUT ptr");
50
if (nsnull == aNewFrame) {
51
return NS_ERROR_NULL_POINTER;
53
nsMathMLForeignFrameWrapper* it = new (aPresShell) nsMathMLForeignFrameWrapper;
55
return NS_ERROR_OUT_OF_MEMORY;
62
nsMathMLForeignFrameWrapper::Init(nsIPresContext* aPresContext,
65
nsStyleContext* aContext,
66
nsIFrame* aPrevInFlow)
68
return nsBlockFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
72
nsMathMLForeignFrameWrapper::Reflow(nsIPresContext* aPresContext,
73
nsHTMLReflowMetrics& aDesiredSize,
74
const nsHTMLReflowState& aReflowState,
75
nsReflowStatus& aStatus)
77
// Let the base class do the reflow
78
nsresult rv = nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
81
mReference.y = aDesiredSize.ascent;
83
// just make-up a bounding metrics
84
mBoundingMetrics.Clear();
85
mBoundingMetrics.ascent = aDesiredSize.ascent;
86
mBoundingMetrics.descent = aDesiredSize.descent;
87
mBoundingMetrics.width = aDesiredSize.width;
88
mBoundingMetrics.leftBearing = 0;
89
mBoundingMetrics.rightBearing = aDesiredSize.width;
90
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
92
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);