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

Side by Side Diff: sky/engine/bindings/core/v8/custom/V8WindowCustom.cpp

Issue 873983005: Remove the global event property. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « sky/engine/bindings/core/v8/V8HiddenValue.h ('k') | sky/engine/core/events/EventTarget.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, 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2011 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 22 matching lines...) Expand all
33 33
34 #include "bindings/core/v8/V8Node.h" 34 #include "bindings/core/v8/V8Node.h"
35 #include "sky/engine/bindings/core/v8/BindingSecurity.h" 35 #include "sky/engine/bindings/core/v8/BindingSecurity.h"
36 #include "sky/engine/bindings/core/v8/ExceptionMessages.h" 36 #include "sky/engine/bindings/core/v8/ExceptionMessages.h"
37 #include "sky/engine/bindings/core/v8/ExceptionState.h" 37 #include "sky/engine/bindings/core/v8/ExceptionState.h"
38 #include "sky/engine/bindings/core/v8/ScheduledAction.h" 38 #include "sky/engine/bindings/core/v8/ScheduledAction.h"
39 #include "sky/engine/bindings/core/v8/ScriptController.h" 39 #include "sky/engine/bindings/core/v8/ScriptController.h"
40 #include "sky/engine/bindings/core/v8/ScriptSourceCode.h" 40 #include "sky/engine/bindings/core/v8/ScriptSourceCode.h"
41 #include "sky/engine/bindings/core/v8/SerializedScriptValue.h" 41 #include "sky/engine/bindings/core/v8/SerializedScriptValue.h"
42 #include "sky/engine/bindings/core/v8/V8Binding.h" 42 #include "sky/engine/bindings/core/v8/V8Binding.h"
43 #include "sky/engine/bindings/core/v8/V8EventListener.h"
44 #include "sky/engine/bindings/core/v8/V8EventListenerList.h"
45 #include "sky/engine/bindings/core/v8/V8GCForContextDispose.h" 43 #include "sky/engine/bindings/core/v8/V8GCForContextDispose.h"
46 #include "sky/engine/bindings/core/v8/V8HiddenValue.h" 44 #include "sky/engine/bindings/core/v8/V8HiddenValue.h"
47 #include "sky/engine/core/dom/Element.h" 45 #include "sky/engine/core/dom/Element.h"
48 #include "sky/engine/core/dom/ExceptionCode.h" 46 #include "sky/engine/core/dom/ExceptionCode.h"
49 #include "sky/engine/core/dom/Node.h" 47 #include "sky/engine/core/dom/Node.h"
50 #include "sky/engine/core/frame/DOMTimer.h" 48 #include "sky/engine/core/frame/DOMTimer.h"
51 #include "sky/engine/core/frame/DOMWindowTimers.h" 49 #include "sky/engine/core/frame/DOMWindowTimers.h"
52 #include "sky/engine/core/frame/FrameView.h" 50 #include "sky/engine/core/frame/FrameView.h"
53 #include "sky/engine/core/frame/LocalDOMWindow.h" 51 #include "sky/engine/core/frame/LocalDOMWindow.h"
54 #include "sky/engine/core/frame/LocalFrame.h" 52 #include "sky/engine/core/frame/LocalFrame.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // Try to do the idle notification before the timeout expires to get better 128 // Try to do the idle notification before the timeout expires to get better
131 // use of any idle time. Aim for the middle of the interval for simplicity. 129 // use of any idle time. Aim for the middle of the interval for simplicity.
132 if (timeout >= 0) { 130 if (timeout >= 0) {
133 double maximumFireInterval = static_cast<double>(timeout) / 1000 / 2; 131 double maximumFireInterval = static_cast<double>(timeout) / 1000 / 2;
134 V8GCForContextDispose::instanceTemplate().notifyIdleSooner(maximumFireIn terval); 132 V8GCForContextDispose::instanceTemplate().notifyIdleSooner(maximumFireIn terval);
135 } 133 }
136 134
137 v8SetReturnValue(info, timerId); 135 v8SetReturnValue(info, timerId);
138 } 136 }
139 137
140 void V8Window::eventAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Val ue>& info)
141 {
142 LocalFrame* frame = V8Window::toNative(info.Holder())->frame();
143 ExceptionState exceptionState(ExceptionState::GetterContext, "event", "Windo w", info.Holder(), info.GetIsolate());
144 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), frame, exc eptionState)) {
145 exceptionState.throwIfNeeded();
146 return;
147 }
148
149 ASSERT(frame);
150 // This is a fast path to retrieve info.Holder()->CreationContext().
151 v8::Local<v8::Context> context = toV8Context(frame, DOMWrapperWorld::current (info.GetIsolate()));
152 if (context.IsEmpty())
153 return;
154
155 v8::Handle<v8::Value> jsEvent = V8HiddenValue::getHiddenValue(info.GetIsolat e(), context->Global(), V8HiddenValue::event(info.GetIsolate()));
156 if (jsEvent.IsEmpty())
157 return;
158 v8SetReturnValue(info, jsEvent);
159 }
160
161 void V8Window::eventAttributeSetterCustom(v8::Local<v8::Value> value, const v8:: PropertyCallbackInfo<void>& info)
162 {
163 LocalFrame* frame = V8Window::toNative(info.Holder())->frame();
164 ExceptionState exceptionState(ExceptionState::SetterContext, "event", "Windo w", info.Holder(), info.GetIsolate());
165 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), frame, exc eptionState)) {
166 exceptionState.throwIfNeeded();
167 return;
168 }
169
170 ASSERT(frame);
171 // This is a fast path to retrieve info.Holder()->CreationContext().
172 v8::Local<v8::Context> context = toV8Context(frame, DOMWrapperWorld::current (info.GetIsolate()));
173 if (context.IsEmpty())
174 return;
175
176 V8HiddenValue::setHiddenValue(info.GetIsolate(), context->Global(), V8Hidden Value::event(info.GetIsolate()), value);
177 }
178
179 // FIXME(fqian): returning string is cheating, and we should 138 // FIXME(fqian): returning string is cheating, and we should
180 // fix this by calling toString function on the receiver. 139 // fix this by calling toString function on the receiver.
181 // However, V8 implements toString in JavaScript, which requires 140 // However, V8 implements toString in JavaScript, which requires
182 // switching context of receiver. I consider it is dangerous. 141 // switching context of receiver. I consider it is dangerous.
183 void V8Window::toStringMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& i nfo) 142 void V8Window::toStringMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& i nfo)
184 { 143 {
185 v8::Handle<v8::Object> domWrapper = V8Window::findInstanceInPrototypeChain(i nfo.This(), info.GetIsolate()); 144 v8::Handle<v8::Object> domWrapper = V8Window::findInstanceInPrototypeChain(i nfo.This(), info.GetIsolate());
186 if (domWrapper.IsEmpty()) { 145 if (domWrapper.IsEmpty()) {
187 v8SetReturnValue(info, info.This()->ObjectProtoToString()); 146 v8SetReturnValue(info, info.This()->ObjectProtoToString());
188 return; 147 return;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 v8::Handle<v8::Context> context = toV8Context(frame, DOMWrapperWorld::curren t(isolate)); 219 v8::Handle<v8::Context> context = toV8Context(frame, DOMWrapperWorld::curren t(isolate));
261 if (context.IsEmpty()) 220 if (context.IsEmpty())
262 return v8Undefined(); 221 return v8Undefined();
263 222
264 v8::Handle<v8::Object> global = context->Global(); 223 v8::Handle<v8::Object> global = context->Global();
265 ASSERT(!global.IsEmpty()); 224 ASSERT(!global.IsEmpty());
266 return global; 225 return global;
267 } 226 }
268 227
269 } // namespace blink 228 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/bindings/core/v8/V8HiddenValue.h ('k') | sky/engine/core/events/EventTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698