/* * TreeQL関連、実際に操作できるタイミングは非アップデート中とかそんな感じなので、 * stateに関する制約が必要。 */ public void AppendContentToLast(string htmlContent, string query = "") { if (viewState != ViewState.Ready) { return; } TagTree.CorrectTrees(layoutedTree); var parser = new HTMLParser(resLoader); var parse = parser.ParseRoot( htmlContent, parsedTagTree => { if (parsedTagTree.errors.Any()) { Debug.LogError("parse errors:" + parsedTagTree.errors.Count); foreach (var error in parsedTagTree.errors) { Debug.LogError("code:" + error.code + " reason:" + error.reason); } return; } // parse succeeded. var newTreeIds = TagTree.CollectTreeIds(parsedTagTree); var currentTreeIds = TagTree.CollectTreeIds(layoutedTree); var appendedTreeIds = newTreeIds.Except(currentTreeIds).ToArray(); var children = parsedTagTree.GetChildren(); // add to content. if (string.IsNullOrEmpty(query)) { layoutedTree.AddChildren(children.ToArray()); } else { var targetTreeFamily = GetTreeFamily(new List <TagTree> { layoutedTree }, GetQuery(query)); targetTreeFamily.Last().AddChildren(children.ToArray()); } // relayout. Update(appendedTreeIds, () => { }); } ); CoroutineExecutor(parse); }
private IEnumerator Parse(string source, float offsetY) { IEnumerator reload = null; var parser = new HTMLParser(resLoader); var parse = parser.ParseRoot( source, parsedTagTree => { if (parsedTagTree.errors.Any()) { if (onParseFailed != null) { onParseFailed(parsedTagTree.errors); } return; } reload = Load(parsedTagTree, viewRect, offsetY, eventReceiverGameObj); } ); while (parse.MoveNext()) { yield return(null); } if (reload == null) { yield break; } while (reload.MoveNext()) { yield return(null); } }