From 7f4c52353549659c0686ef1d0a2b968168a95ff0 Mon Sep 17 00:00:00 2001 From: fukino Date: Wed, 26 Aug 2015 21:20:43 -0700 Subject: [PATCH] Files.app: Consider RTL to calculate hit elements of drag selection. BUG=476425 TEST=manually Review URL: https://codereview.chromium.org/1313343002 Cr-Commit-Position: refs/heads/master@{#345791} --- .../file_manager/foreground/js/ui/file_grid.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/ui/file_manager/file_manager/foreground/js/ui/file_grid.js b/ui/file_manager/file_manager/foreground/js/ui/file_grid.js index 1aa23906afcb..cb0b9e2b4244 100644 --- a/ui/file_manager/file_manager/foreground/js/ui/file_grid.js +++ b/ui/file_manager/file_manager/foreground/js/ui/file_grid.js @@ -98,9 +98,16 @@ FileGrid.decorate = function( new AsyncUtil.RateLimiter(self.relayoutImmediately_.bind(self)); var style = window.getComputedStyle(self); - /** @private {number} */ - self.paddingLeft_ = parseFloat(style.paddingLeft); - /** @private {number} */ + /** + * @private {number} + * @const + */ + self.paddingStart_ = parseFloat( + isRTL() ? style.paddingRight : style.paddingLeft); + /** + * @private {number} + * @const + */ self.paddingTop_ = parseFloat(style.paddingTop); }; @@ -833,15 +840,16 @@ FileGrid.prototype.getHitColumnIndex_ = function(x, reverse) { */ FileGrid.prototype.getHitElements = function(x, y, opt_width, opt_height) { var currentSelection = []; - var left = Math.max(0, x - this.paddingLeft_); + var startXWithPadding = isRTL() ? this.clientWidth - (x + opt_width) : x; + var startX = Math.max(0, startXWithPadding - this.paddingStart_); + var endX = startX + (opt_width ? opt_width - 1 : 0); var top = Math.max(0, y - this.paddingTop_); - var right = left + (opt_width ? opt_width - 1 : 0); var bottom = top + (opt_height ? opt_height - 1 : 0); var firstRow = this.getHitRowIndex_(top, false); var lastRow = this.getHitRowIndex_(bottom, true); - var firstColumn = this.getHitColumnIndex_(left, false); - var lastColumn = this.getHitColumnIndex_(right, true); + var firstColumn = this.getHitColumnIndex_(startX, false); + var lastColumn = this.getHitColumnIndex_(endX, true); for (var row = firstRow; row <= lastRow; row++) { for (var col = firstColumn; col <= lastColumn; col++) { -- 2.11.4.GIT