~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/layout/mathml/base/src/nsMathMLForeignFrameWrapper.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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/
 
6
 * 
 
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.
 
11
 * 
 
12
 * The Original Code is Mozilla MathML Project.
 
13
 * 
 
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.
 
17
 * 
 
18
 * Contributor(s): 
 
19
 *   Roger B. Sidje <rbs@maths.uq.edu.au>
 
20
 */
 
21
 
 
22
//
 
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
 
25
//
 
26
 
 
27
#include "nsCOMPtr.h"
 
28
#include "nsHTMLParts.h"
 
29
#include "nsFrame.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"
 
39
 
 
40
#include "nsMathMLForeignFrameWrapper.h"
 
41
 
 
42
NS_IMPL_ADDREF_INHERITED(nsMathMLForeignFrameWrapper, nsMathMLFrame)
 
43
NS_IMPL_RELEASE_INHERITED(nsMathMLForeignFrameWrapper, nsMathMLFrame)
 
44
NS_IMPL_QUERY_INTERFACE_INHERITED1(nsMathMLForeignFrameWrapper, nsBlockFrame, nsMathMLFrame)
 
45
 
 
46
nsresult
 
47
NS_NewMathMLForeignFrameWrapper(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
 
48
{
 
49
  NS_PRECONDITION(aNewFrame, "null OUT ptr");
 
50
  if (nsnull == aNewFrame) {
 
51
    return NS_ERROR_NULL_POINTER;
 
52
  }
 
53
  nsMathMLForeignFrameWrapper* it = new (aPresShell) nsMathMLForeignFrameWrapper;
 
54
  if (nsnull == it) {
 
55
    return NS_ERROR_OUT_OF_MEMORY;
 
56
  }
 
57
  *aNewFrame = it;
 
58
  return NS_OK;
 
59
}
 
60
 
 
61
NS_IMETHODIMP
 
62
nsMathMLForeignFrameWrapper::Init(nsIPresContext*  aPresContext,
 
63
                                  nsIContent*      aContent,
 
64
                                  nsIFrame*        aParent,
 
65
                                  nsStyleContext*  aContext,
 
66
                                  nsIFrame*        aPrevInFlow)
 
67
{
 
68
  return nsBlockFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
 
69
}
 
70
 
 
71
NS_IMETHODIMP
 
72
nsMathMLForeignFrameWrapper::Reflow(nsIPresContext*          aPresContext,
 
73
                                    nsHTMLReflowMetrics&     aDesiredSize,
 
74
                                    const nsHTMLReflowState& aReflowState,
 
75
                                    nsReflowStatus&          aStatus)
 
76
{
 
77
  // Let the base class do the reflow
 
78
  nsresult rv = nsBlockFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
 
79
 
 
80
  mReference.x = 0;
 
81
  mReference.y = aDesiredSize.ascent;
 
82
 
 
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;
 
91
 
 
92
  NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
 
93
  return rv;
 
94
}