1/* 2 * Copyright (C) 2013 Apple 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 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26WebInspector.SourceCodeTimeline = function(sourceCode, sourceCodeLocation, recordType, recordEventType) 27{ 28 WebInspector.Timeline.call(this); 29 30 console.assert(sourceCode); 31 console.assert(!sourceCodeLocation || sourceCodeLocation.sourceCode === sourceCode); 32 console.assert(recordType); 33 34 this._sourceCode = sourceCode; 35 this._sourceCodeLocation = sourceCodeLocation || null; 36 this._recordType = recordType; 37 this._recordEventType = recordEventType || null; 38}; 39 40WebInspector.SourceCodeTimeline.TypeIdentifier = "source-code-timeline"; 41WebInspector.SourceCodeTimeline.SourceCodeURLCookieKey = "source-code-timeline-source-code-url"; 42WebInspector.SourceCodeTimeline.SourceCodeLocationLineCookieKey = "source-code-timeline-source-code-location-line"; 43WebInspector.SourceCodeTimeline.SourceCodeLocationColumnCookieKey = "source-code-timeline-source-code-location-column"; 44WebInspector.SourceCodeTimeline.SourceCodeURLCookieKey = "source-code-timeline-source-code-url"; 45WebInspector.SourceCodeTimeline.RecordTypeCookieKey = "source-code-timeline-record-type"; 46WebInspector.SourceCodeTimeline.RecordEventTypeCookieKey = "source-code-timeline-record-event-type"; 47 48WebInspector.SourceCodeTimeline.prototype = { 49 constructor: WebInspector.SourceCodeTimeline, 50 __proto__: WebInspector.Timeline.prototype, 51 52 // Public 53 54 get sourceCode() 55 { 56 return this._sourceCode; 57 }, 58 59 get sourceCodeLocation() 60 { 61 return this._sourceCodeLocation; 62 }, 63 64 get recordType() 65 { 66 return this._recordType; 67 }, 68 69 get recordEventType() 70 { 71 return this._recordEventType; 72 }, 73 74 saveIdentityToCookie: function(cookie) 75 { 76 cookie[WebInspector.SourceCodeTimeline.SourceCodeURLCookieKey] = this._sourceCode.url ? this._sourceCode.url.hash : null; 77 cookie[WebInspector.SourceCodeTimeline.SourceCodeLocationLineCookieKey] = this._sourceCodeLocation ? this._sourceCodeLocation.lineNumber : null; 78 cookie[WebInspector.SourceCodeTimeline.SourceCodeLocationColumnCookieKey] = this._sourceCodeLocation ? this._sourceCodeLocation.columnNumber : null; 79 cookie[WebInspector.SourceCodeTimeline.RecordTypeCookieKey] = this._recordType || null; 80 cookie[WebInspector.SourceCodeTimeline.RecordEventTypeCookieKey] = this._recordEventType || null; 81 } 82}; 83