Title: [283312] trunk
Revision
283312
Author
za...@apple.com
Date
2021-09-30 08:26:21 -0700 (Thu, 30 Sep 2021)

Log Message

(REGRESSION r282150) Missing background-color on inline box while hovering
https://bugs.webkit.org/show_bug.cgi?id=230977
<rdar://problem/83682736>

Reviewed by Antti Koivisto.

Source/WebCore:

Check if the RenderInline is still eligible for the modern line layout codepath after style change.

Test: fast/inline/inline-box-background-dynamic.html

* layout/integration/LayoutIntegrationCoverage.cpp:
(WebCore::LayoutIntegration::canUseForRenderInlineChild):
(WebCore::LayoutIntegration::canUseForChild):
(WebCore::LayoutIntegration::canUseForLineLayoutAfterInlineBoxStyleChange):
* layout/integration/LayoutIntegrationCoverage.h:
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::canUseForAfterInlineBoxStyleChange):
* layout/integration/LayoutIntegrationLineLayout.h:
* rendering/RenderInline.cpp:
(WebCore::RenderInline::styleDidChange):

LayoutTests:

* fast/inline/inline-box-background-dynamic-expected.html: Added.
* fast/inline/inline-box-background-dynamic.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (283311 => 283312)


--- trunk/LayoutTests/ChangeLog	2021-09-30 14:53:33 UTC (rev 283311)
+++ trunk/LayoutTests/ChangeLog	2021-09-30 15:26:21 UTC (rev 283312)
@@ -1,3 +1,14 @@
+2021-09-30  Alan Bujtas  <za...@apple.com>
+
+        (REGRESSION r282150) Missing background-color on inline box while hovering
+        https://bugs.webkit.org/show_bug.cgi?id=230977
+        <rdar://problem/83682736>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/inline/inline-box-background-dynamic-expected.html: Added.
+        * fast/inline/inline-box-background-dynamic.html: Added.
+
 2021-09-30  Antti Koivisto  <an...@apple.com>
 
         Having unused TextIterator instance shouldn't crash if document is mutated

Added: trunk/LayoutTests/fast/inline/inline-box-background-dynamic-expected.html (0 => 283312)


--- trunk/LayoutTests/fast/inline/inline-box-background-dynamic-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/inline-box-background-dynamic-expected.html	2021-09-30 15:26:21 UTC (rev 283312)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<style>
+body {
+  margin: 0px;
+}
+div {
+  background-color: green;
+  width: 680px;
+  height: 20px;
+}
+</style>
+<body>
+<div></div>
+</body></html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/inline/inline-box-background-dynamic.html (0 => 283312)


--- trunk/LayoutTests/fast/inline/inline-box-background-dynamic.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/inline-box-background-dynamic.html	2021-09-30 15:26:21 UTC (rev 283312)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<style>
+body {
+  margin: 0px;
+}
+span {
+  color: green;
+  font-family: Ahem;
+  font-size: 20px;
+}
+</style>
+<body>
+<span id=changeThis>PASS if you cannot read this text.</span><script>
+document.body.offsetHeight;
+changeThis.style.backgroundColor = "green";
+</script></body></html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (283311 => 283312)


--- trunk/Source/WebCore/ChangeLog	2021-09-30 14:53:33 UTC (rev 283311)
+++ trunk/Source/WebCore/ChangeLog	2021-09-30 15:26:21 UTC (rev 283312)
@@ -1,3 +1,26 @@
+2021-09-30  Alan Bujtas  <za...@apple.com>
+
+        (REGRESSION r282150) Missing background-color on inline box while hovering
+        https://bugs.webkit.org/show_bug.cgi?id=230977
+        <rdar://problem/83682736>
+
+        Reviewed by Antti Koivisto.
+
+        Check if the RenderInline is still eligible for the modern line layout codepath after style change. 
+
+        Test: fast/inline/inline-box-background-dynamic.html
+
+        * layout/integration/LayoutIntegrationCoverage.cpp:
+        (WebCore::LayoutIntegration::canUseForRenderInlineChild):
+        (WebCore::LayoutIntegration::canUseForChild):
+        (WebCore::LayoutIntegration::canUseForLineLayoutAfterInlineBoxStyleChange):
+        * layout/integration/LayoutIntegrationCoverage.h:
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::canUseForAfterInlineBoxStyleChange):
+        * layout/integration/LayoutIntegrationLineLayout.h:
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::styleDidChange):
+
 2021-09-30  Antti Koivisto  <an...@apple.com>
 
         Regression (283158): Having unused TextIterator instance shouldn't crash if document is mutated

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp (283311 => 283312)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp	2021-09-30 14:53:33 UTC (rev 283311)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp	2021-09-30 15:26:21 UTC (rev 283312)
@@ -473,6 +473,40 @@
     return reasons;
 }
 
+static OptionSet<AvoidanceReason> canUseForRenderInlineChild(const RenderInline& renderInline, IncludeReasons includeReasons)
+{
+    OptionSet<AvoidanceReason> reasons;
+
+    if (renderInline.isSVGInline())
+        SET_REASON_AND_RETURN_IF_NEEDED(ContentIsSVG, reasons, includeReasons);
+    if (renderInline.isRubyInline() || renderInline.isQuote())
+        SET_REASON_AND_RETURN_IF_NEEDED(ContentIsRuby, reasons, includeReasons);
+    if (renderInline.requiresLayer())
+        SET_REASON_AND_RETURN_IF_NEEDED(InlineBoxNeedsLayer, reasons, includeReasons)
+
+    auto& style = renderInline.style();
+    if (style.boxShadow() || !style.hangingPunctuation().isEmpty())
+        SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxHasUnsupportedStyle, reasons, includeReasons)
+    if (style.hasBorder() || style.borderImage().hasImage())
+        SET_REASON_AND_RETURN_IF_NEEDED(InlineBoxHasBorderOrBorderImage, reasons, includeReasons);
+    if (style.hasBackground())
+        SET_REASON_AND_RETURN_IF_NEEDED(InlineBoxHasBackground, reasons, includeReasons);
+    if (style.hasOutline())
+        SET_REASON_AND_RETURN_IF_NEEDED(ContentHasOutline, reasons, includeReasons);
+    if (renderInline.isInFlowPositioned())
+        SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxIsFloatingOrPositioned, reasons, includeReasons);
+    if (renderInline.containingBlock()->style().lineBoxContain() != RenderStyle::initialLineBoxContain())
+        SET_REASON_AND_RETURN_IF_NEEDED(FlowHasLineBoxContainProperty, reasons, includeReasons);
+    auto fontAndTextReasons = canUseForFontAndText(renderInline, includeReasons);
+    if (fontAndTextReasons)
+        ADD_REASONS_AND_RETURN_IF_NEEDED(fontAndTextReasons, reasons, includeReasons);
+    auto styleReasons = canUseForStyle(style, includeReasons);
+    if (styleReasons)
+        ADD_REASONS_AND_RETURN_IF_NEEDED(styleReasons, reasons, includeReasons);
+
+    return reasons;
+}
+
 static OptionSet<AvoidanceReason> canUseForChild(const RenderBlockFlow& flow, const RenderObject& child, IncludeReasons includeReasons)
 {
     OptionSet<AvoidanceReason> reasons;
@@ -543,40 +577,9 @@
         return reasons;
     }
 
-    if (is<RenderInline>(child)) {
-        auto& renderInline = downcast<RenderInline>(child);
-        if (renderInline.isSVGInline())
-            SET_REASON_AND_RETURN_IF_NEEDED(ContentIsSVG, reasons, includeReasons);
-        if (renderInline.isRubyInline() || renderInline.isQuote())
-            SET_REASON_AND_RETURN_IF_NEEDED(ContentIsRuby, reasons, includeReasons);
-        if (renderInline.requiresLayer())
-            SET_REASON_AND_RETURN_IF_NEEDED(InlineBoxNeedsLayer, reasons, includeReasons)
-        if (flow.fragmentedFlowState() != RenderObject::NotInsideFragmentedFlow)
-            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
+    if (is<RenderInline>(child))
+        return canUseForRenderInlineChild(downcast<RenderInline>(child), includeReasons);
 
-        auto& style = renderInline.style();
-        if (!isSupportedStyle(style))
-            SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxHasUnsupportedStyle, reasons, includeReasons)
-        if (style.hasBorder() || style.borderImage().hasImage())
-            SET_REASON_AND_RETURN_IF_NEEDED(InlineBoxHasBorderOrBorderImage, reasons, includeReasons);
-        if (style.hasBackground())
-            SET_REASON_AND_RETURN_IF_NEEDED(InlineBoxHasBackground, reasons, includeReasons);
-        if (style.hasOutline())
-            SET_REASON_AND_RETURN_IF_NEEDED(ContentHasOutline, reasons, includeReasons);
-        if (renderInline.isInFlowPositioned())
-            SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxIsFloatingOrPositioned, reasons, includeReasons);
-        if (renderInline.containingBlock()->style().lineBoxContain() != RenderStyle::initialLineBoxContain())
-            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasLineBoxContainProperty, reasons, includeReasons);
-        auto fontAndTextReasons = canUseForFontAndText(downcast<RenderInline>(child), includeReasons);
-        if (fontAndTextReasons)
-            ADD_REASONS_AND_RETURN_IF_NEEDED(fontAndTextReasons, reasons, includeReasons);
-        auto styleReasons = canUseForStyle(style, includeReasons);
-        if (styleReasons)
-            ADD_REASONS_AND_RETURN_IF_NEEDED(styleReasons, reasons, includeReasons);
-
-        return reasons;
-    }
-
     SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonSupportedChild, reasons, includeReasons);
     return reasons;
 }
@@ -696,7 +699,12 @@
     return canUseForLineLayout(blockContainer);
 }
 
+bool canUseForLineLayoutAfterInlineBoxStyleChange(const RenderInline& renderer, StyleDifference)
+{
+    return canUseForRenderInlineChild(renderer, IncludeReasons::First).isEmpty();
 }
+
 }
+}
 
 #endif

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h (283311 => 283312)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h	2021-09-30 14:53:33 UTC (rev 283311)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h	2021-09-30 15:26:21 UTC (rev 283312)
@@ -104,6 +104,7 @@
 
 bool canUseForLineLayout(const RenderBlockFlow&);
 bool canUseForLineLayoutAfterStyleChange(const RenderBlockFlow&, StyleDifference);
+bool canUseForLineLayoutAfterInlineBoxStyleChange(const RenderInline&, StyleDifference);
 
 enum class IncludeReasons { First , All };
 OptionSet<AvoidanceReason> canUseForLineLayoutWithReason(const RenderBlockFlow&, IncludeReasons);

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (283311 => 283312)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2021-09-30 14:53:33 UTC (rev 283311)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2021-09-30 15:26:21 UTC (rev 283312)
@@ -123,6 +123,12 @@
     return canUseForLineLayoutAfterStyleChange(flow, diff);
 }
 
+bool LineLayout::canUseForAfterInlineBoxStyleChange(const RenderInline& inlineBox, StyleDifference diff)
+{
+    ASSERT(isEnabled());
+    return canUseForLineLayoutAfterInlineBoxStyleChange(inlineBox, diff);
+}
+
 bool LineLayout::shouldSwitchToLegacyOnInvalidation() const
 {
     // FIXME: Support partial invalidation in LFC.

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (283311 => 283312)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2021-09-30 14:53:33 UTC (rev 283311)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2021-09-30 15:26:21 UTC (rev 283312)
@@ -70,6 +70,7 @@
     static bool isEnabled();
     static bool canUseFor(const RenderBlockFlow&);
     static bool canUseForAfterStyleChange(const RenderBlockFlow&, StyleDifference);
+    static bool canUseForAfterInlineBoxStyleChange(const RenderInline&, StyleDifference);
 
     bool shouldSwitchToLegacyOnInvalidation() const;
 

Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (283311 => 283312)


--- trunk/Source/WebCore/rendering/RenderInline.cpp	2021-09-30 14:53:33 UTC (rev 283311)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp	2021-09-30 15:26:21 UTC (rev 283312)
@@ -187,13 +187,14 @@
     }
 
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-    if (auto* lineLayout = LayoutIntegration::LineLayout::containing(*this)) {
-        if (diff >= StyleDifference::Repaint && selfNeedsLayout()) {
-            // FIXME: Add support for partial invalidation.
-            if (auto* container = LayoutIntegration::LineLayout::blockContainer(*this))
-                container->invalidateLineLayoutPath();
-        } else
-            lineLayout->updateStyle(*this, *oldStyle);
+    if (diff >= StyleDifference::Repaint) {
+        if (auto* lineLayout = LayoutIntegration::LineLayout::containing(*this)) {
+            auto shouldInvalidateLineLayoutPath = selfNeedsLayout() || !LayoutIntegration::LineLayout::canUseForAfterInlineBoxStyleChange(*this, diff);
+            if (shouldInvalidateLineLayoutPath)
+                lineLayout->flow().invalidateLineLayoutPath();
+            else
+                lineLayout->updateStyle(*this, *oldStyle);
+        }
     }
 #endif
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to