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

Unified Diff: webkit/port/bindings/v8/v8_events.cpp

Issue 18526: Merge r8050 - When a function handling an event doesn't return a value, it le... (Closed) Base URL: svn://chrome-svn/chrome/branches/release_154.next/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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/port/bindings/v8/v8_events.cpp
===================================================================
--- webkit/port/bindings/v8/v8_events.cpp (revision 8470)
+++ webkit/port/bindings/v8/v8_events.cpp (working copy)
@@ -1,10 +1,10 @@
// Copyright (c) 2008, Google Inc.
// All rights reserved.
-//
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
-//
+//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
-//
+//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -83,6 +83,10 @@
v8::Handle<v8::Value> jsevent = V8Proxy::EventToV8Object(event);
+ // For compatibility, we store the event object as a property on the window
+ // called "event". Because this is the global namespace, we save away any
+ // existing "event" property, and then restore it after executing the
+ // javascript handler.
v8::Local<v8::String> event_symbol = v8::String::NewSymbol("event");
// Save the old 'event' property.
@@ -106,6 +110,10 @@
ret = CallListenerFunction(jsevent, event, isWindowEvent);
}
+ // Restore the old event. This must be done for all exit paths through
+ // this method.
+ context->Global()->Set(event_symbol, saved_evt);
+
if (V8Proxy::HandleOutOfMemory())
ASSERT(ret.IsEmpty());
@@ -127,9 +135,6 @@
}
}
- // Restore the old event.
- context->Global()->Set(event_symbol, saved_evt);
-
Document::updateDocumentsRendering();
}
@@ -145,6 +150,7 @@
}
+
V8EventListener::V8EventListener(Frame* frame, v8::Local<v8::Object> listener,
bool html)
: V8AbstractEventListener(frame, html) {
« 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