Title: [294211] trunk
Revision
294211
Author
za...@apple.com
Date
2022-05-14 15:39:40 -0700 (Sat, 14 May 2022)

Log Message

Changing text color and removing line-clamp on hover causes text to disappear permanently
https://bugs.webkit.org/show_bug.cgi?id=240410

Reviewed by Simon Fraser.

Source/WebCore:

Invalidate the flex items' line layout path when line-clamp property value changes.

While the line clamp property is set on the flex box, it is "forced on" the flex items' inline content.
(i.e. the property is not inherited, it is propagated to the flex children)
It means dynamic value change only runs on the flex box renderer.

Test: fast/block/dynamic-line-clamp-empty-content.html

* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::styleWillChange):

LayoutTests:

* fast/block/dynamic-line-clamp-empty-content-expected.html: Added.
* fast/block/dynamic-line-clamp-empty-content.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (294210 => 294211)


--- trunk/LayoutTests/ChangeLog	2022-05-14 21:35:41 UTC (rev 294210)
+++ trunk/LayoutTests/ChangeLog	2022-05-14 22:39:40 UTC (rev 294211)
@@ -1,5 +1,15 @@
 2022-05-14  Alan Bujtas  <za...@apple.com>
 
+        Changing text color and removing line-clamp on hover causes text to disappear permanently
+        https://bugs.webkit.org/show_bug.cgi?id=240410
+
+        Reviewed by Simon Fraser.
+
+        * fast/block/dynamic-line-clamp-empty-content-expected.html: Added.
+        * fast/block/dynamic-line-clamp-empty-content.html: Added.
+
+2022-05-14  Alan Bujtas  <za...@apple.com>
+
         [Repaint] Border ignores currentColor change when hovering
         https://bugs.webkit.org/show_bug.cgi?id=240401
 

Added: trunk/LayoutTests/fast/block/dynamic-line-clamp-empty-content-expected.html (0 => 294211)


--- trunk/LayoutTests/fast/block/dynamic-line-clamp-empty-content-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/dynamic-line-clamp-empty-content-expected.html	2022-05-14 22:39:40 UTC (rev 294211)
@@ -0,0 +1,10 @@
+<style>
+#clamp {
+  width: 100px;
+  overflow: hidden;
+  display: -webkit-box;
+  -webkit-box-orient: block-axis;
+  -webkit-line-clamp: 2;
+}
+</style>
+<div id=clamp>This text should stay visible after setting line clamp on it.</div>

Added: trunk/LayoutTests/fast/block/dynamic-line-clamp-empty-content.html (0 => 294211)


--- trunk/LayoutTests/fast/block/dynamic-line-clamp-empty-content.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/dynamic-line-clamp-empty-content.html	2022-05-14 22:39:40 UTC (rev 294211)
@@ -0,0 +1,13 @@
+<style>
+#clamp {
+  width: 100px;
+  overflow: hidden;
+  display: -webkit-box;
+  -webkit-box-orient: block-axis;
+}
+</style>
+<div id=clamp>This text should stay visible after setting line clamp on it.</div>
+<script>
+document.body.offsetHeight;
+clamp.style.webkitLineClamp = '2';
+</script>

Modified: trunk/Source/WebCore/ChangeLog (294210 => 294211)


--- trunk/Source/WebCore/ChangeLog	2022-05-14 21:35:41 UTC (rev 294210)
+++ trunk/Source/WebCore/ChangeLog	2022-05-14 22:39:40 UTC (rev 294211)
@@ -1,5 +1,23 @@
 2022-05-14  Alan Bujtas  <za...@apple.com>
 
+        Changing text color and removing line-clamp on hover causes text to disappear permanently
+        https://bugs.webkit.org/show_bug.cgi?id=240410
+
+        Reviewed by Simon Fraser.
+
+        Invalidate the flex items' line layout path when line-clamp property value changes.
+
+        While the line clamp property is set on the flex box, it is "forced on" the flex items' inline content.
+        (i.e. the property is not inherited, it is propagated to the flex children)
+        It means dynamic value change only runs on the flex box renderer.
+
+        Test: fast/block/dynamic-line-clamp-empty-content.html
+
+        * rendering/RenderDeprecatedFlexibleBox.cpp:
+        (WebCore::RenderDeprecatedFlexibleBox::styleWillChange):
+
+2022-05-14  Alan Bujtas  <za...@apple.com>
+
         Unreviewed win build fix.
 
         * layout/integration/flex/LayoutIntegrationFlexLayout.cpp:

Modified: trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp (294210 => 294211)


--- trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2022-05-14 21:35:41 UTC (rev 294210)
+++ trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2022-05-14 22:39:40 UTC (rev 294211)
@@ -179,9 +179,17 @@
 void RenderDeprecatedFlexibleBox::styleWillChange(StyleDifference diff, const RenderStyle& newStyle)
 {
     auto* oldStyle = hasInitializedStyle() ? &style() : nullptr;
-    if (oldStyle && !oldStyle->lineClamp().isNone() && newStyle.lineClamp().isNone())
-        clearLineClamp();
+    if (oldStyle) {
+        auto hadLineClamp = !oldStyle->lineClamp().isNone();
+        auto hasLineClamp = !newStyle.lineClamp().isNone(); 
+        if (hasLineClamp != hadLineClamp) {
+            for (auto& child : childrenOfType<RenderBlockFlow>(*this))
+                child.invalidateLineLayoutPath();
 
+            if (hadLineClamp && !hasLineClamp)
+                clearLineClamp();
+        }
+    }
     RenderBlock::styleWillChange(diff, newStyle);
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to