Title: [147421] trunk/Source/WebCore
- Revision
- 147421
- Author
- [email protected]
- Date
- 2013-04-02 06:15:35 -0700 (Tue, 02 Apr 2013)
Log Message
Web Inspector: [CodeMirror] Popover for codemirror
https://bugs.webkit.org/show_bug.cgi?id=113771
Patch by Andrey Lushnikov <[email protected]> on 2013-04-02
Reviewed by Pavel Feldman.
Implement methods TextEditor.cursorPositionToCoordinates, TextEditor.coordinatesToCursorPosition and
TextEditor.tokenAtTextPosition in CodeMirrorTextEditor to support popover
functionality. Add css classes to highlight popover anchoring text.
No new tests.
* inspector/front-end/CodeMirrorTextEditor.js:
(WebInspector.CodeMirrorTextEditor.prototype.cursorPositionToCoordinates):
(WebInspector.CodeMirrorTextEditor.prototype.coordinatesToCursorPosition):
(WebInspector.CodeMirrorTextEditor.prototype.tokenAtTextPosition):
* inspector/front-end/cm/cmdevtools.css:
(.CodeMirror .source-frame-eval-_expression_):
(.CodeMirror .source-frame-eval-_expression_-end):
(.CodeMirror .source-frame-eval-_expression_-start):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (147420 => 147421)
--- trunk/Source/WebCore/ChangeLog 2013-04-02 12:56:29 UTC (rev 147420)
+++ trunk/Source/WebCore/ChangeLog 2013-04-02 13:15:35 UTC (rev 147421)
@@ -1,3 +1,25 @@
+2013-04-02 Andrey Lushnikov <[email protected]>
+
+ Web Inspector: [CodeMirror] Popover for codemirror
+ https://bugs.webkit.org/show_bug.cgi?id=113771
+
+ Reviewed by Pavel Feldman.
+
+ Implement methods TextEditor.cursorPositionToCoordinates, TextEditor.coordinatesToCursorPosition and
+ TextEditor.tokenAtTextPosition in CodeMirrorTextEditor to support popover
+ functionality. Add css classes to highlight popover anchoring text.
+
+ No new tests.
+
+ * inspector/front-end/CodeMirrorTextEditor.js:
+ (WebInspector.CodeMirrorTextEditor.prototype.cursorPositionToCoordinates):
+ (WebInspector.CodeMirrorTextEditor.prototype.coordinatesToCursorPosition):
+ (WebInspector.CodeMirrorTextEditor.prototype.tokenAtTextPosition):
+ * inspector/front-end/cm/cmdevtools.css:
+ (.CodeMirror .source-frame-eval-_expression_):
+ (.CodeMirror .source-frame-eval-_expression_-end):
+ (.CodeMirror .source-frame-eval-_expression_-start):
+
2013-04-02 Carlos Garcia Campos <[email protected]>
[BlackBerry] Implement ScrollingCoordinator::frameViewLayoutUpdated()
Modified: trunk/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js (147420 => 147421)
--- trunk/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js 2013-04-02 12:56:29 UTC (rev 147420)
+++ trunk/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js 2013-04-02 13:15:35 UTC (rev 147421)
@@ -92,6 +92,67 @@
WebInspector.CodeMirrorTextEditor.prototype = {
/**
+ * @param {number} lineNumber
+ * @param {number} column
+ * @return {?{x: number, y: number, height: number}}
+ */
+ cursorPositionToCoordinates: function(lineNumber, column)
+ {
+ if (lineNumber >= this._codeMirror.lineCount || column > this._codeMirror.getLine(lineNumber).length || lineNumber < 0 || column < 0)
+ return null;
+
+ var metrics = this._codeMirror.cursorCoords(CodeMirror.Pos(lineNumber, column));
+
+ return {
+ x: metrics.left,
+ y: metrics.top,
+ height: metrics.bottom - metrics.top
+ };
+ },
+
+ /**
+ * @param {number} x
+ * @param {number} y
+ * @return {?WebInspector.TextRange}
+ */
+ coordinatesToCursorPosition: function(x, y)
+ {
+ var element = document.elementFromPoint(x, y);
+ if (!element || !element.isSelfOrDescendant(this._codeMirror.getWrapperElement()))
+ return null;
+ var gutterBox = this._codeMirror.getGutterElement().boxInWindow();
+ if (x >= gutterBox.x && x <= gutterBox.x + gutterBox.width &&
+ y >= gutterBox.y && y <= gutterBox.y + gutterBox.height)
+ return null;
+ var coords = this._codeMirror.coordsChar({left: x, top: y});
+ ++coords.ch;
+ return this._toRange(coords, coords);
+ },
+
+ /**
+ * @param {number} lineNumber
+ * @param {number} column
+ * @return {?{startColumn: number, endColumn: number, token: string}}
+ */
+ tokenAtTextPosition: function(lineNumber, column)
+ {
+ if (lineNumber < 0 || lineNumber >= this._codeMirror.lineCount())
+ return null;
+ var token = this._codeMirror.getTokenAt(CodeMirror.Pos(lineNumber, column || 1));
+ if (!token || !token.type)
+ return null;
+ var convertedType = null;
+ if (token.type.startsWith("variable") || token.type.startsWith("property")) {
+ return {
+ startColumn: token.start,
+ endColumn: token.end - 1,
+ type: "_javascript_-ident"
+ };
+ }
+ return null;
+ },
+
+ /**
* @param {WebInspector.TextRange} textRange
* @return {string}
*/
Modified: trunk/Source/WebCore/inspector/front-end/cm/cmdevtools.css (147420 => 147421)
--- trunk/Source/WebCore/inspector/front-end/cm/cmdevtools.css 2013-04-02 12:56:29 UTC (rev 147420)
+++ trunk/Source/WebCore/inspector/front-end/cm/cmdevtools.css 2013-04-02 13:15:35 UTC (rev 147421)
@@ -7,6 +7,24 @@
height: 100% !important;
}
+.CodeMirror .source-frame-eval-_expression_ {
+ outline: 0px;
+ border: 1px solid rgb(163, 41, 34);
+ border-left-width: 0px;
+ border-right-width: 0px;
+}
+
+.CodeMirror .source-frame-eval-_expression_-end {
+ border-right-width: 1px;
+ margin-right: -1px;
+}
+
+.CodeMirror .source-frame-eval-_expression_-start {
+ border-left-width: 1px;
+ margin-left: -1px;
+}
+
+
.CodeMirror-linenumber {
padding-top: 1px !important;
min-width: 22px !important;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes