Skip to content

Commit 383db59

Browse files
author
ArthurHub
committed
* Add support for synchronous image loading
* use AvoidAsyncImagesLoading in HtmlRender
1 parent f9ddf68 commit 383db59

6 files changed

Lines changed: 193 additions & 111 deletions

File tree

‎Source/HtmlRenderer/Dom/CssBox.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,8 @@ internal virtual void MeasureWordsSize(IGraphics g)
652652
{
653653
if (BackgroundImage != CssConstants.None && _imageLoadHandler == null)
654654
{
655-
_imageLoadHandler = new ImageLoadHandler(OnImageLoadComplete);
656-
_imageLoadHandler.LoadImage(HtmlContainer, BackgroundImage, HtmlTag != null ? HtmlTag.Attributes : null);
655+
_imageLoadHandler = new ImageLoadHandler(HtmlContainer, OnImageLoadComplete);
656+
_imageLoadHandler.LoadImage(BackgroundImage, HtmlTag != null ? HtmlTag.Attributes : null);
657657
}
658658

659659
MeasureWordSpacing(g);

‎Source/HtmlRenderer/Dom/CssBoxFrame.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ private void HandlePostApiCall(object sender)
371371
{
372372
if (_videoImageUrl != null)
373373
{
374-
_imageLoadHandler = new ImageLoadHandler(OnLoadImageComplete);
375-
_imageLoadHandler.LoadImage(HtmlContainer, _videoImageUrl, HtmlTag != null ? HtmlTag.Attributes : null);
374+
_imageLoadHandler = new ImageLoadHandler(HtmlContainer, OnLoadImageComplete);
375+
_imageLoadHandler.LoadImage(_videoImageUrl, HtmlTag != null ? HtmlTag.Attributes : null);
376376
}
377377
else
378378
{

‎Source/HtmlRenderer/Dom/CssBoxImage.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ protected override void PaintImp(IGraphics g)
7272
// load image iff it is in visible rectangle
7373
if (_imageLoadHandler == null)
7474
{
75-
_imageLoadHandler = new ImageLoadHandler(OnLoadImageComplete);
76-
_imageLoadHandler.LoadImage(HtmlContainer, GetAttribute("src"), HtmlTag != null ? HtmlTag.Attributes : null);
75+
_imageLoadHandler = new ImageLoadHandler(HtmlContainer, OnLoadImageComplete);
76+
_imageLoadHandler.LoadImage(GetAttribute("src"), HtmlTag != null ? HtmlTag.Attributes : null);
7777
}
7878

7979
var rect = CommonUtils.GetFirstValueOrDefault(Rectangles);
@@ -133,8 +133,8 @@ internal override void MeasureWordsSize(IGraphics g)
133133
{
134134
if (_imageLoadHandler == null && HtmlContainer.AvoidImagesLateLoading)
135135
{
136-
_imageLoadHandler = new ImageLoadHandler(OnLoadImageComplete);
137-
_imageLoadHandler.LoadImage(HtmlContainer, GetAttribute("src"), HtmlTag != null ? HtmlTag.Attributes : null);
136+
_imageLoadHandler = new ImageLoadHandler(HtmlContainer, OnLoadImageComplete);
137+
_imageLoadHandler.LoadImage(GetAttribute("src"), HtmlTag != null ? HtmlTag.Attributes : null);
138138
}
139139

140140
MeasureWordSpacing(g);

0 commit comments

Comments
 (0)