Always post a restyle request if SetTextStyle() indicates it's needed. b=414123 r+sr+a=roc

This commit is contained in:
mats.palmgren@bredband.net 2008-01-26 18:49:47 -08:00
parent cf078aa449
commit d431de32cf
7 changed files with 85 additions and 14 deletions

View File

@ -111,7 +111,7 @@ nsMathMLTokenFrame::SetInitialChildList(nsIAtom* aListName,
return rv; return rv;
SetQuotes(); SetQuotes();
ProcessTextData(PR_FALSE); ProcessTextData();
return rv; return rv;
} }
@ -212,7 +212,7 @@ nsMathMLTokenFrame::MarkIntrinsicWidthsDirty()
{ {
// this could be called due to changes in the nsTextFrame beneath us // this could be called due to changes in the nsTextFrame beneath us
// when something changed in the text content. So re-process our text // when something changed in the text content. So re-process our text
ProcessTextData(PR_TRUE); ProcessTextData();
nsMathMLContainerFrame::MarkIntrinsicWidthsDirty(); nsMathMLContainerFrame::MarkIntrinsicWidthsDirty();
} }
@ -232,16 +232,12 @@ nsMathMLTokenFrame::AttributeChanged(PRInt32 aNameSpaceID,
} }
void void
nsMathMLTokenFrame::ProcessTextData(PRBool aComputeStyleChange) nsMathMLTokenFrame::ProcessTextData()
{ {
// see if the style changes from normal to italic or vice-versa // see if the style changes from normal to italic or vice-versa
if (!SetTextStyle()) if (!SetTextStyle())
return; return;
// has changed but it doesn't have to be reflected straightaway
if (!aComputeStyleChange)
return;
// explicitly request a re-resolve to pick up the change of style // explicitly request a re-resolve to pick up the change of style
PresContext()->PresShell()->FrameConstructor()-> PresContext()->PresShell()->FrameConstructor()->
PostRestyleEvent(mContent, eReStyle_Self, NS_STYLE_HINT_NONE); PostRestyleEvent(mContent, eReStyle_Self, NS_STYLE_HINT_NONE);

View File

@ -82,7 +82,7 @@ public:
virtual nsresult virtual nsresult
ChildListChanged(PRInt32 aModType) ChildListChanged(PRInt32 aModType)
{ {
ProcessTextData(PR_TRUE); ProcessTextData();
return nsMathMLContainerFrame::ChildListChanged(aModType); return nsMathMLContainerFrame::ChildListChanged(aModType);
} }
@ -93,8 +93,7 @@ protected:
virtual PRIntn GetSkipSides() const { return 0; } virtual PRIntn GetSkipSides() const { return 0; }
// hook to perform MathML-specific actions depending on the tag // hook to perform MathML-specific actions depending on the tag
virtual void virtual void ProcessTextData();
ProcessTextData(PRBool aComputeStyleChange);
// helper to set the style of <mi> which has to be italic or normal // helper to set the style of <mi> which has to be italic or normal
// depending on its textual content // depending on its textual content

View File

@ -153,7 +153,7 @@ nsMathMLmoFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
// get the text that we enclose and setup our nsMathMLChar // get the text that we enclose and setup our nsMathMLChar
void void
nsMathMLmoFrame::ProcessTextData(PRBool aComputeStyleChange) nsMathMLmoFrame::ProcessTextData()
{ {
mFlags = 0; mFlags = 0;
@ -958,7 +958,7 @@ nsMathMLmoFrame::MarkIntrinsicWidthsDirty()
// from the parent of our outermost embellished container (we ensure // from the parent of our outermost embellished container (we ensure
// that we are the core, not just a sibling of the core) // that we are the core, not just a sibling of the core)
ProcessTextData(PR_FALSE); ProcessTextData();
nsIFrame* target = this; nsIFrame* target = this;
nsEmbellishData embellishData; nsEmbellishData embellishData;

View File

@ -103,8 +103,7 @@ protected:
float mMaxSize; float mMaxSize;
// overload the base method so that we can setup our nsMathMLChar // overload the base method so that we can setup our nsMathMLChar
virtual void virtual void ProcessTextData();
ProcessTextData(PRBool aComputeStyleChange);
// helper to get our 'form' and lookup in the Operator Dictionary to fetch // helper to get our 'form' and lookup in the Operator Dictionary to fetch
// our default data that may come from there, and to complete the setup // our default data that may come from there, and to complete the setup

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:html="http://www.w3.org/1999/xhtml">
<style type="text/css">mn:first-child {font-style:italic;}</style>
<head>
<title>Testcase for bug 414123</title>
</head>
<body>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<msup>
<mn>M</mn>
<mn>2</mn>
</msup>
</math>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<msup>
<mn>M</mn>
<mn>2</mn>
</msup>
</math>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<msup>
<mn>M</mn>
<mn>2</mn>
</msup>
</math>
</body>
</html>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Testcase for bug 414123</title>
<script>
function boom() {
var t = document.createTextNode('M')
document.getElementById('mi1').appendChild(t);
var mi = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mi");
var mn = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mn");
var msup = document.createElementNS("http://www.w3.org/1998/Math/MathML", "msup");
mi.appendChild(document.createTextNode('M'));
mn.appendChild(document.createTextNode('2'));
msup.appendChild(mi);
msup.appendChild(mn);
document.getElementById('m').appendChild(msup);
}
</script>
</head>
<body onload="boom()">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<msup>
<mi id="mi1"></mi>
<mn>2</mn>
</msup>
</math>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<msup>
<mi>M</mi>
<mn>2</mn>
</msup>
</math>
<math id="m" xmlns="http://www.w3.org/1998/Math/MathML"></math>
</body>
</html>

View File

@ -665,3 +665,4 @@ random == 403134-1.html 403134-1-ref.html # bug 405377
== 411334-1.xml 411334-1-ref.xml == 411334-1.xml 411334-1-ref.xml
== 413292-1.html 413292-1-ref.html == 413292-1.html 413292-1-ref.html
== 413361-1.html 413361-1-ref.html == 413361-1.html 413361-1-ref.html
== 414123.xhtml 414123-ref.xhtml