Bug 71500

Summary: Correct usage of LayoutUnits and integers in Table rendering classes
Product: WebKit Reporter: Levi Weintraub <leviw>
Component: Layout and RenderingAssignee: Levi Weintraub <leviw>
Severity: Normal CC: darin, eae, eric, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 63567    
Description Flags
Patch for landing none

Description Levi Weintraub 2011-11-03 13:23:10 PDT
Table layout still needs to be done with integers to preserve rules from the spec. There were also a few places missing LayoutUnits.
Comment 1 Levi Weintraub 2011-11-03 13:45:51 PDT
Created attachment 113552 [details]
Comment 2 Darin Adler 2011-11-03 15:28:32 PDT
Comment on attachment 113552 [details]

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

Are all those max<int> needed? If both arguments are already int, I would expect you could leave out the <int>.

Lets not leave things behind that show the churn from when we converted to LayoutUnit and back. We should only have things like <int> if they are actually needed.

> Source/WebCore/rendering/AutoTableLayout.cpp:255
> +        maxWidth = max<int>(maxWidth, static_cast<int>(min(maxNonPercent, numeric_limits<LayoutUnit>::max() / 2.0f)));
> +        maxWidth = max<int>(maxWidth, static_cast<int>(min(maxPercent, numeric_limits<LayoutUnit>::max() / 2.0f)));

It seems unfortunate to convert from LayoutUnit to int using static_cast. Isn’t there a better way? For example, could you just leave out the cast entirely, since the argument to max<int> is an int?

> Source/WebCore/rendering/AutoTableLayout.cpp:392
> +                    int cellLogicalWidth = max<int>(m_layoutStruct[pos].effectiveMinLogicalWidth, static_cast<int>(cellMinLogicalWidth * m_layoutStruct[pos].logicalWidth.value() / fixedWidth));

Same comment here about static_cast<int>. I think it can be omitted.

> Source/WebCore/rendering/AutoTableLayout.cpp:428
> +                    int colMaxLogicalWidth = max<int>(m_layoutStruct[pos].effectiveMaxLogicalWidth, static_cast<int>(spanMaxLogicalWidth ? cellMaxLogicalWidth * static_cast<float>(m_layoutStruct[pos].effectiveMaxLogicalWidth) / spanMaxLogicalWidth : cellMaxLogicalWidth));

And here.
Comment 3 Levi Weintraub 2011-11-03 16:54:27 PDT
Created attachment 113581 [details]
Patch for landing
Comment 4 WebKit Review Bot 2011-11-03 17:57:16 PDT
Comment on attachment 113581 [details]
Patch for landing

Clearing flags on attachment: 113581

Committed r99254: <http://trac.webkit.org/changeset/99254>
Comment 5 WebKit Review Bot 2011-11-03 17:57:21 PDT
All reviewed patches have been landed.  Closing bug.