internal void PaintRuns(PaintVisitor p) { List <CssRun> tmpRuns = _runs; int j = tmpRuns.Count; if (j < 1) { return; } //----------------------- //iterate from each words CssBox latestOwner = null; DrawBoard innerCanvas = p.InnerDrawBoard; RequestFont enterFont = innerCanvas.CurrentFont; Color enterColor = innerCanvas.CurrentTextColor; for (int i = 0; i < j; ++i) { //----------------- #if DEBUG dbugCounter.dbugRunPaintCount++; #endif //----------------- CssRun w = tmpRuns[i]; switch (w.Kind) { case CssRunKind.SolidContent: { #if DEBUG //System.Diagnostics.Debug.WriteLine("ox,oy=" + p.CanvasOriginX + "," + p.CanvasOriginY); //System.Diagnostics.Debug.WriteLine("clip=" + p.CurrentClipRect); #endif Rectangle currentClipRect = p.CurrentClipRect; Rectangle wRect = new Rectangle((int)w.Left, (int)w.Top, (int)w.Width, (int)w.Height); wRect.Intersect(currentClipRect); #if DEBUG //System.Diagnostics.Debug.WriteLine("empty_clip=" + (wRect.Height == 0 || wRect.Width == 0)); #endif if (wRect.Height != 0 && wRect.Width != 0) { w.OwnerBox.Paint(p, new RectangleF(w.Left, w.Top, w.Width, w.Height)); } } break; case CssRunKind.BlockRun: { //Console.WriteLine("blockrun"); CssBlockRun blockRun = (CssBlockRun)w; int ox = p.CanvasOriginX; int oy = p.CanvasOriginY; p.SetCanvasOrigin(ox + (int)(blockRun.Left), oy + (int)blockRun.Top); CssBox.Paint(blockRun.ContentBox, p); p.SetCanvasOrigin(ox, oy); } break; case CssRunKind.Text: { if (latestOwner != w.OwnerBox) { //change latestOwner = w.OwnerBox; //change font when change owner p.InnerDrawBoard.CurrentFont = latestOwner.ResolvedFont; p.InnerDrawBoard.CurrentTextColor = latestOwner.ActualColor; } CssTextRun textRun = (CssTextRun)w; if (p.CurrentSolidBackgroundColorHint.A == 255) { //solid bg RenderVxFormattedString formattedStr = CssTextRun.GetCachedFormatString(textRun); if (formattedStr == null) { char[] buffer = CssBox.UnsafeGetTextBuffer(w.OwnerBox); formattedStr = p.CreateRenderVx(buffer, textRun.TextStartIndex, textRun.TextLength); //TODO: see _renderVxFormattedString = d.CreateFormattedString(_mybuffer, 0, _mybuffer.Length, DelayFormattedString); if (formattedStr != null) { CssTextRun.SetCachedFormattedString(textRun, formattedStr); p.DrawText(formattedStr, w.Left, w.Top); } else { //still null p.DrawText(CssBox.UnsafeGetTextBuffer(w.OwnerBox), textRun.TextStartIndex, textRun.TextLength, new PointF(w.Left, w.Top), new SizeF(w.Width, w.Height)); } } else { p.DrawText(formattedStr, w.Left, w.Top); } } else { p.DrawText(CssBox.UnsafeGetTextBuffer(w.OwnerBox), textRun.TextStartIndex, textRun.TextLength, new PointF(w.Left, w.Top), new SizeF(w.Width, w.Height)); } } break; default: { #if DEBUG // w.OwnerBox.dbugPaintTextWordArea(g, offset, w); #endif } break; } } innerCanvas.CurrentFont = enterFont; innerCanvas.CurrentTextColor = enterColor; }