HTML canvas strokes with dash and dashOffset for V8.
Created attachment 109794 [details] Patch
This is a follow-up patch for the bug 63933.
Comment on attachment 109794 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=109794&action=review > Source/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp:116 > + v8::Local<v8::Array> result = v8::Array::New(dash->size()); > + DashArray::const_iterator end = dash->end(); > + int index = 0; > + for (DashArray::const_iterator it = dash->begin(); it != end; ++it, ++index) > + result->Set(v8::Integer::New(index), v8::Number::New(*it)); > + > + return result; > +} I think we already have a function that does this. If we don't have one, you should add it. It's a very general operation. Also, per the recent webkit-dev thread, we should be using indicies rather than iterators to walk arrays. That will also help you avoid the nuttiness of incrementing the iterator and the index at the same time.
> > I think we already have a function that does this. If we don't have one, you should add it. It's a very general operation. To clarify what 'a function that does this' means... 1. Do you mean a function converting Vector<float> to v8:Array? (e.g. v8::Handle<v8::Value> toV8(const Vector<float>& vector)) This is not a general operation. The patch I uploaded is the only place using the operation, so I don't think we should add the function. 2. Do you mean a function converting any Vector to v8::Array? (e.g. template <class T> v8::Handle<v8::Value> toV8(const T& vector)) I'm not sure it is possible to generalize this kind of operation. There are only two places doing this operation under WebCore/bindings/v8, and following is one of them. typedef Vector<RefPtr<ScriptProfile> > ProfilesArray; v8::Handle<v8::Value> V8Console::profilesAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { ...... const ProfilesArray& profiles = imp->profiles(); ...... for (ProfilesArray::const_iterator iter = profiles.begin(); iter != end; ++iter) result->Set(v8::Integer::New(index++), toV8(iter->get())); return result; } This function converts the element of the Vector like this 'toV8(iter->get())', because the element is RefPtr. But my patch converts like this 'v8::Number::New(*iter))', because the element is just float. I don't know a clear way to generalize these two function. Any Idea? > > Also, per the recent webkit-dev thread, we should be using indicies rather than iterators to walk arrays. That will also help you avoid the nuttiness of incrementing the iterator and the index at the same time. agree.
V8 is gone from WebKit.