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

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

Issue 1153613007: bindings: Use CreateDataProperty() instead of ForceSet() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 if (result.IsEmpty()) 82 if (result.IsEmpty())
83 result = toV8(event->dataAsArrayBuffer(), info.Holder(), info.GetIso late()); 83 result = toV8(event->dataAsArrayBuffer(), info.Holder(), info.GetIso late());
84 break; 84 break;
85 } 85 }
86 86
87 // Overwrite the data attribute so it returns the cached result in future in vocations. 87 // Overwrite the data attribute so it returns the cached result in future in vocations.
88 // This custom getter handler will not be called again. 88 // This custom getter handler will not be called again.
89 // TODO(bashi): We use ForceSet() here, and we use hidden values in other 89 // TODO(bashi): We use ForceSet() here, and we use hidden values in other
90 // places (e.g. V8CustomEventCustom.cpp). We should use the same way to 90 // places (e.g. V8CustomEventCustom.cpp). We should use the same way to
91 // handle "any" attributes. 91 // handle "any" attributes.
92 // TODO(bashi): Use DefineOwnProperty() instead of ForceSet().
93 // http://crbug.com/475206
92 v8::PropertyAttribute dataAttr = static_cast<v8::PropertyAttribute>(v8::Dont Delete | v8::ReadOnly); 94 v8::PropertyAttribute dataAttr = static_cast<v8::PropertyAttribute>(v8::Dont Delete | v8::ReadOnly);
93 if (!v8CallBoolean(info.Holder()->ForceSet(info.GetIsolate()->GetCurrentCont ext(), v8AtomicString(info.GetIsolate(), "data"), result, dataAttr))) { 95 if (!v8CallBoolean(info.Holder()->ForceSet(info.GetIsolate()->GetCurrentCont ext(), v8AtomicString(info.GetIsolate(), "data"), result, dataAttr))) {
bashi 2015/06/03 00:16:37 We can't use DefineOwnProperty() here because it r
94 v8SetReturnValue(info, v8::Null(info.GetIsolate())); 96 v8SetReturnValue(info, v8::Null(info.GetIsolate()));
95 return; 97 return;
96 } 98 }
97 v8SetReturnValue(info, result); 99 v8SetReturnValue(info, result);
98 } 100 }
99 101
100 void V8MessageEvent::initMessageEventMethodCustom(const v8::FunctionCallbackInfo <v8::Value>& info) 102 void V8MessageEvent::initMessageEventMethodCustom(const v8::FunctionCallbackInfo <v8::Value>& info)
101 { 103 {
102 ExceptionState exceptionState(ExceptionState::ExecutionContext, "initMessage Event", "MessageEvent", info.Holder(), info.GetIsolate()); 104 ExceptionState exceptionState(ExceptionState::ExecutionContext, "initMessage Event", "MessageEvent", info.Holder(), info.GetIsolate());
103 MessageEvent* event = V8MessageEvent::toImpl(info.Holder()); 105 MessageEvent* event = V8MessageEvent::toImpl(info.Holder());
(...skipping 12 matching lines...) Expand all
116 if (!isUndefinedOrNull(info[portArrayIndex])) { 118 if (!isUndefinedOrNull(info[portArrayIndex])) {
117 portArray = adoptPtrWillBeNoop(new MessagePortArray); 119 portArray = adoptPtrWillBeNoop(new MessagePortArray);
118 *portArray = toRefPtrWillBeMemberNativeArray<MessagePort, V8MessagePort> (info[portArrayIndex], portArrayIndex + 1, info.GetIsolate(), exceptionState); 120 *portArray = toRefPtrWillBeMemberNativeArray<MessagePort, V8MessagePort> (info[portArrayIndex], portArrayIndex + 1, info.GetIsolate(), exceptionState);
119 if (exceptionState.throwIfNeeded()) 121 if (exceptionState.throwIfNeeded())
120 return; 122 return;
121 } 123 }
122 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, ScriptValue(Sc riptState::current(info.GetIsolate()), dataArg), originArg, lastEventIdArg, sour ceArg, portArray.release()); 124 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, ScriptValue(Sc riptState::current(info.GetIsolate()), dataArg), originArg, lastEventIdArg, sour ceArg, portArray.release());
123 } 125 }
124 126
125 } // namespace blink 127 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698