From dce500c0f1b896fd8b52ab036d27bb1e632a9420 Mon Sep 17 00:00:00 2001 From: "rbs%maths.uq.edu.au" Date: Tue, 19 Sep 2006 04:43:14 +0000 Subject: [PATCH] Dynamic changes to MathML table attributes don't work, b=347496, r+sr=roc git-svn-id: svn://10.0.0.236/trunk@211970 18797224-902f-48f8-a5cc-f745e15eee43 --- .../layout/mathml/base/src/nsIMathMLFrame.h | 38 ++-- .../layout/mathml/base/src/nsMathMLFrame.cpp | 31 ++- .../layout/mathml/base/src/nsMathMLFrame.h | 5 + .../mathml/base/src/nsMathMLmrowFrame.cpp | 21 +++ .../mathml/base/src/nsMathMLmrowFrame.h | 5 + .../mathml/base/src/nsMathMLmstyleFrame.cpp | 86 +++------ .../mathml/base/src/nsMathMLmtableFrame.cpp | 177 +++++++++++++++--- .../mathml/base/src/nsMathMLmtableFrame.h | 17 +- 8 files changed, 263 insertions(+), 117 deletions(-) diff --git a/mozilla/layout/mathml/base/src/nsIMathMLFrame.h b/mozilla/layout/mathml/base/src/nsIMathMLFrame.h index 71eb6adf84b..3b9b542e99a 100644 --- a/mozilla/layout/mathml/base/src/nsIMathMLFrame.h +++ b/mozilla/layout/mathml/base/src/nsIMathMLFrame.h @@ -242,21 +242,21 @@ public: * The new values (e.g., display, compress) that are going to be * updated. * - * @param aFlagsToUpdate [in] + * @param aWhichFlags [in] * The flags that are relevant to this call. Since not all calls - * are meant to update all flags at once, aFlagsToUpdate is used + * are meant to update all flags at once, aWhichFlags is used * to distinguish flags that need to retain their existing values * from flags that need to be turned on (or turned off). If a bit - * is set in aFlagsToUpdate, then the corresponding value (which + * is set in aWhichFlags, then the corresponding value (which * can be 0 or 1) is taken from aFlagsValues and applied to the - * frame. Therefore, by setting their bits in aFlagsToUpdate, and + * frame. Therefore, by setting their bits in aWhichFlags, and * setting their desired values in aFlagsValues, it is possible to * update some flags in the frame, leaving the other flags unchanged. */ NS_IMETHOD UpdatePresentationData(PRInt32 aScriptLevelIncrement, PRUint32 aFlagsValues, - PRUint32 aFlagsToUpdate) = 0; + PRUint32 aWhichFlags) = 0; /* UpdatePresentationDataFromChildAt : * Increments the scriplevel and sets the displaystyle and compression flags @@ -284,7 +284,7 @@ public: * The new values (e.g., display, compress) that are going to be * assigned in the whole sub-trees. * - * @param aFlagsToUpdate [in] + * @param aWhichFlags [in] * The flags that are relevant to this call. See UpdatePresentationData() * for more details about this parameter. */ @@ -293,7 +293,7 @@ public: PRInt32 aLastIndex, PRInt32 aScriptLevelIncrement, PRUint32 aFlagsValues, - PRUint32 aFlagsToUpdate) = 0; + PRUint32 aWhichFlags) = 0; /* ReResolveScriptStyle : * During frame construction, the Style System gives us style contexts in @@ -399,7 +399,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIMathMLFrame, NS_IMATHMLFRAME_IID) // This bit is set if the frame is in the *context* of displaystyle=true. // Note: This doesn't mean that the frame has displaystyle=true as attribute, -// is the only tag which allows . +// the displaystyle attribute is only allowed on and . // The bit merely tells the context of the frame. In the context of // displaystyle="false", it is intended to slightly alter how the // rendering is done in inline mode. @@ -421,14 +421,16 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIMathMLFrame, NS_IMATHMLFRAME_IID) // horizontal stretch command on all their non-empty children #define NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY 0x00000008 -// This bit is set if the frame is actually an frame *and* that -// frame has an explicit attribute scriptlevel="value". +// This bit is set if the frame has the explicit attribute +// scriptlevel="value". It is only relevant to because that's +// the only tag where the attribute is allowed by the spec. // Note: the flag is not set if the instead has an incremental +/-value. -#define NS_MATHML_MSTYLE_WITH_EXPLICIT_SCRIPTLEVEL 0x00000010 +#define NS_MATHML_EXPLICIT_SCRIPTLEVEL 0x00000010 -// This bit is set if the frame is actually an *and* that -// has an explicit attribute displaystyle="true" or "false" -#define NS_MATHML_MSTYLE_WITH_DISPLAYSTYLE 0x00000020 +// This bit is set if the frame has the explicit attribute +// displaystyle="true" or "false". It is only relevant to and +// because they are the only tags where the attribute is allowed by the spec. +#define NS_MATHML_EXPLICIT_DISPLAYSTYLE 0x00000020 // This bit is set when the frame cannot be formatted due to an // error (e.g., invalid markup such as a without an overscript). @@ -458,11 +460,11 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIMathMLFrame, NS_IMATHMLFRAME_IID) #define NS_MATHML_WILL_STRETCH_ALL_CHILDREN_HORIZONTALLY(_flags) \ (NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY == ((_flags) & NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY)) -#define NS_MATHML_IS_MSTYLE_WITH_DISPLAYSTYLE(_flags) \ - (NS_MATHML_MSTYLE_WITH_DISPLAYSTYLE == ((_flags) & NS_MATHML_MSTYLE_WITH_DISPLAYSTYLE)) +#define NS_MATHML_HAS_EXPLICIT_DISPLAYSTYLE(_flags) \ + (NS_MATHML_EXPLICIT_DISPLAYSTYLE == ((_flags) & NS_MATHML_EXPLICIT_DISPLAYSTYLE)) -#define NS_MATHML_IS_MSTYLE_WITH_EXPLICIT_SCRIPTLEVEL(_flags) \ - (NS_MATHML_MSTYLE_WITH_EXPLICIT_SCRIPTLEVEL == ((_flags) & NS_MATHML_MSTYLE_WITH_EXPLICIT_SCRIPTLEVEL)) +#define NS_MATHML_HAS_EXPLICIT_SCRIPTLEVEL(_flags) \ + (NS_MATHML_EXPLICIT_SCRIPTLEVEL == ((_flags) & NS_MATHML_EXPLICIT_SCRIPTLEVEL)) #define NS_MATHML_HAS_ERROR(_flags) \ (NS_MATHML_ERROR == ((_flags) & NS_MATHML_ERROR)) diff --git a/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp index a77e51fd3c5..5dd658bfe3b 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp @@ -80,6 +80,31 @@ nsMathMLFrame::GetMathMLFrameType() return eMathMLFrameType_Ordinary; } +// snippet of code used by and , which are the only +// two tags where the displaystyle attribute is allowed by the spec. +/* static */ void +nsMathMLFrame::FindAttrDisplaystyle(nsIContent* aContent, + nsPresentationData& aPresentationData) +{ + NS_ASSERTION(aContent->Tag() == nsMathMLAtoms::mstyle_ || + aContent->Tag() == nsMathMLAtoms::mtable_, "bad caller"); + static nsIContent::AttrValuesArray strings[] = + {&nsMathMLAtoms::_false, &nsMathMLAtoms::_true, nsnull}; + // see if the explicit displaystyle attribute is there + switch (aContent->FindAttrValueIn(kNameSpaceID_None, + nsMathMLAtoms::displaystyle_, strings, eCaseMatters)) { + case 0: + aPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE; + aPresentationData.flags |= NS_MATHML_EXPLICIT_DISPLAYSTYLE; + break; + case 1: + aPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; + aPresentationData.flags |= NS_MATHML_EXPLICIT_DISPLAYSTYLE; + break; + } + // no reset if the attr isn't found. so be sure to call it on inherited flags +} + NS_IMETHODIMP nsMathMLFrame::InheritAutomaticData(nsIFrame* aParent) { @@ -113,11 +138,11 @@ nsMathMLFrame::InheritAutomaticData(nsIFrame* aParent) NS_IMETHODIMP nsMathMLFrame::UpdatePresentationData(PRInt32 aScriptLevelIncrement, PRUint32 aFlagsValues, - PRUint32 aFlagsToUpdate) + PRUint32 aWhichFlags) { mPresentationData.scriptLevel += aScriptLevelIncrement; // update flags that are relevant to this call - if (NS_MATHML_IS_DISPLAYSTYLE(aFlagsToUpdate)) { + if (NS_MATHML_IS_DISPLAYSTYLE(aWhichFlags)) { // updating the displaystyle flag is allowed if (NS_MATHML_IS_DISPLAYSTYLE(aFlagsValues)) { mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; @@ -126,7 +151,7 @@ nsMathMLFrame::UpdatePresentationData(PRInt32 aScriptLevelIncrement, mPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE; } } - if (NS_MATHML_IS_COMPRESSED(aFlagsToUpdate)) { + 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 diff --git a/mozilla/layout/mathml/base/src/nsMathMLFrame.h b/mozilla/layout/mathml/base/src/nsMathMLFrame.h index f598a263383..0ada8661244 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLFrame.h @@ -204,6 +204,11 @@ public: nsPresentationData& aPresentationData, PRBool aClimbTree = PR_TRUE); + // helper used by and to see if they have a displaystyle attribute + static void + FindAttrDisplaystyle(nsIContent* aContent, + nsPresentationData& aPresentationData); + // helper to check if a content has an attribute. If content is nsnull or if // the attribute is not there, check if the attribute is on the mstyle hierarchy // @return PR_TRUE --if attribute exists diff --git a/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.cpp index 95607d9e19d..0491ad9b0d9 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.cpp @@ -73,6 +73,27 @@ nsMathMLmrowFrame::InheritAutomaticData(nsIFrame* aParent) return NS_OK; } +NS_IMETHODIMP +nsMathMLmrowFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) +{ + // Special for : In the frame construction code, we also use + // this frame class as a wrapper for mtable. Hence, we should pass the + // notification to the real mtable + if (mContent->Tag() == nsMathMLAtoms::mtable_) { + nsIFrame* frame = mFrames.FirstChild(); + for ( ; frame; frame = frame->GetFirstChild(nsnull)) { + // drill down to the real mtable + if (frame->GetType() == nsLayoutAtoms::tableOuterFrame) + return frame->AttributeChanged(aNameSpaceID, aAttribute, aModType); + } + NS_NOTREACHED("mtable wrapper without the real table frame"); + } + + return nsMathMLContainerFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType); +} + nsIFrame* nsMathMLmrowFrame::GetContentInsertionFrame() { diff --git a/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.h index 775eeb471cc..0b69e67d731 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.h @@ -50,6 +50,11 @@ class nsMathMLmrowFrame : public nsMathMLContainerFrame { public: friend nsIFrame* NS_NewMathMLmrowFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); + NS_IMETHOD + AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); + virtual nsIFrame* GetContentInsertionFrame(); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp index 68369a97e2a..5fdfdcd7b43 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp @@ -75,20 +75,7 @@ nsMathMLmstyleFrame::InheritAutomaticData(nsIFrame* aParent) mPresentationData.mstyle = this; // see if the displaystyle attribute is there - static nsIContent::AttrValuesArray strings[] = - {&nsMathMLAtoms::_true, &nsMathMLAtoms::_false, nsnull}; - switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsMathMLAtoms::displaystyle_, - strings, eCaseMatters)) { - case 0: - mPresentationData.flags |= NS_MATHML_MSTYLE_WITH_DISPLAYSTYLE; - mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; - break; - - case 1: - mPresentationData.flags |= NS_MATHML_MSTYLE_WITH_DISPLAYSTYLE; - mPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE; - break; - } + nsMathMLFrame::FindAttrDisplaystyle(mContent, mPresentationData); // see if the scriptlevel attribute is there nsAutoString value; @@ -98,7 +85,7 @@ nsMathMLmstyleFrame::InheritAutomaticData(nsIFrame* aParent) userValue = value.ToInteger(&errorCode); if (!errorCode) { if (value[0] != '+' && value[0] != '-') { // record that it is an explicit value - mPresentationData.flags |= NS_MATHML_MSTYLE_WITH_EXPLICIT_SCRIPTLEVEL; + mPresentationData.flags |= NS_MATHML_EXPLICIT_SCRIPTLEVEL; mPresentationData.scriptLevel = userValue; } else { @@ -121,44 +108,26 @@ nsMathMLmstyleFrame::TransmitAutomaticData() return NS_OK; } +// displaystyle and scriptlevel are special in ... +// Since UpdatePresentation() and UpdatePresentationDataFromChildAt() can be called +// by a parent, ensure that the explicit attributes of take precedence NS_IMETHODIMP nsMathMLmstyleFrame::UpdatePresentationData(PRInt32 aScriptLevelIncrement, PRUint32 aFlagsValues, - PRUint32 aFlagsToUpdate) + PRUint32 aWhichFlags) { - // mstyle is special... - // Since UpdatePresentationData() can be called by a parent frame, the - // scriptlevel and displaystyle attributes of mstyle must take precedence. - // Update only if attributes are not there - - // see if updating the displaystyle flag is allowed - if (!NS_MATHML_IS_MSTYLE_WITH_DISPLAYSTYLE(mPresentationData.flags)) { - // see if the displaystyle flag is relevant to this call - if (NS_MATHML_IS_DISPLAYSTYLE(aFlagsToUpdate)) { - if (NS_MATHML_IS_DISPLAYSTYLE(aFlagsValues)) { - mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; - } - else { - mPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE; - } - } + if (NS_MATHML_HAS_EXPLICIT_DISPLAYSTYLE(mPresentationData.flags)) { + // our current state takes precedence, disallow updating the displastyle + aWhichFlags &= ~NS_MATHML_DISPLAYSTYLE; + aFlagsValues &= ~NS_MATHML_DISPLAYSTYLE; + } + if (NS_MATHML_HAS_EXPLICIT_SCRIPTLEVEL(mPresentationData.flags)) { + // our current state takes precedence, disallow updating the scriptlevel + aScriptLevelIncrement = 0; } - // see if updating the scriptlevel is allowed - if (!NS_MATHML_IS_MSTYLE_WITH_EXPLICIT_SCRIPTLEVEL(mPresentationData.flags)) { - mPresentationData.scriptLevel += aScriptLevelIncrement; - } - - // see if the compression flag is relevant to this call - if (NS_MATHML_IS_COMPRESSED(aFlagsToUpdate)) { - 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; + return nsMathMLContainerFrame::UpdatePresentationData( + aScriptLevelIncrement, aFlagsValues, aWhichFlags); } NS_IMETHODIMP @@ -166,22 +135,15 @@ nsMathMLmstyleFrame::UpdatePresentationDataFromChildAt(PRInt32 aFirstInd PRInt32 aLastIndex, PRInt32 aScriptLevelIncrement, PRUint32 aFlagsValues, - PRUint32 aFlagsToUpdate) + PRUint32 aWhichFlags) { - // mstyle is special... - // Since UpdatePresentationDataFromChildAt() can be called by a parent frame, - // wee need to ensure that the attributes of mstyle take precedence - - if (NS_MATHML_IS_DISPLAYSTYLE(aFlagsToUpdate)) { - if (NS_MATHML_IS_MSTYLE_WITH_DISPLAYSTYLE(mPresentationData.flags)) { - // our current state takes precedence, updating is not allowed - aFlagsToUpdate &= ~NS_MATHML_DISPLAYSTYLE; - aFlagsValues &= ~NS_MATHML_DISPLAYSTYLE; - } + if (NS_MATHML_HAS_EXPLICIT_DISPLAYSTYLE(mPresentationData.flags)) { + // our current state takes precedence, disallow updating the displastyle + aWhichFlags &= ~NS_MATHML_DISPLAYSTYLE; + aFlagsValues &= ~NS_MATHML_DISPLAYSTYLE; } - - if (NS_MATHML_IS_MSTYLE_WITH_EXPLICIT_SCRIPTLEVEL(mPresentationData.flags)) { - // our current state takes precedence, updating is not allowed + if (NS_MATHML_HAS_EXPLICIT_SCRIPTLEVEL(mPresentationData.flags)) { + // our current state takes precedence, disallow updating the scriptlevel aScriptLevelIncrement = 0; } @@ -189,7 +151,7 @@ nsMathMLmstyleFrame::UpdatePresentationDataFromChildAt(PRInt32 aFirstInd return nsMathMLContainerFrame::UpdatePresentationDataFromChildAt( aFirstIndex, aLastIndex, aScriptLevelIncrement, - aFlagsValues, aFlagsToUpdate); + aFlagsValues, aWhichFlags); } NS_IMETHODIMP diff --git a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp index 45d99233b70..cea840eb0bf 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp @@ -244,21 +244,20 @@ MapColAttributesIntoCSS(nsIFrame* aTableFrame, static void MapAllAttributesIntoCSS(nsIFrame* aTableFrame) { - //XXX only loop for the sake of it, - //mtable is simple and only has one (pseudo) row-group + // mtable is simple and only has one (pseudo) row-group nsIFrame* rowgroupFrame = aTableFrame->GetFirstChild(nsnull); - for ( ; rowgroupFrame; rowgroupFrame = rowgroupFrame->GetNextSibling()) { - nsIFrame* rowFrame = rowgroupFrame->GetFirstChild(nsnull); - for ( ; rowFrame; rowFrame = rowFrame->GetNextSibling()) { - DEBUG_VERIFY_THAT_FRAME_IS(rowFrame, TABLE_ROW); - if (rowFrame->GetType() == nsGkAtoms::tableRowFrame) { - MapRowAttributesIntoCSS(aTableFrame, rowFrame); - nsIFrame* cellFrame = rowFrame->GetFirstChild(nsnull); - for ( ; cellFrame; cellFrame = cellFrame->GetNextSibling()) { - DEBUG_VERIFY_THAT_FRAME_IS(cellFrame, TABLE_CELL); - if (IS_TABLE_CELL(cellFrame->GetType())) { - MapColAttributesIntoCSS(aTableFrame, rowFrame, cellFrame); - } + if (!rowgroupFrame) return; + + nsIFrame* rowFrame = rowgroupFrame->GetFirstChild(nsnull); + for ( ; rowFrame; rowFrame = rowFrame->GetNextSibling()) { + DEBUG_VERIFY_THAT_FRAME_IS(rowFrame, TABLE_ROW); + if (rowFrame->GetType() == nsGkAtoms::tableRowFrame) { + MapRowAttributesIntoCSS(aTableFrame, rowFrame); + nsIFrame* cellFrame = rowFrame->GetFirstChild(nsnull); + for ( ; cellFrame; cellFrame = cellFrame->GetNextSibling()) { + DEBUG_VERIFY_THAT_FRAME_IS(cellFrame, TABLE_CELL); + if (IS_TABLE_CELL(cellFrame->GetType())) { + MapColAttributesIntoCSS(aTableFrame, rowFrame, cellFrame); } } } @@ -332,6 +331,16 @@ nsMathMLmtableOuterFrame::~nsMathMLmtableOuterFrame() { } +NS_IMETHODIMP +nsMathMLmtableOuterFrame::Init(nsIContent* aContent, + nsIFrame* aParent, + nsIFrame* aPrevInFlow) +{ + nsresult rv = nsTableOuterFrame::Init(aContent, aParent, aPrevInFlow); + nsMathMLFrame::MapCommonAttributesIntoCSS(GetPresContext(), aContent); + return rv; +} + NS_IMETHODIMP nsMathMLmtableOuterFrame::InheritAutomaticData(nsIFrame* aParent) { @@ -341,26 +350,138 @@ nsMathMLmtableOuterFrame::InheritAutomaticData(nsIFrame* aParent) nsMathMLFrame::InheritAutomaticData(aParent); // see if the displaystyle attribute is there and let it override what we inherited - nsAutoString value; - GetAttribute(mContent, nsnull, nsMathMLAtoms::displaystyle_, value); - if (value.EqualsLiteral("true")) { - mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; - } - else if (value.EqualsLiteral("false")) { - mPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE; - } + nsMathMLFrame::FindAttrDisplaystyle(mContent, mPresentationData); return NS_OK; } +// displaystyle is special in mtable... +// Since UpdatePresentation() and UpdatePresentationDataFromChildAt() can be called +// by a parent, ensure that the displaystyle attribute of mtable takes precedence NS_IMETHODIMP -nsMathMLmtableOuterFrame::Init(nsIContent* aContent, - nsIFrame* aParent, - nsIFrame* aPrevInFlow) +nsMathMLmtableOuterFrame::UpdatePresentationData(PRInt32 aScriptLevelIncrement, + PRUint32 aFlagsValues, + PRUint32 aWhichFlags) { - nsresult rv = nsTableOuterFrame::Init(aContent, aParent, aPrevInFlow); - nsMathMLFrame::MapCommonAttributesIntoCSS(GetPresContext(), aContent); - return rv; + if (NS_MATHML_HAS_EXPLICIT_DISPLAYSTYLE(mPresentationData.flags)) { + // our current state takes precedence, disallow updating the displastyle + aWhichFlags &= ~NS_MATHML_DISPLAYSTYLE; + aFlagsValues &= ~NS_MATHML_DISPLAYSTYLE; + } + + return nsMathMLFrame::UpdatePresentationData( + aScriptLevelIncrement, aFlagsValues, aWhichFlags); +} + +NS_IMETHODIMP +nsMathMLmtableOuterFrame::UpdatePresentationDataFromChildAt(PRInt32 aFirstIndex, + PRInt32 aLastIndex, + PRInt32 aScriptLevelIncrement, + PRUint32 aFlagsValues, + PRUint32 aWhichFlags) +{ + if (NS_MATHML_HAS_EXPLICIT_DISPLAYSTYLE(mPresentationData.flags)) { + // our current state takes precedence, disallow updating the displastyle + aWhichFlags &= ~NS_MATHML_DISPLAYSTYLE; + aFlagsValues &= ~NS_MATHML_DISPLAYSTYLE; + } + + nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(this, + aFirstIndex, aLastIndex, aScriptLevelIncrement, aFlagsValues, aWhichFlags); + + return NS_OK; +} + +NS_IMETHODIMP +nsMathMLmtableOuterFrame::AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) +{ + // Attributes common to MathML tags + if (nsMathMLFrame::CommonAttributeChangedFor(GetPresContext(), mContent, aAttribute)) + return NS_OK; + + // Attributes specific to : + // frame : in mathml.css + // framespacing : not yet supported + // groupalign : not yet supported + // equalrows : not yet supported + // equalcolumns : not yet supported + // displaystyle : here + // align : in reflow + // rowalign : here + // rowlines : here + // rowspacing : not yet supported + // columnalign : here + // columnlines : here + // columnspacing : not yet supported + + // mtable is simple and only has one (pseudo) row-group inside our inner-table + nsIFrame* tableFrame = mFrames.FirstChild(); + if (!tableFrame) return NS_OK; + nsIFrame* rowgroupFrame = tableFrame->GetFirstChild(nsnull); + if (!rowgroupFrame) return NS_OK; + + // align - just need to issue a dirty (resize) reflow command + if (aAttribute == nsMathMLAtoms::align) { + GetPresContext()->PresShell()-> + AppendReflowCommand(this, eReflowType_ReflowDirty, nsnull); + return NS_OK; + } + + // displaystyle - may seem innocuous, but it is actually very harsh -- + // like changing an unit. Blow away and recompute all our automatic + // presentational data, and issue a style-changed reflow request + if (aAttribute == nsMathMLAtoms::displaystyle_) { + nsMathMLContainerFrame::RebuildAutomaticDataForChildren(mParent); + nsMathMLContainerFrame::PropagateScriptStyleFor(tableFrame, mPresentationData.scriptLevel); + GetPresContext()->PresShell()-> + AppendReflowCommand(mParent, eReflowType_StyleChanged, nsnull); + return NS_OK; + } + + // ...and the other attributes affect rows or columns in one way or another + nsIAtom* MOZrowAtom = nsnull; + nsIAtom* MOZcolAtom = nsnull; + if (aAttribute == nsMathMLAtoms::rowalign_) + MOZrowAtom = nsMathMLAtoms::MOZrowalign; + else if (aAttribute == nsMathMLAtoms::rowlines_) + MOZrowAtom = nsMathMLAtoms::MOZrowline; + else if (aAttribute == nsMathMLAtoms::columnalign_) + MOZcolAtom = nsMathMLAtoms::MOZcolumnalign; + else if (aAttribute == nsMathMLAtoms::columnlines_) + MOZcolAtom = nsMathMLAtoms::MOZcolumnline; + + if (!MOZrowAtom && !MOZcolAtom) + return NS_OK; + + // clear any cached nsValueList for this table + tableFrame->DeleteProperty(aAttribute); + + // unset any -moz attribute that we may have set earlier, and re-sync + nsIFrame* rowFrame = rowgroupFrame->GetFirstChild(nsnull); + for ( ; rowFrame; rowFrame = rowFrame->GetNextSibling()) { + if (rowFrame->GetType() == nsGkAtoms::tableRowFrame) { + if (MOZrowAtom) { // let rows do the work + rowFrame->GetContent()->UnsetAttr(kNameSpaceID_None, MOZrowAtom, PR_FALSE); + MapRowAttributesIntoCSS(tableFrame, rowFrame); + } else { // let cells do the work + nsIFrame* cellFrame = rowFrame->GetFirstChild(nsnull); + for ( ; cellFrame; cellFrame = cellFrame->GetNextSibling()) { + if (IS_TABLE_CELL(cellFrame->GetType())) { + cellFrame->GetContent()->UnsetAttr(kNameSpaceID_None, MOZcolAtom, PR_FALSE); + MapColAttributesIntoCSS(tableFrame, rowFrame, cellFrame); + } + } + } + } + } + + // Explicitly request a re-resolve and reflow in our subtree to pick up any changes + GetPresContext()->PresShell()->FrameConstructor()-> + PostRestyleEvent(mContent, eReStyle_Self, nsChangeHint_ReflowFrame); + + return NS_OK; } nsIFrame* diff --git a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.h index fc7c9a9b8d1..ab0b377d14e 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.h @@ -58,17 +58,17 @@ public: NS_IMETHOD InheritAutomaticData(nsIFrame* aParent); + NS_IMETHOD + UpdatePresentationData(PRInt32 aScriptLevelIncrement, + PRUint32 aFlagsValues, + PRUint32 aWhichFlags); + NS_IMETHOD UpdatePresentationDataFromChildAt(PRInt32 aFirstIndex, PRInt32 aLastIndex, PRInt32 aScriptLevelIncrement, PRUint32 aFlagsValues, - PRUint32 aFlagsToUpdate) - { - nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(this, - aFirstIndex, aLastIndex, aScriptLevelIncrement, aFlagsValues, aFlagsToUpdate); - return NS_OK; - } + PRUint32 aWhichFlags); NS_IMETHOD ReResolveScriptStyle(PRInt32 aParentScriptLevel) @@ -90,6 +90,11 @@ public: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); + NS_IMETHOD + AttributeChanged(PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); + virtual PRBool IsFrameOfType(PRUint32 aFlags) const; protected: