Quantcast
Channel: HTML Renderer
Viewing all articles
Browse latest Browse all 693

New Post: img and HtmlRenderer.GetAttributeAt

$
0
0
I fixed the problem by modifying DomUtils.GetCssBox.
It was also unable to work with td.

Here is the code in case anyone faces the same problem:
    /// <summary>
    /// Get css box under the given sub-tree at the given x,y location, get the inner most.<br/>
    /// the location must be in correct scroll offset.
    /// </summary>
    /// <param name="box">the box to start search from</param>
    /// <param name="location">the location to find the box by</param>
    /// <param name="visible">Optional: if to get only visible boxes (default - true)</param>
    /// <returns>css link box if exists or null</returns>
    public static CssBox GetCssBox(CssBox box, Point location, bool visible = true)
    {

      if (box != null)
      {
        if ((!visible || box.Visibility == CssConstants.Visible) && (box.Bounds.IsEmpty || box.Bounds.Contains(location)))
        {
          foreach (var childBox in box.Boxes)
          {
            var bounds = (childBox.IsImage ? childBox.FirstWord.Rectangle : childBox.Bounds);
            if (bounds.Contains(location) || (bounds.IsEmpty && childBox.Boxes.Count != 0))
            {
              return GetCssBox(childBox, location) ?? childBox;
            }
          }
        }
      }

      return null;
    }
Sorry if this isn't the perfect implementation ; I don't really know if that's the good way things should be done but at least it works better than the original.

Viewing all articles
Browse latest Browse all 693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>