Bug 639945 - tooltips are not displayed on inline svg elements. r=dao,bzbarsky

This commit is contained in:
Robert Longson 2011-06-30 21:58:21 +01:00
parent bf018509ad
commit 782a97703a
4 changed files with 20 additions and 12 deletions

View File

@ -2981,9 +2981,8 @@ function FillInHTMLTooltip(tipElement)
XLinkTitleText = tipElement.getAttributeNS(XLinkNS, "title");
}
if (lookingForSVGTitle &&
!(tipElement instanceof SVGElement &&
tipElement.parentNode instanceof SVGElement &&
!(tipElement.parentNode instanceof SVGForeignObjectElement))) {
(!(tipElement instanceof SVGElement) ||
tipElement.parentNode.nodeType == Node.DOCUMENT_NODE)) {
lookingForSVGTitle = false;
}
if (lookingForSVGTitle) {

View File

@ -6,6 +6,10 @@ function test () {
let doc = gBrowser.contentDocument;
let tooltip = document.getElementById("aHTMLTooltip");
ok(FillInHTMLTooltip(doc.getElementById("svg1"), "should get title"));
is(tooltip.getAttribute("label"), "This is a non-root SVG element title");
ok(FillInHTMLTooltip(doc.getElementById("text1"), "should get title"));
is(tooltip.getAttribute("label"), " This is a title ");

View File

@ -1,5 +1,14 @@
<svg width="640px" height="480px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0">
<title>This is a root SVG element's title</title>
<foreignObject>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<svg xmlns="http://www.w3.org/2000/svg" id="svg1">
<title>This is a non-root SVG element title</title>
</svg>
</body>
</html>
</foreignObject>
<text id="text1" x="10px" y="32px" font-size="24px">
This contains only &lt;title&gt;
<title>

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -70,7 +70,6 @@
#include "Link.h"
#include "nsIDOMSVGElement.h"
#include "nsIDOMSVGTitleElement.h"
#include "nsIDOMSVGForeignObjectElem.h"
#include "nsIDOMEvent.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMNSUIEvent.h"
@ -1059,9 +1058,8 @@ DefaultTooltipTextProvider::DefaultTooltipTextProvider()
// UseSVGTitle
//
// A helper routine that determines whether we're still interested
// in SVG titles. We need to stop at the SVG root element; that
// either has no parent, has a non-SVG parent or has an SVG ForeignObject
// parent.
// in SVG titles. We need to stop at the SVG root element that
// has a document node parent
//
static PRBool
UseSVGTitle(nsIDOMElement *currElement)
@ -1075,12 +1073,10 @@ UseSVGTitle(nsIDOMElement *currElement)
if (!parent)
return PR_FALSE;
nsCOMPtr<nsIDOMSVGForeignObjectElement> parentFOContent(do_QueryInterface(parent));
if (parentFOContent)
return PR_FALSE;
PRUint16 nodeType;
nsresult rv = parent->GetNodeType(&nodeType);
nsCOMPtr<nsIDOMSVGElement> parentSVGContent(do_QueryInterface(parent));
return (parentSVGContent != nsnull);
return NS_SUCCEEDED(rv) && nodeType != nsIDOMNode::DOCUMENT_NODE;
}
/* void getNodeText (in nsIDOMNode aNode, out wstring aText); */