From 158b3f09fd222b0e93510dc17521833de73bcf88 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Wed, 17 Dec 2014 13:49:29 +0000 Subject: Unify two loops into one --- lib/dom_utils.coffee | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'lib') 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 @@ -51,20 +51,6 @@ DomUtils = width: clientRect.width, height: clientRect.height } 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. @@ -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) -> -- cgit v1.2.3