OLD | NEW |
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return; | 60 return; |
61 } | 61 } |
62 | 62 |
63 ScriptValue preprocessorFunction = scriptResults[0]; | 63 ScriptValue preprocessorFunction = scriptResults[0]; |
64 if (!preprocessorFunction.isFunction()) { | 64 if (!preprocessorFunction.isFunction()) { |
65 frame->host()->console().addMessage(JSMessageSource, ErrorMessageLevel,
"The preprocessor must compile to a function."); | 65 frame->host()->console().addMessage(JSMessageSource, ErrorMessageLevel,
"The preprocessor must compile to a function."); |
66 return; | 66 return; |
67 } | 67 } |
68 | 68 |
69 m_world = DOMWrapperWorld::ensureIsolatedWorld(ScriptPreprocessorIsolatedWor
ldId, DOMWrapperWorld::mainWorldExtensionGroup); | 69 m_world = DOMWrapperWorld::ensureIsolatedWorld(ScriptPreprocessorIsolatedWor
ldId, DOMWrapperWorld::mainWorldExtensionGroup); |
70 v8::Local<v8::Context> context = toV8Context(m_isolate, frame, m_world.get()
); | 70 v8::Local<v8::Context> context = toV8Context(m_isolate, frame, *m_world); |
71 | 71 |
72 m_context.set(m_isolate, context); | 72 m_context.set(m_isolate, context); |
73 m_preprocessorFunction.set(m_isolate, v8::Handle<v8::Function>::Cast(preproc
essorFunction.v8Value())); | 73 m_preprocessorFunction.set(m_isolate, v8::Handle<v8::Function>::Cast(preproc
essorFunction.v8Value())); |
74 } | 74 } |
75 | 75 |
76 String ScriptPreprocessor::preprocessSourceCode(const String& sourceCode, const
String& sourceName) | 76 String ScriptPreprocessor::preprocessSourceCode(const String& sourceCode, const
String& sourceName) |
77 { | 77 { |
78 if (!isValid()) | 78 if (!isValid()) |
79 return sourceCode; | 79 return sourceCode; |
80 | 80 |
(...skipping 26 matching lines...) Expand all Loading... |
107 TemporaryChange<bool> isPreprocessing(m_isPreprocessing, true); | 107 TemporaryChange<bool> isPreprocessing(m_isPreprocessing, true); |
108 v8::Handle<v8::Value> resultValue = V8ScriptRunner::callAsFunction(m_preproc
essorFunction.newLocal(m_isolate), m_context.newLocal(m_isolate)->Global(), WTF_
ARRAY_LENGTH(argv), argv); | 108 v8::Handle<v8::Value> resultValue = V8ScriptRunner::callAsFunction(m_preproc
essorFunction.newLocal(m_isolate), m_context.newLocal(m_isolate)->Global(), WTF_
ARRAY_LENGTH(argv), argv); |
109 | 109 |
110 if (!resultValue.IsEmpty() && resultValue->IsString()) | 110 if (!resultValue.IsEmpty() && resultValue->IsString()) |
111 return toCoreStringWithNullCheck(resultValue.As<v8::String>()); | 111 return toCoreStringWithNullCheck(resultValue.As<v8::String>()); |
112 | 112 |
113 return sourceCode; | 113 return sourceCode; |
114 } | 114 } |
115 | 115 |
116 } // namespace WebCore | 116 } // namespace WebCore |
OLD | NEW |