From 56ba56622c529d570285f42732f4f1ed29830987 Mon Sep 17 00:00:00 2001
From: mrmr1993
Date: Mon, 22 Dec 2014 11:51:06 +0000
Subject: Support small s with link hints
This is primarily to deal with our calculated rects being too small for
the `` on
http://www.mapsofindia.com/worldmap/clickable-world-map.html
---
lib/dom_utils.coffee | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index 7fd126b8..8bb099a1 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -59,13 +59,13 @@ DomUtils =
continue if (computedStyle.getPropertyValue('float') == 'none' &&
computedStyle.getPropertyValue('position') != 'absolute')
childClientRect = @getVisibleClientRect(child)
- continue if (childClientRect == null)
+ continue if clientRect == null
return childClientRect
else
clientRect = @cropRectToVisible clientRect
- continue unless clientRect
+ continue if clientRect == null or clientRect.width < 3 or clientRect.height < 3
# eliminate invisible elements (see test_harnesses/visibility_test.html)
computedStyle = window.getComputedStyle(element, null)
@@ -83,12 +83,12 @@ DomUtils =
#
cropRectToVisible: (rect) ->
boundedRect = Rect.create(
- Math.max(rect.left, 0),
- Math.max(rect.top, 0),
- Math.min(rect.right, window.innerWidth),
- Math.min(rect.bottom, window.innerHeight)
+ Math.max(rect.left, 0)
+ Math.max(rect.top, 0)
+ rect.right
+ rect.bottom
)
- if boundedRect.width < 3 or boundedRect.height < 3
+ if boundedRect.top >= window.innerHeight - 4 or boundedRect.left >= window.innerWidth - 4
null
else
boundedRect
--
cgit v1.2.3
From 15d094675c4e354becf58b5f66754dd939d5daeb Mon Sep 17 00:00:00 2001
From: mrmr1993
Date: Mon, 22 Dec 2014 11:54:49 +0000
Subject: Rename a poorly named variable
---
content_scripts/link_hints.coffee | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 9eb7b87c..616d40ee 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -149,8 +149,8 @@ LinkHints =
map = document.querySelector "map[name=\"#{mapName}\"]"
if map and imgClientRects.length > 0
areas = map.getElementsByTagName "area"
- areaRects = DomUtils.getClientRectsForAreas imgClientRects[0], areas
- visibleElements = visibleElements.concat areaRects
+ areasAndRects = DomUtils.getClientRectsForAreas imgClientRects[0], areas
+ visibleElements = visibleElements.concat areasAndRects
# Check aria properties to see if the element should be ignored.
if (element.getAttribute("aria-hidden")?.toLowerCase() in ["", "true"] or
--
cgit v1.2.3
From 76af56da84753163adc4dbf943374a10f0cb8321 Mon Sep 17 00:00:00 2001
From: mrmr1993
Date: Mon, 22 Dec 2014 11:56:18 +0000
Subject: Use push with a splat rather than concat
---
content_scripts/link_hints.coffee | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 616d40ee..c4bf3f96 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -150,7 +150,7 @@ LinkHints =
if map and imgClientRects.length > 0
areas = map.getElementsByTagName "area"
areasAndRects = DomUtils.getClientRectsForAreas imgClientRects[0], areas
- visibleElements = visibleElements.concat areasAndRects
+ visibleElements.push areasAndRects...
# Check aria properties to see if the element should be ignored.
if (element.getAttribute("aria-hidden")?.toLowerCase() in ["", "true"] or
--
cgit v1.2.3