2011-01-14 Ojan Vafai <ojan@chromium.org>
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Jan 2011 22:13:36 +0000 (22:13 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Jan 2011 22:13:36 +0000 (22:13 +0000)
        Reviewed by Adam Barth.

        improve line selection with fast drags
        https://bugs.webkit.org/show_bug.cgi?id=52477

        * code-review.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@75817 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/bugs.webkit.org/ChangeLog
Websites/bugs.webkit.org/code-review.js

index 782ab8e6aa6742d48698afcdb9f95b1c9ac9171a..27f01e4853e933f3d0d8a41dc9d4b82fbae567eb 100644 (file)
@@ -1,3 +1,12 @@
+2011-01-14  Ojan Vafai  <ojan@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        improve line selection with fast drags
+        https://bugs.webkit.org/show_bug.cgi?id=52477
+
+        * code-review.js:
+
 2011-01-14  Ojan Vafai  <ojan@chromium.org>
 
         Reviewed by Adam Barth.
 2011-01-14  Ojan Vafai  <ojan@chromium.org>
 
         Reviewed by Adam Barth.
index 3555784dff882cdadb5c154429a502cafe0a7cac..8ab7899d677437a382a949ccaa79814e1e3a7412 100644 (file)
   }
 
   $('.lineNumber').live('click', function() {
   }
 
   $('.lineNumber').live('click', function() {
-    var line = $(this).parents('.Line');
+    var line = lineFromLineDescendant($(this));
     if (line.hasClass('commentContext'))
       trimCommentContextToBefore(previousLineFor(line), line.attr('data-comment-base-line'));
   }).live('mousedown', function() {
     in_drag_select = true;
     if (line.hasClass('commentContext'))
       trimCommentContextToBefore(previousLineFor(line), line.attr('data-comment-base-line'));
   }).live('mousedown', function() {
     in_drag_select = true;
-    $(lineFromLineDescendant(this)).addClass('selected');
+    lineFromLineDescendant($(this)).addClass('selected');
     event.preventDefault();
   });
 
     event.preventDefault();
   });
 
       return;
 
     var selected = $('.selected');
       return;
 
     var selected = $('.selected');
+
+    // Select all the lines between the first and last selected lines
+    // in case we didn't get mouseenter events for any of them.
+    var current_index = numberFrom(selected.first().attr('id'));
+    var last_index = numberFrom(selected.last().attr('id'));
+    while (current_index != last_index) {
+      $('#line' + current_index).addClass('selected')
+      current_index++;
+    }
+
+    selected = $('.selected');
     var already_has_comment = selected.last().hasClass('commentContext');
     selected.addClass('commentContext');
 
     var already_has_comment = selected.last().hasClass('commentContext');
     selected.addClass('commentContext');
 
     if (already_has_comment)
       comment_base_line = selected.last().attr('data-comment-base-line');
     else {
     if (already_has_comment)
       comment_base_line = selected.last().attr('data-comment-base-line');
     else {
-      var last = lineFromLineDescendant(selected.last()[0]);
+      var last = lineFromLineDescendant(selected.last());
       addCommentFor($(last));
       comment_base_line = last.id;
     }
       addCommentFor($(last));
       comment_base_line = last.id;
     }
   }
 
   function lineFromLineDescendant(descendant) {
   }
 
   function lineFromLineDescendant(descendant) {
-    while (descendant && !$(descendant).hasClass('Line')) {
-      descendant = descendant.parentNode;
-    }
-    return descendant;
+    return descendant.hasClass('Line') ? descendant : descendant.parents('.Line');
   }
 
   function lineFromLineContainer(lineContainer) {
   }
 
   function lineFromLineContainer(lineContainer) {