Changeset 147421 in webkit
- Timestamp:
- Apr 2, 2013 6:15:35 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r147418 r147421 1 2013-04-02 Andrey Lushnikov <lushnikov@chromium.org> 2 3 Web Inspector: [CodeMirror] Popover for codemirror 4 https://bugs.webkit.org/show_bug.cgi?id=113771 5 6 Reviewed by Pavel Feldman. 7 8 Implement methods TextEditor.cursorPositionToCoordinates, TextEditor.coordinatesToCursorPosition and 9 TextEditor.tokenAtTextPosition in CodeMirrorTextEditor to support popover 10 functionality. Add css classes to highlight popover anchoring text. 11 12 No new tests. 13 14 * inspector/front-end/CodeMirrorTextEditor.js: 15 (WebInspector.CodeMirrorTextEditor.prototype.cursorPositionToCoordinates): 16 (WebInspector.CodeMirrorTextEditor.prototype.coordinatesToCursorPosition): 17 (WebInspector.CodeMirrorTextEditor.prototype.tokenAtTextPosition): 18 * inspector/front-end/cm/cmdevtools.css: 19 (.CodeMirror .source-frame-eval-expression): 20 (.CodeMirror .source-frame-eval-expression-end): 21 (.CodeMirror .source-frame-eval-expression-start): 22 1 23 2013-04-02 Carlos Garcia Campos <cgarcia@igalia.com> 2 24 -
trunk/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js
r146972 r147421 93 93 94 94 /** 95 * @param {number} lineNumber 96 * @param {number} column 97 * @return {?{x: number, y: number, height: number}} 98 */ 99 cursorPositionToCoordinates: function(lineNumber, column) 100 { 101 if (lineNumber >= this._codeMirror.lineCount || column > this._codeMirror.getLine(lineNumber).length || lineNumber < 0 || column < 0) 102 return null; 103 104 var metrics = this._codeMirror.cursorCoords(CodeMirror.Pos(lineNumber, column)); 105 106 return { 107 x: metrics.left, 108 y: metrics.top, 109 height: metrics.bottom - metrics.top 110 }; 111 }, 112 113 /** 114 * @param {number} x 115 * @param {number} y 116 * @return {?WebInspector.TextRange} 117 */ 118 coordinatesToCursorPosition: function(x, y) 119 { 120 var element = document.elementFromPoint(x, y); 121 if (!element || !element.isSelfOrDescendant(this._codeMirror.getWrapperElement())) 122 return null; 123 var gutterBox = this._codeMirror.getGutterElement().boxInWindow(); 124 if (x >= gutterBox.x && x <= gutterBox.x + gutterBox.width && 125 y >= gutterBox.y && y <= gutterBox.y + gutterBox.height) 126 return null; 127 var coords = this._codeMirror.coordsChar({left: x, top: y}); 128 ++coords.ch; 129 return this._toRange(coords, coords); 130 }, 131 132 /** 133 * @param {number} lineNumber 134 * @param {number} column 135 * @return {?{startColumn: number, endColumn: number, token: string}} 136 */ 137 tokenAtTextPosition: function(lineNumber, column) 138 { 139 if (lineNumber < 0 || lineNumber >= this._codeMirror.lineCount()) 140 return null; 141 var token = this._codeMirror.getTokenAt(CodeMirror.Pos(lineNumber, column || 1)); 142 if (!token || !token.type) 143 return null; 144 var convertedType = null; 145 if (token.type.startsWith("variable") || token.type.startsWith("property")) { 146 return { 147 startColumn: token.start, 148 endColumn: token.end - 1, 149 type: "javascript-ident" 150 }; 151 } 152 return null; 153 }, 154 155 /** 95 156 * @param {WebInspector.TextRange} textRange 96 157 * @return {string} -
trunk/Source/WebCore/inspector/front-end/cm/cmdevtools.css
r147026 r147421 7 7 height: 100% !important; 8 8 } 9 10 .CodeMirror .source-frame-eval-expression { 11 outline: 0px; 12 border: 1px solid rgb(163, 41, 34); 13 border-left-width: 0px; 14 border-right-width: 0px; 15 } 16 17 .CodeMirror .source-frame-eval-expression-end { 18 border-right-width: 1px; 19 margin-right: -1px; 20 } 21 22 .CodeMirror .source-frame-eval-expression-start { 23 border-left-width: 1px; 24 margin-left: -1px; 25 } 26 9 27 10 28 .CodeMirror-linenumber {
Note: See TracChangeset
for help on using the changeset viewer.