OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 namespace WebCore { | 43 namespace WebCore { |
44 | 44 |
45 v8::Handle<v8::Value> V8MessageEvent::portsAccessorGetter(v8::Local<v8::String>
name, const v8::AccessorInfo& info) | 45 v8::Handle<v8::Value> V8MessageEvent::portsAccessorGetter(v8::Local<v8::String>
name, const v8::AccessorInfo& info) |
46 { | 46 { |
47 INC_STATS("DOM.MessageEvent.ports"); | 47 INC_STATS("DOM.MessageEvent.ports"); |
48 MessageEvent* event = V8MessageEvent::toNative(info.Holder()); | 48 MessageEvent* event = V8MessageEvent::toNative(info.Holder()); |
49 | 49 |
50 MessagePortArray* ports = event->ports(); | 50 MessagePortArray* ports = event->ports(); |
51 if (!ports || ports->isEmpty()) | 51 if (!ports || ports->isEmpty()) |
52 return v8::Null(); | 52 return v8::Null(); |
| 53 |
| 54 MessagePortArray portsCopy(*ports); |
53 | 55 |
54 v8::Local<v8::Array> portArray = v8::Array::New(ports->size()); | 56 v8::Local<v8::Array> portArray = v8::Array::New(portsCopy.size()); |
55 for (size_t i = 0; i < ports->size(); ++i) | 57 for (size_t i = 0; i < portsCopy.size(); ++i) |
56 portArray->Set(v8::Integer::New(i), toV8((*ports)[i].get())); | 58 portArray->Set(v8::Integer::New(i), toV8(portsCopy[i].get())); |
57 | 59 |
58 return portArray; | 60 return portArray; |
59 } | 61 } |
60 | 62 |
61 v8::Handle<v8::Value> V8MessageEvent::initMessageEventCallback(const v8::Argumen
ts& args) | 63 v8::Handle<v8::Value> V8MessageEvent::initMessageEventCallback(const v8::Argumen
ts& args) |
62 { | 64 { |
63 INC_STATS("DOM.MessageEvent.initMessageEvent"); | 65 INC_STATS("DOM.MessageEvent.initMessageEvent"); |
64 MessageEvent* event = V8MessageEvent::toNative(args.Holder()); | 66 MessageEvent* event = V8MessageEvent::toNative(args.Holder()); |
65 String typeArg = v8ValueToWebCoreString(args[0]); | 67 String typeArg = v8ValueToWebCoreString(args[0]); |
66 bool canBubbleArg = args[1]->BooleanValue(); | 68 bool canBubbleArg = args[1]->BooleanValue(); |
(...skipping 16 matching lines...) Expand all Loading... |
83 if (!getMessagePortArray(args[7], *portArray)) | 85 if (!getMessagePortArray(args[7], *portArray)) |
84 return v8::Undefined(); | 86 return v8::Undefined(); |
85 } | 87 } |
86 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg.releas
e(), originArg, lastEventIdArg, sourceArg, portArray.release()); | 88 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg.releas
e(), originArg, lastEventIdArg, sourceArg, portArray.release()); |
87 v8::PropertyAttribute dataAttr = static_cast<v8::PropertyAttribute>(v8::Dont
Delete | v8::ReadOnly); | 89 v8::PropertyAttribute dataAttr = static_cast<v8::PropertyAttribute>(v8::Dont
Delete | v8::ReadOnly); |
88 SerializedScriptValue::deserializeAndSetProperty(args.Holder(), "data", data
Attr, event->data()); | 90 SerializedScriptValue::deserializeAndSetProperty(args.Holder(), "data", data
Attr, event->data()); |
89 return v8::Undefined(); | 91 return v8::Undefined(); |
90 } | 92 } |
91 | 93 |
92 } // namespace WebCore | 94 } // namespace WebCore |
OLD | NEW |