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

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

Issue 33523002: Have Frame::script() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 2 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 | « Source/bindings/v8/ScriptPreprocessor.h ('k') | Source/bindings/v8/ScriptState.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 22 matching lines...) Expand all
33 33
34 #include "bindings/v8/ScriptController.h" 34 #include "bindings/v8/ScriptController.h"
35 #include "bindings/v8/ScriptSourceCode.h" 35 #include "bindings/v8/ScriptSourceCode.h"
36 #include "bindings/v8/ScriptValue.h" 36 #include "bindings/v8/ScriptValue.h"
37 #include "bindings/v8/V8ScriptRunner.h" 37 #include "bindings/v8/V8ScriptRunner.h"
38 #include "core/page/PageConsole.h" 38 #include "core/page/PageConsole.h"
39 #include "wtf/TemporaryChange.h" 39 #include "wtf/TemporaryChange.h"
40 40
41 namespace WebCore { 41 namespace WebCore {
42 42
43 ScriptPreprocessor::ScriptPreprocessor(const ScriptSourceCode& preprocessorSourc eCode, ScriptController* controller, PageConsole& console) 43 ScriptPreprocessor::ScriptPreprocessor(const ScriptSourceCode& preprocessorSourc eCode, ScriptController& controller, PageConsole& console)
44 : m_isPreprocessing(false) 44 : m_isPreprocessing(false)
45 { 45 {
46 v8::TryCatch tryCatch; 46 v8::TryCatch tryCatch;
47 tryCatch.SetVerbose(true); 47 tryCatch.SetVerbose(true);
48 Vector<ScriptSourceCode> sources; 48 Vector<ScriptSourceCode> sources;
49 sources.append(preprocessorSourceCode); 49 sources.append(preprocessorSourceCode);
50 Vector<ScriptValue> scriptResults; 50 Vector<ScriptValue> scriptResults;
51 controller->executeScriptInIsolatedWorld(ScriptPreprocessorIsolatedWorldId, sources, DOMWrapperWorld::mainWorldExtensionGroup, &scriptResults); 51 controller.executeScriptInIsolatedWorld(ScriptPreprocessorIsolatedWorldId, s ources, DOMWrapperWorld::mainWorldExtensionGroup, &scriptResults);
52 52
53 if (scriptResults.size() != 1) { 53 if (scriptResults.size() != 1) {
54 console.addMessage(JSMessageSource, ErrorMessageLevel, "ScriptPreprocess or internal error, one ScriptSourceCode must give exactly one result."); 54 console.addMessage(JSMessageSource, ErrorMessageLevel, "ScriptPreprocess or internal error, one ScriptSourceCode must give exactly one result.");
55 return; 55 return;
56 } 56 }
57 57
58 ScriptValue preprocessorFunction = scriptResults[0]; 58 ScriptValue preprocessorFunction = scriptResults[0];
59 if (!preprocessorFunction.isFunction()) { 59 if (!preprocessorFunction.isFunction()) {
60 console.addMessage(JSMessageSource, ErrorMessageLevel, "The preprocessor must compile to a function."); 60 console.addMessage(JSMessageSource, ErrorMessageLevel, "The preprocessor must compile to a function.");
61 return; 61 return;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 TemporaryChange<bool> isPreprocessing(m_isPreprocessing, true); 103 TemporaryChange<bool> isPreprocessing(m_isPreprocessing, true);
104 v8::Handle<v8::Value> resultValue = V8ScriptRunner::callAsFunction(m_preproc essorFunction.newLocal(m_isolate), m_context.newLocal(m_isolate)->Global(), WTF_ ARRAY_LENGTH(argv), argv); 104 v8::Handle<v8::Value> resultValue = V8ScriptRunner::callAsFunction(m_preproc essorFunction.newLocal(m_isolate), m_context.newLocal(m_isolate)->Global(), WTF_ ARRAY_LENGTH(argv), argv);
105 105
106 if (!resultValue.IsEmpty() && resultValue->IsString()) 106 if (!resultValue.IsEmpty() && resultValue->IsString())
107 return toWebCoreStringWithNullCheck(resultValue.As<v8::String>()); 107 return toWebCoreStringWithNullCheck(resultValue.As<v8::String>());
108 108
109 return sourceCode; 109 return sourceCode;
110 } 110 }
111 111
112 } // namespace WebCore 112 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/ScriptPreprocessor.h ('k') | Source/bindings/v8/ScriptState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698