/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
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;
}
// by default, just inherit the display of our parent
nsPresentationData parentData;
GetPresentationDataFrom(aParent, parentData);
return NS_OK;
}
NS_IMETHODIMP
nsMathMLFrame::UpdatePresentationData(uint32_t aFlagsValues,
uint32_t aWhichFlags) {
NS_ASSERTION(NS_MATHML_IS_COMPRESSED(aWhichFlags) ||
NS_MATHML_IS_DTLS_SET(aWhichFlags), "aWhichFlags should only be compression or dtls flag");
if (NS_MATHML_IS_COMPRESSED(aWhichFlags)) { // 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
} // These flags determine whether the dtls font feature settings should // be applied. if (NS_MATHML_IS_DTLS_SET(aWhichFlags)) { if (NS_MATHML_IS_DTLS_SET(aFlagsValues)) {
mPresentationData.flags |= NS_MATHML_DTLS;
} else {
mPresentationData.flags &= ~NS_MATHML_DTLS;
}
} return NS_OK;
}
if (aFrame && aFrame->IsMathMLFrame()) {
nsIMathMLFrame* mathMLFrame = do_QueryFrame(aFrame); if (mathMLFrame) {
mathMLFrame->GetEmbellishData(aEmbellishData);
}
}
}
// 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, nsPresentationData& aPresentationData, bool aClimbTree) { // initialize OUT params
aPresentationData.flags = 0;
aPresentationData.baseFrame = nullptr;
nsIFrame* frame = aFrame; while (frame) { if (frame->IsMathMLFrame()) {
nsIMathMLFrame* mathMLFrame = do_QueryFrame(frame); if (mathMLFrame) {
mathMLFrame->GetPresentationData(aPresentationData); break;
}
} // stop if the caller doesn't want to lookup beyond the frame if (!aClimbTree) { break;
} // stop if we reach the root <math> tag
nsIContent* content = frame->GetContent();
NS_ASSERTION(content || !frame->GetParent(), // no assert for the root "dangling frame without a content node"); if (!content) { break;
}
if (content->IsMathMLElement(nsGkAtoms::math)) { break;
}
frame = frame->GetParent();
}
NS_WARNING_ASSERTION(
frame && frame->GetContent(), "bad MathML markup - could not find the top );
}
if (!dom::MathMLElement::ParseNumericValue(aString, cssValue, aFlags,
aPresContext->Document())) { // Invalid attribute value. aLengthValue remains unchanged, so the default // length value is used. return;
}
nsCSSUnit unit = cssValue.GetUnit();
if (unit == eCSSUnit_Percent) { // Relative units. A multiple of the default length value is used.
*aLengthValue = NSToCoordRound(
*aLengthValue * (unit == eCSSUnit_Percent ? cssValue.GetPercentValue()
: cssValue.GetFloatValue())); return;
}
void nsDisplayMathMLBar::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) { // paint the bar with the current text color
DrawTarget* drawTarget = aCtx->GetDrawTarget();
Rect rect = NSRectToNonEmptySnappedRect(
mRect + ToReferenceFrame(), mFrame->PresContext()->AppUnitsPerDevPixel(),
*drawTarget);
ColorPattern color(ToDeviceColor(
mFrame->GetVisitedDependentColor(&nsStyleText::mWebkitTextFillColor)));
drawTarget->FillRect(rect, color);
}
// get the radical rulethickness if (mathFont) {
aRadicalRuleThickness = mathFont->MathTable()->Constant(
gfxMathTable::RadicalRuleThickness, oneDevPixel);
} else {
GetRuleThickness(aFontMetrics, aRadicalRuleThickness);
}
// get the leading to be left at the top of the resulting frame if (mathFont) {
aRadicalExtraAscender = mathFont->MathTable()->Constant(
gfxMathTable::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->MathTable()->Constant(
aDisplayStyle ? gfxMathTable::RadicalDisplayStyleVerticalGap
: gfxMathTable::RadicalVerticalGap,
oneDevPixel);
} else { // Rule 11, App. G, TeXbook
aRadicalVerticalGap =
aRadicalRuleThickness +
(aDisplayStyle ? aFontMetrics->XHeight() : aRadicalRuleThickness) / 4;
}
}
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.