Created attachment 339348 [details] The html that exhibits the bug The attached html includes three paragraphs of text that fills two columns. Immediately after the second paragraph is a figure that contains both an image and a caption. This figure has float:left set, so you would expect it to appear to the left of the subsequent (i.e. third) paragraph. The image, however, appears well after the end of the third (and final) paragraph. In fact, it is positioned so far down the second column that its bottom is cut off by the column, and the remainder of the image appears in a new column. The figure has page-break-inside:avoid set so that the image and the caption are not split between columns. Commenting this line out, though, "fixes" the layout issue. Because the image is too tall to be displayed in the first column, the image is correctly displayed at the top of the second column. Furthermore, the image and the caption are in the same column, so it is (perhaps) somewhat surprising that page-break-inside:avoid would have had any effect at all. Lastly, this incorrect layout is quite dependent upon the height of the image in the figure. In the attached html, the height of the image is set to 484. However, if that is changed to 483, then the layout issue goes away. This seems like it might be related to the height of the third paragraph's rect in the first column. Even though the height of the figure element is more than 483, changing the image's height causes it to be drawn correctly. (Though I'm filing as Safari 11, this bug also exists in Safari Technology Preview.)
Created attachment 339349 [details] Incorrect image layout
Created attachment 339350 [details] Image layout with page-break-inside:avoid commented out Image that shows the expected layout. Commenting out the page-break-inside:avoid avoids the bug. This, however, isn't a real solution because it's needed to prevent the caption and the image from being separated.
Created attachment 339352 [details] Layout for smaller image By changing the image height from 484 to 483, the bug seems to be avoided entirely.
<rdar://problem/122586647>