From dcc7e1ff5ae28b700e12ecf75d403001fc9c2152 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Sat, 6 Dec 2014 21:58:04 +0000 Subject: Only consider fullscreen elements' children for link hints --- lib/dom_utils.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 21018049..5f316c08 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -33,13 +33,13 @@ DomUtils = makeXPath: (elementArray) -> xpath = [] for element in elementArray - xpath.push("//" + element, "//xhtml:" + element) + xpath.push(".//" + element, ".//xhtml:" + element) xpath.join(" | ") - evaluateXPath: (xpath, resultType) -> + evaluateXPath: (xpath, resultType, contextNode = document.documentElement) -> namespaceResolver = (namespace) -> if (namespace == "xhtml") then "http://www.w3.org/1999/xhtml" else null - document.evaluate(xpath, document.documentElement, namespaceResolver, resultType, null) + document.evaluate(xpath, contextNode, namespaceResolver, resultType, null) # # Returns the first visible clientRect of an element if it exists. Otherwise it returns null. -- cgit v1.2.3 From 4837af619b39e92b0eacd082867ba6b139875ba5 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 15 Dec 2014 00:07:35 +0000 Subject: Restrict evaluateXPath to the fullscreen element when fullscreen --- lib/dom_utils.coffee | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 5f316c08..95427903 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -36,7 +36,13 @@ DomUtils = xpath.push(".//" + element, ".//xhtml:" + element) xpath.join(" | ") - evaluateXPath: (xpath, resultType, contextNode = document.documentElement) -> + # Evaluates an XPath on the whole document, or on the contents of the fullscreen element if an element is + # fullscreen. + evaluateXPath: (xpath, resultType) -> + contextNode = if document.webkitIsFullScreen + document.webkitFullscreenElement + else + document.documentElement namespaceResolver = (namespace) -> if (namespace == "xhtml") then "http://www.w3.org/1999/xhtml" else null document.evaluate(xpath, contextNode, namespaceResolver, resultType, null) -- cgit v1.2.3