/// <summary>
        /// Returns true if this range is composes entirely of non-visible elements.
        /// </summary>
        /// <param name="inScopeContextsOnly">flag to ignore out of scope element
        /// (use false unless you absolutely want to ignore visible content in cases like
        ///  [start]&lt;p&gt;[end]&lt;/p&gt;)</param>
        /// <returns></returns>
        public bool IsEmptyOfContent(bool inScopeContextsOnly)
        {
            try
            {
                bool isEmptyOfContent = true;

                WalkRange(
                    delegate(MarkupRange currentRange, MarkupContext context, string text)
                {
                    text = text ?? string.Empty;
                    if (!String.IsNullOrEmpty(text.Trim()))
                    {
                        isEmptyOfContent = false;
                        return(false);
                    }

                    if (context.Element != null && ElementFilters.IsVisibleEmptyElement(context.Element))
                    {
                        isEmptyOfContent = false;
                        return(false);
                    }

                    // Continue walking the range.
                    return(true);
                },
                    inScopeContextsOnly);

                return(isEmptyOfContent);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #2
0
 private static MoveFilterResult StopBeforeVisible(MarkupContext mc)
 {
     if (mc.Context == _MARKUP_CONTEXT_TYPE.CONTEXT_TYPE_Text)
     {
         return(MoveFilterResult.STOP_BACK);
     }
     if (mc.Element != null && ElementFilters.IsInlineElement(mc.Element) && !ElementFilters.IsVisibleEmptyElement(mc.Element))
     {
         return(MoveFilterResult.CONTINUE);
     }
     return(MoveFilterResult.STOP_BACK);
 }