Title: [276484] trunk
Revision
276484
Author
[email protected]
Date
2021-04-22 20:56:57 -0700 (Thu, 22 Apr 2021)

Log Message

Sometimes appHighlights are not painted when created.
https://bugs.webkit.org/show_bug.cgi?id=224904

Reviewed by Antti Koivisto.

Source/WebCore:

In order for highlights to be painted correctly, we need to not use the new line layout code,
so we need to opt out when we are repainting due to a highlight being added or removed.

Test: http/wpt/css/css-highlight-api/highlight-text-dynamic.html

* Modules/highlight/Highlight.cpp:
(WebCore::repaintRange):

LayoutTests:

* http/wpt/css/css-highlight-api/highlight-text-dynamic-expected-mismatch.html: Added.
* http/wpt/css/css-highlight-api/highlight-text-dynamic.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (276483 => 276484)


--- trunk/LayoutTests/ChangeLog	2021-04-23 03:26:18 UTC (rev 276483)
+++ trunk/LayoutTests/ChangeLog	2021-04-23 03:56:57 UTC (rev 276484)
@@ -1,3 +1,13 @@
+2021-04-22  Megan Gardner  <[email protected]>
+
+        Sometimes appHighlights are not painted when created.
+        https://bugs.webkit.org/show_bug.cgi?id=224904
+
+        Reviewed by Antti Koivisto.
+
+        * http/wpt/css/css-highlight-api/highlight-text-dynamic-expected-mismatch.html: Added.
+        * http/wpt/css/css-highlight-api/highlight-text-dynamic.html: Added.
+
 2021-04-22  Diego Pino Garcia  <[email protected]>
 
         [GTK] Unreviewed test gardening. Update test expectations.

Added: trunk/LayoutTests/http/wpt/css/css-highlight-api/highlight-text-dynamic-expected-mismatch.html (0 => 276484)


--- trunk/LayoutTests/http/wpt/css/css-highlight-api/highlight-text-dynamic-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/css/css-highlight-api/highlight-text-dynamic-expected-mismatch.html	2021-04-23 03:56:57 UTC (rev 276484)
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+    <span id="text1">One two three</span>
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/http/wpt/css/css-highlight-api/highlight-text-dynamic.html (0 => 276484)


--- trunk/LayoutTests/http/wpt/css/css-highlight-api/highlight-text-dynamic.html	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/css/css-highlight-api/highlight-text-dynamic.html	2021-04-23 03:56:57 UTC (rev 276484)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>Highlights Paint after dynamic creation.</title>
+    <link rel="help" href=""
+    <link rel="mismatch" href=""
+    <meta name="assert" content="Highlight should paint after being created after first paint.">
+        <style>
+        ::highlight(example-highlight) {
+            background-color: yellow;
+            color:green;
+        }
+    </style>
+</head>
+<body>
+    <span id="text1">One two three</span>
+
+    <script>
+        function setHighlight(timestamp) {
+            let textElement = document.getElementById('text1');
+            let highlight1 = new Highlight(new StaticRange({startContainer: textElement.childNodes[0], startOffset: 1, endContainer: textElement.childNodes[0], endOffset: 2}));
+            CSS.highlights.set("example-highlight", highlight1);
+        }
+
+        document.body.offsetLeft;
+        window.requestAnimationFrame(setHighlight);
+    </script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (276483 => 276484)


--- trunk/Source/WebCore/ChangeLog	2021-04-23 03:26:18 UTC (rev 276483)
+++ trunk/Source/WebCore/ChangeLog	2021-04-23 03:56:57 UTC (rev 276484)
@@ -1,3 +1,18 @@
+2021-04-22  Megan Gardner  <[email protected]>
+
+        Sometimes appHighlights are not painted when created.
+        https://bugs.webkit.org/show_bug.cgi?id=224904
+
+        Reviewed by Antti Koivisto.
+
+        In order for highlights to be painted correctly, we need to not use the new line layout code,
+        so we need to opt out when we are repainting due to a highlight being added or removed.
+
+        Test: http/wpt/css/css-highlight-api/highlight-text-dynamic.html
+
+        * Modules/highlight/Highlight.cpp:
+        (WebCore::repaintRange):
+
 2021-04-22  Jean-Yves Avenard  <[email protected]>
 
         Fix color gamut in WebRTC when using VPx software decoder.

Modified: trunk/Source/WebCore/Modules/highlight/Highlight.cpp (276483 => 276484)


--- trunk/Source/WebCore/Modules/highlight/Highlight.cpp	2021-04-23 03:26:18 UTC (rev 276483)
+++ trunk/Source/WebCore/Modules/highlight/Highlight.cpp	2021-04-23 03:56:57 UTC (rev 276484)
@@ -31,11 +31,16 @@
 #include "JSStaticRange.h"
 #include "NodeTraversal.h"
 #include "PropertySetCSSStyleDeclaration.h"
+#include "RenderBlockFlow.h"
 #include "RenderObject.h"
 #include "StaticRange.h"
 #include "StyleProperties.h"
 #include <wtf/Ref.h>
 
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "LayoutIntegrationLineLayout.h"
+#endif
+
 namespace WebCore {
 
 Highlight::Highlight(Ref<StaticRange>&& range)
@@ -62,8 +67,13 @@
     if (is_gt(treeOrder<ComposedTree>(range.start, range.end)))
         std::swap(sortedRange.start, sortedRange.end);
     for (auto& node : intersectingNodes(sortedRange)) {
-        if (auto renderer = node.renderer())
+        if (auto renderer = node.renderer()) {
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+            if (auto lineLayout = LayoutIntegration::LineLayout::containing(*renderer))
+                lineLayout->flow().ensureLineBoxes();
+#endif
             renderer->repaint();
+        }
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to