REGRESSION (r230480): Cannot adjust photo position on LinkedIn's profile page
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 10 Jun 2018 01:26:53 +0000 (01:26 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 10 Jun 2018 01:26:53 +0000 (01:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186464
<rdar://problem/40369448>

Reviewed by Simon Fraser.

Source/WebCore:

The optimization logic for skipping image layout when we only need overflow computation should check if the image actually needs
simplified layout only. The needsSimplifiedNormalFlowLayout() flag means that the overflow information needs to be updated but
it does not mean that overflow is the only property that we need to recompute.

Test: fast/images/positioned-image-when-transform-is-present.html

* rendering/RenderImage.cpp:
(WebCore::RenderImage::layout):
* rendering/RenderObject.h:
(WebCore::RenderObject::needsSimplifiedNormalFlowLayoutOnly const):

LayoutTests:

* fast/images/positioned-image-when-transform-is-present-expected.html: Added.
* fast/images/positioned-image-when-transform-is-present.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232663 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/images/positioned-image-when-transform-is-present-expected.html [new file with mode: 0644]
LayoutTests/fast/images/positioned-image-when-transform-is-present.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/rendering/RenderObject.h

index 06230ad..ac9c72c 100644 (file)
@@ -1,3 +1,14 @@
+2018-06-09  Zalan Bujtas  <zalan@apple.com>
+
+        REGRESSION (r230480): Cannot adjust photo position on LinkedIn's profile page
+        https://bugs.webkit.org/show_bug.cgi?id=186464
+        <rdar://problem/40369448>
+
+        Reviewed by Simon Fraser.
+
+        * fast/images/positioned-image-when-transform-is-present-expected.html: Added.
+        * fast/images/positioned-image-when-transform-is-present.html: Added.
+
 2018-06-09  Ryosuke Niwa  <rniwa@webkit.org>
 
         REGRESSION(macOS Mojave): move-by-word-visually-multi-line.html fails
diff --git a/LayoutTests/fast/images/positioned-image-when-transform-is-present-expected.html b/LayoutTests/fast/images/positioned-image-when-transform-is-present-expected.html
new file mode 100644 (file)
index 0000000..b100983
--- /dev/null
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that we reposition the image when transform is present.</title>
+</head>
+<body>
+PASS if the image disappears completely.
+</body>
+</html>
diff --git a/LayoutTests/fast/images/positioned-image-when-transform-is-present.html b/LayoutTests/fast/images/positioned-image-when-transform-is-present.html
new file mode 100644 (file)
index 0000000..7a9a052
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that we reposition the image when transform is present.</title>
+<style>
+img {
+       position: absolute;
+       top: 10px;
+       left: 10px;
+       width: 100px;
+       height: 100px;
+       transform: translateX(0px);
+}
+
+div {
+       position: relative;
+       width: 100px;
+       height: 100px;
+       overflow: hidden;
+}
+</style>
+</head>
+<body>
+PASS if the image disappears completely.
+<div><img id=moveOut src="foobar-broken.jpg"></div>
+<script>
+       document.body.offsetHeight;
+       moveOut.style.transform = "translateX(1px)";
+       moveOut.style.left = "200px";
+</script>
+</body>
+</html>
index 16a85a1..89e3e47 100644 (file)
@@ -1,3 +1,22 @@
+2018-06-09  Zalan Bujtas  <zalan@apple.com>
+
+        REGRESSION (r230480): Cannot adjust photo position on LinkedIn's profile page
+        https://bugs.webkit.org/show_bug.cgi?id=186464
+        <rdar://problem/40369448>
+
+        Reviewed by Simon Fraser.
+
+        The optimization logic for skipping image layout when we only need overflow computation should check if the image actually needs
+        simplified layout only. The needsSimplifiedNormalFlowLayout() flag means that the overflow information needs to be updated but
+        it does not mean that overflow is the only property that we need to recompute.
+
+        Test: fast/images/positioned-image-when-transform-is-present.html
+
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::layout):
+        * rendering/RenderObject.h:
+        (WebCore::RenderObject::needsSimplifiedNormalFlowLayoutOnly const):
+
 2018-06-09  Ryosuke Niwa  <rniwa@webkit.org>
 
         REGRESSION(macOS Mojave): move-by-word-visually-multi-line.html fails
index 92422b3..acd99a0 100644 (file)
@@ -709,7 +709,7 @@ bool RenderImage::canHaveChildren() const
 void RenderImage::layout()
 {
     // Recomputing overflow is required only when child content is present. 
-    if (needsSimplifiedNormalFlowLayout() && !m_hasShadowControls) {
+    if (needsSimplifiedNormalFlowLayoutOnly() && !m_hasShadowControls) {
         clearNeedsLayout();
         return;
     }
index ccd686e..bb3f35e 100644 (file)
@@ -475,6 +475,7 @@ public:
 
     bool posChildNeedsLayout() const { return m_bitfields.posChildNeedsLayout(); }
     bool needsSimplifiedNormalFlowLayout() const { return m_bitfields.needsSimplifiedNormalFlowLayout(); }
+    bool needsSimplifiedNormalFlowLayoutOnly() const;
     bool normalChildNeedsLayout() const { return m_bitfields.normalChildNeedsLayout(); }
     
     bool preferredLogicalWidthsDirty() const { return m_bitfields.preferredLogicalWidthsDirty(); }
@@ -1094,6 +1095,12 @@ inline bool RenderObject::backgroundIsKnownToBeObscured(const LayoutPoint& paint
     return m_bitfields.boxDecorationState() == HasBoxDecorationsAndBackgroundIsKnownToBeObscured;
 }
 
+inline bool RenderObject::needsSimplifiedNormalFlowLayoutOnly() const
+{
+    return m_bitfields.needsSimplifiedNormalFlowLayout() && !m_bitfields.needsLayout() && !m_bitfields.normalChildNeedsLayout()
+        && !m_bitfields.posChildNeedsLayout() && !m_bitfields.needsPositionedMovementLayout();
+}
+
 #if ENABLE(TREE_DEBUGGING)
 void printRenderTreeForLiveDocuments();
 void printLayerTreeForLiveDocuments();