bug 445101 - rendering does not change if systemLanguage attribute changes r=jwatt,sr=bzbarsky

This commit is contained in:
Robert Longson 2008-08-05 13:01:47 +01:00
parent ff36003492
commit 9a86e54736
7 changed files with 87 additions and 4 deletions

View File

@ -641,6 +641,24 @@ nsSVGElement::ResetOldStyleBaseType(nsISVGValue *svg_value)
}
}
nsChangeHint
nsSVGElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
PRInt32 aModType) const
{
nsChangeHint retval =
nsSVGElementBase::GetAttributeChangeHint(aAttribute, aModType);
if (aAttribute == nsGkAtoms::requiredFeatures ||
aAttribute == nsGkAtoms::requiredExtensions ||
aAttribute == nsGkAtoms::systemLanguage) {
// It would be nice to only reconstruct the frame if the value returned by
// NS_SVG_PassesConditionalProcessingTests has changed, but we don't know
// that
NS_UpdateHint(retval, nsChangeHint_ReconstructFrame);
}
return retval;
}
PRBool
nsSVGElement::IsNodeOfType(PRUint32 aFlags) const
{

View File

@ -87,6 +87,9 @@ public:
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
PRBool aNotify);
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
PRInt32 aModType) const;
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
virtual already_AddRefed<nsIURI> GetBaseURI() const;

View File

@ -189,6 +189,10 @@ ElementSupportsAttributes(const nsIAtom *aTagName, PRUint16 aAttr)
PRBool
NS_SVG_PassesConditionalProcessingTests(nsIContent *aContent)
{
if (!aContent->IsNodeOfType(nsINode::eELEMENT)) {
return PR_FALSE;
}
if (!ElementSupportsAttributes(aContent->Tag(), ATTRS_CONDITIONAL)) {
return PR_TRUE;
}

View File

@ -81,8 +81,7 @@ nsSVGSwitchElement::MaybeInvalidate()
PRUint32 count = GetChildCount();
for (PRUint32 i = 0; i < count; i++) {
nsIContent * child = GetChildAt(i);
if (child->IsNodeOfType(nsINode::eELEMENT) &&
NS_SVG_PassesConditionalProcessingTests(child)) {
if (NS_SVG_PassesConditionalProcessingTests(child)) {
if (mActiveChild == child) {
return;
@ -108,8 +107,7 @@ nsSVGSwitchElement::UpdateActiveChild()
PRUint32 count = GetChildCount();
for (PRUint32 i = 0; i < count; i++) {
nsIContent * child = GetChildAt(i);
if (child->IsNodeOfType(nsINode::eELEMENT) &&
NS_SVG_PassesConditionalProcessingTests(child)) {
if (NS_SVG_PassesConditionalProcessingTests(child)) {
mActiveChild = child;
return;
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg">
<title>Testcase for conditions</title>
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=409383 -->
<rect width="100%" height="100%" fill="lime"/>
<rect systemLanguage="foo" x="50" y="100" width="50" height="50" fill="red"/>
<rect x="200" y="100" width="50" height="50" fill="red"/>
<rect requiredFeatures="http://www.w3.org/TR/SVG11/feature#Gradient" x="200" y="100" width="50" height="50" fill="lime"/>
<rect requiredFeatures="foo" x="50" y="200" width="50" height="50" fill="red"/>
<rect requiredExtensions="foo" x="200" y="200" width="50" height="50" fill="red"/>
</svg>

After

Width:  |  Height:  |  Size: 789 B

View File

@ -0,0 +1,38 @@
<?xml version="1.0"?>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" onload="m();">
<title>Testcase for dynamic conditions</title>
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=409383 -->
<script>
function m() {
var svgns = "http://www.w3.org/2000/svg";
var rect1 = document.getElementById("rect1");
rect1.setAttribute("systemLanguage", "foo");
var rect2 = document.getElementById("rect2");
rect2.setAttribute("requiredFeatures", "http://www.w3.org/TR/SVG11/feature#Gradient");
var rect3 = document.getElementById("rect3");
rect3.setAttribute("requiredFeatures", "foo");
var rect4 = document.getElementById("rect4");
rect4.setAttribute("requiredExtensions", "foo");
}
</script>
<rect width="100%" height="100%" fill="lime"/>
<rect id="rect1" x="50" y="100" width="50" height="50" fill="red"/>
<rect x="200" y="100" width="50" height="50" fill="red"/>
<rect id="rect2" x="200" y="100" width="50" height="50" fill="lime"/>
<rect id="rect3" x="50" y="200" width="50" height="50" fill="red"/>
<rect id="rect4" x="200" y="200" width="50" height="50" fill="red"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -12,9 +12,11 @@ include moz-only/reftest.list
== clipPath-basic-01.svg pass.svg
== clip-surface-clone-01.svg clip-surface-clone-01-ref.svg
== conditions-01.svg pass.svg
== currentColor-01.svg pass.svg
== currentColor-02.svg pass.svg
== currentColor-03.svg pass.svg
== dynamic-conditions-01.svg pass.svg
== dynamic-link-style-01.svg pass.svg
== dynamic-rect-01.svg dynamic-rect-01-ref.svg
== dynamic-rect-02.svg dynamic-rect-02-ref.svg