From c676a2d954abbca125a06a45f07e7e4455aec5f0 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Fri, 27 Apr 2012 12:24:54 +1200 Subject: [PATCH] Bug 749055 - Add index parameter to nsDisplayMathMLCharForeground. r=roc --- layout/mathml/nsMathMLChar.cpp | 10 ++++++++-- layout/mathml/nsMathMLChar.h | 1 + layout/mathml/nsMathMLmencloseFrame.cpp | 4 ++-- layout/mathml/nsMathMLmfencedFrame.cpp | 7 ++++--- layout/mathml/nsMathMLmoFrame.cpp | 2 +- layout/mathml/nsMathMLmrootFrame.cpp | 2 +- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/layout/mathml/nsMathMLChar.cpp b/layout/mathml/nsMathMLChar.cpp index b3b58adfb68..7fe1d6de437 100644 --- a/layout/mathml/nsMathMLChar.cpp +++ b/layout/mathml/nsMathMLChar.cpp @@ -1899,8 +1899,9 @@ class nsDisplayMathMLCharForeground : public nsDisplayItem { public: nsDisplayMathMLCharForeground(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsMathMLChar* aChar, - bool aIsSelected) - : nsDisplayItem(aBuilder, aFrame), mChar(aChar), mIsSelected(aIsSelected) { + PRUint32 aIndex, bool aIsSelected) + : nsDisplayItem(aBuilder, aFrame), mChar(aChar), + mIndex(aIndex), mIsSelected(aIsSelected) { MOZ_COUNT_CTOR(nsDisplayMathMLCharForeground); } #ifdef NS_BUILD_REFCNT_LOGGING @@ -1934,9 +1935,12 @@ public: bool snap; return GetBounds(aBuilder, &snap); } + + virtual PRUint32 GetPerFrameKey() { return (mIndex << nsDisplayItem::TYPE_BITS) | nsDisplayItem::GetPerFrameKey(); } private: nsMathMLChar* mChar; + PRUint32 mIndex; bool mIsSelected; }; @@ -1982,6 +1986,7 @@ nsresult nsMathMLChar::Display(nsDisplayListBuilder* aBuilder, nsIFrame* aForFrame, const nsDisplayListSet& aLists, + PRUint32 aIndex, const nsRect* aSelectedRect) { nsresult rv = NS_OK; @@ -2026,6 +2031,7 @@ nsMathMLChar::Display(nsDisplayListBuilder* aBuilder, } return aLists.Content()->AppendNewToTop(new (aBuilder) nsDisplayMathMLCharForeground(aBuilder, aForFrame, this, + aIndex, aSelectedRect && !aSelectedRect->IsEmpty())); } diff --git a/layout/mathml/nsMathMLChar.h b/layout/mathml/nsMathMLChar.h index ab0780060a0..887e98fdcd1 100644 --- a/layout/mathml/nsMathMLChar.h +++ b/layout/mathml/nsMathMLChar.h @@ -131,6 +131,7 @@ public: Display(nsDisplayListBuilder* aBuilder, nsIFrame* aForFrame, const nsDisplayListSet& aLists, + PRUint32 aIndex, const nsRect* aSelectedRect = nsnull); void PaintForeground(nsPresContext* aPresContext, diff --git a/layout/mathml/nsMathMLmencloseFrame.cpp b/layout/mathml/nsMathMLmencloseFrame.cpp index 6788eb48773..bed6b1d6b43 100644 --- a/layout/mathml/nsMathMLmencloseFrame.cpp +++ b/layout/mathml/nsMathMLmencloseFrame.cpp @@ -236,7 +236,7 @@ nsMathMLmencloseFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, mencloseRect.x = mencloseRect.y = 0; if (IsToDraw(NOTATION_RADICAL)) { - rv = mMathMLChar[mRadicalCharIndex].Display(aBuilder, this, aLists); + rv = mMathMLChar[mRadicalCharIndex].Display(aBuilder, this, aLists, 0); NS_ENSURE_SUCCESS(rv, rv); nsRect rect; @@ -249,7 +249,7 @@ nsMathMLmencloseFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, } if (IsToDraw(NOTATION_LONGDIV)) { - rv = mMathMLChar[mLongDivCharIndex].Display(aBuilder, this, aLists); + rv = mMathMLChar[mLongDivCharIndex].Display(aBuilder, this, aLists, 1); NS_ENSURE_SUCCESS(rv, rv); nsRect rect; diff --git a/layout/mathml/nsMathMLmfencedFrame.cpp b/layout/mathml/nsMathMLmfencedFrame.cpp index 7d794db8df1..2131a396058 100644 --- a/layout/mathml/nsMathMLmfencedFrame.cpp +++ b/layout/mathml/nsMathMLmfencedFrame.cpp @@ -220,18 +220,19 @@ nsMathMLmfencedFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, //////////// // display fences and separators + PRUint32 count = 0; if (mOpenChar) { - rv = mOpenChar->Display(aBuilder, this, aLists); + rv = mOpenChar->Display(aBuilder, this, aLists, count++); NS_ENSURE_SUCCESS(rv, rv); } if (mCloseChar) { - rv = mCloseChar->Display(aBuilder, this, aLists); + rv = mCloseChar->Display(aBuilder, this, aLists, count++); NS_ENSURE_SUCCESS(rv, rv); } for (PRInt32 i = 0; i < mSeparatorsCount; i++) { - rv = mSeparatorsChar[i].Display(aBuilder, this, aLists); + rv = mSeparatorsChar[i].Display(aBuilder, this, aLists, count++); NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; diff --git a/layout/mathml/nsMathMLmoFrame.cpp b/layout/mathml/nsMathMLmoFrame.cpp index 4a500d7fa62..7cffdfb9c59 100644 --- a/layout/mathml/nsMathMLmoFrame.cpp +++ b/layout/mathml/nsMathMLmoFrame.cpp @@ -140,7 +140,7 @@ nsMathMLmoFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, selectedRect = firstChild->GetRect(); isSelected = true; } - rv = mMathMLChar.Display(aBuilder, this, aLists, isSelected ? &selectedRect : nsnull); + rv = mMathMLChar.Display(aBuilder, this, aLists, 0, isSelected ? &selectedRect : nsnull); NS_ENSURE_SUCCESS(rv, rv); #if defined(NS_DEBUG) && defined(SHOW_BOUNDING_BOX) diff --git a/layout/mathml/nsMathMLmrootFrame.cpp b/layout/mathml/nsMathMLmrootFrame.cpp index 13870275e68..07b041e3b70 100644 --- a/layout/mathml/nsMathMLmrootFrame.cpp +++ b/layout/mathml/nsMathMLmrootFrame.cpp @@ -134,7 +134,7 @@ nsMathMLmrootFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, ///////////// // paint the sqrt symbol if (!NS_MATHML_HAS_ERROR(mPresentationData.flags)) { - rv = mSqrChar.Display(aBuilder, this, aLists); + rv = mSqrChar.Display(aBuilder, this, aLists, 0); NS_ENSURE_SUCCESS(rv, rv); rv = DisplayBar(aBuilder, this, mBarRect, aLists);