Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6312)

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js

Issue 2144593003: Merge dom node and node unit types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js
index 687128a094fe0660f376b9dd56251cb5ebb4e81f..ec46d11828f3308bd6e4b7046d193952eaabfa91 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js
@@ -209,9 +209,17 @@ AutomationUtil.getDirection = function(nodeA, nodeB) {
var divA = ancestorsA[divergence];
var divB = ancestorsB[divergence];
- // One of the nodes is an ancestor of the other. Don't distinguish and just
- // consider it Dir.FORWARD.
- if (!divA || !divB || divA.parent === nodeB || divB.parent === nodeA)
+ // One of the nodes is an ancestor of the other. Order this relationship in
+ // the same way dfs would. nodeA <= nodeB if nodeA is a descendant of
+ // nodeB. nodeA > nodeB if nodeB is a descendant of nodeA.
+
+ if (!divA)
+ return Dir.FORWARD;
+ if (!divB)
+ return Dir.BACKWARD;
+ if (divA.parent === nodeB)
+ return Dir.BACKWARD;
+ if (divB.parent === nodeA)
return Dir.FORWARD;
return divA.indexInParent <= divB.indexInParent ? Dir.FORWARD : Dir.BACKWARD;

Powered by Google App Engine
This is Rietveld 408576698