Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / devtools / front_end / source_frame / ResourceSourceFrame.js
blob026407d59f56d90719387754cc226885c2dde3ab
1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) IBM Corp. 2009 All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15 * its contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 /**
31 * @extends {WebInspector.SourceFrame}
32 * @constructor
33 * @param {!WebInspector.ContentProvider} resource
35 WebInspector.ResourceSourceFrame = function(resource)
37 this._resource = resource;
38 this._messages = [];
39 WebInspector.SourceFrame.call(this, resource);
42 WebInspector.ResourceSourceFrame.prototype = {
43 /**
44 * @param {!WebInspector.ConsoleMessage} message
46 addPersistentMessage: function(message)
48 this._messages.push(message);
49 if (this.loaded)
50 this.addMessageToSource(WebInspector.SourceFrameMessage.fromConsoleMessage(message, message.line - 1, message.column));
53 /**
54 * @override
56 onTextEditorContentLoaded: function()
58 for (var message of this._messages)
59 this.addMessageToSource(WebInspector.SourceFrameMessage.fromConsoleMessage(message, message.line - 1, message.column));
62 get resource()
64 return this._resource;
67 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber)
69 contextMenu.appendApplicableItems(this._resource);
72 __proto__: WebInspector.SourceFrame.prototype
75 /**
76 * @constructor
77 * @extends {WebInspector.VBox}
78 * @param {!WebInspector.ContentProvider} resource
80 WebInspector.ResourceSourceFrameFallback = function(resource)
82 WebInspector.VBox.call(this);
83 this.registerRequiredCSS("source_frame/resourceSourceFrame.css");
84 this._resource = resource;
85 this._content = this.element.createChild("div", "resource-source-frame-fallback monospace");
88 WebInspector.ResourceSourceFrameFallback.prototype = {
89 wasShown: function()
91 if (!this._contentRequested) {
92 this._contentRequested = true;
93 this._resource.requestContent(this._contentLoaded.bind(this));
97 /**
98 * @param {?string} content
100 _contentLoaded: function(content)
102 this._content.textContent = content;
105 __proto__: WebInspector.VBox.prototype