internal static Focusable GetPreviousFocusableInTree(VisualElement currentFocusable)
        {
            if (currentFocusable == null)
            {
                return(null);
            }

            VisualElement ve = currentFocusable.GetPreviousElementDepthFirst();

            while (!ve.canGrabFocus || ve.tabIndex < 0 || ve.excludeFromFocusRing)
            {
                ve = ve.GetPreviousElementDepthFirst();

                if (ve == null)
                {
                    // continue at the end
                    ve = currentFocusable.GetRoot();
                    while (ve.childCount > 0)
                    {
                        ve = ve.hierarchy.ElementAt(ve.childCount - 1);
                    }
                }

                if (ve == currentFocusable)
                {
                    // We went through the whole tree and did not find anything.
                    return(currentFocusable);
                }
            }

            return(ve);
        }
        internal static Focusable GetPreviousFocusableInTree(VisualElement currentFocusable)
        {
            bool      flag = currentFocusable == null;
            Focusable result;

            if (flag)
            {
                result = null;
            }
            else
            {
                VisualElement visualElement = currentFocusable.GetPreviousElementDepthFirst();
                while (!visualElement.canGrabFocus || visualElement.tabIndex < 0 || visualElement.excludeFromFocusRing)
                {
                    visualElement = visualElement.GetPreviousElementDepthFirst();
                    bool flag2 = visualElement == null;
                    if (flag2)
                    {
                        visualElement = currentFocusable.GetRoot();
                        while (visualElement.childCount > 0)
                        {
                            visualElement = visualElement.hierarchy.ElementAt(visualElement.childCount - 1);
                        }
                    }
                    bool flag3 = visualElement == currentFocusable;
                    if (flag3)
                    {
                        result = currentFocusable;
                        return(result);
                    }
                }
                result = visualElement;
            }
            return(result);
        }
        internal static Focusable GetNextFocusableInTree(VisualElement currentFocusable)
        {
            if (currentFocusable == null)
            {
                return(null);
            }

            VisualElement ve = currentFocusable.GetNextElementDepthFirst();

            while (!ve.canGrabFocus || ve.tabIndex < 0 || ve.excludeFromFocusRing)
            {
                ve = ve.GetNextElementDepthFirst();

                if (ve == null)
                {
                    // continue at the beginning
                    ve = currentFocusable.GetRoot();
                }

                if (ve == currentFocusable)
                {
                    // We went through the whole tree and did not find anything.
                    return(currentFocusable);
                }
            }

            return(ve);
        }
        internal static Focusable GetNextFocusableInTree(VisualElement currentFocusable)
        {
            bool      flag = currentFocusable == null;
            Focusable result;

            if (flag)
            {
                result = null;
            }
            else
            {
                VisualElement nextElementDepthFirst = currentFocusable.GetNextElementDepthFirst();
                while (!nextElementDepthFirst.canGrabFocus || nextElementDepthFirst.tabIndex < 0 || nextElementDepthFirst.excludeFromFocusRing)
                {
                    nextElementDepthFirst = nextElementDepthFirst.GetNextElementDepthFirst();
                    bool flag2 = nextElementDepthFirst == null;
                    if (flag2)
                    {
                        nextElementDepthFirst = currentFocusable.GetRoot();
                    }
                    bool flag3 = nextElementDepthFirst == currentFocusable;
                    if (flag3)
                    {
                        result = currentFocusable;
                        return(result);
                    }
                }
                result = nextElementDepthFirst;
            }
            return(result);
        }