Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/253173

Change subject: RangeFix: Update from 0.1.1 to 0.1.2
......................................................................

RangeFix: Update from 0.1.1 to 0.1.2

Code style changes only.

Change-Id: Ifeb01821427ebcdf4c9f66f397f3fa028e7b6a72
---
M lib/rangefix/rangefix.js
1 file changed, 26 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/73/253173/1

diff --git a/lib/rangefix/rangefix.js b/lib/rangefix/rangefix.js
index 35c2b04..70f2f1b 100644
--- a/lib/rangefix/rangefix.js
+++ b/lib/rangefix/rangefix.js
@@ -1,8 +1,8 @@
 /*!
- * RangeFix v0.1.1
+ * RangeFix v0.1.2
  * https://github.com/edg2s/rangefix
  *
- * Copyright 2014 Ed Sanders.
+ * Copyright 2014-15 Ed Sanders.
  * Released under the MIT license
  */
 ( function () {
@@ -29,13 +29,14 @@
         *                  in these functions.
         */
        function isBroken() {
+               var boundingRect, p1, p2, t1, t2, range;
+
                if ( broken === undefined ) {
-                       var boundingRect,
-                               p1 = document.createElement( 'p' ),
-                               p2 = document.createElement( 'p' ),
-                               t1 = document.createTextNode( 'aa' ),
-                               t2 = document.createTextNode( 'aa' ),
-                               range = document.createRange();
+                       p1 = document.createElement( 'p' );
+                       p2 = document.createElement( 'p' );
+                       t1 = document.createTextNode( 'aa' );
+                       t2 = document.createTextNode( 'aa' );
+                       range = document.createRange();
 
                        broken = {};
 
@@ -69,6 +70,8 @@
         * @return {ClientRectList|ClientRect[]} ClientRectList or list of 
ClientRect objects describing range
         */
        rangeFix.getClientRects = function ( range ) {
+               var rects, endContainer, endOffset, partialRange;
+
                if ( !isBroken().getClientRects ) {
                        return range.getClientRects();
                }
@@ -78,10 +81,10 @@
                // we reach the common ancestor, then we can add on from start 
to where
                // we got up to
                // https://code.google.com/p/chromium/issues/detail?id=324437
-               var rects = [],
-                       endContainer = range.endContainer,
-                       endOffset = range.endOffset,
-                       partialRange = document.createRange();
+               rects = [];
+               endContainer = range.endContainer;
+               endOffset = range.endOffset;
+               partialRange = document.createRange();
 
                while ( endContainer !== range.commonAncestorContainer ) {
                        partialRange.setStart( endContainer, 0 );
@@ -109,7 +112,7 @@
         *                                  bounding rectangle, or null if not 
computable
         */
        rangeFix.getBoundingClientRect = function ( range ) {
-               var i, l, boundingRect,
+               var i, l, boundingRect, rect,
                        rects = this.getClientRects( range ),
                        nativeBoundingRect = range.getBoundingClientRect();
 
@@ -132,22 +135,23 @@
                // of the previous line when it is at the start of the line.
                // See 
https://code.google.com/p/chromium/issues/detail?id=426017
                if ( nativeBoundingRect.width === 0 && 
nativeBoundingRect.height === 0 ) {
-                       return rects[0];
+                       return rects[ 0 ];
                }
 
                for ( i = 0, l = rects.length; i < l; i++ ) {
+                       rect = rects[ i ];
                        if ( !boundingRect ) {
                                boundingRect = {
-                                       left: rects[i].left,
-                                       top: rects[i].top,
-                                       right: rects[i].right,
-                                       bottom: rects[i].bottom
+                                       left: rect.left,
+                                       top: rect.top,
+                                       right: rect.right,
+                                       bottom: rect.bottom
                                };
                        } else {
-                               boundingRect.left = Math.min( 
boundingRect.left, rects[i].left );
-                               boundingRect.top = Math.min( boundingRect.top, 
rects[i].top );
-                               boundingRect.right = Math.max( 
boundingRect.right, rects[i].right );
-                               boundingRect.bottom = Math.max( 
boundingRect.bottom, rects[i].bottom );
+                               boundingRect.left = Math.min( 
boundingRect.left, rect.left );
+                               boundingRect.top = Math.min( boundingRect.top, 
rect.top );
+                               boundingRect.right = Math.max( 
boundingRect.right, rect.right );
+                               boundingRect.bottom = Math.max( 
boundingRect.bottom, rect.bottom );
                        }
                }
                if ( boundingRect ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/253173
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifeb01821427ebcdf4c9f66f397f3fa028e7b6a72
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to