Bug 165042 - [css-grid] Convert grid representation into a class
Summary: [css-grid] Convert grid representation into a class
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sergio Villar Senin
URL:
Keywords:
Depends on:
Blocks: 165007
  Show dependency treegraph
 
Reported: 2016-11-23 01:51 PST by Sergio Villar Senin
Modified: 2016-11-24 07:08 PST (History)
10 users (show)

See Also:


Attachments
Patch (10.82 KB, patch)
2016-11-23 01:57 PST, Sergio Villar Senin
no flags Details | Formatted Diff | Diff
Patch (10.87 KB, patch)
2016-11-23 09:04 PST, Sergio Villar Senin
rego: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sergio Villar Senin 2016-11-23 01:51:42 PST
[css-grid] Convert grid representation into a class
Comment 1 Sergio Villar Senin 2016-11-23 01:57:42 PST
Created attachment 295362 [details]
Patch
Comment 2 Javier Fernandez 2016-11-23 04:53:03 PST
Comment on attachment 295362 [details]
Patch

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

I like the change, I think it's a great code refactoring that improves code readability.

> Source/WebCore/rendering/RenderGrid.cpp:54
> +        for (size_t row = oldRowSize; row < numRows(); ++row)

Isn' t numRows() the same value than maximumRowSize ?

> Source/WebCore/rendering/RenderGrid.cpp:55
> +            m_grid[row].grow(numColumns());

Perhaps we should cache numColums() value.

> Source/WebCore/rendering/RenderGrid.cpp:58
> +    if (maximumColumnSize > numColumns()) {

If we have numColumns() cached, we can use it here as well.

> Source/WebCore/rendering/RenderGrid.cpp:59
> +        for (size_t row = 0; row < numRows(); ++row)

Ditto.

> Source/WebCore/rendering/RenderGrid.cpp:1687
> +        m_grid.insert(*child, GridArea(area.rows, area.columns));

Why not using static initializer ? 

    m_grid.insert(*child, { area.rows, area.columns });

> Source/WebCore/rendering/RenderGrid.cpp:2726
> +    return m_grid.numRows() ? m_grid.numColumns() : GridPositionsResolver::explicitGridColumnCount(style(), m_autoRepeatColumns);

I wonder whether it'd be better/clearer to define a more explicit method to figure out the grid size (eg, isEmtty(), has{Rows, Columns} )
Comment 3 Sergio Villar Senin 2016-11-23 08:41:19 PST
Comment on attachment 295362 [details]
Patch

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

>> Source/WebCore/rendering/RenderGrid.cpp:54
>> +        for (size_t row = oldRowSize; row < numRows(); ++row)
> 
> Isn' t numRows() the same value than maximumRowSize ?

Rigth. But that was already there, I just moved the code around

>> Source/WebCore/rendering/RenderGrid.cpp:1687
>> +        m_grid.insert(*child, GridArea(area.rows, area.columns));
> 
> Why not using static initializer ? 
> 
>     m_grid.insert(*child, { area.rows, area.columns });

ACK

>> Source/WebCore/rendering/RenderGrid.cpp:2726
>> +    return m_grid.numRows() ? m_grid.numColumns() : GridPositionsResolver::explicitGridColumnCount(style(), m_autoRepeatColumns);
> 
> I wonder whether it'd be better/clearer to define a more explicit method to figure out the grid size (eg, isEmtty(), has{Rows, Columns} )

It's used just here, I don't think it's really needed.
Comment 4 Sergio Villar Senin 2016-11-23 09:04:14 PST
Created attachment 295369 [details]
Patch
Comment 5 Manuel Rego Casasnovas 2016-11-24 07:01:00 PST
Comment on attachment 295369 [details]
Patch

r=me
Comment 6 Sergio Villar Senin 2016-11-24 07:08:32 PST
Committed r208973: <http://trac.webkit.org/changeset/208973>