- From: Brian Birtles <bbirtles@mozilla.com>
- Date: Mon, 28 Nov 2011 10:59:39 +0900
- To: 'www-svg' <www-svg@w3.org>
Dear all, I'd like to clarify the expected behaviour for the SVGTextContentElement interface[1] in conjunction with display:none. Given the following markup: <text>a<tspan display="none">b</tspan>c</text> What is the expected result of the following methods called on the <text> element? getNumberOfChars getComputedTextLength getSubStringLength getStartPositionOfChar/getEndPositionOfChar/getExtentOfChar Looking at the spec, I would expected getNumberOfChars to return 3 (since "Effectively, this is equivalent to the length of the Node::textContent attribute from DOM Level 3 Core"). However, the results I get from a variety of browsers are as follows:[2] getNumberOfChars: 2 (Firefox 8, Chrome 15, IE9); 3 (Opera 11.60 beta) Other metrics: Firefox 8 behaves as if there are just two characters. Chrome 15 behaves as if there are just two characters (but surprisingly gives the same result for getSubStringLength(0, 1), getSubStringLength(0, 2) and getSubStringLength(0, 3) which is half of getComputedTextLength. It also does not throw INDEX_SIZE_ERR exceptions but just returns 0 values of out of range character indices.) Opera 11.60 beta behaves as if there are three characters in most cases (getSubStringLength(1,1) returns 0 but getExtentOfChar(1) returns a non-zero glyph rect; substrings beginning at 0 equal getComputedTextLength regardless of the length of the substring) IE 9 behaves as if there are just two characters (but fails to throw an exception for getSubStringLength(0, 3)). It seems that most of the major browsers are treating the display:none characters as if they don't exist for the purpose of these metrics. Most likely such characters are not present in the rendering tree and calculating font metrics is tied to the rendering tree. My questions: 1) Have I understood the spec correctly--that getNumberOfChars should return 3? 2) If so, should we change the spec or the browsers? Thanks! Brian [1] http://www.w3.org/TR/SVG11/text.html#InterfaceSVGTextContentElement [2] Test case here: http://brian.sol1.net/svg/interop/text-test.svg
Received on Monday, 28 November 2011 02:00:12 UTC