NS_IMETHODIMP nsMathMLmfracFrame::TransmitAutomaticData() { // 1. The REC says: // The <mfrac> element sets displaystyle to "false", or if it was already // false increments scriptlevel by 1, within numerator and denominator. // 2. The TeXbook (Ch 17. p.141) says the numerator inherits the compression // while the denominator is compressed bool increment = !NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags); SetIncrementScriptLevel(0, increment); SetIncrementScriptLevel(1, increment); UpdatePresentationDataFromChildAt(0, -1, ~NS_MATHML_DISPLAYSTYLE, NS_MATHML_DISPLAYSTYLE); UpdatePresentationDataFromChildAt(1, 1, NS_MATHML_COMPRESSED, NS_MATHML_COMPRESSED); // if our numerator is an embellished operator, let its state bubble to us GetEmbellishDataFrom(mFrames.FirstChild(), mEmbellishData); if (NS_MATHML_IS_EMBELLISH_OPERATOR(mEmbellishData.flags)) { // even when embellished, we need to record that <mfrac> won't fire // Stretch() on its embellished child mEmbellishData.direction = NS_STRETCH_DIRECTION_UNSUPPORTED; } return NS_OK; }
NS_IMETHODIMP nsMathMLmunderoverFrame::TransmitAutomaticData() { // At this stage, all our children are in sync and we can fully // resolve our own mEmbellishData struct //--------------------------------------------------------------------- /* The REC says: As regards munder (respectively mover) : The default value of accentunder is false, unless underscript is an <mo> element or an embellished operator. If underscript is an <mo> element, the value of its accent attribute is used as the default value of accentunder. If underscript is an embellished operator, the accent attribute of the <mo> element at its core is used as the default value. As with all attributes, an explicitly given value overrides the default. XXX The winner is the outermost setting in conflicting settings like these: <munder accentunder='true'> <mi>...</mi> <mo accentunder='false'> ... </mo> </munder> As regards munderover: The accent and accentunder attributes have the same effect as the attributes with the same names on <mover> and <munder>, respectively. Their default values are also computed in the same manner as described for those elements, with the default value of accent depending on overscript and the default value of accentunder depending on underscript. */ nsIFrame* overscriptFrame = nullptr; nsIFrame* underscriptFrame = nullptr; nsIFrame* baseFrame = mFrames.FirstChild(); nsIAtom* tag = mContent->Tag(); if (baseFrame) { if (tag == nsGkAtoms::munder_ || tag == nsGkAtoms::munderover_) { underscriptFrame = baseFrame->GetNextSibling(); } else { NS_ASSERTION(tag == nsGkAtoms::mover_, "mContent->Tag() not recognized"); overscriptFrame = baseFrame->GetNextSibling(); } } if (underscriptFrame && tag == nsGkAtoms::munderover_) { overscriptFrame = underscriptFrame->GetNextSibling(); } // if our base is an embellished operator, let its state bubble to us (in particular, // this is where we get the flag for NS_MATHML_EMBELLISH_MOVABLELIMITS). Our flags // are reset to the default values of false if the base frame isn't embellished. mPresentationData.baseFrame = baseFrame; GetEmbellishDataFrom(baseFrame, mEmbellishData); // The default value of accentunder is false, unless the underscript is embellished // and its core <mo> is an accent nsEmbellishData embellishData; nsAutoString value; if (tag == nsGkAtoms::munder_ || tag == nsGkAtoms::munderover_) { GetEmbellishDataFrom(underscriptFrame, embellishData); if (NS_MATHML_EMBELLISH_IS_ACCENT(embellishData.flags)) { mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTUNDER; } else { mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER; } // if we have an accentunder attribute, it overrides what the underscript said if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accentunder_, value)) { if (value.EqualsLiteral("true")) { mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTUNDER; } else if (value.EqualsLiteral("false")) { mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER; } } } // The default value of accent is false, unless the overscript is embellished // and its core <mo> is an accent if (tag == nsGkAtoms::mover_ || tag == nsGkAtoms::munderover_) { GetEmbellishDataFrom(overscriptFrame, embellishData); if (NS_MATHML_EMBELLISH_IS_ACCENT(embellishData.flags)) { mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTOVER; } else { mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER; } // if we have an accent attribute, it overrides what the overscript said if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accent_, value)) { if (value.EqualsLiteral("true")) { mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTOVER; } else if (value.EqualsLiteral("false")) { mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER; } } } bool subsupDisplay = NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) && StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_INLINE; // disable the stretch-all flag if we are going to act like a superscript if (subsupDisplay) { mPresentationData.flags &= ~NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY; } // Now transmit any change that we want to our children so that they // can update their mPresentationData structs //--------------------------------------------------------------------- /* The REC says: Within underscript, <munderover> always sets displaystyle to "false", but increments scriptlevel by 1 only when accentunder is "false". Within overscript, <munderover> always sets displaystyle to "false", but increments scriptlevel by 1 only when accent is "false". Within subscript and superscript it increments scriptlevel by 1, and sets displaystyle to "false", but leaves both attributes unchanged within base. The TeXBook treats 'over' like a superscript, so p.141 or Rule 13a say it shouldn't be compressed. However, The TeXBook says that math accents and \overline change uncramped styles to their cramped counterparts. */ if (tag == nsGkAtoms::mover_ || tag == nsGkAtoms::munderover_) { uint32_t compress = NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags) ? NS_MATHML_COMPRESSED : 0; mIncrementOver = !NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags) || subsupDisplay; SetIncrementScriptLevel(tag == nsGkAtoms::mover_ ? 1 : 2, mIncrementOver); if (mIncrementOver) { PropagateFrameFlagFor(overscriptFrame, NS_FRAME_MATHML_SCRIPT_DESCENDANT); } PropagatePresentationDataFor(overscriptFrame, compress, compress); } /* The TeXBook treats 'under' like a subscript, so p.141 or Rule 13a say it should be compressed */ if (tag == nsGkAtoms::munder_ || tag == nsGkAtoms::munderover_) { mIncrementUnder = !NS_MATHML_EMBELLISH_IS_ACCENTUNDER(mEmbellishData.flags) || subsupDisplay; SetIncrementScriptLevel(1, mIncrementUnder); if (mIncrementUnder) { PropagateFrameFlagFor(underscriptFrame, NS_FRAME_MATHML_SCRIPT_DESCENDANT); } PropagatePresentationDataFor(underscriptFrame, NS_MATHML_COMPRESSED, NS_MATHML_COMPRESSED); } /* Set flags for dtls font feature settings. dtls Dotless Forms This feature provides dotless forms for Math Alphanumeric characters, such as U+1D422 MATHEMATICAL BOLD SMALL I, U+1D423 MATHEMATICAL BOLD SMALL J, U+1D456 U+MATHEMATICAL ITALIC SMALL I, U+1D457 MATHEMATICAL ITALIC SMALL J, and so on. The dotless forms are to be used as base forms for placing mathematical accents over them. To opt out of this change, add the following to the stylesheet: "font-feature-settings: 'dtls' 0" */ if (overscriptFrame && NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags) && !NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags)) { PropagatePresentationDataFor(baseFrame, NS_MATHML_DTLS, NS_MATHML_DTLS); } return NS_OK; }
NS_IMETHODIMP nsMathMLmoverFrame::TransmitAutomaticData() { // At this stage, all our children are in sync and we can fully // resolve our own mEmbellishData struct //--------------------------------------------------------------------- /* The REC says: The default value of accent is false, unless overscript is an <mo> element or an embellished operator. If overscript is an <mo> element, the value of its accent attribute is used as the default value of accent. If overscript is an embellished operator, the accent attribute of the <mo> element at its core is used as the default value. As with all attributes, an explicitly given value overrides the default. XXX The winner is the outermost in conflicting settings like these: <mover accent='true'> <mi>...</mi> <mo accent='false'> ... </mo> </mover> */ nsIFrame* overscriptFrame = nsnull; nsIFrame* baseFrame = mFrames.FirstChild(); if (baseFrame) overscriptFrame = baseFrame->GetNextSibling(); // if our base is an embellished operator, let its state bubble to us (in particular, // this is where we get the flag for NS_MATHML_EMBELLISH_MOVABLELIMITS). Our flags // are reset to the default values of false if the base frame isn't embellished. mPresentationData.baseFrame = baseFrame; GetEmbellishDataFrom(baseFrame, mEmbellishData); // The default value of accent is false, unless the overscript is embellished // and its core <mo> is an accent nsEmbellishData embellishData; GetEmbellishDataFrom(overscriptFrame, embellishData); if (NS_MATHML_EMBELLISH_IS_ACCENT(embellishData.flags)) mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTOVER; else mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER; // if we have an accent attribute, it overrides what the overscript said static nsIContent::AttrValuesArray strings[] = {&nsGkAtoms::_true, &nsGkAtoms::_false, nsnull}; switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::accent_, strings, eCaseMatters)) { case 0: mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTOVER; break; case 1: mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER; break; } // disable the stretch-all flag if we are going to act like a superscript if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) && !NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags)) mPresentationData.flags &= ~NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY; // Now transmit any change that we want to our children so that they // can update their mPresentationData structs //--------------------------------------------------------------------- /* The REC says: Within overscript, <mover> always sets displaystyle to "false", but increments scriptlevel by 1 only when accent is "false". The TeXBook treats 'over' like a superscript, so p.141 or Rule 13a say it shouldn't be compressed. However, The TeXBook says that math accents and \overline change uncramped styles to their cramped counterparts. */ SetIncrementScriptLevel(1, !NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags)); PRUint32 compress = NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags) ? NS_MATHML_COMPRESSED : 0; PropagatePresentationDataFor(overscriptFrame, ~NS_MATHML_DISPLAYSTYLE | compress, NS_MATHML_DISPLAYSTYLE | compress); return NS_OK; }