| OLD | NEW |
| 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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 // Make it an anonymous function to avoid name conflict for cases like | 355 // Make it an anonymous function to avoid name conflict for cases like |
| 356 // <body onload='onload()'> | 356 // <body onload='onload()'> |
| 357 // <script> function onload() { alert('hi'); } </script>. | 357 // <script> function onload() { alert('hi'); } </script>. |
| 358 // Set function name to function object instead. | 358 // Set function name to function object instead. |
| 359 // See issue 944690. | 359 // See issue 944690. |
| 360 // | 360 // |
| 361 // The ECMAScript spec says (very obliquely) that the parameter to | 361 // The ECMAScript spec says (very obliquely) that the parameter to |
| 362 // an event handler is named "evt". | 362 // an event handler is named "evt". |
| 363 String code = "(function (evt) {\n"; | 363 String code = "(function (evt) {\n"; |
| 364 code.append(m_code); | 364 code.append(m_code); |
| 365 code.append("})"); | 365 code.append("\n})"); |
| 366 | 366 |
| 367 IF_DEVEL(log_info(frame, code, "<getListener>")); | 367 IF_DEVEL(log_info(frame, code, "<getListener>")); |
| 368 | 368 |
| 369 v8::Handle<v8::String> codeExternalString = v8ExternalString(code); | 369 v8::Handle<v8::String> codeExternalString = v8ExternalString(code); |
| 370 v8::Handle<v8::Script> script = V8Proxy::CompileScript(codeExternalString, | 370 v8::Handle<v8::Script> script = V8Proxy::CompileScript(codeExternalString, |
| 371 m_frame->document()->url(), m_lineNumber - 1); | 371 m_frame->document()->url(), m_lineNumber - 1); |
| 372 if (!script.IsEmpty()) { | 372 if (!script.IsEmpty()) { |
| 373 V8Proxy* proxy = V8Proxy::retrieve(m_frame); | 373 V8Proxy* proxy = V8Proxy::retrieve(m_frame); |
| 374 ASSERT(proxy); // must be valid at this point | 374 ASSERT(proxy); // must be valid at this point |
| 375 v8::Local<v8::Value> value = proxy->RunScript(script, false); | 375 v8::Local<v8::Value> value = proxy->RunScript(script, false); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 // handlers push document, form, and the target node on the scope chain. | 440 // handlers push document, form, and the target node on the scope chain. |
| 441 // We do this by using 'with' statement. | 441 // We do this by using 'with' statement. |
| 442 // See chrome/fast/forms/form-action.html | 442 // See chrome/fast/forms/form-action.html |
| 443 // chrome/fast/forms/selected-index-value.html | 443 // chrome/fast/forms/selected-index-value.html |
| 444 // base/fast/overflow/onscroll-layer-self-destruct.html | 444 // base/fast/overflow/onscroll-layer-self-destruct.html |
| 445 code.append(" with (this.ownerDocument ? this.ownerDocument : {}) {\n"); | 445 code.append(" with (this.ownerDocument ? this.ownerDocument : {}) {\n"); |
| 446 code.append(" with (this.form ? this.form : {}) {\n"); | 446 code.append(" with (this.form ? this.form : {}) {\n"); |
| 447 code.append(" with (this) {\n"); | 447 code.append(" with (this) {\n"); |
| 448 code.append(" return (function(evt){"); | 448 code.append(" return (function(evt){"); |
| 449 code.append(m_code); | 449 code.append(m_code); |
| 450 code.append("}).call(this, evt);\n"); | 450 code.append("\n}).call(this, evt);\n"); |
| 451 code.append(" }\n"); | 451 code.append(" }\n"); |
| 452 code.append(" }\n"); | 452 code.append(" }\n"); |
| 453 code.append(" }\n"); | 453 code.append(" }\n"); |
| 454 code.append("})"); | 454 code.append("})"); |
| 455 v8::Handle<v8::String> codeExternalString = v8ExternalString(code); | 455 v8::Handle<v8::String> codeExternalString = v8ExternalString(code); |
| 456 v8::Handle<v8::Script> script = V8Proxy::CompileScript(codeExternalString, | 456 v8::Handle<v8::Script> script = V8Proxy::CompileScript(codeExternalString, |
| 457 m_frame->document()->url(), m_lineNumber - 4); | 457 m_frame->document()->url(), m_lineNumber - 4); |
| 458 if (!script.IsEmpty()) { | 458 if (!script.IsEmpty()) { |
| 459 V8Proxy* proxy = V8Proxy::retrieve(m_frame); | 459 V8Proxy* proxy = V8Proxy::retrieve(m_frame); |
| 460 ASSERT(proxy); | 460 ASSERT(proxy); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 | 554 |
| 555 EventTarget* target = event->currentTarget(); | 555 EventTarget* target = event->currentTarget(); |
| 556 v8::Handle<v8::Value> value = | 556 v8::Handle<v8::Value> value = |
| 557 WorkerContextExecutionProxy::EventTargetToV8Object(target); | 557 WorkerContextExecutionProxy::EventTargetToV8Object(target); |
| 558 if (value.IsEmpty()) return v8::Local<v8::Object>(); | 558 if (value.IsEmpty()) return v8::Local<v8::Object>(); |
| 559 return v8::Local<v8::Object>::New(v8::Handle<v8::Object>::Cast(value)); | 559 return v8::Local<v8::Object>::New(v8::Handle<v8::Object>::Cast(value)); |
| 560 } | 560 } |
| 561 #endif // WORKERS | 561 #endif // WORKERS |
| 562 | 562 |
| 563 } // namespace WebCore | 563 } // namespace WebCore |
| OLD | NEW |