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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/DefaultScriptMapping.js

Issue 2931143003: DevTools: make debugger's rawLocationToUILocation return nullable type (Closed)
Patch Set: add test Created 3 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 * @param {!SDK.Target} target 59 * @param {!SDK.Target} target
60 * @return {string} 60 * @return {string}
61 */ 61 */
62 static projectIdForTarget(target) { 62 static projectIdForTarget(target) {
63 return 'debugger:' + target.id(); 63 return 'debugger:' + target.id();
64 } 64 }
65 65
66 /** 66 /**
67 * @override 67 * @override
68 * @param {!SDK.DebuggerModel.Location} rawLocation 68 * @param {!SDK.DebuggerModel.Location} rawLocation
69 * @return {!Workspace.UILocation} 69 * @return {?Workspace.UILocation}
70 */ 70 */
71 rawLocationToUILocation(rawLocation) { 71 rawLocationToUILocation(rawLocation) {
72 var debuggerModelLocation = /** @type {!SDK.DebuggerModel.Location} */ (rawL ocation); 72 var script = rawLocation.script();
73 var script = debuggerModelLocation.script(); 73 if (!script)
74 return null;
74 var uiSourceCode = script[Bindings.DefaultScriptMapping._uiSourceCodeSymbol] ; 75 var uiSourceCode = script[Bindings.DefaultScriptMapping._uiSourceCodeSymbol] ;
75 var lineNumber = debuggerModelLocation.lineNumber - (script.isInlineScriptWi thSourceURL() ? script.lineOffset : 0); 76 var lineNumber = rawLocation.lineNumber - (script.isInlineScriptWithSourceUR L() ? script.lineOffset : 0);
76 var columnNumber = debuggerModelLocation.columnNumber || 0; 77 var columnNumber = rawLocation.columnNumber || 0;
77 if (script.isInlineScriptWithSourceURL() && !lineNumber && columnNumber) 78 if (script.isInlineScriptWithSourceURL() && !lineNumber && columnNumber)
78 columnNumber -= script.columnOffset; 79 columnNumber -= script.columnOffset;
79 return uiSourceCode.uiLocation(lineNumber, columnNumber); 80 return uiSourceCode.uiLocation(lineNumber, columnNumber);
80 } 81 }
81 82
82 /** 83 /**
83 * @override 84 * @override
84 * @param {!Workspace.UISourceCode} uiSourceCode 85 * @param {!Workspace.UISourceCode} uiSourceCode
85 * @param {number} lineNumber 86 * @param {number} lineNumber
86 * @param {number} columnNumber 87 * @param {number} columnNumber
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 130
130 dispose() { 131 dispose() {
131 Common.EventTarget.removeEventListeners(this._eventListeners); 132 Common.EventTarget.removeEventListeners(this._eventListeners);
132 this._debuggerReset(); 133 this._debuggerReset();
133 this._project.dispose(); 134 this._project.dispose();
134 } 135 }
135 }; 136 };
136 137
137 Bindings.DefaultScriptMapping._scriptSymbol = Symbol('symbol'); 138 Bindings.DefaultScriptMapping._scriptSymbol = Symbol('symbol');
138 Bindings.DefaultScriptMapping._uiSourceCodeSymbol = Symbol('uiSourceCodeSymbol') ; 139 Bindings.DefaultScriptMapping._uiSourceCodeSymbol = Symbol('uiSourceCodeSymbol') ;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698