static CssLineBox FindNearestLine(CssBox startBox, int globalY, int yRange) { CssLineBox latestLine = null; CssBox latestLineBoxOwner = null; float latestLineBoxGlobalYPos = 0; foreach (CssLineBox lineBox in BoxHitUtils.GetDeepDownLineBoxIter(startBox)) { if (lineBox.CacheLineHeight == 0) { continue; } if (latestLineBoxOwner != lineBox.OwnerBox) { //find global position of box latestLineBoxOwner = lineBox.OwnerBox; //TODO: review here , duplicate GetGlobalLocation float gx, gy; latestLineBoxOwner.GetGlobalLocation(out gx, out gy); latestLineBoxGlobalYPos = gy; } float lineGlobalBottom = lineBox.CachedLineBottom + latestLineBoxGlobalYPos; if (lineGlobalBottom <= globalY) { latestLine = lineBox; } else { latestLine = lineBox; break; } } return(latestLine); }