Skip to content

Commit

Permalink
Revert 0258c15. rdar://problem/108930635
Browse files Browse the repository at this point in the history
Identifier: 263322.511@safari-7616.1.14.11-branch
  • Loading branch information
MyahCobbs committed May 23, 2023
1 parent d43cbc4 commit 2422f56
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 67 deletions.

This file was deleted.

22 changes: 0 additions & 22 deletions LayoutTests/fast/images/decode-decoding-change-image-src.html

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
function loadImage(image, src) {
return new Promise((resolve) => {
image.onload = (() => {
// Move the image to a new separate layer.
var box = document.createElement("div");
box.style.willChange = "transform";
box.appendChild(image);
document.body.appendChild(box);

if (window.internals && window.testRunner) {
// Force layout and display so the image gets drawn.
document.body.offsetHeight;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
function loadImage(image, src) {
return new Promise((resolve) => {
image.onload = (() => {
// Move the image to a new separate layer.
var box = document.createElement("div");
box.style.willChange = "transform";
box.appendChild(image);
document.body.appendChild(box);

if (window.internals && window.testRunner) {
// Force layout and display so the image gets drawn.
document.body.offsetHeight;
Expand Down
43 changes: 14 additions & 29 deletions Source/WebCore/rendering/RenderBoxModelObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,47 +309,32 @@ DecodingMode RenderBoxModelObject::decodingModeForImageDraw(const Image& image,
}

// Large image case.
// Some document types force synchronous decoding.
#if PLATFORM(IOS_FAMILY)
if (IOSApplication::isIBooksStorytime())
return DecodingMode::Synchronous;
#endif
if (document().isImageDocument())
return DecodingMode::Synchronous;

// A PaintBehavior may force synchronous decoding.
if (paintInfo.paintBehavior.contains(PaintBehavior::Snapshotting))
return DecodingMode::Synchronous;
if (paintInfo.paintBehavior.contains(PaintBehavior::ForceSynchronousImageDecode))
return DecodingMode::Synchronous;

// <img decoding="sync"> forces synchronous decoding.
if (is<HTMLImageElement>(element())) {
if (downcast<HTMLImageElement>(*element()).decodingMode() == DecodingMode::Synchronous)
auto decodingMode = downcast<HTMLImageElement>(*element()).decodingMode();
if (decodingMode == DecodingMode::Asynchronous)
return DecodingMode::Asynchronous;
if (decodingMode == DecodingMode::Synchronous)
return DecodingMode::Synchronous;
}

// Layout tests may force asynchronous decoding.
if (bitmapImage.isLargeImageAsyncDecodingEnabledForTesting())
return DecodingMode::Asynchronous;

// Not first paint, so we have to avoid flickering anyway.
if (!paintInfo.paintBehavior.contains(PaintBehavior::DefaultAsynchronousImageDecode)) {
// FIXME: isVisibleInViewport() is not cheap. Find a way to make this condition faster.
if (isVisibleInViewport())
return DecodingMode::Synchronous;
}

// <img decoding="async"> forces asynchronous decoding.
if (is<HTMLImageElement>(element())) {
if (downcast<HTMLImageElement>(*element()).decodingMode() == DecodingMode::Asynchronous)
return DecodingMode::Asynchronous;
}

// Resepect the web preferences key: largeImageAsyncDecodingEnabled.
if (settings().largeImageAsyncDecodingEnabled() && bitmapImage.canUseAsyncDecodingForLargeImages())
if (document().isImageDocument())
return DecodingMode::Synchronous;
if (!settings().largeImageAsyncDecodingEnabled())
return DecodingMode::Synchronous;
if (!bitmapImage.canUseAsyncDecodingForLargeImages())
return DecodingMode::Synchronous;
if (paintInfo.paintBehavior.contains(PaintBehavior::TileFirstPaint))
return DecodingMode::Asynchronous;
// FIXME: isVisibleInViewport() is not cheap. Find a way to make this condition faster.
if (!isVisibleInViewport())
return DecodingMode::Asynchronous;

return DecodingMode::Synchronous;
}

Expand Down

0 comments on commit 2422f56

Please sign in to comment.