diff options
| author | mrmr1993 | 2014-12-17 13:49:29 +0000 | 
|---|---|---|
| committer | mrmr1993 | 2014-12-17 13:49:29 +0000 | 
| commit | 158b3f09fd222b0e93510dc17521833de73bcf88 (patch) | |
| tree | 69928fa81ef285ad588db5371bc64ba8a8c2456c | |
| parent | 833942ae06f680bc1949a7bced4719b707950568 (diff) | |
| download | vimium-158b3f09fd222b0e93510dc17521833de73bcf88.tar.bz2 | |
Unify two loops into one
| -rw-r--r-- | lib/dom_utils.coffee | 29 | 
1 files changed, 15 insertions, 14 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 1e2cc812..aaa93923 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -52,20 +52,6 @@ DomUtils =      } for clientRect in element.getClientRects())      for clientRect in clientRects -      clientRect = @cropRectToVisible clientRect - -      if (!clientRect || clientRect.width < 3 || clientRect.height < 3) -        continue - -      # eliminate invisible elements (see test_harnesses/visibility_test.html) -      computedStyle = window.getComputedStyle(element, null) -      if (computedStyle.getPropertyValue('visibility') != 'visible' || -          computedStyle.getPropertyValue('display') == 'none') -        continue - -      return clientRect - -    for clientRect in clientRects        # If the link has zero dimensions, it may be wrapping visible        # but floated elements. Check for this.        if (clientRect.width == 0 || clientRect.height == 0) @@ -78,6 +64,21 @@ DomUtils =            childClientRect = @getVisibleClientRect(child)            continue if (childClientRect == null)            return childClientRect + +      else +        clientRect = @cropRectToVisible clientRect + +        if (!clientRect || clientRect.width < 3 || clientRect.height < 3) +          continue + +        # eliminate invisible elements (see test_harnesses/visibility_test.html) +        computedStyle = window.getComputedStyle(element, null) +        if (computedStyle.getPropertyValue('visibility') != 'visible' || +            computedStyle.getPropertyValue('display') == 'none') +          continue + +        return clientRect +      null    cropRectToVisible: (rect) ->  | 
