Changeset 147322 in webkit
- Timestamp:
- Apr 1, 2013 5:52:13 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r147320 r147322 1 2013-04-01 Andrey Lushnikov <lushnikov@chromium.org> 2 3 Web Inspector: [DTE] Convertion between text and coordinates 4 https://bugs.webkit.org/show_bug.cgi?id=113389 5 6 Reviewed by Pavel Feldman. 7 8 Test to verify added functionality. 9 10 * inspector/editor/text-editor-char-to-coordinates-expected.txt: Added. 11 * inspector/editor/text-editor-char-to-coordinates.html: Added. 12 1 13 2013-04-01 Shinya Kawanaka <shinyak@chromium.org> 2 14 -
trunk/Source/WebCore/ChangeLog
r147321 r147322 1 2013-04-01 Andrey Lushnikov <lushnikov@chromium.org> 2 3 Web Inspector: [DTE] Convertion between text and coordinates 4 https://bugs.webkit.org/show_bug.cgi?id=113389 5 6 Reviewed by Pavel Feldman. 7 8 Test: inspector/editor/text-editor-char-to-coordinates.html 9 10 Implement cursorPositionToCoordinates and coordinatesToCursorPosition 11 methods pair in DefaultTextEditor. 12 13 * inspector/front-end/DefaultTextEditor.js: 14 (WebInspector.DefaultTextEditor.prototype.cursorPositionToCoordinates): 15 (WebInspector.DefaultTextEditor.prototype.coordinatesToCursorPosition): 16 (WebInspector.TextEditorMainPanel.prototype.cursorPositionToCoordinates): 17 (WebInspector.TextEditorMainPanel.prototype.coordinatesToCursorPosition): 18 * inspector/front-end/TextEditor.js: 19 (WebInspector.TextEditor.prototype.cursorPositionToCoordinates): 20 (WebInspector.TextEditor.prototype.coordinatesToCursorPosition): 21 1 22 2013-04-01 Sergey Ryazanov <serya@chromium.org> 2 23 -
trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js
r147095 r147322 133 133 }, 134 134 135 /* 136 * @param {number} lineNumber 137 * @param {number} column 138 * @return {?{x: number, y: number, height: number}} 139 */ 140 cursorPositionToCoordinates: function(lineNumber, column) 141 { 142 return this._mainPanel.cursorPositionToCoordinates(lineNumber, column); 143 }, 144 145 /** 146 * @param {number} x 147 * @param {number} y 148 * @return {?WebInspector.TextRange} 149 */ 150 coordinatesToCursorPosition: function(x, y) 151 { 152 return this._mainPanel.coordinatesToCursorPosition(x, y); 153 }, 154 135 155 /** 136 156 * @param {WebInspector.TextRange} range … … 1448 1468 } 1449 1469 return null; 1470 }, 1471 1472 /** 1473 * @param {number} lineNumber 1474 * @param {number} column 1475 * @return {?{x: number, y: number, height: number}} 1476 */ 1477 cursorPositionToCoordinates: function(lineNumber, column) 1478 { 1479 if (lineNumber >= this._textModel.linesCount || lineNumber < 0) 1480 return null; 1481 var line = this._textModel.line(lineNumber); 1482 if (column > line.length || column < 0) 1483 return null; 1484 1485 var chunk = this.chunkForLine(lineNumber); 1486 if (!chunk.expanded()) 1487 return null; 1488 var lineRow = chunk.expandedLineRow(lineNumber); 1489 var ranges = [{ 1490 startColumn: column, 1491 endColumn: column, 1492 token: "measure-cursor-position" 1493 }]; 1494 var selection = this.selection(); 1495 1496 this.beginDomUpdates(); 1497 this._renderRanges(lineRow, line, ranges); 1498 var spans = lineRow.getElementsByClassName("webkit-measure-cursor-position"); 1499 if (WebInspector.debugDefaultTextEditor) 1500 console.assert(spans.length === 0); 1501 var totalOffset = spans[0].totalOffset(); 1502 var height = spans[0].offsetHeight; 1503 this._paintLineRows([lineRow]); 1504 this.endDomUpdates(); 1505 1506 this._restoreSelection(selection); 1507 return { 1508 x: totalOffset.left, 1509 y: totalOffset.top, 1510 height: height 1511 }; 1512 }, 1513 1514 /** 1515 * @param {number} x 1516 * @param {number} y 1517 * @return {?WebInspector.TextRange} 1518 */ 1519 coordinatesToCursorPosition: function(x, y) 1520 { 1521 var element = document.elementFromPoint(x, y); 1522 if (!element) 1523 return null; 1524 var lineRow = element.enclosingNodeOrSelfWithClass("webkit-line-content"); 1525 if (!lineRow) 1526 return null; 1527 1528 var line = this._textModel.line(lineRow.lineNumber) + " "; 1529 var ranges = []; 1530 const prefix = "character-position-"; 1531 for(var i = 0; i < line.length; ++i) { 1532 ranges.push({ 1533 startColumn: i, 1534 endColumn: i, 1535 token: prefix + i 1536 }); 1537 } 1538 1539 var selection = this.selection(); 1540 1541 this.beginDomUpdates(); 1542 this._renderRanges(lineRow, line, ranges); 1543 var charElement = document.elementFromPoint(x, y); 1544 this._paintLineRows([lineRow]); 1545 this.endDomUpdates(); 1546 1547 this._restoreSelection(selection); 1548 var className = charElement.className; 1549 if (className.indexOf(prefix) < 0) 1550 return null; 1551 var column = parseInt(className.substring(className.indexOf(prefix) + prefix.length), 10); 1552 1553 return WebInspector.TextRange.createFromLocation(lineRow.lineNumber, column); 1450 1554 }, 1451 1555 -
trunk/Source/WebCore/inspector/front-end/TextEditor.js
r147030 r147322 46 46 47 47 markClean: function() { }, 48 49 /* 50 * @param {number} lineNumber 51 * @param {number} column 52 * @return {?{x: number, y: number, height: number}} 53 */ 54 cursorPositionToCoordinates: function(lineNumber, column) { }, 55 56 /** 57 * @param {number} x 58 * @param {number} y 59 * @return {?WebInspector.TextRange} 60 */ 61 coordinatesToCursorPosition: function(x, y) { }, 62 48 63 /** 49 64 * @param {number} lineNumber
Note: See TracChangeset
for help on using the changeset viewer.