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

Side by Side Diff: Source/bindings/v8/ScriptController.h

Issue 13575004: Apply script preprocessor to Web page scripts only. (Closed) Base URL: https://chromium.googlesource.com/external/WebKit_trimmed.git@master
Patch Set: rebase Created 7 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 unified diff | Download patch
« no previous file with comments | « Source/bindings/v8/PageScriptDebugServer.cpp ('k') | Source/bindings/v8/ScriptController.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) 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 2009 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 struct NPObject; 44 struct NPObject;
45 45
46 namespace WebCore { 46 namespace WebCore {
47 47
48 class DOMWrapperWorld; 48 class DOMWrapperWorld;
49 class Event; 49 class Event;
50 class Frame; 50 class Frame;
51 class HTMLDocument; 51 class HTMLDocument;
52 class HTMLPlugInElement; 52 class HTMLPlugInElement;
53 class KURL; 53 class KURL;
54 class ScriptDebugServer;
55 class ScriptPreprocessor;
54 class ScriptSourceCode; 56 class ScriptSourceCode;
55 class ScriptState; 57 class ScriptState;
56 class SecurityOrigin; 58 class SecurityOrigin;
57 class V8WindowShell; 59 class V8WindowShell;
58 class Widget; 60 class Widget;
59 61
60 typedef WTF::Vector<v8::Extension*> V8Extensions; 62 typedef WTF::Vector<v8::Extension*> V8Extensions;
61 63
62 enum ReasonForCallingCanExecuteScripts { 64 enum ReasonForCallingCanExecuteScripts {
63 AboutToExecuteScript, 65 AboutToExecuteScript,
64 NotAboutToExecuteScript 66 NotAboutToExecuteScript
65 }; 67 };
66 68
67 enum IsolatedWorldConstants {
68 EmbedderWorldIdLimit = (1 << 29)
69 };
70
71 class ScriptController { 69 class ScriptController {
72 public: 70 public:
73 ScriptController(Frame*); 71 ScriptController(Frame*);
74 ~ScriptController(); 72 ~ScriptController();
75 73
76 bool initializeMainWorld(); 74 bool initializeMainWorld();
77 V8WindowShell* windowShell(DOMWrapperWorld*); 75 V8WindowShell* windowShell(DOMWrapperWorld*);
78 V8WindowShell* existingWindowShell(DOMWrapperWorld*); 76 V8WindowShell* existingWindowShell(DOMWrapperWorld*);
79 77
80 ScriptValue executeScript(const ScriptSourceCode&); 78 ScriptValue executeScript(const ScriptSourceCode&);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 150
153 NPObject* createScriptObjectForPluginElement(HTMLPlugInElement*); 151 NPObject* createScriptObjectForPluginElement(HTMLPlugInElement*);
154 NPObject* windowScriptNPObject(); 152 NPObject* windowScriptNPObject();
155 153
156 // Registers a v8 extension to be available on webpages. Will only 154 // Registers a v8 extension to be available on webpages. Will only
157 // affect v8 contexts initialized after this call. Takes ownership of 155 // affect v8 contexts initialized after this call. Takes ownership of
158 // the v8::Extension object passed. 156 // the v8::Extension object passed.
159 static void registerExtensionIfNeeded(v8::Extension*); 157 static void registerExtensionIfNeeded(v8::Extension*);
160 static V8Extensions& registeredExtensions(); 158 static V8Extensions& registeredExtensions();
161 159
160 void setScriptPreprocessor(const String& preprocessorSource);
161 void clearScriptPreprocessor();
162 // Source to Source processing iff debugger enabled and it has loaded a prep rocessor.
163 String preprocess(const String& scriptSource, const String& scriptName);
164 void preprocessEval(ScriptDebugServer* , v8::Handle<v8::Object> eventData);
165
162 bool setContextDebugId(int); 166 bool setContextDebugId(int);
163 static int contextDebugId(v8::Handle<v8::Context>); 167 static int contextDebugId(v8::Handle<v8::Context>);
164 168
165 private: 169 private:
166 typedef HashMap<int, OwnPtr<V8WindowShell> > IsolatedWorldMap; 170 typedef HashMap<int, OwnPtr<V8WindowShell> > IsolatedWorldMap;
167 typedef HashMap<Widget*, NPObject*> PluginObjectMap; 171 typedef HashMap<Widget*, NPObject*> PluginObjectMap;
168 172
169 void clearForClose(bool destroyGlobal); 173 void clearForClose(bool destroyGlobal);
170 174
171 Frame* m_frame; 175 Frame* m_frame;
172 const String* m_sourceURL; 176 const String* m_sourceURL;
173 v8::Isolate* m_isolate; 177 v8::Isolate* m_isolate;
174 178
175 OwnPtr<V8WindowShell> m_windowShell; 179 OwnPtr<V8WindowShell> m_windowShell;
176 IsolatedWorldMap m_isolatedWorlds; 180 IsolatedWorldMap m_isolatedWorlds;
177 181
178 bool m_paused; 182 bool m_paused;
179 183
180 // A mapping between Widgets and their corresponding script object. 184 // A mapping between Widgets and their corresponding script object.
181 // This list is used so that when the plugin dies, we can immediately 185 // This list is used so that when the plugin dies, we can immediately
182 // invalidate all sub-objects which are associated with that plugin. 186 // invalidate all sub-objects which are associated with that plugin.
183 // The frame keeps a NPObject reference for each item on the list. 187 // The frame keeps a NPObject reference for each item on the list.
184 PluginObjectMap m_pluginObjects; 188 PluginObjectMap m_pluginObjects;
185 189
186 NPObject* m_windowScriptNPObject; 190 NPObject* m_windowScriptNPObject;
191
192 // Set by the PageDebuggerAgent on reload
193 String m_preprocessorSource;
194 // Set on the first JS compilation after m_preprocessorSource is set.
195 OwnPtr<ScriptPreprocessor> m_scriptPreprocessor;
187 }; 196 };
188 197
189 } // namespace WebCore 198 } // namespace WebCore
190 199
191 #endif // ScriptController_h 200 #endif // ScriptController_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/PageScriptDebugServer.cpp ('k') | Source/bindings/v8/ScriptController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698