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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/DocumentWriteEvaluator.cpp

Issue 2180663002: Replace compileAndRunInternalScript with not internal in DocumentWriteEvaluator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
Index: third_party/WebKit/Source/bindings/core/v8/DocumentWriteEvaluator.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/DocumentWriteEvaluator.cpp b/third_party/WebKit/Source/bindings/core/v8/DocumentWriteEvaluator.cpp
index 66af96ee87dab8644f9bfa595357aa709e0cb7de..91a72c2dcc76a35fee8249ccf4ebf3931d05b461 100644
--- a/third_party/WebKit/Source/bindings/core/v8/DocumentWriteEvaluator.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/DocumentWriteEvaluator.cpp
@@ -119,7 +119,7 @@ bool DocumentWriteEvaluator::ensureEvaluationContext()
return true;
}
-bool DocumentWriteEvaluator::evaluate(const String& scriptSource)
+bool DocumentWriteEvaluator::evaluate(const String& scriptSource, ExecutionContext* executionContext)
{
TRACE_EVENT0("blink", "DocumentWriteEvaluator::evaluate");
v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate();
@@ -128,12 +128,18 @@ bool DocumentWriteEvaluator::evaluate(const String& scriptSource)
v8::Context::Scope contextScope(m_persistentContext.newLocal(isolate));
// TODO(csharrison): Consider logging compile / execution error counts.
- StringUTF8Adaptor sourceUtf8(scriptSource);
- v8::MaybeLocal<v8::String> source = v8::String::NewFromUtf8(isolate, sourceUtf8.data(), v8::NewStringType::kNormal, sourceUtf8.length());
- if (source.IsEmpty())
- return false;
+ blink::ScriptSourceCode sourceCode(scriptSource);
+
v8::TryCatch tryCatch(isolate);
- return !V8ScriptRunner::compileAndRunInternalScript(source.ToLocalChecked(), isolate).IsEmpty();
+ v8::Local<v8::Script> script;
+ if (!V8ScriptRunner::compileScript(sourceCode, isolate).ToLocal(&script))
+ return false;
+ v8::MaybeLocal<v8::Value> result;
+ if (executionContext)
+ result = V8ScriptRunner::runCompiledScript(isolate, script, executionContext);
+ else
+ result = V8ScriptRunner::runCompiledInternalScript(isolate, script);
+ return !result.IsEmpty();
}
bool DocumentWriteEvaluator::shouldEvaluate(const String& source)
@@ -141,13 +147,13 @@ bool DocumentWriteEvaluator::shouldEvaluate(const String& source)
return !m_hostName.isEmpty() && !m_userAgent.isEmpty();
}
-String DocumentWriteEvaluator::evaluateAndEmitWrittenSource(const String& scriptSource)
+String DocumentWriteEvaluator::evaluateAndEmitWrittenSource(const String& scriptSource, ExecutionContext* executionContext)
{
if (!shouldEvaluate(scriptSource))
return "";
TRACE_EVENT0("blink", "DocumentWriteEvaluator::evaluateAndEmitStartTokens");
m_documentWrittenStrings.clear();
- evaluate(scriptSource);
+ evaluate(scriptSource, executionContext);
return m_documentWrittenStrings.toString();
}

Powered by Google App Engine
This is Rietveld 408576698