2004-02-24 00:29:06 +03: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/. */
|
2001-02-23 19:09:14 +03:00
|
|
|
|
|
|
|
#include "nsMathMLFrame.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
2002-01-09 21:51:30 +03:00
|
|
|
#include "nsMathMLChar.h"
|
2009-12-11 10:37:40 +03:00
|
|
|
#include "nsCSSPseudoElements.h"
|
2013-08-31 01:37:12 +04:00
|
|
|
#include "nsMathMLElement.h"
|
2001-02-23 19:09:14 +03:00
|
|
|
|
2002-02-14 15:26:43 +03:00
|
|
|
// used to map attributes into CSS rules
|
2004-01-08 01:30:53 +03:00
|
|
|
#include "nsStyleSet.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2011-04-08 05:04:40 +04:00
|
|
|
#include "nsRenderingContext.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2006-08-15 08:49:43 +04:00
|
|
|
eMathMLFrameType
|
|
|
|
nsMathMLFrame::GetMathMLFrameType()
|
|
|
|
{
|
|
|
|
// see if it is an embellished operator (mapped to 'Op' in TeX)
|
|
|
|
if (mEmbellishData.coreFrame)
|
|
|
|
return GetMathMLFrameTypeFor(mEmbellishData.coreFrame);
|
|
|
|
|
|
|
|
// if it has a prescribed base, fetch the type from there
|
|
|
|
if (mPresentationData.baseFrame)
|
|
|
|
return GetMathMLFrameTypeFor(mPresentationData.baseFrame);
|
|
|
|
|
|
|
|
// everything else is treated as ordinary (mapped to 'Ord' in TeX)
|
|
|
|
return eMathMLFrameType_Ordinary;
|
|
|
|
}
|
|
|
|
|
2002-02-01 18:10:50 +03:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:57:50 +03:00
|
|
|
nsMathMLFrame::InheritAutomaticData(nsIFrame* aParent)
|
2002-02-01 18:10:50 +03:00
|
|
|
{
|
2002-02-02 08:43:03 +03:00
|
|
|
mEmbellishData.flags = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
mEmbellishData.coreFrame = nullptr;
|
2002-02-01 18:10:50 +03:00
|
|
|
mEmbellishData.direction = NS_STRETCH_DIRECTION_UNSUPPORTED;
|
2011-12-22 02:21:59 +04:00
|
|
|
mEmbellishData.leadingSpace = 0;
|
|
|
|
mEmbellishData.trailingSpace = 0;
|
2002-02-07 07:38:08 +03:00
|
|
|
|
|
|
|
mPresentationData.flags = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
mPresentationData.baseFrame = nullptr;
|
2002-02-01 18:10:50 +03:00
|
|
|
|
2008-01-09 12:38:28 +03:00
|
|
|
// by default, just inherit the display of our parent
|
2002-02-07 07:38:08 +03:00
|
|
|
nsPresentationData parentData;
|
|
|
|
GetPresentationDataFrom(aParent, parentData);
|
|
|
|
|
2012-06-25 23:59:42 +04:00
|
|
|
#if defined(DEBUG) && defined(SHOW_BOUNDING_BOX)
|
2002-02-07 07:38:08 +03:00
|
|
|
mPresentationData.flags |= NS_MATHML_SHOW_BOUNDING_METRICS;
|
|
|
|
#endif
|
|
|
|
|
2002-02-01 18:10:50 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-02-23 19:09:14 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsMathMLFrame::UpdatePresentationData(uint32_t aFlagsValues,
|
|
|
|
uint32_t aWhichFlags)
|
2001-02-23 19:09:14 +03:00
|
|
|
{
|
2014-01-14 18:39:50 +04:00
|
|
|
NS_ASSERTION(NS_MATHML_IS_COMPRESSED(aWhichFlags),
|
|
|
|
"aWhichFlags should only be compression flag");
|
|
|
|
|
2006-09-19 08:43:14 +04:00
|
|
|
if (NS_MATHML_IS_COMPRESSED(aWhichFlags)) {
|
2001-02-23 19:09:14 +03:00
|
|
|
// updating the compression flag is allowed
|
|
|
|
if (NS_MATHML_IS_COMPRESSED(aFlagsValues)) {
|
|
|
|
// 'compressed' means 'prime' style in App. G, TeXbook
|
|
|
|
mPresentationData.flags |= NS_MATHML_COMPRESSED;
|
|
|
|
}
|
|
|
|
// no else. the flag is sticky. it retains its value once it is set
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2002-01-09 21:51:30 +03:00
|
|
|
|
|
|
|
// Helper to give a style context suitable for doing the stretching of
|
|
|
|
// a MathMLChar. Frame classes that use this should ensure that the
|
2005-11-21 01:05:24 +03:00
|
|
|
// extra leaf style contexts given to the MathMLChars are accessible to
|
2002-01-09 21:51:30 +03:00
|
|
|
// the Style System via the Get/Set AdditionalStyleContext() APIs.
|
2002-02-07 07:38:08 +03:00
|
|
|
/* static */ void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsMathMLFrame::ResolveMathMLCharStyle(nsPresContext* aPresContext,
|
2002-01-09 21:51:30 +03:00
|
|
|
nsIContent* aContent,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aParentStyleContext,
|
2014-04-24 23:30:00 +04:00
|
|
|
nsMathMLChar* aMathMLChar)
|
2002-01-09 21:51:30 +03:00
|
|
|
{
|
2014-04-24 23:30:00 +04:00
|
|
|
nsCSSPseudoElements::Type pseudoType =
|
2009-12-11 10:37:40 +03:00
|
|
|
nsCSSPseudoElements::ePseudo_mozMathAnonymous; // savings
|
2003-02-22 03:32:13 +03:00
|
|
|
nsRefPtr<nsStyleContext> newStyleContext;
|
2004-01-28 03:18:22 +03:00
|
|
|
newStyleContext = aPresContext->StyleSet()->
|
2010-04-30 17:12:06 +04:00
|
|
|
ResolvePseudoElementStyle(aContent->AsElement(), pseudoType,
|
2013-11-28 10:46:38 +04:00
|
|
|
aParentStyleContext, nullptr);
|
2004-01-28 03:18:22 +03:00
|
|
|
|
2013-08-03 08:11:06 +04:00
|
|
|
aMathMLChar->SetStyleContext(newStyleContext);
|
2002-02-07 07:38:08 +03:00
|
|
|
}
|
2002-01-09 21:51:30 +03:00
|
|
|
|
2002-02-07 07:38:08 +03:00
|
|
|
/* static */ void
|
|
|
|
nsMathMLFrame::GetEmbellishDataFrom(nsIFrame* aFrame,
|
|
|
|
nsEmbellishData& aEmbellishData)
|
|
|
|
{
|
|
|
|
// initialize OUT params
|
|
|
|
aEmbellishData.flags = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
aEmbellishData.coreFrame = nullptr;
|
2002-02-07 07:38:08 +03:00
|
|
|
aEmbellishData.direction = NS_STRETCH_DIRECTION_UNSUPPORTED;
|
2011-12-22 02:21:59 +04:00
|
|
|
aEmbellishData.leadingSpace = 0;
|
|
|
|
aEmbellishData.trailingSpace = 0;
|
2002-02-07 07:38:08 +03:00
|
|
|
|
2006-08-15 08:49:43 +04:00
|
|
|
if (aFrame && aFrame->IsFrameOfType(nsIFrame::eMathML)) {
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIMathMLFrame* mathMLFrame = do_QueryFrame(aFrame);
|
2002-02-07 07:38:08 +03:00
|
|
|
if (mathMLFrame) {
|
|
|
|
mathMLFrame->GetEmbellishData(aEmbellishData);
|
|
|
|
}
|
|
|
|
}
|
2002-01-09 21:51:30 +03:00
|
|
|
}
|
|
|
|
|
2002-01-12 11:06:08 +03:00
|
|
|
// helper to get the presentation data of a frame, by possibly walking up
|
|
|
|
// the frame hierarchy if we happen to be surrounded by non-MathML frames.
|
|
|
|
/* static */ void
|
|
|
|
nsMathMLFrame::GetPresentationDataFrom(nsIFrame* aFrame,
|
2002-02-07 07:38:08 +03:00
|
|
|
nsPresentationData& aPresentationData,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aClimbTree)
|
2002-01-12 11:06:08 +03:00
|
|
|
{
|
2002-02-07 07:38:08 +03:00
|
|
|
// initialize OUT params
|
|
|
|
aPresentationData.flags = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
aPresentationData.baseFrame = nullptr;
|
2002-02-07 07:38:08 +03:00
|
|
|
|
2002-01-12 11:06:08 +03:00
|
|
|
nsIFrame* frame = aFrame;
|
|
|
|
while (frame) {
|
2006-08-15 08:49:43 +04:00
|
|
|
if (frame->IsFrameOfType(nsIFrame::eMathML)) {
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIMathMLFrame* mathMLFrame = do_QueryFrame(frame);
|
2006-08-15 08:49:43 +04:00
|
|
|
if (mathMLFrame) {
|
|
|
|
mathMLFrame->GetPresentationData(aPresentationData);
|
|
|
|
break;
|
|
|
|
}
|
2002-02-07 07:38:08 +03:00
|
|
|
}
|
|
|
|
// stop if the caller doesn't want to lookup beyond the frame
|
|
|
|
if (!aClimbTree) {
|
2002-01-12 11:06:08 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// stop if we reach the root <math> tag
|
2003-07-08 15:00:00 +04:00
|
|
|
nsIContent* content = frame->GetContent();
|
2008-01-16 08:07:09 +03:00
|
|
|
NS_ASSERTION(content || !frame->GetParent(), // no assert for the root
|
|
|
|
"dangling frame without a content node");
|
2002-04-02 07:57:56 +04:00
|
|
|
if (!content)
|
|
|
|
break;
|
2003-11-19 04:20:56 +03:00
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
if (content->Tag() == nsGkAtoms::math) {
|
2002-01-12 11:06:08 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-07-08 15:00:00 +04:00
|
|
|
frame = frame->GetParent();
|
2002-01-12 11:06:08 +03:00
|
|
|
}
|
2008-01-16 08:07:09 +03:00
|
|
|
NS_WARN_IF_FALSE(frame && frame->GetContent(),
|
|
|
|
"bad MathML markup - could not find the top <math> element");
|
2002-01-12 11:06:08 +03:00
|
|
|
}
|
|
|
|
|
2002-01-09 21:51:30 +03:00
|
|
|
/* static */ void
|
2011-04-08 05:04:40 +04:00
|
|
|
nsMathMLFrame::GetRuleThickness(nsRenderingContext& aRenderingContext,
|
2011-04-08 05:05:49 +04:00
|
|
|
nsFontMetrics* aFontMetrics,
|
2002-01-09 21:51:30 +03:00
|
|
|
nscoord& aRuleThickness)
|
|
|
|
{
|
|
|
|
// get the bounding metrics of the overbar char, the rendering context
|
|
|
|
// is assumed to have been set with the font of the current style context
|
2011-04-08 05:04:40 +04:00
|
|
|
NS_ASSERTION(aRenderingContext.FontMetrics()->Font().
|
|
|
|
Equals(aFontMetrics->Font()),
|
|
|
|
"unexpected state");
|
|
|
|
|
2011-04-08 08:18:43 +04:00
|
|
|
nscoord xHeight = aFontMetrics->XHeight();
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t overBar = 0x00AF;
|
2011-04-08 05:04:40 +04:00
|
|
|
nsBoundingMetrics bm = aRenderingContext.GetBoundingMetrics(&overBar, 1);
|
|
|
|
aRuleThickness = bm.ascent + bm.descent;
|
|
|
|
if (aRuleThickness <= 0 || aRuleThickness >= xHeight) {
|
2002-01-09 21:51:30 +03:00
|
|
|
// fall-back to the other version
|
|
|
|
GetRuleThickness(aFontMetrics, aRuleThickness);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
2011-04-08 05:04:40 +04:00
|
|
|
nsMathMLFrame::GetAxisHeight(nsRenderingContext& aRenderingContext,
|
2011-04-08 05:05:49 +04:00
|
|
|
nsFontMetrics* aFontMetrics,
|
2002-01-09 21:51:30 +03:00
|
|
|
nscoord& aAxisHeight)
|
|
|
|
{
|
2014-07-02 07:29:00 +04:00
|
|
|
gfxFont* mathFont = aFontMetrics->GetThebesFontGroup()->GetFirstMathFont();
|
|
|
|
if (mathFont) {
|
|
|
|
aAxisHeight =
|
|
|
|
mathFont->GetMathConstant(gfxFontEntry::AxisHeight,
|
|
|
|
aFontMetrics->AppUnitsPerDevPixel());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-01-09 21:51:30 +03:00
|
|
|
// get the bounding metrics of the minus sign, the rendering context
|
|
|
|
// is assumed to have been set with the font of the current style context
|
2011-04-08 05:04:40 +04:00
|
|
|
NS_ASSERTION(aRenderingContext.FontMetrics()->Font().
|
|
|
|
Equals(aFontMetrics->Font()),
|
|
|
|
"unexpected state");
|
|
|
|
|
2011-04-08 08:18:43 +04:00
|
|
|
nscoord xHeight = aFontMetrics->XHeight();
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t minus = 0x2212; // not '-', but official Unicode minus sign
|
2011-04-08 05:04:40 +04:00
|
|
|
nsBoundingMetrics bm = aRenderingContext.GetBoundingMetrics(&minus, 1);
|
|
|
|
aAxisHeight = bm.ascent - (bm.ascent + bm.descent)/2;
|
|
|
|
if (aAxisHeight <= 0 || aAxisHeight >= xHeight) {
|
2002-01-09 21:51:30 +03:00
|
|
|
// fall-back to the other version
|
|
|
|
GetAxisHeight(aFontMetrics, aAxisHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ nscoord
|
2004-08-01 03:15:21 +04:00
|
|
|
nsMathMLFrame::CalcLength(nsPresContext* aPresContext,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aStyleContext,
|
2002-01-09 21:51:30 +03:00
|
|
|
const nsCSSValue& aCSSValue)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aCSSValue.IsLengthUnit(), "not a length unit");
|
|
|
|
|
|
|
|
if (aCSSValue.IsFixedLengthUnit()) {
|
2010-08-13 13:58:01 +04:00
|
|
|
return aCSSValue.GetFixedLength(aPresContext);
|
|
|
|
}
|
|
|
|
if (aCSSValue.IsPixelLengthUnit()) {
|
|
|
|
return aCSSValue.GetPixelLength();
|
2002-01-09 21:51:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSUnit unit = aCSSValue.GetUnit();
|
|
|
|
|
2010-08-13 13:58:01 +04:00
|
|
|
if (eCSSUnit_EM == unit) {
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleFont* font = aStyleContext->StyleFont();
|
2002-01-09 21:51:30 +03:00
|
|
|
return NSToCoordRound(aCSSValue.GetFloatValue() * (float)font->mFont.size);
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_XHeight == unit) {
|
2011-08-14 21:08:04 +04:00
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
|
|
|
nsLayoutUtils::GetFontMetricsForStyleContext(aStyleContext,
|
|
|
|
getter_AddRefs(fm));
|
2011-04-08 08:18:43 +04:00
|
|
|
nscoord xHeight = fm->XHeight();
|
2002-01-09 21:51:30 +03:00
|
|
|
return NSToCoordRound(aCSSValue.GetFloatValue() * (float)xHeight);
|
|
|
|
}
|
|
|
|
|
2010-08-13 13:58:01 +04:00
|
|
|
// MathML doesn't specify other CSS units such as rem or ch
|
|
|
|
NS_ERROR("Unsupported unit");
|
2002-01-09 21:51:30 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-16 02:30:14 +04:00
|
|
|
/* static */ void
|
|
|
|
nsMathMLFrame::ParseNumericValue(const nsString& aString,
|
|
|
|
nscoord* aLengthValue,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFlags,
|
2012-05-16 02:30:14 +04:00
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsStyleContext* aStyleContext)
|
2002-01-09 21:51:30 +03:00
|
|
|
{
|
2012-05-16 02:30:14 +04:00
|
|
|
nsCSSValue cssValue;
|
|
|
|
|
2012-12-27 20:12:05 +04:00
|
|
|
if (!nsMathMLElement::ParseNumericValue(aString, cssValue, aFlags,
|
|
|
|
aPresContext->Document())) {
|
2012-05-16 02:30:14 +04:00
|
|
|
// Invalid attribute value. aLengthValue remains unchanged, so the default
|
|
|
|
// length value is used.
|
|
|
|
return;
|
2011-06-22 19:55:05 +04:00
|
|
|
}
|
2002-01-09 21:51:30 +03:00
|
|
|
|
2012-05-16 02:30:14 +04:00
|
|
|
nsCSSUnit unit = cssValue.GetUnit();
|
2002-01-09 21:51:30 +03:00
|
|
|
|
2012-05-16 02:30:14 +04:00
|
|
|
if (unit == eCSSUnit_Percent || unit == eCSSUnit_Number) {
|
|
|
|
// Relative units. A multiple of the default length value is used.
|
|
|
|
*aLengthValue = NSToCoordRound(*aLengthValue * (unit == eCSSUnit_Percent ?
|
|
|
|
cssValue.GetPercentValue() :
|
|
|
|
cssValue.GetFloatValue()));
|
|
|
|
return;
|
2002-01-09 21:51:30 +03:00
|
|
|
}
|
2012-05-16 02:30:14 +04:00
|
|
|
|
|
|
|
// Absolute units.
|
|
|
|
*aLengthValue = CalcLength(aPresContext, aStyleContext, cssValue);
|
2002-01-09 21:51:30 +03:00
|
|
|
}
|
2002-02-14 15:26:43 +03:00
|
|
|
|
|
|
|
// ================
|
|
|
|
// Utils to map attributes into CSS rules (work-around to bug 69409 which
|
|
|
|
// is not scheduled to be fixed anytime soon)
|
|
|
|
//
|
|
|
|
|
|
|
|
struct
|
|
|
|
nsCSSMapping {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t compatibility;
|
2002-02-14 15:26:43 +03:00
|
|
|
const nsIAtom* attrAtom;
|
|
|
|
const char* cssProperty;
|
|
|
|
};
|
|
|
|
|
2012-06-25 23:59:42 +04:00
|
|
|
#if defined(DEBUG) && defined(SHOW_BOUNDING_BOX)
|
2006-01-26 05:29:17 +03:00
|
|
|
class nsDisplayMathMLBoundingMetrics : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayMathMLBoundingMetrics(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame, const nsRect& aRect)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame), mRect(aRect) {
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayMathMLBoundingMetrics);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayMathMLBoundingMetrics() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayMathMLBoundingMetrics);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2014-02-24 18:41:56 +04:00
|
|
|
nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("MathMLBoundingMetrics", TYPE_MATHML_BOUNDING_METRICS)
|
2006-01-26 05:29:17 +03:00
|
|
|
private:
|
|
|
|
nsRect mRect;
|
|
|
|
};
|
|
|
|
|
|
|
|
void nsDisplayMathMLBoundingMetrics::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext* aCtx)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
|
|
|
aCtx->SetColor(NS_RGB(0,0,255));
|
2010-08-13 14:01:58 +04:00
|
|
|
aCtx->DrawRect(mRect + ToReferenceFrame());
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsMathMLFrame::DisplayBoundingMetrics(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame, const nsPoint& aPt,
|
|
|
|
const nsBoundingMetrics& aMetrics,
|
|
|
|
const nsDisplayListSet& aLists) {
|
|
|
|
if (!NS_MATHML_PAINT_BOUNDING_METRICS(mPresentationData.flags))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nscoord x = aPt.x + aMetrics.leftBearing;
|
|
|
|
nscoord y = aPt.y - aMetrics.ascent;
|
|
|
|
nscoord w = aMetrics.rightBearing - aMetrics.leftBearing;
|
|
|
|
nscoord h = aMetrics.ascent + aMetrics.descent;
|
|
|
|
|
|
|
|
return aLists.Content()->AppendNewToTop(new (aBuilder)
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayMathMLBoundingMetrics(aBuilder, this, nsRect(x,y,w,h)));
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class nsDisplayMathMLBar : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayMathMLBar(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame, const nsRect& aRect)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame), mRect(aRect) {
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayMathMLBar);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayMathMLBar() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayMathMLBar);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2014-02-24 18:41:56 +04:00
|
|
|
nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("MathMLBar", TYPE_MATHML_BAR)
|
2006-01-26 05:29:17 +03:00
|
|
|
private:
|
|
|
|
nsRect mRect;
|
|
|
|
};
|
|
|
|
|
|
|
|
void nsDisplayMathMLBar::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext* aCtx)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
|
|
|
// paint the bar with the current text color
|
2011-10-29 11:04:20 +04:00
|
|
|
aCtx->SetColor(mFrame->GetVisitedDependentColor(eCSSProperty_color));
|
2010-08-13 14:01:58 +04:00
|
|
|
aCtx->FillRect(mRect + ToReferenceFrame());
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsMathMLFrame::DisplayBar(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame, const nsRect& aRect,
|
|
|
|
const nsDisplayListSet& aLists) {
|
2013-02-17 01:51:02 +04:00
|
|
|
if (!aFrame->StyleVisibility()->IsVisible() || aRect.IsEmpty())
|
2013-02-14 15:12:27 +04:00
|
|
|
return;
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2013-02-14 15:08:08 +04:00
|
|
|
aLists.Content()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayMathMLBar(aBuilder, aFrame, aRect));
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2014-06-17 10:40:00 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
nsMathMLFrame::GetRadicalParameters(nsFontMetrics* aFontMetrics,
|
|
|
|
bool aDisplayStyle,
|
|
|
|
nscoord& aRadicalRuleThickness,
|
|
|
|
nscoord& aRadicalExtraAscender,
|
|
|
|
nscoord& aRadicalVerticalGap)
|
|
|
|
{
|
|
|
|
nscoord oneDevPixel = aFontMetrics->AppUnitsPerDevPixel();
|
|
|
|
gfxFont* mathFont = aFontMetrics->GetThebesFontGroup()->GetFirstMathFont();
|
|
|
|
|
|
|
|
// get the radical rulethickness
|
|
|
|
if (mathFont) {
|
|
|
|
aRadicalRuleThickness =
|
|
|
|
mathFont->GetMathConstant(gfxFontEntry::RadicalRuleThickness,
|
|
|
|
oneDevPixel);
|
|
|
|
} else {
|
|
|
|
GetRuleThickness(aFontMetrics, aRadicalRuleThickness);
|
|
|
|
}
|
|
|
|
|
|
|
|
// get the leading to be left at the top of the resulting frame
|
|
|
|
if (mathFont) {
|
|
|
|
aRadicalExtraAscender =
|
|
|
|
mathFont->GetMathConstant(gfxFontEntry::RadicalExtraAscender,
|
|
|
|
oneDevPixel);
|
|
|
|
} else {
|
|
|
|
// This seems more reliable than using aFontMetrics->GetLeading() on
|
|
|
|
// suspicious fonts.
|
|
|
|
nscoord em;
|
|
|
|
GetEmHeight(aFontMetrics, em);
|
|
|
|
aRadicalExtraAscender = nscoord(0.2f * em);
|
|
|
|
}
|
|
|
|
|
|
|
|
// get the clearance between rule and content
|
|
|
|
if (mathFont) {
|
|
|
|
aRadicalVerticalGap =
|
|
|
|
mathFont->GetMathConstant(aDisplayStyle ?
|
|
|
|
gfxFontEntry::RadicalDisplayStyleVerticalGap :
|
|
|
|
gfxFontEntry::RadicalVerticalGap,
|
|
|
|
oneDevPixel);
|
|
|
|
} else {
|
|
|
|
// Rule 11, App. G, TeXbook
|
|
|
|
aRadicalVerticalGap = aRadicalRuleThickness +
|
|
|
|
(aDisplayStyle ? aFontMetrics->XHeight() : aRadicalRuleThickness) / 4;
|
|
|
|
}
|
|
|
|
}
|