Bug 71500 - Correct usage of LayoutUnits and integers in Table rendering classes
Summary: Correct usage of LayoutUnits and integers in Table rendering classes
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Levi Weintraub
Depends on:
Blocks: 63567
  Show dependency treegraph
Reported: 2011-11-03 13:23 PDT by Levi Weintraub
Modified: 2011-11-03 17:57 PDT (History)
4 users (show)

See Also:

Patch (35.14 KB, patch)
2011-11-03 13:45 PDT, Levi Weintraub
no flags Details | Formatted Diff | Diff
Patch for landing (35.12 KB, patch)
2011-11-03 16:54 PDT, Levi Weintraub
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.