private void Remove(HighlightInfoList list, DomElement element) { for (int iCount = list.Count - 1; iCount >= 0; iCount--) { HighlightInfo info = list[iCount]; bool delete = false; if (info.OwnerElement == element) { delete = true; } else if (info.OwnerElement != null && info.OwnerElement.IsParentOrSupParent(element)) { delete = true; } if (delete) { if (info.Range != null) { this.Document.InvalidateView(info.Range); } list.RemoveAt(iCount); } }//for }
/// <summary> /// 声明指定的元素相关的高亮度显示区域无效,需要重新设置 /// </summary> /// <param name="element">文档元素对象</param> /// <param name="deleteElement">由于删除元素操作而执行本方法, /// 此时不需要将元素添加到高亮度区域状态未知的元素列表</param> public void InvalidateHighlightInfo(DomElement element) { if (element is DomCharElement) { // 字符元素不能设置为高亮度区域,因此不处理,提高效率 return; } if (_InnerHighlightInfos != null) { if (_InvalidateHighlightInfoElements == null) { _InvalidateHighlightInfoElements = new DomElementList(); } if (_InvalidateHighlightInfoElements.Contains(element) == false) { _InvalidateHighlightInfoElements.Add(element); if (_InnerHighlightInfos != null) { for (int iCount = _InnerHighlightInfos.Count - 1; iCount >= 0; iCount--) { HighlightInfo info = _InnerHighlightInfos[iCount]; bool delete = false; if (info.OwnerElement == element) { delete = true; } else if (info.OwnerElement != null && info.OwnerElement.IsParentOrSupParent(element)) { delete = true; } if (delete) { if (info.Range != null) { this.Document.InvalidateView(info.Range); if (info.OwnerElement != null && _InvalidateHighlightInfoElements.Contains(info.OwnerElement) == false) { _InvalidateHighlightInfoElements.Add(info.OwnerElement); } } _InnerHighlightInfos.RemoveAt(iCount); } } //for } //if } //if } }