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

Side by Side Diff: Source/bindings/v8/ScriptDebugServer.cpp

Issue 13575004: Apply script preprocessor to Web page scripts only. (Closed) Base URL: https://chromium.googlesource.com/external/WebKit_trimmed.git@master
Patch Set: Re-implment based on review Created 7 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. 2 * Copyright (c) 2010-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 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "bindings/v8/ScriptDebugServer.h" 32 #include "bindings/v8/ScriptDebugServer.h"
33 33
34 34
35 #include "DebuggerScriptSource.h" 35 #include "DebuggerScriptSource.h"
36 #include "V8JavaScriptCallFrame.h" 36 #include "V8JavaScriptCallFrame.h"
37 #include "bindings/v8/ScopedPersistent.h" 37 #include "bindings/v8/ScopedPersistent.h"
38 #include "bindings/v8/V8PerContextDebugData.h"
38 #include "bindings/v8/ScriptObject.h" 39 #include "bindings/v8/ScriptObject.h"
39 #include "bindings/v8/V8Binding.h" 40 #include "bindings/v8/V8Binding.h"
40 #include "bindings/v8/V8RecursionScope.h" 41 #include "bindings/v8/V8RecursionScope.h"
41 #include "core/inspector/JavaScriptCallFrame.h" 42 #include "core/inspector/JavaScriptCallFrame.h"
42 #include "core/inspector/ScriptDebugListener.h" 43 #include "core/inspector/ScriptDebugListener.h"
43 #include "wtf/StdLibExtras.h" 44 #include "wtf/StdLibExtras.h"
44 #include "wtf/Vector.h" 45 #include "wtf/Vector.h"
45 46
46 namespace WebCore { 47 namespace WebCore {
47 48
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 ASSERT(!eventContext.IsEmpty()); 452 ASSERT(!eventContext.IsEmpty());
452 453
453 ScriptDebugListener* listener = getDebugListenerForContext(eventContext); 454 ScriptDebugListener* listener = getDebugListenerForContext(eventContext);
454 if (listener) { 455 if (listener) {
455 v8::HandleScope scope; 456 v8::HandleScope scope;
456 if (event == v8::BeforeCompile) { 457 if (event == v8::BeforeCompile) {
457 458
458 if (!m_scriptPreprocessor) 459 if (!m_scriptPreprocessor)
459 return; 460 return;
460 461
462 if (V8PerContextDebugData::contextCategory(eventContext) != PageCont extCategory)
463 return;
464
465 v8::Handle<v8::Function> getScriptNameFunction = v8::Local<v8::Funct ion>::Cast(m_debuggerScript.get()->Get(v8::String::New("getScriptName")));
466 v8::Handle<v8::Value> argv1[] = { eventDetails.GetEventData() };
467 v8::Handle<v8::Value> scriptName = getScriptNameFunction->Call(m_deb uggerScript.get(), 1, argv1);
468
469 v8::String::Utf8Value scriptNameUtf8Value(scriptName);
470 String scriptNameString = String::fromUTF8(*scriptNameUtf8Value, scr iptNameUtf8Value.length());
471
472 // Allow eval scripts and Web scripts
473 if (scriptNameString != "undefined" && !V8PerContextDebugData::isSco pedWebCompilation(eventContext))
474 return;
475
476 // FIXME preprocessor needs to know that this compilation can only r eturn a function,
477 // eg DOM attribute event handler.
478 if (V8PerContextDebugData::isOneFunctionWebCompilation())
479 return;
480
461 OwnPtr<ScriptPreprocessor> preprocessor(m_scriptPreprocessor.release ()); 481 OwnPtr<ScriptPreprocessor> preprocessor(m_scriptPreprocessor.release ());
462 v8::Local<v8::Context> debugContext = v8::Debug::GetDebugContext(); 482 v8::Local<v8::Context> debugContext = v8::Debug::GetDebugContext();
463 v8::Context::Scope contextScope(debugContext); 483 v8::Context::Scope contextScope(debugContext);
464 v8::Handle<v8::Function> getScriptSourceFunction = v8::Local<v8::Fun ction>::Cast(m_debuggerScript.get()->Get(v8::String::New("getScriptSource"))); 484 v8::Handle<v8::Function> getScriptSourceFunction = v8::Local<v8::Fun ction>::Cast(m_debuggerScript.get()->Get(v8::String::New("getScriptSource")));
465 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; 485 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() };
466 v8::Handle<v8::Value> script = getScriptSourceFunction->Call(m_debug gerScript.get(), 1, argv); 486 v8::Handle<v8::Value> script = getScriptSourceFunction->Call(m_debug gerScript.get(), 1, argv);
467 487
468 v8::Handle<v8::Function> getScriptNameFunction = v8::Local<v8::Funct ion>::Cast(m_debuggerScript.get()->Get(v8::String::New("getScriptName")));
469 v8::Handle<v8::Value> argv1[] = { eventDetails.GetEventData() };
470 v8::Handle<v8::Value> scriptName = getScriptNameFunction->Call(m_deb uggerScript.get(), 1, argv1);
471
472 v8::Handle<v8::Function> setScriptSourceFunction = v8::Local<v8::Fun ction>::Cast(m_debuggerScript.get()->Get(v8::String::New("setScriptSource"))); 488 v8::Handle<v8::Function> setScriptSourceFunction = v8::Local<v8::Fun ction>::Cast(m_debuggerScript.get()->Get(v8::String::New("setScriptSource")));
473 String patchedScript = preprocessor->preprocessSourceCode(toWebCoreS tringWithUndefinedOrNullCheck(script), toWebCoreStringWithUndefinedOrNullCheck(s criptName)); 489 String patchedScript = preprocessor->preprocessSourceCode(toWebCoreS tringWithUndefinedOrNullCheck(script), scriptNameString);
474 490
475 v8::Handle<v8::Value> argv2[] = { eventDetails.GetEventData(), v8Str ing(patchedScript, debugContext->GetIsolate()) }; 491 v8::Handle<v8::Value> argv2[] = { eventDetails.GetEventData(), v8Str ing(patchedScript, debugContext->GetIsolate()) };
476 setScriptSourceFunction->Call(m_debuggerScript.get(), 2, argv2); 492 setScriptSourceFunction->Call(m_debuggerScript.get(), 2, argv2);
477 m_scriptPreprocessor = preprocessor.release(); 493 m_scriptPreprocessor = preprocessor.release();
478 } else if (event == v8::AfterCompile) { 494 } else if (event == v8::AfterCompile) {
479 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); 495 v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
480 v8::Handle<v8::Function> onAfterCompileFunction = v8::Local<v8::Func tion>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("getAfterCompileSc ript"))); 496 v8::Handle<v8::Function> onAfterCompileFunction = v8::Local<v8::Func tion>::Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("getAfterCompileSc ript")));
481 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; 497 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() };
482 v8::Handle<v8::Value> value = onAfterCompileFunction->Call(m_debugge rScript.get(), 1, argv); 498 v8::Handle<v8::Value> value = onAfterCompileFunction->Call(m_debugge rScript.get(), 1, argv);
483 ASSERT(value->IsObject()); 499 ASSERT(value->IsObject());
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 *result = ScriptValue(tryCatch.Exception()); 649 *result = ScriptValue(tryCatch.Exception());
634 v8::Local<v8::Message> message = tryCatch.Message(); 650 v8::Local<v8::Message> message = tryCatch.Message();
635 if (!message.IsEmpty()) 651 if (!message.IsEmpty())
636 *exceptionMessage = toWebCoreStringWithUndefinedOrNullCheck(message- >Get()); 652 *exceptionMessage = toWebCoreStringWithUndefinedOrNullCheck(message- >Get());
637 } else 653 } else
638 *result = ScriptValue(value); 654 *result = ScriptValue(value);
639 } 655 }
640 656
641 } // namespace WebCore 657 } // namespace WebCore
642 658
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698