OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 27 matching lines...) Expand all Loading... |
38 #include "bindings/v8/V8Binding.h" | 38 #include "bindings/v8/V8Binding.h" |
39 #include "bindings/v8/V8DOMWrapper.h" | 39 #include "bindings/v8/V8DOMWrapper.h" |
40 #include "bindings/v8/V8HiddenPropertyName.h" | 40 #include "bindings/v8/V8HiddenPropertyName.h" |
41 #include "core/dom/ContextFeatures.h" | 41 #include "core/dom/ContextFeatures.h" |
42 #include "core/dom/ExceptionCode.h" | 42 #include "core/dom/ExceptionCode.h" |
43 #include "core/page/Frame.h" | 43 #include "core/page/Frame.h" |
44 #include "RuntimeEnabledFeatures.h" | 44 #include "RuntimeEnabledFeatures.h" |
45 | 45 |
46 namespace WebCore { | 46 namespace WebCore { |
47 | 47 |
| 48 static v8::Handle<v8::Value> cacheState(v8::Handle<v8::Object> customEvent, v8::
Handle<v8::Value> detail) |
| 49 { |
| 50 customEvent->SetHiddenValue(V8HiddenPropertyName::detail(), detail); |
| 51 return detail; |
| 52 } |
| 53 |
| 54 |
48 void V8CustomEvent::detailAttrGetterCustom(v8::Local<v8::String> name, const v8:
:PropertyCallbackInfo<v8::Value>& info) | 55 void V8CustomEvent::detailAttrGetterCustom(v8::Local<v8::String> name, const v8:
:PropertyCallbackInfo<v8::Value>& info) |
49 { | 56 { |
50 CustomEvent* imp = V8CustomEvent::toNative(info.Holder()); | 57 CustomEvent* event = V8CustomEvent::toNative(info.Holder()); |
51 RefPtr<SerializedScriptValue> serialized = imp->serializedScriptValue(); | 58 ASSERT(!event->serializedScriptValue().get()); |
52 if (serialized) { | 59 |
53 v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(V8HiddenProp
ertyName::detail()); | 60 v8::Handle<v8::Value> result = info.Holder()->GetHiddenValue(V8HiddenPropert
yName::detail()); |
54 if (value.IsEmpty()) { | 61 |
55 value = serialized->deserialize(); | 62 if (!result.IsEmpty()) { |
56 info.Holder()->SetHiddenValue(V8HiddenPropertyName::detail(), value)
; | 63 v8SetReturnValue(info, result); |
57 } | |
58 v8SetReturnValue(info, value); | |
59 return; | 64 return; |
60 } | 65 } |
61 v8SetReturnValue(info, imp->detail().v8Value()); | 66 |
| 67 RefPtr<SerializedScriptValue> serialized = event->serializedScriptValue(); |
| 68 if (serialized) { |
| 69 result = serialized->deserialize(); |
| 70 v8SetReturnValue(info, cacheState(info.Holder(), result)); |
| 71 return; |
| 72 } |
| 73 |
| 74 v8SetReturnValue(info, cacheState(info.Holder(), v8::Null(info.GetIsolate())
)); |
| 75 } |
| 76 |
| 77 void V8CustomEvent::initCustomEventMethodCustom(const v8::FunctionCallbackInfo<v
8::Value>& args) |
| 78 { |
| 79 CustomEvent* event = V8CustomEvent::toNative(args.Holder()); |
| 80 |
| 81 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, typeArg, args[0]); |
| 82 V8TRYCATCH_VOID(bool, canBubbleArg, args[1]->BooleanValue()); |
| 83 V8TRYCATCH_VOID(bool, cancelableArg, args[2]->BooleanValue()); |
| 84 v8::Handle<v8::Value> detailsArg = args[3]; |
| 85 |
| 86 args.Holder()->SetHiddenValue(V8HiddenPropertyName::detail(), detailsArg); |
| 87 event->initEvent(typeArg, canBubbleArg, cancelableArg); |
62 } | 88 } |
63 | 89 |
64 } // namespace WebCore | 90 } // namespace WebCore |
OLD | NEW |