initial import
[vuplus_webkit] / Source / WebCore / inspector / front-end / JavaScriptSourceFrame.js
1 /*
2  * Copyright (C) 2011 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 WebInspector.JavaScriptSourceFrame = function(model, uiSourceCode)
32 {
33     // FIXME: move all SourceFrame methods related to JavaScript debugging here and
34     // get rid of SourceFrame._delegate.
35     var delegate = new WebInspector.SourceFrameDelegateForScriptsPanel(model, uiSourceCode);
36     WebInspector.SourceFrame.call(this, delegate, uiSourceCode.url);
37 }
38
39 WebInspector.JavaScriptSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype;
40
41 WebInspector.SourceFrameDelegateForScriptsPanel = function(model, uiSourceCode)
42 {
43     WebInspector.SourceFrameDelegate.call(this);
44     this._model = model;
45     this._uiSourceCode = uiSourceCode;
46     this._popoverObjectGroup = "popover";
47 }
48
49 WebInspector.SourceFrameDelegateForScriptsPanel.prototype = {
50     requestContent: function(callback)
51     {
52         this._uiSourceCode.requestContent(callback);
53     },
54
55     debuggingSupported: function()
56     {
57         return true;
58     },
59
60     setBreakpoint: function(lineNumber, condition, enabled)
61     {
62         this._model.setBreakpoint(this._uiSourceCode, lineNumber, condition, enabled);
63
64         if (!WebInspector.panels.scripts.breakpointsActivated)
65             WebInspector.panels.scripts.toggleBreakpointsClicked();
66     },
67
68     updateBreakpoint: function(lineNumber, condition, enabled)
69     {
70         this._model.updateBreakpoint(this._uiSourceCode, lineNumber, condition, enabled);
71     },
72
73     removeBreakpoint: function(lineNumber)
74     {
75         this._model.removeBreakpoint(this._uiSourceCode, lineNumber);
76     },
77
78     findBreakpoint: function(lineNumber)
79     {
80         return this._model.findBreakpoint(this._uiSourceCode, lineNumber);
81     },
82
83     continueToLine: function(lineNumber)
84     {
85         this._model.continueToLine(this._uiSourceCode, lineNumber);
86     },
87
88     canEditScriptSource: function()
89     {
90         return this._model.canEditScriptSource(this._uiSourceCode);
91     },
92
93     setScriptSource: function(text, callback)
94     {
95         this._model.setScriptSource(this._uiSourceCode, text, callback);
96     },
97
98     setScriptSourceIsBeingEdited: function(inEditMode)
99     {
100         WebInspector.panels.scripts.setScriptSourceIsBeingEdited(this._uiSourceCode, inEditMode);
101     },
102
103     debuggerPaused: function()
104     {
105         return WebInspector.panels.scripts.paused;
106     },
107
108     evaluateInSelectedCallFrame: function(string, callback)
109     {
110         WebInspector.panels.scripts.evaluateInSelectedCallFrame(string, this._popoverObjectGroup, false, false, callback);
111     },
112
113     releaseEvaluationResult: function()
114     {
115         RuntimeAgent.releaseObjectGroup(this._popoverObjectGroup);
116     },
117
118     suggestedFileName: function()
119     {
120         var names = WebInspector.panels.scripts._folderAndDisplayNameForScriptURL(this._uiSourceCode.url);
121         return names.displayName || "untitled.js";
122     }
123 }
124
125 WebInspector.SourceFrameDelegateForScriptsPanel.prototype.__proto__ = WebInspector.SourceFrameDelegate.prototype;