Comment #16 on issue 16107 by [email protected]: WebKit: Vector  
Drawing, altering stroke properties crash
http://code.google.com/p/chromium/issues/detail?id=16107

Just as a followup to the Maps API issue, it turns out the submitted code  
is using an
incorrect datatype.  Here are the comments from the Maps team:

---

It looks like the error is actually a typo in the sample code:
"""
polygon.setStrokeStyle({weight:'5'})
"""

This should actually be:
"""
polygon.setStrokeStyle({weight:5})
"""
(weight is a number, not a string).

The way that the canvas size is extended to cope with stroke weights is  
very simple
(add a strokeWeight tolerance) on each side of the bounds. However, because  
of the
inconsistent way JS handles type coercion between strings and numbers  
interesting
stuff happens if the weight is a string.

Suppose the canvas is supposed to be placed from pixel 50 to pixel 100 on  
the X axis
and the stroke weight is 5, we expect:
var left = 50 - 5 == 45;
var right = 100 + 5 == 105;
var width = right - left = 60;

But if the stroke weight is '5':
var left = 50 - '5' == 45;
var right = 100 + '5' == '1005';  // Addition defaults to string  
concatentation
var width = right - left == 960;  // Big difference!

Hope that helps!


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
Automated mail from issue updates at http://crbug.com/
Subscription options: http://groups.google.com/group/chromium-bugs
-~----------~----~----~----~------~----~------~--~---

Reply via email to