Bug 476547. Make lquote and rquote actually work, especially when there are dynamic changes, by finding the correct text frames to modify and notifying the text frame that the DOM text has changed. r=karlt

This commit is contained in:
Robert O'Callahan 2009-10-07 17:28:41 +13:00
Родитель f7d304494f
Коммит c3acb8ce31
7 изменённых файлов: 63 добавлений и 37 удалений

Просмотреть файл

@ -0,0 +1,5 @@
<html xmlns="http://www.w3.org/1999/xhtml" style="quotes: '&lt;1&gt;' '';">
<body onload="document.getElementById('ms').setAttribute('lquote', '');" style="direction: rtl;">
<span><ms id="ms" xmlns="http://www.w3.org/1998/Math/MathML"><mstyle/></ms></span>
</body>
</html>

Просмотреть файл

@ -47,3 +47,4 @@ load 420420-1.xhtml
load 443089-1.xhtml
load 463763-1.xhtml
load 463763-2.xhtml
load 476547-1.xhtml

Просмотреть файл

@ -142,7 +142,7 @@ nsMathMLTokenFrame::SetInitialChildList(nsIAtom* aListName,
if (NS_FAILED(rv))
return rv;
SetQuotes();
SetQuotes(PR_FALSE);
ProcessTextData();
return rv;
}
@ -259,7 +259,7 @@ nsMathMLTokenFrame::AttributeChanged(PRInt32 aNameSpaceID,
{
if (nsGkAtoms::lquote_ == aAttribute ||
nsGkAtoms::rquote_ == aAttribute) {
SetQuotes();
SetQuotes(PR_TRUE);
}
return nsMathMLContainerFrame::
@ -378,57 +378,44 @@ nsMathMLTokenFrame::SetTextStyle()
// So the main idea in this code is to see if there are lquote and
// rquote attributes. If these are there, we ovewrite the default
// quotes in the text frames.
// XXX this is somewhat bogus, we probably should map lquote and rquote
// to 'content' style rules
//
// But what if the mathml.css file wasn't loaded?
// We also check that we are not relying on null pointers...
static void
SetQuote(nsIFrame* aFrame,
nsString& aValue)
SetQuote(nsIFrame* aFrame, nsString& aValue, PRBool aNotify)
{
nsIFrame* textFrame;
do {
// walk down the hierarchy of first children because they could be wrapped
textFrame = aFrame->GetFirstChild(nsnull);
if (textFrame) {
if (textFrame->GetType() == nsGkAtoms::textFrame)
break;
}
aFrame = textFrame;
} while (textFrame);
if (textFrame) {
nsIContent* quoteContent = textFrame->GetContent();
if (quoteContent && quoteContent->IsNodeOfType(nsINode::eTEXT)) {
quoteContent->SetText(aValue, PR_FALSE); // no notify since we don't want a reflow yet
}
}
if (!aFrame)
return;
nsIFrame* textFrame = aFrame->GetFirstChild(nsnull);
if (!textFrame)
return;
nsIContent* quoteContent = textFrame->GetContent();
if (!quoteContent->IsNodeOfType(nsINode::eTEXT))
return;
quoteContent->SetText(aValue, aNotify);
}
void
nsMathMLTokenFrame::SetQuotes()
nsMathMLTokenFrame::SetQuotes(PRBool aNotify)
{
if (mContent->Tag() != nsGkAtoms::ms_)
return;
nsIFrame* rightFrame = nsnull;
nsIFrame* baseFrame = nsnull;
nsIFrame* leftFrame = mFrames.FirstChild();
if (leftFrame)
baseFrame = leftFrame->GetNextSibling();
if (baseFrame)
rightFrame = baseFrame->GetNextSibling();
if (!leftFrame || !baseFrame || !rightFrame)
return;
nsAutoString value;
// lquote
if (GetAttribute(mContent, mPresentationData.mstyle,
nsGkAtoms::lquote_, value)) {
SetQuote(leftFrame, value);
SetQuote(nsLayoutUtils::GetBeforeFrame(this), value, aNotify);
}
// rquote
if (GetAttribute(mContent, mPresentationData.mstyle,
nsGkAtoms::rquote_, value)) {
SetQuote(rightFrame, value);
SetQuote(nsLayoutUtils::GetAfterFrame(this), value, aNotify);
}
}

Просмотреть файл

@ -102,7 +102,7 @@ protected:
PRBool SetTextStyle();
// helper to set the quotes of <ms>
void SetQuotes();
void SetQuotes(PRBool aNotify);
};
#endif /* nsMathMLTokentFrame_h___ */

Просмотреть файл

@ -0,0 +1,9 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<p>:L_R</p>
<p>:L_&#x201D;</p>
<p>:&#x201C;_R</p>
<p>:L_&#x201D;</p>
<p>:&#x201C;_R</p>
</body>
</html>

Просмотреть файл

@ -0,0 +1,23 @@
<html xmlns="http://www.w3.org/1999/xhtml" class="reftest-wait">
<body>
<p>:<ms xmlns="http://www.w3.org/1998/Math/MathML" lquote="L" rquote="R">_</ms></p>
<p>:<ms id="m1" xmlns="http://www.w3.org/1998/Math/MathML">_</ms></p>
<p>:<ms id="m2" xmlns="http://www.w3.org/1998/Math/MathML">_</ms></p>
<p>:<ms id="m3" xmlns="http://www.w3.org/1998/Math/MathML" lquote="_">_</ms></p>
<p>:<ms id="m4" xmlns="http://www.w3.org/1998/Math/MathML" rquote="_">_</ms></p>
<script>
function doTest() {
var m1 = document.getElementById("m1");
m1.setAttribute("lquote", "L");
var m2 = document.getElementById("m2");
m2.setAttribute("rquote", "R");
var m3 = document.getElementById("m3");
m3.setAttribute("lquote", "L");
var m4 = document.getElementById("m4");
m4.setAttribute("rquote", "R");
document.documentElement.removeAttribute('class');
}
window.addEventListener("MozReftestInvalidate", doTest, false);
</script>
</body>
</html>

Просмотреть файл

@ -1,8 +1,9 @@
== dynamic-mi.xhtml dynamic-mi-ref.xhtml
== mi-mathvariant-1.xhtml mi-mathvariant-1-ref.xhtml
== mi-mathvariant-2.xhtml mi-mathvariant-2-ref.xhtml
== table-width-1.xhtml table-width-1-ref.xhtml
== overbar-width-1.xhtml overbar-width-1-ref.xhtml
== underbar-width-1.xhtml underbar-width-1-ref.xhtml
!= non-spacing-accent-1.xhtml non-spacing-accent-1-ref.xhtml
== overbar-width-1.xhtml overbar-width-1-ref.xhtml
== quotes-1.xhtml quotes-1-ref.xhtml
!= stretchy-underbar-1.xhtml stretchy-underbar-1-ref.xhtml
== table-width-1.xhtml table-width-1-ref.xhtml
== underbar-width-1.xhtml underbar-width-1-ref.xhtml