• 
      

    Scroll oversized images in the image review UI

    Review Request #8377 — Created Sept. 2, 2016 and submitted

    Information

    Review Board
    release-3.0.x
    2300cf1...

    Reviewers

    Previously, oversized images in the image review UI would cause them to
    overflow outside of the review box and increase the width of the page.
    Now, these images are confined to the width of the review box and will
    scroll horizontally when they are too large.

    • Created a review comment on an oversized image; it scrolled with the
      page.
    • Scrolled an oversized image and created a commment; it worked
      correctly and scrolled with the page.
    • Ensured the scroll bar only showed when images were oversized for the
      currently selected scale.
    Description From Last Updated

    Can you test scrolling and then adding a comment?

    daviddavid

    Should be in alphabetical order within the other classes.

    chipx86chipx86

    Since you're adding a new one, can you add docs to the doc comment? ("Model Attributes" section.)

    chipx86chipx86

    Two blank lines.

    chipx86chipx86

    Should be able to cleanly fit all these like: this.listenTo(this.model, 'change:scale', ...)

    chipx86chipx86

    Should be one statement, like before, since we're not chaining.

    chipx86chipx86

    This can be one statement.

    chipx86chipx86

    I really want to avoid using these. I know it's not the most popular opinion, but it ends up resulting …

    chipx86chipx86

    I also want to avoid using for of. This feels like a slim little useful statement, but balloons into a …

    chipx86chipx86

    Same as above. The spacing on either side of the text inside the <li> will be preserved, and we should …

    chipx86chipx86

    No need for the blank line here.

    chipx86chipx86

    This is left over.

    chipx86chipx86

    Trailing newline.

    chipx86chipx86

    We're doing a lot of mixing of local variable declarations and other code. Mind cleaning this up while here by …

    chipx86chipx86

    Might as well add a trailing comma here too.

    chipx86chipx86

    Let's add a trailing comma here, too, while we're at it.

    chipx86chipx86
    reviewbot
    1. Tool: Pyflakes
      Ignored Files:
          reviewboard/static/rb/css/pages/image-review-ui.less
          reviewboard/static/rb/js/views/imageReviewableView.es6.js
      
      
      
      Tool: PEP8 Style Checker
      Ignored Files:
          reviewboard/static/rb/css/pages/image-review-ui.less
          reviewboard/static/rb/js/views/imageReviewableView.es6.js
      
      
    2. 
        
    david
    1. I'd really like to see testing of commenting while scrolled and the display of the comment block outlines at various zoom/scroll combinations.

    2. 
        
    brennie
    reviewbot
    1. Tool: Pyflakes
      Processed Files:
          reviewboard/staticbundles.py
      
      Ignored Files:
          reviewboard/static/rb/css/pages/image-review-ui.less
          reviewboard/static/rb/js/views/regionCommentBlockView.es6.js
          reviewboard/static/rb/js/views/imageReviewableView.es6.js
          reviewboard/static/rb/js/models/imageReviewableModel.es6.js
      
      
      
      Tool: PEP8 Style Checker
      Processed Files:
          reviewboard/staticbundles.py
      
      Ignored Files:
          reviewboard/static/rb/css/pages/image-review-ui.less
          reviewboard/static/rb/js/views/regionCommentBlockView.es6.js
          reviewboard/static/rb/js/views/imageReviewableView.es6.js
          reviewboard/static/rb/js/models/imageReviewableModel.es6.js
      
      
    2. 
        
    chipx86
    1. 
        
    2. Show all issues

      Should be in alphabetical order within the other classes.

    3. Show all issues

      Since you're adding a new one, can you add docs to the doc comment? ("Model Attributes" section.)

    4. Show all issues

      Two blank lines.

    5. Show all issues

      Should be able to cleanly fit all these like:

      this.listenTo(this.model,
                    'change:scale',
                    ...)
      
    6. Show all issues

      Should be one statement, like before, since we're not chaining.

    7. Show all issues

      This can be one statement.

    8. Show all issues

      I really want to avoid using these. I know it's not the most popular opinion, but it ends up resulting in much larger strings, as we have no real control over where spaces and newlines live. All leading indentation ends up as part of the string. This cannot be minified out, resulting in larger JavaScript, and it's more content for the template parser to parse.

      Same below.

    9. Show all issues

      I also want to avoid using for of. This feels like a slim little useful statement, but balloons into a whole lot of very slow code that cannot be easily optimized out.

      This becomes:

      var _iteratorNormalCompletion = true;
      var _didIteratorError = false;
      var _iteratorError = undefined;
      
      try {
          for (var _iterator = scalingFactors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
              var _step$value = _slicedToArray(_step.value, 2);
      
              var scale = _step$value[0];
              var text = _step$value[1];
      
              $menu.append(...)
      
          }
      } catch (err) {
          _didIteratorError = true;
          _iteratorError = err;
      } finally {
          try {
              if (!_iteratorNormalCompletion && _iterator.return) {
                  _iterator.return();
              }
          } finally {
              if (_didIteratorError) {
                  throw _iteratorError;
              }
          }
      }
      
      1. Hmm, this is a Map, not a plain object, so we're limited here to this or .forEach(), which means a function call per iteration, which isn't as fast as a standard for loop either.

        Though, we have a function call anyway, because of iterator.next() and _slicedToArray. So maybe .forEach() is best here. Plus, it'd avoid the exceptions, which can impact optimization in some browsers (though I believe this is less of a problem in modern ones).

        (If only it could optimistically do a native for of...)

        From http://www.incaseofstairs.com/2015/06/es6-feature-performance/:

        for..of is universally slower, ranging from 3 to 20x slower for array iteration over classical array iteration. When iterating over an object with a custom iterator, the performance is also much slower than for..in iteration with hasOwnProperty checks.

    10. Show all issues

      Same as above. The spacing on either side of the text inside the <li> will be preserved, and we should avoid that.

      We should also be treating the text as unsafe HTML, in case we need to localize any of it down the road. (I could see options like "Fit to window".) Building as a jQuery is going to be safer here.

    11. Show all issues

      No need for the blank line here.

    12. Show all issues

      This is left over.

    13. 
        
    brennie
    reviewbot
    1. Tool: PEP8 Style Checker
      Processed Files:
          reviewboard/staticbundles.py
      
      Ignored Files:
          reviewboard/static/rb/css/pages/image-review-ui.less
          reviewboard/static/rb/js/models/imageReviewableModel.js
          reviewboard/static/rb/js/views/imageReviewableView.es6.js
          reviewboard/static/rb/js/models/imageReviewableModel.es6.js
          reviewboard/static/rb/js/views/regionCommentBlockView.es6.js
      
      
      
      Tool: Pyflakes
      Processed Files:
          reviewboard/staticbundles.py
      
      Ignored Files:
          reviewboard/static/rb/css/pages/image-review-ui.less
          reviewboard/static/rb/js/models/imageReviewableModel.js
          reviewboard/static/rb/js/views/imageReviewableView.es6.js
          reviewboard/static/rb/js/models/imageReviewableModel.es6.js
          reviewboard/static/rb/js/views/regionCommentBlockView.es6.js
      
      
    2. 
        
    chipx86
    1. Looks pretty good. A couple of small things and then I'm happy (and super looking forward to having this in!)

    2. Show all issues

      Trailing newline.

    3. reviewboard/static/rb/js/views/imageReviewableView.es6.js (Diff revision 3)
       
       
       
       
       
       
      Show all issues

      We're doing a lot of mixing of local variable declarations and other code. Mind cleaning this up while here by moving the this._max* into its own grouping after the consts?

    4. Show all issues

      Might as well add a trailing comma here too.

    5. Show all issues

      Let's add a trailing comma here, too, while we're at it.

    6. 
        
    brennie
    reviewbot
    1. Tool: PEP8 Style Checker
      Processed Files:
          reviewboard/staticbundles.py
      
      Ignored Files:
          reviewboard/static/rb/css/pages/image-review-ui.less
          reviewboard/static/rb/js/models/imageReviewableModel.js
          reviewboard/static/rb/js/views/imageReviewableView.es6.js
          reviewboard/static/rb/js/models/imageReviewableModel.es6.js
          reviewboard/static/rb/js/views/regionCommentBlockView.es6.js
      
      
      
      Tool: Pyflakes
      Processed Files:
          reviewboard/staticbundles.py
      
      Ignored Files:
          reviewboard/static/rb/css/pages/image-review-ui.less
          reviewboard/static/rb/js/models/imageReviewableModel.js
          reviewboard/static/rb/js/views/imageReviewableView.es6.js
          reviewboard/static/rb/js/models/imageReviewableModel.es6.js
          reviewboard/static/rb/js/views/regionCommentBlockView.es6.js
      
      
    2. 
        
    david
    1. This should really be broken up into two (or three) changes. Only two lines in one file relate to scrolling, and the rest is all the model attribute change and style cleanup.

    2. Show all issues

      Can you test scrolling and then adding a comment?

    3. 
        
    brennie
    reviewbot
    1. Tool: PEP8 Style Checker
      Ignored Files:
          reviewboard/static/rb/css/pages/image-review-ui.less
          reviewboard/static/rb/js/views/imageReviewableView.es6.js
      
      
      
      Tool: Pyflakes
      Ignored Files:
          reviewboard/static/rb/css/pages/image-review-ui.less
          reviewboard/static/rb/js/views/imageReviewableView.es6.js
      
      
    2. 
        
    david
    1. Ship It!
    2. 
        
    brennie
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-3.0.x (eb14738)