Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(974)

Side by Side Diff: Source/bindings/v8/custom/V8MessageEventCustom.cpp

Issue 15862004: Remove custom code for MessageEvent.ports getter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase patch Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/V8Binding.h ('k') | Source/core/dom/MessageEvent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 case MessageEvent::DataTypeScriptValue: { 51 case MessageEvent::DataTypeScriptValue: {
52 ScriptValue scriptValue = event->dataAsScriptValue(); 52 ScriptValue scriptValue = event->dataAsScriptValue();
53 if (scriptValue.hasNoValue()) 53 if (scriptValue.hasNoValue())
54 result = v8Null(info.GetIsolate()); 54 result = v8Null(info.GetIsolate());
55 else 55 else
56 result = scriptValue.v8Value(); 56 result = scriptValue.v8Value();
57 break; 57 break;
58 } 58 }
59 59
60 case MessageEvent::DataTypeSerializedScriptValue: 60 case MessageEvent::DataTypeSerializedScriptValue:
61 if (RefPtr<SerializedScriptValue> serializedValue = event->dataAsSeriali zedScriptValue()) 61 if (RefPtr<SerializedScriptValue> serializedValue = event->dataAsSeriali zedScriptValue()) {
62 result = serializedValue->deserialize(info.GetIsolate(), event->port s()); 62 MessagePortArray ports = event->ports();
63 else 63 result = serializedValue->deserialize(info.GetIsolate(), &ports);
64 } else
64 result = v8Null(info.GetIsolate()); 65 result = v8Null(info.GetIsolate());
65 break; 66 break;
66 67
67 case MessageEvent::DataTypeString: { 68 case MessageEvent::DataTypeString: {
68 String stringValue = event->dataAsString(); 69 String stringValue = event->dataAsString();
69 result = v8String(stringValue, info.GetIsolate()); 70 result = v8String(stringValue, info.GetIsolate());
70 break; 71 break;
71 } 72 }
72 73
73 case MessageEvent::DataTypeBlob: 74 case MessageEvent::DataTypeBlob:
74 result = toV8Fast(event->dataAsBlob(), info, event); 75 result = toV8Fast(event->dataAsBlob(), info, event);
75 break; 76 break;
76 77
77 case MessageEvent::DataTypeArrayBuffer: 78 case MessageEvent::DataTypeArrayBuffer:
78 result = toV8Fast(event->dataAsArrayBuffer(), info, event); 79 result = toV8Fast(event->dataAsArrayBuffer(), info, event);
79 break; 80 break;
80 } 81 }
81 82
82 // Overwrite the data attribute so it returns the cached result in future in vocations. 83 // Overwrite the data attribute so it returns the cached result in future in vocations.
83 // This custom handler (dataAccessGetter) will not be called again. 84 // This custom handler (dataAccessGetter) will not be called again.
84 v8::PropertyAttribute dataAttr = static_cast<v8::PropertyAttribute>(v8::Dont Delete | v8::ReadOnly); 85 v8::PropertyAttribute dataAttr = static_cast<v8::PropertyAttribute>(v8::Dont Delete | v8::ReadOnly);
85 info.Holder()->ForceSet(name, result, dataAttr); 86 info.Holder()->ForceSet(name, result, dataAttr);
86 return result; 87 return result;
87 } 88 }
88 89
89 v8::Handle<v8::Value> V8MessageEvent::portsAttrGetterCustom(v8::Local<v8::String > name, const v8::AccessorInfo& info)
90 {
91 MessageEvent* event = V8MessageEvent::toNative(info.Holder());
92
93 MessagePortArray* ports = event->ports();
94 if (!ports)
95 return v8::Array::New(0);
96
97 MessagePortArray portsCopy(*ports);
98
99 v8::Local<v8::Array> portArray = v8::Array::New(portsCopy.size());
100 for (size_t i = 0; i < portsCopy.size(); ++i)
101 portArray->Set(v8Integer(i, info.GetIsolate()), toV8Fast(portsCopy[i].ge t(), info, event));
102
103 return portArray;
104 }
105
106 v8::Handle<v8::Value> V8MessageEvent::initMessageEventMethodCustom(const v8::Arg uments& args) 90 v8::Handle<v8::Value> V8MessageEvent::initMessageEventMethodCustom(const v8::Arg uments& args)
107 { 91 {
108 MessageEvent* event = V8MessageEvent::toNative(args.Holder()); 92 MessageEvent* event = V8MessageEvent::toNative(args.Holder());
109 String typeArg = toWebCoreString(args[0]); 93 String typeArg = toWebCoreString(args[0]);
110 bool canBubbleArg = args[1]->BooleanValue(); 94 bool canBubbleArg = args[1]->BooleanValue();
111 bool cancelableArg = args[2]->BooleanValue(); 95 bool cancelableArg = args[2]->BooleanValue();
112 ScriptValue dataArg = ScriptValue(args[3]); 96 ScriptValue dataArg = ScriptValue(args[3]);
113 String originArg = toWebCoreString(args[4]); 97 String originArg = toWebCoreString(args[4]);
114 String lastEventIdArg = toWebCoreString(args[5]); 98 String lastEventIdArg = toWebCoreString(args[5]);
115 99
(...skipping 15 matching lines...) Expand all
131 return v8::Undefined(); 115 return v8::Undefined();
132 } 116 }
133 117
134 v8::Handle<v8::Value> V8MessageEvent::webkitInitMessageEventMethodCustom(const v 8::Arguments& args) 118 v8::Handle<v8::Value> V8MessageEvent::webkitInitMessageEventMethodCustom(const v 8::Arguments& args)
135 { 119 {
136 return initMessageEventMethodCustom(args); 120 return initMessageEventMethodCustom(args);
137 } 121 }
138 122
139 123
140 } // namespace WebCore 124 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8Binding.h ('k') | Source/core/dom/MessageEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698