- From: <bugzilla@jessica.w3.org>
- Date: Wed, 13 Jan 2016 22:58:26 +0000
- To: public-html-bugzilla@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=28148 --- Comment #9 from Simon Pieters <simonp@opera.com> --- Blink's coords parsing is at https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/platform/Length.cpp&sq=package:chromium&type=cs&l=71&rcl=1452688339 it seems to replace all characters other than [0-9\.-] with space and then split on spaces, e.g. coords="0x0x,x,10 10" is parsed the same as coords="0,0,10,10". Gecko's coords parsing is described in https://lists.w3.org/Archives/Public/public-html/2009Jan/0086.html . Jonas notes that they have some bugs filed e.g. for not ignoring a leading comma. In webdevdata I find some interesting cases but in particular this from babyneo.de: <map name='header1'> <area shape="rect" alt="Zur Startseite" coords="='69,8,153,86' " href="http://www.babyneo.de/" title="Zur Startseite" > <area shape="rect" alt="Zur Startseite" coords="='5,85,223,140' " href="http://www.babyneo.de/" title="Zur Startseite" > <area shape="rect" alt="Warenkorb anzeigen" coords="='824,49,950,74' " href="http://www.babyneo.de/shopping_cart.php" title="Warenkorb anzeigen" > </map> In Gecko the first value of each get parsed into 0, but IE/Blink/WebKit/Presto parse into the given number ignoring the leading garbage, which appears to more closely match what was intended. I didn't see any using ; in coords. But some with consecutive commas or leading/trailing garbage. I implemented the spec's algorithm in JS and wrote a new different implementation [1], and compared the output of real-world coords values [2], and checked the result against the some of the actual pages to see what would be an improvement in terms of web compat. I believe it's somewhat of a mix of what all browsers do give the best results, and I ended up with the following: function newCoords(input) { var numbers = []; // split var tokens = input.split(/[\s,]+/); // for each token in tokens for (var i = 0; i < tokens.length; ++i) { var token = tokens[i]; // replace garbage with spaces token = token.replace(/[^\d\.-]/g, ' '); // parse as float; add to numbers numbers.push(parseFloat(token, 10) || 0); } // return numbers return numbers; } [1] https://gist.github.com/zcorpan/baa697e081a3e1aa5da0 [2] https://gist.github.com/zcorpan/37050c2b556c5d0b5b88 -- You are receiving this mail because: You are the QA Contact for the bug.
Received on Wednesday, 13 January 2016 22:58:32 UTC