From f97666315006ee30f9e773ae7c6072b64b563ac5 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 29 Jul 2012 15:04:40 +0400 Subject: [PATCH] remove redundant getRowHeight method --- lib/ace/edit_session.js | 14 +------------- lib/ace/layer/gutter.js | 2 +- lib/ace/test/mockrenderer.js | 4 ++-- lib/ace/virtual_renderer.js | 10 +++++----- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index b903356a..144f2aff 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -2029,7 +2029,7 @@ var EditSession = function(text, mode) { * - row (Number): The row number to check * * - * Returns the length of the indicated row. + * Returns number of screenrows in a wrapped line. **/ this.getRowLength = function(row) { if (!this.$useWrapMode || !this.$wrapData[row]) { @@ -2039,18 +2039,6 @@ var EditSession = function(text, mode) { } }; - /** - * EditSession.getRowHeight(config, row) -> Number - * - config (Object): An object containing a parameter indicating the `lineHeight`. - * - row (Number): The row number to check - * - * Returns the height of the indicated row. This is mostly relevant for situations where wrapping occurs, and a single line spans across multiple rows. - * - **/ - this.getRowHeight = function(config, row) { - return this.getRowLength(row) * config.lineHeight; - }; - /** internal, hide, related to: EditSession.documentToScreenColumn * EditSession.getScreenLastRowColumn(screenRow) -> Number * - screenRow (Number): The screen row to check diff --git a/lib/ace/layer/gutter.js b/lib/ace/layer/gutter.js index d30c4ba3..2bf3bc53 100644 --- a/lib/ace/layer/gutter.js +++ b/lib/ace/layer/gutter.js @@ -129,7 +129,7 @@ var Gutter = function(parentEl) { breakpoints[i] ? " ace_breakpoint " : " ", annotation.className, "' title='", annotation.text.join("\n"), - "' style='height:", this.session.getRowLength(i) * config.lineHeight, "px;'>", (i+1)); + "' style='height:", this.session.getRowLength(i) * config.lineHeight, "px;'>", (i)); if (foldWidgets) { var c = foldWidgets[i]; diff --git a/lib/ace/test/mockrenderer.js b/lib/ace/test/mockrenderer.js index 4e5c515d..91b1c1ad 100644 --- a/lib/ace/test/mockrenderer.js +++ b/lib/ace/test/mockrenderer.js @@ -115,10 +115,10 @@ MockRenderer.prototype.scrollToX = function(scrollTop) {}; MockRenderer.prototype.scrollToY = function(scrollLeft) {}; MockRenderer.prototype.scrollToLine = function(line, center) { - var lineHeight = { lineHeight: 16 }; + var lineHeight = 16; var row = 0; for (var l = 1; l < line; l++) { - row += this.session.getRowHeight(lineHeight, l-1) / lineHeight.lineHeight; + row += this.session.getRowLength(l-1); } if (center) { diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index b9abc187..6a6dae4b 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -775,7 +775,7 @@ var VirtualRenderer = function(container, theme) { // Map lines on the screen to lines in the document. var firstRowScreen, firstRowHeight; - var lineHeight = { lineHeight: this.lineHeight }; + var lineHeight = this.lineHeight; firstRow = session.screenToDocumentRow(firstRow, 0); // Check if firstRow is inside of a foldLine. If true, then use the first @@ -786,13 +786,13 @@ var VirtualRenderer = function(container, theme) { } firstRowScreen = session.documentToScreenRow(firstRow, 0); - firstRowHeight = session.getRowHeight(lineHeight, firstRow); + firstRowHeight = session.getRowLength(firstRow) * lineHeight; lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1); - minHeight = this.$size.scrollerHeight + session.getRowHeight(lineHeight, lastRow)+ + minHeight = this.$size.scrollerHeight + session.getRowLength(lastRow) * lineHeight + firstRowHeight; - offset = this.scrollTop - firstRowScreen * this.lineHeight; + offset = this.scrollTop - firstRowScreen * lineHeight; this.layerConfig = { width : longestLine, @@ -800,7 +800,7 @@ var VirtualRenderer = function(container, theme) { firstRow : firstRow, firstRowScreen: firstRowScreen, lastRow : lastRow, - lineHeight : this.lineHeight, + lineHeight : lineHeight, characterWidth : this.characterWidth, minHeight : minHeight, maxHeight : maxHeight,