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

Side by Side Diff: webkit/port/bindings/v8/v8_events.cpp

Issue 18013: When any event is ongoing, we don't set user gesture correctly... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008, Google Inc. 1 // Copyright (c) 2008, Google Inc.
2 // All rights reserved. 2 // 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 v8::Context::Scope scope(context); 77 v8::Context::Scope scope(context);
78 78
79 // m_frame can removed by the callback function, 79 // m_frame can removed by the callback function,
80 // protect it until the callback function returns. 80 // protect it until the callback function returns.
81 RefPtr<Frame> protector(m_frame); 81 RefPtr<Frame> protector(m_frame);
82 82
83 IF_DEVEL(log_info(frame, "Handling DOM event", m_frame->document()->URL())); 83 IF_DEVEL(log_info(frame, "Handling DOM event", m_frame->document()->URL()));
84 84
85 v8::Handle<v8::Value> jsevent = V8Proxy::EventToV8Object(event); 85 v8::Handle<v8::Value> jsevent = V8Proxy::EventToV8Object(event);
86 86
87 v8::Local<v8::String> event_symbol = v8::String::NewSymbol("event"); 87 v8::Local<v8::String> event_symbol = v8::String::NewSymbol("event");
Mike Belshe 2009/01/14 23:36:00 Let's add a comment here: For compatibility, we s
88 88
89 // Save the old 'event' property. 89 // Save the old 'event' property.
90 v8::Local<v8::Value> saved_evt = context->Global()->Get(event_symbol); 90 v8::Local<v8::Value> saved_evt = context->Global()->Get(event_symbol);
91 91
92 // Make the event available in the window object. 92 // Make the event available in the window object.
93 // 93 //
94 // TODO: This does not work as in safari if the window.event 94 // TODO: This does not work as in safari if the window.event
95 // property is already set. We need to make sure that property 95 // property is already set. We need to make sure that property
96 // access is intercepted correctly. 96 // access is intercepted correctly.
97 context->Global()->Set(event_symbol, jsevent); 97 context->Global()->Set(event_symbol, jsevent);
98 98
99 v8::Local<v8::Value> ret; 99 v8::Local<v8::Value> ret;
100 { 100 {
101 // Catch exceptions thrown in the event handler so they do not 101 // Catch exceptions thrown in the event handler so they do not
102 // propagate to javascript code that caused the event to fire. 102 // propagate to javascript code that caused the event to fire.
103 v8::TryCatch try_catch; 103 v8::TryCatch try_catch;
104 try_catch.SetVerbose(true); 104 try_catch.SetVerbose(true);
105 105
106 // Call the event handler. 106 // Call the event handler.
107 ret = CallListenerFunction(jsevent, event, isWindowEvent); 107 ret = CallListenerFunction(jsevent, event, isWindowEvent);
108 } 108 }
109 109
110 // Restore the old event.
Mike Belshe 2009/01/14 23:36:00 Update comment to: Restore the old event. This m
111 context->Global()->Set(event_symbol, saved_evt);
112
110 if (V8Proxy::HandleOutOfMemory()) 113 if (V8Proxy::HandleOutOfMemory())
111 ASSERT(ret.IsEmpty()); 114 ASSERT(ret.IsEmpty());
112 115
113 if (ret.IsEmpty()) { 116 if (ret.IsEmpty()) {
114 return; 117 return;
115 } 118 }
116 119
117 if (!ret.IsEmpty()) { 120 if (!ret.IsEmpty()) {
118 if (!ret->IsNull() && !ret->IsUndefined() && 121 if (!ret->IsNull() && !ret->IsUndefined() &&
119 event->storesResultAsString()) { 122 event->storesResultAsString()) {
120 event->storeResult(ToWebCoreString(ret)); 123 event->storeResult(ToWebCoreString(ret));
121 } 124 }
122 // Prevent default action if the return value is false; 125 // Prevent default action if the return value is false;
123 // TODO(fqian): example, and reference to buganizer entry 126 // TODO(fqian): example, and reference to buganizer entry
124 if (m_isInline) { 127 if (m_isInline) {
125 if (ret->IsBoolean() && !ret->BooleanValue()) { 128 if (ret->IsBoolean() && !ret->BooleanValue()) {
126 event->preventDefault(); 129 event->preventDefault();
127 } 130 }
128 } 131 }
129 } 132 }
130 133
131 // Restore the old event.
132 context->Global()->Set(event_symbol, saved_evt);
133
134 Document::updateDocumentsRendering(); 134 Document::updateDocumentsRendering();
135 } 135 }
136 136
137 137
138 void V8AbstractEventListener::DisposeListenerObject() { 138 void V8AbstractEventListener::DisposeListenerObject() {
139 if (!m_listener.IsEmpty()) { 139 if (!m_listener.IsEmpty()) {
140 #ifndef NDEBUG 140 #ifndef NDEBUG
141 V8Proxy::UnregisterGlobalHandle(this, m_listener); 141 V8Proxy::UnregisterGlobalHandle(this, m_listener);
142 #endif 142 #endif
143 m_listener.Dispose(); 143 m_listener.Dispose();
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 m_wrapped_function->SetName(v8::String::New( 438 m_wrapped_function->SetName(v8::String::New(
439 FromWebCoreString(m_func_name), m_func_name.length())); 439 FromWebCoreString(m_func_name), m_func_name.length()));
440 } 440 }
441 } 441 }
442 } // end of local scope 442 } // end of local scope
443 443
444 return v8::Local<v8::Function>::New(m_wrapped_function); 444 return v8::Local<v8::Function>::New(m_wrapped_function);
445 } 445 }
446 446
447 } // namespace WebCore 447 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698