Index: chrome/browser/resources/chromeos/chromevox/common/dom_util.js |
diff --git a/chrome/browser/resources/chromeos/chromevox/common/dom_util.js b/chrome/browser/resources/chromeos/chromevox/common/dom_util.js |
index 14df858e64f89dc9d52a08215ef797b8b113205f..6f9ba4add259e7f2fbef60755eec61d5deca8143 100644 |
--- a/chrome/browser/resources/chromeos/chromevox/common/dom_util.js |
+++ b/chrome/browser/resources/chromeos/chromevox/common/dom_util.js |
@@ -193,7 +193,8 @@ cvox.DomUtil.computeIsVisible_ = function( |
/** |
* Checks the ancestor chain for the given node for invisibility. If an |
* ancestor is invisible and this cannot be overriden by a descendant, |
- * we return true. |
+ * we return true. If the element is not a descendant of the document |
+ * element it will return true (invisible). |
* @param {Node} node The node to check the ancestor chain for. |
* @return {boolean} True if a descendant is invisible. |
* @private |
@@ -205,8 +206,15 @@ cvox.DomUtil.hasInvisibleAncestor_ = function(node) { |
if (cvox.DomUtil.isInvisibleStyle(style, true)) { |
return true; |
} |
+ // Once we reach the document element and we haven't found anything |
+ // invisible yet, we're done. If we exit the while loop and never found |
+ // the document element, the element wasn't part of the DOM and thus it's |
+ // invisible. |
+ if (ancestor == document.documentElement) { |
+ return false; |
+ } |
} |
- return false; |
+ return true; |
}; |