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

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

Issue 19457002: Make 'any'-typed attributes of events available in isolated worlds (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Patch for landing Created 7 years, 5 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/custom/V8MessageEventCustom.cpp ('k') | Source/core/dom/CustomEvent.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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 v8::Handle<v8::Value> result = info.Holder()->GetHiddenValue(V8HiddenPropert yName::state()); 51 v8::Handle<v8::Value> result = info.Holder()->GetHiddenValue(V8HiddenPropert yName::state());
52 52
53 if (!result.IsEmpty()) { 53 if (!result.IsEmpty()) {
54 v8SetReturnValue(info, result); 54 v8SetReturnValue(info, result);
55 return; 55 return;
56 } 56 }
57 57
58 PopStateEvent* event = V8PopStateEvent::toNative(info.Holder()); 58 PopStateEvent* event = V8PopStateEvent::toNative(info.Holder());
59 History* history = event->history(); 59 History* history = event->history();
60 if (!history || !event->serializedState()) { 60 if (!history || !event->serializedState()) {
61 v8SetReturnValue(info, cacheState(info.Holder(), v8::Null(info.GetIsolat e()))); 61 if (!event->serializedState()) {
62 // If we're in an isolated world and the event was created in the ma in world,
63 // we need to find the 'state' property on the main world wrapper an d clone it.
64 v8::Local<v8::Value> mainWorldState = getHiddenValueFromMainWorldWra pper(info.GetIsolate(), event, V8HiddenPropertyName::state());
65 if (!mainWorldState.IsEmpty())
66 event->setSerializedState(SerializedScriptValue::createAndSwallo wExceptions(mainWorldState, info.GetIsolate()));
67 }
68 if (event->serializedState())
69 result = event->serializedState()->deserialize();
70 else
71 result = v8::Null(info.GetIsolate());
72 v8SetReturnValue(info, cacheState(info.Holder(), result));
62 return; 73 return;
haraken 2014/05/01 14:22:27 This code implements lazy serialization in order t
adamk 2014/05/02 18:33:35 I don't think this analysis is correct. Note that
haraken 2014/05/03 12:35:10 Makes sense, thanks for the clarification! I was o
63 } 74 }
64 75
65 // There's no cached value from a previous invocation, nor a state value was provided by the 76 // There's no cached value from a previous invocation, nor a state value was provided by the
66 // event, but there is a history object, so first we need to see if the stat e object has been 77 // event, but there is a history object, so first we need to see if the stat e object has been
67 // deserialized through the history object already. 78 // deserialized through the history object already.
68 // The current history state object might've changed in the meantime, so we need to take care 79 // The current history state object might've changed in the meantime, so we need to take care
69 // of using the correct one, and always share the same deserialization with history.state. 80 // of using the correct one, and always share the same deserialization with history.state.
70 81
71 bool isSameState = history->isSameAsCurrentState(event->serializedState()); 82 bool isSameState = history->isSameAsCurrentState(event->serializedState());
72 83
73 if (isSameState) { 84 if (isSameState) {
74 v8::Handle<v8::Object> v8History = toV8Fast(history, info, event).As<v8: :Object>(); 85 v8::Handle<v8::Object> v8History = toV8Fast(history, info, event).As<v8: :Object>();
75 if (!history->stateChanged()) { 86 if (!history->stateChanged()) {
76 result = v8History->GetHiddenValue(V8HiddenPropertyName::state()); 87 result = v8History->GetHiddenValue(V8HiddenPropertyName::state());
77 if (!result.IsEmpty()) { 88 if (!result.IsEmpty()) {
78 v8SetReturnValue(info, cacheState(info.Holder(), result)); 89 v8SetReturnValue(info, cacheState(info.Holder(), result));
79 return; 90 return;
80 } 91 }
81 } 92 }
82 result = event->serializedState()->deserialize(info.GetIsolate()); 93 result = event->serializedState()->deserialize(info.GetIsolate());
83 v8History->SetHiddenValue(V8HiddenPropertyName::state(), result); 94 v8History->SetHiddenValue(V8HiddenPropertyName::state(), result);
84 } else 95 } else {
85 result = event->serializedState()->deserialize(info.GetIsolate()); 96 result = event->serializedState()->deserialize(info.GetIsolate());
97 }
86 98
87 v8SetReturnValue(info, cacheState(info.Holder(), result)); 99 v8SetReturnValue(info, cacheState(info.Holder(), result));
88 } 100 }
89 101
90 } // namespace WebCore 102 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/custom/V8MessageEventCustom.cpp ('k') | Source/core/dom/CustomEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698