2007-06-12 10:10:23 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
2000-01-27 15:31:12 +03:00
|
|
|
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsFrame.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
2000-01-27 15:31:12 +03:00
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
|
|
|
|
#include "nsMathMLmspaceFrame.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2000-01-27 15:31:12 +03:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// <mspace> -- space - implementation
|
|
|
|
//
|
|
|
|
|
2005-11-11 05:36:29 +03:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewMathMLmspaceFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2000-01-27 15:31:12 +03:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsMathMLmspaceFrame(aContext);
|
2000-01-27 15:31:12 +03:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmspaceFrame)
|
|
|
|
|
2000-01-27 15:31:12 +03:00
|
|
|
nsMathMLmspaceFrame::~nsMathMLmspaceFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2006-01-21 05:46:19 +03:00
|
|
|
nsMathMLmspaceFrame::IsLeaf() const
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2006-01-21 05:46:19 +03:00
|
|
|
}
|
|
|
|
|
2002-02-07 07:38:08 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsMathMLmspaceFrame::ProcessAttributes(nsPresContext* aPresContext)
|
2000-01-27 15:31:12 +03:00
|
|
|
{
|
|
|
|
nsAutoString value;
|
|
|
|
|
|
|
|
// width
|
2012-05-16 02:30:14 +04:00
|
|
|
//
|
|
|
|
// "Specifies the desired width of the space."
|
|
|
|
//
|
|
|
|
// values: length
|
|
|
|
// default: 0em
|
|
|
|
//
|
|
|
|
// The default value is "0em", so unitless values can be ignored.
|
|
|
|
// <mspace/> is listed among MathML elements allowing negative spacing and
|
|
|
|
// the MathML test suite contains "Presentation/TokenElements/mspace/mspace2"
|
|
|
|
// as an example. Hence we allow negative values.
|
|
|
|
//
|
2000-01-27 15:31:12 +03:00
|
|
|
mWidth = 0;
|
2006-12-26 20:47:52 +03:00
|
|
|
GetAttribute(mContent, mPresentationData.mstyle, nsGkAtoms::width,
|
2005-10-28 15:25:24 +04:00
|
|
|
value);
|
|
|
|
if (!value.IsEmpty()) {
|
2012-05-16 02:30:14 +04:00
|
|
|
ParseNumericValue(value, &mWidth,
|
|
|
|
nsMathMLElement::PARSE_ALLOW_NEGATIVE,
|
|
|
|
aPresContext, mStyleContext);
|
2000-01-27 15:31:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// height
|
2012-05-16 02:30:14 +04:00
|
|
|
//
|
|
|
|
// "Specifies the desired height (above the baseline) of the space."
|
|
|
|
//
|
|
|
|
// values: length
|
|
|
|
// default: 0ex
|
|
|
|
//
|
|
|
|
// The default value is "0ex", so unitless values can be ignored.
|
2012-05-17 17:37:55 +04:00
|
|
|
// We do not allow negative values. See bug 716349.
|
2012-05-16 02:30:14 +04:00
|
|
|
//
|
2000-01-27 15:31:12 +03:00
|
|
|
mHeight = 0;
|
2006-12-26 20:47:52 +03:00
|
|
|
GetAttribute(mContent, mPresentationData.mstyle, nsGkAtoms::height,
|
2005-10-28 15:25:24 +04:00
|
|
|
value);
|
|
|
|
if (!value.IsEmpty()) {
|
2012-05-17 17:37:55 +04:00
|
|
|
ParseNumericValue(value, &mHeight, 0,
|
2012-05-16 02:30:14 +04:00
|
|
|
aPresContext, mStyleContext);
|
2000-01-27 15:31:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// depth
|
2012-05-16 02:30:14 +04:00
|
|
|
//
|
|
|
|
// "Specifies the desired depth (below the baseline) of the space."
|
|
|
|
//
|
|
|
|
// values: length
|
|
|
|
// default: 0ex
|
|
|
|
//
|
|
|
|
// The default value is "0ex", so unitless values can be ignored.
|
2012-05-17 17:37:55 +04:00
|
|
|
// We do not allow negative values. See bug 716349.
|
2012-05-16 02:30:14 +04:00
|
|
|
//
|
2000-01-27 15:31:12 +03:00
|
|
|
mDepth = 0;
|
2006-12-26 20:47:52 +03:00
|
|
|
GetAttribute(mContent, mPresentationData.mstyle, nsGkAtoms::depth_,
|
2005-10-28 15:25:24 +04:00
|
|
|
value);
|
|
|
|
if (!value.IsEmpty()) {
|
2012-05-17 17:37:55 +04:00
|
|
|
ParseNumericValue(value, &mDepth, 0,
|
2012-05-16 02:30:14 +04:00
|
|
|
aPresContext, mStyleContext);
|
2000-01-27 15:31:12 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsMathMLmspaceFrame::Reflow(nsPresContext* aPresContext,
|
2000-01-27 15:31:12 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
2002-02-07 07:38:08 +03:00
|
|
|
{
|
|
|
|
ProcessAttributes(aPresContext);
|
2012-05-17 17:37:55 +04:00
|
|
|
// nsLineLayout doesn't expect negative widths.
|
|
|
|
// XXXfredw Negative spaces are not implemented. See bug 717546
|
2002-02-07 07:38:08 +03:00
|
|
|
|
2011-04-08 05:04:40 +04:00
|
|
|
mBoundingMetrics = nsBoundingMetrics();
|
2013-01-15 16:22:03 +04:00
|
|
|
mBoundingMetrics.width = std::max(0, mWidth);
|
2000-01-27 15:31:12 +03:00
|
|
|
mBoundingMetrics.ascent = mHeight;
|
|
|
|
mBoundingMetrics.descent = mDepth;
|
2005-10-19 04:57:17 +04:00
|
|
|
mBoundingMetrics.leftBearing = 0;
|
2012-05-17 17:37:55 +04:00
|
|
|
mBoundingMetrics.rightBearing = mBoundingMetrics.width;
|
2000-01-27 15:31:12 +03:00
|
|
|
|
|
|
|
aDesiredSize.ascent = mHeight;
|
2012-05-17 17:37:55 +04:00
|
|
|
aDesiredSize.width = mBoundingMetrics.width;
|
2007-01-23 07:06:56 +03:00
|
|
|
aDesiredSize.height = aDesiredSize.ascent + mDepth;
|
2000-01-27 15:31:12 +03:00
|
|
|
// Also return our bounding metrics
|
|
|
|
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
|
|
|
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
2000-01-27 15:31:12 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-11-30 02:52:02 +04:00
|
|
|
|
|
|
|
/* virtual */ nsresult
|
|
|
|
nsMathMLmspaceFrame::MeasureForWidth(nsRenderingContext& aRenderingContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
|
|
|
{
|
|
|
|
ProcessAttributes(PresContext());
|
|
|
|
mBoundingMetrics = nsBoundingMetrics();
|
2013-01-15 16:22:03 +04:00
|
|
|
mBoundingMetrics.width = std::max(0, mWidth);
|
2012-11-30 02:52:02 +04:00
|
|
|
aDesiredSize.width = mBoundingMetrics.width;
|
|
|
|
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
|
|
|
return NS_OK;
|
|
|
|
}
|