author | James Kitchener <jkitch.bug@gmail.com> |
Mon, 19 Aug 2013 09:11:50 -0400 | |
changeset 143058 | bdcadb9eda9599838f4a3c596eb24cad1dd3f57f |
parent 143057 | 5355847939155056f963e1b5b1d359a9b51a3b18 |
child 143059 | 9a06d4cd909ca508e0c53e1f6e175787c01fce99 |
push id | 32613 |
push user | ryanvm@gmail.com |
push date | Mon, 19 Aug 2013 13:17:00 +0000 |
treeherder | mozilla-inbound@96e5f4fc71ef [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | fredw |
bugs | 827713 |
milestone | 26.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
layout/base/nsCSSFrameConstructor.cpp | file | annotate | diff | comparison | revisions | |
layout/generic/nsFrameIdList.h | file | annotate | diff | comparison | revisions | |
layout/mathml/moz.build | file | annotate | diff | comparison | revisions | |
layout/mathml/nsMathMLmsubFrame.cpp | file | annotate | diff | comparison | revisions | |
layout/mathml/nsMathMLmsubFrame.h | file | annotate | diff | comparison | revisions | |
layout/mathml/nsMathMLmsubsupFrame.cpp | file | annotate | diff | comparison | revisions | |
layout/mathml/nsMathMLmsubsupFrame.h | file | annotate | diff | comparison | revisions | |
layout/mathml/nsMathMLmsupFrame.cpp | file | annotate | diff | comparison | revisions | |
layout/mathml/nsMathMLmsupFrame.h | file | annotate | diff | comparison | revisions | |
layout/mathml/nsMathMLmunderoverFrame.cpp | file | annotate | diff | comparison | revisions |
--- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -4567,19 +4567,19 @@ nsCSSFrameConstructor::FindMathMLData(El SIMPLE_MATHML_CREATE(annotation_, NS_NewMathMLTokenFrame), SIMPLE_MATHML_CREATE(annotation_xml_, NS_NewMathMLmrowFrame), SIMPLE_MATHML_CREATE(mi_, NS_NewMathMLTokenFrame), SIMPLE_MATHML_CREATE(mn_, NS_NewMathMLTokenFrame), SIMPLE_MATHML_CREATE(ms_, NS_NewMathMLTokenFrame), SIMPLE_MATHML_CREATE(mtext_, NS_NewMathMLTokenFrame), SIMPLE_MATHML_CREATE(mo_, NS_NewMathMLmoFrame), SIMPLE_MATHML_CREATE(mfrac_, NS_NewMathMLmfracFrame), - SIMPLE_MATHML_CREATE(msup_, NS_NewMathMLmsupFrame), - SIMPLE_MATHML_CREATE(msub_, NS_NewMathMLmsubFrame), - SIMPLE_MATHML_CREATE(msubsup_, NS_NewMathMLmsubsupFrame), + SIMPLE_MATHML_CREATE(msup_, NS_NewMathMLmmultiscriptsFrame), + SIMPLE_MATHML_CREATE(msub_, NS_NewMathMLmmultiscriptsFrame), + SIMPLE_MATHML_CREATE(msubsup_, NS_NewMathMLmmultiscriptsFrame), SIMPLE_MATHML_CREATE(munder_, NS_NewMathMLmunderoverFrame), SIMPLE_MATHML_CREATE(mover_, NS_NewMathMLmunderoverFrame), SIMPLE_MATHML_CREATE(munderover_, NS_NewMathMLmunderoverFrame), SIMPLE_MATHML_CREATE(mphantom_, NS_NewMathMLmphantomFrame), SIMPLE_MATHML_CREATE(mpadded_, NS_NewMathMLmpaddedFrame), SIMPLE_MATHML_CREATE(mspace_, NS_NewMathMLmspaceFrame), SIMPLE_MATHML_CREATE(none, NS_NewMathMLmspaceFrame), SIMPLE_MATHML_CREATE(mprescripts_, NS_NewMathMLmspaceFrame),
--- a/layout/generic/nsFrameIdList.h +++ b/layout/generic/nsFrameIdList.h @@ -85,19 +85,16 @@ FRAME_ID(nsMathMLmoFrame) FRAME_ID(nsMathMLmoverFrame) FRAME_ID(nsMathMLmpaddedFrame) FRAME_ID(nsMathMLmphantomFrame) FRAME_ID(nsMathMLmrootFrame) FRAME_ID(nsMathMLmrowFrame) FRAME_ID(nsMathMLmspaceFrame) FRAME_ID(nsMathMLmsqrtFrame) FRAME_ID(nsMathMLmstyleFrame) -FRAME_ID(nsMathMLmsubFrame) -FRAME_ID(nsMathMLmsubsupFrame) -FRAME_ID(nsMathMLmsupFrame) FRAME_ID(nsMathMLmtableFrame) FRAME_ID(nsMathMLmtableOuterFrame) FRAME_ID(nsMathMLmtdFrame) FRAME_ID(nsMathMLmtdInnerFrame) FRAME_ID(nsMathMLmtrFrame) FRAME_ID(nsMathMLmunderFrame) FRAME_ID(nsMathMLmunderoverFrame) FRAME_ID(nsMathMLsemanticsFrame)
--- a/layout/mathml/moz.build +++ b/layout/mathml/moz.build @@ -21,16 +21,13 @@ CPP_SOURCES += [ 'nsMathMLmoFrame.cpp', 'nsMathMLmpaddedFrame.cpp', 'nsMathMLmphantomFrame.cpp', 'nsMathMLmrootFrame.cpp', 'nsMathMLmrowFrame.cpp', 'nsMathMLmspaceFrame.cpp', 'nsMathMLmsqrtFrame.cpp', 'nsMathMLmstyleFrame.cpp', - 'nsMathMLmsubFrame.cpp', - 'nsMathMLmsubsupFrame.cpp', - 'nsMathMLmsupFrame.cpp', 'nsMathMLmtableFrame.cpp', 'nsMathMLmunderoverFrame.cpp', 'nsMathMLsemanticsFrame.cpp', ]
deleted file mode 100644 --- a/layout/mathml/nsMathMLmsubFrame.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - - -#include "nsCOMPtr.h" -#include "nsFrame.h" -#include "nsPresContext.h" -#include "nsStyleContext.h" -#include "nsStyleConsts.h" - -#include "nsMathMLmsubFrame.h" -#include <algorithm> - -// -// <msub> -- attach a subscript to a base - implementation -// - -nsIFrame* -NS_NewMathMLmsubFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) -{ - return new (aPresShell) nsMathMLmsubFrame(aContext); -} - -NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmsubFrame) - -nsMathMLmsubFrame::~nsMathMLmsubFrame() -{ -} - -NS_IMETHODIMP -nsMathMLmsubFrame::TransmitAutomaticData() -{ - // if our base is an embellished operator, let its state bubble to us - mPresentationData.baseFrame = mFrames.FirstChild(); - GetEmbellishDataFrom(mPresentationData.baseFrame, mEmbellishData); - - // 1. The REC says: - // The <msub> element increments scriptlevel by 1, and sets displaystyle to - // "false", within subscript, but leaves both attributes unchanged within base. - // 2. The TeXbook (Ch 17. p.141) says the subscript is compressed - UpdatePresentationDataFromChildAt(1, -1, - ~NS_MATHML_DISPLAYSTYLE | NS_MATHML_COMPRESSED, - NS_MATHML_DISPLAYSTYLE | NS_MATHML_COMPRESSED); - - return NS_OK; -} - -/* virtual */ nsresult -nsMathMLmsubFrame::Place (nsRenderingContext& aRenderingContext, - bool aPlaceOrigin, - nsHTMLReflowMetrics& aDesiredSize) -{ - // extra spacing after sup/subscript - nscoord scriptSpace = nsPresContext::CSSPointsToAppUnits(0.5f); // 0.5pt as in plain TeX - - // subscriptshift - // - // "Specifies the minimum amount to shift the baseline of subscript down; the - // default is for the rendering agent to use its own positioning rules." - // - // values: length - // default: automatic - // - // We use 0 as the default value so unitless values can be ignored. - // As a minimum, negative values can be ignored. - // - nscoord subScriptShift = 0; - nsAutoString value; - GetAttribute(mContent, mPresentationData.mstyle, - nsGkAtoms::subscriptshift_, value); - if (!value.IsEmpty()) { - ParseNumericValue(value, &subScriptShift, 0, PresContext(), mStyleContext); - } - - return nsMathMLmsubFrame::PlaceSubScript(PresContext(), - aRenderingContext, - aPlaceOrigin, - aDesiredSize, - this, - subScriptShift, - scriptSpace); -} - -// exported routine that both munder and msub share. -// munder uses this when movablelimits is set. -nsresult -nsMathMLmsubFrame::PlaceSubScript (nsPresContext* aPresContext, - nsRenderingContext& aRenderingContext, - bool aPlaceOrigin, - nsHTMLReflowMetrics& aDesiredSize, - nsMathMLContainerFrame* aFrame, - nscoord aUserSubScriptShift, - nscoord aScriptSpace) -{ - // force the scriptSpace to be atleast 1 pixel - aScriptSpace = std::max(nsPresContext::CSSPixelsToAppUnits(1), aScriptSpace); - - //////////////////////////////////// - // Get the children's desired sizes - - nsBoundingMetrics bmBase, bmSubScript; - nsHTMLReflowMetrics baseSize; - nsHTMLReflowMetrics subScriptSize; - nsIFrame* baseFrame = aFrame->GetFirstPrincipalChild(); - nsIFrame* subScriptFrame = nullptr; - if (baseFrame) - subScriptFrame = baseFrame->GetNextSibling(); - if (!baseFrame || !subScriptFrame || subScriptFrame->GetNextSibling()) { - // report an error, encourage people to get their markups in order - if (aPlaceOrigin) { - aFrame->ReportChildCountError(); - } - return aFrame->ReflowError(aRenderingContext, aDesiredSize); - } - GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase); - GetReflowAndBoundingMetricsFor(subScriptFrame, subScriptSize, bmSubScript); - - // get the subdrop from the subscript font - nscoord subDrop; - GetSubDropFromChild(subScriptFrame, subDrop); - // parameter v, Rule 18a, App. G, TeXbook - nscoord minSubScriptShift = bmBase.descent + subDrop; - - ////////////////// - // Place Children - - // get min subscript shift limit from x-height - // = h(x) - 4/5 * sigma_5, Rule 18b, App. G, TeXbook - nscoord xHeight = 0; - nsRefPtr<nsFontMetrics> fm; - nsLayoutUtils::GetFontMetricsForFrame(baseFrame, getter_AddRefs(fm)); - - xHeight = fm->XHeight(); - nscoord minShiftFromXHeight = (nscoord) - (bmSubScript.ascent - (4.0f/5.0f) * xHeight); - - // subScriptShift - // = minimum amount to shift the subscript down set by user or from the font - // = sub1 in TeX - // = subscriptshift attribute * x-height - nscoord subScriptShift, dummy; - // get subScriptShift default from font - GetSubScriptShifts (fm, subScriptShift, dummy); - - subScriptShift = - std::max(subScriptShift, aUserSubScriptShift); - - // get actual subscriptshift to be used - // Rule 18b, App. G, TeXbook - nscoord actualSubScriptShift = - std::max(minSubScriptShift,std::max(subScriptShift,minShiftFromXHeight)); - // get bounding box for base + subscript - nsBoundingMetrics boundingMetrics; - boundingMetrics.ascent = - std::max(bmBase.ascent, bmSubScript.ascent - actualSubScriptShift); - boundingMetrics.descent = - std::max(bmBase.descent, bmSubScript.descent + actualSubScriptShift); - - // add aScriptSpace to the subscript's width - boundingMetrics.width = bmBase.width + bmSubScript.width + aScriptSpace; - boundingMetrics.leftBearing = bmBase.leftBearing; - boundingMetrics.rightBearing = std::max(bmBase.rightBearing, bmBase.width + - std::max(bmSubScript.width + aScriptSpace, bmSubScript.rightBearing)); - aFrame->SetBoundingMetrics (boundingMetrics); - - // reflow metrics - aDesiredSize.ascent = - std::max(baseSize.ascent, subScriptSize.ascent - actualSubScriptShift); - aDesiredSize.height = aDesiredSize.ascent + - std::max(baseSize.height - baseSize.ascent, - subScriptSize.height - subScriptSize.ascent + actualSubScriptShift); - aDesiredSize.width = boundingMetrics.width; - aDesiredSize.mBoundingMetrics = boundingMetrics; - - aFrame->SetReference(nsPoint(0, aDesiredSize.ascent)); - - if (aPlaceOrigin) { - nscoord dx, dy; - // now place the base ... - dx = aFrame->MirrorIfRTL(aDesiredSize.width, baseSize.width, 0); - dy = aDesiredSize.ascent - baseSize.ascent; - FinishReflowChild (baseFrame, aPresContext, nullptr, baseSize, dx, dy, 0); - // ... and subscript - dx = aFrame->MirrorIfRTL(aDesiredSize.width, subScriptSize.width, - bmBase.width); - dy = aDesiredSize.ascent - (subScriptSize.ascent - actualSubScriptShift); - FinishReflowChild (subScriptFrame, aPresContext, nullptr, subScriptSize, dx, dy, 0); - } - - return NS_OK; -}
deleted file mode 100644 --- a/layout/mathml/nsMathMLmsubFrame.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#ifndef nsMathMLmsubFrame_h___ -#define nsMathMLmsubFrame_h___ - -#include "mozilla/Attributes.h" -#include "nsCOMPtr.h" -#include "nsMathMLContainerFrame.h" - -// -// <msub> -- attach a subscript to a base -// - -class nsMathMLmsubFrame : public nsMathMLContainerFrame { -public: - NS_DECL_FRAMEARENA_HELPERS - - friend nsIFrame* NS_NewMathMLmsubFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); - - NS_IMETHOD - TransmitAutomaticData() MOZ_OVERRIDE; - - virtual nsresult - Place(nsRenderingContext& aRenderingContext, - bool aPlaceOrigin, - nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; - - static nsresult - PlaceSubScript (nsPresContext* aPresContext, - nsRenderingContext& aRenderingContext, - bool aPlaceOrigin, - nsHTMLReflowMetrics& aDesiredSize, - nsMathMLContainerFrame* aForFrame, - nscoord aUserSubScriptShift, - nscoord aScriptSpace); - - protected: - nsMathMLmsubFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {} - virtual ~nsMathMLmsubFrame(); -}; - -#endif /* nsMathMLmsubFrame_h___ */
deleted file mode 100644 --- a/layout/mathml/nsMathMLmsubsupFrame.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - - -#include "nsCOMPtr.h" -#include "nsFrame.h" -#include "nsPresContext.h" -#include "nsStyleContext.h" -#include "nsStyleConsts.h" -#include "nsRenderingContext.h" - -#include "nsMathMLmsubsupFrame.h" -#include <algorithm> - -// -// <msubsup> -- attach a subscript-superscript pair to a base - implementation -// - -nsIFrame* -NS_NewMathMLmsubsupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) -{ - return new (aPresShell) nsMathMLmsubsupFrame(aContext); -} - -NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmsubsupFrame) - -nsMathMLmsubsupFrame::~nsMathMLmsubsupFrame() -{ -} - -NS_IMETHODIMP -nsMathMLmsubsupFrame::TransmitAutomaticData() -{ - // if our base is an embellished operator, let its state bubble to us - mPresentationData.baseFrame = mFrames.FirstChild(); - GetEmbellishDataFrom(mPresentationData.baseFrame, mEmbellishData); - - // 1. The REC says: - // The <msubsup> element increments scriptlevel by 1, and sets displaystyle to - // "false", within subscript and superscript, but leaves both attributes - // unchanged within base. - // 2. The TeXbook (Ch 17. p.141) says the superscript inherits the compression - // while the subscript is compressed - UpdatePresentationDataFromChildAt(1, -1, - ~NS_MATHML_DISPLAYSTYLE, - NS_MATHML_DISPLAYSTYLE); - UpdatePresentationDataFromChildAt(1, 1, - NS_MATHML_COMPRESSED, - NS_MATHML_COMPRESSED); - - return NS_OK; -} - -/* virtual */ nsresult -nsMathMLmsubsupFrame::Place(nsRenderingContext& aRenderingContext, - bool aPlaceOrigin, - nsHTMLReflowMetrics& aDesiredSize) -{ - // extra spacing between base and sup/subscript - nscoord scriptSpace = 0; - - // subscriptshift - // - // "Specifies the minimum amount to shift the baseline of subscript down; the - // default is for the rendering agent to use its own positioning rules." - // - // values: length - // default: automatic - // - // We use 0 as the default value so unitless values can be ignored. - // As a minimum, negative values can be ignored. - // - nsAutoString value; - nscoord subScriptShift = 0; - GetAttribute(mContent, mPresentationData.mstyle, - nsGkAtoms::subscriptshift_, value); - if (!value.IsEmpty()) { - ParseNumericValue(value, &subScriptShift, 0, PresContext(), mStyleContext); - } - // superscriptshift - // - // "Specifies the minimum amount to shift the baseline of superscript up; the - // default is for the rendering agent to use its own positioning rules." - // - // values: length - // default: automatic - // - // We use 0 as the default value so unitless values can be ignored. - // As a minimum, negative values can be ignored. - // - nscoord supScriptShift = 0; - GetAttribute(mContent, mPresentationData.mstyle, - nsGkAtoms::superscriptshift_, value); - if (!value.IsEmpty()) { - ParseNumericValue(value, &supScriptShift, 0, PresContext(), mStyleContext); - } - - return nsMathMLmsubsupFrame::PlaceSubSupScript(PresContext(), - aRenderingContext, - aPlaceOrigin, - aDesiredSize, - this, - subScriptShift, - supScriptShift, - scriptSpace); -} - -// exported routine that both munderover and msubsup share. -// munderover uses this when movablelimits is set. -nsresult -nsMathMLmsubsupFrame::PlaceSubSupScript(nsPresContext* aPresContext, - nsRenderingContext& aRenderingContext, - bool aPlaceOrigin, - nsHTMLReflowMetrics& aDesiredSize, - nsMathMLContainerFrame* aFrame, - nscoord aUserSubScriptShift, - nscoord aUserSupScriptShift, - nscoord aScriptSpace) -{ - // force the scriptSpace to be atleast 1 pixel - nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1); - aScriptSpace = std::max(onePixel, aScriptSpace); - - //////////////////////////////////// - // Get the children's desired sizes - - nsHTMLReflowMetrics baseSize; - nsHTMLReflowMetrics subScriptSize; - nsHTMLReflowMetrics supScriptSize; - nsBoundingMetrics bmBase, bmSubScript, bmSupScript; - nsIFrame* subScriptFrame = nullptr; - nsIFrame* supScriptFrame = nullptr; - nsIFrame* baseFrame = aFrame->GetFirstPrincipalChild(); - if (baseFrame) - subScriptFrame = baseFrame->GetNextSibling(); - if (subScriptFrame) - supScriptFrame = subScriptFrame->GetNextSibling(); - if (!baseFrame || !subScriptFrame || !supScriptFrame || - supScriptFrame->GetNextSibling()) { - // report an error, encourage people to get their markups in order - if (aPlaceOrigin) { - aFrame->ReportChildCountError(); - } - return aFrame->ReflowError(aRenderingContext, aDesiredSize); - } - GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase); - GetReflowAndBoundingMetricsFor(subScriptFrame, subScriptSize, bmSubScript); - GetReflowAndBoundingMetricsFor(supScriptFrame, supScriptSize, bmSupScript); - - // get the subdrop from the subscript font - nscoord subDrop; - GetSubDropFromChild(subScriptFrame, subDrop); - // parameter v, Rule 18a, App. G, TeXbook - nscoord minSubScriptShift = bmBase.descent + subDrop; - - // get the supdrop from the supscript font - nscoord supDrop; - GetSupDropFromChild(supScriptFrame, supDrop); - // parameter u, Rule 18a, App. G, TeXbook - nscoord minSupScriptShift = bmBase.ascent - supDrop; - - ////////////////// - // Place Children - ////////////////// - - ////////////////////////////////////////////////// - // Get subscript shift - // slightly different from nsMathMLmsubFrame.cpp - ////////////////////////////////////////////////// - - // subScriptShift{1,2} - // = minimum amount to shift the subscript down - // = sub{1,2} in TeXbook - // subScriptShift1 = subscriptshift attribute * x-height - nscoord subScriptShift1, subScriptShift2; - - nsRefPtr<nsFontMetrics> fm; - nsLayoutUtils::GetFontMetricsForFrame(baseFrame, getter_AddRefs(fm)); - aRenderingContext.SetFont(fm); - - // get x-height (an ex) - nscoord xHeight = fm->XHeight(); - - nscoord ruleSize; - GetRuleThickness (aRenderingContext, fm, ruleSize); - - // Get subScriptShift{1,2} default from font - GetSubScriptShifts (fm, subScriptShift1, subScriptShift2); - - if (0 < aUserSubScriptShift) { - // the user has set the subscriptshift attribute - float scaler = ((float) subScriptShift2) / subScriptShift1; - subScriptShift1 = std::max(subScriptShift1, aUserSubScriptShift); - subScriptShift2 = NSToCoordRound(scaler * subScriptShift1); - } - - // get a tentative value for subscriptshift - // Rule 18d, App. G, TeXbook - nscoord subScriptShift = - std::max(minSubScriptShift,std::max(subScriptShift1,subScriptShift2)); - - ////////////////////////////////////////////////// - // Get supscript shift - // same code from nsMathMLmsupFrame.cpp - ////////////////////////////////////////////////// - - // get min supscript shift limit from x-height - // = d(x) + 1/4 * sigma_5, Rule 18c, App. G, TeXbook - nscoord minShiftFromXHeight = (nscoord) - (bmSupScript.descent + (1.0f/4.0f) * xHeight); - - // supScriptShift{1,2,3} - // = minimum amount to shift the supscript up - // = sup{1,2,3} in TeX - // supScriptShift1 = superscriptshift attribute * x-height - // Note that there are THREE values for supscript shifts depending - // on the current style - nscoord supScriptShift1, supScriptShift2, supScriptShift3; - // Set supScriptShift{1,2,3} default from font - GetSupScriptShifts (fm, supScriptShift1, supScriptShift2, supScriptShift3); - if (0 < aUserSupScriptShift) { - // the user has set the superscriptshift attribute - float scaler2 = ((float) supScriptShift2) / supScriptShift1; - float scaler3 = ((float) supScriptShift3) / supScriptShift1; - supScriptShift1 = std::max(supScriptShift1, aUserSupScriptShift); - supScriptShift2 = NSToCoordRound(scaler2 * supScriptShift1); - supScriptShift3 = NSToCoordRound(scaler3 * supScriptShift1); - } - - // get sup script shift depending on current script level and display style - // Rule 18c, App. G, TeXbook - nscoord supScriptShift; - nsPresentationData presentationData; - aFrame->GetPresentationData(presentationData); - if ( aFrame->StyleFont()->mScriptLevel == 0 && - NS_MATHML_IS_DISPLAYSTYLE(presentationData.flags) && - !NS_MATHML_IS_COMPRESSED(presentationData.flags)) { - // Style D in TeXbook - supScriptShift = supScriptShift1; - } - else if (NS_MATHML_IS_COMPRESSED(presentationData.flags)) { - // Style C' in TeXbook = D',T',S',SS' - supScriptShift = supScriptShift3; - } - else { - // everything else = T,S,SS - supScriptShift = supScriptShift2; - } - - // get tentative value for superscriptshift - // Rule 18c, App. G, TeXbook - supScriptShift = - std::max(minSupScriptShift,std::max(supScriptShift,minShiftFromXHeight)); - - ////////////////////////////////////////////////// - // Negotiate between supScriptShift and subScriptShift - // so that there will be enough gap between them - // Rule 18e, App. G, TeXbook - ////////////////////////////////////////////////// - - nscoord gap = - (supScriptShift - bmSupScript.descent) - - (bmSubScript.ascent - subScriptShift); - if (gap < 4.0f * ruleSize) { - // adjust subScriptShift to get a gap of (4.0 * ruleSize) - subScriptShift += NSToCoordRound ((4.0f * ruleSize) - gap); - } - - // next we want to ensure that the bottom of the superscript - // will be > (4/5) * x-height above baseline - gap = NSToCoordRound ((4.0f/5.0f) * xHeight - - (supScriptShift - bmSupScript.descent)); - if (gap > 0) { - supScriptShift += gap; - subScriptShift -= gap; - } - - ////////////////////////////////////////////////// - // Do the Placing - ////////////////////////////////////////////////// - - // get bounding box for base + subscript + superscript - nsBoundingMetrics boundingMetrics; - boundingMetrics.ascent = - std::max(bmBase.ascent, (bmSupScript.ascent + supScriptShift)); - boundingMetrics.descent = - std::max(bmBase.descent, (bmSubScript.descent + subScriptShift)); - - // leave aScriptSpace after both super/subscript - // add italicCorrection between base and superscript - // add "a little to spare" as well (see TeXbook Ch.11, p.64), as we - // estimate the italic creation ourselves and it isn't the same as TeX - nscoord italicCorrection; - GetItalicCorrection(bmBase, italicCorrection); - italicCorrection += onePixel; - boundingMetrics.width = bmBase.width + aScriptSpace + - std::max((italicCorrection + bmSupScript.width), bmSubScript.width); - boundingMetrics.leftBearing = bmBase.leftBearing; - boundingMetrics.rightBearing = bmBase.width + - std::max((italicCorrection + bmSupScript.rightBearing), bmSubScript.rightBearing); - aFrame->SetBoundingMetrics(boundingMetrics); - - // reflow metrics - aDesiredSize.ascent = - std::max(baseSize.ascent, - std::max(subScriptSize.ascent - subScriptShift, - supScriptSize.ascent + supScriptShift)); - aDesiredSize.height = aDesiredSize.ascent + - std::max(baseSize.height - baseSize.ascent, - std::max(subScriptSize.height - subScriptSize.ascent + subScriptShift, - supScriptSize.height - subScriptSize.ascent - supScriptShift)); - aDesiredSize.width = boundingMetrics.width; - aDesiredSize.mBoundingMetrics = boundingMetrics; - - aFrame->SetReference(nsPoint(0, aDesiredSize.ascent)); - - if (aPlaceOrigin) { - nscoord dx, dy; - // now place the base ... - dx = aFrame->MirrorIfRTL(aDesiredSize.width, baseSize.width, 0); - dy = aDesiredSize.ascent - baseSize.ascent; - FinishReflowChild(baseFrame, aPresContext, nullptr, - baseSize, dx, dy, 0); - // ... and subscript - dx = aFrame->MirrorIfRTL(aDesiredSize.width, subScriptSize.width, - bmBase.width); - dy = aDesiredSize.ascent - (subScriptSize.ascent - subScriptShift); - FinishReflowChild(subScriptFrame, aPresContext, nullptr, - subScriptSize, dx, dy, 0); - // ... and the superscript - dx = aFrame->MirrorIfRTL(aDesiredSize.width, supScriptSize.width, - bmBase.width + italicCorrection); - dy = aDesiredSize.ascent - (supScriptSize.ascent + supScriptShift); - FinishReflowChild(supScriptFrame, aPresContext, nullptr, - supScriptSize, dx, dy, 0); - } - - return NS_OK; -}
deleted file mode 100644 --- a/layout/mathml/nsMathMLmsubsupFrame.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#ifndef nsMathMLmsubsupFrame_h___ -#define nsMathMLmsubsupFrame_h___ - -#include "mozilla/Attributes.h" -#include "nsCOMPtr.h" -#include "nsMathMLContainerFrame.h" - -// -// <msubsup> -- attach a subscript-superscript pair to a base -// - -class nsMathMLmsubsupFrame : public nsMathMLContainerFrame { -public: - NS_DECL_FRAMEARENA_HELPERS - - friend nsIFrame* NS_NewMathMLmsubsupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); - - NS_IMETHOD - TransmitAutomaticData() MOZ_OVERRIDE; - - virtual nsresult - Place(nsRenderingContext& aRenderingContext, - bool aPlaceOrigin, - nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; - - static nsresult - PlaceSubSupScript(nsPresContext* aPresContext, - nsRenderingContext& aRenderingContext, - bool aPlaceOrigin, - nsHTMLReflowMetrics& aDesiredSize, - nsMathMLContainerFrame* aForFrame, - nscoord aUserSubScriptShift, - nscoord aUserSupScriptShift, - nscoord aScriptSpace); - -protected: - nsMathMLmsubsupFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {} - virtual ~nsMathMLmsubsupFrame(); -}; - -#endif /* nsMathMLmsubsupFrame_h___ */
deleted file mode 100644 --- a/layout/mathml/nsMathMLmsupFrame.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#include "nsCOMPtr.h" -#include "nsFrame.h" -#include "nsPresContext.h" -#include "nsStyleContext.h" -#include "nsStyleConsts.h" - -#include "nsMathMLmsupFrame.h" -#include <algorithm> - -// -// <msup> -- attach a superscript to a base - implementation -// - -nsIFrame* -NS_NewMathMLmsupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) -{ - return new (aPresShell) nsMathMLmsupFrame(aContext); -} - -NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmsupFrame) - -nsMathMLmsupFrame::~nsMathMLmsupFrame() -{ -} - -NS_IMETHODIMP -nsMathMLmsupFrame::TransmitAutomaticData() -{ - // if our base is an embellished operator, its flags bubble to us - mPresentationData.baseFrame = mFrames.FirstChild(); - GetEmbellishDataFrom(mPresentationData.baseFrame, mEmbellishData); - - // 1. The REC says: - // The <msup> element increments scriptlevel by 1, and sets displaystyle to - // "false", within superscript, but leaves both attributes unchanged within base. - // 2. The TeXbook (Ch 17. p.141) says the superscript *inherits* the compression, - // so we don't set the compression flag. Our parent will propagate its own. - UpdatePresentationDataFromChildAt(1, -1, - ~NS_MATHML_DISPLAYSTYLE, - NS_MATHML_DISPLAYSTYLE); - - return NS_OK; -} - -/* virtual */ nsresult -nsMathMLmsupFrame::Place(nsRenderingContext& aRenderingContext, - bool aPlaceOrigin, - nsHTMLReflowMetrics& aDesiredSize) -{ - // extra spacing after sup/subscript - nscoord scriptSpace = nsPresContext::CSSPointsToAppUnits(0.5f); // 0.5pt as in plain TeX - - // superscriptshift - // - // "Specifies the minimum amount to shift the baseline of superscript up; the - // default is for the rendering agent to use its own positioning rules." - // - // values: length - // default: automatic - // - // We use 0 as the default value so unitless values can be ignored. - // As a minimum, negative values can be ignored. - // - nsAutoString value; - nscoord supScriptShift = 0; - GetAttribute(mContent, mPresentationData.mstyle, - nsGkAtoms::superscriptshift_, value); - if (!value.IsEmpty()) { - ParseNumericValue(value, &supScriptShift, 0, PresContext(), mStyleContext); - } - - return nsMathMLmsupFrame::PlaceSuperScript(PresContext(), - aRenderingContext, - aPlaceOrigin, - aDesiredSize, - this, - supScriptShift, - scriptSpace); -} - -// exported routine that both mover and msup share. -// mover uses this when movablelimits is set. -nsresult -nsMathMLmsupFrame::PlaceSuperScript(nsPresContext* aPresContext, - nsRenderingContext& aRenderingContext, - bool aPlaceOrigin, - nsHTMLReflowMetrics& aDesiredSize, - nsMathMLContainerFrame* aFrame, - nscoord aUserSupScriptShift, - nscoord aScriptSpace) -{ - // force the scriptSpace to be at least 1 pixel - nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1); - aScriptSpace = std::max(onePixel, aScriptSpace); - - //////////////////////////////////// - // Get the children's desired sizes - - nsHTMLReflowMetrics baseSize; - nsHTMLReflowMetrics supScriptSize; - nsBoundingMetrics bmBase, bmSupScript; - nsIFrame* supScriptFrame = nullptr; - nsIFrame* baseFrame = aFrame->GetFirstPrincipalChild(); - if (baseFrame) - supScriptFrame = baseFrame->GetNextSibling(); - if (!baseFrame || !supScriptFrame || supScriptFrame->GetNextSibling()) { - // report an error, encourage people to get their markups in order - if (aPlaceOrigin) { - aFrame->ReportChildCountError(); - } - return aFrame->ReflowError(aRenderingContext, aDesiredSize); - } - GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase); - GetReflowAndBoundingMetricsFor(supScriptFrame, supScriptSize, bmSupScript); - - // get the supdrop from the supscript font - nscoord supDrop; - GetSupDropFromChild(supScriptFrame, supDrop); - // parameter u, Rule 18a, App. G, TeXbook - nscoord minSupScriptShift = bmBase.ascent - supDrop; - - ////////////////// - // Place Children - - // get min supscript shift limit from x-height - // = d(x) + 1/4 * sigma_5, Rule 18c, App. G, TeXbook - nscoord xHeight = 0; - nsRefPtr<nsFontMetrics> fm; - nsLayoutUtils::GetFontMetricsForFrame(baseFrame, getter_AddRefs(fm)); - - xHeight = fm->XHeight(); - nscoord minShiftFromXHeight = (nscoord) - (bmSupScript.descent + (1.0f/4.0f) * xHeight); - nscoord italicCorrection; - GetItalicCorrection(bmBase, italicCorrection); - - // supScriptShift{1,2,3} - // = minimum amount to shift the supscript up - // = sup{1,2,3} in TeX - // supScriptShift1 = superscriptshift attribute * x-height - // Note that there are THREE values for supscript shifts depending - // on the current style - nscoord supScriptShift1, supScriptShift2, supScriptShift3; - // Set supScriptShift{1,2,3} default from font - GetSupScriptShifts (fm, supScriptShift1, supScriptShift2, supScriptShift3); - - if (0 < aUserSupScriptShift) { - // the user has set the superscriptshift attribute - float scaler2 = ((float) supScriptShift2) / supScriptShift1; - float scaler3 = ((float) supScriptShift3) / supScriptShift1; - supScriptShift1 = - std::max(supScriptShift1, aUserSupScriptShift); - supScriptShift2 = NSToCoordRound(scaler2 * supScriptShift1); - supScriptShift3 = NSToCoordRound(scaler3 * supScriptShift1); - } - - // get sup script shift depending on current script level and display style - // Rule 18c, App. G, TeXbook - nscoord supScriptShift; - nsPresentationData presentationData; - aFrame->GetPresentationData (presentationData); - if ( aFrame->StyleFont()->mScriptLevel == 0 && - NS_MATHML_IS_DISPLAYSTYLE(presentationData.flags) && - !NS_MATHML_IS_COMPRESSED(presentationData.flags)) { - // Style D in TeXbook - supScriptShift = supScriptShift1; - } - else if (NS_MATHML_IS_COMPRESSED(presentationData.flags)) { - // Style C' in TeXbook = D',T',S',SS' - supScriptShift = supScriptShift3; - } - else { - // everything else = T,S,SS - supScriptShift = supScriptShift2; - } - - // get actual supscriptshift to be used - // Rule 18c, App. G, TeXbook - nscoord actualSupScriptShift = - std::max(minSupScriptShift,std::max(supScriptShift,minShiftFromXHeight)); - - // bounding box - nsBoundingMetrics boundingMetrics; - boundingMetrics.ascent = - std::max(bmBase.ascent, (bmSupScript.ascent + actualSupScriptShift)); - boundingMetrics.descent = - std::max(bmBase.descent, (bmSupScript.descent - actualSupScriptShift)); - - // leave aScriptSpace after superscript - // add italicCorrection between base and superscript - // add "a little to spare" as well (see TeXbook Ch.11, p.64), as we - // estimate the italic creation ourselves and it isn't the same as TeX - italicCorrection += onePixel; - boundingMetrics.width = bmBase.width + italicCorrection + - bmSupScript.width + aScriptSpace; - boundingMetrics.leftBearing = bmBase.leftBearing; - boundingMetrics.rightBearing = bmBase.width + italicCorrection + - bmSupScript.rightBearing; - aFrame->SetBoundingMetrics(boundingMetrics); - - // reflow metrics - aDesiredSize.ascent = - std::max(baseSize.ascent, (supScriptSize.ascent + actualSupScriptShift)); - aDesiredSize.height = aDesiredSize.ascent + - std::max(baseSize.height - baseSize.ascent, - (supScriptSize.height - supScriptSize.ascent - actualSupScriptShift)); - aDesiredSize.width = boundingMetrics.width; - aDesiredSize.mBoundingMetrics = boundingMetrics; - - aFrame->SetReference(nsPoint(0, aDesiredSize.ascent)); - - if (aPlaceOrigin) { - nscoord dx, dy; - // now place the base ... - dx = aFrame->MirrorIfRTL(aDesiredSize.width, baseSize.width, 0); - dy = aDesiredSize.ascent - baseSize.ascent; - FinishReflowChild (baseFrame, aPresContext, nullptr, baseSize, dx, dy, 0); - // ... and supscript - dx = aFrame->MirrorIfRTL(aDesiredSize.width, supScriptSize.width, - bmBase.width + italicCorrection); - dy = aDesiredSize.ascent - (supScriptSize.ascent + actualSupScriptShift); - FinishReflowChild (supScriptFrame, aPresContext, nullptr, supScriptSize, dx, dy, 0); - } - - return NS_OK; -}
deleted file mode 100644 --- a/layout/mathml/nsMathMLmsupFrame.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#ifndef nsMathMLmsupFrame_h___ -#define nsMathMLmsupFrame_h___ - -#include "mozilla/Attributes.h" -#include "nsCOMPtr.h" -#include "nsMathMLContainerFrame.h" - -// -// <msup> -- attach a superscript to a base -// - -class nsMathMLmsupFrame : public nsMathMLContainerFrame { -public: - NS_DECL_FRAMEARENA_HELPERS - - friend nsIFrame* NS_NewMathMLmsupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); - - NS_IMETHOD - TransmitAutomaticData() MOZ_OVERRIDE; - - virtual nsresult - Place(nsRenderingContext& aRenderingContext, - bool aPlaceOrigin, - nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; - - static nsresult - PlaceSuperScript (nsPresContext* aPresContext, - nsRenderingContext& aRenderingContext, - bool aPlaceOrigin, - nsHTMLReflowMetrics& aDesiredSize, - nsMathMLContainerFrame* aForFrame, - nscoord aUserSupScriptShift, - nscoord aScriptSpace); - -protected: - nsMathMLmsupFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {} - virtual ~nsMathMLmsupFrame(); -}; - -#endif /* nsMathMLmsupFrame_h___ */
--- a/layout/mathml/nsMathMLmunderoverFrame.cpp +++ b/layout/mathml/nsMathMLmunderoverFrame.cpp @@ -8,19 +8,17 @@ #include "nsFrame.h" #include "nsPresContext.h" #include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsINameSpaceManager.h" #include "nsRenderingContext.h" #include "nsMathMLmunderoverFrame.h" -#include "nsMathMLmsubsupFrame.h" -#include "nsMathMLmsupFrame.h" -#include "nsMathMLmsubFrame.h" +#include "nsMathMLmmultiscriptsFrame.h" #include <algorithm> // // <munderover> -- attach an underscript-overscript pair to a base - implementation // <mover> -- attach an overscript to a base - implementation // <munder> -- attach an underscript to a base - implementation // @@ -305,37 +303,37 @@ nsMathMLmunderoverFrame::Place(nsRenderi nsHTMLReflowMetrics& aDesiredSize) { nsIAtom* tag = mContent->Tag(); if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) && !NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags)) { //place like sub sup or subsup nscoord scriptSpace = nsPresContext::CSSPointsToAppUnits(0.5f); if (tag == nsGkAtoms::munderover_) { - return nsMathMLmsubsupFrame::PlaceSubSupScript(PresContext(), - aRenderingContext, - aPlaceOrigin, - aDesiredSize, - this, 0, 0, - scriptSpace); + return nsMathMLmmultiscriptsFrame::PlaceMultiScript(PresContext(), + aRenderingContext, + aPlaceOrigin, + aDesiredSize, + this, 0, 0, + scriptSpace); } else if (tag == nsGkAtoms::munder_) { - return nsMathMLmsubFrame::PlaceSubScript(PresContext(), - aRenderingContext, - aPlaceOrigin, - aDesiredSize, - this, 0, - scriptSpace); + return nsMathMLmmultiscriptsFrame::PlaceMultiScript(PresContext(), + aRenderingContext, + aPlaceOrigin, + aDesiredSize, + this, 0, 0, + scriptSpace); } else { NS_ASSERTION(tag == nsGkAtoms::mover_, "mContent->Tag() not recognized"); - return nsMathMLmsupFrame::PlaceSuperScript(PresContext(), - aRenderingContext, - aPlaceOrigin, - aDesiredSize, - this, 0, - scriptSpace); + return nsMathMLmmultiscriptsFrame::PlaceMultiScript(PresContext(), + aRenderingContext, + aPlaceOrigin, + aDesiredSize, + this, 0, 0, + scriptSpace); } } //////////////////////////////////// // Get the children's desired sizes nsBoundingMetrics bmBase, bmUnder, bmOver;