<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>311117</bug_id>
          
          <creation_ts>2026-03-30 10:21:13 -0700</creation_ts>
          <short_desc>Potential bug in table border code caught in code review</short_desc>
          <delta_ts>2026-04-01 16:56:45 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Tables</component>
          <version>Safari 18</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://github.com/web-platform-tests/wpt/pull/58929</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sam Weinig">sam</reporter>
          <assigned_to name="Karl Dubost">karlcow</assigned_to>
          <cc>fantasai.bugs</cc>
    
    <cc>karlcow</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2195207</commentid>
    <comment_count>0</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2026-03-30 10:21:13 -0700</bug_when>
    <thetext>I was working on a separate border issue and I noticed a weirdness in RenderTable::outerBorderTop().

```
inline LayoutUnit RenderTable::outerBorderTop() const
{
    if (writingMode().isHorizontal())
        return writingMode().isBlockTopToBottom() ? outerBorderBefore() : outerBorderAfter();
    return writingMode().isInlineTopToBottom() ? outerBorderStart() : borderEnd();
}
```

Notice that it uses `borderEnd()` for the last conditional, not `outerBorderEnd()`.

All the other variants of this function only use &quot;outerBorder*()` calls. For instance, `RenderTable::outerBorderRight()`:

```
inline LayoutUnit RenderTable::outerBorderRight() const
{
    if (writingMode().isHorizontal())
        return writingMode().isInlineLeftToRight() ? outerBorderEnd() : outerBorderStart();
    return writingMode().isBlockLeftToRight() ? outerBorderAfter() : outerBorderBefore();
}
```

This looks like an accidental typo (otherwise, I would expect some kind of comment explaining the inconsistency in the pattern).

I haven&apos;t tried to figure out how to trigger this code or make a test case, but wanted to file the bug so I or someone else might take a look in the future.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2195390</commentid>
    <comment_count>1</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2026-03-30 19:24:52 -0700</bug_when>
    <thetext>This was changed in 
https://searchfox.org/wubkat/diff/72e07604aff9e355a3b669b908981bb66e8e597a/Source/WebCore/rendering/RenderTableInlines.h#96
It had the right term before. 

I didn&apos;t manage to create a test offering a visual difference. 
Plus there are other bugs getting into the way. 


table {
    writing-mode: vertical-rl;
    direction: rtl;
    border-collapse: collapse;
    border: none;
}
td {
    width: 30px;
    height: 30px;
}
/* First row: thin border (what borderEnd sees) */
.thin td {
    border: 2px solid blue;
}
/* Second row: thick border (what outerBorderEnd sees) */
.thick td {
    border: 40px solid red;
}

&lt;table&gt;
    &lt;tbody&gt;
        &lt;tr class=&quot;thin&quot;&gt;
            &lt;td&gt;&lt;/td&gt;
            &lt;td&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr class=&quot;thick&quot;&gt;
            &lt;td&gt;&lt;/td&gt;
            &lt;td&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;



The table must have `border: none`

If the table has a visible border (e.g. `border: 2px solid black`), then `outerBorderEnd()` returns early at line 1536-1537 with the table&apos;s own border value — it never reaches the section iteration loop. Both `borderEnd()` and `outerBorderEnd()` would return the same value, and the bug is invisible.

https://searchfox.org/wubkat/rev/9234d58780c9dd9eaf6c8ad43dac914866768956/Source/WebCore/rendering/RenderTable.cpp#1536-1537
```cpp
if (tb.hasVisibleStyle())
    return CollapsedBorderValue::adjustedCollapsedBorderWidth(Style::evaluate&lt;float&gt;(tb.width, Style::ZoomNeeded { }), protect(document())-&gt;deviceScaleFactor(), !writingMode().isInlineFlipped());
```

With `border: none`, `outerBorderEnd()` falls through to the loop (line 1539-1546)
that iterates all sections and finds the thick border from row 2.

https://searchfox.org/wubkat/rev/9234d58780c9dd9eaf6c8ad43dac914866768956/Source/WebCore/rendering/RenderTable.cpp#1539-1546
```cpp
bool allHidden = true;
for (RenderTableSection* section = topSection(); section; section = sectionBelow(section)) {
    LayoutUnit sw = section-&gt;outerBorderEnd();
    if (sw &lt; 0)
        continue;
    allHidden = false;
    borderWidth = std::max(borderWidth, sw);
}
```

But the bug has no really noticeable visual effect.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2195391</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2026-03-30 19:26:54 -0700</bug_when>
    <thetext>&lt;rdar://problem/173742600&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2195400</commentid>
    <comment_count>3</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2026-03-30 19:44:41 -0700</bug_when>
    <thetext>CSS 2.2 §17.6.2 
https://www.w3.org/TR/CSS22/tables.html#collapsing-borders
  - &quot;initial left and right border width&quot; from first row only
  - &quot;subsequent rows&quot; with larger borders spilling into margin
  - &quot;Any borders that spill into the margin are taken into account when determining if the table overflows some ancestor&quot;

CSS Tables Level 3:
https://drafts.csswg.org/css-tables-3/#computing-cell-measures
  - Defines &quot;table intrinsic offsets&quot; (§3.8.2) as &quot;half the winning border-width&quot; for collapsed-borders mode
  - Has an open issue about this: &quot;Handling of intrinsic offsets when in border collapsing mode&quot; (https://github.com/w3c/csswg-drafts/issues/608)
  - Does not replicate the CSS 2.2 &quot;first row&quot; vs &quot;all rows&quot; distinction or the &quot;spill into margin&quot; overflow language
  - Does not mention ink/visual/scrollable overflow for collapsed borders at all

there is an open issue (#608) specifically about collapsed border intrinsic offsets. 
https://github.com/w3c/csswg-drafts/issues/608

Now I wonder if it was intentional from Elika.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2195401</commentid>
    <comment_count>4</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2026-03-30 19:46:29 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/61737</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2196073</commentid>
    <comment_count>5</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-04-01 16:51:41 -0700</bug_when>
    <thetext>Committed 310404@main (6885c2bcb70b): &lt;https://commits.webkit.org/310404@main&gt;

Reviewed commits have been landed. Closing PR #61737 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2196077</commentid>
    <comment_count>6</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2026-04-01 16:56:45 -0700</bug_when>
    <thetext>Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/58929</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>