// Token: 0x060035C3 RID: 13763 RVA: 0x000F446C File Offset: 0x000F266C internal void InsertAtNode(SplayTreeNode positionNode, ElementEdge edge) { if (edge == ElementEdge.BeforeStart || edge == ElementEdge.AfterEnd) { this.InsertAtNode(positionNode, edge == ElementEdge.BeforeStart); return; } SplayTreeNode splayTreeNode; bool insertBefore; if (edge == ElementEdge.AfterStart) { splayTreeNode = positionNode.GetFirstContainedNode(); insertBefore = true; } else { splayTreeNode = positionNode.GetLastContainedNode(); insertBefore = false; } if (splayTreeNode == null) { positionNode.ContainedNode = this; this.ParentNode = positionNode; Invariant.Assert(this.LeftChildNode == null); Invariant.Assert(this.RightChildNode == null); Invariant.Assert(this.LeftSymbolCount == 0); return; } this.InsertAtNode(splayTreeNode, insertBefore); }
// Dumps a node and all following nodes "flat" -- in notation similar to xaml. internal static void DumpNodeFlatRecursive(SplayTreeNode node) { for (; node != null; node = node.GetNextNode()) { Debug.Write("<" + GetFlatPrefix(node) + node.DebugId); if (node.ContainedNode != null) { Debug.Write(">"); DumpNodeFlatRecursive(node.GetFirstContainedNode()); Debug.Write("</" + GetFlatPrefix(node) + node.DebugId + ">"); } else { Debug.Write("/>"); } } }
// Inserts a node at a specified position. internal void InsertAtNode(SplayTreeNode positionNode, ElementEdge edge) { SplayTreeNode locationNode; bool insertBefore; if (edge == ElementEdge.BeforeStart || edge == ElementEdge.AfterEnd) { // Insert to this node's tree. InsertAtNode(positionNode, edge == ElementEdge.BeforeStart /* insertBefore */); } else { // Insert to this node's contained tree. if (edge == ElementEdge.AfterStart) { locationNode = positionNode.GetFirstContainedNode(); insertBefore = true; } else // ElementEdge == BeforeEnd { locationNode = positionNode.GetLastContainedNode(); insertBefore = false; } if (locationNode == null) { // Inserting the first contained node. positionNode.ContainedNode = this; this.ParentNode = positionNode; Invariant.Assert(this.LeftChildNode == null); Invariant.Assert(this.RightChildNode == null); Invariant.Assert(this.LeftSymbolCount == 0); } else { InsertAtNode(locationNode, insertBefore); } } }
//----------------------------------------------------- // // Private Methods // //------------------------------------------------------ #region Private Methods // Scans all the immediate contained nodes of a TextElementNode, and // calls AddLogicalChild methods if supported to alert the children // about a new parent. private void ReparentLogicalChildren(SplayTreeNode containerNode, DependencyObject newParentLogicalNode, DependencyObject oldParentLogicalNode) { ReparentLogicalChildren(containerNode.GetFirstContainedNode(), null, newParentLogicalNode, oldParentLogicalNode); }
// Debug only. Walks a node and all its children to get a brute force // symbol count. private static int GetNodeSymbolCountSlow(SplayTreeNode node) { SplayTreeNode child; int count; if (node is TextTreeRootNode || node is TextTreeTextElementNode) { count = 2; for (child = node.GetFirstContainedNode(); child != null; child = child.GetNextNode()) { count += GetNodeSymbolCountSlow(child); } } else { Invariant.Assert(node.ContainedNode == null, "Expected leaf node!"); count = node.SymbolCount; } return count; }