Bug 160723

Summary: Web Inspector: Data grid has a double left border when the first column is hidden
Product: WebKit Reporter: Nikita Vasilyev <nvasilyev>
Component: Web InspectorAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, commit-queue, joepeck, mattbaker, nvasilyev, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
See Also: https://bugs.webkit.org/show_bug.cgi?id=161015
Attachments:
Description Flags
[Image] Bug
none
Patch
timothy: review+, nvasilyev: commit-queue-
WIP
nvasilyev: review-, nvasilyev: commit-queue-
Patch
timothy: review+, timothy: commit-queue-
Patch none

Description Nikita Vasilyev 2016-08-09 17:51:07 PDT
Created attachment 285701 [details]
[Image] Bug

Steps:
1. Open Network tab.
2. Right click on the table header and click on "Domain" to hide the first column.

Actual:
The next column ("Type" by default) has a border to its left.

Expected:
The next column ("Type" by default) has no border to its left.
Comment 1 Radar WebKit Bug Importer 2016-08-09 17:51:20 PDT
<rdar://problem/27778081>
Comment 2 Nikita Vasilyev 2016-08-09 18:06:11 PDT
Created attachment 285703 [details]
Patch

cq- because I need more time to make sure it didn't break anything.
Comment 3 Timothy Hatcher 2016-08-10 10:37:57 PDT
Comment on attachment 285703 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=285703&action=review

> Source/WebInspectorUI/UserInterface/Views/DataGrid.css:93
> -    border-right: 0.5px solid var(--border-color);
> +    background-image: linear-gradient(to right, transparent calc(100% - 0.5px), var(--border-color) 0.5px);

Is there a class we can use to set the border with to 0 when the column is hidden?

We would need to be careful with using background since this could conflict with other potential styling in the future. I also worry about performance aspects of using gradients like this — that is a lot of individual gradients.
Comment 4 Nikita Vasilyev 2016-08-10 11:02:55 PDT
(In reply to comment #3)
> Comment on attachment 285703 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=285703&action=review
> 
> > Source/WebInspectorUI/UserInterface/Views/DataGrid.css:93
> > -    border-right: 0.5px solid var(--border-color);
> > +    background-image: linear-gradient(to right, transparent calc(100% - 0.5px), var(--border-color) 0.5px);
> 
> Is there a class we can use to set the border with to 0 when the column is
> hidden?

We would have to add this class to every <td> in the column.

Currently, we change the width of a <col> element. We don't modify <td>'s directly.

<table class="data">
  <colgroup>
    <col style="width: 0%;">
    ...
  </colgroup>
  <tbody>
    <tr>
      <td>...</td>
    </tr>
    ...
  </tbody>
</table>
  

> 
> We would need to be careful with using background since this could conflict
> with other potential styling in the future. I also worry about performance
> aspects of using gradients like this — that is a lot of individual gradients.

Agreed.
Comment 5 Timothy Hatcher 2016-08-10 14:54:32 PDT
Comment on attachment 285703 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=285703&action=review

>>> Source/WebInspectorUI/UserInterface/Views/DataGrid.css:93
>>> +    background-image: linear-gradient(to right, transparent calc(100% - 0.5px), var(--border-color) 0.5px);
>> 
>> Is there a class we can use to set the border with to 0 when the column is hidden?
>> 
>> We would need to be careful with using background since this could conflict with other potential styling in the future. I also worry about performance aspects of using gradients like this — that is a lot of individual gradients.
> 
> We would have to add this class to every <td> in the column.
> 
> Currently, we change the width of a <col> element. We don't modify <td>'s directly.
> 
> <table class="data">
>   <colgroup>
>     <col style="width: 0%;">
>     ...
>   </colgroup>
>   <tbody>
>     <tr>
>       <td>...</td>
>     </tr>
>     ...
>   </tbody>
> </table>

We might want to just remove the hidden table cells and columns from the DOM. We can try this fix assuming it does not have any regressions found in testing.
Comment 6 Matt Baker 2016-08-10 17:16:13 PDT
It's too bad col { visibility: collapse; } isn't supported yet.
Comment 7 Nikita Vasilyev 2016-08-10 18:29:44 PDT
Created attachment 285797 [details]
WIP

This WIP patch removes hidden columns from the DOM and adds them back when they are turned on. In general, it's good for performance to minimize number of unnecessary nodes in the DOM. However, this patch is way more complex than the previous one.
Comment 8 Nikita Vasilyev 2016-08-10 18:31:58 PDT
(In reply to comment #6)
> It's too bad col { visibility: collapse; } isn't supported yet.

Alas.

> [1] Chrome and Safari treat visibility: collapse like hidden, leaving a white gap; they support it only on <tr>, <thead>, <tbody>, and <tfoot>, but not on <col> and <colgroup> elements.

https://developer.mozilla.org/en-US/docs/Web/CSS/visibility
Comment 9 Nikita Vasilyev 2016-08-11 11:40:33 PDT
(In reply to comment #7)
> Created attachment 285797 [details]
> WIP
> 
> This WIP patch removes hidden columns from the DOM and adds them back when
> they are turned on. In general, it's good for performance to minimize number
> of unnecessary nodes in the DOM. However, this patch is way more complex
> than the previous one.

Another way of solving this bug would be by adding borders inside the resizers!

Resizers are optional, some data grids don't have them. For these cases I would still need to add them to the DOM and make them click-through.

I'm not going to go with borders inside the resizers because:
1. I'm almost done with this patch.
2. It's good for performance to minimize number of unnecessary nodes in the DOM.
Comment 10 Nikita Vasilyev 2016-08-15 14:33:50 PDT
Created attachment 286092 [details]
Patch

Another CSS hack.

Tim and I agreed that removing <td>'s from DOM is a more complicated than a pure CSS solution and it doesn't worth spending my time working on this right now.
Comment 11 Nikita Vasilyev 2016-08-16 11:58:17 PDT
Created attachment 286190 [details]
Patch

Rebaselined.
Comment 12 WebKit Commit Bot 2016-08-16 12:27:32 PDT
Comment on attachment 286190 [details]
Patch

Clearing flags on attachment: 286190

Committed r204518: <http://trac.webkit.org/changeset/204518>
Comment 13 WebKit Commit Bot 2016-08-16 12:27:37 PDT
All reviewed patches have been landed.  Closing bug.