/// <summary>
        /// Expands a range to the safest outter tags that can be contained without encompassing
        /// text that is not currently in this range.
        /// </summary>
        /// <param name="range"></param>
        private void SelectOuter(MarkupRange range)
        {
            IHTMLElement parent        = range.ParentElement();
            MarkupRange  editableRange = MarkupHelpers.GetEditableRange(parent, MarkupServices);

            if (editableRange == null)
            {
                return;
            }

            while (parent != null && range.MoveOutwardIfNoContent())
            {
                parent = range.Start.CurrentScope;
            }

            if (range.Start.IsLeftOf(editableRange.Start))
            {
                range.Start.MoveToPointer(editableRange.Start);
            }
            if (range.End.IsRightOf(editableRange.End))
            {
                range.End.MoveToPointer(editableRange.End);
            }
            return;
        }
        private bool IsEditableSelection()
        {
            MarkupRange selectedRange = SelectedMarkupRange;

            if (MarkupHelpers.GetEditableRange(selectedRange.Start.CurrentScope, MarkupServices) != null)
            {
                if (selectedRange.IsEmpty() || MarkupHelpers.GetEditableRange(selectedRange.Start.CurrentScope, MarkupServices) != null)
                {
                    return(true);
                }
            }
            return(false);
        }
        private MarkupRange AdjustSelection()
        {
            MarkupRange selection = CreateMaxSafeRange(SelectedMarkupRange);

            if (selection.IsEmpty())
            {
                MarkupRange editableRange = MarkupHelpers.GetEditableRange(selection.Start.CurrentScope, MarkupServices);
                MarkupPointerMoveHelper.MoveUnitBounded(selection.Start,
                                                        MarkupPointerMoveHelper.MoveDirection.LEFT,
                                                        MarkupPointerAdjacency.BeforeVisible | MarkupPointerAdjacency.BeforeEnterScope,
                                                        editableRange.Start);
                selection.Collapse(true);
            }
            selection.ToTextRange().select();
            return(selection);
        }