Bug 157967 - Changing border color and size simultaneously fails to repaint
Summary: Changing border color and size simultaneously fails to repaint
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tables (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: zalan
URL:
Keywords: InRadar
Depends on: 158002
Blocks:
  Show dependency treegraph
 
Reported: 2016-05-20 20:57 PDT by Philip Rogers
Modified: 2016-05-24 13:02 PDT (History)
8 users (show)

See Also:


Attachments
Dynamic table border style repaint bug (893 bytes, text/html)
2016-05-20 20:57 PDT, Philip Rogers
no flags Details
Test case (458 bytes, text/html)
2016-05-21 08:50 PDT, zalan
no flags Details
Patch (5.59 KB, patch)
2016-05-23 12:56 PDT, zalan
no flags Details | Formatted Diff | Diff
Patch (5.57 KB, patch)
2016-05-23 16:21 PDT, zalan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Rogers 2016-05-20 20:57:06 PDT
Created attachment 279536 [details]
Dynamic table border style repaint bug

We're working on a table border sizing bug in https://crbug.com/613728 where all browsers do something a little weird wrt updating table borders. I noticed a repaint bug in Safari 9.1.1/dev while investigating this.

In the attached testcase, there should be no red visible after 500ms. In Safari, red is visible after 500ms and pressing ctrl+a causes a repaint which makes the red disappear.
Comment 1 zalan 2016-05-21 08:50:43 PDT
Created attachment 279543 [details]
Test case

I assume if we fix the layout issue (so that we relayout all the boxes affected by the collapsed border change) the repaint bug will go away.
Comment 2 zalan 2016-05-21 11:13:11 PDT
Marking the affected cells dirty (including the prefWidth bit) fixes the layout issue (and it fixes the missing repaint too)
Comment 3 zalan 2016-05-21 13:04:24 PDT
I wonder how common this collapse border related style change is as now with this fix, we do a lot more work.

diff --git a/Source/WebCore/rendering/RenderTable.cpp b/Source/WebCore/rendering/RenderTable.cpp
index d8a8d6e..f6289b6 100644
--- a/Source/WebCore/rendering/RenderTable.cpp
+++ b/Source/WebCore/rendering/RenderTable.cpp
@@ -594,6 +594,14 @@ void RenderTable::layout()
     clearNeedsLayout();
 }
 
+static inline void markCellDirtyWhenCollapsedBorderChanges(RenderTableCell* cell)
+{
+    if (!cell)
+        return;
+    cell->invalidateHasEmptyCollapsedBorders();
+    cell->setNeedsLayoutAndPrefWidthsRecalc();
+}
+
 void RenderTable::invalidateCollapsedBorders(RenderTableCell* cellWithStyleChange)
 {
     m_collapsedBordersValid = false;
@@ -608,14 +616,10 @@ void RenderTable::invalidateCollapsedBorders(RenderTableCell* cellWithStyleChang
     if (cellWithStyleChange) {
         // It is enough to invalidate just the surrounding cells when cell border style changes.
         cellWithStyleChange->invalidateHasEmptyCollapsedBorders();
-        if (auto* below = cellBelow(cellWithStyleChange))
-            below->invalidateHasEmptyCollapsedBorders();
-        if (auto* above = cellAbove(cellWithStyleChange))
-            above->invalidateHasEmptyCollapsedBorders();
-        if (auto* before = cellBefore(cellWithStyleChange))
-            before->invalidateHasEmptyCollapsedBorders();
-        if (auto* after = cellAfter(cellWithStyleChange))
-            after->invalidateHasEmptyCollapsedBorders();
+        markCellDirtyWhenCollapsedBorderChanges(cellBelow(cellWithStyleChange));
+        markCellDirtyWhenCollapsedBorderChanges(cellAbove(cellWithStyleChange));
+        markCellDirtyWhenCollapsedBorderChanges(cellBefore(cellWithStyleChange));
+        markCellDirtyWhenCollapsedBorderChanges(cellAfter(cellWithStyleChange));
         return;
     }
Comment 4 zalan 2016-05-23 11:31:49 PDT
rdar://problem/26423918
Comment 5 zalan 2016-05-23 12:56:02 PDT
Created attachment 279578 [details]
Patch
Comment 6 Dave Hyatt 2016-05-23 13:38:15 PDT
Comment on attachment 279578 [details]
Patch

r=me
Comment 7 WebKit Commit Bot 2016-05-23 14:03:29 PDT
Comment on attachment 279578 [details]
Patch

Clearing flags on attachment: 279578

Committed r201296: <http://trac.webkit.org/changeset/201296>
Comment 8 WebKit Commit Bot 2016-05-23 14:03:34 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 WebKit Commit Bot 2016-05-23 15:32:28 PDT
Re-opened since this is blocked by bug 158002
Comment 10 zalan 2016-05-23 16:21:40 PDT
Created attachment 279603 [details]
Patch
Comment 11 zalan 2016-05-23 16:22:11 PDT
Added document.body.offsetWidth to force layout.
Comment 12 WebKit Commit Bot 2016-05-23 18:52:11 PDT
Comment on attachment 279603 [details]
Patch

Clearing flags on attachment: 279603

Committed r201312: <http://trac.webkit.org/changeset/201312>
Comment 13 WebKit Commit Bot 2016-05-23 18:52:17 PDT
All reviewed patches have been landed.  Closing bug.
Comment 15 zalan 2016-05-24 13:02:02 PDT
http://trac.webkit.org/changeset/201346